… | |
… | |
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 | /* |
|
|
254 | * remove leading/trailing space and strip-off leading/trailing quotes. |
|
|
255 | * in place. |
|
|
256 | */ |
239 | */ |
257 | char * |
240 | char * |
258 | rxvt_Str_trim (char *str) NOTHROW |
241 | rxvt_Str_trim (char *str) NOTHROW |
259 | { |
242 | { |
260 | char *r, *s; |
243 | char *r, *s; |
… | |
… | |
269 | r = s + strlen (s) - 1; |
252 | r = s + strlen (s) - 1; |
270 | |
253 | |
271 | /* dump return and other trailing whitespace */ |
254 | /* dump return and other trailing whitespace */ |
272 | while (r > s && isspace (*r)) |
255 | while (r > s && isspace (*r)) |
273 | r--; |
256 | r--; |
274 | |
|
|
275 | #if 0 |
|
|
276 | /* skip matching leading/trailing quotes */ |
|
|
277 | if (*s == '"' && *r == '"' && n > 1) |
|
|
278 | { |
|
|
279 | s++; |
|
|
280 | n -= 2; |
|
|
281 | } |
|
|
282 | #endif |
|
|
283 | |
257 | |
284 | memmove (str, s, r + 1 - s); |
258 | memmove (str, s, r + 1 - s); |
285 | str[r + 1 - s] = 0; |
259 | str[r + 1 - s] = 0; |
286 | |
260 | |
287 | return str; |
261 | return str; |