Commit 3ae8c300 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik
Browse files

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.
parent 18ee22d9
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:
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -804,6 +804,41 @@ g_set_print_handler (GPrintFunc func)
old_print_func = print_func;
print_func = 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
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment