Thu Jun 29 15:57:28 2000  Owen Taylor  <otaylor@redhat.com>

        * NEWS: updated

	* Makefile.am: added snapcheck target to go along with snapshot

	* gstring.c glib.h (g_string_hash): Add g_string_hash to
	go along with g_string_equal.

Tue Jun 27 12:40:23 EDT 2000  David A. Wheeler <dwheeler@dwheeler.com>

	* glib.h: Added g_string_equal for comparing GStrings;
	changed g_str_equal so it returns gboolean (instead of gint).

	* gstring.c: Modified GString implementation to support embedded
	ASCII NUL ('\0') characters, and implemented g_string_equal.

	* testglib.c tests/string-test.c: Added tests for g_string_equal
	and tests for proper handling of embedded ASCII NUL characters.
This commit is contained in:
Owen Taylor 2000-06-29 20:09:36 +00:00 committed by Owen Taylor
parent 6bbcc10e8d
commit 6e47268c14
18 changed files with 382 additions and 33 deletions

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -1,3 +1,23 @@
Thu Jun 29 15:57:28 2000 Owen Taylor <otaylor@redhat.com>
* NEWS: updated
* Makefile.am: added snapcheck target to go along with snapshot
* gstring.c glib.h (g_string_hash): Add g_string_hash to
go along with g_string_equal.
Tue Jun 27 12:40:23 EDT 2000 David A. Wheeler <dwheeler@dwheeler.com>
* glib.h: Added g_string_equal for comparing GStrings;
changed g_str_equal so it returns gboolean (instead of gint).
* gstring.c: Modified GString implementation to support embedded
ASCII NUL ('\0') characters, and implemented g_string_equal.
* testglib.c tests/string-test.c: Added tests for g_string_equal
and tests for proper handling of embedded ASCII NUL characters.
Wed Jun 28 22:52:00 2000 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libglib_la_SOURCES): Fix
@ -52,7 +72,6 @@ Mon May 29 14:10:35 2000 Owen Taylor <otaylor@redhat.com>
Fri May 19 11:39:29 2000 Tim Janik <timj@gtk.org>
* gutils.c (g_snprintf):
(g_vsnprintf): added argument assertments.

View File

@ -134,7 +134,10 @@ sanity:
./sanity_check $(VERSION)
snapshot:
$(MAKE) dist distdir=$(PACKAGE)`date +"%y%m%d"`
$(MAKE) dist distdir=$(PACKAGE)-snap`date +"%Y%m%d"`
snapcheck:
$(MAKE) distcheck distdir=$(PACKAGE)-snap`date +"%Y%m%d"`
dist-hook:
cp glib.spec $(distdir)

8
NEWS
View File

@ -1,5 +1,11 @@
What's new in GLib 1.3.1:
* New GObject library added including object system based on
the GTK+ object system.
* Functions for getting the properties of Unicode characters,
computing the canonical decomposition and ordering combining
characters aand manipulating UTF-8 string manipulation based
on libunicode.
* GString now properly handles embedded nuls.
* Multiple fixes from the 1.2.x branch.
* Upgrade to libtool 1.3.3
* Full thread support (thread creation and destruction).

15
glib.h
View File

@ -1865,6 +1865,9 @@ GString* g_string_new (const gchar *init);
GString* g_string_sized_new (guint dfl_size);
void g_string_free (GString *string,
gboolean free_segment);
gboolean g_string_equal (const GString *v,
const GString *v2);
guint g_string_hash (const GString *str);
GString* g_string_assign (GString *string,
const gchar *rval);
GString* g_string_truncate (GString *string,
@ -1989,13 +1992,13 @@ GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
/* Hash Functions
*/
gint g_str_equal (gconstpointer v,
gconstpointer v2);
guint g_str_hash (gconstpointer v);
gboolean g_str_equal (gconstpointer v,
gconstpointer v2);
guint g_str_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or

View File

@ -134,7 +134,10 @@ sanity:
./sanity_check $(VERSION)
snapshot:
$(MAKE) dist distdir=$(PACKAGE)`date +"%y%m%d"`
$(MAKE) dist distdir=$(PACKAGE)-snap`date +"%Y%m%d"`
snapcheck:
$(MAKE) distcheck distdir=$(PACKAGE)-snap`date +"%Y%m%d"`
dist-hook:
cp glib.spec $(distdir)

View File

@ -1865,6 +1865,9 @@ GString* g_string_new (const gchar *init);
GString* g_string_sized_new (guint dfl_size);
void g_string_free (GString *string,
gboolean free_segment);
gboolean g_string_equal (const GString *v,
const GString *v2);
guint g_string_hash (const GString *str);
GString* g_string_assign (GString *string,
const gchar *rval);
GString* g_string_truncate (GString *string,
@ -1989,13 +1992,13 @@ GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
/* Hash Functions
*/
gint g_str_equal (gconstpointer v,
gconstpointer v2);
guint g_str_hash (gconstpointer v);
gboolean g_str_equal (gconstpointer v,
gconstpointer v2);
guint g_str_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or

View File

@ -67,7 +67,7 @@ static GMemChunk *string_mem_chunk = NULL;
/* Hash Functions.
*/
gint
gboolean
g_str_equal (gconstpointer v1,
gconstpointer v2)
{
@ -265,6 +265,48 @@ g_string_free (GString *string,
G_UNLOCK (string_mem_chunk);
}
gboolean
g_string_equal (const GString *v,
const GString *v2)
{
gchar *p, *q;
GRealString *string1 = (GRealString *) v;
GRealString *string2 = (GRealString *) v2;
gint i = string1->len;
if (i != string2->len)
return FALSE;
p = string1->str;
q = string2->str;
while (i)
{
if (*p != *q)
return FALSE;
p++;
q++;
i--;
}
return TRUE;
}
/* 31 bit hash function */
guint
g_string_hash (const GString *str)
{
const gchar *p = str->str;
gint n = str->len;
guint h = 0;
while (n--)
{
h = (h << 5) - h + *p;
p++;
}
return h;
}
GString*
g_string_assign (GString *string,
const gchar *rval)
@ -320,7 +362,7 @@ g_string_insert_len (GString *fstring,
g_memmove (string->str + pos + len, string->str + pos, string->len - pos);
/* insert the new string */
strncpy (string->str + pos, val, len);
g_memmove (string->str + pos, val, len);
string->len += len;
@ -457,15 +499,17 @@ g_string_down (GString *fstring)
{
GRealString *string = (GRealString *) fstring;
guchar *s;
gint n = string->len;
g_return_val_if_fail (string != NULL, NULL);
s = string->str;
while (*s)
while (n)
{
*s = tolower (*s);
s++;
n--;
}
return fstring;
@ -476,15 +520,17 @@ g_string_up (GString *fstring)
{
GRealString *string = (GRealString *) fstring;
guchar *s;
gint n = string->len;
g_return_val_if_fail (string != NULL, NULL);
s = string->str;
while (*s)
while (n)
{
*s = toupper (*s);
s++;
n--;
}
return fstring;

View File

@ -67,7 +67,7 @@ static GMemChunk *string_mem_chunk = NULL;
/* Hash Functions.
*/
gint
gboolean
g_str_equal (gconstpointer v1,
gconstpointer v2)
{
@ -265,6 +265,48 @@ g_string_free (GString *string,
G_UNLOCK (string_mem_chunk);
}
gboolean
g_string_equal (const GString *v,
const GString *v2)
{
gchar *p, *q;
GRealString *string1 = (GRealString *) v;
GRealString *string2 = (GRealString *) v2;
gint i = string1->len;
if (i != string2->len)
return FALSE;
p = string1->str;
q = string2->str;
while (i)
{
if (*p != *q)
return FALSE;
p++;
q++;
i--;
}
return TRUE;
}
/* 31 bit hash function */
guint
g_string_hash (const GString *str)
{
const gchar *p = str->str;
gint n = str->len;
guint h = 0;
while (n--)
{
h = (h << 5) - h + *p;
p++;
}
return h;
}
GString*
g_string_assign (GString *string,
const gchar *rval)
@ -320,7 +362,7 @@ g_string_insert_len (GString *fstring,
g_memmove (string->str + pos + len, string->str + pos, string->len - pos);
/* insert the new string */
strncpy (string->str + pos, val, len);
g_memmove (string->str + pos, val, len);
string->len += len;
@ -457,15 +499,17 @@ g_string_down (GString *fstring)
{
GRealString *string = (GRealString *) fstring;
guchar *s;
gint n = string->len;
g_return_val_if_fail (string != NULL, NULL);
s = string->str;
while (*s)
while (n)
{
*s = tolower (*s);
s++;
n--;
}
return fstring;
@ -476,15 +520,17 @@ g_string_up (GString *fstring)
{
GRealString *string = (GRealString *) fstring;
guchar *s;
gint n = string->len;
g_return_val_if_fail (string != NULL, NULL);
s = string->str;
while (*s)
while (n)
{
*s = toupper (*s);
s++;
n--;
}
return fstring;

View File

@ -798,8 +798,37 @@ main (int argc,
g_print ("ok\n");
/* g_string_equal */
string1 = g_string_new ("test");
string2 = g_string_new ("te");
g_assert (! g_string_equal(string1, string2));
g_string_append (string2, "st");
g_assert (g_string_equal(string1, string2));
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
/* Check handling of embedded ASCII 0 (NUL) characters in GString. */
string1 = g_string_new ("fiddle");
string2 = g_string_new ("fiddle");
g_assert (g_string_equal(string1, string2));
g_string_append_c(string1, '\0');
g_assert (! g_string_equal(string1, string2));
g_string_append_c(string2, '\0');
g_assert (g_string_equal(string1, string2));
g_string_append_c(string1, 'x');
g_string_append_c(string2, 'y');
g_assert (! g_string_equal(string1, string2));
g_assert (string1->len == 8);
g_string_append(string1, "yzzy");
g_assert (string1->len == 12);
g_assert ( memcmp(string1->str, "fiddle\0xyzzy", 13) == 0);
g_string_insert(string1, 1, "QED");
g_assert ( memcmp(string1->str, "fQEDiddle\0xyzzy", 16) == 0);
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
g_print ("checking timers...\n");
timer = g_timer_new ();
g_print (" spinning for 3 seconds...\n");

View File

@ -180,6 +180,35 @@ main (int argc,
g_assert (strcmp (string1->str, "firstlast") == 0);
g_string_free (string1, TRUE);
/* g_string_equal */
string1 = g_string_new ("test");
string2 = g_string_new ("te");
g_assert (! g_string_equal(string1, string2));
g_string_append (string2, "st");
g_assert (g_string_equal(string1, string2));
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
/* Check handling of embedded ASCII 0 (NUL) characters in GString. */
string1 = g_string_new ("fiddle");
string2 = g_string_new ("fiddle");
g_assert (g_string_equal(string1, string2));
g_string_append_c(string1, '\0');
g_assert (! g_string_equal(string1, string2));
g_string_append_c(string2, '\0');
g_assert (g_string_equal(string1, string2));
g_string_append_c(string1, 'x');
g_string_append_c(string2, 'y');
g_assert (! g_string_equal(string1, string2));
g_assert (string1->len == 8);
g_string_append(string1, "yzzy");
g_assert (string1->len == 12);
g_assert ( memcmp(string1->str, "fiddle\0xyzzy", 13) == 0);
g_string_insert(string1, 1, "QED");
g_assert ( memcmp(string1->str, "fQEDiddle\0xyzzy", 16) == 0);
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
return 0;
}

View File

@ -798,8 +798,37 @@ main (int argc,
g_print ("ok\n");
/* g_string_equal */
string1 = g_string_new ("test");
string2 = g_string_new ("te");
g_assert (! g_string_equal(string1, string2));
g_string_append (string2, "st");
g_assert (g_string_equal(string1, string2));
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
/* Check handling of embedded ASCII 0 (NUL) characters in GString. */
string1 = g_string_new ("fiddle");
string2 = g_string_new ("fiddle");
g_assert (g_string_equal(string1, string2));
g_string_append_c(string1, '\0');
g_assert (! g_string_equal(string1, string2));
g_string_append_c(string2, '\0');
g_assert (g_string_equal(string1, string2));
g_string_append_c(string1, 'x');
g_string_append_c(string2, 'y');
g_assert (! g_string_equal(string1, string2));
g_assert (string1->len == 8);
g_string_append(string1, "yzzy");
g_assert (string1->len == 12);
g_assert ( memcmp(string1->str, "fiddle\0xyzzy", 13) == 0);
g_string_insert(string1, 1, "QED");
g_assert ( memcmp(string1->str, "fQEDiddle\0xyzzy", 16) == 0);
g_string_free (string1, TRUE);
g_string_free (string2, TRUE);
g_print ("checking timers...\n");
timer = g_timer_new ();
g_print (" spinning for 3 seconds...\n");