~ubuntu-branches/ubuntu/raring/libnih/raring

« back to all changes in this revision

Viewing changes to nih/string.c

  • Committer: James Hunt
  • Date: 2013-03-14 10:27:34 UTC
  • mfrom: (1027.1.34 upstart-devel-libnih)
  • Revision ID: james.hunt@ubuntu.com-20130314102734-blit21ei3v9n0u2o
Tags: 1.0.3-4ubuntu16
Merge of important fixes from lp:~upstart-devel/libnih/nih
(LP: #776532, LP: #777097, LP: #834813, LP: #1123588).

Show diffs side-by-side

added added

removed removed

Lines of Context:
405
405
                const char  *ptr;
406
406
 
407
407
                /* Skip initial delimiters */
408
 
                while (repeat && strchr (delim, *str))
 
408
                while (repeat && *str && strchr (delim, *str))
409
409
                        str++;
410
410
 
411
411
                /* Find the end of the token */
413
413
                while (*str && (! strchr (delim, *str)))
414
414
                        str++;
415
415
 
 
416
                /* Don't create an empty string array element in repeat
 
417
                 * mode if there is no token (as a result of a
 
418
                 * duplicated delimiter character).
 
419
                 */
 
420
                if (repeat && (str == ptr))
 
421
                        continue;
 
422
 
416
423
                if (! nih_str_array_addn (&array, parent, &len,
417
424
                                          ptr, str - ptr)) {
418
425
                        nih_free (array);