summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2016-11-26 17:54:33 +0100
committerBruno Haible <bruno@clisp.org>2016-11-26 17:54:33 +0100
commitd519d1a821511eaa22eae6d9019a548aea21e6d3 (patch)
treebc79782c8364d4df30381d7d85296a3ab55caccf
parent31784d388fe19f3de97ea65cfe03b0770db6170f (diff)
downloadgperf-d519d1a821511eaa22eae6d9019a548aea21e6d3.tar.gz
Change the 'len' parameter type to 'size_t'.
-rw-r--r--ChangeLog14
-rw-r--r--NEWS3
-rw-r--r--doc/gperf.texi10
-rw-r--r--src/output.cc30
-rw-r--r--tests/c-parse.exp4
-rw-r--r--tests/charsets.exp4
-rw-r--r--tests/chill.exp4
-rw-r--r--tests/cplusplus.exp4
-rw-r--r--tests/gpc.exp4
-rw-r--r--tests/incomplete.exp4
-rw-r--r--tests/java.exp4
-rw-r--r--tests/languages.exp4
-rw-r--r--tests/modula2.exp4
-rw-r--r--tests/objc.exp4
-rw-r--r--tests/permut2.exp4
-rw-r--r--tests/permut3.exp4
-rw-r--r--tests/permutc2.exp4
-rw-r--r--tests/smtp.gperf2
-rw-r--r--tests/test-4.exp4
19 files changed, 66 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index 9eb3de2..072a0ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2016-11-26 Bruno Haible <bruno@clisp.org>
+ Change the 'len' parameter type to 'size_t'.
+ * src/output.cc (output_upperlower_strncmp, output_upperlower_memcmp,
+ Output::output_hash_function, Output::output_lookup_function,
+ Output::output): Emit declarations with 'size_t len' instead of
+ 'unsigned int len'.
+ * tests/*.exp: Update.
+ * doc/gperf.texi (Output Format): Change declarations of 'hash' and
+ 'in_word_set'.
+ * NEWS: Mention the change.
+ Reported by Pedro Giffuni <pfg@FreeBSD.org>
+ at <http://lists.gnu.org/archive/html/bug-gperf/2014-08/msg00000.html>.
+
+2016-11-26 Bruno Haible <bruno@clisp.org>
+
Use proper 'ar' program when cross-compiling or when AR is specified.
* lib/configure.ac (AR): Determine through AC_CHECK_TOOL.
* lib/Makefile.in (AR): Use value determined by 'configure'.
diff --git a/NEWS b/NEWS
index bcac2f3..f3abd0e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ New in 3.1:
* The generated C code is now in ANSI-C by default. If you want to support
pre-ANSI-C compilers, you need to provide the option --language=C on the
command line or %language=C in the source file.
+* The 'len' parameter of the hash function and of the lookup function is now
+ of type 'size_t' instead of 'unsigned int'. This makes it safe to call these
+ functions with strings of length > 4 GB, on 64-bit machines.
* Added option --constants-prefix.
* Added declaration %define constants-prefix.
diff --git a/doc/gperf.texi b/doc/gperf.texi
index 9c0fd7d..64f08ba 100644
--- a/doc/gperf.texi
+++ b/doc/gperf.texi
@@ -17,7 +17,7 @@
@c some day we should @include version.texi instead of defining
@c these values at hand.
-@set UPDATED 11 January 2011
+@set UPDATED 26 November 2016
@set EDITION 3.1
@set VERSION 3.1
@c ---------------------
@@ -40,7 +40,7 @@
This file documents the features of the GNU Perfect Hash Function
Generator @value{VERSION}.
-Copyright @copyright{} 1989-2011, 2014 Free Software Foundation, Inc.
+Copyright @copyright{} 1989-2016 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
@@ -78,7 +78,7 @@ Software Foundation instead of in the original English.
@page
@vskip 0pt plus 1filll
-Copyright @copyright{} 1989-2011 Free Software Foundation, Inc.
+Copyright @copyright{} 1989-2016 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
@@ -804,7 +804,7 @@ option. Both functions require two arguments, a string, @code{char *}
@var{str}, and a length parameter, @code{int} @var{len}. Their default
function prototypes are as follows:
-@deftypefun {unsigned int} hash (const char * @var{str}, unsigned int @var{len})
+@deftypefun {unsigned int} hash (const char * @var{str}, size_t @var{len})
By default, the generated @code{hash} function returns an integer value
created by adding @var{len} to several user-specified @var{str} byte
positions indexed into an @dfn{associated values} table stored in a
@@ -815,7 +815,7 @@ into @var{str}) are specified via the @samp{-k} option when running
@code{gperf}, as detailed in the @emph{Options} section below (@pxref{Options}).
@end deftypefun
-@deftypefun {} in_word_set (const char * @var{str}, unsigned int @var{len})
+@deftypefun {} in_word_set (const char * @var{str}, size_t @var{len})
If @var{str} is in the keyword set, returns a pointer to that
keyword. More exactly, if the option @samp{-t} (or, equivalently, the
@samp{%struct-type} declaration) was given, it returns
diff --git a/src/output.cc b/src/output.cc
index 1ec5d39..abb9bb5 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -369,14 +369,14 @@ output_upperlower_strncmp ()
"(s1, s2, n)\n"
" %schar *s1;\n"
" %schar *s2;\n"
- " %sunsigned int n;\n" :
+ " %ssize_t n;\n" :
option[C] ?
"(s1, s2, n)\n"
" %sconst char *s1;\n"
" %sconst char *s2;\n"
- " %sunsigned int n;\n" :
+ " %ssize_t n;\n" :
option[ANSIC] | option[CPLUSPLUS] ?
- "(%sconst char *s1, %sconst char *s2, %sunsigned int n)\n" :
+ "(%sconst char *s1, %sconst char *s2, %ssize_t n)\n" :
"",
register_scs, register_scs, register_scs);
#if USE_DOWNCASE_TABLE
@@ -430,14 +430,14 @@ output_upperlower_memcmp ()
"(s1, s2, n)\n"
" %schar *s1;\n"
" %schar *s2;\n"
- " %sunsigned int n;\n" :
+ " %ssize_t n;\n" :
option[C] ?
"(s1, s2, n)\n"
" %sconst char *s1;\n"
" %sconst char *s2;\n"
- " %sunsigned int n;\n" :
+ " %ssize_t n;\n" :
option[ANSIC] | option[CPLUSPLUS] ?
- "(%sconst char *s1, %sconst char *s2, %sunsigned int n)\n" :
+ "(%sconst char *s1, %sconst char *s2, %ssize_t n)\n" :
"",
register_scs, register_scs, register_scs);
#if USE_DOWNCASE_TABLE
@@ -797,7 +797,7 @@ Output::output_asso_values_ref (int pos) const
/* Generates C code for the hash function that returns the
proper encoding for each keyword.
The hash function has the signature
- unsigned int <hash> (const char *str, unsigned int len). */
+ unsigned int <hash> (const char *str, size_t len). */
void
Output::output_hash_function () const
@@ -832,13 +832,13 @@ Output::output_hash_function () const
printf (option[KRC] ?
"(str, len)\n"
" %schar *str;\n"
- " %sunsigned int len;\n" :
+ " %ssize_t len;\n" :
option[C] ?
"(str, len)\n"
" %sconst char *str;\n"
- " %sunsigned int len;\n" :
+ " %ssize_t len;\n" :
option[ANSIC] | option[CPLUSPLUS] ?
- "(%sconst char *str, %sunsigned int len)\n" :
+ "(%sconst char *str, %ssize_t len)\n" :
"",
register_scs, register_scs);
@@ -1999,13 +1999,13 @@ Output::output_lookup_function () const
printf (option[KRC] ?
"(str, len)\n"
" %schar *str;\n"
- " %sunsigned int len;\n" :
+ " %ssize_t len;\n" :
option[C] ?
"(str, len)\n"
" %sconst char *str;\n"
- " %sunsigned int len;\n" :
+ " %ssize_t len;\n" :
option[ANSIC] | option[CPLUSPLUS] ?
- "(%sconst char *str, %sunsigned int len)\n" :
+ "(%sconst char *str, %ssize_t len)\n" :
"",
register_scs, register_scs);
@@ -2178,9 +2178,9 @@ Output::output ()
printf ("class %s\n"
"{\n"
"private:\n"
- " static inline unsigned int %s (const char *str, unsigned int len);\n"
+ " static inline unsigned int %s (const char *str, size_t len);\n"
"public:\n"
- " static %s%s%s (const char *str, unsigned int len);\n"
+ " static %s%s%s (const char *str, size_t len);\n"
"};\n"
"\n",
option.get_class_name (), option.get_hash_name (),
diff --git a/tests/c-parse.exp b/tests/c-parse.exp
index e526710..613d820 100644
--- a/tests/c-parse.exp
+++ b/tests/c-parse.exp
@@ -49,7 +49,7 @@ inline
static unsigned int
hash (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
static unsigned char asso_values[] =
{
@@ -206,7 +206,7 @@ __attribute__ ((__gnu_inline__))
struct resword *
is_reserved_word (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
diff --git a/tests/charsets.exp b/tests/charsets.exp
index 7e2b988..2f008bd 100644
--- a/tests/charsets.exp
+++ b/tests/charsets.exp
@@ -56,7 +56,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static const unsigned short asso_values[] =
{
@@ -1808,7 +1808,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
const struct charset *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
diff --git a/tests/chill.exp b/tests/chill.exp
index 8fa7879..18fb2aa 100644
--- a/tests/chill.exp
+++ b/tests/chill.exp
@@ -47,7 +47,7 @@ inline
static unsigned int
hash (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
static unsigned short asso_values[] =
{
@@ -185,7 +185,7 @@ __attribute__ ((__gnu_inline__))
struct resword *
in_word_set (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
enum
{
diff --git a/tests/cplusplus.exp b/tests/cplusplus.exp
index 69c2fd0..5f28621 100644
--- a/tests/cplusplus.exp
+++ b/tests/cplusplus.exp
@@ -49,7 +49,7 @@ inline
static unsigned int
hash (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
static unsigned char asso_values[] =
{
@@ -110,7 +110,7 @@ __attribute__ ((__gnu_inline__))
struct resword *
is_reserved_word (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
static struct resword wordlist[] =
{
diff --git a/tests/gpc.exp b/tests/gpc.exp
index 59b5a18..b01f40a 100644
--- a/tests/gpc.exp
+++ b/tests/gpc.exp
@@ -56,7 +56,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -97,7 +97,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
struct resword *
-is_reserved_word (register const char *str, register unsigned int len)
+is_reserved_word (register const char *str, register size_t len)
{
static struct resword wordlist[] =
{
diff --git a/tests/incomplete.exp b/tests/incomplete.exp
index dfb0b57..65e8ea5 100644
--- a/tests/incomplete.exp
+++ b/tests/incomplete.exp
@@ -46,7 +46,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -87,7 +87,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
struct month *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
static struct month wordlist[] =
{
diff --git a/tests/java.exp b/tests/java.exp
index 465d6d9..f9e49f2 100644
--- a/tests/java.exp
+++ b/tests/java.exp
@@ -73,7 +73,7 @@ inline
static unsigned int
hash (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
static unsigned char asso_values[] =
{
@@ -128,7 +128,7 @@ __attribute__ ((__gnu_inline__))
struct java_keyword *
java_keyword (str, len)
register const char *str;
- register unsigned int len;
+ register size_t len;
{
static struct java_keyword wordlist[] =
{
diff --git a/tests/languages.exp b/tests/languages.exp
index 051c8e0..8e801d6 100644
--- a/tests/languages.exp
+++ b/tests/languages.exp
@@ -59,7 +59,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static const unsigned short asso_values[] =
{
@@ -1465,7 +1465,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
const struct language *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
diff --git a/tests/modula2.exp b/tests/modula2.exp
index 3c6451d..c58bc6e 100644
--- a/tests/modula2.exp
+++ b/tests/modula2.exp
@@ -44,7 +44,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -114,7 +114,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
const char *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
static unsigned char lengthtable[] =
{
diff --git a/tests/objc.exp b/tests/objc.exp
index 78680c5..7bd0612 100644
--- a/tests/objc.exp
+++ b/tests/objc.exp
@@ -47,7 +47,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -100,7 +100,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
struct resword *
-is_reserved_word (register const char *str, register unsigned int len)
+is_reserved_word (register const char *str, register size_t len)
{
static struct resword wordlist[] =
{
diff --git a/tests/permut2.exp b/tests/permut2.exp
index 5d29a91..9d8e224 100644
--- a/tests/permut2.exp
+++ b/tests/permut2.exp
@@ -46,7 +46,7 @@ inline
#endif
/*ARGSUSED*/
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -87,7 +87,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
const char *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
static const char * wordlist[] =
{
diff --git a/tests/permut3.exp b/tests/permut3.exp
index 2612088..cfae620 100644
--- a/tests/permut3.exp
+++ b/tests/permut3.exp
@@ -46,7 +46,7 @@ inline
#endif
/*ARGSUSED*/
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -87,7 +87,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
const char *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
static const char * wordlist[] =
{
diff --git a/tests/permutc2.exp b/tests/permutc2.exp
index 157b049..083e790 100644
--- a/tests/permutc2.exp
+++ b/tests/permutc2.exp
@@ -91,7 +91,7 @@ inline
#endif
/*ARGSUSED*/
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -132,7 +132,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
const char *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
static const char * wordlist[] =
{
diff --git a/tests/smtp.gperf b/tests/smtp.gperf
index 5d26f5e..da6ec7d 100644
--- a/tests/smtp.gperf
+++ b/tests/smtp.gperf
@@ -148,7 +148,7 @@ main (argc, argv)
char *argv[];
{
int i, j, k, n, exitcode;
- unsigned int len;
+ size_t len;
const struct header_state *hs;
n = 1;
diff --git a/tests/test-4.exp b/tests/test-4.exp
index e860053..c53b0d7 100644
--- a/tests/test-4.exp
+++ b/tests/test-4.exp
@@ -47,7 +47,7 @@ inline
#endif
#endif
static unsigned int
-hash (register const char *str, register unsigned int len)
+hash (register const char *str, register size_t len)
{
static unsigned char asso_values[] =
{
@@ -88,7 +88,7 @@ __attribute__ ((__gnu_inline__))
#endif
#endif
struct resword *
-in_word_set (register const char *str, register unsigned int len)
+in_word_set (register const char *str, register size_t len)
{
static struct resword wordlist[] =
{