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>
|
||||
|
||||
*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>
|
||||
|
||||
*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>
|
||||
|
||||
*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>
|
||||
|
||||
*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>
|
||||
|
||||
*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>
|
||||
|
||||
*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>
|
||||
|
||||
*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>
|
||||
|
||||
*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.
|
||||
</para>
|
||||
|
||||
<!-- # Unused Parameters # -->
|
||||
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
|
||||
@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.
|
||||
@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.
|
||||
|
||||
|
||||
|
@ -31,8 +31,9 @@ Unicode Manipulation
|
||||
|
||||
</para>
|
||||
|
||||
@charset:
|
||||
@Returns:
|
||||
<!-- # Unused Parameters # -->
|
||||
@charset:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION g_unichar_validate ##### -->
|
||||
|
4
garray.c
4
garray.c
@ -515,7 +515,7 @@ g_ptr_array_remove (GPtrArray* farray,
|
||||
gpointer data)
|
||||
{
|
||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||
int i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (array, FALSE);
|
||||
|
||||
@ -536,7 +536,7 @@ g_ptr_array_remove_fast (GPtrArray* farray,
|
||||
gpointer data)
|
||||
{
|
||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||
int i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (array, FALSE);
|
||||
|
||||
|
@ -405,7 +405,7 @@ g_async_queue_timed_pop_unlocked (GAsyncQueue* queue, GTimeVal *end_time)
|
||||
gint
|
||||
g_async_queue_length (GAsyncQueue* queue)
|
||||
{
|
||||
glong retval;
|
||||
gint retval;
|
||||
|
||||
g_return_val_if_fail (queue, 0);
|
||||
g_return_val_if_fail (queue->ref_count > 0, 0);
|
||||
|
@ -121,9 +121,9 @@ completion_check_cache (GCompletion* cmp,
|
||||
gchar** new_prefix)
|
||||
{
|
||||
register GList* list;
|
||||
register gint len;
|
||||
register gint i;
|
||||
register gint plen;
|
||||
register gsize len;
|
||||
register gsize i;
|
||||
register gsize plen;
|
||||
gchar* postfix;
|
||||
gchar* s;
|
||||
|
||||
@ -165,8 +165,8 @@ g_completion_complete (GCompletion* cmp,
|
||||
gchar* prefix,
|
||||
gchar** new_prefix)
|
||||
{
|
||||
gint plen, len;
|
||||
gint done = 0;
|
||||
gsize plen, len;
|
||||
gboolean done = FALSE;
|
||||
GList* list;
|
||||
|
||||
g_return_val_if_fail (cmp != NULL, NULL);
|
||||
@ -193,7 +193,7 @@ g_completion_complete (GCompletion* cmp,
|
||||
else
|
||||
list = list->next;
|
||||
}
|
||||
done = 1;
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#define __G_COMPLETION_H__
|
||||
|
||||
#include <glist.h>
|
||||
#include <stddef.h> /* For size_t */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -41,7 +40,7 @@ typedef gchar* (*GCompletionFunc) (gpointer);
|
||||
|
||||
typedef gint (*GCompletionStrncmpFunc) (const gchar *s1,
|
||||
const gchar *s2,
|
||||
size_t n);
|
||||
gsize n);
|
||||
|
||||
struct _GCompletion
|
||||
{
|
||||
|
189
gconvert.c
189
gconvert.c
@ -96,9 +96,9 @@ g_iconv_open (const gchar *to_codeset,
|
||||
size_t
|
||||
g_iconv (GIConv converter,
|
||||
gchar **inbuf,
|
||||
size_t *inbytes_left,
|
||||
gsize *inbytes_left,
|
||||
gchar **outbuf,
|
||||
size_t *outbytes_left)
|
||||
gsize *outbytes_left)
|
||||
{
|
||||
iconv_t cd = (iconv_t)converter;
|
||||
|
||||
@ -179,21 +179,21 @@ open_converter (const gchar *to_codeset,
|
||||
**/
|
||||
gchar*
|
||||
g_convert (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
gchar *dest;
|
||||
gchar *outp;
|
||||
const gchar *p;
|
||||
size_t inbytes_remaining;
|
||||
size_t outbytes_remaining;
|
||||
size_t err;
|
||||
gsize inbytes_remaining;
|
||||
gsize outbytes_remaining;
|
||||
gsize err;
|
||||
GIConv cd;
|
||||
size_t outbuf_size;
|
||||
gsize outbuf_size;
|
||||
gboolean have_error = FALSE;
|
||||
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
@ -218,10 +218,7 @@ g_convert (const gchar *str,
|
||||
|
||||
p = str;
|
||||
inbytes_remaining = len;
|
||||
|
||||
/* 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;
|
||||
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||
|
||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||
outp = dest = g_malloc (outbuf_size);
|
||||
@ -241,19 +238,11 @@ g_convert (const gchar *str,
|
||||
{
|
||||
size_t used = outp - dest;
|
||||
|
||||
/* glibc's iconv can return E2BIG even if there is space
|
||||
* remaining if an internal buffer is exhausted. The
|
||||
* 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);
|
||||
outbuf_size *= 2;
|
||||
dest = g_realloc (dest, outbuf_size);
|
||||
|
||||
outp = dest + used;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
}
|
||||
outp = dest + used;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
|
||||
goto again;
|
||||
}
|
||||
@ -317,10 +306,7 @@ g_convert (const gchar *str,
|
||||
* input string that were successfully converted, or %NULL.
|
||||
* Even if the conversion was succesful, this may be
|
||||
* less than len if there were partial characters
|
||||
* at the end of the input. If the error
|
||||
* G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
|
||||
* stored will the byte fofset after the last valid
|
||||
* input sequence.
|
||||
* at the end of the input.
|
||||
* @bytes_written: the stored in the output buffer (not including the
|
||||
* terminating nul.
|
||||
* @error: location to store the error occuring, or %NULL to ignore
|
||||
@ -340,12 +326,12 @@ g_convert (const gchar *str,
|
||||
**/
|
||||
gchar*
|
||||
g_convert_with_fallback (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gchar *fallback,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
gchar *utf8;
|
||||
@ -353,13 +339,13 @@ g_convert_with_fallback (const gchar *str,
|
||||
gchar *outp;
|
||||
const gchar *insert_str = NULL;
|
||||
const gchar *p;
|
||||
int inbytes_remaining;
|
||||
gsize inbytes_remaining;
|
||||
const gchar *save_p = NULL;
|
||||
size_t save_inbytes = 0;
|
||||
size_t outbytes_remaining;
|
||||
size_t err;
|
||||
gsize save_inbytes = 0;
|
||||
gsize outbytes_remaining;
|
||||
gsize err;
|
||||
GIConv cd;
|
||||
size_t outbuf_size;
|
||||
gsize outbuf_size;
|
||||
gboolean have_error = 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
|
||||
*/
|
||||
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 + 3) & ~3) + 1;
|
||||
|
||||
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||
outp = dest = g_malloc (outbuf_size);
|
||||
|
||||
@ -442,19 +427,11 @@ g_convert_with_fallback (const gchar *str,
|
||||
{
|
||||
size_t used = outp - dest;
|
||||
|
||||
/* glibc's iconv can return E2BIG even if there is space
|
||||
* remaining if an internal buffer is exhausted. The
|
||||
* 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;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
}
|
||||
outbuf_size *= 2;
|
||||
dest = g_realloc (dest, outbuf_size);
|
||||
|
||||
outp = dest + used;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
|
||||
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:
|
||||
* @opsysstring: a string in the encoding of the current locale
|
||||
@ -564,9 +568,9 @@ g_convert_with_fallback (const gchar *str,
|
||||
**/
|
||||
gchar *
|
||||
g_locale_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -667,15 +671,14 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
||||
|
||||
#else /* !G_PLATFORM_WIN32 */
|
||||
|
||||
char *charset, *str;
|
||||
const char *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 */
|
||||
}
|
||||
|
||||
@ -705,9 +708,9 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
||||
**/
|
||||
gchar *
|
||||
g_locale_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -813,17 +816,15 @@ g_locale_from_utf8 (const gchar *utf8string,
|
||||
return result;
|
||||
|
||||
#else /* !G_PLATFORM_WIN32 */
|
||||
|
||||
gchar *charset, *str;
|
||||
|
||||
const gchar *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 */
|
||||
}
|
||||
|
||||
@ -852,9 +853,9 @@ g_locale_from_utf8 (const gchar *utf8string,
|
||||
**/
|
||||
gchar*
|
||||
g_filename_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -866,21 +867,8 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
||||
return g_locale_to_utf8 (opsysstring, len,
|
||||
bytes_read, bytes_written,
|
||||
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
|
||||
return g_strndup (opsysstring, len);
|
||||
return strdup_len (opsysstring, len, bytes_read, bytes_written);
|
||||
#endif /* !G_PLATFORM_WIN32 */
|
||||
}
|
||||
|
||||
@ -908,9 +896,9 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
||||
**/
|
||||
gchar*
|
||||
g_filename_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -922,20 +910,7 @@ g_filename_from_utf8 (const gchar *utf8string,
|
||||
return g_locale_from_utf8 (utf8string, len,
|
||||
bytes_read, bytes_written,
|
||||
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
|
||||
return g_strndup (utf8string, len);
|
||||
return strdup_len (utf8string, len, bytes_read, bytes_written);
|
||||
#endif /* !G_PLATFORM_WIN32 */
|
||||
}
|
||||
|
42
gconvert.h
42
gconvert.h
@ -41,7 +41,7 @@ typedef enum
|
||||
} GConvertError;
|
||||
|
||||
#define G_CONVERT_ERROR g_convert_error_quark()
|
||||
GQuark g_convert_error_quark();
|
||||
GQuark g_convert_error_quark (void);
|
||||
|
||||
/* Thin wrappers around iconv
|
||||
*/
|
||||
@ -51,54 +51,54 @@ GIConv g_iconv_open (const gchar *to_codeset,
|
||||
const gchar *from_codeset);
|
||||
size_t g_iconv (GIConv converter,
|
||||
gchar **inbuf,
|
||||
size_t *inbytes_left,
|
||||
gsize *inbytes_left,
|
||||
gchar **outbuf,
|
||||
size_t *outbytes_left);
|
||||
gsize *outbytes_left);
|
||||
gint g_iconv_close (GIConv converter);
|
||||
|
||||
|
||||
gchar* g_convert (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
gchar* g_convert_with_fallback (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gchar *fallback,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
|
||||
|
||||
/* Convert between libc's idea of strings and UTF-8.
|
||||
*/
|
||||
gchar* g_locale_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
gchar* g_locale_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
|
||||
/* Convert between the operating system (or C runtime)
|
||||
* representation of file names and UTF-8.
|
||||
*/
|
||||
gchar* g_filename_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
gchar* g_filename_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
|
||||
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)
|
||||
{
|
||||
gchar lcstr[128];
|
||||
int i = 1;
|
||||
|
||||
strncpy (lcstr, str, 127);
|
||||
g_strdown (lcstr);
|
||||
|
12
gfileutils.c
12
gfileutils.c
@ -285,7 +285,7 @@ static gboolean
|
||||
get_contents_stdio (const gchar *filename,
|
||||
FILE *f,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
gchar buf[2048];
|
||||
@ -333,7 +333,7 @@ get_contents_regfile (const gchar *filename,
|
||||
struct stat *stat_buf,
|
||||
gint fd,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
gchar *buf;
|
||||
@ -347,7 +347,7 @@ get_contents_regfile (const gchar *filename,
|
||||
bytes_read = 0;
|
||||
while (bytes_read < size)
|
||||
{
|
||||
gint rc;
|
||||
gssize rc;
|
||||
|
||||
rc = read (fd, buf + bytes_read, size - bytes_read);
|
||||
|
||||
@ -387,7 +387,7 @@ get_contents_regfile (const gchar *filename,
|
||||
static gboolean
|
||||
get_contents_posix (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
@ -456,7 +456,7 @@ get_contents_posix (const gchar *filename,
|
||||
static gboolean
|
||||
get_contents_win32 (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
FILE *f;
|
||||
@ -503,7 +503,7 @@ get_contents_win32 (const gchar *filename,
|
||||
gboolean
|
||||
g_file_get_contents (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
@ -76,7 +76,7 @@ gboolean g_file_test (const gchar *filename,
|
||||
GFileTest test);
|
||||
gboolean g_file_get_contents (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error);
|
||||
|
||||
|
||||
|
7
ghook.c
7
ghook.c
@ -631,5 +631,10 @@ gint
|
||||
g_hook_compare_ids (GHook *new_hook,
|
||||
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)
|
||||
{
|
||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||
int i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (array, FALSE);
|
||||
|
||||
@ -536,7 +536,7 @@ g_ptr_array_remove_fast (GPtrArray* farray,
|
||||
gpointer data)
|
||||
{
|
||||
GRealPtrArray* array = (GRealPtrArray*) farray;
|
||||
int i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (array, FALSE);
|
||||
|
||||
|
@ -405,7 +405,7 @@ g_async_queue_timed_pop_unlocked (GAsyncQueue* queue, GTimeVal *end_time)
|
||||
gint
|
||||
g_async_queue_length (GAsyncQueue* queue)
|
||||
{
|
||||
glong retval;
|
||||
gint retval;
|
||||
|
||||
g_return_val_if_fail (queue, 0);
|
||||
g_return_val_if_fail (queue->ref_count > 0, 0);
|
||||
|
@ -121,9 +121,9 @@ completion_check_cache (GCompletion* cmp,
|
||||
gchar** new_prefix)
|
||||
{
|
||||
register GList* list;
|
||||
register gint len;
|
||||
register gint i;
|
||||
register gint plen;
|
||||
register gsize len;
|
||||
register gsize i;
|
||||
register gsize plen;
|
||||
gchar* postfix;
|
||||
gchar* s;
|
||||
|
||||
@ -165,8 +165,8 @@ g_completion_complete (GCompletion* cmp,
|
||||
gchar* prefix,
|
||||
gchar** new_prefix)
|
||||
{
|
||||
gint plen, len;
|
||||
gint done = 0;
|
||||
gsize plen, len;
|
||||
gboolean done = FALSE;
|
||||
GList* list;
|
||||
|
||||
g_return_val_if_fail (cmp != NULL, NULL);
|
||||
@ -193,7 +193,7 @@ g_completion_complete (GCompletion* cmp,
|
||||
else
|
||||
list = list->next;
|
||||
}
|
||||
done = 1;
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#define __G_COMPLETION_H__
|
||||
|
||||
#include <glist.h>
|
||||
#include <stddef.h> /* For size_t */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -41,7 +40,7 @@ typedef gchar* (*GCompletionFunc) (gpointer);
|
||||
|
||||
typedef gint (*GCompletionStrncmpFunc) (const gchar *s1,
|
||||
const gchar *s2,
|
||||
size_t n);
|
||||
gsize n);
|
||||
|
||||
struct _GCompletion
|
||||
{
|
||||
|
189
glib/gconvert.c
189
glib/gconvert.c
@ -96,9 +96,9 @@ g_iconv_open (const gchar *to_codeset,
|
||||
size_t
|
||||
g_iconv (GIConv converter,
|
||||
gchar **inbuf,
|
||||
size_t *inbytes_left,
|
||||
gsize *inbytes_left,
|
||||
gchar **outbuf,
|
||||
size_t *outbytes_left)
|
||||
gsize *outbytes_left)
|
||||
{
|
||||
iconv_t cd = (iconv_t)converter;
|
||||
|
||||
@ -179,21 +179,21 @@ open_converter (const gchar *to_codeset,
|
||||
**/
|
||||
gchar*
|
||||
g_convert (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
gchar *dest;
|
||||
gchar *outp;
|
||||
const gchar *p;
|
||||
size_t inbytes_remaining;
|
||||
size_t outbytes_remaining;
|
||||
size_t err;
|
||||
gsize inbytes_remaining;
|
||||
gsize outbytes_remaining;
|
||||
gsize err;
|
||||
GIConv cd;
|
||||
size_t outbuf_size;
|
||||
gsize outbuf_size;
|
||||
gboolean have_error = FALSE;
|
||||
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
@ -218,10 +218,7 @@ g_convert (const gchar *str,
|
||||
|
||||
p = str;
|
||||
inbytes_remaining = len;
|
||||
|
||||
/* 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;
|
||||
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||
|
||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||
outp = dest = g_malloc (outbuf_size);
|
||||
@ -241,19 +238,11 @@ g_convert (const gchar *str,
|
||||
{
|
||||
size_t used = outp - dest;
|
||||
|
||||
/* glibc's iconv can return E2BIG even if there is space
|
||||
* remaining if an internal buffer is exhausted. The
|
||||
* 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);
|
||||
outbuf_size *= 2;
|
||||
dest = g_realloc (dest, outbuf_size);
|
||||
|
||||
outp = dest + used;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
}
|
||||
outp = dest + used;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
|
||||
goto again;
|
||||
}
|
||||
@ -317,10 +306,7 @@ g_convert (const gchar *str,
|
||||
* input string that were successfully converted, or %NULL.
|
||||
* Even if the conversion was succesful, this may be
|
||||
* less than len if there were partial characters
|
||||
* at the end of the input. If the error
|
||||
* G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value
|
||||
* stored will the byte fofset after the last valid
|
||||
* input sequence.
|
||||
* at the end of the input.
|
||||
* @bytes_written: the stored in the output buffer (not including the
|
||||
* terminating nul.
|
||||
* @error: location to store the error occuring, or %NULL to ignore
|
||||
@ -340,12 +326,12 @@ g_convert (const gchar *str,
|
||||
**/
|
||||
gchar*
|
||||
g_convert_with_fallback (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gchar *fallback,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
gchar *utf8;
|
||||
@ -353,13 +339,13 @@ g_convert_with_fallback (const gchar *str,
|
||||
gchar *outp;
|
||||
const gchar *insert_str = NULL;
|
||||
const gchar *p;
|
||||
int inbytes_remaining;
|
||||
gsize inbytes_remaining;
|
||||
const gchar *save_p = NULL;
|
||||
size_t save_inbytes = 0;
|
||||
size_t outbytes_remaining;
|
||||
size_t err;
|
||||
gsize save_inbytes = 0;
|
||||
gsize outbytes_remaining;
|
||||
gsize err;
|
||||
GIConv cd;
|
||||
size_t outbuf_size;
|
||||
gsize outbuf_size;
|
||||
gboolean have_error = 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
|
||||
*/
|
||||
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 + 3) & ~3) + 1;
|
||||
|
||||
outbuf_size = len + 1; /* + 1 for nul in case len == 1 */
|
||||
outbytes_remaining = outbuf_size - 1; /* -1 for nul */
|
||||
outp = dest = g_malloc (outbuf_size);
|
||||
|
||||
@ -442,19 +427,11 @@ g_convert_with_fallback (const gchar *str,
|
||||
{
|
||||
size_t used = outp - dest;
|
||||
|
||||
/* glibc's iconv can return E2BIG even if there is space
|
||||
* remaining if an internal buffer is exhausted. The
|
||||
* 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;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
}
|
||||
outbuf_size *= 2;
|
||||
dest = g_realloc (dest, outbuf_size);
|
||||
|
||||
outp = dest + used;
|
||||
outbytes_remaining = outbuf_size - used - 1; /* -1 for nul */
|
||||
|
||||
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:
|
||||
* @opsysstring: a string in the encoding of the current locale
|
||||
@ -564,9 +568,9 @@ g_convert_with_fallback (const gchar *str,
|
||||
**/
|
||||
gchar *
|
||||
g_locale_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -667,15 +671,14 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
||||
|
||||
#else /* !G_PLATFORM_WIN32 */
|
||||
|
||||
char *charset, *str;
|
||||
const char *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 */
|
||||
}
|
||||
|
||||
@ -705,9 +708,9 @@ g_locale_to_utf8 (const gchar *opsysstring,
|
||||
**/
|
||||
gchar *
|
||||
g_locale_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -813,17 +816,15 @@ g_locale_from_utf8 (const gchar *utf8string,
|
||||
return result;
|
||||
|
||||
#else /* !G_PLATFORM_WIN32 */
|
||||
|
||||
gchar *charset, *str;
|
||||
|
||||
const gchar *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 */
|
||||
}
|
||||
|
||||
@ -852,9 +853,9 @@ g_locale_from_utf8 (const gchar *utf8string,
|
||||
**/
|
||||
gchar*
|
||||
g_filename_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -866,21 +867,8 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
||||
return g_locale_to_utf8 (opsysstring, len,
|
||||
bytes_read, bytes_written,
|
||||
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
|
||||
return g_strndup (opsysstring, len);
|
||||
return strdup_len (opsysstring, len, bytes_read, bytes_written);
|
||||
#endif /* !G_PLATFORM_WIN32 */
|
||||
}
|
||||
|
||||
@ -908,9 +896,9 @@ g_filename_to_utf8 (const gchar *opsysstring,
|
||||
**/
|
||||
gchar*
|
||||
g_filename_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
@ -922,20 +910,7 @@ g_filename_from_utf8 (const gchar *utf8string,
|
||||
return g_locale_from_utf8 (utf8string, len,
|
||||
bytes_read, bytes_written,
|
||||
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
|
||||
return g_strndup (utf8string, len);
|
||||
return strdup_len (utf8string, len, bytes_read, bytes_written);
|
||||
#endif /* !G_PLATFORM_WIN32 */
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ typedef enum
|
||||
} GConvertError;
|
||||
|
||||
#define G_CONVERT_ERROR g_convert_error_quark()
|
||||
GQuark g_convert_error_quark();
|
||||
GQuark g_convert_error_quark (void);
|
||||
|
||||
/* Thin wrappers around iconv
|
||||
*/
|
||||
@ -51,54 +51,54 @@ GIConv g_iconv_open (const gchar *to_codeset,
|
||||
const gchar *from_codeset);
|
||||
size_t g_iconv (GIConv converter,
|
||||
gchar **inbuf,
|
||||
size_t *inbytes_left,
|
||||
gsize *inbytes_left,
|
||||
gchar **outbuf,
|
||||
size_t *outbytes_left);
|
||||
gsize *outbytes_left);
|
||||
gint g_iconv_close (GIConv converter);
|
||||
|
||||
|
||||
gchar* g_convert (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
gchar* g_convert_with_fallback (const gchar *str,
|
||||
gint len,
|
||||
gssize len,
|
||||
const gchar *to_codeset,
|
||||
const gchar *from_codeset,
|
||||
gchar *fallback,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
|
||||
|
||||
/* Convert between libc's idea of strings and UTF-8.
|
||||
*/
|
||||
gchar* g_locale_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
gchar* g_locale_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
|
||||
/* Convert between the operating system (or C runtime)
|
||||
* representation of file names and UTF-8.
|
||||
*/
|
||||
gchar* g_filename_to_utf8 (const gchar *opsysstring,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
gchar* g_filename_from_utf8 (const gchar *utf8string,
|
||||
gint len,
|
||||
gint *bytes_read,
|
||||
gint *bytes_written,
|
||||
gssize len,
|
||||
gsize *bytes_read,
|
||||
gsize *bytes_written,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -513,7 +513,6 @@ g_date_fill_parse_tokens (const gchar *str, GDateParseTokens *pt)
|
||||
if (pt->num_ints < 3)
|
||||
{
|
||||
gchar lcstr[128];
|
||||
int i = 1;
|
||||
|
||||
strncpy (lcstr, str, 127);
|
||||
g_strdown (lcstr);
|
||||
|
@ -285,7 +285,7 @@ static gboolean
|
||||
get_contents_stdio (const gchar *filename,
|
||||
FILE *f,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
gchar buf[2048];
|
||||
@ -333,7 +333,7 @@ get_contents_regfile (const gchar *filename,
|
||||
struct stat *stat_buf,
|
||||
gint fd,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
gchar *buf;
|
||||
@ -347,7 +347,7 @@ get_contents_regfile (const gchar *filename,
|
||||
bytes_read = 0;
|
||||
while (bytes_read < size)
|
||||
{
|
||||
gint rc;
|
||||
gssize rc;
|
||||
|
||||
rc = read (fd, buf + bytes_read, size - bytes_read);
|
||||
|
||||
@ -387,7 +387,7 @@ get_contents_regfile (const gchar *filename,
|
||||
static gboolean
|
||||
get_contents_posix (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
@ -456,7 +456,7 @@ get_contents_posix (const gchar *filename,
|
||||
static gboolean
|
||||
get_contents_win32 (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
FILE *f;
|
||||
@ -503,7 +503,7 @@ get_contents_win32 (const gchar *filename,
|
||||
gboolean
|
||||
g_file_get_contents (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
@ -76,7 +76,7 @@ gboolean g_file_test (const gchar *filename,
|
||||
GFileTest test);
|
||||
gboolean g_file_get_contents (const gchar *filename,
|
||||
gchar **contents,
|
||||
guint *length,
|
||||
gsize *length,
|
||||
GError **error);
|
||||
|
||||
|
||||
|
@ -631,5 +631,10 @@ gint
|
||||
g_hook_compare_ids (GHook *new_hook,
|
||||
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;
|
||||
}
|
||||
|
||||
GList*
|
||||
static GList*
|
||||
g_list_sort_real (GList *list,
|
||||
GFunc compare_func,
|
||||
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);
|
||||
}
|
||||
|
||||
GList*
|
||||
static GList*
|
||||
g_list_sort2 (GList *list,
|
||||
GCompareFunc compare_func)
|
||||
{
|
||||
|
@ -141,6 +141,11 @@
|
||||
*/
|
||||
#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
|
||||
* fields through their offsets.
|
||||
*/
|
||||
|
52
glib/gmain.c
52
glib/gmain.c
@ -95,7 +95,7 @@ struct _GMainContext
|
||||
GMemChunk *poll_chunk;
|
||||
guint n_poll_records;
|
||||
GPollFD *cached_poll_array;
|
||||
gint cached_poll_array_size;
|
||||
guint cached_poll_array_size;
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
#ifndef G_OS_WIN32
|
||||
@ -1533,7 +1533,7 @@ g_get_current_time (GTimeVal *result)
|
||||
static void
|
||||
g_main_dispatch (GMainContext *context)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < context->pending_dispatches->len; i++)
|
||||
{
|
||||
@ -2619,29 +2619,51 @@ static gboolean
|
||||
g_timeout_prepare (GSource *source,
|
||||
gint *timeout)
|
||||
{
|
||||
glong sec;
|
||||
glong msec;
|
||||
GTimeVal current_time;
|
||||
|
||||
GTimeoutSource *timeout_source = (GTimeoutSource *)source;
|
||||
|
||||
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;
|
||||
else if (msec > timeout_source->interval)
|
||||
else
|
||||
{
|
||||
/* 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;
|
||||
glong interval_sec = timeout_source->interval / 1000;
|
||||
glong interval_msec = timeout_source->interval % 1000;
|
||||
|
||||
if (msec < 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ struct _GMarkupParseContext
|
||||
gint alloc_attrs;
|
||||
|
||||
const gchar *current_text;
|
||||
gint current_text_len;
|
||||
gssize current_text_len;
|
||||
const gchar *current_text_end;
|
||||
|
||||
GString *leftover_char_portion;
|
||||
@ -540,8 +540,7 @@ unescape_text (GMarkupParseContext *context,
|
||||
(l >= 0x10000 && l <= 0x10FFFF))
|
||||
{
|
||||
gchar buf[7];
|
||||
g_string_append (str,
|
||||
char_str (l, buf));
|
||||
g_string_append (str, char_str (l, buf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -756,7 +755,7 @@ add_attribute (GMarkupParseContext *context, char *name)
|
||||
gboolean
|
||||
g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gssize text_len,
|
||||
GError **error)
|
||||
{
|
||||
const gchar *first_invalid;
|
||||
@ -1662,7 +1661,7 @@ g_markup_parse_context_get_position (GMarkupParseContext *context,
|
||||
static void
|
||||
append_escaped_text (GString *str,
|
||||
const gchar *text,
|
||||
gint length)
|
||||
gssize length)
|
||||
{
|
||||
const gchar *p;
|
||||
const gchar *end;
|
||||
@ -1720,7 +1719,7 @@ append_escaped_text (GString *str,
|
||||
**/
|
||||
gchar*
|
||||
g_markup_escape_text (const gchar *text,
|
||||
gint length)
|
||||
gssize length)
|
||||
{
|
||||
GString *str;
|
||||
|
||||
|
@ -72,7 +72,7 @@ struct _GMarkupParser
|
||||
/* text is not nul-terminated */
|
||||
void (*text) (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
@ -83,7 +83,7 @@ struct _GMarkupParser
|
||||
/* text is not nul-terminated. */
|
||||
void (*passthrough) (GMarkupParseContext *context,
|
||||
const gchar *passthrough_text,
|
||||
gint text_len,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
@ -102,7 +102,7 @@ GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
|
||||
void g_markup_parse_context_free (GMarkupParseContext *context);
|
||||
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gssize text_len,
|
||||
GError **error);
|
||||
|
||||
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 */
|
||||
gchar* g_markup_escape_text (const gchar *text,
|
||||
gint length);
|
||||
gssize length);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -71,9 +71,9 @@ struct _GLogHandler
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static inline guint printf_string_upper_bound (const gchar *format,
|
||||
gboolean may_warn,
|
||||
va_list args);
|
||||
static guint printf_string_upper_bound (const gchar *format,
|
||||
gboolean may_warn,
|
||||
va_list args);
|
||||
|
||||
|
||||
/* --- variables --- */
|
||||
@ -156,9 +156,9 @@ ensure_stdout_valid (void)
|
||||
#endif
|
||||
|
||||
static void
|
||||
write_unsigned (GFileDescriptor fd,
|
||||
gulong num,
|
||||
guint radix)
|
||||
write_unsigned (GFileDescriptor fd,
|
||||
gulong num,
|
||||
guint radix)
|
||||
{
|
||||
char buffer[64];
|
||||
gulong tmp;
|
||||
@ -939,13 +939,13 @@ typedef struct
|
||||
gboolean mod_half, mod_long, mod_extra_long;
|
||||
} PrintfArgSpec;
|
||||
|
||||
static inline guint
|
||||
static gsize
|
||||
printf_string_upper_bound (const gchar *format,
|
||||
gboolean may_warn,
|
||||
va_list args)
|
||||
{
|
||||
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
|
||||
guint len = 1;
|
||||
gsize len = 1;
|
||||
|
||||
if (!format)
|
||||
return len;
|
||||
@ -960,7 +960,7 @@ printf_string_upper_bound (const gchar *format,
|
||||
{
|
||||
PrintfArgSpec spec = { 0, };
|
||||
gboolean seen_l = FALSE, conv_done = FALSE;
|
||||
guint conv_len = 0;
|
||||
gsize conv_len = 0;
|
||||
const gchar *spec_start = format;
|
||||
|
||||
do
|
||||
@ -1241,7 +1241,7 @@ printf_string_upper_bound (const gchar *format,
|
||||
return len;
|
||||
}
|
||||
|
||||
guint
|
||||
gsize
|
||||
g_printf_string_upper_bound (const gchar *format,
|
||||
va_list args)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Log level shift offset for user defined
|
||||
|
@ -135,8 +135,8 @@ read_data (GString *str,
|
||||
gint fd,
|
||||
GError **error)
|
||||
{
|
||||
gint bytes;
|
||||
gchar buf[4096];
|
||||
gssize bytes;
|
||||
gchar buf[4096];
|
||||
|
||||
again:
|
||||
|
||||
@ -875,15 +875,15 @@ do_exec (gint child_err_report_fd,
|
||||
static gboolean
|
||||
read_ints (int fd,
|
||||
gint* buf,
|
||||
gint n_ints_in_buf,
|
||||
gint *n_ints_read,
|
||||
gint n_ints_in_buf,
|
||||
gint *n_ints_read,
|
||||
GError **error)
|
||||
{
|
||||
gint bytes = 0;
|
||||
gsize bytes = 0;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
gint chunk;
|
||||
gssize chunk;
|
||||
|
||||
if (bytes >= sizeof(gint)*2)
|
||||
break; /* give up, who knows what happened, should not be
|
||||
@ -893,7 +893,7 @@ read_ints (int fd,
|
||||
again:
|
||||
chunk = read (fd,
|
||||
((gchar*)buf) + bytes,
|
||||
sizeof(gint)*n_ints_in_buf - bytes);
|
||||
sizeof(gint) * n_ints_in_buf - bytes);
|
||||
if (chunk < 0 && errno == EINTR)
|
||||
goto again;
|
||||
|
||||
@ -911,15 +911,11 @@ read_ints (int fd,
|
||||
}
|
||||
else if (chunk == 0)
|
||||
break; /* EOF */
|
||||
else
|
||||
{
|
||||
g_assert (chunk > 0);
|
||||
|
||||
bytes += chunk;
|
||||
}
|
||||
else /* chunk > 0 */
|
||||
bytes += chunk;
|
||||
}
|
||||
|
||||
*n_ints_read = bytes/4;
|
||||
*n_ints_read = (gint)(bytes / sizeof(gint));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1072,7 +1068,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
|
||||
/* Parent */
|
||||
|
||||
gint buf[2];
|
||||
gint n_ints = 0;
|
||||
gint n_ints = 0;
|
||||
|
||||
/* Close the uncared-about ends of the pipes */
|
||||
close_and_invalidate (&child_err_report_pipe[1]);
|
||||
|
@ -88,7 +88,7 @@ g_memdup (gconstpointer mem,
|
||||
|
||||
gchar*
|
||||
g_strndup (const gchar *str,
|
||||
guint n)
|
||||
gsize n)
|
||||
{
|
||||
gchar *new_str;
|
||||
|
||||
@ -105,7 +105,7 @@ g_strndup (const gchar *str,
|
||||
}
|
||||
|
||||
gchar*
|
||||
g_strnfill (guint length,
|
||||
g_strnfill (gsize length,
|
||||
gchar fill_char)
|
||||
{
|
||||
register gchar *str, *s, *end;
|
||||
@ -188,7 +188,7 @@ g_strdup_printf (const gchar *format,
|
||||
gchar*
|
||||
g_strconcat (const gchar *string1, ...)
|
||||
{
|
||||
guint l;
|
||||
gsize l;
|
||||
va_list args;
|
||||
gchar *s;
|
||||
gchar *concat;
|
||||
@ -1062,7 +1062,7 @@ g_strcasecmp (const gchar *s1,
|
||||
gint
|
||||
g_strncasecmp (const gchar *s1,
|
||||
const gchar *s2,
|
||||
guint n)
|
||||
gsize n)
|
||||
{
|
||||
#ifdef HAVE_STRNCASECMP
|
||||
return strncasecmp (s1, s2, n);
|
||||
@ -1319,11 +1319,11 @@ g_strsplit (const gchar *string,
|
||||
s = strstr (string, delimiter);
|
||||
if (s)
|
||||
{
|
||||
guint delimiter_len = strlen (delimiter);
|
||||
gsize delimiter_len = strlen (delimiter);
|
||||
|
||||
do
|
||||
{
|
||||
guint len;
|
||||
gsize len;
|
||||
gchar *new_string;
|
||||
|
||||
len = s - string;
|
||||
@ -1417,8 +1417,9 @@ g_strjoinv (const gchar *separator,
|
||||
|
||||
if (*str_array)
|
||||
{
|
||||
guint i, len;
|
||||
guint separator_len;
|
||||
gint i;
|
||||
gsize len;
|
||||
gsize separator_len;
|
||||
|
||||
separator_len = strlen (separator);
|
||||
/* First part, getting length */
|
||||
@ -1448,8 +1449,8 @@ g_strjoin (const gchar *separator,
|
||||
{
|
||||
gchar *string, *s;
|
||||
va_list args;
|
||||
guint len;
|
||||
guint separator_len;
|
||||
gsize len;
|
||||
gsize separator_len;
|
||||
gchar *ptr;
|
||||
|
||||
if (separator == NULL)
|
||||
@ -1514,11 +1515,9 @@ g_strjoin (const gchar *separator,
|
||||
**/
|
||||
gchar *
|
||||
g_strstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
gssize haystack_len,
|
||||
const gchar *needle)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (haystack != NULL, NULL);
|
||||
g_return_val_if_fail (needle != NULL, NULL);
|
||||
|
||||
@ -1526,27 +1525,33 @@ g_strstr_len (const gchar *haystack,
|
||||
return strstr (haystack, needle);
|
||||
else
|
||||
{
|
||||
const char *p = haystack;
|
||||
int needle_len = strlen (needle);
|
||||
const char *end = haystack + haystack_len - needle_len;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (char *)haystack;
|
||||
const gchar *p = haystack;
|
||||
gsize needle_len = strlen (needle);
|
||||
const gchar *end;
|
||||
gsize i;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (gchar *)haystack;
|
||||
|
||||
if (haystack_len < needle_len)
|
||||
return NULL;
|
||||
|
||||
end = haystack + haystack_len - needle_len;
|
||||
|
||||
while (*p && p <= end)
|
||||
{
|
||||
for (i = 0; i < needle_len; i++)
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (char *)p;
|
||||
return (gchar *)p;
|
||||
|
||||
next:
|
||||
p++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1564,24 +1569,32 @@ gchar *
|
||||
g_strrstr (const gchar *haystack,
|
||||
const gchar *needle)
|
||||
{
|
||||
int i;
|
||||
int needle_len = strlen (needle);
|
||||
int haystack_len = strlen (haystack);
|
||||
const char *p = haystack + haystack_len - needle_len;
|
||||
gsize i;
|
||||
gsize needle_len;
|
||||
gsize haystack_len;
|
||||
const gchar *p;
|
||||
|
||||
g_return_val_if_fail (haystack != NULL, NULL);
|
||||
g_return_val_if_fail (needle != NULL, NULL);
|
||||
|
||||
|
||||
needle_len = strlen (needle);
|
||||
haystack_len = strlen (haystack);
|
||||
|
||||
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)
|
||||
{
|
||||
for (i = 0; i < needle_len; i++)
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (char *)p;
|
||||
return (gchar *)p;
|
||||
|
||||
next:
|
||||
p--;
|
||||
@ -1608,8 +1621,6 @@ g_strrstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
const gchar *needle)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (haystack != 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);
|
||||
else
|
||||
{
|
||||
int needle_len = strlen (needle);
|
||||
const char *haystack_max = haystack + haystack_len;
|
||||
const char *p = haystack;
|
||||
gsize needle_len = strlen (needle);
|
||||
const gchar *haystack_max = haystack + haystack_len;
|
||||
const gchar *p = haystack;
|
||||
gsize i;
|
||||
|
||||
while (p < haystack_max && *p)
|
||||
p++;
|
||||
|
||||
if (p < haystack + needle_len)
|
||||
return NULL;
|
||||
|
||||
p -= needle_len;
|
||||
|
||||
while (p >= haystack)
|
||||
@ -1632,14 +1647,14 @@ g_strrstr_len (const gchar *haystack,
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (char *)p;
|
||||
return (gchar *)p;
|
||||
|
||||
next:
|
||||
p--;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,11 +46,11 @@ gdouble g_strtod (const gchar *nptr,
|
||||
gchar **endptr);
|
||||
G_CONST_RETURN gchar* g_strerror (gint errnum) 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);
|
||||
gint g_strncasecmp (const gchar *s1,
|
||||
gint g_strncasecmp (const gchar *s1,
|
||||
const gchar *s2,
|
||||
guint n);
|
||||
gsize n);
|
||||
gchar* g_strdown (gchar *string);
|
||||
gchar* g_strup (gchar *string);
|
||||
gchar* g_strreverse (gchar *string);
|
||||
@ -61,12 +61,12 @@ gsize g_strlcat (gchar *dest,
|
||||
const gchar *src,
|
||||
gsize dest_size);
|
||||
gchar * g_strstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
gssize haystack_len,
|
||||
const gchar *needle);
|
||||
gchar * g_strrstr (const gchar *haystack,
|
||||
const gchar *needle);
|
||||
gchar * g_strrstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
gssize haystack_len,
|
||||
const gchar *needle);
|
||||
|
||||
/* removes leading spaces */
|
||||
@ -85,8 +85,8 @@ gchar* g_strdup_printf (const gchar *format,
|
||||
gchar* g_strdup_vprintf (const gchar *format,
|
||||
va_list args);
|
||||
gchar* g_strndup (const gchar *str,
|
||||
guint n);
|
||||
gchar* g_strnfill (guint length,
|
||||
gsize n);
|
||||
gchar* g_strnfill (gsize length,
|
||||
gchar fill_char);
|
||||
gchar* g_strconcat (const gchar *string1,
|
||||
...); /* NULL terminated */
|
||||
|
111
glib/gstring.c
111
glib/gstring.c
@ -49,16 +49,16 @@ struct _GRealStringChunk
|
||||
{
|
||||
GHashTable *const_table;
|
||||
GSList *storage_list;
|
||||
gint storage_next;
|
||||
gint this_size;
|
||||
gint default_size;
|
||||
gsize storage_next;
|
||||
gsize this_size;
|
||||
gsize default_size;
|
||||
};
|
||||
|
||||
struct _GRealString
|
||||
{
|
||||
gchar *str;
|
||||
gint len;
|
||||
gint alloc;
|
||||
gsize len;
|
||||
gsize alloc;
|
||||
};
|
||||
|
||||
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
||||
@ -91,18 +91,36 @@ g_str_hash (gconstpointer key)
|
||||
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.
|
||||
*/
|
||||
|
||||
GStringChunk*
|
||||
g_string_chunk_new (gint default_size)
|
||||
g_string_chunk_new (gsize default_size)
|
||||
{
|
||||
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
||||
gint size = 1;
|
||||
gsize size = 1;
|
||||
|
||||
while (size < default_size)
|
||||
size <<= 1;
|
||||
size = nearest_power (1, default_size);
|
||||
|
||||
new_chunk->const_table = NULL;
|
||||
new_chunk->storage_list = NULL;
|
||||
@ -140,17 +158,14 @@ g_string_chunk_insert (GStringChunk *fchunk,
|
||||
const gchar *string)
|
||||
{
|
||||
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
||||
gint len = strlen (string);
|
||||
gsize len = strlen (string);
|
||||
char* pos;
|
||||
|
||||
g_return_val_if_fail (chunk != NULL, NULL);
|
||||
|
||||
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
||||
{
|
||||
gint new_size = chunk->default_size;
|
||||
|
||||
while (new_size < len+1)
|
||||
new_size <<= 1;
|
||||
gsize new_size = nearest_power (chunk->default_size, len + 1);
|
||||
|
||||
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
||||
g_new (char, new_size));
|
||||
@ -193,29 +208,19 @@ g_string_chunk_insert_const (GStringChunk *fchunk,
|
||||
|
||||
/* Strings.
|
||||
*/
|
||||
static inline gint
|
||||
nearest_power (gint num)
|
||||
{
|
||||
gint n = 1;
|
||||
|
||||
while (n < num)
|
||||
n <<= 1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
g_string_maybe_expand (GRealString* string, gint len)
|
||||
g_string_maybe_expand (GRealString* string,
|
||||
gsize len)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
GString*
|
||||
g_string_sized_new (guint dfl_size)
|
||||
g_string_sized_new (gsize dfl_size)
|
||||
{
|
||||
GRealString *string;
|
||||
|
||||
@ -253,7 +258,7 @@ g_string_new (const gchar *init)
|
||||
|
||||
GString*
|
||||
g_string_new_len (const gchar *init,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
GString *string;
|
||||
|
||||
@ -300,7 +305,7 @@ g_string_equal (const GString *v,
|
||||
gchar *p, *q;
|
||||
GRealString *string1 = (GRealString *) v;
|
||||
GRealString *string2 = (GRealString *) v2;
|
||||
gint i = string1->len;
|
||||
gsize i = string1->len;
|
||||
|
||||
if (i != string2->len)
|
||||
return FALSE;
|
||||
@ -323,7 +328,7 @@ guint
|
||||
g_string_hash (const GString *str)
|
||||
{
|
||||
const gchar *p = str->str;
|
||||
gint n = str->len;
|
||||
gsize n = str->len;
|
||||
guint h = 0;
|
||||
|
||||
while (n--)
|
||||
@ -350,7 +355,7 @@ g_string_assign (GString *string,
|
||||
|
||||
GString*
|
||||
g_string_truncate (GString *fstring,
|
||||
guint len)
|
||||
gsize len)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
|
||||
@ -365,21 +370,22 @@ g_string_truncate (GString *fstring,
|
||||
|
||||
GString*
|
||||
g_string_insert_len (GString *fstring,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (val != NULL, fstring);
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (val);
|
||||
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
g_string_maybe_expand (string, len);
|
||||
|
||||
@ -412,7 +418,7 @@ g_string_append (GString *fstring,
|
||||
GString*
|
||||
g_string_append_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (val != NULL, string);
|
||||
@ -442,7 +448,7 @@ g_string_prepend (GString *fstring,
|
||||
GString*
|
||||
g_string_prepend_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (val != NULL, string);
|
||||
@ -461,30 +467,32 @@ g_string_prepend_c (GString *fstring,
|
||||
|
||||
GString*
|
||||
g_string_insert (GString *fstring,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val)
|
||||
{
|
||||
g_return_val_if_fail (fstring != NULL, NULL);
|
||||
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);
|
||||
}
|
||||
|
||||
GString*
|
||||
g_string_insert_c (GString *fstring,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
gchar c)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
g_string_maybe_expand (string, 1);
|
||||
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
/* If not just an append, move the old stuff */
|
||||
if (pos < string->len)
|
||||
@ -501,19 +509,24 @@ g_string_insert_c (GString *fstring,
|
||||
|
||||
GString*
|
||||
g_string_erase (GString *fstring,
|
||||
gint pos,
|
||||
gint len)
|
||||
gsize pos,
|
||||
gsize len)
|
||||
{
|
||||
GRealString *string = (GRealString*)fstring;
|
||||
|
||||
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 <= string->len, fstring);
|
||||
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));
|
||||
if (len < 0)
|
||||
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;
|
||||
|
||||
@ -527,7 +540,7 @@ g_string_down (GString *fstring)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
guchar *s;
|
||||
gint n = string->len;
|
||||
glong n = string->len;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
@ -548,7 +561,7 @@ g_string_up (GString *fstring)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
guchar *s;
|
||||
gint n = string->len;
|
||||
glong n = string->len;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
|
@ -36,13 +36,13 @@ typedef struct _GStringChunk GStringChunk;
|
||||
|
||||
struct _GString
|
||||
{
|
||||
gchar *str;
|
||||
gint len;
|
||||
gchar *str;
|
||||
gssize len;
|
||||
};
|
||||
|
||||
/* String Chunks
|
||||
*/
|
||||
GStringChunk* g_string_chunk_new (gint size);
|
||||
GStringChunk* g_string_chunk_new (gsize size);
|
||||
void g_string_chunk_free (GStringChunk *chunk);
|
||||
gchar* g_string_chunk_insert (GStringChunk *chunk,
|
||||
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_len (const gchar *init,
|
||||
gint len);
|
||||
GString* g_string_sized_new (guint dfl_size);
|
||||
gssize len);
|
||||
GString* g_string_sized_new (gsize dfl_size);
|
||||
gchar* g_string_free (GString *string,
|
||||
gboolean free_segment);
|
||||
gboolean g_string_equal (const GString *v,
|
||||
@ -64,16 +64,16 @@ guint g_string_hash (const GString *str);
|
||||
GString* g_string_assign (GString *string,
|
||||
const gchar *rval);
|
||||
GString* g_string_truncate (GString *string,
|
||||
guint len);
|
||||
gsize len);
|
||||
GString* g_string_insert_len (GString *string,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val,
|
||||
gint len);
|
||||
gssize len);
|
||||
GString* g_string_append (GString *string,
|
||||
const gchar *val);
|
||||
GString* g_string_append_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len);
|
||||
gssize len);
|
||||
GString* g_string_append_c (GString *string,
|
||||
gchar c);
|
||||
GString* g_string_prepend (GString *string,
|
||||
@ -82,16 +82,16 @@ GString* g_string_prepend_c (GString *string,
|
||||
gchar c);
|
||||
GString* g_string_prepend_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len);
|
||||
gssize len);
|
||||
GString* g_string_insert (GString *string,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val);
|
||||
GString* g_string_insert_c (GString *string,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
gchar c);
|
||||
GString* g_string_erase (GString *string,
|
||||
gint pos,
|
||||
gint len);
|
||||
gsize pos,
|
||||
gsize len);
|
||||
GString* g_string_down (GString *string);
|
||||
GString* g_string_up (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()
|
||||
* 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.
|
||||
*/
|
||||
@ -169,8 +169,8 @@ GLIB_VAR char g_utf8_skip[256];
|
||||
|
||||
gunichar g_utf8_get_char (const gchar *p);
|
||||
gchar* g_utf8_offset_to_pointer (const gchar *str,
|
||||
gint offset);
|
||||
gint g_utf8_pointer_to_offset (const gchar *str,
|
||||
glong offset);
|
||||
glong g_utf8_pointer_to_offset (const gchar *str,
|
||||
const gchar *pos);
|
||||
gchar* g_utf8_prev_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,
|
||||
const gchar *p);
|
||||
|
||||
gint g_utf8_strlen (const gchar *p,
|
||||
gint max);
|
||||
glong g_utf8_strlen (const gchar *p,
|
||||
gssize max);
|
||||
|
||||
/* Copies n characters from src to 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
|
||||
functions are equivalants to strchr and strrchr */
|
||||
gchar* g_utf8_strchr (const gchar *p,
|
||||
gint len,
|
||||
gssize len,
|
||||
gunichar c);
|
||||
gchar* g_utf8_strrchr (const gchar *p,
|
||||
gint len,
|
||||
gssize len,
|
||||
gunichar c);
|
||||
|
||||
gunichar2 *g_utf8_to_utf16 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gunichar * g_utf8_to_ucs4 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gunichar * g_utf8_to_ucs4_fast (const gchar *str,
|
||||
gint len,
|
||||
gint *items_written);
|
||||
glong len,
|
||||
glong *items_written);
|
||||
gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gchar* g_utf16_to_utf8 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gchar* g_ucs4_to_utf8 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
|
||||
/* Convert a single character into UTF-8. outbuf must have at
|
||||
@ -234,14 +234,14 @@ gchar* g_ucs4_to_utf8 (const gunichar *str,
|
||||
* result.
|
||||
*/
|
||||
gint g_unichar_to_utf8 (gunichar c,
|
||||
char *outbuf);
|
||||
gchar *outbuf);
|
||||
|
||||
/* Validate a UTF8 string, return TRUE if valid, put pointer to
|
||||
* first invalid char in **end
|
||||
*/
|
||||
|
||||
gboolean g_utf8_validate (const gchar *str,
|
||||
gint max_len,
|
||||
gssize max_len,
|
||||
const gchar **end);
|
||||
|
||||
/* 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
|
||||
**/
|
||||
gint
|
||||
glong
|
||||
g_utf8_strlen (const gchar *p,
|
||||
gint max)
|
||||
gssize max)
|
||||
{
|
||||
int len = 0;
|
||||
glong len = 0;
|
||||
const gchar *start = p;
|
||||
|
||||
if (max < 0)
|
||||
@ -276,7 +276,7 @@ g_utf8_get_char (const gchar *p)
|
||||
**/
|
||||
gchar *
|
||||
g_utf8_offset_to_pointer (const gchar *str,
|
||||
gint offset)
|
||||
glong offset)
|
||||
{
|
||||
const gchar *s = str;
|
||||
while (offset--)
|
||||
@ -295,12 +295,12 @@ g_utf8_offset_to_pointer (const gchar *str,
|
||||
*
|
||||
* Return value: the resulting character offset
|
||||
**/
|
||||
gint
|
||||
glong
|
||||
g_utf8_pointer_to_offset (const gchar *str,
|
||||
const gchar *pos)
|
||||
{
|
||||
const gchar *s = str;
|
||||
gint offset = 0;
|
||||
glong offset = 0;
|
||||
|
||||
while (s < pos)
|
||||
{
|
||||
@ -413,7 +413,7 @@ static char *utf8_charset_cache = NULL;
|
||||
* Return value: %TRUE if the returned charset is UTF-8
|
||||
**/
|
||||
gboolean
|
||||
g_get_charset (char **charset)
|
||||
g_get_charset (G_CONST_RETURN char **charset)
|
||||
{
|
||||
if (utf8_locale_cache != -1)
|
||||
{
|
||||
@ -441,9 +441,10 @@ g_get_charset (char **charset)
|
||||
* Return value: number of bytes written
|
||||
**/
|
||||
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 i;
|
||||
|
||||
@ -506,7 +507,7 @@ g_unichar_to_utf8 (gunichar c, gchar *outbuf)
|
||||
**/
|
||||
gchar *
|
||||
g_utf8_strchr (const char *p,
|
||||
gint p_len,
|
||||
gssize p_len,
|
||||
gunichar c)
|
||||
{
|
||||
gchar ch[10];
|
||||
@ -533,7 +534,7 @@ g_utf8_strchr (const char *p,
|
||||
**/
|
||||
gchar *
|
||||
g_utf8_strrchr (const char *p,
|
||||
gint p_len,
|
||||
gssize p_len,
|
||||
gunichar c)
|
||||
{
|
||||
gchar ch[10];
|
||||
@ -549,9 +550,9 @@ g_utf8_strrchr (const char *p,
|
||||
* and return (gunichar)-2 on incomplete trailing character
|
||||
*/
|
||||
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;
|
||||
|
||||
if (wc < 0x80)
|
||||
@ -592,8 +593,6 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
||||
return (gunichar)-1;
|
||||
}
|
||||
|
||||
if (len == -1)
|
||||
return (gunichar)-1;
|
||||
if (max_len >= 0 && len > max_len)
|
||||
{
|
||||
for (i = 1; i < max_len; i++)
|
||||
@ -644,8 +643,8 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
||||
**/
|
||||
gunichar *
|
||||
g_utf8_to_ucs4_fast (const gchar *str,
|
||||
gint len,
|
||||
gint *items_written)
|
||||
glong len,
|
||||
glong *items_written)
|
||||
{
|
||||
gint j, charlen;
|
||||
gunichar *result;
|
||||
@ -759,9 +758,9 @@ g_utf8_to_ucs4_fast (const gchar *str,
|
||||
**/
|
||||
gunichar *
|
||||
g_utf8_to_ucs4 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gunichar *result = NULL;
|
||||
@ -838,9 +837,9 @@ g_utf8_to_ucs4 (const gchar *str,
|
||||
**/
|
||||
gchar *
|
||||
g_ucs4_to_utf8 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gint result_length;
|
||||
@ -915,9 +914,9 @@ g_ucs4_to_utf8 (const gunichar *str,
|
||||
**/
|
||||
gchar *
|
||||
g_utf16_to_utf8 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
/* 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 *
|
||||
g_utf16_to_ucs4 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
const gunichar2 *in;
|
||||
@ -1202,9 +1201,9 @@ g_utf16_to_ucs4 (const gunichar2 *str,
|
||||
**/
|
||||
gunichar2 *
|
||||
g_utf8_to_utf16 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gunichar2 *result = NULL;
|
||||
@ -1317,9 +1316,9 @@ g_utf8_to_utf16 (const gchar *str,
|
||||
**/
|
||||
gunichar2 *
|
||||
g_ucs4_to_utf16 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gunichar2 *result = NULL;
|
||||
@ -1407,7 +1406,7 @@ g_ucs4_to_utf16 (const gunichar *str,
|
||||
**/
|
||||
gboolean
|
||||
g_utf8_validate (const gchar *str,
|
||||
gint max_len,
|
||||
gssize max_len,
|
||||
const gchar **end)
|
||||
{
|
||||
|
||||
|
@ -484,17 +484,17 @@ g_basename (const gchar *file_name)
|
||||
gchar*
|
||||
g_path_get_basename (const gchar *file_name)
|
||||
{
|
||||
register gint base;
|
||||
register gint last_nonslash;
|
||||
guint len;
|
||||
register gssize base;
|
||||
register gssize last_nonslash;
|
||||
gsize len;
|
||||
gchar *retval;
|
||||
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
|
||||
if (file_name[0] == '\0')
|
||||
/* empty string */
|
||||
return g_strdup (".");
|
||||
|
||||
|
||||
last_nonslash = strlen (file_name) - 1;
|
||||
|
||||
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
||||
@ -595,7 +595,7 @@ gchar*
|
||||
g_path_get_dirname (const gchar *file_name)
|
||||
{
|
||||
register gchar *base;
|
||||
register guint len;
|
||||
register gsize len;
|
||||
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
@ -759,11 +759,11 @@ g_get_any_init (void)
|
||||
#ifdef P_tmpdir
|
||||
if (!g_tmp_dir)
|
||||
{
|
||||
int k;
|
||||
gsize k;
|
||||
g_tmp_dir = g_strdup (P_tmpdir);
|
||||
k = strlen (g_tmp_dir);
|
||||
if (g_tmp_dir[k-1] == G_DIR_SEPARATOR)
|
||||
g_tmp_dir[k-1] = '\0';
|
||||
if (k > 1 && g_tmp_dir[k - 1] == G_DIR_SEPARATOR)
|
||||
g_tmp_dir[k - 1] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -827,9 +827,9 @@ g_get_any_init (void)
|
||||
struct passwd pwd;
|
||||
# ifdef _SC_GETPW_R_SIZE_MAX
|
||||
/* 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 */
|
||||
guint bufsize = 64;
|
||||
glong bufsize = 64;
|
||||
# endif /* _SC_GETPW_R_SIZE_MAX */
|
||||
gint error;
|
||||
|
||||
|
4
glist.c
4
glist.c
@ -717,7 +717,7 @@ g_list_sort_merge (GList *l1,
|
||||
return list.next;
|
||||
}
|
||||
|
||||
GList*
|
||||
static GList*
|
||||
g_list_sort_real (GList *list,
|
||||
GFunc compare_func,
|
||||
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);
|
||||
}
|
||||
|
||||
GList*
|
||||
static GList*
|
||||
g_list_sort2 (GList *list,
|
||||
GCompareFunc compare_func)
|
||||
{
|
||||
|
@ -141,6 +141,11 @@
|
||||
*/
|
||||
#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
|
||||
* fields through their offsets.
|
||||
*/
|
||||
|
52
gmain.c
52
gmain.c
@ -95,7 +95,7 @@ struct _GMainContext
|
||||
GMemChunk *poll_chunk;
|
||||
guint n_poll_records;
|
||||
GPollFD *cached_poll_array;
|
||||
gint cached_poll_array_size;
|
||||
guint cached_poll_array_size;
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
#ifndef G_OS_WIN32
|
||||
@ -1533,7 +1533,7 @@ g_get_current_time (GTimeVal *result)
|
||||
static void
|
||||
g_main_dispatch (GMainContext *context)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < context->pending_dispatches->len; i++)
|
||||
{
|
||||
@ -2619,29 +2619,51 @@ static gboolean
|
||||
g_timeout_prepare (GSource *source,
|
||||
gint *timeout)
|
||||
{
|
||||
glong sec;
|
||||
glong msec;
|
||||
GTimeVal current_time;
|
||||
|
||||
GTimeoutSource *timeout_source = (GTimeoutSource *)source;
|
||||
|
||||
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;
|
||||
else if (msec > timeout_source->interval)
|
||||
else
|
||||
{
|
||||
/* 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;
|
||||
glong interval_sec = timeout_source->interval / 1000;
|
||||
glong interval_msec = timeout_source->interval % 1000;
|
||||
|
||||
if (msec < 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
11
gmarkup.c
11
gmarkup.c
@ -82,7 +82,7 @@ struct _GMarkupParseContext
|
||||
gint alloc_attrs;
|
||||
|
||||
const gchar *current_text;
|
||||
gint current_text_len;
|
||||
gssize current_text_len;
|
||||
const gchar *current_text_end;
|
||||
|
||||
GString *leftover_char_portion;
|
||||
@ -540,8 +540,7 @@ unescape_text (GMarkupParseContext *context,
|
||||
(l >= 0x10000 && l <= 0x10FFFF))
|
||||
{
|
||||
gchar buf[7];
|
||||
g_string_append (str,
|
||||
char_str (l, buf));
|
||||
g_string_append (str, char_str (l, buf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -756,7 +755,7 @@ add_attribute (GMarkupParseContext *context, char *name)
|
||||
gboolean
|
||||
g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gssize text_len,
|
||||
GError **error)
|
||||
{
|
||||
const gchar *first_invalid;
|
||||
@ -1662,7 +1661,7 @@ g_markup_parse_context_get_position (GMarkupParseContext *context,
|
||||
static void
|
||||
append_escaped_text (GString *str,
|
||||
const gchar *text,
|
||||
gint length)
|
||||
gssize length)
|
||||
{
|
||||
const gchar *p;
|
||||
const gchar *end;
|
||||
@ -1720,7 +1719,7 @@ append_escaped_text (GString *str,
|
||||
**/
|
||||
gchar*
|
||||
g_markup_escape_text (const gchar *text,
|
||||
gint length)
|
||||
gssize length)
|
||||
{
|
||||
GString *str;
|
||||
|
||||
|
@ -72,7 +72,7 @@ struct _GMarkupParser
|
||||
/* text is not nul-terminated */
|
||||
void (*text) (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
@ -83,7 +83,7 @@ struct _GMarkupParser
|
||||
/* text is not nul-terminated. */
|
||||
void (*passthrough) (GMarkupParseContext *context,
|
||||
const gchar *passthrough_text,
|
||||
gint text_len,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
|
||||
@ -102,7 +102,7 @@ GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
|
||||
void g_markup_parse_context_free (GMarkupParseContext *context);
|
||||
gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gssize text_len,
|
||||
GError **error);
|
||||
|
||||
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 */
|
||||
gchar* g_markup_escape_text (const gchar *text,
|
||||
gint length);
|
||||
gssize length);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
20
gmessages.c
20
gmessages.c
@ -71,9 +71,9 @@ struct _GLogHandler
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
static inline guint printf_string_upper_bound (const gchar *format,
|
||||
gboolean may_warn,
|
||||
va_list args);
|
||||
static guint printf_string_upper_bound (const gchar *format,
|
||||
gboolean may_warn,
|
||||
va_list args);
|
||||
|
||||
|
||||
/* --- variables --- */
|
||||
@ -156,9 +156,9 @@ ensure_stdout_valid (void)
|
||||
#endif
|
||||
|
||||
static void
|
||||
write_unsigned (GFileDescriptor fd,
|
||||
gulong num,
|
||||
guint radix)
|
||||
write_unsigned (GFileDescriptor fd,
|
||||
gulong num,
|
||||
guint radix)
|
||||
{
|
||||
char buffer[64];
|
||||
gulong tmp;
|
||||
@ -939,13 +939,13 @@ typedef struct
|
||||
gboolean mod_half, mod_long, mod_extra_long;
|
||||
} PrintfArgSpec;
|
||||
|
||||
static inline guint
|
||||
static gsize
|
||||
printf_string_upper_bound (const gchar *format,
|
||||
gboolean may_warn,
|
||||
va_list args)
|
||||
{
|
||||
static const gboolean honour_longs = SIZEOF_LONG > 4 || SIZEOF_VOID_P > 4;
|
||||
guint len = 1;
|
||||
gsize len = 1;
|
||||
|
||||
if (!format)
|
||||
return len;
|
||||
@ -960,7 +960,7 @@ printf_string_upper_bound (const gchar *format,
|
||||
{
|
||||
PrintfArgSpec spec = { 0, };
|
||||
gboolean seen_l = FALSE, conv_done = FALSE;
|
||||
guint conv_len = 0;
|
||||
gsize conv_len = 0;
|
||||
const gchar *spec_start = format;
|
||||
|
||||
do
|
||||
@ -1241,7 +1241,7 @@ printf_string_upper_bound (const gchar *format,
|
||||
return len;
|
||||
}
|
||||
|
||||
guint
|
||||
gsize
|
||||
g_printf_string_upper_bound (const gchar *format,
|
||||
va_list args)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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>
|
||||
|
||||
* 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,
|
||||
const gchar* suffix)
|
||||
{
|
||||
guint string_len = strlen (string);
|
||||
guint suffix_len = strlen (suffix);
|
||||
gsize string_len = strlen (string);
|
||||
gsize suffix_len = strlen (suffix);
|
||||
|
||||
return string_len >= suffix_len &&
|
||||
strcmp (string + string_len - suffix_len, suffix) == 0;
|
||||
|
26
gspawn.c
26
gspawn.c
@ -135,8 +135,8 @@ read_data (GString *str,
|
||||
gint fd,
|
||||
GError **error)
|
||||
{
|
||||
gint bytes;
|
||||
gchar buf[4096];
|
||||
gssize bytes;
|
||||
gchar buf[4096];
|
||||
|
||||
again:
|
||||
|
||||
@ -875,15 +875,15 @@ do_exec (gint child_err_report_fd,
|
||||
static gboolean
|
||||
read_ints (int fd,
|
||||
gint* buf,
|
||||
gint n_ints_in_buf,
|
||||
gint *n_ints_read,
|
||||
gint n_ints_in_buf,
|
||||
gint *n_ints_read,
|
||||
GError **error)
|
||||
{
|
||||
gint bytes = 0;
|
||||
gsize bytes = 0;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
gint chunk;
|
||||
gssize chunk;
|
||||
|
||||
if (bytes >= sizeof(gint)*2)
|
||||
break; /* give up, who knows what happened, should not be
|
||||
@ -893,7 +893,7 @@ read_ints (int fd,
|
||||
again:
|
||||
chunk = read (fd,
|
||||
((gchar*)buf) + bytes,
|
||||
sizeof(gint)*n_ints_in_buf - bytes);
|
||||
sizeof(gint) * n_ints_in_buf - bytes);
|
||||
if (chunk < 0 && errno == EINTR)
|
||||
goto again;
|
||||
|
||||
@ -911,15 +911,11 @@ read_ints (int fd,
|
||||
}
|
||||
else if (chunk == 0)
|
||||
break; /* EOF */
|
||||
else
|
||||
{
|
||||
g_assert (chunk > 0);
|
||||
|
||||
bytes += chunk;
|
||||
}
|
||||
else /* chunk > 0 */
|
||||
bytes += chunk;
|
||||
}
|
||||
|
||||
*n_ints_read = bytes/4;
|
||||
*n_ints_read = (gint)(bytes / sizeof(gint));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1072,7 +1068,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
|
||||
/* Parent */
|
||||
|
||||
gint buf[2];
|
||||
gint n_ints = 0;
|
||||
gint n_ints = 0;
|
||||
|
||||
/* Close the uncared-about ends of the pipes */
|
||||
close_and_invalidate (&child_err_report_pipe[1]);
|
||||
|
89
gstrfuncs.c
89
gstrfuncs.c
@ -88,7 +88,7 @@ g_memdup (gconstpointer mem,
|
||||
|
||||
gchar*
|
||||
g_strndup (const gchar *str,
|
||||
guint n)
|
||||
gsize n)
|
||||
{
|
||||
gchar *new_str;
|
||||
|
||||
@ -105,7 +105,7 @@ g_strndup (const gchar *str,
|
||||
}
|
||||
|
||||
gchar*
|
||||
g_strnfill (guint length,
|
||||
g_strnfill (gsize length,
|
||||
gchar fill_char)
|
||||
{
|
||||
register gchar *str, *s, *end;
|
||||
@ -188,7 +188,7 @@ g_strdup_printf (const gchar *format,
|
||||
gchar*
|
||||
g_strconcat (const gchar *string1, ...)
|
||||
{
|
||||
guint l;
|
||||
gsize l;
|
||||
va_list args;
|
||||
gchar *s;
|
||||
gchar *concat;
|
||||
@ -1062,7 +1062,7 @@ g_strcasecmp (const gchar *s1,
|
||||
gint
|
||||
g_strncasecmp (const gchar *s1,
|
||||
const gchar *s2,
|
||||
guint n)
|
||||
gsize n)
|
||||
{
|
||||
#ifdef HAVE_STRNCASECMP
|
||||
return strncasecmp (s1, s2, n);
|
||||
@ -1319,11 +1319,11 @@ g_strsplit (const gchar *string,
|
||||
s = strstr (string, delimiter);
|
||||
if (s)
|
||||
{
|
||||
guint delimiter_len = strlen (delimiter);
|
||||
gsize delimiter_len = strlen (delimiter);
|
||||
|
||||
do
|
||||
{
|
||||
guint len;
|
||||
gsize len;
|
||||
gchar *new_string;
|
||||
|
||||
len = s - string;
|
||||
@ -1417,8 +1417,9 @@ g_strjoinv (const gchar *separator,
|
||||
|
||||
if (*str_array)
|
||||
{
|
||||
guint i, len;
|
||||
guint separator_len;
|
||||
gint i;
|
||||
gsize len;
|
||||
gsize separator_len;
|
||||
|
||||
separator_len = strlen (separator);
|
||||
/* First part, getting length */
|
||||
@ -1448,8 +1449,8 @@ g_strjoin (const gchar *separator,
|
||||
{
|
||||
gchar *string, *s;
|
||||
va_list args;
|
||||
guint len;
|
||||
guint separator_len;
|
||||
gsize len;
|
||||
gsize separator_len;
|
||||
gchar *ptr;
|
||||
|
||||
if (separator == NULL)
|
||||
@ -1514,11 +1515,9 @@ g_strjoin (const gchar *separator,
|
||||
**/
|
||||
gchar *
|
||||
g_strstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
gssize haystack_len,
|
||||
const gchar *needle)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (haystack != NULL, NULL);
|
||||
g_return_val_if_fail (needle != NULL, NULL);
|
||||
|
||||
@ -1526,27 +1525,33 @@ g_strstr_len (const gchar *haystack,
|
||||
return strstr (haystack, needle);
|
||||
else
|
||||
{
|
||||
const char *p = haystack;
|
||||
int needle_len = strlen (needle);
|
||||
const char *end = haystack + haystack_len - needle_len;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (char *)haystack;
|
||||
const gchar *p = haystack;
|
||||
gsize needle_len = strlen (needle);
|
||||
const gchar *end;
|
||||
gsize i;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (gchar *)haystack;
|
||||
|
||||
if (haystack_len < needle_len)
|
||||
return NULL;
|
||||
|
||||
end = haystack + haystack_len - needle_len;
|
||||
|
||||
while (*p && p <= end)
|
||||
{
|
||||
for (i = 0; i < needle_len; i++)
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (char *)p;
|
||||
return (gchar *)p;
|
||||
|
||||
next:
|
||||
p++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1564,24 +1569,32 @@ gchar *
|
||||
g_strrstr (const gchar *haystack,
|
||||
const gchar *needle)
|
||||
{
|
||||
int i;
|
||||
int needle_len = strlen (needle);
|
||||
int haystack_len = strlen (haystack);
|
||||
const char *p = haystack + haystack_len - needle_len;
|
||||
gsize i;
|
||||
gsize needle_len;
|
||||
gsize haystack_len;
|
||||
const gchar *p;
|
||||
|
||||
g_return_val_if_fail (haystack != NULL, NULL);
|
||||
g_return_val_if_fail (needle != NULL, NULL);
|
||||
|
||||
|
||||
needle_len = strlen (needle);
|
||||
haystack_len = strlen (haystack);
|
||||
|
||||
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)
|
||||
{
|
||||
for (i = 0; i < needle_len; i++)
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (char *)p;
|
||||
return (gchar *)p;
|
||||
|
||||
next:
|
||||
p--;
|
||||
@ -1608,8 +1621,6 @@ g_strrstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
const gchar *needle)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (haystack != 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);
|
||||
else
|
||||
{
|
||||
int needle_len = strlen (needle);
|
||||
const char *haystack_max = haystack + haystack_len;
|
||||
const char *p = haystack;
|
||||
gsize needle_len = strlen (needle);
|
||||
const gchar *haystack_max = haystack + haystack_len;
|
||||
const gchar *p = haystack;
|
||||
gsize i;
|
||||
|
||||
while (p < haystack_max && *p)
|
||||
p++;
|
||||
|
||||
if (p < haystack + needle_len)
|
||||
return NULL;
|
||||
|
||||
p -= needle_len;
|
||||
|
||||
while (p >= haystack)
|
||||
@ -1632,14 +1647,14 @@ g_strrstr_len (const gchar *haystack,
|
||||
if (p[i] != needle[i])
|
||||
goto next;
|
||||
|
||||
return (char *)p;
|
||||
return (gchar *)p;
|
||||
|
||||
next:
|
||||
p--;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
14
gstrfuncs.h
14
gstrfuncs.h
@ -46,11 +46,11 @@ gdouble g_strtod (const gchar *nptr,
|
||||
gchar **endptr);
|
||||
G_CONST_RETURN gchar* g_strerror (gint errnum) 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);
|
||||
gint g_strncasecmp (const gchar *s1,
|
||||
gint g_strncasecmp (const gchar *s1,
|
||||
const gchar *s2,
|
||||
guint n);
|
||||
gsize n);
|
||||
gchar* g_strdown (gchar *string);
|
||||
gchar* g_strup (gchar *string);
|
||||
gchar* g_strreverse (gchar *string);
|
||||
@ -61,12 +61,12 @@ gsize g_strlcat (gchar *dest,
|
||||
const gchar *src,
|
||||
gsize dest_size);
|
||||
gchar * g_strstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
gssize haystack_len,
|
||||
const gchar *needle);
|
||||
gchar * g_strrstr (const gchar *haystack,
|
||||
const gchar *needle);
|
||||
gchar * g_strrstr_len (const gchar *haystack,
|
||||
gint haystack_len,
|
||||
gssize haystack_len,
|
||||
const gchar *needle);
|
||||
|
||||
/* removes leading spaces */
|
||||
@ -85,8 +85,8 @@ gchar* g_strdup_printf (const gchar *format,
|
||||
gchar* g_strdup_vprintf (const gchar *format,
|
||||
va_list args);
|
||||
gchar* g_strndup (const gchar *str,
|
||||
guint n);
|
||||
gchar* g_strnfill (guint length,
|
||||
gsize n);
|
||||
gchar* g_strnfill (gsize length,
|
||||
gchar fill_char);
|
||||
gchar* g_strconcat (const gchar *string1,
|
||||
...); /* NULL terminated */
|
||||
|
111
gstring.c
111
gstring.c
@ -49,16 +49,16 @@ struct _GRealStringChunk
|
||||
{
|
||||
GHashTable *const_table;
|
||||
GSList *storage_list;
|
||||
gint storage_next;
|
||||
gint this_size;
|
||||
gint default_size;
|
||||
gsize storage_next;
|
||||
gsize this_size;
|
||||
gsize default_size;
|
||||
};
|
||||
|
||||
struct _GRealString
|
||||
{
|
||||
gchar *str;
|
||||
gint len;
|
||||
gint alloc;
|
||||
gsize len;
|
||||
gsize alloc;
|
||||
};
|
||||
|
||||
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
||||
@ -91,18 +91,36 @@ g_str_hash (gconstpointer key)
|
||||
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.
|
||||
*/
|
||||
|
||||
GStringChunk*
|
||||
g_string_chunk_new (gint default_size)
|
||||
g_string_chunk_new (gsize default_size)
|
||||
{
|
||||
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
||||
gint size = 1;
|
||||
gsize size = 1;
|
||||
|
||||
while (size < default_size)
|
||||
size <<= 1;
|
||||
size = nearest_power (1, default_size);
|
||||
|
||||
new_chunk->const_table = NULL;
|
||||
new_chunk->storage_list = NULL;
|
||||
@ -140,17 +158,14 @@ g_string_chunk_insert (GStringChunk *fchunk,
|
||||
const gchar *string)
|
||||
{
|
||||
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
||||
gint len = strlen (string);
|
||||
gsize len = strlen (string);
|
||||
char* pos;
|
||||
|
||||
g_return_val_if_fail (chunk != NULL, NULL);
|
||||
|
||||
if ((chunk->storage_next + len + 1) > chunk->this_size)
|
||||
{
|
||||
gint new_size = chunk->default_size;
|
||||
|
||||
while (new_size < len+1)
|
||||
new_size <<= 1;
|
||||
gsize new_size = nearest_power (chunk->default_size, len + 1);
|
||||
|
||||
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
||||
g_new (char, new_size));
|
||||
@ -193,29 +208,19 @@ g_string_chunk_insert_const (GStringChunk *fchunk,
|
||||
|
||||
/* Strings.
|
||||
*/
|
||||
static inline gint
|
||||
nearest_power (gint num)
|
||||
{
|
||||
gint n = 1;
|
||||
|
||||
while (n < num)
|
||||
n <<= 1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
g_string_maybe_expand (GRealString* string, gint len)
|
||||
g_string_maybe_expand (GRealString* string,
|
||||
gsize len)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
GString*
|
||||
g_string_sized_new (guint dfl_size)
|
||||
g_string_sized_new (gsize dfl_size)
|
||||
{
|
||||
GRealString *string;
|
||||
|
||||
@ -253,7 +258,7 @@ g_string_new (const gchar *init)
|
||||
|
||||
GString*
|
||||
g_string_new_len (const gchar *init,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
GString *string;
|
||||
|
||||
@ -300,7 +305,7 @@ g_string_equal (const GString *v,
|
||||
gchar *p, *q;
|
||||
GRealString *string1 = (GRealString *) v;
|
||||
GRealString *string2 = (GRealString *) v2;
|
||||
gint i = string1->len;
|
||||
gsize i = string1->len;
|
||||
|
||||
if (i != string2->len)
|
||||
return FALSE;
|
||||
@ -323,7 +328,7 @@ guint
|
||||
g_string_hash (const GString *str)
|
||||
{
|
||||
const gchar *p = str->str;
|
||||
gint n = str->len;
|
||||
gsize n = str->len;
|
||||
guint h = 0;
|
||||
|
||||
while (n--)
|
||||
@ -350,7 +355,7 @@ g_string_assign (GString *string,
|
||||
|
||||
GString*
|
||||
g_string_truncate (GString *fstring,
|
||||
guint len)
|
||||
gsize len)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
|
||||
@ -365,21 +370,22 @@ g_string_truncate (GString *fstring,
|
||||
|
||||
GString*
|
||||
g_string_insert_len (GString *fstring,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (val != NULL, fstring);
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (val);
|
||||
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
g_string_maybe_expand (string, len);
|
||||
|
||||
@ -412,7 +418,7 @@ g_string_append (GString *fstring,
|
||||
GString*
|
||||
g_string_append_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (val != NULL, string);
|
||||
@ -442,7 +448,7 @@ g_string_prepend (GString *fstring,
|
||||
GString*
|
||||
g_string_prepend_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len)
|
||||
gssize len)
|
||||
{
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (val != NULL, string);
|
||||
@ -461,30 +467,32 @@ g_string_prepend_c (GString *fstring,
|
||||
|
||||
GString*
|
||||
g_string_insert (GString *fstring,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val)
|
||||
{
|
||||
g_return_val_if_fail (fstring != NULL, NULL);
|
||||
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);
|
||||
}
|
||||
|
||||
GString*
|
||||
g_string_insert_c (GString *fstring,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
gchar c)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
g_string_maybe_expand (string, 1);
|
||||
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, fstring);
|
||||
|
||||
/* If not just an append, move the old stuff */
|
||||
if (pos < string->len)
|
||||
@ -501,19 +509,24 @@ g_string_insert_c (GString *fstring,
|
||||
|
||||
GString*
|
||||
g_string_erase (GString *fstring,
|
||||
gint pos,
|
||||
gint len)
|
||||
gsize pos,
|
||||
gsize len)
|
||||
{
|
||||
GRealString *string = (GRealString*)fstring;
|
||||
|
||||
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 <= string->len, fstring);
|
||||
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));
|
||||
if (len < 0)
|
||||
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;
|
||||
|
||||
@ -527,7 +540,7 @@ g_string_down (GString *fstring)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
guchar *s;
|
||||
gint n = string->len;
|
||||
glong n = string->len;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
@ -548,7 +561,7 @@ g_string_up (GString *fstring)
|
||||
{
|
||||
GRealString *string = (GRealString *) fstring;
|
||||
guchar *s;
|
||||
gint n = string->len;
|
||||
glong n = string->len;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
|
28
gstring.h
28
gstring.h
@ -36,13 +36,13 @@ typedef struct _GStringChunk GStringChunk;
|
||||
|
||||
struct _GString
|
||||
{
|
||||
gchar *str;
|
||||
gint len;
|
||||
gchar *str;
|
||||
gssize len;
|
||||
};
|
||||
|
||||
/* String Chunks
|
||||
*/
|
||||
GStringChunk* g_string_chunk_new (gint size);
|
||||
GStringChunk* g_string_chunk_new (gsize size);
|
||||
void g_string_chunk_free (GStringChunk *chunk);
|
||||
gchar* g_string_chunk_insert (GStringChunk *chunk,
|
||||
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_len (const gchar *init,
|
||||
gint len);
|
||||
GString* g_string_sized_new (guint dfl_size);
|
||||
gssize len);
|
||||
GString* g_string_sized_new (gsize dfl_size);
|
||||
gchar* g_string_free (GString *string,
|
||||
gboolean free_segment);
|
||||
gboolean g_string_equal (const GString *v,
|
||||
@ -64,16 +64,16 @@ guint g_string_hash (const GString *str);
|
||||
GString* g_string_assign (GString *string,
|
||||
const gchar *rval);
|
||||
GString* g_string_truncate (GString *string,
|
||||
guint len);
|
||||
gsize len);
|
||||
GString* g_string_insert_len (GString *string,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val,
|
||||
gint len);
|
||||
gssize len);
|
||||
GString* g_string_append (GString *string,
|
||||
const gchar *val);
|
||||
GString* g_string_append_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len);
|
||||
gssize len);
|
||||
GString* g_string_append_c (GString *string,
|
||||
gchar c);
|
||||
GString* g_string_prepend (GString *string,
|
||||
@ -82,16 +82,16 @@ GString* g_string_prepend_c (GString *string,
|
||||
gchar c);
|
||||
GString* g_string_prepend_len (GString *string,
|
||||
const gchar *val,
|
||||
gint len);
|
||||
gssize len);
|
||||
GString* g_string_insert (GString *string,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
const gchar *val);
|
||||
GString* g_string_insert_c (GString *string,
|
||||
gint pos,
|
||||
gssize pos,
|
||||
gchar c);
|
||||
GString* g_string_erase (GString *string,
|
||||
gint pos,
|
||||
gint len);
|
||||
gsize pos,
|
||||
gsize len);
|
||||
GString* g_string_down (GString *string);
|
||||
GString* g_string_up (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()
|
||||
* 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.
|
||||
*/
|
||||
@ -169,8 +169,8 @@ GLIB_VAR char g_utf8_skip[256];
|
||||
|
||||
gunichar g_utf8_get_char (const gchar *p);
|
||||
gchar* g_utf8_offset_to_pointer (const gchar *str,
|
||||
gint offset);
|
||||
gint g_utf8_pointer_to_offset (const gchar *str,
|
||||
glong offset);
|
||||
glong g_utf8_pointer_to_offset (const gchar *str,
|
||||
const gchar *pos);
|
||||
gchar* g_utf8_prev_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,
|
||||
const gchar *p);
|
||||
|
||||
gint g_utf8_strlen (const gchar *p,
|
||||
gint max);
|
||||
glong g_utf8_strlen (const gchar *p,
|
||||
gssize max);
|
||||
|
||||
/* Copies n characters from src to 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
|
||||
functions are equivalants to strchr and strrchr */
|
||||
gchar* g_utf8_strchr (const gchar *p,
|
||||
gint len,
|
||||
gssize len,
|
||||
gunichar c);
|
||||
gchar* g_utf8_strrchr (const gchar *p,
|
||||
gint len,
|
||||
gssize len,
|
||||
gunichar c);
|
||||
|
||||
gunichar2 *g_utf8_to_utf16 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gunichar * g_utf8_to_ucs4 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gunichar * g_utf8_to_ucs4_fast (const gchar *str,
|
||||
gint len,
|
||||
gint *items_written);
|
||||
glong len,
|
||||
glong *items_written);
|
||||
gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gchar* g_utf16_to_utf8 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
gchar* g_ucs4_to_utf8 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error);
|
||||
|
||||
/* Convert a single character into UTF-8. outbuf must have at
|
||||
@ -234,14 +234,14 @@ gchar* g_ucs4_to_utf8 (const gunichar *str,
|
||||
* result.
|
||||
*/
|
||||
gint g_unichar_to_utf8 (gunichar c,
|
||||
char *outbuf);
|
||||
gchar *outbuf);
|
||||
|
||||
/* Validate a UTF8 string, return TRUE if valid, put pointer to
|
||||
* first invalid char in **end
|
||||
*/
|
||||
|
||||
gboolean g_utf8_validate (const gchar *str,
|
||||
gint max_len,
|
||||
gssize max_len,
|
||||
const gchar **end);
|
||||
|
||||
/* 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
|
||||
**/
|
||||
gint
|
||||
glong
|
||||
g_utf8_strlen (const gchar *p,
|
||||
gint max)
|
||||
gssize max)
|
||||
{
|
||||
int len = 0;
|
||||
glong len = 0;
|
||||
const gchar *start = p;
|
||||
|
||||
if (max < 0)
|
||||
@ -276,7 +276,7 @@ g_utf8_get_char (const gchar *p)
|
||||
**/
|
||||
gchar *
|
||||
g_utf8_offset_to_pointer (const gchar *str,
|
||||
gint offset)
|
||||
glong offset)
|
||||
{
|
||||
const gchar *s = str;
|
||||
while (offset--)
|
||||
@ -295,12 +295,12 @@ g_utf8_offset_to_pointer (const gchar *str,
|
||||
*
|
||||
* Return value: the resulting character offset
|
||||
**/
|
||||
gint
|
||||
glong
|
||||
g_utf8_pointer_to_offset (const gchar *str,
|
||||
const gchar *pos)
|
||||
{
|
||||
const gchar *s = str;
|
||||
gint offset = 0;
|
||||
glong offset = 0;
|
||||
|
||||
while (s < pos)
|
||||
{
|
||||
@ -413,7 +413,7 @@ static char *utf8_charset_cache = NULL;
|
||||
* Return value: %TRUE if the returned charset is UTF-8
|
||||
**/
|
||||
gboolean
|
||||
g_get_charset (char **charset)
|
||||
g_get_charset (G_CONST_RETURN char **charset)
|
||||
{
|
||||
if (utf8_locale_cache != -1)
|
||||
{
|
||||
@ -441,9 +441,10 @@ g_get_charset (char **charset)
|
||||
* Return value: number of bytes written
|
||||
**/
|
||||
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 i;
|
||||
|
||||
@ -506,7 +507,7 @@ g_unichar_to_utf8 (gunichar c, gchar *outbuf)
|
||||
**/
|
||||
gchar *
|
||||
g_utf8_strchr (const char *p,
|
||||
gint p_len,
|
||||
gssize p_len,
|
||||
gunichar c)
|
||||
{
|
||||
gchar ch[10];
|
||||
@ -533,7 +534,7 @@ g_utf8_strchr (const char *p,
|
||||
**/
|
||||
gchar *
|
||||
g_utf8_strrchr (const char *p,
|
||||
gint p_len,
|
||||
gssize p_len,
|
||||
gunichar c)
|
||||
{
|
||||
gchar ch[10];
|
||||
@ -549,9 +550,9 @@ g_utf8_strrchr (const char *p,
|
||||
* and return (gunichar)-2 on incomplete trailing character
|
||||
*/
|
||||
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;
|
||||
|
||||
if (wc < 0x80)
|
||||
@ -592,8 +593,6 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
||||
return (gunichar)-1;
|
||||
}
|
||||
|
||||
if (len == -1)
|
||||
return (gunichar)-1;
|
||||
if (max_len >= 0 && len > max_len)
|
||||
{
|
||||
for (i = 1; i < max_len; i++)
|
||||
@ -644,8 +643,8 @@ g_utf8_get_char_extended (const gchar *p, int max_len)
|
||||
**/
|
||||
gunichar *
|
||||
g_utf8_to_ucs4_fast (const gchar *str,
|
||||
gint len,
|
||||
gint *items_written)
|
||||
glong len,
|
||||
glong *items_written)
|
||||
{
|
||||
gint j, charlen;
|
||||
gunichar *result;
|
||||
@ -759,9 +758,9 @@ g_utf8_to_ucs4_fast (const gchar *str,
|
||||
**/
|
||||
gunichar *
|
||||
g_utf8_to_ucs4 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gunichar *result = NULL;
|
||||
@ -838,9 +837,9 @@ g_utf8_to_ucs4 (const gchar *str,
|
||||
**/
|
||||
gchar *
|
||||
g_ucs4_to_utf8 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gint result_length;
|
||||
@ -915,9 +914,9 @@ g_ucs4_to_utf8 (const gunichar *str,
|
||||
**/
|
||||
gchar *
|
||||
g_utf16_to_utf8 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
/* 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 *
|
||||
g_utf16_to_ucs4 (const gunichar2 *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
const gunichar2 *in;
|
||||
@ -1202,9 +1201,9 @@ g_utf16_to_ucs4 (const gunichar2 *str,
|
||||
**/
|
||||
gunichar2 *
|
||||
g_utf8_to_utf16 (const gchar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gunichar2 *result = NULL;
|
||||
@ -1317,9 +1316,9 @@ g_utf8_to_utf16 (const gchar *str,
|
||||
**/
|
||||
gunichar2 *
|
||||
g_ucs4_to_utf16 (const gunichar *str,
|
||||
gint len,
|
||||
gint *items_read,
|
||||
gint *items_written,
|
||||
glong len,
|
||||
glong *items_read,
|
||||
glong *items_written,
|
||||
GError **error)
|
||||
{
|
||||
gunichar2 *result = NULL;
|
||||
@ -1407,7 +1406,7 @@ g_ucs4_to_utf16 (const gunichar *str,
|
||||
**/
|
||||
gboolean
|
||||
g_utf8_validate (const gchar *str,
|
||||
gint max_len,
|
||||
gssize max_len,
|
||||
const gchar **end)
|
||||
{
|
||||
|
||||
|
22
gutils.c
22
gutils.c
@ -484,17 +484,17 @@ g_basename (const gchar *file_name)
|
||||
gchar*
|
||||
g_path_get_basename (const gchar *file_name)
|
||||
{
|
||||
register gint base;
|
||||
register gint last_nonslash;
|
||||
guint len;
|
||||
register gssize base;
|
||||
register gssize last_nonslash;
|
||||
gsize len;
|
||||
gchar *retval;
|
||||
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
|
||||
if (file_name[0] == '\0')
|
||||
/* empty string */
|
||||
return g_strdup (".");
|
||||
|
||||
|
||||
last_nonslash = strlen (file_name) - 1;
|
||||
|
||||
while (last_nonslash >= 0 && file_name [last_nonslash] == G_DIR_SEPARATOR)
|
||||
@ -595,7 +595,7 @@ gchar*
|
||||
g_path_get_dirname (const gchar *file_name)
|
||||
{
|
||||
register gchar *base;
|
||||
register guint len;
|
||||
register gsize len;
|
||||
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
@ -759,11 +759,11 @@ g_get_any_init (void)
|
||||
#ifdef P_tmpdir
|
||||
if (!g_tmp_dir)
|
||||
{
|
||||
int k;
|
||||
gsize k;
|
||||
g_tmp_dir = g_strdup (P_tmpdir);
|
||||
k = strlen (g_tmp_dir);
|
||||
if (g_tmp_dir[k-1] == G_DIR_SEPARATOR)
|
||||
g_tmp_dir[k-1] = '\0';
|
||||
if (k > 1 && g_tmp_dir[k - 1] == G_DIR_SEPARATOR)
|
||||
g_tmp_dir[k - 1] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -827,9 +827,9 @@ g_get_any_init (void)
|
||||
struct passwd pwd;
|
||||
# ifdef _SC_GETPW_R_SIZE_MAX
|
||||
/* 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 */
|
||||
guint bufsize = 64;
|
||||
glong bufsize = 64;
|
||||
# endif /* _SC_GETPW_R_SIZE_MAX */
|
||||
gint error;
|
||||
|
||||
|
@ -56,7 +56,7 @@ end_element_handler (GMarkupParseContext *context,
|
||||
static void
|
||||
text_handler (GMarkupParseContext *context,
|
||||
const gchar *text,
|
||||
gint text_len,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
@ -68,7 +68,7 @@ text_handler (GMarkupParseContext *context,
|
||||
static void
|
||||
passthrough_handler (GMarkupParseContext *context,
|
||||
const gchar *passthrough_text,
|
||||
gint text_len,
|
||||
gsize text_len,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <gmodule.h>
|
||||
#include <string.h>
|
||||
|
||||
gchar* global_state;
|
||||
|
||||
|
@ -30,8 +30,8 @@ my_pipe (int *fds)
|
||||
int
|
||||
read_all (int fd, char *buf, int len)
|
||||
{
|
||||
int bytes_read = 0;
|
||||
int count;
|
||||
size_t bytes_read = 0;
|
||||
ssize_t count;
|
||||
|
||||
while (bytes_read < len)
|
||||
{
|
||||
@ -53,8 +53,8 @@ read_all (int fd, char *buf, int len)
|
||||
int
|
||||
write_all (int fd, char *buf, int len)
|
||||
{
|
||||
int bytes_written = 0;
|
||||
int count;
|
||||
size_t bytes_written = 0;
|
||||
ssize_t count;
|
||||
|
||||
while (bytes_written < len)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ static int n_active_children;
|
||||
static int n_iters = 10000;
|
||||
static GMainLoop *loop;
|
||||
|
||||
void
|
||||
static void
|
||||
io_pipe (GIOChannel **channels)
|
||||
{
|
||||
int fds[2];
|
||||
@ -27,11 +27,11 @@ io_pipe (GIOChannel **channels)
|
||||
channels[1] = g_io_channel_unix_new (fds[1]);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
read_all (GIOChannel *channel, char *buf, int len)
|
||||
{
|
||||
int bytes_read = 0;
|
||||
int count;
|
||||
gsize bytes_read = 0;
|
||||
gsize count;
|
||||
GIOError err;
|
||||
|
||||
while (bytes_read < len)
|
||||
@ -51,11 +51,11 @@ read_all (GIOChannel *channel, char *buf, int len)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
write_all (GIOChannel *channel, char *buf, int len)
|
||||
{
|
||||
int bytes_written = 0;
|
||||
int count;
|
||||
gsize bytes_written = 0;
|
||||
gsize count;
|
||||
GIOError err;
|
||||
|
||||
while (bytes_written < len)
|
||||
@ -70,7 +70,7 @@ write_all (GIOChannel *channel, char *buf, int len)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
||||
{
|
||||
int i;
|
||||
@ -94,7 +94,7 @@ run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
||||
exit (0);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
input_callback (GIOChannel *source,
|
||||
GIOCondition condition,
|
||||
gpointer data)
|
||||
@ -130,7 +130,7 @@ input_callback (GIOChannel *source,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
create_child ()
|
||||
{
|
||||
int pid;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
static gint exit_status = 0;
|
||||
|
||||
void
|
||||
static void
|
||||
croak (char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
@ -18,7 +18,7 @@ croak (char *format, ...)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
fail (char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
@ -84,7 +84,7 @@ process (gint line,
|
||||
const gchar *end;
|
||||
gboolean is_valid = g_utf8_validate (utf8, -1, &end);
|
||||
GError *error = NULL;
|
||||
gint items_read, items_written;
|
||||
glong items_read, items_written;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
@ -188,7 +188,7 @@ process (gint line,
|
||||
gunichar2 *utf16_from_utf8;
|
||||
gunichar2 *utf16_from_ucs4;
|
||||
gunichar *ucs4_result;
|
||||
gint bytes_written;
|
||||
gsize bytes_written;
|
||||
gint n_chars;
|
||||
gchar *utf8_result;
|
||||
|
||||
|
@ -30,8 +30,8 @@ my_pipe (int *fds)
|
||||
int
|
||||
read_all (int fd, char *buf, int len)
|
||||
{
|
||||
int bytes_read = 0;
|
||||
int count;
|
||||
size_t bytes_read = 0;
|
||||
ssize_t count;
|
||||
|
||||
while (bytes_read < len)
|
||||
{
|
||||
@ -53,8 +53,8 @@ read_all (int fd, char *buf, int len)
|
||||
int
|
||||
write_all (int fd, char *buf, int len)
|
||||
{
|
||||
int bytes_written = 0;
|
||||
int count;
|
||||
size_t bytes_written = 0;
|
||||
ssize_t count;
|
||||
|
||||
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 GMainLoop *loop;
|
||||
|
||||
void
|
||||
static void
|
||||
io_pipe (GIOChannel **channels)
|
||||
{
|
||||
int fds[2];
|
||||
@ -27,11 +27,11 @@ io_pipe (GIOChannel **channels)
|
||||
channels[1] = g_io_channel_unix_new (fds[1]);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
read_all (GIOChannel *channel, char *buf, int len)
|
||||
{
|
||||
int bytes_read = 0;
|
||||
int count;
|
||||
gsize bytes_read = 0;
|
||||
gsize count;
|
||||
GIOError err;
|
||||
|
||||
while (bytes_read < len)
|
||||
@ -51,11 +51,11 @@ read_all (GIOChannel *channel, char *buf, int len)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
write_all (GIOChannel *channel, char *buf, int len)
|
||||
{
|
||||
int bytes_written = 0;
|
||||
int count;
|
||||
gsize bytes_written = 0;
|
||||
gsize count;
|
||||
GIOError err;
|
||||
|
||||
while (bytes_written < len)
|
||||
@ -70,7 +70,7 @@ write_all (GIOChannel *channel, char *buf, int len)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
||||
{
|
||||
int i;
|
||||
@ -94,7 +94,7 @@ run_child (GIOChannel *in_channel, GIOChannel *out_channel)
|
||||
exit (0);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
input_callback (GIOChannel *source,
|
||||
GIOCondition condition,
|
||||
gpointer data)
|
||||
@ -130,7 +130,7 @@ input_callback (GIOChannel *source,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
create_child ()
|
||||
{
|
||||
int pid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user