Applied patch from (Raja R Harinath <harinath@cs.umn.edu>) to add function

Wed Jan 21 01:13:25 1998  Tim Janik  <timj@psynet.net>

        * Applied patch from (Raja R Harinath <harinath@cs.umn.edu>)
          to add function g_snprintf.
        * configure.in (AC_CHECK_FUNCS): Check for vsnprintf.
        * glib.h: Add prototype for g_snprintf.
        * glibconfig.h.in: Add HAVE_VSNPRINTF.
        * gutils.c (g_snprintf): new function.
This commit is contained in:
Tim Janik 1998-01-21 00:46:48 +00:00 committed by Tim Janik
parent 18ee22d93b
commit 3ae8c300bb
6 changed files with 53 additions and 2 deletions

View File

@ -1,3 +1,12 @@
Wed Jan 21 01:13:25 1998 Tim Janik <timj@psynet.net>
* Applied patch from (Raja R Harinath <harinath@cs.umn.edu>)
to add function g_snprintf.
* configure.in (AC_CHECK_FUNCS): Check for vsnprintf.
* glib.h: Add prototype for g_snprintf.
* glibconfig.h.in: Add HAVE_VSNPRINTF.
* gutils.c (g_snprintf): new function.
Sat Jan 17 23:52:40 1998 Owen Taylor <owt1@cornell.edu>
* gstring.{c,h} gscanner.c:

View File

@ -39,6 +39,7 @@
#undef HAVE_SYS_SELECT_H
#undef HAVE_STRERROR
#undef HAVE_STRSIGNAL
#undef HAVE_VSNPRINTF
#undef HAVE_VALUES_H
#undef HAVE_VPRINTF

View File

@ -70,7 +70,7 @@ AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H))
AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
# Check for strerror, strsignal, and memmove functions
AC_CHECK_FUNCS(strerror strsignal memmove)
AC_CHECK_FUNCS(strerror strsignal memmove vsnprintf)
# Check for sys_errlist
AC_MSG_CHECKING(sys_errlist)

View File

@ -630,6 +630,8 @@ gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */
gdouble g_strtod (const gchar *nptr, gchar **endptr);
gchar* g_strerror (gint errnum);
gchar* g_strsignal (gint signum);
gint g_snprintf (gchar *str, gulong n, gchar const *fmt, ...);
/* We make the assumption that if memmove isn't available, then
* bcopy will do the job. This isn't safe everywhere. (bcopy can't

View File

@ -23,6 +23,7 @@
#undef HAVE_SYS_SELECT_H
#undef HAVE_STRERROR
#undef HAVE_STRSIGNAL
#undef HAVE_VSNPRINTF
#undef HAVE_VALUES_H
#undef HAVE_VPRINTF
@ -61,6 +62,9 @@
/* Define if you have the strsignal function. */
#undef HAVE_STRSIGNAL
/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF
/* Define if you have the <float.h> header file. */
#undef HAVE_FLOAT_H

View File

@ -807,3 +807,38 @@ g_set_print_handler (GPrintFunc func)
return old_print_func;
}
gint
g_snprintf (gchar *str,
gulong n,
gchar const *fmt,
...)
{
#ifdef HAVE_VSNPRINTF
va_list args;
gint retval;
va_start (args, fmt);
retval = vsnprintf (str, n, fmt, args);
va_end (args);
return retval;
#else
gchar *printed;
va_list args, args2;
va_start (args, fmt);
va_start (args2, fmt);
printed = g_vsprintf (fmt, &args, &args2);
strncpy (str, printed, n);
str[n-1] = '\0';
va_end (args2);
va_end (args);
return strlen (str);
#endif
}