[gobject-introspection] gitypelib: And another fix for empty strings
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] gitypelib: And another fix for empty strings
- Date: Mon, 8 Apr 2013 19:40:03 +0000 (UTC)
commit d03bbfa52c328f2250b40777077b464e6978d47f
Author: Colin Walters <walters verbum org>
Date: Mon Apr 8 15:32:15 2013 -0400
gitypelib: And another fix for empty strings
girepository/gitypelib.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c
index f7d07e3..a643cde 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]