diff options
author | Colin Walters <walters@verbum.org> | 2013-04-08 15:32:15 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-04-08 15:32:15 -0400 |
commit | d03bbfa52c328f2250b40777077b464e6978d47f (patch) | |
tree | 0be9ee84ede2e1c786fa47ec6840c9a39d150c22 /girepository | |
parent | 3cfad15a57bb16cc7a0ee3655c8e0d4bdab0a056 (diff) | |
download | gobject-introspection-d03bbfa52c328f2250b40777077b464e6978d47f.tar.gz |
gitypelib: And another fix for empty strings
Diffstat (limited to 'girepository')
-rw-r--r-- | girepository/gitypelib.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index f7d07e3f..a643cde1 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -226,6 +226,7 @@ g_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, typedef struct { const char *s; const char *separator; + gsize sep_len; GString buf; } StrSplitIter; @@ -236,6 +237,7 @@ strsplit_iter_init (StrSplitIter *iter, { iter->s = s; iter->separator = separator; + iter->sep_len = strlen (separator); iter->buf.str = NULL; iter->buf.len = 0; iter->buf.allocated_len = 0; @@ -254,7 +256,7 @@ strsplit_iter_next (StrSplitIter *iter, next = strstr (s, iter->separator); if (next) { - iter->s = next + 1; + iter->s = next + iter->sep_len; len = next - s; } else @@ -262,8 +264,15 @@ strsplit_iter_next (StrSplitIter *iter, iter->s = NULL; len = strlen (s); } - g_string_overwrite_len (&iter->buf, 0, s, (gssize)len); - *out_val = iter->buf.str; + if (len == 0) + { + *out_val = ""; + } + else + { + g_string_overwrite_len (&iter->buf, 0, s, (gssize)len); + *out_val = iter->buf.str; + } return TRUE; } |