summaryrefslogtreecommitdiff
path: root/Build/source/texk/psutils
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2014-06-19 11:14:35 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2014-06-19 11:14:35 +0000
commite5b8a1a0369901d3d73384cf553619d9351679aa (patch)
treea0b0d02bb0421b6f6f1dce118d40dfe6e91147b6 /Build/source/texk/psutils
parenta7803f3483864a647563ebda46f5fa39a92bb205 (diff)
texk/*/, utils/*/: Avoid undefined behaviour when char is signed
git-svn-id: svn://tug.org/texlive/trunk@34310 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/psutils')
-rw-r--r--Build/source/texk/psutils/psutils-1.23-PATCHES/ChangeLog4
-rw-r--r--Build/source/texk/psutils/psutils-1.23-PATCHES/patch-02-unsigned83
-rw-r--r--Build/source/texk/psutils/psutils-1.23/psselect.c8
-rw-r--r--Build/source/texk/psutils/psutils-1.23/psspec.c4
-rw-r--r--Build/source/texk/psutils/psutils-1.23/pstops.c2
-rw-r--r--Build/source/texk/psutils/psutils-1.23/psutil.c4
6 files changed, 96 insertions, 9 deletions
diff --git a/Build/source/texk/psutils/psutils-1.23-PATCHES/ChangeLog b/Build/source/texk/psutils/psutils-1.23-PATCHES/ChangeLog
index 923c64493ff..c00f0d6efa7 100644
--- a/Build/source/texk/psutils/psutils-1.23-PATCHES/ChangeLog
+++ b/Build/source/texk/psutils/psutils-1.23-PATCHES/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-19 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * patch-02-unsigned (new): Avoid undefined behaviour.
+
2014-01-16 Peter Breitenlohner <peb@mppmu.mpg.de>
Import psutils-1.23.
diff --git a/Build/source/texk/psutils/psutils-1.23-PATCHES/patch-02-unsigned b/Build/source/texk/psutils/psutils-1.23-PATCHES/patch-02-unsigned
new file mode 100644
index 00000000000..97d13b3c290
--- /dev/null
+++ b/Build/source/texk/psutils/psutils-1.23-PATCHES/patch-02-unsigned
@@ -0,0 +1,83 @@
+ Avoid undefined behaviour when char is unsigned.
+
+diff -ur psutils-1.23.orig/psselect.c psutils-1.23/psselect.c
+--- psutils-1.23.orig/psselect.c 2014-01-15 20:08:26.000000000 +0100
++++ psutils-1.23/psselect.c 2014-06-19 12:56:34.000000000 +0200
+@@ -43,9 +43,9 @@
+ if(!str) return NULL;
+
+ sign = (*str == '_' && ++str) ? -1 : 1;
+- if (isdigit(*str)) {
++ if (isdigit((unsigned char)*str)) {
+ first = sign*atoi(str);
+- while (isdigit(*str)) str++;
++ while (isdigit((unsigned char)*str)) str++;
+ }
+ switch (*str) {
+ case '\0':
+@@ -62,9 +62,9 @@
+ sign = (*str == '_' && ++str) ? -1 : 1;
+ if (!first)
+ first = 1;
+- if (isdigit(*str)) {
++ if (isdigit((unsigned char)*str)) {
+ int last = sign*atoi(str);
+- while (isdigit(*str)) str++;
++ while (isdigit((unsigned char)*str)) str++;
+ if (*str == '\0')
+ return (makerange(first, last, rp));
+ if (*str == ',')
+diff -ur psutils-1.23.orig/psspec.c psutils-1.23/psspec.c
+--- psutils-1.23.orig/psspec.c 2014-01-15 20:08:26.000000000 +0100
++++ psutils-1.23/psspec.c 2014-06-19 12:56:34.000000000 +0200
+@@ -35,7 +35,7 @@
+ char *s = *sp;
+ int num = atoi(s);
+
+- while (isdigit(*s))
++ while (isdigit((unsigned char)*s))
+ s++;
+ if (*sp == s) argerror();
+ *sp = s;
+@@ -47,7 +47,7 @@
+ char *s = *sp;
+ double num = atof(s);
+
+- while (isdigit(*s) || *s == '-' || *s == '.')
++ while (isdigit((unsigned char)*s) || *s == '-' || *s == '.')
+ s++;
+ if (*sp == s) argerror();
+ *sp = s;
+diff -ur psutils-1.23.orig/pstops.c psutils-1.23/pstops.c
+--- psutils-1.23.orig/pstops.c 2014-01-15 20:08:26.000000000 +0100
++++ psutils-1.23/pstops.c 2014-06-19 12:56:34.000000000 +0200
+@@ -34,7 +34,7 @@
+
+ head = tail = newspec();
+ while (*str) {
+- if (isdigit(*str)) {
++ if (isdigit((unsigned char)*str)) {
+ num = parseint(&str);
+ } else {
+ switch (*str++) {
+diff -ur psutils-1.23.orig/psutil.c psutils-1.23/psutil.c
+--- psutils-1.23.orig/psutil.c 2014-01-16 08:57:40.000000000 +0100
++++ psutils-1.23/psutil.c 2014-06-19 12:56:34.000000000 +0200
+@@ -258,7 +258,7 @@
+ if (fgets(buffer, BUFSIZ, infile) != NULL &&
+ iscomment(buffer, "%%Page:")) {
+ char *start, *end;
+- for (start = buffer+7; isspace(*start); start++);
++ for (start = buffer+7; isspace((unsigned char)*start); start++);
+ if (*start == '(') {
+ int paren = 1;
+ for (end = start+1; paren > 0; end++)
+@@ -275,7 +275,7 @@
+ break;
+ }
+ } else
+- for (end = start; !isspace(*end); end++);
++ for (end = start; !isspace((unsigned char)*end); end++);
+ strncpy(pagelabel, start, end-start);
+ pagelabel[end-start] = '\0';
+ pageno = atoi(end);
diff --git a/Build/source/texk/psutils/psutils-1.23/psselect.c b/Build/source/texk/psutils/psutils-1.23/psselect.c
index 9440f0bb95b..55a4d0e7b1e 100644
--- a/Build/source/texk/psutils/psutils-1.23/psselect.c
+++ b/Build/source/texk/psutils/psutils-1.23/psselect.c
@@ -43,9 +43,9 @@ static PageRange *addrange(char *str, PageRange *rp)
if(!str) return NULL;
sign = (*str == '_' && ++str) ? -1 : 1;
- if (isdigit(*str)) {
+ if (isdigit((unsigned char)*str)) {
first = sign*atoi(str);
- while (isdigit(*str)) str++;
+ while (isdigit((unsigned char)*str)) str++;
}
switch (*str) {
case '\0':
@@ -62,9 +62,9 @@ static PageRange *addrange(char *str, PageRange *rp)
sign = (*str == '_' && ++str) ? -1 : 1;
if (!first)
first = 1;
- if (isdigit(*str)) {
+ if (isdigit((unsigned char)*str)) {
int last = sign*atoi(str);
- while (isdigit(*str)) str++;
+ while (isdigit((unsigned char)*str)) str++;
if (*str == '\0')
return (makerange(first, last, rp));
if (*str == ',')
diff --git a/Build/source/texk/psutils/psutils-1.23/psspec.c b/Build/source/texk/psutils/psutils-1.23/psspec.c
index e02e6ffd3f6..19a31a6408f 100644
--- a/Build/source/texk/psutils/psutils-1.23/psspec.c
+++ b/Build/source/texk/psutils/psutils-1.23/psspec.c
@@ -35,7 +35,7 @@ int parseint(char **sp)
char *s = *sp;
int num = atoi(s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
s++;
if (*sp == s) argerror();
*sp = s;
@@ -47,7 +47,7 @@ double parsedouble(char **sp)
char *s = *sp;
double num = atof(s);
- while (isdigit(*s) || *s == '-' || *s == '.')
+ while (isdigit((unsigned char)*s) || *s == '-' || *s == '.')
s++;
if (*sp == s) argerror();
*sp = s;
diff --git a/Build/source/texk/psutils/psutils-1.23/pstops.c b/Build/source/texk/psutils/psutils-1.23/pstops.c
index c6b82b960ee..e37a0a27f60 100644
--- a/Build/source/texk/psutils/psutils-1.23/pstops.c
+++ b/Build/source/texk/psutils/psutils-1.23/pstops.c
@@ -34,7 +34,7 @@ static PageSpec *parsespecs(char *str)
head = tail = newspec();
while (*str) {
- if (isdigit(*str)) {
+ if (isdigit((unsigned char)*str)) {
num = parseint(&str);
} else {
switch (*str++) {
diff --git a/Build/source/texk/psutils/psutils-1.23/psutil.c b/Build/source/texk/psutils/psutils-1.23/psutil.c
index 8533bff4906..f129341ed69 100644
--- a/Build/source/texk/psutils/psutils-1.23/psutil.c
+++ b/Build/source/texk/psutils/psutils-1.23/psutil.c
@@ -258,7 +258,7 @@ void seekpage(int p)
if (fgets(buffer, BUFSIZ, infile) != NULL &&
iscomment(buffer, "%%Page:")) {
char *start, *end;
- for (start = buffer+7; isspace(*start); start++);
+ for (start = buffer+7; isspace((unsigned char)*start); start++);
if (*start == '(') {
int paren = 1;
for (end = start+1; paren > 0; end++)
@@ -275,7 +275,7 @@ void seekpage(int p)
break;
}
} else
- for (end = start; !isspace(*end); end++);
+ for (end = start; !isspace((unsigned char)*end); end++);
strncpy(pagelabel, start, end-start);
pagelabel[end-start] = '\0';
pageno = atoi(end);