1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Change the 'len' parameter type to 'size_t'.

This commit is contained in:
Bruno Haible
2016-11-26 17:54:33 +01:00
parent 31784d388f
commit d519d1a821
19 changed files with 66 additions and 49 deletions

View File

@@ -1,3 +1,17 @@
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> 2016-11-26 Bruno Haible <bruno@clisp.org>
Use proper 'ar' program when cross-compiling or when AR is specified. Use proper 'ar' program when cross-compiling or when AR is specified.

3
NEWS
View File

@@ -2,6 +2,9 @@ New in 3.1:
* The generated C code is now in ANSI-C by default. If you want to support * 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 pre-ANSI-C compilers, you need to provide the option --language=C on the
command line or %language=C in the source file. 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 option --constants-prefix.
* Added declaration %define constants-prefix. * Added declaration %define constants-prefix.

View File

@@ -17,7 +17,7 @@
@c some day we should @include version.texi instead of defining @c some day we should @include version.texi instead of defining
@c these values at hand. @c these values at hand.
@set UPDATED 11 January 2011 @set UPDATED 26 November 2016
@set EDITION 3.1 @set EDITION 3.1
@set VERSION 3.1 @set VERSION 3.1
@c --------------------- @c ---------------------
@@ -40,7 +40,7 @@
This file documents the features of the GNU Perfect Hash Function This file documents the features of the GNU Perfect Hash Function
Generator @value{VERSION}. 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 Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are manual provided the copyright notice and this permission notice are
@@ -78,7 +78,7 @@ Software Foundation instead of in the original English.
@page @page
@vskip 0pt plus 1filll @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 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 @var{str}, and a length parameter, @code{int} @var{len}. Their default
function prototypes are as follows: 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 By default, the generated @code{hash} function returns an integer value
created by adding @var{len} to several user-specified @var{str} byte created by adding @var{len} to several user-specified @var{str} byte
positions indexed into an @dfn{associated values} table stored in a 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}). @code{gperf}, as detailed in the @emph{Options} section below (@pxref{Options}).
@end deftypefun @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 If @var{str} is in the keyword set, returns a pointer to that
keyword. More exactly, if the option @samp{-t} (or, equivalently, the keyword. More exactly, if the option @samp{-t} (or, equivalently, the
@samp{%struct-type} declaration) was given, it returns @samp{%struct-type} declaration) was given, it returns

View File

@@ -369,14 +369,14 @@ output_upperlower_strncmp ()
"(s1, s2, n)\n" "(s1, s2, n)\n"
" %schar *s1;\n" " %schar *s1;\n"
" %schar *s2;\n" " %schar *s2;\n"
" %sunsigned int n;\n" : " %ssize_t n;\n" :
option[C] ? option[C] ?
"(s1, s2, n)\n" "(s1, s2, n)\n"
" %sconst char *s1;\n" " %sconst char *s1;\n"
" %sconst char *s2;\n" " %sconst char *s2;\n"
" %sunsigned int n;\n" : " %ssize_t n;\n" :
option[ANSIC] | option[CPLUSPLUS] ? 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); register_scs, register_scs, register_scs);
#if USE_DOWNCASE_TABLE #if USE_DOWNCASE_TABLE
@@ -430,14 +430,14 @@ output_upperlower_memcmp ()
"(s1, s2, n)\n" "(s1, s2, n)\n"
" %schar *s1;\n" " %schar *s1;\n"
" %schar *s2;\n" " %schar *s2;\n"
" %sunsigned int n;\n" : " %ssize_t n;\n" :
option[C] ? option[C] ?
"(s1, s2, n)\n" "(s1, s2, n)\n"
" %sconst char *s1;\n" " %sconst char *s1;\n"
" %sconst char *s2;\n" " %sconst char *s2;\n"
" %sunsigned int n;\n" : " %ssize_t n;\n" :
option[ANSIC] | option[CPLUSPLUS] ? 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); register_scs, register_scs, register_scs);
#if USE_DOWNCASE_TABLE #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 /* Generates C code for the hash function that returns the
proper encoding for each keyword. proper encoding for each keyword.
The hash function has the signature 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 void
Output::output_hash_function () const Output::output_hash_function () const
@@ -832,13 +832,13 @@ Output::output_hash_function () const
printf (option[KRC] ? printf (option[KRC] ?
"(str, len)\n" "(str, len)\n"
" %schar *str;\n" " %schar *str;\n"
" %sunsigned int len;\n" : " %ssize_t len;\n" :
option[C] ? option[C] ?
"(str, len)\n" "(str, len)\n"
" %sconst char *str;\n" " %sconst char *str;\n"
" %sunsigned int len;\n" : " %ssize_t len;\n" :
option[ANSIC] | option[CPLUSPLUS] ? option[ANSIC] | option[CPLUSPLUS] ?
"(%sconst char *str, %sunsigned int len)\n" : "(%sconst char *str, %ssize_t len)\n" :
"", "",
register_scs, register_scs); register_scs, register_scs);
@@ -1999,13 +1999,13 @@ Output::output_lookup_function () const
printf (option[KRC] ? printf (option[KRC] ?
"(str, len)\n" "(str, len)\n"
" %schar *str;\n" " %schar *str;\n"
" %sunsigned int len;\n" : " %ssize_t len;\n" :
option[C] ? option[C] ?
"(str, len)\n" "(str, len)\n"
" %sconst char *str;\n" " %sconst char *str;\n"
" %sunsigned int len;\n" : " %ssize_t len;\n" :
option[ANSIC] | option[CPLUSPLUS] ? option[ANSIC] | option[CPLUSPLUS] ?
"(%sconst char *str, %sunsigned int len)\n" : "(%sconst char *str, %ssize_t len)\n" :
"", "",
register_scs, register_scs); register_scs, register_scs);
@@ -2178,9 +2178,9 @@ Output::output ()
printf ("class %s\n" printf ("class %s\n"
"{\n" "{\n"
"private:\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" "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"
"\n", "\n",
option.get_class_name (), option.get_hash_name (), option.get_class_name (), option.get_hash_name (),

View File

@@ -49,7 +49,7 @@ inline
static unsigned int static unsigned int
hash (str, len) hash (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
static unsigned char asso_values[] = static unsigned char asso_values[] =
{ {
@@ -206,7 +206,7 @@ __attribute__ ((__gnu_inline__))
struct resword * struct resword *
is_reserved_word (str, len) is_reserved_word (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{ {

View File

@@ -56,7 +56,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static const unsigned short asso_values[] =
{ {
@@ -1808,7 +1808,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
const struct charset * 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) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{ {

View File

@@ -47,7 +47,7 @@ inline
static unsigned int static unsigned int
hash (str, len) hash (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
static unsigned short asso_values[] = static unsigned short asso_values[] =
{ {
@@ -185,7 +185,7 @@ __attribute__ ((__gnu_inline__))
struct resword * struct resword *
in_word_set (str, len) in_word_set (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
enum enum
{ {

View File

@@ -49,7 +49,7 @@ inline
static unsigned int static unsigned int
hash (str, len) hash (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
static unsigned char asso_values[] = static unsigned char asso_values[] =
{ {
@@ -110,7 +110,7 @@ __attribute__ ((__gnu_inline__))
struct resword * struct resword *
is_reserved_word (str, len) is_reserved_word (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
static struct resword wordlist[] = static struct resword wordlist[] =
{ {

View File

@@ -56,7 +56,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -97,7 +97,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
struct resword * 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[] = static struct resword wordlist[] =
{ {

View File

@@ -46,7 +46,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -87,7 +87,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
struct month * 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[] = static struct month wordlist[] =
{ {

View File

@@ -73,7 +73,7 @@ inline
static unsigned int static unsigned int
hash (str, len) hash (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
static unsigned char asso_values[] = static unsigned char asso_values[] =
{ {
@@ -128,7 +128,7 @@ __attribute__ ((__gnu_inline__))
struct java_keyword * struct java_keyword *
java_keyword (str, len) java_keyword (str, len)
register const char *str; register const char *str;
register unsigned int len; register size_t len;
{ {
static struct java_keyword wordlist[] = static struct java_keyword wordlist[] =
{ {

View File

@@ -59,7 +59,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static const unsigned short asso_values[] =
{ {
@@ -1465,7 +1465,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
const struct language * 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) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{ {

View File

@@ -44,7 +44,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -114,7 +114,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
const char * 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[] = static unsigned char lengthtable[] =
{ {

View File

@@ -47,7 +47,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -100,7 +100,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
struct resword * 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[] = static struct resword wordlist[] =
{ {

View File

@@ -46,7 +46,7 @@ inline
#endif #endif
/*ARGSUSED*/ /*ARGSUSED*/
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -87,7 +87,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
const char * 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[] = static const char * wordlist[] =
{ {

View File

@@ -46,7 +46,7 @@ inline
#endif #endif
/*ARGSUSED*/ /*ARGSUSED*/
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -87,7 +87,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
const char * 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[] = static const char * wordlist[] =
{ {

View File

@@ -91,7 +91,7 @@ inline
#endif #endif
/*ARGSUSED*/ /*ARGSUSED*/
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -132,7 +132,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
const char * 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[] = static const char * wordlist[] =
{ {

View File

@@ -148,7 +148,7 @@ main (argc, argv)
char *argv[]; char *argv[];
{ {
int i, j, k, n, exitcode; int i, j, k, n, exitcode;
unsigned int len; size_t len;
const struct header_state *hs; const struct header_state *hs;
n = 1; n = 1;

View File

@@ -47,7 +47,7 @@ inline
#endif #endif
#endif #endif
static unsigned int 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[] = static unsigned char asso_values[] =
{ {
@@ -88,7 +88,7 @@ __attribute__ ((__gnu_inline__))
#endif #endif
#endif #endif
struct resword * 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[] = static struct resword wordlist[] =
{ {