summaryrefslogtreecommitdiff
path: root/doc/gperf.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/gperf.html')
-rw-r--r--doc/gperf.html355
1 files changed, 195 insertions, 160 deletions
diff --git a/doc/gperf.html b/doc/gperf.html
index 6dde98c..d619e68 100644
--- a/doc/gperf.html
+++ b/doc/gperf.html
@@ -1,14 +1,13 @@
<HTML>
<HEAD>
-<!-- This HTML file has been created by texi2html 1.51
- from gperf.texi on 7 May 2003 -->
+<!-- Created by texi2html 1.56k from gperf.texi on 12 June 2003 -->
<TITLE>Perfect Hash Function Generator</TITLE>
</HEAD>
<BODY>
-<H1>User's Guide to <CODE>gperf</CODE> 3.0</H1>
+<H1>User's Guide to <CODE>gperf</CODE> 3.0.1</H1>
<H2>The GNU Perfect Hash Function Generator</H2>
-<H2>Edition 3.0, 7 May 2003</H2>
+<H2>Edition 3.0.1, 12 June 2003</H2>
<ADDRESS>Douglas C. Schmidt</ADDRESS>
<ADDRESS>Bruno Haible</ADDRESS>
<P>
@@ -21,37 +20,37 @@
<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>
+<LI><A NAME="TOC8" HREF="gperf.html#SEC8">3.1 Input Format to <CODE>gperf</CODE></A>
<UL>
-<LI><A NAME="TOC9" HREF="gperf.html#SEC9">3.1.1 Declarations</A>
+<LI><A NAME="TOC9" HREF="gperf.html#SEC9">3.1.1 Declarations</A>
<UL>
-<LI><A NAME="TOC10" HREF="gperf.html#SEC10">3.1.1.1 User-supplied <CODE>struct</CODE></A>
-<LI><A NAME="TOC11" HREF="gperf.html#SEC11">3.1.1.2 Gperf Declarations</A>
-<LI><A NAME="TOC12" HREF="gperf.html#SEC12">3.1.1.3 C Code Inclusion</A>
+<LI><A NAME="TOC10" HREF="gperf.html#SEC10">3.1.1.1 User-supplied <CODE>struct</CODE></A>
+<LI><A NAME="TOC11" HREF="gperf.html#SEC11">3.1.1.2 Gperf Declarations</A>
+<LI><A NAME="TOC12" HREF="gperf.html#SEC12">3.1.1.3 C Code Inclusion</A>
</UL>
-<LI><A NAME="TOC13" HREF="gperf.html#SEC13">3.1.2 Format for Keyword Entries</A>
-<LI><A NAME="TOC14" HREF="gperf.html#SEC14">3.1.3 Including Additional C Functions</A>
-<LI><A NAME="TOC15" HREF="gperf.html#SEC15">3.1.4 Where to place directives for GNU <CODE>indent</CODE>.</A>
+<LI><A NAME="TOC13" HREF="gperf.html#SEC13">3.1.2 Format for Keyword Entries</A>
+<LI><A NAME="TOC14" HREF="gperf.html#SEC14">3.1.3 Including Additional C Functions</A>
+<LI><A NAME="TOC15" HREF="gperf.html#SEC15">3.1.4 Where to place directives for GNU <CODE>indent</CODE>.</A>
</UL>
-<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>
+<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>
-<LI><A NAME="TOC21" HREF="gperf.html#SEC21">4.3 Options to specify the Language for the Output Code</A>
-<LI><A NAME="TOC22" HREF="gperf.html#SEC22">4.4 Options for fine tuning Details in the Output Code</A>
-<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>
+<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>
+<LI><A NAME="TOC21" HREF="gperf.html#SEC21">4.3 Options to specify the Language for the Output Code</A>
+<LI><A NAME="TOC22" HREF="gperf.html#SEC22">4.4 Options for fine tuning Details in the Output Code</A>
+<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>
@@ -62,7 +61,7 @@
<P>
Version 2, June 1991
-</P>
+
<PRE>
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
@@ -87,7 +86,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
@@ -96,14 +95,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
@@ -111,13 +110,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
@@ -126,7 +125,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
@@ -134,16 +133,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>
@@ -412,7 +411,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>
@@ -422,14 +421,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>
@@ -453,12 +452,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>
@@ -475,13 +474,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
@@ -500,7 +499,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>
@@ -537,7 +536,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
@@ -550,7 +549,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
@@ -561,16 +560,16 @@ 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 <STRONG>static search structure</STRONG> is an Abstract Data Type with certain
+A <EM>static search structure</EM> is an Abstract Data Type with certain
fundamental operations, e.g., <EM>initialize</EM>, <EM>insert</EM>,
and <EM>retrieve</EM>. Conceptually, all insertions occur before any
retrievals. In practice, <CODE>gperf</CODE> generates a <EM>static</EM> array
@@ -580,11 +579,11 @@ insertions. It is a useful data structure for representing <EM>static
search sets</EM>. Static search sets occur frequently in software system
applications. Typical static search sets include compiler reserved
words, assembler instruction opcodes, and built-in shell interpreter
-commands. Search set members, called <STRONG>keywords</STRONG>, are inserted into
+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
@@ -596,14 +595,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>
@@ -629,7 +628,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
@@ -645,23 +644,23 @@ 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
"keywords" from an input file (or from the standard input by
default). It attempts to derive a perfect hashing function that
-recognizes a member of the <STRONG>static keyword set</STRONG> with at most a
+recognizes a member of the <EM>static keyword set</EM> with at most a
single probe into the lookup table. If <CODE>gperf</CODE> succeeds in
generating such a function it produces a pair of C source code routines
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
@@ -673,7 +672,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.
@@ -681,10 +680,10 @@ 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>
+
+<H2><A NAME="SEC8" HREF="gperf.html#TOC8">3.1 Input Format to <CODE>gperf</CODE></A></H2>
<P>
<A NAME="IDX4"></A>
<A NAME="IDX5"></A>
@@ -696,7 +695,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
@@ -711,14 +710,13 @@ 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
@@ -730,7 +728,7 @@ april
-<H3><A NAME="SEC9" HREF="gperf.html#TOC9">3.1.1 Declarations</A></H3>
+<H3><A NAME="SEC9" HREF="gperf.html#TOC9">3.1.1 Declarations</A></H3>
<P>
The keyword input file optionally contains a section for including
@@ -738,11 +736,10 @@ 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>
-<H4><A NAME="SEC10" HREF="gperf.html#TOC10">3.1.1.1 User-supplied <CODE>struct</CODE></A></H4>
+<H4><A NAME="SEC10" HREF="gperf.html#TOC10">3.1.1.1 User-supplied <CODE>struct</CODE></A></H4>
<P>
If the <SAMP>`-t'</SAMP> option (or, equivalently, the <SAMP>`%struct-type'</SAMP> declaration)
@@ -755,15 +752,15 @@ 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 months { char *name; int number; int days; int leap_days; };
+struct month { char *name; int number; int days; int leap_days; };
%%
january, 1, 31, 31
february, 2, 28, 29
@@ -786,10 +783,23 @@ 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:
+
+
+
+<PRE>
+struct month;
+%%
+january, 1, 31, 31
+...
+</PRE>
+
-<H4><A NAME="SEC11" HREF="gperf.html#TOC11">3.1.1.2 Gperf Declarations</A></H4>
+<H4><A NAME="SEC11" HREF="gperf.html#TOC11">3.1.1.2 Gperf Declarations</A></H4>
<P>
The declaration section can contain <CODE>gperf</CODE> declarations. They
@@ -797,7 +807,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>
@@ -818,11 +828,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>
@@ -933,7 +943,7 @@ test like <SAMP>`c &#62;= 'A' &#38;&#38; c &#60;= 'Z''</SAMP> guarantees this.)
<DD>
<A NAME="IDX19"></A>
Compare keyword lengths before trying a string comparison. This option
-is mandatory for binary comparisons (see section <A HREF="gperf.html#SEC17">3.3 Use of NUL bytes</A>). It also might
+is mandatory for binary comparisons (see section <A HREF="gperf.html#SEC17">3.3 Use of NUL bytes</A>). It also might
cut down on the number of string comparisons made during the lookup, since
keywords with different lengths are never compared via <CODE>strcmp</CODE>.
However, using <SAMP>`%compare-lengths'</SAMP> might greatly increase the size of the
@@ -1036,7 +1046,7 @@ 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>
+<H4><A NAME="SEC12" HREF="gperf.html#TOC12">3.1.1.3 C Code Inclusion</A></H4>
<P>
<A NAME="IDX31"></A>
@@ -1048,15 +1058,15 @@ inside left-justified surrounding <SAMP>`%{'</SAMP>, <SAMP>`%}'</SAMP> pairs. H
an input fragment based on the previous example that illustrates this
feature:
-</P>
+
<PRE>
%{
#include &#60;assert.h&#62;
/* This section of code is inserted directly into the output. */
-int return_month_days (struct months *months, int is_leap_year);
+int return_month_days (struct month *months, int is_leap_year);
%}
-struct months { char *name; int number; int days; int leap_days; };
+struct month { char *name; int number; int days; int leap_days; };
%%
january, 1, 31, 31
february, 2, 28, 29
@@ -1066,7 +1076,7 @@ march, 3, 31, 31
-<H3><A NAME="SEC13" HREF="gperf.html#TOC13">3.1.2 Format for Keyword Entries</A></H3>
+<H3><A NAME="SEC13" HREF="gperf.html#TOC13">3.1.2 Format for Keyword Entries</A></H3>
<P>
The second input file format section contains lines of keywords and any
@@ -1076,7 +1086,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
@@ -1088,7 +1098,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
@@ -1108,7 +1118,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
@@ -1119,10 +1129,10 @@ 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>
+
+<H3><A NAME="SEC14" HREF="gperf.html#TOC14">3.1.3 Including Additional C Functions</A></H3>
<P>
The optional third section also corresponds closely with conventions
@@ -1132,10 +1142,10 @@ 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>
+
+<H3><A NAME="SEC15" HREF="gperf.html#TOC15">3.1.4 Where to place directives for GNU <CODE>indent</CODE>.</A></H3>
<P>
If you want to invoke GNU <CODE>indent</CODE> on a <CODE>gperf</CODE> input file,
@@ -1145,7 +1155,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
@@ -1163,7 +1173,7 @@ functions
you would insert <SAMP>`*INDENT-OFF*'</SAMP> and <SAMP>`*INDENT-ON*'</SAMP> comments
as follows:
-</P>
+
<PRE>
/* *INDENT-OFF* */
@@ -1183,11 +1193,11 @@ functions
-<H2><A NAME="SEC16" HREF="gperf.html#TOC16">3.2 Output Format for Generated C Code with <CODE>gperf</CODE></A></H2>
+<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>
-</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
@@ -1196,22 +1206,22 @@ 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>
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 <STRONG>associated values</STRONG> table stored in a
+positions indexed into an <EM>associated values</EM> table stored in a
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>
@@ -1223,7 +1233,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
@@ -1232,12 +1242,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>
@@ -1268,14 +1278,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>
+
+<H2><A NAME="SEC17" HREF="gperf.html#TOC17">3.3 Use of NUL bytes</A></H2>
<P>
<A NAME="IDX37"></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
@@ -1283,7 +1293,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
@@ -1292,7 +1302,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
@@ -1302,10 +1312,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
@@ -1313,11 +1323,10 @@ 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>
-<H2><A NAME="SEC19" HREF="gperf.html#TOC19">4.1 Specifying the Location of the Output File</A></H2>
+<H2><A NAME="SEC19" HREF="gperf.html#TOC19">4.1 Specifying the Location of the Output File</A></H2>
<DL COMPACT>
@@ -1330,16 +1339,16 @@ 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>
+
+<H2><A NAME="SEC20" HREF="gperf.html#TOC20">4.2 Options that affect Interpretation of the Input File</A></H2>
<P>
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>).
+(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>
@@ -1379,13 +1388,13 @@ the <CODE>gperf</CODE> generated function.
-<H2><A NAME="SEC21" HREF="gperf.html#TOC21">4.3 Options to specify the Language for the Output Code</A></H2>
+<H2><A NAME="SEC21" HREF="gperf.html#TOC21">4.3 Options to specify the Language for the Output Code</A></H2>
<P>
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>).
+(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>
@@ -1433,13 +1442,13 @@ This option is supported for compatibility with previous releases of
-<H2><A NAME="SEC22" HREF="gperf.html#TOC22">4.4 Options for fine tuning Details in the Output Code</A></H2>
+<H2><A NAME="SEC22" HREF="gperf.html#TOC22">4.4 Options for fine tuning Details in the Output Code</A></H2>
<P>
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>).
+(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>
@@ -1510,7 +1519,7 @@ to support 8-bit and multibyte characters.
<DT><SAMP>`--compare-lengths'</SAMP>
<DD>
Compare keyword lengths before trying a string comparison. This option
-is mandatory for binary comparisons (see section <A HREF="gperf.html#SEC17">3.3 Use of NUL bytes</A>). It also might
+is mandatory for binary comparisons (see section <A HREF="gperf.html#SEC17">3.3 Use of NUL bytes</A>). It also might
cut down on the number of string comparisons made during the lookup, since
keywords with different lengths are never compared via <CODE>strcmp</CODE>.
However, using <SAMP>`-l'</SAMP> might greatly increase the size of the
@@ -1628,7 +1637,7 @@ This option is supported for compatibility with previous releases of
-<H2><A NAME="SEC23" HREF="gperf.html#TOC23">4.5 Options for changing the Algorithms employed by <CODE>gperf</CODE></A></H2>
+<H2><A NAME="SEC23" HREF="gperf.html#TOC23">4.5 Options for changing the Algorithms employed by <CODE>gperf</CODE></A></H2>
<DL COMPACT>
@@ -1753,7 +1762,7 @@ heuristic.
-<H2><A NAME="SEC24" HREF="gperf.html#TOC24">4.6 Informative Output</A></H2>
+<H2><A NAME="SEC24" HREF="gperf.html#TOC24">4.6 Informative Output</A></H2>
<DL COMPACT>
@@ -1784,13 +1793,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>
@@ -1826,7 +1835,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
@@ -1834,7 +1843,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>
@@ -1857,91 +1866,118 @@ 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>
<P>
-<H2>%</H2>
+Jump to:
+<A HREF="#cindex_%">%</A>
+-
+<A HREF="#cindex_a">a</A>
+-
+<A HREF="#cindex_b">b</A>
+-
+<A HREF="#cindex_c">c</A>
+-
+<A HREF="#cindex_d">d</A>
+-
+<A HREF="#cindex_f">f</A>
+-
+<A HREF="#cindex_h">h</A>
+-
+<A HREF="#cindex_i">i</A>
+-
+<A HREF="#cindex_j">j</A>
+-
+<A HREF="#cindex_k">k</A>
+-
+<A HREF="#cindex_m">m</A>
+-
+<A HREF="#cindex_n">n</A>
+-
+<A HREF="#cindex_s">s</A>
+<P>
+<H2><A NAME="cindex_%">%</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX8"><SAMP>`%%'</SAMP></A>
<LI><A HREF="gperf.html#IDX18"><SAMP>`%7bit'</SAMP></A>
@@ -1969,66 +2005,65 @@ Foundation, 1989.
<LI><A HREF="gperf.html#IDX31"><SAMP>`%{'</SAMP></A>
<LI><A HREF="gperf.html#IDX32"><SAMP>`%}'</SAMP></A>
</DIR>
-<H2>a</H2>
+<H2><A NAME="cindex_a">a</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX42">Array name</A>
</DIR>
-<H2>b</H2>
+<H2><A NAME="cindex_b">b</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX1">Bugs</A>
</DIR>
-<H2>c</H2>
+<H2><A NAME="cindex_c">c</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX41">Class name</A>
</DIR>
-<H2>d</H2>
+<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>
</DIR>
-<H2>f</H2>
+<H2><A NAME="cindex_f">f</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX4">Format</A>
<LI><A HREF="gperf.html#IDX7">Functions section</A>
</DIR>
-<H2>h</H2>
+<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>
</DIR>
-<H2>i</H2>
+<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>
</DIR>
-<H2>j</H2>
+<H2><A NAME="cindex_j">j</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX45">Jump value</A>
</DIR>
-<H2>k</H2>
+<H2><A NAME="cindex_k">k</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX6">Keywords section</A>
</DIR>
-<H2>m</H2>
+<H2><A NAME="cindex_m">m</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX3">Minimal perfect hash functions</A>
</DIR>
-<H2>n</H2>
+<H2><A NAME="cindex_n">n</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX37">NUL</A>
</DIR>
-<H2>s</H2>
+<H2><A NAME="cindex_s">s</A></H2>
<DIR>
<LI><A HREF="gperf.html#IDX39">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>
</DIR>
-</P>
+
<P><HR><P>
-This document was generated on 7 May 2003 using the
-<A HREF="http://wwwcn.cern.ch/dci/texi2html/">texi2html</A>
-translator version 1.51.</P>
+This document was generated on 12 June 2003 using
+<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A>&nbsp;1.56k.
</BODY>
</HTML>