summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/backupfile.c7
-rw-r--r--usr.bin/patch/inp.c9
-rw-r--r--usr.bin/patch/patch.c14
-rw-r--r--usr.bin/patch/pch.c53
-rw-r--r--usr.bin/patch/util.c10
5 files changed, 49 insertions, 44 deletions
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c
index 2d4037b6638..d9e40bcba7e 100644
--- a/usr.bin/patch/backupfile.c
+++ b/usr.bin/patch/backupfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: backupfile.c,v 1.20 2009/10/27 23:59:41 deraadt Exp $ */
+/* $OpenBSD: backupfile.c,v 1.21 2013/11/26 13:19:07 deraadt Exp $ */
/*
* backupfile.c -- make Emacs style backup file names Copyright (C) 1990 Free
@@ -132,8 +132,9 @@ version_number(const char *base, const char *backup, size_t base_length)
const char *p;
version = 0;
- if (!strncmp(base, backup, base_length) && ISDIGIT(backup[base_length])) {
- for (p = &backup[base_length]; ISDIGIT(*p); ++p)
+ if (!strncmp(base, backup, base_length) &&
+ ISDIGIT((unsigned char)backup[base_length])) {
+ for (p = &backup[base_length]; ISDIGIT((unsigned char)*p); ++p)
version = version * 10 + *p - '0';
if (p[0] != '~' || p[1])
version = 0;
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index eed1aefad68..67cc3a83d72 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inp.c,v 1.36 2012/04/10 14:46:34 ajacoutot Exp $ */
+/* $OpenBSD: inp.c,v 1.37 2013/11/26 13:19:07 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -461,11 +461,12 @@ rev_in_string(const char *string)
if (revision == NULL)
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;
}
}
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 687ccc8b0f1..fba035c33bd 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.50 2012/05/15 19:32:02 millert Exp $ */
+/* $OpenBSD: patch.c,v 1.51 2013/11/26 13:19:07 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -508,7 +508,7 @@ get_some_switches(void)
break;
case 'D':
do_defines = true;
- if (!isalpha(*optarg) && *optarg != '_')
+ if (!isalpha((unsigned char)*optarg) && *optarg != '_')
fatal("argument to -D is not an identifier\n");
snprintf(if_defined, sizeof if_defined,
"#ifdef %s\n", optarg);
@@ -1030,12 +1030,12 @@ static bool
similar(const char *a, const char *b, int len)
{
while (len) {
- if (isspace(*b)) { /* whitespace (or \n) to match? */
- if (!isspace(*a)) /* no corresponding whitespace? */
- return false;
- while (len && isspace(*b) && *b != '\n')
+ if (isspace((unsigned char)*b)) { /* whitespace (or \n) to match? */
+ if (!isspace((unsigned char)*a))
+ return false; /* no corresponding whitespace */
+ 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 */
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 4538787172e..85dc5ae2647 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pch.c,v 1.40 2013/07/11 12:39:31 otto Exp $ */
+/* $OpenBSD: pch.c,v 1.41 2013/11/26 13:19:07 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -283,9 +283,9 @@ intuit_diff_type(void)
else
indent++;
}
- for (t = s; isdigit(*t) || *t == ','; t++)
+ for (t = s; isdigit((unsigned char)*t) || *t == ','; t++)
;
- this_is_a_command = (isdigit(*s) &&
+ 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;
@@ -306,10 +306,11 @@ intuit_diff_type(void)
names[INDEX_FILE].path = fetchname(s + 6,
&names[INDEX_FILE].exists, strippath);
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 == '\0') {
@@ -567,17 +568,18 @@ another_hunk(void)
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))
memmove(s, s + 2, strlen(s + 2) + 1);
p_first = (LINENUM) atol(s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
s++;
if (*s == ',') {
- for (; *s && !isdigit(*s); s++)
+ for (; *s && !isdigit((unsigned char)*s); s++)
;
if (!*s)
malformed();
@@ -636,15 +638,16 @@ another_hunk(void)
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))
+ while (isdigit((unsigned char)*s))
s++;
if (*s == ',') {
- for (; *s && !isdigit(*s); s++)
+ for (; *s && !isdigit((unsigned char)*s); s++)
;
if (!*s)
malformed();
@@ -674,8 +677,8 @@ another_hunk(void)
change_line:
if (buf[1] == '\n' && canonicalize)
strlcpy(buf + 1, " \n", sizeof buf - 1);
- 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;
@@ -721,7 +724,7 @@ another_hunk(void)
}
break;
case ' ':
- if (!isspace(buf[1]) &&
+ if (!isspace((unsigned char)buf[1]) &&
repl_beginning && repl_could_be_missing) {
repl_missing = true;
goto hunk_done;
@@ -849,11 +852,11 @@ hunk_done:
if (!*s)
malformed();
p_first = (LINENUM) atol(s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
s++;
if (*s == ',') {
p_ptrn_lines = (LINENUM) atol(++s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
s++;
} else
p_ptrn_lines = 1;
@@ -862,11 +865,11 @@ hunk_done:
if (*s != '+' || !*++s)
malformed();
p_newfirst = (LINENUM) atol(s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
s++;
if (*s == ',') {
p_repl_lines = (LINENUM) atol(++s);
- while (isdigit(*s))
+ while (isdigit((unsigned char)*s))
s++;
} else
p_repl_lines = 1;
@@ -1009,16 +1012,16 @@ hunk_done:
p_context = 0;
ret = pgets(buf, sizeof buf, pfp);
p_input_line++;
- if (ret == NULL || !isdigit(*buf)) {
+ if (ret == NULL || !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))
+ while (isdigit((unsigned char)*s))
s++;
} else
p_ptrn_lines = (*s != 'a');
@@ -1026,7 +1029,7 @@ hunk_done:
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);
@@ -1383,11 +1386,11 @@ do_ed_script(void)
break;
}
p_input_line++;
- for (t = buf; isdigit(*t) || *t == ','; t++)
+ for (t = buf; isdigit((unsigned char)*t) || *t == ','; t++)
;
/* POSIX defines allowed commands as {a,c,d,i,s} */
- if (isdigit(*buf) && (*t == 'a' || *t == 'c' || *t == 'd' ||
- *t == 'i' || *t == 's')) {
+ if (isdigit((unsigned char)*buf) &&
+ (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t == 's')) {
if (pipefp != NULL)
fputs(buf, pipefp);
if (*t != 'd') {
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 45d0d7d7d6c..40414a75c4c 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $ */
+/* $OpenBSD: util.c,v 1.36 2013/11/26 13:19:07 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -129,10 +129,10 @@ backup_file(const char *orig)
while (stat(bakname, &filestat) == 0 &&
orig_device == filestat.st_dev && orig_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
memmove(simplename, simplename + 1,
strlen(simplename + 1) + 1);
@@ -333,7 +333,7 @@ fetchname(const char *at, bool *exists, int strip_leading)
if (at == NULL || *at == '\0')
return NULL;
- while (isspace(*at))
+ while (isspace((unsigned char)*at))
at++;
#ifdef DEBUGGING
if (debug & 128)
@@ -347,7 +347,7 @@ fetchname(const char *at, bool *exists, int strip_leading)
tab = strchr(t, '\t') != NULL;
/* Strip off up to `strip_leading' path components and NUL terminate. */
for (sleading = strip_leading; *t != '\0' && ((tab && *t != '\t') ||
- !isspace(*t)); t++) {
+ !isspace((unsigned char)*t)); t++) {
if (t[0] == '/' && t[1] != '/' && t[1] != '\0')
if (--sleading >= 0)
name = t + 1;