The following commit has been merged in the master branch:
commit f1bccd4763343d0897db3361022fec8ab5411a34
Author: Guillem Jover <[email protected]>
Date: Thu Feb 24 10:15:47 2011 +0100
Use varbuf_end_str() instead of ad-hoc varbuf_add_char() calls
This allows the strings to be terminated, thus printable or accessed
through the standard C string functions, and at the same time
appendable.
diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c
index 999fb9a..8ef5926 100644
--- a/dpkg-deb/info.c
+++ b/dpkg-deb/info.c
@@ -101,7 +101,7 @@ info_spew(const char *debar, const char *dir, const char
*const *argv)
varbuf_add_str(&controlfile, dir);
varbuf_add_char(&controlfile, '/');
varbuf_add_str(&controlfile, component);
- varbuf_add_char(&controlfile, '\0');
+ varbuf_end_str(&controlfile);
fd = open(controlfile.buf, O_RDONLY);
if (fd >= 0) {
diff --git a/dpkg-split/split.c b/dpkg-split/split.c
index 311ffc6..7e6047a 100644
--- a/dpkg-split/split.c
+++ b/dpkg-split/split.c
@@ -72,7 +72,7 @@ deb_field(const char *filename, const char *field)
/* Parant reads from pipe. */
varbuf_reset(&buf);
fd_vbuf_copy(p[0], &buf, -1, _("package field value extraction"));
- varbuf_add_char(&buf, '\0');
+ varbuf_end_str(&buf);
close(p[0]);
diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c
index 20d3bfb..7d3f9c9 100644
--- a/lib/dpkg/dbmodify.c
+++ b/lib/dpkg/dbmodify.c
@@ -417,6 +417,6 @@ const char *pkgadminfile(struct pkginfo *pkg, const char
*whichfile) {
varbuf_add_str(&vb, pkg->name);
varbuf_add_char(&vb, '.');
varbuf_add_str(&vb, whichfile);
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
return vb.buf;
}
diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index 7817976..524926f 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -392,7 +392,7 @@ writerecord(FILE *file, const char *filename,
struct varbuf vb = VARBUF_INIT;
varbufrecord(&vb,pigp,pifp);
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
if (fputs(vb.buf,file) < 0)
ohshite(_("failed to write details of `%.50s' to `%.250s'"), pigp->name,
filename);
@@ -434,7 +434,7 @@ writedb(const char *filename, bool available, bool mustsync)
continue;
varbufrecord(&vb,pigp,pifp);
varbuf_add_char(&vb, '\n');
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
if (fputs(vb.buf,file) < 0)
ohshite(_("failed to write %s database record about '%.50s' to
'%.250s'"),
which, pigp->name, filename);
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index d27c9db..e1f650e 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -347,7 +347,7 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
depnamelength= p - depnamestart ;
varbuf_reset(&depname);
varbuf_add_buf(&depname, depnamestart, depnamelength);
- varbuf_add_char(&depname, '\0');
+ varbuf_end_str(&depname);
if (!depname.buf[0])
parse_error(ps, pigp,
_("`%s' field, missing package name, or garbage where "
@@ -448,7 +448,7 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
"version unterminated"), fip->name, depname.buf);
varbuf_reset(&version);
varbuf_add_buf(&version, versionstart, versionlength);
- varbuf_add_char(&version, '\0');
+ varbuf_end_str(&version);
parse_db_version(ps, pigp, &dop->version, version.buf,
_("'%s' field, reference to '%.255s': "
"error in version"), fip->name, depname.buf);
@@ -505,7 +505,7 @@ scan_word(const char **valp)
varbuf_reset(&word);
varbuf_add_buf(&word, start, end - start);
- varbuf_add_char(&word, '\0');
+ varbuf_end_str(&word);
*valp = p;
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 58a1daf..92415f5 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -122,7 +122,7 @@ pkg_parse_field(struct parsedb_state *ps, struct
field_state *fs,
varbuf_reset(&fs->value);
varbuf_add_buf(&fs->value, fs->valuestart, fs->valuelen);
- varbuf_add_char(&fs->value, '\0');
+ varbuf_end_str(&fs->value);
fip->rcall(pkg, pkgbin, ps, fs->value.buf, fip);
} else {
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index e96fe10..0a92a35 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -200,7 +200,7 @@ const char *versiondescribe
vb= &bufs[bufnum]; bufnum++; if (bufnum == 10) bufnum= 0;
varbuf_reset(vb);
varbufversion(vb,version,vdew);
- varbuf_add_char(vb, '\0');
+ varbuf_end_str(vb);
return vb->buf;
}
diff --git a/lib/dpkg/pkg-format.c b/lib/dpkg/pkg-format.c
index bc107ee..ed94e29 100644
--- a/lib/dpkg/pkg-format.c
+++ b/lib/dpkg/pkg-format.c
@@ -228,7 +228,7 @@ pkg_format_show(const struct pkg_format_node *head,
if (strcasecmp(head->data, fip->name) == 0) {
fip->wcall(&wb, pkg, pif, 0, fip);
- varbuf_add_char(&wb, '\0');
+ varbuf_end_str(&wb);
varbuf_printf(&fb, fmt, wb.buf);
varbuf_reset(&wb);
ok = true;
@@ -259,7 +259,7 @@ pkg_format_show(const struct pkg_format_node *head,
}
if (vb.buf) {
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
fputs(vb.buf, stdout);
}
diff --git a/lib/dpkg/trigdeferred.l b/lib/dpkg/trigdeferred.l
index 99aea15..a769649 100644
--- a/lib/dpkg/trigdeferred.l
+++ b/lib/dpkg/trigdeferred.l
@@ -102,7 +102,7 @@ constructfn(struct varbuf *vb, const char *dir, const char
*tail)
varbuf_reset(vb);
varbuf_add_str(vb, dir);
varbuf_add_str(vb, tail);
- varbuf_add_char(vb, '\0');
+ varbuf_end_str(vb);
}
/**
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 84ce92e..d99ad45 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -365,7 +365,7 @@ trk_explicit_start(const char *trig)
varbuf_reset(&trk_explicit_fn);
varbuf_add_str(&trk_explicit_fn, triggersdir);
varbuf_add_str(&trk_explicit_fn, trig);
- varbuf_add_char(&trk_explicit_fn, '\0');
+ varbuf_end_str(&trk_explicit_fn);
trk_explicit_f = fopen(trk_explicit_fn.buf, "r");
if (!trk_explicit_f) {
diff --git a/lib/dpkg/varbuf.h b/lib/dpkg/varbuf.h
index a1aa82c..51e2760 100644
--- a/lib/dpkg/varbuf.h
+++ b/lib/dpkg/varbuf.h
@@ -130,8 +130,7 @@ varbuf::operator()(const char *s)
inline void
varbuf::terminate(void/*to shut 2.6.3 up*/)
{
- varbuf_add_char(this, '\0');
- used--;
+ varbuf_end_str(this);
}
inline const char *
diff --git a/src/archives.c b/src/archives.c
index 3eff7ca..645062e 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -288,17 +288,17 @@ set_selinux_path_context(const char *matchpath, const
char *path, mode_t mode)
void setupfnamevbs(const char *filename) {
varbuf_trunc(&fnamevb, fnameidlu);
varbuf_add_str(&fnamevb, filename);
- varbuf_add_char(&fnamevb, '\0');
+ varbuf_end_str(&fnamevb);
varbuf_trunc(&fnametmpvb, fnameidlu);
varbuf_add_str(&fnametmpvb, filename);
varbuf_add_str(&fnametmpvb, DPKGTEMPEXT);
- varbuf_add_char(&fnametmpvb, '\0');
+ varbuf_end_str(&fnametmpvb);
varbuf_trunc(&fnamenewvb, fnameidlu);
varbuf_add_str(&fnamenewvb, filename);
varbuf_add_str(&fnamenewvb, DPKGNEWEXT);
- varbuf_add_char(&fnamenewvb, '\0');
+ varbuf_end_str(&fnamenewvb);
debug(dbg_eachfiledetail, "setupvnamevbs main=`%s' tmp=`%s' new=`%s'",
fnamevb.buf, fnametmpvb.buf, fnamenewvb.buf);
@@ -387,7 +387,7 @@ linktosameexistingdir(const struct tar_entry *ti, const
char *fname,
varbuf_add_buf(symlinkfn, fname, (lastslash - fname) + 1);
}
varbuf_add_str(symlinkfn, ti->linkname);
- varbuf_add_char(symlinkfn, '\0');
+ varbuf_end_str(symlinkfn);
statr= stat(symlinkfn->buf, &newstab);
if (statr) {
@@ -739,7 +739,7 @@ tarobject(void *ctx, struct tar_entry *ti)
linknode = findnamenode(ti->linkname, 0);
if (linknode->flags & fnnf_deferred_rename)
varbuf_add_str(&hardlinkfn, DPKGNEWEXT);
- varbuf_add_char(&hardlinkfn, '\0');
+ varbuf_end_str(&hardlinkfn);
if (link(hardlinkfn.buf,fnamenewvb.buf))
ohshite(_("error creating hard link `%.255s'"), ti->name);
debug(dbg_eachfiledetail, "tarobject hardlink");
@@ -807,7 +807,7 @@ tarobject(void *ctx, struct tar_entry *ti)
ohshite(_("unable to read link `%.255s'"), ti->name);
assert(r == stab.st_size);
varbuf_trunc(&symlinkfn, r);
- varbuf_add_char(&symlinkfn, '\0');
+ varbuf_end_str(&symlinkfn);
if (symlink(symlinkfn.buf,fnametmpvb.buf))
ohshite(_("unable to make backup symlink for `%.255s'"), ti->name);
if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
@@ -1015,7 +1015,7 @@ void check_breaks(struct dependency *dep, struct pkginfo
*pkg,
return;
}
- varbuf_add_char(&why, '\0');
+ varbuf_end_str(&why);
if (fixbydeconf && f_autodeconf) {
char action[512];
@@ -1099,7 +1099,7 @@ void check_conflict(struct dependency *dep, struct
pkginfo *pkg,
continue;
if (depisok(pdep->up, &removalwhy, NULL, false))
continue;
- varbuf_add_char(&removalwhy, '\0');
+ varbuf_end_str(&removalwhy);
if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
break;
}
@@ -1116,7 +1116,7 @@ void check_conflict(struct dependency *dep, struct
pkginfo *pkg,
continue;
if (depisok(pdep->up, &removalwhy, NULL, false))
continue;
- varbuf_add_char(&removalwhy, '\0');
+ varbuf_end_str(&removalwhy);
fprintf(stderr, _("dpkg"
": may have trouble removing %s, as it provides %s
...\n"),
fixbyrm->name, providecheck->list->ed->name);
@@ -1152,7 +1152,7 @@ void check_conflict(struct dependency *dep, struct
pkginfo *pkg,
fixbyrm->clientdata->istobe = itb_normal;
}
}
- varbuf_add_char(&conflictwhy, '\0');
+ varbuf_end_str(&conflictwhy);
fprintf(stderr, _("dpkg: regarding %s containing %s:\n%s"),
pfilename, pkg->name, conflictwhy.buf);
if (!force_conflicts(dep->list))
diff --git a/src/configure.c b/src/configure.c
index e1d903c..e0e5fe5 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -88,7 +88,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct
conffile *conff)
varbuf_reset(&cdr2);
varbuf_add_str(&cdr2, cdr.buf);
- varbuf_add_char(&cdr2, '\0');
+ varbuf_end_str(&cdr2);
/* XXX: Make sure there's enough room for extensions. */
varbuf_grow(&cdr2, 50);
cdr2rest = cdr2.buf + strlen(cdr.buf);
@@ -165,9 +165,9 @@ deferred_configure_conffile(struct pkginfo *pkg, struct
conffile *conff)
if (unlink(cdr2.buf) && errno != ENOENT)
warning(_("%s: failed to remove old backup '%.250s':
%s"),
pkg->name, cdr2.buf, strerror(errno));
- cdr.used--;
+
varbuf_add_str(&cdr, DPKGDISTEXT);
- varbuf_add_char(&cdr, '\0');
+ varbuf_end_str(&cdr);
strcpy(cdr2rest, DPKGNEWEXT);
trig_file_activate(usenode, pkg);
if (rename(cdr2.buf, cdr.buf))
@@ -287,14 +287,14 @@ deferred_configure(struct pkginfo *pkg)
ok = breakses_ok(pkg, &aemsgs) ? ok : 0;
if (ok == 0) {
sincenothing = 0;
- varbuf_add_char(&aemsgs, '\0');
+ varbuf_end_str(&aemsgs);
fprintf(stderr,
_("dpkg: dependency problems prevent configuration of
%s:\n%s"),
pkg->name, aemsgs.buf);
varbuf_destroy(&aemsgs);
ohshit(_("dependency problems - leaving unconfigured"));
} else if (aemsgs.used) {
- varbuf_add_char(&aemsgs, '\0');
+ varbuf_end_str(&aemsgs);
fprintf(stderr,
_("dpkg: %s: dependency problems, but configuring
anyway as you requested:\n%s"),
pkg->name, aemsgs.buf);
@@ -381,7 +381,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in)
if (*in != '/')
varbuf_add_char(result, '/');
varbuf_add_str(result, in);
- varbuf_add_char(result, '\0');
+ varbuf_end_str(result);
loopprotect = 0;
@@ -419,7 +419,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in)
}
assert(r == stab.st_size); /* XXX: debug */
varbuf_trunc(&target, r);
- varbuf_add_char(&target, '\0');
+ varbuf_end_str(&target);
debug(dbg_conffdetail,
"conffderef readlink gave %d, '%s'",
@@ -431,7 +431,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in)
debug(dbg_conffdetail,
"conffderef readlink absolute");
} else {
- for (r = result->used - 2; r > 0 &&
result->buf[r] != '/'; r--)
+ for (r = result->used - 1; r > 0 &&
result->buf[r] != '/'; r--)
;
if (r < 0) {
warning(_("%s: conffile '%.250s'
resolves to degenerate filename\n"
@@ -448,7 +448,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in)
(int)result->used, result->buf);
}
varbuf_add_buf(result, target.buf, target.used);
- varbuf_add_char(result, '\0');
+ varbuf_end_str(result);
} else {
warning(_("%s: conffile '%.250s' is not a plain file or
symlink (= '%s')"),
pkg->name, in, result->buf);
diff --git a/src/depcon.c b/src/depcon.c
index 084e021..4c87fe6 100644
--- a/src/depcon.c
+++ b/src/depcon.c
@@ -117,7 +117,7 @@ findbreakcyclerecursive(struct pkginfo *pkg, struct
cyclesofarlink *sofar)
varbuf_add_str(&str_pkgs, " <- ");
varbuf_add_str(&str_pkgs, sol->pkg->name);
}
- varbuf_add_char(&str_pkgs, '\0');
+ varbuf_end_str(&str_pkgs);
debug(dbg_depcondetail, "findbreakcyclerecursive %s %s", pkg->name,
str_pkgs.buf);
varbuf_destroy(&str_pkgs);
@@ -199,7 +199,7 @@ void describedepcon(struct varbuf *addto, struct dependency
*dep) {
}
varbufdependency(&depstr, dep);
- varbuf_add_char(&depstr, '\0');
+ varbuf_end_str(&depstr);
varbuf_printf(addto, fmt, dep->up->name, depstr.buf);
varbuf_destroy(&depstr);
diff --git a/src/divertdb.c b/src/divertdb.c
index 5600c25..19f20cc 100644
--- a/src/divertdb.c
+++ b/src/divertdb.c
@@ -56,7 +56,7 @@ ensure_diversions(void)
varbuf_reset(&vb);
varbuf_add_str(&vb, admindir);
varbuf_add_str(&vb, "/" DIVERSIONSFILE);
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
onerr_abort++;
diff --git a/src/enquiry.c b/src/enquiry.c
index 5f2573e..f94f54d 100644
--- a/src/enquiry.c
+++ b/src/enquiry.c
@@ -406,7 +406,7 @@ void predeppackage(const char *const *argv) {
if (!pkg) {
varbuf_reset(&vb);
describedepcon(&vb,dep);
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
fprintf(stderr, _("dpkg: cannot see how to satisfy pre-dependency:\n
%s\n"),vb.buf);
ohshit(_("cannot satisfy pre-dependencies for %.250s (wanted due to
%.250s)"),
dep->up->name,startpkg->name);
diff --git a/src/filesdb.c b/src/filesdb.c
index 7382f72..f5388fe 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -470,7 +470,7 @@ write_filelist_except(struct pkginfo *pkg, struct
fileinlist *list,
varbuf_reset(&newvb);
varbuf_add_str(&newvb, listfile);
varbuf_add_str(&newvb, NEWDBEXT);
- varbuf_add_char(&newvb, '\0');
+ varbuf_end_str(&newvb);
file= fopen(newvb.buf,"w+");
if (!file)
diff --git a/src/help.c b/src/help.c
index 551592a..f232891 100644
--- a/src/help.c
+++ b/src/help.c
@@ -120,7 +120,7 @@ void checkpath(void) {
if (path_len)
varbuf_add_char(&filename, '/');
varbuf_add_str(&filename, *prog);
- varbuf_add_char(&filename, '\0');
+ varbuf_end_str(&filename);
if (stat(filename.buf, &stab) == 0 && (stab.st_mode & 0111))
break;
@@ -198,7 +198,7 @@ preexecscript(struct command *cmd)
varbuf_add_char(&args, ' ');
varbuf_add_str(&args, *argv);
}
- varbuf_add_char(&args, '\0');
+ varbuf_end_str(&args);
debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename, args.buf);
varbuf_destroy(&args);
}
diff --git a/src/main.c b/src/main.c
index 8c82692..3096174 100644
--- a/src/main.c
+++ b/src/main.c
@@ -670,11 +670,11 @@ void commandfd(const char *const *argv) {
} while (c != EOF && c != '\n');
if (c == EOF) ohshit(_("unexpected eof before end of line %d"),lno);
if (!argc) continue;
- varbuf_add_char(&linevb, '\0');
+ varbuf_end_str(&linevb);
newargs = m_realloc(newargs, sizeof(const char *) * (argc + 1));
argc= 1;
ptr= linevb.buf;
- endptr= ptr + linevb.used;
+ endptr = ptr + linevb.used + 1;
skipchar = false;
while(ptr < endptr) {
if (skipchar) {
diff --git a/src/packages.c b/src/packages.c
index 8f0243c..bb6b2e4 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -467,7 +467,7 @@ breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok,
if (virtbroken && ignore_depends(virtbroken)) return;
varbufdependency(&depmsg, breaks->up);
- varbuf_add_char(&depmsg, '\0');
+ varbuf_end_str(&depmsg);
varbuf_printf(aemsgs, _(" %s (%s) breaks %s and is %s.\n"), breaker->name,
versiondescribe(&breaker->installed.version, vdew_nonambig),
depmsg.buf, gettext(statusstrings[breaker->status]));
@@ -597,8 +597,8 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo
*removing,
if (interestingwarnings) {
/* Don't print the line about the package to be removed if
* that's the only line. */
+ varbuf_end_str(&oemsgs);
varbuf_add_str(aemsgs, _("; however:\n"));
- varbuf_add_char(&oemsgs, '\0');
varbuf_add_str(aemsgs, oemsgs.buf);
} else {
varbuf_add_str(aemsgs, ".\n");
diff --git a/src/processarc.c b/src/processarc.c
index a8c9323..3892ac7 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -353,7 +353,7 @@ void process_archive(const char *filename) {
break;
case dep_predepends:
if (!depisok(dsearch, &depprobwhy, NULL, true)) {
- varbuf_add_char(&depprobwhy, '\0');
+ varbuf_end_str(&depprobwhy);
fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency
problem:\n%s"),
pfilename, pkg->name, depprobwhy.buf);
if (!force_depends(dsearch->list))
@@ -732,7 +732,7 @@ void process_archive(const char *filename) {
varbuf_trunc(&fnamevb, fnameidlu);
varbuf_add_str(&fnamevb, usenode->name);
- varbuf_add_char(&fnamevb, '\0');
+ varbuf_end_str(&fnamevb);
if (!stat(namenode->name,&stab) && S_ISDIR(stab.st_mode)) {
debug(dbg_eachfiledetail, "process_archive: %s is a directory",
@@ -791,7 +791,7 @@ void process_archive(const char *filename) {
varbuf_add_str(&cfilename, instdir);
varbuf_add_char(&cfilename, '/');
varbuf_add_str(&cfilename, cfile->namenode->name);
- varbuf_add_char(&cfilename, '\0');
+ varbuf_end_str(&cfilename);
if (lstat(cfilename.buf, &tmp_stat) == 0) {
cfile->namenode->filestat = nfmalloc(sizeof(struct stat));
@@ -877,7 +877,7 @@ void process_archive(const char *filename) {
varbuf_reset(&infofnvb);
varbuf_add_str(&infofnvb, pkgadmindir());
infodirlen= infofnvb.used;
- varbuf_add_char(&infofnvb, '\0');
+ varbuf_end_str(&infofnvb);
dsd= opendir(infofnvb.buf);
if (!dsd) ohshite(_("cannot read info directory"));
push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
@@ -906,7 +906,7 @@ void process_archive(const char *filename) {
de->d_name);
varbuf_trunc(&infofnvb, infodirlen);
varbuf_add_str(&infofnvb, de->d_name);
- varbuf_add_char(&infofnvb, '\0');
+ varbuf_end_str(&infofnvb);
strcpy(cidirrest,p);
/* We keep files to rename in a list as doing the rename immediately
@@ -1108,7 +1108,7 @@ void process_archive(const char *filename) {
pdep->up->type != dep_recommends) continue;
if (depisok(pdep->up, &depprobwhy, NULL, false))
continue;
- varbuf_add_char(&depprobwhy, '\0');
+ varbuf_end_str(&depprobwhy);
debug(dbg_veryverbose,"process_archive cannot disappear:
%s",depprobwhy.buf);
break;
}
@@ -1126,7 +1126,7 @@ void process_archive(const char *filename) {
continue;
if (depisok(pdep->up, &depprobwhy, NULL, false))
continue;
- varbuf_add_char(&depprobwhy, '\0');
+ varbuf_end_str(&depprobwhy);
debug(dbg_veryverbose,"process_archive cannot disappear (provides
%s): %s",
providecheck->list->ed->name, depprobwhy.buf);
goto break_from_both_loops_at_once;
@@ -1156,7 +1156,7 @@ void process_archive(const char *filename) {
varbuf_reset(&fnvb);
varbuf_add_str(&fnvb, pkgadmindir());
infodirbaseused= fnvb.used;
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
@@ -1171,7 +1171,7 @@ void process_archive(const char *filename) {
debug(dbg_stupidlyverbose, "process_archive info this pkg");
varbuf_trunc(&fnvb, infodirbaseused);
varbuf_add_str(&fnvb, de->d_name);
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
if (unlink(fnvb.buf))
ohshite(_("unable to delete disappearing control info file
`%.250s'"),fnvb.buf);
debug(dbg_scripts, "process_archive info unlinked %s",fnvb.buf);
@@ -1267,7 +1267,7 @@ void process_archive(const char *filename) {
varbuf_trunc(&fnametmpvb, fnameidlu);
varbuf_add_str(&fnametmpvb, namenodetouse(cfile->namenode, pkg)->name);
varbuf_add_str(&fnametmpvb, DPKGTEMPEXT);
- varbuf_add_char(&fnametmpvb, '\0');
+ varbuf_end_str(&fnametmpvb);
ensure_pathname_nonexisting(fnametmpvb.buf);
}
diff --git a/src/querycmd.c b/src/querycmd.c
index 07aa84d..a3cc078 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -313,7 +313,7 @@ searchfiles(const char *const *argv)
if (!strpbrk(thisarg, "*[?\\")) {
varbuf_reset(&path);
varbuf_add_str(&path, thisarg);
- varbuf_add_char(&path, '\0');
+ varbuf_end_str(&path);
varbuf_trunc(&path, path_trim_slash_slashdot(path.buf));
@@ -325,7 +325,7 @@ searchfiles(const char *const *argv)
varbuf_add_char(&vb, '*');
varbuf_add_str(&vb, thisarg);
varbuf_add_char(&vb, '*');
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
thisarg= vb.buf;
}
if (!strpbrk(thisarg, "*[?\\")) {
@@ -547,7 +547,7 @@ control_path_pkg(struct pkginfo *pkg)
varbuf_init(&db_path, 0);
varbuf_add_str(&db_path, pkgadmindir());
db_path_len = db_path.used;
- varbuf_add_char(&db_path, '\0');
+ varbuf_end_str(&db_path);
db_dir = opendir(db_path.buf);
if (!db_dir)
@@ -584,7 +584,7 @@ control_path_pkg(struct pkginfo *pkg)
varbuf_trunc(&db_path, db_path_len);
varbuf_add_str(&db_path, db_de->d_name);
- varbuf_add_char(&db_path, '\0');
+ varbuf_end_str(&db_path);
printf("%s\n", db_path.buf);
}
diff --git a/src/remove.c b/src/remove.c
index d618c5f..fcf1fe6 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -122,13 +122,13 @@ void deferred_remove(struct pkginfo *pkg) {
return;
} else if (rok == 0) {
sincenothing= 0;
- varbuf_add_char(&raemsgs, '\0');
+ varbuf_end_str(&raemsgs);
fprintf(stderr,
_("dpkg: dependency problems prevent removal of %s:\n%s"),
pkg->name, raemsgs.buf);
ohshit(_("dependency problems - not removing"));
} else if (raemsgs.used) {
- varbuf_add_char(&raemsgs, '\0');
+ varbuf_end_str(&raemsgs);
fprintf(stderr,
_("dpkg: %s: dependency problems, but removing anyway as you
requested:\n%s"),
pkg->name, raemsgs.buf);
@@ -221,19 +221,19 @@ removal_bulk_remove_files(struct pkginfo *pkg)
before= fnvb.used;
varbuf_add_str(&fnvb, DPKGTEMPEXT);
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
debug(dbg_eachfiledetail, "removal_bulk cleaning temp `%s'", fnvb.buf);
ensure_pathname_nonexisting(fnvb.buf);
varbuf_trunc(&fnvb, before);
varbuf_add_str(&fnvb, DPKGNEWEXT);
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
debug(dbg_eachfiledetail, "removal_bulk cleaning new `%s'", fnvb.buf);
ensure_pathname_nonexisting(fnvb.buf);
varbuf_trunc(&fnvb, before);
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
if (!stat(fnvb.buf,&stab) && S_ISDIR(stab.st_mode)) {
debug(dbg_eachfiledetail, "removal_bulk is a directory");
/* Only delete a directory or a link to one if we're the only
@@ -275,7 +275,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
varbuf_reset(&fnvb);
varbuf_add_str(&fnvb, pkgadmindir());
infodirbaseused= fnvb.used;
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
@@ -298,7 +298,7 @@ removal_bulk_remove_files(struct pkginfo *pkg)
debug(dbg_stupidlyverbose, "removal_bulk info not postrm or list");
varbuf_trunc(&fnvb, infodirbaseused);
varbuf_add_str(&fnvb, de->d_name);
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
if (unlink(fnvb.buf))
ohshite(_("unable to delete control info file `%.250s'"),fnvb.buf);
debug(dbg_scripts, "removal_bulk info unlinked %s",fnvb.buf);
@@ -343,7 +343,7 @@ static void removal_bulk_remove_leftover_dirs(struct
pkginfo *pkg) {
varbuf_reset(&fnvb);
varbuf_add_str(&fnvb, instdir);
varbuf_add_str(&fnvb, usenode->name);
- varbuf_add_char(&fnvb, '\0');
+ varbuf_end_str(&fnvb);
if (!stat(fnvb.buf,&stab) && S_ISDIR(stab.st_mode)) {
debug(dbg_eachfiledetail, "removal_bulk is a directory");
@@ -447,7 +447,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo
*pkg) {
debug(dbg_conffdetail, "removal_bulk conffile `%s' (= `%s')",
conff->name, r == -1 ? "<r==-1>" : fnvb.buf);
if (r == -1) continue;
- conffnameused= fnvb.used-1;
+ conffnameused = fnvb.used;
if (unlink(fnvb.buf) && errno != ENOENT && errno != ENOTDIR)
ohshite(_("cannot remove old config file `%.250s' (= `%.250s')"),
conff->name, fnvb.buf);
@@ -457,7 +457,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo
*pkg) {
varbuf_add_str(&removevb, fnvb.buf);
varbuf_add_char(&removevb, '/');
removevbbase= removevb.used;
- varbuf_add_char(&removevb, '\0');
+ varbuf_end_str(&removevb);
dsd= opendir(removevb.buf);
if (!dsd) {
int e=errno;
@@ -496,7 +496,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo
*pkg) {
yes_remove:
varbuf_trunc(&removevb, removevbbase);
varbuf_add_str(&removevb, de->d_name);
- varbuf_add_char(&removevb, '\0');
+ varbuf_end_str(&removevb);
debug(dbg_conffdetail, "removal_bulk conffile dsd entry removing `%s'",
removevb.buf);
if (unlink(removevb.buf) && errno != ENOENT && errno != ENOTDIR)
diff --git a/src/select.c b/src/select.c
index a23e2ff..8be05f4 100644
--- a/src/select.c
+++ b/src/select.c
@@ -109,7 +109,7 @@ void setselections(const char *const *argv) {
if (c == EOF) ohshit(_("unexpected eof in package name at line %d"),lno);
if (c == '\n') ohshit(_("unexpected end of line in package name at line
%d"),lno);
}
- varbuf_add_char(&namevb, '\0');
+ varbuf_end_str(&namevb);
while (c != EOF && isspace(c)) {
c= getchar();
@@ -122,7 +122,7 @@ void setselections(const char *const *argv) {
varbuf_add_char(&selvb, c);
c= getchar();
}
- varbuf_add_char(&selvb, '\0');
+ varbuf_end_str(&selvb);
while (c != EOF && c != '\n') {
c= getchar();
diff --git a/src/statdb.c b/src/statdb.c
index 8ae1208..0dc217d 100644
--- a/src/statdb.c
+++ b/src/statdb.c
@@ -119,7 +119,7 @@ ensure_statoverrides(void)
varbuf_reset(&vb);
varbuf_add_str(&vb, admindir);
varbuf_add_str(&vb, "/" STATOVERRIDEFILE);
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
onerr_abort++;
diff --git a/src/trigproc.c b/src/trigproc.c
index 224cb51..07bf346 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -317,7 +317,7 @@ trigproc(struct pkginfo *pkg)
varbuf_add_char(&namesarg, ' ');
varbuf_add_str(&namesarg, tp->name);
}
- varbuf_add_char(&namesarg, '\0');
+ varbuf_end_str(&namesarg);
/* Setting the status to half-configured
* causes modstatdb_note to clear pending triggers. */
diff --git a/src/update.c b/src/update.c
index 08b1f9f..5e41557 100644
--- a/src/update.c
+++ b/src/update.c
@@ -76,7 +76,7 @@ void updateavailable(const char *const *argv) {
varbuf_add_str(&vb, admindir);
varbuf_add_str(&vb, "/" AVAILFILE);
- varbuf_add_char(&vb, '\0');
+ varbuf_end_str(&vb);
if (cipaction->arg_int == act_avmerge)
parsedb(vb.buf, pdb_recordavailable | pdb_rejectstatus | pdb_lax_parser,
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]