1998-06-11 01:21:14 +02:00
|
|
|
/* GLIB - Library of useful routines for C programming
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 13:02:02 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-06-11 01:21:14 +02:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 13:02:02 +02:00
|
|
|
* Lesser General Public License for more details.
|
1998-06-11 01:21:14 +02:00
|
|
|
*
|
2000-07-26 13:02:02 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-06-11 01:21:14 +02:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
1998-12-15 06:28:02 +01:00
|
|
|
|
1999-02-24 07:14:27 +01:00
|
|
|
/*
|
2000-07-26 13:02:02 +02:00
|
|
|
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:14:27 +01:00
|
|
|
* file for a list of people on the GLib Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
/*
|
|
|
|
* MT safe
|
|
|
|
*/
|
|
|
|
|
1999-04-17 22:04:49 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
1998-06-11 01:21:14 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
1998-06-12 11:38:32 +02:00
|
|
|
#include "glib.h"
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
typedef struct _GRealStringChunk GRealStringChunk;
|
|
|
|
typedef struct _GRealString GRealString;
|
|
|
|
|
|
|
|
struct _GRealStringChunk
|
|
|
|
{
|
|
|
|
GHashTable *const_table;
|
|
|
|
GSList *storage_list;
|
|
|
|
gint storage_next;
|
|
|
|
gint this_size;
|
|
|
|
gint default_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GRealString
|
|
|
|
{
|
|
|
|
gchar *str;
|
|
|
|
gint len;
|
|
|
|
gint alloc;
|
|
|
|
};
|
|
|
|
|
1999-02-10 10:40:46 +01:00
|
|
|
G_LOCK_DEFINE_STATIC (string_mem_chunk);
|
1998-06-11 01:21:14 +02:00
|
|
|
static GMemChunk *string_mem_chunk = NULL;
|
|
|
|
|
|
|
|
/* Hash Functions.
|
|
|
|
*/
|
|
|
|
|
2000-06-29 22:09:36 +02:00
|
|
|
gboolean
|
2000-02-17 12:57:35 +01:00
|
|
|
g_str_equal (gconstpointer v1,
|
|
|
|
gconstpointer v2)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
const gchar *string1 = v1;
|
|
|
|
const gchar *string2 = v2;
|
|
|
|
|
|
|
|
return strcmp (string1, string2) == 0;
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
/* 31 bit hash function */
|
1998-06-11 01:21:14 +02:00
|
|
|
guint
|
2000-02-17 12:57:35 +01:00
|
|
|
g_str_hash (gconstpointer key)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
const char *p = key;
|
|
|
|
guint h = *p;
|
|
|
|
|
|
|
|
if (h)
|
|
|
|
for (p += 1; *p != '\0'; p++)
|
|
|
|
h = (h << 5) - h + *p;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
return h;
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* String Chunks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GStringChunk*
|
|
|
|
g_string_chunk_new (gint default_size)
|
|
|
|
{
|
|
|
|
GRealStringChunk *new_chunk = g_new (GRealStringChunk, 1);
|
|
|
|
gint size = 1;
|
|
|
|
|
|
|
|
while (size < default_size)
|
|
|
|
size <<= 1;
|
|
|
|
|
|
|
|
new_chunk->const_table = NULL;
|
|
|
|
new_chunk->storage_list = NULL;
|
|
|
|
new_chunk->storage_next = size;
|
|
|
|
new_chunk->default_size = size;
|
|
|
|
new_chunk->this_size = size;
|
|
|
|
|
|
|
|
return (GStringChunk*) new_chunk;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
g_string_chunk_free (GStringChunk *fchunk)
|
|
|
|
{
|
|
|
|
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
|
|
|
GSList *tmp_list;
|
|
|
|
|
|
|
|
g_return_if_fail (chunk != NULL);
|
|
|
|
|
|
|
|
if (chunk->storage_list)
|
|
|
|
{
|
|
|
|
for (tmp_list = chunk->storage_list; tmp_list; tmp_list = tmp_list->next)
|
|
|
|
g_free (tmp_list->data);
|
|
|
|
|
|
|
|
g_slist_free (chunk->storage_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chunk->const_table)
|
|
|
|
g_hash_table_destroy (chunk->const_table);
|
|
|
|
|
|
|
|
g_free (chunk);
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar*
|
|
|
|
g_string_chunk_insert (GStringChunk *fchunk,
|
|
|
|
const gchar *string)
|
|
|
|
{
|
|
|
|
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
|
|
|
gint 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;
|
|
|
|
|
|
|
|
chunk->storage_list = g_slist_prepend (chunk->storage_list,
|
|
|
|
g_new (char, new_size));
|
|
|
|
|
|
|
|
chunk->this_size = new_size;
|
|
|
|
chunk->storage_next = 0;
|
|
|
|
}
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
pos = ((char *) chunk->storage_list->data) + chunk->storage_next;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
strcpy (pos, string);
|
|
|
|
|
|
|
|
chunk->storage_next += len + 1;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar*
|
|
|
|
g_string_chunk_insert_const (GStringChunk *fchunk,
|
|
|
|
const gchar *string)
|
|
|
|
{
|
|
|
|
GRealStringChunk *chunk = (GRealStringChunk*) fchunk;
|
|
|
|
char* lookup;
|
|
|
|
|
|
|
|
g_return_val_if_fail (chunk != NULL, NULL);
|
|
|
|
|
|
|
|
if (!chunk->const_table)
|
|
|
|
chunk->const_table = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
|
|
lookup = (char*) g_hash_table_lookup (chunk->const_table, (gchar *)string);
|
|
|
|
|
|
|
|
if (!lookup)
|
|
|
|
{
|
|
|
|
lookup = g_string_chunk_insert (fchunk, string);
|
|
|
|
g_hash_table_insert (chunk->const_table, lookup, lookup);
|
|
|
|
}
|
|
|
|
|
|
|
|
return lookup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Strings.
|
|
|
|
*/
|
1999-07-24 20:50:58 +02:00
|
|
|
static inline gint
|
1999-04-17 22:04:49 +02:00
|
|
|
nearest_power (gint num)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
|
|
|
gint n = 1;
|
|
|
|
|
|
|
|
while (n < num)
|
|
|
|
n <<= 1;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_string_maybe_expand (GRealString* string, gint len)
|
|
|
|
{
|
|
|
|
if (string->len + len >= string->alloc)
|
|
|
|
{
|
1999-04-17 22:04:49 +02:00
|
|
|
string->alloc = nearest_power (string->len + len + 1);
|
1998-06-11 01:21:14 +02:00
|
|
|
string->str = g_realloc (string->str, string->alloc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
|
|
|
g_string_sized_new (guint dfl_size)
|
|
|
|
{
|
|
|
|
GRealString *string;
|
|
|
|
|
1998-12-16 06:38:35 +01:00
|
|
|
G_LOCK (string_mem_chunk);
|
1998-06-11 01:21:14 +02:00
|
|
|
if (!string_mem_chunk)
|
|
|
|
string_mem_chunk = g_mem_chunk_new ("string mem chunk",
|
|
|
|
sizeof (GRealString),
|
|
|
|
1024, G_ALLOC_AND_FREE);
|
|
|
|
|
|
|
|
string = g_chunk_new (GRealString, string_mem_chunk);
|
1998-12-16 06:38:35 +01:00
|
|
|
G_UNLOCK (string_mem_chunk);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
string->alloc = 0;
|
|
|
|
string->len = 0;
|
|
|
|
string->str = NULL;
|
|
|
|
|
|
|
|
g_string_maybe_expand (string, MAX (dfl_size, 2));
|
|
|
|
string->str[0] = 0;
|
|
|
|
|
|
|
|
return (GString*) string;
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
|
|
|
g_string_new (const gchar *init)
|
|
|
|
{
|
|
|
|
GString *string;
|
|
|
|
|
2000-10-27 04:46:04 +02:00
|
|
|
string = g_string_sized_new (init ? strlen (init) + 2 : 2);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
if (init)
|
|
|
|
g_string_append (string, init);
|
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
2000-10-27 04:46:04 +02:00
|
|
|
GString*
|
|
|
|
g_string_new_len (const gchar *init,
|
|
|
|
gint len)
|
|
|
|
{
|
|
|
|
GString *string;
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
return g_string_new (init);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
string = g_string_sized_new (len);
|
|
|
|
|
|
|
|
if (init)
|
|
|
|
g_string_append_len (string, init, len);
|
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-17 23:37:18 +02:00
|
|
|
gchar*
|
1998-06-11 01:21:14 +02:00
|
|
|
g_string_free (GString *string,
|
2000-02-17 12:57:35 +01:00
|
|
|
gboolean free_segment)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
2000-08-17 23:37:18 +02:00
|
|
|
gchar *segment;
|
|
|
|
|
2000-09-01 15:45:43 +02:00
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
if (free_segment)
|
2000-08-17 23:37:18 +02:00
|
|
|
{
|
|
|
|
g_free (string->str);
|
|
|
|
segment = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
segment = string->str;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
1998-12-16 06:38:35 +01:00
|
|
|
G_LOCK (string_mem_chunk);
|
1998-06-11 01:21:14 +02:00
|
|
|
g_mem_chunk_free (string_mem_chunk, string);
|
1998-12-16 06:38:35 +01:00
|
|
|
G_UNLOCK (string_mem_chunk);
|
2000-08-17 23:37:18 +02:00
|
|
|
|
|
|
|
return segment;
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
2000-06-29 22:09:36 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-06-11 01:21:14 +02:00
|
|
|
GString*
|
2000-02-17 12:57:35 +01:00
|
|
|
g_string_assign (GString *string,
|
1998-06-11 01:21:14 +02:00
|
|
|
const gchar *rval)
|
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
g_return_val_if_fail (rval != NULL, string);
|
|
|
|
|
|
|
|
g_string_truncate (string, 0);
|
|
|
|
g_string_append (string, rval);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
return string;
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
2000-02-17 12:57:35 +01:00
|
|
|
g_string_truncate (GString *fstring,
|
2000-05-19 12:01:08 +02:00
|
|
|
guint len)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
GRealString *string = (GRealString *) fstring;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
string->len = MIN (len, string->len);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
string->str[string->len] = 0;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
return fstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
2000-02-17 12:57:35 +01:00
|
|
|
g_string_insert_len (GString *fstring,
|
|
|
|
gint pos,
|
|
|
|
const gchar *val,
|
|
|
|
gint len)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
GRealString *string = (GRealString *) fstring;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
g_return_val_if_fail (val != NULL, fstring);
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (pos <= string->len, fstring);
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
len = strlen (val);
|
|
|
|
|
|
|
|
if (pos < 0)
|
|
|
|
pos = string->len;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_string_maybe_expand (string, len);
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
/* If we aren't appending at the end, move a hunk
|
|
|
|
* of the old string to the end, opening up space
|
|
|
|
*/
|
|
|
|
if (pos < string->len)
|
|
|
|
g_memmove (string->str + pos + len, string->str + pos, string->len - pos);
|
|
|
|
|
|
|
|
/* insert the new string */
|
2000-06-29 22:09:36 +02:00
|
|
|
g_memmove (string->str + pos, val, len);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
string->len += len;
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
string->str[string->len] = 0;
|
|
|
|
|
1998-06-11 01:21:14 +02:00
|
|
|
return fstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
2000-02-17 12:57:35 +01:00
|
|
|
g_string_append (GString *fstring,
|
|
|
|
const gchar *val)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (fstring != NULL, NULL);
|
|
|
|
g_return_val_if_fail (val != NULL, fstring);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
return g_string_insert_len (fstring, -1, val, -1);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
2000-02-17 12:57:35 +01:00
|
|
|
g_string_append_len (GString *string,
|
|
|
|
const gchar *val,
|
|
|
|
gint len)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (val != NULL, string);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
return g_string_insert_len (string, -1, val, len);
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
GString*
|
|
|
|
g_string_append_c (GString *fstring,
|
|
|
|
gchar c)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (fstring != NULL, NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
return g_string_insert_c (fstring, -1, c);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
2000-02-17 12:57:35 +01:00
|
|
|
g_string_prepend (GString *fstring,
|
|
|
|
const gchar *val)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (fstring != NULL, NULL);
|
|
|
|
g_return_val_if_fail (val != NULL, fstring);
|
|
|
|
|
|
|
|
return g_string_insert_len (fstring, 0, val, -1);
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
GString*
|
|
|
|
g_string_prepend_len (GString *string,
|
|
|
|
const gchar *val,
|
|
|
|
gint len)
|
|
|
|
{
|
1998-06-11 01:21:14 +02:00
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (val != NULL, string);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
return g_string_insert_len (string, 0, val, len);
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
GString*
|
|
|
|
g_string_prepend_c (GString *fstring,
|
|
|
|
gchar c)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (fstring != NULL, NULL);
|
|
|
|
|
|
|
|
return g_string_insert_c (fstring, 0, c);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
|
|
|
g_string_insert (GString *fstring,
|
|
|
|
gint pos,
|
|
|
|
const gchar *val)
|
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (fstring != NULL, NULL);
|
1998-06-11 01:21:14 +02:00
|
|
|
g_return_val_if_fail (val != NULL, fstring);
|
2000-02-17 12:57:35 +01:00
|
|
|
g_return_val_if_fail (pos <= fstring->len, fstring);
|
|
|
|
|
|
|
|
return g_string_insert_len (fstring, pos, val, -1);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
GString*
|
1998-06-11 01:21:14 +02:00
|
|
|
g_string_insert_c (GString *fstring,
|
|
|
|
gint pos,
|
|
|
|
gchar c)
|
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
GRealString *string = (GRealString *) fstring;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
g_return_val_if_fail (pos <= string->len, fstring);
|
|
|
|
|
|
|
|
g_string_maybe_expand (string, 1);
|
|
|
|
|
2000-02-17 12:57:35 +01:00
|
|
|
if (pos < 0)
|
|
|
|
pos = string->len;
|
|
|
|
|
|
|
|
/* If not just an append, move the old stuff */
|
|
|
|
if (pos < string->len)
|
|
|
|
g_memmove (string->str + pos + 1, string->str + pos, string->len - pos);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
string->str[pos] = c;
|
|
|
|
|
|
|
|
string->len += 1;
|
|
|
|
|
|
|
|
string->str[string->len] = 0;
|
|
|
|
|
|
|
|
return fstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
|
|
|
g_string_erase (GString *fstring,
|
2000-02-17 12:57:35 +01:00
|
|
|
gint pos,
|
|
|
|
gint len)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
|
|
|
|
string->len -= len;
|
|
|
|
|
|
|
|
string->str[string->len] = 0;
|
|
|
|
|
|
|
|
return fstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
|
|
|
g_string_down (GString *fstring)
|
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
GRealString *string = (GRealString *) fstring;
|
1999-07-24 20:50:58 +02:00
|
|
|
guchar *s;
|
2000-06-29 22:09:36 +02:00
|
|
|
gint n = string->len;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
|
2000-09-29 15:37:01 +02:00
|
|
|
s = (guchar *) string->str;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-06-29 22:09:36 +02:00
|
|
|
while (n)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
|
|
|
*s = tolower (*s);
|
|
|
|
s++;
|
2000-06-29 22:09:36 +02:00
|
|
|
n--;
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return fstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
GString*
|
|
|
|
g_string_up (GString *fstring)
|
|
|
|
{
|
2000-02-17 12:57:35 +01:00
|
|
|
GRealString *string = (GRealString *) fstring;
|
1999-07-24 20:50:58 +02:00
|
|
|
guchar *s;
|
2000-06-29 22:09:36 +02:00
|
|
|
gint n = string->len;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
|
2000-09-29 15:37:01 +02:00
|
|
|
s = (guchar *) string->str;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
2000-06-29 22:09:36 +02:00
|
|
|
while (n)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
|
|
|
*s = toupper (*s);
|
|
|
|
s++;
|
2000-06-29 22:09:36 +02:00
|
|
|
n--;
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return fstring;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
changed prototype of g_boxed_type_register_static() to contain an optional
Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: changed prototype of g_boxed_type_register_static()
to contain an optional init function and a hint at whether the
boxed structure uses ref counting internally.
added g_value_set_boxed_take_ownership().
made G_TYPE_BOXED an abstract value type.
* genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
types.
* glib-genmarshal.c: argument type changes, preparation for third-party
arg specification.
* gobject.[hc]: cleaned up get/set property code.
added g_strdup_value_contents() to improve warnings.
* gparam.[hc]: added g_param_value_convert(), taking over responsibility
of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
validation alterations may be valid a part of the property setting
process.
* gparamspecs.[hc]: made value comparisons stable (for sort applications).
added GParamSpecValueArray, a param spec for value arrays and
GParamSpecClosure. nuked the value exchange functions and
GParamSpecCCallback.
* gtype.[hc]: catch unintialized usages of the type system with
g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
to flag types that introduce a value table, but can't be used for
g_value_init(). cleaned up reserved type ids.
* gvalue.[hc]: code cleanups and saner checking.
nuked the value exchange API. implemented value transformations, we
can't really "convert" values, rather transforms are an anylogy to
C casts, real conversions need a param spec for validation, which is
why g_param_value_convert() does real conversions now.
* gvaluearray.[hc]: new files that implement a GValueArray, a struct
that can hold inhomogeneous arrays of value (to that extend that it
also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
this is exposed to the type system as a boxed type.
* gvaluetransform.c: new file implementing most of the former value
exchange functions as single-sided transformations.
* gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
g_value_set_string_take_ownership().
* *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
* *.[hc]: many fixes and cleanups.
* many warning improvements.
Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
* gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
into G_VALUE_LCOPY(), this needs proper documenting.
* gparam.c: fixed G_PARAM_USER_MASK.
* gtype.c (type_data_make_W):
(type_data_last_unref_Wm): fixed invalid memory freeing.
* gobject.c (g_object_last_unref): destroy signal handlers associated
with object, right before finalization.
* gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
that don't actually support details.
* gobject.[hc]: got rid of property trailers. nuked GObject
properties "data" and the "signal" variants.
(g_object_connect): new convenience function to do multiple
signal connections at once.
(g_object_disconnect): likewise, for disconnections.
* gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
* gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
as private (the latter got renamed from g_value_get_as_pointer()).
Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
* glib-object.h: add gvaluearray.h.
* gstring.[hc]: fixup naming of g_string_sprint*.
* gtypes.h: fixed GCompareDataFunc naming.
Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: shuffled rules to avoid excessive
rebuilds.
* gobject/gobject-sections.txt: updates.
* gobject/tmpl/*: bunch of updates, added another patch
from Eric Lemings <eric.b.lemings@lmco.com>.
2001-03-07 15:46:45 +01:00
|
|
|
g_string_printfa_internal (GString *string,
|
|
|
|
const gchar *fmt,
|
|
|
|
va_list args)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
gchar *buffer;
|
|
|
|
|
|
|
|
buffer = g_strdup_vprintf (fmt, args);
|
|
|
|
g_string_append (string, buffer);
|
|
|
|
g_free (buffer);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
changed prototype of g_boxed_type_register_static() to contain an optional
Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: changed prototype of g_boxed_type_register_static()
to contain an optional init function and a hint at whether the
boxed structure uses ref counting internally.
added g_value_set_boxed_take_ownership().
made G_TYPE_BOXED an abstract value type.
* genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
types.
* glib-genmarshal.c: argument type changes, preparation for third-party
arg specification.
* gobject.[hc]: cleaned up get/set property code.
added g_strdup_value_contents() to improve warnings.
* gparam.[hc]: added g_param_value_convert(), taking over responsibility
of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
validation alterations may be valid a part of the property setting
process.
* gparamspecs.[hc]: made value comparisons stable (for sort applications).
added GParamSpecValueArray, a param spec for value arrays and
GParamSpecClosure. nuked the value exchange functions and
GParamSpecCCallback.
* gtype.[hc]: catch unintialized usages of the type system with
g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
to flag types that introduce a value table, but can't be used for
g_value_init(). cleaned up reserved type ids.
* gvalue.[hc]: code cleanups and saner checking.
nuked the value exchange API. implemented value transformations, we
can't really "convert" values, rather transforms are an anylogy to
C casts, real conversions need a param spec for validation, which is
why g_param_value_convert() does real conversions now.
* gvaluearray.[hc]: new files that implement a GValueArray, a struct
that can hold inhomogeneous arrays of value (to that extend that it
also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
this is exposed to the type system as a boxed type.
* gvaluetransform.c: new file implementing most of the former value
exchange functions as single-sided transformations.
* gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
g_value_set_string_take_ownership().
* *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
* *.[hc]: many fixes and cleanups.
* many warning improvements.
Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
* gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
into G_VALUE_LCOPY(), this needs proper documenting.
* gparam.c: fixed G_PARAM_USER_MASK.
* gtype.c (type_data_make_W):
(type_data_last_unref_Wm): fixed invalid memory freeing.
* gobject.c (g_object_last_unref): destroy signal handlers associated
with object, right before finalization.
* gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
that don't actually support details.
* gobject.[hc]: got rid of property trailers. nuked GObject
properties "data" and the "signal" variants.
(g_object_connect): new convenience function to do multiple
signal connections at once.
(g_object_disconnect): likewise, for disconnections.
* gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
* gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
as private (the latter got renamed from g_value_get_as_pointer()).
Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
* glib-object.h: add gvaluearray.h.
* gstring.[hc]: fixup naming of g_string_sprint*.
* gtypes.h: fixed GCompareDataFunc naming.
Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: shuffled rules to avoid excessive
rebuilds.
* gobject/gobject-sections.txt: updates.
* gobject/tmpl/*: bunch of updates, added another patch
from Eric Lemings <eric.b.lemings@lmco.com>.
2001-03-07 15:46:45 +01:00
|
|
|
g_string_printf (GString *string,
|
|
|
|
const gchar *fmt,
|
|
|
|
...)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
va_list args;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
|
|
g_string_truncate (string, 0);
|
|
|
|
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
va_start (args, fmt);
|
changed prototype of g_boxed_type_register_static() to contain an optional
Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: changed prototype of g_boxed_type_register_static()
to contain an optional init function and a hint at whether the
boxed structure uses ref counting internally.
added g_value_set_boxed_take_ownership().
made G_TYPE_BOXED an abstract value type.
* genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
types.
* glib-genmarshal.c: argument type changes, preparation for third-party
arg specification.
* gobject.[hc]: cleaned up get/set property code.
added g_strdup_value_contents() to improve warnings.
* gparam.[hc]: added g_param_value_convert(), taking over responsibility
of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
validation alterations may be valid a part of the property setting
process.
* gparamspecs.[hc]: made value comparisons stable (for sort applications).
added GParamSpecValueArray, a param spec for value arrays and
GParamSpecClosure. nuked the value exchange functions and
GParamSpecCCallback.
* gtype.[hc]: catch unintialized usages of the type system with
g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
to flag types that introduce a value table, but can't be used for
g_value_init(). cleaned up reserved type ids.
* gvalue.[hc]: code cleanups and saner checking.
nuked the value exchange API. implemented value transformations, we
can't really "convert" values, rather transforms are an anylogy to
C casts, real conversions need a param spec for validation, which is
why g_param_value_convert() does real conversions now.
* gvaluearray.[hc]: new files that implement a GValueArray, a struct
that can hold inhomogeneous arrays of value (to that extend that it
also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
this is exposed to the type system as a boxed type.
* gvaluetransform.c: new file implementing most of the former value
exchange functions as single-sided transformations.
* gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
g_value_set_string_take_ownership().
* *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
* *.[hc]: many fixes and cleanups.
* many warning improvements.
Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
* gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
into G_VALUE_LCOPY(), this needs proper documenting.
* gparam.c: fixed G_PARAM_USER_MASK.
* gtype.c (type_data_make_W):
(type_data_last_unref_Wm): fixed invalid memory freeing.
* gobject.c (g_object_last_unref): destroy signal handlers associated
with object, right before finalization.
* gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
that don't actually support details.
* gobject.[hc]: got rid of property trailers. nuked GObject
properties "data" and the "signal" variants.
(g_object_connect): new convenience function to do multiple
signal connections at once.
(g_object_disconnect): likewise, for disconnections.
* gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
* gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
as private (the latter got renamed from g_value_get_as_pointer()).
Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
* glib-object.h: add gvaluearray.h.
* gstring.[hc]: fixup naming of g_string_sprint*.
* gtypes.h: fixed GCompareDataFunc naming.
Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: shuffled rules to avoid excessive
rebuilds.
* gobject/gobject-sections.txt: updates.
* gobject/tmpl/*: bunch of updates, added another patch
from Eric Lemings <eric.b.lemings@lmco.com>.
2001-03-07 15:46:45 +01:00
|
|
|
g_string_printfa_internal (string, fmt, args);
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
va_end (args);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
changed prototype of g_boxed_type_register_static() to contain an optional
Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: changed prototype of g_boxed_type_register_static()
to contain an optional init function and a hint at whether the
boxed structure uses ref counting internally.
added g_value_set_boxed_take_ownership().
made G_TYPE_BOXED an abstract value type.
* genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
types.
* glib-genmarshal.c: argument type changes, preparation for third-party
arg specification.
* gobject.[hc]: cleaned up get/set property code.
added g_strdup_value_contents() to improve warnings.
* gparam.[hc]: added g_param_value_convert(), taking over responsibility
of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
validation alterations may be valid a part of the property setting
process.
* gparamspecs.[hc]: made value comparisons stable (for sort applications).
added GParamSpecValueArray, a param spec for value arrays and
GParamSpecClosure. nuked the value exchange functions and
GParamSpecCCallback.
* gtype.[hc]: catch unintialized usages of the type system with
g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
to flag types that introduce a value table, but can't be used for
g_value_init(). cleaned up reserved type ids.
* gvalue.[hc]: code cleanups and saner checking.
nuked the value exchange API. implemented value transformations, we
can't really "convert" values, rather transforms are an anylogy to
C casts, real conversions need a param spec for validation, which is
why g_param_value_convert() does real conversions now.
* gvaluearray.[hc]: new files that implement a GValueArray, a struct
that can hold inhomogeneous arrays of value (to that extend that it
also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
this is exposed to the type system as a boxed type.
* gvaluetransform.c: new file implementing most of the former value
exchange functions as single-sided transformations.
* gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
g_value_set_string_take_ownership().
* *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
* *.[hc]: many fixes and cleanups.
* many warning improvements.
Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
* gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
into G_VALUE_LCOPY(), this needs proper documenting.
* gparam.c: fixed G_PARAM_USER_MASK.
* gtype.c (type_data_make_W):
(type_data_last_unref_Wm): fixed invalid memory freeing.
* gobject.c (g_object_last_unref): destroy signal handlers associated
with object, right before finalization.
* gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
that don't actually support details.
* gobject.[hc]: got rid of property trailers. nuked GObject
properties "data" and the "signal" variants.
(g_object_connect): new convenience function to do multiple
signal connections at once.
(g_object_disconnect): likewise, for disconnections.
* gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
* gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
as private (the latter got renamed from g_value_get_as_pointer()).
Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
* glib-object.h: add gvaluearray.h.
* gstring.[hc]: fixup naming of g_string_sprint*.
* gtypes.h: fixed GCompareDataFunc naming.
Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: shuffled rules to avoid excessive
rebuilds.
* gobject/gobject-sections.txt: updates.
* gobject/tmpl/*: bunch of updates, added another patch
from Eric Lemings <eric.b.lemings@lmco.com>.
2001-03-07 15:46:45 +01:00
|
|
|
g_string_printfa (GString *string,
|
|
|
|
const gchar *fmt,
|
|
|
|
...)
|
1998-06-11 01:21:14 +02:00
|
|
|
{
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
va_list args;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
va_start (args, fmt);
|
changed prototype of g_boxed_type_register_static() to contain an optional
Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: changed prototype of g_boxed_type_register_static()
to contain an optional init function and a hint at whether the
boxed structure uses ref counting internally.
added g_value_set_boxed_take_ownership().
made G_TYPE_BOXED an abstract value type.
* genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
types.
* glib-genmarshal.c: argument type changes, preparation for third-party
arg specification.
* gobject.[hc]: cleaned up get/set property code.
added g_strdup_value_contents() to improve warnings.
* gparam.[hc]: added g_param_value_convert(), taking over responsibility
of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
validation alterations may be valid a part of the property setting
process.
* gparamspecs.[hc]: made value comparisons stable (for sort applications).
added GParamSpecValueArray, a param spec for value arrays and
GParamSpecClosure. nuked the value exchange functions and
GParamSpecCCallback.
* gtype.[hc]: catch unintialized usages of the type system with
g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
to flag types that introduce a value table, but can't be used for
g_value_init(). cleaned up reserved type ids.
* gvalue.[hc]: code cleanups and saner checking.
nuked the value exchange API. implemented value transformations, we
can't really "convert" values, rather transforms are an anylogy to
C casts, real conversions need a param spec for validation, which is
why g_param_value_convert() does real conversions now.
* gvaluearray.[hc]: new files that implement a GValueArray, a struct
that can hold inhomogeneous arrays of value (to that extend that it
also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
this is exposed to the type system as a boxed type.
* gvaluetransform.c: new file implementing most of the former value
exchange functions as single-sided transformations.
* gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
g_value_set_string_take_ownership().
* *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
* *.[hc]: many fixes and cleanups.
* many warning improvements.
Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
* gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
into G_VALUE_LCOPY(), this needs proper documenting.
* gparam.c: fixed G_PARAM_USER_MASK.
* gtype.c (type_data_make_W):
(type_data_last_unref_Wm): fixed invalid memory freeing.
* gobject.c (g_object_last_unref): destroy signal handlers associated
with object, right before finalization.
* gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
that don't actually support details.
* gobject.[hc]: got rid of property trailers. nuked GObject
properties "data" and the "signal" variants.
(g_object_connect): new convenience function to do multiple
signal connections at once.
(g_object_disconnect): likewise, for disconnections.
* gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
* gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
as private (the latter got renamed from g_value_get_as_pointer()).
Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
* glib-object.h: add gvaluearray.h.
* gstring.[hc]: fixup naming of g_string_sprint*.
* gtypes.h: fixed GCompareDataFunc naming.
Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: shuffled rules to avoid excessive
rebuilds.
* gobject/gobject-sections.txt: updates.
* gobject/tmpl/*: bunch of updates, added another patch
from Eric Lemings <eric.b.lemings@lmco.com>.
2001-03-07 15:46:45 +01:00
|
|
|
g_string_printfa_internal (string, fmt, args);
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
va_end (args);
|
1998-06-11 01:21:14 +02:00
|
|
|
}
|