Mercurial > hg
comparison mcabber/src/utils.c @ 554:2424bbf0a6db
Some more work on do_room()
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 29 Nov 2005 23:25:01 +0100 |
parents | b1d71f5107a1 |
children | c4fee1a2c478 |
comparison
equal
deleted
inserted
replaced
553:b1d71f5107a1 | 554:2424bbf0a6db |
---|---|
352 | 352 |
353 // strip_arg_special_chars(string) | 353 // strip_arg_special_chars(string) |
354 // Remove quotes and backslashes before an escaped quote | 354 // Remove quotes and backslashes before an escaped quote |
355 // Only quotes need a backslash | 355 // Only quotes need a backslash |
356 // Ex.: ["a b"] -> [a b]; [a\"b] -> [a"b] | 356 // Ex.: ["a b"] -> [a b]; [a\"b] -> [a"b] |
357 static void strip_arg_special_chars(char *s) | 357 void strip_arg_special_chars(char *s) |
358 { | 358 { |
359 int instring = FALSE; | 359 int instring = FALSE; |
360 int escape = FALSE; | 360 int escape = FALSE; |
361 char *p; | 361 char *p; |
362 | 362 |
381 } | 381 } |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 // split_arg(arg, n) | 386 // split_arg(arg, n, preservelast) |
387 // Split the string arg into a maximum of n pieces, taking care of | 387 // Split the string arg into a maximum of n pieces, taking care of |
388 // double quotes. | 388 // double quotes. |
389 // Return a null-terminated array of strings. This array should be freed | 389 // Return a null-terminated array of strings. This array should be freed |
390 // be the caller after use, for example with free_arg_lst(). | 390 // be the caller after use, for example with free_arg_lst(). |
391 char **split_arg(const char *arg, unsigned int n) | 391 char **split_arg(const char *arg, unsigned int n, int dontstriplast) |
392 { | 392 { |
393 char **arglst; | 393 char **arglst; |
394 const char *p, *start, *end; | 394 const char *p, *start, *end; |
395 int i = 0; | 395 int i = 0; |
396 int instring = FALSE; | 396 int instring = FALSE; |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 if (start < end) { | 427 if (start < end) { |
428 *(arglst+i) = g_strndup(start, end-start); | 428 *(arglst+i) = g_strndup(start, end-start); |
429 strip_arg_special_chars(*(arglst+i)); | 429 if (!dontstriplast) |
430 strip_arg_special_chars(*(arglst+i)); | |
430 } | 431 } |
431 | 432 |
432 return arglst; | 433 return arglst; |
433 } | 434 } |
434 | 435 |