Adam Heath лет назад: 25
Родитель
Сommit
1555f1aa3c
16 измененных файлов с 138 добавлено и 134 удалено
  1. 4 0
      ChangeLog
  2. 4 4
      lib/compat.c
  3. 16 16
      lib/database.c
  4. 6 6
      lib/dbmodify.c
  5. 2 2
      lib/dump.c
  6. 8 8
      lib/ehandle.c
  7. 44 44
      lib/fields.c
  8. 2 2
      lib/lock.c
  9. 2 2
      lib/mlib.c
  10. 4 4
      lib/myopt.c
  11. 1 1
      lib/nfmalloc.c
  12. 26 26
      lib/parse.c
  13. 9 9
      lib/parsehelp.c
  14. 1 1
      lib/star.c
  15. 7 7
      lib/tarfn.c
  16. 2 2
      lib/varbuf.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+Mon Apr 23 06:27:47 CDT 2001 Adam Heath <doogie@debian.org>
+
+  * lib/*.c: Changed 0 to NULL.
+
 Mon Apr 23 06:25:36 CDT 2001 Adam Heath <doogie@debian.org>
 
   * dpkg-deb/extract.c: More %z format fixes.

+ 4 - 4
lib/compat.c

@@ -35,7 +35,7 @@
 
 #ifndef HAVE_VSNPRINTF
 int vsnprintf (char *buf, size_t maxsize, const char *fmt, va_list al) {
-  static FILE *file= 0;
+  static FILE *file= NULL;
 
   struct stat stab;
   unsigned long want, nr;
@@ -60,7 +60,7 @@ int vsnprintf (char *buf, size_t maxsize, const char *fmt, va_list al) {
   }
   nr= fread(buf,1,want-1,file);
   if (nr != want-1) ohshite(_("read error in vsnprintf truncated"));
-  buf[want]= 0;
+  buf[want]= NULL;
 
   return retval;
 }
@@ -155,7 +155,7 @@ int scandir(const char *dir, struct dirent ***namelist,
   used=0; avail=20;
   *namelist= malloc(avail*sizeof(struct dirent*));
   if (!*namelist) return -1;
-  while ((e= readdir(d)) != 0) {
+  while ((e= readdir(d)) != NULL) {
     if (!select(e)) continue;
     m= malloc(sizeof(struct dirent) + strlen(e->d_name));
     if (!m) return -1;
@@ -169,7 +169,7 @@ int scandir(const char *dir, struct dirent ***namelist,
     (*namelist)[used]= m;
     used++;
   }
-  (*namelist)[used]= 0;
+  (*namelist)[used]= NULL;
   scandir_comparfn= compar;
   qsort(*namelist, used, sizeof(struct dirent*), scandir_compar);
   return used;

+ 16 - 16
lib/database.c

@@ -108,35 +108,35 @@ static int hash(const char *name) {
 
 void blankversion(struct versionrevision *version) {
   version->epoch= 0;
-  version->version= version->revision= 0;
+  version->version= version->revision= NULL;
 }
 
 void blankpackage(struct pkginfo *pigp) {
-  pigp->name= 0;
+  pigp->name= NULL;
   pigp->status= stat_notinstalled;
   pigp->eflag= eflagv_ok;
   pigp->want= want_unknown;
   pigp->priority= pri_unknown;
-  pigp->otherpriority = 0;
-  pigp->section= 0;
+  pigp->otherpriority = NULL;
+  pigp->section= NULL;
   blankversion(&pigp->configversion);
-  pigp->files= 0;
+  pigp->files= NULL;
   pigp->installed.valid= 0;
   pigp->available.valid= 0;
-  pigp->clientdata= 0;
+  pigp->clientdata= NULL;
   blankpackageperfile(&pigp->installed);
   blankpackageperfile(&pigp->available);
 }
 
 void blankpackageperfile(struct pkginfoperfile *pifp) {
   pifp->essential= 0;
-  pifp->depends= 0;
-  pifp->depended= 0;
-  pifp->description= pifp->maintainer= pifp->source= pifp->installedsize= pifp->bugs= pifp->origin= 0;
-  pifp->architecture= 0;
+  pifp->depends= NULL;
+  pifp->depended= NULL;
+  pifp->description= pifp->maintainer= pifp->source= pifp->installedsize= pifp->bugs= pifp->origin= NULL;
+  pifp->architecture= NULL;
   blankversion(&pifp->version);
-  pifp->conffiles= 0;
-  pifp->arbs= 0;
+  pifp->conffiles= NULL;
+  pifp->arbs= NULL;
   pifp->valid= 1;
 }
 
@@ -180,7 +180,7 @@ struct pkginfo *findpackage(const char *name) {
   newpkg= nfmalloc(sizeof(struct pkginfo));
   blankpackage(newpkg);
   newpkg->name= nfstrsave(name);
-  newpkg->next= 0;
+  newpkg->next= NULL;
   *pointerp= newpkg;
   npackages++;
 
@@ -199,7 +199,7 @@ struct pkgiterator {
 struct pkgiterator *iterpkgstart(void) {
   struct pkgiterator *i;
   i= m_malloc(sizeof(struct pkgiterator));
-  i->pigp= 0;
+  i->pigp= NULL;
   i->nbinn= 0;
   return i;
 }
@@ -207,7 +207,7 @@ struct pkgiterator *iterpkgstart(void) {
 struct pkginfo *iterpkgnext(struct pkgiterator *i) {
   struct pkginfo *r;
   while (!i->pigp) {
-    if (i->nbinn >= BINS) return 0;
+    if (i->nbinn >= BINS) return NULL;
     i->pigp= bins[i->nbinn++];
   }
   r= i->pigp; i->pigp= r->next; return r;
@@ -221,7 +221,7 @@ void resetpackages(void) {
   int i;
   nffreeall();
   npackages= 0;
-  for (i=0; i<BINS; i++) bins[i]= 0;
+  for (i=0; i<BINS; i++) bins[i]= NULL;
 }
 
 void hashreport(FILE *file) {

+ 6 - 6
lib/dbmodify.c

@@ -37,10 +37,10 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
-char *statusfile=0, *availablefile=0;
+char *statusfile=NULL, *availablefile=NULL;
 
 static enum modstatdb_rw cstatus=-1, cflags=0;
-static char *importanttmpfile=0;
+static char *importanttmpfile=NULL;
 static FILE *importanttmp;
 static int nextupdate;
 static int updateslength;
@@ -67,7 +67,7 @@ static void cleanupdates(void) {
   struct dirent **cdlist;
   int cdn, i;
 
-  parsedb(statusfile, pdb_weakclassification, 0,0,0);
+  parsedb(statusfile, pdb_weakclassification, NULL,NULL,NULL);
 
   *updatefnrest= 0;
   updateslength= -1;
@@ -78,7 +78,7 @@ static void cleanupdates(void) {
     
     for (i=0; i<cdn; i++) {
       strcpy(updatefnrest, cdlist[i]->d_name);
-      parsedb(updatefnbuf, pdb_weakclassification, 0,0,0);
+      parsedb(updatefnbuf, pdb_weakclassification, NULL,NULL,NULL);
       if (cstatus < msdbrw_write) free(cdlist[i]);
     }
 
@@ -122,7 +122,7 @@ enum modstatdb_rw modstatdb_init(const char *adir, enum modstatdb_rw readwritere
     {   STATUSFILE,                 &statusfile         },
     {   AVAILFILE,                  &availablefile      },
     {   UPDATESDIR IMPORTANTTMP,    &importanttmpfile   },
-    {   0, 0                                            }
+    {   NULL, NULL                                      }
   }, *fnip;
   
   admindir= adir;
@@ -172,7 +172,7 @@ enum modstatdb_rw modstatdb_init(const char *adir, enum modstatdb_rw readwritere
     if(!(cflags & msdbrw_noavail))
     parsedb(availablefile,
             pdb_recordavailable|pdb_rejectstatus,
-            0,0,0);
+            NULL,NULL,NULL);
   }
 
   if (cstatus >= msdbrw_write) {

+ 2 - 2
lib/dump.c

@@ -82,7 +82,7 @@ void w_section(struct varbuf *vb,
 void w_charfield(struct varbuf *vb,
                  const struct pkginfo *pigp, const struct pkginfoperfile *pifp,
                  const struct fieldinfo *fip) {
-  const char *value= pifp->valid ? PKGPFIELD(pifp,fip->integer,const char*) : 0;
+  const char *value= pifp->valid ? PKGPFIELD(pifp,fip->integer,const char*) : NULL;
   if (!value || !*value) return;
   varbufaddstr(vb,fip->name); varbufaddstr(vb, ": "); varbufaddstr(vb,value);
   varbufaddc(vb,'\n');
@@ -253,7 +253,7 @@ void writedb(const char *filename, int available, int mustsync) {
     ohshite(_("unable to set buffering on status file"));
 
   it= iterpkgstart();
-  while ((pigp= iterpkgnext(it)) != 0) {
+  while ((pigp= iterpkgnext(it)) != NULL) {
     pifp= available ? &pigp->available : &pigp->installed;
     /* Don't dump records which have no useful content. */
     if (!informative(pigp,pifp)) continue;

+ 8 - 8
lib/ehandle.c

@@ -60,7 +60,7 @@ struct errorcontext {
   const char *contextstring;
 };
 
-static struct errorcontext *volatile econtext= 0;
+static struct errorcontext *volatile econtext= NULL;
 static struct { struct cleanupentry ce; void *args[20]; } emergency;
 
 void set_error_display(void (*printerror)(const char *, const char *),
@@ -85,7 +85,7 @@ void push_error_handler(jmp_buf *jbufp,
   }
   necp->next= econtext;
   necp->jbufp= jbufp;
-  necp->cleanups= 0;
+  necp->cleanups= NULL;
   necp->printerror= printerror;
   necp->contextstring= contextstring;
   econtext= necp;
@@ -122,10 +122,10 @@ static void run_cleanups(struct errorcontext *econ, int flagsetin) {
           run_cleanups(&recurserr, ehflag_bombout | ehflag_recursiveerror);
         } else {
           recurserr.jbufp= &recurejbuf;
-          recurserr.cleanups= 0;
-          recurserr.next= 0;
+          recurserr.cleanups= NULL;
+          recurserr.next= NULL;
           recurserr.printerror= print_error_cleanup;
-          recurserr.contextstring= 0;
+          recurserr.contextstring= NULL;
           econtext= &recurserr;
           cep->calls[i].call(cep->argc,cep->argv);
         }
@@ -161,9 +161,9 @@ void push_checkpoint(int mask, int value) {
   int i;
   
   cep= m_malloc(sizeof(struct cleanupentry) + sizeof(char*));
-  for (i=0; i<NCALLS; i++) { cep->calls[i].call=0; cep->calls[i].mask=0; }
+  for (i=0; i<NCALLS; i++) { cep->calls[i].call=NULL; cep->calls[i].mask=0; }
   cep->cpmask= mask; cep->cpvalue= value;
-  cep->argc= 0; cep->argv[0]= 0;
+  cep->argc= 0; cep->argv[0]= NULL;
   cep->next= econtext->cleanups;
   econtext->cleanups= cep;
 }
@@ -189,7 +189,7 @@ void push_cleanup(void (*call1)(int argc, void **argv), int mask1,
   cep->cpmask=~0; cep->cpvalue=0; cep->argc= nargs;
   va_start(al,nargs);
   args= cep->argv; while (nargs-- >0) *args++= va_arg(al,void*);
-  *args++= 0;
+  *args++= NULL;
   va_end(al);
   cep->next= econtext->cleanups;
   econtext->cleanups= cep;

+ 44 - 44
lib/fields.c

@@ -36,11 +36,11 @@ static int convert_string
 {
   const char *ep;
   int c, l = 0;
-  struct namevalue *nvip= 0;
+  struct namevalue *nvip= NULL;
   memcpy(&nvip,&ivip,sizeof(struct namevalue *));
 
   ep= startp;
-  if (!*ep) parseerr(0,filename,lno, warnto,warncount,pigp,0, _("%s is missing"),what);
+  if (!*ep) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("%s is missing"),what);
   while (nvip->name) {
     if ((l= nvip->length) == 0) {
       l= strlen(nvip->name);
@@ -53,14 +53,14 @@ static int convert_string
   }
   if (!nvip->name) {
     if (otherwise != -1) return otherwise;
-    parseerr(0,filename,lno, warnto,warncount,pigp,0, _("`%.*s' is not allowed for %s"),
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%.*s' is not allowed for %s"),
              l > 50 ? 50 : l, startp, what);
   }
   ep = startp + l;
   c = *ep;
   while (isspace(c)) c= *++ep;
   if (c && !endpp)
-    parseerr(0,filename,lno, warnto,warncount,pigp,0, _("junk after %s"),what);
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("junk after %s"),what);
   if (endpp) *endpp= ep;
   return nvip->value;
 }
@@ -69,8 +69,8 @@ void f_name(struct pkginfo *pigp, struct pkginfoperfile *pifp, enum parsedbflags
             const char *filename, int lno, FILE *warnto, int *warncount,
             const char *value, const struct fieldinfo *fip) {
   const char *e;
-  if ((e= illegal_packagename(value,0)) != 0)
-    parseerr(0,filename,lno, warnto,warncount,pigp,0, _("invalid package name (%.250s)"),e);
+  if ((e= illegal_packagename(value,NULL)) != NULL)
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("invalid package name (%.250s)"),e);
   pigp->name= nfstrsave(value);
   findpackage(value); /* We discard the value from findpackage, but calling it
                        * forces an entry in the hash table to be made if it isn't
@@ -88,10 +88,10 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   int allowextend;
 
   if (!*value)
-    parseerr(0,filename,lno, warnto,warncount,pigp,0,
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
              _("empty file details field `%s'"),fip->name);
   if (!(flags & pdb_recordavailable))
-    parseerr(0,filename,lno, warnto,warncount,pigp,0,
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
              _("file details field `%s' not allowed in status file"),fip->name);
   allowextend= !pigp->files;
   fdpp= &pigp->files;
@@ -102,11 +102,11 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp,
     fdp= *fdpp;
     if (!fdp) {
       if (!allowextend)
-        parseerr(0,filename,lno, warnto,warncount,pigp,0, _("too many values "
+        parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("too many values "
                  "in file details field `%s' (compared to others)"),fip->name);
       fdp= nfmalloc(sizeof(struct filedetails));
-      fdp->next= 0;
-      fdp->name= fdp->msdosname= fdp->size= fdp->md5sum= 0;
+      fdp->next= NULL;
+      fdp->name= fdp->msdosname= fdp->size= fdp->md5sum= NULL;
       *fdpp= fdp;
     }
     FILEFFIELD(fdp,fip->integer,const char*)= cpos;
@@ -115,7 +115,7 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp,
     cpos= space;
   }
   if (*fdpp)
-    parseerr(0,filename,lno, warnto,warncount,pigp,0, _("too few values "
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("too few values "
              "in file details field `%s' (compared to others)"),fip->name);
 }
 
@@ -133,7 +133,7 @@ void f_boolean(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   pifp->essential=
     *value ? convert_string(filename,lno,_("yes/no in `essential' field"), -1,
                             warnto,warncount,pigp,
-                            value,booleaninfos,0)
+                            value,booleaninfos,NULL)
            : 0;
 }
 
@@ -152,7 +152,7 @@ void f_priority(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   if (!*value) return;
   pigp->priority= convert_string(filename,lno,"word in `priority' field", pri_other,
                              warnto,warncount,pigp,
-                             value,priorityinfos,0);
+                             value,priorityinfos,NULL);
   if (pigp->priority == pri_other) pigp->otherpriority= nfstrsave(value);
 }
 
@@ -163,7 +163,7 @@ void f_status(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   const char *ep;
 
   if (flags & pdb_rejectstatus)
-    parseerr(0,filename,lno, warnto,warncount,pigp,0,
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
              _("value for `status' field not allowed in this context"));
   if (flags & pdb_recordavailable) return;
   
@@ -176,7 +176,7 @@ void f_status(struct pkginfo *pigp, struct pkginfoperfile *pifp,
     pigp->eflag &= ~eflagf_obsoletehold;
   }
   pigp->status= convert_string(filename,lno,_("third (status) word in `status' field"), -1,
-                               warnto,warncount,pigp, ep,statusinfos,0);
+                               warnto,warncount,pigp, ep,statusinfos,NULL);
 }
 
 void f_version(struct pkginfo *pigp, struct pkginfoperfile *pifp,
@@ -186,7 +186,7 @@ void f_version(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   const char *emsg;
   
   emsg= parseversion(&pifp->version,value);
-  if (emsg) parseerr(0,filename,lno, warnto,warncount,pigp,0, _("error "
+  if (emsg) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("error "
                      "in Version string `%.250s': %.250s"),value,emsg);
 }  
 
@@ -196,7 +196,7 @@ void f_revision(struct pkginfo *pigp, struct pkginfoperfile *pifp,
                 const char *value, const struct fieldinfo *fip) {
   char *newversion;
 
-  parseerr(0,filename,lno, warnto,warncount,pigp,1,
+  parseerr(NULL,filename,lno, warnto,warncount,pigp,1,
            _("obsolete `Revision' or `Package-Revision' field used"));
   if (!*value) return;
   if (pifp->version.revision && *pifp->version.revision) {
@@ -214,12 +214,12 @@ void f_configversion(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   const char *emsg;
   
   if (flags & pdb_rejectstatus)
-    parseerr(0,filename,lno, warnto,warncount,pigp,0,
+    parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
              _("value for `config-version' field not allowed in this context"));
   if (flags & pdb_recordavailable) return;
 
   emsg= parseversion(&pigp->configversion,value);
-  if (emsg) parseerr(0,filename,lno, warnto,warncount,pigp,0, _("error "
+  if (emsg) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("error "
                      "in Config-Version string `%.250s': %.250s"),value,emsg);
 }
 
@@ -236,18 +236,18 @@ void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   while (*value) {
     c= *value++;
     if (c == '\n') continue;
-    if (c != ' ') parseerr(0,filename,lno, warnto,warncount,pigp,0, _("value for"
+    if (c != ' ') parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("value for"
                            " `conffiles' has line starting with non-space `%c'"), c);
     for (endent= value; (c= *endent)!=0 && c != '\n'; endent++);
     for (endfn= endent; *endfn != ' '; endfn--);
     if (endfn <= value+1 || endfn >= endent-1)
-      parseerr(0,filename,lno, warnto,warncount,pigp,0,
+      parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                _("value for `conffiles' has malformatted line `%.*s'"),
                (int)(endent-value > 250 ? 250 : endent-value), value);
     newlink= nfmalloc(sizeof(struct conffile));
     value= skip_slash_dotslash(value);
     namelen= (int)(endfn-value);
-    if (namelen <= 0) parseerr(0,filename,lno, warnto,warncount,pigp,0,
+    if (namelen <= 0) parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                                _("root or null directory is listed as a conffile"));
     newptr = nfmalloc(namelen+2);
     newptr[0]= '/';
@@ -257,7 +257,7 @@ void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp,
     hashlen= (int)(endent-endfn)-1; newptr= nfmalloc(hashlen+1);
     memcpy(newptr,endfn+1,hashlen); newptr[hashlen]= 0;
     newlink->hash= newptr;
-    newlink->next =0;
+    newlink->next =NULL;
     *lastp= newlink;
     lastp= &newlink->next;
     value= endent;
@@ -283,11 +283,11 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   ldypp= &pifp->depends; while (*ldypp) ldypp= &(*ldypp)->next;
   for (;;) { /* loop creating new struct dependency's */
     dyp= nfmalloc(sizeof(struct dependency));
-    dyp->up= 0; /* Set this to zero for now, as we don't know what our real
+    dyp->up= NULL; /* Set this to zero for now, as we don't know what our real
                  * struct pkginfo address (in the database) is going to be yet.
                  */
-    dyp->next= 0; *ldypp= dyp; ldypp= &dyp->next;
-    dyp->list= 0; ldopp= &dyp->list;
+    dyp->next= NULL; *ldypp= dyp; ldypp= &dyp->next;
+    dyp->list= NULL; ldopp= &dyp->list;
     dyp->type= fip->integer;
     for (;;) { /* loop creating new struct deppossi's */
       depnamestart= p;
@@ -303,18 +303,18 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
       strncpy(depname, depnamestart, depnamelength);
       *(depname + depnamelength)= 0;
       if (!*depname)
-        parseerr(0,filename,lno, warnto,warncount,pigp,0, _("`%s' field, missing"
+        parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%s' field, missing"
                  " package name, or garbage where package name expected"), fip->name);
-      emsg= illegal_packagename(depname,0);
-      if (emsg) parseerr(0,filename,lno, warnto,warncount,pigp,0, _("`%s' field,"
+      emsg= illegal_packagename(depname,NULL);
+      if (emsg) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%s' field,"
                          " invalid package name `%.255s': %s"),
                          fip->name,depname,emsg);
       dop= nfmalloc(sizeof(struct deppossi));
       dop->up= dyp;
       dop->ed= findpackage(depname);
-      dop->next= 0; *ldopp= dop; ldopp= &dop->next;
-      dop->nextrev= 0; /* Don't link this (which is after all only `newpig' from */
-      dop->backrev= 0; /* the main parsing loop in parsedb) into the depended on
+      dop->next= NULL; *ldopp= dop; ldopp= &dop->next;
+      dop->nextrev= NULL; /* Don't link this (which is after all only `newpig' from */
+      dop->backrev= NULL; /* the main parsing loop in parsedb) into the depended on
                         * packages' lists yet.  This will be done later when we
                         * install this (in parse.c).  For the moment we do the
                         * `forward' links in deppossi (`ed') only, and the backward
@@ -336,13 +336,13 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
             dop->verrel |= (dvrf_strict | dvrf_builtup);
             p++;
           } else if (c2 == '<' || c2 == '>') {
-            parseerr(0,filename,lno, warnto,warncount,pigp,0,
+            parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                     _("`%s' field, reference to `%.255s':\n"
                     " bad version relationship %c%c"),
                     fip->name,depname,c1,c2);
             dop->verrel= dvr_none;
           } else {
-            parseerr(0,filename,lno, warnto,warncount,pigp,1,
+            parseerr(NULL,filename,lno, warnto,warncount,pigp,1,
                      _("`%s' field, reference to `%.255s':\n"
                      " `%c' is obsolete, use `%c=' or `%c%c' instead"),
                      fip->name,depname,c1,c1,c1,c1);
@@ -352,18 +352,18 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
           dop->verrel= dvr_exact;
           p++;
         } else {
-          parseerr(0,filename,lno, warnto,warncount,pigp,1,
+          parseerr(NULL,filename,lno, warnto,warncount,pigp,1,
                    _("`%s' field, reference to `%.255s':\n"
                    " implicit exact match on version number, suggest using `=' instead"),
                    fip->name,depname);
           dop->verrel= dvr_exact;
         }
 	if ((dop->verrel!=dvr_exact) && (fip->integer==dep_provides))
-	  parseerr(0,filename,lno,warnto,warncount,pigp,1,
+	  parseerr(NULL,filename,lno,warnto,warncount,pigp,1,
 		  _("Only exact versions may be used for Provides"));
 
         if (!isspace(*p) && !isalnum(*p)) {
-          parseerr(0,filename,lno, warnto,warncount,pigp,1,
+          parseerr(NULL,filename,lno, warnto,warncount,pigp,1,
                    _("`%s' field, reference to `%.255s':\n"
                    " version value starts with non-alphanumeric, suggest adding a space"),
                    fip->name,depname);
@@ -377,13 +377,13 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
           p++;
         }
         while (isspace(*p)) p++;
-        if (*p == '(') parseerr(0,filename,lno, warnto,warncount,pigp,0,
+        if (*p == '(') parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                                 _("`%s' field, reference to `%.255s': "
                                 "version contains `('"),fip->name,depname);
-	else if (*p != ')') parseerr(0,filename,lno, warnto,warncount,pigp,0,
+	else if (*p != ')') parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                                 _("`%s' field, reference to `%.255s': "
                                 "version contains ` '"),fip->name,depname);
-        else if (*p == 0) parseerr(0,filename,lno, warnto,warncount,pigp,0,
+        else if (*p == 0) parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                                    _("`%s' field, reference to `%.255s': "
                                    "version unterminated"),fip->name,depname);
 	versionlength= p - versionstart;
@@ -394,7 +394,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
 	strncpy(version,  versionstart, versionlength);
 	*(version + versionlength)= 0;
         emsg= parseversion(&dop->version,version);
-        if (emsg) parseerr(0,filename,lno, warnto,warncount,pigp,0,
+        if (emsg) parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                            _("`%s' field, reference to `%.255s': "
                            "error in version: %.255s"),fip->name,depname,emsg);
         p++; while (isspace(*p)) p++;
@@ -404,13 +404,13 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
       }
       if (!*p || *p == ',') break;
       if (*p != '|')
-        parseerr(0,filename,lno, warnto,warncount,pigp,0, _("`%s' field, syntax"
+        parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%s' field, syntax"
                  " error after reference to package `%.255s'"),
                  fip->name, dop->ed->name);
       if (fip->integer == dep_conflicts ||
           fip->integer == dep_provides ||
           fip->integer == dep_replaces)
-        parseerr(0,filename,lno, warnto,warncount,pigp,0,
+        parseerr(NULL,filename,lno, warnto,warncount,pigp,0,
                  _("alternatives (`|') not allowed in %s field"),
                  fip->name);
       p++; while (isspace(*p)) p++;

+ 2 - 2
lib/lock.c

@@ -32,7 +32,7 @@
 #include <dpkg.h>
 #include <dpkg-db.h>
 
-static char *dblockfile= 0;
+static char *dblockfile= NULL;
 static int dblockfd= -1;
 
 static void cu_unlockdb(int argc, void **argv) {
@@ -80,5 +80,5 @@ void lockdatabase(const char *admindir) {
   }
   n= fcntl(dblockfd, F_GETFD);
   if (n >= 0) fcntl(dblockfd, F_SETFD, n | FD_CLOEXEC);
-  push_cleanup(cu_unlockdb,~0, 0,0, 0);
+  push_cleanup(cu_unlockdb,~0, NULL,0, 0);
 }

+ 2 - 2
lib/mlib.c

@@ -82,8 +82,8 @@ int m_fork(void) {
   r= fork();
   if (r == -1) { onerr_abort++; ohshite(_("fork failed")); }
   if (r > 0) return r;
-  push_cleanup(cu_m_fork,~0, 0,0, 0);
-  set_error_display(print_error_forked,0);
+  push_cleanup(cu_m_fork,~0, NULL,0, 0);
+  set_error_display(print_error_forked,NULL);
   return r;
 }
 

+ 4 - 4
lib/myopt.c

@@ -76,7 +76,7 @@ void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
       else *cip->sassignto= opt;
     } else {
       if (opt) ohshite(_("configuration error: %s does not take a value"), linebuf);
-      if (cip->call) cip->call(cip,0);
+      if (cip->call) cip->call(cip,NULL);
       else *cip->iassignto= cip->arg;
     }
   }
@@ -94,7 +94,7 @@ void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos) {
     ++(*argvp);
     if (!strcmp(p,"--")) break;
     if (*++p == '-') {
-      ++p; value=0;
+      ++p; value=NULL;
       for (cip= cmdinfos;
            cip->olong || cip->oshort;
            cip++) {
@@ -114,7 +114,7 @@ void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos) {
         else *cip->sassignto= value;
       } else {
         if (value) badusage(_("--%s option does not take a value"),cip->olong);
-        if (cip->call) cip->call(cip,0);
+        if (cip->call) cip->call(cip,NULL);
         else *cip->iassignto= cip->arg;
       }
     } else {
@@ -134,7 +134,7 @@ void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos) {
           else *cip->sassignto= value;
         } else {
           if (*p == '=') badusage(_("-%c option does not take a value"),cip->oshort);
-          if (cip->call) cip->call(cip,0);
+          if (cip->call) cip->call(cip,NULL);
           else *cip->iassignto= cip->arg;
         }
       }

+ 1 - 1
lib/nfmalloc.c

@@ -62,6 +62,6 @@ char *nfstrnsave(const char *string, int l) {
 }
 
 void nffreeall(void) {
-  obstack_free(&db_obs, 0);
+  obstack_free(&db_obs, NULL);
   dbobs_init = 0;
 }

+ 26 - 26
lib/parse.c

@@ -70,7 +70,7 @@ const struct fieldinfo fieldinfos[]= {
   { "MSDOS-Filename",   f_filecharf,       w_filecharf,      FILEFOFF(msdosname)      },
   { "Description",      f_charfield,       w_charfield,      PKGIFPOFF(description)   },
   /* Note that aliases are added to the nicknames table in parsehelp.c. */
-  {  0   /* sentinel - tells code that list is ended */                               }
+  {  NULL   /* sentinel - tells code that list is ended */                               }
 };
 #define NFIELDS (sizeof(fieldinfos)/sizeof(struct fieldinfo))
 const int nfields= NFIELDS;
@@ -104,7 +104,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
   fd= open(filename, O_RDONLY);
   if (fd == -1) ohshite(_("failed to open package info file `%.255s' for reading"),filename);
 
-  push_cleanup(cu_parsedb,~0, 0,0, 1,&fd);
+  push_cleanup(cu_parsedb,~0, NULL,0, 1,&fd);
 
   if (fstat(fd, &stat) == -1)
     ohshite(_("can't stat package info file `%.255s'"),filename);
@@ -144,16 +144,16 @@ int parsedb(const char *filename, enum parsedbflags flags,
       fieldlen= dataptr - fieldstart - 1;
       while (EOF_mmap(dataptr, endptr) && c != '\n' && isspace(c)) c= getc_mmap(dataptr);
       if (EOF_mmap(dataptr, endptr))
-        parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+        parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                  _("EOF after field name `%.*s'"),fieldlen,fieldstart);
       if (c == '\n')
-        parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+        parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                  _("newline in field name `%.*s'"),fieldlen,fieldstart);
       if (c == MSDOS_EOF_CHAR)
-        parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+        parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                  _("MSDOS EOF (^Z) in field name `%.*s'"),fieldlen,fieldstart);
       if (c != ':')
-        parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+        parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                  _("field name `%.*s' must be followed by colon"),fieldlen,fieldstart);
 /* Skip space after ':' but before value and eol */
       for (;;) {
@@ -161,11 +161,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
         if (EOF_mmap(dataptr, endptr) || c == '\n' || !isspace(c)) break;
       }
       if (EOF_mmap(dataptr, endptr))
-        parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+        parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                  _("EOF before value of field `%.*s' (missing final newline)"),
                  fieldlen,fieldstart);
       if (c == MSDOS_EOF_CHAR)
-        parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+        parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                  _("MSDOS EOF char in value of field `%.*s' (missing newline?)"),
                  fieldlen,fieldstart);
       valuestart= dataptr - 1;
@@ -179,7 +179,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
           ungetc_mmap(c,dataptr, data);
           c= '\n';
         } else if (EOF_mmap(dataptr, endptr)) {
-          parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+          parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                    _("EOF during value of field `%.*s' (missing final newline)"),
                    fieldlen,fieldstart);
         }
@@ -202,47 +202,47 @@ int parsedb(const char *filename, enum parsedbflags flags,
 	strncpy(value,valuestart,valuelen);
 	*(value+valuelen)= 0;
         if (*ip++)
-          parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+          parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                    _("duplicate value for `%s' field"), fip->name);
         fip->rcall(&newpig,newpifp,flags,filename,lno-1,warnto,warncount,value,fip);
       } else {
         if (fieldlen<2)
-          parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+          parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                    _("user-defined field name `%.*s' too short"), fieldlen,fieldstart);
         larpp= &newpifp->arbs;
-        while ((arp= *larpp) != 0) {
+        while ((arp= *larpp) != NULL) {
           if (!strncasecmp(arp->name,fieldstart,fieldlen))
-            parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+            parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                      _("duplicate value for user-defined field `%.*s'"), fieldlen,fieldstart);
           larpp= &arp->next;
         }
         arp= nfmalloc(sizeof(struct arbitraryfield));
         arp->name= nfstrnsave(fieldstart,fieldlen);
         arp->value= nfstrnsave(valuestart,valuelen);
-        arp->next= 0;
+        arp->next= NULL;
         *larpp= arp;
       }
       if (EOF_mmap(dataptr, endptr) || c == '\n' || c == MSDOS_EOF_CHAR) break;
     } /* loop per field */
     if (pdone && donep)
-      parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+      parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                _("several package info entries found, only one allowed"));
-    parsemustfield(0,filename,lno, warnto,warncount,&newpig,0,
+    parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,0,
                    &newpig.name, "package name");
     if ((flags & pdb_recordavailable) || newpig.status != stat_notinstalled) {
-      parsemustfield(0,filename,lno, warnto,warncount,&newpig,1,
+      parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,1,
                      (const char **)&newpifp->description, "description");
-      parsemustfield(0,filename,lno, warnto,warncount,&newpig,1,
+      parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,1,
                      (const char **)&newpifp->maintainer, "maintainer");
       if (newpig.status != stat_halfinstalled)
-        parsemustfield(0,filename,lno, warnto,warncount,&newpig,0,
+        parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,0,
                        &newpifp->version.version, "version");
     }
     if (flags & pdb_recordavailable)
-      parsemustfield(0,filename,lno, warnto,warncount,&newpig,1,
+      parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,1,
                      (const char **)&newpifp->architecture, "architecture");
     else if (newpifp->architecture && *newpifp->architecture)
-      newpifp->architecture= 0;
+      newpifp->architecture= NULL;
 
     /* Check the Config-Version information:
      * If there is a Config-Version it is definitely to be used, but
@@ -253,7 +253,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
     if (!(flags & pdb_recordavailable)) {
       if (newpig.configversion.version) {
         if (newpig.status == stat_installed || newpig.status == stat_notinstalled)
-          parseerr(0,filename,lno, warnto,warncount,&newpig,0,
+          parseerr(NULL,filename,lno, warnto,warncount,&newpig,0,
                    _("Configured-Version for package with inappropriate Status"));
       } else {
         if (newpig.status == stat_installed) newpig.configversion= newpifp->version;
@@ -267,9 +267,9 @@ int parsedb(const char *filename, enum parsedbflags flags,
     if (!(flags & pdb_recordavailable) &&
         newpig.status == stat_notinstalled &&
         newpifp->conffiles) {
-      parseerr(0,filename,lno, warnto,warncount,&newpig,1,
+      parseerr(NULL,filename,lno, warnto,warncount,&newpig,1,
                _("Package which in state not-installed has conffiles, forgetting them"));
-      newpifp->conffiles= 0;
+      newpifp->conffiles= NULL;
     }
 
     pigp= findpackage(newpig.name);
@@ -306,7 +306,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
       pigp->eflag= newpig.eflag;
       pigp->status= newpig.status;
       pigp->configversion= newpig.configversion;
-      pigp->files= 0;
+      pigp->files= NULL;
     } else if (!(flags & pdb_ignorefiles)) {
       pigp->files= newpig.files;
     }
@@ -388,7 +388,7 @@ void copy_dependency_links(struct pkginfo *pkg,
       addtopifp= available ? &dop->ed->available : &dop->ed->installed;
       if (!addtopifp->valid) blankpackageperfile(addtopifp);
       dop->nextrev= addtopifp->depended;
-      dop->backrev= 0;
+      dop->backrev= NULL;
       if (addtopifp->depended)
         addtopifp->depended->backrev= dop;
       addtopifp->depended= dop;

+ 9 - 9
lib/parsehelp.c

@@ -58,7 +58,7 @@ void parseerr
 const struct namevalue booleaninfos[]= {  /* Note !  These must be in order ! */
   { "no",                             0,                 2 },
   { "yes",                            1,                 3 },
-  {  0                                                   }
+  {  NULL                                                  }
 };
 
 const struct namevalue priorityinfos[]= {  /* Note !  These must be in order ! */
@@ -72,7 +72,7 @@ const struct namevalue priorityinfos[]= {  /* Note !  These must be in order ! *
   { "this is a bug - please report",  pri_other,        28 },
   { "unknown",                        pri_unknown,      7 },
   { "base",                           pri_required,     4 }, /* fixme: alias, remove */
-  {  0                                                 }
+  {  NULL                                                 }
 };
 
 const struct namevalue statusinfos[]= {  /* Note !  These must be in order ! */
@@ -85,7 +85,7 @@ const struct namevalue statusinfos[]= {  /* Note !  These must be in order ! */
   /* These are additional entries for reading only, in any order ... */
   { "postinst-failed", stat_halfconfigured,  15 }, /* fixme: backwards compat., remove */
   { "removal-failed",  stat_halfinstalled,   14 }, /* fixme: backwards compat., remove */
-  {  0                                      }
+  {  NULL                                       }
 };
 
 const struct namevalue eflaginfos[]= {  /* Note !  These must be in order ! */
@@ -93,7 +93,7 @@ const struct namevalue eflaginfos[]= {  /* Note !  These must be in order ! */
   { "reinstreq",               eflagv_reinstreq,         9 },
   { "hold",                    eflagv_obsoletehold,      4 },
   { "hold-reinstreq",          eflagv_obsoleteboth,      14 },
-  {  0                                                   }
+  {  NULL                                                   }
 };
 
 const struct namevalue wantinfos[]= {  /* Note !  These must be in order ! */
@@ -102,7 +102,7 @@ const struct namevalue wantinfos[]= {  /* Note !  These must be in order ! */
   { "hold",      want_hold,       4 },
   { "deinstall", want_deinstall,  9 },
   { "purge",     want_purge,      5 },
-  {  0                           }
+  {  NULL                           }
 };
 
 const char *illegal_packagename(const char *p, const char **ep) {
@@ -115,10 +115,10 @@ const char *illegal_packagename(const char *p, const char **ep) {
   if (!*++p) return _("must be at least two characters");
   while ((c= *p++)!=0)
     if (!isalnum(c) && !strchr(alsoallowed,c)) break;
-  if (!c) return 0;
+  if (!c) return NULL;
   if (isspace(c) && ep) {
     while (isspace(*p)) p++;
-    *ep= p; return 0;
+    *ep= p; return NULL;
   }
   snprintf(buf, sizeof(buf),
           _("character `%c' not allowed - only letters, digits and %s allowed"),
@@ -133,7 +133,7 @@ const struct nickname nicknames[]= {
   { "Class",             "Priority"    },
   { "Package-Revision",  "Revision"    },
   { "Package_Revision",  "Revision"    },
-  {  0                                 }
+  {  NULL                              }
 };
 
 int informativeversion(const struct versionrevision *version) {
@@ -207,7 +207,7 @@ const char *parseversion(struct versionrevision *rversion, const char *string) {
   if (hyphen) *hyphen++= 0;
   rversion->revision= hyphen ? hyphen : "";
   
-  return 0;
+  return NULL;
 }
 
 void parsemustfield

+ 1 - 1
lib/star.c

@@ -153,7 +153,7 @@ static const TarFunctions	functions = {
 int
 main(int argc, char * * argv)
 {
-	int	status = TarExtractor((void *)0, &functions);
+	int	status = TarExtractor(NULL, &functions);
 
 	if ( status == -1 ) {
 		fflush(stdout);

+ 7 - 7
lib/tarfn.c

@@ -32,7 +32,7 @@ struct TarHeader {
 typedef struct TarHeader	TarHeader;
 
 static const unsigned int	TarChecksumOffset
-	= (unsigned int)&(((TarHeader *)0)->Checksum);
+	= (unsigned int)&(((TarHeader *)NULL)->Checksum);
 
 /* Octal-ASCII-to-long */
 static long
@@ -56,8 +56,8 @@ DecodeTarHeader(char * block, TarInfo * d)
 {
 	TarHeader *		h = (TarHeader *)block;
 	unsigned char *		s = (unsigned char *)block;
-	struct passwd *		passwd = 0;
-	struct group *		group = 0;
+	struct passwd *		passwd = NULL;
+	struct group *		group = NULL;
 	unsigned int		i;
 	long			sum;
 	long			checksum;
@@ -111,8 +111,8 @@ TarExtractor(
        char    **longp;
        int     long_read;
 
-       next_long_name = 0;
-       next_long_link = 0;
+       next_long_name = NULL;
+       next_long_link = NULL;
        long_read = 0;
 
 	h.UserData = userData;
@@ -136,8 +136,8 @@ TarExtractor(
                  h.LinkName = next_long_link;
                }
 
-               next_long_name = 0;
-               next_long_link = 0;
+               next_long_name = NULL;
+               next_long_link = NULL;
 
 		if ( h.Name[0] == '\0' ) {
 			errno = 0;	/* Indicates broken tarfile */

+ 2 - 2
lib/varbuf.c

@@ -89,7 +89,7 @@ void varbufaddbuf(struct varbuf *v, const void *s, const int l) {
 void varbufinit(struct varbuf *v) {
   /* NB: dbmodify.c does its own init to get a big buffer */
   v->size= v->used= 0;
-  v->buf= 0;
+  v->buf= NULL;
 }
 
 void varbufreset(struct varbuf *v) {
@@ -108,5 +108,5 @@ void varbufextend(struct varbuf *v) {
 }
 
 void varbuffree(struct varbuf *v) {
-  free(v->buf); v->buf=0; v->size=0; v->used=0;
+  free(v->buf); v->buf=NULL; v->size=0; v->used=0;
 }