From f0e5634dd6fcd77bd9d4d2407cde2c4a3a330617 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 15 May 2006 05:08:25 +0000 Subject: [PATCH] Removed nsprintf(), nvsprintf(). Moved spprintf() definition into str.c. --- src/language/dictionary/sys-file-info.c | 10 +++++----- src/libpspp/ChangeLog | 9 +++++++++ src/libpspp/str.c | 15 ++++++++++++++ src/libpspp/str.h | 26 +++---------------------- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 13c3275e..5c3985be 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -482,11 +482,11 @@ describe_variable (struct variable *v, struct tab_table *t, int r, int as) double x, y; mv_pop_range (&mv, &x, &y); if (x == LOWEST) - cp += nsprintf (cp, "LOWEST THRU %g", y); + cp += sprintf (cp, "LOWEST THRU %g", y); else if (y == HIGHEST) - cp += nsprintf (cp, "%g THRU HIGHEST", x); + cp += sprintf (cp, "%g THRU HIGHEST", x); else - cp += nsprintf (cp, "%g THRU %g", x, y); + cp += sprintf (cp, "%g THRU %g", x, y); cnt++; } while (mv_has_value (&mv)) @@ -494,9 +494,9 @@ describe_variable (struct variable *v, struct tab_table *t, int r, int as) union value value; mv_pop_value (&mv, &value); if (cnt++ > 0) - cp += nsprintf (cp, "; "); + cp += sprintf (cp, "; "); if (v->type == NUMERIC) - cp += nsprintf (cp, "%g", value.f); + cp += sprintf (cp, "%g", value.f); else { *cp++ = '"'; diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index 30556119..befea203 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,12 @@ +Sun May 14 22:06:53 2006 Ben Pfaff + + * str.c (spprintf): Moved definition of spprintf() here, from + str.h. + + * str.h: (nsprintf) Removed. Changed all users to use sprintf() + instead. + (nvsprintf) Removed. Changed all users to use vsprintf() instead. + Sun May 14 20:52:20 2006 Ben Pfaff * str.c (ds_init): Remove `capacity' argument and just initialize diff --git a/src/libpspp/str.c b/src/libpspp/str.c index ef2be7d0..655774d6 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -236,6 +236,21 @@ str_lowercase (char *s) for (; *s != '\0'; s++) *s = tolower ((unsigned char) *s); } + +/* Formats FORMAT into DST, as with sprintf(), and returns the + address of the terminating null written to DST. */ +char * +spprintf (char *dst, const char *format, ...) +{ + va_list args; + int count; + + va_start (args, format); + count = vsprintf (dst, format, args); + va_end (args); + + return dst + count; +} /* Initializes ST with initial contents S. */ void diff --git a/src/libpspp/str.h b/src/libpspp/str.h index 379762fc..cd7cdb05 100644 --- a/src/libpspp/str.h +++ b/src/libpspp/str.h @@ -61,6 +61,8 @@ void str_copy_trunc (char *, size_t, const char *); void str_copy_buf_trunc (char *, size_t, const char *, size_t); void str_uppercase (char *); void str_lowercase (char *); + +char *spprintf (char *dst, const char *format, ...); /* Fixed-length strings. */ struct fixed_string @@ -173,6 +175,7 @@ void ds_concat (struct string *, const char *, size_t); void ds_vprintf (struct string *st, const char *, va_list); void ds_printf (struct string *, const char *, ...) PRINTF_FORMAT (2, 3); +char *ds_append_uninit (struct string *st, size_t incr); #if __GNUC__ > 1 extern inline void @@ -202,27 +205,4 @@ ds_end (const struct string *st) } #endif -#define nsprintf sprintf -#define nvsprintf vsprintf - -/* Formats FORMAT into DST, as with sprintf(), and returns the - address of the terminating null written to DST. */ -static inline char * -spprintf (char *dst, const char *format, ...) -{ - va_list args; - int count; - - va_start (args, format); - count = nvsprintf (dst, format, args); - va_end (args); - - return dst + count; -} - - -char * ds_append_uninit(struct string *st, size_t incr); - - - #endif /* str_h */ -- 2.30.2