Sfoglia il codice sorgente

Use NUL character instead of 0

Guillem Jover 17 anni fa
parent
commit
f40457f44f

+ 2 - 2
dpkg-deb/build.c

@@ -132,7 +132,7 @@ static struct _finfo* getfi(const char* root, int fd) {
     }
     if (res==0)	// EOF -> parent died
       return NULL;
-    if (fn[i]==0)
+    if (fn[i] == '\0')
       break;
 
     i++;
@@ -323,7 +323,7 @@ void do_build(const char *const *argv) {
           while ((c= getc(cf)) != EOF && c != '\n');
           continue;
         }
-        conffilename[n-1]= 0;
+        conffilename[n - 1] = '\0';
         strcpy(controlfile, directory);
         strcat(controlfile, "/");
         strcat(controlfile, conffilename);

+ 8 - 6
dpkg-deb/extract.c

@@ -79,7 +79,7 @@ parseheaderlength(const char *inh, size_t len,
   assert(sizeof(lintbuf) > len);
   memcpy(lintbuf,inh,len);
   lintbuf[len]= ' ';
-  *strchr(lintbuf,' ')= 0;
+  *strchr(lintbuf, ' ') = '\0';
   r = strtol(lintbuf, &endp, 10);
   if (r < 0)
     ohshit(_("file `%.250s' is corrupt - negative member length %zi"), fn, r);
@@ -147,18 +147,18 @@ void extracthalf(const char *debar, const char *directory,
         infobuf= m_malloc(memberlen+1);
         if (fread(infobuf,1, memberlen + (memberlen&1), ar) != memberlen + (memberlen&1))
           readfail(ar,debar,_("header info member"));
-        infobuf[memberlen]= 0;
+        infobuf[memberlen] = '\0';
         cur= strchr(infobuf,'\n');
         if (!cur) ohshit(_("archive has no newlines in header"));
-        *cur= 0;
+        *cur = '\0';
         cur= strchr(infobuf,'.');
         if (!cur) ohshit(_("archive has no dot in version number"));
-        *cur= 0;
+        *cur = '\0';
         if (strcmp(infobuf,"2"))
           ohshit(_("archive version %.250s not understood, get newer dpkg-deb"), infobuf);
         *cur= '.';
         strncpy(versionbuf,infobuf,sizeof(versionbuf));
-        versionbuf[sizeof(versionbuf)-1]= 0;
+        versionbuf[sizeof(versionbuf) - 1] = '\0';
         header_done= 1;
       } else if (arh.ar_name[0] == '_') {
           /* Members with `_' are noncritical, and if we don't understand them
@@ -215,7 +215,9 @@ void extracthalf(const char *debar, const char *directory,
              nlc == '\n') {
     
     oldformat= 1;
-    l= strlen(versionbuf); if (l && versionbuf[l-1]=='\n') versionbuf[l-1]=0;
+    l = strlen(versionbuf);
+    if (l && versionbuf[l - 1] == '\n')
+      versionbuf[l - 1] = '\0';
     if (!fgets(ctrllenbuf,sizeof(ctrllenbuf),ar))
       readfail(ar, debar, _("control information length"));
     if (sscanf(ctrllenbuf,"%zi%c%d",&ctrllennum,&nlc,&dummy) !=2 || nlc != '\n')

+ 4 - 3
dpkg-deb/info.c

@@ -142,7 +142,8 @@ static void info_list(const char *debar, const char *directory) {
     if (S_ISREG(stab.st_mode)) {
       if (!(cc= fopen(cdep->d_name,"r")))
         ohshite(_("cannot open `%.255s' (in `%.255s')"),cdep->d_name,directory);
-      lines= 0; interpreter[0]= 0;
+      lines = 0;
+      interpreter[0] = '\0';
       if ((c= getc(cc))== '#') {
         if ((c= getc(cc))== '!') {
           while ((c= getc(cc))== ' ');
@@ -150,7 +151,7 @@ static void info_list(const char *debar, const char *directory) {
           while (il<INTERPRETER_MAX && !isspace(c) && c!=EOF) {
             *p++= c; il++; c= getc(cc);
           }
-          *p++= 0;
+          *p++ = '\0';
           if (c=='\n') lines++;
         }
       }
@@ -200,7 +201,7 @@ static void info_field(const char *debar, const char *directory,
       for (pf=fieldname, fnl=0;
            fnl <= MAXFIELDNAME && c!=EOF && !isspace(c) && c!=':';
            c= getc(cc)) { *pf++= c; fnl++; }
-      *pf++= 0;
+      *pf++ = '\0';
       doing= fnl >= MAXFIELDNAME || c=='\n' || c==EOF;
       for (fp=fields; !doing && *fp; fp++)
         if (!strcasecmp(*fp,fieldname)) doing=1;

+ 4 - 4
dpkg-split/info.c

@@ -57,7 +57,7 @@ static unsigned long parseheaderlength(const char *inh, size_t len,
   assert(sizeof(lintbuf) > len);
   memcpy(lintbuf,inh,len);
   lintbuf[len]= ' ';
-  *strchr(lintbuf,' ')= 0;
+  *strchr(lintbuf, ' ') = '\0';
   return unsignedlong(lintbuf,fn,what);
 }
 
@@ -71,7 +71,7 @@ static char *nextline(char **ripp, const char *fn, const char *what) {
     ohshit(_("file `%.250s' is corrupt - missing newline after %.250s"),fn,what);
   *ripp= newline+1;
   while (newline > rip && isspace(newline[-1])) newline--;
-  *newline= 0;
+  *newline = '\0';
   return rip;
 }
 
@@ -109,7 +109,7 @@ struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir)
     if (c != '\n')
       ohshit(_("file `%.250s' is corrupt - bad padding character (code %d)"),fn,c);
   }
-  readinfobuf[thisilen]= 0;
+  readinfobuf[thisilen] = '\0';
   if (memchr(readinfobuf,0,thisilen))
     ohshit(_("file `%.250s' is corrupt - nulls in info section"),fn);
 
@@ -136,7 +136,7 @@ struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir)
   partnums = nextline(&rip, fn, _("part numbers"));
   slash= strchr(partnums,'/');
   if (!slash) ohshit(_("file `%.250s' is corrupt - no slash between part numbers"),fn);
-  *slash++= 0;
+  *slash++ = '\0';
 
   templong = unsignedlong(slash, fn, _("number of parts"));
   if (templong <= 0 || templong > INT_MAX)

+ 2 - 1
dpkg-split/queue.c

@@ -53,7 +53,8 @@ static int decompose_filename(const char *filename, struct partqueue *pq) {
 
   if (strspn(filename,"0123456789abcdef") != 32 || filename[32] != '.') return 0;
   q= nfmalloc(33);
-  memcpy(q,filename,32); q[32]= 0;
+  memcpy(q, filename, 32);
+  q[32] = '\0';
   pq->info.md5sum= q;
   p= filename+33;
   pq->info.maxpartlen= strtol(p,&q,16); if (q==p || *q++ != '.') return 0;

+ 1 - 1
dpkg-split/split.c

@@ -56,7 +56,7 @@ void do_split(const char *const *argv) {
     strcpy(palloc,sourcefile);
     if (!strcmp(palloc+l-(sizeof(DEBEXT)-1),DEBEXT)) {
       l -= (sizeof(DEBEXT)-1);
-      palloc[l]= 0;
+      palloc[l] = '\0';
     }
     prefix= palloc;
   }

+ 1 - 1
lib/dbmodify.c

@@ -75,7 +75,7 @@ static void cleanupdates(void) {
 
   parsedb(statusfile, pdb_weakclassification, NULL,NULL,NULL);
 
-  *updatefnrest= 0;
+  *updatefnrest = '\0';
   updateslength= -1;
   cdn= scandir(updatefnbuf, &cdlist, &ulist_select, alphasort);
   if (cdn == -1) ohshite(_("cannot scan updates directory `%.255s'"),updatefnbuf);

+ 10 - 8
lib/fields.c

@@ -96,7 +96,8 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   cpos= nfstrsave(value);
   while (*cpos) {
     space= cpos; while (*space && !isspace(*space)) space++;
-    if (*space) *space++= 0;
+    if (*space)
+      *space++ = '\0';
     fdp= *fdpp;
     if (!fdp) {
       if (!allowextend)
@@ -273,7 +274,7 @@ void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp,
       parse_error(filename, lno, pigp,
                   _("value for `conffiles' has line starting with non-space `%c'"),
                   c);
-    for (endent= value; (c= *endent)!=0 && c != '\n'; endent++);
+    for (endent = value; (c = *endent) != '\0' && c != '\n'; endent++) ;
     conffvalue_lastword(value, endent, endent,
 			&hashstart, &hashlen, &endfn,
                         filename, lno, pigp);
@@ -292,10 +293,11 @@ void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp,
     newptr = nfmalloc(namelen+2);
     newptr[0]= '/';
     memcpy(newptr+1,value,namelen);
-    newptr[namelen+1]= 0;
+    newptr[namelen+1] = '\0';
     newlink->name= newptr;
     newptr= nfmalloc(hashlen+1);
-    memcpy(newptr,hashstart,hashlen); newptr[hashlen]= 0;
+    memcpy(newptr, hashstart, hashlen);
+    newptr[hashlen] = '\0';
     newlink->hash= newptr;
     newlink->obsolete= obsolete;
     newlink->next =NULL;
@@ -342,7 +344,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
         depname = m_realloc(depname, depnamelength + 1);
       }
       strncpy(depname, depnamestart, depnamelength);
-      *(depname + depnamelength)= 0;
+      *(depname + depnamelength) = '\0';
       if (!*depname)
         parse_error(filename, lno, pigp,
                     _("`%s' field, missing package name, or garbage where "
@@ -431,7 +433,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
           parse_error(filename, lno, pigp,
                       _("`%s' field, reference to `%.255s': "
                         "version contains `%c'"), fip->name,depname, ' ');
-        else if (*p == 0)
+        else if (*p == '\0')
           parse_error(filename, lno, pigp,
                       _("`%s' field, reference to `%.255s': "
                         "version unterminated"), fip->name, depname);
@@ -440,7 +442,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
           version = m_realloc(version, versionlength + 1);
 	}
 	strncpy(version,  versionstart, versionlength);
-	*(version + versionlength)= 0;
+        *(version + versionlength) = '\0';
         emsg= parseversion(&dop->version,version);
         if (emsg)
           parse_error(filename, lno, pigp,
@@ -505,7 +507,7 @@ scan_word(const char **valp)
     buf = m_realloc(buf, avail);
   }
   memcpy(buf, start, l);
-  buf[l] = 0;
+  buf[l] = '\0';
   *valp = p;
 
   return buf;

+ 1 - 1
lib/mlib.c

@@ -160,7 +160,7 @@ off_t buffer_write(buffer_data_t data, void *buf, off_t length, const char *desc
 	    sprintf((char *)hash, "%02x", *p++);
 	    hash += 2;
 	  }
-	  *hash = 0;
+	  *hash = '\0';
 	  free(ctx);
 	}
 	break;

+ 6 - 4
lib/myopt.c

@@ -64,14 +64,16 @@ void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
     const struct cmdinfo *cip;
     int l;
 
-    if ((linebuf[0]=='#') || (linebuf[0]=='\n') || (linebuf[0]==0)) continue;
+    if ((linebuf[0] == '#') || (linebuf[0] == '\n') || (linebuf[0] == '\0'))
+      continue;
     l=strlen(linebuf);
-    if (linebuf[l-1]=='\n') linebuf[l-1]=0;
+    if (linebuf[l - 1] == '\n')
+      linebuf[l - 1] = '\0';
     for (opt=linebuf;isalnum(*opt)||*opt=='-';opt++) ;
-    if (*opt==0)
+    if (*opt == '\0')
       opt=NULL;
     else {
-      *opt++=0;
+      *opt++ = '\0';
       if (*opt=='=') opt++;
       while (isspace(*opt)) opt++;
     }

+ 4 - 2
lib/parse.c

@@ -202,7 +202,9 @@ int parsedb(const char *filename, enum parsedbflags flags,
 /* trim ending space on value */
       while (valuelen && isspace(*(valuestart+valuelen-1)))
  valuelen--;
-      for (nick= nicknames; nick->nick && (strncasecmp(nick->nick,fieldstart, fieldlen) || nick->nick[fieldlen] != 0); nick++);
+      for (nick = nicknames;
+           nick->nick && (strncasecmp(nick->nick, fieldstart, fieldlen) ||
+                          nick->nick[fieldlen] != '\0'); nick++) ;
       if (nick->nick) {
 	fieldstart= nick->canon;
 	fieldlen= strlen(fieldstart);
@@ -213,7 +215,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
       if (fip->name) {
         value = m_realloc(value, valuelen + 1);
 	memcpy(value,valuestart,valuelen);
-	*(value+valuelen)= 0;
+        *(value + valuelen) = '\0';
         if (*ip++)
           parse_error(filename, lno, &newpig,
                       _("duplicate value for `%s' field"), fip->name);

+ 3 - 2
lib/parsehelp.c

@@ -140,7 +140,7 @@ const char *illegal_packagename(const char *p, const char **ep) {
   
   if (!*p) return _("may not be empty string");
   if (!isalnum(*p)) return _("must start with an alphanumeric");
-  while ((c= *p++)!=0)
+  while ((c = *p++) != '\0')
     if (!isalnum(c) && !strchr(alsoallowed,c)) break;
   if (!c) return NULL;
   if (isspace(c) && ep) {
@@ -243,7 +243,8 @@ const char *parseversion(struct versionrevision *rversion, const char *string) {
   }
   rversion->version= nfstrnsave(string,end-string);
   hyphen= strrchr(rversion->version,'-');
-  if (hyphen) *hyphen++= 0;
+  if (hyphen)
+    *hyphen++ = '\0';
   rversion->revision= hyphen ? hyphen : "";
   
   return NULL;

+ 1 - 1
lib/tarfn.c

@@ -69,7 +69,7 @@ StoC(const char *s, int size)
 	len = strnlen(s, size);
 	str = m_malloc(len + 1);
 	memcpy(str, s, len);
-	str[len] = 0;
+	str[len] = '\0';
 
 	return str;
 }

+ 4 - 4
lib/triglib.c

@@ -253,7 +253,7 @@ trig_classify_byname(const char *name)
 
 		slash = name;
 		while (slash) {
-			if (slash[1] == 0 || slash[1] == '/')
+			if (slash[1] == '\0' || slash[1] == '/')
 				goto invalid;
 
 			slash = strchr(slash + 2, '/');
@@ -535,7 +535,7 @@ trig_file_interests_ensure(void)
 		if (!space || linebuf[0] != '/')
 			ohshit(_("syntax error in file triggers file `%.250s'"),
 			       triggersfilefile);
-		*space++ = 0;
+		*space++ = '\0';
 		if ((emsg = illegal_packagename(space, NULL)))
 			ohshit(_("file triggers record mentions illegal "
 			         "package name `%.250s' (for interest in file "
@@ -662,12 +662,12 @@ trig_parse_ci(const char *file, trig_parse_cicb *interest,
 		for (eol = linebuf + l; eol > cmd && cisspace(eol[-1]); eol--);
 		if (eol == cmd)
 			continue;
-		*eol = 0;
+		*eol = '\0';
 
 		for (spc = cmd; *spc && !cisspace(*spc); spc++);
 		if (!*spc)
 			ohshit(_("triggers ci file contains unknown directive syntax"));
-		*spc++ = 0;
+		*spc++ = '\0';
 		while (cisspace(*spc))
 			spc++;
 		if (!strcmp(cmd, "interest")) {

+ 1 - 1
lib/utils.c

@@ -58,7 +58,7 @@ fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn)
 		ohshit(_("fgets gave an empty string from `%.250s'"), fn);
 	if (buf[--l] != '\n')
 		ohshit(_("too-long line or missing newline in `%.250s'"), fn);
-	buf[l] = 0;
+	buf[l] = '\0';
 
 	return l;
 }

+ 3 - 3
src/archives.c

@@ -97,7 +97,7 @@ quote_filename(char *buf, int size, char *s)
       size -= 2;
       break;
     default:
-      if (((*s) & 0x80) == 0) {
+      if (((*s) & 0x80) == '\0') {
         *buf++ = *s++;
         --size;
       } else {
@@ -1080,7 +1080,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
 void cu_cidir(int argc, void **argv) {
   char *cidir= (char*)argv[0];
   char *cidirrest= (char*)argv[1];
-  cidirrest[-1]= 0;
+  cidirrest[-1] = '\0';
   ensure_pathname_nonexisting(cidir);
 }  
 
@@ -1171,7 +1171,7 @@ void archivefiles(const char *const *argv) {
     p= findoutput.buf; i=0;
     while (*p) {
       arglist[i++]= p;
-      while ((c= *p++) != 0);
+      while ((c = *p++) != '\0') ;
     }
     arglist[i] = NULL;
     argp= arglist;

+ 1 - 1
src/configure.c

@@ -382,7 +382,7 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) {
 				if (r < linkreadbufsize-1) break;
 				need= r<<2;
 			}
-			linkreadbuf[r]= 0;
+			linkreadbuf[r] = '\0';
 			if (linkreadbuf[0] == '/') {
 				varbufreset(result);
 				varbufaddstr(result,instdir);

+ 1 - 1
src/depcon.c

@@ -300,7 +300,7 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
            * Later on, if nothing has put anything in linebuf, we know that it
            * isn't and issue a diagnostic then.
            */
-          *linebuf= 0;
+          *linebuf = '\0';
           break;
         case stat_unpacked:
         case stat_halfconfigured:

+ 1 - 1
src/filesdb.c

@@ -172,7 +172,7 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
       /* add the file to the list */
       if (ptr == thisline)
         ohshit(_("files list file for package `%.250s' contains empty filename"),pkg->name);
-      *ptr = 0;
+      *ptr = '\0';
       newent= nfmalloc(sizeof(struct fileinlist));
       newent->namenode= findnamenode(thisline, fnn_nocopy);
       newent->next = NULL;

+ 4 - 4
src/main.c

@@ -265,10 +265,10 @@ static void ignoredepends(const struct cmdinfo *cip, const char *value) {
 
   copy= m_malloc(strlen(value)+2);
   strcpy(copy,value);
-  copy[strlen(value)+1]= 0;
+  copy[strlen(value) + 1] = '\0';
   for (p=copy; *p; p++) {
     if (*p != ',') continue;
-    *p++= 0;
+    *p++ = '\0';
     if (!*p || *p==',' || p==copy+1)
       badusage(_("null package name in --ignore-depends comma-separated list `%.250s'"),
                value);
@@ -590,7 +590,7 @@ void commandfd(const char *const *argv) {
 	continue;
       } else if (isspace(*ptr)) {
 	if (mode == 1) {
-	  *ptr= 0;
+	  *ptr = '\0';
 	  mode= 0;
 	}
       } else {
@@ -602,7 +602,7 @@ void commandfd(const char *const *argv) {
       }
       ptr++;
     }
-    *ptr= 0;
+    *ptr = '\0';
     newargs[argc++] = NULL;
 
 /* We strdup each argument, but never free it, because the error messages

+ 5 - 4
src/processarc.c

@@ -181,13 +181,14 @@ void process_archive(const char *filename) {
   }
   cidirrest= cidir + strlen(cidir);
 
-  assert(*cidir && cidirrest[-1] == '/'); cidirrest[-1]= 0;
+  assert(*cidir && cidirrest[-1] == '/');
+  cidirrest[-1] = '\0';
   ensure_pathname_nonexisting(cidir); cidirrest[-1]= '/';
   
   push_cleanup(cu_cidir, ~0, NULL, 0, 2, (void *)cidir, (void *)cidirrest);
   c1= m_fork();
   if (!c1) {
-    cidirrest[-1]= 0;
+    cidirrest[-1] = '\0';
     execlp(BACKEND, BACKEND, "--control", filename, cidir, NULL);
     ohshite(_("failed to exec dpkg-deb to extract control information"));
   }
@@ -329,7 +330,7 @@ void process_archive(const char *filename) {
                conffilenamebuf, MAXCONFFILENAME);
       while (p > conffilenamebuf && isspace(p[-1])) --p;
       if (p == conffilenamebuf) continue;
-      *p= 0;
+      *p = '\0';
       namenode= findnamenode(conffilenamebuf, 0);
       namenode->oldhash= NEWCONFFILEFLAG;
       newconff= newconff_append(&newconffileslastp, namenode);
@@ -828,7 +829,7 @@ void process_archive(const char *filename) {
   }
   pop_cleanup(ehflag_normaltidy); /* closedir */
   
-  *cidirrest= 0; /* the directory itself */
+  *cidirrest = '\0'; /* the directory itself */
   dsd= opendir(cidir);
   if (!dsd) ohshite(_("unable to open temp control directory"));
   push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);

+ 1 - 1
src/query.c

@@ -79,7 +79,7 @@ list1package(struct pkginfo *pkg, int *head, struct pkg_array *array)
   const char *pdesc;
   static char format[80]   = "";
     
-  if (format[0]==0) {
+  if (format[0] == '\0') {
     w=getwidth();
     if (w == -1) {
       nw=14, vw=14, dw=44;

+ 1 - 1
src/remove.c

@@ -453,7 +453,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
         ohshite(_("cannot remove old config file `%.250s' (= `%.250s')"),
                 conff->name, fnvb.buf);
       p= strrchr(fnvb.buf,'/'); if (!p) continue;
-      *p= 0;
+      *p = '\0';
       varbufreset(&removevb);
       varbufaddstr(&removevb,fnvb.buf);
       varbufaddc(&removevb,'/');

+ 4 - 4
src/statdb.c

@@ -169,12 +169,12 @@ ensure_statoverrides(void)
 		nextline = ptr + 1;
 		if (ptr == thisline)
 			ohshit(_("statoverride file contains empty line"));
-		*ptr = 0;
+		*ptr = '\0';
 
 		/* Extract the uid. */
 		if (!(ptr = memchr(thisline, ' ', nextline - thisline)))
 			ohshit(_("syntax error in statoverride file"));
-		*ptr = 0;
+		*ptr = '\0';
 
 		fso->uid = statdb_parse_uid(thisline);
 
@@ -186,7 +186,7 @@ ensure_statoverrides(void)
 		/* Extract the gid */
 		if (!(ptr = memchr(thisline, ' ', nextline - thisline)))
 			ohshit(_("syntax error in statoverride file"));
-		*ptr = 0;
+		*ptr = '\0';
 
 		fso->gid = statdb_parse_gid(thisline);
 
@@ -198,7 +198,7 @@ ensure_statoverrides(void)
 		/* Extract the mode */
 		if (!(ptr = memchr(thisline, ' ', nextline - thisline)))
 			ohshit(_("syntax error in statoverride file"));
-		*ptr = 0;
+		*ptr = '\0';
 
 		fso->mode = statdb_parse_mode(thisline);
 

+ 1 - 1
utils/start-stop-daemon.c

@@ -677,7 +677,7 @@ parse_schedule(const char *schedule_str)
 				badusage("invalid schedule item: far too long"
 				         " (you must delimit items with slashes)");
 			memcpy(item_buf, schedule_str, str_len);
-			item_buf[str_len] = 0;
+			item_buf[str_len] = '\0';
 			schedule_str = slash ? slash + 1 : NULL;
 
 			parse_schedule_item(item_buf, &schedule[count]);