Add (unsigned char) cast to ctype macros

This commit is contained in:
Andrey A. Chernov 1997-10-23 02:44:23 +00:00
parent 2e6bafc0a2
commit 5a90c8dbf2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30661
4 changed files with 82 additions and 38 deletions

View File

@ -1,6 +1,15 @@
/* $Header: /home/ncvs/src/gnu/usr.bin/patch/inp.c,v 1.4 1997/02/13 21:10:39 jmg Exp $
/* $Header: /home/ncvs/src/gnu/usr.bin/patch/inp.c,v 1.5 1997/03/17 01:44:40 jmg Exp $
*
* $Log: inp.c,v $
* Revision 1.5 1997/03/17 01:44:40 jmg
* fix compilation warnings in patch... (with slight modification)
*
* also remove -Wall that I acidentally committed last time I was here...
*
* Submitted-by: Philippe Charnier
*
* Closes PR#2998
*
* Revision 1.4 1997/02/13 21:10:39 jmg
* Fix a problem with patch in that is will always default, even when the
* controlling terminal is closed. Now the function ask() will return 1 when th
@ -386,11 +395,11 @@ char *string;
if (revision == Nullch)
return TRUE;
patlen = strlen(revision);
if (strnEQ(string,revision,patlen) && isspace(string[patlen]))
if (strnEQ(string,revision,patlen) && isspace((unsigned char)string[patlen]))
return TRUE;
for (s = string; *s; s++) {
if (isspace(*s) && strnEQ(s+1, revision, patlen) &&
isspace(s[patlen+1] )) {
if (isspace((unsigned char)*s) && strnEQ(s+1, revision, patlen) &&
isspace((unsigned char)s[patlen+1] )) {
return TRUE;
}
}

View File

@ -1,5 +1,5 @@
char rcsid[] =
"$Header: /home/ncvs/src/gnu/usr.bin/patch/patch.c,v 1.7 1997/02/13 21:10:41 jmg Exp $";
"$Header: /home/ncvs/src/gnu/usr.bin/patch/patch.c,v 1.8 1997/03/17 01:44:42 jmg Exp $";
/* patch - a program to apply diffs to original files
*
@ -9,6 +9,15 @@ char rcsid[] =
* money off of it, or pretend that you wrote it.
*
* $Log: patch.c,v $
* Revision 1.8 1997/03/17 01:44:42 jmg
* fix compilation warnings in patch... (with slight modification)
*
* also remove -Wall that I acidentally committed last time I was here...
*
* Submitted-by: Philippe Charnier
*
* Closes PR#2998
*
* Revision 1.7 1997/02/13 21:10:41 jmg
* Fix a problem with patch in that is will always default, even when the
* controlling terminal is closed. Now the function ask() will return 1 when th
@ -544,7 +553,7 @@ get_some_switches()
break;
case 'D':
do_defines = TRUE;
if (!isalpha(*optarg) && '_' != *optarg)
if (!isalpha((unsigned char)*optarg) && '_' != *optarg)
fatal1("argument to -D is not an identifier\n");
Sprintf(if_defined, "#ifdef %s\n", optarg);
Sprintf(not_defined, "#ifndef %s\n", optarg);
@ -954,12 +963,12 @@ Reg2 char *b;
Reg3 int len;
{
while (len) {
if (isspace(*b)) { /* whitespace (or \n) to match? */
if (!isspace(*a)) /* no corresponding whitespace? */
if (isspace((unsigned char)*b)) { /* whitespace (or \n) to match? */
if (!isspace((unsigned char)*a)) /* no corresponding whitespace? */
return FALSE;
while (len && isspace(*b) && *b != '\n')
while (len && isspace((unsigned char)*b) && *b != '\n')
b++,len--; /* skip pattern whitespace */
while (isspace(*a) && *a != '\n')
while (isspace((unsigned char)*a) && *a != '\n')
a++; /* skip target whitespace */
if (*a == '\n' || *b == '\n')
return (*a == *b); /* should end in sync */

View File

@ -1,8 +1,34 @@
/* $Header: /usr/cvs/src/gnu/usr.bin/patch/pch.c,v 1.8 1996/04/12 11:37:32 markm Exp $
/* $Header: /home/ncvs/src/gnu/usr.bin/patch/pch.c,v 1.9 1997/02/13 21:10:43 jmg Exp $
*
* $Log: pch.c,v $
* Revision 1.9 1997/02/13 21:10:43 jmg
* Fix a problem with patch in that is will always default, even when the
* controlling terminal is closed. Now the function ask() will return 1 when th
* input is known to come from a file or terminal, or it will return 0 when ther
* was a read error.
*
* Modified the question "Skip patch?" so that on an error from ask it will skip
* the patch instead of looping.
*
* Closes PR#777
*
* 2.2 candidate
*
* Revision 1.8 1996/04/12 11:37:32 markm
* Attempt to break a $Log$ snafu where a *** /--- (minus space)
* Attempt to break a $Log: pch.c,v $
* Attempt to break a Revision 1.9 1997/02/13 21:10:43 jmg
* Attempt to break a Fix a problem with patch in that is will always default, even when the
* Attempt to break a controlling terminal is closed. Now the function ask() will return 1 when th
* Attempt to break a input is known to come from a file or terminal, or it will return 0 when ther
* Attempt to break a was a read error.
* Attempt to break a
* Attempt to break a Modified the question "Skip patch?" so that on an error from ask it will skip
* Attempt to break a the patch instead of looping.
* Attempt to break a
* Attempt to break a Closes PR#777
* Attempt to break a
* Attempt to break a 2.2 candidate
* Attempt to break a snafu where a *** /--- (minus space)
* was fouling up a comment in the checked-out code.
*
* Revision 1.7 1996/04/11 10:13:40 markm
@ -302,8 +328,8 @@ intuit_diff_type()
else
indent++;
}
for (t=s; isdigit(*t) || *t == ','; t++) ;
this_is_a_command = (isdigit(*s) &&
for (t=s; isdigit((unsigned char)*t) || *t == ','; t++) ;
this_is_a_command = (isdigit((unsigned char)*s) &&
(*t == 'd' || *t == 'c' || *t == 'a') );
if (first_command_line < 0L && this_is_a_command) {
first_command_line = this_line;
@ -319,9 +345,9 @@ intuit_diff_type()
else if (strnEQ(s, "Index:", 6))
indtmp = savestr(s+6);
else if (strnEQ(s, "Prereq:", 7)) {
for (t=s+7; isspace(*t); t++) ;
for (t=s+7; isspace((unsigned char)*t); t++) ;
revision = savestr(t);
for (t=revision; *t && !isspace(*t); t++) ;
for (t=revision; *t && !isspace((unsigned char)*t); t++) ;
*t = '\0';
if (!*revision) {
free(revision);
@ -567,15 +593,15 @@ another_hunk()
p_end--;
return FALSE;
}
for (s=buf; *s && !isdigit(*s); s++) ;
for (s=buf; *s && !isdigit((unsigned char)*s); s++) ;
if (!*s)
malformed ();
if (strnEQ(s,"0,0",3))
strcpy(s,s+2);
p_first = (LINENUM) atol(s);
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
if (*s == ',') {
for (; *s && !isdigit(*s); s++) ;
for (; *s && !isdigit((unsigned char)*s); s++) ;
if (!*s)
malformed ();
p_ptrn_lines = ((LINENUM)atol(s)) - p_first + 1;
@ -633,13 +659,13 @@ another_hunk()
return FALSE;
}
p_Char[p_end] = '=';
for (s=buf; *s && !isdigit(*s); s++) ;
for (s=buf; *s && !isdigit((unsigned char)*s); s++) ;
if (!*s)
malformed ();
p_newfirst = (LINENUM) atol(s);
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
if (*s == ',') {
for (; *s && !isdigit(*s); s++) ;
for (; *s && !isdigit((unsigned char)*s); s++) ;
if (!*s)
malformed ();
p_repl_lines = ((LINENUM)atol(s)) - p_newfirst + 1;
@ -667,7 +693,7 @@ another_hunk()
change_line:
if (buf[1] == '\n' && canonicalize)
strcpy(buf+1," \n");
if (!isspace(buf[1]) && buf[1] != '>' && buf[1] != '<' &&
if (!isspace((unsigned char)buf[1]) && buf[1] != '>' && buf[1] != '<' &&
repl_beginning && repl_could_be_missing) {
repl_missing = TRUE;
goto hunk_done;
@ -703,7 +729,7 @@ another_hunk()
}
break;
case ' ':
if (!isspace(buf[1]) &&
if (!isspace((unsigned char)buf[1]) &&
repl_beginning && repl_could_be_missing) {
repl_missing = TRUE;
goto hunk_done;
@ -827,20 +853,20 @@ another_hunk()
if (!*s)
malformed ();
p_first = (LINENUM) atol(s);
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
if (*s == ',') {
p_ptrn_lines = (LINENUM) atol(++s);
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
} else
p_ptrn_lines = 1;
if (*s == ' ') s++;
if (*s != '+' || !*++s)
malformed ();
p_newfirst = (LINENUM) atol(s);
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
if (*s == ',') {
p_repl_lines = (LINENUM) atol(++s);
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
} else
p_repl_lines = 1;
if (*s == ' ') s++;
@ -962,15 +988,15 @@ another_hunk()
p_context = 0;
ret = pgets(buf, sizeof buf, pfp);
p_input_line++;
if (ret == Nullch || !isdigit(*buf)) {
if (ret == Nullch || !isdigit((unsigned char)*buf)) {
next_intuit_at(line_beginning,p_input_line);
return FALSE;
}
p_first = (LINENUM)atol(buf);
for (s=buf; isdigit(*s); s++) ;
for (s=buf; isdigit((unsigned char)*s); s++) ;
if (*s == ',') {
p_ptrn_lines = (LINENUM)atol(++s) - p_first + 1;
while (isdigit(*s)) s++;
while (isdigit((unsigned char)*s)) s++;
}
else
p_ptrn_lines = (*s != 'a');
@ -978,7 +1004,7 @@ another_hunk()
if (hunk_type == 'a')
p_first++; /* do append rather than insert */
min = (LINENUM)atol(++s);
for (; isdigit(*s); s++) ;
for (; isdigit((unsigned char)*s); s++) ;
if (*s == ',')
max = (LINENUM)atol(++s);
else
@ -1312,8 +1338,8 @@ do_ed_script()
break;
}
p_input_line++;
for (t=buf; isdigit(*t) || *t == ','; t++) ;
this_line_is_command = (isdigit(*buf) &&
for (t=buf; isdigit((unsigned char)*t) || *t == ','; t++) ;
this_line_is_command = (isdigit((unsigned char)*buf) &&
(*t == 'd' || *t == 'c' || *t == 'a') );
if (this_line_is_command) {
if (!skip_rest_of_patch)

View File

@ -80,9 +80,9 @@ char *from, *to;
while (stat(bakname, &filestat) == 0 &&
to_device == filestat.st_dev && to_inode == filestat.st_ino) {
/* Skip initial non-lowercase chars. */
for (s=simplename; *s && !islower(*s); s++) ;
for (s=simplename; *s && !islower((unsigned char)*s); s++) ;
if (*s)
*s = toupper(*s);
*s = toupper((unsigned char)*s);
else
Strcpy(simplename, simplename+1);
}
@ -376,7 +376,7 @@ int assume_exists;
if (!at)
return Nullch;
while (isspace(*at))
while (isspace((unsigned char)*at))
at++;
#ifdef DEBUGGING
if (debug & 128)
@ -387,7 +387,7 @@ int assume_exists;
name = fullname = t = savestr(at);
/* Strip off up to `sleading' leading slashes and null terminate. */
for (; *t && !isspace(*t); t++)
for (; *t && !isspace((unsigned char)*t); t++)
if (*t == '/')
if (--sleading >= 0)
name = t+1;