From 2048ef1bcb81fa766ccff3bb1cf30a886316983c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 4 Mar 2006 20:38:51 +0000 Subject: [PATCH] Remove BLP_INT_DIGITS. Now we use the intprops.h header file instead. In many source files, replace INT_DIGITS by INT_STRLEN_BOUND(int) and include intprops.h. --- ChangeLog | 9 +++++++++ Smake | 10 +++++----- acinclude.m4 | 35 ----------------------------------- configure.ac | 2 -- src/ChangeLog | 5 +++++ src/data/filename.c | 4 +++- src/language/control/repeat.c | 3 ++- src/language/data-io/list.q | 4 +++- src/language/stats/flip.c | 3 ++- src/output/groff-font.c | 3 ++- src/output/output.c | 3 ++- src/output/postscript.c | 19 ++++++++++--------- 12 files changed, 43 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7220fe7..22e40403 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sat Mar 4 12:27:06 2006 Ben Pfaff + + * Smake: Require "intprops" gnulib module. + + * acinclude.m4: Remove BLP_INT_DIGITS. Now we use the intprops.h + header file instead. + + * configure.ac: Don't call BLP_INT_DIGITS. + Sat Mar 4 11:53:36 2006 Ben Pfaff * acinclude.m4: Remove BLP_RANDOM. Its results were unused. diff --git a/Smake b/Smake index b4ed61a8..744bb051 100644 --- a/Smake +++ b/Smake @@ -4,11 +4,11 @@ GNULIB = ../gnulib GNULIB_TOOL = $(GNULIB)/gnulib-tool GNULIB_MODULES = alloca alloca-opt assert full-read full-write \ -gethostname getline getlogin_r getopt gettext memcasecmp memchr memcmp \ -memmem memmove memset progname readlink restrict snprintf stat-macros \ -stdbool stpcpy strcase strcspn strerror strftime strstr strtod \ -strtok_r strtol strtoul vsnprintf xalloc xalloc-die xreadlink \ -xvasprintf +gethostname getline getlogin_r getopt gettext intprops memcasecmp \ +memchr memcmp memmem memmove memset progname readlink restrict \ +snprintf stat-macros stdbool stpcpy strcase strcspn strerror strftime \ +strstr strtod strtok_r strtol strtoul vsnprintf xalloc xalloc-die \ +xreadlink xvasprintf all: po/POTFILES.in test -d m4 || mkdir m4 diff --git a/acinclude.m4 b/acinclude.m4 index e45a9be4..e3ddb129 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -3,41 +3,6 @@ dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl Check longest integer in digits. - -AC_DEFUN([BLP_INT_DIGITS], -[ -AC_MSG_CHECKING(number of digits in LONG_MIN (incl. sign)) -AC_CACHE_VAL(blp_int_digits, - [AC_TRY_RUN([#include - #include - int - main() - { - int len; - char s[80]; - sprintf(s, "%ld", LONG_MAX); - len = strlen(s); - sprintf(s, "%ld", LONG_MIN); - if(strlen(s)>len) len=strlen(s); - sprintf(s, "%lu", ULONG_MAX); - if(strlen(s)>len) len=strlen(s); - exit(len); - } - ], - eval "blp_int_digits=19", - eval "blp_int_digits=$?" - if test "$blp_int_digits" -lt 11; then - blp_int_digits=11 - fi, - eval "blp_int_digits=19") - ]) -AC_DEFINE_UNQUOTED([INT_DIGITS], $blp_int_digits, - [Number of digits in longest `long' value, including sign. - This is usually 11, for 32-bit `long's, or 19, for 64-bit - `long's.]) -AC_MSG_RESULT($blp_int_digits) ])dnl - dnl Check for readline and history libraries. dnl Modified for PSPP by Ben Pfaff, based on readline.m4 serial 3 from diff --git a/configure.ac b/configure.ac index 1528d72c..658d1217 100644 --- a/configure.ac +++ b/configure.ac @@ -103,8 +103,6 @@ AC_DEFINE(FPREP_IEEE754, 1, AC_C_BIGENDIAN -BLP_INT_DIGITS - AC_FUNC_VPRINTF AC_CHECK_FUNCS([strchr strrchr __setfpucw isinf isnan finite getpid feholdexcept]) diff --git a/src/ChangeLog b/src/ChangeLog index 3bee27f3..1cf3b3e5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 4 12:28:09 2006 Ben Pfaff + + * In many source files, replace INT_DIGITS by + INT_STRLEN_BOUND(int) and include intprops.h. + John Darrington: * Replaced '_' with '-' in most filenames. diff --git a/src/data/filename.c b/src/data/filename.c index 2865bd33..4bf5edd9 100644 --- a/src/data/filename.c +++ b/src/data/filename.c @@ -25,6 +25,7 @@ #include #include #include "alloc.h" +#include "intprops.h" #include "message.h" #include "str.h" #include "settings.h" @@ -770,7 +771,8 @@ fn_open_ext (struct file_ext *f) p = strstr (f->filename, "%d"); if (p) { - char *s = local_alloc (strlen (f->filename) + INT_DIGITS - 1); + char *s = local_alloc (strlen (f->filename) + + INT_STRLEN_BOUND (int) - 1); char *cp; memcpy (s, f->filename, p - f->filename); diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c index bba14c6c..a26fda4b 100644 --- a/src/language/control/repeat.c +++ b/src/language/control/repeat.c @@ -26,6 +26,7 @@ #include "alloc.h" #include "command.h" #include "dictionary.h" +#include "intprops.h" #include "message.h" #include "line-buffer.h" #include "lexer.h" @@ -363,7 +364,7 @@ parse_ids (struct repeat_entry *e) static inline void store_numeric (char **repl, long value) { - *repl = xmalloc (INT_DIGITS + 1); + *repl = xmalloc (INT_STRLEN_BOUND (value) + 1); sprintf (*repl, "%ld", value); } diff --git a/src/language/data-io/list.q b/src/language/data-io/list.q index 0834e2ad..18b08fee 100644 --- a/src/language/data-io/list.q +++ b/src/language/data-io/list.q @@ -25,6 +25,7 @@ #include "case.h" #include "command.h" #include "dictionary.h" +#include "intprops.h" #include "lexer.h" #include "message.h" #include "magic.h" @@ -434,7 +435,8 @@ write_fallback_headers (struct outp_driver *d) int line_number = 0; const char *Line = _("Line"); - char *leader = local_alloc (strlen (Line) + INT_DIGITS + 1 + 1); + char *leader = local_alloc (strlen (Line) + + INT_STRLEN_BOUND (line_number) + 1 + 1); while (index < cmd.n_variables) { diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index f816a0f5..bc5399a7 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -30,6 +30,7 @@ #include "command.h" #include "dictionary.h" #include "message.h" +#include "intprops.h" #include "lexer.h" #include "misc.h" #include "pool.h" @@ -332,7 +333,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) strcpy (v->name, "VPOSINF"); else { - char name[INT_DIGITS + 2]; + char name[INT_STRLEN_BOUND (int) + 2]; sprintf (name, "V%d", (int) f); str_copy_trunc (v->name, sizeof v->name, name); } diff --git a/src/output/groff-font.c b/src/output/groff-font.c index b08ee636..c8014d78 100644 --- a/src/output/groff-font.c +++ b/src/output/groff-font.c @@ -30,6 +30,7 @@ #include "filename.h" #include "getline.h" #include "hash.h" +#include "intprops.h" #include "pool.h" #include "str.h" #include "version.h" @@ -539,7 +540,7 @@ font_char_name_to_index (const char *name) int font_number_to_index (int x) { - char name[INT_DIGITS + 2]; + char name[INT_STRLEN_BOUND (x) + 2]; /* Note that space is the only character that can't appear in a character name. That makes it an excellent choice for a name diff --git a/src/output/output.c b/src/output/output.c index b1b40463..3f79a6a0 100644 --- a/src/output/output.c +++ b/src/output/output.c @@ -28,6 +28,7 @@ #include "message.h" #include "filename.h" #include "htmlP.h" +#include "intprops.h" #include "misc.h" #include "settings.h" #include "str.h" @@ -194,7 +195,7 @@ expand_name (char *bp, char *ep) static const char * find_defn_value (const char *key) { - static char buf[INT_DIGITS + 1]; + static char buf[INT_STRLEN_BOUND (int) + 1]; struct outp_defn *d; for (d = outp_macros; d; d = d->next) diff --git a/src/output/postscript.c b/src/output/postscript.c index fbe8f642..f54ef168 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -41,6 +41,7 @@ #include "font.h" #include "getline.h" #include "hash.h" +#include "intprops.h" #include "misc.h" #include "output.h" #include "manager.h" @@ -1190,20 +1191,20 @@ postopen (struct file_ext *f) {"title", 0}, {0, 0}, }; - char boundbox[INT_DIGITS * 4 + 4]; + char boundbox[INT_STRLEN_BOUND (int) * 4 + 4]; #if HAVE_UNISTD_H char host[128]; #endif - char scaling[INT_DIGITS + 5]; + char scaling[INT_STRLEN_BOUND (int) + 5]; time_t curtime; struct tm *loctime; char *p, *cp; - char paper_width[INT_DIGITS + 1]; - char paper_length[INT_DIGITS + 1]; - char left_margin[INT_DIGITS + 1]; - char top_margin[INT_DIGITS + 1]; - char line_width[INT_DIGITS + 1]; - char line_width_thick[INT_DIGITS + 1]; + char paper_width[INT_STRLEN_BOUND (int) + 1]; + char paper_length[INT_STRLEN_BOUND (int) + 1]; + char left_margin[INT_STRLEN_BOUND (int) + 1]; + char top_margin[INT_STRLEN_BOUND (int) + 1]; + char line_width[INT_STRLEN_BOUND (int) + 1]; + char line_width_thick[INT_STRLEN_BOUND (int) + 1]; struct outp_driver *this = f->param; struct ps_driver_ext *x = this->ext; @@ -2402,7 +2403,7 @@ write_text (struct outp_driver *this, int last_y; - char number[INT_DIGITS + 1]; + char number[INT_STRLEN_BOUND (int) + 1]; char line[80]; char *lp; -- 2.30.2