Re: Some string parsing functions
- From: Pavel Císler <pavel eazel com>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-devel-list redhat com
- Subject: Re: Some string parsing functions
- Date: Sat, 15 Jul 2000 21:17:46 -0700
> > gint g_str_find_substr_index_start_from (const gchar *str, guint startpos, const gchar *str_to_find);
>
> strstr (str + starpos, str_to_find)
>
Not quite. You would probably want the following semantics (probably implemented more efficiently):
const char *match;
if (strlen(str) <= startpos)
return -1;
match = strstr(str + startpos, str_to_find);
if (!match)
return -1;
return match-str;
which would indeed justify wrapping it in a call.
>
> > gint g_str_find_substr_index_right (const gchar *str, const gchar *str_to_find);
>
> > gchar *g_str_copy_substr (const gchar *str, guint index, guint count);
>
> g_strndup (str + index, count);
>
> > gchar *g_str_copy_substr_index (const gchar *str, guint startpos, guint endpos);
>
> g_strndup (str + starpos, endpos - startpos);
>
These would also be more convenient if they checked that the string you are trying to copy is long enough, again justifying the respective
call.
Pavel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]