… | |
… | |
233 | static class rxvt_failure_exception rxvt_failure_exception; |
233 | static class rxvt_failure_exception rxvt_failure_exception; |
234 | throw (rxvt_failure_exception); |
234 | throw (rxvt_failure_exception); |
235 | } |
235 | } |
236 | |
236 | |
237 | /* |
237 | /* |
238 | * check that the first characters of S1 match S2 |
238 | * remove leading/trailing space in place. |
239 | * |
|
|
240 | * No Match |
|
|
241 | * return: 0 |
|
|
242 | * Match |
|
|
243 | * return: strlen (S2) |
|
|
244 | */ |
|
|
245 | int |
|
|
246 | rxvt_Str_match (const char *s1, const char *s2) NOTHROW |
|
|
247 | { |
|
|
248 | int n = strlen (s2); |
|
|
249 | |
|
|
250 | return ((strncmp (s1, s2, n) == 0) ? n : 0); |
|
|
251 | } |
|
|
252 | |
|
|
253 | const char * |
|
|
254 | rxvt_Str_skip_space (const char *str) NOTHROW |
|
|
255 | { |
|
|
256 | if (str) |
|
|
257 | while (*str && isspace (*str)) |
|
|
258 | str++; |
|
|
259 | |
|
|
260 | return str; |
|
|
261 | } |
|
|
262 | |
|
|
263 | /* |
|
|
264 | * remove leading/trailing space and strip-off leading/trailing quotes. |
|
|
265 | * in place. |
|
|
266 | */ |
239 | */ |
267 | char * |
240 | char * |
268 | rxvt_Str_trim (char *str) NOTHROW |
241 | rxvt_Str_trim (char *str) NOTHROW |
269 | { |
242 | { |
270 | char *r, *s; |
243 | char *r, *s; |
… | |
… | |
279 | r = s + strlen (s) - 1; |
252 | r = s + strlen (s) - 1; |
280 | |
253 | |
281 | /* dump return and other trailing whitespace */ |
254 | /* dump return and other trailing whitespace */ |
282 | while (r > s && isspace (*r)) |
255 | while (r > s && isspace (*r)) |
283 | r--; |
256 | r--; |
284 | |
|
|
285 | #if 0 |
|
|
286 | /* skip matching leading/trailing quotes */ |
|
|
287 | if (*s == '"' && *r == '"' && n > 1) |
|
|
288 | { |
|
|
289 | s++; |
|
|
290 | n -= 2; |
|
|
291 | } |
|
|
292 | #endif |
|
|
293 | |
257 | |
294 | memmove (str, s, r + 1 - s); |
258 | memmove (str, s, r + 1 - s); |
295 | str[r + 1 - s] = 0; |
259 | str[r + 1 - s] = 0; |
296 | |
260 | |
297 | return str; |
261 | return str; |