Ticket #1791: patch-ah

File patch-ah, 1.9 KB (added by vle@…, 16 years ago)

fix for isspace(3) calls

Line 
1$NetBSD: patch-ah,v 1.3 2006/10/31 22:33:28 wiz Exp $
2
3--- subreader.c.orig 2010-08-29 11:27:00.000000000 +0000
4+++ subreader.c
5@@ -94,10 +94,10 @@ static int eol(char p) {
6 /* Remove leading and trailing space */
7 static void trail_space(char *s) {
8 int i = 0;
9- while (isspace(s[i])) ++i;
10+ while (isspace((unsigned char)s[i])) ++i;
11 if (i) strcpy(s, s + i);
12 i = strlen(s) - 1;
13- while (i > 0 && isspace(s[i])) s[i--] = '\0';
14+ while (i > 0 && isspace((unsigned char)s[i])) s[i--] = '\0';
15 }
16
17 static char *stristr(const char *haystack, const char *needle) {
18@@ -725,7 +725,7 @@ static subtitle *sub_read_line_pjs(strea
19 if (!stream_read_line (st, line, LINE_LEN, utf16))
20 return NULL;
21 /* skip spaces */
22- for (s=line; *s && isspace(*s); s++);
23+ for (s=line; *s && isspace((unsigned char)*s); s++);
24 /* allow empty lines at the end of the file */
25 if (*s==0)
26 return NULL;
27@@ -778,7 +778,7 @@ static subtitle *sub_read_line_mpsub(str
28 else return current;
29 }
30 p=line;
31- while (isspace(*p)) p++;
32+ while (isspace(*(unsigned char*)p)) p++;
33 if (eol(*p) && num > 0) return current;
34 if (eol(*p)) return NULL;
35
36@@ -1824,18 +1824,18 @@ char * strreplace( char * in,char * what
37 static void strcpy_trim(char *d, char *s)
38 {
39 // skip leading whitespace
40- while (*s && isspace(*s)) {
41+ while (*s && isspace((unsigned char)*s)) {
42 s++;
43 }
44 for (;;) {
45 // copy word
46- while (*s && !isspace(*s)) {
47+ while (*s && !isspace((unsigned char)*s)) {
48 *d = tolower(*s);
49 s++; d++;
50 }
51 if (*s == 0) break;
52 // trim excess whitespace
53- while (*s && isspace(*s)) {
54+ while (*s && isspace((unsigned char)*s)) {
55 s++;
56 }
57 if (*s == 0) break;
58@@ -1874,7 +1874,7 @@ static void strcpy_get_ext(char *d, char
59 static int whiteonly(char *s)
60 {
61 while (*s) {
62- if (!isspace(*s)) return 0;
63+ if (!isspace((unsigned char)*s)) return 0;
64 s++;
65 }
66 return 1;