Ticket #3547: mc-3547-cleanup-conversion-warning-strutils_escape.patch
File mc-3547-cleanup-conversion-warning-strutils_escape.patch, 6.8 KB (added by and, 8 years ago) |
---|
-
lib/strescape.h
fix -Wconversion warning at strutils_escape/strutils_unescape() remove src_len parameter support, never used in mc patch will fix following warnings: strescape.c:180:34: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] strescape.c:188:34: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] strescape.c:196:34: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] strescape.c:213:37: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] strescape.c:221:37: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] strescape.c:228:37: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] panel.c:2646:41: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] treestore.c:330:63: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] learn.c:363:63: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion] patch against a5cd0093c5330ae6118cbf2830cf288dd4a68ed0 compile test with gcc 4.6/4.9/5.2 and clang 3.7 Signed-off-by: Andreas Mohr <and@gmx.li>
a e 15 15 16 16 /*** declarations of public functions ************************************************************/ 17 17 18 char *strutils_escape (const char *, gsize,const char *, gboolean);19 char *strutils_unescape (const char *, gsize,const char *, gboolean);18 char *strutils_escape (const char *, const char *, gboolean); 19 char *strutils_unescape (const char *, const char *, gboolean); 20 20 21 21 char *strutils_shell_unescape (const char *); 22 22 char *strutils_shell_escape (const char *); -
lib/strutil/strescape.c
a e 46 46 /*** public functions ****************************************************************************/ 47 47 48 48 char * 49 strutils_escape (const char *src, gsize src_len,const char *escaped_chars,49 strutils_escape (const char *src, const char *escaped_chars, 50 50 gboolean escape_non_printable) 51 51 { 52 52 GString *ret; 53 gsize curr_index ;53 gsize curr_index, src_len; 54 54 /* do NOT break allocation semantics */ 55 55 if (src == NULL) 56 56 return NULL; … … 60 60 61 61 ret = g_string_new (""); 62 62 63 if (src_len == (gsize) (-1)) 64 src_len = strlen (src); 63 src_len = strlen (src); 65 64 66 65 for (curr_index = 0; curr_index < src_len; curr_index++) 67 66 { … … 96 95 97 96 /* --------------------------------------------------------------------------------------------- */ 98 97 char * 99 strutils_unescape (const char *src, gsize src_len,const char *unescaped_chars,98 strutils_unescape (const char *src, const char *unescaped_chars, 100 99 gboolean unescape_non_printable) 101 100 { 102 101 GString *ret; 103 gsize curr_index ;102 gsize curr_index, src_len; 104 103 105 104 if (src == NULL) 106 105 return NULL; … … 110 109 111 110 ret = g_string_sized_new (16); 112 111 113 if (src_len == (gsize) (-1)) 114 src_len = strlen (src); 112 src_len = strlen (src); 115 113 src_len--; 116 114 117 115 for (curr_index = 0; curr_index < src_len; curr_index++) … … 177 175 char * 178 176 strutils_shell_escape (const char *src) 179 177 { 180 return strutils_escape (src, -1,ESCAPE_SHELL_CHARS, FALSE);178 return strutils_escape (src, ESCAPE_SHELL_CHARS, FALSE); 181 179 } 182 180 183 181 /* --------------------------------------------------------------------------------------------- */ … … 185 183 char * 186 184 strutils_glob_escape (const char *src) 187 185 { 188 return strutils_escape (src, -1,ESCAPE_GLOB_CHARS, TRUE);186 return strutils_escape (src, ESCAPE_GLOB_CHARS, TRUE); 189 187 } 190 188 191 189 /* --------------------------------------------------------------------------------------------- */ … … 193 191 char * 194 192 strutils_regex_escape (const char *src) 195 193 { 196 return strutils_escape (src, -1,ESCAPE_REGEX_CHARS, TRUE);194 return strutils_escape (src, ESCAPE_REGEX_CHARS, TRUE); 197 195 } 198 196 199 197 /* --------------------------------------------------------------------------------------------- */ … … 210 208 char * 211 209 strutils_shell_unescape (const char *text) 212 210 { 213 return strutils_unescape (text, -1,ESCAPE_SHELL_CHARS, TRUE);211 return strutils_unescape (text, ESCAPE_SHELL_CHARS, TRUE); 214 212 } 215 213 216 214 /* --------------------------------------------------------------------------------------------- */ … … 218 216 char * 219 217 strutils_glob_unescape (const char *text) 220 218 { 221 return strutils_unescape (text, -1,ESCAPE_GLOB_CHARS, TRUE);219 return strutils_unescape (text, ESCAPE_GLOB_CHARS, TRUE); 222 220 } 223 221 224 222 /* --------------------------------------------------------------------------------------------- */ 225 223 char * 226 224 strutils_regex_unescape (const char *text) 227 225 { 228 return strutils_unescape (text, -1,ESCAPE_REGEX_CHARS, TRUE);226 return strutils_unescape (text, ESCAPE_REGEX_CHARS, TRUE); 229 227 } 230 228 231 229 /* --------------------------------------------------------------------------------------------- */ -
src/filemanager/panel.c
a e 2643 2643 } 2644 2644 2645 2645 reg_exp = g_strdup_printf ("%s*", panel->search_buffer); 2646 esc_str = strutils_escape (reg_exp, -1,",|\\{}[]", TRUE);2646 esc_str = strutils_escape (reg_exp, ",|\\{}[]", TRUE); 2647 2647 search = mc_search_new (esc_str, -1, NULL); 2648 2648 search->search_type = MC_SEARCH_T_GLOB; 2649 2649 search->is_entire_line = TRUE; -
src/filemanager/treestore.c
a e 327 327 static char * 328 328 encode (const vfs_path_t * vpath, size_t offset) 329 329 { 330 return strutils_escape (vfs_path_as_str (vpath) + offset, -1,"\n\\", FALSE);330 return strutils_escape (vfs_path_as_str (vpath) + offset, "\n\\", FALSE); 331 331 } 332 332 333 333 /* --------------------------------------------------------------------------------------------- */ -
src/learn.c
a e 360 360 { 361 361 char *esc_str; 362 362 363 esc_str = strutils_escape (learnkeys[i].sequence, -1,";\\", TRUE);363 esc_str = strutils_escape (learnkeys[i].sequence, ";\\", TRUE); 364 364 mc_config_set_string_raw_value (mc_main_config, section, key_name_conv_tab[i].name, 365 365 esc_str); 366 366 g_free (esc_str); -
tests/lib/mcconfig/config_string.c
a e 215 215 { 216 216 char *esc_str; 217 217 218 esc_str = strutils_escape ("T;E\\X;T-FOR-\\T;E;S\\TI;N'G", -1,";", TRUE);218 esc_str = strutils_escape ("T;E\\X;T-FOR-\\T;E;S\\TI;N'G", ";", TRUE); 219 219 mc_config_set_string_raw (mc_config, "test-group1", "test-param1", esc_str); 220 220 g_free (esc_str); 221 221 }