mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
* doc/gperf.texi (UPDATED): Correct to be today.
* doc: Regenerated by doing make in a configured tree. Requires makeinfo, texi2dvi, texi2pdf, and texi2html.
This commit is contained in:
284
doc/gperf.html
284
doc/gperf.html
@@ -1,13 +1,14 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Created by texi2html 1.56k from gperf.texi on 12 June 2003 -->
|
||||
<!-- This HTML file has been created by texi2html 1.52
|
||||
from gperf.texi on 13 January 2006 -->
|
||||
|
||||
<TITLE>Perfect Hash Function Generator</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H1>User's Guide to <CODE>gperf</CODE> 3.0.1</H1>
|
||||
<H1>User's Guide to <CODE>gperf</CODE> 3.0.2</H1>
|
||||
<H2>The GNU Perfect Hash Function Generator</H2>
|
||||
<H2>Edition 3.0.1, 12 June 2003</H2>
|
||||
<H2>Edition 3.0.2, 13 January 2006</H2>
|
||||
<ADDRESS>Douglas C. Schmidt</ADDRESS>
|
||||
<ADDRESS>Bruno Haible</ADDRESS>
|
||||
<P>
|
||||
@@ -20,9 +21,9 @@
|
||||
<LI><A NAME="TOC3" HREF="gperf.html#SEC3">How to Apply These Terms to Your New Programs</A>
|
||||
</UL>
|
||||
<LI><A NAME="TOC4" HREF="gperf.html#SEC4">Contributors to GNU <CODE>gperf</CODE> Utility</A>
|
||||
<LI><A NAME="TOC5" HREF="gperf.html#SEC5">1. Introduction</A>
|
||||
<LI><A NAME="TOC6" HREF="gperf.html#SEC6">2. Static search structures and GNU <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC7" HREF="gperf.html#SEC7">3. High-Level Description of GNU <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC5" HREF="gperf.html#SEC5">1 Introduction</A>
|
||||
<LI><A NAME="TOC6" HREF="gperf.html#SEC6">2 Static search structures and GNU <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC7" HREF="gperf.html#SEC7">3 High-Level Description of GNU <CODE>gperf</CODE></A>
|
||||
<UL>
|
||||
<LI><A NAME="TOC8" HREF="gperf.html#SEC8">3.1 Input Format to <CODE>gperf</CODE></A>
|
||||
<UL>
|
||||
@@ -39,7 +40,7 @@
|
||||
<LI><A NAME="TOC16" HREF="gperf.html#SEC16">3.2 Output Format for Generated C Code with <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC17" HREF="gperf.html#SEC17">3.3 Use of NUL bytes</A>
|
||||
</UL>
|
||||
<LI><A NAME="TOC18" HREF="gperf.html#SEC18">4. Invoking <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC18" HREF="gperf.html#SEC18">4 Invoking <CODE>gperf</CODE></A>
|
||||
<UL>
|
||||
<LI><A NAME="TOC19" HREF="gperf.html#SEC19">4.1 Specifying the Location of the Output File</A>
|
||||
<LI><A NAME="TOC20" HREF="gperf.html#SEC20">4.2 Options that affect Interpretation of the Input File</A>
|
||||
@@ -48,9 +49,9 @@
|
||||
<LI><A NAME="TOC23" HREF="gperf.html#SEC23">4.5 Options for changing the Algorithms employed by <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC24" HREF="gperf.html#SEC24">4.6 Informative Output</A>
|
||||
</UL>
|
||||
<LI><A NAME="TOC25" HREF="gperf.html#SEC25">5. Known Bugs and Limitations with <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC26" HREF="gperf.html#SEC26">6. Things Still Left to Do</A>
|
||||
<LI><A NAME="TOC27" HREF="gperf.html#SEC27">7. Bibliography</A>
|
||||
<LI><A NAME="TOC25" HREF="gperf.html#SEC25">5 Known Bugs and Limitations with <CODE>gperf</CODE></A>
|
||||
<LI><A NAME="TOC26" HREF="gperf.html#SEC26">6 Things Still Left to Do</A>
|
||||
<LI><A NAME="TOC27" HREF="gperf.html#SEC27">7 Bibliography</A>
|
||||
<LI><A NAME="TOC28" HREF="gperf.html#SEC28">Concept Index</A>
|
||||
</UL>
|
||||
<P><HR><P>
|
||||
@@ -61,7 +62,7 @@
|
||||
<P>
|
||||
Version 2, June 1991
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
@@ -86,7 +87,7 @@ using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
@@ -95,14 +96,14 @@ this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
@@ -110,13 +111,13 @@ you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
@@ -125,7 +126,7 @@ want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
@@ -133,16 +134,16 @@ program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<OL>
|
||||
<LI>
|
||||
@@ -411,7 +412,7 @@ POSSIBILITY OF SUCH DAMAGES.
|
||||
<P>
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H2><A NAME="SEC3" HREF="gperf.html#TOC3">How to Apply These Terms to Your New Programs</A></H2>
|
||||
@@ -421,14 +422,14 @@ END OF TERMS AND CONDITIONS
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
<VAR>one line to give the program's name and an idea of what it does.</VAR>
|
||||
@@ -452,12 +453,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
<P>
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
Gnomovision version 69, Copyright (C) <VAR>year</VAR> <VAR>name of author</VAR>
|
||||
@@ -474,13 +475,13 @@ commands you use may be called something other than <SAMP>`show w'</SAMP> and
|
||||
<SAMP>`show c'</SAMP>; they could even be mouse-clicks or menu items--whatever
|
||||
suits your program.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
Yoyodyne, Inc., hereby disclaims all copyright
|
||||
@@ -499,7 +500,7 @@ consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H1><A NAME="SEC4" HREF="gperf.html#TOC4">Contributors to GNU <CODE>gperf</CODE> Utility</A></H1>
|
||||
@@ -536,7 +537,7 @@ added a testsuite.
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC5" HREF="gperf.html#TOC5">1. Introduction</A></H1>
|
||||
<H1><A NAME="SEC5" HREF="gperf.html#TOC5">1 Introduction</A></H1>
|
||||
|
||||
<P>
|
||||
<CODE>gperf</CODE> is a perfect hash function generator written in C++. It
|
||||
@@ -549,7 +550,7 @@ pair of C functions. These functions determine whether a given
|
||||
character string <VAR>s</VAR> occurs in <VAR>W</VAR>, using at most one probe into
|
||||
the lookup table.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
<CODE>gperf</CODE> currently generates the reserved keyword recognizer for
|
||||
lexical analyzers in several production and research compilers and
|
||||
@@ -560,14 +561,14 @@ A paper describing <CODE>gperf</CODE>'s design and implementation in greater
|
||||
detail is available in the Second USENIX C++ Conference proceedings
|
||||
or from <CODE>http://www.cs.wustl.edu/~schmidt/resume.html</CODE>.
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC6" HREF="gperf.html#TOC6">2. Static search structures and GNU <CODE>gperf</CODE></A></H1>
|
||||
<H1><A NAME="SEC6" HREF="gperf.html#TOC6">2 Static search structures and GNU <CODE>gperf</CODE></A></H1>
|
||||
<P>
|
||||
<A NAME="IDX2"></A>
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
A <EM>static search structure</EM> is an Abstract Data Type with certain
|
||||
fundamental operations, e.g., <EM>initialize</EM>, <EM>insert</EM>,
|
||||
@@ -583,7 +584,7 @@ commands. Search set members, called <EM>keywords</EM>, are inserted into
|
||||
the structure only once, usually during program initialization, and are
|
||||
not generally modified at run-time.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Numerous static search structure implementations exist, e.g.,
|
||||
arrays, linked lists, binary search trees, digital search tries, and
|
||||
@@ -595,14 +596,14 @@ proportional to log <VAR>n</VAR>. Conversely, hash table implementations
|
||||
often locate a table entry in constant time, but typically impose
|
||||
additional memory overhead and exhibit poor worst case performance.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
<A NAME="IDX3"></A>
|
||||
<EM>Minimal perfect hash functions</EM> provide an optimal solution for a
|
||||
particular class of static search sets. A minimal perfect hash
|
||||
function is defined by two properties:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<UL>
|
||||
<LI>
|
||||
@@ -628,7 +629,7 @@ behavior generates <EM>near-minimal</EM> perfect hash functions for
|
||||
keyword sets. However, <CODE>gperf</CODE> provides many options that permit
|
||||
user control over the degree of minimality and perfection.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Static search sets often exhibit relative stability over time. For
|
||||
example, Ada's 63 reserved words have remained constant for nearly a
|
||||
@@ -644,10 +645,10 @@ not yet part of the official GNU distribution. Each compiler utilizes
|
||||
<CODE>gperf</CODE> to automatically generate static search structures that
|
||||
efficiently identify their respective reserved keywords.
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC7" HREF="gperf.html#TOC7">3. High-Level Description of GNU <CODE>gperf</CODE></A></H1>
|
||||
<H1><A NAME="SEC7" HREF="gperf.html#TOC7">3 High-Level Description of GNU <CODE>gperf</CODE></A></H1>
|
||||
|
||||
<P>
|
||||
The perfect hash function generator <CODE>gperf</CODE> reads a set of
|
||||
@@ -660,7 +661,7 @@ that perform hashing and table lookup recognition. All generated C code
|
||||
is directed to the standard output. Command-line options described
|
||||
below allow you to modify the input and output format to <CODE>gperf</CODE>.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
By default, <CODE>gperf</CODE> attempts to produce time-efficient code, with
|
||||
less emphasis on efficient space utilization. However, several options
|
||||
@@ -672,7 +673,7 @@ statement scheme that minimizes data space storage size. Furthermore,
|
||||
using a C <CODE>switch</CODE> may actually speed up the keyword retrieval time
|
||||
somewhat. Actual results depend on your C compiler, of course.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
In general, <CODE>gperf</CODE> assigns values to the bytes it is using
|
||||
for hashing until some set of values gives each keyword a unique value.
|
||||
@@ -680,7 +681,7 @@ A helpful heuristic is that the larger the hash value range, the easier
|
||||
it is for <CODE>gperf</CODE> to find and generate a perfect hash function.
|
||||
Experimentation is the key to getting the most from <CODE>gperf</CODE>.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H2><A NAME="SEC8" HREF="gperf.html#TOC8">3.1 Input Format to <CODE>gperf</CODE></A></H2>
|
||||
@@ -695,7 +696,7 @@ is similar to GNU utilities <CODE>flex</CODE> and <CODE>bison</CODE> (or UNIX
|
||||
utilities <CODE>lex</CODE> and <CODE>yacc</CODE>). Here's an outline of the general
|
||||
format:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
declarations
|
||||
@@ -710,13 +711,14 @@ functions
|
||||
the functions section are optional. The following sections describe the
|
||||
input format for each section.
|
||||
|
||||
</P>
|
||||
|
||||
<P>
|
||||
It is possible to omit the declaration section entirely, if the <SAMP>`-t'</SAMP>
|
||||
option is not given. In this case the input file begins directly with the
|
||||
first keyword line, e.g.:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
january
|
||||
@@ -736,6 +738,7 @@ arbitrary C declarations and definitions, <CODE>gperf</CODE> declarations that
|
||||
act like command-line options, as well as for providing a user-supplied
|
||||
<CODE>struct</CODE>.
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
|
||||
@@ -752,12 +755,12 @@ This first field must be called <SAMP>`name'</SAMP>, although it is possible to
|
||||
its name with the <SAMP>`-K'</SAMP> option (or, equivalently, the
|
||||
<SAMP>`%define slot-name'</SAMP> declaration) described below.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Here is a simple example, using months of the year and their attributes as
|
||||
input:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
struct month { char *name; int number; int days; int leap_days; };
|
||||
@@ -783,12 +786,12 @@ other fields are a pair of consecutive percent signs, <SAMP>`%%'</SAMP>,
|
||||
appearing left justified in the first column, as in the UNIX utility
|
||||
<CODE>lex</CODE>.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
If the <CODE>struct</CODE> has already been declared in an include file, it can
|
||||
be mentioned in an abbreviated form, like this:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
struct month;
|
||||
@@ -807,7 +810,7 @@ influence the way <CODE>gperf</CODE> works, like command line options do.
|
||||
In fact, every such declaration is equivalent to a command line option.
|
||||
There are three forms of declarations:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<OL>
|
||||
<LI>
|
||||
@@ -828,11 +831,11 @@ Declarations of names of entities in the output file, like
|
||||
When a declaration is given both in the input file and as a command line
|
||||
option, the command-line option's value prevails.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
The following <CODE>gperf</CODE> declarations are available.
|
||||
|
||||
|
||||
</P>
|
||||
<DL COMPACT>
|
||||
|
||||
<DT><SAMP>`%delimiters=<VAR>delimiter-list</VAR>'</SAMP>
|
||||
@@ -1024,9 +1027,17 @@ hash table. Default name is <SAMP>`wordlist'</SAMP>. This option permits the
|
||||
use of two hash tables in the same file, even when the option <SAMP>`-G'</SAMP>
|
||||
(or, equivalently, the <SAMP>`%global-table'</SAMP> declaration) is given.
|
||||
|
||||
<DT><SAMP>`%switch=<VAR>count</VAR>'</SAMP>
|
||||
<DT><SAMP>`%define length-table-name <VAR>name</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX29"></A>
|
||||
Allows you to specify the name for the generated array containing the
|
||||
length table. Default name is <SAMP>`lengthtable'</SAMP>. This option permits the
|
||||
use of two length tables in the same file, even when the option <SAMP>`-G'</SAMP>
|
||||
(or, equivalently, the <SAMP>`%global-table'</SAMP> declaration) is given.
|
||||
|
||||
<DT><SAMP>`%switch=<VAR>count</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX30"></A>
|
||||
Causes the generated C code to use a <CODE>switch</CODE> statement scheme,
|
||||
rather than an array lookup table. This can lead to a reduction in both
|
||||
time and space requirements for some input files. The argument to this
|
||||
@@ -1039,7 +1050,7 @@ was inspired in part by Keith Bostic's original C program.
|
||||
|
||||
<DT><SAMP>`%omit-struct-type'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX30"></A>
|
||||
<A NAME="IDX31"></A>
|
||||
Prevents the transfer of the type declaration to the output file. Use
|
||||
this option if the type is already defined elsewhere.
|
||||
</DL>
|
||||
@@ -1049,8 +1060,8 @@ this option if the type is already defined elsewhere.
|
||||
<H4><A NAME="SEC12" HREF="gperf.html#TOC12">3.1.1.3 C Code Inclusion</A></H4>
|
||||
|
||||
<P>
|
||||
<A NAME="IDX31"></A>
|
||||
<A NAME="IDX32"></A>
|
||||
<A NAME="IDX33"></A>
|
||||
Using a syntax similar to GNU utilities <CODE>flex</CODE> and <CODE>bison</CODE>, it
|
||||
is possible to directly include C source text and comments verbatim into
|
||||
the generated output file. This is accomplished by enclosing the region
|
||||
@@ -1058,7 +1069,7 @@ inside left-justified surrounding <SAMP>`%{'</SAMP>, <SAMP>`%}'</SAMP> pairs. H
|
||||
an input fragment based on the previous example that illustrates this
|
||||
feature:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
%{
|
||||
@@ -1086,7 +1097,7 @@ in the first column is considered a comment. Everything following the
|
||||
beginning with <SAMP>`%'</SAMP> in the first column is an option declaration and
|
||||
must not occur within the keywords section.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
The first field of each non-comment line is always the keyword itself. It
|
||||
can be given in two ways: as a simple name, i.e., without surrounding
|
||||
@@ -1098,7 +1109,7 @@ In this context, a "field" is considered to extend up to, but
|
||||
not include, the first blank, comma, or newline. Here is a simple
|
||||
example taken from a partial list of C reserved words:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
# These are a few C reserved words, see the c.gperf file
|
||||
@@ -1118,7 +1129,7 @@ return
|
||||
Note that unlike <CODE>flex</CODE> or <CODE>bison</CODE> the first <SAMP>`%%'</SAMP> marker
|
||||
may be elided if the declaration section is empty.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Additional fields may optionally follow the leading keyword. Fields
|
||||
should be separated by commas, and terminate at the end of line. What
|
||||
@@ -1129,7 +1140,7 @@ declaration section. If the <SAMP>`-t'</SAMP> option (or, equivalently, the
|
||||
these fields are simply ignored. All previous examples except the last
|
||||
one contain keyword attributes.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H3><A NAME="SEC14" HREF="gperf.html#TOC14">3.1.3 Including Additional C Functions</A></H3>
|
||||
@@ -1142,7 +1153,7 @@ file, is included verbatim into the generated output file. Naturally,
|
||||
it is your responsibility to ensure that the code contained in this
|
||||
section is valid C.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H3><A NAME="SEC15" HREF="gperf.html#TOC15">3.1.4 Where to place directives for GNU <CODE>indent</CODE>.</A></H3>
|
||||
@@ -1155,7 +1166,7 @@ interpretation of the input file. Therefore you have to insert some
|
||||
directives for GNU <CODE>indent</CODE>. More precisely, assuming the most
|
||||
general input file structure
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
declarations part 1
|
||||
@@ -1173,7 +1184,7 @@ functions
|
||||
you would insert <SAMP>`*INDENT-OFF*'</SAMP> and <SAMP>`*INDENT-ON*'</SAMP> comments
|
||||
as follows:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
/* *INDENT-OFF* */
|
||||
@@ -1195,9 +1206,9 @@ functions
|
||||
|
||||
<H2><A NAME="SEC16" HREF="gperf.html#TOC16">3.2 Output Format for Generated C Code with <CODE>gperf</CODE></A></H2>
|
||||
<P>
|
||||
<A NAME="IDX33"></A>
|
||||
|
||||
<A NAME="IDX34"></A>
|
||||
|
||||
</P>
|
||||
<P>
|
||||
Several options control how the generated C code appears on the standard
|
||||
output. Two C function are generated. They are called <CODE>hash</CODE> and
|
||||
@@ -1206,11 +1217,11 @@ option. Both functions require two arguments, a string, <CODE>char *</CODE>
|
||||
<VAR>str</VAR>, and a length parameter, <CODE>int</CODE> <VAR>len</VAR>. Their default
|
||||
function prototypes are as follows:
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
<DL>
|
||||
<DT><U>Function:</U> unsigned int <B>hash</B> <I>(const char * <VAR>str</VAR>, unsigned int <VAR>len</VAR>)</I>
|
||||
<DD><A NAME="IDX34"></A>
|
||||
<DD><A NAME="IDX35"></A>
|
||||
By default, the generated <CODE>hash</CODE> function returns an integer value
|
||||
created by adding <VAR>len</VAR> to several user-specified <VAR>str</VAR> byte
|
||||
positions indexed into an <EM>associated values</EM> table stored in a
|
||||
@@ -1218,14 +1229,14 @@ local static array. The associated values table is constructed
|
||||
internally by <CODE>gperf</CODE> and later output as a static local C array
|
||||
called <SAMP>`hash_table'</SAMP>. The relevant selected positions (i.e. indices
|
||||
into <VAR>str</VAR>) are specified via the <SAMP>`-k'</SAMP> option when running
|
||||
<CODE>gperf</CODE>, as detailed in the <EM>Options</EM> section below (see section <A HREF="gperf.html#SEC18">4. Invoking <CODE>gperf</CODE></A>).
|
||||
<CODE>gperf</CODE>, as detailed in the <EM>Options</EM> section below (see section <A HREF="gperf.html#SEC18">4 Invoking <CODE>gperf</CODE></A>).
|
||||
</DL>
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
<DL>
|
||||
<DT><U>Function:</U> <B>in_word_set</B> <I>(const char * <VAR>str</VAR>, unsigned int <VAR>len</VAR>)</I>
|
||||
<DD><A NAME="IDX35"></A>
|
||||
<DD><A NAME="IDX36"></A>
|
||||
If <VAR>str</VAR> is in the keyword set, returns a pointer to that
|
||||
keyword. More exactly, if the option <SAMP>`-t'</SAMP> (or, equivalently, the
|
||||
<SAMP>`%struct-type'</SAMP> declaration) was given, it returns
|
||||
@@ -1233,7 +1244,7 @@ a pointer to the matching keyword's structure. Otherwise it returns
|
||||
<CODE>NULL</CODE>.
|
||||
</DL>
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
If the option <SAMP>`-c'</SAMP> (or, equivalently, the <SAMP>`%compare-strncmp'</SAMP>
|
||||
declaration) is not used, <VAR>str</VAR> must be a NUL terminated
|
||||
@@ -1242,12 +1253,12 @@ string of exactly length <VAR>len</VAR>. If <SAMP>`-c'</SAMP> (or, equivalently
|
||||
simply be an array of <VAR>len</VAR> bytes and does not need to be NUL
|
||||
terminated.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
The code generated for these two functions is affected by the following
|
||||
options:
|
||||
|
||||
|
||||
</P>
|
||||
<DL COMPACT>
|
||||
|
||||
<DT><SAMP>`-t'</SAMP>
|
||||
@@ -1260,7 +1271,7 @@ Make use of the user-defined <CODE>struct</CODE>.
|
||||
<DD>
|
||||
<DT><SAMP>`--switch=<VAR>total-switch-statements</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX36"></A>
|
||||
<A NAME="IDX37"></A>
|
||||
Generate 1 or more C <CODE>switch</CODE> statement rather than use a large,
|
||||
(and potentially sparse) static array. Although the exact time and
|
||||
space savings of this approach vary according to your C compiler's
|
||||
@@ -1278,14 +1289,14 @@ with the various input and output options, and timing the resulting C
|
||||
code, you can determine the best option choices for different keyword
|
||||
set characteristics.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H2><A NAME="SEC17" HREF="gperf.html#TOC17">3.3 Use of NUL bytes</A></H2>
|
||||
<P>
|
||||
<A NAME="IDX37"></A>
|
||||
|
||||
<A NAME="IDX38"></A>
|
||||
|
||||
</P>
|
||||
<P>
|
||||
By default, the code generated by <CODE>gperf</CODE> operates on zero
|
||||
terminated strings, the usual representation of strings in C. This means
|
||||
@@ -1293,7 +1304,7 @@ that the keywords in the input file must not contain NUL bytes,
|
||||
and the <VAR>str</VAR> argument passed to <CODE>hash</CODE> or <CODE>in_word_set</CODE>
|
||||
must be NUL terminated and have exactly length <VAR>len</VAR>.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
If option <SAMP>`-c'</SAMP> (or, equivalently, the <SAMP>`%compare-strncmp'</SAMP>
|
||||
declaration) is used, then the <VAR>str</VAR> argument does not need
|
||||
@@ -1302,7 +1313,7 @@ access the first <VAR>len</VAR>, not <VAR>len+1</VAR>, bytes starting at <VAR>st
|
||||
However, the keywords in the input file still must not contain NUL
|
||||
bytes.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
If option <SAMP>`-l'</SAMP> (or, equivalently, the <SAMP>`%compare-lengths'</SAMP>
|
||||
declaration) is used, then the hash table performs binary
|
||||
@@ -1312,10 +1323,10 @@ generated by <CODE>gperf</CODE> will treat NUL like any other byte.
|
||||
Also, in this case the <SAMP>`-c'</SAMP> option (or, equivalently, the
|
||||
<SAMP>`%compare-strncmp'</SAMP> declaration) is ignored.
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC18" HREF="gperf.html#TOC18">4. Invoking <CODE>gperf</CODE></A></H1>
|
||||
<H1><A NAME="SEC18" HREF="gperf.html#TOC18">4 Invoking <CODE>gperf</CODE></A></H1>
|
||||
|
||||
<P>
|
||||
There are <EM>many</EM> options to <CODE>gperf</CODE>. They were added to make
|
||||
@@ -1323,6 +1334,7 @@ the program more convenient for use with real applications. "On-line"
|
||||
help is readily available via the <SAMP>`--help'</SAMP> option. Here is the
|
||||
complete list of options.
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
|
||||
@@ -1339,7 +1351,7 @@ Allows you to specify the name of the file to which the output is written to.
|
||||
The results are written to standard output if no output file is specified
|
||||
or if it is <SAMP>`-'</SAMP>.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H2><A NAME="SEC20" HREF="gperf.html#TOC20">4.2 Options that affect Interpretation of the Input File</A></H2>
|
||||
@@ -1348,14 +1360,14 @@ or if it is <SAMP>`-'</SAMP>.
|
||||
These options are also available as declarations in the input file
|
||||
(see section <A HREF="gperf.html#SEC11">3.1.1.2 Gperf Declarations</A>).
|
||||
|
||||
|
||||
</P>
|
||||
<DL COMPACT>
|
||||
|
||||
<DT><SAMP>`-e <VAR>keyword-delimiter-list</VAR>'</SAMP>
|
||||
<DD>
|
||||
<DT><SAMP>`--delimiters=<VAR>keyword-delimiter-list</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX38"></A>
|
||||
<A NAME="IDX39"></A>
|
||||
Allows you to provide a string containing delimiters used to
|
||||
separate keywords from their attributes. The default is ",". This
|
||||
option is essential if you want to use keywords that have embedded
|
||||
@@ -1394,7 +1406,7 @@ the <CODE>gperf</CODE> generated function.
|
||||
These options are also available as declarations in the input file
|
||||
(see section <A HREF="gperf.html#SEC11">3.1.1.2 Gperf Declarations</A>).
|
||||
|
||||
|
||||
</P>
|
||||
<DL COMPACT>
|
||||
|
||||
<DT><SAMP>`-L <VAR>generated-language-name</VAR>'</SAMP>
|
||||
@@ -1448,14 +1460,14 @@ This option is supported for compatibility with previous releases of
|
||||
Most of these options are also available as declarations in the input file
|
||||
(see section <A HREF="gperf.html#SEC11">3.1.1.2 Gperf Declarations</A>).
|
||||
|
||||
|
||||
</P>
|
||||
<DL COMPACT>
|
||||
|
||||
<DT><SAMP>`-K <VAR>slot-name</VAR>'</SAMP>
|
||||
<DD>
|
||||
<DT><SAMP>`--slot-name=<VAR>slot-name</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX39"></A>
|
||||
<A NAME="IDX40"></A>
|
||||
This option is only useful when option <SAMP>`-t'</SAMP> (or, equivalently, the
|
||||
<SAMP>`%struct-type'</SAMP> declaration) has been given.
|
||||
By default, the program assumes the structure component identifier for
|
||||
@@ -1467,7 +1479,7 @@ field in your supplied <CODE>struct</CODE>.
|
||||
<DD>
|
||||
<DT><SAMP>`--initializer-suffix=<VAR>initializers</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX40"></A>
|
||||
<A NAME="IDX41"></A>
|
||||
This option is only useful when option <SAMP>`-t'</SAMP> (or, equivalently, the
|
||||
<SAMP>`%struct-type'</SAMP> declaration) has been given.
|
||||
It permits to specify initializers for the structure members following
|
||||
@@ -1495,7 +1507,7 @@ generated hash functions to be used in the same application.
|
||||
<DD>
|
||||
<DT><SAMP>`--class-name=<VAR>class-name</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX41"></A>
|
||||
<A NAME="IDX42"></A>
|
||||
This option is only useful when option <SAMP>`-L C++'</SAMP> (or, equivalently,
|
||||
the <SAMP>`%language=C++'</SAMP> declaration) has been given. It
|
||||
allows you to specify the name of generated C++ class. Default name is
|
||||
@@ -1601,17 +1613,25 @@ of one more test-and-branch instruction at run time.
|
||||
<DD>
|
||||
<DT><SAMP>`--word-array-name=<VAR>hash-table-array-name</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX42"></A>
|
||||
<A NAME="IDX43"></A>
|
||||
Allows you to specify the name for the generated array containing the
|
||||
hash table. Default name is <SAMP>`wordlist'</SAMP>. This option permits the
|
||||
use of two hash tables in the same file, even when the option <SAMP>`-G'</SAMP>
|
||||
(or, equivalently, the <SAMP>`%global-table'</SAMP> declaration) is given.
|
||||
|
||||
<DT><SAMP>`--length-table-name=<VAR>length-table-array-name</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX44"></A>
|
||||
Allows you to specify the name for the generated array containing the
|
||||
length table. Default name is <SAMP>`lengthtable'</SAMP>. This option permits the
|
||||
use of two length tables in the same file, even when the option <SAMP>`-G'</SAMP>
|
||||
(or, equivalently, the <SAMP>`%global-table'</SAMP> declaration) is given.
|
||||
|
||||
<DT><SAMP>`-S <VAR>total-switch-statements</VAR>'</SAMP>
|
||||
<DD>
|
||||
<DT><SAMP>`--switch=<VAR>total-switch-statements</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX43"></A>
|
||||
<A NAME="IDX45"></A>
|
||||
Causes the generated C code to use a <CODE>switch</CODE> statement scheme,
|
||||
rather than an array lookup table. This can lead to a reduction in both
|
||||
time and space requirements for some input files. The argument to this
|
||||
@@ -1671,7 +1691,7 @@ through a search that minimizes the number of byte positions.
|
||||
<DD>
|
||||
<DT><SAMP>`--duplicates'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX44"></A>
|
||||
<A NAME="IDX46"></A>
|
||||
Handle keywords whose selected byte sets hash to duplicate values.
|
||||
Duplicate hash values can occur if a set of keywords has the same names, but
|
||||
possesses different attributes, or if the selected byte positions are not well
|
||||
@@ -1708,7 +1728,7 @@ option is not particularly useful when <SAMP>`-S'</SAMP> (or, equivalently,
|
||||
<DD>
|
||||
<DT><SAMP>`--jump=<VAR>jump-value</VAR>'</SAMP>
|
||||
<DD>
|
||||
<A NAME="IDX45"></A>
|
||||
<A NAME="IDX47"></A>
|
||||
Affects the "jump value", i.e., how far to advance the associated
|
||||
byte value upon collisions. <VAR>Jump-value</VAR> is rounded up to an
|
||||
odd number, the default is 5. If the <VAR>jump-value</VAR> is 0 <CODE>gperf</CODE>
|
||||
@@ -1793,13 +1813,13 @@ option is enabled.
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC25" HREF="gperf.html#TOC25">5. Known Bugs and Limitations with <CODE>gperf</CODE></A></H1>
|
||||
<H1><A NAME="SEC25" HREF="gperf.html#TOC25">5 Known Bugs and Limitations with <CODE>gperf</CODE></A></H1>
|
||||
|
||||
<P>
|
||||
The following are some limitations with the current release of
|
||||
<CODE>gperf</CODE>:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<UL>
|
||||
<LI>
|
||||
@@ -1835,7 +1855,7 @@ the constraint.
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC26" HREF="gperf.html#TOC26">6. Things Still Left to Do</A></H1>
|
||||
<H1><A NAME="SEC26" HREF="gperf.html#TOC26">6 Things Still Left to Do</A></H1>
|
||||
|
||||
<P>
|
||||
It should be "relatively" easy to replace the current perfect hash
|
||||
@@ -1843,7 +1863,7 @@ function algorithm with a more exhaustive approach; the perfect hash
|
||||
module is essential independent from other program modules. Additional
|
||||
worthwhile improvements include:
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
<UL>
|
||||
<LI>
|
||||
@@ -1866,85 +1886,85 @@ C and C++ routines.
|
||||
|
||||
|
||||
|
||||
<H1><A NAME="SEC27" HREF="gperf.html#TOC27">7. Bibliography</A></H1>
|
||||
<H1><A NAME="SEC27" HREF="gperf.html#TOC27">7 Bibliography</A></H1>
|
||||
|
||||
<P>
|
||||
[1] Chang, C.C.: <I>A Scheme for Constructing Ordered Minimal Perfect
|
||||
Hashing Functions</I> Information Sciences 39(1986), 187-195.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[2] Cichelli, Richard J. <I>Author's Response to "On Cichelli's Minimal Perfect Hash
|
||||
Functions Method"</I> Communications of the ACM, 23, 12(December 1980), 729.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[3] Cichelli, Richard J. <I>Minimal Perfect Hash Functions Made Simple</I>
|
||||
Communications of the ACM, 23, 1(January 1980), 17-19.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[4] Cook, C. R. and Oldehoeft, R.R. <I>A Letter Oriented Minimal
|
||||
Perfect Hashing Function</I> SIGPLAN Notices, 17, 9(September 1982), 18-27.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[5] Cormack, G. V. and Horspool, R. N. S. and Kaiserwerth, M.
|
||||
<I>Practical Perfect Hashing</I> Computer Journal, 28, 1(January 1985), 54-58.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[6] Jaeschke, G. <I>Reciprocal Hashing: A Method for Generating Minimal
|
||||
Perfect Hashing Functions</I> Communications of the ACM, 24, 12(December
|
||||
1981), 829-833.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[7] Jaeschke, G. and Osterburg, G. <I>On Cichelli's Minimal Perfect
|
||||
Hash Functions Method</I> Communications of the ACM, 23, 12(December 1980),
|
||||
728-729.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[8] Sager, Thomas J. <I>A Polynomial Time Generator for Minimal Perfect
|
||||
Hash Functions</I> Communications of the ACM, 28, 5(December 1985), 523-532
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[9] Schmidt, Douglas C. <I>GPERF: A Perfect Hash Function Generator</I>
|
||||
Second USENIX C++ Conference Proceedings, April 1990.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[10] Schmidt, Douglas C. <I>GPERF: A Perfect Hash Function Generator</I>
|
||||
C++ Report, SIGS 10 10 (November/December 1998).
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[11] Sebesta, R.W. and Taylor, M.A. <I>Minimal Perfect Hash Functions
|
||||
for Reserved Word Lists</I> SIGPLAN Notices, 20, 12(September 1985), 47-53.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[12] Sprugnoli, R. <I>Perfect Hashing Functions: A Single Probe
|
||||
Retrieving Method for Static Sets</I> Communications of the ACM, 20
|
||||
11(November 1977), 841-850.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[13] Stallman, Richard M. <I>Using and Porting GNU CC</I> Free Software Foundation,
|
||||
1988.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[14] Stroustrup, Bjarne <I>The C++ Programming Language.</I> Addison-Wesley, 1986.
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
[15] Tiemann, Michael D. <I>User's Guide to GNU C++</I> Free Software
|
||||
Foundation, 1989.
|
||||
|
||||
|
||||
</P>
|
||||
|
||||
|
||||
<H1><A NAME="SEC28" HREF="gperf.html#TOC28">Concept Index</A></H1>
|
||||
@@ -1986,6 +2006,7 @@ Jump to:
|
||||
<LI><A HREF="gperf.html#IDX17"><SAMP>`%define class-name'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX15"><SAMP>`%define hash-function-name'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX14"><SAMP>`%define initializer-suffix'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX29"><SAMP>`%define length-table-name'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX16"><SAMP>`%define lookup-function-name'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX13"><SAMP>`%define slot-name'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX26"><SAMP>`%define string-pool-name'</SAMP></A>
|
||||
@@ -1997,17 +2018,17 @@ Jump to:
|
||||
<LI><A HREF="gperf.html#IDX23"><SAMP>`%includes'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX12"><SAMP>`%language'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX27"><SAMP>`%null-strings'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX30"><SAMP>`%omit-struct-type'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX31"><SAMP>`%omit-struct-type'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX25"><SAMP>`%pic'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX21"><SAMP>`%readonly-tables'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX10"><SAMP>`%struct-type'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX29"><SAMP>`%switch'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX31"><SAMP>`%{'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX32"><SAMP>`%}'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX30"><SAMP>`%switch'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX32"><SAMP>`%{'</SAMP></A>
|
||||
<LI><A HREF="gperf.html#IDX33"><SAMP>`%}'</SAMP></A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_a">a</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX42">Array name</A>
|
||||
<LI><A HREF="gperf.html#IDX43">Array name</A>, <A HREF="gperf.html#IDX44">Array name</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_b">b</A></H2>
|
||||
<DIR>
|
||||
@@ -2015,13 +2036,13 @@ Jump to:
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_c">c</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX41">Class name</A>
|
||||
<LI><A HREF="gperf.html#IDX42">Class name</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_d">d</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX5">Declaration section</A>
|
||||
<LI><A HREF="gperf.html#IDX38">Delimiters</A>
|
||||
<LI><A HREF="gperf.html#IDX44">Duplicates</A>
|
||||
<LI><A HREF="gperf.html#IDX39">Delimiters</A>
|
||||
<LI><A HREF="gperf.html#IDX46">Duplicates</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_f">f</A></H2>
|
||||
<DIR>
|
||||
@@ -2030,17 +2051,17 @@ Jump to:
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_h">h</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX34">hash</A>
|
||||
<LI><A HREF="gperf.html#IDX33">hash table</A>
|
||||
<LI><A HREF="gperf.html#IDX35">hash</A>
|
||||
<LI><A HREF="gperf.html#IDX34">hash table</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_i">i</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX35">in_word_set</A>
|
||||
<LI><A HREF="gperf.html#IDX40">Initializers</A>
|
||||
<LI><A HREF="gperf.html#IDX36">in_word_set</A>
|
||||
<LI><A HREF="gperf.html#IDX41">Initializers</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_j">j</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX45">Jump value</A>
|
||||
<LI><A HREF="gperf.html#IDX47">Jump value</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_k">k</A></H2>
|
||||
<DIR>
|
||||
@@ -2052,18 +2073,19 @@ Jump to:
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_n">n</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX37">NUL</A>
|
||||
<LI><A HREF="gperf.html#IDX38">NUL</A>
|
||||
</DIR>
|
||||
<H2><A NAME="cindex_s">s</A></H2>
|
||||
<DIR>
|
||||
<LI><A HREF="gperf.html#IDX39">Slot name</A>
|
||||
<LI><A HREF="gperf.html#IDX40">Slot name</A>
|
||||
<LI><A HREF="gperf.html#IDX2">Static search structure</A>
|
||||
<LI><A HREF="gperf.html#IDX36"><CODE>switch</CODE></A>, <A HREF="gperf.html#IDX43"><CODE>switch</CODE></A>
|
||||
<LI><A HREF="gperf.html#IDX37"><CODE>switch</CODE></A>, <A HREF="gperf.html#IDX45"><CODE>switch</CODE></A>
|
||||
</DIR>
|
||||
|
||||
|
||||
</P>
|
||||
<P><HR><P>
|
||||
This document was generated on 12 June 2003 using
|
||||
<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A> 1.56k.
|
||||
This document was generated on 13 January 2006 using the
|
||||
<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A>
|
||||
translator version 1.52.</P>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
340
doc/gperf.info
340
doc/gperf.info
@@ -1,5 +1,4 @@
|
||||
Dies ist gperf.info, hergestellt von Makeinfo Version 4.3 aus
|
||||
gperf.texi.
|
||||
This is gperf.info, produced by makeinfo version 4.8 from gperf.texi.
|
||||
|
||||
INFO-DIR-SECTION Programming Tools
|
||||
START-INFO-DIR-ENTRY
|
||||
@@ -7,9 +6,9 @@ START-INFO-DIR-ENTRY
|
||||
END-INFO-DIR-ENTRY
|
||||
|
||||
This file documents the features of the GNU Perfect Hash Function
|
||||
Generator 3.0.1.
|
||||
Generator 3.0.2.
|
||||
|
||||
Copyright (C) 1989-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-2004 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
|
||||
@@ -34,7 +33,7 @@ File: gperf.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir)
|
||||
Introduction
|
||||
************
|
||||
|
||||
This manual documents the GNU `gperf' perfect hash function generator
|
||||
This manual documents the GNU `gperf' perfect hash function generator
|
||||
utility, focusing on its features and how to use them, and how to report
|
||||
bugs.
|
||||
|
||||
@@ -88,6 +87,7 @@ GNU GENERAL PUBLIC LICENSE
|
||||
**************************
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
@@ -97,9 +97,9 @@ GNU GENERAL PUBLIC LICENSE
|
||||
Preamble
|
||||
========
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
The licenses for most software are designed to take away your freedom
|
||||
to share and change it. By contrast, the GNU General Public License is
|
||||
intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
@@ -352,7 +352,6 @@ modification follow.
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
|
||||
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
@@ -376,11 +375,10 @@ modification follow.
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
=============================================
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
@@ -473,10 +471,10 @@ Contributors to GNU `gperf' Utility
|
||||
|
||||
File: gperf.info, Node: Motivation, Next: Search Structures, Prev: Contributors, Up: Top
|
||||
|
||||
Introduction
|
||||
************
|
||||
1 Introduction
|
||||
**************
|
||||
|
||||
`gperf' is a perfect hash function generator written in C++. It
|
||||
`gperf' is a perfect hash function generator written in C++. It
|
||||
transforms an N element user-specified keyword set W into a perfect
|
||||
hash function F. F uniquely maps keywords in W onto the range 0..K,
|
||||
where K >= N-1. If K = N-1 then F is a _minimal_ perfect hash function.
|
||||
@@ -496,10 +494,10 @@ available in the Second USENIX C++ Conference proceedings or from
|
||||
|
||||
File: gperf.info, Node: Search Structures, Next: Description, Prev: Motivation, Up: Top
|
||||
|
||||
Static search structures and GNU `gperf'
|
||||
****************************************
|
||||
2 Static search structures and GNU `gperf'
|
||||
******************************************
|
||||
|
||||
A "static search structure" is an Abstract Data Type with certain
|
||||
A "static search structure" is an Abstract Data Type with certain
|
||||
fundamental operations, e.g., _initialize_, _insert_, and _retrieve_.
|
||||
Conceptually, all insertions occur before any retrievals. In practice,
|
||||
`gperf' generates a _static_ array containing search set keywords and
|
||||
@@ -562,8 +560,8 @@ efficiently identify their respective reserved keywords.
|
||||
|
||||
File: gperf.info, Node: Description, Next: Options, Prev: Search Structures, Up: Top
|
||||
|
||||
High-Level Description of GNU `gperf'
|
||||
*************************************
|
||||
3 High-Level Description of GNU `gperf'
|
||||
***************************************
|
||||
|
||||
* Menu:
|
||||
|
||||
@@ -600,10 +598,10 @@ Experimentation is the key to getting the most from `gperf'.
|
||||
|
||||
File: gperf.info, Node: Input Format, Next: Output Format, Prev: Description, Up: Description
|
||||
|
||||
Input Format to `gperf'
|
||||
=======================
|
||||
3.1 Input Format to `gperf'
|
||||
===========================
|
||||
|
||||
You can control the input file format by varying certain command-line
|
||||
You can control the input file format by varying certain command-line
|
||||
arguments, in particular the `-t' option. The input's appearance is
|
||||
similar to GNU utilities `flex' and `bison' (or UNIX utilities `lex'
|
||||
and `yacc'). Here's an outline of the general format:
|
||||
@@ -638,10 +636,10 @@ the first keyword line, e.g.:
|
||||
|
||||
File: gperf.info, Node: Declarations, Next: Keywords, Prev: Input Format, Up: Input Format
|
||||
|
||||
Declarations
|
||||
------------
|
||||
3.1.1 Declarations
|
||||
------------------
|
||||
|
||||
The keyword input file optionally contains a section for including
|
||||
The keyword input file optionally contains a section for including
|
||||
arbitrary C declarations and definitions, `gperf' declarations that act
|
||||
like command-line options, as well as for providing a user-supplied
|
||||
`struct'.
|
||||
@@ -655,10 +653,10 @@ like command-line options, as well as for providing a user-supplied
|
||||
|
||||
File: gperf.info, Node: User-supplied Struct, Next: Gperf Declarations, Prev: Declarations, Up: Declarations
|
||||
|
||||
User-supplied `struct'
|
||||
......................
|
||||
3.1.1.1 User-supplied `struct'
|
||||
..............................
|
||||
|
||||
If the `-t' option (or, equivalently, the `%struct-type' declaration)
|
||||
If the `-t' option (or, equivalently, the `%struct-type' declaration)
|
||||
_is_ enabled, you _must_ provide a C `struct' as the last component in
|
||||
the declaration section from the input file. The first field in this
|
||||
struct must be of type `char *' or `const char *' if the `-P' option is
|
||||
@@ -700,10 +698,10 @@ be mentioned in an abbreviated form, like this:
|
||||
|
||||
File: gperf.info, Node: Gperf Declarations, Next: C Code Inclusion, Prev: User-supplied Struct, Up: Declarations
|
||||
|
||||
Gperf Declarations
|
||||
..................
|
||||
3.1.1.2 Gperf Declarations
|
||||
..........................
|
||||
|
||||
The declaration section can contain `gperf' declarations. They
|
||||
The declaration section can contain `gperf' declarations. They
|
||||
influence the way `gperf' works, like command line options do. In
|
||||
fact, every such declaration is equivalent to a command line option.
|
||||
There are three forms of declarations:
|
||||
@@ -869,6 +867,13 @@ line option, the command-line option's value prevails.
|
||||
the use of two hash tables in the same file, even when the option
|
||||
`-G' (or, equivalently, the `%global-table' declaration) is given.
|
||||
|
||||
`%define length-table-name NAME'
|
||||
Allows you to specify the name for the generated array containing
|
||||
the length table. Default name is `lengthtable'. This option
|
||||
permits the use of two length tables in the same file, even when
|
||||
the option `-G' (or, equivalently, the `%global-table'
|
||||
declaration) is given.
|
||||
|
||||
`%switch=COUNT'
|
||||
Causes the generated C code to use a `switch' statement scheme,
|
||||
rather than an array lookup table. This can lead to a reduction
|
||||
@@ -888,10 +893,10 @@ line option, the command-line option's value prevails.
|
||||
|
||||
File: gperf.info, Node: C Code Inclusion, Prev: Gperf Declarations, Up: Declarations
|
||||
|
||||
C Code Inclusion
|
||||
................
|
||||
3.1.1.3 C Code Inclusion
|
||||
........................
|
||||
|
||||
Using a syntax similar to GNU utilities `flex' and `bison', it is
|
||||
Using a syntax similar to GNU utilities `flex' and `bison', it is
|
||||
possible to directly include C source text and comments verbatim into
|
||||
the generated output file. This is accomplished by enclosing the region
|
||||
inside left-justified surrounding `%{', `%}' pairs. Here is an input
|
||||
@@ -912,13 +917,13 @@ fragment based on the previous example that illustrates this feature:
|
||||
|
||||
File: gperf.info, Node: Keywords, Next: Functions, Prev: Declarations, Up: Input Format
|
||||
|
||||
Format for Keyword Entries
|
||||
--------------------------
|
||||
3.1.2 Format for Keyword Entries
|
||||
--------------------------------
|
||||
|
||||
The second input file format section contains lines of keywords and
|
||||
any associated attributes you might supply. A line beginning with `#'
|
||||
in the first column is considered a comment. Everything following the
|
||||
`#' is ignored, up to and including the following newline. A line
|
||||
The second input file format section contains lines of keywords and any
|
||||
associated attributes you might supply. A line beginning with `#' in
|
||||
the first column is considered a comment. Everything following the `#'
|
||||
is ignored, up to and including the following newline. A line
|
||||
beginning with `%' in the first column is an option declaration and
|
||||
must not occur within the keywords section.
|
||||
|
||||
@@ -959,10 +964,10 @@ attributes.
|
||||
|
||||
File: gperf.info, Node: Functions, Next: Controls for GNU indent, Prev: Keywords, Up: Input Format
|
||||
|
||||
Including Additional C Functions
|
||||
--------------------------------
|
||||
3.1.3 Including Additional C Functions
|
||||
--------------------------------------
|
||||
|
||||
The optional third section also corresponds closely with conventions
|
||||
The optional third section also corresponds closely with conventions
|
||||
found in `flex' and `bison'. All text in this section, starting at the
|
||||
final `%%' and extending to the end of the input file, is included
|
||||
verbatim into the generated output file. Naturally, it is your
|
||||
@@ -972,10 +977,10 @@ valid C.
|
||||
|
||||
File: gperf.info, Node: Controls for GNU indent, Prev: Functions, Up: Input Format
|
||||
|
||||
Where to place directives for GNU `indent'.
|
||||
-------------------------------------------
|
||||
3.1.4 Where to place directives for GNU `indent'.
|
||||
-------------------------------------------------
|
||||
|
||||
If you want to invoke GNU `indent' on a `gperf' input file, you will
|
||||
If you want to invoke GNU `indent' on a `gperf' input file, you will
|
||||
see that GNU `indent' doesn't understand the `%%', `%{' and `%}'
|
||||
directives that control `gperf''s interpretation of the input file.
|
||||
Therefore you have to insert some directives for GNU `indent'. More
|
||||
@@ -1010,17 +1015,17 @@ you would insert `*INDENT-OFF*' and `*INDENT-ON*' comments as follows:
|
||||
|
||||
File: gperf.info, Node: Output Format, Next: Binary Strings, Prev: Input Format, Up: Description
|
||||
|
||||
Output Format for Generated C Code with `gperf'
|
||||
===============================================
|
||||
3.2 Output Format for Generated C Code with `gperf'
|
||||
===================================================
|
||||
|
||||
Several options control how the generated C code appears on the
|
||||
standard output. Two C function are generated. They are called `hash'
|
||||
and `in_word_set', although you may modify their names with a
|
||||
command-line option. Both functions require two arguments, a string,
|
||||
`char *' STR, and a length parameter, `int' LEN. Their default
|
||||
function prototypes are as follows:
|
||||
Several options control how the generated C code appears on the standard
|
||||
output. Two C function are generated. They are called `hash' and
|
||||
`in_word_set', although you may modify their names with a command-line
|
||||
option. Both functions require two arguments, a string, `char *' STR,
|
||||
and a length parameter, `int' LEN. Their default function prototypes
|
||||
are as follows:
|
||||
|
||||
- Funktion: unsigned int hash (const char * STR, unsigned int LEN)
|
||||
-- Function: unsigned int hash (const char * STR, unsigned int LEN)
|
||||
By default, the generated `hash' function returns an integer value
|
||||
created by adding LEN to several user-specified STR byte positions
|
||||
indexed into an "associated values" table stored in a local static
|
||||
@@ -1030,7 +1035,7 @@ function prototypes are as follows:
|
||||
STR) are specified via the `-k' option when running `gperf', as
|
||||
detailed in the _Options_ section below (*note Options::).
|
||||
|
||||
- Funktion: in_word_set (const char * STR, unsigned int LEN)
|
||||
-- Function: in_word_set (const char * STR, unsigned int LEN)
|
||||
If STR is in the keyword set, returns a pointer to that keyword.
|
||||
More exactly, if the option `-t' (or, equivalently, the
|
||||
`%struct-type' declaration) was given, it returns a pointer to the
|
||||
@@ -1068,14 +1073,14 @@ set characteristics.
|
||||
|
||||
File: gperf.info, Node: Binary Strings, Prev: Output Format, Up: Description
|
||||
|
||||
Use of NUL bytes
|
||||
================
|
||||
3.3 Use of NUL bytes
|
||||
====================
|
||||
|
||||
By default, the code generated by `gperf' operates on zero
|
||||
terminated strings, the usual representation of strings in C. This
|
||||
means that the keywords in the input file must not contain NUL bytes,
|
||||
and the STR argument passed to `hash' or `in_word_set' must be NUL
|
||||
terminated and have exactly length LEN.
|
||||
By default, the code generated by `gperf' operates on zero terminated
|
||||
strings, the usual representation of strings in C. This means that the
|
||||
keywords in the input file must not contain NUL bytes, and the STR
|
||||
argument passed to `hash' or `in_word_set' must be NUL terminated and
|
||||
have exactly length LEN.
|
||||
|
||||
If option `-c' (or, equivalently, the `%compare-strncmp'
|
||||
declaration) is used, then the STR argument does not need to be NUL
|
||||
@@ -1093,10 +1098,10 @@ equivalently, the `%compare-strncmp' declaration) is ignored.
|
||||
|
||||
File: gperf.info, Node: Options, Next: Bugs, Prev: Description, Up: Top
|
||||
|
||||
Invoking `gperf'
|
||||
****************
|
||||
4 Invoking `gperf'
|
||||
******************
|
||||
|
||||
There are _many_ options to `gperf'. They were added to make the
|
||||
There are _many_ options to `gperf'. They were added to make the
|
||||
program more convenient for use with real applications. "On-line" help
|
||||
is readily available via the `--help' option. Here is the complete
|
||||
list of options.
|
||||
@@ -1113,8 +1118,8 @@ list of options.
|
||||
|
||||
File: gperf.info, Node: Output File, Next: Input Details, Prev: Options, Up: Options
|
||||
|
||||
Specifying the Location of the Output File
|
||||
==========================================
|
||||
4.1 Specifying the Location of the Output File
|
||||
==============================================
|
||||
|
||||
`--output-file=FILE'
|
||||
Allows you to specify the name of the file to which the output is
|
||||
@@ -1126,10 +1131,10 @@ specified or if it is `-'.
|
||||
|
||||
File: gperf.info, Node: Input Details, Next: Output Language, Prev: Output File, Up: Options
|
||||
|
||||
Options that affect Interpretation of the Input File
|
||||
====================================================
|
||||
4.2 Options that affect Interpretation of the Input File
|
||||
========================================================
|
||||
|
||||
These options are also available as declarations in the input file
|
||||
These options are also available as declarations in the input file
|
||||
(*note Gperf Declarations::).
|
||||
|
||||
`-e KEYWORD-DELIMITER-LIST'
|
||||
@@ -1165,10 +1170,10 @@ Options that affect Interpretation of the Input File
|
||||
|
||||
File: gperf.info, Node: Output Language, Next: Output Details, Prev: Input Details, Up: Options
|
||||
|
||||
Options to specify the Language for the Output Code
|
||||
===================================================
|
||||
4.3 Options to specify the Language for the Output Code
|
||||
=======================================================
|
||||
|
||||
These options are also available as declarations in the input file
|
||||
These options are also available as declarations in the input file
|
||||
(*note Gperf Declarations::).
|
||||
|
||||
`-L GENERATED-LANGUAGE-NAME'
|
||||
@@ -1207,11 +1212,11 @@ Options to specify the Language for the Output Code
|
||||
|
||||
File: gperf.info, Node: Output Details, Next: Algorithmic Details, Prev: Output Language, Up: Options
|
||||
|
||||
Options for fine tuning Details in the Output Code
|
||||
==================================================
|
||||
4.4 Options for fine tuning Details in the Output Code
|
||||
======================================================
|
||||
|
||||
Most of these options are also available as declarations in the
|
||||
input file (*note Gperf Declarations::).
|
||||
Most of these options are also available as declarations in the input
|
||||
file (*note Gperf Declarations::).
|
||||
|
||||
`-K SLOT-NAME'
|
||||
`--slot-name=SLOT-NAME'
|
||||
@@ -1338,6 +1343,13 @@ input file (*note Gperf Declarations::).
|
||||
the use of two hash tables in the same file, even when the option
|
||||
`-G' (or, equivalently, the `%global-table' declaration) is given.
|
||||
|
||||
`--length-table-name=LENGTH-TABLE-ARRAY-NAME'
|
||||
Allows you to specify the name for the generated array containing
|
||||
the length table. Default name is `lengthtable'. This option
|
||||
permits the use of two length tables in the same file, even when
|
||||
the option `-G' (or, equivalently, the `%global-table'
|
||||
declaration) is given.
|
||||
|
||||
`-S TOTAL-SWITCH-STATEMENTS'
|
||||
`--switch=TOTAL-SWITCH-STATEMENTS'
|
||||
Causes the generated C code to use a `switch' statement scheme,
|
||||
@@ -1363,8 +1375,8 @@ input file (*note Gperf Declarations::).
|
||||
|
||||
File: gperf.info, Node: Algorithmic Details, Next: Verbosity, Prev: Output Details, Up: Options
|
||||
|
||||
Options for changing the Algorithms employed by `gperf'
|
||||
=======================================================
|
||||
4.5 Options for changing the Algorithms employed by `gperf'
|
||||
===========================================================
|
||||
|
||||
`-k SELECTED-BYTE-POSITIONS'
|
||||
`--key-positions=SELECTED-BYTE-POSITIONS'
|
||||
@@ -1472,8 +1484,8 @@ Options for changing the Algorithms employed by `gperf'
|
||||
|
||||
File: gperf.info, Node: Verbosity, Prev: Algorithmic Details, Up: Options
|
||||
|
||||
Informative Output
|
||||
==================
|
||||
4.6 Informative Output
|
||||
======================
|
||||
|
||||
`-h'
|
||||
`--help'
|
||||
@@ -1496,11 +1508,10 @@ Informative Output
|
||||
|
||||
File: gperf.info, Node: Bugs, Next: Projects, Prev: Options, Up: Top
|
||||
|
||||
Known Bugs and Limitations with `gperf'
|
||||
***************************************
|
||||
5 Known Bugs and Limitations with `gperf'
|
||||
*****************************************
|
||||
|
||||
The following are some limitations with the current release of
|
||||
`gperf':
|
||||
The following are some limitations with the current release of `gperf':
|
||||
|
||||
* The `gperf' utility is tuned to execute quickly, and works quickly
|
||||
for small to medium size data sets (around 1000 keywords). It is
|
||||
@@ -1529,10 +1540,10 @@ Known Bugs and Limitations with `gperf'
|
||||
|
||||
File: gperf.info, Node: Projects, Next: Bibliography, Prev: Bugs, Up: Top
|
||||
|
||||
Things Still Left to Do
|
||||
***********************
|
||||
6 Things Still Left to Do
|
||||
*************************
|
||||
|
||||
It should be "relatively" easy to replace the current perfect hash
|
||||
It should be "relatively" easy to replace the current perfect hash
|
||||
function algorithm with a more exhaustive approach; the perfect hash
|
||||
module is essential independent from other program modules. Additional
|
||||
worthwhile improvements include:
|
||||
@@ -1554,10 +1565,10 @@ worthwhile improvements include:
|
||||
|
||||
File: gperf.info, Node: Bibliography, Next: Concept Index, Prev: Projects, Up: Top
|
||||
|
||||
Bibliography
|
||||
************
|
||||
7 Bibliography
|
||||
**************
|
||||
|
||||
[1] Chang, C.C.: A Scheme for Constructing Ordered Minimal Perfect
|
||||
[1] Chang, C.C.: A Scheme for Constructing Ordered Minimal Perfect
|
||||
Hashing Functions Information Sciences 39(1986), 187-195.
|
||||
|
||||
[2] Cichelli, Richard J. Author's Response to "On Cichelli's Minimal
|
||||
@@ -1612,83 +1623,86 @@ File: gperf.info, Node: Concept Index, Prev: Bibliography, Up: Top
|
||||
Concept Index
|
||||
*************
|
||||
|
||||
| ||||