* Boston, MA 02111-1307, USA.
*/
-/*
+/*
+ * Modified by the GLib Team and others 1997-1999. See the AUTHORS
+ * 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/.
+ */
+
+/*
* MT safe
*/
#include <string.h>
#include <locale.h>
#include <ctype.h> /* For tolower() */
+#if !defined (HAVE_STRSIGNAL) || !defined(NO_SYS_SIGLIST_DECL)
+#include <signal.h>
+#endif
#include "glib.h"
/* do not include <unistd.h> in this place since it
* inteferes with g_strsignal() on some OSes
g_strdup (const gchar *str)
{
gchar *new_str;
-
+
if (str)
{
new_str = g_new (char, strlen (str) + 1);
}
else
new_str = NULL;
-
+
return new_str;
}
va_list args;
gchar *s;
gchar *concat;
-
+
g_return_val_if_fail (string1 != NULL, NULL);
-
+
l = 1 + strlen (string1);
va_start (args, string1);
s = va_arg (args, gchar*);
s = va_arg (args, gchar*);
}
va_end (args);
-
+
concat = g_new (gchar, l);
concat[0] = 0;
-
+
strcat (concat, string1);
va_start (args, string1);
s = va_arg (args, gchar*);
s = va_arg (args, gchar*);
}
va_end (args);
-
+
return concat;
}
gchar *fail_pos_2;
gdouble val_1;
gdouble val_2 = 0;
-
+
g_return_val_if_fail (nptr != NULL, 0);
-
+
fail_pos_1 = NULL;
fail_pos_2 = NULL;
-
+
val_1 = strtod (nptr, &fail_pos_1);
-
+
if (fail_pos_1 && fail_pos_1[0] != 0)
{
gchar *old_locale;
-
+
old_locale = setlocale (LC_NUMERIC, "C");
val_2 = strtod (nptr, &fail_pos_2);
setlocale (LC_NUMERIC, old_locale);
}
-
+
if (!fail_pos_1 || fail_pos_1[0] == 0 || fail_pos_1 >= fail_pos_2)
{
if (endptr)
gchar*
g_strerror (gint errnum)
{
- static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
+ static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
char *msg;
-
+
#ifdef HAVE_STRERROR
return strerror (errnum);
#elif NO_SYS_ERRLIST
#else /* NO_SYS_ERRLIST */
extern int sys_nerr;
extern char *sys_errlist[];
-
+
if ((errnum > 0) && (errnum <= sys_nerr))
return sys_errlist [errnum];
#endif /* NO_SYS_ERRLIST */
msg = g_static_private_get (&msg_private);
- if( !msg )
+ if (!msg)
{
- msg = g_new( gchar, 64 );
+ msg = g_new (gchar, 64);
g_static_private_set (&msg_private, msg, g_free);
}
sprintf (msg, "unknown error (%d)", errnum);
+
return msg;
}
gchar*
g_strsignal (gint signum)
{
- static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
+ static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
char *msg;
-
+
#ifdef HAVE_STRSIGNAL
extern char *strsignal (int sig);
return strsignal (signum);
#endif
}
#else /* NO_SYS_SIGLIST */
- extern char *sys_siglist[];
- return sys_siglist [signum];
+
+#ifdef NO_SYS_SIGLIST_DECL
+ extern char *sys_siglist[]; /*(see Tue Jan 19 00:44:24 1999 in changelog)*/
+#endif
+
+ return (char*) /* this function should return const --josh */ sys_siglist [signum];
#endif /* NO_SYS_SIGLIST */
msg = g_static_private_get (&msg_private);
- if( !msg )
+ if (!msg)
{
- msg = g_new( gchar, 64 );
+ msg = g_new (gchar, 64);
g_static_private_set (&msg_private, msg, g_free);
}
-
+
sprintf (msg, "unknown signal (%d)", signum);
+
return msg;
}
va_list args)
{
guint len = 1;
-
+
while (*format)
{
gboolean long_int = FALSE;
gboolean extra_long = FALSE;
gchar c;
-
+
c = *format++;
-
+
if (c == '%')
{
gboolean done = FALSE;
-
+
while (*format && !done)
{
switch (*format++)
{
gchar *string_arg;
-
+
case '*':
len += va_arg (args, int);
break;
else
len += 1;
}
-
+
return len;
}
g_strdown (gchar *string)
{
register gchar *s;
-
+
g_return_if_fail (string != NULL);
-
+
s = string;
-
+
while (*s)
{
*s = tolower (*s);
g_strup (gchar *string)
{
register gchar *s;
-
+
g_return_if_fail (string != NULL);
-
+
s = string;
-
+
while (*s)
{
*s = toupper (*s);
g_strreverse (gchar *string)
{
g_return_if_fail (string != NULL);
-
+
if (*string)
{
register gchar *h, *t;
-
+
h = string;
t = string + strlen (string) - 1;
-
+
while (h < t)
{
register gchar c;
-
+
c = *h;
*h = *t;
h++;
return strcasecmp (s1, s2);
#else
gint c1, c2;
-
+
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
return (c1 - c2);
s1++; s2++;
}
-
+
return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
#endif
}
return strncasecmp (s1, s2, n);
#else
gint c1, c2;
-
+
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
gchar new_delim)
{
register gchar *c;
-
+
g_return_val_if_fail (string != NULL, NULL);
-
+
if (!delimiters)
delimiters = G_STR_DELIMITERS;
-
+
for (c = string; *c; c++)
{
if (strchr (delimiters, *c))
if (s)
{
guint delimiter_len = strlen (delimiter);
-
+
do
{
guint len;
gchar *new_string;
-
+
len = s - string;
new_string = g_new (gchar, len + 1);
strncpy (new_string, string, len);
n++;
string_list = g_slist_prepend (string_list, g_strdup (string));
}
-
+
str_array = g_new (gchar*, n);
i = n - 1;
gchar **str_array)
{
gchar *string;
-
+
g_return_val_if_fail (str_array != NULL, NULL);
if(separator == NULL)
len = 1 + strlen (str_array[0]);
for(i = 1; str_array[i] != NULL; i++)
len += separator_len + strlen(str_array[i]);
-
+
string = g_new (gchar, len);
*string = 0;
strcat (string, *str_array);