From: Guillem Jover Date: Sat, 28 Jun 2008 13:12:16 +0000 (+0300) Subject: libdpkg: Remove unused file argument from parseerr and parsemustfield X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c187f8f58691d3216656f553d47985b2d8a6cf;p=dpkg libdpkg: Remove unused file argument from parseerr and parsemustfield --- diff --git a/ChangeLog b/ChangeLog index 979cc149..191f69b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-28 Guillem Jover + + * lib/parsedump.h (parseerr, parsemustfield): Remove unused 'file' + argument. Fix all callers. + * lib/parsehelp.c (parseerr): Remove checks on 'file'. + 2008-06-28 Tollef Fog Heen * src/archives.c (tarobject): Refactor tarfile object skipping to ... diff --git a/lib/fields.c b/lib/fields.c index fb90a12f..01e114e4 100644 --- a/lib/fields.c +++ b/lib/fields.c @@ -42,7 +42,8 @@ static int convert_string memcpy(&nvip,&ivip,sizeof(struct namevalue *)); ep= startp; - if (!*ep) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("%s is missing"),what); + if (!*ep) + parseerr(filename, lno, warnto, warncount, pigp, 0, _("%s is missing"), what); while (nvip->name) { if ((l= nvip->length) == 0) { l= strlen(nvip->name); @@ -55,14 +56,14 @@ static int convert_string } if (!nvip->name) { if (otherwise != -1) return otherwise; - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%.*s' is not allowed for %s"), + parseerr(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(NULL,filename,lno, warnto,warncount,pigp,0, _("junk after %s"),what); + parseerr(filename, lno, warnto, warncount, pigp, 0, _("junk after %s"), what); if (endpp) *endpp= ep; return nvip->value; } @@ -72,7 +73,7 @@ void f_name(struct pkginfo *pigp, struct pkginfoperfile *pifp, enum parsedbflags const char *value, const struct fieldinfo *fip) { const char *e; if ((e= illegal_packagename(value,NULL)) != NULL) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("invalid package name (%.250s)"),e); + parseerr(filename, lno, warnto, warncount, pigp, 0, _("invalid package name (%.250s)"), e); pigp->name= findpackage(value)->name; /* We use the new name, as findpackage() may have done a tolower for us. @@ -88,10 +89,10 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp, int allowextend; if (!*value) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(filename, lno, warnto, warncount, pigp, 0, _("empty file details field `%s'"),fip->name); if (!(flags & pdb_recordavailable)) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(filename, lno, warnto, warncount, pigp, 0, _("file details field `%s' not allowed in status file"),fip->name); allowextend= !pigp->files; fdpp= &pigp->files; @@ -102,7 +103,7 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp, fdp= *fdpp; if (!fdp) { if (!allowextend) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("too many values " + parseerr(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= NULL; @@ -115,7 +116,7 @@ void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp, cpos= space; } if (*fdpp) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("too few values " + parseerr(filename, lno, warnto, warncount, pigp, 0, _("too few values " "in file details field `%s' (compared to others)"),fip->name); } @@ -163,7 +164,7 @@ void f_status(struct pkginfo *pigp, struct pkginfoperfile *pifp, const char *ep; if (flags & pdb_rejectstatus) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(filename, lno, warnto, warncount, pigp, 0, _("value for `status' field not allowed in this context")); if (flags & pdb_recordavailable) return; @@ -188,7 +189,7 @@ void f_version(struct pkginfo *pigp, struct pkginfoperfile *pifp, const char *emsg; emsg= parseversion(&pifp->version,value); - if (emsg) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("error " + if (emsg) parseerr(filename, lno, warnto, warncount, pigp, 0, _("error " "in Version string `%.250s': %.250s"),value,emsg); } @@ -198,7 +199,7 @@ void f_revision(struct pkginfo *pigp, struct pkginfoperfile *pifp, const char *value, const struct fieldinfo *fip) { char *newversion; - parseerr(NULL,filename,lno, warnto,warncount,pigp,1, + parseerr(filename, lno, warnto, warncount, pigp, 1, _("obsolete `Revision' or `Package-Revision' field used")); if (!*value) return; if (pifp->version.revision && *pifp->version.revision) { @@ -216,12 +217,12 @@ void f_configversion(struct pkginfo *pigp, struct pkginfoperfile *pifp, const char *emsg; if (flags & pdb_rejectstatus) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(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(NULL,filename,lno, warnto,warncount,pigp,0, _("error " + if (emsg) parseerr(filename, lno, warnto, warncount, pigp, 0, _("error " "in Config-Version string `%.250s': %.250s"),value,emsg); } @@ -245,7 +246,7 @@ static void conffvalue_lastword(const char *value, const char *from, return; malformed: - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(filename, lno, warnto, warncount, pigp, 0, _("value for `conffiles' has malformatted line `%.*s'"), (int)(endent-value > 250 ? 250 : endent-value), value); } @@ -264,7 +265,7 @@ void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp, while (*value) { c= *value++; if (c == '\n') continue; - if (c != ' ') parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("value for" + if (c != ' ') parseerr(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++); conffvalue_lastword(value, endent, endent, @@ -279,7 +280,7 @@ void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp, newlink= nfmalloc(sizeof(struct conffile)); value= skip_slash_dotslash(value); namelen= (int)(endfn-value); - if (namelen <= 0) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + if (namelen <= 0) parseerr(filename, lno, warnto, warncount, pigp, 0, _("root or null directory is listed as a conffile")); newptr = nfmalloc(namelen+2); newptr[0]= '/'; @@ -336,10 +337,10 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, strncpy(depname, depnamestart, depnamelength); *(depname + depnamelength)= 0; if (!*depname) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%s' field, missing" + parseerr(filename, lno, warnto, warncount, pigp, 0, _("`%s' field, missing" " package name, or garbage where package name expected"), fip->name); emsg= illegal_packagename(depname,NULL); - if (emsg) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%s' field," + if (emsg) parseerr(filename, lno, warnto, warncount, pigp, 0, _("`%s' field," " invalid package name `%.255s': %s"), fip->name,depname,emsg); dop= nfmalloc(sizeof(struct deppossi)); @@ -369,13 +370,13 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, dop->verrel |= (dvrf_strict | dvrf_builtup); p++; } else if (c2 == '<' || c2 == '>') { - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(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(NULL,filename,lno, warnto,warncount,pigp,1, + parseerr(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); @@ -385,18 +386,18 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, dop->verrel= dvr_exact; p++; } else { - parseerr(NULL,filename,lno, warnto,warncount,pigp,1, + parseerr(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(NULL,filename,lno,warnto,warncount,pigp,1, + parseerr(filename, lno, warnto, warncount, pigp, 1, _("Only exact versions may be used for Provides")); if (!isspace(*p) && !isalnum(*p)) { - parseerr(NULL,filename,lno, warnto,warncount,pigp,1, + parseerr(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); @@ -411,13 +412,13 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, } versionlength= p - versionstart; while (isspace(*p)) p++; - if (*p == '(') parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + if (*p == '(') parseerr(filename, lno, warnto, warncount, pigp, 0, _("`%s' field, reference to `%.255s': " "version contains `%c'"), fip->name,depname, ')'); - else if (*p != ')') parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + else if (*p != ')') parseerr(filename, lno, warnto, warncount, pigp, 0, _("`%s' field, reference to `%.255s': " "version contains `%c'"), fip->name,depname, ' '); - else if (*p == 0) parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + else if (*p == 0) parseerr(filename, lno, warnto, warncount, pigp, 0, _("`%s' field, reference to `%.255s': " "version unterminated"),fip->name,depname); if (versionlength >= versionused) { @@ -427,7 +428,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(NULL,filename,lno, warnto,warncount,pigp,0, + if (emsg) parseerr(filename, lno, warnto, warncount, pigp, 0, _("`%s' field, reference to `%.255s': " "error in version: %.255s"),fip->name,depname,emsg); p++; while (isspace(*p)) p++; @@ -437,14 +438,14 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp, } if (!*p || *p == ',') break; if (*p != '|') - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, _("`%s' field, syntax" + parseerr(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_breaks || fip->integer == dep_provides || fip->integer == dep_replaces) - parseerr(NULL,filename,lno, warnto,warncount,pigp,0, + parseerr(filename, lno, warnto, warncount, pigp, 0, _("alternatives (`|') not allowed in %s field"), fip->name); p++; while (isspace(*p)) p++; @@ -505,17 +506,17 @@ f_trigpend(struct pkginfo *pend, struct pkginfoperfile *pifp, const char *word, *emsg; if (flags & pdb_rejectstatus) - parseerr(NULL, filename, lno, warnto, warncount, pend, 0, + parseerr(filename, lno, warnto, warncount, pend, 0, _("value for `triggers-pending' field not allowed in this context")); while ((word = scan_word(&value))) { emsg = illegal_triggername(word); if (emsg) - parseerr(NULL, filename, lno, warnto, warncount, pend, 0, + parseerr(filename, lno, warnto, warncount, pend, 0, _("illegal pending trigger name `%.255s': %s"), word, emsg); if (!trig_note_pend_core(pend, nfstrsave(word))) - parseerr(NULL, filename, lno, warnto, warncount, pend, 0, + parseerr(filename, lno, warnto, warncount, pend, 0, _("duplicate pending trigger `%.255s'"), word); } } @@ -530,19 +531,19 @@ f_trigaw(struct pkginfo *aw, struct pkginfoperfile *pifp, struct pkginfo *pend; if (flags & pdb_rejectstatus) - parseerr(NULL, filename, lno, warnto, warncount, aw, 0, + parseerr(filename, lno, warnto, warncount, aw, 0, _("value for `triggers-awaited' field not allowed in this context")); while ((word = scan_word(&value))) { emsg = illegal_packagename(word, NULL); if (emsg) - parseerr(NULL, filename, lno, warnto, warncount, aw, 0, + parseerr(filename, lno, warnto, warncount, aw, 0, _("illegal package name in awaited trigger `%.255s': %s"), word, emsg); pend = findpackage(word); if (!trig_note_aw(pend, aw)) - parseerr(NULL, filename, lno, warnto, warncount, aw, 0, + parseerr(filename, lno, warnto, warncount, aw, 0, _("duplicate awaited trigger package `%.255s'"), word); } } diff --git a/lib/parse.c b/lib/parse.c index 6d982bb8..80badee1 100644 --- a/lib/parse.c +++ b/lib/parse.c @@ -151,16 +151,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(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("EOF after field name `%.*s'"),fieldlen,fieldstart); if (c == '\n') - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("newline in field name `%.*s'"),fieldlen,fieldstart); if (c == MSDOS_EOF_CHAR) - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("MSDOS EOF (^Z) in field name `%.*s'"),fieldlen,fieldstart); if (c != ':') - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("field name `%.*s' must be followed by colon"),fieldlen,fieldstart); /* Skip space after ':' but before value and eol */ while(!EOF_mmap(dataptr, endptr)) { @@ -168,11 +168,11 @@ int parsedb(const char *filename, enum parsedbflags flags, if (c == '\n' || !isspace(c)) break; } if (EOF_mmap(dataptr, endptr)) - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("EOF before value of field `%.*s' (missing final newline)"), fieldlen,fieldstart); if (c == MSDOS_EOF_CHAR) - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("MSDOS EOF char in value of field `%.*s' (missing newline?)"), fieldlen,fieldstart); valuestart= dataptr - 1; @@ -186,7 +186,7 @@ int parsedb(const char *filename, enum parsedbflags flags, ungetc_mmap(c,dataptr, data); c= '\n'; } else if (EOF_mmap(dataptr, endptr)) { - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("EOF during value of field `%.*s' (missing final newline)"), fieldlen,fieldstart); } @@ -209,17 +209,17 @@ int parsedb(const char *filename, enum parsedbflags flags, memcpy(value,valuestart,valuelen); *(value+valuelen)= 0; if (*ip++) - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(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(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("user-defined field name `%.*s' too short"), fieldlen,fieldstart); larpp= &newpifp->arbs; while ((arp= *larpp) != NULL) { if (!strncasecmp(arp->name,fieldstart,fieldlen)) - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("duplicate value for user-defined field `%.*s'"), fieldlen,fieldstart); larpp= &arp->next; } @@ -232,21 +232,21 @@ int parsedb(const char *filename, enum parsedbflags flags, if (EOF_mmap(dataptr, endptr) || c == '\n' || c == MSDOS_EOF_CHAR) break; } /* loop per field */ if (pdone && donep) - parseerr(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("several package info entries found, only one allowed")); - parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,0, + parsemustfield(filename, lno, warnto, warncount, &newpig, 0, &newpig.name, "package name"); if ((flags & pdb_recordavailable) || newpig.status != stat_notinstalled) { - parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,1, + parsemustfield(filename, lno, warnto, warncount, &newpig, 1, (const char **)&newpifp->description, "description"); - parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,1, + parsemustfield(filename, lno, warnto, warncount, &newpig, 1, (const char **)&newpifp->maintainer, "maintainer"); if (newpig.status != stat_halfinstalled) - parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,0, + parsemustfield(filename, lno, warnto, warncount, &newpig, 0, &newpifp->version.version, "version"); } if (flags & pdb_recordavailable) - parsemustfield(NULL,filename,lno, warnto,warncount,&newpig,1, + parsemustfield(filename, lno, warnto, warncount, &newpig, 1, (const char **)&newpifp->architecture, "architecture"); /* Check the Config-Version information: @@ -258,7 +258,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(NULL,filename,lno, warnto,warncount,&newpig,0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("Configured-Version for package with inappropriate Status")); } else { if (newpig.status == stat_installed) newpig.configversion= newpifp->version; @@ -268,21 +268,21 @@ int parsedb(const char *filename, enum parsedbflags flags, if (newpig.trigaw.head && (newpig.status <= stat_configfiles || newpig.status >= stat_triggerspending)) - parseerr(NULL, filename, lno, warnto, warncount, &newpig, 0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("package has status %s but triggers are awaited"), statusinfos[newpig.status].name); else if (newpig.status == stat_triggersawaited && !newpig.trigaw.head) - parseerr(NULL, filename, lno, warnto, warncount, &newpig, 0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("package has status triggers-awaited but no triggers awaited")); if (!(newpig.status == stat_triggerspending || newpig.status == stat_triggersawaited) && newpig.trigpend_head) - parseerr(NULL, filename, lno, warnto, warncount, &newpig, 0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("package has status %s but triggers are pending"), statusinfos[newpig.status].name); else if (newpig.status == stat_triggerspending && !newpig.trigpend_head) - parseerr(NULL, filename, lno, warnto, warncount, &newpig, 0, + parseerr(filename, lno, warnto, warncount, &newpig, 0, _("package has status triggers-pending but no triggers pending")); /* There was a bug that could make a not-installed package have @@ -292,7 +292,7 @@ int parsedb(const char *filename, enum parsedbflags flags, if (!(flags & pdb_recordavailable) && newpig.status == stat_notinstalled && newpifp->conffiles) { - parseerr(NULL,filename,lno, warnto,warncount,&newpig,1, + parseerr(filename, lno, warnto, warncount, &newpig, 1, _("Package which in state not-installed has conffiles, forgetting them")); newpifp->conffiles= NULL; } diff --git a/lib/parsedump.h b/lib/parsedump.h index 43470f2d..8837bbd9 100644 --- a/lib/parsedump.h +++ b/lib/parsedump.h @@ -59,10 +59,10 @@ struct fieldinfo { size_t integer; }; -void parseerr(FILE *file, const char *filename, int lno, FILE *warnto, int *warncount, +void parseerr(const char *filename, int lno, FILE *warnto, int *warncount, const struct pkginfo *pigp, int warnonly, - const char *fmt, ...) PRINTFFORMAT(8,9); -void parsemustfield(FILE *file, const char *filename, int lno, + const char *fmt, ...) PRINTFFORMAT(7,8); +void parsemustfield(const char *filename, int lno, FILE *warnto, int *warncount, const struct pkginfo *pigp, int warnonly, const char **value, const char *what); diff --git a/lib/parsehelp.c b/lib/parsehelp.c index 3b6a4bff..0623dbd7 100644 --- a/lib/parsehelp.c +++ b/lib/parsehelp.c @@ -29,13 +29,12 @@ #include "parsedump.h" void parseerr -(FILE *file, const char *filename, int lno, FILE *warnto, int *warncount, +(const char *filename, int lno, FILE *warnto, int *warncount, const struct pkginfo *pigp, int warnonly, const char *fmt, ...) { va_list al; char buf1[768], buf2[1000], *p, *q; - if (file && ferror(file)) ohshite(_("failed to read `%s' at line %d"),filename,lno); if (warnonly) sprintf(buf1, _("warning, in file `%.255s' near line %d"), @@ -230,17 +229,17 @@ const char *parseversion(struct versionrevision *rversion, const char *string) { } void parsemustfield -(FILE *file, const char *filename, int lno, +(const char *filename, int lno, FILE *warnto, int *warncount, const struct pkginfo *pigp, int warnonly, const char **value, const char *what) { static const char *empty = ""; if (!*value) { - parseerr(file,filename,lno, warnto,warncount,pigp,warnonly, _("missing %s"),what); + parseerr(filename, lno, warnto, warncount, pigp, warnonly, _("missing %s"), what); *value= empty; } else if (!**value) { - parseerr(file,filename,lno, warnto,warncount,pigp,warnonly, + parseerr(filename, lno, warnto, warncount, pigp, warnonly, _("empty value for %s"),what); } }