OLD | NEW |
1 /* libnih | 1 /* libnih |
2 * | 2 * |
3 * string.c - useful string utility functions | 3 * string.c - useful string utility functions |
4 * | 4 * |
5 * Copyright © 2009 Scott James Remnant <scott@netsplit.com>. | 5 * Copyright © 2009 Scott James Remnant <scott@netsplit.com>. |
6 * Copyright © 2009 Canonical Ltd. | 6 * Copyright © 2009 Canonical Ltd. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License version 2, as | 9 * it under the terms of the GNU General Public License version 2, as |
10 * published by the Free Software Foundation. | 10 * published by the Free Software Foundation. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 len = 0; | 399 len = 0; |
400 array = nih_str_array_new (parent); | 400 array = nih_str_array_new (parent); |
401 if (! array) | 401 if (! array) |
402 return NULL; | 402 return NULL; |
403 | 403 |
404 while (*str) { | 404 while (*str) { |
405 const char *ptr; | 405 const char *ptr; |
406 | 406 |
407 /* Skip initial delimiters */ | 407 /* Skip initial delimiters */ |
408 » » while (repeat && strchr (delim, *str)) | 408 » » while (repeat && *str && strchr (delim, *str)) |
409 str++; | 409 str++; |
410 | 410 |
| 411 if (! *str) |
| 412 break; |
| 413 |
411 /* Find the end of the token */ | 414 /* Find the end of the token */ |
412 ptr = str; | 415 ptr = str; |
413 while (*str && (! strchr (delim, *str))) | 416 while (*str && (! strchr (delim, *str))) |
414 str++; | 417 str++; |
415 | 418 |
416 if (! nih_str_array_addn (&array, parent, &len, | 419 if (! nih_str_array_addn (&array, parent, &len, |
417 ptr, str - ptr)) { | 420 ptr, str - ptr)) { |
418 nih_free (array); | 421 nih_free (array); |
419 return NULL; | 422 return NULL; |
420 } | 423 } |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 size_t indent) | 950 size_t indent) |
948 { | 951 { |
949 size_t len; | 952 size_t len; |
950 | 953 |
951 nih_assert (str != NULL); | 954 nih_assert (str != NULL); |
952 | 955 |
953 len = nih_str_screen_width () - 1; | 956 len = nih_str_screen_width () - 1; |
954 | 957 |
955 return nih_str_wrap (parent, str, len, first_indent, indent); | 958 return nih_str_wrap (parent, str, len, first_indent, indent); |
956 } | 959 } |
OLD | NEW |