Re: [Vala] Possible but in string.index_of, index_of_char and contains
- From: Evan Nemerson <evan coeus-group com>
- To: Nor Jaidi Tuah <norjaidi tuah ubd edu bn>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Possible but in string.index_of, index_of_char and contains
- Date: Wed, 16 Oct 2013 20:20:37 -0700
On Thu, 2013-10-17 at 11:07 +0800, Nor Jaidi Tuah wrote:
On Wed, 2013-10-16 at 19:45 -0700, Evan Nemerson wrote:
On Thu, 2013-10-17 at 09:19 +0800, Nor Jaidi Tuah wrote:
"ABC".index_of_char('\x00'): 0
This looks like a bug. But why should
you want to search for \x00 ?
string.index_of_char is basically a wrapper around g_utf8_strchr. I
guess g_utf8_strchr could return null if c==0, but it does feel a bit
ridiculous. If you feel strongly about it you can file a bug against
glib.
I thought it should return -1.
string.index_of_char is a wrapper which calls string.utf8_strchr.
string.utf8_strchr is the binding for g_utf8_strchr. g_utf8_strchr
should probably return NULL (instead of a pointer to the beginning of
the string), which would cause string.index_of_char to return -1.
But this is a very very very minor bug.
I can't think of a reason to search for \x00
(Any program searching for \0 in a string
must have a serious bug somewhere)
So, getting this fixed really gains nothing.
Agreed. I'd probably do a g_return_val_if_fail (c != 0, NULL) to make
it clear that the request is nonsensical.
-Evan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]