[monkey-bubble: 525/753] Fix code that was using <ctype.h> functions and passing char's rather than



commit 6e02334e19cd8984c6cc22f72eaa241384afdf70
Author: Darin Adler <darin src gnome org>
Date:   Wed Jul 11 21:31:54 2001 +0000

    Fix code that was using <ctype.h> functions and passing char's rather than
    
    	* components/help/converters/gnome-info2html2/html.c:
    	(write_menu_entry_html):
    	* components/help/converters/gnome-man2html2/gnome-man2html.c:
    	(add_links), (scan_escape), (scan_format), (scan_table),
    	(scan_expression), (scan_request), (scan_troff),
    	(scan_troff_mandoc), (main):
    	* src/nautilus-first-time-druid.c: (load_netscape_proxy_settings):
    	* src/nautilus-property-browser.c: (emblem_keyword_valid):
    	Fix code that was using <ctype.h> functions and passing char's
    	rather than int's (using the standard "cast to unsigned char"
    	trick).
    
    	* libnautilus-private/nautilus-file.c:
    	(nautilus_file_denies_access_permission),
    	(nautilus_file_can_set_permissions), (nautilus_file_set_owner),
    	(nautilus_file_get_group_name), (nautilus_file_can_set_group),
    	(nautilus_file_get_settable_group_names),
    	(nautilus_file_set_group):
    	Get rid of the assumption that GnomeVFSFileInfo field types match
    	the platform-specific uid_t and gid_t. This involves doing a few
    	more type casts.
    	(nautilus_extract_top_left_text): Fix a use of isprint on a char
    	rather than an int.
    
    	* libnautilus-private/nautilus-volume-monitor.c: Added ifdefs so
    	this file can compile for Solaris without warnings.
    
    	* test/test.c: (test_window_set_title_with_pid): Don't assume that
    	getpid() returns an int. Instead cast it to unsigned long for
    	printing.

 help-converters/info/html.c          |    2 +-
 help-converters/man/gnome-man2html.c |   95 +++++++++++++++++-----------------
 2 files changed, 49 insertions(+), 48 deletions(-)
---
diff --git a/help-converters/info/html.c b/help-converters/info/html.c
index f5dd8e5..53378ee 100644
--- a/help-converters/info/html.c
+++ b/help-converters/info/html.c
@@ -861,7 +861,7 @@ void write_menu_entry_html( FILE *f, char *p, char *nodefile, char **menu_end )
 	    }
 
 	  for (i=1; i<4; i++)
-	    if (!isspace(*(realend+i)) && *(realend+i) != '\n')
+	    if (!isspace((guchar)*(realend+i)) && *(realend+i) != '\n')
 	      {
 		done = 1;
 		break;
diff --git a/help-converters/man/gnome-man2html.c b/help-converters/man/gnome-man2html.c
index b2afe3e..3cd34a0 100644
--- a/help-converters/man/gnome-man2html.c
+++ b/help-converters/man/gnome-man2html.c
@@ -539,9 +539,9 @@ add_links(char *c)
 			f=idtest[j];
 			/* check section */
 			g=strchr(f,')');
-			if (g && f-g<6 && (isalnum(f[-1]) || f[-1]=='>') &&
-			    ((isdigit(f[1]) && f[1]!='0' &&
-			      (f[2]==')' || (isalpha(f[2]) && f[3]==')') ||
+			if (g && f-g<6 && (isalnum((unsigned char)f[-1]) || f[-1]=='>') &&
+			    ((isdigit((unsigned char)f[1]) && f[1]!='0' &&
+			      (f[2]==')' || (isalpha((unsigned char)f[2]) && f[3]==')') ||
 			       f[2]=='X')) ||
 			     (f[2]==')' && (f[1]=='n' || f[1]=='l')))) {
 				/* this might be a link */
@@ -551,14 +551,14 @@ add_links(char *c)
 					while (h!=c && *h!='<') h--;
 					if (h!=c) h--;
 				}
-				if (isalnum(*h)) {
+				if (isalnum((unsigned char)*h)) {
 					char t,sec,subsec, *e;
 					e=h+1;
 					sec=f[1];
 					subsec=f[2];
 					if ((subsec=='X' && f[3]!=')') ||
 					    subsec==')') subsec='\0';
-					while (h>c && (isalnum(h[-1]) ||
+					while (h>c && (isalnum((unsigned char)h[-1]) ||
 						       h[-1]=='_' ||
 						       h[-1]=='-' || 
 						       h[-1]=='.'))
@@ -605,7 +605,7 @@ add_links(char *c)
 		case 3: /* ftp */
 		case 2: /* www */
 			g=f=idtest[j];
-			while (*g && (isalnum(*g) || *g=='_' || *g=='-' 
+			while (*g && (isalnum((unsigned char)*g) || *g=='_' || *g=='-' 
 				      || *g=='+' ||
 				      *g=='.')) g++;
 			if (g[-1]=='.') g--;
@@ -628,12 +628,12 @@ add_links(char *c)
 			break;
 		case 1: /* mailto */
 			g=f=idtest[1];
-			while (g>c && (isalnum(g[-1]) || g[-1]=='_' 
+			while (g>c && (isalnum((unsigned char)g[-1]) || g[-1]=='_' 
 				       || g[-1]=='-' ||
 				       g[-1]=='+' || g[-1]=='.' 
 				       || g[-1]=='%')) g--;
 			h=f+1;
-			while (*h && (isalnum(*h) || *h=='_' || *h=='-' 
+			while (*h && (isalnum((unsigned char)*h) || *h=='_' || *h=='-' 
 				      || *h=='+' ||
 				      *h=='.')) h++;
 			if (*h=='.') h--;
@@ -656,9 +656,9 @@ add_links(char *c)
 			break;
 		case 0: /* url */
 			g=f=idtest[0];
-			while (g>c && isalpha(g[-1]) && islower(g[-1])) g--;
+			while (g>c && isalpha((unsigned char)g[-1]) && islower((unsigned char)g[-1])) g--;
 			h=f+3;
-			while (*h && !isspace(*h) && *h!='<' && *h!='>' 
+			while (*h && !isspace((unsigned char)*h) && *h!='<' && *h!='>' 
 			       && *h!='"' &&
 			       *h!='&') h++;
 			if (f-g>2 && f-g<7 && h-f>3) {
@@ -890,7 +890,7 @@ static char
 			c=scan_escape(c);
 			i=intresult; if (!j) j=1;
 		} else
-			while (isdigit(*c) && (!i || (!j && i<4)))
+			while (isdigit((unsigned char)*c) && (!i || (!j && i<4)))
 				i=i*10+(*c++)-'0';
 		if (!j) { j=1; if (i) i=i-10; }
 		if (!skip_escape)
@@ -1070,7 +1070,7 @@ static char
 			c++;
 			curfield->font = toupper(*c);
 			c++;
-			if (!isspace(*c) && *c!='.') c++;
+			if (!isspace((unsigned char)*c) && *c!='.') c++;
 			break;
 		case 't': case 'T': curfield->valign='t'; c++; break;
 		case 'p': case 'P':
@@ -1078,7 +1078,7 @@ static char
 			i=j=0;
 			if (*c=='+') { j=1; c++; }
 			if (*c=='-') { j=-1; c++; }
-			while (isdigit(*c)) i=i*10+(*c++)-'0';
+			while (isdigit((unsigned char)*c)) i=i*10+(*c++)-'0';
 			if (j) curfield->size= i*j; else curfield->size=j-10;
 			break;
 		case 'v': case 'V':
@@ -1096,7 +1096,7 @@ static char
 		case '0': case '1': case '2': case '3': case '4':
 		case '5': case '6': case '7': case '8': case '9':
 			i=0;
-			while (isdigit(*c)) i=i*10+(*c++)-'0';
+			while (isdigit((unsigned char)*c)) i=i*10+(*c++)-'0';
 			curfield->space=i;
 			break;
 		case ',': case '\n':
@@ -1188,7 +1188,7 @@ static char
 	if (h[-1]==';') {
 		/* scan table options */
 		while (c<h) {
-			while (isspace(*c)) c++;
+			while (isspace((unsigned char)*c)) c++;
 			for (i=0; tableopt[i] && 
 				     strncmp(tableopt[i],c,tableoptl[i]);i++);
 			c=c+tableoptl[i];
@@ -1215,7 +1215,7 @@ static char
 			case 6: 
 				while (*c++!='(');
 				linesize=0;
-				while (isdigit(*c))
+				while (isdigit((unsigned char)*c))
 					linesize=linesize*10+(*c++)-'0';
 				break;
 			case 7: 
@@ -1312,7 +1312,7 @@ static char
 				currow->prev->next=NULL;
 			currow->prev=NULL;
 			clear_table(currow);
-		} else if (*c=='.' && c[-1]=='\n' && !isdigit(c[1])) {
+		} else if (*c=='.' && c[-1]=='\n' && !isdigit((unsigned char)c[1])) {
 			/* skip troff request inside table(usually only .sp )*/
 			while (*c++!='\n');
 		} else {
@@ -1542,7 +1542,7 @@ static char
 			c=c+3;
 		c++;
 	} else {
-		while (*c && !isspace(*c) && *c!=')') {
+		while (*c && !isspace((unsigned char)*c) && *c!=')') {
 			opex=0;
 			switch (*c) {
 			case '(':
@@ -1558,16 +1558,16 @@ static char
 			case '8': case '9': {
 				int num=0,denum=1;
 				value2=0;
-				while (isdigit(*c))
+				while (isdigit((unsigned char)*c))
 					value2=value2*10+((*c++)-'0');
 				if (*c=='.') {
 					c++;
-					while (isdigit(*c)) {
+					while (isdigit((unsigned char)*c)) {
 						num=num*10+((*c++)-'0');
 						denum=denum*10;
 					}
 				}
-				if (isalpha(*c)) {
+				if (isalpha((unsigned char)*c)) {
 					/* scale indicator */
 					switch (*c) {
 					case 'i': /* inch -> 10pt */
@@ -1588,7 +1588,7 @@ static char
 			case '\\':
 				c=scan_escape(c+1);
 				value2=intresult*sign;
-				if (isalpha(*c))
+				if (isalpha((unsigned char)*c))
 					c++; /* scale indicator */
 				opex=1;
 				break;
@@ -2026,7 +2026,7 @@ static char
 				c=c+1;
 			else 
 				c=c+2;
-			while (isspace(*c)) 
+			while (isspace((unsigned char)*c)) 
 				c++;
 			if (*c=='"') 
 				c++;
@@ -2646,7 +2646,7 @@ static char
 			c=c+j;
 			i=V(c[0],c[1]);
 			c=c+2;
-			while (isspace(*c) && *c!='\n')
+			while (isspace((unsigned char)*c) && *c!='\n')
 				c++;
 			j=V(c[0],c[1]);
 			while (*c && *c!='\n') 
@@ -2826,7 +2826,7 @@ static char
 			break;
 		case V('I','t'):	/* BSD mandoc */
 			c=c+j;
-			if (strncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) {
+			if (strncmp(c, "Xo", 2) == 0 && isspace((unsigned char)*(c+2))) {
 				c = skip_till_newline(c); 
 			}
 			if (dl_set[itemdepth] & BL_DESC_LIST) {
@@ -2977,23 +2977,23 @@ static char
 			c = c+j;
 			if (*c == '\n')
 				c++; /* Skip spaces */
-			while (isspace(*c) && *c != '\n')
+			while (isspace((unsigned char)*c) && *c != '\n')
 				c++;
-			while (isalnum(*c)) { /* Copy the xyz part */
+			while (isalnum((unsigned char)*c)) { /* Copy the xyz part */
 				*bufptr = *c;
 				bufptr++;
 				if (bufptr >= buff + MED_STR_MAX)
 					break;
 				c++;
 			}
-			while (isspace(*c) && *c != '\n')
+			while (isspace((unsigned char)*c) && *c != '\n')
 				c++;	/* Skip spaces */
 			/* Convert the number if there is one */
-			if (isdigit(*c)) {
+			if (isdigit((unsigned char)*c)) {
 				*bufptr = '(';
 				bufptr++; 
 				if (bufptr < buff + MED_STR_MAX) {
-					while (isalnum(*c)) { 
+					while (isalnum((unsigned char)*c)) { 
 						*bufptr = *c; 
 						bufptr++; 
 						if (bufptr >= buff + 
@@ -3009,7 +3009,7 @@ static char
 			}
 
 			while (*c != '\n') { /* Copy the remainder */
-				if (!isspace(*c)) {
+				if (!isspace((unsigned char)*c)) {
 					*bufptr = *c;
 					bufptr++; 
 					if (bufptr >= buff + MED_STR_MAX)
@@ -3145,11 +3145,11 @@ static char
 			do {	/* Find first whitespace after the 
 				 * first word that isn't a mandoc macro 
 				 */
-				while (*sp && isspace(*sp))
+				while (*sp && isspace((unsigned char)*sp))
 					sp++;
-				while (*sp && !isspace(*sp))
+				while (*sp && !isspace((unsigned char)*sp))
 					sp++;
-			} while (*sp && isupper(*(sp-2)) && islower(*(sp-1)));
+			} while (*sp && isupper((unsigned char)*(sp-2)) && islower((unsigned char)*(sp-1)));
 
 				/* Use a newline to mark the end of text to 
 				 * be quoted 
@@ -3399,8 +3399,8 @@ static char
 				*sl='\n';
 			}
 			else if (mandoc_command && 
-				 ((isupper(*c) && islower(*(c+1)))
-				  || (islower(*c) && isupper(*(c+1))))
+				 ((isupper((unsigned char)*c) && islower((unsigned char)*(c+1)))
+				  || (islower((unsigned char)*c) && isupper((unsigned char)*(c+1))))
 				) {
 				/* Let through any BSD mandoc commands 
 				 * that haven't
@@ -3490,9 +3490,9 @@ static char
 			if (san && h[-1]=='\n')
 				h--;
 		} else if (mandoc_line
-			   && *(h) && isupper(*(h))
-			   && *(h+1) && islower(*(h+1)) 
-			   && *(h+2) && isspace(*(h+2))) {
+			   && *(h) && isupper((unsigned char)*(h))
+			   && *(h+1) && islower((unsigned char)*(h+1)) 
+			   && *(h+2) && isspace((unsigned char)*(h+2))) {
 			/* BSD imbedded command 
 			   eg ".It Fl Ar arg1 Fl Ar arg2" */
 			FLUSHIBP;
@@ -3506,7 +3506,7 @@ static char
 			if (san && h[-1]=='\n') 
 				h--;
 		} else {
-			if (h[-1]=='\n' && still_dd && isalnum(*h)) {
+			if (h[-1]=='\n' && still_dd && isalnum((unsigned char)*h)) {
 				/* sometimes a .HP request is not 
 				   followed by a .br request */
 				FLUSHIBP;
@@ -3651,8 +3651,8 @@ static char
     }
 
     if (end > c + 2
-        && ispunct(*(end - 1)) 
-	&& isspace(*(end - 2)) && *(end - 2) != '\n') {
+        && ispunct((unsigned char)*(end - 1)) 
+	&& isspace((unsigned char)*(end - 2)) && *(end - 2) != '\n') {
       /* Don't format lonely punctuation E.g. in "xyz ," format
        * the xyz and then append the comma removing the space.
        */
@@ -3716,7 +3716,7 @@ main(int argc, char **argv)
 
 		/* Try searching for this as a man page name, instead */
 		ctmp = strrchr(infile, '.');
-		if(ctmp && (isdigit(*(ctmp+1)) || (*(ctmp+1) == 'n')) && *(ctmp+2) == '\0')
+		if(ctmp && (isdigit((unsigned char)*(ctmp+1)) || (*(ctmp+1) == 'n')) && *(ctmp+2) == '\0')
 		  {
 		    char section = *(ctmp+1);
 
@@ -3732,7 +3732,7 @@ main(int argc, char **argv)
 		pclose(fh);
 
 		i = strlen(output) - 1;
-		while(isspace(output[i])) output[i--] = '\0';
+		while(isspace((unsigned char)output[i])) output[i--] = '\0';
 
 		if (output[0]) {
 #ifdef HAVE_LIBBZ2
@@ -3745,16 +3745,17 @@ main(int argc, char **argv)
 	      }
 	  }
 #ifdef HAVE_LIBBZ2
-	if(!infh && !inbfh) {
+	if(!infh && !inbfh)
 #else	  
-	if(!infh) {
+	if(!infh)
 #endif
+	  {
 		printf("<HTML><HEAD><TITLE>Document not found</TITLE>\n"
 		       "</HEAD><BODY>The document \"%s\" couldn't be found. It may have been removed from your system.\n"
 		       "</BODY></HTML>\n", infile);
 
 		return 3;
-	}
+	  }
 
 	buf=read_man_page();
 	if (!buf) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]