mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-01 08:27:59 +00:00
upgrade gperf to the last GPLv2 version (3.0.3)
Reviewed by: cognet Approved by: cognet
This commit is contained in:
parent
d04fbf251a
commit
acca521c82
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228060
@ -1,2 +1,2 @@
|
||||
Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
Bruno Haible <haible@clisp.cons.org>
|
||||
Bruno Haible <bruno@clisp.org>
|
||||
|
@ -2,7 +2,7 @@
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA.
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,3 +6,9 @@ $FreeBSD$
|
||||
*/texinfo.tex
|
||||
*/tests
|
||||
*/getopt*
|
||||
*/*.pdf
|
||||
*/*.vms
|
||||
*/*.texi
|
||||
*/*.texinfo
|
||||
*/*.msvc
|
||||
*/*.woe32
|
||||
|
@ -19,8 +19,8 @@ diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
The file `configure.ac' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.ac' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
@ -4,32 +4,38 @@
|
||||
SHELL = /bin/sh
|
||||
MAKE = make
|
||||
|
||||
all : configures src/config.h.in doc/gperf.1
|
||||
all : configures src/config.h.in src/config.h.msvc src/config.h_vms doc/gperf.1
|
||||
|
||||
CONFIGURES = configure lib/configure src/configure tests/configure doc/configure
|
||||
|
||||
configures : $(CONFIGURES)
|
||||
|
||||
configure : configure.in aclocal.m4
|
||||
autoconf -l .
|
||||
configure : configure.ac aclocal.m4
|
||||
autoconf -I .
|
||||
|
||||
lib/configure : lib/configure.in aclocal.m4
|
||||
cd lib && autoconf -l ..
|
||||
lib/configure : lib/configure.ac aclocal.m4
|
||||
cd lib && autoconf -I ..
|
||||
|
||||
src/configure : src/configure.in aclocal.m4
|
||||
cd src && autoconf -l ..
|
||||
src/configure : src/configure.ac aclocal.m4
|
||||
cd src && autoconf -I ..
|
||||
|
||||
tests/configure : tests/configure.in aclocal.m4
|
||||
cd tests && autoconf -l ..
|
||||
tests/configure : tests/configure.ac aclocal.m4
|
||||
cd tests && autoconf -I ..
|
||||
|
||||
doc/configure : doc/configure.in aclocal.m4
|
||||
cd doc && autoconf -l ..
|
||||
doc/configure : doc/configure.ac aclocal.m4
|
||||
cd doc && autoconf -I ..
|
||||
|
||||
check-configures : $(CONFIGURES)
|
||||
set -e; for f in $(CONFIGURES); do bash -x -n $$f; done
|
||||
|
||||
src/config.h.in : src/configure.in aclocal.m4
|
||||
cd src && autoheader -l ..
|
||||
src/config.h.in : src/configure.ac aclocal.m4
|
||||
cd src && autoheader -I ..
|
||||
|
||||
src/config.h.msvc : src/config.h.in
|
||||
cp src/config.h.in src/config.h.msvc
|
||||
|
||||
src/config.h_vms : src/config.h.in
|
||||
cp src/config.h.in src/config.h_vms
|
||||
|
||||
doc/gperf.1 : force
|
||||
prog=`PATH=build/src:src:$$PATH which gperf`; if test -n "$$prog"; then doc/help2man --name='generate a perfect hash function from a key set' --section=1 $$prog > doc/gperf.1; fi
|
||||
|
@ -1,13 +1,14 @@
|
||||
# Makefile for gperf
|
||||
|
||||
# Copyright (C) 1989, 1992, 1993, 1998 Free Software Foundation, Inc.
|
||||
# written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
# Copyright (C) 1989, 1992, 1993, 1998, 2002 Free Software Foundation, Inc.
|
||||
# Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
# and Bruno Haible <bruno@clisp.org>.
|
||||
#
|
||||
# This file is part of GNU GPERF.
|
||||
#
|
||||
# GNU GPERF is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 1, or (at your option)
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,8 +17,9 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU GPERF; see the file COPYING. If not, write to
|
||||
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# along with this program; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
|
@ -1,3 +1,73 @@
|
||||
New in 3.0.3:
|
||||
|
||||
* The generated C code is compatible with gcc-4.3.x in c99 or gnu99 mode.
|
||||
|
||||
New in 3.0.2:
|
||||
|
||||
* Compiles with g++-4.0.x.
|
||||
* Added option --length-table-name.
|
||||
* Added declaration %define length-table-name.
|
||||
* Fixed #line directives for filenames containing backslashes.
|
||||
|
||||
New in 3.0.1:
|
||||
|
||||
* Bug fix.
|
||||
|
||||
New in 3.0:
|
||||
|
||||
* Added option --output that allows to specify the output file name.
|
||||
* Some options have been renamed:
|
||||
--hash-fn-name=NAME --> --hash-function-name=NAME
|
||||
--lookup-fn-name=NAME --> --lookup-function-name=NAME
|
||||
--compare-strlen --> --compare-lengths
|
||||
--global --> --global-table
|
||||
The older variants are still supported for backward compatibility.
|
||||
* The following options can now be specified inside the input file:
|
||||
%delimiters=DELIMITER-LIST
|
||||
%struct-type
|
||||
%ignore-case
|
||||
%language=LANGUAGE-NAME
|
||||
%define slot-name NAME
|
||||
%define initializer-suffix INITIALIZERS
|
||||
%define hash-function-name NAME
|
||||
%define lookup-function-name NAME
|
||||
%define class-name NAME
|
||||
%7bit
|
||||
%compare-lengths
|
||||
%compare-strncmp
|
||||
%readonly-tables
|
||||
%enum
|
||||
%includes
|
||||
%global-table
|
||||
%pic
|
||||
%define string-pool-name NAME
|
||||
%null-strings
|
||||
%define word-array-name NAME
|
||||
%switch=COUNT
|
||||
%omit-struct-type
|
||||
* When the option -k is not given, the default key positions are now
|
||||
computed depending on the set of keywords.
|
||||
* If the input file is given by name, the output file will now contain
|
||||
#line directives referring to the input file.
|
||||
* Some keyword sets containing permutations, like { "xy", "yx", "xz", "zx" }
|
||||
or { "abc", "acb", "bca", "cab" }, are now handled by gperf without
|
||||
requiring the option -D.
|
||||
* The generated table is usually much smaller than it was with earlier
|
||||
versions of gperf.
|
||||
* Added option -m/--multiple-iterations that allows to further reduce the
|
||||
size of the generated table.
|
||||
* When the search for a good hash function is not immediately successful,
|
||||
the table's size will grow as needed. Earlier versions of gperf bailed
|
||||
out with an "Internal error, duplicate hash code value".
|
||||
* The options -f/--fast and -o/--occurrence-sort have no effect any more.
|
||||
* Added options -P/--pic and --null-strings that optimize the generated code
|
||||
for use in shared libraries. -P/--pic does a perfect optimization but may
|
||||
require some small code changes (see the documentation for details), whereas
|
||||
--null-strings does only a half-hearted optimization but works without
|
||||
needing any change to surrounding code.
|
||||
* Added option --ignore-case that produces a case independent lookup function.
|
||||
* Bug fixes.
|
||||
|
||||
New in 2.7.2:
|
||||
|
||||
* Keywords may now be enclosed in double quotes; this permits the use of
|
||||
|
@ -22,8 +22,7 @@ this distribution follows, see the GNU standards document
|
||||
ftp://ftp.gnu.org/pub/gnu/standards.*, especially the 'Makefile
|
||||
Conventions', 'Configuration', and 'User Interfaces' sections.
|
||||
|
||||
Mail suggestions and bug reports to both <bug-gnu-utils@gnu.org> and
|
||||
<gperf-bugs@lists.sourceforge.net>. When reporting bugs, please
|
||||
include in the subject line the package name and version (output of
|
||||
'gperf --version') for which you found a problem.
|
||||
Mail suggestions and bug reports to <bug-gnu-gperf@gnu.org>. When
|
||||
reporting bugs, please include in the subject line the package name
|
||||
and version (output of 'gperf --version') for which you found a problem.
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
|
||||
/* Define if the C++ compiler supports "throw ()" declarations. */
|
||||
#undef HAVE_THROW_DECL
|
||||
|
2
contrib/gperf/aclocal.m4
vendored
2
contrib/gperf/aclocal.m4
vendored
@ -1,7 +1,5 @@
|
||||
AC_PREREQ(2.12)
|
||||
|
||||
AC_DEFUN(CL_PROG_RANLIB, [AC_CHECK_PROG(RANLIB, ranlib, ranlib, true)])
|
||||
|
||||
AC_DEFUN(CL_PROG_INSTALL,
|
||||
[dnl This is mostly copied from AC_PROG_INSTALL.
|
||||
# Find a good install program. We prefer a C program (faster),
|
||||
|
2984
contrib/gperf/configure
vendored
2984
contrib/gperf/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,14 @@
|
||||
dnl autoconf configuration for gperf
|
||||
|
||||
dnl Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
dnl written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
dnl Copyright (C) 1998, 2002, 2003, 2005-2007 Free Software Foundation, Inc.
|
||||
dnl Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
dnl and Bruno Haible <bruno@clisp.org>.
|
||||
dnl
|
||||
dnl This file is part of GNU GPERF.
|
||||
dnl
|
||||
dnl GNU GPERF is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 1, or (at your option)
|
||||
dnl the Free Software Foundation; either version 2, or (at your option)
|
||||
dnl any later version.
|
||||
dnl
|
||||
dnl GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,12 +17,21 @@ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with GNU GPERF; see the file COPYING. If not, write to the
|
||||
dnl Free Software Foundation, 59 Temple Place - Suite 330, Boston,
|
||||
dnl MA 02111-1307, USA.
|
||||
dnl along with this program; see the file COPYING.
|
||||
dnl If not, write to the Free Software Foundation, Inc.,
|
||||
dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT(doc/gperf.1)
|
||||
AC_PROG_MAKE_SET
|
||||
AC_OBJEXT
|
||||
AC_EXEEXT
|
||||
|
||||
dnl An autoconf-2.52 bug: AC_CONFIG_SUBDIRS requires AC_CONFIG_AUX_DIR_DEFAULT.
|
||||
ac_aux_dir=$srcdir
|
||||
AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])
|
||||
AC_CONFIG_SUBDIRS(lib src tests doc)
|
||||
|
||||
dnl This piece of sed script replaces every line containing '@subdir@'
|
||||
dnl by several consecutive lines, each referencing one subdir.
|
||||
extrasub="$extrasub"'
|
||||
@ -43,4 +53,3 @@ d
|
||||
}
|
||||
'
|
||||
AC_OUTPUT(Makefile)
|
||||
AC_OUTPUT_SUBDIRS(lib src tests doc)
|
@ -1,12 +1,14 @@
|
||||
# Makefile for gperf/doc
|
||||
|
||||
# Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998, 2000, 2002-2003, 2007 Free Software Foundation, Inc.
|
||||
# Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
# and Bruno Haible <bruno@clisp.org>.
|
||||
#
|
||||
# This file is part of GNU GPERF.
|
||||
#
|
||||
# GNU GPERF is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 1, or (at your option)
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -15,8 +17,9 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
# along with this program; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
@ -27,14 +30,16 @@ srcdir = @srcdir@
|
||||
prefix = @prefix@
|
||||
local_prefix = /usr/local
|
||||
exec_prefix = @exec_prefix@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
man1dir = $(mandir)/man1
|
||||
docdir = $(prefix)/doc/@PACKAGE@
|
||||
dvidir = $(docdir)
|
||||
psdir = $(docdir)
|
||||
htmldir = $(docdir)
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
psdir = @psdir@
|
||||
pdfdir = @pdfdir@
|
||||
htmldir = @htmldir@
|
||||
|
||||
# Programs used by "make":
|
||||
RM = rm -f
|
||||
@ -44,7 +49,8 @@ RM = rm -f
|
||||
TEX = tex
|
||||
TEXI2DVI = texi2dvi
|
||||
DVIPS = dvips -D600
|
||||
MAKEINFO = LANG= LANGUAGE= makeinfo
|
||||
TEXI2PDF = texi2pdf
|
||||
MAKEINFO = LANG= LC_MESSAGES= LC_ALL= LANGUAGE= makeinfo
|
||||
TEXI2HTML = texi2html
|
||||
|
||||
# Programs used by "make install":
|
||||
@ -59,7 +65,7 @@ SHELL = /bin/sh
|
||||
|
||||
VPATH = $(srcdir)
|
||||
|
||||
all : info dvi ps html
|
||||
all : info ps pdf html
|
||||
|
||||
|
||||
info : $(srcdir)/gperf.info
|
||||
@ -79,7 +85,15 @@ $(srcdir)/gperf.dvi : $(srcdir)/gperf.texi $(srcdir)/gpl.texinfo
|
||||
ps : $(srcdir)/gperf.ps
|
||||
|
||||
$(srcdir)/gperf.ps : $(srcdir)/gperf.dvi
|
||||
$(DVIPS) -o $@ $<
|
||||
$(DVIPS) -o $@ $(srcdir)/gperf.dvi
|
||||
|
||||
|
||||
pdf : $(srcdir)/gperf.pdf
|
||||
|
||||
$(srcdir)/gperf.pdf : $(srcdir)/gperf.texi $(srcdir)/gpl.texinfo
|
||||
cd $(srcdir) && $(RM) gperf.aux gperf.toc gperf.cp gperf.fn gperf.ky gperf.pg gperf.tp gperf.vr gperf.log gperf.cps
|
||||
cd $(srcdir) && $(TEXI2PDF) gperf.texi
|
||||
cd $(srcdir) && $(RM) gperf.aux gperf.toc gperf.cp gperf.fn gperf.ky gperf.pg gperf.tp gperf.vr gperf.log gperf.cps
|
||||
|
||||
|
||||
html : gperf.html gperf_toc.html
|
||||
@ -100,7 +114,9 @@ install : all force
|
||||
# $(MKINSTALLDIRS) $(DESTDIR)$(dvidir)
|
||||
# $(INSTALL_DATA) $(srcdir)/gperf.dvi $(DESTDIR)$(dvidir)/gperf.dvi
|
||||
# $(MKINSTALLDIRS) $(DESTDIR)$(psdir)
|
||||
# $(INSTALL_DATA) $(srcdir)/gperf.ps $(DESTDIR)$(dvidir)/gperf.ps
|
||||
# $(INSTALL_DATA) $(srcdir)/gperf.ps $(DESTDIR)$(psdir)/gperf.ps
|
||||
# $(MKINSTALLDIRS) $(DESTDIR)$(pdfdir)
|
||||
# $(INSTALL_DATA) $(srcdir)/gperf.pdf $(DESTDIR)$(pdfdir)/gperf.pdf
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(htmldir)
|
||||
$(INSTALL_DATA) $(srcdir)/gperf.html $(DESTDIR)$(htmldir)/gperf.html
|
||||
|
||||
@ -109,6 +125,7 @@ installdirs : force
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(man1dir)
|
||||
# $(MKINSTALLDIRS) $(DESTDIR)$(dvidir)
|
||||
# $(MKINSTALLDIRS) $(DESTDIR)$(psdir)
|
||||
# $(MKINSTALLDIRS) $(DESTDIR)$(pdfdir)
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(htmldir)
|
||||
|
||||
uninstall : force
|
||||
@ -116,6 +133,7 @@ uninstall : force
|
||||
$(RM) $(DESTDIR)$(man1dir)/gperf.1
|
||||
# $(RM) $(DESTDIR)$(dvidir)/gperf.dvi
|
||||
# $(RM) $(DESTDIR)$(psdir)/gperf.ps
|
||||
# $(RM) $(DESTDIR)$(pdfdir)/gperf.pdf
|
||||
$(RM) $(DESTDIR)$(htmldir)/gperf.html
|
||||
|
||||
check : all
|
||||
@ -129,7 +147,7 @@ distclean : clean
|
||||
$(RM) config.status config.log config.cache Makefile
|
||||
|
||||
maintainer-clean : distclean
|
||||
$(RM) *.info *.dvi *.ps *.html
|
||||
$(RM) *.info *.dvi *.ps *.pdf *.html
|
||||
|
||||
force :
|
||||
|
||||
|
2817
contrib/gperf/doc/configure
vendored
2817
contrib/gperf/doc/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,14 @@
|
||||
dnl autoconf configuration for gperf/doc
|
||||
|
||||
dnl Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||
dnl written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
dnl Copyright (C) 1998, 2000, 2002-2003, 2007 Free Software Foundation, Inc.
|
||||
dnl Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
dnl and Bruno Haible <bruno@clisp.org>.
|
||||
dnl
|
||||
dnl This file is part of GNU GPERF.
|
||||
dnl
|
||||
dnl GNU GPERF is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 1, or (at your option)
|
||||
dnl the Free Software Foundation; either version 2, or (at your option)
|
||||
dnl any later version.
|
||||
dnl
|
||||
dnl GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,10 +17,11 @@ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with GNU GPERF; see the file COPYING. If not, write to the
|
||||
dnl Free Software Foundation, 59 Temple Place - Suite 330, Boston,
|
||||
dnl MA 02111-1307, USA.
|
||||
dnl along with this program; see the file COPYING.
|
||||
dnl If not, write to the Free Software Foundation, Inc.,
|
||||
dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT(gperf.1)
|
||||
PACKAGE=gperf
|
||||
AC_SUBST(PACKAGE)
|
@ -1,21 +1,27 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.022.
|
||||
.TH GPERF "1" "September 2000" "GNU gperf 2.7.2" FSF
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23.
|
||||
.TH GPERF "1" "May 2007" "GNU gperf 3.0.3" FSF
|
||||
.SH NAME
|
||||
gperf \- generate a perfect hash function from a key set
|
||||
.SH SYNOPSIS
|
||||
.B gperf
|
||||
[\fIOPTION\fR]... [\fIINPUT-FILE\fR]
|
||||
.SH DESCRIPTION
|
||||
GNU `gperf' generates perfect hash functions.
|
||||
GNU 'gperf' generates perfect hash functions.
|
||||
.PP
|
||||
If a long option shows an argument as mandatory, then it is mandatory
|
||||
for the equivalent short option also.
|
||||
.SS "Output file location:"
|
||||
.HP
|
||||
\fB\-\-output\-file\fR=\fIFILE\fR Write output to specified file.
|
||||
.PP
|
||||
The results are written to standard output if no output file is specified
|
||||
or if it is -.
|
||||
.SS "Input file interpretation:"
|
||||
.TP
|
||||
\fB\-e\fR, \fB\-\-delimiters\fR=\fIDELIMITER\-LIST\fR
|
||||
Allow user to provide a string containing delimiters
|
||||
used to separate keywords from their attributes.
|
||||
Default is ",\en".
|
||||
Default is ",".
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-\-struct\-type\fR
|
||||
Allows the user to include a structured type
|
||||
@ -23,6 +29,11 @@ declaration for generated code. Any text before %%
|
||||
is considered part of the type declaration. Key
|
||||
words and additional fields may follow this, one
|
||||
group of fields per line.
|
||||
.TP
|
||||
\fB\-\-ignore\-case\fR
|
||||
Consider upper and lower case ASCII characters as
|
||||
equivalent. Note that locale dependent case mappings
|
||||
are ignored.
|
||||
.SS "Language for the output code:"
|
||||
.TP
|
||||
\fB\-L\fR, \fB\-\-language\fR=\fILANGUAGE\-NAME\fR
|
||||
@ -39,21 +50,27 @@ structure.
|
||||
Initializers for additional components in the keyword
|
||||
structure.
|
||||
.TP
|
||||
\fB\-H\fR, \fB\-\-hash\-fn\-name\fR=\fINAME\fR
|
||||
\fB\-H\fR, \fB\-\-hash\-function\-name\fR=\fINAME\fR
|
||||
Specify name of generated hash function. Default is
|
||||
`hash'.
|
||||
\&'hash'.
|
||||
.TP
|
||||
\fB\-N\fR, \fB\-\-lookup\-fn\-name\fR=\fINAME\fR
|
||||
\fB\-N\fR, \fB\-\-lookup\-function\-name\fR=\fINAME\fR
|
||||
Specify name of generated lookup function. Default
|
||||
name is `in_word_set'.
|
||||
name is 'in_word_set'.
|
||||
.TP
|
||||
\fB\-Z\fR, \fB\-\-class\-name\fR=\fINAME\fR
|
||||
Specify name of generated C++ class. Default name is
|
||||
`Perfect_Hash'.
|
||||
\&'Perfect_Hash'.
|
||||
.TP
|
||||
\fB\-7\fR, \fB\-\-seven\-bit\fR
|
||||
Assume 7-bit characters.
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-compare\-lengths\fR
|
||||
Compare key lengths before trying a string
|
||||
comparison. This is necessary if the keywords
|
||||
contain NUL bytes. It also helps cut down on the
|
||||
number of string comparisons made during the lookup.
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-compare\-strncmp\fR
|
||||
Generate comparison code using strncmp rather than
|
||||
strcmp.
|
||||
@ -70,14 +87,31 @@ lookup function rather than with defines.
|
||||
Include the necessary system include file <string.h>
|
||||
at the beginning of the code.
|
||||
.TP
|
||||
\fB\-G\fR, \fB\-\-global\fR
|
||||
\fB\-G\fR, \fB\-\-global\-table\fR
|
||||
Generate the static table of keywords as a static
|
||||
global variable, rather than hiding it inside of the
|
||||
lookup function (which is the default behavior).
|
||||
.TP
|
||||
\fB\-P\fR, \fB\-\-pic\fR
|
||||
Optimize the generated table for inclusion in shared
|
||||
libraries. This reduces the startup time of programs
|
||||
using a shared library containing the generated code.
|
||||
.TP
|
||||
\fB\-Q\fR, \fB\-\-string\-pool\-name\fR=\fINAME\fR
|
||||
Specify name of string pool generated by option \fB\-\-pic\fR.
|
||||
Default name is 'stringpool'.
|
||||
.TP
|
||||
\fB\-\-null\-strings\fR
|
||||
Use NULL strings instead of empty strings for empty
|
||||
keyword table entries.
|
||||
.TP
|
||||
\fB\-W\fR, \fB\-\-word\-array\-name\fR=\fINAME\fR
|
||||
Specify name of word list array. Default name is
|
||||
`wordlist'.
|
||||
\&'wordlist'.
|
||||
.TP
|
||||
\fB\-\-length\-table\-name\fR=\fINAME\fR
|
||||
Specify name of length table array. Default name is
|
||||
\&'lengthtable'.
|
||||
.TP
|
||||
\fB\-S\fR, \fB\-\-switch\fR=\fICOUNT\fR
|
||||
Causes the generated C code to use a switch
|
||||
@ -99,30 +133,23 @@ defined elsewhere.
|
||||
.TP
|
||||
\fB\-k\fR, \fB\-\-key\-positions\fR=\fIKEYS\fR
|
||||
Select the key positions used in the hash function.
|
||||
The allowable choices range between 1-126, inclusive.
|
||||
The allowable choices range between 1-255, inclusive.
|
||||
The positions are separated by commas, ranges may be
|
||||
used, and key positions may occur in any order.
|
||||
Also, the meta-character '*' causes the generated
|
||||
hash function to consider ALL key positions, and $
|
||||
indicates the ``final character'' of a key, e.g.,
|
||||
indicates the "final character" of a key, e.g.,
|
||||
$,1,2,4,6-10.
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-compare\-strlen\fR
|
||||
Compare key lengths before trying a string
|
||||
comparison. This helps cut down on the number of
|
||||
string comparisons made during the lookup.
|
||||
.TP
|
||||
\fB\-D\fR, \fB\-\-duplicates\fR
|
||||
Handle keywords that hash to duplicate values. This
|
||||
is useful for certain highly redundant keyword sets.
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-fast\fR=\fIITERATIONS\fR
|
||||
Generate the gen-perf.hash function ``fast''. This
|
||||
decreases gperf's running time at the cost of
|
||||
minimizing generated table size. The numeric
|
||||
argument represents the number of times to iterate
|
||||
when resolving a collision. `0' means ``iterate by
|
||||
the number of keywords''.
|
||||
\fB\-m\fR, \fB\-\-multiple\-iterations\fR=\fIITERATIONS\fR
|
||||
Perform multiple choices of the \fB\-i\fR and \fB\-j\fR values,
|
||||
and choose the best results. This increases the
|
||||
running time by a factor of ITERATIONS but does a
|
||||
good job minimizing the generated table size.
|
||||
.TP
|
||||
\fB\-i\fR, \fB\-\-initial\-asso\fR=\fIN\fR
|
||||
Provide an initial value for the associate values
|
||||
@ -130,7 +157,7 @@ array. Default is 0. Setting this value larger helps
|
||||
inflate the size of the final table.
|
||||
.TP
|
||||
\fB\-j\fR, \fB\-\-jump\fR=\fIJUMP\-VALUE\fR
|
||||
Affects the ``jump value'', i.e., how far to advance
|
||||
Affects the "jump value", i.e., how far to advance
|
||||
the associated character value upon collisions. Must
|
||||
be an odd number, default is 5.
|
||||
.TP
|
||||
@ -138,25 +165,20 @@ be an odd number, default is 5.
|
||||
Do not include the length of the keyword when
|
||||
computing the hash function.
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-occurrence\-sort\fR
|
||||
Reorders input keys by frequency of occurrence of
|
||||
the key sets. This should decrease the search time
|
||||
dramatically.
|
||||
.TP
|
||||
\fB\-r\fR, \fB\-\-random\fR
|
||||
Utilizes randomness to initialize the associated
|
||||
values table.
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-size\-multiple\fR=\fIN\fR
|
||||
Affects the size of the generated hash table. The
|
||||
numeric argument N indicates ``how many times larger
|
||||
or smaller'' the associated value range should be,
|
||||
numeric argument N indicates "how many times larger
|
||||
or smaller" the associated value range should be,
|
||||
in relationship to the number of keys, e.g. a value
|
||||
of 3 means ``allow the maximum associated value to
|
||||
of 3 means "allow the maximum associated value to
|
||||
be about 3 times larger than the number of input
|
||||
keys.'' Conversely, a value of \fB\-3\fR means ``make the
|
||||
keys". Conversely, a value of 1/3 means "make the
|
||||
maximum associated value about 3 times smaller than
|
||||
the number of input keys. A larger table should
|
||||
the number of input keys". A larger table should
|
||||
decrease the time required for an unsuccessful
|
||||
search, at the expense of extra table space. Default
|
||||
value is 1.
|
||||
@ -171,8 +193,15 @@ Print the gperf version number.
|
||||
\fB\-d\fR, \fB\-\-debug\fR
|
||||
Enables the debugging option (produces verbose
|
||||
output to the standard error).
|
||||
.SH AUTHOR
|
||||
Written by Douglas C. Schmidt and Bruno Haible.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-gnu-utils@gnu.org>.
|
||||
Report bugs to <bug-gnu-gperf@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 1989-1998, 2000-2004, 2006-2007 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B gperf
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,398 +0,0 @@
|
||||
@c This GPL is meant to be included from other files.
|
||||
@c To format a standalone GPL, use license.texi.
|
||||
|
||||
@center Version 2, June 1991
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
@end display
|
||||
|
||||
@unnumberedsec 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
|
||||
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
|
||||
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.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
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.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
@iftex
|
||||
@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
@end iftex
|
||||
@ifinfo
|
||||
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
@end ifinfo
|
||||
|
||||
@enumerate 0
|
||||
@item
|
||||
This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The ``Program'', below,
|
||||
refers to any such program or work, and a ``work based on the Program''
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term ``modification''.) Each licensee is addressed as ``you''.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
@item
|
||||
You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
@item
|
||||
You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
@enumerate a
|
||||
@item
|
||||
You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
@item
|
||||
You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
@item
|
||||
If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
@end enumerate
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
@item
|
||||
You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
@enumerate a
|
||||
@item
|
||||
Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
@item
|
||||
Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
@item
|
||||
Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
@end enumerate
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
@item
|
||||
You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
@item
|
||||
You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
@item
|
||||
Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
@item
|
||||
If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
@item
|
||||
If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
@item
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and ``any
|
||||
later version'', you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
@item
|
||||
If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
@iftex
|
||||
@vskip -@baselineskip
|
||||
@vskip -@baselineskip
|
||||
@heading NO WARRANTY
|
||||
@end iftex
|
||||
@ifinfo
|
||||
@center NO WARRANTY
|
||||
@end ifinfo
|
||||
|
||||
@item
|
||||
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 HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
@item
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
@end enumerate
|
||||
|
||||
@iftex
|
||||
@heading END OF TERMS AND CONDITIONS
|
||||
@end iftex
|
||||
@ifinfo
|
||||
@center END OF TERMS AND CONDITIONS
|
||||
@end ifinfo
|
||||
|
||||
@page
|
||||
@unnumberedsec How to Apply These Terms to Your New Programs
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
@smallexample
|
||||
@var{one line to give the program's name and an idea of what it does.}
|
||||
Copyright (C) @var{year} @var{name of author}
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
@end smallexample
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
@smallexample
|
||||
Gnomovision version 69, Copyright (C) @var{year} @var{name of author}
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
|
||||
type `show w'. This is free software, and you are welcome
|
||||
to redistribute it under certain conditions; type `show c'
|
||||
for details.
|
||||
@end smallexample
|
||||
|
||||
The hypothetical commands @samp{show w} and @samp{show c} should show
|
||||
the appropriate parts of the General Public License. Of course, the
|
||||
commands you use may be called something other than @samp{show w} and
|
||||
@samp{show c}; they could even be mouse-clicks or menu items---whatever
|
||||
suits your program.
|
||||
|
||||
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:
|
||||
|
||||
@example
|
||||
@group
|
||||
Yoyodyne, Inc., hereby disclaims all copyright
|
||||
interest in the program `Gnomovision'
|
||||
(which makes passes at compilers) written
|
||||
by James Hacker.
|
||||
|
||||
@var{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
@end group
|
||||
@end example
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
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.
|
@ -15,7 +15,7 @@
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# Written by Brendan O'Dea <bod@compusol.com.au>
|
||||
# Available from ftp://ftp.gnu.org/gnu/help2man/
|
||||
@ -27,7 +27,7 @@ use Text::Tabs qw(expand);
|
||||
use POSIX qw(strftime setlocale LC_TIME);
|
||||
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '1.022';
|
||||
my $this_version = '1.23';
|
||||
my $version_info = <<EOT;
|
||||
GNU $this_program $this_version
|
||||
|
||||
@ -269,9 +269,11 @@ s/^\n+//;
|
||||
s/\n*$/\n/;
|
||||
s/\n\n+/\n\n/g;
|
||||
|
||||
# Temporarily exchange leading dots and backslashes for tokens.
|
||||
# Temporarily exchange leading dots, apostrophes and backslashes for
|
||||
# tokens.
|
||||
s/^\./\x80/mg;
|
||||
s/\\/\x81/g;
|
||||
s/^'/\x81/mg;
|
||||
s/\\/\x82/g;
|
||||
|
||||
# Start a new paragraph (if required) for these.
|
||||
s/([^\n])\n(Report +bugs|Email +bug +reports +to|Written +by)/$1\n\n$2/g;
|
||||
@ -366,7 +368,7 @@ while (length)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length ($4 || "$1$3");
|
||||
$content = ".TP\n\x82$2\n\x82$5\n";
|
||||
$content = ".TP\n\x83$2\n\x83$5\n";
|
||||
unless ($4)
|
||||
{
|
||||
# Indent may be different on second line.
|
||||
@ -378,7 +380,7 @@ while (length)
|
||||
elsif (s/^ {1,10}([+-]\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$content = ".HP\n\x82$1\n";
|
||||
$content = ".HP\n\x83$1\n";
|
||||
$indent = 80; # not continued
|
||||
}
|
||||
|
||||
@ -387,7 +389,7 @@ while (length)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length $1;
|
||||
$content = ".TP\n\x82$2\n\x82$3\n";
|
||||
$content = ".TP\n\x83$2\n\x83$3\n";
|
||||
}
|
||||
|
||||
# Indented paragraph.
|
||||
@ -395,7 +397,7 @@ while (length)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$indent = length $1;
|
||||
$content = ".IP\n\x82$2\n";
|
||||
$content = ".IP\n\x83$2\n";
|
||||
}
|
||||
|
||||
# Left justified paragraph.
|
||||
@ -411,7 +413,7 @@ while (length)
|
||||
while (s/^ {$indent}(\S.*)\n//)
|
||||
{
|
||||
$matched .= $& if %append;
|
||||
$content .= "\x82$1\n"
|
||||
$content .= "\x83$1\n"
|
||||
}
|
||||
|
||||
# Move to next paragraph.
|
||||
@ -419,9 +421,10 @@ while (length)
|
||||
|
||||
for ($content)
|
||||
{
|
||||
# Leading dot protection.
|
||||
s/\x82\./\x80/g;
|
||||
s/\x82//g;
|
||||
# Leading dot and apostrophe protection.
|
||||
s/\x83\./\x80/g;
|
||||
s/\x83'/\x81/g;
|
||||
s/\x83//g;
|
||||
|
||||
# Convert options.
|
||||
s/(^| )(-[][\w=-]+)/$1 . convert_option $2/mge;
|
||||
@ -482,12 +485,13 @@ for (@pre, (grep ! /^($filter)$/o, @include), @post)
|
||||
{
|
||||
my $quote = /\W/ ? '"' : '';
|
||||
print ".SH $quote$_$quote\n";
|
||||
|
||||
|
||||
for ($include{$_})
|
||||
{
|
||||
# Replace leading dot an backslash tokens.
|
||||
# Replace leading dot, apostrophe and backslash tokens.
|
||||
s/\x80/\\&./g;
|
||||
s/\x81/\\e/g;
|
||||
s/\x81/\\&'/g;
|
||||
s/\x82/\\e/g;
|
||||
print;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,14 @@
|
||||
# Makefile for gperf/lib
|
||||
|
||||
# Copyright (C) 1989, 1992, 1993, 1998 Free Software Foundation, Inc.
|
||||
# written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
# Copyright (C) 1989, 1992, 1993, 1998, 2002 Free Software Foundation, Inc.
|
||||
# Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
# and Bruno Haible <bruno@clisp.org>.
|
||||
#
|
||||
# This file is part of GNU GPERF.
|
||||
#
|
||||
# GNU GPERF is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 1, or (at your option)
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,8 +17,9 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
# along with this program; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
@ -38,6 +40,8 @@ CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCPP = @CXXCPP@
|
||||
# Both C and C++ compiler
|
||||
OBJEXT = @OBJEXT@
|
||||
# Other
|
||||
AR = ar
|
||||
AR_FLAGS = rc
|
||||
@ -58,7 +62,7 @@ SHELL = /bin/sh
|
||||
|
||||
VPATH = $(srcdir)
|
||||
|
||||
OBJECTS = getopt.o getopt1.o hash.o
|
||||
OBJECTS = getopt.$(OBJEXT) getopt1.$(OBJEXT) getline.$(OBJEXT) hash.$(OBJEXT)
|
||||
CPPFLAGS = -I$(srcdir)
|
||||
|
||||
TARGETLIB = libgp.a
|
||||
@ -85,6 +89,9 @@ getopt.o : getopt.c getopt.h
|
||||
getopt1.o : getopt1.c getopt.h
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/getopt1.c
|
||||
|
||||
getline.o : getline.cc getline.h
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/getline.cc
|
||||
|
||||
hash.o : hash.cc hash.h
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/hash.cc
|
||||
|
||||
|
4952
contrib/gperf/lib/configure
vendored
4952
contrib/gperf/lib/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,14 @@
|
||||
dnl autoconf configuration for gperf/lib
|
||||
|
||||
dnl Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
dnl written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
dnl Copyright (C) 1998, 2002, 2005, 2007 Free Software Foundation, Inc.
|
||||
dnl Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
dnl and Bruno Haible <bruno@clisp.org>.
|
||||
dnl
|
||||
dnl This file is part of GNU GPERF.
|
||||
dnl
|
||||
dnl GNU GPERF is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 1, or (at your option)
|
||||
dnl the Free Software Foundation; either version 2, or (at your option)
|
||||
dnl any later version.
|
||||
dnl
|
||||
dnl GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,10 +17,11 @@ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with GNU GPERF; see the file COPYING. If not, write to the
|
||||
dnl Free Software Foundation, 59 Temple Place - Suite 330, Boston,
|
||||
dnl MA 02111-1307, USA.
|
||||
dnl along with this program; see the file COPYING.
|
||||
dnl If not, write to the Free Software Foundation, Inc.,
|
||||
dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT(hash.cc)
|
||||
AC_PROG_MAKE_SET
|
||||
dnl
|
||||
@ -33,7 +35,7 @@ AC_PROG_CXX
|
||||
dnl sets variable CXX
|
||||
AC_PROG_CXXCPP
|
||||
dnl sets variable CXXCPP
|
||||
CL_PROG_RANLIB
|
||||
AC_PROG_RANLIB
|
||||
dnl sets variable RANLIB
|
||||
CL_PROG_INSTALL
|
||||
dnl sets variables INSTALL, INSTALL_DATA, INSTALL_PROGRAM
|
119
contrib/gperf/lib/getline.cc
Normal file
119
contrib/gperf/lib/getline.cc
Normal file
@ -0,0 +1,119 @@
|
||||
/* getline.c -- Replacement for GNU C library function getline
|
||||
|
||||
Copyright (C) 1993, 1996, 2001-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */
|
||||
|
||||
/* Specification. */
|
||||
#include "getline.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Always add at least this many bytes when extending the buffer. */
|
||||
#define MIN_CHUNK 64
|
||||
|
||||
/* Reads up to (and including) a TERMINATOR from STREAM into *LINEPTR + OFFSET
|
||||
(and null-terminate it). *LINEPTR is a pointer returned from new [] (or
|
||||
NULL), pointing to *N characters of space. It is realloc'd as
|
||||
necessary. Returns the number of characters read (not including the
|
||||
null terminator), or -1 on error or immediate EOF.
|
||||
NOTE: There is another getstr() function declared in <curses.h>. */
|
||||
|
||||
static int
|
||||
getstr (char **lineptr, size_t *n, FILE *stream, char terminator, size_t offset)
|
||||
{
|
||||
size_t nchars_avail; /* Allocated but unused chars in *LINEPTR. */
|
||||
char *read_pos; /* Where we're reading into *LINEPTR. */
|
||||
|
||||
if (!lineptr || !n || !stream)
|
||||
return -1;
|
||||
|
||||
if (!*lineptr)
|
||||
{
|
||||
*n = MIN_CHUNK;
|
||||
*lineptr = new char[*n];
|
||||
}
|
||||
|
||||
nchars_avail = *n - offset;
|
||||
read_pos = *lineptr + offset;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
register int c = getc (stream);
|
||||
|
||||
/* We always want at least one char left in the buffer, since we
|
||||
always (unless we get an error while reading the first char)
|
||||
NUL-terminate the line buffer. */
|
||||
|
||||
assert (*n - nchars_avail == (size_t) (read_pos - *lineptr));
|
||||
if (nchars_avail < 2)
|
||||
{
|
||||
if (*n > MIN_CHUNK)
|
||||
*n *= 2;
|
||||
else
|
||||
*n += MIN_CHUNK;
|
||||
|
||||
nchars_avail = *n + *lineptr - read_pos;
|
||||
char *new_line = new char[*n];
|
||||
if (*lineptr)
|
||||
{
|
||||
memcpy (new_line, *lineptr, read_pos - *lineptr);
|
||||
delete[] *lineptr;
|
||||
}
|
||||
*lineptr = new_line;
|
||||
read_pos = *n - nchars_avail + *lineptr;
|
||||
assert (*n - nchars_avail == (size_t) (read_pos - *lineptr));
|
||||
}
|
||||
|
||||
if (c == EOF || ferror (stream))
|
||||
{
|
||||
/* Return partial line, if any. */
|
||||
if (read_pos == *lineptr)
|
||||
return -1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
*read_pos++ = c;
|
||||
nchars_avail--;
|
||||
|
||||
if (c == terminator)
|
||||
/* Return the line. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Done - NUL terminate and return the number of chars read. */
|
||||
*read_pos = '\0';
|
||||
|
||||
return read_pos - (*lineptr + offset);
|
||||
}
|
||||
|
||||
int
|
||||
get_line (char **lineptr, size_t *n, FILE *stream)
|
||||
{
|
||||
return getstr (lineptr, n, stream, '\n', 0);
|
||||
}
|
||||
|
||||
int
|
||||
get_delim (char **lineptr, size_t *n, int delimiter, FILE *stream)
|
||||
{
|
||||
return getstr (lineptr, n, stream, delimiter, 0);
|
||||
}
|
41
contrib/gperf/lib/getline.h
Normal file
41
contrib/gperf/lib/getline.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 1995, 2000-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
#ifndef GETLINE_H_
|
||||
# define GETLINE_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
|
||||
/* Like the glibc functions get_line and get_delim, except that the result
|
||||
must be freed using delete[], not free(). */
|
||||
|
||||
/* Reads up to (and including) a newline from STREAM into *LINEPTR
|
||||
(and null-terminate it). *LINEPTR is a pointer returned from new [] (or
|
||||
NULL), pointing to *N characters of space. It is realloc'd as
|
||||
necessary. Returns the number of characters read (not including the
|
||||
null terminator), or -1 on error or immediate EOF. */
|
||||
extern int get_line (char **lineptr, size_t *n, FILE *stream);
|
||||
|
||||
/* Reads up to (and including) a DELIMITER from STREAM into *LINEPTR
|
||||
(and null-terminate it). *LINEPTR is a pointer returned from new [] (or
|
||||
NULL), pointing to *N characters of space. It is realloc'd as
|
||||
necessary. Returns the number of characters read (not including the
|
||||
null terminator), or -1 on error or immediate EOF. */
|
||||
extern int get_delim (char **lineptr, size_t *n, int delimiter, FILE *stream);
|
||||
|
||||
#endif /* not GETLINE_H_ */
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (C) 1990, 2000 Free Software Foundation
|
||||
written by Doug Lea (dl@rocky.oswego.edu)
|
||||
Copyright (C) 1990, 2000, 2002 Free Software Foundation
|
||||
written by Doug Lea <dl@rocky.oswego.edu>
|
||||
*/
|
||||
|
||||
#include <hash.h>
|
||||
@ -12,14 +12,14 @@ Copyright (C) 1990, 2000 Free Software Foundation
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
hashpjw (const char *x, unsigned int len) // From Dragon book, p436
|
||||
hashpjw (const unsigned char *x, unsigned int len) // From Dragon book, p436
|
||||
{
|
||||
unsigned int h = 0;
|
||||
unsigned int g;
|
||||
|
||||
for (; len > 0; len--)
|
||||
{
|
||||
h = (h << 4) + (unsigned char) *x++;
|
||||
h = (h << 4) + *x++;
|
||||
if ((g = h & 0xf0000000) != 0)
|
||||
h = (h ^ (g >> 24)) ^ g;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// This may look like C code, but it is really -*- C++ -*-
|
||||
|
||||
/*
|
||||
Copyright (C) 1988, 1992, 2000 Free Software Foundation
|
||||
written by Doug Lea (dl@rocky.oswego.edu)
|
||||
Copyright (C) 1988, 1992, 2000, 2002 Free Software Foundation
|
||||
written by Doug Lea <dl@rocky.oswego.edu>
|
||||
*/
|
||||
|
||||
#ifndef _hash_h
|
||||
@ -10,6 +10,6 @@ Copyright (C) 1988, 1992, 2000 Free Software Foundation
|
||||
|
||||
/* a hash function for char[] arrays using the
|
||||
method described in Aho, Sethi, & Ullman, p 436. */
|
||||
extern unsigned int hashpjw (const char *string, unsigned int len);
|
||||
extern unsigned int hashpjw (const unsigned char *string, unsigned int len);
|
||||
|
||||
#endif
|
||||
|
@ -1,13 +1,14 @@
|
||||
# Makefile for gperf/src
|
||||
|
||||
# Copyright (C) 1989, 1992, 1993, 1998, 2000 Free Software Foundation, Inc.
|
||||
# written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
# Copyright (C) 1989, 1992, 1993, 1998, 2000, 2002, 2006 Free Software Foundation, Inc.
|
||||
# Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
# and Bruno Haible <bruno@clisp.org>.
|
||||
#
|
||||
# This file is part of GNU GPERF.
|
||||
#
|
||||
# GNU GPERF is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 1, or (at your option)
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,8 +17,9 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
# along with this program; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
@ -41,6 +43,8 @@ CXXFLAGS = @CXXFLAGS@
|
||||
CXXCPP = @CXXCPP@
|
||||
# Both C and C++ compiler
|
||||
LDFLAGS = @LDFLAGS@
|
||||
OBJEXT = @OBJEXT@
|
||||
EXEEXT = @EXEEXT@
|
||||
# Other
|
||||
MV = mv
|
||||
LN = ln
|
||||
@ -59,12 +63,12 @@ SHELL = /bin/sh
|
||||
|
||||
VPATH = $(srcdir)
|
||||
|
||||
OBJECTS = new.o options.o iterator.o main.o gen-perf.o key-list.o list-node.o \
|
||||
hash-table.o bool-array.o read-line.o trace.o vectors.o version.o
|
||||
LIBS = ../lib/libgp.a -lm
|
||||
OBJECTS = version.$(OBJEXT) positions.$(OBJEXT) options.$(OBJEXT) keyword.$(OBJEXT) keyword-list.$(OBJEXT) \
|
||||
input.$(OBJEXT) bool-array.$(OBJEXT) hash-table.$(OBJEXT) search.$(OBJEXT) output.$(OBJEXT) main.$(OBJEXT)
|
||||
LIBS = ../lib/libgp.a @GPERF_LIBM@
|
||||
CPPFLAGS = -I. -I$(srcdir)/../lib
|
||||
|
||||
TARGETPROG = gperf
|
||||
TARGETPROG = gperf$(EXEEXT)
|
||||
|
||||
all : $(TARGETPROG)
|
||||
|
||||
@ -83,43 +87,38 @@ $(TARGETPROG): $(OBJECTS)
|
||||
# Dependencies.
|
||||
CONFIG_H = config.h
|
||||
VERSION_H = version.h
|
||||
VECTORS_H = vectors.h
|
||||
TRACE_H = trace.h
|
||||
READ_LINE_H = read-line.h read-line.icc $(TRACE_H)
|
||||
OPTIONS_H = options.h options.icc $(TRACE_H)
|
||||
LIST_NODE_H = list-node.h $(VECTORS_H)
|
||||
KEY_LIST_H = key-list.h $(LIST_NODE_H) $(VECTORS_H) $(READ_LINE_H)
|
||||
ITERATOR_H = iterator.h
|
||||
HASH_TABLE_H = hash-table.h $(LIST_NODE_H)
|
||||
BOOL_ARRAY_H = bool-array.h bool-array.icc $(TRACE_H) $(OPTIONS_H)
|
||||
GEN_PERF_H = gen-perf.h $(KEY_LIST_H) $(BOOL_ARRAY_H)
|
||||
POSITIONS_H = positions.h positions.icc
|
||||
OPTIONS_H = options.h options.icc $(POSITIONS_H)
|
||||
KEYWORD_H = keyword.h keyword.icc
|
||||
KEYWORD_LIST_H = keyword-list.h keyword-list.icc $(KEYWORD_H)
|
||||
INPUT_H = input.h $(KEYWORD_LIST_H)
|
||||
BOOL_ARRAY_H = bool-array.h bool-array.icc $(OPTIONS_H)
|
||||
HASH_TABLE_H = hash-table.h $(KEYWORD_H)
|
||||
SEARCH_H = search.h $(KEYWORD_LIST_H) $(POSITIONS_H) $(BOOL_ARRAY_H)
|
||||
OUTPUT_H = output.h $(KEYWORD_LIST_H) $(POSITIONS_H)
|
||||
|
||||
bool-array.o : bool-array.cc $(BOOL_ARRAY_H) $(OPTIONS_H) $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/bool-array.cc
|
||||
gen-perf.o : gen-perf.cc $(GEN_PERF_H) $(OPTIONS_H) $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/gen-perf.cc
|
||||
hash-table.o : hash-table.cc $(HASH_TABLE_H) $(OPTIONS_H) $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/hash-table.cc
|
||||
iterator.o : iterator.cc $(ITERATOR_H) $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/iterator.cc
|
||||
key-list.o : key-list.cc $(KEY_LIST_H) $(OPTIONS_H) $(READ_LINE_H) $(HASH_TABLE_H) $(TRACE_H) $(VERSION_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/key-list.cc
|
||||
list-node.o : list-node.cc $(LIST_NODE_H) $(OPTIONS_H) $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/list-node.cc
|
||||
main.o : main.cc $(OPTIONS_H) $(GEN_PERF_H) $(TRACE_H) $(CONFIG_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/main.cc
|
||||
new.o : new.cc $(TRACE_H) $(CONFIG_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/new.cc
|
||||
options.o : options.cc $(OPTIONS_H) $(ITERATOR_H) $(TRACE_H) $(VECTORS_H) $(VERSION_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/options.cc
|
||||
read-line.o : read-line.cc $(READ_LINE_H) $(OPTIONS_H) $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/read-line.cc
|
||||
trace.o : trace.cc $(TRACE_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/trace.cc
|
||||
vectors.o : vectors.cc $(VECTORS_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/vectors.cc
|
||||
version.o : version.cc $(VERSION_H)
|
||||
version.$(OBJEXT): version.cc $(VERSION_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/version.cc
|
||||
positions.$(OBJEXT): positions.cc $(POSITIONS_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/positions.cc
|
||||
options.$(OBJEXT): options.cc $(OPTIONS_H) $(VERSION_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/options.cc
|
||||
keyword.$(OBJEXT): keyword.cc $(KEYWORD_H) $(POSITIONS_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/keyword.cc
|
||||
keyword-list.$(OBJEXT): keyword-list.cc $(KEYWORD_LIST_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/keyword-list.cc
|
||||
input.$(OBJEXT): input.cc $(INPUT_H) $(OPTIONS_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/input.cc
|
||||
bool-array.$(OBJEXT): bool-array.cc $(BOOL_ARRAY_H) $(OPTIONS_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/bool-array.cc
|
||||
hash-table.$(OBJEXT): hash-table.cc $(HASH_TABLE_H) $(OPTIONS_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/hash-table.cc
|
||||
search.$(OBJEXT): search.cc $(SEARCH_H) $(OPTIONS_H) $(HASH_TABLE_H) $(CONFIG_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/search.cc
|
||||
output.$(OBJEXT): output.cc $(OUTPUT_H) $(OPTIONS_H) $(VERSION_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/output.cc
|
||||
main.$(OBJEXT): main.cc $(OPTIONS_H) $(INPUT_H) $(SEARCH_H) $(OUTPUT_H)
|
||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(srcdir)/main.cc
|
||||
|
||||
install : all force
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
|
||||
@ -136,7 +135,7 @@ check : all
|
||||
mostlyclean : clean
|
||||
|
||||
clean : force
|
||||
$(RM) *~ *.s *.o *.a $(TARGETPROG) core
|
||||
$(RM) *~ *.s *.$(OBJEXT) *.a $(TARGETPROG) core
|
||||
|
||||
distclean : clean
|
||||
$(RM) config.status config.log config.cache Makefile config.h
|
||||
|
@ -1,43 +1,41 @@
|
||||
/* Fast lookup table abstraction implemented as an Iteration Number Array
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Specification. */
|
||||
#include "bool-array.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "options.h"
|
||||
#include "trace.h"
|
||||
|
||||
STORAGE_TYPE * Bool_Array::storage_array;
|
||||
STORAGE_TYPE Bool_Array::iteration_number;
|
||||
unsigned int Bool_Array::size;
|
||||
|
||||
/* Prints out debugging diagnostics. */
|
||||
|
||||
Bool_Array::~Bool_Array (void)
|
||||
/* Frees this object. */
|
||||
Bool_Array::~Bool_Array ()
|
||||
{
|
||||
T (Trace t ("Bool_Array::~Bool_Array");)
|
||||
/* Print out debugging diagnostics. */
|
||||
if (option[DEBUG])
|
||||
fprintf (stderr, "\ndumping boolean array information\n"
|
||||
"size = %d\niteration number = %d\nend of array dump\n",
|
||||
size, iteration_number);
|
||||
_size, _iteration_number);
|
||||
delete[] const_cast<unsigned int *>(_storage_array);
|
||||
}
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
@ -2,54 +2,67 @@
|
||||
|
||||
/* Simple lookup table abstraction implemented as an Iteration Number Array.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Define and implement a simple boolean array abstraction,
|
||||
uses an Iteration Numbering implementation to save on initialization time. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef bool_array_h
|
||||
#define bool_array_h 1
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
#ifdef LO_CAL
|
||||
/* If we are on a memory diet then we'll only make these use a limited
|
||||
amount of storage space. */
|
||||
typedef unsigned short STORAGE_TYPE;
|
||||
#else
|
||||
typedef unsigned int STORAGE_TYPE;
|
||||
#endif
|
||||
/* A Bool_Array instance is a bit array of fixed size, optimized for being
|
||||
filled sparsely and cleared frequently. For example, when processing
|
||||
tests/chill.gperf, the array will be:
|
||||
- of size 15391,
|
||||
- clear will be called 3509 times,
|
||||
- set_bit will be called 300394 times.
|
||||
With a conventional bit array implementation, clear would be too slow.
|
||||
With a tree/hash based bit array implementation, set_bit would be slower. */
|
||||
|
||||
class Bool_Array
|
||||
{
|
||||
private:
|
||||
static STORAGE_TYPE *storage_array; /* Initialization of the index space. */
|
||||
static STORAGE_TYPE iteration_number; /* Keep track of the current iteration. */
|
||||
static unsigned int size; /* Keep track of array size. */
|
||||
|
||||
public:
|
||||
Bool_Array (void);
|
||||
~Bool_Array (void);
|
||||
static void init (STORAGE_TYPE *buffer, unsigned int s);
|
||||
static int find (int hash_value);
|
||||
static void reset (void);
|
||||
/* Initializes the bit array with room for SIZE bits, numbered from
|
||||
0 to SIZE-1. */
|
||||
Bool_Array (unsigned int size);
|
||||
|
||||
/* Frees this object. */
|
||||
~Bool_Array ();
|
||||
|
||||
/* Resets all bits to zero. */
|
||||
void clear ();
|
||||
|
||||
/* Sets the specified bit to true.
|
||||
Returns its previous value (false or true). */
|
||||
bool set_bit (unsigned int index);
|
||||
|
||||
private:
|
||||
/* Size of array. */
|
||||
unsigned int const _size;
|
||||
|
||||
/* Current iteration number. Always nonzero. Starts out as 1, and is
|
||||
incremented each time clear() is called. */
|
||||
unsigned int _iteration_number;
|
||||
|
||||
/* For each index, we store in storage_array[index] the iteration_number at
|
||||
the time set_bit(index) was last called. */
|
||||
unsigned int * const _storage_array;
|
||||
};
|
||||
|
||||
#ifdef __OPTIMIZE__ /* efficiency hack! */
|
||||
|
@ -1,84 +1,77 @@
|
||||
/* Inline Functions for bool-array.{h,cc}.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
// This needs:
|
||||
//#include <stdio.h>
|
||||
//#include <string.h>
|
||||
//#include "options.h"
|
||||
//#include "trace.h"
|
||||
|
||||
/* Initializes the bit array with room for SIZE bits, numbered from
|
||||
0 to SIZE-1. */
|
||||
INLINE
|
||||
Bool_Array::Bool_Array (void)
|
||||
Bool_Array::Bool_Array (unsigned int size)
|
||||
: _size (size),
|
||||
_iteration_number (1),
|
||||
_storage_array (new unsigned int [size])
|
||||
{
|
||||
T (Trace t ("Bool_Array::Bool_Array");)
|
||||
storage_array = 0;
|
||||
iteration_number = size = 0;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
Bool_Array::init (STORAGE_TYPE *buffer, unsigned int s)
|
||||
{
|
||||
T (Trace t ("Bool_Array::init");)
|
||||
size = s;
|
||||
iteration_number = 1;
|
||||
storage_array = buffer;
|
||||
memset (storage_array, 0, s * sizeof (*storage_array));
|
||||
memset (_storage_array, 0, size * sizeof (_storage_array[0]));
|
||||
if (option[DEBUG])
|
||||
fprintf (stderr, "\nbool array size = %d, total bytes = %d\n",
|
||||
size, (unsigned int) (size * sizeof (*storage_array)));
|
||||
_size,
|
||||
static_cast<unsigned int> (_size * sizeof (_storage_array[0])));
|
||||
}
|
||||
|
||||
INLINE int
|
||||
Bool_Array::find (int index)
|
||||
/* Sets the specified bit to true.
|
||||
Returns its previous value (false or true). */
|
||||
INLINE bool
|
||||
Bool_Array::set_bit (unsigned int index)
|
||||
{
|
||||
T (Trace t ("Bool_Array::find");)
|
||||
if (storage_array[index] == iteration_number)
|
||||
return 1;
|
||||
if (_storage_array[index] == _iteration_number)
|
||||
/* The bit was set since the last clear() call. */
|
||||
return true;
|
||||
else
|
||||
{
|
||||
storage_array[index] = iteration_number;
|
||||
return 0;
|
||||
/* The last operation on this bit was clear(). Set it now. */
|
||||
_storage_array[index] = _iteration_number;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Resets all bits to zero. */
|
||||
INLINE void
|
||||
Bool_Array::reset (void)
|
||||
Bool_Array::clear ()
|
||||
{
|
||||
T (Trace t ("Bool_Array::reset");)
|
||||
/* If we wrap around it's time to zero things out again! However, this only
|
||||
occurs once about every 2^31 or 2^15 iterations, so it should probably
|
||||
never happen! */
|
||||
occurs once about every 2^32 iterations, so it will not happen more
|
||||
frequently than once per second. */
|
||||
|
||||
if (++iteration_number == 0)
|
||||
if (++_iteration_number == 0)
|
||||
{
|
||||
_iteration_number = 1;
|
||||
memset (_storage_array, 0, _size * sizeof (_storage_array[0]));
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, "(re-initializing bool_array)...");
|
||||
fflush (stderr);
|
||||
}
|
||||
iteration_number = 1;
|
||||
memset (storage_array, 0, size * sizeof (*storage_array));
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, "done\n");
|
||||
fprintf (stderr, "(re-initialized bool_array)\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if the C++ compiler supports "throw ()" declarations. */
|
||||
#undef HAVE_THROW_DECL
|
||||
/* Define if the C++ compiler supports stack-allocated variable-size arrays.
|
||||
*/
|
||||
#undef HAVE_DYNAMIC_ARRAY
|
||||
|
||||
/* Define if you have the getrlimit function. */
|
||||
#undef HAVE_GETRLIMIT
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define if you have the setrlimit function. */
|
||||
#undef HAVE_SETRLIMIT
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define if you have the <sys/resource.h> header file. */
|
||||
#undef HAVE_SYS_RESOURCE_H
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
20
contrib/gperf/src/config.h_vms
Normal file
20
contrib/gperf/src/config.h_vms
Normal file
@ -0,0 +1,20 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if the C++ compiler supports stack-allocated variable-size arrays.
|
||||
*/
|
||||
#undef HAVE_DYNAMIC_ARRAY
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
5287
contrib/gperf/src/configure
vendored
5287
contrib/gperf/src/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,14 @@
|
||||
dnl autoconf configuration for gperf/src
|
||||
|
||||
dnl Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||
dnl written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
dnl Copyright (C) 1998, 2000, 2002-2003, 2007 Free Software Foundation, Inc.
|
||||
dnl Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
dnl and Bruno Haible <bruno@clisp.org>.
|
||||
dnl
|
||||
dnl This file is part of GNU GPERF.
|
||||
dnl
|
||||
dnl GNU GPERF is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 1, or (at your option)
|
||||
dnl the Free Software Foundation; either version 2, or (at your option)
|
||||
dnl any later version.
|
||||
dnl
|
||||
dnl GNU GPERF is distributed in the hope that it will be useful,
|
||||
@ -16,11 +17,12 @@ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with GNU GPERF; see the file COPYING. If not, write to the
|
||||
dnl Free Software Foundation, 59 Temple Place - Suite 330, Boston,
|
||||
dnl MA 02111-1307, USA.
|
||||
dnl along with this program; see the file COPYING.
|
||||
dnl If not, write to the Free Software Foundation, Inc.,
|
||||
dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
AC_INIT(gen-perf.cc)
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT(main.cc)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
AC_PROG_MAKE_SET
|
||||
dnl
|
||||
@ -39,32 +41,27 @@ CL_PROG_INSTALL
|
||||
dnl
|
||||
dnl checks for compiler characteristics
|
||||
dnl
|
||||
AC_MSG_CHECKING([for working throw()])
|
||||
AC_CACHE_VAL(gp_cv_cxx_throw_decl,[
|
||||
AC_MSG_CHECKING([for stack-allocated variable-size arrays])
|
||||
AC_CACHE_VAL(gp_cv_cxx_dynamic_array, [
|
||||
AC_LANG_SAVE()
|
||||
AC_LANG_CPLUSPLUS()
|
||||
AC_TRY_COMPILE([#include <stdlib.h>
|
||||
void operator delete (void* ptr) throw() {}], [],
|
||||
gp_cv_cxx_throw_decl=yes, gp_cv_cxx_throw_decl=no)
|
||||
AC_TRY_COMPILE([int func (int n) { int dynamic_array[n]; }], [],
|
||||
gp_cv_cxx_dynamic_array=yes, gp_cv_cxx_dynamic_array=no)
|
||||
AC_LANG_RESTORE()
|
||||
])
|
||||
AC_MSG_RESULT([$]gp_cv_cxx_throw_decl)
|
||||
if test [$]gp_cv_cxx_throw_decl = yes; then
|
||||
AC_DEFINE(HAVE_THROW_DECL)
|
||||
AC_MSG_RESULT($gp_cv_cxx_dynamic_array)
|
||||
if test $gp_cv_cxx_dynamic_array = yes; then
|
||||
AC_DEFINE(HAVE_DYNAMIC_ARRAY, 1,
|
||||
[Define if the C++ compiler supports stack-allocated variable-size arrays.])
|
||||
fi
|
||||
dnl
|
||||
dnl checks for functions and declarations
|
||||
dnl
|
||||
AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h)
|
||||
dnl DEFs HAVE_UNISTD_H, HAVE_SYS_TIME_H, HAVE_SYS_RESOURCE_H
|
||||
if test $ac_cv_header_sys_resource_h = yes; then
|
||||
AC_CHECK_FUNCS(getrlimit)
|
||||
dnl DEFS HAVE_GETRLIMIT
|
||||
if test $ac_cv_func_getrlimit = yes; then
|
||||
AC_CHECK_FUNCS(setrlimit)
|
||||
dnl DEFS HAVE_SETRLIMIT
|
||||
fi
|
||||
fi
|
||||
dnl
|
||||
dnl checks for libraries
|
||||
dnl
|
||||
AC_CHECK_LIB(m, rand, GPERF_LIBM="-lm", GPERF_LIBM="")
|
||||
AC_SUBST(GPERF_LIBM)
|
||||
dnl
|
||||
dnl That's it.
|
||||
dnl
|
@ -1,359 +0,0 @@
|
||||
/* Provides high-level routines to manipulate the keywork list
|
||||
structures the code generation output.
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* declares rand(), srand() */
|
||||
#include <time.h> /* declares time() */
|
||||
#include "options.h"
|
||||
#include "gen-perf.h"
|
||||
#include "trace.h"
|
||||
|
||||
/* Efficiently returns the least power of two greater than or equal to X! */
|
||||
#define POW(X) ((!X)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X)))
|
||||
|
||||
/* Reads input keys, possibly applies the reordering heuristic, sets the
|
||||
maximum associated value size (rounded up to the nearest power of 2),
|
||||
may initialize the associated values array, and determines the maximum
|
||||
hash table size. Note: using the random numbers is often helpful,
|
||||
though not as deterministic, of course! */
|
||||
|
||||
Gen_Perf::Gen_Perf (void)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::Gen_Perf");)
|
||||
int asso_value_max;
|
||||
int non_linked_length;
|
||||
|
||||
Key_List::read_keys ();
|
||||
if (option[ORDER])
|
||||
reorder ();
|
||||
asso_value_max = option.get_asso_max ();
|
||||
non_linked_length = Key_List::keyword_list_length ();
|
||||
num_done = 1;
|
||||
fewest_collisions = 0;
|
||||
if (asso_value_max == 0)
|
||||
asso_value_max = non_linked_length;
|
||||
else if (asso_value_max > 0)
|
||||
asso_value_max *= non_linked_length;
|
||||
else /* if (asso_value_max < 0) */
|
||||
asso_value_max = non_linked_length / -asso_value_max;
|
||||
option.set_asso_max (POW (asso_value_max));
|
||||
|
||||
if (option[RANDOM])
|
||||
{
|
||||
srand ((long) time (0));
|
||||
|
||||
for (int i = 0; i < ALPHA_SIZE; i++)
|
||||
asso_values[i] = (rand () & asso_value_max - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int asso_value = option.initial_value ();
|
||||
|
||||
if (asso_value) /* Initialize array if user requests non-zero default. */
|
||||
for (int i = ALPHA_SIZE - 1; i >= 0; i--)
|
||||
asso_values[i] = asso_value & option.get_asso_max () - 1;
|
||||
}
|
||||
max_hash_value = Key_List::max_key_length () + option.get_asso_max () *
|
||||
option.get_max_keysig_size ();
|
||||
|
||||
if (option[DEBUG])
|
||||
fprintf (stderr, "total non-linked keys = %d\nmaximum associated value is %d"
|
||||
"\nmaximum size of generated hash table is %d\n",
|
||||
non_linked_length, asso_value_max, max_hash_value);
|
||||
}
|
||||
|
||||
/* Merge two disjoint hash key multisets to form the ordered disjoint union of the sets.
|
||||
(In a multiset, an element can occur multiple times.)
|
||||
Precondition: both set_1 and set_2 must be ordered. Returns the length
|
||||
of the combined set. */
|
||||
|
||||
inline int
|
||||
Gen_Perf::compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::compute_disjoint_union");)
|
||||
char *base = set_3;
|
||||
|
||||
while (size_1 > 0 && size_2 > 0)
|
||||
if (*set_1 == *set_2)
|
||||
set_1++, size_1--, set_2++, size_2--;
|
||||
else
|
||||
{
|
||||
char next;
|
||||
if (*set_1 < *set_2)
|
||||
next = *set_1++, size_1--;
|
||||
else
|
||||
next = *set_2++, size_2--;
|
||||
if (set_3 == base || next != set_3[-1])
|
||||
*set_3++ = next;
|
||||
}
|
||||
|
||||
while (size_1 > 0)
|
||||
{
|
||||
char next;
|
||||
next = *set_1++, size_1--;
|
||||
if (set_3 == base || next != set_3[-1])
|
||||
*set_3++ = next;
|
||||
}
|
||||
|
||||
while (size_2 > 0)
|
||||
{
|
||||
char next;
|
||||
next = *set_2++, size_2--;
|
||||
if (set_3 == base || next != set_3[-1])
|
||||
*set_3++ = next;
|
||||
}
|
||||
return set_3 - base;
|
||||
}
|
||||
|
||||
/* Sort the UNION_SET in increasing frequency of occurrence.
|
||||
This speeds up later processing since we may assume the resulting
|
||||
set (Set_3, in this case), is ordered. Uses insertion sort, since
|
||||
the UNION_SET is typically short. */
|
||||
|
||||
inline void
|
||||
Gen_Perf::sort_set (char *union_set, int len)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::sort_set");)
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = len - 1; i < j; i++)
|
||||
{
|
||||
int curr;
|
||||
char tmp;
|
||||
|
||||
for (curr = i + 1, tmp = union_set[curr];
|
||||
curr > 0 && occurrences[(unsigned char)tmp] < occurrences[(unsigned char)(union_set[curr-1])];
|
||||
curr--)
|
||||
union_set[curr] = union_set[curr - 1];
|
||||
|
||||
union_set[curr] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate a key set's hash value. */
|
||||
|
||||
inline int
|
||||
Gen_Perf::hash (List_Node *key_node)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::hash");)
|
||||
int sum = option[NOLENGTH] ? 0 : key_node->key_length;
|
||||
|
||||
const char *p = key_node->char_set;
|
||||
int i = key_node->char_set_length;
|
||||
for (; i > 0; p++, i--)
|
||||
sum += asso_values[(unsigned char)(*p)];
|
||||
|
||||
return key_node->hash_value = sum;
|
||||
}
|
||||
|
||||
/* Find out how character value change affects successfully hashed items.
|
||||
Returns FALSE if no other hash values are affected, else returns TRUE.
|
||||
Note that because Option.Get_Asso_Max is a power of two we can guarantee
|
||||
that all legal Asso_Values are visited without repetition since
|
||||
Option.Get_Jump was forced to be an odd value! */
|
||||
|
||||
inline int
|
||||
Gen_Perf::affects_prev (char c, List_Node *curr)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::affects_prev");)
|
||||
int original_char = asso_values[(unsigned char)c];
|
||||
int total_iterations = !option[FAST]
|
||||
? option.get_asso_max () : option.get_iterations () ? option.get_iterations () : keyword_list_length ();
|
||||
|
||||
/* Try all legal associated values. */
|
||||
|
||||
for (int i = total_iterations - 1; i >= 0; i--)
|
||||
{
|
||||
int collisions = 0;
|
||||
|
||||
asso_values[(unsigned char)c] =
|
||||
(asso_values[(unsigned char)c] + (option.get_jump () ? option.get_jump () : rand ()))
|
||||
& (option.get_asso_max () - 1);
|
||||
|
||||
/* Iteration Number array is a win, O(1) intialization time! */
|
||||
reset ();
|
||||
|
||||
/* See how this asso_value change affects previous keywords. If
|
||||
it does better than before we'll take it! */
|
||||
|
||||
for (List_Node *ptr = head;
|
||||
!Bool_Array::find (hash (ptr)) || ++collisions < fewest_collisions;
|
||||
ptr = ptr->next)
|
||||
if (ptr == curr)
|
||||
{
|
||||
fewest_collisions = collisions;
|
||||
if (option[DEBUG])
|
||||
fprintf (stderr, "- resolved after %d iterations", total_iterations - i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore original values, no more tries. */
|
||||
asso_values[(unsigned char)c] = original_char;
|
||||
/* If we're this far it's time to try the next character.... */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Change a character value, try least-used characters first. */
|
||||
|
||||
void
|
||||
Gen_Perf::change (List_Node *prior, List_Node *curr)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::change");)
|
||||
static char *union_set;
|
||||
int union_set_length;
|
||||
|
||||
if (!union_set)
|
||||
union_set = new char [2 * option.get_max_keysig_size ()];
|
||||
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, "collision on keyword #%d, prior = \"%.*s\", curr = \"%.*s\" hash = %d\n",
|
||||
num_done,
|
||||
prior->key_length, prior->key,
|
||||
curr->key_length, curr->key,
|
||||
curr->hash_value);
|
||||
fflush (stderr);
|
||||
}
|
||||
union_set_length = compute_disjoint_union (prior->char_set, prior->char_set_length, curr->char_set, curr->char_set_length, union_set);
|
||||
sort_set (union_set, union_set_length);
|
||||
|
||||
/* Try changing some values, if change doesn't alter other values continue normal action. */
|
||||
fewest_collisions++;
|
||||
|
||||
const char *p = union_set;
|
||||
int i = union_set_length;
|
||||
for (; i > 0; p++, i--)
|
||||
if (!affects_prev (*p, curr))
|
||||
{
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, " by changing asso_value['%c'] (char #%td) to %d\n",
|
||||
*p, p - union_set + 1, asso_values[(unsigned char)(*p)]);
|
||||
fflush (stderr);
|
||||
}
|
||||
return; /* Good, doesn't affect previous hash values, we'll take it. */
|
||||
}
|
||||
|
||||
for (List_Node *ptr = head; ptr != curr; ptr = ptr->next)
|
||||
hash (ptr);
|
||||
|
||||
hash (curr);
|
||||
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, "** collision not resolved after %d iterations, %d duplicates remain, continuing...\n",
|
||||
!option[FAST] ? option.get_asso_max () : option.get_iterations () ? option.get_iterations () : keyword_list_length (),
|
||||
fewest_collisions + total_duplicates);
|
||||
fflush (stderr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Does the hard stuff....
|
||||
Initializes the Iteration Number array, and attempts to find a perfect
|
||||
function that will hash all the key words without getting any
|
||||
duplications. This is made much easier since we aren't attempting
|
||||
to generate *minimum* functions, only perfect ones.
|
||||
If we can't generate a perfect function in one pass *and* the user
|
||||
hasn't enabled the DUP option, we'll inform the user to try the
|
||||
randomization option, use -D, or choose alternative key positions.
|
||||
The alternatives (e.g., back-tracking) are too time-consuming, i.e,
|
||||
exponential in the number of keys. */
|
||||
|
||||
int
|
||||
Gen_Perf::operator() (void)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::operator()");)
|
||||
#if LARGE_STACK_ARRAYS
|
||||
STORAGE_TYPE buffer[max_hash_value + 1];
|
||||
#else
|
||||
// Note: we don't use new, because that invokes a custom operator new.
|
||||
STORAGE_TYPE *buffer
|
||||
= (STORAGE_TYPE*) malloc (sizeof(STORAGE_TYPE) * (max_hash_value + 1));
|
||||
if (buffer == NULL)
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
Bool_Array::init (buffer, max_hash_value + 1);
|
||||
|
||||
List_Node *curr;
|
||||
for (curr = head; curr; curr = curr->next)
|
||||
{
|
||||
hash (curr);
|
||||
|
||||
for (List_Node *ptr = head; ptr != curr; ptr = ptr->next)
|
||||
if (ptr->hash_value == curr->hash_value)
|
||||
{
|
||||
change (ptr, curr);
|
||||
break;
|
||||
}
|
||||
num_done++;
|
||||
}
|
||||
|
||||
/* Make one final check, just to make sure nothing weird happened.... */
|
||||
|
||||
Bool_Array::reset ();
|
||||
|
||||
for (curr = head; curr; curr = curr->next)
|
||||
if (Bool_Array::find (hash (curr)))
|
||||
if (option[DUP]) /* Keep track of this number... */
|
||||
total_duplicates++;
|
||||
else /* Yow, big problems. we're outta here! */
|
||||
{
|
||||
fprintf (stderr, "\nInternal error, duplicate value %d:\n"
|
||||
"try options -D or -r, or use new key positions.\n\n", hash (curr));
|
||||
#if !LARGE_STACK_ARRAYS
|
||||
free ((char *) buffer);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Sorts the key word list by hash value, and then outputs the list.
|
||||
The generated hash table code is only output if the early stage of
|
||||
processing turned out O.K. */
|
||||
|
||||
sort ();
|
||||
output ();
|
||||
#if !LARGE_STACK_ARRAYS
|
||||
free ((char *) buffer);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Prints out some diagnostics upon completion. */
|
||||
|
||||
Gen_Perf::~Gen_Perf (void)
|
||||
{
|
||||
T (Trace t ("Gen_Perf::~Gen_Perf");)
|
||||
if (option[DEBUG])
|
||||
{
|
||||
fprintf (stderr, "\ndumping occurrence and associated values tables\n");
|
||||
|
||||
for (int i = 0; i < ALPHA_SIZE; i++)
|
||||
if (occurrences[i])
|
||||
fprintf (stderr, "asso_values[%c] = %6d, occurrences[%c] = %6d\n",
|
||||
i, asso_values[i], i, occurrences[i]);
|
||||
|
||||
fprintf (stderr, "end table dumping\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Provides high-level routines to manipulate the keyword list
|
||||
structures the code generation output.
|
||||
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#ifndef gen_perf_h
|
||||
#define gen_perf_h 1
|
||||
|
||||
#include "key-list.h"
|
||||
#include "bool-array.h"
|
||||
|
||||
class Gen_Perf : private Key_List, private Bool_Array
|
||||
{
|
||||
private:
|
||||
int max_hash_value; /* Maximum possible hash value. */
|
||||
int fewest_collisions; /* Records fewest # of collisions for asso value. */
|
||||
int num_done; /* Number of keywords processed without a collision. */
|
||||
|
||||
void change (List_Node *prior, List_Node *curr);
|
||||
int affects_prev (char c, List_Node *curr);
|
||||
static int hash (List_Node *key_node);
|
||||
static int compute_disjoint_union (const char *set_1, int size_1, const char *set_2, int size_2, char *set_3);
|
||||
static void sort_set (char *union_set, int len);
|
||||
|
||||
public:
|
||||
Gen_Perf (void);
|
||||
~Gen_Perf (void);
|
||||
int operator () (void);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,95 +1,167 @@
|
||||
/* Hash table for checking keyword links. Implemented using double hashing.
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Specification. */
|
||||
#include "hash-table.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* declares memset(), strcmp() */
|
||||
#include <hash.h>
|
||||
#include "options.h"
|
||||
#include "trace.h"
|
||||
|
||||
/* The size of the hash table is always the smallest power of 2 >= the size
|
||||
indicated by the user. This allows several optimizations, including
|
||||
the use of double hashing and elimination of the mod instruction.
|
||||
Note that the size had better be larger than the number of items
|
||||
in the hash table, else there's trouble!!! Note that the memory
|
||||
for the hash table is allocated *outside* the intialization routine.
|
||||
This compromises information hiding somewhat, but greatly reduces
|
||||
memory fragmentation, since we can now use alloca! */
|
||||
/* We use a hash table with double hashing. This is the simplest kind of
|
||||
hash table, given that we always only insert and never remove entries
|
||||
from the hash table. */
|
||||
|
||||
Hash_Table::Hash_Table (List_Node **table_ptr, int s, int ignore_len):
|
||||
table (table_ptr), size (s), collisions (0), ignore_length (ignore_len)
|
||||
/* To make double hashing efficient, there need to be enough spare entries. */
|
||||
static const int size_factor = 10;
|
||||
|
||||
/* We make the size of the hash table a power of 2. This allows for two
|
||||
optimizations: It eliminates the modulo instruction, and allows for an
|
||||
easy secondary hashing function. */
|
||||
|
||||
/* Constructor. */
|
||||
Hash_Table::Hash_Table (unsigned int size, bool ignore_length)
|
||||
: _ignore_length (ignore_length),
|
||||
_collisions (0)
|
||||
{
|
||||
T (Trace t ("Hash_Table::Hash_Table");)
|
||||
memset ((char *) table, 0, size * sizeof (*table));
|
||||
}
|
||||
/* There need to be enough spare entries. */
|
||||
size = size * size_factor;
|
||||
|
||||
Hash_Table::~Hash_Table (void)
|
||||
{
|
||||
T (Trace t ("Hash_Table::~Hash_Table");)
|
||||
if (option[DEBUG])
|
||||
/* Find smallest power of 2 that is >= size. */
|
||||
unsigned int shift = 0;
|
||||
if ((size >> 16) > 0)
|
||||
{
|
||||
int field_width = option.get_max_keysig_size ();
|
||||
|
||||
fprintf (stderr,
|
||||
"\ndumping the hash table\n"
|
||||
"total available table slots = %d, total bytes = %d, total collisions = %d\n"
|
||||
"location, %*s, keyword\n",
|
||||
size, size * (int) sizeof (*table), collisions,
|
||||
field_width, "keysig");
|
||||
|
||||
for (int i = size - 1; i >= 0; i--)
|
||||
if (table[i])
|
||||
fprintf (stderr, "%8d, %*.*s, %.*s\n",
|
||||
i,
|
||||
field_width, table[i]->char_set_length, table[i]->char_set,
|
||||
table[i]->key_length, table[i]->key);
|
||||
|
||||
fprintf (stderr, "\nend dumping hash table\n\n");
|
||||
size = size >> 16;
|
||||
shift += 16;
|
||||
}
|
||||
if ((size >> 8) > 0)
|
||||
{
|
||||
size = size >> 8;
|
||||
shift += 8;
|
||||
}
|
||||
if ((size >> 4) > 0)
|
||||
{
|
||||
size = size >> 4;
|
||||
shift += 4;
|
||||
}
|
||||
if ((size >> 2) > 0)
|
||||
{
|
||||
size = size >> 2;
|
||||
shift += 2;
|
||||
}
|
||||
if ((size >> 1) > 0)
|
||||
{
|
||||
size = size >> 1;
|
||||
shift += 1;
|
||||
}
|
||||
_log_size = shift;
|
||||
_size = 1 << shift;
|
||||
|
||||
/* Allocate table. */
|
||||
_table = new KeywordExt*[_size];
|
||||
memset (_table, 0, _size * sizeof (*_table));
|
||||
}
|
||||
|
||||
/* If the ITEM is already in the hash table return the item found
|
||||
in the table. Otherwise inserts the ITEM, and returns FALSE.
|
||||
Uses double hashing. */
|
||||
|
||||
List_Node *
|
||||
Hash_Table::insert (List_Node *item)
|
||||
/* Destructor. */
|
||||
Hash_Table::~Hash_Table ()
|
||||
{
|
||||
T (Trace t ("Hash_Table::operator()");)
|
||||
unsigned hash_val = hashpjw (item->char_set, item->char_set_length);
|
||||
int probe = hash_val & (size - 1);
|
||||
int increment = ((hash_val ^ item->key_length) | 1) & (size - 1);
|
||||
delete[] _table;
|
||||
}
|
||||
|
||||
while (table[probe])
|
||||
/* Print the table's contents. */
|
||||
void
|
||||
Hash_Table::dump () const
|
||||
{
|
||||
int field_width;
|
||||
|
||||
field_width = 0;
|
||||
{
|
||||
for (int i = _size - 1; i >= 0; i--)
|
||||
if (_table[i])
|
||||
if (field_width < _table[i]->_selchars_length)
|
||||
field_width = _table[i]->_selchars_length;
|
||||
}
|
||||
|
||||
fprintf (stderr,
|
||||
"\ndumping the hash table\n"
|
||||
"total available table slots = %d, total bytes = %d, total collisions = %d\n"
|
||||
"location, %*s, keyword\n",
|
||||
_size, _size * static_cast<unsigned int>(sizeof (*_table)),
|
||||
_collisions, field_width, "keysig");
|
||||
|
||||
for (int i = _size - 1; i >= 0; i--)
|
||||
if (_table[i])
|
||||
{
|
||||
fprintf (stderr, "%8d, ", i);
|
||||
if (field_width > _table[i]->_selchars_length)
|
||||
fprintf (stderr, "%*s", field_width - _table[i]->_selchars_length, "");
|
||||
for (int j = 0; j < _table[i]->_selchars_length; j++)
|
||||
putc (_table[i]->_selchars[j], stderr);
|
||||
fprintf (stderr, ", %.*s\n",
|
||||
_table[i]->_allchars_length, _table[i]->_allchars);
|
||||
}
|
||||
|
||||
fprintf (stderr, "\nend dumping hash table\n\n");
|
||||
}
|
||||
|
||||
/* Compares two items. */
|
||||
inline bool
|
||||
Hash_Table::equal (KeywordExt *item1, KeywordExt *item2) const
|
||||
{
|
||||
return item1->_selchars_length == item2->_selchars_length
|
||||
&& memcmp (item1->_selchars, item2->_selchars,
|
||||
item2->_selchars_length * sizeof (unsigned int))
|
||||
== 0
|
||||
&& (_ignore_length
|
||||
|| item1->_allchars_length == item2->_allchars_length);
|
||||
}
|
||||
|
||||
/* Attempts to insert ITEM in the table. If there is already an equal
|
||||
entry in it, returns it. Otherwise inserts ITEM and returns NULL. */
|
||||
KeywordExt *
|
||||
Hash_Table::insert (KeywordExt *item)
|
||||
{
|
||||
unsigned hash_val =
|
||||
hashpjw (reinterpret_cast<const unsigned char *>(item->_selchars),
|
||||
item->_selchars_length * sizeof (unsigned int));
|
||||
unsigned int probe = hash_val & (_size - 1);
|
||||
unsigned int increment =
|
||||
(((hash_val >> _log_size)
|
||||
^ (_ignore_length ? 0 : item->_allchars_length))
|
||||
<< 1) + 1;
|
||||
/* Note that because _size is a power of 2 and increment is odd,
|
||||
we have gcd(increment,_size) = 1, which guarantees that we'll find
|
||||
an empty entry during the loop. */
|
||||
|
||||
while (_table[probe] != NULL)
|
||||
{
|
||||
if (table[probe]->char_set_length == item->char_set_length
|
||||
&& memcmp (table[probe]->char_set, item->char_set, item->char_set_length) == 0
|
||||
&& (ignore_length || table[probe]->key_length == item->key_length))
|
||||
return table[probe];
|
||||
if (equal (_table[probe], item))
|
||||
return _table[probe];
|
||||
|
||||
collisions++;
|
||||
probe = (probe + increment) & (size - 1);
|
||||
_collisions++;
|
||||
probe = (probe + increment) & (_size - 1);
|
||||
}
|
||||
|
||||
table[probe] = item;
|
||||
return (List_Node *) 0;
|
||||
_table[probe] = item;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2,42 +2,65 @@
|
||||
|
||||
/* Hash table used to check for duplicate keyword entries.
|
||||
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef hash_table_h
|
||||
#define hash_table_h 1
|
||||
|
||||
#include "list-node.h"
|
||||
#include "keyword.h"
|
||||
|
||||
/* Hash table of KeywordExt* entries.
|
||||
Two entries are considered equal if their _selchars are the same and
|
||||
- if !ignore_length - if their _allchars_length are the same. */
|
||||
|
||||
class Hash_Table
|
||||
{
|
||||
private:
|
||||
List_Node **table; /* Vector of pointers to linked lists of List_Node's. */
|
||||
int size; /* Size of the vector. */
|
||||
int collisions; /* Find out how well our double hashing is working! */
|
||||
int ignore_length;
|
||||
|
||||
public:
|
||||
Hash_Table (List_Node **t, int s, int ignore_len);
|
||||
~Hash_Table (void);
|
||||
List_Node *insert (List_Node *item);
|
||||
/* Constructor.
|
||||
size is the maximum number of entries.
|
||||
ignore_length determines a detail in the comparison function. */
|
||||
Hash_Table (unsigned int size, bool ignore_length);
|
||||
/* Destructor. */
|
||||
~Hash_Table ();
|
||||
/* Attempts to insert ITEM in the table. If there is already an equal
|
||||
entry in it, returns it. Otherwise inserts ITEM and returns NULL. */
|
||||
KeywordExt * insert (KeywordExt *item);
|
||||
/* Print the table's contents. */
|
||||
void dump () const;
|
||||
|
||||
private:
|
||||
/* Vector of entries. */
|
||||
KeywordExt ** _table;
|
||||
/* Size of the vector. */
|
||||
unsigned int _size;
|
||||
/* log2(_size). */
|
||||
unsigned int _log_size;
|
||||
/* A detail of the comparison function. */
|
||||
bool const _ignore_length;
|
||||
/* Statistics: Number of collisions so far. */
|
||||
unsigned int _collisions;
|
||||
|
||||
/* Compares two items. */
|
||||
bool equal (KeywordExt *item1, KeywordExt *item2) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
1005
contrib/gperf/src/input.cc
Normal file
1005
contrib/gperf/src/input.cc
Normal file
File diff suppressed because it is too large
Load Diff
69
contrib/gperf/src/input.h
Normal file
69
contrib/gperf/src/input.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Input routines.
|
||||
|
||||
Copyright (C) 1989-1998, 2002-2003 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef input_h
|
||||
#define input_h 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include "keyword-list.h"
|
||||
|
||||
class Input
|
||||
{
|
||||
public:
|
||||
Input (FILE *stream, Keyword_Factory *keyword_factory);
|
||||
~Input ();
|
||||
void read_input ();
|
||||
private:
|
||||
/* Input stream. */
|
||||
FILE * _stream;
|
||||
/* Creates the keywords. */
|
||||
Keyword_Factory * const _factory;
|
||||
public:
|
||||
/* Memory block containing the entire input. */
|
||||
char * _input;
|
||||
char * _input_end;
|
||||
/* The C code from the declarations section. */
|
||||
const char * _verbatim_declarations;
|
||||
const char * _verbatim_declarations_end;
|
||||
unsigned int _verbatim_declarations_lineno;
|
||||
/* The C code from the end of the file. */
|
||||
const char * _verbatim_code;
|
||||
const char * _verbatim_code_end;
|
||||
unsigned int _verbatim_code_lineno;
|
||||
/* Declaration of struct type for a keyword and its attributes. */
|
||||
const char * _struct_decl;
|
||||
unsigned int _struct_decl_lineno;
|
||||
/* Return type of the lookup function. */
|
||||
const char * _return_type;
|
||||
/* Shorthand for user-defined struct tag type. */
|
||||
const char * _struct_tag;
|
||||
/* List of all keywords. */
|
||||
Keyword_List * _head;
|
||||
/* Whether the keyword chars would have different values in a different
|
||||
character set. */
|
||||
bool _charset_dependent;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,87 +0,0 @@
|
||||
/* Provides an Iterator for keyword characters.
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "iterator.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include "trace.h"
|
||||
|
||||
/* Constructor for Iterator. */
|
||||
|
||||
Iterator::Iterator (const char *s, int lo, int hi, int word_end, int bad_val, int key_end)
|
||||
{
|
||||
T (Trace t ("Iterator::Iterator");)
|
||||
end = key_end;
|
||||
error_value = bad_val;
|
||||
end_word = word_end;
|
||||
str = s;
|
||||
hi_bound = hi;
|
||||
lo_bound = lo;
|
||||
}
|
||||
|
||||
/* Provide an Iterator, returning the ``next'' value from
|
||||
the list of valid values given in the constructor. */
|
||||
|
||||
int
|
||||
Iterator::operator() (void)
|
||||
{
|
||||
T (Trace t ("Iterator::operator()");)
|
||||
/* Variables to record the Iterator's status when handling ranges, e.g., 3-12. */
|
||||
|
||||
static int size;
|
||||
static int curr_value;
|
||||
static int upper_bound;
|
||||
|
||||
if (size)
|
||||
{
|
||||
if (++curr_value >= upper_bound)
|
||||
size = 0;
|
||||
return curr_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (*str)
|
||||
switch (*str)
|
||||
{
|
||||
default: return error_value;
|
||||
case ',': str++; break;
|
||||
case '$': str++; return end_word;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
for (curr_value = 0; isdigit ((unsigned char)(*str)); str++)
|
||||
curr_value = curr_value * 10 + (*str - '0');
|
||||
|
||||
if (*str == '-')
|
||||
{
|
||||
|
||||
for (size = 1, upper_bound = 0;
|
||||
isdigit ((unsigned char)(*++str));
|
||||
upper_bound = upper_bound * 10 + (*str - '0'));
|
||||
|
||||
if (upper_bound <= curr_value || upper_bound > hi_bound)
|
||||
return error_value;
|
||||
}
|
||||
return curr_value >= lo_bound && curr_value <= hi_bound
|
||||
? curr_value : error_value;
|
||||
}
|
||||
|
||||
return end;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Provides an Iterator for keyword characters.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Provides an Iterator that expands and decodes a control string containing digits
|
||||
and ranges, returning an integer every time the generator function is called.
|
||||
This is used to decode the user's key position requests. For example:
|
||||
"-k 1,2,5-10,$" will return 1, 2, 5, 6, 7, 8, 9, 10, and 0 ( representing
|
||||
the abstract ``last character of the key'' on successive calls to the
|
||||
member function operator ().
|
||||
No errors are handled in these routines, they are passed back to the
|
||||
calling routines via a user-supplied Error_Value */
|
||||
|
||||
#ifndef iterator_h
|
||||
#define iterator_h 1
|
||||
|
||||
class Iterator
|
||||
{
|
||||
private:
|
||||
const char *str; /* A pointer to the string provided by the user. */
|
||||
int end; /* Value returned after last key is processed. */
|
||||
int end_word; /* A value marking the abstract ``end of word'' ( usually '$'). */
|
||||
int error_value; /* Error value returned when input is syntactically erroneous. */
|
||||
int hi_bound; /* Greatest possible value, inclusive. */
|
||||
int lo_bound; /* Smallest possible value, inclusive. */
|
||||
|
||||
public:
|
||||
Iterator (const char *s, int lo, int hi, int word_end, int bad_val, int key_end);
|
||||
int operator () (void);
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,96 +0,0 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Data and function member declarations for the keyword list class.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
/* The key word list is a useful abstraction that keeps track of
|
||||
various pieces of information that enable that fast generation
|
||||
of the Gen_Perf.hash function. A Key_List is a singly-linked
|
||||
list of List_Nodes. */
|
||||
|
||||
#ifndef key_list_h
|
||||
#define key_list_h 1
|
||||
|
||||
#include "list-node.h"
|
||||
#include "vectors.h"
|
||||
#include "read-line.h"
|
||||
|
||||
/* OSF/1 cxx needs these forward declarations. */
|
||||
struct Output_Constants;
|
||||
struct Output_Compare;
|
||||
|
||||
class Key_List : private Read_Line, public Vectors
|
||||
{
|
||||
private:
|
||||
const char *array_type; /* Pointer to the type for word list. */
|
||||
const char *return_type; /* Pointer to return type for lookup function. */
|
||||
const char *struct_tag; /* Shorthand for user-defined struct tag type. */
|
||||
const char *include_src; /* C source code to be included verbatim. */
|
||||
int max_key_len; /* Maximum length of the longest keyword. */
|
||||
int min_key_len; /* Minimum length of the shortest keyword. */
|
||||
int min_hash_value; /* Minimum hash value for all keywords. */
|
||||
int max_hash_value; /* Maximum hash value for all keywords. */
|
||||
int occurrence_sort; /* True if sorting by occurrence. */
|
||||
int hash_sort; /* True if sorting by hash value. */
|
||||
int additional_code; /* True if any additional C code is included. */
|
||||
int list_len; /* Length of head's Key_List, not counting duplicates. */
|
||||
int total_keys; /* Total number of keys, counting duplicates. */
|
||||
static int determined[MAX_ALPHA_SIZE]; /* Used in function reorder, below. */
|
||||
static int get_occurrence (List_Node *ptr);
|
||||
#ifndef strcspn
|
||||
static int strcspn (const char *s, const char *reject);
|
||||
#endif
|
||||
static int already_determined (List_Node *ptr);
|
||||
static void set_determined (List_Node *ptr);
|
||||
void compute_min_max (void);
|
||||
int num_hash_values (void);
|
||||
void output_constants (struct Output_Constants&);
|
||||
void output_hash_function (void);
|
||||
void output_keylength_table (void);
|
||||
void output_keyword_table (void);
|
||||
void output_lookup_array (void);
|
||||
void output_lookup_tables (void);
|
||||
void output_lookup_function_body (const struct Output_Compare&);
|
||||
void output_lookup_function (void);
|
||||
void set_output_types (void);
|
||||
void dump (void);
|
||||
const char *get_array_type (void);
|
||||
const char *save_include_src (void);
|
||||
const char *get_special_input (char delimiter);
|
||||
List_Node *merge (List_Node *list1, List_Node *list2);
|
||||
List_Node *merge_sort (List_Node *head);
|
||||
|
||||
protected:
|
||||
List_Node *head; /* Points to the head of the linked list. */
|
||||
int total_duplicates; /* Total number of duplicate hash values. */
|
||||
|
||||
public:
|
||||
Key_List (void);
|
||||
~Key_List (void);
|
||||
int keyword_list_length (void);
|
||||
int max_key_length (void);
|
||||
void reorder (void);
|
||||
void sort (void);
|
||||
void read_keys (void);
|
||||
void output (void);
|
||||
};
|
||||
|
||||
#endif
|
175
contrib/gperf/src/keyword-list.cc
Normal file
175
contrib/gperf/src/keyword-list.cc
Normal file
@ -0,0 +1,175 @@
|
||||
/* Keyword list.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Specification. */
|
||||
#include "keyword-list.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* -------------------------- Keyword_List class --------------------------- */
|
||||
|
||||
/* Constructor. */
|
||||
Keyword_List::Keyword_List (Keyword *car)
|
||||
: _cdr (NULL), _car (car)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------- KeywordExt_List class ------------------------- */
|
||||
|
||||
/* Constructor. */
|
||||
KeywordExt_List::KeywordExt_List (KeywordExt *car)
|
||||
: Keyword_List (car)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------ Keyword_List functions ------------------------- */
|
||||
|
||||
/* Copies a linear list, sharing the list elements. */
|
||||
Keyword_List *
|
||||
copy_list (Keyword_List *list)
|
||||
{
|
||||
Keyword_List *result;
|
||||
Keyword_List **lastp = &result;
|
||||
while (list != NULL)
|
||||
{
|
||||
Keyword_List *new_cons = new Keyword_List (list->first());
|
||||
*lastp = new_cons;
|
||||
lastp = &new_cons->rest();
|
||||
list = list->rest();
|
||||
}
|
||||
*lastp = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Copies a linear list, sharing the list elements. */
|
||||
KeywordExt_List *
|
||||
copy_list (KeywordExt_List *list)
|
||||
{
|
||||
return static_cast<KeywordExt_List *> (copy_list (static_cast<Keyword_List *> (list)));
|
||||
}
|
||||
|
||||
/* Deletes a linear list, keeping the list elements in memory. */
|
||||
void
|
||||
delete_list (Keyword_List *list)
|
||||
{
|
||||
while (list != NULL)
|
||||
{
|
||||
Keyword_List *rest = list->rest();
|
||||
delete list;
|
||||
list = rest;
|
||||
}
|
||||
}
|
||||
|
||||
/* Type of a comparison function. */
|
||||
typedef bool (*Keyword_Comparison) (Keyword *keyword1, Keyword *keyword2);
|
||||
|
||||
/* Merges two sorted lists together to form one sorted list. */
|
||||
static Keyword_List *
|
||||
merge (Keyword_List *list1, Keyword_List *list2, Keyword_Comparison less)
|
||||
{
|
||||
Keyword_List *result;
|
||||
Keyword_List **resultp = &result;
|
||||
for (;;)
|
||||
{
|
||||
if (!list1)
|
||||
{
|
||||
*resultp = list2;
|
||||
break;
|
||||
}
|
||||
if (!list2)
|
||||
{
|
||||
*resultp = list1;
|
||||
break;
|
||||
}
|
||||
if (less (list2->first(), list1->first()))
|
||||
{
|
||||
*resultp = list2;
|
||||
resultp = &list2->rest();
|
||||
/* We would have a stable sorting if the next line would read:
|
||||
list2 = *resultp; */
|
||||
list2 = list1; list1 = *resultp;
|
||||
}
|
||||
else
|
||||
{
|
||||
*resultp = list1;
|
||||
resultp = &list1->rest();
|
||||
list1 = *resultp;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Sorts a linear list, given a comparison function.
|
||||
Note: This uses a variant of mergesort that is *not* a stable sorting
|
||||
algorithm. */
|
||||
Keyword_List *
|
||||
mergesort_list (Keyword_List *list, Keyword_Comparison less)
|
||||
{
|
||||
if (list == NULL || list->rest() == NULL)
|
||||
/* List of length 0 or 1. Nothing to do. */
|
||||
return list;
|
||||
else
|
||||
{
|
||||
/* Determine a list node in the middle. */
|
||||
Keyword_List *middle = list;
|
||||
for (Keyword_List *temp = list->rest();;)
|
||||
{
|
||||
temp = temp->rest();
|
||||
if (temp == NULL)
|
||||
break;
|
||||
temp = temp->rest();
|
||||
middle = middle->rest();
|
||||
if (temp == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Cut the list into two halves.
|
||||
If the list has n elements, the left half has ceiling(n/2) elements
|
||||
and the right half has floor(n/2) elements. */
|
||||
Keyword_List *right_half = middle->rest();
|
||||
middle->rest() = NULL;
|
||||
|
||||
/* Sort the two halves, then merge them. */
|
||||
return merge (mergesort_list (list, less),
|
||||
mergesort_list (right_half, less),
|
||||
less);
|
||||
}
|
||||
}
|
||||
|
||||
KeywordExt_List *
|
||||
mergesort_list (KeywordExt_List *list,
|
||||
bool (*less) (KeywordExt *keyword1, KeywordExt *keyword2))
|
||||
{
|
||||
return
|
||||
static_cast<KeywordExt_List *>
|
||||
(mergesort_list (static_cast<Keyword_List *> (list),
|
||||
reinterpret_cast<Keyword_Comparison> (less)));
|
||||
}
|
||||
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
#define INLINE /* not inline */
|
||||
#include "keyword-list.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif /* not defined __OPTIMIZE__ */
|
85
contrib/gperf/src/keyword-list.h
Normal file
85
contrib/gperf/src/keyword-list.h
Normal file
@ -0,0 +1,85 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Keyword list.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef keyword_list_h
|
||||
#define keyword_list_h 1
|
||||
|
||||
#include "keyword.h"
|
||||
|
||||
/* List node of a linear list of Keyword. */
|
||||
class Keyword_List
|
||||
{
|
||||
public:
|
||||
/* Constructor. */
|
||||
Keyword_List (Keyword *car);
|
||||
|
||||
/* Access to first element of list. */
|
||||
Keyword * first () const;
|
||||
/* Access to next element of list. */
|
||||
Keyword_List *& rest ();
|
||||
|
||||
protected:
|
||||
Keyword_List * _cdr;
|
||||
Keyword * const _car;
|
||||
};
|
||||
|
||||
/* List node of a linear list of KeywordExt. */
|
||||
class KeywordExt_List : public Keyword_List
|
||||
{
|
||||
public:
|
||||
/* Constructor. */
|
||||
KeywordExt_List (KeywordExt *car);
|
||||
|
||||
/* Access to first element of list. */
|
||||
KeywordExt * first () const;
|
||||
/* Access to next element of list. */
|
||||
KeywordExt_List *& rest ();
|
||||
};
|
||||
|
||||
/* Copies a linear list, sharing the list elements. */
|
||||
extern Keyword_List * copy_list (Keyword_List *list);
|
||||
extern KeywordExt_List * copy_list (KeywordExt_List *list);
|
||||
|
||||
/* Deletes a linear list, keeping the list elements in memory. */
|
||||
extern void delete_list (Keyword_List *list);
|
||||
|
||||
/* Sorts a linear list, given a comparison function.
|
||||
Note: This uses a variant of mergesort that is *not* a stable sorting
|
||||
algorithm. */
|
||||
extern Keyword_List * mergesort_list (Keyword_List *list,
|
||||
bool (*less) (Keyword *keyword1,
|
||||
Keyword *keyword2));
|
||||
extern KeywordExt_List * mergesort_list (KeywordExt_List *list,
|
||||
bool (*less) (KeywordExt *keyword1,
|
||||
KeywordExt *keyword2));
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
#define INLINE inline
|
||||
#include "keyword-list.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
53
contrib/gperf/src/keyword-list.icc
Normal file
53
contrib/gperf/src/keyword-list.icc
Normal file
@ -0,0 +1,53 @@
|
||||
/* Inline Functions for keyword-list.{h,cc}.
|
||||
|
||||
Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* -------------------------- Keyword_List class --------------------------- */
|
||||
|
||||
/* Access to first element of list. */
|
||||
INLINE Keyword *
|
||||
Keyword_List::first () const
|
||||
{
|
||||
return _car;
|
||||
}
|
||||
|
||||
/* Access to next element of list. */
|
||||
INLINE Keyword_List *&
|
||||
Keyword_List::rest ()
|
||||
{
|
||||
return _cdr;
|
||||
}
|
||||
|
||||
/* ------------------------- KeywordExt_List class ------------------------- */
|
||||
|
||||
/* Access to first element of list. */
|
||||
INLINE KeywordExt *
|
||||
KeywordExt_List::first () const
|
||||
{
|
||||
return static_cast<KeywordExt*>(_car);
|
||||
}
|
||||
|
||||
/* Access to next element of list. */
|
||||
INLINE KeywordExt_List *&
|
||||
KeywordExt_List::rest ()
|
||||
{
|
||||
return *reinterpret_cast<KeywordExt_List**>(&_cdr);
|
||||
}
|
161
contrib/gperf/src/keyword.cc
Normal file
161
contrib/gperf/src/keyword.cc
Normal file
@ -0,0 +1,161 @@
|
||||
/* Keyword data.
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Specification. */
|
||||
#include "keyword.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "positions.h"
|
||||
|
||||
|
||||
/* --------------------------- KeywordExt class --------------------------- */
|
||||
|
||||
/* Sort a small set of 'unsigned int', base[0..len-1], in place. */
|
||||
static inline void sort_char_set (unsigned int *base, int len)
|
||||
{
|
||||
/* Bubble sort is sufficient here. */
|
||||
for (int i = 1; i < len; i++)
|
||||
{
|
||||
int j;
|
||||
unsigned int tmp;
|
||||
|
||||
for (j = i, tmp = base[j]; j > 0 && tmp < base[j - 1]; j--)
|
||||
base[j] = base[j - 1];
|
||||
|
||||
base[j] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initializes selchars and selchars_length.
|
||||
|
||||
General idea:
|
||||
The hash function will be computed as
|
||||
asso_values[allchars[key_pos[0]]] +
|
||||
asso_values[allchars[key_pos[1]]] + ...
|
||||
We compute selchars as the multiset
|
||||
{ allchars[key_pos[0]], allchars[key_pos[1]], ... }
|
||||
so that the hash function becomes
|
||||
asso_values[selchars[0]] + asso_values[selchars[1]] + ...
|
||||
Furthermore we sort the selchars array, to ease detection of duplicates
|
||||
later.
|
||||
|
||||
More in detail: The arguments alpha_unify (used for case-insensitive
|
||||
hash functions) and alpha_inc (used to disambiguate permutations)
|
||||
apply slight modifications. The hash function will be computed as
|
||||
sum (j=0,1,...: k = key_pos[j]:
|
||||
asso_values[alpha_unify[allchars[k]+alpha_inc[k]]])
|
||||
+ (allchars_length if !option[NOLENGTH], 0 otherwise).
|
||||
We compute selchars as the multiset
|
||||
{ alpha_unify[allchars[k]+alpha_inc[k]] : j=0,1,..., k = key_pos[j] }
|
||||
so that the hash function becomes
|
||||
asso_values[selchars[0]] + asso_values[selchars[1]] + ...
|
||||
+ (allchars_length if !option[NOLENGTH], 0 otherwise).
|
||||
*/
|
||||
|
||||
unsigned int *
|
||||
KeywordExt::init_selchars_low (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc)
|
||||
{
|
||||
/* Iterate through the list of positions, initializing selchars
|
||||
(via ptr). */
|
||||
PositionIterator iter = positions.iterator(_allchars_length);
|
||||
|
||||
unsigned int *key_set = new unsigned int[iter.remaining()];
|
||||
unsigned int *ptr = key_set;
|
||||
|
||||
for (int i; (i = iter.next ()) != PositionIterator::EOS; )
|
||||
{
|
||||
unsigned int c;
|
||||
if (i == Positions::LASTCHAR)
|
||||
/* Special notation for last KEY position, i.e. '$'. */
|
||||
c = static_cast<unsigned char>(_allchars[_allchars_length - 1]);
|
||||
else if (i < _allchars_length)
|
||||
{
|
||||
/* Within range of KEY length, so we'll keep it. */
|
||||
c = static_cast<unsigned char>(_allchars[i]);
|
||||
if (alpha_inc)
|
||||
c += alpha_inc[i];
|
||||
}
|
||||
else
|
||||
/* Out of range of KEY length, the iterator should not have
|
||||
produced this. */
|
||||
abort ();
|
||||
if (alpha_unify)
|
||||
c = alpha_unify[c];
|
||||
*ptr = c;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
_selchars = key_set;
|
||||
_selchars_length = ptr - key_set;
|
||||
|
||||
return key_set;
|
||||
}
|
||||
|
||||
void
|
||||
KeywordExt::init_selchars_tuple (const Positions& positions, const unsigned int *alpha_unify)
|
||||
{
|
||||
init_selchars_low (positions, alpha_unify, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
KeywordExt::init_selchars_multiset (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc)
|
||||
{
|
||||
unsigned int *selchars =
|
||||
init_selchars_low (positions, alpha_unify, alpha_inc);
|
||||
|
||||
/* Sort the selchars elements alphabetically. */
|
||||
sort_char_set (selchars, _selchars_length);
|
||||
}
|
||||
|
||||
/* Deletes selchars. */
|
||||
void
|
||||
KeywordExt::delete_selchars ()
|
||||
{
|
||||
delete[] const_cast<unsigned int *>(_selchars);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------- Keyword_Factory class ------------------------- */
|
||||
|
||||
Keyword_Factory::Keyword_Factory ()
|
||||
{
|
||||
}
|
||||
|
||||
Keyword_Factory::~Keyword_Factory ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
char empty_string[1] = "";
|
||||
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
#define INLINE /* not inline */
|
||||
#include "keyword.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif /* not defined __OPTIMIZE__ */
|
116
contrib/gperf/src/keyword.h
Normal file
116
contrib/gperf/src/keyword.h
Normal file
@ -0,0 +1,116 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Keyword data.
|
||||
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef keyword_h
|
||||
#define keyword_h 1
|
||||
|
||||
/* Class defined in "positions.h". */
|
||||
class Positions;
|
||||
|
||||
/* An instance of this class is a keyword, as specified in the input file. */
|
||||
|
||||
struct Keyword
|
||||
{
|
||||
/* Constructor. */
|
||||
Keyword (const char *allchars, int allchars_length,
|
||||
const char *rest);
|
||||
|
||||
/* Data members defined immediately by the input file. */
|
||||
/* The keyword as a string, possibly containing NUL bytes. */
|
||||
const char *const _allchars;
|
||||
int const _allchars_length;
|
||||
/* Additional stuff seen on the same line of the input file. */
|
||||
const char *const _rest;
|
||||
/* Line number of this keyword in the input file. */
|
||||
unsigned int _lineno;
|
||||
};
|
||||
|
||||
/* A keyword, in the context of a given keyposition list. */
|
||||
|
||||
struct KeywordExt : public Keyword
|
||||
{
|
||||
/* Constructor. */
|
||||
KeywordExt (const char *allchars, int allchars_length,
|
||||
const char *rest);
|
||||
|
||||
/* Data members depending on the keyposition list. */
|
||||
/* The selected characters that participate for the hash function,
|
||||
selected according to the keyposition list, as a canonically reordered
|
||||
multiset. */
|
||||
const unsigned int * _selchars;
|
||||
int _selchars_length;
|
||||
/* Chained list of keywords having the same _selchars and
|
||||
- if !option[NOLENGTH] - also the same _allchars_length.
|
||||
Note that these duplicates are not members of the main keyword list. */
|
||||
KeywordExt * _duplicate_link;
|
||||
|
||||
/* Methods depending on the keyposition list. */
|
||||
/* Initializes selchars and selchars_length, without reordering. */
|
||||
void init_selchars_tuple (const Positions& positions, const unsigned int *alpha_unify);
|
||||
/* Initializes selchars and selchars_length, with reordering. */
|
||||
void init_selchars_multiset (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
|
||||
/* Deletes selchars. */
|
||||
void delete_selchars ();
|
||||
|
||||
/* Data members used by the algorithm. */
|
||||
int _hash_value; /* Hash value for the keyword. */
|
||||
|
||||
/* Data members used by the output routines. */
|
||||
int _final_index;
|
||||
|
||||
private:
|
||||
unsigned int * init_selchars_low (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
|
||||
};
|
||||
|
||||
/* An abstract factory for creating Keyword instances.
|
||||
This factory is used to make the Input class independent of the concrete
|
||||
class KeywordExt. */
|
||||
|
||||
class Keyword_Factory
|
||||
{
|
||||
public:
|
||||
/* Constructor. */
|
||||
Keyword_Factory ();
|
||||
/* Destructor. */
|
||||
virtual ~Keyword_Factory ();
|
||||
|
||||
/* Creates a new Keyword. */
|
||||
virtual /*abstract*/ Keyword *
|
||||
create_keyword (const char *allchars, int allchars_length,
|
||||
const char *rest) = 0;
|
||||
};
|
||||
|
||||
/* A statically allocated empty string. */
|
||||
extern char empty_string[1];
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
#define INLINE inline
|
||||
#include "keyword.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
42
contrib/gperf/src/keyword.icc
Normal file
42
contrib/gperf/src/keyword.icc
Normal file
@ -0,0 +1,42 @@
|
||||
/* Inline Functions for keyword.{h,cc}.
|
||||
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* ----------------------------- Keyword class ----------------------------- */
|
||||
|
||||
/* Constructor. */
|
||||
INLINE
|
||||
Keyword::Keyword (const char *allchars, int allchars_length, const char *rest)
|
||||
: _allchars (allchars), _allchars_length (allchars_length), _rest (rest)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------- KeywordExt class --------------------------- */
|
||||
|
||||
/* Constructor. */
|
||||
INLINE
|
||||
KeywordExt::KeywordExt (const char *allchars, int allchars_length, const char *rest)
|
||||
: Keyword (allchars, allchars_length, rest),
|
||||
_final_index (-1)
|
||||
{
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/* Creates and initializes a new list node.
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "list-node.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* declares exit() */
|
||||
#include "options.h"
|
||||
#include "trace.h"
|
||||
|
||||
/* Sorts the key set alphabetically to speed up subsequent operations.
|
||||
Uses insertion sort since the set is probably quite small. */
|
||||
|
||||
inline void
|
||||
List_Node::set_sort (char *base, int len)
|
||||
{
|
||||
T (Trace t ("List_Node::set_sort");)
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = len - 1; i < j; i++)
|
||||
{
|
||||
char curr, tmp;
|
||||
|
||||
for (curr = i + 1, tmp = base[curr]; curr > 0 && tmp < base[curr-1]; curr--)
|
||||
base[curr] = base[curr - 1];
|
||||
|
||||
base[curr] = tmp;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Initializes a List_Node. This requires obtaining memory for the CHAR_SET
|
||||
initializing them using the information stored in the KEY_POSITIONS array in Options,
|
||||
and checking for simple errors. It's important to note that KEY and REST are
|
||||
both pointers to the different offsets into the same block of dynamic memory pointed
|
||||
to by parameter K. The data member REST is used to store any additional fields
|
||||
of the input file (it is set to the "" string if Option[TYPE] is not enabled).
|
||||
This is useful if the user wishes to incorporate a lookup structure,
|
||||
rather than just an array of keys. Finally, KEY_NUMBER contains a count
|
||||
of the total number of keys seen so far. This is used to initialize
|
||||
the INDEX field to some useful value. */
|
||||
|
||||
List_Node::List_Node (const char *k, int len, const char *r):
|
||||
link (0), next (0), key (k), key_length (len), rest (r), index (0)
|
||||
{
|
||||
T (Trace t ("List_Node::List_Node");)
|
||||
char *key_set = new char[(option[ALLCHARS] ? len : option.get_max_keysig_size ())];
|
||||
char *ptr = key_set;
|
||||
int i;
|
||||
|
||||
if (option[ALLCHARS]) /* Use all the character positions in the KEY. */
|
||||
for (i = len; i > 0; k++, ptr++, i--)
|
||||
++occurrences[(unsigned char)(*ptr = *k)];
|
||||
else /* Only use those character positions specified by the user. */
|
||||
{
|
||||
/* Iterate through the list of key_positions, initializing occurrences table
|
||||
and char_set (via char * pointer ptr). */
|
||||
|
||||
for (option.reset (); (i = option.get ()) != EOS; )
|
||||
{
|
||||
if (i == WORD_END) /* Special notation for last KEY position, i.e. '$'. */
|
||||
*ptr = key[len - 1];
|
||||
else if (i <= len) /* Within range of KEY length, so we'll keep it. */
|
||||
*ptr = key[i - 1];
|
||||
else /* Out of range of KEY length, so we'll just skip it. */
|
||||
continue;
|
||||
++occurrences[(unsigned char)(*ptr++)];
|
||||
}
|
||||
|
||||
/* Didn't get any hits and user doesn't want to consider the
|
||||
keylength, so there are essentially no usable hash positions! */
|
||||
if (ptr == char_set && option[NOLENGTH])
|
||||
{
|
||||
fprintf (stderr, "Can't hash keyword %.*s with chosen key positions.\n",
|
||||
key_length, key);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the KEY_SET items alphabetically. */
|
||||
set_sort (key_set, ptr - key_set);
|
||||
|
||||
char_set = key_set;
|
||||
char_set_length = ptr - key_set;
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Data and function members for defining values and operations of a list node.
|
||||
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#ifndef list_node_h
|
||||
#define list_node_h 1
|
||||
|
||||
#include "vectors.h"
|
||||
|
||||
struct List_Node : private Vectors
|
||||
{
|
||||
List_Node *link; /* TRUE if key has an identical KEY_SET as another key. */
|
||||
List_Node *next; /* Points to next element on the list. */
|
||||
const char *key; /* Each keyword string stored here. */
|
||||
int key_length; /* Length of the key. */
|
||||
const char *rest; /* Additional information for building hash function. */
|
||||
const char *char_set; /* Set of characters to hash, specified by user. */
|
||||
int char_set_length; /* Length of char_set. */
|
||||
int hash_value; /* Hash value for the key. */
|
||||
int occurrence; /* A metric for frequency of key set occurrences. */
|
||||
int index; /* Position of this node relative to other nodes. */
|
||||
|
||||
List_Node (const char *key, int len, const char *rest);
|
||||
static void set_sort (char *base, int len);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,76 +1,155 @@
|
||||
/* Driver program for the Gen_Perf hash function generator
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
/* Driver program for the hash function generator
|
||||
Copyright (C) 1989-1998, 2000, 2002-2003 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
/* Simple driver program for the Gen_Perf.hash function generator.
|
||||
Most of the hard work is done in class Gen_Perf and its class methods. */
|
||||
|
||||
#include "config.h"
|
||||
#include <sys/types.h>
|
||||
#if LARGE_STACK_ARRAYS && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "options.h"
|
||||
#include "gen-perf.h"
|
||||
#include "trace.h"
|
||||
#include "input.h"
|
||||
#include "search.h"
|
||||
#include "output.h"
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* This Keyword factory produces KeywordExt instances. */
|
||||
|
||||
class KeywordExt_Factory : public Keyword_Factory
|
||||
{
|
||||
virtual Keyword * create_keyword (const char *allchars, int allchars_length,
|
||||
const char *rest);
|
||||
};
|
||||
|
||||
Keyword *
|
||||
KeywordExt_Factory::create_keyword (const char *allchars, int allchars_length, const char *rest)
|
||||
{
|
||||
return new KeywordExt (allchars, allchars_length, rest);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
T (Trace t ("main");)
|
||||
int exitcode;
|
||||
|
||||
/* Set the Options. Open the input file and assign stdin to it. */
|
||||
option.parse_options (argc, argv);
|
||||
|
||||
/* Open the input file. */
|
||||
if (option.get_input_file_name ())
|
||||
if (!freopen (option.get_input_file_name (), "r", stdin))
|
||||
{
|
||||
fprintf (stderr, "Cannot open input file '%s'\n",
|
||||
option.get_input_file_name ());
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#if LARGE_STACK_ARRAYS && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK)
|
||||
/* Get rid of any avoidable limit on stack size. */
|
||||
{
|
||||
struct rlimit rlim;
|
||||
if (getrlimit (RLIMIT_STACK, &rlim) == 0)
|
||||
if (rlim.rlim_cur < rlim.rlim_max)
|
||||
{
|
||||
rlim.rlim_cur = rlim.rlim_max;
|
||||
setrlimit (RLIMIT_STACK, &rlim);
|
||||
}
|
||||
/* Initialize the keyword list. */
|
||||
KeywordExt_Factory factory;
|
||||
Input inputter (stdin, &factory);
|
||||
inputter.read_input ();
|
||||
/* We can cast the keyword list to KeywordExt_List* because its list
|
||||
elements were created by KeywordExt_Factory. */
|
||||
KeywordExt_List* list = static_cast<KeywordExt_List*>(inputter._head);
|
||||
|
||||
{
|
||||
/* Search for a good hash function. */
|
||||
Search searcher (list);
|
||||
searcher.optimize ();
|
||||
list = searcher._head;
|
||||
|
||||
/* Open the output file. */
|
||||
if (option.get_output_file_name ())
|
||||
if (strcmp (option.get_output_file_name (), "-") != 0)
|
||||
if (!freopen (option.get_output_file_name (), "w", stdout))
|
||||
{
|
||||
fprintf (stderr, "Cannot open output file '%s'\n",
|
||||
option.get_output_file_name ());
|
||||
exit (1);
|
||||
}
|
||||
|
||||
{
|
||||
/* Output the hash function code. */
|
||||
Output outputter (searcher._head,
|
||||
inputter._struct_decl,
|
||||
inputter._struct_decl_lineno,
|
||||
inputter._return_type,
|
||||
inputter._struct_tag,
|
||||
inputter._verbatim_declarations,
|
||||
inputter._verbatim_declarations_end,
|
||||
inputter._verbatim_declarations_lineno,
|
||||
inputter._verbatim_code,
|
||||
inputter._verbatim_code_end,
|
||||
inputter._verbatim_code_lineno,
|
||||
inputter._charset_dependent,
|
||||
searcher._total_keys,
|
||||
searcher._max_key_len,
|
||||
searcher._min_key_len,
|
||||
searcher._key_positions,
|
||||
searcher._alpha_inc,
|
||||
searcher._total_duplicates,
|
||||
searcher._alpha_size,
|
||||
searcher._asso_values);
|
||||
outputter.output ();
|
||||
|
||||
/* Check for write error on stdout. */
|
||||
exitcode = 0;
|
||||
if (fflush (stdout) || ferror (stdout))
|
||||
{
|
||||
fprintf (stderr, "error while writing output file\n");
|
||||
exitcode = 1;
|
||||
}
|
||||
|
||||
/* Here we run the Output destructor. */
|
||||
}
|
||||
/* Here we run the Search destructor. */
|
||||
}
|
||||
|
||||
/* Also delete the list that was allocated inside Input and reordered
|
||||
inside Search. */
|
||||
for (KeywordExt_List *ptr = list; ptr; ptr = ptr->rest())
|
||||
{
|
||||
KeywordExt *keyword = ptr->first();
|
||||
do
|
||||
{
|
||||
KeywordExt *next_keyword = keyword->_duplicate_link;
|
||||
delete[] const_cast<unsigned int *>(keyword->_selchars);
|
||||
if (keyword->_rest != empty_string)
|
||||
delete[] const_cast<char*>(keyword->_rest);
|
||||
if (!(keyword->_allchars >= inputter._input
|
||||
&& keyword->_allchars < inputter._input_end))
|
||||
delete[] const_cast<char*>(keyword->_allchars);
|
||||
delete keyword;
|
||||
keyword = next_keyword;
|
||||
}
|
||||
while (keyword != NULL);
|
||||
}
|
||||
delete_list (list);
|
||||
|
||||
/* Here we run the Input destructor. */
|
||||
}
|
||||
#endif /* RLIMIT_STACK */
|
||||
|
||||
/* Sets the Options. */
|
||||
option (argc, argv);
|
||||
|
||||
/* Initializes the key word list. */
|
||||
Gen_Perf generate_table;
|
||||
|
||||
/* Generates and prints the Gen_Perf hash table. */
|
||||
int status = generate_table ();
|
||||
|
||||
/* Check for write error on stdout. */
|
||||
if (fflush (stdout) || ferror (stdout))
|
||||
status = 1;
|
||||
|
||||
/* Don't use exit() here, it skips the destructors. */
|
||||
return status;
|
||||
/* Don't use exit() here, it skips the destructors. */
|
||||
return exitcode;
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
/* Defines a buffered memory allocation abstraction that reduces calls to
|
||||
malloc.
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* declares malloc(), exit() */
|
||||
#include "trace.h"
|
||||
|
||||
/* Determine default alignment. If your C++ compiler does not
|
||||
like this then try something like #define DEFAULT_ALIGNMENT 8. */
|
||||
struct fooalign {char x; double d;};
|
||||
const int ALIGNMENT = ((char *)&((struct fooalign *) 0)->d - (char *)0);
|
||||
|
||||
/* Provide an abstraction that cuts down on the number of
|
||||
calls to NEW by buffering the memory pool from which
|
||||
strings are allocated. */
|
||||
|
||||
void *
|
||||
operator new (size_t size)
|
||||
{
|
||||
T (Trace t ("operator new");)
|
||||
static char *buf_start = 0; /* Large array used to reduce calls to NEW. */
|
||||
static char *buf_end = 0; /* Indicates end of BUF_START. */
|
||||
static size_t buf_size = 4096; /* Size of buffer pointed to by BUF_START. */
|
||||
char *temp;
|
||||
|
||||
/* Align this on correct boundaries, just to be safe... */
|
||||
size = ((size + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT;
|
||||
|
||||
/* If we are about to overflow our buffer we'll just grab another
|
||||
chunk of memory. Since we never free the original memory it
|
||||
doesn't matter that no one points to the beginning of that
|
||||
chunk. Note we use a heuristic that grows the buffer either by
|
||||
size of the request or by twice the previous size, whichever is
|
||||
larger. */
|
||||
|
||||
if (buf_start + size >= buf_end)
|
||||
{
|
||||
buf_size *= 2;
|
||||
if (buf_size < size)
|
||||
buf_size = size;
|
||||
if ((buf_start = (char *)malloc (buf_size)) != (char *)0)
|
||||
buf_end = buf_start + buf_size;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "Virtual memory exhausted in `operator new'\n");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
temp = buf_start;
|
||||
buf_start += size;
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* We need this deletion operator in order to make the linker happy.
|
||||
Because `operator new' and `operator delete' always come together. */
|
||||
|
||||
void
|
||||
operator delete (void *ptr)
|
||||
#ifdef HAVE_THROW_DECL
|
||||
throw()
|
||||
#endif
|
||||
{
|
||||
T (Trace t ("operator delete");)
|
||||
// We cannot call free here, as it doesn't match the mallocs.
|
||||
// free ((char *) ptr);
|
||||
(void) ptr;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -2,154 +2,292 @@
|
||||
|
||||
/* Handles parsing the Options provided to the user.
|
||||
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2000, 2002-2004 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* This module provides a uniform interface to the various options available
|
||||
to a user of the gperf hash function generator. In addition to the
|
||||
run-time options, found in the Option_Type below, there is also the
|
||||
hash table Size and the Keys to be used in the hashing.
|
||||
The overall design of this module was an experiment in using C++
|
||||
classes as a mechanism to enhance centralization of option and
|
||||
and error handling, which tend to get out of hand in a C program. */
|
||||
to a user of the gperf hash function generator. */
|
||||
|
||||
#ifndef options_h
|
||||
#define options_h 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include "positions.h"
|
||||
|
||||
/* Enumerate the potential debugging Options. */
|
||||
/* Enumeration of the possible boolean options. */
|
||||
|
||||
enum Option_Type
|
||||
{
|
||||
DEBUG = 01, /* Enable debugging (prints diagnostics to stderr). */
|
||||
ORDER = 02, /* Apply ordering heuristic to speed-up search time. */
|
||||
ALLCHARS = 04, /* Use all characters in hash function. */
|
||||
TYPE = 010, /* Handle user-defined type structured keyword input. */
|
||||
RANDOM = 020, /* Randomly initialize the associated values table. */
|
||||
DEFAULTCHARS = 040, /* Make default char positions be 1,$ (end of keyword). */
|
||||
SWITCH = 0100, /* Generate switch output to save space. */
|
||||
NOLENGTH = 0200, /* Don't include keyword length in hash computations. */
|
||||
LENTABLE = 0400, /* Generate a length table for string comparison. */
|
||||
DUP = 01000, /* Handle duplicate hash values for keywords. */
|
||||
FAST = 02000, /* Generate the hash function ``fast.'' */
|
||||
NOTYPE = 04000, /* Don't include user-defined type definition in output -- it's already defined elsewhere. */
|
||||
COMP = 010000, /* Generate strncmp rather than strcmp. */
|
||||
GLOBAL = 020000, /* Make the keyword table a global variable. */
|
||||
CONST = 040000, /* Make the generated tables readonly (const). */
|
||||
KRC = 0100000, /* Generate K&R C code: no prototypes, no const. */
|
||||
C = 0200000, /* Generate C code: no prototypes, but const (user can #define it away). */
|
||||
ANSIC = 0400000, /* Generate ISO/ANSI C code: prototypes and const, but no class. */
|
||||
CPLUSPLUS = 01000000, /* Generate C++ code: prototypes, const, class, inline, enum. */
|
||||
ENUM = 02000000, /* Use enum for constants. */
|
||||
INCLUDE = 04000000, /* Generate #include statements. */
|
||||
SEVENBIT = 010000000 /* Assume 7-bit, not 8-bit, characters. */
|
||||
/* --- Input file interpretation --- */
|
||||
|
||||
/* Handle user-defined type structured keyword input. */
|
||||
TYPE = 1 << 0,
|
||||
|
||||
/* Ignore case of ASCII characters. */
|
||||
UPPERLOWER = 1 << 1,
|
||||
|
||||
/* --- Language for the output code --- */
|
||||
|
||||
/* Generate K&R C code: no prototypes, no const. */
|
||||
KRC = 1 << 2,
|
||||
|
||||
/* Generate C code: no prototypes, but const (user can #define it away). */
|
||||
C = 1 << 3,
|
||||
|
||||
/* Generate ISO/ANSI C code: prototypes and const, but no class. */
|
||||
ANSIC = 1 << 4,
|
||||
|
||||
/* Generate C++ code: prototypes, const, class, inline, enum. */
|
||||
CPLUSPLUS = 1 << 5,
|
||||
|
||||
/* --- Details in the output code --- */
|
||||
|
||||
/* Assume 7-bit, not 8-bit, characters. */
|
||||
SEVENBIT = 1 << 6,
|
||||
|
||||
/* Generate a length table for string comparison. */
|
||||
LENTABLE = 1 << 7,
|
||||
|
||||
/* Generate strncmp rather than strcmp. */
|
||||
COMP = 1 << 8,
|
||||
|
||||
/* Make the generated tables readonly (const). */
|
||||
CONST = 1 << 9,
|
||||
|
||||
/* Use enum for constants. */
|
||||
ENUM = 1 << 10,
|
||||
|
||||
/* Generate #include statements. */
|
||||
INCLUDE = 1 << 11,
|
||||
|
||||
/* Make the keyword table a global variable. */
|
||||
GLOBAL = 1 << 12,
|
||||
|
||||
/* Use NULL strings instead of empty strings for empty table entries. */
|
||||
NULLSTRINGS = 1 << 13,
|
||||
|
||||
/* Optimize for position-independent code. */
|
||||
SHAREDLIB = 1 << 14,
|
||||
|
||||
/* Generate switch output to save space. */
|
||||
SWITCH = 1 << 15,
|
||||
|
||||
/* Don't include user-defined type definition in output -- it's already
|
||||
defined elsewhere. */
|
||||
NOTYPE = 1 << 16,
|
||||
|
||||
/* --- Algorithm employed by gperf --- */
|
||||
|
||||
/* Use the given key positions. */
|
||||
POSITIONS = 1 << 17,
|
||||
|
||||
/* Handle duplicate hash values for keywords. */
|
||||
DUP = 1 << 18,
|
||||
|
||||
/* Don't include keyword length in hash computations. */
|
||||
NOLENGTH = 1 << 19,
|
||||
|
||||
/* Randomly initialize the associated values table. */
|
||||
RANDOM = 1 << 20,
|
||||
|
||||
/* --- Informative output --- */
|
||||
|
||||
/* Enable debugging (prints diagnostics to stderr). */
|
||||
DEBUG = 1 << 21
|
||||
};
|
||||
|
||||
/* Define some useful constants (these don't really belong here, but I'm
|
||||
not sure where else to put them!). These should be consts, but g++
|
||||
doesn't seem to do the right thing with them at the moment... ;-( */
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_KEY_POS = 128 - 1, /* Max size of each word's key set. */
|
||||
WORD_START = 1, /* Signals the start of a word. */
|
||||
WORD_END = 0, /* Signals the end of a word. */
|
||||
EOS = MAX_KEY_POS /* Signals end of the key list. */
|
||||
};
|
||||
|
||||
/* Class manager for gperf program Options. */
|
||||
/* Class manager for gperf program Options. */
|
||||
|
||||
class Options
|
||||
{
|
||||
public:
|
||||
Options (void);
|
||||
~Options (void);
|
||||
int operator[] (Option_Type option);
|
||||
void operator() (int argc, char *argv[]);
|
||||
void operator= (enum Option_Type);
|
||||
void operator!= (enum Option_Type);
|
||||
static void print_options (void);
|
||||
static void set_asso_max (int r);
|
||||
static int get_asso_max (void);
|
||||
static void reset (void);
|
||||
static int get (void);
|
||||
static int get_iterations (void);
|
||||
static int get_max_keysig_size (void);
|
||||
static void set_keysig_size (int);
|
||||
static int get_jump (void);
|
||||
static int initial_value (void);
|
||||
static int get_total_switches (void);
|
||||
static const char *get_function_name (void);
|
||||
static const char *get_key_name (void);
|
||||
static const char *get_initializer_suffix (void);
|
||||
static const char *get_class_name (void);
|
||||
static const char *get_hash_name (void);
|
||||
static const char *get_wordlist_name (void);
|
||||
static const char *get_delimiter (void);
|
||||
/* Constructor. */
|
||||
Options ();
|
||||
|
||||
/* Destructor. */
|
||||
~Options ();
|
||||
|
||||
/* Parses the options given in the command-line arguments. */
|
||||
void parse_options (int argc, char *argv[]);
|
||||
|
||||
/* Prints the given options. */
|
||||
void print_options () const;
|
||||
|
||||
/* Accessors. */
|
||||
|
||||
/* Tests a given boolean option. Returns true if set, false otherwise. */
|
||||
bool operator[] (Option_Type option) const;
|
||||
/* Sets a given boolean option. */
|
||||
void set (Option_Type option);
|
||||
|
||||
/* Returns the input file name. */
|
||||
const char * get_input_file_name () const;
|
||||
|
||||
/* Returns the output file name. */
|
||||
const char * get_output_file_name () const;
|
||||
|
||||
/* Sets the output language, if not already set. */
|
||||
void set_language (const char *language);
|
||||
|
||||
/* Returns the jump value. */
|
||||
int get_jump () const;
|
||||
|
||||
/* Returns the initial associated character value. */
|
||||
int get_initial_asso_value () const;
|
||||
|
||||
/* Returns the number of iterations for finding good asso_values. */
|
||||
int get_asso_iterations () const;
|
||||
|
||||
/* Returns the total number of switch statements to generate. */
|
||||
int get_total_switches () const;
|
||||
/* Sets the total number of switch statements, if not already set. */
|
||||
void set_total_switches (int total_switches);
|
||||
|
||||
/* Returns the factor by which to multiply the generated table's size. */
|
||||
float get_size_multiple () const;
|
||||
|
||||
/* Returns the generated function name. */
|
||||
const char * get_function_name () const;
|
||||
/* Sets the generated function name, if not already set. */
|
||||
void set_function_name (const char *name);
|
||||
|
||||
/* Returns the keyword key name. */
|
||||
const char * get_slot_name () const;
|
||||
/* Sets the keyword key name, if not already set. */
|
||||
void set_slot_name (const char *name);
|
||||
|
||||
/* Returns the struct initializer suffix. */
|
||||
const char * get_initializer_suffix () const;
|
||||
/* Sets the struct initializer suffix, if not already set. */
|
||||
void set_initializer_suffix (const char *initializers);
|
||||
|
||||
/* Returns the generated class name. */
|
||||
const char * get_class_name () const;
|
||||
/* Sets the generated class name, if not already set. */
|
||||
void set_class_name (const char *name);
|
||||
|
||||
/* Returns the hash function name. */
|
||||
const char * get_hash_name () const;
|
||||
/* Sets the hash function name, if not already set. */
|
||||
void set_hash_name (const char *name);
|
||||
|
||||
/* Returns the hash table array name. */
|
||||
const char * get_wordlist_name () const;
|
||||
/* Sets the hash table array name, if not already set. */
|
||||
void set_wordlist_name (const char *name);
|
||||
|
||||
/* Returns the length table array name. */
|
||||
const char * get_lengthtable_name () const;
|
||||
/* Sets the length table array name, if not already set. */
|
||||
void set_lengthtable_name (const char *name);
|
||||
|
||||
/* Returns the string pool name. */
|
||||
const char * get_stringpool_name () const;
|
||||
/* Sets the string pool name, if not already set. */
|
||||
void set_stringpool_name (const char *name);
|
||||
|
||||
/* Returns the string used to delimit keywords from other attributes. */
|
||||
const char * get_delimiters () const;
|
||||
/* Sets the delimiters string, if not already set. */
|
||||
void set_delimiters (const char *delimiters);
|
||||
|
||||
/* Returns key positions. */
|
||||
const Positions& get_key_positions () const;
|
||||
|
||||
private:
|
||||
static int option_word; /* Holds the user-specified Options. */
|
||||
static int total_switches; /* Number of switch statements to generate. */
|
||||
static int total_keysig_size; /* Total number of distinct key_positions. */
|
||||
static int size; /* Range of the hash table. */
|
||||
static int key_pos; /* Tracks current key position for Iterator. */
|
||||
static int jump; /* Jump length when trying alternative values. */
|
||||
static int initial_asso_value; /* Initial value for asso_values table. */
|
||||
static int argument_count; /* Records count of command-line arguments. */
|
||||
static int iterations; /* Amount to iterate when a collision occurs. */
|
||||
static char **argument_vector; /* Stores a pointer to command-line vector. */
|
||||
static const char *function_name; /* Names used for generated lookup function. */
|
||||
static const char *key_name; /* Name used for keyword key. */
|
||||
static const char *initializer_suffix; /* Suffix for empty struct initializers. */
|
||||
static const char *class_name; /* Name used for generated C++ class. */
|
||||
static const char *hash_name; /* Name used for generated hash function. */
|
||||
static const char *wordlist_name; /* Name used for hash table array. */
|
||||
static const char *delimiters; /* Separates keywords from other attributes. */
|
||||
static char key_positions[MAX_KEY_POS]; /* Contains user-specified key choices. */
|
||||
static int key_sort (char *base, int len); /* Sorts key positions in REVERSE order. */
|
||||
static void short_usage (FILE * strm); /* Prints proper program usage. */
|
||||
static void long_usage (FILE * strm); /* Prints proper program usage. */
|
||||
/* Prints program usage to given stream. */
|
||||
static void short_usage (FILE * stream);
|
||||
|
||||
/* Prints program usage to given stream. */
|
||||
static void long_usage (FILE * stream);
|
||||
|
||||
/* Records count of command-line arguments. */
|
||||
int _argument_count;
|
||||
|
||||
/* Stores a pointer to command-line argument vector. */
|
||||
char ** _argument_vector;
|
||||
|
||||
/* Holds the boolean options. */
|
||||
int _option_word;
|
||||
|
||||
/* Name of input file. */
|
||||
char * _input_file_name;
|
||||
|
||||
/* Name of output file. */
|
||||
char * _output_file_name;
|
||||
|
||||
/* The output language. */
|
||||
const char * _language;
|
||||
|
||||
/* Jump length when trying alternative values. */
|
||||
int _jump;
|
||||
|
||||
/* Initial value for asso_values table. */
|
||||
int _initial_asso_value;
|
||||
|
||||
/* Number of attempts at finding good asso_values. */
|
||||
int _asso_iterations;
|
||||
|
||||
/* Number of switch statements to generate. */
|
||||
int _total_switches;
|
||||
|
||||
/* Factor by which to multiply the generated table's size. */
|
||||
float _size_multiple;
|
||||
|
||||
/* Names used for generated lookup function. */
|
||||
const char * _function_name;
|
||||
|
||||
/* Name used for keyword key. */
|
||||
const char * _slot_name;
|
||||
|
||||
/* Suffix for empty struct initializers. */
|
||||
const char * _initializer_suffix;
|
||||
|
||||
/* Name used for generated C++ class. */
|
||||
const char * _class_name;
|
||||
|
||||
/* Name used for generated hash function. */
|
||||
const char * _hash_name;
|
||||
|
||||
/* Name used for hash table array. */
|
||||
const char * _wordlist_name;
|
||||
|
||||
/* Name used for length table array. */
|
||||
const char * _lengthtable_name;
|
||||
|
||||
/* Name used for the string pool. */
|
||||
const char * _stringpool_name;
|
||||
|
||||
/* Separates keywords from other attributes. */
|
||||
const char * _delimiters;
|
||||
|
||||
/* Contains user-specified key choices. */
|
||||
Positions _key_positions;
|
||||
};
|
||||
|
||||
/* Global option coordinator for the entire program. */
|
||||
/* Global option coordinator for the entire program. */
|
||||
extern Options option;
|
||||
|
||||
/* Set to 1 if your want to stack-allocate some large arrays.
|
||||
This requires compiler support for variable-size arrays on the stack
|
||||
(not ANSI). */
|
||||
#ifndef LARGE_STACK_ARRAYS
|
||||
#if defined(__GNUG__) && !defined(__STRICT_ANSI__)
|
||||
#define LARGE_STACK_ARRAYS 1
|
||||
#else
|
||||
#define LARGE_STACK_ARRAYS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Set to 1 if the stack is large enough for holding a text line. */
|
||||
#ifndef LARGE_STACK
|
||||
#define LARGE_STACK 1
|
||||
#endif
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
#include "trace.h"
|
||||
#define INLINE inline
|
||||
#include "options.icc"
|
||||
#undef INLINE
|
||||
|
@ -1,183 +1,157 @@
|
||||
/* Inline Functions for options.{h,cc}.
|
||||
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2000, 2002-2004 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
// This needs:
|
||||
//#include "trace.h"
|
||||
/* ----------------------------- Class Options ----------------------------- */
|
||||
|
||||
/* TRUE if option enable, else FALSE. */
|
||||
INLINE int
|
||||
Options::operator[] (Option_Type option)
|
||||
/* Tests a given boolean option. Returns true if set, false otherwise. */
|
||||
INLINE bool
|
||||
Options::operator[] (Option_Type option) const
|
||||
{
|
||||
T (Trace t ("Options::operator[]");)
|
||||
return option_word & option;
|
||||
return _option_word & option;
|
||||
}
|
||||
|
||||
/* Enables option OPT. */
|
||||
/* Sets a given boolean option. */
|
||||
INLINE void
|
||||
Options::operator = (enum Option_Type opt)
|
||||
Options::set (Option_Type option)
|
||||
{
|
||||
T (Trace t ("Options::operator=");)
|
||||
option_word |= opt;
|
||||
_option_word |= option;
|
||||
}
|
||||
|
||||
/* Disables option OPT. */
|
||||
INLINE void
|
||||
Options::operator != (enum Option_Type opt)
|
||||
{
|
||||
T (Trace t ("Options::operator!=");)
|
||||
option_word &= ~opt;
|
||||
}
|
||||
|
||||
/* Initializes the key Iterator. */
|
||||
INLINE void
|
||||
Options::reset (void)
|
||||
{
|
||||
T (Trace t ("Options::reset");)
|
||||
key_pos = 0;
|
||||
}
|
||||
|
||||
/* Returns current key_position and advance index. */
|
||||
INLINE int
|
||||
Options::get (void)
|
||||
{
|
||||
T (Trace t ("Options::get");)
|
||||
return key_positions[key_pos++];
|
||||
}
|
||||
|
||||
/* Sets the size of the table size. */
|
||||
INLINE void
|
||||
Options::set_asso_max (int r)
|
||||
{
|
||||
T (Trace t ("Options::set_asso_max");)
|
||||
size = r;
|
||||
}
|
||||
|
||||
/* Returns the size of the table size. */
|
||||
INLINE int
|
||||
Options::get_asso_max (void)
|
||||
{
|
||||
T (Trace t ("Options::get_asso_max");)
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Returns total distinct key positions. */
|
||||
INLINE int
|
||||
Options::get_max_keysig_size (void)
|
||||
{
|
||||
T (Trace t ("Options::get_max_keysig_size");)
|
||||
return total_keysig_size;
|
||||
}
|
||||
|
||||
/* Sets total distinct key positions. */
|
||||
INLINE void
|
||||
Options::set_keysig_size (int size)
|
||||
{
|
||||
T (Trace t ("Options::set_keysig_size");)
|
||||
total_keysig_size = size;
|
||||
}
|
||||
|
||||
/* Returns the jump value. */
|
||||
INLINE int
|
||||
Options::get_jump (void)
|
||||
{
|
||||
T (Trace t ("Options::get_jump");)
|
||||
return jump;
|
||||
}
|
||||
|
||||
/* Returns the generated function name. */
|
||||
/* Returns the input file name. */
|
||||
INLINE const char *
|
||||
Options::get_function_name (void)
|
||||
Options::get_input_file_name () const
|
||||
{
|
||||
T (Trace t ("Options::get_function_name");)
|
||||
return function_name;
|
||||
return _input_file_name;
|
||||
}
|
||||
|
||||
/* Returns the keyword key name. */
|
||||
/* Returns the output file name. */
|
||||
INLINE const char *
|
||||
Options::get_key_name (void)
|
||||
Options::get_output_file_name () const
|
||||
{
|
||||
T (Trace t ("Options::get_key_name");)
|
||||
return key_name;
|
||||
return _output_file_name;
|
||||
}
|
||||
|
||||
/* Returns the struct initializer suffix. */
|
||||
INLINE const char *
|
||||
Options::get_initializer_suffix (void)
|
||||
{
|
||||
T (Trace t ("Options::get_initializer_suffix");)
|
||||
return initializer_suffix;
|
||||
}
|
||||
|
||||
/* Returns the hash function name. */
|
||||
INLINE const char *
|
||||
Options::get_hash_name (void)
|
||||
{
|
||||
T (Trace t ("Options::get_hash_name");)
|
||||
return hash_name;
|
||||
}
|
||||
|
||||
/* Returns the hash table array name. */
|
||||
INLINE const char *
|
||||
Options::get_wordlist_name (void)
|
||||
{
|
||||
T (Trace t ("Options::get_wordlist_name");)
|
||||
return wordlist_name;
|
||||
}
|
||||
|
||||
/* Returns the generated class name. */
|
||||
INLINE const char *
|
||||
Options::get_class_name (void)
|
||||
{
|
||||
T (Trace t ("Options::get_class_name");)
|
||||
return class_name;
|
||||
}
|
||||
|
||||
/* Returns the initial associated character value. */
|
||||
/* Returns the jump value. */
|
||||
INLINE int
|
||||
Options::initial_value (void)
|
||||
Options::get_jump () const
|
||||
{
|
||||
T (Trace t ("Options::initial_value");)
|
||||
return initial_asso_value;
|
||||
return _jump;
|
||||
}
|
||||
|
||||
/* Returns the iterations value. */
|
||||
/* Returns the initial associated character value. */
|
||||
INLINE int
|
||||
Options::get_iterations (void)
|
||||
Options::get_initial_asso_value () const
|
||||
{
|
||||
T (Trace t ("Options::get_iterations");)
|
||||
return iterations;
|
||||
return _initial_asso_value;
|
||||
}
|
||||
|
||||
/* Returns the string used to delimit keywords from other attributes. */
|
||||
/* Returns the number of iterations for finding finding good asso_values. */
|
||||
INLINE int
|
||||
Options::get_asso_iterations () const
|
||||
{
|
||||
return _asso_iterations;
|
||||
}
|
||||
|
||||
/* Returns the total number of switch statements to generate. */
|
||||
INLINE int
|
||||
Options::get_total_switches () const
|
||||
{
|
||||
return _total_switches;
|
||||
}
|
||||
|
||||
/* Returns the factor by which to multiply the generated table's size. */
|
||||
INLINE float
|
||||
Options::get_size_multiple () const
|
||||
{
|
||||
return _size_multiple;
|
||||
}
|
||||
|
||||
/* Returns the generated function name. */
|
||||
INLINE const char *
|
||||
Options::get_delimiter ()
|
||||
Options::get_function_name () const
|
||||
{
|
||||
T (Trace t ("Options::get_delimiter");)
|
||||
return delimiters;
|
||||
return _function_name;
|
||||
}
|
||||
|
||||
/* Gets the total number of switch statements to generate. */
|
||||
INLINE int
|
||||
Options::get_total_switches ()
|
||||
/* Returns the keyword key name. */
|
||||
INLINE const char *
|
||||
Options::get_slot_name () const
|
||||
{
|
||||
T (Trace t ("Options::get_total_switches");)
|
||||
return total_switches;
|
||||
return _slot_name;
|
||||
}
|
||||
|
||||
/* Returns the struct initializer suffix. */
|
||||
INLINE const char *
|
||||
Options::get_initializer_suffix () const
|
||||
{
|
||||
return _initializer_suffix;
|
||||
}
|
||||
|
||||
/* Returns the generated class name. */
|
||||
INLINE const char *
|
||||
Options::get_class_name () const
|
||||
{
|
||||
return _class_name;
|
||||
}
|
||||
|
||||
/* Returns the hash function name. */
|
||||
INLINE const char *
|
||||
Options::get_hash_name () const
|
||||
{
|
||||
return _hash_name;
|
||||
}
|
||||
|
||||
/* Returns the hash table array name. */
|
||||
INLINE const char *
|
||||
Options::get_wordlist_name () const
|
||||
{
|
||||
return _wordlist_name;
|
||||
}
|
||||
|
||||
/* Returns the length table array name. */
|
||||
INLINE const char *
|
||||
Options::get_lengthtable_name () const
|
||||
{
|
||||
return _lengthtable_name;
|
||||
}
|
||||
|
||||
/* Returns the string pool name. */
|
||||
INLINE const char *
|
||||
Options::get_stringpool_name () const
|
||||
{
|
||||
return _stringpool_name;
|
||||
}
|
||||
|
||||
/* Returns the string used to delimit keywords from other attributes. */
|
||||
INLINE const char *
|
||||
Options::get_delimiters () const
|
||||
{
|
||||
return _delimiters;
|
||||
}
|
||||
|
||||
/* Returns key positions. */
|
||||
INLINE const Positions&
|
||||
Options::get_key_positions () const
|
||||
{
|
||||
return _key_positions;
|
||||
}
|
||||
|
2100
contrib/gperf/src/output.cc
Normal file
2100
contrib/gperf/src/output.cc
Normal file
File diff suppressed because it is too large
Load Diff
154
contrib/gperf/src/output.h
Normal file
154
contrib/gperf/src/output.h
Normal file
@ -0,0 +1,154 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Output routines.
|
||||
|
||||
Copyright (C) 1989-1998, 2000, 2002-2003 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef output_h
|
||||
#define output_h 1
|
||||
|
||||
#include "keyword-list.h"
|
||||
#include "positions.h"
|
||||
|
||||
/* OSF/1 cxx needs these forward declarations. */
|
||||
struct Output_Constants;
|
||||
struct Output_Compare;
|
||||
|
||||
class Output
|
||||
{
|
||||
public:
|
||||
/* Constructor. */
|
||||
Output (KeywordExt_List *head,
|
||||
const char *struct_decl,
|
||||
unsigned int struct_decl_lineno,
|
||||
const char *return_type,
|
||||
const char *struct_tag,
|
||||
const char *verbatim_declarations,
|
||||
const char *verbatim_declarations_end,
|
||||
unsigned int verbatim_declarations_lineno,
|
||||
const char *verbatim_code,
|
||||
const char *verbatim_code_end,
|
||||
unsigned int verbatim_code_lineno,
|
||||
bool charset_dependent,
|
||||
int total_keys,
|
||||
int max_key_len, int min_key_len,
|
||||
const Positions& positions,
|
||||
const unsigned int *alpha_inc,
|
||||
int total_duplicates,
|
||||
unsigned int alpha_size,
|
||||
const int *asso_values);
|
||||
|
||||
/* Generates the hash function and the key word recognizer function. */
|
||||
void output ();
|
||||
|
||||
private:
|
||||
|
||||
/* Computes the minimum and maximum hash values, and stores them
|
||||
in _min_hash_value and _max_hash_value. */
|
||||
void compute_min_max ();
|
||||
|
||||
/* Returns the number of different hash values. */
|
||||
int num_hash_values () const;
|
||||
|
||||
/* Outputs the maximum and minimum hash values etc. */
|
||||
void output_constants (struct Output_Constants&) const;
|
||||
|
||||
/* Generates a C expression for an asso_values[] reference. */
|
||||
void output_asso_values_ref (int pos) const;
|
||||
|
||||
/* Generates C code for the hash function that returns the
|
||||
proper encoding for each keyword. */
|
||||
void output_hash_function () const;
|
||||
|
||||
/* Prints out a table of keyword lengths, for use with the
|
||||
comparison code in generated function 'in_word_set'. */
|
||||
void output_keylength_table () const;
|
||||
|
||||
/* Prints out the string pool, containing the strings of the keyword table.
|
||||
*/
|
||||
void output_string_pool () const;
|
||||
|
||||
/* Prints out the array containing the keywords for the hash function. */
|
||||
void output_keyword_table () const;
|
||||
|
||||
/* Generates the large, sparse table that maps hash values into
|
||||
the smaller, contiguous range of the keyword table. */
|
||||
void output_lookup_array () const;
|
||||
|
||||
/* Generate all pools needed for the lookup function. */
|
||||
void output_lookup_pools () const;
|
||||
|
||||
/* Generate all the tables needed for the lookup function. */
|
||||
void output_lookup_tables () const;
|
||||
|
||||
/* Generates C code to perform the keyword lookup. */
|
||||
void output_lookup_function_body (const struct Output_Compare&) const;
|
||||
|
||||
/* Generates C code for the lookup function. */
|
||||
void output_lookup_function () const;
|
||||
|
||||
/* Linked list of keywords. */
|
||||
KeywordExt_List * _head;
|
||||
|
||||
/* Declaration of struct type for a keyword and its attributes. */
|
||||
const char * const _struct_decl;
|
||||
unsigned int const _struct_decl_lineno;
|
||||
/* Pointer to return type for lookup function. */
|
||||
const char * _return_type;
|
||||
/* Shorthand for user-defined struct tag type. */
|
||||
const char * _struct_tag;
|
||||
/* Element type of keyword array. */
|
||||
const char * _wordlist_eltype;
|
||||
/* The C code from the declarations section. */
|
||||
const char * const _verbatim_declarations;
|
||||
const char * const _verbatim_declarations_end;
|
||||
unsigned int const _verbatim_declarations_lineno;
|
||||
/* The C code from the end of the file. */
|
||||
const char * const _verbatim_code;
|
||||
const char * const _verbatim_code_end;
|
||||
unsigned int const _verbatim_code_lineno;
|
||||
/* Whether the keyword chars would have different values in a different
|
||||
character set. */
|
||||
bool _charset_dependent;
|
||||
/* Total number of keys, counting duplicates. */
|
||||
int const _total_keys;
|
||||
/* Maximum length of the longest keyword. */
|
||||
int const _max_key_len;
|
||||
/* Minimum length of the shortest keyword. */
|
||||
int const _min_key_len;
|
||||
/* Key positions. */
|
||||
Positions const _key_positions;
|
||||
/* Adjustments to add to bytes add specific key positions. */
|
||||
const unsigned int * const _alpha_inc;
|
||||
/* Total number of duplicate hash values. */
|
||||
int const _total_duplicates;
|
||||
/* Minimum hash value for all keywords. */
|
||||
int _min_hash_value;
|
||||
/* Maximum hash value for all keywords. */
|
||||
int _max_hash_value;
|
||||
/* Size of alphabet. */
|
||||
unsigned int const _alpha_size;
|
||||
/* Value associated with each character. */
|
||||
const int * const _asso_values;
|
||||
};
|
||||
|
||||
#endif
|
177
contrib/gperf/src/positions.cc
Normal file
177
contrib/gperf/src/positions.cc
Normal file
@ -0,0 +1,177 @@
|
||||
/* A set of byte positions.
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Specification. */
|
||||
#include "positions.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* declares exit() */
|
||||
#include <string.h>
|
||||
|
||||
/* ---------------------------- Class Positions ---------------------------- */
|
||||
|
||||
/* Set operations. Assumes the array is in reverse order. */
|
||||
|
||||
bool
|
||||
Positions::contains (int pos) const
|
||||
{
|
||||
unsigned int count = _size;
|
||||
const int *p = _positions + _size - 1;
|
||||
|
||||
for (; count > 0; p--, count--)
|
||||
{
|
||||
if (*p == pos)
|
||||
return true;
|
||||
if (*p > pos)
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Positions::add (int pos)
|
||||
{
|
||||
set_useall (false);
|
||||
|
||||
unsigned int count = _size;
|
||||
|
||||
if (count == MAX_SIZE)
|
||||
{
|
||||
fprintf (stderr, "Positions::add internal error: overflow\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int *p = _positions + _size - 1;
|
||||
|
||||
for (; count > 0; p--, count--)
|
||||
{
|
||||
if (*p == pos)
|
||||
{
|
||||
fprintf (stderr, "Positions::add internal error: duplicate\n");
|
||||
exit (1);
|
||||
}
|
||||
if (*p > pos)
|
||||
break;
|
||||
p[1] = p[0];
|
||||
}
|
||||
p[1] = pos;
|
||||
_size++;
|
||||
}
|
||||
|
||||
void
|
||||
Positions::remove (int pos)
|
||||
{
|
||||
set_useall (false);
|
||||
|
||||
unsigned int count = _size;
|
||||
if (count > 0)
|
||||
{
|
||||
int *p = _positions + _size - 1;
|
||||
|
||||
if (*p == pos)
|
||||
{
|
||||
_size--;
|
||||
return;
|
||||
}
|
||||
if (*p < pos)
|
||||
{
|
||||
int prev = *p;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
p--;
|
||||
count--;
|
||||
if (count == 0)
|
||||
break;
|
||||
if (*p == pos)
|
||||
{
|
||||
*p = prev;
|
||||
_size--;
|
||||
return;
|
||||
}
|
||||
if (*p > pos)
|
||||
break;
|
||||
int curr = *p;
|
||||
*p = prev;
|
||||
prev = curr;
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf (stderr, "Positions::remove internal error: not found\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Output in external syntax. */
|
||||
void
|
||||
Positions::print () const
|
||||
{
|
||||
if (_useall)
|
||||
printf ("*");
|
||||
else
|
||||
{
|
||||
bool first = true;
|
||||
bool seen_LASTCHAR = false;
|
||||
unsigned int count = _size;
|
||||
const int *p = _positions + _size - 1;
|
||||
|
||||
for (; count > 0; p--)
|
||||
{
|
||||
count--;
|
||||
if (*p == LASTCHAR)
|
||||
seen_LASTCHAR = true;
|
||||
else
|
||||
{
|
||||
if (!first)
|
||||
printf (",");
|
||||
printf ("%d", *p + 1);
|
||||
if (count > 0 && p[-1] == *p + 1)
|
||||
{
|
||||
printf ("-");
|
||||
do
|
||||
{
|
||||
p--;
|
||||
count--;
|
||||
}
|
||||
while (count > 0 && p[-1] == *p + 1);
|
||||
printf ("%d", *p + 1);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
if (seen_LASTCHAR)
|
||||
{
|
||||
if (!first)
|
||||
printf (",");
|
||||
printf ("$");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
#define INLINE /* not inline */
|
||||
#include "positions.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif /* not defined __OPTIMIZE__ */
|
175
contrib/gperf/src/positions.h
Normal file
175
contrib/gperf/src/positions.h
Normal file
@ -0,0 +1,175 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* A set of byte positions.
|
||||
|
||||
Copyright (C) 1989-1998, 2000, 2002, 2005 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef positions_h
|
||||
#define positions_h 1
|
||||
|
||||
/* Classes defined below. */
|
||||
class PositionIterator;
|
||||
class PositionReverseIterator;
|
||||
|
||||
/* This class denotes a set of byte positions, used to access a keyword. */
|
||||
|
||||
class Positions
|
||||
{
|
||||
friend class PositionIterator;
|
||||
friend class PositionReverseIterator;
|
||||
public:
|
||||
/* Denotes the last char of a keyword, depending on the keyword's length. */
|
||||
enum { LASTCHAR = -1 };
|
||||
|
||||
/* Maximum key position specifiable by the user, 1-based.
|
||||
Note that MAX_KEY_POS-1 must fit into the element type of _positions[],
|
||||
below. */
|
||||
enum { MAX_KEY_POS = 255 };
|
||||
|
||||
/* Maximum possible size. Since duplicates are eliminated and the possible
|
||||
0-based positions are -1 .. MAX_KEY_POS-1, this is: */
|
||||
enum { MAX_SIZE = MAX_KEY_POS + 1 };
|
||||
|
||||
/* Constructors. */
|
||||
Positions ();
|
||||
Positions (int pos1);
|
||||
Positions (int pos1, int pos2);
|
||||
|
||||
/* Copy constructor. */
|
||||
Positions (const Positions& src);
|
||||
|
||||
/* Assignment operator. */
|
||||
Positions& operator= (const Positions& src);
|
||||
|
||||
/* Accessors. */
|
||||
bool is_useall () const;
|
||||
int operator[] (unsigned int index) const;
|
||||
unsigned int get_size () const;
|
||||
|
||||
/* Write access. */
|
||||
void set_useall (bool useall);
|
||||
int * pointer ();
|
||||
void set_size (unsigned int size);
|
||||
|
||||
/* Sorts the array in reverse order.
|
||||
Returns true if there are no duplicates, false otherwise. */
|
||||
bool sort ();
|
||||
|
||||
/* Creates an iterator, returning the positions in descending order. */
|
||||
PositionIterator iterator () const;
|
||||
/* Creates an iterator, returning the positions in descending order,
|
||||
that apply to strings of length <= maxlen. */
|
||||
PositionIterator iterator (int maxlen) const;
|
||||
/* Creates an iterator, returning the positions in ascending order. */
|
||||
PositionReverseIterator reviterator () const;
|
||||
/* Creates an iterator, returning the positions in ascending order,
|
||||
that apply to strings of length <= maxlen. */
|
||||
PositionReverseIterator reviterator (int maxlen) const;
|
||||
|
||||
/* Set operations. Assumes the array is in reverse order. */
|
||||
bool contains (int pos) const;
|
||||
void add (int pos);
|
||||
void remove (int pos);
|
||||
|
||||
/* Output in external syntax. */
|
||||
void print () const;
|
||||
|
||||
private:
|
||||
/* The special case denoted by '*'. */
|
||||
bool _useall;
|
||||
/* Number of positions. */
|
||||
unsigned int _size;
|
||||
/* Array of positions. 0 for the first char, 1 for the second char etc.,
|
||||
LASTCHAR for the last char. */
|
||||
int _positions[MAX_SIZE];
|
||||
};
|
||||
|
||||
/* This class denotes an iterator through a set of byte positions. */
|
||||
|
||||
class PositionIterator
|
||||
{
|
||||
friend class Positions;
|
||||
public:
|
||||
/* Copy constructor. */
|
||||
PositionIterator (const PositionIterator& src);
|
||||
|
||||
/* End of iteration marker. */
|
||||
enum { EOS = -2 };
|
||||
|
||||
/* Retrieves the next position, or EOS past the end. */
|
||||
int next ();
|
||||
|
||||
/* Returns the number of remaining positions, i.e. how often next() will
|
||||
return a value != EOS. */
|
||||
unsigned int remaining () const;
|
||||
|
||||
private:
|
||||
/* Initializes an iterator through POSITIONS. */
|
||||
PositionIterator (Positions const& positions);
|
||||
/* Initializes an iterator through POSITIONS, ignoring positions >= maxlen. */
|
||||
PositionIterator (Positions const& positions, int maxlen);
|
||||
|
||||
const Positions& _set;
|
||||
unsigned int _index;
|
||||
};
|
||||
|
||||
/* This class denotes an iterator in reverse direction through a set of
|
||||
byte positions. */
|
||||
|
||||
class PositionReverseIterator
|
||||
{
|
||||
friend class Positions;
|
||||
public:
|
||||
/* Copy constructor. */
|
||||
PositionReverseIterator (const PositionReverseIterator& src);
|
||||
|
||||
/* End of iteration marker. */
|
||||
enum { EOS = -2 };
|
||||
|
||||
/* Retrieves the next position, or EOS past the end. */
|
||||
int next ();
|
||||
|
||||
/* Returns the number of remaining positions, i.e. how often next() will
|
||||
return a value != EOS. */
|
||||
unsigned int remaining () const;
|
||||
|
||||
private:
|
||||
/* Initializes an iterator through POSITIONS. */
|
||||
PositionReverseIterator (Positions const& positions);
|
||||
/* Initializes an iterator through POSITIONS, ignoring positions >= maxlen. */
|
||||
PositionReverseIterator (Positions const& positions, int maxlen);
|
||||
|
||||
const Positions& _set;
|
||||
unsigned int _index;
|
||||
unsigned int _minindex;
|
||||
};
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
#include <string.h>
|
||||
#define INLINE inline
|
||||
#include "positions.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
285
contrib/gperf/src/positions.icc
Normal file
285
contrib/gperf/src/positions.icc
Normal file
@ -0,0 +1,285 @@
|
||||
/* Inline Functions for positions.{h,cc}.
|
||||
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
// This needs:
|
||||
//#include <string.h>
|
||||
|
||||
/* ---------------------------- Class Positions ---------------------------- */
|
||||
|
||||
/* Constructors. */
|
||||
|
||||
INLINE
|
||||
Positions::Positions ()
|
||||
: _useall (false),
|
||||
_size (0)
|
||||
{
|
||||
}
|
||||
|
||||
INLINE
|
||||
Positions::Positions (int pos1)
|
||||
: _useall (false),
|
||||
_size (1)
|
||||
{
|
||||
_positions[0] = pos1;
|
||||
}
|
||||
|
||||
INLINE
|
||||
Positions::Positions (int pos1, int pos2)
|
||||
: _useall (false),
|
||||
_size (2)
|
||||
{
|
||||
_positions[0] = pos1;
|
||||
_positions[1] = pos2;
|
||||
}
|
||||
|
||||
/* Copy constructor. */
|
||||
|
||||
INLINE
|
||||
Positions::Positions (const Positions& src)
|
||||
: _useall (src._useall),
|
||||
_size (src._size)
|
||||
{
|
||||
memcpy (_positions, src._positions, _size * sizeof (_positions[0]));
|
||||
}
|
||||
|
||||
/* Assignment operator. */
|
||||
|
||||
INLINE Positions&
|
||||
Positions::operator= (const Positions& src)
|
||||
{
|
||||
_useall = src._useall;
|
||||
_size = src._size;
|
||||
memcpy (_positions, src._positions, _size * sizeof (_positions[0]));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* Accessors. */
|
||||
|
||||
INLINE bool
|
||||
Positions::is_useall () const
|
||||
{
|
||||
return _useall;
|
||||
}
|
||||
|
||||
INLINE int
|
||||
Positions::operator[] (unsigned int index) const
|
||||
{
|
||||
return _positions[index];
|
||||
}
|
||||
|
||||
INLINE unsigned int
|
||||
Positions::get_size () const
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
/* Write access. */
|
||||
|
||||
INLINE void
|
||||
Positions::set_useall (bool useall)
|
||||
{
|
||||
_useall = useall;
|
||||
if (useall)
|
||||
{
|
||||
/* The positions are 0, 1, ..., MAX_KEY_POS-1, in descending order. */
|
||||
_size = MAX_KEY_POS;
|
||||
int *ptr = _positions;
|
||||
for (int i = MAX_KEY_POS - 1; i >= 0; i--)
|
||||
*ptr++ = i;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE int *
|
||||
Positions::pointer ()
|
||||
{
|
||||
return _positions;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
Positions::set_size (unsigned int size)
|
||||
{
|
||||
_size = size;
|
||||
}
|
||||
|
||||
/* Sorts the array in reverse order.
|
||||
Returns true if there are no duplicates, false otherwise. */
|
||||
INLINE bool
|
||||
Positions::sort ()
|
||||
{
|
||||
if (_useall)
|
||||
return true;
|
||||
|
||||
/* Bubble sort. */
|
||||
bool duplicate_free = true;
|
||||
int *base = _positions;
|
||||
unsigned int len = _size;
|
||||
|
||||
for (unsigned int i = 1; i < len; i++)
|
||||
{
|
||||
unsigned int j;
|
||||
int tmp;
|
||||
|
||||
for (j = i, tmp = base[j]; j > 0 && tmp >= base[j - 1]; j--)
|
||||
if ((base[j] = base[j - 1]) == tmp) /* oh no, a duplicate!!! */
|
||||
duplicate_free = false;
|
||||
|
||||
base[j] = tmp;
|
||||
}
|
||||
|
||||
return duplicate_free;
|
||||
}
|
||||
|
||||
/* Creates an iterator, returning the positions in descending order. */
|
||||
INLINE PositionIterator
|
||||
Positions::iterator () const
|
||||
{
|
||||
return PositionIterator (*this);
|
||||
}
|
||||
|
||||
/* Creates an iterator, returning the positions in descending order,
|
||||
that apply to strings of length <= maxlen. */
|
||||
INLINE PositionIterator
|
||||
Positions::iterator (int maxlen) const
|
||||
{
|
||||
return PositionIterator (*this, maxlen);
|
||||
}
|
||||
|
||||
/* Creates an iterator, returning the positions in ascending order. */
|
||||
INLINE PositionReverseIterator
|
||||
Positions::reviterator () const
|
||||
{
|
||||
return PositionReverseIterator (*this);
|
||||
}
|
||||
|
||||
/* Creates an iterator, returning the positions in ascending order,
|
||||
that apply to strings of length <= maxlen. */
|
||||
INLINE PositionReverseIterator
|
||||
Positions::reviterator (int maxlen) const
|
||||
{
|
||||
return PositionReverseIterator (*this, maxlen);
|
||||
}
|
||||
|
||||
/* ------------------------- Class PositionIterator ------------------------ */
|
||||
|
||||
/* Initializes an iterator through POSITIONS. */
|
||||
INLINE
|
||||
PositionIterator::PositionIterator (Positions const& positions)
|
||||
: _set (positions),
|
||||
_index (0)
|
||||
{
|
||||
}
|
||||
|
||||
/* Initializes an iterator through POSITIONS, ignoring positions >= maxlen. */
|
||||
INLINE
|
||||
PositionIterator::PositionIterator (Positions const& positions, int maxlen)
|
||||
: _set (positions)
|
||||
{
|
||||
if (positions._useall)
|
||||
_index = (maxlen <= Positions::MAX_KEY_POS ? Positions::MAX_KEY_POS - maxlen : 0);
|
||||
else
|
||||
{
|
||||
unsigned int index;
|
||||
for (index = 0;
|
||||
index < positions._size && positions._positions[index] >= maxlen;
|
||||
index++)
|
||||
;
|
||||
_index = index;
|
||||
}
|
||||
}
|
||||
|
||||
/* Retrieves the next position, or EOS past the end. */
|
||||
INLINE int
|
||||
PositionIterator::next ()
|
||||
{
|
||||
return (_index < _set._size ? _set._positions[_index++] : EOS);
|
||||
}
|
||||
|
||||
/* Returns the number of remaining positions, i.e. how often next() will
|
||||
return a value != EOS. */
|
||||
INLINE unsigned int
|
||||
PositionIterator::remaining () const
|
||||
{
|
||||
return _set._size - _index;
|
||||
}
|
||||
|
||||
/* Copy constructor. */
|
||||
INLINE
|
||||
PositionIterator::PositionIterator (const PositionIterator& src)
|
||||
: _set (src._set),
|
||||
_index (src._index)
|
||||
{
|
||||
}
|
||||
|
||||
/* --------------------- Class PositionReverseIterator --------------------- */
|
||||
|
||||
/* Initializes an iterator through POSITIONS. */
|
||||
INLINE
|
||||
PositionReverseIterator::PositionReverseIterator (Positions const& positions)
|
||||
: _set (positions),
|
||||
_index (_set._size),
|
||||
_minindex (0)
|
||||
{
|
||||
}
|
||||
|
||||
/* Initializes an iterator through POSITIONS, ignoring positions >= maxlen. */
|
||||
INLINE
|
||||
PositionReverseIterator::PositionReverseIterator (Positions const& positions, int maxlen)
|
||||
: _set (positions),
|
||||
_index (_set._size)
|
||||
{
|
||||
if (positions._useall)
|
||||
_minindex = (maxlen <= Positions::MAX_KEY_POS ? Positions::MAX_KEY_POS - maxlen : 0);
|
||||
else
|
||||
{
|
||||
unsigned int index;
|
||||
for (index = 0;
|
||||
index < positions._size && positions._positions[index] >= maxlen;
|
||||
index++)
|
||||
;
|
||||
_minindex = index;
|
||||
}
|
||||
}
|
||||
|
||||
/* Retrieves the next position, or EOS past the end. */
|
||||
INLINE int
|
||||
PositionReverseIterator::next ()
|
||||
{
|
||||
return (_index > _minindex ? _set._positions[--_index] : EOS);
|
||||
}
|
||||
|
||||
/* Returns the number of remaining positions, i.e. how often next() will
|
||||
return a value != EOS. */
|
||||
INLINE unsigned int
|
||||
PositionReverseIterator::remaining () const
|
||||
{
|
||||
return _index - _minindex;
|
||||
}
|
||||
|
||||
/* Copy constructor. */
|
||||
INLINE
|
||||
PositionReverseIterator::PositionReverseIterator (const PositionReverseIterator& src)
|
||||
: _set (src._set),
|
||||
_index (src._index),
|
||||
_minindex (src._minindex)
|
||||
{
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/* Correctly reads an arbitrarily size string.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "read-line.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* declares memcpy() */
|
||||
#include "options.h"
|
||||
#include "trace.h"
|
||||
|
||||
/* Recursively fills up the buffer. */
|
||||
|
||||
#define CHUNK_SIZE 4096
|
||||
|
||||
/* CHUNKS is the number of chunks (each of size CHUNK_SIZE) which have
|
||||
already been read and which are temporarily stored on the stack.
|
||||
This function reads the remainder of the line, allocates a buffer
|
||||
for the entire line, fills the part beyond &buffer[chunks*CHUNK_SIZE],
|
||||
and returns &buffer[chunks*CHUNK_SIZE]. */
|
||||
|
||||
char *
|
||||
Read_Line::readln_aux (int chunks)
|
||||
{
|
||||
T (Trace t ("Read_Line::readln_aux");)
|
||||
#if LARGE_STACK
|
||||
char buf[CHUNK_SIZE];
|
||||
#else
|
||||
// Note: we don't use new, because that invokes a custom operator new.
|
||||
char *buf = (char*)malloc(CHUNK_SIZE);
|
||||
if (buf == NULL)
|
||||
abort ();
|
||||
#endif
|
||||
char *bufptr = buf;
|
||||
char *ptr;
|
||||
int c;
|
||||
|
||||
while (c = getc (fp), c != EOF && c != '\n') /* fill the current buffer */
|
||||
{
|
||||
*bufptr++ = c;
|
||||
if (bufptr - buf == CHUNK_SIZE)
|
||||
{
|
||||
if ((ptr = readln_aux (chunks + 1)) != NULL)
|
||||
|
||||
/* prepend remainder to ptr buffer */
|
||||
{
|
||||
ptr -= CHUNK_SIZE;
|
||||
memcpy (ptr, buf, CHUNK_SIZE);
|
||||
}
|
||||
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (c == EOF && bufptr == buf && chunks == 0)
|
||||
ptr = NULL;
|
||||
else
|
||||
{
|
||||
size_t s1 = chunks * CHUNK_SIZE;
|
||||
size_t s2 = bufptr - buf;
|
||||
|
||||
ptr = new char[s1+s2+1];
|
||||
ptr += s1;
|
||||
ptr[s2] = '\0';
|
||||
memcpy (ptr, buf, s2);
|
||||
}
|
||||
done:
|
||||
#if !LARGE_STACK
|
||||
free (buf);
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
#define INLINE /* not inline */
|
||||
#include "read-line.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif /* not defined __OPTIMIZE__ */
|
@ -1,53 +0,0 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Reads arbitrarily long string from input file, returning it as a
|
||||
dynamically allocated buffer.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
/* Returns a pointer to an arbitrary length string. Returns NULL on error or EOF
|
||||
The storage for the string is dynamically allocated by new. */
|
||||
|
||||
#ifndef read_line_h
|
||||
#define read_line_h 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class Read_Line
|
||||
{
|
||||
private:
|
||||
char *readln_aux (int chunks);
|
||||
FILE *fp; /* FILE pointer to the input stream. */
|
||||
|
||||
public:
|
||||
Read_Line (FILE *stream = stdin) : fp (stream) {}
|
||||
char *get_line (void);
|
||||
};
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
#include "trace.h"
|
||||
#define INLINE inline
|
||||
#include "read-line.icc"
|
||||
#undef INLINE
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,47 +0,0 @@
|
||||
/* Inline Functions for read-line.{h,cc}.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
// This needs:
|
||||
//#include <stdio.h>
|
||||
//#include "trace.h"
|
||||
|
||||
/* Returns the ``next'' line, ignoring comments beginning with '#'. */
|
||||
INLINE char *
|
||||
Read_Line::get_line (void)
|
||||
{
|
||||
T (Trace t ("Read_Line::get_line");)
|
||||
int c;
|
||||
|
||||
while ((c = getc (fp)) == '#')
|
||||
{
|
||||
while (c = getc (fp), c != EOF && c != '\n')
|
||||
;
|
||||
|
||||
if (c == EOF)
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
if (c == EOF)
|
||||
return (char *)0;
|
||||
|
||||
ungetc (c, stdin);
|
||||
return readln_aux (0);
|
||||
}
|
1684
contrib/gperf/src/search.cc
Normal file
1684
contrib/gperf/src/search.cc
Normal file
File diff suppressed because it is too large
Load Diff
165
contrib/gperf/src/search.h
Normal file
165
contrib/gperf/src/search.h
Normal file
@ -0,0 +1,165 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Search algorithm.
|
||||
|
||||
Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef search_h
|
||||
#define search_h 1
|
||||
|
||||
#include "keyword-list.h"
|
||||
#include "positions.h"
|
||||
#include "bool-array.h"
|
||||
|
||||
struct EquivalenceClass;
|
||||
|
||||
class Search
|
||||
{
|
||||
public:
|
||||
Search (KeywordExt_List *list);
|
||||
~Search ();
|
||||
void optimize ();
|
||||
private:
|
||||
void prepare ();
|
||||
|
||||
/* Computes the upper bound on the indices passed to asso_values[],
|
||||
assuming no alpha_increments. */
|
||||
unsigned int compute_alpha_size () const;
|
||||
|
||||
/* Computes the unification rules between different asso_values[c],
|
||||
assuming no alpha_increments. */
|
||||
unsigned int * compute_alpha_unify () const;
|
||||
|
||||
/* Initializes each keyword's _selchars array. */
|
||||
void init_selchars_tuple (const Positions& positions, const unsigned int *alpha_unify) const;
|
||||
/* Deletes each keyword's _selchars array. */
|
||||
void delete_selchars () const;
|
||||
|
||||
/* Count the duplicate keywords that occur with a given set of positions. */
|
||||
unsigned int count_duplicates_tuple (const Positions& positions, const unsigned int *alpha_unify) const;
|
||||
|
||||
/* Find good key positions. */
|
||||
void find_positions ();
|
||||
|
||||
/* Count the duplicate keywords that occur with the found set of positions. */
|
||||
unsigned int count_duplicates_tuple () const;
|
||||
|
||||
/* Computes the upper bound on the indices passed to asso_values[]. */
|
||||
unsigned int compute_alpha_size (const unsigned int *alpha_inc) const;
|
||||
|
||||
/* Computes the unification rules between different asso_values[c]. */
|
||||
unsigned int * compute_alpha_unify (const Positions& positions, const unsigned int *alpha_inc) const;
|
||||
|
||||
/* Initializes each keyword's _selchars array. */
|
||||
void init_selchars_multiset (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc) const;
|
||||
|
||||
/* Count the duplicate keywords that occur with the given set of positions
|
||||
and a given alpha_inc[] array. */
|
||||
unsigned int count_duplicates_multiset (const unsigned int *alpha_inc) const;
|
||||
|
||||
/* Find good _alpha_inc[]. */
|
||||
void find_alpha_inc ();
|
||||
|
||||
/* Initializes the asso_values[] related parameters. */
|
||||
void prepare_asso_values ();
|
||||
|
||||
EquivalenceClass * compute_partition (bool *undetermined) const;
|
||||
|
||||
unsigned int count_possible_collisions (EquivalenceClass *partition, unsigned int c) const;
|
||||
|
||||
bool unchanged_partition (EquivalenceClass *partition, unsigned int c) const;
|
||||
|
||||
/* Finds some _asso_values[] that fit. */
|
||||
void find_asso_values ();
|
||||
|
||||
/* Computes a keyword's hash value, relative to the current _asso_values[],
|
||||
and stores it in keyword->_hash_value. */
|
||||
int compute_hash (KeywordExt *keyword) const;
|
||||
|
||||
/* Finds good _asso_values[]. */
|
||||
void find_good_asso_values ();
|
||||
|
||||
/* Sorts the keyword list by hash value. */
|
||||
void sort ();
|
||||
|
||||
public:
|
||||
|
||||
/* Linked list of keywords. */
|
||||
KeywordExt_List * _head;
|
||||
|
||||
/* Total number of keywords, counting duplicates. */
|
||||
int _total_keys;
|
||||
|
||||
/* Maximum length of the longest keyword. */
|
||||
int _max_key_len;
|
||||
|
||||
/* Minimum length of the shortest keyword. */
|
||||
int _min_key_len;
|
||||
|
||||
/* User-specified or computed key positions. */
|
||||
Positions _key_positions;
|
||||
|
||||
/* Adjustments to add to bytes add specific key positions. */
|
||||
unsigned int * _alpha_inc;
|
||||
|
||||
/* Size of alphabet. */
|
||||
unsigned int _alpha_size;
|
||||
|
||||
/* Alphabet character unification, either the identity or a mapping from
|
||||
upper case characters to lower case characters (and maybe more). */
|
||||
unsigned int * _alpha_unify;
|
||||
|
||||
/* Maximum _selchars_length over all keywords. */
|
||||
unsigned int _max_selchars_length;
|
||||
|
||||
/* Total number of duplicates that have been moved to _duplicate_link lists
|
||||
(not counting their representatives which stay on the main list). */
|
||||
int _total_duplicates;
|
||||
|
||||
/* Counts occurrences of each key set character.
|
||||
_occurrences[c] is the number of times that c occurs among the _selchars
|
||||
of a keyword. */
|
||||
int * _occurrences;
|
||||
/* Value associated with each character. */
|
||||
int * _asso_values;
|
||||
|
||||
private:
|
||||
|
||||
/* Length of _head list. Number of keywords, not counting duplicates. */
|
||||
int _list_len;
|
||||
|
||||
/* Exclusive upper bound for every _asso_values[c]. A power of 2. */
|
||||
unsigned int _asso_value_max;
|
||||
|
||||
/* Initial value for asso_values table. -1 means random. */
|
||||
int _initial_asso_value;
|
||||
/* Jump length when trying alternative values. 0 means random. */
|
||||
int _jump;
|
||||
|
||||
/* Maximal possible hash value. */
|
||||
int _max_hash_value;
|
||||
|
||||
/* Sparse bit vector for collision detection. */
|
||||
Bool_Array * _collision_detector;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,35 +0,0 @@
|
||||
/* Tracing function calls.
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int Trace::nesting = 0;
|
||||
|
||||
Trace::Trace (const char *n)
|
||||
{
|
||||
fprintf (stderr, "%*scalling %s\n", 3 * nesting++, "", name = n);
|
||||
}
|
||||
|
||||
Trace::~Trace (void)
|
||||
{
|
||||
fprintf (stderr, "%*sleaving %s\n", 3 * --nesting, "", name);
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/* Tracing function calls.
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#ifndef trace_h
|
||||
#define trace_h 1
|
||||
|
||||
#ifdef TRACE
|
||||
#define T(X) X
|
||||
#else
|
||||
#define T(X)
|
||||
#endif
|
||||
|
||||
class Trace
|
||||
{
|
||||
private:
|
||||
static int nesting;
|
||||
const char *name;
|
||||
public:
|
||||
Trace (const char *n);
|
||||
~Trace (void);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
/* Static class data members that are shared between several classes.
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#include "vectors.h"
|
||||
|
||||
int Vectors::ALPHA_SIZE = MAX_ALPHA_SIZE;
|
||||
int Vectors::occurrences[MAX_ALPHA_SIZE];
|
||||
int Vectors::asso_values[MAX_ALPHA_SIZE];
|
@ -1,37 +0,0 @@
|
||||
/* This may look like C code, but it is really -*- C++ -*- */
|
||||
|
||||
/* Static class data members that are shared between several classes via
|
||||
inheritance.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
|
||||
#ifndef vectors_h
|
||||
#define vectors_h 1
|
||||
|
||||
static const int MAX_ALPHA_SIZE = 256;
|
||||
|
||||
struct Vectors
|
||||
{
|
||||
static int ALPHA_SIZE; /* Size of alphabet. */
|
||||
static int occurrences[MAX_ALPHA_SIZE]; /* Counts occurrences of each key set character. */
|
||||
static int asso_values[MAX_ALPHA_SIZE]; /* Value associated with each character. */
|
||||
};
|
||||
|
||||
#endif
|
@ -1,22 +1,28 @@
|
||||
/* Current program version number.
|
||||
|
||||
Copyright (C) 1989-1998, 2000 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2000, 2002-2003, 2005, 2007 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
const char *version_string = "2.7.2";
|
||||
/* Specification. */
|
||||
#include "version.h"
|
||||
|
||||
/* Current release version. */
|
||||
const char *version_string = "3.0.3";
|
||||
|
@ -1,23 +1,25 @@
|
||||
/* Current program version number.
|
||||
|
||||
Copyright (C) 1989-1998 Free Software Foundation, Inc.
|
||||
written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
Copyright (C) 1989-1998, 2002 Free Software Foundation, Inc.
|
||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||
and Bruno Haible <bruno@clisp.org>.
|
||||
|
||||
This file is part of GNU GPERF.
|
||||
This file is part of GNU GPERF.
|
||||
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 1, or (at your option)
|
||||
any later version.
|
||||
GNU GPERF is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU GPERF is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Current release version. */
|
||||
extern const char *version_string;
|
||||
|
@ -1,232 +0,0 @@
|
||||
# Makefile for gperf/tests
|
||||
|
||||
# Copyright (C) 1989, 1992, 1993, 1995, 1998 Free Software Foundation, Inc.
|
||||
# written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
#
|
||||
# This file is part of GNU GPERF.
|
||||
#
|
||||
# GNU GPERF is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 1, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# GNU GPERF is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU GPERF; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
# Directories used by "make":
|
||||
srcdir = @srcdir@
|
||||
|
||||
# Programs used by "make":
|
||||
# C compiler
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
# C++ compiler
|
||||
CXX = @CXX@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCPP = @CXXCPP@
|
||||
# Other
|
||||
MV = mv
|
||||
LN = ln
|
||||
RM = rm -f
|
||||
@SET_MAKE@
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
VPATH = $(srcdir)
|
||||
|
||||
GPERF = ../src/gperf
|
||||
|
||||
all :
|
||||
|
||||
install : all
|
||||
|
||||
installdirs :
|
||||
|
||||
uninstall :
|
||||
|
||||
check : check-link-c check-link-c++ check-c check-ada check-modula3 check-pascal check-test
|
||||
@true
|
||||
|
||||
extracheck : @CHECK_LANG_SYNTAX@
|
||||
@true
|
||||
|
||||
check-link-c: force
|
||||
@echo "performing some tests of the perfect hash generator"
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/test.c
|
||||
$(GPERF) -p -c -l -S1 -o $(srcdir)/c.gperf > cinset.c
|
||||
$(CC) $(CFLAGS) -o cout cinset.c test.o
|
||||
|
||||
check-link-c++: force
|
||||
|
||||
check-c:
|
||||
@echo "testing ANSI C reserved words, all items should be found in the set"
|
||||
./cout -v < $(srcdir)/c.gperf > c.out
|
||||
diff $(srcdir)/c.exp c.out
|
||||
|
||||
check-ada:
|
||||
$(GPERF) -k1,4,'$$' $(srcdir)/ada.gperf > adainset.c
|
||||
# double '$$' is only there since make gets confused; program wants only 1 '$'
|
||||
$(CC) $(CFLAGS) -o aout adainset.c test.o
|
||||
@echo "testing Ada reserved words, all items should be found in the set"
|
||||
./aout -v < $(srcdir)/ada.gperf > ada-res.out
|
||||
diff $(srcdir)/ada-res.exp ada-res.out
|
||||
$(GPERF) -p -D -k1,'$$' -s 2 -o $(srcdir)/adadefs.gperf > preinset.c
|
||||
$(CC) $(CFLAGS) -o preout preinset.c test.o
|
||||
@echo "testing Ada predefined words, all items should be found in the set"
|
||||
./preout -v < $(srcdir)/adadefs.gperf > ada-pred.out
|
||||
diff $(srcdir)/ada-pred.exp ada-pred.out
|
||||
|
||||
check-modula3:
|
||||
$(GPERF) -k1,2,'$$' -o $(srcdir)/modula3.gperf > m3inset.c
|
||||
$(CC) $(CFLAGS) -o m3out m3inset.c test.o
|
||||
@echo "testing Modula3 reserved words, all items should be found in the set"
|
||||
./m3out -v < $(srcdir)/modula3.gperf > modula.out
|
||||
diff $(srcdir)/modula.exp modula.out
|
||||
|
||||
check-pascal:
|
||||
$(GPERF) -o -S2 -p < $(srcdir)/pascal.gperf > pinset.c
|
||||
$(CC) $(CFLAGS) -o pout pinset.c test.o
|
||||
@echo "testing Pascal reserved words, all items should be found in the set"
|
||||
./pout -v < $(srcdir)/pascal.gperf > pascal.out
|
||||
diff $(srcdir)/pascal.exp pascal.out
|
||||
|
||||
# these next 5 are demos that show off the generated code
|
||||
check-test:
|
||||
$(GPERF) -p -j1 -g -o -t -N is_reserved_word -k1,3,'$$' < $(srcdir)/c-parse.gperf > test-1.out
|
||||
diff $(srcdir)/test-1.exp test-1.out
|
||||
$(GPERF) -n -k1-8 -l < $(srcdir)/modula2.gperf > test-2.out
|
||||
diff $(srcdir)/test-2.exp test-2.out
|
||||
$(GPERF) -p -j 1 -o -a -C -g -t -k1,4,$$ < $(srcdir)/gplus.gperf > test-3.out
|
||||
diff $(srcdir)/test-3.exp test-3.out
|
||||
$(GPERF) -D -p -t < $(srcdir)/c-parse.gperf > test-4.out
|
||||
diff $(srcdir)/test-4.exp test-4.out
|
||||
$(GPERF) -g -o -j1 -t -p -N is_reserved_word < $(srcdir)/gpc.gperf > test-5.out
|
||||
diff $(srcdir)/test-5.exp test-5.out
|
||||
# prints out the help message
|
||||
-$(GPERF) -h > test-6.out 2>&1
|
||||
diff $(srcdir)/test-6.exp test-6.out
|
||||
@echo "only if, do, for, case, goto, else, while, and return should be found "
|
||||
./aout -v < $(srcdir)/c.gperf > test-7.out
|
||||
diff $(srcdir)/test-7.exp test-7.out
|
||||
|
||||
# The following validates valid language syntax with different parameters.
|
||||
# Works only with gcc and g++, and only on platforms where "gcc -ansi" is
|
||||
# usable. (There are still platforms where gcc-2.8.0's fixincludes does not
|
||||
# work well enough.)
|
||||
|
||||
VALIDATE = CC='$(CC)' CFLAGS='$(CFLAGS)' CXX='$(CXX)' CXXFLAGS='$(CXXFLAGS)' GPERF='$(GPERF)' ./validate
|
||||
|
||||
check-lang-syntax : force
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -c
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -E
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -G
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -G -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -G -E
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -D
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -D -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -c
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -E
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -G
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -D
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 10 -D -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -S 1000
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -D
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -D -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -S 10
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -S 10 -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -S 10 -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -S 10 -D
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -S 10 -D -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -p -S 1000
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -K key_name
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -H hash_function_name
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest1.gperf -W word_list_name
|
||||
sed -e 's,in_word_set,lookup_function_name,g' < jstest1.gperf > tmp-jstest1.gperf && \
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 tmp-jstest1.gperf -N lookup_function_name
|
||||
sed -e 's,Perfect_Hash,class_name,g' < jstest1.gperf > tmp-jstest1.gperf && \
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 tmp-jstest1.gperf -Z class_name
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -c
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -E
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -G
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -G -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -G -E
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -D
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -D -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -c
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -C
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -E
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -G
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -D
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 10 -D -l
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -S 1000
|
||||
sed -e 's,name,key_name,g' < jstest2.gperf > tmp-jstest2.gperf && \
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 tmp-jstest2.gperf -t -p -K key_name
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 jstest2.gperf -t -p -H hash_function_name
|
||||
sed -e 's,in_word_set,lookup_function_name,g' < jstest2.gperf > tmp-jstest2.gperf && \
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 tmp-jstest2.gperf -t -p -N lookup_function_name
|
||||
sed -e 's,Perfect_Hash,class_name,g' < jstest2.gperf > tmp-jstest2.gperf && \
|
||||
$(VALIDATE) KR-C,C,ANSI-C,C++ -k1,2 tmp-jstest2.gperf -t -p -Z class_name
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -c
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -C
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -E
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -G
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -G -C
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -G -E
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -l
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -D
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -D -l
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -c
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -C
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -E
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -G
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -l
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -D
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 10 -D -l
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -S 1000
|
||||
sed -e 's,name,key_name,g' < jstest3.gperf > tmp-jstest3.gperf && \
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 tmp-jstest3.gperf -t -p -K key_name
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 jstest3.gperf -t -p -H hash_function_name
|
||||
sed -e 's,in_word_set,lookup_function_name,g' < jstest3.gperf > tmp-jstest3.gperf && \
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 tmp-jstest3.gperf -t -p -N lookup_function_name
|
||||
sed -e 's,Perfect_Hash,class_name,g' < jstest3.gperf > tmp-jstest3.gperf && \
|
||||
$(VALIDATE) C,ANSI-C,C++ -k1,2 tmp-jstest3.gperf -t -p -Z class_name
|
||||
|
||||
mostlyclean : clean
|
||||
|
||||
clean : force
|
||||
$(RM) *.o core *inset.c output.* *.out aout cout m3out pout preout tmp-* valitest*
|
||||
|
||||
distclean : clean
|
||||
$(RM) config.status config.log config.cache Makefile
|
||||
|
||||
maintainer-clean : distclean
|
||||
|
||||
force :
|
||||
|
@ -1,54 +0,0 @@
|
||||
in word set boolean
|
||||
in word set character
|
||||
in word set constraint_error
|
||||
in word set false
|
||||
in word set float
|
||||
in word set integer
|
||||
in word set natural
|
||||
in word set numeric_error
|
||||
in word set positive
|
||||
in word set program_error
|
||||
in word set storage_error
|
||||
in word set string
|
||||
in word set tasking_error
|
||||
in word set true
|
||||
in word set address
|
||||
in word set aft
|
||||
in word set base
|
||||
in word set callable
|
||||
in word set constrained
|
||||
in word set count
|
||||
in word set delta
|
||||
in word set digits
|
||||
in word set emax
|
||||
in word set epsilon
|
||||
in word set first
|
||||
in word set firstbit
|
||||
in word set fore
|
||||
in word set image
|
||||
in word set large
|
||||
in word set last
|
||||
in word set lastbit
|
||||
in word set length
|
||||
in word set machine_emax
|
||||
in word set machine_emin
|
||||
in word set machine_mantissa
|
||||
in word set machine_overflows
|
||||
in word set machine_radix
|
||||
in word set machine_rounds
|
||||
in word set mantissa
|
||||
in word set pos
|
||||
in word set position
|
||||
in word set pred
|
||||
in word set range
|
||||
in word set safe_emax
|
||||
in word set safe_large
|
||||
in word set safe_small
|
||||
in word set size
|
||||
in word set small
|
||||
in word set storage_size
|
||||
in word set succ
|
||||
in word set terminated
|
||||
in word set val
|
||||
in word set value
|
||||
in word set width
|
@ -1,63 +0,0 @@
|
||||
in word set else
|
||||
in word set exit
|
||||
in word set terminate
|
||||
in word set type
|
||||
in word set raise
|
||||
in word set range
|
||||
in word set reverse
|
||||
in word set declare
|
||||
in word set end
|
||||
in word set record
|
||||
in word set exception
|
||||
in word set not
|
||||
in word set then
|
||||
in word set return
|
||||
in word set separate
|
||||
in word set select
|
||||
in word set digits
|
||||
in word set renames
|
||||
in word set subtype
|
||||
in word set elsif
|
||||
in word set function
|
||||
in word set for
|
||||
in word set package
|
||||
in word set procedure
|
||||
in word set private
|
||||
in word set while
|
||||
in word set when
|
||||
in word set new
|
||||
in word set entry
|
||||
in word set delay
|
||||
in word set case
|
||||
in word set constant
|
||||
in word set at
|
||||
in word set abort
|
||||
in word set accept
|
||||
in word set and
|
||||
in word set delta
|
||||
in word set access
|
||||
in word set abs
|
||||
in word set pragma
|
||||
in word set array
|
||||
in word set use
|
||||
in word set out
|
||||
in word set do
|
||||
in word set others
|
||||
in word set of
|
||||
in word set or
|
||||
in word set all
|
||||
in word set limited
|
||||
in word set loop
|
||||
in word set null
|
||||
in word set task
|
||||
in word set in
|
||||
in word set is
|
||||
in word set if
|
||||
in word set rem
|
||||
in word set mod
|
||||
in word set begin
|
||||
in word set body
|
||||
in word set xor
|
||||
in word set goto
|
||||
in word set generic
|
||||
in word set with
|
@ -1,63 +0,0 @@
|
||||
else
|
||||
exit
|
||||
terminate
|
||||
type
|
||||
raise
|
||||
range
|
||||
reverse
|
||||
declare
|
||||
end
|
||||
record
|
||||
exception
|
||||
not
|
||||
then
|
||||
return
|
||||
separate
|
||||
select
|
||||
digits
|
||||
renames
|
||||
subtype
|
||||
elsif
|
||||
function
|
||||
for
|
||||
package
|
||||
procedure
|
||||
private
|
||||
while
|
||||
when
|
||||
new
|
||||
entry
|
||||
delay
|
||||
case
|
||||
constant
|
||||
at
|
||||
abort
|
||||
accept
|
||||
and
|
||||
delta
|
||||
access
|
||||
abs
|
||||
pragma
|
||||
array
|
||||
use
|
||||
out
|
||||
do
|
||||
others
|
||||
of
|
||||
or
|
||||
all
|
||||
limited
|
||||
loop
|
||||
null
|
||||
task
|
||||
in
|
||||
is
|
||||
if
|
||||
rem
|
||||
mod
|
||||
begin
|
||||
body
|
||||
xor
|
||||
goto
|
||||
generic
|
||||
with
|
@ -1,54 +0,0 @@
|
||||
boolean
|
||||
character
|
||||
constraint_error
|
||||
false
|
||||
float
|
||||
integer
|
||||
natural
|
||||
numeric_error
|
||||
positive
|
||||
program_error
|
||||
storage_error
|
||||
string
|
||||
tasking_error
|
||||
true
|
||||
address
|
||||
aft
|
||||
base
|
||||
callable
|
||||
constrained
|
||||
count
|
||||
delta
|
||||
digits
|
||||
emax
|
||||
epsilon
|
||||
first
|
||||
firstbit
|
||||
fore
|
||||
image
|
||||
large
|
||||
last
|
||||
lastbit
|
||||
length
|
||||
machine_emax
|
||||
machine_emin
|
||||
machine_mantissa
|
||||
machine_overflows
|
||||
machine_radix
|
||||
machine_rounds
|
||||
mantissa
|
||||
pos
|
||||
position
|
||||
pred
|
||||
range
|
||||
safe_emax
|
||||
safe_large
|
||||
safe_small
|
||||
size
|
||||
small
|
||||
storage_size
|
||||
succ
|
||||
terminated
|
||||
val
|
||||
value
|
||||
width
|
@ -1,47 +0,0 @@
|
||||
asm
|
||||
auto
|
||||
break
|
||||
case
|
||||
catch
|
||||
char
|
||||
class
|
||||
const
|
||||
continue
|
||||
default
|
||||
delete
|
||||
do
|
||||
double
|
||||
else
|
||||
enum
|
||||
extern
|
||||
float
|
||||
for
|
||||
friend
|
||||
goto
|
||||
if
|
||||
inline
|
||||
int
|
||||
long
|
||||
new
|
||||
operator
|
||||
overload
|
||||
private
|
||||
protected
|
||||
public
|
||||
register
|
||||
return
|
||||
short
|
||||
signed
|
||||
sizeof
|
||||
static
|
||||
struct
|
||||
switch
|
||||
template
|
||||
this
|
||||
typedef
|
||||
union
|
||||
unsigned
|
||||
virtual
|
||||
void
|
||||
volatile
|
||||
while
|
@ -1,56 +0,0 @@
|
||||
%{
|
||||
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
|
||||
%}
|
||||
struct resword { char *name; short token; enum rid rid; };
|
||||
%%
|
||||
__alignof, ALIGNOF, NORID
|
||||
__alignof__, ALIGNOF, NORID
|
||||
__asm, ASM, NORID
|
||||
__asm__, ASM, NORID
|
||||
__attribute, ATTRIBUTE, NORID
|
||||
__attribute__, ATTRIBUTE, NORID
|
||||
__const, TYPE_QUAL, RID_CONST
|
||||
__const__, TYPE_QUAL, RID_CONST
|
||||
__inline, SCSPEC, RID_INLINE
|
||||
__inline__, SCSPEC, RID_INLINE
|
||||
__signed, TYPESPEC, RID_SIGNED
|
||||
__signed__, TYPESPEC, RID_SIGNED
|
||||
__typeof, TYPEOF, NORID
|
||||
__typeof__, TYPEOF, NORID
|
||||
__volatile, TYPE_QUAL, RID_VOLATILE
|
||||
__volatile__, TYPE_QUAL, RID_VOLATILE
|
||||
asm, ASM, NORID
|
||||
auto, SCSPEC, RID_AUTO
|
||||
break, BREAK, NORID
|
||||
case, CASE, NORID
|
||||
char, TYPESPEC, RID_CHAR
|
||||
const, TYPE_QUAL, RID_CONST
|
||||
continue, CONTINUE, NORID
|
||||
default, DEFAULT, NORID
|
||||
do, DO, NORID
|
||||
double, TYPESPEC, RID_DOUBLE
|
||||
else, ELSE, NORID
|
||||
enum, ENUM, NORID
|
||||
extern, SCSPEC, RID_EXTERN
|
||||
float, TYPESPEC, RID_FLOAT
|
||||
for, FOR, NORID
|
||||
goto, GOTO, NORID
|
||||
if, IF, NORID
|
||||
inline, SCSPEC, RID_INLINE
|
||||
int, TYPESPEC, RID_INT
|
||||
long, TYPESPEC, RID_LONG
|
||||
register, SCSPEC, RID_REGISTER
|
||||
return, RETURN, NORID
|
||||
short, TYPESPEC, RID_SHORT
|
||||
signed, TYPESPEC, RID_SIGNED
|
||||
sizeof, SIZEOF, NORID
|
||||
static, SCSPEC, RID_STATIC
|
||||
struct, STRUCT, NORID
|
||||
switch, SWITCH, NORID
|
||||
typedef, SCSPEC, RID_TYPEDEF
|
||||
typeof, TYPEOF, NORID
|
||||
union, UNION, NORID
|
||||
unsigned, TYPESPEC, RID_UNSIGNED
|
||||
void, TYPESPEC, RID_VOID
|
||||
volatile, TYPE_QUAL, RID_VOLATILE
|
||||
while, WHILE, NORID
|
@ -1,32 +0,0 @@
|
||||
in word set if
|
||||
in word set do
|
||||
in word set int
|
||||
in word set for
|
||||
in word set case
|
||||
in word set char
|
||||
in word set auto
|
||||
in word set goto
|
||||
in word set else
|
||||
in word set long
|
||||
in word set void
|
||||
in word set enum
|
||||
in word set float
|
||||
in word set short
|
||||
in word set union
|
||||
in word set break
|
||||
in word set while
|
||||
in word set const
|
||||
in word set double
|
||||
in word set static
|
||||
in word set extern
|
||||
in word set struct
|
||||
in word set return
|
||||
in word set sizeof
|
||||
in word set switch
|
||||
in word set signed
|
||||
in word set typedef
|
||||
in word set default
|
||||
in word set unsigned
|
||||
in word set continue
|
||||
in word set register
|
||||
in word set volatile
|
@ -1,32 +0,0 @@
|
||||
if
|
||||
do
|
||||
int
|
||||
for
|
||||
case
|
||||
char
|
||||
auto
|
||||
goto
|
||||
else
|
||||
long
|
||||
void
|
||||
enum
|
||||
float
|
||||
short
|
||||
union
|
||||
break
|
||||
while
|
||||
const
|
||||
double
|
||||
static
|
||||
extern
|
||||
struct
|
||||
return
|
||||
sizeof
|
||||
switch
|
||||
signed
|
||||
typedef
|
||||
default
|
||||
unsigned
|
||||
continue
|
||||
register
|
||||
volatile
|
1214
contrib/gperf/tests/configure
vendored
1214
contrib/gperf/tests/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,45 +0,0 @@
|
||||
dnl autoconf configuration for gperf/tests
|
||||
|
||||
dnl Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
dnl written by Douglas C. Schmidt (schmidt@ics.uci.edu)
|
||||
dnl
|
||||
dnl This file is part of GNU GPERF.
|
||||
dnl
|
||||
dnl GNU GPERF is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 1, or (at your option)
|
||||
dnl any later version.
|
||||
dnl
|
||||
dnl GNU GPERF is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with GNU GPERF; see the file COPYING. If not, write to the
|
||||
dnl Free Software Foundation, 59 Temple Place - Suite 330, Boston,
|
||||
dnl MA 02111-1307, USA.
|
||||
|
||||
AC_INIT(c-parse.gperf)
|
||||
AC_PROG_MAKE_SET
|
||||
dnl
|
||||
dnl checks for programs
|
||||
dnl
|
||||
AC_PROG_CC
|
||||
dnl sets variable CC
|
||||
AC_PROG_CPP
|
||||
dnl sets variable CPP
|
||||
AC_PROG_CXX
|
||||
dnl sets variable CXX
|
||||
AC_PROG_CXXCPP
|
||||
dnl sets variable CXXCPP
|
||||
if test $ac_cv_prog_gcc = yes -a $ac_cv_prog_gxx = yes; then
|
||||
CHECK_LANG_SYNTAX='check-lang-syntax'
|
||||
else
|
||||
CHECK_LANG_SYNTAX=''
|
||||
fi
|
||||
AC_SUBST(CHECK_LANG_SYNTAX)
|
||||
dnl
|
||||
dnl That's it.
|
||||
dnl
|
||||
AC_OUTPUT(Makefile)
|
@ -1,48 +0,0 @@
|
||||
%{
|
||||
/* ISO Pascal 7185 reserved words.
|
||||
*
|
||||
* For GNU Pascal compiler (GPC) by jtv@hut.fi
|
||||
*
|
||||
* run this through the Doug Schmidt's gperf program
|
||||
* with command
|
||||
* gperf -g -o -j1 -t -p -N is_reserved_word
|
||||
*
|
||||
*/
|
||||
%}
|
||||
struct resword { char *name; short token; short iclass;};
|
||||
%%
|
||||
And, AND, PASCAL_ISO
|
||||
Array, ARRAY, PASCAL_ISO
|
||||
Begin, BEGIN_, PASCAL_ISO
|
||||
Case, CASE, PASCAL_ISO
|
||||
Const, CONST, PASCAL_ISO
|
||||
Div, DIV, PASCAL_ISO
|
||||
Do, DO, PASCAL_ISO
|
||||
Downto, DOWNTO, PASCAL_ISO
|
||||
Else, ELSE, PASCAL_ISO
|
||||
End, END, PASCAL_ISO
|
||||
File, FILE_, PASCAL_ISO
|
||||
For, FOR, PASCAL_ISO
|
||||
Function, FUNCTION, PASCAL_ISO
|
||||
Goto, GOTO, PASCAL_ISO
|
||||
If, IF, PASCAL_ISO
|
||||
In, IN, PASCAL_ISO
|
||||
Label, LABEL, PASCAL_ISO
|
||||
Mod, MOD, PASCAL_ISO
|
||||
Nil, NIL, PASCAL_ISO
|
||||
Not, NOT, PASCAL_ISO
|
||||
Of, OF, PASCAL_ISO
|
||||
Or, OR, PASCAL_ISO
|
||||
Packed, PACKED, PASCAL_ISO
|
||||
Procedure, PROCEDURE, PASCAL_ISO
|
||||
Program,PROGRAM,PASCAL_ISO
|
||||
Record, RECORD, PASCAL_ISO
|
||||
Repeat, REPEAT, PASCAL_ISO
|
||||
Set, SET, PASCAL_ISO
|
||||
Then, THEN, PASCAL_ISO
|
||||
To, TO, PASCAL_ISO
|
||||
Type, TYPE, PASCAL_ISO
|
||||
Until, UNTIL, PASCAL_ISO
|
||||
Var, VAR, PASCAL_ISO
|
||||
While, WHILE, PASCAL_ISO
|
||||
With, WITH, PASCAL_ISO
|
@ -1,76 +0,0 @@
|
||||
%{
|
||||
/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
|
||||
%}
|
||||
struct resword { char *name; short token; enum rid rid;};
|
||||
%%
|
||||
__alignof, ALIGNOF, NORID
|
||||
__alignof__, ALIGNOF, NORID
|
||||
__asm, ASM, NORID
|
||||
__asm__, ASM, NORID
|
||||
__attribute, ATTRIBUTE, NORID
|
||||
__attribute__, ATTRIBUTE, NORID
|
||||
__const, TYPE_QUAL, RID_CONST
|
||||
__const__, TYPE_QUAL, RID_CONST
|
||||
__inline, SCSPEC, RID_INLINE
|
||||
__inline__, SCSPEC, RID_INLINE
|
||||
__signed, TYPESPEC, RID_SIGNED
|
||||
__signed__, TYPESPEC, RID_SIGNED
|
||||
__typeof, TYPEOF, NORID
|
||||
__typeof__, TYPEOF, NORID
|
||||
__volatile, TYPE_QUAL, RID_VOLATILE
|
||||
__volatile__, TYPE_QUAL, RID_VOLATILE
|
||||
all, ALL, NORID /* Extension */,
|
||||
except, EXCEPT, NORID /* Extension */,
|
||||
exception, AGGR, RID_EXCEPTION /* Extension */,
|
||||
raise, RAISE, NORID /* Extension */,
|
||||
raises, RAISES, NORID /* Extension */,
|
||||
reraise, RERAISE, NORID /* Extension */,
|
||||
try, TRY, NORID /* Extension */,
|
||||
asm, ASM, NORID,
|
||||
auto, SCSPEC, RID_AUTO,
|
||||
break, BREAK, NORID,
|
||||
case, CASE, NORID,
|
||||
catch, CATCH, NORID,
|
||||
char, TYPESPEC, RID_CHAR,
|
||||
class, AGGR, RID_CLASS,
|
||||
const, TYPE_QUAL, RID_CONST,
|
||||
continue, CONTINUE, NORID,
|
||||
default, DEFAULT, NORID,
|
||||
delete, DELETE, NORID,
|
||||
do, DO, NORID,
|
||||
double, TYPESPEC, RID_DOUBLE,
|
||||
dynamic, DYNAMIC, NORID,
|
||||
else, ELSE, NORID,
|
||||
enum, ENUM, NORID,
|
||||
extern, SCSPEC, RID_EXTERN,
|
||||
float, TYPESPEC, RID_FLOAT,
|
||||
for, FOR, NORID,
|
||||
friend, SCSPEC, RID_FRIEND,
|
||||
goto, GOTO, NORID,
|
||||
if, IF, NORID,
|
||||
inline, SCSPEC, RID_INLINE,
|
||||
int, TYPESPEC, RID_INT,
|
||||
long, TYPESPEC, RID_LONG,
|
||||
new, NEW, NORID,
|
||||
operator, OPERATOR, NORID,
|
||||
overload, OVERLOAD, NORID,
|
||||
private, PRIVATE, NORID,
|
||||
protected, PROTECTED, NORID,
|
||||
public, PUBLIC, NORID,
|
||||
register, SCSPEC, RID_REGISTER,
|
||||
return, RETURN, NORID,
|
||||
short, TYPESPEC, RID_SHORT,
|
||||
signed, TYPESPEC, RID_SIGNED,
|
||||
sizeof, SIZEOF, NORID,
|
||||
static, SCSPEC, RID_STATIC,
|
||||
struct, AGGR, RID_RECORD,
|
||||
switch, SWITCH, NORID,
|
||||
this, THIS, NORID,
|
||||
typedef, SCSPEC, RID_TYPEDEF,
|
||||
typeof, TYPEOF, NORID,
|
||||
union, AGGR, RID_UNION,
|
||||
unsigned, TYPESPEC, RID_UNSIGNED,
|
||||
virtual, SCSPEC, RID_VIRTUAL,
|
||||
void, TYPESPEC, RID_VOID,
|
||||
volatile, TYPE_QUAL, RID_VOLATILE,
|
||||
while, WHILE, NORID,
|
@ -1,63 +0,0 @@
|
||||
%{
|
||||
extern int m_text(), m_private(), m_who(), m_whois(), m_user(), m_list();
|
||||
extern int m_topic(), m_invite(), m_channel(), m_version(), m_quit();
|
||||
extern int m_server(), m_kill(), m_info(), m_links(), m_summon(), m_stats();
|
||||
extern int m_users(), m_nick(), m_error(), m_help(), m_whoreply();
|
||||
extern int m_squit(), m_restart(), m_away(), m_die(), m_connect();
|
||||
extern int m_ping(), m_pong(), m_oper(), m_pass(), m_wall(), m_trace();
|
||||
extern int m_time(), m_rehash(), m_names(), m_namreply(), m_admin();
|
||||
extern int m_linreply(), m_notice(), m_lusers(), m_voice(), m_grph();
|
||||
extern int m_xtra(), m_motd();
|
||||
%}
|
||||
struct Message {
|
||||
char *cmd;
|
||||
int (* func)();
|
||||
int count;
|
||||
int parameters;
|
||||
};
|
||||
%%
|
||||
NICK, m_nick, 0, 1
|
||||
MSG, m_text, 0, 1
|
||||
PRIVMSG, m_private, 0, 2
|
||||
WHO, m_who, 0, 1
|
||||
WHOIS, m_whois, 0, 4
|
||||
USER, m_user, 0, 4
|
||||
SERVER, m_server, 0, 2
|
||||
LIST, m_list, 0, 1
|
||||
TOPIC, m_topic, 0, 1
|
||||
INVITE, m_invite, 0, 2
|
||||
CHANNEL, m_channel, 0, 1
|
||||
VERSION, m_version, 0, 1
|
||||
QUIT, m_quit, 0, 2
|
||||
SQUIT, m_squit, 0, 2
|
||||
KILL, m_kill, 0, 2
|
||||
INFO, m_info, 0, 1
|
||||
LINKS, m_links, 0, 1
|
||||
SUMMON, m_summon, 0, 1
|
||||
STATS, m_stats, 0, 1
|
||||
USERS, m_users, 0, 1
|
||||
RESTART, m_restart, 0, 1
|
||||
WHOREPLY,m_whoreply, 0, 7
|
||||
HELP, m_help, 0, 2
|
||||
ERROR, m_error, 0, 1
|
||||
AWAY, m_away, 0, 1
|
||||
DIE, m_die, 0, 1
|
||||
CONNECT, m_connect, 0, 3
|
||||
PING, m_ping, 0, 2
|
||||
PONG, m_pong, 0, 3
|
||||
OPER, m_oper, 0, 3
|
||||
PASS, m_pass, 0, 2
|
||||
WALL, m_wall, 0, 1
|
||||
TIME, m_time, 0, 1
|
||||
REHASH, m_rehash, 0, 1
|
||||
NAMES, m_names, 0, 1
|
||||
NAMREPLY,m_namreply, 0, 3
|
||||
ADMIN, m_admin, 0, 1
|
||||
TRACE, m_trace, 0, 1
|
||||
LINREPLY,m_linreply, 0, 2
|
||||
NOTICE, m_notice, 0, 2
|
||||
LUSERS, m_lusers, 0, 1
|
||||
VOICE, m_voice, 0, 2
|
||||
GRPH, m_grph, 0, 2
|
||||
XTRA, m_xtra, 0, 2
|
||||
MOTD, m_motd, 0, 2
|
@ -1,73 +0,0 @@
|
||||
%{
|
||||
/* Command-line: gperf -k'1,2,$' -t -p -K 'name' -H 'js_kw_hash' -N 'js_kw_lookup' -a -g jscript.gperf */
|
||||
%}
|
||||
struct js_keyword {
|
||||
char * name;
|
||||
int token;
|
||||
}
|
||||
|
||||
%%
|
||||
# Javascript reserved words, see "keywords.html"
|
||||
abstract, TK_ABSTRACT
|
||||
boolean, TK_BOOLEAN
|
||||
break, TK_BREAK
|
||||
byte, TK_BYTE
|
||||
case, TK_CASE
|
||||
catch, TK_CATCH
|
||||
char, TK_CHAR
|
||||
class, TK_CLASS
|
||||
const, TK_CONST
|
||||
continue, TK_CONTINUE
|
||||
default, TK_DEFAULT
|
||||
do, TK_DO
|
||||
double, TK_DOUBLE
|
||||
else, TK_ELSE
|
||||
extends, TK_EXTENDS
|
||||
false, TK_FALSE
|
||||
final, TK_FINAL
|
||||
finally, TK_FINALLY
|
||||
float, TK_FLOAT
|
||||
for, TK_FOR
|
||||
function, TK_FUNCTION
|
||||
goto, TK_GOTO
|
||||
if, TK_IF
|
||||
implements, TK_IMPLEMENTS
|
||||
import, TK_IMPORT
|
||||
in, TK_IN
|
||||
instanceof, TK_INSTANCEOF
|
||||
int, TK_INT
|
||||
interface, TK_INTERFACE
|
||||
long, TK_LONG
|
||||
native, TK_NATIVE
|
||||
new, TK_NEW
|
||||
null, TK_NULL
|
||||
package, TK_PACKAGE
|
||||
private, TK_PRIVATE
|
||||
protected, TK_PROTECTED
|
||||
public, TK_PUBLIC
|
||||
return, TK_RETURN
|
||||
short, TK_SHORT
|
||||
static, TK_STATIC
|
||||
super, TK_SUPER
|
||||
switch, TK_SWITCH
|
||||
synchronized, TK_SYNCHRONIZED
|
||||
this, TK_THIS
|
||||
throw, TK_THROW
|
||||
throws, TK_THROWS
|
||||
transient, TK_TRANSIENT
|
||||
true, TK_TRUE
|
||||
try, TK_TRY
|
||||
var, TK_VAR
|
||||
void, TK_VOID
|
||||
while, TK_WHILE
|
||||
with, TK_WITH
|
||||
%%
|
||||
|
||||
int js_keyword_lookup (register const char *str, register int len)
|
||||
{
|
||||
struct js_keyword * keyword = js_kw_lookup(str,len);
|
||||
if (keyword)
|
||||
return keyword->token;
|
||||
else
|
||||
return TK_IDENT;
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
abstract
|
||||
boolean
|
||||
break
|
||||
byte
|
||||
case
|
||||
catch
|
||||
char
|
||||
class
|
||||
const
|
||||
continue
|
||||
default
|
||||
do
|
||||
double
|
||||
else
|
||||
extends
|
||||
false
|
||||
final
|
||||
finally
|
||||
float
|
||||
for
|
||||
function
|
||||
goto
|
||||
if
|
||||
implements
|
||||
import
|
||||
in
|
||||
instanceof
|
||||
int
|
||||
interface
|
||||
long
|
||||
native
|
||||
new
|
||||
null
|
||||
package
|
||||
private
|
||||
protected
|
||||
public
|
||||
return
|
||||
short
|
||||
static
|
||||
super
|
||||
switch
|
||||
synchronized
|
||||
this
|
||||
throw
|
||||
throws
|
||||
transient
|
||||
true
|
||||
try
|
||||
var
|
||||
void
|
||||
while
|
||||
with
|
||||
%%
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define CONST const
|
||||
#else
|
||||
#define CONST
|
||||
#endif
|
||||
static CONST char* testdata[] = {
|
||||
"bogus",
|
||||
"abstract",
|
||||
"boolean",
|
||||
"break",
|
||||
"byte",
|
||||
"case",
|
||||
"catch",
|
||||
"char",
|
||||
"class",
|
||||
"const",
|
||||
"continue",
|
||||
"default",
|
||||
"do",
|
||||
"double",
|
||||
"else",
|
||||
"extends",
|
||||
"false",
|
||||
"final",
|
||||
"finally",
|
||||
"float",
|
||||
"for",
|
||||
"function",
|
||||
"goto",
|
||||
"if",
|
||||
"implements",
|
||||
"import",
|
||||
"in",
|
||||
"instanceof",
|
||||
"int",
|
||||
"interface",
|
||||
"long",
|
||||
"native",
|
||||
"new",
|
||||
"null",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"return",
|
||||
"short",
|
||||
"static",
|
||||
"super",
|
||||
"switch",
|
||||
"synchronized",
|
||||
"this",
|
||||
"throw",
|
||||
"throws",
|
||||
"transient",
|
||||
"true",
|
||||
"try",
|
||||
"var",
|
||||
"void",
|
||||
"while",
|
||||
"with"
|
||||
};
|
||||
int main ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++)
|
||||
{
|
||||
#ifdef CPLUSPLUS_TEST
|
||||
CONST char * resword = Perfect_Hash::in_word_set(testdata[i],strlen(testdata[i]));
|
||||
#else
|
||||
CONST char * resword = in_word_set(testdata[i],strlen(testdata[i]));
|
||||
#endif
|
||||
if (i > 0)
|
||||
{
|
||||
if (!resword)
|
||||
exit (1);
|
||||
if (strcmp(testdata[i],resword))
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resword)
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
struct js_keyword {
|
||||
char * name;
|
||||
int token;
|
||||
}
|
||||
%%
|
||||
abstract, 1
|
||||
boolean, 2
|
||||
break, 3
|
||||
byte, 4
|
||||
case, 5
|
||||
catch, 6
|
||||
char, 7
|
||||
class, 8
|
||||
const, 9
|
||||
continue, 10
|
||||
default, 11
|
||||
do, 12
|
||||
double, 13
|
||||
else, 14
|
||||
extends, 15
|
||||
false, 16
|
||||
final, 17
|
||||
finally, 18
|
||||
float, 19
|
||||
for, 20
|
||||
function, 21
|
||||
goto, 22
|
||||
if, 23
|
||||
implements, 24
|
||||
import, 25
|
||||
in, 26
|
||||
instanceof, 27
|
||||
int, 28
|
||||
interface, 29
|
||||
long, 30
|
||||
native, 31
|
||||
new, 32
|
||||
null, 33
|
||||
package, 34
|
||||
private, 35
|
||||
protected, 36
|
||||
public, 37
|
||||
return, 38
|
||||
short, 39
|
||||
static, 40
|
||||
super, 41
|
||||
switch, 42
|
||||
synchronized, 43
|
||||
this, 44
|
||||
throw, 45
|
||||
throws, 46
|
||||
transient, 47
|
||||
true, 48
|
||||
try, 49
|
||||
var, 50
|
||||
void, 51
|
||||
while, 52
|
||||
with, 53
|
||||
%%
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define CONST const
|
||||
#else
|
||||
#define CONST
|
||||
#endif
|
||||
static CONST char* testdata[] = {
|
||||
"bogus",
|
||||
"abstract",
|
||||
"boolean",
|
||||
"break",
|
||||
"byte",
|
||||
"case",
|
||||
"catch",
|
||||
"char",
|
||||
"class",
|
||||
"const",
|
||||
"continue",
|
||||
"default",
|
||||
"do",
|
||||
"double",
|
||||
"else",
|
||||
"extends",
|
||||
"false",
|
||||
"final",
|
||||
"finally",
|
||||
"float",
|
||||
"for",
|
||||
"function",
|
||||
"goto",
|
||||
"if",
|
||||
"implements",
|
||||
"import",
|
||||
"in",
|
||||
"instanceof",
|
||||
"int",
|
||||
"interface",
|
||||
"long",
|
||||
"native",
|
||||
"new",
|
||||
"null",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"return",
|
||||
"short",
|
||||
"static",
|
||||
"super",
|
||||
"switch",
|
||||
"synchronized",
|
||||
"this",
|
||||
"throw",
|
||||
"throws",
|
||||
"transient",
|
||||
"true",
|
||||
"try",
|
||||
"var",
|
||||
"void",
|
||||
"while",
|
||||
"with"
|
||||
};
|
||||
int main ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++)
|
||||
{
|
||||
#ifdef CPLUSPLUS_TEST
|
||||
CONST struct js_keyword * resword = Perfect_Hash::in_word_set(testdata[i],strlen(testdata[i]));
|
||||
#else
|
||||
CONST struct js_keyword * resword = in_word_set(testdata[i],strlen(testdata[i]));
|
||||
#endif
|
||||
if (i > 0)
|
||||
{
|
||||
if (!resword)
|
||||
exit (1);
|
||||
if (strcmp(testdata[i],resword->name))
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resword)
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
struct js_keyword {
|
||||
const char * name;
|
||||
int token;
|
||||
}
|
||||
%%
|
||||
abstract, 1
|
||||
boolean, 2
|
||||
break, 3
|
||||
byte, 4
|
||||
case, 5
|
||||
catch, 6
|
||||
char, 7
|
||||
class, 8
|
||||
const, 9
|
||||
continue, 10
|
||||
default, 11
|
||||
do, 12
|
||||
double, 13
|
||||
else, 14
|
||||
extends, 15
|
||||
false, 16
|
||||
final, 17
|
||||
finally, 18
|
||||
float, 19
|
||||
for, 20
|
||||
function, 21
|
||||
goto, 22
|
||||
if, 23
|
||||
implements, 24
|
||||
import, 25
|
||||
in, 26
|
||||
instanceof, 27
|
||||
int, 28
|
||||
interface, 29
|
||||
long, 30
|
||||
native, 31
|
||||
new, 32
|
||||
null, 33
|
||||
package, 34
|
||||
private, 35
|
||||
protected, 36
|
||||
public, 37
|
||||
return, 38
|
||||
short, 39
|
||||
static, 40
|
||||
super, 41
|
||||
switch, 42
|
||||
synchronized, 43
|
||||
this, 44
|
||||
throw, 45
|
||||
throws, 46
|
||||
transient, 47
|
||||
true, 48
|
||||
try, 49
|
||||
var, 50
|
||||
void, 51
|
||||
while, 52
|
||||
with, 53
|
||||
%%
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define CONST const
|
||||
#else
|
||||
#define CONST
|
||||
#endif
|
||||
static CONST char* testdata[] = {
|
||||
"bogus",
|
||||
"abstract",
|
||||
"boolean",
|
||||
"break",
|
||||
"byte",
|
||||
"case",
|
||||
"catch",
|
||||
"char",
|
||||
"class",
|
||||
"const",
|
||||
"continue",
|
||||
"default",
|
||||
"do",
|
||||
"double",
|
||||
"else",
|
||||
"extends",
|
||||
"false",
|
||||
"final",
|
||||
"finally",
|
||||
"float",
|
||||
"for",
|
||||
"function",
|
||||
"goto",
|
||||
"if",
|
||||
"implements",
|
||||
"import",
|
||||
"in",
|
||||
"instanceof",
|
||||
"int",
|
||||
"interface",
|
||||
"long",
|
||||
"native",
|
||||
"new",
|
||||
"null",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"return",
|
||||
"short",
|
||||
"static",
|
||||
"super",
|
||||
"switch",
|
||||
"synchronized",
|
||||
"this",
|
||||
"throw",
|
||||
"throws",
|
||||
"transient",
|
||||
"true",
|
||||
"try",
|
||||
"var",
|
||||
"void",
|
||||
"while",
|
||||
"with"
|
||||
};
|
||||
int main ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++)
|
||||
{
|
||||
#ifdef CPLUSPLUS_TEST
|
||||
CONST struct js_keyword * resword = Perfect_Hash::in_word_set(testdata[i],strlen(testdata[i]));
|
||||
#else
|
||||
CONST struct js_keyword * resword = in_word_set(testdata[i],strlen(testdata[i]));
|
||||
#endif
|
||||
if (i > 0)
|
||||
{
|
||||
if (!resword)
|
||||
exit (1);
|
||||
if (strcmp(testdata[i],resword->name))
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resword)
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
COMMAND;
|
||||
%%
|
||||
!, cm_force_sentence_end, false
|
||||
', insert_self, false
|
||||
*, cm_asterisk, false
|
||||
., cm_force_sentence_end, false
|
||||
:, cm_force_abbreviated_whitespace, false
|
||||
?, cm_force_sentence_end, false
|
||||
@, insert_self, false
|
||||
TeX, cm_TeX, true
|
||||
`, insert_self, false
|
||||
appendix, cm_appendix, false
|
||||
appendixsec, cm_appendixsec, false
|
||||
appendixsubsec, cm_appendixsubsec, false
|
||||
asis, cm_asis, true
|
||||
b, cm_bold, true
|
||||
br, cm_br, false
|
||||
bullet, cm_bullet, true
|
||||
bye, cm_bye, false
|
||||
c, cm_comment, false
|
||||
center, cm_center, false
|
||||
chapter, cm_chapter, false
|
||||
cindex, cm_cindex, false
|
||||
cite, cm_cite, true
|
||||
code, cm_code, true
|
||||
comment, cm_comment, false
|
||||
contents, do_nothing, false
|
||||
copyright, cm_copyright, true
|
||||
ctrl, cm_ctrl, true
|
||||
defcodeindex, cm_defindex, false
|
||||
defindex, cm_defindex, false
|
||||
dfn, cm_dfn, true
|
||||
display, cm_display, false
|
||||
dots, cm_dots, true
|
||||
emph, cm_emph, true
|
||||
end, cm_end, false
|
||||
enumerate, cm_enumerate, false
|
||||
equiv, cm_equiv, true
|
||||
error, cm_error, true
|
||||
example, cm_example, false
|
||||
exdent, cm_exdent, false
|
||||
expansion, cm_expansion, true
|
||||
file, cm_file, true
|
||||
findex, cm_findex, false
|
||||
format, cm_format, false
|
||||
group, cm_group, false
|
||||
i, cm_italic, true
|
||||
iappendix, cm_appendix, false
|
||||
iappendixsec, cm_appendixsec, false
|
||||
iappendixsubsec, cm_appendixsubsec, false
|
||||
ichapter, cm_chapter, false
|
||||
ifinfo, cm_ifinfo, false
|
||||
iftex, cm_iftex, false
|
||||
ignore, cm_ignore, false
|
||||
include, cm_include, false
|
||||
inforef, cm_inforef, true
|
||||
input, cm_include, false
|
||||
isection, cm_section, false
|
||||
isubsection, cm_subsection, false
|
||||
isubsubsection, cm_subsubsection, false
|
||||
item, cm_item, false
|
||||
itemize, cm_itemize, false
|
||||
itemx, cm_itemx, false
|
||||
iunnumbered, cm_unnumbered, false
|
||||
iunnumberedsec, cm_unnumberedsec, false
|
||||
iunnumberedsubsec, cm_unnumberedsubsec, false
|
||||
kbd, cm_kbd, true
|
||||
key, cm_key, true
|
||||
kindex, cm_kindex, false
|
||||
lisp, cm_lisp, false
|
||||
menu, cm_menu
|
||||
minus, cm_minus, true
|
||||
need, cm_need, false
|
||||
node, cm_node, false
|
||||
noindent, cm_noindent, false
|
||||
page, do_nothing, false
|
||||
pindex, cm_pindex, false
|
||||
point, cm_point, true
|
||||
print, cm_print, true
|
||||
printindex, cm_printindex, false
|
||||
pxref, cm_pxref, true
|
||||
quotation, cm_quotation, false
|
||||
r, cm_roman, true
|
||||
ref, cm_xref, true
|
||||
refill, cm_refill, false
|
||||
result, cm_result, true
|
||||
samp, cm_samp, true
|
||||
sc, cm_sc, true
|
||||
section, cm_section, false
|
||||
setchapternewpage, cm_setchapternewpage, false
|
||||
setfilename, cm_setfilename, false
|
||||
settitle, cm_settitle, false
|
||||
smallexample, cm_smallexample, false
|
||||
sp, cm_sp, false
|
||||
strong, cm_strong, true
|
||||
subsection, cm_subsection, false
|
||||
subsubsection, cm_subsubsection, false
|
||||
summarycontents, do_nothing, false
|
||||
syncodeindex, cm_synindex, false
|
||||
synindex, cm_synindex, false
|
||||
t, cm_title, true
|
||||
table, cm_table, false
|
||||
tex, cm_tex, false
|
||||
tindex, cm_tindex, false
|
||||
titlepage, cm_titlepage, false
|
||||
unnumbered, cm_unnumbered, false
|
||||
unnumberedsec, cm_unnumberedsec, false
|
||||
unnumberedsubsec, cm_unnumberedsubsec, false
|
||||
var, cm_var, true
|
||||
vindex, cm_vindex, false
|
||||
w, cm_w, true
|
||||
xref, cm_xref, true
|
||||
{, insert_self, false
|
||||
}, insert_self, false
|
||||
infoinclude, cm_infoinclude, false
|
||||
footnote, cm_footnote, false
|
@ -1,106 +0,0 @@
|
||||
in word set AND
|
||||
in word set ARRAY
|
||||
in word set BEGIN
|
||||
in word set BITS
|
||||
in word set BY
|
||||
in word set CASE
|
||||
in word set CONST
|
||||
in word set DIV
|
||||
in word set DO
|
||||
in word set ELSE
|
||||
in word set ELSIF
|
||||
in word set END
|
||||
in word set EVAL
|
||||
in word set EXCEPT
|
||||
in word set EXCEPTION
|
||||
in word set EXIT
|
||||
in word set EXPORTS
|
||||
in word set FINALLY
|
||||
in word set FOR
|
||||
in word set FROM
|
||||
in word set IF
|
||||
in word set IMPORT
|
||||
in word set INTERFACE
|
||||
in word set IN
|
||||
in word set INLINE
|
||||
in word set LOCK
|
||||
in word set METHODS
|
||||
in word set MOD
|
||||
in word set MODULE
|
||||
in word set NOT
|
||||
in word set OBJECT
|
||||
in word set OF
|
||||
in word set OR
|
||||
in word set PROCEDURE
|
||||
in word set RAISES
|
||||
in word set READONLY
|
||||
in word set RECORD
|
||||
in word set REF
|
||||
in word set REPEAT
|
||||
in word set RETURN
|
||||
in word set SET
|
||||
in word set THEN
|
||||
in word set TO
|
||||
in word set TRY
|
||||
in word set TYPE
|
||||
in word set TYPECASE
|
||||
in word set UNSAFE
|
||||
in word set UNTIL
|
||||
in word set UNTRACED
|
||||
in word set VALUE
|
||||
in word set VAR
|
||||
in word set WHILE
|
||||
in word set WITH
|
||||
in word set and
|
||||
in word set array
|
||||
in word set begin
|
||||
in word set bits
|
||||
in word set by
|
||||
in word set case
|
||||
in word set const
|
||||
in word set div
|
||||
in word set do
|
||||
in word set else
|
||||
in word set elsif
|
||||
in word set end
|
||||
in word set eval
|
||||
in word set except
|
||||
in word set exception
|
||||
in word set exit
|
||||
in word set exports
|
||||
in word set finally
|
||||
in word set for
|
||||
in word set from
|
||||
in word set if
|
||||
in word set import
|
||||
in word set interface
|
||||
in word set in
|
||||
in word set inline
|
||||
in word set lock
|
||||
in word set methods
|
||||
in word set mod
|
||||
in word set module
|
||||
in word set not
|
||||
in word set object
|
||||
in word set of
|
||||
in word set or
|
||||
in word set procedure
|
||||
in word set raises
|
||||
in word set readonly
|
||||
in word set record
|
||||
in word set ref
|
||||
in word set repeat
|
||||
in word set return
|
||||
in word set set
|
||||
in word set then
|
||||
in word set to
|
||||
in word set try
|
||||
in word set type
|
||||
in word set typecase
|
||||
in word set unsafe
|
||||
in word set until
|
||||
in word set untraced
|
||||
in word set value
|
||||
in word set var
|
||||
in word set while
|
||||
in word set with
|
@ -1,40 +0,0 @@
|
||||
AND
|
||||
ARRAY
|
||||
BEGIN
|
||||
BY
|
||||
CASE
|
||||
CONST
|
||||
DEFINITION
|
||||
DIV
|
||||
DO
|
||||
ELSE
|
||||
ELSIF
|
||||
END
|
||||
EXIT
|
||||
EXPORT
|
||||
FOR
|
||||
FROM
|
||||
IF
|
||||
IMPLEMENTATION
|
||||
IMPORT
|
||||
IN
|
||||
LOOP
|
||||
MOD
|
||||
MODULE
|
||||
NOT
|
||||
OF
|
||||
OR
|
||||
POINTER
|
||||
PROCEDURE
|
||||
QUALIFIED
|
||||
RECORD
|
||||
REPEAT
|
||||
RETURN
|
||||
SET
|
||||
THEN
|
||||
TO
|
||||
TYPE
|
||||
UNTIL
|
||||
VAR
|
||||
WHILE
|
||||
WITH
|
@ -1,106 +0,0 @@
|
||||
AND
|
||||
ARRAY
|
||||
BEGIN
|
||||
BITS
|
||||
BY
|
||||
CASE
|
||||
CONST
|
||||
DIV
|
||||
DO
|
||||
ELSE
|
||||
ELSIF
|
||||
END
|
||||
EVAL
|
||||
EXCEPT
|
||||
EXCEPTION
|
||||
EXIT
|
||||
EXPORTS
|
||||
FINALLY
|
||||
FOR
|
||||
FROM
|
||||
IF
|
||||
IMPORT
|
||||
INTERFACE
|
||||
IN
|
||||
INLINE
|
||||
LOCK
|
||||
METHODS
|
||||
MOD
|
||||
MODULE
|
||||
NOT
|
||||
OBJECT
|
||||
OF
|
||||
OR
|
||||
PROCEDURE
|
||||
RAISES
|
||||
READONLY
|
||||
RECORD
|
||||
REF
|
||||
REPEAT
|
||||
RETURN
|
||||
SET
|
||||
THEN
|
||||
TO
|
||||
TRY
|
||||
TYPE
|
||||
TYPECASE
|
||||
UNSAFE
|
||||
UNTIL
|
||||
UNTRACED
|
||||
VALUE
|
||||
VAR
|
||||
WHILE
|
||||
WITH
|
||||
and
|
||||
array
|
||||
begin
|
||||
bits
|
||||
by
|
||||
case
|
||||
const
|
||||
div
|
||||
do
|
||||
else
|
||||
elsif
|
||||
end
|
||||
eval
|
||||
except
|
||||
exception
|
||||
exit
|
||||
exports
|
||||
finally
|
||||
for
|
||||
from
|
||||
if
|
||||
import
|
||||
interface
|
||||
in
|
||||
inline
|
||||
lock
|
||||
methods
|
||||
mod
|
||||
module
|
||||
not
|
||||
object
|
||||
of
|
||||
or
|
||||
procedure
|
||||
raises
|
||||
readonly
|
||||
record
|
||||
ref
|
||||
repeat
|
||||
return
|
||||
set
|
||||
then
|
||||
to
|
||||
try
|
||||
type
|
||||
typecase
|
||||
unsafe
|
||||
until
|
||||
untraced
|
||||
value
|
||||
var
|
||||
while
|
||||
with
|
@ -1,36 +0,0 @@
|
||||
in word set with
|
||||
in word set array
|
||||
in word set and
|
||||
in word set function
|
||||
in word set case
|
||||
in word set var
|
||||
in word set const
|
||||
in word set until
|
||||
in word set then
|
||||
in word set set
|
||||
in word set record
|
||||
in word set program
|
||||
in word set procedure
|
||||
in word set or
|
||||
in word set packed
|
||||
in word set not
|
||||
in word set nil
|
||||
in word set label
|
||||
in word set in
|
||||
in word set repeat
|
||||
in word set of
|
||||
in word set goto
|
||||
in word set forward
|
||||
in word set for
|
||||
in word set while
|
||||
in word set file
|
||||
in word set else
|
||||
in word set downto
|
||||
in word set do
|
||||
in word set div
|
||||
in word set to
|
||||
in word set type
|
||||
in word set end
|
||||
in word set mod
|
||||
in word set begin
|
||||
in word set if
|
@ -1,36 +0,0 @@
|
||||
with
|
||||
array
|
||||
and
|
||||
function
|
||||
case
|
||||
var
|
||||
const
|
||||
until
|
||||
then
|
||||
set
|
||||
record
|
||||
program
|
||||
procedure
|
||||
or
|
||||
packed
|
||||
not
|
||||
nil
|
||||
label
|
||||
in
|
||||
repeat
|
||||
of
|
||||
goto
|
||||
forward
|
||||
for
|
||||
while
|
||||
file
|
||||
else
|
||||
downto
|
||||
do
|
||||
div
|
||||
to
|
||||
type
|
||||
end
|
||||
mod
|
||||
begin
|
||||
if
|
@ -1,153 +0,0 @@
|
||||
/* C code produced by gperf version 2.7 */
|
||||
/* Command-line: ../src/gperf -p -j1 -g -o -t -N is_reserved_word -k1,3,$ */
|
||||
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
|
||||
struct resword { char *name; short token; enum rid rid; };
|
||||
|
||||
#define TOTAL_KEYWORDS 51
|
||||
#define MIN_WORD_LENGTH 2
|
||||
#define MAX_WORD_LENGTH 13
|
||||
#define MIN_HASH_VALUE 8
|
||||
#define MAX_HASH_VALUE 82
|
||||
/* maximum key range = 75, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static unsigned int
|
||||
hash (str, len)
|
||||
register const char *str;
|
||||
register unsigned int len;
|
||||
{
|
||||
static unsigned char asso_values[] =
|
||||
{
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 0, 83, 1, 2, 34,
|
||||
19, 6, 11, 29, 0, 17, 83, 0, 23, 28,
|
||||
26, 30, 31, 83, 15, 1, 0, 28, 13, 4,
|
||||
83, 83, 5, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
|
||||
83, 83, 83, 83, 83, 83
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
case 3:
|
||||
hval += asso_values[(unsigned char)str[2]];
|
||||
case 2:
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval + asso_values[(unsigned char)str[len - 1]];
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
struct resword *
|
||||
is_reserved_word (str, len)
|
||||
register const char *str;
|
||||
register unsigned int len;
|
||||
{
|
||||
static struct resword wordlist[] =
|
||||
{
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{"__asm__", ASM, NORID},
|
||||
{""},
|
||||
{"__typeof__", TYPEOF, NORID},
|
||||
{"__signed__", TYPESPEC, RID_SIGNED},
|
||||
{"__alignof__", ALIGNOF, NORID},
|
||||
{"break", BREAK, NORID},
|
||||
{"__attribute__", ATTRIBUTE, NORID},
|
||||
{""}, {""},
|
||||
{"else", ELSE, NORID},
|
||||
{"__attribute", ATTRIBUTE, NORID},
|
||||
{"__typeof", TYPEOF, NORID},
|
||||
{"int", TYPESPEC, RID_INT},
|
||||
{"__alignof", ALIGNOF, NORID},
|
||||
{"struct", STRUCT, NORID},
|
||||
{"sizeof", SIZEOF, NORID},
|
||||
{"switch", SWITCH, NORID},
|
||||
{"__volatile__", TYPE_QUAL, RID_VOLATILE},
|
||||
{""},
|
||||
{"__inline__", SCSPEC, RID_INLINE},
|
||||
{"__signed", TYPESPEC, RID_SIGNED},
|
||||
{"__volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"if", IF, NORID},
|
||||
{"__inline", SCSPEC, RID_INLINE},
|
||||
{"while", WHILE, NORID},
|
||||
{""},
|
||||
{"__asm", ASM, NORID},
|
||||
{"auto", SCSPEC, RID_AUTO},
|
||||
{"short", TYPESPEC, RID_SHORT},
|
||||
{"default", DEFAULT, NORID},
|
||||
{"extern", SCSPEC, RID_EXTERN},
|
||||
{""}, {""},
|
||||
{"__const", TYPE_QUAL, RID_CONST},
|
||||
{"static", SCSPEC, RID_STATIC},
|
||||
{"__const__", TYPE_QUAL, RID_CONST},
|
||||
{"for", FOR, NORID},
|
||||
{"case", CASE, NORID},
|
||||
{"float", TYPESPEC, RID_FLOAT},
|
||||
{"return", RETURN, NORID},
|
||||
{"typeof", TYPEOF, NORID},
|
||||
{"typedef", SCSPEC, RID_TYPEDEF},
|
||||
{"volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"do", DO, NORID},
|
||||
{"inline", SCSPEC, RID_INLINE},
|
||||
{"void", TYPESPEC, RID_VOID},
|
||||
{"char", TYPESPEC, RID_CHAR},
|
||||
{"signed", TYPESPEC, RID_SIGNED},
|
||||
{"unsigned", TYPESPEC, RID_UNSIGNED},
|
||||
{""}, {""},
|
||||
{"double", TYPESPEC, RID_DOUBLE},
|
||||
{"asm", ASM, NORID},
|
||||
{""}, {""},
|
||||
{"goto", GOTO, NORID},
|
||||
{""},
|
||||
{"const", TYPE_QUAL, RID_CONST},
|
||||
{"enum", ENUM, NORID},
|
||||
{"register", SCSPEC, RID_REGISTER},
|
||||
{""}, {""}, {""}, {""}, {""}, {""},
|
||||
{"continue", CONTINUE, NORID},
|
||||
{""},
|
||||
{"union", UNION, NORID},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
{"long", TYPESPEC, RID_LONG}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (*str == *s && !strcmp (str + 1, s + 1))
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user