diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-08-02 08:24:31 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-08-02 08:24:31 +0000 |
commit | 3ca4175052e8a6c26a6cc93501e92a4436cad3df (patch) | |
tree | cd8c6b5f88ff65d5e74c27638eaaf4ec13572828 /src/utils.c | |
parent | e059bc94965dd6cb4afcff3d5efceec32a98a5a0 (diff) |
fixed gcc-4.0 warnings.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@457 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 97 |
1 files changed, 50 insertions, 47 deletions
diff --git a/src/utils.c b/src/utils.c index 932c8320..56c60c0f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -147,12 +147,12 @@ gboolean str_case_find_equal(const gchar *haystack, const gchar *needle) gint to_number(const gchar *nstr) { - register const guchar *p; + register const gchar *p; if (*nstr == '\0') return -1; for (p = nstr; *p != '\0'; p++) - if (!isdigit(*p)) return -1; + if (!g_ascii_isdigit(*p)) return -1; return atoi(nstr); } @@ -322,14 +322,14 @@ gchar *strncpy2(gchar *dest, const gchar *src, size_t n) #if !HAVE_ISWALNUM int iswalnum(wint_t wc) { - return isalnum((int)wc); + return g_ascii_isalnum((int)wc); } #endif #if !HAVE_ISWSPACE int iswspace(wint_t wc) { - return isspace((int)wc); + return g_ascii_isspace((int)wc); } #endif @@ -525,26 +525,26 @@ gint get_mbs_len(const gchar *s) } /* Examine if next block is non-ASCII string */ -gboolean is_next_nonascii(const guchar *s) +gboolean is_next_nonascii(const gchar *s) { - const guchar *p; + const gchar *p; /* skip head space */ - for (p = s; *p != '\0' && isspace(*p); p++) + for (p = s; *p != '\0' && g_ascii_isspace(*p); p++) ; - for (; *p != '\0' && !isspace(*p); p++) { - if (*p > 127 || *p < 32) + for (; *p != '\0' && !g_ascii_isspace(*p); p++) { + if (*(guchar *)p > 127 || *(guchar *)p < 32) return TRUE; } return FALSE; } -gint get_next_word_len(const guchar *s) +gint get_next_word_len(const gchar *s) { gint len = 0; - for (; *s != '\0' && !isspace(*s); s++, len++) + for (; *s != '\0' && !g_ascii_isspace(*s); s++, len++) ; return len; @@ -586,7 +586,7 @@ gint subject_compare_for_sort(const gchar *s1, const gchar *s2) void trim_subject_for_compare(gchar *str) { - guchar *srcp; + gchar *srcp; eliminate_parenthesis(str, '[', ']'); eliminate_parenthesis(str, '(', ')'); @@ -594,34 +594,34 @@ void trim_subject_for_compare(gchar *str) while (!g_ascii_strncasecmp(str, "Re:", 3)) { srcp = str + 3; - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(str, srcp, strlen(srcp) + 1); } } void trim_subject_for_sort(gchar *str) { - guchar *srcp; + gchar *srcp; g_strstrip(str); while (!g_ascii_strncasecmp(str, "Re:", 3)) { srcp = str + 3; - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(str, srcp, strlen(srcp) + 1); } } void trim_subject(gchar *str) { - register guchar *srcp, *destp; + register gchar *srcp, *destp; gchar op, cl; gint in_brace; destp = str; while (!g_ascii_strncasecmp(destp, "Re:", 3)) { destp += 3; - while (isspace(*destp)) destp++; + while (g_ascii_isspace(*destp)) destp++; } if (*destp == '[') { @@ -644,13 +644,13 @@ void trim_subject(gchar *str) if (in_brace == 0) break; } - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(destp, srcp, strlen(srcp) + 1); } void eliminate_parenthesis(gchar *str, gchar op, gchar cl) { - register guchar *srcp, *destp; + register gchar *srcp, *destp; gint in_brace; srcp = destp = str; @@ -667,7 +667,7 @@ void eliminate_parenthesis(gchar *str, gchar op, gchar cl) if (in_brace == 0) break; } - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(destp, srcp, strlen(srcp) + 1); } } @@ -732,14 +732,14 @@ void extract_parenthesis_with_skip_quote(gchar *str, gchar quote_chr, void eliminate_quote(gchar *str, gchar quote_chr) { - register guchar *srcp, *destp; + register gchar *srcp, *destp; srcp = destp = str; while ((destp = strchr(destp, quote_chr))) { if ((srcp = strchr(destp + 1, quote_chr))) { srcp++; - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(destp, srcp, strlen(srcp) + 1); } else { *destp = '\0'; @@ -762,7 +762,7 @@ void extract_quote(gchar *str, gchar quote_chr) void eliminate_address_comment(gchar *str) { - register guchar *srcp, *destp; + register gchar *srcp, *destp; gint in_brace; srcp = destp = str; @@ -773,7 +773,7 @@ void eliminate_address_comment(gchar *str) if (*srcp == '@') { destp = srcp + 1; } else { - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(destp, srcp, strlen(srcp) + 1); } } else { @@ -796,7 +796,7 @@ void eliminate_address_comment(gchar *str) if (in_brace == 0) break; } - while (isspace(*srcp)) srcp++; + while (g_ascii_isspace(*srcp)) srcp++; memmove(destp, srcp, strlen(srcp) + 1); } } @@ -994,12 +994,12 @@ void remove_return(gchar *str) void remove_space(gchar *str) { - register guchar *p = str; + register gchar *p = str; register gint spc; while (*p) { spc = 0; - while (isspace(*(p + spc))) + while (g_ascii_isspace(*(p + spc))) spc++; if (spc) memmove(p, p + spc, strlen(p + spc) + 1); @@ -1010,14 +1010,14 @@ void remove_space(gchar *str) void unfold_line(gchar *str) { - register guchar *p = str; + register gchar *p = str; register gint spc; while (*p) { if (*p == '\n' || *p == '\r') { *p++ = ' '; spc = 0; - while (isspace(*(p + spc))) + while (g_ascii_isspace(*(p + spc))) spc++; if (spc) memmove(p, p + spc, strlen(p + spc) + 1); @@ -1077,14 +1077,16 @@ gboolean is_header_line(const gchar *str) return FALSE; } -gboolean is_ascii_str(const guchar *str) +gboolean is_ascii_str(const gchar *str) { - while (*str != '\0') { - if (*str != '\t' && *str != ' ' && - *str != '\r' && *str != '\n' && - (*str < 32 || *str >= 127)) + const guchar *p = (const guchar *)str; + + while (*p != '\0') { + if (*p != '\t' && *p != ' ' && + *p != '\r' && *p != '\n' && + (*p < 32 || *p >= 127)) return FALSE; - str++; + p++; } return TRUE; @@ -1092,15 +1094,15 @@ gboolean is_ascii_str(const guchar *str) gint get_quote_level(const gchar *str) { - const guchar *first_pos; - const guchar *last_pos; - const guchar *p = str; + const gchar *first_pos; + const gchar *last_pos; + const gchar *p = str; gint quote_level = -1; /* speed up line processing by only searching to the last '>' */ if ((first_pos = strchr(str, '>')) != NULL) { /* skip a line if it contains a '<' before the initial '>' */ - if (memchr(str, '<', first_pos - (const guchar *)str) != NULL) + if (memchr(str, '<', first_pos - str) != NULL) return -1; last_pos = strrchr(first_pos, '>'); } else @@ -1108,7 +1110,7 @@ gint get_quote_level(const gchar *str) while (p <= last_pos) { while (p < last_pos) { - if (isspace(*p)) + if (g_ascii_isspace(*p)) p++; else break; @@ -1116,9 +1118,9 @@ gint get_quote_level(const gchar *str) if (*p == '>') quote_level++; - else if (*p != '-' && !isspace(*p) && p <= last_pos) { + else if (*p != '-' && !g_ascii_isspace(*p) && p <= last_pos) { /* any characters are allowed except '-' and space */ - while (*p != '-' && *p != '>' && !isspace(*p) && + while (*p != '-' && *p != '>' && !g_ascii_isspace(*p) && p < last_pos) p++; if (*p == '>') @@ -1257,7 +1259,7 @@ gchar **strsplit_parenthesis(const gchar *str, gchar op, gchar cl, n++; str = s_cl + 1; - while (*str && isspace(*(guchar *)str)) str++; + while (*str && g_ascii_isspace(*str)) str++; if (*str != op) { string_list = g_slist_prepend(string_list, g_strdup("")); @@ -1428,14 +1430,14 @@ gchar *trim_string_before(const gchar *str, gint len) GList *uri_list_extract_filenames(const gchar *uri_list) { GList *result = NULL; - const guchar *p, *q; + const gchar *p, *q; gchar *file; p = uri_list; while (p) { if (*p != '#') { - while (isspace(*p)) p++; + while (g_ascii_isspace(*p)) p++; if (!strncmp(p, "file:", 5)) { p += 5; while (*p == '/' && *(p + 1) == '/') p++; @@ -1444,7 +1446,8 @@ GList *uri_list_extract_filenames(const gchar *uri_list) if (q > p) { q--; - while (q > p && isspace(*q)) q--; + while (q > p && g_ascii_isspace(*q)) + q--; file = g_malloc(q - p + 2); strncpy(file, p, q - p + 1); file[q - p + 1] = '\0'; @@ -2867,7 +2870,7 @@ gchar *file_read_to_str(const gchar *file) gchar *file_read_stream_to_str(FILE *fp) { GByteArray *array; - gchar buf[BUFSIZ]; + guchar buf[BUFSIZ]; gint n_read; gchar *str; |