Back to index

tetex-bin  3.0
Functions
safe_sprintf.c File Reference
#include <curses.priv.h>
#include <ctype.h>

Go to the source code of this file.

Functions

 _nc_printf_string (const char *fmt, va_list ap)

Function Documentation

_nc_printf_string ( const char *  fmt,
va_list  ap 
)

Definition at line 214 of file safe_sprintf.c.

{
    static char *buf;
    static size_t used;
    char *result = 0;

    if (fmt != 0) {
#if USE_SAFE_SPRINTF
       int len = _nc_printf_length(fmt, ap);

       if ((int) used < len + 1) {
           used = 2 * (len + 1);
           buf = typeRealloc(char, used, buf);
       }
       if (buf != 0) {
           *buf = '\0';
           if (len >= 0) {
              vsprintf(buf, fmt, ap);
           }
           result = buf;
       }
#else
       static int rows, cols;

       if (screen_lines > rows || screen_columns > cols) {
           if (screen_lines > rows)
              rows = screen_lines;
           if (screen_columns > cols)
              cols = screen_columns;
           used = (rows * (cols + 1)) + 1;
           buf = typeRealloc(char, used, buf);
       }

       if (buf != 0) {
# if HAVE_VSNPRINTF
           vsnprintf(buf, used, fmt, ap); /* GNU extension */
# else
           vsprintf(buf, fmt, ap); /* ANSI */
# endif
           result = buf;
       }
#endif
    } else if (buf != 0) {  /* see _nc_freeall() */
       free(buf);
       buf = 0;
       used = 0;
    }
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: