1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Initialize the Keyword::_lineno field through the constructor.

This commit is contained in:
Bruno Haible
2017-04-16 17:39:15 +02:00
parent 09cfae667e
commit a459641a53
5 changed files with 30 additions and 15 deletions

View File

@@ -1,3 +1,15 @@
2017-04-16 Bruno Haible <bruno@clisp.org>
Initialize the Keyword::_lineno field through the constructor.
* src/keyword.h (struct Keyword, struct KeywordExt): Add lineno argument
to constructor.
(Keyword_Factory::create_keyword): Add lineno argument.
* src/keyword.icc (struct Keyword, struct KeywordExt): Add lineno
argument to constructor.
* src/main.cc (KeywordExt_Factory::create_keyword): Pass lineno argument
to KeywordExt constructor.
* src/input.cc (Input::read_input): Pass lineno to create_keyword.
2017-03-31 Bruno Haible <bruno@clisp.org> 2017-03-31 Bruno Haible <bruno@clisp.org>
Fix doc build error with perl 5.22. Fix doc build error with perl 5.22.

View File

@@ -972,8 +972,7 @@ Input::read_input ()
/* Allocate Keyword and add it to the list. */ /* Allocate Keyword and add it to the list. */
Keyword *new_kw = _factory->create_keyword (keyword, keyword_length, Keyword *new_kw = _factory->create_keyword (keyword, keyword_length,
rest); rest, lineno);
new_kw->_lineno = lineno;
*list_tail = new Keyword_List (new_kw); *list_tail = new Keyword_List (new_kw);
list_tail = &(*list_tail)->rest(); list_tail = &(*list_tail)->rest();
} }

View File

@@ -2,7 +2,7 @@
/* Keyword data. /* Keyword data.
Copyright (C) 1989-1998, 2000, 2002-2003 Free Software Foundation, Inc. Copyright (C) 1989-1998, 2000, 2002-2003, 2017 Free Software Foundation, Inc.
Written by Douglas C. Schmidt <schmidt@ics.uci.edu> Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
and Bruno Haible <bruno@clisp.org>. and Bruno Haible <bruno@clisp.org>.
@@ -33,7 +33,7 @@ struct Keyword
{ {
/* Constructor. */ /* Constructor. */
Keyword (const char *allchars, int allchars_length, Keyword (const char *allchars, int allchars_length,
const char *rest); const char *rest, unsigned int lineno);
/* Data members defined immediately by the input file. */ /* Data members defined immediately by the input file. */
/* The keyword as a string, possibly containing NUL bytes. */ /* The keyword as a string, possibly containing NUL bytes. */
@@ -51,7 +51,7 @@ struct KeywordExt : public Keyword
{ {
/* Constructor. */ /* Constructor. */
KeywordExt (const char *allchars, int allchars_length, KeywordExt (const char *allchars, int allchars_length,
const char *rest); const char *rest, unsigned int lineno);
/* Data members depending on the keyposition list. */ /* Data members depending on the keyposition list. */
/* The selected characters that participate for the hash function, /* The selected characters that participate for the hash function,
@@ -97,7 +97,7 @@ public:
/* Creates a new Keyword. */ /* Creates a new Keyword. */
virtual /*abstract*/ Keyword * virtual /*abstract*/ Keyword *
create_keyword (const char *allchars, int allchars_length, create_keyword (const char *allchars, int allchars_length,
const char *rest) = 0; const char *rest, unsigned int lineno) = 0;
}; };
/* A statically allocated empty string. */ /* A statically allocated empty string. */

View File

@@ -1,6 +1,6 @@
/* Inline Functions for keyword.{h,cc}. /* Inline Functions for keyword.{h,cc}.
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc. Copyright (C) 1989-1998, 2000, 2002, 2017 Free Software Foundation, Inc.
Written by Douglas C. Schmidt <schmidt@ics.uci.edu> Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
and Bruno Haible <bruno@clisp.org>. and Bruno Haible <bruno@clisp.org>.
@@ -23,8 +23,10 @@
/* Constructor. */ /* Constructor. */
INLINE INLINE
Keyword::Keyword (const char *allchars, int allchars_length, const char *rest) Keyword::Keyword (const char *allchars, int allchars_length,
: _allchars (allchars), _allchars_length (allchars_length), _rest (rest) const char *rest, unsigned int lineno)
: _allchars (allchars), _allchars_length (allchars_length),
_rest (rest), _lineno (lineno)
{ {
} }
@@ -33,8 +35,9 @@ Keyword::Keyword (const char *allchars, int allchars_length, const char *rest)
/* Constructor. */ /* Constructor. */
INLINE INLINE
KeywordExt::KeywordExt (const char *allchars, int allchars_length, const char *rest) KeywordExt::KeywordExt (const char *allchars, int allchars_length,
: Keyword (allchars, allchars_length, rest), const char *rest, unsigned int lineno)
: Keyword (allchars, allchars_length, rest, lineno),
_final_index (-1) _final_index (-1)
{ {
} }

View File

@@ -1,5 +1,5 @@
/* Driver program for the hash function generator /* Driver program for the hash function generator
Copyright (C) 1989-1998, 2000, 2002-2003, 2009 Free Software Foundation, Inc. Copyright (C) 1989-1998, 2000, 2002-2003, 2009, 2017 Free Software Foundation, Inc.
Written by Douglas C. Schmidt <schmidt@ics.uci.edu> Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
and Bruno Haible <bruno@clisp.org>. and Bruno Haible <bruno@clisp.org>.
@@ -34,13 +34,14 @@
class KeywordExt_Factory : public Keyword_Factory class KeywordExt_Factory : public Keyword_Factory
{ {
virtual Keyword * create_keyword (const char *allchars, int allchars_length, virtual Keyword * create_keyword (const char *allchars, int allchars_length,
const char *rest); const char *rest, unsigned int lineno);
}; };
Keyword * Keyword *
KeywordExt_Factory::create_keyword (const char *allchars, int allchars_length, const char *rest) KeywordExt_Factory::create_keyword (const char *allchars, int allchars_length,
const char *rest, unsigned int lineno)
{ {
return new KeywordExt (allchars, allchars_length, rest); return new KeywordExt (allchars, allchars_length, rest, lineno);
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */