shithub: neatroff

Download patch

ref: ccff1a68e10909fb73e471772d1d603e3fa72297
parent: d5d1763b989a4146ebcea19c8f3c1ffa864ccb2d
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Aug 24 20:14:41 EDT 2017

tr: missing casts for isdigit()

--- a/clr.c
+++ b/clr.c
@@ -43,16 +43,17 @@
 
 int clr_get(char *s)
 {
+	int c = (unsigned char) s[0];
 	int i;
-	if (s[0] == '#' && strlen(s) == 7)
+	if (c == '#' && strlen(s) == 7)
 		return CLR_RGB(ccom(s + 1, 2), ccom(s + 3, 2), ccom(s + 5, 2));
-	if (s[0] == '#' && strlen(s) == 4)
+	if (c == '#' && strlen(s) == 4)
 		return CLR_RGB(ccom(s + 1, 1), ccom(s + 2, 1), ccom(s + 3, 1));
-	if (s[0] == '#' && strlen(s) == 3)
+	if (c == '#' && strlen(s) == 3)
 		return CLR_RGB(ccom(s + 1, 2), ccom(s + 1, 2), ccom(s + 1, 2));
-	if (s[0] == '#' && strlen(s) == 2)
+	if (c == '#' && strlen(s) == 2)
 		return CLR_RGB(ccom(s + 1, 1), ccom(s + 1, 1), ccom(s + 1, 1));
-	if (isdigit(s[0]) && atoi(s) >= 0 && atoi(s) < LEN(colors))
+	if (isdigit(c) && atoi(s) >= 0 && atoi(s) < LEN(colors))
 		return colors[atoi(s)].value;
 	for (i = 0; i < LEN(colors); i++)
 		if (!strcmp(colors[i].name, s))
--- a/eval.c
+++ b/eval.c
@@ -37,7 +37,7 @@
 	char *s = *_s;
 	int n = 0;		/* the result */
 	int mag = 0;		/* n should be divided by mag */
-	while (isdigit(*s) || *s == '.') {
+	while (isdigit((unsigned char) *s) || *s == '.') {
 		if (*s == '.') {
 			mag = 1;
 			s++;
@@ -66,7 +66,7 @@
 
 static int evalisnum(char **s)
 {
-	return **s == '.' || isdigit(**s);
+	return **s == '.' || isdigit((unsigned char) **s);
 }
 
 static int evalexpr(char **s);
--- a/tr.c
+++ b/tr.c
@@ -345,7 +345,7 @@
 	n_na = 0;
 	if (!s)
 		return;
-	if (isdigit(s[0]))
+	if (isdigit((unsigned char) s[0]))
 		n_j = atoi(s) & 15;
 	else
 		n_j = s[0] == 'p' ? AD_P | adjmode(s[1], AD_B) : adjmode(s[0], n_j);
@@ -631,11 +631,11 @@
 	n_nm = 1;
 	n_ln = eval_re(args[1], n_ln, 0);
 	n_ln = MAX(0, n_ln);
-	if (args[2] && isdigit(args[2][0]))
+	if (args[2] && isdigit((unsigned char) args[2][0]))
 		n_nM = MAX(1, eval(args[2], 0));
-	if (args[3] && isdigit(args[3][0]))
+	if (args[3] && isdigit((unsigned char) args[3][0]))
 		n_nS = MAX(0, eval(args[3], 0));
-	if (args[4] && isdigit(args[4][0]))
+	if (args[4] && isdigit((unsigned char) args[4][0]))
 		n_nI = MAX(0, eval(args[4], 0));
 }