New functions.

* gstrfuncs.c (g_strccpy, g_strecpy): New functions.

	* glib.h: Declare and document them. Define the deprecated
	g_strescape as a macro that calls g_strecpy.

	* tests/strfunc-test.c (main): Test them.

	* makefile.{cygwin,msc}.in
	* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
	program.

	* glib.def: Additions and removals.

	* README.win32: Improve gcc build instructions.

	* build-dll: Also build import library for MSVC.
This commit is contained in:
Tor Lillqvist 1999-07-31 21:45:21 +00:00
parent 87c7aeb93b
commit 1146c6fbb3
22 changed files with 535 additions and 74 deletions

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -1,3 +1,22 @@
1999-08-01 Tor Lillqvist <tml@iki.fi>
* gstrfuncs.c (g_strccpy, g_strecpy): New functions.
* glib.h: Declare and document them. Define the deprecated
g_strescape as a macro that calls g_strecpy.
* tests/strfunc-test.c (main): Test them.
* makefile.{cygwin,msc}.in
* tests/makefile.{cygwin,msc}.in: Remove gstack and its test
program.
* glib.def: Additions and removals.
* README.win32: Improve gcc build instructions.
* build-dll: Also build import library for MSVC.
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org>
* merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36.

View File

@ -10,12 +10,11 @@ library is used.
To build GLib on Win32, you can use either the Microsoft compiler and To build GLib on Win32, you can use either the Microsoft compiler and
tools, or gcc. Both the compiler from MSVC 5.0 and from MSVC 6.0 have tools, or gcc. Both the compiler from MSVC 5.0 and from MSVC 6.0 have
been used successfully. With gcc I mean the gcc-2.95 pre-release as been used successfully. With gcc I mean gcc-2.95 as distributed by
distributed by Mumit Khan, running under cygwin-b20.1. To successfully Mumit Khan, running under cygwin-b20.1. To successfully use gcc,
use gcc, follow the instructions below. We want to use gcc follow the instructions below. We want to use gcc -mno-cygwin,
-mno-cygwin, i.e. produce executables (.exe and .dll files) that do i.e. produce executables (.exe and .dll files) that do *not* require
*not* require the cygwin runtime library. This is sometimes called the cygwin runtime library. This is sometimes called "mingw32".
"mingw32".
To test the GLib functions, go to the tests subdirectory and enter To test the GLib functions, go to the tests subdirectory and enter
`nmake -f makefile.msc check` or `make -f makefile.cygwin check`. `nmake -f makefile.msc check` or `make -f makefile.cygwin check`.
@ -94,48 +93,24 @@ The gcc support was added quite recently, but seems to work. Debugging
with gdb works. I use the latest and greatest gcc and mingw32. with gdb works. I use the latest and greatest gcc and mingw32.
Somewhat earlier versions will also work, but you are on your own. Somewhat earlier versions will also work, but you are on your own.
Fetch the gcc-2.95 developer snapshot from Read and understand these instruction carefully. If you don't
ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/cygwin/snapshots/gcc-2.95-19990715/. understand or can't follow the instructions, you probably shouldn't
Install it somewhere, for instance \gcc-2.95. want to build glib (or gtk or gimp) yourself anyway.
Fetch the mingw runtime snapshot from 1999-07-15 from Fetch gcc-2.95 built for cygwin from
ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/runtime/. You ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/cygwin/gcc-2.95/gcc-2.95-cygb20.tar.gz
must fix two bugs in it: Install it somewhere, for instance "C:\gcc-2.95" (/gcc-2.95 as seen
from cygwin). We call this directory $GCCDIR below. You will have
subdirectories "H-i586-cygwin32" and "include" under $GCCDIR.
1) Fix the prototype and call to __getmainargs() in init.c to include Next, you need to modify the gcc setup to use the msvcrt runtime
one more parameter, an int *, which should be passed the address of a instead of crtdll. Also, the mingw32 and win32 API headers and import
zero int. Code snippets below: libraries need to be added. I have collected all the necessary
additions in the file
... http://www.iki.fi/tml/gimp/win32/gcc-2.95-additions.zip . Install that
#ifdef __MSVCRT__ in $GCCDIR. If you really want to do everything by yourself, follow
extern void __getmainargs(int *, char***, char***, int, int *); the instructions in
#else http://www.iki.fi/tml/gimp/win32/gcc-environment-setup.html
...
#ifdef __MSVCRT__
int newmode = 0;
(void) __getmainargs(&_argc, &_argv, &dummy_environ, _CRT_glob, &newmode);
#else
...
2) Fix the type of the function __p___argv() in stdlib.h to be char***,
not char**.
Build the mingw32 runtime and install the libraries in the
gcc-2.95\H-i586-cygwin32\lib directory, and the headers in the
gcc-2.95\H-i586-cygwin32\i586-cygwin32\include\mingw32 directory.
Remember to build and install also the w32api import libraries and
headers.
I prefer to use the msvcrt runtime and not the default
crtdll. Especially, as the pthread library also uses msvcrt, using
crtdll would probably not be a good idea at all. Using msvcrt can be
achieved by applying a few changes to the specs file.
The specs file is in gcc-2.95\H-i586-cygwin32\lib\gcc-lib\i586-cygwin32\2.95
The necessary changes are: replace -lcrtdll with -lmsvcrt, replace
crt1 with crt2, change -lmoldname to -lmoldname-msvc, and define
__MSVCRT__.
Next, go back to the GLib directory and build using `make -f Next, go back to the GLib directory and build using `make -f
makefile.cygwin`. Building the dlls uses the script build-dll which makefile.cygwin`. Building the dlls uses the script build-dll which

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# Temporary hack until building dlls or executables with exported # Temporary hack until building dlls or executables with exported
# entry points is easier with gcc -mno-cygwin ("mingw32"). # entry points is easier with gcc -mno-cygwin ("mingw32").
@ -36,4 +36,12 @@ $DLLTOOL --as=$AS --dllname $dllfile $defswitch --base-file $library.base --outp
$GCC -mdll -mno-cygwin -Wl,$library.exp -o $dllfile $ldargs && $GCC -mdll -mno-cygwin -Wl,$library.exp -o $dllfile $ldargs &&
$DLLTOOL --as=$AS --dllname $dllfile $defswitch --output-lib lib$libname.a $objs $DLLTOOL --as=$AS --dllname $dllfile $defswitch --output-lib lib$libname.a $objs
# Finally, also build import libraries for the Microsoft linker. You
# will either need to have some decent version of MSVC, or get lib.exe
# (and link.exe) from the (freely downloadable) Microsoft Platform SDK.
if type -p lib.exe && [ -n "$def" -a "$def" != '-' ]; then
lib -name:$libname.dll -def:$def -out:$libname.lib
fi
rm $library.base $library.exp 2>/dev/null rm $library.base $library.exp 2>/dev/null

View File

@ -58,10 +58,10 @@ EXPORTS
g_date_julian g_date_julian
g_date_monday_week_of_year g_date_monday_week_of_year
g_date_monday_weeks_in_year g_date_monday_weeks_in_year
g_date_month
g_date_new g_date_new
g_date_new_dmy g_date_new_dmy
g_date_new_julian g_date_new_julian
g_date_month
g_date_set_day g_date_set_day
g_date_set_dmy g_date_set_dmy
g_date_set_julian g_date_set_julian
@ -121,12 +121,12 @@ EXPORTS
g_hook_get g_hook_get
g_hook_insert_before g_hook_insert_before
g_hook_insert_sorted g_hook_insert_sorted
g_hook_list_clear
g_hook_list_init g_hook_list_init
g_hook_list_invoke g_hook_list_invoke
g_hook_list_invoke_check g_hook_list_invoke_check
g_hook_list_marshal g_hook_list_marshal
g_hook_list_marshal_check g_hook_list_marshal_check
g_hook_list_clear
g_hook_next_valid g_hook_next_valid
g_hook_prepend g_hook_prepend
g_hook_ref g_hook_ref
@ -190,8 +190,8 @@ EXPORTS
g_main_iteration g_main_iteration
g_main_new g_main_new
g_main_pending g_main_pending
g_main_remove_poll
g_main_quit g_main_quit
g_main_remove_poll
g_main_run g_main_run
g_main_set_poll_func g_main_set_poll_func
g_malloc g_malloc
@ -255,6 +255,19 @@ EXPORTS
g_quark_from_string g_quark_from_string
g_quark_to_string g_quark_to_string
g_quark_try_string g_quark_try_string
g_queue_create
g_queue_free
g_queue_is_empty
g_queue_peek_head
g_queue_peek_tail
g_queue_pop_head
g_queue_pop_head_link
g_queue_pop_tail
g_queue_pop_tail_link
g_queue_push_head
g_queue_push_head_link
g_queue_push_tail
g_queue_push_tail_link
g_rand_double g_rand_double
g_rand_double_range g_rand_double_range
g_rand_free g_rand_free
@ -331,7 +344,6 @@ EXPORTS
g_slist_reverse g_slist_reverse
g_slist_sort g_slist_sort
g_snprintf g_snprintf
g_spaced_primes_closest
g_source_add g_source_add
g_source_remove g_source_remove
g_source_remove_by_source_data g_source_remove_by_source_data
@ -355,12 +367,15 @@ EXPORTS
g_strchomp g_strchomp
g_strchug g_strchug
g_strconcat g_strconcat
g_strccpy
g_strdelimit g_strdelimit
g_strdown g_strdown
g_strdup g_strdup
g_strdup_printf g_strdup_printf
g_strdup_vprintf g_strdup_vprintf
g_strecpy
g_strerror g_strerror
g_strescape
g_strfreev g_strfreev
g_string_append g_string_append
g_string_append_c g_string_append_c
@ -377,17 +392,12 @@ EXPORTS
g_string_new g_string_new
g_string_prepend g_string_prepend
g_string_prepend_c g_string_prepend_c
g_string_readline
g_string_readline_buffered
g_string_sized_new g_string_sized_new
g_string_sprintf g_string_sprintf
g_string_sprintfa g_string_sprintfa
g_string_tokenise
g_string_tokenise_free
g_string_truncate g_string_truncate
g_string_up g_string_up
g_strjoinv g_strjoinv
g_strescape
g_strncasecmp g_strncasecmp
g_strndup g_strndup
g_strnfill g_strnfill
@ -397,9 +407,11 @@ EXPORTS
g_strtod g_strtod
g_strup g_strup
g_thread_create g_thread_create
g_thread_functions_for_glib_use
g_thread_join g_thread_join
g_thread_self g_thread_self
g_thread_set_priority g_thread_set_priority
g_threads_got_initialized
g_timeout_add g_timeout_add
g_timeout_add_full g_timeout_add_full
g_timer_destroy g_timer_destroy
@ -426,8 +438,9 @@ EXPORTS
glib_major_version glib_major_version
glib_micro_version glib_micro_version
glib_minor_version glib_minor_version
gwin_closedir
gwin_ftruncate gwin_ftruncate
gwin_opendir gwin_opendir
gwin_readdir gwin_readdir
gwin_rewinddir gwin_rewinddir
gwin_closedir g_spaced_primes_closest

16
glib.h
View File

@ -1515,9 +1515,25 @@ gchar* g_strconcat (const gchar *string1,
...); /* NULL terminated */ ...); /* NULL terminated */
gchar* g_strjoin (const gchar *separator, gchar* g_strjoin (const gchar *separator,
...); /* NULL terminated */ ...); /* NULL terminated */
/* Copy a string interpreting C string -style escape sequences.
* The recognized sequences are \b \f \n \r \t \\ \" and the octal format.
*/
gchar* g_strccpy (gchar *dest,
const gchar *source);
/* Copy a string escaping nonprintable characters like in C strings.
* Inverse of g_strccpy. The exceptions parameter if non-NULL points
* to a string containing characters that are not escaped.
*/
gchar* g_strecpy (gchar *dest,
const gchar *source,
const gchar *exceptions);
/* deprecated function */ /* deprecated function */
gchar* g_strescape (gchar *string); gchar* g_strescape (gchar *string);
/* Define a macro for it */
#define g_strescape(src) g_strecpy (g_malloc (strlen (src)*4+1), src, NULL)
gpointer g_memdup (gconstpointer mem, gpointer g_memdup (gconstpointer mem,
guint byte_size); guint byte_size);

View File

@ -58,10 +58,10 @@ EXPORTS
g_date_julian g_date_julian
g_date_monday_week_of_year g_date_monday_week_of_year
g_date_monday_weeks_in_year g_date_monday_weeks_in_year
g_date_month
g_date_new g_date_new
g_date_new_dmy g_date_new_dmy
g_date_new_julian g_date_new_julian
g_date_month
g_date_set_day g_date_set_day
g_date_set_dmy g_date_set_dmy
g_date_set_julian g_date_set_julian
@ -121,12 +121,12 @@ EXPORTS
g_hook_get g_hook_get
g_hook_insert_before g_hook_insert_before
g_hook_insert_sorted g_hook_insert_sorted
g_hook_list_clear
g_hook_list_init g_hook_list_init
g_hook_list_invoke g_hook_list_invoke
g_hook_list_invoke_check g_hook_list_invoke_check
g_hook_list_marshal g_hook_list_marshal
g_hook_list_marshal_check g_hook_list_marshal_check
g_hook_list_clear
g_hook_next_valid g_hook_next_valid
g_hook_prepend g_hook_prepend
g_hook_ref g_hook_ref
@ -190,8 +190,8 @@ EXPORTS
g_main_iteration g_main_iteration
g_main_new g_main_new
g_main_pending g_main_pending
g_main_remove_poll
g_main_quit g_main_quit
g_main_remove_poll
g_main_run g_main_run
g_main_set_poll_func g_main_set_poll_func
g_malloc g_malloc
@ -255,6 +255,19 @@ EXPORTS
g_quark_from_string g_quark_from_string
g_quark_to_string g_quark_to_string
g_quark_try_string g_quark_try_string
g_queue_create
g_queue_free
g_queue_is_empty
g_queue_peek_head
g_queue_peek_tail
g_queue_pop_head
g_queue_pop_head_link
g_queue_pop_tail
g_queue_pop_tail_link
g_queue_push_head
g_queue_push_head_link
g_queue_push_tail
g_queue_push_tail_link
g_rand_double g_rand_double
g_rand_double_range g_rand_double_range
g_rand_free g_rand_free
@ -331,7 +344,6 @@ EXPORTS
g_slist_reverse g_slist_reverse
g_slist_sort g_slist_sort
g_snprintf g_snprintf
g_spaced_primes_closest
g_source_add g_source_add
g_source_remove g_source_remove
g_source_remove_by_source_data g_source_remove_by_source_data
@ -355,12 +367,15 @@ EXPORTS
g_strchomp g_strchomp
g_strchug g_strchug
g_strconcat g_strconcat
g_strccpy
g_strdelimit g_strdelimit
g_strdown g_strdown
g_strdup g_strdup
g_strdup_printf g_strdup_printf
g_strdup_vprintf g_strdup_vprintf
g_strecpy
g_strerror g_strerror
g_strescape
g_strfreev g_strfreev
g_string_append g_string_append
g_string_append_c g_string_append_c
@ -377,17 +392,12 @@ EXPORTS
g_string_new g_string_new
g_string_prepend g_string_prepend
g_string_prepend_c g_string_prepend_c
g_string_readline
g_string_readline_buffered
g_string_sized_new g_string_sized_new
g_string_sprintf g_string_sprintf
g_string_sprintfa g_string_sprintfa
g_string_tokenise
g_string_tokenise_free
g_string_truncate g_string_truncate
g_string_up g_string_up
g_strjoinv g_strjoinv
g_strescape
g_strncasecmp g_strncasecmp
g_strndup g_strndup
g_strnfill g_strnfill
@ -397,9 +407,11 @@ EXPORTS
g_strtod g_strtod
g_strup g_strup
g_thread_create g_thread_create
g_thread_functions_for_glib_use
g_thread_join g_thread_join
g_thread_self g_thread_self
g_thread_set_priority g_thread_set_priority
g_threads_got_initialized
g_timeout_add g_timeout_add
g_timeout_add_full g_timeout_add_full
g_timer_destroy g_timer_destroy
@ -426,8 +438,9 @@ EXPORTS
glib_major_version glib_major_version
glib_micro_version glib_micro_version
glib_minor_version glib_minor_version
gwin_closedir
gwin_ftruncate gwin_ftruncate
gwin_opendir gwin_opendir
gwin_readdir gwin_readdir
gwin_rewinddir gwin_rewinddir
gwin_closedir g_spaced_primes_closest

View File

@ -1515,9 +1515,25 @@ gchar* g_strconcat (const gchar *string1,
...); /* NULL terminated */ ...); /* NULL terminated */
gchar* g_strjoin (const gchar *separator, gchar* g_strjoin (const gchar *separator,
...); /* NULL terminated */ ...); /* NULL terminated */
/* Copy a string interpreting C string -style escape sequences.
* The recognized sequences are \b \f \n \r \t \\ \" and the octal format.
*/
gchar* g_strccpy (gchar *dest,
const gchar *source);
/* Copy a string escaping nonprintable characters like in C strings.
* Inverse of g_strccpy. The exceptions parameter if non-NULL points
* to a string containing characters that are not escaped.
*/
gchar* g_strecpy (gchar *dest,
const gchar *source,
const gchar *exceptions);
/* deprecated function */ /* deprecated function */
gchar* g_strescape (gchar *string); gchar* g_strescape (gchar *string);
/* Define a macro for it */
#define g_strescape(src) g_strecpy (g_malloc (strlen (src)*4+1), src, NULL)
gpointer g_memdup (gconstpointer mem, gpointer g_memdup (gconstpointer mem,
guint byte_size); guint byte_size);

View File

@ -1072,6 +1072,137 @@ g_strdelimit (gchar *string,
return string; return string;
} }
gchar*
g_strccpy (gchar *dest,
const gchar *source)
{
const gchar *p = source;
gchar *q = dest;
g_return_val_if_fail (dest != NULL, NULL);
while (*p)
{
if (*p == '\\')
{
p++;
switch (*p)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
*q = 0;
while ((*p >= '0') && (*p <= '7'))
{
*q = (*q * 8) + (*p - '0');
p++;
}
q++;
p--;
break;
case 'b':
*q++ = '\b';
break;
case 'f':
*q++ = '\f';
break;
case 'n':
*q++ = '\n';
break;
case 'r':
*q++ = '\r';
break;
case 't':
*q++ = '\t';
break;
default: /* Also handles \" and \\ */
*q++ = *p;
break;
}
}
else
*q++ = *p;
p++;
}
*q = 0;
return dest;
}
gchar *
g_strecpy (gchar *dest,
const gchar *src,
const gchar *exceptions)
{
const guchar *p = (guchar *) src;
gchar *q = dest;
guchar excmap[256];
memset (excmap, 0, 256);
if (exceptions)
{
guchar *e = (guchar *) exceptions;
while (*e)
{
excmap[*e] = 1;
e++;
}
}
while (*p)
{
if (excmap[*p])
*q++ = *p;
else
{
switch (*p)
{
case '\b':
*q++ = '\\';
*q++ = 'b';
break;
case '\f':
*q++ = '\\';
*q++ = 'f';
break;
case '\n':
*q++ = '\\';
*q++ = 'n';
break;
case '\r':
*q++ = '\\';
*q++ = 'r';
break;
case '\t':
*q++ = '\\';
*q++ = 't';
break;
case '\\':
*q++ = '\\';
*q++ = '\\';
break;
case '"':
*q++ = '\\';
*q++ = '"';
break;
default:
if ((*p < ' ') || (*p >= 0177))
{
*q++ = '\\';
*q++ = '0' + (((*p) >> 6)&07);
*q++ = '0' + (((*p) >> 3)&07);
*q++ = '0' + ((*p)&07);
}
else
*q++ = *p;
break;
}
}
p++;
}
*q = 0;
return dest;
}
gchar* gchar*
g_strescape (gchar *string) g_strescape (gchar *string)
{ {

View File

@ -74,7 +74,6 @@ glib_OBJECTS = \
gqueue.obj \ gqueue.obj \
grand.obj \ grand.obj \
gslist.obj \ gslist.obj \
gstack.obj \
gthread.obj \ gthread.obj \
gtimer.obj \ gtimer.obj \
gtree.obj \ gtree.obj \

View File

@ -1072,6 +1072,137 @@ g_strdelimit (gchar *string,
return string; return string;
} }
gchar*
g_strccpy (gchar *dest,
const gchar *source)
{
const gchar *p = source;
gchar *q = dest;
g_return_val_if_fail (dest != NULL, NULL);
while (*p)
{
if (*p == '\\')
{
p++;
switch (*p)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
*q = 0;
while ((*p >= '0') && (*p <= '7'))
{
*q = (*q * 8) + (*p - '0');
p++;
}
q++;
p--;
break;
case 'b':
*q++ = '\b';
break;
case 'f':
*q++ = '\f';
break;
case 'n':
*q++ = '\n';
break;
case 'r':
*q++ = '\r';
break;
case 't':
*q++ = '\t';
break;
default: /* Also handles \" and \\ */
*q++ = *p;
break;
}
}
else
*q++ = *p;
p++;
}
*q = 0;
return dest;
}
gchar *
g_strecpy (gchar *dest,
const gchar *src,
const gchar *exceptions)
{
const guchar *p = (guchar *) src;
gchar *q = dest;
guchar excmap[256];
memset (excmap, 0, 256);
if (exceptions)
{
guchar *e = (guchar *) exceptions;
while (*e)
{
excmap[*e] = 1;
e++;
}
}
while (*p)
{
if (excmap[*p])
*q++ = *p;
else
{
switch (*p)
{
case '\b':
*q++ = '\\';
*q++ = 'b';
break;
case '\f':
*q++ = '\\';
*q++ = 'f';
break;
case '\n':
*q++ = '\\';
*q++ = 'n';
break;
case '\r':
*q++ = '\\';
*q++ = 'r';
break;
case '\t':
*q++ = '\\';
*q++ = 't';
break;
case '\\':
*q++ = '\\';
*q++ = '\\';
break;
case '"':
*q++ = '\\';
*q++ = '"';
break;
default:
if ((*p < ' ') || (*p >= 0177))
{
*q++ = '\\';
*q++ = '0' + (((*p) >> 6)&07);
*q++ = '0' + (((*p) >> 3)&07);
*q++ = '0' + ((*p)&07);
}
else
*q++ = *p;
break;
}
}
p++;
}
*q = 0;
return dest;
}
gchar* gchar*
g_strescape (gchar *string) g_strescape (gchar *string)
{ {

View File

@ -67,7 +67,6 @@ glib_OBJECTS = \
gqueue.o \ gqueue.o \
grand.o \ grand.o \
gslist.o \ gslist.o \
gstack.o \
gthread.o \ gthread.o \
gtimer.o \ gtimer.o \
gtree.o \ gtree.o \

View File

@ -74,7 +74,6 @@ glib_OBJECTS = \
gqueue.obj \ gqueue.obj \
grand.obj \ grand.obj \
gslist.obj \ gslist.obj \
gstack.obj \
gthread.obj \ gthread.obj \
gtimer.obj \ gtimer.obj \
gtree.obj \ gtree.obj \

View File

@ -24,9 +24,8 @@ TESTS = \
rand-test.exe \ rand-test.exe \
relation-test.exe\ relation-test.exe\
slist-test.exe \ slist-test.exe \
stack-test.exe \
string-test.exe \
strfunc-test.exe\ strfunc-test.exe\
string-test.exe \
thread-test.exe \ thread-test.exe \
tree-test.exe \ tree-test.exe \
type-test.exe type-test.exe

View File

@ -26,9 +26,8 @@ TESTS = \
rand-test.exe \ rand-test.exe \
relation-test.exe\ relation-test.exe\
slist-test.exe \ slist-test.exe \
stack-test.exe \
string-test.exe \
strfunc-test.exe\ strfunc-test.exe\
string-test.exe \
thread-test.exe \ thread-test.exe \
tree-test.exe \ tree-test.exe \
type-test.exe type-test.exe

View File

@ -99,6 +99,17 @@ main (int argc,
g_assert (strcmp(string, "00021 test ") == 0); g_assert (strcmp(string, "00021 test ") == 0);
g_free (string); g_free (string);
g_assert (strcmp(g_strccpy(g_malloc(100),
"abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313"),
"abc\\\"\b\f\n\r\t\003\177\234\313") == 0);
g_assert (strcmp(g_strecpy(g_malloc(100),
"abc\\\"\b\f\n\r\t\003\177\234\313",
NULL),
"abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313") == 0);
g_assert (strcmp(g_strecpy(g_malloc(100),"abc\\\"\b\f\n\r\t\003\177\234\313",
"\b\f\001\002\003\004"),
"abc\\\\\\\"\b\f\\n\\r\\t\003\\177\\234\\313") == 0);
return 0; return 0;
} }