mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-14 19:55:12 +01:00
Changes for 64-bit cleanliness, loosely based on patch from Mark Murnane.
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com> Changes for 64-bit cleanliness, loosely based on patch from Mark Murnane. * gconvert.c (g_convert/g_convert_with_fallback): Remove workarounds for since-fixed GNU libc bugs. Minor doc fix. * gconvert.[ch]: Change gint to gsize/gssize as appropriate. * gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect computation of bytes_read / bytes_written. * gfileutils.[ch] (g_file_get_contents): Make length out parameter 'gsize *len'. * ghook.c (g_hook_compare_ids): Don't compare a and b as 'a - b'. * gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE, GSIZE_TO_POINTER. * gmain.c (g_timeout_prepare): Rewrite to avoid overflows. (Fixes bug when system clock skews backwards more than 24 days.) * gmarkup.[ch]: Make lengths passed to callbacks gsize, length for g_markup_parse-context_parse(), g_markup_escape_text() gssize. * gmessages.[ch] (g_printf_string_upper_bound): Change return value to gsize. * gmessages.c (printf_string_upper_bound): Remove a ridiculous use of 'inline' on a 300 line function. * gstring.[ch]: Represent size of string as a gsize, not gint. Make parameters to functions take gsize, or gssize where -1 is allowed. * gstring.c (g_string_erase): Make g_string_erase (string, pos, -1) a synonym for g_string_truncate for consistency with other G* APIs. * gstrfuncs.[ch]: Make all functions taking a string length, take a gsize, or gssize if -1 is allowed. (g_strstr_len, g_strrstr_len). Also fix some boundary conditions in g_str[r]str[_len]. * gutf8.c tests/unicode-encoding.c: Make parameters that are byte lengths gsize, gssize as appropriate. Make character offsets, other counts, glong. * gasyncqueue.c gcompletion.c timeloop.c timeloop-basic.c gutils.c gspawn.c. Small 64 bit cleanliness fixups. * glist.c (g_list_sort2, g_list_sort_real): Fix functions that should have been static. * gdate.c (g_date_fill_parse_tokens): Fix extra declaration that was shadowing another. * tests/module-test.c: Include string.h Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com> * gutf8.c (g_get_charset): Make argument G_CONST_RETURN char **.
This commit is contained in:
parent
a7bd3d0d5e
commit
f5c28ce4ab
73
ChangeLog
73
ChangeLog
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -1,3 +1,76 @@
|
|||||||
|
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Changes for 64-bit cleanliness, loosely based on patch
|
||||||
|
from Mark Murnane.
|
||||||
|
|
||||||
|
* gconvert.c (g_convert/g_convert_with_fallback): Remove
|
||||||
|
workarounds for since-fixed GNU libc bugs. Minor
|
||||||
|
doc fix.
|
||||||
|
|
||||||
|
* gconvert.[ch]: Change gint to gsize/gssize as
|
||||||
|
appropriate.
|
||||||
|
|
||||||
|
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
|
||||||
|
computation of bytes_read / bytes_written.
|
||||||
|
|
||||||
|
* gfileutils.[ch] (g_file_get_contents): Make length
|
||||||
|
out parameter 'gsize *len'.
|
||||||
|
|
||||||
|
* ghook.c (g_hook_compare_ids): Don't compare a
|
||||||
|
and b as 'a - b'.
|
||||||
|
|
||||||
|
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
|
||||||
|
GSIZE_TO_POINTER.
|
||||||
|
|
||||||
|
* gmain.c (g_timeout_prepare): Rewrite to avoid
|
||||||
|
overflows. (Fixes bug when system clock skews
|
||||||
|
backwards more than 24 days.)
|
||||||
|
|
||||||
|
* gmarkup.[ch]: Make lengths passed to callbacks
|
||||||
|
gsize, length for g_markup_parse-context_parse(),
|
||||||
|
g_markup_escape_text() gssize.
|
||||||
|
|
||||||
|
* gmessages.[ch] (g_printf_string_upper_bound): Change
|
||||||
|
return value to gsize.
|
||||||
|
|
||||||
|
* gmessages.c (printf_string_upper_bound): Remove
|
||||||
|
a ridiculous use of 'inline' on a 300 line function.
|
||||||
|
|
||||||
|
* gstring.[ch]: Represent size of string as a gsize,
|
||||||
|
not gint. Make parameters to functions take gsize,
|
||||||
|
or gssize where -1 is allowed.
|
||||||
|
|
||||||
|
* gstring.c (g_string_erase): Make
|
||||||
|
g_string_erase (string, pos, -1) a synonym for
|
||||||
|
g_string_truncate for consistency with other G*
|
||||||
|
APIs.
|
||||||
|
|
||||||
|
* gstrfuncs.[ch]: Make all functions taking a string
|
||||||
|
length, take a gsize, or gssize if -1 is allowed.
|
||||||
|
(g_strstr_len, g_strrstr_len). Also fix some boundary
|
||||||
|
conditions in g_str[r]str[_len].
|
||||||
|
|
||||||
|
* gutf8.c tests/unicode-encoding.c: Make parameters that
|
||||||
|
are byte lengths gsize, gssize as appropriate. Make
|
||||||
|
character offsets, other counts, glong.
|
||||||
|
|
||||||
|
* gasyncqueue.c gcompletion.c
|
||||||
|
timeloop.c timeloop-basic.c gutils.c gspawn.c.
|
||||||
|
Small 64 bit cleanliness fixups.
|
||||||
|
|
||||||
|
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
|
||||||
|
that should have been static.
|
||||||
|
|
||||||
|
* gdate.c (g_date_fill_parse_tokens): Fix extra
|
||||||
|
declaration that was shadowing another.
|
||||||
|
|
||||||
|
* tests/module-test.c: Include string.h
|
||||||
|
|
||||||
|
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gutf8.c (g_get_charset): Make argument
|
||||||
|
G_CONST_RETURN char **.
|
||||||
|
|
||||||
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
2001-06-22 Andrew Lanoix <alanoix@umich.edu>
|
||||||
|
|
||||||
*giowin32.c: Debug and partial rewrite of async socket code
|
*giowin32.c: Debug and partial rewrite of async socket code
|
||||||
|
@ -71,7 +71,6 @@ arrays or arrays on the stack.
|
|||||||
Portable way to copy <type>va_list</type> variables.
|
Portable way to copy <type>va_list</type> variables.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<!-- # Unused Parameters # -->
|
|
||||||
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
|
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
|
||||||
@ap2: a <type>va_list</type>.
|
@ap2: a <type>va_list</type>.
|
||||||
|
|
||||||
|
@ -232,7 +232,8 @@ The rest of the #GString is shifted down to fill the gap.
|
|||||||
|
|
||||||
@string: a #GString.
|
@string: a #GString.
|
||||||
@pos: the position of the characters to remove.
|
@pos: the position of the characters to remove.
|
||||||
@len: the number of characters to remove.
|
@len: the number of characters to remove, or -1 to remove all
|
||||||
|
following characters.
|
||||||
@Returns: the #GString.
|
@Returns: the #GString.
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +31,9 @@ Unicode Manipulation
|
|||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@charset:
|
|
||||||
@Returns:
|
@Returns:
|
||||||
|
<!-- # Unused Parameters # -->
|
||||||
|
@charset:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION g_unichar_validate ##### -->
|
<!-- ##### FUNCTION g_unichar_validate ##### -->
|
||||||
|
4
garray.c
4
garray.c
@ -515,7 +515,7 @@ g_ptr_array_remove (GPtrArray* farray,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||||
int i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (array, FALSE);
|
g_return_val_if_fail (array, FALSE);
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ g_ptr_array_remove_fast (GPtrArray* farray,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||||
int i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (array, FALSE);
|
g_return_val_if_fail (array, FALSE);
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ g_async_queue_timed_pop_unlocked (GAsyncQueue* queue, GTimeVal *end_time)
|
|||||||
gint
|
gint
|
||||||
g_async_queue_length (GAsyncQueue* queue)
|
g_async_queue_length (GAsyncQueue* queue)
|
||||||
{
|
{
|
||||||
glong retval;
|
gint retval;
|
||||||
|
|
||||||
g_return_val_if_fail (queue, 0);
|
g_return_val_if_fail (queue, 0);
|
||||||
g_return_val_if_fail (queue->ref_count > 0, 0);
|
g_return_val_if_fail (queue->ref_count > 0, 0);
|
||||||
|
@ -121,9 +121,9 @@ completion_check_cache (GCompletion* cmp,
|
|||||||
gchar** new_prefix)
|
gchar** new_prefix)
|
||||||
{
|
{
|
||||||
register GList* list;
|
register GList* list;
|
||||||
register gint len;
|
register gsize len;
|
||||||
register gint i;
|
register gsize i;
|
||||||
register gint plen;
|
register gsize plen;
|
||||||
gchar* postfix;
|
gchar* postfix;
|
||||||
gchar* s;
|
gchar* s;
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ g_completion_complete (GCompletion* cmp,
|
|||||||
gchar* prefix,
|
gchar* prefix,
|
||||||
gchar** new_prefix)
|
gchar** new_prefix)
|
||||||
{
|
{
|
||||||
gint plen, len;
|
gsize plen, len;
|
||||||
gint done = 0;
|
gboolean done = FALSE;
|
||||||
GList* list;
|
GList* list;
|
||||||
|
|
||||||
g_return_val_if_fail (cmp != NULL, NULL);
|
g_return_val_if_fail (cmp != NULL, NULL);
|
||||||
@ -193,7 +193,7 @@ g_completion_complete (GCompletion* cmp,
|
|||||||
else
|
else
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
done = 1;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#define __G_COMPLETION_H__
|
#define __G_COMPLETION_H__
|
||||||
|
|
||||||
#include <glist.h>
|
#include <glist.h>
|
||||||
#include <stddef.h> /* For size_t */
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ typedef gchar* (*GCompletionFunc) (gpointer);
|
|||||||
|
|
||||||
typedef gint (*GCompletionStrncmpFunc) (const gchar *s1,
|
typedef gint (*GCompletionStrncmpFunc) (const gchar *s1,
|
||||||
const gchar *s2,
|
const gchar *s2,
|
||||||
size_t n);
|
gsize n);
|
||||||
|
|
||||||
struct _GCompletion
|
struct _GCompletion
|
||||||
{
|
{
|
||||||
|
189
gconvert.c
189
gconvert.c
@ -96,9 +96,9 @@ g_iconv_open (const gchar *to_codeset,
|
|||||||
size_t
|
size_t
|
||||||
g_iconv (GIConv converter,
|
g_iconv (GIConv converter,
|
||||||
gchar **inbuf,
|
gchar **inbuf,
|
||||||
size_t *inbytes_left,
|
gsize *inbytes_left,
|
||||||
gchar **outbuf,
|
gchar **outbuf,
|
||||||
size_t *outbytes_left)
|
gsize *outbytes_left)
|
||||||
{
|
{
|
||||||
iconv_t cd = (iconv_t)converter;
|
iconv_t cd = (iconv_t)converter;
|
||||||
|
|
||||||
@ -179,21 +179,21 @@ open_converter (const gchar *to_codeset,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_convert (const gchar *str,
|
g_convert (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *dest;
|
gchar *dest;
|
||||||
gchar *outp;
|
gchar *outp;
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
size_t inbytes_remaining;
|
gsize inbytes_remaining;
|
||||||
size_t outbytes_remaining;
|
gsize outbytes_remaining;
|
||||||
size_t err;
|
gsize err;
|
||||||
GIConv cd;
|
GIConv cd;
|
||||||
size_t outbuf_size;
|
gsize outbuf_size;
|
||||||
gboolean have_error = FALSE;
|
gboolean have_error = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (str != NULL, NULL);
|
g_return_val_if_fail (str != NULL, NULL);
|
||||||
@ -218,10 +218,7 @@ g_convert (const gchar *str,
|
|||||||
|
|
||||||
p = str;
|
p = str;
|
||||||
inbytes_remaining = len;
|
inbytes_remaining = len;
|
||||||
|
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||||
/* Due to a GLIBC bug, round outbuf_size up to a multiple of 4 */
|
|
||||||
/* + 1 for nul in case len == 1 */
|
|
||||||
outbuf_size = ((len + 3) & ~3) + 1;
|
|
||||||
|
|
||||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||||
outp = dest = g_malloc (outbuf_size);
|
outp = dest = g_malloc (outbuf_size);
|
||||||
@ -241,19 +238,11 @@ g_convert (const gchar *str,
|
|||||||
{
|
{
|
||||||
size_t used = outp - dest;
|
size_t used = outp - dest;
|
||||||
|
|
||||||
/* glibc's iconv can return E2BIG even if there is space
|
outbuf_size *= 2;
|
||||||
* remaining if an internal buffer is exhausted. The
|
dest = g_realloc (dest, outbuf_size);
|
||||||
* folllowing is a heuristic to catch this. The 16 is
|
|
||||||
* pretty arbitrary.
|
|
||||||
*/
|
|
||||||
if (used + 16 > outbuf_size)
|
|
||||||
{
|
|
||||||
outbuf_size = (outbuf_size - 1) * 2 + 1;
|
|
||||||
dest = g_realloc (dest, outbuf_size);
|
|
||||||
|
|
||||||
outp = dest + used;
|
outp = dest + used;
|
||||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||||
}
|
|
||||||
|
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -317,10 +306,7 @@ g_convert (const gchar *str,
|
|||||||
* input string that were successfully converted, or %NULL.
|
* input string that were successfully converted, or %NULL.
|
||||||
* Even if the conversion was succesful, this may be
|
* Even if the conversion was succesful, this may be
|
||||||
* less than len if there were partial characters
|
* less than len if there were partial characters
|
||||||
* at the end of the input. If the error
|
* at the end of the input.
|
||||||
* G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
|
|
||||||
* stored will the byte fofset after the last valid
|
|
||||||
* input sequence.
|
|
||||||
* @bytes_written: the stored in the output buffer (not including the
|
* @bytes_written: the stored in the output buffer (not including the
|
||||||
* terminating nul.
|
* terminating nul.
|
||||||
* @error: location to store the error occuring, or %NULL to ignore
|
* @error: location to store the error occuring, or %NULL to ignore
|
||||||
@ -340,12 +326,12 @@ g_convert (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_convert_with_fallback (const gchar *str,
|
g_convert_with_fallback (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gchar *fallback,
|
gchar *fallback,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *utf8;
|
gchar *utf8;
|
||||||
@ -353,13 +339,13 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
gchar *outp;
|
gchar *outp;
|
||||||
const gchar *insert_str = NULL;
|
const gchar *insert_str = NULL;
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
int inbytes_remaining;
|
gsize inbytes_remaining;
|
||||||
const gchar *save_p = NULL;
|
const gchar *save_p = NULL;
|
||||||
size_t save_inbytes = 0;
|
gsize save_inbytes = 0;
|
||||||
size_t outbytes_remaining;
|
gsize outbytes_remaining;
|
||||||
size_t err;
|
gsize err;
|
||||||
GIConv cd;
|
GIConv cd;
|
||||||
size_t outbuf_size;
|
gsize outbuf_size;
|
||||||
gboolean have_error = FALSE;
|
gboolean have_error = FALSE;
|
||||||
gboolean done = FALSE;
|
gboolean done = FALSE;
|
||||||
|
|
||||||
@ -419,9 +405,8 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
* for the original string while we are converting the fallback
|
* for the original string while we are converting the fallback
|
||||||
*/
|
*/
|
||||||
p = utf8;
|
p = utf8;
|
||||||
/* Due to a GLIBC bug, round outbuf_size up to a multiple of 4 */
|
|
||||||
/* + 1 for nul in case len == 1 */
|
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||||
outbuf_size = ((len + 3) & ~3) + 1;
|
|
||||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||||
outp = dest = g_malloc (outbuf_size);
|
outp = dest = g_malloc (outbuf_size);
|
||||||
|
|
||||||
@ -442,19 +427,11 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
{
|
{
|
||||||
size_t used = outp - dest;
|
size_t used = outp - dest;
|
||||||
|
|
||||||
/* glibc's iconv can return E2BIG even if there is space
|
outbuf_size *= 2;
|
||||||
* remaining if an internal buffer is exhausted. The
|
dest = g_realloc (dest, outbuf_size);
|
||||||
* folllowing is a heuristic to catch this. The 16 is
|
|
||||||
* pretty arbitrary.
|
outp = dest + used;
|
||||||
*/
|
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||||
if (used + 16 > outbuf_size)
|
|
||||||
{
|
|
||||||
outbuf_size = (outbuf_size - 1) * 2 + 1;
|
|
||||||
dest = g_realloc (dest, outbuf_size);
|
|
||||||
|
|
||||||
outp = dest + used;
|
|
||||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -538,6 +515,33 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
strdup_len (const gchar *string,
|
||||||
|
gssize len,
|
||||||
|
gsize *bytes_written,
|
||||||
|
gsize *bytes_read)
|
||||||
|
|
||||||
|
{
|
||||||
|
gsize real_len;
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
real_len = strlen (string);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
real_len = 0;
|
||||||
|
|
||||||
|
while (real_len < len && string[real_len])
|
||||||
|
real_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes_read)
|
||||||
|
*bytes_read = real_len;
|
||||||
|
if (bytes_written)
|
||||||
|
*bytes_written = real_len;
|
||||||
|
|
||||||
|
return g_strndup (string, real_len);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_locale_to_utf8:
|
* g_locale_to_utf8:
|
||||||
* @opsysstring: a string in the encoding of the current locale
|
* @opsysstring: a string in the encoding of the current locale
|
||||||
@ -564,9 +568,9 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_locale_to_utf8 (const gchar *opsysstring,
|
g_locale_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -667,15 +671,14 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
|||||||
|
|
||||||
#else /* !G_PLATFORM_WIN32 */
|
#else /* !G_PLATFORM_WIN32 */
|
||||||
|
|
||||||
char *charset, *str;
|
const char *charset;
|
||||||
|
|
||||||
if (g_get_charset (&charset))
|
if (g_get_charset (&charset))
|
||||||
return g_strdup (opsysstring);
|
return strdup_len (opsysstring, len, bytes_read, bytes_written);
|
||||||
|
else
|
||||||
|
return g_convert (opsysstring, len,
|
||||||
|
"UTF-8", charset, bytes_read, bytes_written, error);
|
||||||
|
|
||||||
str = g_convert (opsysstring, len,
|
|
||||||
"UTF-8", charset, bytes_read, bytes_written, error);
|
|
||||||
|
|
||||||
return str;
|
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,9 +708,9 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_locale_from_utf8 (const gchar *utf8string,
|
g_locale_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -813,17 +816,15 @@ g_locale_from_utf8 (const gchar *utf8string,
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
#else /* !G_PLATFORM_WIN32 */
|
#else /* !G_PLATFORM_WIN32 */
|
||||||
|
|
||||||
gchar *charset, *str;
|
const gchar *charset;
|
||||||
|
|
||||||
if (g_get_charset (&charset))
|
if (g_get_charset (&charset))
|
||||||
return g_strdup (utf8string);
|
return strdup_len (utf8string, len, bytes_read, bytes_written);
|
||||||
|
else
|
||||||
|
return g_convert (utf8string, len,
|
||||||
|
charset, "UTF-8", bytes_read, bytes_written, error);
|
||||||
|
|
||||||
str = g_convert (utf8string, strlen (utf8string),
|
|
||||||
charset, "UTF-8", bytes_read, bytes_written, error);
|
|
||||||
|
|
||||||
return str;
|
|
||||||
|
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -852,9 +853,9 @@ g_locale_from_utf8 (const gchar *utf8string,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_filename_to_utf8 (const gchar *opsysstring,
|
g_filename_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -866,21 +867,8 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
|||||||
return g_locale_to_utf8 (opsysstring, len,
|
return g_locale_to_utf8 (opsysstring, len,
|
||||||
bytes_read, bytes_written,
|
bytes_read, bytes_written,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
if (bytes_read || bytes_written)
|
|
||||||
{
|
|
||||||
gint len = strlen (opsysstring);
|
|
||||||
|
|
||||||
if (bytes_read)
|
|
||||||
*bytes_read = len;
|
|
||||||
if (bytes_written)
|
|
||||||
*bytes_written = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
return g_strdup (opsysstring);
|
|
||||||
else
|
else
|
||||||
return g_strndup (opsysstring, len);
|
return strdup_len (opsysstring, len, bytes_read, bytes_written);
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,9 +896,9 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_filename_from_utf8 (const gchar *utf8string,
|
g_filename_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -922,20 +910,7 @@ g_filename_from_utf8 (const gchar *utf8string,
|
|||||||
return g_locale_from_utf8 (utf8string, len,
|
return g_locale_from_utf8 (utf8string, len,
|
||||||
bytes_read, bytes_written,
|
bytes_read, bytes_written,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
if (bytes_read || bytes_written)
|
|
||||||
{
|
|
||||||
gint len = strlen (utf8string);
|
|
||||||
|
|
||||||
if (bytes_read)
|
|
||||||
*bytes_read = len;
|
|
||||||
if (bytes_written)
|
|
||||||
*bytes_written = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
return g_strdup (utf8string);
|
|
||||||
else
|
else
|
||||||
return g_strndup (utf8string, len);
|
return strdup_len (utf8string, len, bytes_read, bytes_written);
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
42
gconvert.h
42
gconvert.h
@ -41,7 +41,7 @@ typedef enum
|
|||||||
} GConvertError;
|
} GConvertError;
|
||||||
|
|
||||||
#define G_CONVERT_ERROR g_convert_error_quark()
|
#define G_CONVERT_ERROR g_convert_error_quark()
|
||||||
GQuark g_convert_error_quark();
|
GQuark g_convert_error_quark (void);
|
||||||
|
|
||||||
/* Thin wrappers around iconv
|
/* Thin wrappers around iconv
|
||||||
*/
|
*/
|
||||||
@ -51,54 +51,54 @@ GIConv g_iconv_open (const gchar *to_codeset,
|
|||||||
const gchar *from_codeset);
|
const gchar *from_codeset);
|
||||||
size_t g_iconv (GIConv converter,
|
size_t g_iconv (GIConv converter,
|
||||||
gchar **inbuf,
|
gchar **inbuf,
|
||||||
size_t *inbytes_left,
|
gsize *inbytes_left,
|
||||||
gchar **outbuf,
|
gchar **outbuf,
|
||||||
size_t *outbytes_left);
|
gsize *outbytes_left);
|
||||||
gint g_iconv_close (GIConv converter);
|
gint g_iconv_close (GIConv converter);
|
||||||
|
|
||||||
|
|
||||||
gchar* g_convert (const gchar *str,
|
gchar* g_convert (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_convert_with_fallback (const gchar *str,
|
gchar* g_convert_with_fallback (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gchar *fallback,
|
gchar *fallback,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
/* Convert between libc's idea of strings and UTF-8.
|
/* Convert between libc's idea of strings and UTF-8.
|
||||||
*/
|
*/
|
||||||
gchar* g_locale_to_utf8 (const gchar *opsysstring,
|
gchar* g_locale_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_locale_from_utf8 (const gchar *utf8string,
|
gchar* g_locale_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Convert between the operating system (or C runtime)
|
/* Convert between the operating system (or C runtime)
|
||||||
* representation of file names and UTF-8.
|
* representation of file names and UTF-8.
|
||||||
*/
|
*/
|
||||||
gchar* g_filename_to_utf8 (const gchar *opsysstring,
|
gchar* g_filename_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_filename_from_utf8 (const gchar *utf8string,
|
gchar* g_filename_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
1
gdate.c
1
gdate.c
@ -513,7 +513,6 @@ g_date_fill_parse_tokens (const gchar *str, GDateParseTokens *pt)
|
|||||||
if (pt->num_ints < 3)
|
if (pt->num_ints < 3)
|
||||||
{
|
{
|
||||||
gchar lcstr[128];
|
gchar lcstr[128];
|
||||||
int i = 1;
|
|
||||||
|
|
||||||
strncpy (lcstr, str, 127);
|
strncpy (lcstr, str, 127);
|
||||||
g_strdown (lcstr);
|
g_strdown (lcstr);
|
||||||
|
12
gfileutils.c
12
gfileutils.c
@ -285,7 +285,7 @@ static gboolean
|
|||||||
get_contents_stdio (const gchar *filename,
|
get_contents_stdio (const gchar *filename,
|
||||||
FILE *f,
|
FILE *f,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar buf[2048];
|
gchar buf[2048];
|
||||||
@ -333,7 +333,7 @@ get_contents_regfile (const gchar *filename,
|
|||||||
struct stat *stat_buf,
|
struct stat *stat_buf,
|
||||||
gint fd,
|
gint fd,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *buf;
|
gchar *buf;
|
||||||
@ -347,7 +347,7 @@ get_contents_regfile (const gchar *filename,
|
|||||||
bytes_read = 0;
|
bytes_read = 0;
|
||||||
while (bytes_read < size)
|
while (bytes_read < size)
|
||||||
{
|
{
|
||||||
gint rc;
|
gssize rc;
|
||||||
|
|
||||||
rc = read (fd, buf + bytes_read, size - bytes_read);
|
rc = read (fd, buf + bytes_read, size - bytes_read);
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ get_contents_regfile (const gchar *filename,
|
|||||||
static gboolean
|
static gboolean
|
||||||
get_contents_posix (const gchar *filename,
|
get_contents_posix (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
@ -456,7 +456,7 @@ get_contents_posix (const gchar *filename,
|
|||||||
static gboolean
|
static gboolean
|
||||||
get_contents_win32 (const gchar *filename,
|
get_contents_win32 (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
@ -503,7 +503,7 @@ get_contents_win32 (const gchar *filename,
|
|||||||
gboolean
|
gboolean
|
||||||
g_file_get_contents (const gchar *filename,
|
g_file_get_contents (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (filename != NULL, FALSE);
|
g_return_val_if_fail (filename != NULL, FALSE);
|
||||||
|
@ -76,7 +76,7 @@ gboolean g_file_test (const gchar *filename,
|
|||||||
GFileTest test);
|
GFileTest test);
|
||||||
gboolean g_file_get_contents (const gchar *filename,
|
gboolean g_file_get_contents (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
|
7
ghook.c
7
ghook.c
@ -631,5 +631,10 @@ gint
|
|||||||
g_hook_compare_ids (GHook *new_hook,
|
g_hook_compare_ids (GHook *new_hook,
|
||||||
GHook *sibling)
|
GHook *sibling)
|
||||||
{
|
{
|
||||||
return ((glong) new_hook->hook_id) - ((glong) sibling->hook_id);
|
if (new_hook->hook_id < sibling->hook_id)
|
||||||
|
return -1;
|
||||||
|
else if (new_hook->hook_id > sibling->hook_id)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ g_ptr_array_remove (GPtrArray* farray,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||||
int i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (array, FALSE);
|
g_return_val_if_fail (array, FALSE);
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ g_ptr_array_remove_fast (GPtrArray* farray,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||||
int i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (array, FALSE);
|
g_return_val_if_fail (array, FALSE);
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ g_async_queue_timed_pop_unlocked (GAsyncQueue* queue, GTimeVal *end_time)
|
|||||||
gint
|
gint
|
||||||
g_async_queue_length (GAsyncQueue* queue)
|
g_async_queue_length (GAsyncQueue* queue)
|
||||||
{
|
{
|
||||||
glong retval;
|
gint retval;
|
||||||
|
|
||||||
g_return_val_if_fail (queue, 0);
|
g_return_val_if_fail (queue, 0);
|
||||||
g_return_val_if_fail (queue->ref_count > 0, 0);
|
g_return_val_if_fail (queue->ref_count > 0, 0);
|
||||||
|
@ -121,9 +121,9 @@ completion_check_cache (GCompletion* cmp,
|
|||||||
gchar** new_prefix)
|
gchar** new_prefix)
|
||||||
{
|
{
|
||||||
register GList* list;
|
register GList* list;
|
||||||
register gint len;
|
register gsize len;
|
||||||
register gint i;
|
register gsize i;
|
||||||
register gint plen;
|
register gsize plen;
|
||||||
gchar* postfix;
|
gchar* postfix;
|
||||||
gchar* s;
|
gchar* s;
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ g_completion_complete (GCompletion* cmp,
|
|||||||
gchar* prefix,
|
gchar* prefix,
|
||||||
gchar** new_prefix)
|
gchar** new_prefix)
|
||||||
{
|
{
|
||||||
gint plen, len;
|
gsize plen, len;
|
||||||
gint done = 0;
|
gboolean done = FALSE;
|
||||||
GList* list;
|
GList* list;
|
||||||
|
|
||||||
g_return_val_if_fail (cmp != NULL, NULL);
|
g_return_val_if_fail (cmp != NULL, NULL);
|
||||||
@ -193,7 +193,7 @@ g_completion_complete (GCompletion* cmp,
|
|||||||
else
|
else
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
done = 1;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#define __G_COMPLETION_H__
|
#define __G_COMPLETION_H__
|
||||||
|
|
||||||
#include <glist.h>
|
#include <glist.h>
|
||||||
#include <stddef.h> /* For size_t */
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ typedef gchar* (*GCompletionFunc) (gpointer);
|
|||||||
|
|
||||||
typedef gint (*GCompletionStrncmpFunc) (const gchar *s1,
|
typedef gint (*GCompletionStrncmpFunc) (const gchar *s1,
|
||||||
const gchar *s2,
|
const gchar *s2,
|
||||||
size_t n);
|
gsize n);
|
||||||
|
|
||||||
struct _GCompletion
|
struct _GCompletion
|
||||||
{
|
{
|
||||||
|
189
glib/gconvert.c
189
glib/gconvert.c
@ -96,9 +96,9 @@ g_iconv_open (const gchar *to_codeset,
|
|||||||
size_t
|
size_t
|
||||||
g_iconv (GIConv converter,
|
g_iconv (GIConv converter,
|
||||||
gchar **inbuf,
|
gchar **inbuf,
|
||||||
size_t *inbytes_left,
|
gsize *inbytes_left,
|
||||||
gchar **outbuf,
|
gchar **outbuf,
|
||||||
size_t *outbytes_left)
|
gsize *outbytes_left)
|
||||||
{
|
{
|
||||||
iconv_t cd = (iconv_t)converter;
|
iconv_t cd = (iconv_t)converter;
|
||||||
|
|
||||||
@ -179,21 +179,21 @@ open_converter (const gchar *to_codeset,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_convert (const gchar *str,
|
g_convert (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *dest;
|
gchar *dest;
|
||||||
gchar *outp;
|
gchar *outp;
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
size_t inbytes_remaining;
|
gsize inbytes_remaining;
|
||||||
size_t outbytes_remaining;
|
gsize outbytes_remaining;
|
||||||
size_t err;
|
gsize err;
|
||||||
GIConv cd;
|
GIConv cd;
|
||||||
size_t outbuf_size;
|
gsize outbuf_size;
|
||||||
gboolean have_error = FALSE;
|
gboolean have_error = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (str != NULL, NULL);
|
g_return_val_if_fail (str != NULL, NULL);
|
||||||
@ -218,10 +218,7 @@ g_convert (const gchar *str,
|
|||||||
|
|
||||||
p = str;
|
p = str;
|
||||||
inbytes_remaining = len;
|
inbytes_remaining = len;
|
||||||
|
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||||
/* Due to a GLIBC bug, round outbuf_size up to a multiple of 4 */
|
|
||||||
/* + 1 for nul in case len == 1 */
|
|
||||||
outbuf_size = ((len + 3) & ~3) + 1;
|
|
||||||
|
|
||||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||||
outp = dest = g_malloc (outbuf_size);
|
outp = dest = g_malloc (outbuf_size);
|
||||||
@ -241,19 +238,11 @@ g_convert (const gchar *str,
|
|||||||
{
|
{
|
||||||
size_t used = outp - dest;
|
size_t used = outp - dest;
|
||||||
|
|
||||||
/* glibc's iconv can return E2BIG even if there is space
|
outbuf_size *= 2;
|
||||||
* remaining if an internal buffer is exhausted. The
|
dest = g_realloc (dest, outbuf_size);
|
||||||
* folllowing is a heuristic to catch this. The 16 is
|
|
||||||
* pretty arbitrary.
|
|
||||||
*/
|
|
||||||
if (used + 16 > outbuf_size)
|
|
||||||
{
|
|
||||||
outbuf_size = (outbuf_size - 1) * 2 + 1;
|
|
||||||
dest = g_realloc (dest, outbuf_size);
|
|
||||||
|
|
||||||
outp = dest + used;
|
outp = dest + used;
|
||||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||||
}
|
|
||||||
|
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -317,10 +306,7 @@ g_convert (const gchar *str,
|
|||||||
* input string that were successfully converted, or %NULL.
|
* input string that were successfully converted, or %NULL.
|
||||||
* Even if the conversion was succesful, this may be
|
* Even if the conversion was succesful, this may be
|
||||||
* less than len if there were partial characters
|
* less than len if there were partial characters
|
||||||
* at the end of the input. If the error
|
* at the end of the input.
|
||||||
* G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
|
|
||||||
* stored will the byte fofset after the last valid
|
|
||||||
* input sequence.
|
|
||||||
* @bytes_written: the stored in the output buffer (not including the
|
* @bytes_written: the stored in the output buffer (not including the
|
||||||
* terminating nul.
|
* terminating nul.
|
||||||
* @error: location to store the error occuring, or %NULL to ignore
|
* @error: location to store the error occuring, or %NULL to ignore
|
||||||
@ -340,12 +326,12 @@ g_convert (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_convert_with_fallback (const gchar *str,
|
g_convert_with_fallback (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gchar *fallback,
|
gchar *fallback,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *utf8;
|
gchar *utf8;
|
||||||
@ -353,13 +339,13 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
gchar *outp;
|
gchar *outp;
|
||||||
const gchar *insert_str = NULL;
|
const gchar *insert_str = NULL;
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
int inbytes_remaining;
|
gsize inbytes_remaining;
|
||||||
const gchar *save_p = NULL;
|
const gchar *save_p = NULL;
|
||||||
size_t save_inbytes = 0;
|
gsize save_inbytes = 0;
|
||||||
size_t outbytes_remaining;
|
gsize outbytes_remaining;
|
||||||
size_t err;
|
gsize err;
|
||||||
GIConv cd;
|
GIConv cd;
|
||||||
size_t outbuf_size;
|
gsize outbuf_size;
|
||||||
gboolean have_error = FALSE;
|
gboolean have_error = FALSE;
|
||||||
gboolean done = FALSE;
|
gboolean done = FALSE;
|
||||||
|
|
||||||
@ -419,9 +405,8 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
* for the original string while we are converting the fallback
|
* for the original string while we are converting the fallback
|
||||||
*/
|
*/
|
||||||
p = utf8;
|
p = utf8;
|
||||||
/* Due to a GLIBC bug, round outbuf_size up to a multiple of 4 */
|
|
||||||
/* + 1 for nul in case len == 1 */
|
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||||
outbuf_size = ((len + 3) & ~3) + 1;
|
|
||||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||||
outp = dest = g_malloc (outbuf_size);
|
outp = dest = g_malloc (outbuf_size);
|
||||||
|
|
||||||
@ -442,19 +427,11 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
{
|
{
|
||||||
size_t used = outp - dest;
|
size_t used = outp - dest;
|
||||||
|
|
||||||
/* glibc's iconv can return E2BIG even if there is space
|
outbuf_size *= 2;
|
||||||
* remaining if an internal buffer is exhausted. The
|
dest = g_realloc (dest, outbuf_size);
|
||||||
* folllowing is a heuristic to catch this. The 16 is
|
|
||||||
* pretty arbitrary.
|
outp = dest + used;
|
||||||
*/
|
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||||
if (used + 16 > outbuf_size)
|
|
||||||
{
|
|
||||||
outbuf_size = (outbuf_size - 1) * 2 + 1;
|
|
||||||
dest = g_realloc (dest, outbuf_size);
|
|
||||||
|
|
||||||
outp = dest + used;
|
|
||||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -538,6 +515,33 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
strdup_len (const gchar *string,
|
||||||
|
gssize len,
|
||||||
|
gsize *bytes_written,
|
||||||
|
gsize *bytes_read)
|
||||||
|
|
||||||
|
{
|
||||||
|
gsize real_len;
|
||||||
|
|
||||||
|
if (len < 0)
|
||||||
|
real_len = strlen (string);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
real_len = 0;
|
||||||
|
|
||||||
|
while (real_len < len && string[real_len])
|
||||||
|
real_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes_read)
|
||||||
|
*bytes_read = real_len;
|
||||||
|
if (bytes_written)
|
||||||
|
*bytes_written = real_len;
|
||||||
|
|
||||||
|
return g_strndup (string, real_len);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_locale_to_utf8:
|
* g_locale_to_utf8:
|
||||||
* @opsysstring: a string in the encoding of the current locale
|
* @opsysstring: a string in the encoding of the current locale
|
||||||
@ -564,9 +568,9 @@ g_convert_with_fallback (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_locale_to_utf8 (const gchar *opsysstring,
|
g_locale_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -667,15 +671,14 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
|||||||
|
|
||||||
#else /* !G_PLATFORM_WIN32 */
|
#else /* !G_PLATFORM_WIN32 */
|
||||||
|
|
||||||
char *charset, *str;
|
const char *charset;
|
||||||
|
|
||||||
if (g_get_charset (&charset))
|
if (g_get_charset (&charset))
|
||||||
return g_strdup (opsysstring);
|
return strdup_len (opsysstring, len, bytes_read, bytes_written);
|
||||||
|
else
|
||||||
|
return g_convert (opsysstring, len,
|
||||||
|
"UTF-8", charset, bytes_read, bytes_written, error);
|
||||||
|
|
||||||
str = g_convert (opsysstring, len,
|
|
||||||
"UTF-8", charset, bytes_read, bytes_written, error);
|
|
||||||
|
|
||||||
return str;
|
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,9 +708,9 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_locale_from_utf8 (const gchar *utf8string,
|
g_locale_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -813,17 +816,15 @@ g_locale_from_utf8 (const gchar *utf8string,
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
#else /* !G_PLATFORM_WIN32 */
|
#else /* !G_PLATFORM_WIN32 */
|
||||||
|
|
||||||
gchar *charset, *str;
|
const gchar *charset;
|
||||||
|
|
||||||
if (g_get_charset (&charset))
|
if (g_get_charset (&charset))
|
||||||
return g_strdup (utf8string);
|
return strdup_len (utf8string, len, bytes_read, bytes_written);
|
||||||
|
else
|
||||||
|
return g_convert (utf8string, len,
|
||||||
|
charset, "UTF-8", bytes_read, bytes_written, error);
|
||||||
|
|
||||||
str = g_convert (utf8string, strlen (utf8string),
|
|
||||||
charset, "UTF-8", bytes_read, bytes_written, error);
|
|
||||||
|
|
||||||
return str;
|
|
||||||
|
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -852,9 +853,9 @@ g_locale_from_utf8 (const gchar *utf8string,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_filename_to_utf8 (const gchar *opsysstring,
|
g_filename_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -866,21 +867,8 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
|||||||
return g_locale_to_utf8 (opsysstring, len,
|
return g_locale_to_utf8 (opsysstring, len,
|
||||||
bytes_read, bytes_written,
|
bytes_read, bytes_written,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
if (bytes_read || bytes_written)
|
|
||||||
{
|
|
||||||
gint len = strlen (opsysstring);
|
|
||||||
|
|
||||||
if (bytes_read)
|
|
||||||
*bytes_read = len;
|
|
||||||
if (bytes_written)
|
|
||||||
*bytes_written = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
return g_strdup (opsysstring);
|
|
||||||
else
|
else
|
||||||
return g_strndup (opsysstring, len);
|
return strdup_len (opsysstring, len, bytes_read, bytes_written);
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,9 +896,9 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_filename_from_utf8 (const gchar *utf8string,
|
g_filename_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_PLATFORM_WIN32
|
#ifdef G_PLATFORM_WIN32
|
||||||
@ -922,20 +910,7 @@ g_filename_from_utf8 (const gchar *utf8string,
|
|||||||
return g_locale_from_utf8 (utf8string, len,
|
return g_locale_from_utf8 (utf8string, len,
|
||||||
bytes_read, bytes_written,
|
bytes_read, bytes_written,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
if (bytes_read || bytes_written)
|
|
||||||
{
|
|
||||||
gint len = strlen (utf8string);
|
|
||||||
|
|
||||||
if (bytes_read)
|
|
||||||
*bytes_read = len;
|
|
||||||
if (bytes_written)
|
|
||||||
*bytes_written = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
return g_strdup (utf8string);
|
|
||||||
else
|
else
|
||||||
return g_strndup (utf8string, len);
|
return strdup_len (utf8string, len, bytes_read, bytes_written);
|
||||||
#endif /* !G_PLATFORM_WIN32 */
|
#endif /* !G_PLATFORM_WIN32 */
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ typedef enum
|
|||||||
} GConvertError;
|
} GConvertError;
|
||||||
|
|
||||||
#define G_CONVERT_ERROR g_convert_error_quark()
|
#define G_CONVERT_ERROR g_convert_error_quark()
|
||||||
GQuark g_convert_error_quark();
|
GQuark g_convert_error_quark (void);
|
||||||
|
|
||||||
/* Thin wrappers around iconv
|
/* Thin wrappers around iconv
|
||||||
*/
|
*/
|
||||||
@ -51,54 +51,54 @@ GIConv g_iconv_open (const gchar *to_codeset,
|
|||||||
const gchar *from_codeset);
|
const gchar *from_codeset);
|
||||||
size_t g_iconv (GIConv converter,
|
size_t g_iconv (GIConv converter,
|
||||||
gchar **inbuf,
|
gchar **inbuf,
|
||||||
size_t *inbytes_left,
|
gsize *inbytes_left,
|
||||||
gchar **outbuf,
|
gchar **outbuf,
|
||||||
size_t *outbytes_left);
|
gsize *outbytes_left);
|
||||||
gint g_iconv_close (GIConv converter);
|
gint g_iconv_close (GIConv converter);
|
||||||
|
|
||||||
|
|
||||||
gchar* g_convert (const gchar *str,
|
gchar* g_convert (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_convert_with_fallback (const gchar *str,
|
gchar* g_convert_with_fallback (const gchar *str,
|
||||||
gint len,
|
gssize len,
|
||||||
const gchar *to_codeset,
|
const gchar *to_codeset,
|
||||||
const gchar *from_codeset,
|
const gchar *from_codeset,
|
||||||
gchar *fallback,
|
gchar *fallback,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
/* Convert between libc's idea of strings and UTF-8.
|
/* Convert between libc's idea of strings and UTF-8.
|
||||||
*/
|
*/
|
||||||
gchar* g_locale_to_utf8 (const gchar *opsysstring,
|
gchar* g_locale_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_locale_from_utf8 (const gchar *utf8string,
|
gchar* g_locale_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Convert between the operating system (or C runtime)
|
/* Convert between the operating system (or C runtime)
|
||||||
* representation of file names and UTF-8.
|
* representation of file names and UTF-8.
|
||||||
*/
|
*/
|
||||||
gchar* g_filename_to_utf8 (const gchar *opsysstring,
|
gchar* g_filename_to_utf8 (const gchar *opsysstring,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_filename_from_utf8 (const gchar *utf8string,
|
gchar* g_filename_from_utf8 (const gchar *utf8string,
|
||||||
gint len,
|
gssize len,
|
||||||
gint *bytes_read,
|
gsize *bytes_read,
|
||||||
gint *bytes_written,
|
gsize *bytes_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -513,7 +513,6 @@ g_date_fill_parse_tokens (const gchar *str, GDateParseTokens *pt)
|
|||||||
if (pt->num_ints < 3)
|
if (pt->num_ints < 3)
|
||||||
{
|
{
|
||||||
gchar lcstr[128];
|
gchar lcstr[128];
|
||||||
int i = 1;
|
|
||||||
|
|
||||||
strncpy (lcstr, str, 127);
|
strncpy (lcstr, str, 127);
|
||||||
g_strdown (lcstr);
|
g_strdown (lcstr);
|
||||||
|
@ -285,7 +285,7 @@ static gboolean
|
|||||||
get_contents_stdio (const gchar *filename,
|
get_contents_stdio (const gchar *filename,
|
||||||
FILE *f,
|
FILE *f,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar buf[2048];
|
gchar buf[2048];
|
||||||
@ -333,7 +333,7 @@ get_contents_regfile (const gchar *filename,
|
|||||||
struct stat *stat_buf,
|
struct stat *stat_buf,
|
||||||
gint fd,
|
gint fd,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gchar *buf;
|
gchar *buf;
|
||||||
@ -347,7 +347,7 @@ get_contents_regfile (const gchar *filename,
|
|||||||
bytes_read = 0;
|
bytes_read = 0;
|
||||||
while (bytes_read < size)
|
while (bytes_read < size)
|
||||||
{
|
{
|
||||||
gint rc;
|
gssize rc;
|
||||||
|
|
||||||
rc = read (fd, buf + bytes_read, size - bytes_read);
|
rc = read (fd, buf + bytes_read, size - bytes_read);
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ get_contents_regfile (const gchar *filename,
|
|||||||
static gboolean
|
static gboolean
|
||||||
get_contents_posix (const gchar *filename,
|
get_contents_posix (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
@ -456,7 +456,7 @@ get_contents_posix (const gchar *filename,
|
|||||||
static gboolean
|
static gboolean
|
||||||
get_contents_win32 (const gchar *filename,
|
get_contents_win32 (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
@ -503,7 +503,7 @@ get_contents_win32 (const gchar *filename,
|
|||||||
gboolean
|
gboolean
|
||||||
g_file_get_contents (const gchar *filename,
|
g_file_get_contents (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (filename != NULL, FALSE);
|
g_return_val_if_fail (filename != NULL, FALSE);
|
||||||
|
@ -76,7 +76,7 @@ gboolean g_file_test (const gchar *filename,
|
|||||||
GFileTest test);
|
GFileTest test);
|
||||||
gboolean g_file_get_contents (const gchar *filename,
|
gboolean g_file_get_contents (const gchar *filename,
|
||||||
gchar **contents,
|
gchar **contents,
|
||||||
guint *length,
|
gsize *length,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
|
@ -631,5 +631,10 @@ gint
|
|||||||
g_hook_compare_ids (GHook *new_hook,
|
g_hook_compare_ids (GHook *new_hook,
|
||||||
GHook *sibling)
|
GHook *sibling)
|
||||||
{
|
{
|
||||||
return ((glong) new_hook->hook_id) - ((glong) sibling->hook_id);
|
if (new_hook->hook_id < sibling->hook_id)
|
||||||
|
return -1;
|
||||||
|
else if (new_hook->hook_id > sibling->hook_id)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -717,7 +717,7 @@ g_list_sort_merge (GList *l1,
|
|||||||
return list.next;
|
return list.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
GList*
|
static GList*
|
||||||
g_list_sort_real (GList *list,
|
g_list_sort_real (GList *list,
|
||||||
GFunc compare_func,
|
GFunc compare_func,
|
||||||
gboolean use_data,
|
gboolean use_data,
|
||||||
@ -765,7 +765,7 @@ g_list_sort_with_data (GList *list,
|
|||||||
return g_list_sort_real (list, (GFunc) compare_func, TRUE, user_data);
|
return g_list_sort_real (list, (GFunc) compare_func, TRUE, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
GList*
|
static GList*
|
||||||
g_list_sort2 (GList *list,
|
g_list_sort2 (GList *list,
|
||||||
GCompareFunc compare_func)
|
GCompareFunc compare_func)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +141,11 @@
|
|||||||
*/
|
*/
|
||||||
#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
||||||
|
|
||||||
|
/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT
|
||||||
|
*/
|
||||||
|
#define GPOINTER_TO_SIZE(p) ((gsize) (p))
|
||||||
|
#define GSIZE_TO_POINTER(s) ((gpointer) (gsize) (s))
|
||||||
|
|
||||||
/* Provide convenience macros for handling structure
|
/* Provide convenience macros for handling structure
|
||||||
* fields through their offsets.
|
* fields through their offsets.
|
||||||
*/
|
*/
|
||||||
|
52
glib/gmain.c
52
glib/gmain.c
@ -95,7 +95,7 @@ struct _GMainContext
|
|||||||
GMemChunk *poll_chunk;
|
GMemChunk *poll_chunk;
|
||||||
guint n_poll_records;
|
guint n_poll_records;
|
||||||
GPollFD *cached_poll_array;
|
GPollFD *cached_poll_array;
|
||||||
gint cached_poll_array_size;
|
guint cached_poll_array_size;
|
||||||
|
|
||||||
#ifdef G_THREADS_ENABLED
|
#ifdef G_THREADS_ENABLED
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
@ -1533,7 +1533,7 @@ g_get_current_time (GTimeVal *result)
|
|||||||
static void
|
static void
|
||||||
g_main_dispatch (GMainContext *context)
|
g_main_dispatch (GMainContext *context)
|
||||||
{
|
{
|
||||||
gint i;
|
guint i;
|
||||||
|
|
||||||
for (i = 0; i < context->pending_dispatches->len; i++)
|
for (i = 0; i < context->pending_dispatches->len; i++)
|
||||||
{
|
{
|
||||||
@ -2619,29 +2619,51 @@ static gboolean
|
|||||||
g_timeout_prepare (GSource *source,
|
g_timeout_prepare (GSource *source,
|
||||||
gint *timeout)
|
gint *timeout)
|
||||||
{
|
{
|
||||||
|
glong sec;
|
||||||
glong msec;
|
glong msec;
|
||||||
GTimeVal current_time;
|
GTimeVal current_time;
|
||||||
|
|
||||||
GTimeoutSource *timeout_source = (GTimeoutSource *)source;
|
GTimeoutSource *timeout_source = (GTimeoutSource *)source;
|
||||||
|
|
||||||
g_source_get_current_time (source, ¤t_time);
|
g_source_get_current_time (source, ¤t_time);
|
||||||
|
|
||||||
msec = ((timeout_source->expiration.tv_sec - current_time.tv_sec) * 1000 +
|
|
||||||
(timeout_source->expiration.tv_usec - current_time.tv_usec) / 1000);
|
|
||||||
|
|
||||||
if (msec < 0)
|
sec = timeout_source->expiration.tv_sec - current_time.tv_sec;
|
||||||
|
msec = (timeout_source->expiration.tv_usec - current_time.tv_usec) / 1000;
|
||||||
|
|
||||||
|
/* We do the following in a rather convoluted fashion to deal with
|
||||||
|
* the fact that we don't have an integral type big enough to hold
|
||||||
|
* the difference of two timevals in millseconds.
|
||||||
|
*/
|
||||||
|
if (sec < 0 || (sec == 0 && msec < 0))
|
||||||
msec = 0;
|
msec = 0;
|
||||||
else if (msec > timeout_source->interval)
|
else
|
||||||
{
|
{
|
||||||
/* The system time has been set backwards, so we
|
glong interval_sec = timeout_source->interval / 1000;
|
||||||
* reset the expiration time to now + timeout_source->interval;
|
glong interval_msec = timeout_source->interval % 1000;
|
||||||
* this at least avoids hanging for long periods of time.
|
|
||||||
*/
|
if (msec < 0)
|
||||||
g_timeout_set_expiration (timeout_source, ¤t_time);
|
{
|
||||||
msec = timeout_source->interval;
|
msec += 1000;
|
||||||
|
sec -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sec > interval_sec ||
|
||||||
|
(sec == interval_sec && msec > interval_msec))
|
||||||
|
{
|
||||||
|
/* The system time has been set backwards, so we
|
||||||
|
* reset the expiration time to now + timeout_source->interval;
|
||||||
|
* this at least avoids hanging for long periods of time.
|
||||||
|
*/
|
||||||
|
g_timeout_set_expiration (timeout_source, ¤t_time);
|
||||||
|
msec = timeout_source->interval;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msec += sec * 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*timeout = msec;
|
*timeout = (gint)msec;
|
||||||
|
|
||||||
return msec == 0;
|
return msec == 0;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ struct _GMarkupParseContext
|
|||||||
gint alloc_attrs;
|
gint alloc_attrs;
|
||||||
|
|
||||||
const gchar *current_text;
|
const gchar *current_text;
|
||||||
gint current_text_len;
|
gssize current_text_len;
|
||||||
const gchar *current_text_end;
|
const gchar *current_text_end;
|
||||||
|
|
||||||
GString *leftover_char_portion;
|
GString *leftover_char_portion;
|
||||||
@ -540,8 +540,7 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
(l >= 0x10000 && l <= 0x10FFFF))
|
(l >= 0x10000 && l <= 0x10FFFF))
|
||||||
{
|
{
|
||||||
gchar buf[7];
|
gchar buf[7];
|
||||||
g_string_append (str,
|
g_string_append (str, char_str (l, buf));
|
||||||
char_str (l, buf));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -756,7 +755,7 @@ add_attribute (GMarkupParseContext *context, char *name)
|
|||||||
gboolean
|
gboolean
|
||||||
g_markup_parse_context_parse (GMarkupParseContext *context,
|
g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gssize text_len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const gchar *first_invalid;
|
const gchar *first_invalid;
|
||||||
@ -1662,7 +1661,7 @@ g_markup_parse_context_get_position (GMarkupParseContext *context,
|
|||||||
static void
|
static void
|
||||||
append_escaped_text (GString *str,
|
append_escaped_text (GString *str,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint length)
|
gssize length)
|
||||||
{
|
{
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
const gchar *end;
|
const gchar *end;
|
||||||
@ -1720,7 +1719,7 @@ append_escaped_text (GString *str,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_markup_escape_text (const gchar *text,
|
g_markup_escape_text (const gchar *text,
|
||||||
gint length)
|
gssize length)
|
||||||
{
|
{
|
||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ struct _GMarkupParser
|
|||||||
/* text is not nul-terminated */
|
/* text is not nul-terminated */
|
||||||
void (*text) (GMarkupParseContext *context,
|
void (*text) (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gsize text_len,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ struct _GMarkupParser
|
|||||||
/* text is not nul-terminated. */
|
/* text is not nul-terminated. */
|
||||||
void (*passthrough) (GMarkupParseContext *context,
|
void (*passthrough) (GMarkupParseContext *context,
|
||||||
const gchar *passthrough_text,
|
const gchar *passthrough_text,
|
||||||
gint text_len,
|
gsize text_len,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
|
|||||||
void g_markup_parse_context_free (GMarkupParseContext *context);
|
void g_markup_parse_context_free (GMarkupParseContext *context);
|
||||||
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
|
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gssize text_len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
|
gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
|
||||||
@ -115,7 +115,7 @@ void g_markup_parse_context_get_position (GMarkupParseContext *c
|
|||||||
|
|
||||||
/* useful when saving */
|
/* useful when saving */
|
||||||
gchar* g_markup_escape_text (const gchar *text,
|
gchar* g_markup_escape_text (const gchar *text,
|
||||||
gint length);
|
gssize length);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ struct _GLogHandler
|
|||||||
|
|
||||||
|
|
||||||
/* --- prototypes --- */
|
/* --- prototypes --- */
|
||||||
static inline guint printf_string_upper_bound (const gchar *format,
|
static guint printf_string_upper_bound (const gchar *format,
|
||||||
gboolean may_warn,
|
gboolean may_warn,
|
||||||
va_list args);
|
va_list args);
|
||||||
|
|
||||||
|
|
||||||
/* --- variables --- */
|
/* --- variables --- */
|
||||||
@ -156,9 +156,9 @@ ensure_stdout_valid (void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_unsigned (GFileDescriptor fd,
|
write_unsigned (GFileDescriptor fd,
|
||||||
gulong num,
|
gulong num,
|
||||||
guint radix)
|
guint radix)
|
||||||
{
|
{
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
gulong tmp;
|
gulong tmp;
|
||||||
@ -939,13 +939,13 @@ typedef struct
|
|||||||
gboolean mod_half, mod_long, mod_extra_long;
|
gboolean mod_half, mod_long, mod_extra_long;
|
||||||
} PrintfArgSpec;
|
} PrintfArgSpec;
|
||||||
|
|
||||||
static inline guint
|
static gsize
|
||||||
printf_string_upper_bound (const gchar *format,
|
printf_string_upper_bound (const gchar *format,
|
||||||
gboolean may_warn,
|
gboolean may_warn,
|
||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
|
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
|
||||||
guint len = 1;
|
gsize len = 1;
|
||||||
|
|
||||||
if (!format)
|
if (!format)
|
||||||
return len;
|
return len;
|
||||||
@ -960,7 +960,7 @@ printf_string_upper_bound (const gchar *format,
|
|||||||
{
|
{
|
||||||
PrintfArgSpec spec = { 0, };
|
PrintfArgSpec spec = { 0, };
|
||||||
gboolean seen_l = FALSE, conv_done = FALSE;
|
gboolean seen_l = FALSE, conv_done = FALSE;
|
||||||
guint conv_len = 0;
|
gsize conv_len = 0;
|
||||||
const gchar *spec_start = format;
|
const gchar *spec_start = format;
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -1241,7 +1241,7 @@ printf_string_upper_bound (const gchar *format,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
gsize
|
||||||
g_printf_string_upper_bound (const gchar *format,
|
g_printf_string_upper_bound (const gchar *format,
|
||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
/* calculate a string size, guarranteed to fit format + args.
|
/* calculate a string size, guarranteed to fit format + args.
|
||||||
*/
|
*/
|
||||||
guint g_printf_string_upper_bound (const gchar* format,
|
gsize g_printf_string_upper_bound (const gchar* format,
|
||||||
va_list args);
|
va_list args);
|
||||||
|
|
||||||
/* Log level shift offset for user defined
|
/* Log level shift offset for user defined
|
||||||
|
@ -135,8 +135,8 @@ read_data (GString *str,
|
|||||||
gint fd,
|
gint fd,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint bytes;
|
gssize bytes;
|
||||||
gchar buf[4096];
|
gchar buf[4096];
|
||||||
|
|
||||||
again:
|
again:
|
||||||
|
|
||||||
@ -875,15 +875,15 @@ do_exec (gint child_err_report_fd,
|
|||||||
static gboolean
|
static gboolean
|
||||||
read_ints (int fd,
|
read_ints (int fd,
|
||||||
gint* buf,
|
gint* buf,
|
||||||
gint n_ints_in_buf,
|
gint n_ints_in_buf,
|
||||||
gint *n_ints_read,
|
gint *n_ints_read,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint bytes = 0;
|
gsize bytes = 0;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
gint chunk;
|
gssize chunk;
|
||||||
|
|
||||||
if (bytes >= sizeof(gint)*2)
|
if (bytes >= sizeof(gint)*2)
|
||||||
break; /* give up, who knows what happened, should not be
|
break; /* give up, who knows what happened, should not be
|
||||||
@ -893,7 +893,7 @@ read_ints (int fd,
|
|||||||
again:
|
again:
|
||||||
chunk = read (fd,
|
chunk = read (fd,
|
||||||
((gchar*)buf) + bytes,
|
((gchar*)buf) + bytes,
|
||||||
sizeof(gint)*n_ints_in_buf - bytes);
|
sizeof(gint) * n_ints_in_buf - bytes);
|
||||||
if (chunk < 0 && errno == EINTR)
|
if (chunk < 0 && errno == EINTR)
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
@ -911,15 +911,11 @@ read_ints (int fd,
|
|||||||
}
|
}
|
||||||
else if (chunk == 0)
|
else if (chunk == 0)
|
||||||
break; /* EOF */
|
break; /* EOF */
|
||||||
else
|
else /* chunk > 0 */
|
||||||
{
|
bytes += chunk;
|
||||||
g_assert (chunk > 0);
|
|
||||||
|
|
||||||
bytes += chunk;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*n_ints_read = bytes/4;
|
*n_ints_read = (gint)(bytes / sizeof(gint));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1072,7 +1068,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
|
|||||||
/* Parent */
|
/* Parent */
|
||||||
|
|
||||||
gint buf[2];
|
gint buf[2];
|
||||||
gint n_ints = 0;
|
gint n_ints = 0;
|
||||||
|
|
||||||
/* Close the uncared-about ends of the pipes */
|
/* Close the uncared-about ends of the pipes */
|
||||||
close_and_invalidate (&child_err_report_pipe[1]);
|
close_and_invalidate (&child_err_report_pipe[1]);
|
||||||
|
@ -88,7 +88,7 @@ g_memdup (gconstpointer mem,
|
|||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_strndup (const gchar *str,
|
g_strndup (const gchar *str,
|
||||||
guint n)
|
gsize n)
|
||||||
{
|
{
|
||||||
gchar *new_str;
|
gchar *new_str;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ g_strndup (const gchar *str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_strnfill (guint length,
|
g_strnfill (gsize length,
|
||||||
gchar fill_char)
|
gchar fill_char)
|
||||||
{
|
{
|
||||||
register gchar *str, *s, *end;
|
register gchar *str, *s, *end;
|
||||||
@ -188,7 +188,7 @@ g_strdup_printf (const gchar *format,
|
|||||||
gchar*
|
gchar*
|
||||||
g_strconcat (const gchar *string1, ...)
|
g_strconcat (const gchar *string1, ...)
|
||||||
{
|
{
|
||||||
guint l;
|
gsize l;
|
||||||
va_list args;
|
va_list args;
|
||||||
gchar *s;
|
gchar *s;
|
||||||
gchar *concat;
|
gchar *concat;
|
||||||
@ -1062,7 +1062,7 @@ g_strcasecmp (const gchar *s1,
|
|||||||
gint
|
gint
|
||||||
g_strncasecmp (const gchar *s1,
|
g_strncasecmp (const gchar *s1,
|
||||||
const gchar *s2,
|
const gchar *s2,
|
||||||
guint n)
|
gsize n)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_STRNCASECMP
|
#ifdef HAVE_STRNCASECMP
|
||||||
return strncasecmp (s1, s2, n);
|
return strncasecmp (s1, s2, n);
|
||||||
@ -1319,11 +1319,11 @@ g_strsplit (const gchar *string,
|
|||||||
s = strstr (string, delimiter);
|
s = strstr (string, delimiter);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
guint delimiter_len = strlen (delimiter);
|
gsize delimiter_len = strlen (delimiter);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
guint len;
|
gsize len;
|
||||||
gchar *new_string;
|
gchar *new_string;
|
||||||
|
|
||||||
len = s - string;
|
len = s - string;
|
||||||
@ -1417,8 +1417,9 @@ g_strjoinv (const gchar *separator,
|
|||||||
|
|
||||||
if (*str_array)
|
if (*str_array)
|
||||||
{
|
{
|
||||||
guint i, len;
|
gint i;
|
||||||
guint separator_len;
|
gsize len;
|
||||||
|
gsize separator_len;
|
||||||
|
|
||||||
separator_len = strlen (separator);
|
separator_len = strlen (separator);
|
||||||
/* First part, getting length */
|
/* First part, getting length */
|
||||||
@ -1448,8 +1449,8 @@ g_strjoin (const gchar *separator,
|
|||||||
{
|
{
|
||||||
gchar *string, *s;
|
gchar *string, *s;
|
||||||
va_list args;
|
va_list args;
|
||||||
guint len;
|
gsize len;
|
||||||
guint separator_len;
|
gsize separator_len;
|
||||||
gchar *ptr;
|
gchar *ptr;
|
||||||
|
|
||||||
if (separator == NULL)
|
if (separator == NULL)
|
||||||
@ -1514,11 +1515,9 @@ g_strjoin (const gchar *separator,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_strstr_len (const gchar *haystack,
|
g_strstr_len (const gchar *haystack,
|
||||||
gint haystack_len,
|
gssize haystack_len,
|
||||||
const gchar *needle)
|
const gchar *needle)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (haystack != NULL, NULL);
|
g_return_val_if_fail (haystack != NULL, NULL);
|
||||||
g_return_val_if_fail (needle != NULL, NULL);
|
g_return_val_if_fail (needle != NULL, NULL);
|
||||||
|
|
||||||
@ -1526,27 +1525,33 @@ g_strstr_len (const gchar *haystack,
|
|||||||
return strstr (haystack, needle);
|
return strstr (haystack, needle);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *p = haystack;
|
const gchar *p = haystack;
|
||||||
int needle_len = strlen (needle);
|
gsize needle_len = strlen (needle);
|
||||||
const char *end = haystack + haystack_len - needle_len;
|
const gchar *end;
|
||||||
|
gsize i;
|
||||||
if (needle_len == 0)
|
|
||||||
return (char *)haystack;
|
|
||||||
|
|
||||||
|
if (needle_len == 0)
|
||||||
|
return (gchar *)haystack;
|
||||||
|
|
||||||
|
if (haystack_len < needle_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
end = haystack + haystack_len - needle_len;
|
||||||
|
|
||||||
while (*p && p <= end)
|
while (*p && p <= end)
|
||||||
{
|
{
|
||||||
for (i = 0; i < needle_len; i++)
|
for (i = 0; i < needle_len; i++)
|
||||||
if (p[i] != needle[i])
|
if (p[i] != needle[i])
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return (char *)p;
|
return (gchar *)p;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1564,24 +1569,32 @@ gchar *
|
|||||||
g_strrstr (const gchar *haystack,
|
g_strrstr (const gchar *haystack,
|
||||||
const gchar *needle)
|
const gchar *needle)
|
||||||
{
|
{
|
||||||
int i;
|
gsize i;
|
||||||
int needle_len = strlen (needle);
|
gsize needle_len;
|
||||||
int haystack_len = strlen (haystack);
|
gsize haystack_len;
|
||||||
const char *p = haystack + haystack_len - needle_len;
|
const gchar *p;
|
||||||
|
|
||||||
g_return_val_if_fail (haystack != NULL, NULL);
|
g_return_val_if_fail (haystack != NULL, NULL);
|
||||||
g_return_val_if_fail (needle != NULL, NULL);
|
g_return_val_if_fail (needle != NULL, NULL);
|
||||||
|
|
||||||
|
needle_len = strlen (needle);
|
||||||
|
haystack_len = strlen (haystack);
|
||||||
|
|
||||||
if (needle_len == 0)
|
if (needle_len == 0)
|
||||||
return (char *)p;
|
return (gchar *)haystack;
|
||||||
|
|
||||||
|
if (haystack_len < needle_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = haystack + haystack_len - needle_len;
|
||||||
|
|
||||||
while (p >= haystack)
|
while (p >= haystack)
|
||||||
{
|
{
|
||||||
for (i = 0; i < needle_len; i++)
|
for (i = 0; i < needle_len; i++)
|
||||||
if (p[i] != needle[i])
|
if (p[i] != needle[i])
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return (char *)p;
|
return (gchar *)p;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
p--;
|
p--;
|
||||||
@ -1608,8 +1621,6 @@ g_strrstr_len (const gchar *haystack,
|
|||||||
gint haystack_len,
|
gint haystack_len,
|
||||||
const gchar *needle)
|
const gchar *needle)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (haystack != NULL, NULL);
|
g_return_val_if_fail (haystack != NULL, NULL);
|
||||||
g_return_val_if_fail (needle != NULL, NULL);
|
g_return_val_if_fail (needle != NULL, NULL);
|
||||||
|
|
||||||
@ -1617,13 +1628,17 @@ g_strrstr_len (const gchar *haystack,
|
|||||||
return g_strrstr (haystack, needle);
|
return g_strrstr (haystack, needle);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int needle_len = strlen (needle);
|
gsize needle_len = strlen (needle);
|
||||||
const char *haystack_max = haystack + haystack_len;
|
const gchar *haystack_max = haystack + haystack_len;
|
||||||
const char *p = haystack;
|
const gchar *p = haystack;
|
||||||
|
gsize i;
|
||||||
|
|
||||||
while (p < haystack_max && *p)
|
while (p < haystack_max && *p)
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
|
if (p < haystack + needle_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
p -= needle_len;
|
p -= needle_len;
|
||||||
|
|
||||||
while (p >= haystack)
|
while (p >= haystack)
|
||||||
@ -1632,14 +1647,14 @@ g_strrstr_len (const gchar *haystack,
|
|||||||
if (p[i] != needle[i])
|
if (p[i] != needle[i])
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return (char *)p;
|
return (gchar *)p;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
p--;
|
p--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ gdouble g_strtod (const gchar *nptr,
|
|||||||
gchar **endptr);
|
gchar **endptr);
|
||||||
G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
|
G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
|
||||||
G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
|
G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
|
||||||
gint g_strcasecmp (const gchar *s1,
|
gint g_strcasecmp (const gchar *s1,
|
||||||
const gchar *s2);
|
const gchar *s2);
|
||||||
gint g_strncasecmp (const gchar *s1,
|
gint g_strncasecmp (const gchar *s1,
|
||||||
const gchar *s2,
|
const gchar *s2,
|
||||||
guint n);
|
gsize n);
|
||||||
gchar* g_strdown (gchar *string);
|
gchar* g_strdown (gchar *string);
|
||||||
gchar* g_strup (gchar *string);
|
gchar* g_strup (gchar *string);
|
||||||
gchar* g_strreverse (gchar *string);
|
gchar* g_strreverse (gchar *string);
|
||||||
@ -61,12 +61,12 @@ gsize g_strlcat (gchar *dest,
|
|||||||
const gchar *src,
|
const gchar *src,
|
||||||
gsize dest_size);
|
gsize dest_size);
|
||||||
gchar * g_strstr_len (const gchar *haystack,
|
gchar * g_strstr_len (const gchar *haystack,
|
||||||
gint haystack_len,
|
gssize haystack_len,
|
||||||
const gchar *needle);
|
const gchar *needle);
|
||||||
gchar * g_strrstr (const gchar *haystack,
|
gchar * g_strrstr (const gchar *haystack,
|
||||||
const gchar *needle);
|
const gchar *needle);
|
||||||
gchar * g_strrstr_len (const gchar *haystack,
|
gchar * g_strrstr_len (const gchar *haystack,
|
||||||
gint haystack_len,
|
gssize haystack_len,
|
||||||
const gchar *needle);
|
const gchar *needle);
|
||||||
|
|
||||||
/* removes leading spaces */
|
/* removes leading spaces */
|
||||||
@ -85,8 +85,8 @@ gchar* g_strdup_printf (const gchar *format,
|
|||||||
gchar* g_strdup_vprintf (const gchar *format,
|
gchar* g_strdup_vprintf (const gchar *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
gchar* g_strndup (const gchar *str,
|
gchar* g_strndup (const gchar *str,
|
||||||
guint n);
|
gsize n);
|
||||||
gchar* g_strnfill (guint length,
|
gchar* g_strnfill (gsize length,
|
||||||
gchar fill_char);
|
gchar fill_char);
|
||||||
gchar* g_strconcat (const gchar *string1,
|
gchar* g_strconcat (const gchar *string1,
|
||||||
...); /* NULL terminated */
|
...); /* NULL terminated */
|
||||||
|
111
glib/gstring.c
111
glib/gstring.c
@ -49,16 +49,16 @@ struct _GRealStringChunk
|
|||||||
{
|
{
|
||||||
GHashTable *const_table;
|
GHashTable *const_table;
|
||||||
GSList *storage_list;
|
GSList *storage_list;
|
||||||
gint storage_next;
|
gsize storage_next;
|
||||||
gint this_size;
|
gsize this_size;
|
||||||
gint default_size;
|
gsize default_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GRealString
|
struct _GRealString
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
gint len;
|
gsize len;
|
||||||
gint alloc;
|
gsize alloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
||||||
@ -91,18 +91,36 @@ g_str_hash (gconstpointer key)
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MY_MAXSIZE ((gsize)-1)
|
||||||
|
|
||||||
|
static inline gsize
|
||||||
|
nearest_power (gsize base, gsize num)
|
||||||
|
{
|
||||||
|
if (num > MY_MAXSIZE / 2)
|
||||||
|
{
|
||||||
|
return MY_MAXSIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gsize n = base;
|
||||||
|
|
||||||
|
while (n < num)
|
||||||
|
n <<= 1;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* String Chunks.
|
/* String Chunks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GStringChunk*
|
GStringChunk*
|
||||||
g_string_chunk_new (gint default_size)
|
g_string_chunk_new (gsize default_size)
|
||||||
{
|
{
|
||||||
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
||||||
gint size = 1;
|
gsize size = 1;
|
||||||
|
|
||||||
while (size < default_size)
|
size = nearest_power (1, default_size);
|
||||||
size <<= 1;
|
|
||||||
|
|
||||||
new_chunk->const_table = NULL;
|
new_chunk->const_table = NULL;
|
||||||
new_chunk->storage_list = NULL;
|
new_chunk->storage_list = NULL;
|
||||||
@ -140,17 +158,14 @@ g_string_chunk_insert (GStringChunk *fchunk,
|
|||||||
const gchar *string)
|
const gchar *string)
|
||||||
{
|
{
|
||||||
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
||||||
gint len = strlen (string);
|
gsize len = strlen (string);
|
||||||
char* pos;
|
char* pos;
|
||||||
|
|
||||||
g_return_val_if_fail (chunk != NULL, NULL);
|
g_return_val_if_fail (chunk != NULL, NULL);
|
||||||
|
|
||||||
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
||||||
{
|
{
|
||||||
gint new_size = chunk->default_size;
|
gsize new_size = nearest_power (chunk->default_size, len + 1);
|
||||||
|
|
||||||
while (new_size < len+1)
|
|
||||||
new_size <<= 1;
|
|
||||||
|
|
||||||
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
||||||
g_new (char, new_size));
|
g_new (char, new_size));
|
||||||
@ -193,29 +208,19 @@ g_string_chunk_insert_const (GStringChunk *fchunk,
|
|||||||
|
|
||||||
/* Strings.
|
/* Strings.
|
||||||
*/
|
*/
|
||||||
static inline gint
|
|
||||||
nearest_power (gint num)
|
|
||||||
{
|
|
||||||
gint n = 1;
|
|
||||||
|
|
||||||
while (n < num)
|
|
||||||
n <<= 1;
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_string_maybe_expand (GRealString* string, gint len)
|
g_string_maybe_expand (GRealString* string,
|
||||||
|
gsize len)
|
||||||
{
|
{
|
||||||
if (string->len + len >= string->alloc)
|
if (string->len + len >= string->alloc)
|
||||||
{
|
{
|
||||||
string->alloc = nearest_power (string->len + len + 1);
|
string->alloc = nearest_power (1, string->len + len + 1);
|
||||||
string->str = g_realloc (string->str, string->alloc);
|
string->str = g_realloc (string->str, string->alloc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_sized_new (guint dfl_size)
|
g_string_sized_new (gsize dfl_size)
|
||||||
{
|
{
|
||||||
GRealString *string;
|
GRealString *string;
|
||||||
|
|
||||||
@ -253,7 +258,7 @@ g_string_new (const gchar *init)
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_new_len (const gchar *init,
|
g_string_new_len (const gchar *init,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
GString *string;
|
GString *string;
|
||||||
|
|
||||||
@ -300,7 +305,7 @@ g_string_equal (const GString *v,
|
|||||||
gchar *p, *q;
|
gchar *p, *q;
|
||||||
GRealString *string1 = (GRealString *) v;
|
GRealString *string1 = (GRealString *) v;
|
||||||
GRealString *string2 = (GRealString *) v2;
|
GRealString *string2 = (GRealString *) v2;
|
||||||
gint i = string1->len;
|
gsize i = string1->len;
|
||||||
|
|
||||||
if (i != string2->len)
|
if (i != string2->len)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -323,7 +328,7 @@ guint
|
|||||||
g_string_hash (const GString *str)
|
g_string_hash (const GString *str)
|
||||||
{
|
{
|
||||||
const gchar *p = str->str;
|
const gchar *p = str->str;
|
||||||
gint n = str->len;
|
gsize n = str->len;
|
||||||
guint h = 0;
|
guint h = 0;
|
||||||
|
|
||||||
while (n--)
|
while (n--)
|
||||||
@ -350,7 +355,7 @@ g_string_assign (GString *string,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_truncate (GString *fstring,
|
g_string_truncate (GString *fstring,
|
||||||
guint len)
|
gsize len)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
|
|
||||||
@ -365,21 +370,22 @@ g_string_truncate (GString *fstring,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_insert_len (GString *fstring,
|
g_string_insert_len (GString *fstring,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, fstring);
|
g_return_val_if_fail (val != NULL, fstring);
|
||||||
g_return_val_if_fail (pos <= string->len, fstring);
|
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen (val);
|
len = strlen (val);
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = string->len;
|
pos = string->len;
|
||||||
|
else
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
|
||||||
g_string_maybe_expand (string, len);
|
g_string_maybe_expand (string, len);
|
||||||
|
|
||||||
@ -412,7 +418,7 @@ g_string_append (GString *fstring,
|
|||||||
GString*
|
GString*
|
||||||
g_string_append_len (GString *string,
|
g_string_append_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, string);
|
g_return_val_if_fail (val != NULL, string);
|
||||||
@ -442,7 +448,7 @@ g_string_prepend (GString *fstring,
|
|||||||
GString*
|
GString*
|
||||||
g_string_prepend_len (GString *string,
|
g_string_prepend_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, string);
|
g_return_val_if_fail (val != NULL, string);
|
||||||
@ -461,30 +467,32 @@ g_string_prepend_c (GString *fstring,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_insert (GString *fstring,
|
g_string_insert (GString *fstring,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val)
|
const gchar *val)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (fstring != NULL, NULL);
|
g_return_val_if_fail (fstring != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, fstring);
|
g_return_val_if_fail (val != NULL, fstring);
|
||||||
g_return_val_if_fail (pos <= fstring->len, fstring);
|
if (pos >= 0)
|
||||||
|
g_return_val_if_fail (pos <= fstring->len, fstring);
|
||||||
|
|
||||||
return g_string_insert_len (fstring, pos, val, -1);
|
return g_string_insert_len (fstring, pos, val, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_insert_c (GString *fstring,
|
g_string_insert_c (GString *fstring,
|
||||||
gint pos,
|
gssize pos,
|
||||||
gchar c)
|
gchar c)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (pos <= string->len, fstring);
|
|
||||||
|
|
||||||
g_string_maybe_expand (string, 1);
|
g_string_maybe_expand (string, 1);
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = string->len;
|
pos = string->len;
|
||||||
|
else
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
|
||||||
/* If not just an append, move the old stuff */
|
/* If not just an append, move the old stuff */
|
||||||
if (pos < string->len)
|
if (pos < string->len)
|
||||||
@ -501,19 +509,24 @@ g_string_insert_c (GString *fstring,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_erase (GString *fstring,
|
g_string_erase (GString *fstring,
|
||||||
gint pos,
|
gsize pos,
|
||||||
gint len)
|
gsize len)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString*)fstring;
|
GRealString *string = (GRealString*)fstring;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (len >= 0, fstring);
|
|
||||||
g_return_val_if_fail (pos >= 0, fstring);
|
g_return_val_if_fail (pos >= 0, fstring);
|
||||||
g_return_val_if_fail (pos <= string->len, fstring);
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
g_return_val_if_fail (pos + len <= string->len, fstring);
|
|
||||||
|
|
||||||
if (pos + len < string->len)
|
if (len < 0)
|
||||||
g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
|
len = string->len - pos;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (pos + len <= string->len, fstring);
|
||||||
|
|
||||||
|
if (pos + len < string->len)
|
||||||
|
g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
|
||||||
|
}
|
||||||
|
|
||||||
string->len -= len;
|
string->len -= len;
|
||||||
|
|
||||||
@ -527,7 +540,7 @@ g_string_down (GString *fstring)
|
|||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
guchar *s;
|
guchar *s;
|
||||||
gint n = string->len;
|
glong n = string->len;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
|
||||||
@ -548,7 +561,7 @@ g_string_up (GString *fstring)
|
|||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
guchar *s;
|
guchar *s;
|
||||||
gint n = string->len;
|
glong n = string->len;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ typedef struct _GStringChunk GStringChunk;
|
|||||||
|
|
||||||
struct _GString
|
struct _GString
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
gint len;
|
gssize len;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* String Chunks
|
/* String Chunks
|
||||||
*/
|
*/
|
||||||
GStringChunk* g_string_chunk_new (gint size);
|
GStringChunk* g_string_chunk_new (gsize size);
|
||||||
void g_string_chunk_free (GStringChunk *chunk);
|
void g_string_chunk_free (GStringChunk *chunk);
|
||||||
gchar* g_string_chunk_insert (GStringChunk *chunk,
|
gchar* g_string_chunk_insert (GStringChunk *chunk,
|
||||||
const gchar *string);
|
const gchar *string);
|
||||||
@ -54,8 +54,8 @@ gchar* g_string_chunk_insert_const (GStringChunk *chunk,
|
|||||||
*/
|
*/
|
||||||
GString* g_string_new (const gchar *init);
|
GString* g_string_new (const gchar *init);
|
||||||
GString* g_string_new_len (const gchar *init,
|
GString* g_string_new_len (const gchar *init,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_sized_new (guint dfl_size);
|
GString* g_string_sized_new (gsize dfl_size);
|
||||||
gchar* g_string_free (GString *string,
|
gchar* g_string_free (GString *string,
|
||||||
gboolean free_segment);
|
gboolean free_segment);
|
||||||
gboolean g_string_equal (const GString *v,
|
gboolean g_string_equal (const GString *v,
|
||||||
@ -64,16 +64,16 @@ guint g_string_hash (const GString *str);
|
|||||||
GString* g_string_assign (GString *string,
|
GString* g_string_assign (GString *string,
|
||||||
const gchar *rval);
|
const gchar *rval);
|
||||||
GString* g_string_truncate (GString *string,
|
GString* g_string_truncate (GString *string,
|
||||||
guint len);
|
gsize len);
|
||||||
GString* g_string_insert_len (GString *string,
|
GString* g_string_insert_len (GString *string,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_append (GString *string,
|
GString* g_string_append (GString *string,
|
||||||
const gchar *val);
|
const gchar *val);
|
||||||
GString* g_string_append_len (GString *string,
|
GString* g_string_append_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_append_c (GString *string,
|
GString* g_string_append_c (GString *string,
|
||||||
gchar c);
|
gchar c);
|
||||||
GString* g_string_prepend (GString *string,
|
GString* g_string_prepend (GString *string,
|
||||||
@ -82,16 +82,16 @@ GString* g_string_prepend_c (GString *string,
|
|||||||
gchar c);
|
gchar c);
|
||||||
GString* g_string_prepend_len (GString *string,
|
GString* g_string_prepend_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_insert (GString *string,
|
GString* g_string_insert (GString *string,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val);
|
const gchar *val);
|
||||||
GString* g_string_insert_c (GString *string,
|
GString* g_string_insert_c (GString *string,
|
||||||
gint pos,
|
gssize pos,
|
||||||
gchar c);
|
gchar c);
|
||||||
GString* g_string_erase (GString *string,
|
GString* g_string_erase (GString *string,
|
||||||
gint pos,
|
gsize pos,
|
||||||
gint len);
|
gsize len);
|
||||||
GString* g_string_down (GString *string);
|
GString* g_string_down (GString *string);
|
||||||
GString* g_string_up (GString *string);
|
GString* g_string_up (GString *string);
|
||||||
void g_string_printf (GString *string,
|
void g_string_printf (GString *string,
|
||||||
|
@ -109,7 +109,7 @@ typedef enum
|
|||||||
* in case the locale's charset will be changed later using setlocale()
|
* in case the locale's charset will be changed later using setlocale()
|
||||||
* or in some other way.
|
* or in some other way.
|
||||||
*/
|
*/
|
||||||
gboolean g_get_charset (char **charset);
|
gboolean g_get_charset (G_CONST_RETURN char **charset);
|
||||||
|
|
||||||
/* These are all analogs of the <ctype.h> functions.
|
/* These are all analogs of the <ctype.h> functions.
|
||||||
*/
|
*/
|
||||||
@ -169,8 +169,8 @@ GLIB_VAR char g_utf8_skip[256];
|
|||||||
|
|
||||||
gunichar g_utf8_get_char (const gchar *p);
|
gunichar g_utf8_get_char (const gchar *p);
|
||||||
gchar* g_utf8_offset_to_pointer (const gchar *str,
|
gchar* g_utf8_offset_to_pointer (const gchar *str,
|
||||||
gint offset);
|
glong offset);
|
||||||
gint g_utf8_pointer_to_offset (const gchar *str,
|
glong g_utf8_pointer_to_offset (const gchar *str,
|
||||||
const gchar *pos);
|
const gchar *pos);
|
||||||
gchar* g_utf8_prev_char (const gchar *p);
|
gchar* g_utf8_prev_char (const gchar *p);
|
||||||
gchar* g_utf8_find_next_char (const gchar *p,
|
gchar* g_utf8_find_next_char (const gchar *p,
|
||||||
@ -178,8 +178,8 @@ gchar* g_utf8_find_next_char (const gchar *p,
|
|||||||
gchar* g_utf8_find_prev_char (const gchar *str,
|
gchar* g_utf8_find_prev_char (const gchar *str,
|
||||||
const gchar *p);
|
const gchar *p);
|
||||||
|
|
||||||
gint g_utf8_strlen (const gchar *p,
|
glong g_utf8_strlen (const gchar *p,
|
||||||
gint max);
|
gssize max);
|
||||||
|
|
||||||
/* Copies n characters from src to dest */
|
/* Copies n characters from src to dest */
|
||||||
gchar* g_utf8_strncpy (gchar *dest,
|
gchar* g_utf8_strncpy (gchar *dest,
|
||||||
@ -189,44 +189,44 @@ gchar* g_utf8_strncpy (gchar *dest,
|
|||||||
/* Find the UTF-8 character corresponding to ch, in string p. These
|
/* Find the UTF-8 character corresponding to ch, in string p. These
|
||||||
functions are equivalants to strchr and strrchr */
|
functions are equivalants to strchr and strrchr */
|
||||||
gchar* g_utf8_strchr (const gchar *p,
|
gchar* g_utf8_strchr (const gchar *p,
|
||||||
gint len,
|
gssize len,
|
||||||
gunichar c);
|
gunichar c);
|
||||||
gchar* g_utf8_strrchr (const gchar *p,
|
gchar* g_utf8_strrchr (const gchar *p,
|
||||||
gint len,
|
gssize len,
|
||||||
gunichar c);
|
gunichar c);
|
||||||
|
|
||||||
gunichar2 *g_utf8_to_utf16 (const gchar *str,
|
gunichar2 *g_utf8_to_utf16 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gunichar * g_utf8_to_ucs4 (const gchar *str,
|
gunichar * g_utf8_to_ucs4 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gunichar * g_utf8_to_ucs4_fast (const gchar *str,
|
gunichar * g_utf8_to_ucs4_fast (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_written);
|
glong *items_written);
|
||||||
gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
|
gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_utf16_to_utf8 (const gunichar2 *str,
|
gchar* g_utf16_to_utf8 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
|
gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_ucs4_to_utf8 (const gunichar *str,
|
gchar* g_ucs4_to_utf8 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Convert a single character into UTF-8. outbuf must have at
|
/* Convert a single character into UTF-8. outbuf must have at
|
||||||
@ -234,14 +234,14 @@ gchar* g_ucs4_to_utf8 (const gunichar *str,
|
|||||||
* result.
|
* result.
|
||||||
*/
|
*/
|
||||||
gint g_unichar_to_utf8 (gunichar c,
|
gint g_unichar_to_utf8 (gunichar c,
|
||||||
char *outbuf);
|
gchar *outbuf);
|
||||||
|
|
||||||
/* Validate a UTF8 string, return TRUE if valid, put pointer to
|
/* Validate a UTF8 string, return TRUE if valid, put pointer to
|
||||||
* first invalid char in **end
|
* first invalid char in **end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean g_utf8_validate (const gchar *str,
|
gboolean g_utf8_validate (const gchar *str,
|
||||||
gint max_len,
|
gssize max_len,
|
||||||
const gchar **end);
|
const gchar **end);
|
||||||
|
|
||||||
/* Validate a Unicode character */
|
/* Validate a Unicode character */
|
||||||
|
71
glib/gutf8.c
71
glib/gutf8.c
@ -201,11 +201,11 @@ g_utf8_prev_char (const gchar *p)
|
|||||||
*
|
*
|
||||||
* Return value: the length of the string in characters
|
* Return value: the length of the string in characters
|
||||||
**/
|
**/
|
||||||
gint
|
glong
|
||||||
g_utf8_strlen (const gchar *p,
|
g_utf8_strlen (const gchar *p,
|
||||||
gint max)
|
gssize max)
|
||||||
{
|
{
|
||||||
int len = 0;
|
glong len = 0;
|
||||||
const gchar *start = p;
|
const gchar *start = p;
|
||||||
|
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
@ -276,7 +276,7 @@ g_utf8_get_char (const gchar *p)
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf8_offset_to_pointer (const gchar *str,
|
g_utf8_offset_to_pointer (const gchar *str,
|
||||||
gint offset)
|
glong offset)
|
||||||
{
|
{
|
||||||
const gchar *s = str;
|
const gchar *s = str;
|
||||||
while (offset--)
|
while (offset--)
|
||||||
@ -295,12 +295,12 @@ g_utf8_offset_to_pointer (const gchar *str,
|
|||||||
*
|
*
|
||||||
* Return value: the resulting character offset
|
* Return value: the resulting character offset
|
||||||
**/
|
**/
|
||||||
gint
|
glong
|
||||||
g_utf8_pointer_to_offset (const gchar *str,
|
g_utf8_pointer_to_offset (const gchar *str,
|
||||||
const gchar *pos)
|
const gchar *pos)
|
||||||
{
|
{
|
||||||
const gchar *s = str;
|
const gchar *s = str;
|
||||||
gint offset = 0;
|
glong offset = 0;
|
||||||
|
|
||||||
while (s < pos)
|
while (s < pos)
|
||||||
{
|
{
|
||||||
@ -413,7 +413,7 @@ static char *utf8_charset_cache = NULL;
|
|||||||
* Return value: %TRUE if the returned charset is UTF-8
|
* Return value: %TRUE if the returned charset is UTF-8
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
g_get_charset (char **charset)
|
g_get_charset (G_CONST_RETURN char **charset)
|
||||||
{
|
{
|
||||||
if (utf8_locale_cache != -1)
|
if (utf8_locale_cache != -1)
|
||||||
{
|
{
|
||||||
@ -441,9 +441,10 @@ g_get_charset (char **charset)
|
|||||||
* Return value: number of bytes written
|
* Return value: number of bytes written
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
g_unichar_to_utf8 (gunichar c, gchar *outbuf)
|
g_unichar_to_utf8 (gunichar c,
|
||||||
|
gchar *outbuf)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
guint len = 0;
|
||||||
int first;
|
int first;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -506,7 +507,7 @@ g_unichar_to_utf8 (gunichar c, gchar *outbuf)
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf8_strchr (const char *p,
|
g_utf8_strchr (const char *p,
|
||||||
gint p_len,
|
gssize p_len,
|
||||||
gunichar c)
|
gunichar c)
|
||||||
{
|
{
|
||||||
gchar ch[10];
|
gchar ch[10];
|
||||||
@ -533,7 +534,7 @@ g_utf8_strchr (const char *p,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf8_strrchr (const char *p,
|
g_utf8_strrchr (const char *p,
|
||||||
gint p_len,
|
gssize p_len,
|
||||||
gunichar c)
|
gunichar c)
|
||||||
{
|
{
|
||||||
gchar ch[10];
|
gchar ch[10];
|
||||||
@ -549,9 +550,9 @@ g_utf8_strrchr (const char *p,
|
|||||||
* and return (gunichar)-2 on incomplete trailing character
|
* and return (gunichar)-2 on incomplete trailing character
|
||||||
*/
|
*/
|
||||||
static inline gunichar
|
static inline gunichar
|
||||||
g_utf8_get_char_extended (const gchar *p, int max_len)
|
g_utf8_get_char_extended (const gchar *p, gsize max_len)
|
||||||
{
|
{
|
||||||
gint i, len;
|
guint i, len;
|
||||||
gunichar wc = (guchar) *p;
|
gunichar wc = (guchar) *p;
|
||||||
|
|
||||||
if (wc < 0x80)
|
if (wc < 0x80)
|
||||||
@ -592,8 +593,6 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
|||||||
return (gunichar)-1;
|
return (gunichar)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == -1)
|
|
||||||
return (gunichar)-1;
|
|
||||||
if (max_len >= 0 && len > max_len)
|
if (max_len >= 0 && len > max_len)
|
||||||
{
|
{
|
||||||
for (i = 1; i < max_len; i++)
|
for (i = 1; i < max_len; i++)
|
||||||
@ -644,8 +643,8 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
|||||||
**/
|
**/
|
||||||
gunichar *
|
gunichar *
|
||||||
g_utf8_to_ucs4_fast (const gchar *str,
|
g_utf8_to_ucs4_fast (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_written)
|
glong *items_written)
|
||||||
{
|
{
|
||||||
gint j, charlen;
|
gint j, charlen;
|
||||||
gunichar *result;
|
gunichar *result;
|
||||||
@ -759,9 +758,9 @@ g_utf8_to_ucs4_fast (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gunichar *
|
gunichar *
|
||||||
g_utf8_to_ucs4 (const gchar *str,
|
g_utf8_to_ucs4 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gunichar *result = NULL;
|
gunichar *result = NULL;
|
||||||
@ -838,9 +837,9 @@ g_utf8_to_ucs4 (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_ucs4_to_utf8 (const gunichar *str,
|
g_ucs4_to_utf8 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint result_length;
|
gint result_length;
|
||||||
@ -915,9 +914,9 @@ g_ucs4_to_utf8 (const gunichar *str,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf16_to_utf8 (const gunichar2 *str,
|
g_utf16_to_utf8 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
/* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
|
/* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
|
||||||
@ -1059,9 +1058,9 @@ g_utf16_to_utf8 (const gunichar2 *str,
|
|||||||
**/
|
**/
|
||||||
gunichar *
|
gunichar *
|
||||||
g_utf16_to_ucs4 (const gunichar2 *str,
|
g_utf16_to_ucs4 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const gunichar2 *in;
|
const gunichar2 *in;
|
||||||
@ -1202,9 +1201,9 @@ g_utf16_to_ucs4 (const gunichar2 *str,
|
|||||||
**/
|
**/
|
||||||
gunichar2 *
|
gunichar2 *
|
||||||
g_utf8_to_utf16 (const gchar *str,
|
g_utf8_to_utf16 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gunichar2 *result = NULL;
|
gunichar2 *result = NULL;
|
||||||
@ -1317,9 +1316,9 @@ g_utf8_to_utf16 (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gunichar2 *
|
gunichar2 *
|
||||||
g_ucs4_to_utf16 (const gunichar *str,
|
g_ucs4_to_utf16 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gunichar2 *result = NULL;
|
gunichar2 *result = NULL;
|
||||||
@ -1407,7 +1406,7 @@ g_ucs4_to_utf16 (const gunichar *str,
|
|||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
g_utf8_validate (const gchar *str,
|
g_utf8_validate (const gchar *str,
|
||||||
gint max_len,
|
gssize max_len,
|
||||||
const gchar **end)
|
const gchar **end)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -484,17 +484,17 @@ g_basename (const gchar *file_name)
|
|||||||
gchar*
|
gchar*
|
||||||
g_path_get_basename (const gchar *file_name)
|
g_path_get_basename (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gint base;
|
register gssize base;
|
||||||
register gint last_nonslash;
|
register gssize last_nonslash;
|
||||||
guint len;
|
gsize len;
|
||||||
gchar *retval;
|
gchar *retval;
|
||||||
|
|
||||||
g_return_val_if_fail (file_name != NULL, NULL);
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
if (file_name[0] == '\0')
|
if (file_name[0] == '\0')
|
||||||
/* empty string */
|
/* empty string */
|
||||||
return g_strdup (".");
|
return g_strdup (".");
|
||||||
|
|
||||||
last_nonslash = strlen (file_name) - 1;
|
last_nonslash = strlen (file_name) - 1;
|
||||||
|
|
||||||
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
||||||
@ -595,7 +595,7 @@ gchar*
|
|||||||
g_path_get_dirname (const gchar *file_name)
|
g_path_get_dirname (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gchar *base;
|
register gchar *base;
|
||||||
register guint len;
|
register gsize len;
|
||||||
|
|
||||||
g_return_val_if_fail (file_name != NULL, NULL);
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
@ -759,11 +759,11 @@ g_get_any_init (void)
|
|||||||
#ifdef P_tmpdir
|
#ifdef P_tmpdir
|
||||||
if (!g_tmp_dir)
|
if (!g_tmp_dir)
|
||||||
{
|
{
|
||||||
int k;
|
gsize k;
|
||||||
g_tmp_dir = g_strdup (P_tmpdir);
|
g_tmp_dir = g_strdup (P_tmpdir);
|
||||||
k = strlen (g_tmp_dir);
|
k = strlen (g_tmp_dir);
|
||||||
if (g_tmp_dir[k-1] == G_DIR_SEPARATOR)
|
if (k > 1 && g_tmp_dir[k - 1] == G_DIR_SEPARATOR)
|
||||||
g_tmp_dir[k-1] = '\0';
|
g_tmp_dir[k - 1] = '\0';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -827,9 +827,9 @@ g_get_any_init (void)
|
|||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
# ifdef _SC_GETPW_R_SIZE_MAX
|
# ifdef _SC_GETPW_R_SIZE_MAX
|
||||||
/* This reurns the maximum length */
|
/* This reurns the maximum length */
|
||||||
guint bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
|
glong bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
|
||||||
# else /* _SC_GETPW_R_SIZE_MAX */
|
# else /* _SC_GETPW_R_SIZE_MAX */
|
||||||
guint bufsize = 64;
|
glong bufsize = 64;
|
||||||
# endif /* _SC_GETPW_R_SIZE_MAX */
|
# endif /* _SC_GETPW_R_SIZE_MAX */
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
|
4
glist.c
4
glist.c
@ -717,7 +717,7 @@ g_list_sort_merge (GList *l1,
|
|||||||
return list.next;
|
return list.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
GList*
|
static GList*
|
||||||
g_list_sort_real (GList *list,
|
g_list_sort_real (GList *list,
|
||||||
GFunc compare_func,
|
GFunc compare_func,
|
||||||
gboolean use_data,
|
gboolean use_data,
|
||||||
@ -765,7 +765,7 @@ g_list_sort_with_data (GList *list,
|
|||||||
return g_list_sort_real (list, (GFunc) compare_func, TRUE, user_data);
|
return g_list_sort_real (list, (GFunc) compare_func, TRUE, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
GList*
|
static GList*
|
||||||
g_list_sort2 (GList *list,
|
g_list_sort2 (GList *list,
|
||||||
GCompareFunc compare_func)
|
GCompareFunc compare_func)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +141,11 @@
|
|||||||
*/
|
*/
|
||||||
#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
|
||||||
|
|
||||||
|
/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT
|
||||||
|
*/
|
||||||
|
#define GPOINTER_TO_SIZE(p) ((gsize) (p))
|
||||||
|
#define GSIZE_TO_POINTER(s) ((gpointer) (gsize) (s))
|
||||||
|
|
||||||
/* Provide convenience macros for handling structure
|
/* Provide convenience macros for handling structure
|
||||||
* fields through their offsets.
|
* fields through their offsets.
|
||||||
*/
|
*/
|
||||||
|
52
gmain.c
52
gmain.c
@ -95,7 +95,7 @@ struct _GMainContext
|
|||||||
GMemChunk *poll_chunk;
|
GMemChunk *poll_chunk;
|
||||||
guint n_poll_records;
|
guint n_poll_records;
|
||||||
GPollFD *cached_poll_array;
|
GPollFD *cached_poll_array;
|
||||||
gint cached_poll_array_size;
|
guint cached_poll_array_size;
|
||||||
|
|
||||||
#ifdef G_THREADS_ENABLED
|
#ifdef G_THREADS_ENABLED
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
@ -1533,7 +1533,7 @@ g_get_current_time (GTimeVal *result)
|
|||||||
static void
|
static void
|
||||||
g_main_dispatch (GMainContext *context)
|
g_main_dispatch (GMainContext *context)
|
||||||
{
|
{
|
||||||
gint i;
|
guint i;
|
||||||
|
|
||||||
for (i = 0; i < context->pending_dispatches->len; i++)
|
for (i = 0; i < context->pending_dispatches->len; i++)
|
||||||
{
|
{
|
||||||
@ -2619,29 +2619,51 @@ static gboolean
|
|||||||
g_timeout_prepare (GSource *source,
|
g_timeout_prepare (GSource *source,
|
||||||
gint *timeout)
|
gint *timeout)
|
||||||
{
|
{
|
||||||
|
glong sec;
|
||||||
glong msec;
|
glong msec;
|
||||||
GTimeVal current_time;
|
GTimeVal current_time;
|
||||||
|
|
||||||
GTimeoutSource *timeout_source = (GTimeoutSource *)source;
|
GTimeoutSource *timeout_source = (GTimeoutSource *)source;
|
||||||
|
|
||||||
g_source_get_current_time (source, ¤t_time);
|
g_source_get_current_time (source, ¤t_time);
|
||||||
|
|
||||||
msec = ((timeout_source->expiration.tv_sec - current_time.tv_sec) * 1000 +
|
|
||||||
(timeout_source->expiration.tv_usec - current_time.tv_usec) / 1000);
|
|
||||||
|
|
||||||
if (msec < 0)
|
sec = timeout_source->expiration.tv_sec - current_time.tv_sec;
|
||||||
|
msec = (timeout_source->expiration.tv_usec - current_time.tv_usec) / 1000;
|
||||||
|
|
||||||
|
/* We do the following in a rather convoluted fashion to deal with
|
||||||
|
* the fact that we don't have an integral type big enough to hold
|
||||||
|
* the difference of two timevals in millseconds.
|
||||||
|
*/
|
||||||
|
if (sec < 0 || (sec == 0 && msec < 0))
|
||||||
msec = 0;
|
msec = 0;
|
||||||
else if (msec > timeout_source->interval)
|
else
|
||||||
{
|
{
|
||||||
/* The system time has been set backwards, so we
|
glong interval_sec = timeout_source->interval / 1000;
|
||||||
* reset the expiration time to now + timeout_source->interval;
|
glong interval_msec = timeout_source->interval % 1000;
|
||||||
* this at least avoids hanging for long periods of time.
|
|
||||||
*/
|
if (msec < 0)
|
||||||
g_timeout_set_expiration (timeout_source, ¤t_time);
|
{
|
||||||
msec = timeout_source->interval;
|
msec += 1000;
|
||||||
|
sec -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sec > interval_sec ||
|
||||||
|
(sec == interval_sec && msec > interval_msec))
|
||||||
|
{
|
||||||
|
/* The system time has been set backwards, so we
|
||||||
|
* reset the expiration time to now + timeout_source->interval;
|
||||||
|
* this at least avoids hanging for long periods of time.
|
||||||
|
*/
|
||||||
|
g_timeout_set_expiration (timeout_source, ¤t_time);
|
||||||
|
msec = timeout_source->interval;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msec += sec * 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*timeout = msec;
|
*timeout = (gint)msec;
|
||||||
|
|
||||||
return msec == 0;
|
return msec == 0;
|
||||||
}
|
}
|
||||||
|
11
gmarkup.c
11
gmarkup.c
@ -82,7 +82,7 @@ struct _GMarkupParseContext
|
|||||||
gint alloc_attrs;
|
gint alloc_attrs;
|
||||||
|
|
||||||
const gchar *current_text;
|
const gchar *current_text;
|
||||||
gint current_text_len;
|
gssize current_text_len;
|
||||||
const gchar *current_text_end;
|
const gchar *current_text_end;
|
||||||
|
|
||||||
GString *leftover_char_portion;
|
GString *leftover_char_portion;
|
||||||
@ -540,8 +540,7 @@ unescape_text (GMarkupParseContext *context,
|
|||||||
(l >= 0x10000 && l <= 0x10FFFF))
|
(l >= 0x10000 && l <= 0x10FFFF))
|
||||||
{
|
{
|
||||||
gchar buf[7];
|
gchar buf[7];
|
||||||
g_string_append (str,
|
g_string_append (str, char_str (l, buf));
|
||||||
char_str (l, buf));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -756,7 +755,7 @@ add_attribute (GMarkupParseContext *context, char *name)
|
|||||||
gboolean
|
gboolean
|
||||||
g_markup_parse_context_parse (GMarkupParseContext *context,
|
g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gssize text_len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const gchar *first_invalid;
|
const gchar *first_invalid;
|
||||||
@ -1662,7 +1661,7 @@ g_markup_parse_context_get_position (GMarkupParseContext *context,
|
|||||||
static void
|
static void
|
||||||
append_escaped_text (GString *str,
|
append_escaped_text (GString *str,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint length)
|
gssize length)
|
||||||
{
|
{
|
||||||
const gchar *p;
|
const gchar *p;
|
||||||
const gchar *end;
|
const gchar *end;
|
||||||
@ -1720,7 +1719,7 @@ append_escaped_text (GString *str,
|
|||||||
**/
|
**/
|
||||||
gchar*
|
gchar*
|
||||||
g_markup_escape_text (const gchar *text,
|
g_markup_escape_text (const gchar *text,
|
||||||
gint length)
|
gssize length)
|
||||||
{
|
{
|
||||||
GString *str;
|
GString *str;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ struct _GMarkupParser
|
|||||||
/* text is not nul-terminated */
|
/* text is not nul-terminated */
|
||||||
void (*text) (GMarkupParseContext *context,
|
void (*text) (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gsize text_len,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ struct _GMarkupParser
|
|||||||
/* text is not nul-terminated. */
|
/* text is not nul-terminated. */
|
||||||
void (*passthrough) (GMarkupParseContext *context,
|
void (*passthrough) (GMarkupParseContext *context,
|
||||||
const gchar *passthrough_text,
|
const gchar *passthrough_text,
|
||||||
gint text_len,
|
gsize text_len,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
|
|||||||
void g_markup_parse_context_free (GMarkupParseContext *context);
|
void g_markup_parse_context_free (GMarkupParseContext *context);
|
||||||
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
|
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gssize text_len,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
|
gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
|
||||||
@ -115,7 +115,7 @@ void g_markup_parse_context_get_position (GMarkupParseContext *c
|
|||||||
|
|
||||||
/* useful when saving */
|
/* useful when saving */
|
||||||
gchar* g_markup_escape_text (const gchar *text,
|
gchar* g_markup_escape_text (const gchar *text,
|
||||||
gint length);
|
gssize length);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
20
gmessages.c
20
gmessages.c
@ -71,9 +71,9 @@ struct _GLogHandler
|
|||||||
|
|
||||||
|
|
||||||
/* --- prototypes --- */
|
/* --- prototypes --- */
|
||||||
static inline guint printf_string_upper_bound (const gchar *format,
|
static guint printf_string_upper_bound (const gchar *format,
|
||||||
gboolean may_warn,
|
gboolean may_warn,
|
||||||
va_list args);
|
va_list args);
|
||||||
|
|
||||||
|
|
||||||
/* --- variables --- */
|
/* --- variables --- */
|
||||||
@ -156,9 +156,9 @@ ensure_stdout_valid (void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_unsigned (GFileDescriptor fd,
|
write_unsigned (GFileDescriptor fd,
|
||||||
gulong num,
|
gulong num,
|
||||||
guint radix)
|
guint radix)
|
||||||
{
|
{
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
gulong tmp;
|
gulong tmp;
|
||||||
@ -939,13 +939,13 @@ typedef struct
|
|||||||
gboolean mod_half, mod_long, mod_extra_long;
|
gboolean mod_half, mod_long, mod_extra_long;
|
||||||
} PrintfArgSpec;
|
} PrintfArgSpec;
|
||||||
|
|
||||||
static inline guint
|
static gsize
|
||||||
printf_string_upper_bound (const gchar *format,
|
printf_string_upper_bound (const gchar *format,
|
||||||
gboolean may_warn,
|
gboolean may_warn,
|
||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
|
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
|
||||||
guint len = 1;
|
gsize len = 1;
|
||||||
|
|
||||||
if (!format)
|
if (!format)
|
||||||
return len;
|
return len;
|
||||||
@ -960,7 +960,7 @@ printf_string_upper_bound (const gchar *format,
|
|||||||
{
|
{
|
||||||
PrintfArgSpec spec = { 0, };
|
PrintfArgSpec spec = { 0, };
|
||||||
gboolean seen_l = FALSE, conv_done = FALSE;
|
gboolean seen_l = FALSE, conv_done = FALSE;
|
||||||
guint conv_len = 0;
|
gsize conv_len = 0;
|
||||||
const gchar *spec_start = format;
|
const gchar *spec_start = format;
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -1241,7 +1241,7 @@ printf_string_upper_bound (const gchar *format,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
gsize
|
||||||
g_printf_string_upper_bound (const gchar *format,
|
g_printf_string_upper_bound (const gchar *format,
|
||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
/* calculate a string size, guarranteed to fit format + args.
|
/* calculate a string size, guarranteed to fit format + args.
|
||||||
*/
|
*/
|
||||||
guint g_printf_string_upper_bound (const gchar* format,
|
gsize g_printf_string_upper_bound (const gchar* format,
|
||||||
va_list args);
|
va_list args);
|
||||||
|
|
||||||
/* Log level shift offset for user defined
|
/* Log level shift offset for user defined
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2001-05-21 Mark Murnane <Mark.Murnane@ireland.sun.com>
|
||||||
|
|
||||||
|
* gmodule.c (g_str_check_suffix): Modified type of string_len
|
||||||
|
and suffix_len to be gsize. Properly accommodates return from
|
||||||
|
strlen().
|
||||||
|
|
||||||
2001-05-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
2001-05-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* gmodule.c (g_module_set_error_unduped): Do not g_strdup, as
|
* gmodule.c (g_module_set_error_unduped): Do not g_strdup, as
|
||||||
|
@ -279,8 +279,8 @@ static inline gboolean
|
|||||||
str_check_suffix (const gchar* string,
|
str_check_suffix (const gchar* string,
|
||||||
const gchar* suffix)
|
const gchar* suffix)
|
||||||
{
|
{
|
||||||
guint string_len = strlen (string);
|
gsize string_len = strlen (string);
|
||||||
guint suffix_len = strlen (suffix);
|
gsize suffix_len = strlen (suffix);
|
||||||
|
|
||||||
return string_len >= suffix_len &&
|
return string_len >= suffix_len &&
|
||||||
strcmp (string + string_len - suffix_len, suffix) == 0;
|
strcmp (string + string_len - suffix_len, suffix) == 0;
|
||||||
|
26
gspawn.c
26
gspawn.c
@ -135,8 +135,8 @@ read_data (GString *str,
|
|||||||
gint fd,
|
gint fd,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint bytes;
|
gssize bytes;
|
||||||
gchar buf[4096];
|
gchar buf[4096];
|
||||||
|
|
||||||
again:
|
again:
|
||||||
|
|
||||||
@ -875,15 +875,15 @@ do_exec (gint child_err_report_fd,
|
|||||||
static gboolean
|
static gboolean
|
||||||
read_ints (int fd,
|
read_ints (int fd,
|
||||||
gint* buf,
|
gint* buf,
|
||||||
gint n_ints_in_buf,
|
gint n_ints_in_buf,
|
||||||
gint *n_ints_read,
|
gint *n_ints_read,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint bytes = 0;
|
gsize bytes = 0;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
gint chunk;
|
gssize chunk;
|
||||||
|
|
||||||
if (bytes >= sizeof(gint)*2)
|
if (bytes >= sizeof(gint)*2)
|
||||||
break; /* give up, who knows what happened, should not be
|
break; /* give up, who knows what happened, should not be
|
||||||
@ -893,7 +893,7 @@ read_ints (int fd,
|
|||||||
again:
|
again:
|
||||||
chunk = read (fd,
|
chunk = read (fd,
|
||||||
((gchar*)buf) + bytes,
|
((gchar*)buf) + bytes,
|
||||||
sizeof(gint)*n_ints_in_buf - bytes);
|
sizeof(gint) * n_ints_in_buf - bytes);
|
||||||
if (chunk < 0 && errno == EINTR)
|
if (chunk < 0 && errno == EINTR)
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
@ -911,15 +911,11 @@ read_ints (int fd,
|
|||||||
}
|
}
|
||||||
else if (chunk == 0)
|
else if (chunk == 0)
|
||||||
break; /* EOF */
|
break; /* EOF */
|
||||||
else
|
else /* chunk > 0 */
|
||||||
{
|
bytes += chunk;
|
||||||
g_assert (chunk > 0);
|
|
||||||
|
|
||||||
bytes += chunk;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*n_ints_read = bytes/4;
|
*n_ints_read = (gint)(bytes / sizeof(gint));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1072,7 +1068,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
|
|||||||
/* Parent */
|
/* Parent */
|
||||||
|
|
||||||
gint buf[2];
|
gint buf[2];
|
||||||
gint n_ints = 0;
|
gint n_ints = 0;
|
||||||
|
|
||||||
/* Close the uncared-about ends of the pipes */
|
/* Close the uncared-about ends of the pipes */
|
||||||
close_and_invalidate (&child_err_report_pipe[1]);
|
close_and_invalidate (&child_err_report_pipe[1]);
|
||||||
|
89
gstrfuncs.c
89
gstrfuncs.c
@ -88,7 +88,7 @@ g_memdup (gconstpointer mem,
|
|||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_strndup (const gchar *str,
|
g_strndup (const gchar *str,
|
||||||
guint n)
|
gsize n)
|
||||||
{
|
{
|
||||||
gchar *new_str;
|
gchar *new_str;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ g_strndup (const gchar *str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar*
|
gchar*
|
||||||
g_strnfill (guint length,
|
g_strnfill (gsize length,
|
||||||
gchar fill_char)
|
gchar fill_char)
|
||||||
{
|
{
|
||||||
register gchar *str, *s, *end;
|
register gchar *str, *s, *end;
|
||||||
@ -188,7 +188,7 @@ g_strdup_printf (const gchar *format,
|
|||||||
gchar*
|
gchar*
|
||||||
g_strconcat (const gchar *string1, ...)
|
g_strconcat (const gchar *string1, ...)
|
||||||
{
|
{
|
||||||
guint l;
|
gsize l;
|
||||||
va_list args;
|
va_list args;
|
||||||
gchar *s;
|
gchar *s;
|
||||||
gchar *concat;
|
gchar *concat;
|
||||||
@ -1062,7 +1062,7 @@ g_strcasecmp (const gchar *s1,
|
|||||||
gint
|
gint
|
||||||
g_strncasecmp (const gchar *s1,
|
g_strncasecmp (const gchar *s1,
|
||||||
const gchar *s2,
|
const gchar *s2,
|
||||||
guint n)
|
gsize n)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_STRNCASECMP
|
#ifdef HAVE_STRNCASECMP
|
||||||
return strncasecmp (s1, s2, n);
|
return strncasecmp (s1, s2, n);
|
||||||
@ -1319,11 +1319,11 @@ g_strsplit (const gchar *string,
|
|||||||
s = strstr (string, delimiter);
|
s = strstr (string, delimiter);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
guint delimiter_len = strlen (delimiter);
|
gsize delimiter_len = strlen (delimiter);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
guint len;
|
gsize len;
|
||||||
gchar *new_string;
|
gchar *new_string;
|
||||||
|
|
||||||
len = s - string;
|
len = s - string;
|
||||||
@ -1417,8 +1417,9 @@ g_strjoinv (const gchar *separator,
|
|||||||
|
|
||||||
if (*str_array)
|
if (*str_array)
|
||||||
{
|
{
|
||||||
guint i, len;
|
gint i;
|
||||||
guint separator_len;
|
gsize len;
|
||||||
|
gsize separator_len;
|
||||||
|
|
||||||
separator_len = strlen (separator);
|
separator_len = strlen (separator);
|
||||||
/* First part, getting length */
|
/* First part, getting length */
|
||||||
@ -1448,8 +1449,8 @@ g_strjoin (const gchar *separator,
|
|||||||
{
|
{
|
||||||
gchar *string, *s;
|
gchar *string, *s;
|
||||||
va_list args;
|
va_list args;
|
||||||
guint len;
|
gsize len;
|
||||||
guint separator_len;
|
gsize separator_len;
|
||||||
gchar *ptr;
|
gchar *ptr;
|
||||||
|
|
||||||
if (separator == NULL)
|
if (separator == NULL)
|
||||||
@ -1514,11 +1515,9 @@ g_strjoin (const gchar *separator,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_strstr_len (const gchar *haystack,
|
g_strstr_len (const gchar *haystack,
|
||||||
gint haystack_len,
|
gssize haystack_len,
|
||||||
const gchar *needle)
|
const gchar *needle)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (haystack != NULL, NULL);
|
g_return_val_if_fail (haystack != NULL, NULL);
|
||||||
g_return_val_if_fail (needle != NULL, NULL);
|
g_return_val_if_fail (needle != NULL, NULL);
|
||||||
|
|
||||||
@ -1526,27 +1525,33 @@ g_strstr_len (const gchar *haystack,
|
|||||||
return strstr (haystack, needle);
|
return strstr (haystack, needle);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *p = haystack;
|
const gchar *p = haystack;
|
||||||
int needle_len = strlen (needle);
|
gsize needle_len = strlen (needle);
|
||||||
const char *end = haystack + haystack_len - needle_len;
|
const gchar *end;
|
||||||
|
gsize i;
|
||||||
if (needle_len == 0)
|
|
||||||
return (char *)haystack;
|
|
||||||
|
|
||||||
|
if (needle_len == 0)
|
||||||
|
return (gchar *)haystack;
|
||||||
|
|
||||||
|
if (haystack_len < needle_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
end = haystack + haystack_len - needle_len;
|
||||||
|
|
||||||
while (*p && p <= end)
|
while (*p && p <= end)
|
||||||
{
|
{
|
||||||
for (i = 0; i < needle_len; i++)
|
for (i = 0; i < needle_len; i++)
|
||||||
if (p[i] != needle[i])
|
if (p[i] != needle[i])
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return (char *)p;
|
return (gchar *)p;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1564,24 +1569,32 @@ gchar *
|
|||||||
g_strrstr (const gchar *haystack,
|
g_strrstr (const gchar *haystack,
|
||||||
const gchar *needle)
|
const gchar *needle)
|
||||||
{
|
{
|
||||||
int i;
|
gsize i;
|
||||||
int needle_len = strlen (needle);
|
gsize needle_len;
|
||||||
int haystack_len = strlen (haystack);
|
gsize haystack_len;
|
||||||
const char *p = haystack + haystack_len - needle_len;
|
const gchar *p;
|
||||||
|
|
||||||
g_return_val_if_fail (haystack != NULL, NULL);
|
g_return_val_if_fail (haystack != NULL, NULL);
|
||||||
g_return_val_if_fail (needle != NULL, NULL);
|
g_return_val_if_fail (needle != NULL, NULL);
|
||||||
|
|
||||||
|
needle_len = strlen (needle);
|
||||||
|
haystack_len = strlen (haystack);
|
||||||
|
|
||||||
if (needle_len == 0)
|
if (needle_len == 0)
|
||||||
return (char *)p;
|
return (gchar *)haystack;
|
||||||
|
|
||||||
|
if (haystack_len < needle_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = haystack + haystack_len - needle_len;
|
||||||
|
|
||||||
while (p >= haystack)
|
while (p >= haystack)
|
||||||
{
|
{
|
||||||
for (i = 0; i < needle_len; i++)
|
for (i = 0; i < needle_len; i++)
|
||||||
if (p[i] != needle[i])
|
if (p[i] != needle[i])
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return (char *)p;
|
return (gchar *)p;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
p--;
|
p--;
|
||||||
@ -1608,8 +1621,6 @@ g_strrstr_len (const gchar *haystack,
|
|||||||
gint haystack_len,
|
gint haystack_len,
|
||||||
const gchar *needle)
|
const gchar *needle)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (haystack != NULL, NULL);
|
g_return_val_if_fail (haystack != NULL, NULL);
|
||||||
g_return_val_if_fail (needle != NULL, NULL);
|
g_return_val_if_fail (needle != NULL, NULL);
|
||||||
|
|
||||||
@ -1617,13 +1628,17 @@ g_strrstr_len (const gchar *haystack,
|
|||||||
return g_strrstr (haystack, needle);
|
return g_strrstr (haystack, needle);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int needle_len = strlen (needle);
|
gsize needle_len = strlen (needle);
|
||||||
const char *haystack_max = haystack + haystack_len;
|
const gchar *haystack_max = haystack + haystack_len;
|
||||||
const char *p = haystack;
|
const gchar *p = haystack;
|
||||||
|
gsize i;
|
||||||
|
|
||||||
while (p < haystack_max && *p)
|
while (p < haystack_max && *p)
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
|
if (p < haystack + needle_len)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
p -= needle_len;
|
p -= needle_len;
|
||||||
|
|
||||||
while (p >= haystack)
|
while (p >= haystack)
|
||||||
@ -1632,14 +1647,14 @@ g_strrstr_len (const gchar *haystack,
|
|||||||
if (p[i] != needle[i])
|
if (p[i] != needle[i])
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
return (char *)p;
|
return (gchar *)p;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
p--;
|
p--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
14
gstrfuncs.h
14
gstrfuncs.h
@ -46,11 +46,11 @@ gdouble g_strtod (const gchar *nptr,
|
|||||||
gchar **endptr);
|
gchar **endptr);
|
||||||
G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
|
G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
|
||||||
G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
|
G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
|
||||||
gint g_strcasecmp (const gchar *s1,
|
gint g_strcasecmp (const gchar *s1,
|
||||||
const gchar *s2);
|
const gchar *s2);
|
||||||
gint g_strncasecmp (const gchar *s1,
|
gint g_strncasecmp (const gchar *s1,
|
||||||
const gchar *s2,
|
const gchar *s2,
|
||||||
guint n);
|
gsize n);
|
||||||
gchar* g_strdown (gchar *string);
|
gchar* g_strdown (gchar *string);
|
||||||
gchar* g_strup (gchar *string);
|
gchar* g_strup (gchar *string);
|
||||||
gchar* g_strreverse (gchar *string);
|
gchar* g_strreverse (gchar *string);
|
||||||
@ -61,12 +61,12 @@ gsize g_strlcat (gchar *dest,
|
|||||||
const gchar *src,
|
const gchar *src,
|
||||||
gsize dest_size);
|
gsize dest_size);
|
||||||
gchar * g_strstr_len (const gchar *haystack,
|
gchar * g_strstr_len (const gchar *haystack,
|
||||||
gint haystack_len,
|
gssize haystack_len,
|
||||||
const gchar *needle);
|
const gchar *needle);
|
||||||
gchar * g_strrstr (const gchar *haystack,
|
gchar * g_strrstr (const gchar *haystack,
|
||||||
const gchar *needle);
|
const gchar *needle);
|
||||||
gchar * g_strrstr_len (const gchar *haystack,
|
gchar * g_strrstr_len (const gchar *haystack,
|
||||||
gint haystack_len,
|
gssize haystack_len,
|
||||||
const gchar *needle);
|
const gchar *needle);
|
||||||
|
|
||||||
/* removes leading spaces */
|
/* removes leading spaces */
|
||||||
@ -85,8 +85,8 @@ gchar* g_strdup_printf (const gchar *format,
|
|||||||
gchar* g_strdup_vprintf (const gchar *format,
|
gchar* g_strdup_vprintf (const gchar *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
gchar* g_strndup (const gchar *str,
|
gchar* g_strndup (const gchar *str,
|
||||||
guint n);
|
gsize n);
|
||||||
gchar* g_strnfill (guint length,
|
gchar* g_strnfill (gsize length,
|
||||||
gchar fill_char);
|
gchar fill_char);
|
||||||
gchar* g_strconcat (const gchar *string1,
|
gchar* g_strconcat (const gchar *string1,
|
||||||
...); /* NULL terminated */
|
...); /* NULL terminated */
|
||||||
|
111
gstring.c
111
gstring.c
@ -49,16 +49,16 @@ struct _GRealStringChunk
|
|||||||
{
|
{
|
||||||
GHashTable *const_table;
|
GHashTable *const_table;
|
||||||
GSList *storage_list;
|
GSList *storage_list;
|
||||||
gint storage_next;
|
gsize storage_next;
|
||||||
gint this_size;
|
gsize this_size;
|
||||||
gint default_size;
|
gsize default_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GRealString
|
struct _GRealString
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
gint len;
|
gsize len;
|
||||||
gint alloc;
|
gsize alloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
||||||
@ -91,18 +91,36 @@ g_str_hash (gconstpointer key)
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MY_MAXSIZE ((gsize)-1)
|
||||||
|
|
||||||
|
static inline gsize
|
||||||
|
nearest_power (gsize base, gsize num)
|
||||||
|
{
|
||||||
|
if (num > MY_MAXSIZE / 2)
|
||||||
|
{
|
||||||
|
return MY_MAXSIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gsize n = base;
|
||||||
|
|
||||||
|
while (n < num)
|
||||||
|
n <<= 1;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* String Chunks.
|
/* String Chunks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GStringChunk*
|
GStringChunk*
|
||||||
g_string_chunk_new (gint default_size)
|
g_string_chunk_new (gsize default_size)
|
||||||
{
|
{
|
||||||
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
||||||
gint size = 1;
|
gsize size = 1;
|
||||||
|
|
||||||
while (size < default_size)
|
size = nearest_power (1, default_size);
|
||||||
size <<= 1;
|
|
||||||
|
|
||||||
new_chunk->const_table = NULL;
|
new_chunk->const_table = NULL;
|
||||||
new_chunk->storage_list = NULL;
|
new_chunk->storage_list = NULL;
|
||||||
@ -140,17 +158,14 @@ g_string_chunk_insert (GStringChunk *fchunk,
|
|||||||
const gchar *string)
|
const gchar *string)
|
||||||
{
|
{
|
||||||
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
||||||
gint len = strlen (string);
|
gsize len = strlen (string);
|
||||||
char* pos;
|
char* pos;
|
||||||
|
|
||||||
g_return_val_if_fail (chunk != NULL, NULL);
|
g_return_val_if_fail (chunk != NULL, NULL);
|
||||||
|
|
||||||
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
||||||
{
|
{
|
||||||
gint new_size = chunk->default_size;
|
gsize new_size = nearest_power (chunk->default_size, len + 1);
|
||||||
|
|
||||||
while (new_size < len+1)
|
|
||||||
new_size <<= 1;
|
|
||||||
|
|
||||||
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
||||||
g_new (char, new_size));
|
g_new (char, new_size));
|
||||||
@ -193,29 +208,19 @@ g_string_chunk_insert_const (GStringChunk *fchunk,
|
|||||||
|
|
||||||
/* Strings.
|
/* Strings.
|
||||||
*/
|
*/
|
||||||
static inline gint
|
|
||||||
nearest_power (gint num)
|
|
||||||
{
|
|
||||||
gint n = 1;
|
|
||||||
|
|
||||||
while (n < num)
|
|
||||||
n <<= 1;
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_string_maybe_expand (GRealString* string, gint len)
|
g_string_maybe_expand (GRealString* string,
|
||||||
|
gsize len)
|
||||||
{
|
{
|
||||||
if (string->len + len >= string->alloc)
|
if (string->len + len >= string->alloc)
|
||||||
{
|
{
|
||||||
string->alloc = nearest_power (string->len + len + 1);
|
string->alloc = nearest_power (1, string->len + len + 1);
|
||||||
string->str = g_realloc (string->str, string->alloc);
|
string->str = g_realloc (string->str, string->alloc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_sized_new (guint dfl_size)
|
g_string_sized_new (gsize dfl_size)
|
||||||
{
|
{
|
||||||
GRealString *string;
|
GRealString *string;
|
||||||
|
|
||||||
@ -253,7 +258,7 @@ g_string_new (const gchar *init)
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_new_len (const gchar *init,
|
g_string_new_len (const gchar *init,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
GString *string;
|
GString *string;
|
||||||
|
|
||||||
@ -300,7 +305,7 @@ g_string_equal (const GString *v,
|
|||||||
gchar *p, *q;
|
gchar *p, *q;
|
||||||
GRealString *string1 = (GRealString *) v;
|
GRealString *string1 = (GRealString *) v;
|
||||||
GRealString *string2 = (GRealString *) v2;
|
GRealString *string2 = (GRealString *) v2;
|
||||||
gint i = string1->len;
|
gsize i = string1->len;
|
||||||
|
|
||||||
if (i != string2->len)
|
if (i != string2->len)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -323,7 +328,7 @@ guint
|
|||||||
g_string_hash (const GString *str)
|
g_string_hash (const GString *str)
|
||||||
{
|
{
|
||||||
const gchar *p = str->str;
|
const gchar *p = str->str;
|
||||||
gint n = str->len;
|
gsize n = str->len;
|
||||||
guint h = 0;
|
guint h = 0;
|
||||||
|
|
||||||
while (n--)
|
while (n--)
|
||||||
@ -350,7 +355,7 @@ g_string_assign (GString *string,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_truncate (GString *fstring,
|
g_string_truncate (GString *fstring,
|
||||||
guint len)
|
gsize len)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
|
|
||||||
@ -365,21 +370,22 @@ g_string_truncate (GString *fstring,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_insert_len (GString *fstring,
|
g_string_insert_len (GString *fstring,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, fstring);
|
g_return_val_if_fail (val != NULL, fstring);
|
||||||
g_return_val_if_fail (pos <= string->len, fstring);
|
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen (val);
|
len = strlen (val);
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = string->len;
|
pos = string->len;
|
||||||
|
else
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
|
||||||
g_string_maybe_expand (string, len);
|
g_string_maybe_expand (string, len);
|
||||||
|
|
||||||
@ -412,7 +418,7 @@ g_string_append (GString *fstring,
|
|||||||
GString*
|
GString*
|
||||||
g_string_append_len (GString *string,
|
g_string_append_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, string);
|
g_return_val_if_fail (val != NULL, string);
|
||||||
@ -442,7 +448,7 @@ g_string_prepend (GString *fstring,
|
|||||||
GString*
|
GString*
|
||||||
g_string_prepend_len (GString *string,
|
g_string_prepend_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len)
|
gssize len)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, string);
|
g_return_val_if_fail (val != NULL, string);
|
||||||
@ -461,30 +467,32 @@ g_string_prepend_c (GString *fstring,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_insert (GString *fstring,
|
g_string_insert (GString *fstring,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val)
|
const gchar *val)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (fstring != NULL, NULL);
|
g_return_val_if_fail (fstring != NULL, NULL);
|
||||||
g_return_val_if_fail (val != NULL, fstring);
|
g_return_val_if_fail (val != NULL, fstring);
|
||||||
g_return_val_if_fail (pos <= fstring->len, fstring);
|
if (pos >= 0)
|
||||||
|
g_return_val_if_fail (pos <= fstring->len, fstring);
|
||||||
|
|
||||||
return g_string_insert_len (fstring, pos, val, -1);
|
return g_string_insert_len (fstring, pos, val, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_insert_c (GString *fstring,
|
g_string_insert_c (GString *fstring,
|
||||||
gint pos,
|
gssize pos,
|
||||||
gchar c)
|
gchar c)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (pos <= string->len, fstring);
|
|
||||||
|
|
||||||
g_string_maybe_expand (string, 1);
|
g_string_maybe_expand (string, 1);
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = string->len;
|
pos = string->len;
|
||||||
|
else
|
||||||
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
|
|
||||||
/* If not just an append, move the old stuff */
|
/* If not just an append, move the old stuff */
|
||||||
if (pos < string->len)
|
if (pos < string->len)
|
||||||
@ -501,19 +509,24 @@ g_string_insert_c (GString *fstring,
|
|||||||
|
|
||||||
GString*
|
GString*
|
||||||
g_string_erase (GString *fstring,
|
g_string_erase (GString *fstring,
|
||||||
gint pos,
|
gsize pos,
|
||||||
gint len)
|
gsize len)
|
||||||
{
|
{
|
||||||
GRealString *string = (GRealString*)fstring;
|
GRealString *string = (GRealString*)fstring;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (len >= 0, fstring);
|
|
||||||
g_return_val_if_fail (pos >= 0, fstring);
|
g_return_val_if_fail (pos >= 0, fstring);
|
||||||
g_return_val_if_fail (pos <= string->len, fstring);
|
g_return_val_if_fail (pos <= string->len, fstring);
|
||||||
g_return_val_if_fail (pos + len <= string->len, fstring);
|
|
||||||
|
|
||||||
if (pos + len < string->len)
|
if (len < 0)
|
||||||
g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
|
len = string->len - pos;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (pos + len <= string->len, fstring);
|
||||||
|
|
||||||
|
if (pos + len < string->len)
|
||||||
|
g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
|
||||||
|
}
|
||||||
|
|
||||||
string->len -= len;
|
string->len -= len;
|
||||||
|
|
||||||
@ -527,7 +540,7 @@ g_string_down (GString *fstring)
|
|||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
guchar *s;
|
guchar *s;
|
||||||
gint n = string->len;
|
glong n = string->len;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
|
||||||
@ -548,7 +561,7 @@ g_string_up (GString *fstring)
|
|||||||
{
|
{
|
||||||
GRealString *string = (GRealString *) fstring;
|
GRealString *string = (GRealString *) fstring;
|
||||||
guchar *s;
|
guchar *s;
|
||||||
gint n = string->len;
|
glong n = string->len;
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
|
||||||
|
28
gstring.h
28
gstring.h
@ -36,13 +36,13 @@ typedef struct _GStringChunk GStringChunk;
|
|||||||
|
|
||||||
struct _GString
|
struct _GString
|
||||||
{
|
{
|
||||||
gchar *str;
|
gchar *str;
|
||||||
gint len;
|
gssize len;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* String Chunks
|
/* String Chunks
|
||||||
*/
|
*/
|
||||||
GStringChunk* g_string_chunk_new (gint size);
|
GStringChunk* g_string_chunk_new (gsize size);
|
||||||
void g_string_chunk_free (GStringChunk *chunk);
|
void g_string_chunk_free (GStringChunk *chunk);
|
||||||
gchar* g_string_chunk_insert (GStringChunk *chunk,
|
gchar* g_string_chunk_insert (GStringChunk *chunk,
|
||||||
const gchar *string);
|
const gchar *string);
|
||||||
@ -54,8 +54,8 @@ gchar* g_string_chunk_insert_const (GStringChunk *chunk,
|
|||||||
*/
|
*/
|
||||||
GString* g_string_new (const gchar *init);
|
GString* g_string_new (const gchar *init);
|
||||||
GString* g_string_new_len (const gchar *init,
|
GString* g_string_new_len (const gchar *init,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_sized_new (guint dfl_size);
|
GString* g_string_sized_new (gsize dfl_size);
|
||||||
gchar* g_string_free (GString *string,
|
gchar* g_string_free (GString *string,
|
||||||
gboolean free_segment);
|
gboolean free_segment);
|
||||||
gboolean g_string_equal (const GString *v,
|
gboolean g_string_equal (const GString *v,
|
||||||
@ -64,16 +64,16 @@ guint g_string_hash (const GString *str);
|
|||||||
GString* g_string_assign (GString *string,
|
GString* g_string_assign (GString *string,
|
||||||
const gchar *rval);
|
const gchar *rval);
|
||||||
GString* g_string_truncate (GString *string,
|
GString* g_string_truncate (GString *string,
|
||||||
guint len);
|
gsize len);
|
||||||
GString* g_string_insert_len (GString *string,
|
GString* g_string_insert_len (GString *string,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_append (GString *string,
|
GString* g_string_append (GString *string,
|
||||||
const gchar *val);
|
const gchar *val);
|
||||||
GString* g_string_append_len (GString *string,
|
GString* g_string_append_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_append_c (GString *string,
|
GString* g_string_append_c (GString *string,
|
||||||
gchar c);
|
gchar c);
|
||||||
GString* g_string_prepend (GString *string,
|
GString* g_string_prepend (GString *string,
|
||||||
@ -82,16 +82,16 @@ GString* g_string_prepend_c (GString *string,
|
|||||||
gchar c);
|
gchar c);
|
||||||
GString* g_string_prepend_len (GString *string,
|
GString* g_string_prepend_len (GString *string,
|
||||||
const gchar *val,
|
const gchar *val,
|
||||||
gint len);
|
gssize len);
|
||||||
GString* g_string_insert (GString *string,
|
GString* g_string_insert (GString *string,
|
||||||
gint pos,
|
gssize pos,
|
||||||
const gchar *val);
|
const gchar *val);
|
||||||
GString* g_string_insert_c (GString *string,
|
GString* g_string_insert_c (GString *string,
|
||||||
gint pos,
|
gssize pos,
|
||||||
gchar c);
|
gchar c);
|
||||||
GString* g_string_erase (GString *string,
|
GString* g_string_erase (GString *string,
|
||||||
gint pos,
|
gsize pos,
|
||||||
gint len);
|
gsize len);
|
||||||
GString* g_string_down (GString *string);
|
GString* g_string_down (GString *string);
|
||||||
GString* g_string_up (GString *string);
|
GString* g_string_up (GString *string);
|
||||||
void g_string_printf (GString *string,
|
void g_string_printf (GString *string,
|
||||||
|
58
gunicode.h
58
gunicode.h
@ -109,7 +109,7 @@ typedef enum
|
|||||||
* in case the locale's charset will be changed later using setlocale()
|
* in case the locale's charset will be changed later using setlocale()
|
||||||
* or in some other way.
|
* or in some other way.
|
||||||
*/
|
*/
|
||||||
gboolean g_get_charset (char **charset);
|
gboolean g_get_charset (G_CONST_RETURN char **charset);
|
||||||
|
|
||||||
/* These are all analogs of the <ctype.h> functions.
|
/* These are all analogs of the <ctype.h> functions.
|
||||||
*/
|
*/
|
||||||
@ -169,8 +169,8 @@ GLIB_VAR char g_utf8_skip[256];
|
|||||||
|
|
||||||
gunichar g_utf8_get_char (const gchar *p);
|
gunichar g_utf8_get_char (const gchar *p);
|
||||||
gchar* g_utf8_offset_to_pointer (const gchar *str,
|
gchar* g_utf8_offset_to_pointer (const gchar *str,
|
||||||
gint offset);
|
glong offset);
|
||||||
gint g_utf8_pointer_to_offset (const gchar *str,
|
glong g_utf8_pointer_to_offset (const gchar *str,
|
||||||
const gchar *pos);
|
const gchar *pos);
|
||||||
gchar* g_utf8_prev_char (const gchar *p);
|
gchar* g_utf8_prev_char (const gchar *p);
|
||||||
gchar* g_utf8_find_next_char (const gchar *p,
|
gchar* g_utf8_find_next_char (const gchar *p,
|
||||||
@ -178,8 +178,8 @@ gchar* g_utf8_find_next_char (const gchar *p,
|
|||||||
gchar* g_utf8_find_prev_char (const gchar *str,
|
gchar* g_utf8_find_prev_char (const gchar *str,
|
||||||
const gchar *p);
|
const gchar *p);
|
||||||
|
|
||||||
gint g_utf8_strlen (const gchar *p,
|
glong g_utf8_strlen (const gchar *p,
|
||||||
gint max);
|
gssize max);
|
||||||
|
|
||||||
/* Copies n characters from src to dest */
|
/* Copies n characters from src to dest */
|
||||||
gchar* g_utf8_strncpy (gchar *dest,
|
gchar* g_utf8_strncpy (gchar *dest,
|
||||||
@ -189,44 +189,44 @@ gchar* g_utf8_strncpy (gchar *dest,
|
|||||||
/* Find the UTF-8 character corresponding to ch, in string p. These
|
/* Find the UTF-8 character corresponding to ch, in string p. These
|
||||||
functions are equivalants to strchr and strrchr */
|
functions are equivalants to strchr and strrchr */
|
||||||
gchar* g_utf8_strchr (const gchar *p,
|
gchar* g_utf8_strchr (const gchar *p,
|
||||||
gint len,
|
gssize len,
|
||||||
gunichar c);
|
gunichar c);
|
||||||
gchar* g_utf8_strrchr (const gchar *p,
|
gchar* g_utf8_strrchr (const gchar *p,
|
||||||
gint len,
|
gssize len,
|
||||||
gunichar c);
|
gunichar c);
|
||||||
|
|
||||||
gunichar2 *g_utf8_to_utf16 (const gchar *str,
|
gunichar2 *g_utf8_to_utf16 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gunichar * g_utf8_to_ucs4 (const gchar *str,
|
gunichar * g_utf8_to_ucs4 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gunichar * g_utf8_to_ucs4_fast (const gchar *str,
|
gunichar * g_utf8_to_ucs4_fast (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_written);
|
glong *items_written);
|
||||||
gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
|
gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_utf16_to_utf8 (const gunichar2 *str,
|
gchar* g_utf16_to_utf8 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
|
gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar* g_ucs4_to_utf8 (const gunichar *str,
|
gchar* g_ucs4_to_utf8 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/* Convert a single character into UTF-8. outbuf must have at
|
/* Convert a single character into UTF-8. outbuf must have at
|
||||||
@ -234,14 +234,14 @@ gchar* g_ucs4_to_utf8 (const gunichar *str,
|
|||||||
* result.
|
* result.
|
||||||
*/
|
*/
|
||||||
gint g_unichar_to_utf8 (gunichar c,
|
gint g_unichar_to_utf8 (gunichar c,
|
||||||
char *outbuf);
|
gchar *outbuf);
|
||||||
|
|
||||||
/* Validate a UTF8 string, return TRUE if valid, put pointer to
|
/* Validate a UTF8 string, return TRUE if valid, put pointer to
|
||||||
* first invalid char in **end
|
* first invalid char in **end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean g_utf8_validate (const gchar *str,
|
gboolean g_utf8_validate (const gchar *str,
|
||||||
gint max_len,
|
gssize max_len,
|
||||||
const gchar **end);
|
const gchar **end);
|
||||||
|
|
||||||
/* Validate a Unicode character */
|
/* Validate a Unicode character */
|
||||||
|
71
gutf8.c
71
gutf8.c
@ -201,11 +201,11 @@ g_utf8_prev_char (const gchar *p)
|
|||||||
*
|
*
|
||||||
* Return value: the length of the string in characters
|
* Return value: the length of the string in characters
|
||||||
**/
|
**/
|
||||||
gint
|
glong
|
||||||
g_utf8_strlen (const gchar *p,
|
g_utf8_strlen (const gchar *p,
|
||||||
gint max)
|
gssize max)
|
||||||
{
|
{
|
||||||
int len = 0;
|
glong len = 0;
|
||||||
const gchar *start = p;
|
const gchar *start = p;
|
||||||
|
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
@ -276,7 +276,7 @@ g_utf8_get_char (const gchar *p)
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf8_offset_to_pointer (const gchar *str,
|
g_utf8_offset_to_pointer (const gchar *str,
|
||||||
gint offset)
|
glong offset)
|
||||||
{
|
{
|
||||||
const gchar *s = str;
|
const gchar *s = str;
|
||||||
while (offset--)
|
while (offset--)
|
||||||
@ -295,12 +295,12 @@ g_utf8_offset_to_pointer (const gchar *str,
|
|||||||
*
|
*
|
||||||
* Return value: the resulting character offset
|
* Return value: the resulting character offset
|
||||||
**/
|
**/
|
||||||
gint
|
glong
|
||||||
g_utf8_pointer_to_offset (const gchar *str,
|
g_utf8_pointer_to_offset (const gchar *str,
|
||||||
const gchar *pos)
|
const gchar *pos)
|
||||||
{
|
{
|
||||||
const gchar *s = str;
|
const gchar *s = str;
|
||||||
gint offset = 0;
|
glong offset = 0;
|
||||||
|
|
||||||
while (s < pos)
|
while (s < pos)
|
||||||
{
|
{
|
||||||
@ -413,7 +413,7 @@ static char *utf8_charset_cache = NULL;
|
|||||||
* Return value: %TRUE if the returned charset is UTF-8
|
* Return value: %TRUE if the returned charset is UTF-8
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
g_get_charset (char **charset)
|
g_get_charset (G_CONST_RETURN char **charset)
|
||||||
{
|
{
|
||||||
if (utf8_locale_cache != -1)
|
if (utf8_locale_cache != -1)
|
||||||
{
|
{
|
||||||
@ -441,9 +441,10 @@ g_get_charset (char **charset)
|
|||||||
* Return value: number of bytes written
|
* Return value: number of bytes written
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
g_unichar_to_utf8 (gunichar c, gchar *outbuf)
|
g_unichar_to_utf8 (gunichar c,
|
||||||
|
gchar *outbuf)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
guint len = 0;
|
||||||
int first;
|
int first;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -506,7 +507,7 @@ g_unichar_to_utf8 (gunichar c, gchar *outbuf)
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf8_strchr (const char *p,
|
g_utf8_strchr (const char *p,
|
||||||
gint p_len,
|
gssize p_len,
|
||||||
gunichar c)
|
gunichar c)
|
||||||
{
|
{
|
||||||
gchar ch[10];
|
gchar ch[10];
|
||||||
@ -533,7 +534,7 @@ g_utf8_strchr (const char *p,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf8_strrchr (const char *p,
|
g_utf8_strrchr (const char *p,
|
||||||
gint p_len,
|
gssize p_len,
|
||||||
gunichar c)
|
gunichar c)
|
||||||
{
|
{
|
||||||
gchar ch[10];
|
gchar ch[10];
|
||||||
@ -549,9 +550,9 @@ g_utf8_strrchr (const char *p,
|
|||||||
* and return (gunichar)-2 on incomplete trailing character
|
* and return (gunichar)-2 on incomplete trailing character
|
||||||
*/
|
*/
|
||||||
static inline gunichar
|
static inline gunichar
|
||||||
g_utf8_get_char_extended (const gchar *p, int max_len)
|
g_utf8_get_char_extended (const gchar *p, gsize max_len)
|
||||||
{
|
{
|
||||||
gint i, len;
|
guint i, len;
|
||||||
gunichar wc = (guchar) *p;
|
gunichar wc = (guchar) *p;
|
||||||
|
|
||||||
if (wc < 0x80)
|
if (wc < 0x80)
|
||||||
@ -592,8 +593,6 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
|||||||
return (gunichar)-1;
|
return (gunichar)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == -1)
|
|
||||||
return (gunichar)-1;
|
|
||||||
if (max_len >= 0 && len > max_len)
|
if (max_len >= 0 && len > max_len)
|
||||||
{
|
{
|
||||||
for (i = 1; i < max_len; i++)
|
for (i = 1; i < max_len; i++)
|
||||||
@ -644,8 +643,8 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
|||||||
**/
|
**/
|
||||||
gunichar *
|
gunichar *
|
||||||
g_utf8_to_ucs4_fast (const gchar *str,
|
g_utf8_to_ucs4_fast (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_written)
|
glong *items_written)
|
||||||
{
|
{
|
||||||
gint j, charlen;
|
gint j, charlen;
|
||||||
gunichar *result;
|
gunichar *result;
|
||||||
@ -759,9 +758,9 @@ g_utf8_to_ucs4_fast (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gunichar *
|
gunichar *
|
||||||
g_utf8_to_ucs4 (const gchar *str,
|
g_utf8_to_ucs4 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gunichar *result = NULL;
|
gunichar *result = NULL;
|
||||||
@ -838,9 +837,9 @@ g_utf8_to_ucs4 (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_ucs4_to_utf8 (const gunichar *str,
|
g_ucs4_to_utf8 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint result_length;
|
gint result_length;
|
||||||
@ -915,9 +914,9 @@ g_ucs4_to_utf8 (const gunichar *str,
|
|||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_utf16_to_utf8 (const gunichar2 *str,
|
g_utf16_to_utf8 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
/* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
|
/* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
|
||||||
@ -1059,9 +1058,9 @@ g_utf16_to_utf8 (const gunichar2 *str,
|
|||||||
**/
|
**/
|
||||||
gunichar *
|
gunichar *
|
||||||
g_utf16_to_ucs4 (const gunichar2 *str,
|
g_utf16_to_ucs4 (const gunichar2 *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const gunichar2 *in;
|
const gunichar2 *in;
|
||||||
@ -1202,9 +1201,9 @@ g_utf16_to_ucs4 (const gunichar2 *str,
|
|||||||
**/
|
**/
|
||||||
gunichar2 *
|
gunichar2 *
|
||||||
g_utf8_to_utf16 (const gchar *str,
|
g_utf8_to_utf16 (const gchar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gunichar2 *result = NULL;
|
gunichar2 *result = NULL;
|
||||||
@ -1317,9 +1316,9 @@ g_utf8_to_utf16 (const gchar *str,
|
|||||||
**/
|
**/
|
||||||
gunichar2 *
|
gunichar2 *
|
||||||
g_ucs4_to_utf16 (const gunichar *str,
|
g_ucs4_to_utf16 (const gunichar *str,
|
||||||
gint len,
|
glong len,
|
||||||
gint *items_read,
|
glong *items_read,
|
||||||
gint *items_written,
|
glong *items_written,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gunichar2 *result = NULL;
|
gunichar2 *result = NULL;
|
||||||
@ -1407,7 +1406,7 @@ g_ucs4_to_utf16 (const gunichar *str,
|
|||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
g_utf8_validate (const gchar *str,
|
g_utf8_validate (const gchar *str,
|
||||||
gint max_len,
|
gssize max_len,
|
||||||
const gchar **end)
|
const gchar **end)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
22
gutils.c
22
gutils.c
@ -484,17 +484,17 @@ g_basename (const gchar *file_name)
|
|||||||
gchar*
|
gchar*
|
||||||
g_path_get_basename (const gchar *file_name)
|
g_path_get_basename (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gint base;
|
register gssize base;
|
||||||
register gint last_nonslash;
|
register gssize last_nonslash;
|
||||||
guint len;
|
gsize len;
|
||||||
gchar *retval;
|
gchar *retval;
|
||||||
|
|
||||||
g_return_val_if_fail (file_name != NULL, NULL);
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
if (file_name[0] == '\0')
|
if (file_name[0] == '\0')
|
||||||
/* empty string */
|
/* empty string */
|
||||||
return g_strdup (".");
|
return g_strdup (".");
|
||||||
|
|
||||||
last_nonslash = strlen (file_name) - 1;
|
last_nonslash = strlen (file_name) - 1;
|
||||||
|
|
||||||
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
||||||
@ -595,7 +595,7 @@ gchar*
|
|||||||
g_path_get_dirname (const gchar *file_name)
|
g_path_get_dirname (const gchar *file_name)
|
||||||
{
|
{
|
||||||
register gchar *base;
|
register gchar *base;
|
||||||
register guint len;
|
register gsize len;
|
||||||
|
|
||||||
g_return_val_if_fail (file_name != NULL, NULL);
|
g_return_val_if_fail (file_name != NULL, NULL);
|
||||||
|
|
||||||
@ -759,11 +759,11 @@ g_get_any_init (void)
|
|||||||
#ifdef P_tmpdir
|
#ifdef P_tmpdir
|
||||||
if (!g_tmp_dir)
|
if (!g_tmp_dir)
|
||||||
{
|
{
|
||||||
int k;
|
gsize k;
|
||||||
g_tmp_dir = g_strdup (P_tmpdir);
|
g_tmp_dir = g_strdup (P_tmpdir);
|
||||||
k = strlen (g_tmp_dir);
|
k = strlen (g_tmp_dir);
|
||||||
if (g_tmp_dir[k-1] == G_DIR_SEPARATOR)
|
if (k > 1 && g_tmp_dir[k - 1] == G_DIR_SEPARATOR)
|
||||||
g_tmp_dir[k-1] = '\0';
|
g_tmp_dir[k - 1] = '\0';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -827,9 +827,9 @@ g_get_any_init (void)
|
|||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
# ifdef _SC_GETPW_R_SIZE_MAX
|
# ifdef _SC_GETPW_R_SIZE_MAX
|
||||||
/* This reurns the maximum length */
|
/* This reurns the maximum length */
|
||||||
guint bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
|
glong bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
|
||||||
# else /* _SC_GETPW_R_SIZE_MAX */
|
# else /* _SC_GETPW_R_SIZE_MAX */
|
||||||
guint bufsize = 64;
|
glong bufsize = 64;
|
||||||
# endif /* _SC_GETPW_R_SIZE_MAX */
|
# endif /* _SC_GETPW_R_SIZE_MAX */
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
static void
|
static void
|
||||||
text_handler (GMarkupParseContext *context,
|
text_handler (GMarkupParseContext *context,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint text_len,
|
gsize text_len,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ text_handler (GMarkupParseContext *context,
|
|||||||
static void
|
static void
|
||||||
passthrough_handler (GMarkupParseContext *context,
|
passthrough_handler (GMarkupParseContext *context,
|
||||||
const gchar *passthrough_text,
|
const gchar *passthrough_text,
|
||||||
gint text_len,
|
gsize text_len,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
gchar* global_state;
|
gchar* global_state;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ my_pipe (int *fds)
|
|||||||
int
|
int
|
||||||
read_all (int fd, char *buf, int len)
|
read_all (int fd, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
int count;
|
ssize_t count;
|
||||||
|
|
||||||
while (bytes_read < len)
|
while (bytes_read < len)
|
||||||
{
|
{
|
||||||
@ -53,8 +53,8 @@ read_all (int fd, char *buf, int len)
|
|||||||
int
|
int
|
||||||
write_all (int fd, char *buf, int len)
|
write_all (int fd, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_written = 0;
|
size_t bytes_written = 0;
|
||||||
int count;
|
ssize_t count;
|
||||||
|
|
||||||
while (bytes_written < len)
|
while (bytes_written < len)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ static int n_active_children;
|
|||||||
static int n_iters = 10000;
|
static int n_iters = 10000;
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
|
||||||
void
|
static void
|
||||||
io_pipe (GIOChannel **channels)
|
io_pipe (GIOChannel **channels)
|
||||||
{
|
{
|
||||||
int fds[2];
|
int fds[2];
|
||||||
@ -27,11 +27,11 @@ io_pipe (GIOChannel **channels)
|
|||||||
channels[1] = g_io_channel_unix_new (fds[1]);
|
channels[1] = g_io_channel_unix_new (fds[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
read_all (GIOChannel *channel, char *buf, int len)
|
read_all (GIOChannel *channel, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_read = 0;
|
gsize bytes_read = 0;
|
||||||
int count;
|
gsize count;
|
||||||
GIOError err;
|
GIOError err;
|
||||||
|
|
||||||
while (bytes_read < len)
|
while (bytes_read < len)
|
||||||
@ -51,11 +51,11 @@ read_all (GIOChannel *channel, char *buf, int len)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
write_all (GIOChannel *channel, char *buf, int len)
|
write_all (GIOChannel *channel, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_written = 0;
|
gsize bytes_written = 0;
|
||||||
int count;
|
gsize count;
|
||||||
GIOError err;
|
GIOError err;
|
||||||
|
|
||||||
while (bytes_written < len)
|
while (bytes_written < len)
|
||||||
@ -70,7 +70,7 @@ write_all (GIOChannel *channel, char *buf, int len)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -94,7 +94,7 @@ run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
input_callback (GIOChannel *source,
|
input_callback (GIOChannel *source,
|
||||||
GIOCondition condition,
|
GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -130,7 +130,7 @@ input_callback (GIOChannel *source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
create_child ()
|
create_child ()
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
static gint exit_status = 0;
|
static gint exit_status = 0;
|
||||||
|
|
||||||
void
|
static void
|
||||||
croak (char *format, ...)
|
croak (char *format, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -18,7 +18,7 @@ croak (char *format, ...)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
fail (char *format, ...)
|
fail (char *format, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -84,7 +84,7 @@ process (gint line,
|
|||||||
const gchar *end;
|
const gchar *end;
|
||||||
gboolean is_valid = g_utf8_validate (utf8, -1, &end);
|
gboolean is_valid = g_utf8_validate (utf8, -1, &end);
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gint items_read, items_written;
|
glong items_read, items_written;
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ process (gint line,
|
|||||||
gunichar2 *utf16_from_utf8;
|
gunichar2 *utf16_from_utf8;
|
||||||
gunichar2 *utf16_from_ucs4;
|
gunichar2 *utf16_from_ucs4;
|
||||||
gunichar *ucs4_result;
|
gunichar *ucs4_result;
|
||||||
gint bytes_written;
|
gsize bytes_written;
|
||||||
gint n_chars;
|
gint n_chars;
|
||||||
gchar *utf8_result;
|
gchar *utf8_result;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ my_pipe (int *fds)
|
|||||||
int
|
int
|
||||||
read_all (int fd, char *buf, int len)
|
read_all (int fd, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
int count;
|
ssize_t count;
|
||||||
|
|
||||||
while (bytes_read < len)
|
while (bytes_read < len)
|
||||||
{
|
{
|
||||||
@ -53,8 +53,8 @@ read_all (int fd, char *buf, int len)
|
|||||||
int
|
int
|
||||||
write_all (int fd, char *buf, int len)
|
write_all (int fd, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_written = 0;
|
size_t bytes_written = 0;
|
||||||
int count;
|
ssize_t count;
|
||||||
|
|
||||||
while (bytes_written < len)
|
while (bytes_written < len)
|
||||||
{
|
{
|
||||||
|
20
timeloop.c
20
timeloop.c
@ -12,7 +12,7 @@ static int n_active_children;
|
|||||||
static int n_iters = 10000;
|
static int n_iters = 10000;
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
|
||||||
void
|
static void
|
||||||
io_pipe (GIOChannel **channels)
|
io_pipe (GIOChannel **channels)
|
||||||
{
|
{
|
||||||
int fds[2];
|
int fds[2];
|
||||||
@ -27,11 +27,11 @@ io_pipe (GIOChannel **channels)
|
|||||||
channels[1] = g_io_channel_unix_new (fds[1]);
|
channels[1] = g_io_channel_unix_new (fds[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
read_all (GIOChannel *channel, char *buf, int len)
|
read_all (GIOChannel *channel, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_read = 0;
|
gsize bytes_read = 0;
|
||||||
int count;
|
gsize count;
|
||||||
GIOError err;
|
GIOError err;
|
||||||
|
|
||||||
while (bytes_read < len)
|
while (bytes_read < len)
|
||||||
@ -51,11 +51,11 @@ read_all (GIOChannel *channel, char *buf, int len)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
write_all (GIOChannel *channel, char *buf, int len)
|
write_all (GIOChannel *channel, char *buf, int len)
|
||||||
{
|
{
|
||||||
int bytes_written = 0;
|
gsize bytes_written = 0;
|
||||||
int count;
|
gsize count;
|
||||||
GIOError err;
|
GIOError err;
|
||||||
|
|
||||||
while (bytes_written < len)
|
while (bytes_written < len)
|
||||||
@ -70,7 +70,7 @@ write_all (GIOChannel *channel, char *buf, int len)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -94,7 +94,7 @@ run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
input_callback (GIOChannel *source,
|
input_callback (GIOChannel *source,
|
||||||
GIOCondition condition,
|
GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -130,7 +130,7 @@ input_callback (GIOChannel *source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
create_child ()
|
create_child ()
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user