浏览代码

libdpkg: Rename varbufaddstr() to varbuf_add_str()

Make the varbuf API a bit more consistent.
Guillem Jover 15 年之前
父节点
当前提交
91c3515c24
共有 21 个文件被更改,包括 146 次插入134 次删除
  1. 2 2
      dpkg-deb/info.c
  2. 3 3
      lib/dpkg/dbmodify.c
  3. 52 41
      lib/dpkg/dump.c
  4. 3 2
      lib/dpkg/parsehelp.c
  5. 2 2
      lib/dpkg/trigdeferred.l
  6. 2 2
      lib/dpkg/triglib.c
  7. 2 2
      lib/dpkg/varbuf.h
  8. 13 13
      src/archives.c
  9. 5 5
      src/configure.c
  10. 9 9
      src/depcon.c
  11. 2 2
      src/divertdb.c
  12. 5 5
      src/filesdb.c
  13. 2 2
      src/help.c
  14. 6 6
      src/packages.c
  15. 9 9
      src/processarc.c
  16. 4 4
      src/querycmd.c
  17. 14 14
      src/remove.c
  18. 6 6
      src/statcmd.c
  19. 2 2
      src/statdb.c
  20. 1 1
      src/trigproc.c
  21. 2 2
      src/update.c

+ 2 - 2
dpkg-deb/info.c

@@ -98,9 +98,9 @@ info_spew(const char *debar, const char *dir, const char *const *argv)
 
   while ((component = *argv++) != NULL) {
     varbuf_reset(&controlfile);
-    varbufaddstr(&controlfile, dir);
+    varbuf_add_str(&controlfile, dir);
     varbuf_add_char(&controlfile, '/');
-    varbufaddstr(&controlfile, component);
+    varbuf_add_str(&controlfile, component);
     varbuf_add_char(&controlfile, '\0');
 
     fd = open(controlfile.buf, O_RDONLY);

+ 3 - 3
lib/dpkg/dbmodify.c

@@ -406,10 +406,10 @@ pkgadmindir(void)
 const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
   static struct varbuf vb;
   varbuf_reset(&vb);
-  varbufaddstr(&vb, infodir);
-  varbufaddstr(&vb,pkg->name);
+  varbuf_add_str(&vb, infodir);
+  varbuf_add_str(&vb, pkg->name);
   varbuf_add_char(&vb, '.');
-  varbufaddstr(&vb,whichfile);
+  varbuf_add_str(&vb, whichfile);
   varbuf_add_char(&vb, '\0');
   return vb.buf;
 }

+ 52 - 41
lib/dpkg/dump.c

@@ -47,8 +47,8 @@ void w_name(struct varbuf *vb,
             enum fwriteflags flags, const struct fieldinfo *fip) {
   assert(pigp->name);
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Package: ");
-  varbufaddstr(vb, pigp->name);
+    varbuf_add_str(vb, "Package: ");
+  varbuf_add_str(vb, pigp->name);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
@@ -58,7 +58,7 @@ void w_version(struct varbuf *vb,
                enum fwriteflags flags, const struct fieldinfo *fip) {
   if (!informativeversion(&pifp->version)) return;
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Version: ");
+    varbuf_add_str(vb, "Version: ");
   varbufversion(vb,&pifp->version,vdew_nonambig);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
@@ -75,7 +75,7 @@ void w_configversion(struct varbuf *vb,
       pigp->status == stat_triggersawaited)
     return;
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Config-Version: ");
+    varbuf_add_str(vb, "Config-Version: ");
   varbufversion(vb,&pigp->configversion,vdew_nonambig);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
@@ -92,8 +92,8 @@ void w_section(struct varbuf *vb,
   const char *value= pigp->section;
   if (!value || !*value) return;
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Section: ");
-  varbufaddstr(vb,value);
+    varbuf_add_str(vb, "Section: ");
+  varbuf_add_str(vb, value);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
@@ -104,10 +104,10 @@ void w_charfield(struct varbuf *vb,
   const char *value = PKGPFIELD(pifp, fip->integer, const char *);
   if (!value || !*value) return;
   if (flags&fw_printheader) {
-    varbufaddstr(vb,fip->name);
-    varbufaddstr(vb, ": ");
+    varbuf_add_str(vb, fip->name);
+    varbuf_add_str(vb, ": ");
   }
-  varbufaddstr(vb,value);
+  varbuf_add_str(vb, value);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
@@ -122,13 +122,13 @@ void w_filecharf(struct varbuf *vb,
   if (!fdp || !FILEFFIELD(fdp,fip->integer,const char*)) return;
 
   if (flags&fw_printheader) {
-    varbufaddstr(vb,fip->name);
+    varbuf_add_str(vb, fip->name);
     varbuf_add_char(vb, ':');
   }
 
   while (fdp) {
     varbuf_add_char(vb, ' ');
-    varbufaddstr(vb,FILEFFIELD(fdp,fip->integer,const char*));
+    varbuf_add_str(vb, FILEFFIELD(fdp, fip->integer, const char *));
     fdp= fdp->next;
   }
 
@@ -141,12 +141,13 @@ void w_booleandefno(struct varbuf *vb,
                     enum fwriteflags flags, const struct fieldinfo *fip) {
   bool value = PKGPFIELD(pifp, fip->integer, bool);
   if (!(flags&fw_printheader)) {
-    varbufaddstr(vb, value ? "yes" : "no");
+    varbuf_add_str(vb, value ? "yes" : "no");
     return;
   }
   if (!value) return;
   assert(value == true);
-  varbufaddstr(vb,fip->name); varbufaddstr(vb, ": yes\n");
+  varbuf_add_str(vb, fip->name);
+  varbuf_add_str(vb, ": yes\n");
 }
 
 void w_priority(struct varbuf *vb,
@@ -155,11 +156,10 @@ void w_priority(struct varbuf *vb,
   if (pigp->priority == pri_unknown) return;
   assert(pigp->priority <= pri_unknown);
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Priority: ");
-  varbufaddstr(vb,
-               pigp->priority == pri_other
-               ? pigp->otherpriority
-               : priorityinfos[pigp->priority].name);
+    varbuf_add_str(vb, "Priority: ");
+  varbuf_add_str(vb, pigp->priority == pri_other ?
+                     pigp->otherpriority :
+                     priorityinfos[pigp->priority].name);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
@@ -202,12 +202,12 @@ void w_status(struct varbuf *vb,
 #undef AW
 
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Status: ");
-  varbufaddstr(vb, wantinfos[pigp->want].name);
+    varbuf_add_str(vb, "Status: ");
+  varbuf_add_str(vb, wantinfos[pigp->want].name);
   varbuf_add_char(vb, ' ');
-  varbufaddstr(vb, eflaginfos[pigp->eflag].name);
+  varbuf_add_str(vb, eflaginfos[pigp->eflag].name);
   varbuf_add_char(vb, ' ');
-  varbufaddstr(vb,statusinfos[pigp->status].name);
+  varbuf_add_str(vb, statusinfos[pigp->status].name);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
@@ -219,18 +219,27 @@ void varbufdependency(struct varbuf *vb, struct dependency *dep) {
   possdel= "";
   for (dop= dep->list; dop; dop= dop->next) {
     assert(dop->up == dep);
-    varbufaddstr(vb,possdel); possdel= " | ";
-    varbufaddstr(vb,dop->ed->name);
+    varbuf_add_str(vb, possdel);
+    possdel = " | ";
+    varbuf_add_str(vb, dop->ed->name);
     if (dop->verrel != dvr_none) {
-      varbufaddstr(vb," (");
+      varbuf_add_str(vb, " (");
       switch (dop->verrel) {
       case dvr_exact:
         varbuf_add_char(vb, '=');
         break;
-      case dvr_laterequal: varbufaddstr(vb,">="); break;
-      case dvr_earlierequal: varbufaddstr(vb,"<="); break;
-      case dvr_laterstrict: varbufaddstr(vb,">>"); break;
-      case dvr_earlierstrict: varbufaddstr(vb,"<<"); break;
+      case dvr_laterequal:
+        varbuf_add_str(vb, ">=");
+        break;
+      case dvr_earlierequal:
+        varbuf_add_str(vb, "<=");
+        break;
+      case dvr_laterstrict:
+        varbuf_add_str(vb, ">>");
+        break;
+      case dvr_earlierstrict:
+        varbuf_add_str(vb, "<<");
+        break;
       default:
         internerr("unknown verrel '%d'", dop->verrel);
       }
@@ -257,7 +266,8 @@ void w_dependency(struct varbuf *vb,
   for (dyp= pifp->depends; dyp; dyp= dyp->next) {
     if (dyp->type != fip->integer) continue;
     assert(dyp->up == pigp);
-    varbufaddstr(vb,depdel); depdel= ", ";
+    varbuf_add_str(vb, depdel);
+    depdel = ", ";
     varbufdependency(vb,dyp);
   }
   if ((flags&fw_printheader) && (depdel!=fnbuf))
@@ -272,15 +282,16 @@ void w_conffiles(struct varbuf *vb,
   if (!pifp->conffiles || pifp == &pigp->available)
     return;
   if (flags&fw_printheader)
-    varbufaddstr(vb,"Conffiles:\n");
+    varbuf_add_str(vb, "Conffiles:\n");
   for (i=pifp->conffiles; i; i= i->next) {
     if (i != pifp->conffiles)
       varbuf_add_char(vb, '\n');
     varbuf_add_char(vb, ' ');
-    varbufaddstr(vb, i->name);
+    varbuf_add_str(vb, i->name);
     varbuf_add_char(vb, ' ');
-    varbufaddstr(vb,i->hash);
-    if (i->obsolete) varbufaddstr(vb," obsolete");
+    varbuf_add_str(vb, i->hash);
+    if (i->obsolete)
+      varbuf_add_str(vb, " obsolete");
   }
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
@@ -300,10 +311,10 @@ w_trigpend(struct varbuf *vb,
          pigp->status <= stat_triggerspending);
 
   if (flags & fw_printheader)
-    varbufaddstr(vb, "Triggers-Pending:");
+    varbuf_add_str(vb, "Triggers-Pending:");
   for (tp = pigp->trigpend_head; tp; tp = tp->next) {
     varbuf_add_char(vb, ' ');
-    varbufaddstr(vb, tp->name);
+    varbuf_add_str(vb, tp->name);
   }
   if (flags & fw_printheader)
     varbuf_add_char(vb, '\n');
@@ -323,10 +334,10 @@ w_trigaw(struct varbuf *vb,
          pigp->status <= stat_triggersawaited);
 
   if (flags & fw_printheader)
-    varbufaddstr(vb, "Triggers-Awaited:");
+    varbuf_add_str(vb, "Triggers-Awaited:");
   for (ta = pigp->trigaw.head; ta; ta = ta->sameaw.next) {
     varbuf_add_char(vb, ' ');
-    varbufaddstr(vb, ta->pend->name);
+    varbuf_add_str(vb, ta->pend->name);
   }
   if (flags & fw_printheader)
     varbuf_add_char(vb, '\n');
@@ -341,9 +352,9 @@ void varbufrecord(struct varbuf *vb,
     fip->wcall(vb,pigp,pifp,fw_printheader,fip);
   }
   for (afp = pifp->arbs; afp; afp = afp->next) {
-    varbufaddstr(vb, afp->name);
-    varbufaddstr(vb, ": ");
-    varbufaddstr(vb, afp->value);
+    varbuf_add_str(vb, afp->name);
+    varbuf_add_str(vb, ": ");
+    varbuf_add_str(vb, afp->value);
     varbuf_add_char(vb, '\n');
   }
 }

+ 3 - 2
lib/dpkg/parsehelp.c

@@ -177,10 +177,11 @@ void varbufversion
   default:
     internerr("unknown versiondisplayepochwhen '%d'", vdew);
   }
-  if (version->version) varbufaddstr(vb,version->version);
+  if (version->version)
+    varbuf_add_str(vb, version->version);
   if (version->revision && *version->revision) {
     varbuf_add_char(vb, '-');
-    varbufaddstr(vb,version->revision);
+    varbuf_add_str(vb, version->revision);
   }
 }
 

+ 2 - 2
lib/dpkg/trigdeferred.l

@@ -100,8 +100,8 @@ static void
 constructfn(struct varbuf *vb, const char *dir, const char *tail)
 {
 	varbuf_reset(vb);
-	varbufaddstr(vb, dir);
-	varbufaddstr(vb, tail);
+	varbuf_add_str(vb, dir);
+	varbuf_add_str(vb, tail);
 	varbuf_add_char(vb, '\0');
 }
 

+ 2 - 2
lib/dpkg/triglib.c

@@ -363,8 +363,8 @@ trk_explicit_start(const char *trig)
 	trk_explicit_activate_done();
 
 	varbuf_reset(&trk_explicit_fn);
-	varbufaddstr(&trk_explicit_fn, triggersdir);
-	varbufaddstr(&trk_explicit_fn, trig);
+	varbuf_add_str(&trk_explicit_fn, triggersdir);
+	varbuf_add_str(&trk_explicit_fn, trig);
 	varbuf_add_char(&trk_explicit_fn, '\0');
 
 	trk_explicit_f = fopen(trk_explicit_fn.buf, "r");

+ 2 - 2
lib/dpkg/varbuf.h

@@ -74,7 +74,7 @@ void varbuf_destroy(struct varbuf *v);
 void varbuf_add_char(struct varbuf *v, int c);
 void varbuf_dup_char(struct varbuf *v, int c, size_t n);
 void varbuf_map_char(struct varbuf *v, int c_src, int c_dst);
-#define varbufaddstr(v, s) varbufaddbuf(v, s, strlen(s))
+#define varbuf_add_str(v, s) varbufaddbuf(v, s, strlen(s))
 void varbufaddbuf(struct varbuf *v, const void *s, size_t size);
 
 int varbufprintf(struct varbuf *v, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
@@ -123,7 +123,7 @@ varbuf::operator()(int c)
 inline void
 varbuf::operator()(const char *s)
 {
-	varbufaddstr(this, s);
+	varbuf_add_str(this, s);
 }
 
 inline void

+ 13 - 13
src/archives.c

@@ -292,17 +292,17 @@ set_selinux_path_context(const char *matchpath, const char *path, mode_t mode)
 
 void setupfnamevbs(const char *filename) {
   varbuf_trunc(&fnamevb, fnameidlu);
-  varbufaddstr(&fnamevb,filename);
+  varbuf_add_str(&fnamevb, filename);
   varbuf_add_char(&fnamevb, '\0');
 
   varbuf_trunc(&fnametmpvb, fnameidlu);
-  varbufaddstr(&fnametmpvb,filename);
-  varbufaddstr(&fnametmpvb,DPKGTEMPEXT);
+  varbuf_add_str(&fnametmpvb, filename);
+  varbuf_add_str(&fnametmpvb, DPKGTEMPEXT);
   varbuf_add_char(&fnametmpvb, '\0');
 
   varbuf_trunc(&fnamenewvb, fnameidlu);
-  varbufaddstr(&fnamenewvb,filename);
-  varbufaddstr(&fnamenewvb,DPKGNEWEXT);
+  varbuf_add_str(&fnamenewvb, filename);
+  varbuf_add_str(&fnamenewvb, DPKGNEWEXT);
   varbuf_add_char(&fnamenewvb, '\0');
 
   debug(dbg_eachfiledetail, "setupvnamevbs main=`%s' tmp=`%s' new=`%s'",
@@ -385,13 +385,13 @@ linktosameexistingdir(const struct tar_entry *ti, const char *fname,
   /* But is it to the same dir? */
   varbuf_reset(symlinkfn);
   if (ti->linkname[0] == '/') {
-    varbufaddstr(symlinkfn, instdir);
+    varbuf_add_str(symlinkfn, instdir);
   } else {
     lastslash= strrchr(fname, '/');
     assert(lastslash);
     varbufaddbuf(symlinkfn, fname, (lastslash - fname) + 1);
   }
-  varbufaddstr(symlinkfn, ti->linkname);
+  varbuf_add_str(symlinkfn, ti->linkname);
   varbuf_add_char(symlinkfn, '\0');
 
   statr= stat(symlinkfn->buf, &newstab);
@@ -738,12 +738,12 @@ tarobject(void *ctx, struct tar_entry *ti)
     break;
   case tar_filetype_hardlink:
     varbuf_reset(&hardlinkfn);
-    varbufaddstr(&hardlinkfn, instdir);
+    varbuf_add_str(&hardlinkfn, instdir);
     varbuf_add_char(&hardlinkfn, '/');
-    varbufaddstr(&hardlinkfn, ti->linkname);
+    varbuf_add_str(&hardlinkfn, ti->linkname);
     linknode = findnamenode(ti->linkname, 0);
     if (linknode->flags & fnnf_deferred_rename)
-      varbufaddstr(&hardlinkfn, DPKGNEWEXT);
+      varbuf_add_str(&hardlinkfn, DPKGNEWEXT);
     varbuf_add_char(&hardlinkfn, '\0');
     if (link(hardlinkfn.buf,fnamenewvb.buf))
       ohshite(_("error creating hard link `%.255s'"), ti->name);
@@ -1278,11 +1278,11 @@ void archivefiles(const char *const *argv) {
   varbuf_reset(&fnametmpvb);
   varbuf_reset(&fnamenewvb);
 
-  varbufaddstr(&fnamevb, instdir);
+  varbuf_add_str(&fnamevb, instdir);
   varbuf_add_char(&fnamevb, '/');
-  varbufaddstr(&fnametmpvb, instdir);
+  varbuf_add_str(&fnametmpvb, instdir);
   varbuf_add_char(&fnametmpvb, '/');
-  varbufaddstr(&fnamenewvb, instdir);
+  varbuf_add_str(&fnamenewvb, instdir);
   varbuf_add_char(&fnamenewvb, '/');
   fnameidlu= fnamevb.used;
 

+ 5 - 5
src/configure.c

@@ -87,7 +87,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 	md5hash(pkg, currenthash, cdr.buf);
 
 	varbuf_reset(&cdr2);
-	varbufaddstr(&cdr2, cdr.buf);
+	varbuf_add_str(&cdr2, cdr.buf);
 	varbuf_add_char(&cdr2, '\0');
 	/* XXX: Make sure there's enough room for extensions. */
 	varbuf_grow(&cdr2, 50);
@@ -166,7 +166,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 			warning(_("%s: failed to remove old backup '%.250s': %s"),
 			        pkg->name, cdr2.buf, strerror(errno));
 		cdr.used--;
-		varbufaddstr(&cdr, DPKGDISTEXT);
+		varbuf_add_str(&cdr, DPKGDISTEXT);
 		varbuf_add_char(&cdr, '\0');
 		strcpy(cdr2rest, DPKGNEWEXT);
 		trig_file_activate(usenode, pkg);
@@ -377,10 +377,10 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in)
 	int loopprotect;
 
 	varbuf_reset(result);
-	varbufaddstr(result, instdir);
+	varbuf_add_str(result, instdir);
 	if (*in != '/')
 		varbuf_add_char(result, '/');
-	varbufaddstr(result, in);
+	varbuf_add_str(result, in);
 	varbuf_add_char(result, '\0');
 
 	loopprotect = 0;
@@ -427,7 +427,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in)
 
 			if (target.buf[0] == '/') {
 				varbuf_reset(result);
-				varbufaddstr(result, instdir);
+				varbuf_add_str(result, instdir);
 				debug(dbg_conffdetail,
 				      "conffderef readlink absolute");
 			} else {

+ 9 - 9
src/depcon.c

@@ -114,8 +114,8 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
     struct varbuf str_pkgs = VARBUF_INIT;
 
     for (sol = sofar; sol; sol = sol->prev) {
-      varbufaddstr(&str_pkgs, " <- ");
-      varbufaddstr(&str_pkgs, sol->pkg->name);
+      varbuf_add_str(&str_pkgs, " <- ");
+      varbuf_add_str(&str_pkgs, sol->pkg->name);
     }
     varbuf_add_char(&str_pkgs, '\0');
     debug(dbg_depcondetail, "findbreakcyclerecursive %s %s", pkg->name,
@@ -348,7 +348,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
       default:
         internerr("unknown istobe depended '%d'", possi->ed->clientdata->istobe);
       }
-      varbufaddstr(whynot, linebuf);
+      varbuf_add_str(whynot, linebuf);
 
       /* If there was no version specified we try looking for Providers. */
       if (possi->verrel == dvr_none) {
@@ -393,14 +393,14 @@ depisok(struct dependency *dep, struct varbuf *whynot,
             internerr("unknown istobe provider '%d'",
                       provider->up->up->clientdata->istobe);
           }
-          varbufaddstr(whynot, linebuf);
+          varbuf_add_str(whynot, linebuf);
         }
 
         if (!*linebuf) {
           /* If the package wasn't installed at all, and we haven't said
            * yet why this isn't satisfied, we should say so now. */
           sprintf(linebuf, _("  %.250s is not installed.\n"), possi->ed->name);
-          varbufaddstr(whynot, linebuf);
+          varbuf_add_str(whynot, linebuf);
         }
       }
     }
@@ -430,7 +430,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
         sprintf(linebuf, _("  %.250s (version %.250s) is to be installed.\n"),
                 possi->ed->name,
                 versiondescribe(&possi->ed->available.version,vdew_nonambig));
-        varbufaddstr(whynot, linebuf);
+        varbuf_add_str(whynot, linebuf);
         if (!canfixbyremove)
           return false;
         nconflicts++;
@@ -456,7 +456,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
                   possi->ed->name,
                   versiondescribe(&possi->ed->installed.version,vdew_nonambig),
                   gettext(statusstrings[possi->ed->status]));
-          varbufaddstr(whynot, linebuf);
+          varbuf_add_str(whynot, linebuf);
           if (!canfixbyremove)
             return false;
           nconflicts++;
@@ -481,7 +481,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
           continue; /* Conflicts and provides the same. */
         sprintf(linebuf, _("  %.250s provides %.250s and is to be installed.\n"),
                 provider->up->up->name, possi->ed->name);
-        varbufaddstr(whynot, linebuf);
+        varbuf_add_str(whynot, linebuf);
         /* We can't remove the one we're about to install: */
         if (canfixbyremove)
           *canfixbyremove = NULL;
@@ -524,7 +524,7 @@ depisok(struct dependency *dep, struct varbuf *whynot,
                     _("  %.250s provides %.250s and is present and %s.\n"),
                     provider->up->up->name, possi->ed->name,
                     gettext(statusstrings[provider->up->up->status]));
-            varbufaddstr(whynot, linebuf);
+            varbuf_add_str(whynot, linebuf);
             if (!canfixbyremove)
               return false;
             nconflicts++;

+ 2 - 2
src/divertdb.c

@@ -54,8 +54,8 @@ ensure_diversions(void)
 	struct diversion *ov, *oicontest, *oialtname;
 
 	varbuf_reset(&vb);
-	varbufaddstr(&vb, admindir);
-	varbufaddstr(&vb, "/" DIVERSIONSFILE);
+	varbuf_add_str(&vb, admindir);
+	varbuf_add_str(&vb, "/" DIVERSIONSFILE);
 	varbuf_add_char(&vb, '\0');
 
 	onerr_abort++;

+ 5 - 5
src/filesdb.c

@@ -465,14 +465,14 @@ write_filelist_except(struct pkginfo *pkg, struct fileinlist *list,
   FILE *file;
 
   varbuf_reset(&vb);
-  varbufaddstr(&vb, pkgadmindir());
-  varbufaddstr(&vb,pkg->name);
-  varbufaddstr(&vb,"." LISTFILE);
+  varbuf_add_str(&vb, pkgadmindir());
+  varbuf_add_str(&vb, pkg->name);
+  varbuf_add_str(&vb, "." LISTFILE);
   varbuf_add_char(&vb, '\0');
 
   varbuf_reset(&newvb);
-  varbufaddstr(&newvb,vb.buf);
-  varbufaddstr(&newvb,NEWDBEXT);
+  varbuf_add_str(&newvb, vb.buf);
+  varbuf_add_str(&newvb, NEWDBEXT);
   varbuf_add_char(&newvb, '\0');
 
   file= fopen(newvb.buf,"w+");

+ 2 - 2
src/help.c

@@ -119,7 +119,7 @@ void checkpath(void) {
       varbufaddbuf(&filename, path, path_len);
       if (path_len)
         varbuf_add_char(&filename, '/');
-      varbufaddstr(&filename, *prog);
+      varbuf_add_str(&filename, *prog);
       varbuf_add_char(&filename, '\0');
 
       if (stat(filename.buf, &stab) == 0 && (stab.st_mode & 0111))
@@ -196,7 +196,7 @@ preexecscript(struct command *cmd)
 
     while (*++argv) {
       varbuf_add_char(&args, ' ');
-      varbufaddstr(&args, *argv);
+      varbuf_add_str(&args, *argv);
     }
     varbuf_add_char(&args, '\0');
     debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename, args.buf);

+ 6 - 6
src/packages.c

@@ -593,18 +593,18 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
       anycannotfixbytrig = true;
       ok = dep_check_halt;
     case found_forced:
-      varbufaddstr(aemsgs, " ");
-      varbufaddstr(aemsgs, pkg->name);
-      varbufaddstr(aemsgs, _(" depends on "));
+      varbuf_add_str(aemsgs, " ");
+      varbuf_add_str(aemsgs, pkg->name);
+      varbuf_add_str(aemsgs, _(" depends on "));
       varbufdependency(aemsgs, dep);
       if (interestingwarnings) {
         /* Don't print the line about the package to be removed if
          * that's the only line. */
-        varbufaddstr(aemsgs, _("; however:\n"));
+        varbuf_add_str(aemsgs, _("; however:\n"));
         varbuf_add_char(&oemsgs, '\0');
-        varbufaddstr(aemsgs, oemsgs.buf);
+        varbuf_add_str(aemsgs, oemsgs.buf);
       } else {
-        varbufaddstr(aemsgs, ".\n");
+        varbuf_add_str(aemsgs, ".\n");
       }
       break;
     case found_defer:

+ 9 - 9
src/processarc.c

@@ -690,7 +690,7 @@ void process_archive(const char *filename) {
     trig_file_activate(usenode, pkg);
 
     varbuf_trunc(&fnamevb, fnameidlu);
-    varbufaddstr(&fnamevb, usenode->name);
+    varbuf_add_str(&fnamevb, usenode->name);
     varbuf_add_char(&fnamevb, '\0');
 
     if (!stat(namenode->name,&stab) && S_ISDIR(stab.st_mode)) {
@@ -747,9 +747,9 @@ void process_archive(const char *filename) {
 	  struct stat tmp_stat;
 
 	  varbuf_reset(&cfilename);
-	  varbufaddstr(&cfilename, instdir);
+	  varbuf_add_str(&cfilename, instdir);
 	  varbuf_add_char(&cfilename, '/');
-	  varbufaddstr(&cfilename, cfile->namenode->name);
+	  varbuf_add_str(&cfilename, cfile->namenode->name);
 	  varbuf_add_char(&cfilename, '\0');
 
 	  if (lstat(cfilename.buf, &tmp_stat) == 0) {
@@ -834,7 +834,7 @@ void process_archive(const char *filename) {
    * (any that are left) and install them. */
   debug(dbg_general, "process_archive updating info directory");
   varbuf_reset(&infofnvb);
-  varbufaddstr(&infofnvb, pkgadmindir());
+  varbuf_add_str(&infofnvb, pkgadmindir());
   infodirlen= infofnvb.used;
   varbuf_add_char(&infofnvb, '\0');
   dsd= opendir(infofnvb.buf);
@@ -864,7 +864,7 @@ void process_archive(const char *filename) {
       ohshit(_("old version of package has overly-long info file name starting `%.250s'"),
              de->d_name);
     varbuf_trunc(&infofnvb, infodirlen);
-    varbufaddstr(&infofnvb,de->d_name);
+    varbuf_add_str(&infofnvb, de->d_name);
     varbuf_add_char(&infofnvb, '\0');
     strcpy(cidirrest,p);
 
@@ -1113,7 +1113,7 @@ void process_archive(const char *filename) {
 
     /* OK, now we delete all the stuff in the ‘info’ directory .. */
     varbuf_reset(&fnvb);
-    varbufaddstr(&fnvb, pkgadmindir());
+    varbuf_add_str(&fnvb, pkgadmindir());
     infodirbaseused= fnvb.used;
     varbuf_add_char(&fnvb, '\0');
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
@@ -1129,7 +1129,7 @@ void process_archive(const char *filename) {
           strncmp(de->d_name,otherpkg->name,p-de->d_name)) continue;
       debug(dbg_stupidlyverbose, "process_archive info this pkg");
       varbuf_trunc(&fnvb, infodirbaseused);
-      varbufaddstr(&fnvb,de->d_name);
+      varbuf_add_str(&fnvb, de->d_name);
       varbuf_add_char(&fnvb, '\0');
       if (unlink(fnvb.buf))
         ohshite(_("unable to delete disappearing control info file `%.250s'"),fnvb.buf);
@@ -1224,8 +1224,8 @@ void process_archive(const char *filename) {
   for (cfile= newfileslist; cfile; cfile= cfile->next) {
     if (cfile->namenode->flags & fnnf_new_conff) continue;
     varbuf_trunc(&fnametmpvb, fnameidlu);
-    varbufaddstr(&fnametmpvb,namenodetouse(cfile->namenode,pkg)->name);
-    varbufaddstr(&fnametmpvb,DPKGTEMPEXT);
+    varbuf_add_str(&fnametmpvb, namenodetouse(cfile->namenode, pkg)->name);
+    varbuf_add_str(&fnametmpvb, DPKGTEMPEXT);
     varbuf_add_char(&fnametmpvb, '\0');
     ensure_pathname_nonexisting(fnametmpvb.buf);
   }

+ 4 - 4
src/querycmd.c

@@ -312,7 +312,7 @@ searchfiles(const char *const *argv)
      * not a pattern, just a path. */
     if (!strpbrk(thisarg, "*[?\\")) {
       varbuf_reset(&path);
-      varbufaddstr(&path, thisarg);
+      varbuf_add_str(&path, thisarg);
       varbuf_add_char(&path, '\0');
 
       varbuf_trunc(&path, path_trim_slash_slashdot(path.buf));
@@ -323,7 +323,7 @@ searchfiles(const char *const *argv)
     if (!strchr("*[?/",*thisarg)) {
       varbuf_reset(&vb);
       varbuf_add_char(&vb, '*');
-      varbufaddstr(&vb,thisarg);
+      varbuf_add_str(&vb, thisarg);
       varbuf_add_char(&vb, '*');
       varbuf_add_char(&vb, '\0');
       thisarg= vb.buf;
@@ -545,7 +545,7 @@ control_path_pkg(struct pkginfo *pkg)
   size_t db_path_len;
 
   varbuf_init(&db_path, 0);
-  varbufaddstr(&db_path, pkgadmindir());
+  varbuf_add_str(&db_path, pkgadmindir());
   db_path_len = db_path.used;
   varbuf_add_char(&db_path, '\0');
 
@@ -583,7 +583,7 @@ control_path_pkg(struct pkginfo *pkg)
       continue;
 
     varbuf_trunc(&db_path, db_path_len);
-    varbufaddstr(&db_path, db_de->d_name);
+    varbuf_add_str(&db_path, db_de->d_name);
     varbuf_add_char(&db_path, '\0');
 
     printf("%s\n", db_path.buf);

+ 14 - 14
src/remove.c

@@ -217,18 +217,18 @@ static void removal_bulk_remove_files(
       trig_file_activate(usenode, pkg);
 
       varbuf_reset(&fnvb);
-      varbufaddstr(&fnvb,instdir);
-      varbufaddstr(&fnvb, usenode->name);
+      varbuf_add_str(&fnvb, instdir);
+      varbuf_add_str(&fnvb, usenode->name);
       before= fnvb.used;
 
-      varbufaddstr(&fnvb,DPKGTEMPEXT);
+      varbuf_add_str(&fnvb, DPKGTEMPEXT);
       varbuf_add_char(&fnvb, '\0');
       debug(dbg_eachfiledetail, "removal_bulk cleaning temp `%s'", fnvb.buf);
 
       ensure_pathname_nonexisting(fnvb.buf);
 
       varbuf_trunc(&fnvb, before);
-      varbufaddstr(&fnvb,DPKGNEWEXT);
+      varbuf_add_str(&fnvb, DPKGNEWEXT);
       varbuf_add_char(&fnvb, '\0');
       debug(dbg_eachfiledetail, "removal_bulk cleaning new `%s'", fnvb.buf);
       ensure_pathname_nonexisting(fnvb.buf);
@@ -269,7 +269,7 @@ static void removal_bulk_remove_files(
     maintainer_script_installed(pkg, POSTRMFILE, "post-removal",
                                 "remove", NULL);
     varbuf_reset(&fnvb);
-    varbufaddstr(&fnvb, pkgadmindir());
+    varbuf_add_str(&fnvb, pkgadmindir());
     infodirbaseused= fnvb.used;
     varbuf_add_char(&fnvb, '\0');
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
@@ -295,7 +295,7 @@ static void removal_bulk_remove_files(
       }
       debug(dbg_stupidlyverbose, "removal_bulk info not postrm or list");
       varbuf_trunc(&fnvb, infodirbaseused);
-      varbufaddstr(&fnvb,de->d_name);
+      varbuf_add_str(&fnvb, de->d_name);
       varbuf_add_char(&fnvb, '\0');
       if (unlink(fnvb.buf))
         ohshite(_("unable to delete control info file `%.250s'"),fnvb.buf);
@@ -339,8 +339,8 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
     trig_file_activate(usenode, pkg);
 
     varbuf_reset(&fnvb);
-    varbufaddstr(&fnvb,instdir);
-    varbufaddstr(&fnvb, usenode->name);
+    varbuf_add_str(&fnvb, instdir);
+    varbuf_add_str(&fnvb, usenode->name);
     varbuf_add_char(&fnvb, '\0');
 
     if (!stat(fnvb.buf,&stab) && S_ISDIR(stab.st_mode)) {
@@ -447,7 +447,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
       p= strrchr(fnvb.buf,'/'); if (!p) continue;
       *p = '\0';
       varbuf_reset(&removevb);
-      varbufaddstr(&removevb,fnvb.buf);
+      varbuf_add_str(&removevb, fnvb.buf);
       varbuf_add_char(&removevb, '/');
       removevbbase= removevb.used;
       varbuf_add_char(&removevb, '\0');
@@ -488,7 +488,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
         continue;
       yes_remove:
         varbuf_trunc(&removevb, removevbbase);
-        varbufaddstr(&removevb, de->d_name);
+        varbuf_add_str(&removevb, de->d_name);
         varbuf_add_char(&removevb, '\0');
         debug(dbg_conffdetail, "removal_bulk conffile dsd entry removing `%s'",
               removevb.buf);
@@ -557,17 +557,17 @@ void removal_bulk(struct pkginfo *pkg) {
     removal_bulk_remove_leftover_dirs(pkg);
 
     varbuf_reset(&fnvb);
-    varbufaddstr(&fnvb, pkgadmindir());
-    varbufaddstr(&fnvb,pkg->name);
+    varbuf_add_str(&fnvb, pkgadmindir());
+    varbuf_add_str(&fnvb, pkg->name);
     pkgnameused= fnvb.used;
 
-    varbufaddstr(&fnvb,"." LISTFILE);
+    varbuf_add_str(&fnvb, "." LISTFILE);
     varbuf_add_char(&fnvb, '\0');
     debug(dbg_general, "removal_bulk purge done, removing list `%s'",fnvb.buf);
     if (unlink(fnvb.buf) && errno != ENOENT) ohshite(_("cannot remove old files list"));
 
     varbuf_trunc(&fnvb, pkgnameused);
-    varbufaddstr(&fnvb,"." POSTRMFILE);
+    varbuf_add_str(&fnvb, "." POSTRMFILE);
     varbuf_add_char(&fnvb, '\0');
     debug(dbg_general, "removal_bulk purge done, removing postrm `%s'",fnvb.buf);
     if (unlink(fnvb.buf) && errno != ENOENT) ohshite(_("can't remove old postrm script"));

+ 6 - 6
src/statcmd.c

@@ -199,16 +199,16 @@ statdb_write(void)
 	struct varbuf dbname_new = VARBUF_INIT;
 	struct varbuf dbname_old = VARBUF_INIT;
 
-	varbufaddstr(&dbname, admindir);
-	varbufaddstr(&dbname, "/" STATOVERRIDEFILE);
+	varbuf_add_str(&dbname, admindir);
+	varbuf_add_str(&dbname, "/" STATOVERRIDEFILE);
 	varbuf_add_char(&dbname, '\0');
 
-	varbufaddstr(&dbname_new, dbname.buf);
-	varbufaddstr(&dbname_new, NEWDBEXT);
+	varbuf_add_str(&dbname_new, dbname.buf);
+	varbuf_add_str(&dbname_new, NEWDBEXT);
 	varbuf_add_char(&dbname_new, '\0');
 
-	varbufaddstr(&dbname_old, dbname.buf);
-	varbufaddstr(&dbname_old, OLDDBEXT);
+	varbuf_add_str(&dbname_old, dbname.buf);
+	varbuf_add_str(&dbname_old, OLDDBEXT);
 	varbuf_add_char(&dbname_old, '\0');
 
 	dbfile = fopen(dbname_new.buf, "w");

+ 2 - 2
src/statdb.c

@@ -117,8 +117,8 @@ ensure_statoverrides(void)
 	struct filenamenode *fnn;
 
 	varbuf_reset(&vb);
-	varbufaddstr(&vb, admindir);
-	varbufaddstr(&vb, "/" STATOVERRIDEFILE);
+	varbuf_add_str(&vb, admindir);
+	varbuf_add_str(&vb, "/" STATOVERRIDEFILE);
 	varbuf_add_char(&vb, '\0');
 
 	onerr_abort++;

+ 1 - 1
src/trigproc.c

@@ -315,7 +315,7 @@ trigproc(struct pkginfo *pkg)
 		varbuf_reset(&namesarg);
 		for (tp = pkg->trigpend_head; tp; tp = tp->next) {
 			varbuf_add_char(&namesarg, ' ');
-			varbufaddstr(&namesarg, tp->name);
+			varbuf_add_str(&namesarg, tp->name);
 		}
 		varbuf_add_char(&namesarg, '\0');
 

+ 2 - 2
src/update.c

@@ -74,8 +74,8 @@ void updateavailable(const char *const *argv) {
     internerr("unknown action '%d'", cipaction->arg);
   }
 
-  varbufaddstr(&vb,admindir);
-  varbufaddstr(&vb,"/" AVAILFILE);
+  varbuf_add_str(&vb, admindir);
+  varbuf_add_str(&vb, "/" AVAILFILE);
   varbuf_add_char(&vb, '\0');
 
   if (cipaction->arg == act_avmerge)