summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog2
-rw-r--r--dpkg-deb/build.c4
-rw-r--r--dpkg-deb/info.c4
-rw-r--r--dpkg-split/info.c5
-rw-r--r--dpkg-split/split.c10
-rw-r--r--dselect/baselist.cc5
-rw-r--r--dselect/methparse.cc26
-rw-r--r--dselect/pkgtop.cc4
-rw-r--r--lib/dpkg/arch.c6
-rw-r--r--lib/dpkg/dbmodify.c5
-rw-r--r--lib/dpkg/deb-version.c5
-rw-r--r--lib/dpkg/fields.c49
-rw-r--r--lib/dpkg/options.c9
-rw-r--r--lib/dpkg/parse.c14
-rw-r--r--lib/dpkg/parsehelp.c19
-rw-r--r--lib/dpkg/pkg-db.c7
-rw-r--r--lib/dpkg/string.c3
-rw-r--r--lib/dpkg/triglib.c9
-rw-r--r--lib/dpkg/version.c14
-rw-r--r--src/main.c12
-rw-r--r--src/remove.c5
-rw-r--r--src/select.c16
-rw-r--r--src/unpack.c4
23 files changed, 139 insertions, 98 deletions
diff --git a/debian/changelog b/debian/changelog
index 49b771535..36da28881 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
* Document dpkg-query --search behavior in man page. Closes: #775379
* Document postinst “triggered” argument in debian/dpkg.postinst comment
header.
+ * Switch C/C++ code to use a new set of C locale character type functions
+ independent of the current locale.
-- Guillem Jover <guillem@debian.org> Tue, 09 Dec 2014 23:53:18 +0100
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 442298d6a..3a9eca4dc 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -29,7 +29,6 @@
#include <errno.h>
#include <limits.h>
-#include <ctype.h>
#include <string.h>
#include <dirent.h>
#include <fcntl.h>
@@ -40,6 +39,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/path.h>
@@ -302,7 +302,7 @@ check_conffiles(const char *dir)
varbuf_printf(&controlfile, "%s/%s", dir, conffilename);
if (lstat(controlfile.buf, &controlstab)) {
if (errno == ENOENT) {
- if ((n > 1) && isspace(conffilename[n - 2]))
+ if ((n > 1) && c_isspace(conffilename[n - 2]))
warning(_("conffile filename '%s' contains trailing white spaces"),
conffilename);
ohshit(_("conffile `%.250s' does not appear in package"), conffilename);
diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c
index b3a660269..9640ea4bb 100644
--- a/dpkg-deb/info.c
+++ b/dpkg-deb/info.c
@@ -28,7 +28,6 @@
#include <errno.h>
#include <limits.h>
-#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
@@ -38,6 +37,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/parsedump.h>
@@ -159,7 +159,7 @@ info_list(const char *debar, const char *dir)
if (getc(cc) == '!') {
while ((c= getc(cc))== ' ');
p=interpreter; *p++='#'; *p++='!'; il=2;
- while (il<INTERPRETER_MAX && !isspace(c) && c!=EOF) {
+ while (il < INTERPRETER_MAX && !c_isspace(c) && c != EOF) {
*p++= c; il++; c= getc(cc);
}
*p = '\0';
diff --git a/dpkg-split/info.c b/dpkg-split/info.c
index 528be881e..80f928f0b 100644
--- a/dpkg-split/info.c
+++ b/dpkg-split/info.c
@@ -26,7 +26,6 @@
#include <errno.h>
#include <limits.h>
-#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <ar.h>
@@ -36,6 +35,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/ar.h>
@@ -67,7 +67,8 @@ static char *nextline(char **ripp, const char *fn, const char *what) {
if (!newline)
ohshit(_("file `%.250s' is corrupt - missing newline after %.250s"),fn,what);
*ripp= newline+1;
- while (newline > rip && isspace(newline[-1])) newline--;
+ while (newline > rip && c_isspace(newline[-1]))
+ newline--;
*newline = '\0';
return rip;
}
diff --git a/dpkg-split/split.c b/dpkg-split/split.c
index fe4b60e2e..47b9c3ee3 100644
--- a/dpkg-split/split.c
+++ b/dpkg-split/split.c
@@ -30,7 +30,6 @@
#include <fcntl.h>
#include <libgen.h>
#include <string.h>
-#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <stdint.h>
@@ -38,6 +37,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/path.h>
@@ -86,7 +86,7 @@ deb_field(const char *filename, const char *field)
/* Trim down trailing junk. */
for (end = buf.buf + strlen(buf.buf) - 1; end - buf.buf >= 1; end--)
- if (isspace(*end))
+ if (c_isspace(*end))
*end = '\0';
else
break;
@@ -103,9 +103,9 @@ clean_msdos_filename(char *filename)
for (s = d = filename; *s; d++, s++) {
if (*s == '+')
*d = 'x';
- else if (isupper(*s))
- *d = tolower(*s);
- else if (islower(*s) || isdigit(*s))
+ else if (c_isupper(*s))
+ *d = c_tolower(*s);
+ else if (c_islower(*s) || c_isdigit(*s))
*d = *s;
else
s++;
diff --git a/dselect/baselist.cc b/dselect/baselist.cc
index acd149249..8e2f44f65 100644
--- a/dselect/baselist.cc
+++ b/dselect/baselist.cc
@@ -27,13 +27,13 @@
#include <assert.h>
#include <errno.h>
-#include <ctype.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
@@ -367,7 +367,8 @@ void baselist::wordwrapinfo(int offset, const char *m) {
int offleft=offset; while (*m == ' ' && offleft>0) { m++; offleft--; }
const char *p= strchr(m,'\n');
int l= p ? (int)(p-m) : strlen(m);
- while (l && isspace(m[l-1])) l--;
+ while (l && c_isspace(m[l - 1]))
+ l--;
if (!l || (*m == '.' && l == 1)) {
if (wrapping) waddch(infopad,'\n');
waddch(infopad, '\n');
diff --git a/dselect/methparse.cc b/dselect/methparse.cc
index c74bda2a8..ce38181c8 100644
--- a/dselect/methparse.cc
+++ b/dselect/methparse.cc
@@ -28,7 +28,6 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
-#include <ctype.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
@@ -36,6 +35,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
@@ -99,9 +99,10 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) {
c= dent->d_name[0];
debug(dbg_general, "readmethods('%s',...) considering '%s' ...",
pathbase, dent->d_name);
- if (c != '_' && !isalpha(c)) continue;
+ if (c != '_' && !c_isalpha(c))
+ continue;
char *p = dent->d_name + 1;
- while ((c = *p) != 0 && isalnum(c) && c != '_')
+ while ((c = *p) != 0 && c_isalnum(c) && c != '_')
p++;
if (c) continue;
methodlen= strlen(dent->d_name);
@@ -142,16 +143,18 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) {
pathbase, meth->name, meth->path, meth->pathinmeth);
while ((c= fgetc(names)) != EOF) {
- if (isspace(c)) continue;
+ if (c_isspace(c))
+ continue;
opt= new dselect_option;
opt->meth= meth;
vb.reset();
do {
- if (!isdigit(c)) badmethod(pathbuf,_("non-digit where digit wanted"));
+ if (!c_isdigit(c))
+ badmethod(pathbuf, _("non-digit where digit wanted"));
vb(c);
c= fgetc(names);
if (c == EOF) eofmethod(pathbuf,names,_("EOF in index string"));
- } while (!isspace(c));
+ } while (!c_isspace(c));
if (strlen(vb.string()) > OPTIONINDEXMAXLEN)
badmethod(pathbuf,_("index string too long"));
strcpy(opt->index,vb.string());
@@ -159,23 +162,24 @@ void readmethods(const char *pathbase, dselect_option **optionspp, int *nread) {
if (c == '\n') badmethod(pathbuf,_("newline before option name start"));
c= fgetc(names);
if (c == EOF) eofmethod(pathbuf,names,_("EOF before option name start"));
- } while (isspace(c));
+ } while (c_isspace(c));
vb.reset();
- if (!isalpha(c) && c != '_')
+ if (!c_isalpha(c) && c != '_')
badmethod(pathbuf,_("nonalpha where option name start wanted"));
do {
- if (!isalnum(c) && c != '_') badmethod(pathbuf,_("non-alphanum in option name"));
+ if (!c_isalnum(c) && c != '_')
+ badmethod(pathbuf, _("non-alphanum in option name"));
vb(c);
c= fgetc(names);
if (c == EOF) eofmethod(pathbuf,names,_("EOF in option name"));
- } while (!isspace(c));
+ } while (!c_isspace(c));
opt->name= new char[strlen(vb.string())+1];
strcpy(opt->name,vb.string());
do {
if (c == '\n') badmethod(pathbuf,_("newline before summary"));
c= fgetc(names);
if (c == EOF) eofmethod(pathbuf,names,_("EOF before summary"));
- } while (isspace(c));
+ } while (c_isspace(c));
vb.reset();
do {
vb(c);
diff --git a/dselect/pkgtop.cc b/dselect/pkgtop.cc
index dde30b7f8..a940eaa5c 100644
--- a/dselect/pkgtop.cc
+++ b/dselect/pkgtop.cc
@@ -23,11 +23,11 @@
#include <compat.h>
#include <assert.h>
-#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
@@ -190,7 +190,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
for (i = col_priority.width, p = pkg->otherpriority;
i > 0 && *p;
i--, p++)
- waddch(listpad, tolower(*p));
+ waddch(listpad, c_tolower(*p));
while (i-- > 0) waddch(listpad,' ');
} else {
wprintw(listpad, "%-*.*s", col_priority.width, col_priority.width,
diff --git a/lib/dpkg/arch.c b/lib/dpkg/arch.c
index 921eda629..9aebe1d49 100644
--- a/lib/dpkg/arch.c
+++ b/lib/dpkg/arch.c
@@ -25,13 +25,13 @@
#include <assert.h>
#include <limits.h>
-#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/ehandle.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
@@ -62,10 +62,10 @@ dpkg_arch_name_is_illegal(const char *name)
assert(name);
if (!*p)
return _("may not be empty string");
- if (!isalnum(*p))
+ if (!c_isalnum(*p))
return _("must start with an alphanumeric");
while (*++p != '\0')
- if (!isalnum(*p) && *p != '-')
+ if (!c_isalnum(*p) && *p != '-')
break;
if (*p == '\0')
return NULL;
diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c
index 9acba1f69..5cff6f19f 100644
--- a/lib/dpkg/dbmodify.c
+++ b/lib/dpkg/dbmodify.c
@@ -30,7 +30,6 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
-#include <ctype.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
@@ -41,6 +40,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/file.h>
@@ -64,7 +64,8 @@ static int ulist_select(const struct dirent *de) {
const char *p;
int l;
for (p= de->d_name, l=0; *p; p++, l++)
- if (!cisdigit(*p)) return 0;
+ if (!c_isdigit(*p))
+ return 0;
if (l > IMPORTANTMAXLEN)
ohshit(_("updates directory contains file `%.250s' whose name is too long "
"(length=%d, max=%d)"), de->d_name, l, IMPORTANTMAXLEN);
diff --git a/lib/dpkg/deb-version.c b/lib/dpkg/deb-version.c
index 51079e1d0..ea53a592a 100644
--- a/lib/dpkg/deb-version.c
+++ b/lib/dpkg/deb-version.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/deb-version.h>
@@ -48,7 +49,7 @@ deb_version_parse(struct deb_version *version, const char *str)
int major = 0;
int minor = 0;
- for (end = str; *end && cisdigit(*end); end++)
+ for (end = str; *end && c_isdigit(*end); end++)
major = major * 10 + *end - '0';
if (end == str)
@@ -56,7 +57,7 @@ deb_version_parse(struct deb_version *version, const char *str)
if (*end != '.')
return _("format version has no dot");
- for (end = str_minor = end + 1; *end && cisdigit(*end); end++)
+ for (end = str_minor = end + 1; *end && c_isdigit(*end); end++)
minor = minor * 10 + *end - '0';
if (end == str_minor)
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index bbee2ab30..abbf23e96 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -26,11 +26,11 @@
#include <config.h>
#include <compat.h>
-#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/arch.h>
@@ -60,7 +60,7 @@ parse_nv_next(struct parsedb_state *ps,
str_end = NULL;
} else {
str_end = str_start + nv->length;
- while (isspace(str_end[0]))
+ while (c_isspace(str_end[0]))
str_end++;
}
*strp = str_end;
@@ -115,7 +115,9 @@ f_filecharf(struct pkginfo *pkg, struct pkgbin *pkgbin,
fdpp = &pkg->files;
cpos= nfstrsave(value);
while (*cpos) {
- space= cpos; while (*space && !isspace(*space)) space++;
+ space = cpos;
+ while (*space && !c_isspace(*space))
+ space++;
if (*space)
*space++ = '\0';
fdp= *fdpp;
@@ -131,7 +133,8 @@ f_filecharf(struct pkginfo *pkg, struct pkgbin *pkgbin,
}
STRUCTFIELD(fdp, fip->integer, const char *) = cpos;
fdpp= &fdp->next;
- while (*space && isspace(*space)) space++;
+ while (*space && c_isspace(*space))
+ space++;
cpos= space;
}
if (*fdpp)
@@ -396,7 +399,7 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
for (;;) {
depnamestart= p;
/* Skip over package name characters. */
- while (*p && !isspace(*p) && *p != ':' && *p != '(' && *p != ',' &&
+ while (*p && !c_isspace(*p) && *p != ':' && *p != '(' && *p != ',' &&
*p != '|')
p++;
depnamelength= p - depnamestart ;
@@ -437,7 +440,7 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
int archlength;
archstart = ++p;
- while (*p && !isspace(*p) && *p != '(' && *p != ',' && *p != '|')
+ while (*p && !c_isspace(*p) && *p != '(' && *p != ',' && *p != '|')
p++;
archlength = p - archstart;
if (archlength == 0)
@@ -471,11 +474,14 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
}
/* Skip whitespace after package name. */
- while (isspace(*p)) p++;
+ while (c_isspace(*p))
+ p++;
/* See if we have a versioned relation. */
if (*p == '(') {
- p++; while (isspace(*p)) p++;
+ p++;
+ while (c_isspace(*p))
+ p++;
c1= *p;
if (c1 == '<' || c1 == '>') {
c2= *++p;
@@ -515,7 +521,7 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
_("only exact versions may be used for '%s' field"),
"Provides");
- if (!isspace(*p) && !isalnum(*p)) {
+ if (!c_isspace(*p) && !c_isalnum(*p)) {
parse_warn(ps,
_("`%s' field, reference to `%.255s':\n"
" version value starts with non-alphanumeric, "
@@ -523,15 +529,18 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
fip->name, depname.buf);
}
/* Skip spaces between the relation and the version. */
- while (isspace(*p)) p++;
+ while (c_isspace(*p))
+ p++;
versionstart= p;
while (*p && *p != ')' && *p != '(') {
- if (isspace(*p)) break;
+ if (c_isspace(*p))
+ break;
p++;
}
versionlength= p - versionstart;
- while (isspace(*p)) p++;
+ while (c_isspace(*p))
+ p++;
if (*p == '(')
parse_error(ps,
_("`%s' field, reference to `%.255s': "
@@ -550,7 +559,9 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
parse_db_version(ps, &dop->version, version.buf,
_("'%s' field, reference to '%.255s': "
"error in version"), fip->name, depname.buf);
- p++; while (isspace(*p)) p++;
+ p++;
+ while (c_isspace(*p))
+ p++;
} else {
dop->verrel = DPKG_RELATION_NONE;
dpkg_version_blank(&dop->version);
@@ -566,10 +577,14 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
fip->integer == dep_replaces)
parse_error(ps,
_("alternatives (`|') not allowed in %s field"), fip->name);
- p++; while (isspace(*p)) p++;
+ p++;
+ while (c_isspace(*p))
+ p++;
}
if (!*p) break;
- p++; while (isspace(*p)) p++;
+ p++;
+ while (c_isspace(*p))
+ p++;
}
}
@@ -585,7 +600,7 @@ scan_word(const char **valp)
*valp = p;
return NULL;
}
- if (cisspace(*p)) {
+ if (c_iswhite(*p)) {
p++;
continue;
}
@@ -593,7 +608,7 @@ scan_word(const char **valp)
break;
}
for (;;) {
- if (*p && !cisspace(*p)) {
+ if (*p && !c_iswhite(*p)) {
p++;
continue;
}
diff --git a/lib/dpkg/options.c b/lib/dpkg/options.c
index 62f74ae2f..9674466d6 100644
--- a/lib/dpkg/options.c
+++ b/lib/dpkg/options.c
@@ -24,7 +24,6 @@
#include <compat.h>
#include <errno.h>
-#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <dirent.h>
@@ -32,6 +31,7 @@
#include <stdlib.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/string.h>
#include <dpkg/options.h>
@@ -92,13 +92,14 @@ dpkg_options_load_file(const char *fn, const struct cmdinfo *cmdinfos)
l=strlen(linebuf);
if (linebuf[l - 1] == '\n')
linebuf[l - 1] = '\0';
- for (opt=linebuf;isalnum(*opt)||*opt=='-';opt++) ;
+ for (opt = linebuf; c_isalnum(*opt) || *opt == '-'; opt++) ;
if (*opt == '\0')
opt=NULL;
else {
*opt++ = '\0';
if (*opt=='=') opt++;
- while (isspace(*opt)) opt++;
+ while (c_isspace(*opt))
+ opt++;
opt = str_strip_quotes(opt);
if (opt == NULL)
@@ -147,7 +148,7 @@ valid_config_filename(const struct dirent *dent)
return 0;
for (c = dent->d_name; *c; c++)
- if (!isalnum(*c) && *c != '_' && *c != '-')
+ if (!c_isalnum(*c) && *c != '_' && *c != '-')
return 0;
if (*c == '\0')
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index d70d3f00b..a2847bd6a 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -30,7 +30,6 @@
#include <assert.h>
#include <fcntl.h>
-#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
@@ -39,6 +38,7 @@
#include <dpkg/macros.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/string.h>
@@ -621,7 +621,7 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs,
/* Scan field name. */
fs->fieldstart = ps->dataptr - 1;
- while (!parse_EOF(ps) && !isspace(c) && c != ':' && c != MSDOS_EOF_CHAR)
+ while (!parse_EOF(ps) && !c_isspace(c) && c != ':' && c != MSDOS_EOF_CHAR)
c = parse_getc(ps);
fs->fieldlen = ps->dataptr - fs->fieldstart - 1;
if (fs->fieldlen == 0)
@@ -631,7 +631,7 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs,
fs->fieldlen, fs->fieldstart);
/* Skip spaces before ‘:’. */
- while (!parse_EOF(ps) && c != '\n' && isspace(c))
+ while (!parse_EOF(ps) && c != '\n' && c_isspace(c))
c = parse_getc(ps);
/* Validate ‘:’. */
@@ -653,7 +653,7 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs,
/* Skip space after ‘:’ but before value and EOL. */
while (!parse_EOF(ps)) {
c = parse_getc(ps);
- if (c == '\n' || !isspace(c))
+ if (c == '\n' || !c_isspace(c))
break;
}
if (parse_EOF(ps))
@@ -682,12 +682,12 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs,
c = parse_getc(ps);
/* Found double EOL, or start of new field. */
- if (parse_EOF(ps) || c == '\n' || !isspace(c))
+ if (parse_EOF(ps) || c == '\n' || !c_isspace(c))
break;
parse_ungetc(c, ps);
blank_line = true;
- } else if (blank_line && !isspace(c)) {
+ } else if (blank_line && !c_isspace(c)) {
blank_line = false;
}
@@ -701,7 +701,7 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs,
fs->valuelen = ps->dataptr - fs->valuestart - 1;
/* Trim ending space on value. */
- while (fs->valuelen && isspace(*(fs->valuestart + fs->valuelen - 1)))
+ while (fs->valuelen && c_isspace(*(fs->valuestart + fs->valuelen - 1)))
fs->valuelen--;
parse_field(ps, fs, parse_obj);
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index 3537de1fb..7d58659b9 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -23,13 +23,13 @@
#include <compat.h>
#include <errno.h>
-#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/string.h>
@@ -110,10 +110,11 @@ pkg_name_is_illegal(const char *p)
int c;
if (!*p) return _("may not be empty string");
- if (!isalnum(*p))
+ if (!c_isalnum(*p))
return _("must start with an alphanumeric character");
while ((c = *p++) != '\0')
- if (!isalnum(c) && !strchr(alsoallowed,c)) break;
+ if (!c_isalnum(c) && !strchr(alsoallowed, c))
+ break;
if (!c) return NULL;
snprintf(buf, sizeof(buf), _(
@@ -189,7 +190,7 @@ parseversion(struct dpkg_version *rversion, const char *string,
const char *end, *ptr;
/* Trim leading and trailing space. */
- while (*string && isblank(*string))
+ while (*string && c_isblank(*string))
string++;
if (!*string)
@@ -198,11 +199,11 @@ parseversion(struct dpkg_version *rversion, const char *string,
/* String now points to the first non-whitespace char. */
end = string;
/* Find either the end of the string, or a whitespace char. */
- while (*end && !isblank(*end))
+ while (*end && !c_isblank(*end))
end++;
/* Check for extra chars after trailing space. */
ptr = end;
- while (*ptr && isblank(*ptr))
+ while (*ptr && c_isblank(*ptr))
ptr++;
if (*ptr)
return dpkg_put_error(err, _("version string has embedded spaces"));
@@ -234,14 +235,14 @@ parseversion(struct dpkg_version *rversion, const char *string,
/* XXX: Would be faster to use something like cisversion and cisrevision. */
ptr = rversion->version;
- if (*ptr && !cisdigit(*ptr++))
+ if (*ptr && !c_isdigit(*ptr++))
return dpkg_put_warn(err, _("version number does not start with digit"));
for (; *ptr; ptr++) {
- if (!cisdigit(*ptr) && !cisalpha(*ptr) && strchr(".-+~:", *ptr) == NULL)
+ if (!c_isdigit(*ptr) && !c_isalpha(*ptr) && strchr(".-+~:", *ptr) == NULL)
return dpkg_put_warn(err, _("invalid character in version number"));
}
for (ptr = rversion->revision; *ptr; ptr++) {
- if (!cisdigit(*ptr) && !cisalpha(*ptr) && strchr(".+~", *ptr) == NULL)
+ if (!c_isdigit(*ptr) && !c_isalpha(*ptr) && strchr(".+~", *ptr) == NULL)
return dpkg_put_warn(err, _("invalid character in revision number"));
}
diff --git a/lib/dpkg/pkg-db.c b/lib/dpkg/pkg-db.c
index 77fbf190d..7ea4b66aa 100644
--- a/lib/dpkg/pkg-db.c
+++ b/lib/dpkg/pkg-db.c
@@ -25,11 +25,11 @@
#include <compat.h>
#include <assert.h>
-#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/string.h>
@@ -67,7 +67,10 @@ pkg_db_find_set(const char *inname)
char *name = m_strdup(inname), *p;
p= name;
- while(*p) { *p= tolower(*p); p++; }
+ while (*p) {
+ *p = c_tolower(*p);
+ p++;
+ }
setp = bins + (str_fnv_hash(name) % (BINS));
while (*setp && strcasecmp((*setp)->name, name))
diff --git a/lib/dpkg/string.c b/lib/dpkg/string.c
index a3b58bee3..477a04fbe 100644
--- a/lib/dpkg/string.c
+++ b/lib/dpkg/string.c
@@ -24,6 +24,7 @@
#include <string.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/string.h>
#include <dpkg/dpkg.h>
@@ -100,7 +101,7 @@ str_quote_meta(const char *src)
new_dst = dst = m_malloc(strlen(src) * 2);
while (*src) {
- if (!cisdigit(*src) && !cisalpha(*src))
+ if (!c_isdigit(*src) && !c_isalpha(*src))
*dst++ = '\\';
*dst++ = *src++;
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 65b098b68..a2e501c16 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/pkg.h>
@@ -693,19 +694,19 @@ trig_parse_ci(const char *file, trig_parse_cicb *interest,
push_cleanup(cu_closestream, ~0, NULL, 0, 1, f);
while ((l = fgets_checked(linebuf, sizeof(linebuf), f, file)) >= 0) {
- for (cmd = linebuf; cisspace(*cmd); cmd++);
+ for (cmd = linebuf; c_iswhite(*cmd); cmd++) ;
if (*cmd == '#')
continue;
- for (eol = linebuf + l; eol > cmd && cisspace(eol[-1]); eol--);
+ for (eol = linebuf + l; eol > cmd && c_iswhite(eol[-1]); eol--) ;
if (eol == cmd)
continue;
*eol = '\0';
- for (spc = cmd; *spc && !cisspace(*spc); spc++);
+ for (spc = cmd; *spc && !c_iswhite(*spc); spc++) ;
if (!*spc)
ohshit(_("triggers ci file contains unknown directive syntax"));
*spc++ = '\0';
- while (cisspace(*spc))
+ while (c_iswhite(*spc))
spc++;
if (strcmp(cmd, "interest") == 0 ||
strcmp(cmd, "interest-await") == 0) {
diff --git a/lib/dpkg/version.c b/lib/dpkg/version.c
index 909901c99..7adaa18e4 100644
--- a/lib/dpkg/version.c
+++ b/lib/dpkg/version.c
@@ -22,7 +22,7 @@
#include <config.h>
#include <compat.h>
-#include <dpkg/dpkg.h> /* cis* */
+#include <dpkg/c-ctype.h>
#include <dpkg/ehandle.h>
#include <dpkg/string.h>
#include <dpkg/version.h>
@@ -66,9 +66,9 @@ dpkg_version_is_informative(const struct dpkg_version *version)
static int
order(int c)
{
- if (cisdigit(c))
+ if (c_isdigit(c))
return 0;
- else if (cisalpha(c))
+ else if (c_isalpha(c))
return c;
else if (c == '~')
return -1;
@@ -89,7 +89,7 @@ verrevcmp(const char *a, const char *b)
while (*a || *b) {
int first_diff = 0;
- while ((*a && !cisdigit(*a)) || (*b && !cisdigit(*b))) {
+ while ((*a && !c_isdigit(*a)) || (*b && !c_isdigit(*b))) {
int ac = order(*a);
int bc = order(*b);
@@ -103,16 +103,16 @@ verrevcmp(const char *a, const char *b)
a++;
while (*b == '0')
b++;
- while (cisdigit(*a) && cisdigit(*b)) {
+ while (c_isdigit(*a) && c_isdigit(*b)) {
if (!first_diff)
first_diff = *a - *b;
a++;
b++;
}
- if (cisdigit(*a))
+ if (c_isdigit(*a))
return 1;
- if (cisdigit(*b))
+ if (c_isdigit(*b))
return -1;
if (first_diff)
return first_diff;
diff --git a/src/main.c b/src/main.c
index 4b3137c11..58f099759 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,7 +32,6 @@
#if HAVE_LOCALE_H
#include <locale.h>
#endif
-#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
@@ -43,6 +42,7 @@
#include <dpkg/macros.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/arch.h>
@@ -793,7 +793,11 @@ commandfd(const char *const *argv)
push_error_context();
- do { c= getc(in); if (c == '\n') lno++; } while (c != EOF && isspace(c));
+ do {
+ c = getc(in);
+ if (c == '\n')
+ lno++;
+ } while (c != EOF && c_isspace(c));
if (c == EOF) break;
if (c == '#') {
do { c= getc(in); if (c == '\n') lno++; } while (c != EOF && c != '\n');
@@ -806,7 +810,7 @@ commandfd(const char *const *argv)
if (c == '\n') lno++;
/* This isn't fully accurate, but overestimating can't hurt. */
- if (isspace(c))
+ if (c_isspace(c))
argc++;
} while (c != EOF && c != '\n');
if (c == EOF) ohshit(_("unexpected eof before end of line %d"),lno);
@@ -825,7 +829,7 @@ commandfd(const char *const *argv)
endptr--;
skipchar = true;
continue;
- } else if (isspace(*ptr)) {
+ } else if (c_isspace(*ptr)) {
if (mode == true) {
*ptr = '\0';
mode = false;
diff --git a/src/remove.c b/src/remove.c
index a76dd6c90..61b908a71 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -26,7 +26,6 @@
#include <sys/stat.h>
#include <errno.h>
-#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
@@ -35,6 +34,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/pkg.h>
@@ -558,7 +558,8 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
goto yes_remove;
p= de->d_name+conffbasenamelen;
if (*p++ == '~') {
- while (*p && cisdigit(*p)) p++;
+ while (*p && c_isdigit(*p))
+ p++;
if (*p == '~' && !*++p) goto yes_remove;
}
}
diff --git a/src/select.c b/src/select.c
index cdfd5bdd4..a1eeb5292 100644
--- a/src/select.c
+++ b/src/select.c
@@ -25,12 +25,12 @@
#include <compat.h>
#include <fnmatch.h>
-#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/pkg-array.h>
@@ -133,7 +133,11 @@ setselections(const char *const *argv)
for (;;) {
struct dpkg_error err;
- do { c= getchar(); if (c == '\n') lno++; } while (c != EOF && isspace(c));
+ do {
+ c = getchar();
+ if (c == '\n')
+ lno++;
+ } while (c != EOF && c_isspace(c));
if (c == EOF) break;
if (c == '#') {
do { c= getchar(); if (c == '\n') lno++; } while (c != EOF && c != '\n');
@@ -141,7 +145,7 @@ setselections(const char *const *argv)
}
varbuf_reset(&namevb);
- while (!isspace(c)) {
+ while (!c_isspace(c)) {
varbuf_add_char(&namevb, c);
c= getchar();
if (c == EOF) ohshit(_("unexpected eof in package name at line %d"),lno);
@@ -149,14 +153,14 @@ setselections(const char *const *argv)
}
varbuf_end_str(&namevb);
- while (c != EOF && isspace(c)) {
+ while (c != EOF && c_isspace(c)) {
c= getchar();
if (c == EOF) ohshit(_("unexpected eof after package name at line %d"),lno);
if (c == '\n') ohshit(_("unexpected end of line after package name at line %d"),lno);
}
varbuf_reset(&selvb);
- while (c != EOF && !isspace(c)) {
+ while (c != EOF && !c_isspace(c)) {
varbuf_add_char(&selvb, c);
c= getchar();
}
@@ -164,7 +168,7 @@ setselections(const char *const *argv)
while (c != EOF && c != '\n') {
c= getchar();
- if (!isspace(c))
+ if (!c_isspace(c))
ohshit(_("unexpected data after package and selection at line %d"),lno);
}
pkg = pkg_spec_parse_pkg(namevb.buf, &err);
diff --git a/src/unpack.c b/src/unpack.c
index 954b6b549..bdd16f1b1 100644
--- a/src/unpack.c
+++ b/src/unpack.c
@@ -30,7 +30,6 @@
#include <assert.h>
#include <errno.h>
-#include <ctype.h>
#include <string.h>
#include <time.h>
#include <utime.h>
@@ -42,6 +41,7 @@
#include <stdio.h>
#include <dpkg/i18n.h>
+#include <dpkg/c-ctype.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#include <dpkg/pkg.h>
@@ -229,7 +229,7 @@ deb_parse_conffiles(struct pkginfo *pkg, const char *control_conffiles,
if (p[-1] != '\n')
ohshit(_("conffile name '%s' is too long, or missing final newline"),
conffilenamebuf);
- while (p > conffilenamebuf && isspace(p[-1]))
+ while (p > conffilenamebuf && c_isspace(p[-1]))
--p;
if (p == conffilenamebuf)
continue;