From 800e4fc1598b07afce4fbbbab5875c3bc5e10835 Mon Sep 17 00:00:00 2001 From: Darin Adler Date: Wed, 11 Jul 2001 21:31:55 +0000 Subject: [PATCH] Fix code that was using 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 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. --- ChangeLog | 33 +++++++ .../help/converters/gnome-info2html2/html.c | 2 +- .../gnome-man2html2/gnome-man2html.c | 95 ++++++++++--------- libnautilus-private/nautilus-file.c | 20 ++-- libnautilus-private/nautilus-volume-monitor.c | 2 + src/nautilus-first-time-druid.c | 4 +- src/nautilus-property-browser.c | 3 +- test/test.c | 2 +- 8 files changed, 99 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36ef98bcf..3fa1b07ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2001-07-11 Darin Adler + + * 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 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. + 2001-07-11 Alex Larsson * acconfig.h: diff --git a/components/help/converters/gnome-info2html2/html.c b/components/help/converters/gnome-info2html2/html.c index f5dd8e545..53378eeb0 100644 --- a/components/help/converters/gnome-info2html2/html.c +++ b/components/help/converters/gnome-info2html2/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/components/help/converters/gnome-man2html2/gnome-man2html.c b/components/help/converters/gnome-man2html2/gnome-man2html.c index b2afe3e19..3cd34a088 100644 --- a/components/help/converters/gnome-man2html2/gnome-man2html.c +++ b/components/help/converters/gnome-man2html2/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 (cprev->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("Document not found\n" "The document \"%s\" couldn't be found. It may have been removed from your system.\n" "\n", infile); return 3; - } + } buf=read_man_page(); if (!buf) { diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 3a5e914f2..84f4cbaf9 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -614,7 +614,7 @@ nautilus_file_denies_access_permission (NautilusFile *file, * Can we trust the uid in the file info? Might * there be garbage there? What will it do for non-local files? */ - if (user_id == file->details->info->uid) { + if (user_id == (uid_t) file->details->info->uid) { return (file->details->info->permissions & owner_permission) == 0; } @@ -627,13 +627,13 @@ nautilus_file_denies_access_permission (NautilusFile *file, * there be garbage there? What will it do for non-local files? */ if (password_info != NULL - && password_info->pw_gid == file->details->info->gid) { + && password_info->pw_gid == (gid_t) file->details->info->gid) { return (file->details->info->permissions & group_permission) == 0; } /* Check supplementary groups */ num_supplementary_groups = getgroups (NGROUPS_MAX, supplementary_groups); for (i = 0; i < num_supplementary_groups; i++) { - if (file->details->info->gid == supplementary_groups[i]) { + if ((gid_t) file->details->info->gid == supplementary_groups[i]) { return (file->details->info->permissions & group_permission) == 0; } } @@ -2889,7 +2889,7 @@ nautilus_file_can_set_permissions (NautilusFile *file) user_id = geteuid(); /* Owner is allowed to set permissions. */ - if (user_id == file->details->info->uid) { + if (user_id == (uid_t) file->details->info->uid) { return TRUE; } @@ -3292,7 +3292,7 @@ nautilus_file_set_owner (NautilusFile *file, * don't want to send the file-changed signal if nothing * changed. */ - if (new_id == file->details->info->uid) { + if (new_id == (uid_t) file->details->info->uid) { (* callback) (file, GNOME_VFS_OK, callback_data); return; } @@ -3390,7 +3390,7 @@ nautilus_file_get_group_name (NautilusFile *file) * there be garbage there? What will it do for non-local files? */ /* No need to free result of getgrgid */ - group_info = getgrgid (file->details->info->gid); + group_info = getgrgid ((gid_t) file->details->info->gid); if (group_info != NULL) { return g_strdup (group_info->gr_name); @@ -3431,7 +3431,7 @@ nautilus_file_can_set_group (NautilusFile *file) user_id = geteuid(); /* Owner is allowed to set group (with restrictions). */ - if (user_id == file->details->info->uid) { + if (user_id == (uid_t) file->details->info->uid) { return TRUE; } @@ -3534,7 +3534,7 @@ nautilus_file_get_settable_group_names (NautilusFile *file) if (user_id == 0) { /* Root is allowed to set group to anything. */ result = nautilus_get_group_names_including (NULL); - } else if (user_id == file->details->info->uid) { + } else if (user_id == (uid_t) file->details->info->uid) { /* Owner is allowed to set group to any that owner is member of. */ user_name_string = get_user_name_from_id (user_id); result = nautilus_get_group_names_including (user_name_string); @@ -3595,7 +3595,7 @@ nautilus_file_set_group (NautilusFile *file, return; } - if (new_id == file->details->info->gid) { + if (new_id == (gid_t) file->details->info->gid) { (* callback) (file, GNOME_VFS_OK, callback_data); return; } @@ -5056,7 +5056,7 @@ nautilus_extract_top_left_text (const char *text, if (*in == '\n') { break; } - if (isprint (*in)) { + if (isprint ((guchar) *in)) { *out++ = *in; i++; } diff --git a/libnautilus-private/nautilus-volume-monitor.c b/libnautilus-private/nautilus-volume-monitor.c index 91179dc48..01b4a0cb2 100644 --- a/libnautilus-private/nautilus-volume-monitor.c +++ b/libnautilus-private/nautilus-volume-monitor.c @@ -462,6 +462,7 @@ get_removable_volumes (void) return g_list_sort (g_list_reverse (volumes), (GCompareFunc) floppy_sort); } +#ifndef SOLARIS_MNT static gboolean volume_is_removable (const NautilusVolume *volume) @@ -554,6 +555,7 @@ volume_is_read_only (const NautilusVolume *volume) return FALSE; } +#endif /* !SOLARIS_MNT */ char * nautilus_volume_monitor_get_volume_name (const NautilusVolume *volume) diff --git a/src/nautilus-first-time-druid.c b/src/nautilus-first-time-druid.c index 0c9c7f9c6..c2d1cb52c 100644 --- a/src/nautilus-first-time-druid.c +++ b/src/nautilus-first-time-druid.c @@ -1459,7 +1459,7 @@ load_netscape_proxy_settings (void) } else if ( NULL != (current = strstr (line, "\"network.proxy.http_port\""))) { current += strlen ("\"network.proxy.http_port\""); - while ( *current && !isdigit(*current)) { + while (*current && !isdigit ((guchar) *current)) { current++; } @@ -1473,7 +1473,7 @@ load_netscape_proxy_settings (void) /* Proxy type must equal '1' */ current += strlen ("\"network.proxy.type\""); - while ( *current && !isdigit(*current)) { + while (*current && !isdigit ((guchar) *current)) { current++; } diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index 2f2f67dae..55f1d4783 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -1252,7 +1252,8 @@ emblem_keyword_valid (const char *keyword) keyword_length = strlen (keyword); for (index = 0; index < keyword_length; index++) { - if (!isalnum (keyword[index]) && !isspace (keyword[index])) { + if (!isalnum ((guchar) keyword[index]) + && !isspace ((guchar) keyword[index])) { return FALSE; } } diff --git a/test/test.c b/test/test.c index af3a0f16c..bca28f8dc 100644 --- a/test/test.c +++ b/test/test.c @@ -311,7 +311,7 @@ test_window_set_title_with_pid (GtkWindow *window, g_return_if_fail (GTK_IS_WINDOW (window)); - tmp = g_strdup_printf ("%d: %s", getpid (), title); + tmp = g_strdup_printf ("%lu: %s", (gulong) getpid (), title); gtk_window_set_title (GTK_WINDOW (window), tmp); g_free (tmp); }