mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-09 18:55:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f6ddeafb | ||
|
|
a75649b395 | ||
|
|
c0cac722f7 | ||
|
|
9738f41e3f | ||
|
|
a5c75d7fc6 | ||
|
|
8280e1797d | ||
|
|
ae64af3556 | ||
|
|
d1a1114f7f | ||
|
|
b906441c95 | ||
|
|
bd7018115a | ||
|
|
e0a13e7b30 | ||
|
|
43674285cc | ||
|
|
c97011bfc1 | ||
|
|
d862b1be60 | ||
|
|
f414d77d38 | ||
|
|
f25e23a632 | ||
|
|
54d25cfb74 | ||
|
|
3d38c03a86 | ||
|
|
b63473552d | ||
|
|
1b17ce8ebc | ||
|
|
09ba4ab244 | ||
|
|
262aa8dd59 | ||
|
|
0252b55c07 | ||
|
|
ad66f664ef | ||
|
|
21846f695d | ||
|
|
c0ad8bf3c2 | ||
|
|
eb34f4177c | ||
|
|
3a93251e73 | ||
|
|
427c0dda0c | ||
|
|
3f8237696f | ||
|
|
9503bbd27d | ||
|
|
3c146b5e6f | ||
|
|
948be909e9 | ||
|
|
8442d6ba22 | ||
|
|
645e30d193 | ||
|
|
6a254321ad | ||
|
|
04b6e11ebb | ||
|
|
c0d9cc4211 | ||
|
|
accea6db68 | ||
|
|
93a1e33a1d | ||
|
|
49e794c553 | ||
|
|
88ba3d332f | ||
|
|
002b9b7d1f | ||
|
|
6563aa9221 | ||
|
|
48c4080d0d | ||
|
|
63400d5d02 | ||
|
|
04c5cba268 | ||
|
|
d7163c0a58 | ||
|
|
db2cc12fd0 | ||
|
|
7e78575709 | ||
|
|
f9a85a156a | ||
|
|
c81bad8950 | ||
|
|
158e69f984 | ||
|
|
211e7860a2 | ||
|
|
e3fbd37fc0 | ||
|
|
a11166dddc | ||
|
|
9ff012ca23 | ||
|
|
3d70dbe593 | ||
|
|
91e1aa523d | ||
|
|
00a6930855 | ||
|
|
6fc82eafd5 | ||
|
|
0755be2ff9 | ||
|
|
b4ebc2134b | ||
|
|
30ad432609 | ||
|
|
1a92955799 | ||
|
|
a319e6a7a3 | ||
|
|
eb9568566a | ||
|
|
d5629ce34a | ||
|
|
c2143a71d6 | ||
|
|
c340180d81 | ||
|
|
c837b82803 | ||
|
|
e601ff27f4 | ||
|
|
c131cbff03 | ||
|
|
50f095c92f | ||
|
|
16cb098b72 | ||
|
|
9742c552f2 | ||
|
|
8434f2222e | ||
|
|
d6eba4239f | ||
|
|
81fe8b23e9 | ||
|
|
02e090934a | ||
|
|
87b7d7bad5 | ||
|
|
cf126971ad | ||
|
|
c896cfc95e | ||
|
|
a447fcd20c | ||
|
|
a861a3390f | ||
|
|
2cf6e61086 | ||
|
|
c8f002c7d3 | ||
|
|
cd08e51eda | ||
|
|
bb0027a9ac | ||
|
|
3325ddc49c | ||
|
|
c6f1a33c06 | ||
|
|
1509d42fcb | ||
|
|
273a74fa89 | ||
|
|
2ed0e35f86 | ||
|
|
217598dadc | ||
|
|
52489d4445 | ||
|
|
e8832397ea | ||
|
|
caf23d249c | ||
|
|
640748eecf | ||
|
|
88bce5a2ef | ||
|
|
1bfb97dba5 | ||
|
|
fc5734fe23 | ||
|
|
3650b4b8dd | ||
|
|
4b3d3a8e46 | ||
|
|
4a2a22f4c0 | ||
|
|
b8df32232a | ||
|
|
a762e609e7 | ||
|
|
12b0043a6d | ||
|
|
5dde258a9e | ||
|
|
a945ec3929 | ||
|
|
7601152fab | ||
|
|
fae437e835 | ||
|
|
1a715ef2fc | ||
|
|
a5d5099417 | ||
|
|
b275314e2d | ||
|
|
c5f5043618 | ||
|
|
2ab9a04ffc | ||
|
|
865b9df14c | ||
|
|
c76e14da4b | ||
|
|
7db2ed2d82 | ||
|
|
3a9e26be57 | ||
|
|
e68e0410ab | ||
|
|
e1a4f3a428 | ||
|
|
536545f3a4 | ||
|
|
8b752b00fd | ||
|
|
613f5e1a89 | ||
|
|
524346a3a3 | ||
|
|
26e0cadc37 | ||
|
|
e68d4575b3 | ||
|
|
bb3f671805 | ||
|
|
88e7e94146 | ||
|
|
1154ccedaf | ||
|
|
97650f4efc | ||
|
|
d257636504 | ||
|
|
ccaf65bc63 | ||
|
|
87675353bf | ||
|
|
ce4ccb4b11 | ||
|
|
bc933ef16d | ||
|
|
53d4308dbb | ||
|
|
574fb2d568 | ||
|
|
05811fd755 | ||
|
|
0e4d575330 | ||
|
|
24c7d80020 | ||
|
|
9222837b27 | ||
|
|
260008e546 | ||
|
|
8a731ca829 | ||
|
|
32e1e0a486 | ||
|
|
e5fb671032 | ||
|
|
c7ca99d4b0 | ||
|
|
df0e7316a9 | ||
|
|
39f4191608 | ||
|
|
d57650a5ff | ||
|
|
5a08f1ce21 | ||
|
|
720623af84 | ||
|
|
fb8135fa99 | ||
|
|
4fa887b790 | ||
|
|
4144248075 | ||
|
|
e0e5bf84b0 | ||
|
|
b5480d74b8 | ||
|
|
676385e29c | ||
|
|
01241d47b4 | ||
|
|
ba29c4ec25 | ||
|
|
e2aaf4c4f9 | ||
|
|
7cca31a2f2 | ||
|
|
60491a948b | ||
|
|
2a10b47aaf | ||
|
|
12bebc0445 | ||
|
|
febef6caec | ||
|
|
9be0c25bf0 | ||
|
|
976e627098 | ||
|
|
3424c3868f | ||
|
|
1ae7286376 | ||
|
|
87542d29a5 | ||
|
|
1a31ed21b1 | ||
|
|
e776192e4f | ||
|
|
5c1180b3c4 | ||
|
|
e317006080 | ||
|
|
253862fd4c | ||
|
|
366eea36d3 | ||
|
|
1ce5149ac8 | ||
|
|
4f25ebb043 | ||
|
|
93b68a0e09 | ||
|
|
7431029172 | ||
|
|
58612f1de0 | ||
|
|
02097d3eab | ||
|
|
f25bfb75aa | ||
|
|
c732d2c6dc | ||
|
|
8c165d891d | ||
|
|
ca98bf5758 | ||
|
|
0bfb02fff7 | ||
|
|
24c0aad7e7 | ||
|
|
5719c1092f | ||
|
|
271efced67 | ||
|
|
abd741b1f6 | ||
|
|
9280d3ef89 | ||
|
|
dafdc66ff0 | ||
|
|
56c4720342 | ||
|
|
1e0bab9276 | ||
|
|
74886d31e7 | ||
|
|
04e6065479 | ||
|
|
10e5b8bd0a | ||
|
|
9801d40c50 | ||
|
|
c026349221 | ||
|
|
9757c359ef | ||
|
|
6b98e4b563 | ||
|
|
ee000ba4fc | ||
|
|
8efe435c05 | ||
|
|
4f6bb8b24b | ||
|
|
1921f1d7a4 | ||
|
|
4515534cd2 | ||
|
|
f958596b44 | ||
|
|
2c5690250c | ||
|
|
592e8d4d01 | ||
|
|
0c15323de7 | ||
|
|
e96c9728da | ||
|
|
75d1fe1611 | ||
|
|
6c35d22c39 | ||
|
|
3420246357 | ||
|
|
1d6412adeb | ||
|
|
4cdb01db9b | ||
|
|
44995b2e39 | ||
|
|
e9955c8373 | ||
|
|
39fd0b540d | ||
|
|
d7215705ee | ||
|
|
5346290247 | ||
|
|
2e04746125 | ||
|
|
9af3fbce7c | ||
|
|
1485e106a4 | ||
|
|
da4160c30a | ||
|
|
f6d0f937fd | ||
|
|
69078d4b3b | ||
|
|
0624954c7e | ||
|
|
5e424082ce | ||
|
|
44536b35c4 | ||
|
|
8b9f2372c7 | ||
|
|
3ae2b51f08 | ||
|
|
2f1afb737f | ||
|
|
e9bca3aded | ||
|
|
86eff18354 | ||
|
|
9411f454b0 | ||
|
|
717be1971f | ||
|
|
efea623135 | ||
|
|
670ddffd5b | ||
|
|
769b430fce | ||
|
|
7067cb3620 | ||
|
|
4a713ec2e3 | ||
|
|
b0e5f19eab | ||
|
|
54049e5db0 | ||
|
|
b408954b40 | ||
|
|
a49aecd528 | ||
|
|
5504898e82 | ||
|
|
4fd2214bc6 | ||
|
|
ec3bc3961d | ||
|
|
78df825093 | ||
|
|
68cd8af38b | ||
|
|
660bc8dd09 | ||
|
|
c0c9ea051b | ||
|
|
6390a83f8b | ||
|
|
db7c8e9a72 | ||
|
|
158c687b65 | ||
|
|
fcc618005a | ||
|
|
308a2f7637 | ||
|
|
a46c847244 | ||
|
|
5683e9b26a | ||
|
|
0c2d3f4cba | ||
|
|
e41fdc9310 | ||
|
|
1565b72064 | ||
|
|
5181e40827 | ||
|
|
cfaee611d8 | ||
|
|
458be8e0ed | ||
|
|
a900a6248c | ||
|
|
9bbd181ae0 | ||
|
|
d4e7d3a191 | ||
|
|
39ceb25bdb | ||
|
|
5372019fab | ||
|
|
5df5f6d538 | ||
|
|
77714df234 | ||
|
|
b87f8b2159 | ||
|
|
8bb936e4f7 | ||
|
|
fba798c78e | ||
|
|
9306c70c63 | ||
|
|
3c9160d912 | ||
|
|
53c71a12c8 | ||
|
|
2de3aceee7 | ||
|
|
289dd0cf98 | ||
|
|
db85e524b4 | ||
|
|
0164db681e | ||
|
|
83ccf991a6 | ||
|
|
1f41899519 | ||
|
|
77f6f42074 | ||
|
|
45119f0446 | ||
|
|
b2d52318fa | ||
|
|
3a8b410924 | ||
|
|
2243f537c6 | ||
|
|
84614e1373 | ||
|
|
fdbcd8e289 | ||
|
|
64bd62a1be | ||
|
|
900c877b41 | ||
|
|
82b6cb3fb2 | ||
|
|
6cbfbcc58c |
@@ -0,0 +1 @@
|
||||
patch_list='Bison Patches <[email protected]>'
|
||||
@@ -0,0 +1,136 @@
|
||||
-*- outline -*-
|
||||
|
||||
This file attempts to describe the rules to use when hacking Bison.
|
||||
Don't put this file into the distribution. Don't mention it in the
|
||||
ChangeLog.
|
||||
|
||||
Everything related to the development of Bison is on Savannah:
|
||||
|
||||
http://savannah.gnu.org/projects/bison/
|
||||
|
||||
|
||||
* Administrivia
|
||||
|
||||
** If you incorporate a change from somebody on the net:
|
||||
First, if it is a large change, you must make sure they have signed
|
||||
the appropriate paperwork. Second, be sure to add their name and
|
||||
email address to THANKS.
|
||||
|
||||
** If a change fixes a test, mention the test in the ChangeLog entry.
|
||||
|
||||
** Bug reports
|
||||
If somebody reports a new bug, mention his name in the ChangeLog entry
|
||||
and in the test case you write. Put him into THANKS.
|
||||
|
||||
The correct response to most actual bugs is to write a new test case
|
||||
which demonstrates the bug. Then fix the bug, re-run the test suite,
|
||||
and check everything in.
|
||||
|
||||
|
||||
* Hacking
|
||||
|
||||
** Visible changes
|
||||
Which include serious bug fixes, must be mentioned in NEWS.
|
||||
|
||||
** Translations
|
||||
Only user visible strings are to be translated: error messages, bits
|
||||
of the .output file etc. This excludes impossible error messages
|
||||
(comparable to assert/abort), and all the --trace output which is
|
||||
meant for the maintainers only.
|
||||
|
||||
|
||||
* Test suite
|
||||
|
||||
** make check
|
||||
Use liberally.
|
||||
|
||||
** Release checks
|
||||
Try to run the test suite with more severe conditions before a
|
||||
release:
|
||||
|
||||
- Configure the package with --enable-gcc-warnings, so that one checks
|
||||
that 1. Bison compiles cleanly, 2. the parsers it produces compile
|
||||
cleanly too.
|
||||
|
||||
- Change tests/bison to run `valgrind -q bison' to run Bison under
|
||||
Valgrind.
|
||||
|
||||
- Run the test suite with `./testsuite PREPARSER='valgrind -q' to make
|
||||
sure the parser behave properly.
|
||||
|
||||
- Change tests/atlocal/CFLAGS to add your preferred options. For
|
||||
instance, `-traditional' to check that the parsers are K&R. Note
|
||||
that it does not make sense for glr.c, which should be ANSI,
|
||||
but currently is actually GNU C, nor for lalr1.cc, which anyway is
|
||||
not exercised yet in the test suite.
|
||||
|
||||
- Change tests/atlocal/CC to use a C++ compiler.
|
||||
|
||||
|
||||
* Release Procedure
|
||||
|
||||
** Tests
|
||||
See above.
|
||||
|
||||
** Update the foreign files
|
||||
Running `make update' in the top level should make it all for you.
|
||||
This covers PO files too. Beware that it happens that some PO files
|
||||
contain serious problems and are rejected by recent Gettext releases:
|
||||
fix them all, and complain to the Translation Project!
|
||||
|
||||
Note that there might be *new* PO files. Don't forget to update the
|
||||
whole machinery, which not only includes LINGUAS, but `cvs add'ing the
|
||||
PO files too.
|
||||
|
||||
** Update NEWS
|
||||
The version number, *and* the date of the release (including for
|
||||
betas).
|
||||
|
||||
** Update ChangeLog
|
||||
Should have an entry similar to `Version 1.49b.'.
|
||||
Check all this in once `make distcheck' passes.
|
||||
|
||||
** make alpha
|
||||
Running `make alpha' is absolutely perfect for beta releases: it makes
|
||||
the tarballs, the xdeltas, and prepares (in /tmp/) a proto
|
||||
announcement. It is so neat, that that's what I use anyway for
|
||||
genuine releases, but adjusting things by hand (e.g., the urls in the
|
||||
announcement file, the ChangeLog which is not needed etc.).
|
||||
|
||||
If it fails, you're on your own...
|
||||
|
||||
It requires GNU Make.
|
||||
|
||||
** Upload
|
||||
Put the tarballs/xdeltas where they should be. Or put it somewhere,
|
||||
and send the URL to [email protected].
|
||||
|
||||
** Bump the version number
|
||||
In configure.ac. Run `make', check this in.
|
||||
|
||||
** Announce
|
||||
Complete/fix the announcement file, and send it at least to
|
||||
[email protected] (if a real release, or a ``serious beta''),
|
||||
[email protected], and [email protected].
|
||||
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Bison 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 Bison 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 Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
+4
-8
@@ -1,4 +1,5 @@
|
||||
## Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
## Copyright (C) 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
|
||||
@@ -15,16 +16,11 @@
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
## 02111-1307 USA
|
||||
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
AUTOMAKE_OPTIONS = 1.6 check-news readme-alpha dist-bzip2
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = config intl po lib data src doc m4 tests
|
||||
SUBDIRS = config po lib data src doc m4 tests
|
||||
|
||||
EXTRA_DIST = config/config.rpath REFERENCES configure.bat OChangeLog Makefile.maint GNUmakefile
|
||||
|
||||
DISTCLEANFILES = intl/libintl.h
|
||||
EXTRA_DIST = REFERENCES OChangeLog Makefile.maint GNUmakefile
|
||||
|
||||
|
||||
## ---------------------------- ##
|
||||
|
||||
@@ -1,13 +1,29 @@
|
||||
Bison News
|
||||
----------
|
||||
|
||||
Changes in version 1.49a:
|
||||
Changes in version 1.49c:
|
||||
|
||||
|
||||
Changes in version 1.49b, 2002-08-12:
|
||||
|
||||
* GLR parsing
|
||||
The declaration
|
||||
%glr-parser
|
||||
causes Bison to produce a Generalized LR (GLR) parser, capable of handling
|
||||
almost any context-free grammar, ambiguous or not. The new declarations
|
||||
%dprec and %merge on grammar rules allow parse-time resolution of
|
||||
ambiguities. Contributed by Paul Hilfinger.
|
||||
|
||||
* Output Directory
|
||||
When not in Yacc compatibility mode, when the output file was not
|
||||
specified, runnning `bison foo/bar.y' created `foo/bar.c'. It
|
||||
now creates `bar.c'.
|
||||
|
||||
* Undefined token
|
||||
The undefined token was systematically mapped to 2 which prevented
|
||||
the use of 2 from the user. This is no longer the case.
|
||||
|
||||
* Undefined token
|
||||
* Unknown token numbers
|
||||
If yylex returned a code out of range, yyparse could die. This is
|
||||
no longer the case.
|
||||
|
||||
@@ -17,20 +33,48 @@ Changes in version 1.49a:
|
||||
user specified that one of her tokens is numbered 256, then error
|
||||
will be mapped onto another number.
|
||||
|
||||
* Large grammars
|
||||
Are now supported (large token numbers, large grammar size (= sum of
|
||||
the LHS and RHS lengths), large LALR tables).
|
||||
* Verbose error messages
|
||||
They no longer report `..., expecting error or...' for state where
|
||||
error recovery is possible.
|
||||
|
||||
* The initial rule is explicit.
|
||||
* End token
|
||||
Defaults to `$end' instead of `$'.
|
||||
|
||||
* Error recovery now conforms to documentation and to POSIX
|
||||
When a Bison-generated parser encounters a syntax error, it now pops
|
||||
the stack until it finds a state that allows shifting the error
|
||||
token. Formerly, it popped the stack until it found a state that
|
||||
allowed some non-error action other than a default reduction on the
|
||||
error token. The new behavior has long been the documented behavior,
|
||||
and has long been required by POSIX. For more details, please see
|
||||
<http://mail.gnu.org/pipermail/bug-bison/2002-May/001452.html>.
|
||||
|
||||
* Traces
|
||||
Popped tokens and nonterminals are now reported.
|
||||
|
||||
* Larger grammars
|
||||
Larger grammars are now supported (larger token numbers, larger grammar
|
||||
size (= sum of the LHS and RHS lengths), larger LALR tables).
|
||||
Formerly, many of these numbers ran afoul of 16-bit limits;
|
||||
now these limits are 32 bits on most hosts.
|
||||
|
||||
* Explicit initial rule
|
||||
Bison used to play hacks with the initial rule, which the user does
|
||||
not write. It is now explicit, and visible in the reports and
|
||||
graphs as rule 0.
|
||||
|
||||
* Useless rules are actually removed.
|
||||
* Useless rules
|
||||
Before, Bison reported the useless rules, but, although not used,
|
||||
included them in the parsers.
|
||||
included them in the parsers. They are now actually removed.
|
||||
|
||||
* False `Token not used' report fixed.
|
||||
* Useless rules, useless nonterminals
|
||||
They are now reported, as a warning, with their locations.
|
||||
|
||||
* Rules never reduced
|
||||
Rules that can never be reduced because of conflicts are now
|
||||
reported.
|
||||
|
||||
* Incorrect `Token not used'
|
||||
On a grammar such as
|
||||
|
||||
%token useless useful
|
||||
@@ -40,21 +84,62 @@ Changes in version 1.49a:
|
||||
where a token was used to set the precedence of the last rule,
|
||||
bison reported both `useful' and `useless' as useless tokens.
|
||||
|
||||
* Revert the C++ namespace changes introduced in 1.31, as they caused too
|
||||
many portability hassles.
|
||||
* Revert the C++ namespace changes introduced in 1.31
|
||||
as they caused too many portability hassles.
|
||||
|
||||
* Items overflow
|
||||
Bison no longer dumps core when there are too many items, it just
|
||||
dies.
|
||||
* Default locations
|
||||
By an accident of design, the default computation of @$ was
|
||||
performed after another default computation was performed: @$ = @1.
|
||||
The latter is now removed: YYLLOC_DEFAULT is fully responsible of
|
||||
the computation of @$.
|
||||
|
||||
* Token end-of-file
|
||||
The token end of file may be specified by the user, in which case,
|
||||
the user symbol is used in the reports, the graphs, and the verbose
|
||||
error messages instead of `$', which remains being the defaults.
|
||||
error messages instead of `$end', which remains being the default.
|
||||
For instance
|
||||
%token YYEOF 0
|
||||
or
|
||||
%token YYEOF 0 "end of file"
|
||||
|
||||
* Semantic parser
|
||||
This old option, which has been broken for ages, is removed.
|
||||
|
||||
* New translations
|
||||
Brazilian Portuguese, thanks to Alexandre Folle de Menezes.
|
||||
Croatian, thanks to Denis Lackovic.
|
||||
|
||||
* Incorrect token definitions
|
||||
When fed with `%token 'a' "A"', Bison used to output `#define 'a' 65'.
|
||||
|
||||
* Token definitions as enums
|
||||
Tokens are output both as the traditional #define's, and, provided
|
||||
the compiler supports ANSI C or is a C++ compiler, as enums.
|
||||
This helps debuggers producing symbols instead of values.
|
||||
|
||||
* Reports
|
||||
In addition to --verbose, bison supports --report=THINGS, which
|
||||
produces additional information:
|
||||
- itemset
|
||||
complete the core item sets with their closure
|
||||
- lookahead
|
||||
explicitly associate lookaheads to items
|
||||
- solved
|
||||
describe shift/reduce conflicts solving.
|
||||
Bison used to systematically output this information on top of
|
||||
the report. Solved conflicts are now attached to their states.
|
||||
|
||||
* Type clashes
|
||||
Previous versions don't complain when there is a type clash on
|
||||
the default action if the rule has a mid-rule action, such as in:
|
||||
|
||||
%type <foo> bar
|
||||
%%
|
||||
bar: '0' {} '0';
|
||||
|
||||
This is fixed.
|
||||
|
||||
* GNU M4 is now required when using Bison.
|
||||
|
||||
Changes in version 1.35, 2002-03-25:
|
||||
|
||||
|
||||
+38
-13
@@ -1,13 +1,19 @@
|
||||
These notes intend to help people working on the CVS versions of
|
||||
Bison. Only the sources are installed in the CVS repository (to ease
|
||||
the maintenance, merges etc.), therefore you will have to the
|
||||
maintainer tools we depend upon:
|
||||
-*- outline -*-
|
||||
|
||||
- Automake 1.6 or 1.6.1
|
||||
- Autoconf 2.53a or better
|
||||
ftp://alpha.gnu.org/gnu/autoconf/autoconf-2.53a.tar.gz (992 kB)
|
||||
ftp://alpha.gnu.org/gnu/autoconf/autoconf-2.53a.tar.bz2 (756 kB)
|
||||
- Gettext 0.10.1
|
||||
These notes intend to help people working on the CVS versions of
|
||||
Bison.
|
||||
|
||||
* Requirements
|
||||
|
||||
Only the sources are installed in the CVS repository (to ease the
|
||||
maintenance, merges etc.), therefore you will have to the maintainer
|
||||
tools we depend upon:
|
||||
|
||||
- Automake 1.7
|
||||
|
||||
- Autoconf 2.54
|
||||
|
||||
- Gettext 0.11.5
|
||||
|
||||
Only building the initial full source tree will be a bit painful,
|
||||
later, a plain `cvs update -P & make' should be sufficient.
|
||||
@@ -37,24 +43,43 @@ should output no difference, except maybe the date in po/*.po files.
|
||||
|
||||
Enjoy!
|
||||
|
||||
* Troubleshooting
|
||||
|
||||
Unfortunately the current Gettext still does not include all the
|
||||
needed tools so that the bootstrapping always perform successfully.
|
||||
|
||||
If you experience problems, I suggest the following:
|
||||
|
||||
1. Do a regular CVS checkout
|
||||
|
||||
2. Fetch a recent tarball in:
|
||||
http://www.lrde.epita.fr/~akim/download/
|
||||
|
||||
3. Extract it
|
||||
|
||||
4. Override the content of your checkout with the content of this
|
||||
tarball, i.e.:
|
||||
cp -r bison-1.49b/* bison-cvs
|
||||
|
||||
5. Proceed on ./configure && make etc.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Autoconf.
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Autoconf is free software; you can redistribute it and/or modify
|
||||
GNU Bison 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 Autoconf is distributed in the hope that it will be useful,
|
||||
GNU Bison 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 autoconf; see the file COPYING. If not, write to
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
@@ -1,53 +1,60 @@
|
||||
Bison was originally written by Robert Corbett. It would not be what
|
||||
it is today without the invaluable help of these people:
|
||||
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille [email protected]
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Andreas Schwab [email protected]
|
||||
Airy Andre [email protected]
|
||||
Akim Demaille [email protected]
|
||||
Albert Chin-A-Young [email protected]
|
||||
Alexander Belopolsky [email protected]
|
||||
Andreas Schwab [email protected]
|
||||
Arnold Robbins [email protected]
|
||||
Benoit Perrot [email protected]
|
||||
Bruce Lilly [email protected]
|
||||
Cris van Pelt [email protected]
|
||||
Daniel Hagerty [email protected]
|
||||
David J. MacKenzie djm@gnu.org
|
||||
Benoit Perrot [email protected]
|
||||
Bruce Lilly [email protected]
|
||||
Cris Bailiff [email protected]
|
||||
Cris van Pelt [email protected]
|
||||
Daniel Hagerty hag@gnu.org
|
||||
David J. MacKenzie [email protected]
|
||||
Dick Streefland [email protected]
|
||||
Enrico Scholz [email protected]
|
||||
Enrico Scholz [email protected]
|
||||
Evgeny Stambulchik [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
Florian Krohm [email protected]
|
||||
H. Merijn Brand [email protected]
|
||||
Hans Aberg [email protected]
|
||||
Jesse Thilo [email protected]
|
||||
Jim Meyering [email protected]
|
||||
Juan Manuel Guerrero [email protected]
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne [email protected]
|
||||
Laurent Mascherpa [email protected]
|
||||
Magnus Fromreide [email protected]
|
||||
Marc Autret [email protected]
|
||||
Michael Hayes [email protected]z
|
||||
Mike Castle [email protected]
|
||||
Neil Booth [email protected]
|
||||
Nelson H. F. Beebe [email protected]
|
||||
Nicolas Burrus [email protected]
|
||||
Nicolas Tisserand [email protected]
|
||||
Noah Friedman [email protected]
|
||||
Pascal Bart pascal.bart@epita.fr
|
||||
Paul Eggert [email protected]
|
||||
Per Allansson [email protected]
|
||||
Peter Hámorský [email protected]
|
||||
Piotr Gackiewicz gacek@intertel.com.pl
|
||||
Richard Stallman [email protected]
|
||||
Robert Anisko [email protected]
|
||||
Shura [email protected]
|
||||
Tim Josling [email protected]
|
||||
Tom Lane [email protected]
|
||||
Tom Tromey [email protected]
|
||||
Wayne Green [email protected]
|
||||
Wolfram Wagner [email protected]
|
||||
Wwp [email protected]
|
||||
Fabrice Bauzac [email protected]
|
||||
Florian Krohm [email protected]
|
||||
H. Merijn Brand [email protected]
|
||||
Hans Aberg [email protected]
|
||||
Jesse Thilo [email protected]
|
||||
Jim Meyering [email protected]
|
||||
Juan Manuel Guerrero [email protected]
|
||||
Kees Zeelenberg [email protected]
|
||||
Keith Browne [email protected]
|
||||
Laurent Mascherpa [email protected]
|
||||
Magnus Fromreide [email protected]
|
||||
Marc Autret [email protected]
|
||||
Martin Mokrejs [email protected]z
|
||||
Matt Kraai [email protected]
|
||||
Michael Hayes [email protected]
|
||||
Mike Castle [email protected]
|
||||
Neil Booth [email protected]
|
||||
Nelson H. F. Beebe [email protected]
|
||||
Nicolas Burrus [email protected]
|
||||
Nicolas Tisserand nicolas.tisserand@epita.fr
|
||||
Noah Friedman [email protected]
|
||||
Pascal Bart [email protected]
|
||||
Paul Eggert [email protected]
|
||||
Paul Hilfinger Hilfinger@CS.Berkeley.EDU
|
||||
Per Allansson [email protected]
|
||||
Peter Hámorský [email protected]
|
||||
Piotr Gackiewicz [email protected]
|
||||
R Blake [email protected]
|
||||
Raja R Harinath [email protected]
|
||||
Richard Stallman [email protected]
|
||||
Robert Anisko [email protected]
|
||||
Shura [email protected]
|
||||
Tim Josling [email protected]
|
||||
Tom Lane [email protected]
|
||||
Tom Tromey [email protected]
|
||||
Wayne Green [email protected]
|
||||
Wolfram Wagner [email protected]
|
||||
Wwp [email protected]
|
||||
Zack Weinberg [email protected]
|
||||
|
||||
Many people are not named here because we lost track of them. We
|
||||
thank them! Please, help us keeping this list up to date.
|
||||
|
||||
@@ -1,49 +1,130 @@
|
||||
-*- outline -*-
|
||||
|
||||
* Header guards
|
||||
|
||||
* URGENT: Prologue
|
||||
The %union is declared after the user C declarations. It can be
|
||||
a problem if YYSTYPE is declared after the user part.
|
||||
En rentrant chez moi, je relance un `make' sur un projet que j'ai avancé
|
||||
ailleurs durant la semaine. Le système que j'utilise ici est un peu plus
|
||||
à jour que l'autre, et le Bison est probablement plus récent itou. Ici,
|
||||
c'est la version 1.33. J'obtiens, en montrant un peu plus que nécessaire:
|
||||
|
||||
Actually, the real problem seems that the %union ought to be output
|
||||
where it was defined. For instance, in gettext/intl/plural.y, we
|
||||
have:
|
||||
---------------------------------------------------------------------->
|
||||
cd ~/fpub/pyrexpp/Pyrexpp/
|
||||
LANGUAGE= /usr/bin/make MAKEFLAGS='-k -j2'
|
||||
/usr/bin/make -C .. install
|
||||
make[1]: Entre dans le répertoire `/bpi/titan/home/pinard/fpub/pyrexpp'
|
||||
install -g bpi -m 2775 -d Prépare-titan
|
||||
chmod g+sw Prépare-titan
|
||||
touch Prépare-titan/.estampille
|
||||
/usr/bin/gcc -fPIC -I/usr/include/python2.2 -IPrépare-titan -g -c -o Prépare-titan/ctools.o ctools.c
|
||||
bison -d -o Prépare-titan/c-parser.c c-parser.y
|
||||
/usr/bin/gcc -fPIC -I/usr/include/python2.2 -IPrépare-titan -g -c -o Prépare-titan/c-parser.o Prépare-titan/c-parser.c
|
||||
flex -t c-scanner.l | grep -v '^#line' > Prépare-titan/c-scanner.c
|
||||
/usr/bin/gcc -fPIC -I/usr/include/python2.2 -IPrépare-titan -g -c -o Prépare-titan/c-scanner.o Prépare-titan/c-scanner.c
|
||||
In file included from Prépare-titan/c-scanner.c:547:
|
||||
Prépare-titan/c-parser.h:1: warning: garbage at end of `#ifndef' argument
|
||||
Prépare-titan/c-parser.h:2: warning: missing white space after `#define BISON_PR'
|
||||
/usr/bin/gcc -o Prépare-titan/ctools.so Prépare-titan/ctools.o Prépare-titan/c-scanner.o -shared -lm
|
||||
python setup.py --quiet build
|
||||
install -g bpi -m 664 Prépare-titan/ctools.so /bpi/titan/local/lib/python2.2/site-packages/Pyrexpp
|
||||
python setup.py --quiet install
|
||||
make[1]: Quitte le répertoire `/bpi/titan/home/pinard/fpub/pyrexpp'
|
||||
[...]
|
||||
----------------------------------------------------------------------<
|
||||
|
||||
%{
|
||||
...
|
||||
#include "gettextP.h"
|
||||
...
|
||||
%}
|
||||
Diagnostics que je n'avais sûrement pas, plus tôt en journée, sur l'autre
|
||||
système. En allant voir, je trouve:
|
||||
|
||||
%union {
|
||||
unsigned long int num;
|
||||
enum operator op;
|
||||
struct expression *exp;
|
||||
}
|
||||
---------------------------------------------------------------------->
|
||||
#ifndef BISON_PRÉPARE_TITAN_C_PARSER_H
|
||||
# define BISON_PRÉPARE_TITAN_C_PARSER_H
|
||||
|
||||
%{
|
||||
...
|
||||
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
|
||||
...
|
||||
%}
|
||||
# ifndef YYSTYPE
|
||||
# define YYSTYPE int
|
||||
# endif
|
||||
# define IDENTIFIER 257
|
||||
[...]
|
||||
|
||||
Where the first part defines struct expression, the second uses it to
|
||||
define YYSTYPE, and the last uses YYSTYPE. Only this order is valid.
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
Note that we have the same problem with GCC.
|
||||
#endif /* not BISON_PRÉPARE_TITAN_C_PARSER_H */
|
||||
----------------------------------------------------------------------<
|
||||
|
||||
I suggest splitting the prologue into pre-prologue and post-prologue.
|
||||
The reason is that:
|
||||
Le pré-processeur de C n'est pas à l'aise avec les caractères accentués
|
||||
dans les identificateurs.
|
||||
|
||||
1. we keep language independance as it is the skeleton that joins the
|
||||
two prologues (there is no need for the engine to encode union yystype
|
||||
and to output it inside the prologue, which breaks the language
|
||||
independance of the generator)
|
||||
Bon, de mon expérience, il n'a jamais été nécessaire de protéger un fichier
|
||||
`.h' de Bison ou Yacc contre de multiples inclusions, mais si ça été
|
||||
fait, je présume qu'il y avait un problème réel et convaincant à régler,
|
||||
et qu'il ne s'agit pas d'une simple fantaisie: je ne mettrai donc pas
|
||||
ça en doute. Mais le choix du nom de l'identificateur laisse à désirer,
|
||||
tu en conviendras :-). Et faut-il vraiment y inclure le répertoire?
|
||||
|
||||
2. that makes it possible to have several %union in input. I think
|
||||
this is a pleasant (but useless currently) feature, but in the future,
|
||||
I want a means to %include other bits of grammars, and _then_ it will
|
||||
be important for the various bits to define their needs in %union.
|
||||
|
||||
* URGENT: Documenting C++ output
|
||||
Write a first documentation for C++ output.
|
||||
|
||||
|
||||
* Documentation
|
||||
Before releasing, make sure the documentation refers to the current
|
||||
`output' format.
|
||||
|
||||
|
||||
* Error messages
|
||||
Some are really funky. For instance
|
||||
|
||||
type clash (`%s' `%s') on default action
|
||||
|
||||
is really weird. Revisit them all.
|
||||
|
||||
|
||||
* read_pipe.c
|
||||
This is not portable to DOS for instance. Implement a more portable
|
||||
scheme. Sources of inspiration include GNU diff, and Free Recode.
|
||||
|
||||
|
||||
* value_components_used
|
||||
Was defined but not used: where was it coming from? It can't be to
|
||||
check if %union is used, since the user is free to $<foo>n on her
|
||||
union, doesn't she?
|
||||
|
||||
|
||||
* Report
|
||||
|
||||
** GLR
|
||||
How would Paul like to display the conflicted actions? In particular,
|
||||
what when two reductions are possible on a given lookahead, but one is
|
||||
part of $default. Should we make the two reductions explicit, or just
|
||||
keep $default? See the following point.
|
||||
|
||||
** Disabled Reductions
|
||||
See `tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
|
||||
what we want to do.
|
||||
|
||||
** Documentation
|
||||
Extend with error productions. The hard part will probably be finding
|
||||
the right rule so that a single state does not exhibit too many yet
|
||||
undocumented ``features''. Maybe an empty action ought to be
|
||||
presented too. Shall we try to make a single grammar with all these
|
||||
features, or should we have several very small grammars?
|
||||
|
||||
** --report=conflict-path
|
||||
Provide better assistance for understanding the conflicts by providing
|
||||
a sample text exhibiting the (LALR) ambiguity. See the paper from
|
||||
DeRemer and Penello: they already provide the algorithm.
|
||||
|
||||
|
||||
* Extensions
|
||||
|
||||
** yyerror, yysymprint interface
|
||||
It should be improved, in particular when using Bison features such as
|
||||
locations, and YYPARSE_PARAMS. For the time being, it is recommended
|
||||
to #define yyerror and yyprint to steal internal variables...
|
||||
|
||||
** Several %unions
|
||||
I think this is a pleasant (but useless currently) feature, but in the
|
||||
future, I want a means to %include other bits of grammars, and _then_
|
||||
it will be important for the various bits to define their needs in
|
||||
%union.
|
||||
|
||||
When implementing multiple-%union support, bare the following in mind:
|
||||
|
||||
@@ -60,30 +141,52 @@ When implementing multiple-%union support, bare the following in mind:
|
||||
char *sval;
|
||||
}
|
||||
|
||||
* Language independent actions
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules, i.e., transform
|
||||
|
||||
Currently bison, the generator, transforms $1, $$ and so forth into
|
||||
direct C code, manipulating the stacks. This is problematic, because
|
||||
(i) it means that if we want more languages, we need to update the
|
||||
generator, and (ii), it forces names everywhere (e.g., the C++
|
||||
skeleton would be happy to use other naming schemes, and actually,
|
||||
even other accessing schemes).
|
||||
exp: arith | bool;
|
||||
arith: exp '+' exp;
|
||||
bool: exp '&' exp;
|
||||
|
||||
Therefore we want
|
||||
into
|
||||
|
||||
1. the generator to replace $1, etc. by M4 macro invocations
|
||||
(b4_dollar(1), b4_at(3), b4_dollar_dollar) etc.
|
||||
exp: exp '+' exp | exp '&' exp;
|
||||
|
||||
2. the skeletons to define these macros.
|
||||
when there are no actions. This can significantly speed up some
|
||||
grammars. I can't find the papers. In particular the book `LR
|
||||
parsing: Theory and Practice' is impossible to find, but according to
|
||||
`Parsing Techniques: a Practical Guide', it includes information about
|
||||
this issue. Does anybody have it?
|
||||
|
||||
But currently the actions are double-quoted, to protect them from M4
|
||||
evaluation. So we need to:
|
||||
|
||||
3. stop quoting them
|
||||
|
||||
4. change the [ and ] in the actions into @<:@ and @:>@
|
||||
* Documentation
|
||||
|
||||
** History/Bibliography
|
||||
Some history of Bison and some bibliography would be most welcome.
|
||||
Are there any Texinfo standards for bibliography?
|
||||
|
||||
|
||||
|
||||
* Java, Fortran, etc.
|
||||
|
||||
|
||||
** Java
|
||||
|
||||
There are a couple of proposed outputs:
|
||||
|
||||
- BYACC/J
|
||||
which is based on Byacc.
|
||||
<http://troi.lincom-asg.com/~rjamison/byacc/>
|
||||
|
||||
- Bison Java
|
||||
which is based on Bison.
|
||||
<http://www.goice.co.jp/member/mo/hack-progs/bison-java.html>
|
||||
|
||||
Sébastien Serrurier ([email protected]) is working on this: he is
|
||||
expected to contact the authors, design the output, and implement it
|
||||
into Bison.
|
||||
|
||||
5. extend the postprocessor to maps these back onto [ and ].
|
||||
|
||||
* Coding system independence
|
||||
Paul notes:
|
||||
@@ -98,153 +201,7 @@ Paul notes:
|
||||
PDP-10 ports :-) but they should probably be documented
|
||||
somewhere.
|
||||
|
||||
* Using enums instead of int for tokens.
|
||||
Paul suggests:
|
||||
|
||||
#ifndef YYTOKENTYPE
|
||||
# if defined (__STDC__) || defined (__cplusplus)
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
FOO = 256,
|
||||
BAR,
|
||||
...
|
||||
};
|
||||
/* POSIX requires `int' for tokens in interfaces. */
|
||||
# define YYTOKENTYPE int
|
||||
# endif
|
||||
#endif
|
||||
#define FOO 256
|
||||
#define BAR 257
|
||||
...
|
||||
|
||||
* Output directory
|
||||
Akim:
|
||||
|
||||
| I consider this to be a bug in bison:
|
||||
|
|
||||
| /tmp % mkdir src
|
||||
| /tmp % cp ~/src/bison/tests/calc.y src
|
||||
| /tmp % mkdir build && cd build
|
||||
| /tmp/build % bison ../src/calc.y
|
||||
| /tmp/build % cd ..
|
||||
| /tmp % ls -l build src
|
||||
| build:
|
||||
| total 0
|
||||
|
|
||||
| src:
|
||||
| total 32
|
||||
| -rw-r--r-- 1 akim lrde 27553 oct 2 16:31 calc.tab.c
|
||||
| -rw-r--r-- 1 akim lrde 3335 oct 2 16:31 calc.y
|
||||
|
|
||||
|
|
||||
| Would it be safe to change this behavior to something more reasonable?
|
||||
| Do you think some people depend upon this?
|
||||
|
||||
Jim:
|
||||
|
||||
Is it that behavior documented?
|
||||
If so, then it's probably not reasonable to change it.
|
||||
I've Cc'd the automake list, because some of automake's
|
||||
rules use bison through $(YACC) -- though I'll bet they
|
||||
all use it in yacc-compatible mode.
|
||||
|
||||
Pavel:
|
||||
|
||||
Hello, Jim and others!
|
||||
|
||||
> Is it that behavior documented?
|
||||
> If so, then it's probably not reasonable to change it.
|
||||
> I've Cc'd the automake list, because some of automake's
|
||||
> rules use bison through $(YACC) -- though I'll bet they
|
||||
> all use it in yacc-compatible mode.
|
||||
|
||||
Yes, Automake currently used bison in Automake-compatible mode, but it
|
||||
would be fair for Automake to switch to the native mode as long as the
|
||||
processed files are distributed and "missing" emulates bison.
|
||||
|
||||
In any case, the makefiles should specify the output file explicitly
|
||||
instead of relying on weird defaults.
|
||||
|
||||
> | src:
|
||||
> | total 32
|
||||
> | -rw-r--r-- 1 akim lrde 27553 oct 2 16:31 calc.tab.c
|
||||
> | -rw-r--r-- 1 akim lrde 3335 oct 2 16:31 calc.y
|
||||
|
||||
This is not _that_ ugly as it seems - with Automake you want to put
|
||||
sources where they belong - to the source directory.
|
||||
|
||||
> | This is not _that_ ugly as it seems - with Automake you want to put
|
||||
> | sources where they belong - to the source directory.
|
||||
>
|
||||
> The difference source/build you are referring to is based on Automake
|
||||
> concepts. They have no sense at all for tools such as bison or gcc
|
||||
> etc. They have input and output. I do not want them to try to grasp
|
||||
> source/build. I want them to behave uniformly: output *here*.
|
||||
|
||||
I realize that.
|
||||
|
||||
It's unfortunate that the native mode of Bison behaves in a less uniform
|
||||
way than the yacc mode. I agree with your point. Bison maintainters may
|
||||
want to fix it along with the documentation.
|
||||
|
||||
|
||||
* Unit rules
|
||||
Maybe we could expand unit rules, i.e., transform
|
||||
|
||||
exp: arith | bool;
|
||||
arith: exp '+' exp;
|
||||
bool: exp '&' exp;
|
||||
|
||||
into
|
||||
|
||||
exp: exp '+' exp | exp '&' exp;
|
||||
|
||||
when there are no actions. This can significantly speed up some
|
||||
grammars.
|
||||
|
||||
* Stupid error messages
|
||||
An example shows it easily:
|
||||
|
||||
src/bison/tests % ./testsuite -k calc,location,error-verbose -l
|
||||
GNU Bison 1.49a test suite test groups:
|
||||
|
||||
NUM: FILENAME:LINE TEST-GROUP-NAME
|
||||
KEYWORDS
|
||||
|
||||
51: calc.at:440 Calculator --locations --yyerror-verbose
|
||||
52: calc.at:442 Calculator --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
|
||||
54: calc.at:445 Calculator --debug --defines --locations --name-prefix=calc --verbose --yacc --yyerror-verbose
|
||||
src/bison/tests % ./testsuite 51 -d
|
||||
## --------------------------- ##
|
||||
## GNU Bison 1.49a test suite. ##
|
||||
## --------------------------- ##
|
||||
51: calc.at:440 ok
|
||||
## ---------------------------- ##
|
||||
## All 1 tests were successful. ##
|
||||
## ---------------------------- ##
|
||||
src/bison/tests % cd ./testsuite.dir/51
|
||||
tests/testsuite.dir/51 % echo "()" | ./calc
|
||||
1.2-1.3: parse error, unexpected ')', expecting error or "number" or '-' or '('
|
||||
|
||||
* yyerror, yyprint interface
|
||||
It should be improved, in particular when using Bison features such as
|
||||
locations, and YYPARSE_PARAMS. For the time being, it is recommended
|
||||
to #define yyerror and yyprint to steal internal variables...
|
||||
|
||||
* read_pipe.c
|
||||
This is not portable to DOS for instance. Implement a more portable
|
||||
scheme. Sources of inspiration include GNU diff, and Free Recode.
|
||||
|
||||
* Memory leaks in the generator
|
||||
A round of memory leak clean ups would be most welcome. Dmalloc,
|
||||
Checker GCC, Electric Fence, or Valgrind: you chose your tool.
|
||||
|
||||
* Memory leaks in the parser
|
||||
The same applies to the generated parsers. In particular, this is
|
||||
critical for user data: when aborting a parsing, when handling the
|
||||
error token etc., we often throw away yylval without giving a chance
|
||||
of cleaning it up to the user.
|
||||
|
||||
* --graph
|
||||
Show reductions. []
|
||||
@@ -253,10 +210,9 @@ Show reductions. []
|
||||
** %no-lines [ok]
|
||||
** %no-parser []
|
||||
** %pure-parser []
|
||||
** %semantic-parser []
|
||||
** %token-table []
|
||||
** Options which could use parse_dquoted_param ().
|
||||
Maybe transfered in lex.c.
|
||||
Maybe transferred in lex.c.
|
||||
*** %skeleton [ok]
|
||||
*** %output []
|
||||
*** %file-prefix []
|
||||
@@ -273,7 +229,7 @@ Find the best graph parameters. []
|
||||
* doc/bison.texinfo
|
||||
** Update
|
||||
informations about ERROR_VERBOSE. []
|
||||
** Add explainations about
|
||||
** Add explanations about
|
||||
skeleton muscles. []
|
||||
%skeleton. []
|
||||
|
||||
@@ -281,59 +237,6 @@ skeleton muscles. []
|
||||
** tests/pure-parser.at []
|
||||
New tests.
|
||||
|
||||
* Debugging parsers
|
||||
|
||||
From Greg McGary:
|
||||
|
||||
akim demaille <[email protected]> writes:
|
||||
|
||||
> With great pleasure! Nonetheless, things which are debatable
|
||||
> (or not, but just `big') should be discuss in `public': something
|
||||
> like help- or [email protected] is just fine. Jesse and I are there,
|
||||
> but there is also Jim and some other people.
|
||||
|
||||
I have no idea whether it qualifies as big or controversial, so I'll
|
||||
just summarize for you. I proposed this change years ago and was
|
||||
surprised that it was met with utter indifference!
|
||||
|
||||
This debug feature is for the programs/grammars one develops with
|
||||
bison, not for debugging bison itself. I find that the YYDEBUG
|
||||
output comes in a very inconvenient format for my purposes.
|
||||
When debugging gcc, for instance, what I want is to see a trace of
|
||||
the sequence of reductions and the line#s for the semantic actions
|
||||
so I can follow what's happening. Single-step in gdb doesn't cut it
|
||||
because to move from one semantic action to the next takes you through
|
||||
lots of internal machinery of the parser, which is uninteresting.
|
||||
|
||||
The change I made was to the format of the debug output, so that it
|
||||
comes out in the format of C error messages, digestible by emacs
|
||||
compile mode, like so:
|
||||
|
||||
grammar.y:1234: foo: bar(0x123456) baz(0x345678)
|
||||
|
||||
where "foo: bar baz" is the reduction rule, whose semantic action
|
||||
appears on line 1234 of the bison grammar file grammar.y. The hex
|
||||
numbers on the rhs tokens are the parse-stack values associated with
|
||||
those tokens. Of course, yytype might be something totally
|
||||
incompatible with that representation, but for the most part, yytype
|
||||
values are single words (scalars or pointers). In the case of gcc,
|
||||
they're most often pointers to tree nodes. Come to think of it, the
|
||||
right thing to do is to make the printing of stack values be
|
||||
user-definable. It would also be useful to include the filename &
|
||||
line# of the file being parsed, but the main filename & line# should
|
||||
continue to be that of grammar.y
|
||||
|
||||
Anyway, this feature has saved my life on numerous occasions. The way
|
||||
I customarily use it is to first run bison with the traces on, isolate
|
||||
the sequence of reductions that interests me, put those traces in a
|
||||
buffer and force it into compile-mode, then visit each of those lines
|
||||
in the grammar and set breakpoints with C-x SPACE. Then, I can run
|
||||
again under the control of gdb and stop at each semantic action.
|
||||
With the hex addresses of tree nodes, I can inspect the values
|
||||
associated with any rhs token.
|
||||
|
||||
You like?
|
||||
|
||||
* input synclines
|
||||
Some users create their foo.y files, and equip them with #line. Bison
|
||||
should recognize these, and preserve them.
|
||||
@@ -342,66 +245,45 @@ should recognize these, and preserve them.
|
||||
See if we can integrate backtracking in Bison. Contact the BTYacc
|
||||
maintainers.
|
||||
|
||||
* Automaton report
|
||||
Display more clearly the lookaheads for each item.
|
||||
** Keeping the conflicted actions
|
||||
First, analyze the differences between byacc and btyacc (I'm referring
|
||||
to the executables). Find where the conflicts are preserved.
|
||||
|
||||
** Compare with the GLR tables
|
||||
See how isomorphic the way BTYacc and the way the GLR adjustments in
|
||||
Bison are compatible. *As much as possible* one should try to use the
|
||||
same implementation in the Bison executables. I insist: it should be
|
||||
very feasible to use the very same conflict tables.
|
||||
|
||||
** Adjust the skeletons
|
||||
Import the skeletons for C and C++.
|
||||
|
||||
** Improve the skeletons
|
||||
Have them support yysymprint, yydestruct and so forth.
|
||||
|
||||
* RR conflicts
|
||||
See if we can use precedence between rules to solve RR conflicts. See
|
||||
what POSIX says.
|
||||
|
||||
* Precedence
|
||||
|
||||
** Partial order
|
||||
It is unfortunate that there is a total order for precedence. It
|
||||
makes it impossible to have modular precedence information. We should
|
||||
move to partial orders.
|
||||
move to partial orders (sounds like series/parallel orders to me).
|
||||
|
||||
* Parsing grammars
|
||||
Rewrite the reader in Bison.
|
||||
This will be possible with a Bison parser for the grammar, as it will
|
||||
make it much easier to extend the grammar.
|
||||
|
||||
* Problems with aliases
|
||||
From: "Baum, Nathan I" <[email protected]>
|
||||
Subject: Token Alias Bug
|
||||
To: "'[email protected]'" <[email protected]>
|
||||
** Correlation b/w precedence and associativity
|
||||
Also, I fail to understand why we have to assign the same
|
||||
associativity to operators with the same precedence. For instance,
|
||||
why can't I decide that the precedence of * and / is the same, but the
|
||||
latter is nonassoc?
|
||||
|
||||
I've noticed a bug in bison. Sadly, our eternally wise sysadmins won't let
|
||||
us use CVS, so I can't find out if it's been fixed already...
|
||||
If there is really no profound motivation, we should find a new syntax
|
||||
to allow specifying this.
|
||||
|
||||
Basically, I made a program (in flex) that went through a .y file looking
|
||||
for "..."-tokens, and then outputed a %token
|
||||
line for it. For single-character ""-tokens, I reasoned, I could just use
|
||||
[%token 'A' "A"]. However, this causes Bison to output a [#define 'A' 65],
|
||||
which cppp chokes on, not unreasonably. (And even if cppp didn't choke, I
|
||||
obviously wouldn't want (char)'A' to be replaced with (int)65 throughout my
|
||||
code.
|
||||
|
||||
Bison normally forgoes outputing a #define for a character token. However,
|
||||
it always outputs an aliased token -- even if the token is an alias for a
|
||||
character token. We don't want that. The problem is in /output.c/, as I
|
||||
recall. When it outputs the token definitions, it checks for a character
|
||||
token, and then checks for an alias token. If the character token check is
|
||||
placed after the alias check, then it works correctly.
|
||||
|
||||
Alias tokens seem to be something of a kludge. What about an [%alias "..."]
|
||||
command...
|
||||
|
||||
%alias T_IF "IF"
|
||||
|
||||
Hmm. I can't help thinking... What about a --generate-lex option that
|
||||
creates an .l file for the alias tokens used... (Or an option to make a
|
||||
gperf file, etc...)
|
||||
|
||||
* Presentation of the report file
|
||||
From: "Baum, Nathan I" <[email protected]>
|
||||
Subject: Token Alias Bug
|
||||
To: "'[email protected]'" <[email protected]>
|
||||
|
||||
I've also noticed something, that whilst not *wrong*, is inconvienient: I
|
||||
use the verbose mode to help find the causes of unresolved shift/reduce
|
||||
conflicts. However, this mode insists on starting the .output file with a
|
||||
list of *resolved* conflicts, something I find quite useless. Might it be
|
||||
possible to define a -v mode, and a -vv mode -- Where the -vv mode shows
|
||||
everything, but the -v mode only tells you what you need for examining
|
||||
conflicts? (Or, perhaps, a "*** This state has N conflicts ***" marker above
|
||||
each state with conflicts.)
|
||||
** RR conflicts
|
||||
See if we can use precedence between rules to solve RR conflicts. See
|
||||
what POSIX says.
|
||||
|
||||
|
||||
* $undefined
|
||||
@@ -412,6 +294,7 @@ addition to the $undefined value.
|
||||
|
||||
Suggest: Change the name $undefined to undefined; looks better in outputs.
|
||||
|
||||
|
||||
* Default Action
|
||||
From Hans:
|
||||
- For use with my C++ parser, I transported the "switch (yyn)" statement
|
||||
@@ -426,6 +309,20 @@ $<type_name>$ = $<type_name>1. I therefore think that one should implement
|
||||
a Bison option where every typed default rule is explicitly written out
|
||||
(same typed ruled can of course be grouped together).
|
||||
|
||||
Note: Robert Anisko handles this. He knows how to do it.
|
||||
|
||||
|
||||
* Warnings
|
||||
It would be nice to have warning support. See how Autoconf handles
|
||||
them, it is fairly well described there. It would be very nice to
|
||||
implement this in such a way that other programs could use
|
||||
lib/warnings.[ch].
|
||||
|
||||
Don't work on this without first announcing you do, as I already have
|
||||
thought about it, and know many of the components that can be used to
|
||||
implement it.
|
||||
|
||||
|
||||
* Pre and post actions.
|
||||
From: Florian Krohm <[email protected]>
|
||||
Subject: YYACT_EPILOGUE
|
||||
@@ -454,23 +351,27 @@ at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
|
||||
I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
|
||||
to bison. If you're interested, I'll work on a patch.
|
||||
|
||||
* Move to Graphviz
|
||||
Well, VCG seems really dead. Move to Graphviz instead. Also, equip
|
||||
the parser with a means to create the (visual) parse tree.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Autoconf.
|
||||
This file is part of GNU Bison.
|
||||
|
||||
GNU Autoconf is free software; you can redistribute it and/or modify
|
||||
GNU Bison 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 Autoconf is distributed in the hope that it will be useful,
|
||||
GNU Bison 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 autoconf; see the file COPYING. If not, write to
|
||||
along with Bison; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
@@ -2,21 +2,5 @@
|
||||
|
||||
echo "Bootstrapping CVS Bison..."
|
||||
|
||||
# This will run gettextize which will patch some files, and cause
|
||||
# autoconf to choke (because for instance intl/Makefile is registered
|
||||
# several times).
|
||||
echo "running: autoreconf --verbose --install --force"
|
||||
autoreconf --verbose --install --force
|
||||
|
||||
# gettextize modified these files: restore them.
|
||||
for f in m4/Makefile.am Makefile.am configure.in
|
||||
do
|
||||
if test -f "$f~"; then
|
||||
mv -f "$f~" "$f"
|
||||
fi
|
||||
done
|
||||
rm -f po/Makevars.template
|
||||
|
||||
# Since some files were restored, some files must probably be remade.
|
||||
# But automake could not install all of its files, so pass --install
|
||||
# for it.
|
||||
autoreconf --verbose --install
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
EXTRA_DIST = move-if-change prev-version.txt
|
||||
EXTRA_DIST = move-if-change prev-version.txt config.rpath
|
||||
|
||||
+102
-115
@@ -207,18 +207,22 @@ aix)
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
base=`echo "$object" | sed -e 's/\.o$/.d/' -e 's/\.lo$/.d/'`
|
||||
tmpdepfile1="$base.o.d"
|
||||
tmpdepfile2="$base.d"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1="$dir.libs/$base.lo.d"
|
||||
tmpdepfile2="$dir.libs/$base.d"
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1="$dir$base.o.d"
|
||||
tmpdepfile2="$dir$base.d"
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
@@ -250,34 +254,40 @@ tru64)
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the proprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
( IFS=" "
|
||||
case " $* " in
|
||||
*" --mode=compile "*) # this is libtool, let us make it quiet
|
||||
for arg
|
||||
do # cycle over the arguments
|
||||
case "$arg" in
|
||||
"--mode=compile")
|
||||
# insert --quiet before "--mode=compile"
|
||||
set fnord "$@" --quiet
|
||||
shift # fnord
|
||||
;;
|
||||
esac
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # "$arg"
|
||||
done
|
||||
# always write the proprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'. We will use -o /dev/null later,
|
||||
# however we can't do the remplacement now because
|
||||
# `-o $object' might simply not be used
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
"$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
@@ -295,33 +305,28 @@ dashXmstdout)
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# X makedepend
|
||||
(
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in no)
|
||||
set ""; shift
|
||||
cleared=yes
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift;;
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
@@ -334,35 +339,39 @@ makedepend)
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the proprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
( IFS=" "
|
||||
case " $* " in
|
||||
*" --mode=compile "*)
|
||||
for arg
|
||||
do # cycle over the arguments
|
||||
case $arg in
|
||||
"--mode=compile")
|
||||
# insert --quiet before "--mode=compile"
|
||||
set fnord "$@" --quiet
|
||||
shift # fnord
|
||||
;;
|
||||
esac
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # "$arg"
|
||||
done
|
||||
# always write the proprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
"$@" -E |
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
@@ -374,47 +383,25 @@ msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the proprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
( IFS=" "
|
||||
case " $* " in
|
||||
*" --mode=compile "*)
|
||||
for arg
|
||||
do # cycle over the arguments
|
||||
case $arg in
|
||||
"--mode=compile")
|
||||
# insert --quiet before "--mode=compile"
|
||||
set fnord "$@" --quiet
|
||||
shift # fnord
|
||||
;;
|
||||
esac
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # "$arg"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
"$@" || exit $?
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
) &
|
||||
proc=$!
|
||||
"$@"
|
||||
stat=$?
|
||||
wait "$proc"
|
||||
if test "$stat" != 0; then exit $stat; fi
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ else
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
if [ -f "$src" ] || [ -d "$src" ]
|
||||
then
|
||||
:
|
||||
else
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.29c
|
||||
1.49a
|
||||
|
||||
+18
-20
@@ -18,12 +18,12 @@
|
||||
# 02111-1307 USA
|
||||
|
||||
# We need a recent Autoconf to run a recent Autotest.
|
||||
AC_PREREQ(2.53)
|
||||
AC_PREREQ(2.54)
|
||||
|
||||
AC_INIT([GNU Bison], [1.49a], [[email protected]])
|
||||
AC_INIT([GNU Bison], [1.49c], [[email protected]])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
|
||||
AM_INIT_AUTOMAKE([bison], [1.49a])
|
||||
AM_INIT_AUTOMAKE([1.7 check-news readme-alpha dist-bzip2])
|
||||
AM_CONFIG_HEADER(config.h:config.hin)
|
||||
|
||||
# Initialize the test suite.
|
||||
@@ -78,11 +78,7 @@ AC_DEFINE([_GNU_SOURCE],1,[Define to 1 for GNU C library extensions.])
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(ctype.h locale.h memory.h stdlib.h string.h unistd.h)
|
||||
|
||||
# Checks for typedefs.
|
||||
|
||||
# Checks for structures.
|
||||
AC_CHECK_HEADERS([ctype.h locale.h memory.h stdlib.h string.h unistd.h])
|
||||
|
||||
# Checks for compiler characteristics.
|
||||
AC_C_CONST
|
||||
@@ -96,25 +92,27 @@ AC_FUNC_ERROR_AT_LINE
|
||||
AC_FUNC_STRNLEN
|
||||
UTILS_FUNC_MKSTEMP
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
AC_CHECK_DECLS([free, stpcpy, strchr, strspn, strnlen, malloc, memchr, memrchr])
|
||||
AC_REPLACE_FUNCS(stpcpy strchr strspn memchr memrchr)
|
||||
jm_FUNC_MALLOC
|
||||
jm_FUNC_REALLOC
|
||||
AC_CHECK_DECLS([free, getenv, getopt,
|
||||
stpcpy, strchr, strspn, strnlen,
|
||||
malloc, memchr, memrchr])
|
||||
AC_REPLACE_FUNCS(memchr memrchr \
|
||||
strchr stpcpy strrchr strspn strtol)
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_REALLOC
|
||||
jm_PREREQ_QUOTEARG
|
||||
jm_FUNC_ARGMATCH
|
||||
jm_PREREQ_ERROR
|
||||
jm_PREREQ_TEMPNAME
|
||||
AM_WITH_DMALLOC
|
||||
BISON_PREREQ_TIMEVAR
|
||||
|
||||
ALL_LINGUAS="de es et fr it ja nl ru sv tr"
|
||||
AM_GNU_GETTEXT(, need-ngettext)
|
||||
|
||||
# This is necessary so that .o files in LIBOBJS are also built via
|
||||
# the ANSI2KNR-filtering rules.
|
||||
LIB@&t@OBJS=`echo $LIB@&t@OBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
|
||||
AC_SUBST(LIB@&t@OBJS)
|
||||
# Gettext.
|
||||
AM_GNU_GETTEXT(external, need-ngettext)
|
||||
AM_GNU_GETTEXT_VERSION(0.11.5)
|
||||
|
||||
AC_OUTPUT([Makefile
|
||||
config/Makefile
|
||||
intl/Makefile po/Makefile.in
|
||||
po/Makefile.in
|
||||
data/Makefile
|
||||
lib/Makefile src/Makefile doc/Makefile
|
||||
m4/Makefile])
|
||||
@@ -1,28 +0,0 @@
|
||||
@echo off
|
||||
echo Configuring bison for go32
|
||||
rem This batch file assumes a unix-type "sed" program
|
||||
|
||||
echo # Makefile generated by "configure.bat"> Makefile
|
||||
echo all.dos : bison >> Makefile
|
||||
|
||||
if exist config.sed del config.sed
|
||||
|
||||
echo "s/@srcdir@/./g ">> config.sed
|
||||
echo "s/@CC@/gcc/g ">> config.sed
|
||||
echo "s/@INSTALL@//g ">> config.sed
|
||||
echo "s/@INSTALL_PROGRAM@//g ">> config.sed
|
||||
echo "s/@INSTALL_DATA@//g ">> config.sed
|
||||
echo "s/@DEFS@/-DHAVE_STRERROR/g ">> config.sed
|
||||
echo "s/@LIBS@//g ">> config.sed
|
||||
echo "s/@ALLOCA@//g ">> config.sed
|
||||
|
||||
echo "/^bison[ ]*:/,/-o/ { ">> config.sed
|
||||
echo " s/ \$(CC)/ >bison.rf/ ">> config.sed
|
||||
echo " /-o/ a\ ">> config.sed
|
||||
echo " $(CC) @bison.rf ">> config.sed
|
||||
echo "} ">> config.sed
|
||||
|
||||
sed -e "s/^\"//" -e "s/\"$//" -e "s/[ ]*$//" config.sed > config2.sed
|
||||
sed -f config2.sed Makefile.in >> Makefile
|
||||
del config.sed
|
||||
del config2.sed
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
## Copyright 2002 Free Software Foundation, Inc.
|
||||
## Copyright (C) 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
|
||||
@@ -15,7 +15,7 @@
|
||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
## 02111-1307 USA
|
||||
|
||||
dist_pkgdata_DATA = bison.simple bison.hairy bison.c++
|
||||
dist_pkgdata_DATA = c.m4 yacc.c lalr1.cc glr.c
|
||||
|
||||
m4sugardir = $(pkgdatadir)/m4sugar
|
||||
dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/version.m4
|
||||
|
||||
@@ -1,336 +0,0 @@
|
||||
%%{section} %%{output-prefix} %%{output-infix} %%".c"
|
||||
/* -*- C -*- */
|
||||
|
||||
/* YYERROR and YYCOST are set by guards. If yyerror is set to a
|
||||
nonzero value by a guard, the reduction with which the guard is
|
||||
associated is not performed, and the error recovery mechanism is
|
||||
invoked. Yycost indicates the cost of performing the reduction
|
||||
given the attributes of the symbols. */
|
||||
static int yyerror;
|
||||
static int yycost;
|
||||
|
||||
/* YYMAXDEPTH indicates the size of the parser's state and value
|
||||
stacks. */
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
# define YYMAXDEPTH 500
|
||||
#endif
|
||||
|
||||
/* YYMAXRULES must be at least as large as the number of rules that
|
||||
could be placed in the rule queue. That number could be determined
|
||||
from the grammar and the size of the stack, but, as yet, it is not.
|
||||
*/
|
||||
|
||||
#ifndef YYMAXRULES
|
||||
# define YYMAXRULES 100
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXBACKUP
|
||||
# define YYMAXBACKUP 100
|
||||
#endif
|
||||
|
||||
|
||||
/* The state stack. */
|
||||
static short yyss[YYMAXDEPTH];
|
||||
/* The semantic value stack. */
|
||||
static YYSTYPE yyvs[YYMAXDEPTH];
|
||||
/* The location stack. */
|
||||
static YYLTYPE yyls[YYMAXDEPTH];
|
||||
/* The rule queue. */
|
||||
static short yyrq[YYMAXRULES];
|
||||
/* The lookahead symbol. */
|
||||
static int yychar;
|
||||
|
||||
/* the semantic value of the lookahead symbol. */
|
||||
static YYSTYPE yylval;
|
||||
|
||||
/* the semantic value for the state at the top of the state stack. */
|
||||
static YYSTYPE yytval;
|
||||
|
||||
/* the variable used to return semantic values from the action
|
||||
routines. */
|
||||
static YYSTYPE yyval;
|
||||
|
||||
/* location data for the lookahead symbol. */
|
||||
static YYLTYPE yylloc;
|
||||
|
||||
/* location data for the state at the top of the state stack. */
|
||||
static YYLTYPE yytloc;
|
||||
|
||||
|
||||
static int yynunlexed;
|
||||
static short yyunchar[YYMAXBACKUP];
|
||||
static YYSTYPE yyunval[YYMAXBACKUP];
|
||||
static YYLTYPE yyunloc[YYMAXBACKUP];
|
||||
|
||||
/* a pointer to the top of the state stack; only set during error
|
||||
recovery. */
|
||||
static short *yygssp;
|
||||
|
||||
/* a pointer to the top of the value stack; only set during error
|
||||
recovery. */
|
||||
static YYSTYPE *yygvsp;
|
||||
|
||||
/* a pointer to the top of the location stack; only set during error
|
||||
recovery. */
|
||||
static YYLTYPE *yyglsp;
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------.
|
||||
| Yyget is an interface between the parser and the lexical analyzer. |
|
||||
| It is costly to provide such an interface, but it avoids requiring |
|
||||
| the lexical analyzer to be able to back up the scan. |
|
||||
`--------------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
yyget (void)
|
||||
{
|
||||
if (yynunlexed > 0)
|
||||
{
|
||||
yynunlexed--;
|
||||
yychar = yyunchar[yynunlexed];
|
||||
yylval = yyunval[yynunlexed];
|
||||
yylloc = yyunloc[yynunlexed];
|
||||
}
|
||||
else if (yychar <= 0)
|
||||
yychar = 0;
|
||||
else
|
||||
{
|
||||
yychar = yylex ();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else
|
||||
yychar = YYTRANSLATE (yychar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
yyunlex (int chr, YYSTYPE val, YYLTYPE loc)
|
||||
{
|
||||
yyunchar[yynunlexed] = chr;
|
||||
yyunval[yynunlexed] = val;
|
||||
yyunloc[yynunlexed] = loc;
|
||||
yynunlexed++;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
yyrestore (short *first, short *last)
|
||||
{
|
||||
short *ssp;
|
||||
short *rp;
|
||||
int symbol;
|
||||
int state;
|
||||
int tvalsaved;
|
||||
|
||||
ssp = yygssp;
|
||||
yyunlex (yychar, yylval, yylloc);
|
||||
|
||||
tvalsaved = 0;
|
||||
while (first != last)
|
||||
{
|
||||
symbol = yystos[*ssp];
|
||||
if (symbol < YYNTBASE)
|
||||
{
|
||||
yyunlex (symbol, yytval, yytloc);
|
||||
tvalsaved = 1;
|
||||
ssp--;
|
||||
}
|
||||
|
||||
ssp--;
|
||||
|
||||
if (first == yyrq)
|
||||
first = yyrq + YYMAXRULES;
|
||||
|
||||
first--;
|
||||
|
||||
for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
|
||||
{
|
||||
if (symbol < YYNTBASE)
|
||||
state = yytable[yypact[*ssp] + symbol];
|
||||
else
|
||||
{
|
||||
state = yypgoto[symbol - YYNTBASE] + *ssp;
|
||||
|
||||
if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
|
||||
state = yytable[state];
|
||||
else
|
||||
state = yydefgoto[symbol - YYNTBASE];
|
||||
}
|
||||
|
||||
*++ssp = state;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tvalsaved && ssp > yyss)
|
||||
{
|
||||
yyunlex (yystos[*ssp], yytval, yytloc);
|
||||
ssp--;
|
||||
}
|
||||
|
||||
yygssp = ssp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
yyparse (void)
|
||||
{
|
||||
int yystate;
|
||||
int yyn;
|
||||
short *yyssp;
|
||||
short *yyrq0;
|
||||
short *yyptr;
|
||||
YYSTYPE *yyvsp;
|
||||
|
||||
int yylen;
|
||||
YYLTYPE *yylsp;
|
||||
short *yyrq1;
|
||||
short *yyrq2;
|
||||
|
||||
yystate = 0;
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs - 1;
|
||||
yylsp = yyls - 1;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
|
||||
yychar = yylex ();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else
|
||||
yychar = YYTRANSLATE (yychar);
|
||||
|
||||
yynewstate:
|
||||
|
||||
if (yyssp >= yyss + YYMAXDEPTH - 1)
|
||||
{
|
||||
yyabort ("Parser Stack Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
yyresume:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
yyn += yychar;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yystate = yyn;
|
||||
|
||||
yyptr = yyrq2;
|
||||
while (yyptr != yyrq1)
|
||||
{
|
||||
yyn = *yyptr++;
|
||||
yylen = yyr2[yyn];
|
||||
yyvsp -= yylen;
|
||||
yylsp -= yylen;
|
||||
|
||||
yyguard (yyn, yyvsp, yylsp);
|
||||
if (yyerror)
|
||||
goto yysemerr;
|
||||
|
||||
yyaction (yyn, yyvsp, yylsp);
|
||||
*++yyvsp = yyval;
|
||||
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->first_line = yytloc.first_line;
|
||||
yylsp->first_column = yytloc.first_column;
|
||||
yylsp->last_line = (yylsp - 1)->last_line;
|
||||
yylsp->last_column = (yylsp - 1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp + yylen - 1)->last_line;
|
||||
yylsp->last_column = (yylsp + yylen - 1)->last_column;
|
||||
}
|
||||
|
||||
if (yyptr == yyrq + YYMAXRULES)
|
||||
yyptr = yyrq;
|
||||
}
|
||||
|
||||
if (yystate == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
yyrq2 = yyptr;
|
||||
yyrq1 = yyrq0;
|
||||
|
||||
*++yyvsp = yytval;
|
||||
*++yylsp = yytloc;
|
||||
yytval = yylval;
|
||||
yytloc = yylloc;
|
||||
yyget ();
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yyreduce:
|
||||
|
||||
*yyrq0++ = yyn;
|
||||
|
||||
if (yyrq0 == yyrq + YYMAXRULES)
|
||||
yyrq0 = yyrq;
|
||||
|
||||
if (yyrq0 == yyrq2)
|
||||
{
|
||||
yyabort ("Parser Rule Queue Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
yyssp -= yyr2[yyn];
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yysemerr:
|
||||
*--yyptr = yyn;
|
||||
yyrq2 = yyptr;
|
||||
yyvsp += yyr2[yyn];
|
||||
|
||||
yyerrlab:
|
||||
|
||||
yygssp = yyssp;
|
||||
yygvsp = yyvsp;
|
||||
yyglsp = yylsp;
|
||||
yyrestore (yyrq0, yyrq2);
|
||||
yyrecover ();
|
||||
yystate = *yygssp;
|
||||
yyssp = yygssp;
|
||||
yyvsp = yygvsp;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
goto yyresume;
|
||||
}
|
||||
|
||||
%%{actions}
|
||||
@@ -0,0 +1,177 @@
|
||||
m4_divert(-1) -*- C -*-
|
||||
|
||||
# C M4 Macros for Bison.
|
||||
# Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA
|
||||
# 02111-1307 USA
|
||||
|
||||
|
||||
## ----------- ##
|
||||
## Copuright. ##
|
||||
## ----------- ##
|
||||
|
||||
# b4_copyright(TITLE, YEARS)
|
||||
# --------------------------
|
||||
m4_define([b4_copyright],
|
||||
[/* A Bison parser, made from b4_filename, by GNU bison b4_version. */
|
||||
|
||||
/* $1,
|
||||
Copyright (C) $2 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., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */])
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data Types. ##
|
||||
## ------------ ##
|
||||
|
||||
|
||||
# b4_ints_in(INT1, INT2, LOW, HIGH)
|
||||
# ---------------------------------
|
||||
# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
|
||||
m4_define([b4_ints_in],
|
||||
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
||||
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
||||
b4_ints_in($@, [-128], [128]), [1], [signed char],
|
||||
|
||||
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
|
||||
m4_eval([0 <= $1]), [1], [unsigned int],
|
||||
|
||||
[int])])
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# `NAME_min' to `NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
|
||||
## ------------------------- ##
|
||||
## Assigning token numbers. ##
|
||||
## ------------------------- ##
|
||||
|
||||
# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# -----------------------------------------
|
||||
# Output the definition of this token as #define.
|
||||
m4_define([b4_token_define],
|
||||
[#define $1 $2
|
||||
])
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[$1 = $2])
|
||||
|
||||
|
||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------
|
||||
# Output the definition of the tokens (if there are) as enums and #define.
|
||||
m4_define([b4_token_defines],
|
||||
[m4_if([$@], [[]], [],
|
||||
[/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# if defined (__STDC__) || defined (__cplusplus)
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
m4_map_sep([ b4_token_enum], [,
|
||||
],
|
||||
[$@])
|
||||
};
|
||||
# endif
|
||||
/* POSIX requires `int' for tokens in interfaces. */
|
||||
# define YYTOKENTYPE int
|
||||
#endif /* !YYTOKENTYPE */
|
||||
m4_map([b4_token_define], [$@])
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
## ---------------------------------------------- ##
|
||||
## Declaring C functions in both K&R and ANSI-C. ##
|
||||
## ---------------------------------------------- ##
|
||||
|
||||
|
||||
# b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
|
||||
# ------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_function],
|
||||
[$2
|
||||
#if defined (__STDC__) || defined (__cplusplus)
|
||||
$1 (b4_c_ansi_args(m4_shiftn(2, $@)))
|
||||
#else
|
||||
$1 (b4_c_knr_arg_names(m4_shiftn(2, $@)))
|
||||
b4_c_knr_arg_decls(m4_shiftn(2, $@))
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_ansi_args([TYPE1, NAME1], ...)
|
||||
# -----------------------------------
|
||||
# Output the arguments ANSI-C definition.
|
||||
m4_define([b4_c_ansi_args],
|
||||
[m4_map_sep([b4_c_ansi_arg], [, ], [$@])])
|
||||
|
||||
m4_define([b4_c_ansi_arg],
|
||||
[$1 $2])
|
||||
|
||||
|
||||
# b4_c_knr_args([TYPE1, NAME1], ...)
|
||||
# ----------------------------------
|
||||
# Output the argument names.
|
||||
m4_define([b4_c_knr_arg_names],
|
||||
[m4_map_sep([b4_c_knr_arg_name], [, ], [$@])])
|
||||
|
||||
m4_define([b4_c_knr_arg_name],
|
||||
[$2])
|
||||
|
||||
|
||||
# b4_c_knr_args([TYPE1, NAME1], ...)
|
||||
# ----------------------------------
|
||||
# Output the K&R argument declarations.
|
||||
m4_define([b4_c_knr_arg_decls],
|
||||
[m4_map_sep([b4_c_knr_arg_decl],
|
||||
[
|
||||
],
|
||||
[$@])])
|
||||
|
||||
m4_define([b4_c_knr_arg_decl],
|
||||
[ $1 $2;])
|
||||
+1870
File diff suppressed because it is too large
Load Diff
+211
-206
@@ -1,39 +1,55 @@
|
||||
m4_divert(-1)
|
||||
# C++ skeleton for Bison
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
# b4_sint_type(MAX)
|
||||
# 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
|
||||
|
||||
m4_include([c.m4])
|
||||
|
||||
# b4_lhs_value([TYPE])
|
||||
# --------------------
|
||||
# Expansion of $<TYPE>$.
|
||||
m4_define([b4_lhs_value],
|
||||
[yyval[]m4_ifval([$1], [.$1])])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
||||
# --------------------------------------
|
||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||
# symbols on RHS.
|
||||
m4_define([b4_rhs_value],
|
||||
[semantic_stack_@<:@m4_eval([$1 - $2])@:>@m4_ifval([$3], [.$3])])
|
||||
|
||||
m4_define_default([b4_ltype], [Location])
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Return the smallest signed int type able to handle the number MAX.
|
||||
m4_define([b4_sint_type],
|
||||
[m4_if(m4_eval([$1 <= 127]), [1], [signed char],
|
||||
m4_eval([$1 <= 32767]), [1], [signed short],
|
||||
m4_eval([$1 <= 2147483647]), [1], [signed int],
|
||||
[m4_fatal([no signed int type for $1])])])
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[yyloc])
|
||||
|
||||
|
||||
# b4_uint_type(MAX)
|
||||
# -----------------
|
||||
# Return the smallest unsigned int type able to handle the number MAX.
|
||||
m4_define([b4_uint_type],
|
||||
[m4_if(m4_eval([$1 <= 255]), [1], [unsigned char],
|
||||
m4_eval([$1 <= 65535]), [1], [unsigned short],
|
||||
m4_eval([$1 <= 4294967295]), [1], [unsigned int],
|
||||
[m4_fatal([no unsigned int type for $1])])])
|
||||
# b4_rhs_location(RULE-LENGTH, NUM)
|
||||
# ---------------------------------
|
||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[location_stack_@<:@m4_eval([$1 - $2])@:>@])
|
||||
|
||||
|
||||
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ------------------------------------------
|
||||
# Output the definition of this token as #define.
|
||||
m4_define([b4_token_define],
|
||||
[#define $1 $2
|
||||
])
|
||||
|
||||
|
||||
# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||
# -------------------------------------------------------
|
||||
# Output the definition of the tokens as #define.
|
||||
m4_define([b4_token_defines],
|
||||
[m4_map([b4_token_define], [$@])])
|
||||
|
||||
m4_define_default([b4_input_suffix], [.y])
|
||||
|
||||
m4_define_default([b4_output_parser_suffix],
|
||||
@@ -71,37 +87,11 @@ m4_define([b4_constructor],
|
||||
],
|
||||
[])])
|
||||
|
||||
m4_define([b4_copyright],
|
||||
[/* -*- C++ -*- */
|
||||
/* A Bison parser, made from b4_filename,
|
||||
by GNU bison b4_version. */
|
||||
|
||||
/* Skeleton output parser for bison,
|
||||
Copyright 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., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */])
|
||||
|
||||
m4_divert(0)dnl
|
||||
#output "b4_output_header_name"
|
||||
b4_copyright
|
||||
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
||||
[2002])
|
||||
#ifndef b4_header_guard
|
||||
# define b4_header_guard
|
||||
|
||||
@@ -109,6 +99,7 @@ b4_copyright
|
||||
#include "location.hh"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
/* Using locations. */
|
||||
#define YYLSP_NEEDED b4_locations_flag
|
||||
@@ -116,6 +107,9 @@ b4_copyright
|
||||
/* Copy the first part of user declarations. */
|
||||
b4_pre_prologue
|
||||
|
||||
/* Line __line__ of __file__. */
|
||||
#line __oline__ "__ofile__"
|
||||
|
||||
/* Tokens. */
|
||||
b4_token_defines(b4_tokens)
|
||||
|
||||
@@ -130,17 +124,19 @@ b4_token_defines(b4_tokens)
|
||||
#endif
|
||||
|
||||
#ifndef YYSTYPE
|
||||
m4_ifdef([b4_stype_line],
|
||||
m4_ifdef([b4_stype],
|
||||
[#line b4_stype_line "b4_filename"
|
||||
])dnl
|
||||
typedef b4_stype
|
||||
yystype;
|
||||
typedef union b4_stype yystype;
|
||||
/* Line __line__ of __file__. */
|
||||
#line __oline__ "__ofile__"],
|
||||
[typedef int yystype;])
|
||||
# define YYSTYPE yystype
|
||||
#endif
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
b4_post_prologue
|
||||
|
||||
/* Line __line__ of __file__. */
|
||||
#line __oline__ "__ofile__"
|
||||
#ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
@@ -148,18 +144,6 @@ b4_post_prologue
|
||||
Current.last_column = Rhs[[N]].last_column;
|
||||
#endif
|
||||
|
||||
m4_if(b4_locations_flag, [0], [],
|
||||
[#ifndef YYLTYPE
|
||||
typedef struct yyltype
|
||||
{
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
} yyltype;
|
||||
# define YYLTYPE yyltype
|
||||
#endif])
|
||||
|
||||
namespace yy
|
||||
{
|
||||
class b4_name;
|
||||
@@ -172,8 +156,8 @@ namespace yy
|
||||
template < >
|
||||
struct Traits< b4_name >
|
||||
{
|
||||
typedef b4_uint_type(b4_token_number_max) TokenNumberType;
|
||||
typedef b4_sint_type(b4_rhs_number_max) RhsNumberType;
|
||||
typedef b4_int_type_for([b4_translate]) TokenNumberType;
|
||||
typedef b4_int_type_for([b4_rhs]) RhsNumberType;
|
||||
typedef int StateType;
|
||||
typedef yystype SemanticType;
|
||||
typedef b4_ltype LocationType;
|
||||
@@ -200,10 +184,12 @@ namespace yy
|
||||
b4_name (bool debug,
|
||||
LocationType initlocation[]b4_param) :
|
||||
b4_constructor[]debug_ (debug),
|
||||
cdebug_ (std::cerr),
|
||||
initlocation_ (initlocation)
|
||||
#else
|
||||
b4_name (bool debug[]b4_param) :
|
||||
b4_constructor[]debug_ (debug)
|
||||
b4_constructor[]debug_ (debug),
|
||||
cdebug_ (std::cerr)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
@@ -226,14 +212,16 @@ namespace yy
|
||||
LocationStack location_stack_;
|
||||
|
||||
/* Tables. */
|
||||
static const short pact_[[]];
|
||||
static const short defact_[[]];
|
||||
static const short pgoto_[[]];
|
||||
static const short defgoto_[[]];
|
||||
static const short table_[[]];
|
||||
static const short check_[[]];
|
||||
static const TokenNumberType r1_[[]];
|
||||
static const short r2_[[]];
|
||||
static const b4_int_type_for([b4_pact]) pact_[[]];
|
||||
static const b4_int_type_for([b4_pact]) pact_ninf_;
|
||||
static const b4_int_type_for([b4_defact]) defact_[[]];
|
||||
static const b4_int_type_for([b4_pgoto]) pgoto_[[]];
|
||||
static const b4_int_type_for([b4_defgoto]) defgoto_[[]];
|
||||
static const b4_int_type_for([b4_table]) table_[[]];
|
||||
static const b4_int_type_for([b4_table]) table_ninf_;
|
||||
static const b4_int_type_for([b4_check]) check_[[]];
|
||||
static const b4_int_type_for([b4_r1]) r1_[[]];
|
||||
static const b4_int_type_for([b4_r2]) r2_[[]];
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE
|
||||
static const char* const name_[[]];
|
||||
@@ -242,8 +230,10 @@ namespace yy
|
||||
/* More tables, for debugging. */
|
||||
#if YYDEBUG
|
||||
static const RhsNumberType rhs_[[]];
|
||||
static const short prhs_[[]];
|
||||
static const short rline_[[]];
|
||||
static const b4_int_type_for([b4_prhs]) prhs_[[]];
|
||||
static const b4_int_type_for([b4_rline]) rline_[[]];
|
||||
static const b4_int_type_for([b4_stos]) stos_[[]];
|
||||
static const b4_int_type_for([b4_toknum]) token_number_[[]];
|
||||
#endif
|
||||
|
||||
/* Even more tables. */
|
||||
@@ -252,9 +242,7 @@ namespace yy
|
||||
/* Constants. */
|
||||
static const int eof_;
|
||||
static const int last_;
|
||||
static const int flag_;
|
||||
static const int nnts_;
|
||||
static const int nsym_;
|
||||
static const int empty_;
|
||||
static const int final_;
|
||||
static const int terror_;
|
||||
@@ -267,9 +255,12 @@ namespace yy
|
||||
/* State. */
|
||||
int n_;
|
||||
int len_;
|
||||
int debug_;
|
||||
int state_;
|
||||
|
||||
/* Debugging. */
|
||||
int debug_;
|
||||
std::ostream &cdebug_;
|
||||
|
||||
/* Lookahead and lookahead in internal form. */
|
||||
int looka_;
|
||||
int ilooka_;
|
||||
@@ -291,23 +282,18 @@ namespace yy
|
||||
}
|
||||
|
||||
#endif /* not b4_header_guard */
|
||||
|
||||
dnl
|
||||
#output "b4_output_prefix[]b4_output_infix[].cc"
|
||||
b4_copyright
|
||||
b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
|
||||
[2002])
|
||||
|
||||
#include "b4_output_header_name"
|
||||
|
||||
/* Enable debugging if requested. */
|
||||
#if YYDEBUG
|
||||
# include <cstdio>
|
||||
# define YYFPRINTF std::fprintf
|
||||
# define YYDPRINTF(Args) \
|
||||
do { \
|
||||
if (debug_) \
|
||||
YYFPRINTF Args; \
|
||||
} while (0)
|
||||
# define YYCDEBUG if (debug_) cdebug_
|
||||
#else /* !YYDEBUG */
|
||||
# define YYDPRINTF(Args)
|
||||
# define YYCDEBUG if (0) cdebug_
|
||||
#endif /* !YYDEBUG */
|
||||
|
||||
int
|
||||
@@ -321,24 +307,18 @@ yy::b4_name::parse ()
|
||||
semantic_stack_ = SemanticStack (1);
|
||||
location_stack_ = LocationStack (1);
|
||||
|
||||
/* Reserve initial space. The C parser needed that, but is it really
|
||||
useful here? */
|
||||
state_stack_.reserve (initdepth_);
|
||||
semantic_stack_.reserve (initdepth_);
|
||||
location_stack_.reserve (initdepth_);
|
||||
|
||||
/* Start. */
|
||||
state_ = 0;
|
||||
looka_ = empty_;
|
||||
#if YYLSP_NEEDED
|
||||
location = initlocation_;
|
||||
#endif
|
||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||
YYCDEBUG << "Starting parse" << std::endl;
|
||||
|
||||
/* New state. */
|
||||
yynewstate:
|
||||
state_stack_.push (state_);
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", state_));
|
||||
YYCDEBUG << "Entering state " << state_ << std::endl;
|
||||
goto yybackup;
|
||||
|
||||
/* Backup. */
|
||||
@@ -346,13 +326,13 @@ yy::b4_name::parse ()
|
||||
|
||||
/* Try to take a decision without lookahead. */
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ == flag_)
|
||||
if (n_ == pact_ninf_)
|
||||
goto yydefault;
|
||||
|
||||
/* Read a lookahead token. */
|
||||
if (looka_ == empty_)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Reading a token: "));
|
||||
YYCDEBUG << "Reading a token: ";
|
||||
lex_ ();
|
||||
}
|
||||
|
||||
@@ -361,7 +341,7 @@ yy::b4_name::parse ()
|
||||
{
|
||||
looka_ = eof_;
|
||||
ilooka_ = 0;
|
||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
||||
YYCDEBUG << "Now at end of input." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -369,9 +349,10 @@ yy::b4_name::parse ()
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "Next token is %d (%s", looka_, name_[[ilooka_]]);
|
||||
YYCDEBUG << "Next token is " << looka_
|
||||
<< " (" << name_[[ilooka_]];
|
||||
print_ ();
|
||||
YYFPRINTF (stderr, ")\n");
|
||||
YYCDEBUG << ')' << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -384,7 +365,7 @@ yy::b4_name::parse ()
|
||||
n_ = table_[[n_]];
|
||||
if (n_ < 0)
|
||||
{
|
||||
if (n_ == flag_)
|
||||
if (n_ == table_ninf_)
|
||||
goto yyerrlab;
|
||||
else
|
||||
{
|
||||
@@ -400,7 +381,8 @@ yy::b4_name::parse ()
|
||||
goto yyacceptlab;
|
||||
|
||||
/* Shift the lookahead token. */
|
||||
YYDPRINTF ((stderr, "Shifting token %d (%s), ", looka_, name_[[ilooka_]]));
|
||||
YYCDEBUG << "Shifting token " << looka_
|
||||
<< " (" << name_[[ilooka_]] << "), ";
|
||||
|
||||
/* Discard the token being shifted unless it is eof. */
|
||||
if (looka_ != eof_)
|
||||
@@ -429,8 +411,8 @@ yy::b4_name::parse ()
|
||||
len_ = r2_[[n_]];
|
||||
if (len_)
|
||||
{
|
||||
yyval = semantic_stack_[[1 - len_]];
|
||||
yyloc = location_stack_[[1 - len_]];
|
||||
yyval = semantic_stack_[[len_ - 1]];
|
||||
yyloc = location_stack_[[len_ - 1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,11 +423,12 @@ yy::b4_name::parse ()
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", n_ - 1, rline_[[n_]]);
|
||||
for (unsigned i = prhs_[[n_]];
|
||||
YYCDEBUG << "Reducing via rule " << n_ - 1
|
||||
<< " (line " << rline_[[n_]] << "), ";
|
||||
for (b4_int_type_for([b4_prhs]) i = prhs_[[n_]];
|
||||
rhs_[[i]] >= 0; ++i)
|
||||
YYFPRINTF (stderr, "%s ", name_[[rhs_[i]]]);
|
||||
YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]);
|
||||
YYCDEBUG << name_[[rhs_[i]]] << ' ';
|
||||
YYCDEBUG << "-> " << name_[[r1_[n_]]] << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -455,15 +438,10 @@ yy::b4_name::parse ()
|
||||
YYLLOC_DEFAULT (yyloc, slice, len_);
|
||||
}
|
||||
|
||||
{
|
||||
SemanticStack& yyvsp (semantic_stack_);
|
||||
LocationStack& yylsp (location_stack_);
|
||||
|
||||
switch (n_)
|
||||
{
|
||||
b4_actions
|
||||
}
|
||||
}
|
||||
switch (n_)
|
||||
{
|
||||
b4_actions
|
||||
}
|
||||
|
||||
/* Line __line__ of __file__. */
|
||||
#line __oline__ "__ofile__"
|
||||
@@ -475,11 +453,11 @@ yy::b4_name::parse ()
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "state stack now");
|
||||
YYCDEBUG << "state stack now";
|
||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||
i != state_stack_.end (); ++i)
|
||||
YYFPRINTF (stderr, " %d", *i);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
YYCDEBUG << ' ' << *i;
|
||||
YYCDEBUG << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -504,20 +482,20 @@ yy::b4_name::parse ()
|
||||
|
||||
#if YYERROR_VERBOSE
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ > flag_ && n_ < last_)
|
||||
if (pact_ninf_ < n_ && n_ < last_)
|
||||
{
|
||||
message = "parse error, unexpected ";
|
||||
message += name_[[ilooka_]];
|
||||
{
|
||||
int count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
if (check_[[x + n_]] == x)
|
||||
if (check_[[x + n_]] == x && x != terror_)
|
||||
++count;
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
|
||||
if (check_[[x + n_]] == x)
|
||||
if (check_[[x + n_]] == x && x != terror_)
|
||||
{
|
||||
message += (!count++) ? ", expecting " : " or ";
|
||||
message += name_[[x]];
|
||||
@@ -542,7 +520,8 @@ yy::b4_name::parse ()
|
||||
/* Return failure if at end of input. */
|
||||
if (looka_ == eof_)
|
||||
goto yyabortlab;
|
||||
YYDPRINTF ((stderr, "Discarding token %d (%s).\n", looka_, name_[[ilooka_]]));
|
||||
YYCDEBUG << "Discarding token " << looka_
|
||||
<< " (" << name_[[ilooka_]] << ")." << std::endl;
|
||||
looka_ = empty_;
|
||||
}
|
||||
|
||||
@@ -550,52 +529,67 @@ yy::b4_name::parse ()
|
||||
token. */
|
||||
|
||||
errstatus = 3;
|
||||
goto yyerrhandle;
|
||||
|
||||
/* Pop the current state because it cannot handle the error token. */
|
||||
yyerrdefault:
|
||||
yyerrpop:
|
||||
if (!state_stack_.height ())
|
||||
goto yyabortlab;
|
||||
state_ = (state_stack_.pop (), state_stack_[[0]]);
|
||||
semantic_stack_.pop ();
|
||||
location_stack_.pop ();;
|
||||
for (;;)
|
||||
{
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ != pact_ninf_)
|
||||
{
|
||||
n_ += terror_;
|
||||
if (0 <= n_ && n_ <= last_ && check_[[n_]] == terror_)
|
||||
{
|
||||
n_ = table_[[n_]];
|
||||
if (0 < n_)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pop the current state because it cannot handle the error token. */
|
||||
if (!state_stack_.height ())
|
||||
goto yyabortlab;
|
||||
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYFPRINTF (stderr, "Error: state stack now");
|
||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||
i != state_stack_.end (); ++i)
|
||||
YYFPRINTF (stderr, " %d", *i);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
if (debug_)
|
||||
{
|
||||
if (stos_[[state_]] < ntokens_)
|
||||
{
|
||||
YYCDEBUG << "Error: popping token "
|
||||
<< token_number_[[stos_[state_]]]
|
||||
<< " (" << name_[[stos_[state_]]];
|
||||
# ifdef YYPRINT
|
||||
YYPRINT (stderr, token_number_[[stos_[state_]]],
|
||||
semantic_stack_.top ());
|
||||
# endif
|
||||
YYCDEBUG << ')' << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
YYCDEBUG << "Error: popping nonterminal ("
|
||||
<< name_[[stos_[state_]]] << ')' << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
yyerrhandle:
|
||||
n_ = pact_[[state_]];
|
||||
if (n_ == flag_)
|
||||
goto yyerrdefault;
|
||||
state_ = (state_stack_.pop (), state_stack_[[0]]);
|
||||
semantic_stack_.pop ();
|
||||
location_stack_.pop ();;
|
||||
|
||||
n_ += terror_;
|
||||
if (n_ < 0 || n_ > last_ || check_[[n_]] != terror_)
|
||||
goto yyerrdefault;
|
||||
|
||||
n_ = table_[[n_]];
|
||||
if (n_ < 0)
|
||||
{
|
||||
if (n_ == flag_)
|
||||
goto yyerrpop;
|
||||
n_ = -n_;
|
||||
goto yyreduce;
|
||||
#if YYDEBUG
|
||||
if (debug_)
|
||||
{
|
||||
YYCDEBUG << "Error: state stack now";
|
||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||
i != state_stack_.end (); ++i)
|
||||
YYCDEBUG << ' ' << *i;
|
||||
YYCDEBUG << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (!n_)
|
||||
goto yyerrpop;
|
||||
|
||||
if (n_ == final_)
|
||||
goto yyacceptlab;
|
||||
|
||||
YYDPRINTF ((stderr, "Shifting error token, "));
|
||||
YYCDEBUG << "Shifting error token, ";
|
||||
|
||||
semantic_stack_.push (value);
|
||||
location_stack_.push (location);
|
||||
@@ -624,7 +618,8 @@ yy::b4_name::lex_ ()
|
||||
|
||||
/* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
|
||||
STATE-NUM. */
|
||||
const short
|
||||
const b4_int_type_for([b4_pact]) yy::b4_name::pact_ninf_ = b4_pact_ninf;
|
||||
const b4_int_type_for([b4_pact])
|
||||
yy::b4_name::pact_[[]] =
|
||||
{
|
||||
b4_pact
|
||||
@@ -633,21 +628,21 @@ yy::b4_name::pact_[[]] =
|
||||
/* YYDEFACT[[S]] -- default rule to reduce with in state S when YYTABLE
|
||||
doesn't specify something else to do. Zero means the default is an
|
||||
error. */
|
||||
const short
|
||||
const b4_int_type_for([b4_defact])
|
||||
yy::b4_name::defact_[[]] =
|
||||
{
|
||||
b4_defact
|
||||
};
|
||||
|
||||
/* YYPGOTO[[NTERM-NUM]]. */
|
||||
const short
|
||||
const b4_int_type_for([b4_pgoto])
|
||||
yy::b4_name::pgoto_[[]] =
|
||||
{
|
||||
b4_pgoto
|
||||
};
|
||||
|
||||
/* YYDEFGOTO[[NTERM-NUM]]. */
|
||||
const short
|
||||
const b4_int_type_for([b4_defgoto])
|
||||
yy::b4_name::defgoto_[[]] =
|
||||
{
|
||||
b4_defgoto
|
||||
@@ -656,28 +651,47 @@ yy::b4_name::defgoto_[[]] =
|
||||
/* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
|
||||
positive, shift that token. If negative, reduce the rule which
|
||||
number is the opposite. If zero, do what YYDEFACT says. */
|
||||
const short
|
||||
const b4_int_type_for([b4_table]) yy::b4_name::table_ninf_ = b4_table_ninf;
|
||||
const b4_int_type_for([b4_table])
|
||||
yy::b4_name::table_[[]] =
|
||||
{
|
||||
b4_table
|
||||
};
|
||||
|
||||
/* YYCHECK. */
|
||||
const short
|
||||
const b4_int_type_for([b4_check])
|
||||
yy::b4_name::check_[[]] =
|
||||
{
|
||||
b4_check
|
||||
};
|
||||
|
||||
#if YYDEBUG
|
||||
/* STOS_[[STATE-NUM]] -- The (internal number of the) accessing
|
||||
symbol of state STATE-NUM. */
|
||||
const b4_int_type_for([b4_stos])
|
||||
yy::b4_name::stos_[[]] =
|
||||
{
|
||||
b4_stos
|
||||
};
|
||||
|
||||
/* TOKEN_NUMBER_[[YYLEX-NUM]] -- Internal token number corresponding
|
||||
to YYLEX-NUM. */
|
||||
const b4_int_type_for([b4_toknum])
|
||||
yy::b4_name::token_number_[[]] =
|
||||
{
|
||||
b4_toknum
|
||||
};
|
||||
#endif
|
||||
|
||||
/* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
|
||||
const yy::b4_name::TokenNumberType
|
||||
const b4_int_type_for([b4_r1])
|
||||
yy::b4_name::r1_[[]] =
|
||||
{
|
||||
b4_r1
|
||||
};
|
||||
|
||||
/* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
|
||||
const short
|
||||
const b4_int_type_for([b4_r2])
|
||||
yy::b4_name::r2_[[]] =
|
||||
{
|
||||
b4_r2
|
||||
@@ -703,14 +717,14 @@ yy::b4_name::rhs_[[]] =
|
||||
|
||||
/* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
|
||||
YYRHS. */
|
||||
const short
|
||||
const b4_int_type_for([b4_prhs])
|
||||
yy::b4_name::prhs_[[]] =
|
||||
{
|
||||
b4_prhs
|
||||
};
|
||||
|
||||
/* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */
|
||||
const short
|
||||
const b4_int_type_for([b4_rline])
|
||||
yy::b4_name::rline_[[]] =
|
||||
{
|
||||
b4_rline
|
||||
@@ -735,32 +749,30 @@ yy::b4_name::translate_ (int token)
|
||||
|
||||
const int yy::b4_name::eof_ = 0;
|
||||
const int yy::b4_name::last_ = b4_last;
|
||||
const int yy::b4_name::flag_ = b4_flag;
|
||||
const int yy::b4_name::nnts_ = b4_nnts;
|
||||
const int yy::b4_name::nsym_ = b4_nsym;
|
||||
const int yy::b4_name::nnts_ = b4_nterms_number;
|
||||
const int yy::b4_name::empty_ = -2;
|
||||
const int yy::b4_name::final_ = b4_final;
|
||||
const int yy::b4_name::final_ = b4_final_state_number;
|
||||
const int yy::b4_name::terror_ = 1;
|
||||
const int yy::b4_name::errcode_ = 256;
|
||||
const int yy::b4_name::ntokens_ = b4_ntokens;
|
||||
const int yy::b4_name::ntokens_ = b4_tokens_number;
|
||||
const int yy::b4_name::initdepth_ = b4_initdepth;
|
||||
|
||||
const unsigned yy::b4_name::user_token_number_max_ = b4_user_token_number_max;
|
||||
const yy::b4_name::TokenNumberType yy::b4_name::undef_token_ = b4_undef_token_number;
|
||||
|
||||
b4_epilogue
|
||||
|
||||
dnl
|
||||
#output "stack.hh"
|
||||
b4_copyright
|
||||
b4_copyright([2002])
|
||||
|
||||
#ifndef BISON_STACK_HH
|
||||
# define BISON_STACK_HH
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
namespace yy
|
||||
{
|
||||
template < class T, class S = std::vector< T > >
|
||||
template < class T, class S = std::deque< T > >
|
||||
class Stack
|
||||
{
|
||||
public:
|
||||
@@ -778,23 +790,23 @@ namespace yy
|
||||
|
||||
inline
|
||||
T&
|
||||
operator [[]] (int index)
|
||||
operator [[]] (unsigned index)
|
||||
{
|
||||
return seq_[[height () - 1 + index]];
|
||||
return seq_[[index]];
|
||||
}
|
||||
|
||||
inline
|
||||
const T&
|
||||
operator [[]] (int index) const
|
||||
operator [[]] (unsigned index) const
|
||||
{
|
||||
return seq_[[height () - 1 + index]];
|
||||
return seq_[[index]];
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
push (const T& t)
|
||||
{
|
||||
seq_.push_back (t);
|
||||
seq_.push_front (t);
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -802,14 +814,7 @@ namespace yy
|
||||
pop (unsigned n = 1)
|
||||
{
|
||||
for (; n; --n)
|
||||
seq_.pop_back ();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
reserve (unsigned n)
|
||||
{
|
||||
seq_.reserve (n);
|
||||
seq_.pop_front ();
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -842,7 +847,7 @@ namespace yy
|
||||
const T&
|
||||
operator [[]] (unsigned index) const
|
||||
{
|
||||
return stack_[[index - range_]];
|
||||
return stack_[[range_ - index]];
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -853,9 +858,9 @@ namespace yy
|
||||
}
|
||||
|
||||
#endif // not BISON_STACK_HH
|
||||
|
||||
dnl
|
||||
#output "location.hh"
|
||||
b4_copyright
|
||||
b4_copyright([2002])
|
||||
|
||||
#ifndef BISON_LOCATION_HH
|
||||
# define BISON_LOCATION_HH
|
||||
+21
-6
@@ -422,8 +422,8 @@ m4_define([m4_bmatch],
|
||||
[m4_if([$#], 0, [],
|
||||
[$#], 1, [],
|
||||
[$#], 2, [$2],
|
||||
m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
|
||||
[$3])])
|
||||
[m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
|
||||
[$3])])])
|
||||
|
||||
|
||||
# m4_map(MACRO, LIST)
|
||||
@@ -432,11 +432,26 @@ m4_define([m4_bmatch],
|
||||
# of LIST (which can be lists themselves, for multiple arguments MACROs).
|
||||
m4_define([m4_fst], [$1])
|
||||
m4_define([m4_map],
|
||||
[m4_if([$2], [[]], [],
|
||||
[m4_if([$2], [], [],
|
||||
[$2], [[]], [],
|
||||
[$1(m4_fst($2))[]dnl
|
||||
m4_map([$1], m4_cdr($2))])])
|
||||
|
||||
|
||||
# m4_map_sep(MACRO, SEPARATOR, LIST)
|
||||
# ----------------------------------
|
||||
# Invoke MACRO($1), SEPARATOR, MACRO($2), ..., MACRO($N) where $1, $2... $N
|
||||
# are the elements of LIST (which can be lists themselves, for multiple
|
||||
# arguments MACROs).
|
||||
m4_define([m4_map_sep],
|
||||
[m4_if([$3], [[]], [],
|
||||
[$1(m4_fst($3))[]dnl
|
||||
m4_if(m4_cdr($3),
|
||||
[[]], [],
|
||||
[$2])[]dnl
|
||||
m4_map_sep([$1], [$2], m4_cdr($3))])])
|
||||
|
||||
|
||||
## ---------------------------------------- ##
|
||||
## 6. Enhanced version of some primitives. ##
|
||||
## ---------------------------------------- ##
|
||||
@@ -469,7 +484,7 @@ m4_define([m4_bpatsubsts],
|
||||
# ------------------
|
||||
# This macro invokes all its arguments (in sequence, of course). It is
|
||||
# useful for making your macros more structured and readable by dropping
|
||||
# unecessary dnl's and have the macros indented properly.
|
||||
# unnecessary dnl's and have the macros indented properly.
|
||||
m4_define([m4_do],
|
||||
[m4_if($#, 0, [],
|
||||
$#, 1, [$1],
|
||||
@@ -615,7 +630,7 @@ m4_if($1, [$2], [],
|
||||
# Implementing `foreach' loops in m4 is much more tricky than it may
|
||||
# seem. Actually, the example of a `foreach' loop in the m4
|
||||
# documentation is wrong: it does not quote the arguments properly,
|
||||
# which leads to undesired expansions.
|
||||
# which leads to undesirable expansions.
|
||||
#
|
||||
# The example in the documentation is:
|
||||
#
|
||||
@@ -1484,7 +1499,7 @@ m4_define([m4_flatten],
|
||||
# of brackets around $1 (don't forget that the result must be quoted
|
||||
# too, hence one more quoting than applications).
|
||||
#
|
||||
# Then notice the 2 last pattens: they are in charge of removing the
|
||||
# Then notice the 2 last patterns: they are in charge of removing the
|
||||
# leading/trailing spaces. Why not just `[^ ]'? Because they are
|
||||
# applied to doubly quoted strings, i.e. more or less [[STRING]]. So
|
||||
# if there is a leading space in STRING, then it is the *third*
|
||||
|
||||
+423
-343
File diff suppressed because it is too large
Load Diff
+904
-143
File diff suppressed because it is too large
Load Diff
+17
-10
@@ -21,12 +21,9 @@ CFLAGS = @CFLAGS@ $(WARNING_CFLAGS)
|
||||
|
||||
noinst_LIBRARIES = libbison.a
|
||||
|
||||
# libintl.h in is build/intl, libgettext.h in src/intl/,
|
||||
# config.h in build/., and system.h is in src/src/.
|
||||
INCLUDES = -I$(top_builddir)/intl \
|
||||
-I$(top_builddir) \
|
||||
# config.h is in build/., and system.h is in src/src/.
|
||||
INCLUDES = -I$(top_builddir) \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/intl \
|
||||
-I$(top_srcdir)/lib
|
||||
|
||||
# Heck, we are still using an old version of Automake which does not
|
||||
@@ -40,14 +37,24 @@ libbison_a_SOURCES = \
|
||||
getopt.h getopt.c getopt1.c \
|
||||
hash.h hash.c \
|
||||
quote.h quote.c quotearg.h quotearg.c \
|
||||
readpipe.c unlocked-io.h \
|
||||
xalloc.h xmalloc.c xstrdup.c xstrndup.c \
|
||||
readpipe.c
|
||||
$(bitsets_sources) $(additional_bitsets_sources) $(timevars_sources)
|
||||
|
||||
# Implementation of bitsets
|
||||
libbison_a_SOURCES += \
|
||||
bbitset.h \
|
||||
bitset-int.h bitset.h bitsetv.h ebitset.h lbitset.h sbitset.h \
|
||||
bitset.c bitsetv.c ebitset.c lbitset.c sbitset.c
|
||||
bitsets_sources = \
|
||||
libiberty.h \
|
||||
abitset.c bitset.c bitset_stats.h ebitset.c lbitset.h \
|
||||
abitset.h bitset.h bitsetv.c ebitset.h \
|
||||
bbitset.h bitset_stats.c bitsetv.h lbitset.c
|
||||
|
||||
# Additional bitset operations.
|
||||
additional_bitsets_sources = \
|
||||
bitsetv-print.h bitsetv-print.c
|
||||
|
||||
# timevars, stolen from GCC.
|
||||
timevars_sources = \
|
||||
timevar.h timevar.c timevar.def
|
||||
|
||||
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
|
||||
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
|
||||
|
||||
+92
-111
@@ -1,4 +1,4 @@
|
||||
/* Simple bitsets.
|
||||
/* Array bitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
@@ -21,57 +21,57 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "sbitset.h"
|
||||
#include "abitset.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This file implements fixed size bitsets stored as an array
|
||||
of words. Any unused bits in the last word must be zero. */
|
||||
|
||||
typedef struct sbitset_struct
|
||||
typedef struct abitset_struct
|
||||
{
|
||||
unsigned int n_bits; /* Number of bits. */
|
||||
bitset_word words[1]; /* The array of bits. */
|
||||
}
|
||||
*sbitset;
|
||||
*abitset;
|
||||
|
||||
|
||||
struct bitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
struct sbitset_struct s;
|
||||
struct abitset_struct a;
|
||||
};
|
||||
|
||||
static void sbitset_unused_clear PARAMS ((bitset));
|
||||
static void abitset_unused_clear PARAMS ((bitset));
|
||||
|
||||
static int sbitset_small_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
static int abitset_small_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
|
||||
static void sbitset_set PARAMS ((bitset, bitset_bindex));
|
||||
static void sbitset_reset PARAMS ((bitset, bitset_bindex));
|
||||
static int sbitset_test PARAMS ((bitset, bitset_bindex));
|
||||
static int sbitset_size PARAMS ((bitset));
|
||||
static int sbitset_op1 PARAMS ((bitset, enum bitset_ops));
|
||||
static int sbitset_op2 PARAMS ((bitset, bitset, enum bitset_ops));
|
||||
static int sbitset_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops));
|
||||
static int sbitset_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
static void abitset_set PARAMS ((bitset, bitset_bindex));
|
||||
static void abitset_reset PARAMS ((bitset, bitset_bindex));
|
||||
static int abitset_test PARAMS ((bitset, bitset_bindex));
|
||||
static int abitset_size PARAMS ((bitset));
|
||||
static int abitset_op1 PARAMS ((bitset, enum bitset_ops));
|
||||
static int abitset_op2 PARAMS ((bitset, bitset, enum bitset_ops));
|
||||
static int abitset_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops));
|
||||
static int abitset_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
enum bitset_ops));
|
||||
static int sbitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
static int abitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
static int sbitset_reverse_list
|
||||
static int abitset_reverse_list
|
||||
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
|
||||
|
||||
#define SBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||
#define SBITSET_WORDS(X) ((X)->s.words)
|
||||
#define SBITSET_N_BITS(X) ((X)->s.n_bits)
|
||||
#define ABITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||
#define ABITSET_WORDS(X) ((X)->a.words)
|
||||
#define ABITSET_N_BITS(X) ((X)->a.n_bits)
|
||||
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
static int
|
||||
sbitset_size (src)
|
||||
abitset_size (src)
|
||||
bitset src;
|
||||
{
|
||||
return SBITSET_N_BITS (src);
|
||||
return ABITSET_N_BITS (src);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ sbitset_size (src)
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static int
|
||||
sbitset_small_list (src, list, num, next)
|
||||
abitset_small_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
@@ -90,13 +90,13 @@ sbitset_small_list (src, list, num, next)
|
||||
bitset_windex size;
|
||||
bitset_word word;
|
||||
|
||||
word = SBITSET_WORDS (src)[0];
|
||||
word = ABITSET_WORDS (src)[0];
|
||||
|
||||
/* Short circuit common case. */
|
||||
if (!word)
|
||||
return 0;
|
||||
|
||||
size = SBITSET_N_BITS (src);
|
||||
size = ABITSET_N_BITS (src);
|
||||
bitno = *next;
|
||||
if (bitno >= size)
|
||||
return 0;
|
||||
@@ -139,33 +139,33 @@ sbitset_small_list (src, list, num, next)
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
static void
|
||||
sbitset_set (dst, bitno)
|
||||
abitset_set (dst, bitno)
|
||||
bitset dst ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This should never occur for sbitsets. */
|
||||
/* This should never occur for abitsets. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
static void
|
||||
sbitset_reset (dst, bitno)
|
||||
abitset_reset (dst, bitno)
|
||||
bitset dst ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This should never occur for sbitsets. */
|
||||
/* This should never occur for abitsets. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test bit BITNO in bitset SRC. */
|
||||
static int
|
||||
sbitset_test (src, bitno)
|
||||
abitset_test (src, bitno)
|
||||
bitset src ATTRIBUTE_UNUSED;
|
||||
bitset_bindex bitno ATTRIBUTE_UNUSED;
|
||||
{
|
||||
/* This should never occur for sbitsets. */
|
||||
/* This should never occur for abitsets. */
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ sbitset_test (src, bitno)
|
||||
actual number of bits found and with *NEXT indicating where search
|
||||
stopped. */
|
||||
static int
|
||||
sbitset_reverse_list (src, list, num, next)
|
||||
abitset_reverse_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
@@ -189,8 +189,8 @@ sbitset_reverse_list (src, list, num, next)
|
||||
unsigned int bitcnt;
|
||||
bitset_bindex bitoff;
|
||||
bitset_word word;
|
||||
bitset_word *srcp = SBITSET_WORDS (src);
|
||||
bitset_bindex n_bits = SBITSET_N_BITS (src);
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_bindex n_bits = ABITSET_N_BITS (src);
|
||||
|
||||
rbitno = *next;
|
||||
|
||||
@@ -208,8 +208,7 @@ sbitset_reverse_list (src, list, num, next)
|
||||
bitcnt = bitno % BITSET_WORD_BITS;
|
||||
bitoff = windex * BITSET_WORD_BITS;
|
||||
|
||||
for (; windex != ~0U; windex--, bitoff -= BITSET_WORD_BITS,
|
||||
bitcnt = BITSET_WORD_BITS - 1)
|
||||
do
|
||||
{
|
||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||
for (; word; bitcnt--)
|
||||
@@ -225,7 +224,10 @@ sbitset_reverse_list (src, list, num, next)
|
||||
}
|
||||
word <<= 1;
|
||||
}
|
||||
bitoff -= BITSET_WORD_BITS;
|
||||
bitcnt = BITSET_WORD_BITS - 1;
|
||||
}
|
||||
while (windex--);
|
||||
|
||||
*next = n_bits - (bitoff + 1);
|
||||
return count;
|
||||
@@ -236,7 +238,7 @@ sbitset_reverse_list (src, list, num, next)
|
||||
*NEXT and store in array LIST. Return with actual number of bits
|
||||
found and with *NEXT indicating where search stopped. */
|
||||
static int
|
||||
sbitset_list (src, list, num, next)
|
||||
abitset_list (src, list, num, next)
|
||||
bitset src;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
@@ -247,7 +249,7 @@ sbitset_list (src, list, num, next)
|
||||
bitset_windex windex;
|
||||
bitset_bindex bitoff;
|
||||
bitset_windex size = src->b.csize;
|
||||
bitset_word *srcp = SBITSET_WORDS (src);
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word word;
|
||||
|
||||
bitno = *next;
|
||||
@@ -268,7 +270,7 @@ sbitset_list (src, list, num, next)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bitno >= SBITSET_N_BITS (src))
|
||||
if (bitno >= ABITSET_N_BITS (src))
|
||||
return 0;
|
||||
|
||||
windex = bitno / BITSET_WORD_BITS;
|
||||
@@ -340,25 +342,25 @@ sbitset_list (src, list, num, next)
|
||||
|
||||
/* Ensure that any unused bits within the last word are clear. */
|
||||
static inline void
|
||||
sbitset_unused_clear (dst)
|
||||
abitset_unused_clear (dst)
|
||||
bitset dst;
|
||||
{
|
||||
unsigned int last_bit;
|
||||
|
||||
last_bit = SBITSET_N_BITS (dst) % BITSET_WORD_BITS;
|
||||
last_bit = ABITSET_N_BITS (dst) % BITSET_WORD_BITS;
|
||||
if (last_bit)
|
||||
SBITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||
(bitset_word) ((1 << last_bit) - 1);
|
||||
ABITSET_WORDS (dst)[dst->b.csize - 1] &=
|
||||
((bitset_word) 1 << last_bit) - 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op1 (dst, op)
|
||||
abitset_op1 (dst, op)
|
||||
bitset dst;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
unsigned int i;
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
unsigned int bytes;
|
||||
|
||||
bytes = sizeof (bitset_word) * dst->b.csize;
|
||||
@@ -370,8 +372,8 @@ sbitset_op1 (dst, op)
|
||||
break;
|
||||
|
||||
case BITSET_OP_ONES:
|
||||
memset (dstp, ~0, bytes);
|
||||
sbitset_unused_clear (dst);
|
||||
memset (dstp, -1, bytes);
|
||||
abitset_unused_clear (dst);
|
||||
break;
|
||||
|
||||
case BITSET_OP_EMPTY_P:
|
||||
@@ -389,22 +391,16 @@ sbitset_op1 (dst, op)
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op2 (dst, src, op)
|
||||
abitset_op2 (dst, src, op)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
unsigned int i;
|
||||
bitset_word *srcp = SBITSET_WORDS (src);
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_word *srcp = ABITSET_WORDS (src);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
#ifdef ENABLE_CHECKING
|
||||
/* Check for compatiblity. */
|
||||
if (SBITSET_N_BITS (src) != SBITSET_N_BITS (dst))
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_COPY:
|
||||
@@ -416,7 +412,7 @@ sbitset_op2 (dst, src, op)
|
||||
case BITSET_OP_NOT:
|
||||
for (i = 0; i < size; i++)
|
||||
*dstp++ = ~(*srcp++);
|
||||
sbitset_unused_clear (dst);
|
||||
abitset_unused_clear (dst);
|
||||
break;
|
||||
|
||||
case BITSET_OP_EQUAL_P:
|
||||
@@ -446,7 +442,7 @@ sbitset_op2 (dst, src, op)
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op3 (dst, src1, src2, op)
|
||||
abitset_op3 (dst, src1, src2, op)
|
||||
bitset dst;
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
@@ -454,18 +450,11 @@ sbitset_op3 (dst, src1, src2, op)
|
||||
{
|
||||
unsigned int i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p = SBITSET_WORDS (src1);
|
||||
bitset_word *src2p = SBITSET_WORDS (src2);
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
#ifdef ENABLE_CHECKING
|
||||
/* Check for compatiblity. */
|
||||
if (SBITSET_N_BITS (src1) != SBITSET_N_BITS (dst)
|
||||
SBITSET_N_BITS (src2) != SBITSET_N_BITS (dst))
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_OR:
|
||||
@@ -529,7 +518,7 @@ sbitset_op3 (dst, src1, src2, op)
|
||||
|
||||
|
||||
static int
|
||||
sbitset_op4 (dst, src1, src2, src3, op)
|
||||
abitset_op4 (dst, src1, src2, src3, op)
|
||||
bitset dst;
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
@@ -538,20 +527,12 @@ sbitset_op4 (dst, src1, src2, src3, op)
|
||||
{
|
||||
unsigned int i;
|
||||
int changed = 0;
|
||||
bitset_word *src1p = SBITSET_WORDS (src1);
|
||||
bitset_word *src2p = SBITSET_WORDS (src2);
|
||||
bitset_word *src3p = SBITSET_WORDS (src3);
|
||||
bitset_word *dstp = SBITSET_WORDS (dst);
|
||||
bitset_word *src1p = ABITSET_WORDS (src1);
|
||||
bitset_word *src2p = ABITSET_WORDS (src2);
|
||||
bitset_word *src3p = ABITSET_WORDS (src3);
|
||||
bitset_word *dstp = ABITSET_WORDS (dst);
|
||||
bitset_windex size = dst->b.csize;
|
||||
|
||||
#ifdef ENABLE_CHECKING
|
||||
/* Check for compatiblity. */
|
||||
if (SBITSET_N_BITS (src1) != SBITSET_N_BITS (dst)
|
||||
|| SBITSET_N_BITS (src2) != SBITSET_N_BITS (dst)
|
||||
|| SBITSET_N_BITS (src3) != SBITSET_N_BITS (dst))
|
||||
abort ();
|
||||
#endif
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case BITSET_OP_OR_AND:
|
||||
@@ -602,71 +583,71 @@ sbitset_op4 (dst, src1, src2, src3, op)
|
||||
|
||||
|
||||
/* Vector of operations for single word bitsets. */
|
||||
struct bitset_ops_struct sbitset_small_ops = {
|
||||
sbitset_set,
|
||||
sbitset_reset,
|
||||
sbitset_test,
|
||||
sbitset_size,
|
||||
sbitset_op1,
|
||||
sbitset_op2,
|
||||
sbitset_op3,
|
||||
sbitset_op4,
|
||||
sbitset_small_list,
|
||||
sbitset_reverse_list,
|
||||
struct bitset_ops_struct abitset_small_ops = {
|
||||
abitset_set,
|
||||
abitset_reset,
|
||||
abitset_test,
|
||||
abitset_size,
|
||||
abitset_op1,
|
||||
abitset_op2,
|
||||
abitset_op3,
|
||||
abitset_op4,
|
||||
abitset_small_list,
|
||||
abitset_reverse_list,
|
||||
NULL,
|
||||
BITSET_ARRAY
|
||||
};
|
||||
|
||||
|
||||
/* Vector of operations for multiple word bitsets. */
|
||||
struct bitset_ops_struct sbitset_ops = {
|
||||
sbitset_set,
|
||||
sbitset_reset,
|
||||
sbitset_test,
|
||||
sbitset_size,
|
||||
sbitset_op1,
|
||||
sbitset_op2,
|
||||
sbitset_op3,
|
||||
sbitset_op4,
|
||||
sbitset_list,
|
||||
sbitset_reverse_list,
|
||||
struct bitset_ops_struct abitset_ops = {
|
||||
abitset_set,
|
||||
abitset_reset,
|
||||
abitset_test,
|
||||
abitset_size,
|
||||
abitset_op1,
|
||||
abitset_op2,
|
||||
abitset_op3,
|
||||
abitset_op4,
|
||||
abitset_list,
|
||||
abitset_reverse_list,
|
||||
NULL,
|
||||
BITSET_ARRAY
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
sbitset_bytes (n_bits)
|
||||
abitset_bytes (n_bits)
|
||||
bitset_bindex n_bits;
|
||||
{
|
||||
unsigned int bytes, size;
|
||||
|
||||
size = SBITSET_N_WORDS (n_bits);
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
bytes = size * sizeof (bitset_word);
|
||||
return sizeof (struct bitset_struct) + bytes - sizeof (bitset_word);
|
||||
}
|
||||
|
||||
|
||||
bitset
|
||||
sbitset_init (bset, n_bits)
|
||||
abitset_init (bset, n_bits)
|
||||
bitset bset;
|
||||
bitset_bindex n_bits;
|
||||
{
|
||||
bitset_windex size;
|
||||
|
||||
size = SBITSET_N_WORDS (n_bits);
|
||||
SBITSET_N_BITS (bset) = n_bits;
|
||||
size = ABITSET_N_WORDS (n_bits);
|
||||
ABITSET_N_BITS (bset) = n_bits;
|
||||
|
||||
/* Use optimized routines if bitset fits within a single word.
|
||||
There is probably little merit if using caching since
|
||||
the small bitset will always fit in the cache. */
|
||||
if (size == 1)
|
||||
bset->b.ops = &sbitset_small_ops;
|
||||
bset->b.ops = &abitset_small_ops;
|
||||
else
|
||||
bset->b.ops = &sbitset_ops;
|
||||
bset->b.ops = &abitset_ops;
|
||||
|
||||
bset->b.cindex = 0;
|
||||
bset->b.csize = size;
|
||||
bset->b.cdata = SBITSET_WORDS (bset);
|
||||
bset->b.cdata = ABITSET_WORDS (bset);
|
||||
return bset;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Functions to support sbitsets.
|
||||
/* Functions to support abitsets.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
|
||||
|
||||
@@ -16,13 +16,13 @@ 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. */
|
||||
|
||||
#ifndef _SBITSET_H
|
||||
#define _SBITSET_H
|
||||
#ifndef _ABITSET_H
|
||||
#define _ABITSET_H
|
||||
|
||||
#include "bbitset.h"
|
||||
|
||||
extern int sbitset_bytes PARAMS ((bitset_bindex));
|
||||
extern int abitset_bytes PARAMS ((bitset_bindex));
|
||||
|
||||
extern bitset sbitset_init PARAMS ((bitset, bitset_bindex));
|
||||
extern bitset abitset_init PARAMS ((bitset, bitset_bindex));
|
||||
|
||||
#endif
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
Copyright (C) 1990, 1998, 1999, 2001 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>
|
||||
Modified by Akim Demaille <[email protected]> */
|
||||
|
||||
#include "argmatch.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* When reporting an invalid argument, show nonprinting characters
|
||||
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
||||
literal_quoting_style. */
|
||||
#ifndef ARGMATCH_QUOTING_STYLE
|
||||
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
||||
#endif
|
||||
|
||||
/* The following test is to work around the gross typo in
|
||||
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
|
||||
is defined to 0, not 1. */
|
||||
#if !EXIT_FAILURE
|
||||
# undef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/* Non failing version of argmatch call this function after failing. */
|
||||
#ifndef ARGMATCH_DIE
|
||||
# define ARGMATCH_DIE exit (EXIT_FAILURE)
|
||||
#endif
|
||||
|
||||
#ifdef ARGMATCH_DIE_DECL
|
||||
ARGMATCH_DIE_DECL;
|
||||
#endif
|
||||
|
||||
static void
|
||||
__argmatch_die (void)
|
||||
{
|
||||
ARGMATCH_DIE;
|
||||
}
|
||||
|
||||
/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
||||
Default to __argmatch_die, but allow caller to change this at run-time. */
|
||||
argmatch_exit_fn argmatch_die = __argmatch_die;
|
||||
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array ARGLIST, return the index in ARGLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element).
|
||||
If SENSITIVE, comparison is case sensitive.
|
||||
|
||||
If VALLIST is none null, use it to resolve ambiguities limited to
|
||||
synonyms, i.e., for
|
||||
"yes", "yop" -> 0
|
||||
"no", "nope" -> 1
|
||||
"y" is a valid argument, for `0', and "n" for `1'. */
|
||||
|
||||
static int
|
||||
__argmatch_internal (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive)
|
||||
{
|
||||
int i; /* Temporary index in ARGLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
int matchind = -1; /* Index of first nonexact match. */
|
||||
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
|
||||
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; arglist[i]; i++)
|
||||
{
|
||||
if (case_sensitive
|
||||
? !strncmp (arglist[i], arg, arglen)
|
||||
: !strncasecmp (arglist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (arglist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
{
|
||||
/* Second nonexact match found. */
|
||||
if (vallist == NULL
|
||||
|| memcmp (vallist + valsize * matchind,
|
||||
vallist + valsize * i, valsize))
|
||||
{
|
||||
/* There is a real ambiguity, or we could not
|
||||
disambiguate. */
|
||||
ambiguous = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
return -2;
|
||||
else
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* argmatch - case sensitive version */
|
||||
int
|
||||
argmatch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
return __argmatch_internal (arg, arglist, vallist, valsize, 1);
|
||||
}
|
||||
|
||||
/* argcasematch - case insensitive version */
|
||||
int
|
||||
argcasematch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
return __argmatch_internal (arg, arglist, vallist, valsize, 0);
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
CONTEXT is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
argmatch_invalid (const char *context, const char *value, int problem)
|
||||
{
|
||||
char const *format = (problem == -1
|
||||
? _("invalid argument %s for %s")
|
||||
: _("ambiguous argument %s for %s"));
|
||||
|
||||
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
|
||||
quote_n (1, context));
|
||||
}
|
||||
|
||||
/* List the valid arguments for argmatch.
|
||||
ARGLIST is the same as in argmatch.
|
||||
VALLIST is a pointer to an array of values.
|
||||
VALSIZE is the size of the elements of VALLIST */
|
||||
void
|
||||
argmatch_valid (const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
const char *last_val = NULL;
|
||||
|
||||
/* We try to put synonyms on the same line. The assumption is that
|
||||
synonyms follow each other */
|
||||
fprintf (stderr, _("Valid arguments are:"));
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if ((i == 0)
|
||||
|| memcmp (last_val, vallist + valsize * i, valsize))
|
||||
{
|
||||
fprintf (stderr, "\n - `%s'", arglist[i]);
|
||||
last_val = vallist + valsize * i;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, ", `%s'", arglist[i]);
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
/* Never failing versions of the previous functions.
|
||||
|
||||
CONTEXT is the context for which argmatch is called (e.g.,
|
||||
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
|
||||
calls the (supposed never to return) function EXIT_FN. */
|
||||
|
||||
int
|
||||
__xargmatch_internal (const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive,
|
||||
argmatch_exit_fn exit_fn)
|
||||
{
|
||||
int res = __argmatch_internal (arg, arglist,
|
||||
vallist, valsize,
|
||||
case_sensitive);
|
||||
if (res >= 0)
|
||||
/* Success. */
|
||||
return res;
|
||||
|
||||
/* We failed. Explain why. */
|
||||
argmatch_invalid (context, arg, res);
|
||||
argmatch_valid (arglist, vallist, valsize);
|
||||
(*exit_fn) ();
|
||||
|
||||
return -1; /* To please the compilers. */
|
||||
}
|
||||
|
||||
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
|
||||
return the first corresponding argument in ARGLIST */
|
||||
const char *
|
||||
argmatch_to_argument (const char *value,
|
||||
const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if (!memcmp (value, vallist + valsize * i, valsize))
|
||||
return arglist[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
/*
|
||||
* Based on "getversion.c" by David MacKenzie <[email protected]>
|
||||
*/
|
||||
char *program_name;
|
||||
extern const char *getenv ();
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
none,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered
|
||||
};
|
||||
|
||||
/* Two tables describing arguments (keys) and their corresponding
|
||||
values */
|
||||
static const char *const backup_args[] =
|
||||
{
|
||||
"no", "none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_vals[] =
|
||||
{
|
||||
none, none, none,
|
||||
simple, simple,
|
||||
numbered_existing, numbered_existing,
|
||||
numbered, numbered
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, const char *const *argv)
|
||||
{
|
||||
const char *cp;
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
program_name = (char *) argv[0];
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ((cp = getenv ("VERSION_CONTROL")))
|
||||
backup_type = XARGCASEMATCH ("$VERSION_CONTROL", cp,
|
||||
backup_args, backup_vals);
|
||||
|
||||
if (argc == 2)
|
||||
backup_type = XARGCASEMATCH (program_name, argv[1],
|
||||
backup_args, backup_vals);
|
||||
|
||||
printf ("The version control is `%s'\n",
|
||||
ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
Copyright (C) 1990, 1998, 1999, 2001 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>
|
||||
Modified by Akim Demaille <[email protected]> */
|
||||
|
||||
#ifndef ARGMATCH_H_
|
||||
# define ARGMATCH_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifndef PARAMS
|
||||
# if PROTOTYPES || (defined (__STDC__) && __STDC__)
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif /* GCC. */
|
||||
# endif /* Not PARAMS. */
|
||||
|
||||
/* Assert there are as many real arguments as there are values
|
||||
(argument list ends with a NULL guard). There is no execution
|
||||
cost, since it will be statically evalauted to `assert (0)' or
|
||||
`assert (1)'. Unfortunately there is no -Wassert-0. */
|
||||
|
||||
# undef ARRAY_CARDINALITY
|
||||
# define ARRAY_CARDINALITY(Array) (sizeof ((Array)) / sizeof (*(Array)))
|
||||
|
||||
# define ARGMATCH_ASSERT(Arglist, Vallist) \
|
||||
assert (ARRAY_CARDINALITY ((Arglist)) == ARRAY_CARDINALITY ((Vallist)) + 1)
|
||||
|
||||
/* Return the index of the element of ARGLIST (NULL terminated) that
|
||||
matches with ARG. If VALLIST is not NULL, then use it to resolve
|
||||
false ambiguities (i.e., different matches of ARG but corresponding
|
||||
to the same values in VALLIST). */
|
||||
|
||||
int argmatch
|
||||
PARAMS ((const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
int argcasematch
|
||||
PARAMS ((const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH(Arg, Arglist, Vallist) \
|
||||
argmatch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
# define ARGCASEMATCH(Arg, Arglist, Vallist) \
|
||||
argcasematch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
/* xargmatch calls this function when it fails. This function should not
|
||||
return. By default, this is a function that calls ARGMATCH_DIE which
|
||||
in turn defaults to `exit (EXIT_FAILURE)'. */
|
||||
typedef void (*argmatch_exit_fn) PARAMS ((void));
|
||||
extern argmatch_exit_fn argmatch_die;
|
||||
|
||||
/* Report on stderr why argmatch failed. Report correct values. */
|
||||
|
||||
void argmatch_invalid
|
||||
PARAMS ((const char *context, const char *value, int problem));
|
||||
|
||||
/* Left for compatibility with the old name invalid_arg */
|
||||
|
||||
# define invalid_arg(Context, Value, Problem) \
|
||||
argmatch_invalid ((Context), (Value), (Problem))
|
||||
|
||||
|
||||
|
||||
/* Report on stderr the list of possible arguments. */
|
||||
|
||||
void argmatch_valid
|
||||
PARAMS ((const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH_VALID(Arglist, Vallist) \
|
||||
argmatch_valid (Arglist, (const char *) Vallist, sizeof (*(Vallist)))
|
||||
|
||||
|
||||
|
||||
/* Same as argmatch, but upon failure, reports a explanation on the
|
||||
failure, and exits using the function EXIT_FN. */
|
||||
|
||||
int __xargmatch_internal
|
||||
PARAMS ((const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive, argmatch_exit_fn exit_fn));
|
||||
|
||||
/* Programmer friendly interface to __xargmatch_internal. */
|
||||
|
||||
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
|
||||
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
|
||||
(const char *) (Vallist), \
|
||||
sizeof (*(Vallist)), \
|
||||
1, argmatch_die)])
|
||||
|
||||
# define XARGCASEMATCH(Context, Arg, Arglist, Vallist) \
|
||||
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
|
||||
(const char *) (Vallist), \
|
||||
sizeof (*(Vallist)), \
|
||||
0, argmatch_die)])
|
||||
|
||||
/* Convert a value into a corresponding argument. */
|
||||
|
||||
const char *argmatch_to_argument
|
||||
PARAMS ((char const *value, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
|
||||
argmatch_to_argument ((Value), (Arglist), \
|
||||
(const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
#endif /* ARGMATCH_H_ */
|
||||
+41
-33
@@ -19,53 +19,61 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
char *base_name PARAMS ((char const *name));
|
||||
#include "dirname.h"
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
If NAME is all slashes, be sure to return `/'. */
|
||||
|
||||
Return the address of the last file name component of NAME. If
|
||||
NAME has no file name components because it is all slashes, return
|
||||
NAME if it is empty, the address of its last slash otherwise. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
int all_slashes = 1;
|
||||
char const *base = name + FILESYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
|
||||
for (p = name; *p; p++)
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
base = p + 1;
|
||||
else
|
||||
all_slashes = 0;
|
||||
{
|
||||
/* Treat multiple adjacent slashes like a single slash. */
|
||||
do p++;
|
||||
while (ISSLASH (*p));
|
||||
|
||||
/* If the file name ends in slash, use the trailing slash as
|
||||
the basename if no non-slashes have been found. */
|
||||
if (! *p)
|
||||
{
|
||||
if (ISSLASH (*base))
|
||||
base = p - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* *P is a non-slash preceded by a slash. */
|
||||
base = p;
|
||||
}
|
||||
}
|
||||
|
||||
/* If NAME is all slashes, arrange to return `/'. */
|
||||
if (*base == '\0' && ISSLASH (*name) && all_slashes)
|
||||
--base;
|
||||
|
||||
/* Make sure the last byte is not a slash. */
|
||||
assert (all_slashes || !ISSLASH (*(p - 1)));
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
/* Return the length of of the basename NAME. Typically NAME is the
|
||||
value returned by base_name. Act like strlen (NAME), except omit
|
||||
redundant trailing slashes. */
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
+47
-92
@@ -19,43 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#ifndef _BBITSET_H
|
||||
#define _BBITSET_H
|
||||
|
||||
/* Bison modifications: BEGIN. */
|
||||
#define IN_BISON 1
|
||||
#if IN_BISON
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
# include <stdlib.h>
|
||||
|
||||
# define BITSET_STATS 1
|
||||
/* This file is the public interface to the bitset abstract data type.
|
||||
Only use the functions and macros defined in this file. */
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# endif
|
||||
# include "xalloc.h"
|
||||
#else /* ! IN_BISON */
|
||||
# include "libiberty.h"
|
||||
#endif
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
@@ -64,80 +28,78 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/* Currently we support three flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, faster).
|
||||
BITSET_LIST: Linked list of array of bits (variable size, least storage
|
||||
for large very sparse sets).
|
||||
BITSET_TABLE: Expandable table of pointers to array of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
*/
|
||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM};
|
||||
#define BITSET_TYPE_NAMES {"sbitset", "lbitset", "ebitset"}
|
||||
for large very sparse sets).
|
||||
BITSET_TABLE: Expandable table of pointers to array of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
|
||||
/* Non-zero to enable bitset caching. */
|
||||
#define BITSET_CACHE 1
|
||||
BITSET_STATS: Wrapper bitset for internal use only.
|
||||
*/
|
||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM,
|
||||
BITSET_STATS};
|
||||
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset"}
|
||||
|
||||
enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC};
|
||||
|
||||
/* Non-zero to use inline functions instead of macros. */
|
||||
#define BITSET_INLINE 0
|
||||
|
||||
/* Non-zero to enable bitset statistics gathering. */
|
||||
#define BITSET_STATS 1
|
||||
|
||||
/* Non-zero to enable bitset type checking. */
|
||||
#define BITSET_CHECK 1
|
||||
|
||||
/* Data type used to store a word of bits. */
|
||||
typedef unsigned long bitset_word;
|
||||
#define BITSET_WORD_BITS ((unsigned) CHAR_BIT * sizeof (bitset_word))
|
||||
#define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (bitset_word)))
|
||||
|
||||
/* Bit index. */
|
||||
typedef unsigned long bitset_bindex;
|
||||
/* Bit index. In theory we might need a type wider than size_t, but
|
||||
in practice we lose at most a factor of CHAR_BIT by going with
|
||||
size_t, and that is good enough. */
|
||||
typedef size_t bitset_bindex;
|
||||
|
||||
/* Word index. */
|
||||
typedef unsigned long bitset_windex;
|
||||
typedef size_t bitset_windex;
|
||||
|
||||
#define BITSET_INDEX_MAX ((1U << (BITSET_WORD_BITS - 1)))
|
||||
#define BITSET_INDEX_MAX ((bitset_word) 1 << (BITSET_WORD_BITS - 1))
|
||||
|
||||
#define BITSET_MSB (1U << (BITSET_WORD_BITS - 1))
|
||||
#define BITSET_MSB ((bitset_word) 1 << (BITSET_WORD_BITS - 1))
|
||||
|
||||
#define BITSET_LIST_SIZE 1024
|
||||
|
||||
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||
BITSET_OP_COPY, BITSET_OP_NOT,
|
||||
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||
BITSET_OP_COPY, BITSET_OP_NOT,
|
||||
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
|
||||
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
|
||||
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
||||
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
||||
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define BITSET_SIZE_(SRC) (SRC)->b.ops->size (SRC)
|
||||
#define BITSET_SIZE_(SRC) (SRC)->b.ops->size (SRC)
|
||||
|
||||
/* Return type of bitset SRC. */
|
||||
#define BITSET_TYPE_(DST) (DST)->b.ops->type
|
||||
#define BITSET_TYPE_(DST) (DST)->b.ops->type
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
#define BITSET_SET_(DST, BITNO) (DST)->b.ops->set (DST, BITNO)
|
||||
#define BITSET_SET_(DST, BITNO) (DST)->b.ops->set (DST, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
#define BITSET_RESET_(DST, BITNO) (DST)->b.ops->reset (DST, BITNO)
|
||||
#define BITSET_RESET_(DST, BITNO) (DST)->b.ops->reset (DST, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define BITSET_TEST_(SRC, BITNO) (SRC)->b.ops->test (SRC, BITNO)
|
||||
#define BITSET_TEST_(SRC, BITNO) (SRC)->b.ops->test (SRC, BITNO)
|
||||
|
||||
/* Free bitset SRC. */
|
||||
#define BITSET_FREE_(SRC)\
|
||||
((SRC)->b.ops->free ? (SRC)->b.ops->free (SRC) :(void)0)
|
||||
|
||||
/* Perform operation OP on DST. */
|
||||
#define BITSET_OP1_(DST, OP) (DST)->b.ops->op1 (DST, OP)
|
||||
#define BITSET_OP1_(DST, OP) (DST)->b.ops->op1 (DST, OP)
|
||||
|
||||
/* Perform operation OP on SRC and store in DST. */
|
||||
#define BITSET_OP2_(DST, SRC, OP) (DST)->b.ops->op2 (DST, SRC, OP)
|
||||
#define BITSET_OP2_(DST, SRC, OP) (DST)->b.ops->op2 (DST, SRC, OP)
|
||||
|
||||
/* DST = SRC1 OP SRC2. */
|
||||
#define BITSET_OP3_(DST, SRC1, SRC2, OP) \
|
||||
(DST)->b.ops->op3 (DST, SRC1, SRC2, OP)
|
||||
(DST)->b.ops->op3 (DST, SRC1, SRC2, OP)
|
||||
|
||||
/* DST = (SRC1 OP1 SRC2) OP2 SRC3. */
|
||||
#define BITSET_OP4_(DST, SRC1, SRC2, SRC3, OP) \
|
||||
(DST)->b.ops->op4 (DST, SRC1, SRC2, SRC3, OP)
|
||||
(DST)->b.ops->op4 (DST, SRC1, SRC2, SRC3, OP)
|
||||
|
||||
/* DST = 0. */
|
||||
#define BITSET_ZERO_(DST) BITSET_OP1_ (DST, BITSET_OP_ZERO);
|
||||
@@ -149,63 +111,63 @@ enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||
#define BITSET_EMPTY_P_(SRC) BITSET_OP1_ (SRC, BITSET_OP_EMPTY_P);
|
||||
|
||||
/* Return DST == SRC. */
|
||||
#define BITSET_EQUAL_P_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_EQUAL_P)
|
||||
#define BITSET_EQUAL_P_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_EQUAL_P)
|
||||
|
||||
/* Return DST == DST | SRC. */
|
||||
#define BITSET_SUBSET_P_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_SUBSET_P)
|
||||
#define BITSET_SUBSET_P_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_SUBSET_P)
|
||||
|
||||
/* Return DST & SRC == 0. */
|
||||
#define BITSET_DISJOINT_P_(DST, SRC)\
|
||||
BITSET_OP2_ (DST, SRC, BITSET_OP_DISJOINT_P)
|
||||
BITSET_OP2_ (DST, SRC, BITSET_OP_DISJOINT_P)
|
||||
|
||||
/* DST = SRC. */
|
||||
#define BITSET_COPY_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_COPY)
|
||||
#define BITSET_COPY_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_COPY)
|
||||
|
||||
/* DST = ~SRC. */
|
||||
#define BITSET_NOT_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_NOT)
|
||||
#define BITSET_NOT_(DST, SRC) BITSET_OP2_ (DST, SRC, BITSET_OP_NOT)
|
||||
|
||||
/* DST = SRC1 | SRC2. */
|
||||
#define BITSET_OR_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2,\
|
||||
BITSET_OP_OR)
|
||||
BITSET_OP_OR)
|
||||
|
||||
/* DST = SRC1 ^ SRC2. */
|
||||
#define BITSET_XOR_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2,\
|
||||
BITSET_OP_XOR)
|
||||
BITSET_OP_XOR)
|
||||
|
||||
/* DST = SRC1 & SRC2. */
|
||||
#define BITSET_AND_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2, \
|
||||
BITSET_OP_AND)
|
||||
BITSET_OP_AND)
|
||||
|
||||
/* DST = SRC1 & ~SRC2. */
|
||||
#define BITSET_ANDN_(DST, SRC1, SRC2) BITSET_OP3_ (DST, SRC1, SRC2, \
|
||||
BITSET_OP_ANDN)
|
||||
BITSET_OP_ANDN)
|
||||
|
||||
/* DST = (SRC1 & SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & SRC2) | SRC3. */
|
||||
#define BITSET_AND_OR_(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_AND_OR)
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_AND_OR)
|
||||
|
||||
/* DST = (SRC1 | SRC2) & SRC3. Return non-zero if
|
||||
DST != (SRC1 | SRC2) & SRC3. */
|
||||
#define BITSET_OR_AND_(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_OR_AND)
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_OR_AND)
|
||||
|
||||
/* DST = (SRC1 & ~SRC2) | SRC3. Return non-zero if
|
||||
DST != (SRC1 & ~SRC2) | SRC3. */
|
||||
#define BITSET_ANDN_OR_(DST, SRC1, SRC2, SRC3)\
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_ANDN_OR)
|
||||
BITSET_OP4_ (DST, SRC1, SRC2, SRC3, BITSET_OP_ANDN_OR)
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#define BITSET_LIST_(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->b.ops->list (BSET, LIST, NUM, NEXT)
|
||||
(BSET)->b.ops->list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define BITSET_REVERSE_LIST_(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->b.ops->reverse_list (BSET, LIST, NUM, NEXT)
|
||||
(BSET)->b.ops->reverse_list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
|
||||
struct bbitset_struct
|
||||
@@ -250,7 +212,6 @@ struct bitset_ops_struct
|
||||
|
||||
#define BITSET_COMPATIBLE_(BSET1, BSET2) ((BSET1)->b.ops == (BSET2)->b.ops)
|
||||
|
||||
#if BITSET_CHECK
|
||||
#define BITSET_CHECK2_(DST, SRC) \
|
||||
if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();
|
||||
|
||||
@@ -261,15 +222,9 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) \
|
||||
#define BITSET_CHECK4_(DST, SRC1, SRC2, SRC3) \
|
||||
if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
|
||||
|| !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();
|
||||
#else
|
||||
#define BITSET_CHECK2_(DST, SRC)
|
||||
|
||||
#define BITSET_CHECK3_(DST, SRC1, SRC2)
|
||||
|
||||
#define BITSET_CHECK4_(DST, SRC1, SRC2, SRC3)
|
||||
#endif
|
||||
|
||||
extern int bitset_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
extern int bitset_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
enum bitset_ops op));
|
||||
|
||||
#endif /* _BBITSET_H */
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/* Internal bitset definitions.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
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. */
|
||||
|
||||
#ifndef _BITSET_INT_H
|
||||
#define _BITSET_INT_H
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Currently we support three flavours of bitsets:
|
||||
BITSET_ARRAY: Array of bits (fixed size, faster).
|
||||
BITSET_LIST: Linked list of array of bits (variable size, least storage
|
||||
for large very sparse sets).
|
||||
BITSET_TABLE: Expandable table of pointers to array of bits
|
||||
(variable size, less storage for large sparse sets).
|
||||
*/
|
||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM};
|
||||
#define BITSET__TYPE_NAMES {"sbitset", "lbitset", "ebitset"}
|
||||
|
||||
/* Non-zero to enable bitset caching. */
|
||||
#define BITSET_CACHE 1
|
||||
|
||||
/* Non-zero to use inline functions instead of macros. */
|
||||
#define BITSET_INLINE 0
|
||||
|
||||
/* Non-zero to enable bitset statistics gathering. */
|
||||
#define BITSET_STATS 1
|
||||
|
||||
/* Non-zero to enable bitset type checking. */
|
||||
#define BITSET_CHECK 0
|
||||
|
||||
typedef unsigned long bitset_word;
|
||||
#define BITSET_WORD_BITS ((unsigned) CHAR_BIT * sizeof (bitset_word))
|
||||
|
||||
/* Bit index. */
|
||||
typedef unsigned long bitset_bindex;
|
||||
|
||||
/* Word index. */
|
||||
typedef unsigned long bitset_windex;
|
||||
|
||||
#define BITSET_INDEX_MAX ((1U << (BITSET_WORD_BITS - 1)))
|
||||
|
||||
#define BITSET_MSB (1U << (BITSET_WORD_BITS - 1))
|
||||
|
||||
#define BITSET_LIST_SIZE 1024
|
||||
|
||||
enum bitset_ops {BITSET_ZERO, BITSET_ONES, BITSET_EMPTY_P,
|
||||
BITSET_COPY, BITSET_EQUAL_P, BITSET_SUBSET_P, BITSET_NOT,
|
||||
BITSET_AND, BITSET_OR, BITSET_XOR, BITSET_ANDN, BITSET_ORN,
|
||||
BITSET_OR_AND, BITSET_AND_OR, BITSET_ANDN_OR};
|
||||
|
||||
/* Return size in bits of bitset SRC. */
|
||||
#define BITSET__SIZE(SRC) (SRC)->ops->size (SRC)
|
||||
|
||||
/* Set bit BITNO in bitset DST. */
|
||||
#define BITSET__SET(DST, BITNO) (DST)->ops->set (DST, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset DST. */
|
||||
#define BITSET__RESET(DST, BITNO) (DST)->ops->reset (DST, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define BITSET__TEST(SRC, BITNO) (SRC)->ops->test (SRC, BITNO)
|
||||
|
||||
/* Free bitset SRC. */
|
||||
#define BITSET__FREE(SRC) ((SRC)->ops->free) (SRC)
|
||||
|
||||
/* Perform operation OP on DST. */
|
||||
#define BITSET__OP1(DST, OP) (DST)->ops->op1 (DST, OP)
|
||||
|
||||
/* Perform operation OP on SRC and store in DST. */
|
||||
#define BITSET__OP2(DST, SRC, OP) (DST)->ops->op2 (DST, SRC, OP)
|
||||
|
||||
/* DST = SRC1 OP SRC2. */
|
||||
#define BITSET__OP3(DST, SRC1, SRC2, OP) \
|
||||
(DST)->ops->op3 (DST, SRC1, SRC2, OP)
|
||||
|
||||
/* DST = (SRC1 OP1 SRC2) OP2 SRC3. */
|
||||
#define BITSET__OP4(DST, SRC1, SRC2, SRC3, OP) \
|
||||
(DST)->ops->op4 (DST, SRC1, SRC2, SRC3, OP)
|
||||
|
||||
/* DST = SRC. */
|
||||
#define BITSET__COPY(DST, SRC) BITSET__OP2 (DST, SRC, BITSET_COPY)
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#define BITSET__LIST(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->ops->list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define BITSET__REVERSE_LIST(BSET, LIST, NUM, NEXT) \
|
||||
(BSET)->ops->reverse_list (BSET, LIST, NUM, NEXT)
|
||||
|
||||
#endif /* _BITSET_INT_H */
|
||||
+39
-366
@@ -22,105 +22,14 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "bitset.h"
|
||||
#include "sbitset.h"
|
||||
#include "abitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "bitset_stats.h"
|
||||
#include "obstack.h"
|
||||
|
||||
static void bitset_print PARAMS ((FILE *, bitset, int));
|
||||
|
||||
#if BITSET_STATS
|
||||
#define BITSET_STATS_FILE "bitset.dat"
|
||||
|
||||
#define BITSET_LOG_COUNT_BINS 10
|
||||
#define BITSET_LOG_SIZE_BINS 16
|
||||
#define BITSET_DENSITY_BINS 20
|
||||
|
||||
struct bitset_type_stats_struct
|
||||
{
|
||||
unsigned int xmallocs;
|
||||
unsigned int xfrees;
|
||||
unsigned int oballocs;
|
||||
unsigned int obfrees;
|
||||
unsigned int lists;
|
||||
unsigned int list_counts[BITSET_LOG_COUNT_BINS];
|
||||
unsigned int list_sizes[BITSET_LOG_SIZE_BINS];
|
||||
unsigned int list_density[BITSET_DENSITY_BINS];
|
||||
};
|
||||
|
||||
struct bitset_stats_struct
|
||||
{
|
||||
unsigned int runs;
|
||||
struct bitset_type_stats_struct types[BITSET_TYPE_NUM];
|
||||
};
|
||||
|
||||
struct bitset_stats_struct bitset_stats_data;
|
||||
struct bitset_stats_struct *bitset_stats;
|
||||
|
||||
static void bitset_percent_histogram_print PARAMS ((FILE *, const char *,
|
||||
const char *,
|
||||
unsigned int,
|
||||
unsigned int *));
|
||||
static void bitset_log_histogram_print PARAMS ((FILE *, const char *,
|
||||
const char *,
|
||||
unsigned int,
|
||||
unsigned int *));
|
||||
static void bitset_stats_print_1
|
||||
PARAMS ((FILE *, const char *, struct bitset_type_stats_struct *));
|
||||
static void bitset_stats_print PARAMS ((FILE *, int));
|
||||
static void bitset_stats_read PARAMS ((void));
|
||||
static void bitset_stats_write PARAMS ((void));
|
||||
|
||||
#define BITSET_STATS_XMALLOCS_INC(TYPE) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[(TYPE)].xmallocs++
|
||||
|
||||
#define BITSET_STATS_XFREES_INC(BSET) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[BITSET_TYPE_ (BSET)].xfrees++
|
||||
|
||||
#define BITSET_STATS_OBALLOCS_INC(TYPE) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[(TYPE)].oballocs++
|
||||
|
||||
#define BITSET_STATS_OBFREES_INC(BSET) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[BITSET_TYPE_ (BSET)].obfrees++
|
||||
|
||||
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[BITSET_TYPE_ (BSET)].lists++
|
||||
|
||||
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
|
||||
|
||||
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
|
||||
|
||||
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
||||
if (bitset_stats) \
|
||||
bitset_stats->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
||||
|
||||
#else
|
||||
#define BITSET_STATS_XMALLOCS_INC(TYPE)
|
||||
|
||||
#define BITSET_STATS_XFREES_INC(BSET)
|
||||
|
||||
#define BITSET_STATS_OBALLOCS_INC(TYPE)
|
||||
|
||||
#define BITSET_STATS_OBFREES_INC(BSET)
|
||||
|
||||
#define BITSET_STATS_LISTS_INC(BSET)
|
||||
|
||||
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I)
|
||||
|
||||
#define BITSET_STATS_LIST_SIZES_INC(BSET, I)
|
||||
|
||||
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I)
|
||||
#endif /* BITSET_STATS */
|
||||
|
||||
|
||||
/* Return number of bytes required to create a N_BIT bitset
|
||||
of TYPE. The bitset may grow to require more bytes than this. */
|
||||
@@ -131,10 +40,13 @@ bitset_bytes (type, n_bits)
|
||||
{
|
||||
unsigned int bytes;
|
||||
|
||||
if (bitset_stats_enabled)
|
||||
return bitset_stats_bytes ();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BITSET_ARRAY:
|
||||
bytes = sbitset_bytes (n_bits);
|
||||
bytes = abitset_bytes (n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_LIST:
|
||||
@@ -160,10 +72,13 @@ bitset_init (bset, n_bits, type)
|
||||
bitset_bindex n_bits;
|
||||
enum bitset_type type;
|
||||
{
|
||||
if (bitset_stats_enabled)
|
||||
return bitset_stats_init (bset, n_bits, type);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BITSET_ARRAY:
|
||||
return sbitset_init (bset, n_bits);
|
||||
return abitset_init (bset, n_bits);
|
||||
|
||||
case BITSET_LIST:
|
||||
return lbitset_init (bset, n_bits);
|
||||
@@ -187,7 +102,6 @@ bitset_type_choose (n_bits, attr)
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
#if BITSET_CHECK
|
||||
/* Check attributes. */
|
||||
if (attr & BITSET_FIXED && attr & BITSET_VARIABLE)
|
||||
abort ();
|
||||
@@ -196,7 +110,6 @@ bitset_type_choose (n_bits, attr)
|
||||
|
||||
/* Note that sometimes we will be asked for a zero length
|
||||
fixed size bitset. */
|
||||
#endif
|
||||
|
||||
/* Choose the type of bitset. */
|
||||
|
||||
@@ -222,14 +135,12 @@ bitset_alloc (n_bits, type)
|
||||
unsigned int bytes;
|
||||
bitset bset;
|
||||
|
||||
BITSET_STATS_XMALLOCS_INC (type);
|
||||
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bset = (bitset) xcalloc (1, bytes);
|
||||
|
||||
/* The cache is disabled until some elements are allocated. If we
|
||||
have variable length arrays, then we may need to allocate dummy
|
||||
have variable length arrays, then we may need to allocate a dummy
|
||||
element. */
|
||||
|
||||
return bitset_init (bset, n_bits, type);
|
||||
@@ -246,8 +157,6 @@ bitset_obstack_alloc (bobstack, n_bits, type)
|
||||
unsigned int bytes;
|
||||
bitset bset;
|
||||
|
||||
BITSET_STATS_OBALLOCS_INC (type);
|
||||
|
||||
bytes = bitset_bytes (type, n_bits);
|
||||
|
||||
bset = obstack_alloc (bobstack, bytes);
|
||||
@@ -277,8 +186,6 @@ void
|
||||
bitset_free (bset)
|
||||
bitset bset;
|
||||
{
|
||||
BITSET_STATS_XFREES_INC (bset);
|
||||
|
||||
BITSET_FREE_ (bset);
|
||||
free (bset);
|
||||
}
|
||||
@@ -289,12 +196,25 @@ void
|
||||
bitset_obstack_free (bset)
|
||||
bitset bset;
|
||||
{
|
||||
BITSET_STATS_OBFREES_INC (bset);
|
||||
|
||||
BITSET_FREE_ (bset);
|
||||
}
|
||||
|
||||
|
||||
/* Return bitset type. */
|
||||
enum bitset_type
|
||||
bitset_type_get (bset)
|
||||
bitset bset;
|
||||
{
|
||||
enum bitset_type type;
|
||||
|
||||
type = BITSET_TYPE_ (bset);
|
||||
if (type != BITSET_STATS)
|
||||
return type;
|
||||
|
||||
return bitset_stats_type_get (bset);
|
||||
}
|
||||
|
||||
|
||||
/* Find next bit set in SRC starting from and including BITNO.
|
||||
Return -1 if SRC empty. */
|
||||
int
|
||||
@@ -389,12 +309,13 @@ bitset_print (file, bset, verbose)
|
||||
int verbose;
|
||||
{
|
||||
unsigned int i, pos;
|
||||
bitset_iterator iter;
|
||||
|
||||
if (verbose)
|
||||
fprintf (file, "n_bits = %d, set = {", bitset_size (bset));
|
||||
|
||||
pos = 30;
|
||||
BITSET_EXECUTE (bset, 0, i,
|
||||
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||
{
|
||||
if (pos > 70)
|
||||
{
|
||||
@@ -404,7 +325,7 @@ bitset_print (file, bset, verbose)
|
||||
|
||||
fprintf (file, "%d ", i);
|
||||
pos += 1 + (i >= 10) + (i >= 100);
|
||||
});
|
||||
};
|
||||
|
||||
if (verbose)
|
||||
fprintf (file, "}\n");
|
||||
@@ -418,6 +339,7 @@ bitset_copy (dst, src)
|
||||
bitset src;
|
||||
{
|
||||
unsigned int i;
|
||||
bitset_iterator iter;
|
||||
|
||||
if (BITSET_COMPATIBLE_ (dst, src))
|
||||
return BITSET_COPY_ (dst, src);
|
||||
@@ -425,10 +347,10 @@ bitset_copy (dst, src)
|
||||
/* Convert bitset types. We assume that the DST bitset
|
||||
is large enough to hold the SRC bitset. */
|
||||
bitset_zero (dst);
|
||||
BITSET_EXECUTE (src, 0, i,
|
||||
BITSET_FOR_EACH (iter, src, i, 0)
|
||||
{
|
||||
bitset_set (dst, i);
|
||||
});
|
||||
};
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -453,6 +375,10 @@ bitset_count (src)
|
||||
int num;
|
||||
int count;
|
||||
|
||||
/* This could be greatly sped up by adding a count method for each
|
||||
bitset implementation that uses a direct technique (based on
|
||||
masks) for counting the number of bits set in a word. */
|
||||
|
||||
next = 0;
|
||||
for (count = 0; (num = bitset_list (src, list, BITSET_LIST_SIZE, &next));
|
||||
count += num)
|
||||
@@ -495,7 +421,6 @@ bitset_subset_p (dst, src)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_SUBSET_P_ (dst, src);
|
||||
}
|
||||
|
||||
@@ -506,7 +431,6 @@ bitset_equal_p (dst, src)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_EQUAL_P_ (dst, src);
|
||||
}
|
||||
|
||||
@@ -517,7 +441,6 @@ bitset_disjoint_p (dst, src)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_DISJOINT_P_ (dst, src);
|
||||
}
|
||||
|
||||
@@ -528,7 +451,6 @@ bitset_not (dst, src)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_NOT_ (dst, src);
|
||||
}
|
||||
|
||||
@@ -540,7 +462,6 @@ bitset_or (dst, src1, src2)
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_OR_ (dst, src1, src2);
|
||||
}
|
||||
|
||||
@@ -552,7 +473,6 @@ bitset_and (dst, src1, src2)
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_AND_ (dst, src1, src2);
|
||||
}
|
||||
|
||||
@@ -564,7 +484,6 @@ bitset_xor (dst, src1, src2)
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_XOR_ (dst, src1, src2);
|
||||
}
|
||||
|
||||
@@ -576,11 +495,12 @@ bitset_andn (dst, src1, src2)
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_ANDN_ (dst, src1, src2);
|
||||
}
|
||||
|
||||
|
||||
/* This is a fallback for implementations that do not support
|
||||
four operand operations. */
|
||||
int
|
||||
bitset_op4 (dst, src1, src2, src3, op)
|
||||
bitset dst;
|
||||
@@ -593,7 +513,7 @@ bitset_op4 (dst, src1, src2, src3, op)
|
||||
bitset tmp;
|
||||
|
||||
/* Create temporary bitset. */
|
||||
tmp = bitset_alloc (0, BITSET_TYPE_ (dst));
|
||||
tmp = bitset_alloc (0, bitset_type_get (dst));
|
||||
|
||||
switch (op)
|
||||
{
|
||||
@@ -630,7 +550,6 @@ bitset_or_and (dst, src1, src2, src3)
|
||||
bitset src2;
|
||||
bitset src3;
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
return BITSET_OR_AND_ (dst, src1, src2, src3);
|
||||
}
|
||||
|
||||
@@ -644,7 +563,6 @@ bitset_and_or (dst, src1, src2, src3)
|
||||
bitset src2;
|
||||
bitset src3;
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
return BITSET_AND_OR_ (dst, src1, src2, src3);
|
||||
}
|
||||
|
||||
@@ -658,7 +576,6 @@ bitset_andn_or (dst, src1, src2, src3)
|
||||
bitset src2;
|
||||
bitset src3;
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
return BITSET_ANDN_OR_ (dst, src1, src2, src3);
|
||||
}
|
||||
|
||||
@@ -690,247 +607,3 @@ bitset_release_memory ()
|
||||
lbitset_release_memory ();
|
||||
ebitset_release_memory ();
|
||||
}
|
||||
|
||||
|
||||
#if BITSET_STATS
|
||||
int
|
||||
bitset_list (bset, list, num, next)
|
||||
bitset bset;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
{
|
||||
bitset_bindex count;
|
||||
|
||||
count = BITSET_LIST_ (bset, list, num, next);
|
||||
|
||||
if (bitset_stats)
|
||||
{
|
||||
bitset_bindex tmp;
|
||||
bitset_bindex size;
|
||||
bitset_bindex i;
|
||||
enum bitset_type type;
|
||||
|
||||
type = BITSET_TYPE_ (bset);
|
||||
BITSET_STATS_LISTS_INC (bset);
|
||||
|
||||
/* Log histogram of number of set bits. */
|
||||
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_COUNT_BINS)
|
||||
i = BITSET_LOG_COUNT_BINS - 1;
|
||||
BITSET_STATS_LIST_COUNTS_INC (bset, i);
|
||||
|
||||
/* Log histogram of number of bits in set. */
|
||||
size = bitset_size (bset);
|
||||
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_SIZE_BINS)
|
||||
i = BITSET_LOG_SIZE_BINS - 1;
|
||||
BITSET_STATS_LIST_SIZES_INC (bset, i);
|
||||
|
||||
/* Histogram of fraction of bits set. */
|
||||
i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
|
||||
if (i >= BITSET_DENSITY_BINS)
|
||||
i = BITSET_DENSITY_BINS - 1;
|
||||
BITSET_STATS_LIST_DENSITY_INC (bset, i);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* Print a percentage histogram with message MSG to FILE. */
|
||||
static void
|
||||
bitset_percent_histogram_print (file, name, msg, n_bins, bins)
|
||||
FILE *file;
|
||||
const char *name;
|
||||
const char *msg;
|
||||
unsigned int n_bins;
|
||||
unsigned int *bins;
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int total;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < n_bins; i++)
|
||||
fprintf (file, "%.0f-%.0f%%\t%8d (%5.1f%%)\n",
|
||||
i * 100.0 / n_bins,
|
||||
(i + 1) * 100.0 / n_bins, bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
|
||||
|
||||
/* Print a log histogram with message MSG to FILE. */
|
||||
static void
|
||||
bitset_log_histogram_print (file, name, msg, n_bins, bins)
|
||||
FILE *file;
|
||||
const char *name;
|
||||
const char *msg;
|
||||
unsigned int n_bins;
|
||||
unsigned int *bins;
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int total;
|
||||
unsigned int max_width;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
/* 2 * ceil (log10(2) * (N - 1)) + 1 */
|
||||
max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < 2; i++)
|
||||
fprintf (file, "%*d\t%8d (%5.1f%%)\n",
|
||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||
|
||||
/* Perhaps we should bail out once the histogram goes to zero. */
|
||||
for (; i < n_bins; i++)
|
||||
fprintf (file, "%*d-%d\t%8d (%5.1f%%)\n",
|
||||
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||
1 << (i - 1), (1 << i) - 1, bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
|
||||
|
||||
/* Print bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print_1 (file, name, stats)
|
||||
FILE *file;
|
||||
const char *name;
|
||||
struct bitset_type_stats_struct *stats;
|
||||
{
|
||||
if (!stats)
|
||||
return;
|
||||
|
||||
fprintf (file, "%d %ss xmalloced, %d freed.\n",
|
||||
stats->xmallocs, name, stats->xfrees);
|
||||
fprintf (file, "%d %ss oballoced, %d freed.\n",
|
||||
stats->oballocs, name, stats->obfrees);
|
||||
|
||||
fprintf (file, "%d bitset_lists\n", stats->lists);
|
||||
|
||||
bitset_log_histogram_print (file, name, "count log histogram\n",
|
||||
BITSET_LOG_COUNT_BINS, stats->list_counts);
|
||||
|
||||
bitset_log_histogram_print (file, name, "size log histogram\n",
|
||||
BITSET_LOG_SIZE_BINS, stats->list_sizes);
|
||||
|
||||
bitset_percent_histogram_print (file, name, "density histogram\n",
|
||||
BITSET_DENSITY_BINS, stats->list_density);
|
||||
}
|
||||
|
||||
|
||||
/* Print all bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print (file, verbose)
|
||||
FILE *file;
|
||||
int verbose ATTRIBUTE_UNUSED;
|
||||
{
|
||||
int i;
|
||||
static const char *names[] = BITSET_TYPE_NAMES;
|
||||
|
||||
if (!bitset_stats)
|
||||
return;
|
||||
|
||||
fprintf (file, "Bitset statistics:\n\n");
|
||||
|
||||
if (bitset_stats->runs > 1)
|
||||
fprintf (file, "Accumulated runs = %d\n", bitset_stats->runs);
|
||||
|
||||
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||
bitset_stats_print_1 (file, names[i], &bitset_stats->types[i]);
|
||||
}
|
||||
#endif /* BITSET_STATS */
|
||||
|
||||
|
||||
/* Initialise bitset statistics logging. */
|
||||
void
|
||||
bitset_stats_init ()
|
||||
{
|
||||
#if BITSET_STATS
|
||||
bitset_stats = &bitset_stats_data;
|
||||
bitset_stats_read ();
|
||||
#endif /* BITSET_STATS */
|
||||
}
|
||||
|
||||
|
||||
/* Read bitset statistics file. */
|
||||
static void
|
||||
bitset_stats_read ()
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats)
|
||||
return;
|
||||
|
||||
file = fopen (BITSET_STATS_FILE, "r");
|
||||
if (file)
|
||||
{
|
||||
if (fread (&bitset_stats_data, sizeof (bitset_stats_data),
|
||||
1, file) != 1)
|
||||
{
|
||||
if (ferror (file))
|
||||
perror ("Could not read stats file.");
|
||||
else
|
||||
fprintf (stderr, "Bad stats file size.\n");
|
||||
}
|
||||
fclose (file);
|
||||
}
|
||||
bitset_stats_data.runs++;
|
||||
}
|
||||
|
||||
|
||||
/* Write bitset statistics file. */
|
||||
static void
|
||||
bitset_stats_write ()
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats)
|
||||
return;
|
||||
|
||||
file = fopen (BITSET_STATS_FILE, "w");
|
||||
if (file)
|
||||
{
|
||||
if (fwrite (&bitset_stats_data, sizeof (bitset_stats_data),
|
||||
1, file) != 1)
|
||||
perror ("Could not write stats file.");
|
||||
fclose (file);
|
||||
}
|
||||
else
|
||||
perror ("Could not open stats file for writing.");
|
||||
}
|
||||
|
||||
|
||||
/* Dump bitset statistics to FILE. */
|
||||
void
|
||||
bitset_stats_dump (file)
|
||||
FILE *file;
|
||||
{
|
||||
#if BITSET_STATS
|
||||
bitset_stats_print (file, 0);
|
||||
bitset_stats_write ();
|
||||
#endif /* BITSET_STATS */
|
||||
}
|
||||
|
||||
|
||||
/* Function to be called from debugger to print bitset stats. */
|
||||
void
|
||||
debug_bitset_stats (void)
|
||||
{
|
||||
#if BITSET_STATS
|
||||
bitset_stats_print (stderr, 1);
|
||||
#endif /* BITSET_STATS */
|
||||
}
|
||||
|
||||
+66
-78
@@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _BITSET_H
|
||||
#define _BITSET_H
|
||||
#define _BITSET_H
|
||||
|
||||
/* This file is the public interface to the bitset abstract data type.
|
||||
Only use the functions and macros defined in this file. */
|
||||
@@ -44,6 +44,18 @@ struct bitset_struct
|
||||
struct bbitset_struct b;
|
||||
};
|
||||
|
||||
|
||||
/* The contents of this structure should be considered private.
|
||||
It is used for iterating over set bits. */
|
||||
typedef struct
|
||||
{
|
||||
bitset_bindex list[BITSET_LIST_SIZE];
|
||||
bitset_bindex next;
|
||||
int num;
|
||||
int i;
|
||||
} bitset_iterator;
|
||||
|
||||
|
||||
/* Return bytes required for bitset of desired type and size. */
|
||||
extern int bitset_bytes PARAMS ((enum bitset_type, bitset_bindex));
|
||||
|
||||
@@ -78,7 +90,10 @@ extern int bitset_size PARAMS ((bitset));
|
||||
/* Return number of bits set in bitset SRC. */
|
||||
extern int bitset_count PARAMS ((bitset));
|
||||
|
||||
#if BITSET_CACHE && BITSET_INLINE
|
||||
/* Return bitset type. */
|
||||
extern enum bitset_type bitset_type_get PARAMS ((bitset));
|
||||
|
||||
#if BITSET_INLINE
|
||||
static inline void bitset_set PARAMS ((bitset, bitset_bindex));
|
||||
static inline void bitset_reset PARAMS ((bitset, bitset_bindex));
|
||||
static inline int bitset_test PARAMS ((bitset, bitset_bindex));
|
||||
@@ -90,9 +105,9 @@ static inline void bitset_set (bset, bitno)
|
||||
{
|
||||
bitset_windex index = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = index - bset->b.cindex;
|
||||
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
bset->b.cdata[offset] |= (1 << (bitno % BITSET_WORD_BITS));
|
||||
bset->b.cdata[offset] |= ((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
else
|
||||
BITSET_SET_ (bset, bitno);
|
||||
}
|
||||
@@ -105,9 +120,9 @@ static inline void bitset_reset (bset, bitno)
|
||||
{
|
||||
bitset_windex index = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = index - bset->b.cindex;
|
||||
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
bset->b.cdata[offset] &= ~(1 << (bitno % BITSET_WORD_BITS));
|
||||
bset->b.cdata[offset] &= ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
else
|
||||
BITSET_RESET_ (bset, bitno);
|
||||
}
|
||||
@@ -120,7 +135,7 @@ static inline int bitset_test (bset, bitno)
|
||||
{
|
||||
bitset_windex index = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = index - bset->b.cindex;
|
||||
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||
else
|
||||
@@ -128,7 +143,7 @@ static inline int bitset_test (bset, bitno)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BITSET_CACHE && ! BITSET_INLINE
|
||||
#if ! BITSET_INLINE
|
||||
|
||||
/* Set bit BITNO in bitset BSET. */
|
||||
#define bitset_set(bset, bitno) \
|
||||
@@ -139,7 +154,8 @@ do \
|
||||
bitset_windex _offset = _index - (bset)->b.cindex; \
|
||||
\
|
||||
if (_offset < (bset)->b.csize) \
|
||||
(bset)->b.cdata[_offset] |= (1 << (_bitno % BITSET_WORD_BITS)); \
|
||||
(bset)->b.cdata[_offset] |= \
|
||||
((bitset_word) 1 << (_bitno % BITSET_WORD_BITS)); \
|
||||
else \
|
||||
BITSET_SET_ ((bset), _bitno); \
|
||||
} while (0)
|
||||
@@ -154,7 +170,8 @@ do \
|
||||
bitset_windex _offset = _index - (bset)->b.cindex; \
|
||||
\
|
||||
if (_offset < (bset)->b.csize) \
|
||||
(bset)->b.cdata[_offset] &= ~(1 << (_bitno % BITSET_WORD_BITS)); \
|
||||
(bset)->b.cdata[_offset] &= \
|
||||
~((bitset_word) 1 << (_bitno % BITSET_WORD_BITS)); \
|
||||
else \
|
||||
BITSET_RESET_ ((bset), _bitno); \
|
||||
} while (0)
|
||||
@@ -163,21 +180,13 @@ do \
|
||||
/* Test bit BITNO in bitset BSET. */
|
||||
#define bitset_test(bset, bitno) \
|
||||
(((((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex) < (bset)->b.csize) \
|
||||
? ((bset)->b.cdata[(((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex)] \
|
||||
>> ((bitno) % BITSET_WORD_BITS)) & 1 \
|
||||
: (unsigned int) BITSET_TEST_ ((bset), (bitno)))
|
||||
? (((int) \
|
||||
((bset)->b.cdata[(((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex)] \
|
||||
>> ((bitno) % BITSET_WORD_BITS))) \
|
||||
& 1) \
|
||||
: BITSET_TEST_ ((bset), (bitno)))
|
||||
#endif
|
||||
|
||||
#if ! BITSET_CACHE
|
||||
/* Set bit BITNO in bitset SRC. */
|
||||
#define bitset_set(SRC, BITNO) BITSET_SET_ (SRC, BITNO)
|
||||
|
||||
/* Reset bit BITNO in bitset SRC. */
|
||||
#define bitset_reset(SRC, BITNO) BITSET_RESET_ (SRC, BITNO)
|
||||
|
||||
/* Return non-zero if bit BITNO in bitset SRC is set. */
|
||||
#define bitset_test(SRC, BITNO) BITSET_TEST_ (SRC, BITNO)
|
||||
#endif
|
||||
|
||||
/* Toggle bit BITNO in bitset BSET and return non-zero if now set. */
|
||||
extern int bitset_toggle PARAMS ((bitset, bitset_bindex));
|
||||
@@ -239,22 +248,17 @@ extern int bitset_prev PARAMS ((bitset, bitset_bindex));
|
||||
/* Return non-zero if BITNO in SRC is the only set bit. */
|
||||
extern int bitset_only_set_p PARAMS ((bitset, bitset_bindex));
|
||||
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
/* Find list of up to NUM bits set in BSET starting from and including
|
||||
*NEXT. Return with actual number of bits found and with *NEXT
|
||||
indicating where search stopped. */
|
||||
#if BITSET_STATS
|
||||
extern int bitset_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
#else
|
||||
#define bitset_list(BSET, LIST, NUM, NEXT) \
|
||||
BITSET_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
#endif
|
||||
BITSET_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find reverse list of up to NUM bits set in BSET starting from and
|
||||
including NEXT. Return with actual number of bits found and with
|
||||
*NEXT indicating where search stopped. */
|
||||
#define bitset_reverse_list(BSET, LIST, NUM, NEXT) \
|
||||
BITSET_REVERSE_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
BITSET_REVERSE_LIST_ (BSET, LIST, NUM, NEXT)
|
||||
|
||||
/* Find first set bit. */
|
||||
extern int bitset_first PARAMS ((bitset));
|
||||
@@ -265,69 +269,52 @@ extern int bitset_last PARAMS ((bitset));
|
||||
/* Dump bitset. */
|
||||
extern void bitset_dump PARAMS ((FILE *, bitset));
|
||||
|
||||
/* Loop over all elements of BSET, starting with MIN, executing CODE. */
|
||||
#define BITSET_EXECUTE(BSET, MIN, N, CODE) \
|
||||
do { \
|
||||
bitset_bindex _list[BITSET_LIST_SIZE]; \
|
||||
bitset_bindex _next = (MIN); \
|
||||
int _num; \
|
||||
\
|
||||
while ((_num = bitset_list ((BSET), _list, BITSET_LIST_SIZE, &_next)))\
|
||||
{ \
|
||||
int _i; \
|
||||
\
|
||||
for (_i = 0; _i < _num; _i++) \
|
||||
{ \
|
||||
(N) = _list[_i]; \
|
||||
CODE; \
|
||||
} \
|
||||
if (_num < BITSET_LIST_SIZE) \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
/* Loop over all elements of BSET, starting with MIN, setting BIT
|
||||
to the index of each set bit. */
|
||||
#define BITSET_FOR_EACH(ITER, BSET, BIT, MIN) \
|
||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||
(ITER.num == BITSET_LIST_SIZE) \
|
||||
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
||||
BITSET_LIST_SIZE, &ITER.next));) \
|
||||
for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
|
||||
|
||||
|
||||
/* Loop over all elements of BSET, in reverse order starting with
|
||||
MIN, executing CODE. */
|
||||
#define BITSET_REVERSE_EXECUTE(BSET, MIN, N, CODE) \
|
||||
do { \
|
||||
bitset_bindex _list[BITSET_LIST_SIZE]; \
|
||||
bitset_bindex _next = (MIN); \
|
||||
int _num; \
|
||||
\
|
||||
while ((_num = bitset_reverse_list ((BSET), _list, \
|
||||
BITSET_LIST_SIZE, &_next))) \
|
||||
{ \
|
||||
int _i; \
|
||||
\
|
||||
for (_i = 0; _i < _num; _i++) \
|
||||
{ \
|
||||
(N) = _list[_i]; \
|
||||
CODE; \
|
||||
} \
|
||||
if (_num < BITSET_LIST_SIZE) \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
MIN, setting BIT to the index of each set bit. */
|
||||
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, BIT, MIN) \
|
||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||
(ITER.num == BITSET_LIST_SIZE) \
|
||||
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
||||
BITSET_LIST_SIZE, &ITER.next));) \
|
||||
for (ITER.i = 0; (BIT) = ITER.list[ITER.i], ITER.i < ITER.num; ITER.i++)
|
||||
|
||||
|
||||
/* Define set operations in terms of logical operations. */
|
||||
|
||||
#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
|
||||
#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
|
||||
|
||||
#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
|
||||
#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
|
||||
|
||||
#define bitset_union(DST, SRC1, SRC2) bitset_or (DST, SRC1, SRC2)
|
||||
#define bitset_union(DST, SRC1, SRC2) bitset_or (DST, SRC1, SRC2)
|
||||
|
||||
#define bitset_diff_union(DST, SRC1, SRC2, SRC3) \
|
||||
bitset_andn_or (DST, SRC1, SRC2, SRC3)
|
||||
bitset_andn_or (DST, SRC1, SRC2, SRC3)
|
||||
|
||||
|
||||
/* Release any memory tied up with bitsets. */
|
||||
extern void bitset_release_memory PARAMS ((void));
|
||||
|
||||
/* Initialise bitset stats. */
|
||||
extern void bitset_stats_init PARAMS ((void));
|
||||
/* Enable bitset stats gathering. */
|
||||
extern void bitset_stats_enable PARAMS ((void));
|
||||
|
||||
/* Disable bitset stats gathering. */
|
||||
extern void bitset_stats_disable PARAMS ((void));
|
||||
|
||||
/* Read bitset stats file of accummulated stats. */
|
||||
void bitset_stats_read PARAMS ((const char *filename));
|
||||
|
||||
/* Write bitset stats file of accummulated stats. */
|
||||
void bitset_stats_write PARAMS ((const char *filename));
|
||||
|
||||
/* Dump bitset stats. */
|
||||
extern void bitset_stats_dump PARAMS ((FILE *));
|
||||
@@ -339,3 +326,4 @@ extern void debug_bitset PARAMS ((bitset));
|
||||
extern void debug_bitset_stats PARAMS ((void));
|
||||
|
||||
#endif /* _BITSET_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
/* Bitset statistics.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* This file is a wrapper bitset implementation for the other bitset
|
||||
implementations. It provides bitset compatibility checking and
|
||||
statistics gathering without having to instrument the bitset
|
||||
implementations. When statistics gathering is enabled, the bitset
|
||||
operations get vectored through here and we then call the appropriate
|
||||
routines.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "bbitset.h"
|
||||
#include "abitset.h"
|
||||
#include "ebitset.h"
|
||||
#include "lbitset.h"
|
||||
#include "bitset_stats.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(Msgid) gettext (Msgid)
|
||||
|
||||
/* Configuration macros. */
|
||||
#define BITSET_STATS_FILE "bitset.dat"
|
||||
#define BITSET_LOG_COUNT_BINS 10
|
||||
#define BITSET_LOG_SIZE_BINS 16
|
||||
#define BITSET_DENSITY_BINS 20
|
||||
|
||||
|
||||
/* Accessor macros. */
|
||||
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||
bitset_stats_info->types[(TYPE)].allocs++
|
||||
#define BITSET_STATS_FREES_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
|
||||
#define BITSET_STATS_SETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
|
||||
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
|
||||
#define BITSET_STATS_RESETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
|
||||
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
|
||||
#define BITSET_STATS_TESTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
|
||||
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
|
||||
#define BITSET_STATS_LISTS_INC(BSET) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
|
||||
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
|
||||
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
|
||||
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
|
||||
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
|
||||
|
||||
|
||||
typedef struct bitset_stats_struct
|
||||
{
|
||||
bitset bset;
|
||||
} *bitset_stats;
|
||||
|
||||
|
||||
struct bitset_struct
|
||||
{
|
||||
struct bbitset_struct b;
|
||||
struct bitset_stats_struct s;
|
||||
};
|
||||
|
||||
|
||||
struct bitset_type_info_struct
|
||||
{
|
||||
unsigned int allocs;
|
||||
unsigned int frees;
|
||||
unsigned int lists;
|
||||
unsigned int sets;
|
||||
unsigned int cache_sets;
|
||||
unsigned int resets;
|
||||
unsigned int cache_resets;
|
||||
unsigned int tests;
|
||||
unsigned int cache_tests;
|
||||
unsigned int list_counts[BITSET_LOG_COUNT_BINS];
|
||||
unsigned int list_sizes[BITSET_LOG_SIZE_BINS];
|
||||
unsigned int list_density[BITSET_DENSITY_BINS];
|
||||
};
|
||||
|
||||
struct bitset_stats_info_struct
|
||||
{
|
||||
unsigned int runs;
|
||||
struct bitset_type_info_struct types[BITSET_TYPE_NUM];
|
||||
};
|
||||
|
||||
|
||||
struct bitset_stats_info_struct bitset_stats_info_data;
|
||||
struct bitset_stats_info_struct *bitset_stats_info;
|
||||
int bitset_stats_enabled = 0;
|
||||
|
||||
|
||||
static void bitset_stats_set PARAMS ((bitset, bitset_bindex));
|
||||
static void bitset_stats_reset PARAMS ((bitset, bitset_bindex));
|
||||
static int bitset_stats_test PARAMS ((bitset, bitset_bindex));
|
||||
static int bitset_stats_size PARAMS ((bitset));
|
||||
static int bitset_stats_op1 PARAMS ((bitset, enum bitset_ops));
|
||||
static int bitset_stats_op2 PARAMS ((bitset, bitset, enum bitset_ops));
|
||||
static int bitset_stats_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops));
|
||||
static int bitset_stats_op4 PARAMS ((bitset, bitset, bitset, bitset,
|
||||
enum bitset_ops));
|
||||
static int bitset_stats_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
|
||||
bitset_bindex *));
|
||||
static int bitset_stats_reverse_list
|
||||
PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
|
||||
static void bitset_stats_free PARAMS ((bitset));
|
||||
static void bitset_percent_histogram_print PARAMS ((FILE *, const char *,
|
||||
const char *,
|
||||
unsigned int,
|
||||
unsigned int *));
|
||||
static void bitset_log_histogram_print PARAMS ((FILE *, const char *,
|
||||
const char *,
|
||||
unsigned int,
|
||||
unsigned int *));
|
||||
static void bitset_stats_print_1
|
||||
PARAMS ((FILE *, const char *, struct bitset_type_info_struct *));
|
||||
static void bitset_stats_print PARAMS ((FILE *, int));
|
||||
|
||||
|
||||
/* Print a percentage histogram with message MSG to FILE. */
|
||||
static void
|
||||
bitset_percent_histogram_print (file, name, msg, n_bins, bins)
|
||||
FILE *file;
|
||||
const char *name;
|
||||
const char *msg;
|
||||
unsigned int n_bins;
|
||||
unsigned int *bins;
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int total;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < n_bins; i++)
|
||||
fprintf (file, "%.0f-%.0f%%\t%8d (%5.1f%%)\n",
|
||||
i * 100.0 / n_bins,
|
||||
(i + 1) * 100.0 / n_bins, bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
|
||||
|
||||
/* Print a log histogram with message MSG to FILE. */
|
||||
static void
|
||||
bitset_log_histogram_print (file, name, msg, n_bins, bins)
|
||||
FILE *file;
|
||||
const char *name;
|
||||
const char *msg;
|
||||
unsigned int n_bins;
|
||||
unsigned int *bins;
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int total;
|
||||
unsigned int max_width;
|
||||
unsigned int last_bin;
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < n_bins; i++)
|
||||
total += bins[i];
|
||||
|
||||
if (!total)
|
||||
return;
|
||||
|
||||
for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
|
||||
continue;
|
||||
last_bin = i - 1;
|
||||
|
||||
/* 2 * ceil (log10 (2) * (N - 1)) + 1. */
|
||||
max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1;
|
||||
|
||||
fprintf (file, "%s %s", name, msg);
|
||||
for (i = 0; i < 2; i++)
|
||||
fprintf (file, "%*d\t%8d (%5.1f%%)\n",
|
||||
max_width, i, bins[i], 100.0 * bins[i] / total);
|
||||
|
||||
for (; i <= last_bin; i++)
|
||||
fprintf (file, "%*d-%d\t%8d (%5.1f%%)\n",
|
||||
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||
1 << (i - 1), (1 << i) - 1, bins[i],
|
||||
(100.0 * bins[i]) / total);
|
||||
}
|
||||
|
||||
|
||||
/* Print bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print_1 (file, name, stats)
|
||||
FILE *file;
|
||||
const char *name;
|
||||
struct bitset_type_info_struct *stats;
|
||||
{
|
||||
if (!stats)
|
||||
return;
|
||||
|
||||
fprintf (file, "%s:\n", name);
|
||||
fprintf (file, _("%d bitset_allocs, %d freed (%.2f%%).\n"),
|
||||
stats->allocs, stats->frees,
|
||||
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
||||
fprintf (file, _("%d bitset_sets, %d cached (%.2f%%)\n"),
|
||||
stats->sets, stats->cache_sets,
|
||||
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
||||
fprintf (file, _("%d bitset_resets, %d cached (%.2f%%)\n"),
|
||||
stats->resets, stats->cache_resets,
|
||||
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
||||
fprintf (file, _("%d bitset_tests, %d cached (%.2f%%)\n"),
|
||||
stats->tests, stats->cache_tests,
|
||||
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
||||
|
||||
fprintf (file, _("%d bitset_lists\n"), stats->lists);
|
||||
|
||||
bitset_log_histogram_print (file, name, _("count log histogram\n"),
|
||||
BITSET_LOG_COUNT_BINS, stats->list_counts);
|
||||
|
||||
bitset_log_histogram_print (file, name, _("size log histogram\n"),
|
||||
BITSET_LOG_SIZE_BINS, stats->list_sizes);
|
||||
|
||||
bitset_percent_histogram_print (file, name, _("density histogram\n"),
|
||||
BITSET_DENSITY_BINS, stats->list_density);
|
||||
}
|
||||
|
||||
|
||||
/* Print all bitset statistics to FILE. */
|
||||
static void
|
||||
bitset_stats_print (file, verbose)
|
||||
FILE *file;
|
||||
int verbose ATTRIBUTE_UNUSED;
|
||||
{
|
||||
int i;
|
||||
static const char *names[] = BITSET_TYPE_NAMES;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
fprintf (file, _("Bitset statistics:\n\n"));
|
||||
|
||||
if (bitset_stats_info->runs > 1)
|
||||
fprintf (file, _("Accumulated runs = %d\n"), bitset_stats_info->runs);
|
||||
|
||||
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||
bitset_stats_print_1 (file, names[i], &bitset_stats_info->types[i]);
|
||||
}
|
||||
|
||||
|
||||
/* Initialise bitset statistics logging. */
|
||||
void
|
||||
bitset_stats_enable ()
|
||||
{
|
||||
if (!bitset_stats_info)
|
||||
bitset_stats_info = &bitset_stats_info_data;
|
||||
bitset_stats_enabled = 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bitset_stats_disable ()
|
||||
{
|
||||
bitset_stats_enabled = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Read bitset statistics file. */
|
||||
void
|
||||
bitset_stats_read (filename)
|
||||
const char *filename;
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!filename)
|
||||
filename = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (filename, "r");
|
||||
if (file)
|
||||
{
|
||||
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
1, file) != 1)
|
||||
{
|
||||
if (ferror (file))
|
||||
perror (_("Could not read stats file."));
|
||||
else
|
||||
fprintf (stderr, _("Bad stats file size.\n"));
|
||||
}
|
||||
fclose (file);
|
||||
}
|
||||
bitset_stats_info_data.runs++;
|
||||
}
|
||||
|
||||
|
||||
/* Write bitset statistics file. */
|
||||
void
|
||||
bitset_stats_write (filename)
|
||||
const char *filename;
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (!bitset_stats_info)
|
||||
return;
|
||||
|
||||
if (!filename)
|
||||
filename = BITSET_STATS_FILE;
|
||||
|
||||
file = fopen (filename, "w");
|
||||
if (file)
|
||||
{
|
||||
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||
1, file) != 1)
|
||||
perror (_("Could not write stats file."));
|
||||
fclose (file);
|
||||
}
|
||||
else
|
||||
perror (_("Could not open stats file for writing."));
|
||||
}
|
||||
|
||||
|
||||
/* Dump bitset statistics to FILE. */
|
||||
void
|
||||
bitset_stats_dump (file)
|
||||
FILE *file;
|
||||
{
|
||||
bitset_stats_print (file, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Function to be called from debugger to print bitset stats. */
|
||||
void
|
||||
debug_bitset_stats (void)
|
||||
{
|
||||
bitset_stats_print (stderr, 1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_set (dst, bitno)
|
||||
bitset dst;
|
||||
bitset_bindex bitno;
|
||||
{
|
||||
bitset bset = dst->s.bset;
|
||||
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = wordno - bset->b.cindex;
|
||||
|
||||
BITSET_STATS_SETS_INC (bset);
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
{
|
||||
bset->b.cdata[offset] |= (bitset_word) 1 << (bitno % BITSET_WORD_BITS);
|
||||
BITSET_STATS_CACHE_SETS_INC (bset);
|
||||
}
|
||||
else
|
||||
BITSET_SET_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_reset (dst, bitno)
|
||||
bitset dst;
|
||||
bitset_bindex bitno;
|
||||
{
|
||||
bitset bset = dst->s.bset;
|
||||
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = wordno - bset->b.cindex;
|
||||
|
||||
BITSET_STATS_RESETS_INC (bset);
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
{
|
||||
bset->b.cdata[offset] &=
|
||||
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
BITSET_STATS_CACHE_RESETS_INC (bset);
|
||||
}
|
||||
else
|
||||
BITSET_RESET_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_test (src, bitno)
|
||||
bitset src;
|
||||
bitset_bindex bitno;
|
||||
{
|
||||
bitset bset = src->s.bset;
|
||||
bitset_windex wordno = bitno / BITSET_WORD_BITS;
|
||||
bitset_windex offset = wordno - bset->b.cindex;
|
||||
|
||||
BITSET_STATS_TESTS_INC (bset);
|
||||
|
||||
if (offset < bset->b.csize)
|
||||
{
|
||||
BITSET_STATS_CACHE_TESTS_INC (bset);
|
||||
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1;
|
||||
}
|
||||
else
|
||||
return BITSET_TEST_ (bset, bitno);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_size (src)
|
||||
bitset src;
|
||||
{
|
||||
return BITSET_SIZE_ (src->s.bset);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_op1 (dst, op)
|
||||
bitset dst;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
return BITSET_OP1_ (dst->s.bset, op);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_op2 (dst, src, op)
|
||||
bitset dst;
|
||||
bitset src;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
BITSET_CHECK2_ (dst, src);
|
||||
return BITSET_OP2_ (dst->s.bset, src->s.bset, op);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_op3 (dst, src1, src2, op)
|
||||
bitset dst;
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
BITSET_CHECK3_ (dst, src1, src2);
|
||||
return BITSET_OP3_ (dst->s.bset, src1->s.bset, src2->s.bset, op);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_op4 (dst, src1, src2, src3, op)
|
||||
bitset dst;
|
||||
bitset src1;
|
||||
bitset src2;
|
||||
bitset src3;
|
||||
enum bitset_ops op;
|
||||
{
|
||||
BITSET_CHECK4_ (dst, src1, src2, src3);
|
||||
|
||||
/* This is a bit of a hack. If the implementation handles
|
||||
a four operand operation then vector to it, passing
|
||||
the enclosed bitsets. Otherwise use the fallback
|
||||
bitset_op4 routine. */
|
||||
if (dst->s.bset->b.ops->op4 != bitset_op4)
|
||||
return BITSET_OP4_ (dst->s.bset, src1->s.bset, src2->s.bset,
|
||||
src3->s.bset, op);
|
||||
|
||||
return bitset_op4 (dst, src1, src2, src3, op);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_list (bset, list, num, next)
|
||||
bitset bset;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
{
|
||||
bitset_bindex count;
|
||||
bitset_bindex tmp;
|
||||
bitset_bindex size;
|
||||
bitset_bindex i;
|
||||
enum bitset_type type;
|
||||
|
||||
count = BITSET_LIST_ (bset->s.bset, list, num, next);
|
||||
|
||||
type = BITSET_TYPE_ (bset->s.bset);
|
||||
BITSET_STATS_LISTS_INC (bset->s.bset);
|
||||
|
||||
/* Log histogram of number of set bits. */
|
||||
for (i = 0, tmp = count; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_COUNT_BINS)
|
||||
i = BITSET_LOG_COUNT_BINS - 1;
|
||||
BITSET_STATS_LIST_COUNTS_INC (bset->s.bset, i);
|
||||
|
||||
/* Log histogram of number of bits in set. */
|
||||
size = BITSET_SIZE_ (bset->s.bset);
|
||||
for (i = 0, tmp = size; tmp; tmp >>= 1, i++)
|
||||
continue;
|
||||
if (i >= BITSET_LOG_SIZE_BINS)
|
||||
i = BITSET_LOG_SIZE_BINS - 1;
|
||||
BITSET_STATS_LIST_SIZES_INC (bset->s.bset, i);
|
||||
|
||||
/* Histogram of fraction of bits set. */
|
||||
i = size ? (count * BITSET_DENSITY_BINS) / size : 0;
|
||||
if (i >= BITSET_DENSITY_BINS)
|
||||
i = BITSET_DENSITY_BINS - 1;
|
||||
BITSET_STATS_LIST_DENSITY_INC (bset->s.bset, i);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
bitset_stats_reverse_list (bset, list, num, next)
|
||||
bitset bset;
|
||||
bitset_bindex *list;
|
||||
bitset_bindex num;
|
||||
bitset_bindex *next;
|
||||
{
|
||||
return BITSET_REVERSE_LIST_ (bset->s.bset, list, num, next);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
bitset_stats_free (bset)
|
||||
bitset bset;
|
||||
{
|
||||
BITSET_STATS_FREES_INC (bset->s.bset);
|
||||
BITSET_FREE_ (bset->s.bset);
|
||||
}
|
||||
|
||||
|
||||
struct bitset_ops_struct bitset_stats_ops = {
|
||||
bitset_stats_set,
|
||||
bitset_stats_reset,
|
||||
bitset_stats_test,
|
||||
bitset_stats_size,
|
||||
bitset_stats_op1,
|
||||
bitset_stats_op2,
|
||||
bitset_stats_op3,
|
||||
bitset_stats_op4,
|
||||
bitset_stats_list,
|
||||
bitset_stats_reverse_list,
|
||||
bitset_stats_free,
|
||||
BITSET_STATS
|
||||
};
|
||||
|
||||
|
||||
/* Return enclosed bitset type. */
|
||||
enum bitset_type
|
||||
bitset_stats_type_get (bset)
|
||||
bitset bset;
|
||||
{
|
||||
return BITSET_TYPE_ (bset->s.bset);
|
||||
}
|
||||
|
||||
|
||||
int bitset_stats_bytes (void)
|
||||
{
|
||||
return sizeof (struct bitset_struct);
|
||||
}
|
||||
|
||||
|
||||
bitset
|
||||
bitset_stats_init (bset, n_bits, type)
|
||||
bitset bset;
|
||||
bitset_bindex n_bits;
|
||||
enum bitset_type type;
|
||||
{
|
||||
unsigned int bytes;
|
||||
bitset sbset;
|
||||
|
||||
bset->b.ops = &bitset_stats_ops;
|
||||
|
||||
/* Disable cache. */
|
||||
bset->b.cindex = 0;
|
||||
bset->b.csize = 0;
|
||||
bset->b.cdata = 0;
|
||||
|
||||
/* Set up the actual bitset implementation that
|
||||
we are a wrapper over. */
|
||||
switch (type)
|
||||
{
|
||||
case BITSET_ARRAY:
|
||||
bytes = abitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
abitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_LIST:
|
||||
bytes = lbitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
lbitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
case BITSET_TABLE:
|
||||
bytes = ebitset_bytes (n_bits);
|
||||
sbset = (bitset) xcalloc (1, bytes);
|
||||
ebitset_init (sbset, n_bits);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
bset->s.bset = sbset;
|
||||
|
||||
BITSET_STATS_ALLOCS_INC (type);
|
||||
|
||||
return bset;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/* Functions to support bitset statistics.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Michael Hayes ([email protected]).
|
||||
|
||||
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. */
|
||||
|
||||
#ifndef _BITSET_STATS_H
|
||||
#define _BITSET_STATS_H
|
||||
|
||||
#include "bbitset.h"
|
||||
|
||||
extern int bitset_stats_enabled;
|
||||
|
||||
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));
|
||||
|
||||
extern int bitset_stats_bytes PARAMS ((void));
|
||||
|
||||
extern bitset bitset_stats_init PARAMS ((bitset, bitset_bindex,
|
||||
enum bitset_type));
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison.
|
||||
|
||||
Bison 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.
|
||||
|
||||
Bison 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 Bison; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "bitsetv-print.h"
|
||||
|
||||
/*--------------------------------------------------------.
|
||||
| Display the MATRIX array of SIZE bitsets of size SIZE. |
|
||||
`--------------------------------------------------------*/
|
||||
|
||||
void
|
||||
bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
||||
{
|
||||
size_t i, j;
|
||||
size_t hsize = bitset_size (bset[0]);
|
||||
|
||||
/* Title. */
|
||||
fprintf (out, "%s BEGIN\n", title);
|
||||
|
||||
/* Column numbers. */
|
||||
fputs (" ", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
putc (i / 10 ? '0' + i / 10 : ' ', out);
|
||||
putc ('\n', out);
|
||||
fputs (" ", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
fprintf (out, "%d", i % 10);
|
||||
putc ('\n', out);
|
||||
|
||||
/* Bar. */
|
||||
fputs (" .", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
putc ('-', out);
|
||||
fputs (".\n", out);
|
||||
|
||||
/* Contents. */
|
||||
for (i = 0; bset[i]; ++i)
|
||||
{
|
||||
fprintf (out, "%2d|", i);
|
||||
for (j = 0; j < hsize; ++j)
|
||||
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
|
||||
fputs ("|\n", out);
|
||||
}
|
||||
|
||||
/* Bar. */
|
||||
fputs (" `", out);
|
||||
for (i = 0; i < hsize; ++i)
|
||||
putc ('-', out);
|
||||
fputs ("'\n", out);
|
||||
|
||||
/* End title. */
|
||||
fprintf (out, "%s END\n\n", title);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* Bitset vectors.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Akim Demaille ([email protected]).
|
||||
|
||||
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. */
|
||||
|
||||
#ifndef _BITSETV_PRINT_H
|
||||
#define _BITSETV_PRINT_H
|
||||
|
||||
#include "bitsetv.h"
|
||||
|
||||
/* Dump vector of bitsets as a matrix. */
|
||||
extern void bitsetv_matrix_dump PARAMS ((FILE *, const char *,
|
||||
bitsetv));
|
||||
|
||||
#endif /* _BITSETV_H */
|
||||
+1
-1
@@ -49,7 +49,7 @@ bitsetv_alloc (n_vecs, n_bits, type)
|
||||
for (i = 0; i < n_vecs; i++)
|
||||
{
|
||||
bsetv[i] = (bitset) ((char *) bsetv + vector_bytes + i * bytes);
|
||||
|
||||
|
||||
bitset_init (bsetv[i], n_bits, type);
|
||||
}
|
||||
|
||||
|
||||
+24
-108
@@ -1,5 +1,5 @@
|
||||
/* dirname.c -- return all but the last element in a path
|
||||
Copyright (C) 1990, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1990, 1998, 2000, 2001 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
|
||||
@@ -19,126 +19,43 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
#if defined STDC_HEADERS || defined HAVE_STRING_H
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
# ifndef strrchr
|
||||
# define strrchr rindex
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef HAVE_DECL_MEMRCHR
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_MEMRCHR
|
||||
void *memrchr ();
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
#define BACKSLASH_IS_PATH_SEPARATOR ISSLASH ('\\')
|
||||
|
||||
/* Return the length of `dirname (PATH)' and set *RESULT to point
|
||||
to PATH or to `"."', as appropriate. Works properly even if
|
||||
there are trailing slashes (by effectively ignoring them).
|
||||
WARNING: This function doesn't work for cwd-relative names like
|
||||
`a:foo' that are specified with a drive-letter prefix. That case
|
||||
is handled in the caller. */
|
||||
static size_t
|
||||
dir_name_r (char const *path, char const **result)
|
||||
/* Return the length of `dirname (PATH)', or zero if PATH is
|
||||
in the working directory. Works properly even if
|
||||
there are trailing slashes (by effectively ignoring them). */
|
||||
size_t
|
||||
dir_len (char const *path)
|
||||
{
|
||||
char const *slash;
|
||||
size_t length; /* Length of result, not including NUL. */
|
||||
size_t prefix_length = FILESYSTEM_PREFIX_LEN (path);
|
||||
size_t length;
|
||||
|
||||
slash = strrchr (path, '/');
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char const *b = strrchr (path, '\\');
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = base_name (path) - path; prefix_length < length; length--)
|
||||
if (! ISSLASH (path[length - 1]))
|
||||
return length;
|
||||
|
||||
/* If the last byte of PATH is a slash, decrement SLASH until it's
|
||||
pointing at the leftmost in a sequence of trailing slashes. */
|
||||
if (slash && slash[1] == 0)
|
||||
{
|
||||
while (path < slash && ISSLASH (slash[-1]))
|
||||
{
|
||||
--slash;
|
||||
}
|
||||
|
||||
if (path < slash)
|
||||
{
|
||||
size_t len = slash - path;
|
||||
slash = memrchr (path, '/', len);
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char const *b = memrchr (path, '\\', len);
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slash == 0)
|
||||
{
|
||||
/* File is in the current directory. */
|
||||
|
||||
length = FILESYSTEM_PREFIX_LEN (path);
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
path = ".";
|
||||
length = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remove any trailing slashes from the result. If we have a
|
||||
canonicalized "d:/path", leave alone the root case "d:/". */
|
||||
char const *lim = path + FILESYSTEM_PREFIX_LEN (path);
|
||||
|
||||
while (lim < slash && ISSLASH (*slash))
|
||||
--slash;
|
||||
|
||||
length = slash - path + 1;
|
||||
}
|
||||
|
||||
*result = path;
|
||||
return length;
|
||||
/* But don't strip the only slash from "/". */
|
||||
return prefix_length + ISSLASH (path[prefix_length]);
|
||||
}
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
allocated with malloc. If out of memory, return 0.
|
||||
allocated with xmalloc.
|
||||
Works properly even if there are trailing slashes
|
||||
(by effectively ignoring them). */
|
||||
|
||||
char *
|
||||
dir_name (char const *path)
|
||||
{
|
||||
char const *result;
|
||||
size_t length = dir_name_r (path, &result);
|
||||
int append_dot = (length && length == FILESYSTEM_PREFIX_LEN (newpath));
|
||||
char *newpath = (char *) malloc (length + append_dot + 1);
|
||||
if (newpath == 0)
|
||||
return 0;
|
||||
strncpy (newpath, result, length);
|
||||
/* If PATH is "d:foo", return "d:.", the CWD on drive d: */
|
||||
size_t length = dir_len (path);
|
||||
int append_dot = (length == FILESYSTEM_PREFIX_LEN (path));
|
||||
char *newpath = xmalloc (length + append_dot + 1);
|
||||
memcpy (newpath, path, length);
|
||||
if (append_dot)
|
||||
newpath[length++] = '.';
|
||||
newpath[length] = 0;
|
||||
@@ -149,7 +66,8 @@ dir_name (char const *path)
|
||||
/*
|
||||
|
||||
Run the test like this (expect no output):
|
||||
gcc -DHAVE_CONFIG_H -DTEST_DIRNAME -I.. -O -Wall memrchr.c dirname.c
|
||||
gcc -DHAVE_CONFIG_H -DTEST_DIRNAME -I.. -O -Wall \
|
||||
basename.c dirname.c xmalloc.c
|
||||
sed -n '/^BEGIN-DATA$/,/^END-DATA$/p' dirname.c|grep -v DATA|./a.out
|
||||
|
||||
BEGIN-DATA
|
||||
@@ -165,7 +83,6 @@ END-DATA
|
||||
|
||||
# define MAX_BUFF_LEN 1024
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
@@ -183,7 +100,6 @@ main ()
|
||||
if (strcmp (result, expected_result))
|
||||
printf ("%s: got %s, expected %s\n", path, result, expected_result);
|
||||
}
|
||||
exit (0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
+19
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1998, 2001 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
|
||||
@@ -25,7 +25,23 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
char *
|
||||
dir_name PARAMS ((const char *path));
|
||||
# ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
# endif
|
||||
|
||||
# ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
|
||||
# endif
|
||||
|
||||
# ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
# endif
|
||||
|
||||
char *base_name PARAMS ((char const *path));
|
||||
char *dir_name PARAMS ((char const *path));
|
||||
size_t base_len PARAMS ((char const *path));
|
||||
size_t dir_len PARAMS ((char const *path));
|
||||
|
||||
int strip_trailing_slashes PARAMS ((char *path));
|
||||
|
||||
#endif /* not DIRNAME_H_ */
|
||||
|
||||
+33
-30
@@ -47,10 +47,7 @@
|
||||
|
||||
|
||||
/* Number of words to use for each element. */
|
||||
|
||||
#ifndef EBITSET_ELT_WORDS
|
||||
#define EBITSET_ELT_WORDS 2
|
||||
#endif
|
||||
|
||||
/* Number of bits stored in each element. */
|
||||
#define EBITSET_ELT_BITS \
|
||||
@@ -197,9 +194,6 @@ ebitset_elt_alloc ()
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We can't use gcc_obstack_init to initialize the obstack since
|
||||
print-rtl.c now calls bitset functions, and bitset is linked
|
||||
into the gen* functions. */
|
||||
if (!ebitset_obstack_init)
|
||||
{
|
||||
ebitset_obstack_init = 1;
|
||||
@@ -242,7 +236,7 @@ ebitset_elt_alloc ()
|
||||
}
|
||||
|
||||
|
||||
/* Allocate a ebitset element. The bits are not cleared. */
|
||||
/* Allocate a ebitset element. The bits are cleared. */
|
||||
static inline ebitset_elt *
|
||||
ebitset_elt_calloc ()
|
||||
{
|
||||
@@ -584,7 +578,8 @@ ebitset_set (dst, bitno)
|
||||
|
||||
ebitset_elt_find (dst, windex, EBITSET_CREATE);
|
||||
|
||||
dst->b.cdata[windex - dst->b.cindex] |= (1 << (bitno % BITSET_WORD_BITS));
|
||||
dst->b.cdata[windex - dst->b.cindex] |=
|
||||
(bitset_word) 1 << (bitno % BITSET_WORD_BITS);
|
||||
}
|
||||
|
||||
|
||||
@@ -599,7 +594,8 @@ ebitset_reset (dst, bitno)
|
||||
if (!ebitset_elt_find (dst, windex, EBITSET_FIND))
|
||||
return;
|
||||
|
||||
dst->b.cdata[windex - dst->b.cindex] &= ~(1 << (bitno % BITSET_WORD_BITS));
|
||||
dst->b.cdata[windex - dst->b.cindex] &=
|
||||
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
|
||||
/* If all the data is zero, perhaps we should remove it now...
|
||||
However, there is a good chance that the element will be needed
|
||||
@@ -652,7 +648,6 @@ ebitset_reverse_list (bset, list, num, next)
|
||||
bitset_windex woffset;
|
||||
bitset_bindex count;
|
||||
bitset_windex size;
|
||||
bitset_word word;
|
||||
ebitset_elts *elts;
|
||||
|
||||
if (EBITSET_OP_ZERO_P (bset))
|
||||
@@ -680,40 +675,48 @@ ebitset_reverse_list (bset, list, num, next)
|
||||
bcount = bitno % BITSET_WORD_BITS;
|
||||
boffset = windex * BITSET_WORD_BITS;
|
||||
|
||||
for (; eindex != ~0U;
|
||||
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS, eindex--)
|
||||
do
|
||||
{
|
||||
ebitset_elt *elt;
|
||||
bitset_word *srcp;
|
||||
|
||||
elt = elts[eindex];
|
||||
if (!elt)
|
||||
continue;
|
||||
|
||||
srcp = EBITSET_WORDS (elt);
|
||||
|
||||
for (; woffset != ~0U; woffset--, boffset -= BITSET_WORD_BITS,
|
||||
bcount = BITSET_WORD_BITS - 1)
|
||||
if (elt)
|
||||
{
|
||||
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||
bitset_word *srcp;
|
||||
|
||||
for (; word; bcount--)
|
||||
srcp = EBITSET_WORDS (elt);
|
||||
|
||||
do
|
||||
{
|
||||
if (word & BITSET_MSB)
|
||||
bitset_word word;
|
||||
|
||||
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||
|
||||
for (; word; bcount--)
|
||||
{
|
||||
list[count++] = boffset + bcount;
|
||||
if (count >= num)
|
||||
if (word & BITSET_MSB)
|
||||
{
|
||||
*next = n_bits - (boffset + bcount);
|
||||
return count;
|
||||
list[count++] = boffset + bcount;
|
||||
if (count >= num)
|
||||
{
|
||||
*next = n_bits - (boffset + bcount);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
word <<= 1;
|
||||
}
|
||||
word <<= 1;
|
||||
|
||||
boffset -= BITSET_WORD_BITS;
|
||||
bcount = BITSET_WORD_BITS - 1;
|
||||
}
|
||||
while (woffset--);
|
||||
|
||||
woffset = EBITSET_ELT_WORDS;
|
||||
}
|
||||
|
||||
woffset = EBITSET_ELT_WORDS;
|
||||
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
|
||||
}
|
||||
while (eindex--);
|
||||
|
||||
*next = n_bits - (boffset + 1);
|
||||
return count;
|
||||
@@ -884,7 +887,7 @@ ebitset_op1 (dst, op)
|
||||
we should just add pointers to a ones element. */
|
||||
elt =
|
||||
ebitset_elt_find (dst, j * EBITSET_ELT_WORDS, EBITSET_CREATE);
|
||||
memset (EBITSET_WORDS (elt), ~0, sizeof (EBITSET_WORDS (elt)));
|
||||
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _EBITSET_H
|
||||
#define _EBITSET_H
|
||||
#define _EBITSET_H
|
||||
|
||||
#include "bbitset.h"
|
||||
|
||||
|
||||
+11
-11
@@ -3,20 +3,19 @@
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
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 Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <[email protected]>. */
|
||||
|
||||
@@ -54,6 +53,7 @@ void exit ();
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "unlocked-io.h"
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
|
||||
+27
-59
@@ -2,24 +2,23 @@
|
||||
NOTE: getopt is now part of the C library, so if you don't know what
|
||||
"Keep this file name-space clean" means, talk to [email protected]
|
||||
before changing it!
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
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 Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||
@@ -31,14 +30,6 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
# ifndef const
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
@@ -60,14 +51,12 @@
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */
|
||||
#if HAVE_STDLIB_H || defined __GNU_LIBRARY__
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H || defined __GNU_LIBRARY__
|
||||
# include <unistd.h>
|
||||
#endif /* GNU C library. */
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
# include <unixlib.h>
|
||||
@@ -190,30 +179,18 @@ static enum
|
||||
/* Value of POSIXLY_CORRECT environment variable. */
|
||||
static char *posixly_correct;
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||
because there are many ways it can cause trouble.
|
||||
On some systems, it contains special magic macros that don't work
|
||||
in GCC. */
|
||||
#if HAVE_STRING_H || defined __GNU_LIBRARY__
|
||||
# include <string.h>
|
||||
# define my_index strchr
|
||||
#else
|
||||
|
||||
# if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# else
|
||||
# if HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
# endif
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
#ifndef getenv
|
||||
extern char *getenv ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_STRCHR && !defined strchr && !defined __GNU_LIBRARY__
|
||||
# define strchr my_strchr
|
||||
static char *
|
||||
my_index (str, chr)
|
||||
strchr (str, chr)
|
||||
const char *str;
|
||||
int chr;
|
||||
{
|
||||
@@ -225,20 +202,11 @@ my_index (str, chr)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If using GCC, we can safely declare strlen this way.
|
||||
If not using GCC, it is ok not to declare it. */
|
||||
#ifdef __GNUC__
|
||||
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
|
||||
That was relevant to code that was here before. */
|
||||
# if (!defined __STDC__ || !__STDC__) && !defined strlen
|
||||
/* gcc with -traditional declares the built-in strlen to return int,
|
||||
and has done so at least since version 2.4.5. -- rms. */
|
||||
extern int strlen (const char *);
|
||||
# endif /* not __STDC__ */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* not __GNU_LIBRARY__ */
|
||||
#if !HAVE_DECL_GETENV && !defined getenv && !defined __GNU_LIBRARY__
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
@@ -647,7 +615,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
|
||||
if (longopts != NULL
|
||||
&& (argv[optind][1] == '-'
|
||||
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
|
||||
|| (long_only && (argv[optind][2] || !strchr (optstring, argv[optind][1])))))
|
||||
{
|
||||
char *nameend;
|
||||
const struct option *p;
|
||||
@@ -762,7 +730,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
|| my_index (optstring, *nextchar) == NULL)
|
||||
|| strchr (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (print_errors)
|
||||
{
|
||||
@@ -786,7 +754,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = my_index (optstring, c);
|
||||
char *temp = strchr (optstring, c);
|
||||
|
||||
/* Increment `optind' when we start to process its last character. */
|
||||
if (*nextchar == '\0')
|
||||
|
||||
+27
-18
@@ -1,21 +1,23 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1989-1994, 1996-1999, 2001, 2002 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
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 Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
@@ -27,11 +29,16 @@
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
not defined, include <stdlib.h>, which will pull in <features.h> for us
|
||||
if it's from glibc (and will declare getopt). Fall back on <ctype.h> if
|
||||
<stdlib.h> might not exist. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
# if HAVE_STDLIB_H || STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# else
|
||||
# include <ctype.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -138,14 +145,16 @@ struct option
|
||||
`getopt'. */
|
||||
|
||||
#if (defined __STDC__ && __STDC__) || defined __cplusplus
|
||||
# ifdef __GNU_LIBRARY__
|
||||
# if defined HAVE_DECL_GETOPT && !HAVE_DECL_GETOPT
|
||||
# ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
|
||||
# else /* not __GNU_LIBRARY__ */
|
||||
# else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
# endif /* __GNU_LIBRARY__ */
|
||||
# endif /* __GNU_LIBRARY__ */
|
||||
# endif /* defined HAVE_DECL_GETOPT && !HAVE_DECL_GETOPT */
|
||||
|
||||
# ifndef __need_getopt
|
||||
extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
|
||||
|
||||
+11
-21
@@ -1,37 +1,27 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98, 2002
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
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 Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
|
||||
+18
-9
@@ -1,20 +1,19 @@
|
||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 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 Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
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
|
||||
Library General Public License for more details.
|
||||
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 Library 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. */
|
||||
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. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
@@ -27,6 +26,16 @@
|
||||
|
||||
#else
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
|
||||
+44
-6
@@ -36,14 +36,14 @@ typedef enum {false = 0, true = 1} bool;
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef HAVE_DECL_FREE
|
||||
# error "this configure-time declaration test was not run"
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_FREE
|
||||
void free ();
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_MALLOC
|
||||
# error "this configure-time declaration test was not run"
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_MALLOC
|
||||
char *malloc ();
|
||||
@@ -61,6 +61,40 @@ char *malloc ();
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
struct hash_table
|
||||
{
|
||||
/* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
|
||||
for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets
|
||||
are not empty, there are N_ENTRIES active entries in the table. */
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *bucket_limit;
|
||||
unsigned n_buckets;
|
||||
unsigned n_buckets_used;
|
||||
unsigned n_entries;
|
||||
|
||||
/* Tuning arguments, kept in a physicaly separate structure. */
|
||||
const Hash_tuning *tuning;
|
||||
|
||||
/* Three functions are given to `hash_initialize', see the documentation
|
||||
block for this function. In a word, HASHER randomizes a user entry
|
||||
into a number up from 0 up to some maximum minus 1; COMPARATOR returns
|
||||
true if two user entries compare equally; and DATA_FREER is the cleanup
|
||||
function for a user entry. */
|
||||
Hash_hasher hasher;
|
||||
Hash_comparator comparator;
|
||||
Hash_data_freer data_freer;
|
||||
|
||||
/* A linked list of freed struct hash_entry structs. */
|
||||
struct hash_entry *free_entry_list;
|
||||
|
||||
#if USE_OBSTACK
|
||||
/* Whenever obstacks are used, it is possible to allocate all overflowed
|
||||
entries into a single stack, so they all can be freed in a single
|
||||
operation. It is not clear if the speedup is worth the trouble. */
|
||||
struct obstack entry_stack;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* A hash table contains many internal entries, each holding a pointer to
|
||||
some user provided data (also called a user entry). An entry indistinctly
|
||||
refers to both the internal entry and its associated user entry. A user
|
||||
@@ -576,19 +610,22 @@ void
|
||||
hash_clear (Hash_table *table)
|
||||
{
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *cursor;
|
||||
|
||||
for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
|
||||
{
|
||||
if (bucket->data)
|
||||
{
|
||||
struct hash_entry *cursor;
|
||||
struct hash_entry *next;
|
||||
|
||||
/* Free the bucket overflow. */
|
||||
for (cursor = bucket->next; cursor; cursor = cursor->next)
|
||||
for (cursor = bucket->next; cursor; cursor = next)
|
||||
{
|
||||
if (table->data_freer)
|
||||
(*table->data_freer) (cursor->data);
|
||||
cursor->data = NULL;
|
||||
|
||||
next = cursor->next;
|
||||
/* Relinking is done one entry at a time, as it is to be expected
|
||||
that overflows are either rare or short. */
|
||||
cursor->next = table->free_entry_list;
|
||||
@@ -995,13 +1032,14 @@ hash_print (const Hash_table *table)
|
||||
struct hash_entry *cursor;
|
||||
|
||||
if (bucket)
|
||||
printf ("%d:\n", slot);
|
||||
printf ("%d:\n", bucket - table->bucket);
|
||||
|
||||
for (cursor = bucket; cursor; cursor = cursor->next)
|
||||
{
|
||||
char *s = (char *) cursor->data;
|
||||
/* FIXME */
|
||||
printf (" %s\n", s);
|
||||
if (s)
|
||||
printf (" %s\n", s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-40
@@ -1,5 +1,5 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering <[email protected]>, 1998.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,13 +21,16 @@
|
||||
/* Make sure USE_OBSTACK is defined to 1 if you want the allocator to use
|
||||
obstacks instead of malloc, and recompile `hash.c' with same setting. */
|
||||
|
||||
#ifndef PARAMS
|
||||
# if PROTOTYPES || __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
#ifndef HASH_H_
|
||||
# define HASH_H_
|
||||
|
||||
# ifndef PARAMS
|
||||
# if PROTOTYPES || __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef unsigned (*Hash_hasher) PARAMS ((const void *, unsigned));
|
||||
typedef bool (*Hash_comparator) PARAMS ((const void *, const void *));
|
||||
@@ -54,39 +57,7 @@ struct hash_tuning
|
||||
|
||||
typedef struct hash_tuning Hash_tuning;
|
||||
|
||||
struct hash_table
|
||||
{
|
||||
/* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
|
||||
for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets
|
||||
are not empty, there are N_ENTRIES active entries in the table. */
|
||||
struct hash_entry *bucket;
|
||||
struct hash_entry *bucket_limit;
|
||||
unsigned n_buckets;
|
||||
unsigned n_buckets_used;
|
||||
unsigned n_entries;
|
||||
|
||||
/* Tuning arguments, kept in a physicaly separate structure. */
|
||||
const Hash_tuning *tuning;
|
||||
|
||||
/* Three functions are given to `hash_initialize', see the documentation
|
||||
block for this function. In a word, HASHER randomizes a user entry
|
||||
into a number up from 0 up to some maximum minus 1; COMPARATOR returns
|
||||
true if two user entries compare equally; and DATA_FREER is the cleanup
|
||||
function for a user entry. */
|
||||
Hash_hasher hasher;
|
||||
Hash_comparator comparator;
|
||||
Hash_data_freer data_freer;
|
||||
|
||||
/* A linked list of freed struct hash_entry structs. */
|
||||
struct hash_entry *free_entry_list;
|
||||
|
||||
#if USE_OBSTACK
|
||||
/* Whenever obstacks are used, it is possible to allocate all overflowed
|
||||
entries into a single stack, so they all can be freed in a single
|
||||
operation. It is not clear if the speedup is worth the trouble. */
|
||||
struct obstack entry_stack;
|
||||
#endif
|
||||
};
|
||||
struct hash_table;
|
||||
|
||||
typedef struct hash_table Hash_table;
|
||||
|
||||
@@ -118,3 +89,5 @@ void hash_free PARAMS ((Hash_table *));
|
||||
bool hash_rehash PARAMS ((Hash_table *, unsigned));
|
||||
void *hash_insert PARAMS ((Hash_table *, const void *));
|
||||
void *hash_delete PARAMS ((Hash_table *, const void *));
|
||||
|
||||
#endif
|
||||
|
||||
+6
-9
@@ -40,9 +40,7 @@
|
||||
but the more memory wasted for sparse bitsets and the longer the time
|
||||
to search for set bits. */
|
||||
|
||||
#ifndef LBITSET_ELT_WORDS
|
||||
#define LBITSET_ELT_WORDS 2
|
||||
#endif
|
||||
|
||||
typedef bitset_word lbitset_word;
|
||||
|
||||
@@ -139,9 +137,6 @@ lbitset_elt_alloc ()
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We can't use gcc_obstack_init to initialize the obstack since
|
||||
print-rtl.c now calls bitset functions, and bitset is linked
|
||||
into the gen* functions. */
|
||||
if (!lbitset_obstack_init)
|
||||
{
|
||||
lbitset_obstack_init = 1;
|
||||
@@ -184,7 +179,7 @@ lbitset_elt_alloc ()
|
||||
}
|
||||
|
||||
|
||||
/* Allocate a lbitset element. The bits are not cleared. */
|
||||
/* Allocate a lbitset element. The bits are cleared. */
|
||||
static inline lbitset_elt *
|
||||
lbitset_elt_calloc ()
|
||||
{
|
||||
@@ -590,7 +585,8 @@ lbitset_set (dst, bitno)
|
||||
|
||||
lbitset_elt_find (dst, windex, LBITSET_CREATE);
|
||||
|
||||
dst->b.cdata[windex - dst->b.cindex] |= (1 << (bitno % BITSET_WORD_BITS));
|
||||
dst->b.cdata[windex - dst->b.cindex] |=
|
||||
(bitset_word) 1 << (bitno % BITSET_WORD_BITS);
|
||||
}
|
||||
|
||||
|
||||
@@ -605,7 +601,8 @@ lbitset_reset (dst, bitno)
|
||||
if (!lbitset_elt_find (dst, windex, LBITSET_FIND))
|
||||
return;
|
||||
|
||||
dst->b.cdata[windex - dst->b.cindex] &= ~(1 << (bitno % BITSET_WORD_BITS));
|
||||
dst->b.cdata[windex - dst->b.cindex] &=
|
||||
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||
|
||||
/* If all the data is zero, perhaps we should unlink it now... */
|
||||
}
|
||||
@@ -956,7 +953,7 @@ lbitset_op1 (dst, op)
|
||||
{
|
||||
/* Create new elements if they cannot be found. */
|
||||
elt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||
memset (elt->words, ~0, sizeof (elt->words));
|
||||
memset (elt->words, -1, sizeof (elt->words));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _LBITSET_H
|
||||
#define _LBITSET_H
|
||||
#define _LBITSET_H
|
||||
|
||||
#include "bbitset.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/* Fake libiberty.h for Bison.
|
||||
Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
/* Bison depends on libiberty's implementation of bitsets, which
|
||||
requires a `libiberty.h' file. This file provides the minimum
|
||||
services. */
|
||||
|
||||
#ifndef BISON_LIBIBERTY_H_
|
||||
# define BISON_LIBIBERTY_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
# include <stdlib.h>
|
||||
|
||||
/* This file is the public interface to the bitset abstract data type.
|
||||
Only use the functions and macros defined in this file. */
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
# endif
|
||||
|
||||
# include "xalloc.h"
|
||||
|
||||
#endif /* ! BISON_LIBIBERTY_H_ */
|
||||
+386
@@ -0,0 +1,386 @@
|
||||
/* Copyright (C) 1991, 1993, 1995, 1997, 1998 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund ([email protected]).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to [email protected].
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#undef __ptr_t
|
||||
#if defined __cplusplus || (defined __STDC__ && __STDC__)
|
||||
# define __ptr_t void *
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef const
|
||||
# define const
|
||||
# define __ptr_t char *
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
#ifndef __P
|
||||
# if defined __GNUC__ || (defined __STDC__ && __STDC__)
|
||||
# define __P(args) args
|
||||
# else
|
||||
# define __P(args) ()
|
||||
# endif /* GCC. */
|
||||
#endif /* Not __P. */
|
||||
|
||||
#if defined HAVE_STRING_H || defined _LIBC
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#undef memcmp
|
||||
|
||||
#ifdef _LIBC
|
||||
|
||||
# include <memcopy.h>
|
||||
# include <endian.h>
|
||||
|
||||
# if __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define WORDS_BIGENDIAN
|
||||
# endif
|
||||
|
||||
#else /* Not in the GNU C library. */
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
/* Type to use for aligned memory operations.
|
||||
This should normally be the biggest type supported by a single load
|
||||
and store. Must be an unsigned type. */
|
||||
# define op_t unsigned long int
|
||||
# define OPSIZ (sizeof(op_t))
|
||||
|
||||
/* Threshold value for when to enter the unrolled loops. */
|
||||
# define OP_T_THRES 16
|
||||
|
||||
/* Type to use for unaligned operations. */
|
||||
typedef unsigned char byte;
|
||||
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
# define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
|
||||
# else
|
||||
# define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
|
||||
# endif
|
||||
|
||||
#endif /* In the GNU C library. */
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
|
||||
#else
|
||||
# define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
|
||||
#endif
|
||||
|
||||
/* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */
|
||||
|
||||
/* The strategy of this memcmp is:
|
||||
|
||||
1. Compare bytes until one of the block pointers is aligned.
|
||||
|
||||
2. Compare using memcmp_common_alignment or
|
||||
memcmp_not_common_alignment, regarding the alignment of the other
|
||||
block after the initial byte operations. The maximum number of
|
||||
full words (of type op_t) are compared in this way.
|
||||
|
||||
3. Compare the few remaining bytes. */
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
|
||||
A and B are known to be different.
|
||||
This is needed only on little-endian machines. */
|
||||
|
||||
static int memcmp_bytes __P((op_t, op_t));
|
||||
|
||||
# ifdef __GNUC__
|
||||
__inline
|
||||
# endif
|
||||
static int
|
||||
memcmp_bytes (long unsigned int a, long unsigned int b)
|
||||
{
|
||||
long int srcp1 = (long int) &a;
|
||||
long int srcp2 = (long int) &b;
|
||||
op_t a0, b0;
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
}
|
||||
while (a0 == b0);
|
||||
return a0 - b0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int memcmp_common_alignment __P((long, long, size_t));
|
||||
|
||||
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
|
||||
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
|
||||
memory operations on `op_t's. */
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
memcmp_common_alignment (long int srcp1, long int srcp2, size_t len)
|
||||
{
|
||||
op_t a0, a1;
|
||||
op_t b0, b1;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
default: /* Avoid warning about uninitialized local variables. */
|
||||
case 2:
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= 2 * OPSIZ;
|
||||
srcp2 -= 2 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= OPSIZ;
|
||||
srcp2 -= OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return 0;
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
goto do3;
|
||||
case 1:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp1 += OPSIZ;
|
||||
srcp2 += OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
/* Fall through. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
if (a1 != b1)
|
||||
return CMP_LT_OR_GT (a1, b1);
|
||||
|
||||
do3:
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[1];
|
||||
if (a0 != b0)
|
||||
return CMP_LT_OR_GT (a0, b0);
|
||||
|
||||
do2:
|
||||
a0 = ((op_t *) srcp1)[2];
|
||||
b0 = ((op_t *) srcp2)[2];
|
||||
if (a1 != b1)
|
||||
return CMP_LT_OR_GT (a1, b1);
|
||||
|
||||
do1:
|
||||
a1 = ((op_t *) srcp1)[3];
|
||||
b1 = ((op_t *) srcp2)[3];
|
||||
if (a0 != b0)
|
||||
return CMP_LT_OR_GT (a0, b0);
|
||||
|
||||
srcp1 += 4 * OPSIZ;
|
||||
srcp2 += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
if (a1 != b1)
|
||||
return CMP_LT_OR_GT (a1, b1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int memcmp_not_common_alignment __P((long, long, size_t));
|
||||
|
||||
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
|
||||
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
|
||||
operations on `op_t', but SRCP1 *should be unaligned*. */
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static int
|
||||
memcmp_not_common_alignment (long int srcp1, long int srcp2, size_t len)
|
||||
{
|
||||
op_t a0, a1, a2, a3;
|
||||
op_t b0, b1, b2, b3;
|
||||
op_t x;
|
||||
int shl, shr;
|
||||
|
||||
/* Calculate how to shift a word read at the memory operation
|
||||
aligned srcp1 to make it aligned for comparison. */
|
||||
|
||||
shl = 8 * (srcp1 % OPSIZ);
|
||||
shr = 8 * OPSIZ - shl;
|
||||
|
||||
/* Make SRCP1 aligned by rounding it down to the beginning of the `op_t'
|
||||
it points in the middle of. */
|
||||
srcp1 &= -OPSIZ;
|
||||
|
||||
switch (len % 4)
|
||||
{
|
||||
default: /* Avoid warning about uninitialized local variables. */
|
||||
case 2:
|
||||
a1 = ((op_t *) srcp1)[0];
|
||||
a2 = ((op_t *) srcp1)[1];
|
||||
b2 = ((op_t *) srcp2)[0];
|
||||
srcp1 -= 1 * OPSIZ;
|
||||
srcp2 -= 2 * OPSIZ;
|
||||
len += 2;
|
||||
goto do1;
|
||||
case 3:
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[0];
|
||||
srcp2 -= 1 * OPSIZ;
|
||||
len += 1;
|
||||
goto do2;
|
||||
case 0:
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
return 0;
|
||||
a3 = ((op_t *) srcp1)[0];
|
||||
a0 = ((op_t *) srcp1)[1];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
srcp1 += 1 * OPSIZ;
|
||||
goto do3;
|
||||
case 1:
|
||||
a2 = ((op_t *) srcp1)[0];
|
||||
a3 = ((op_t *) srcp1)[1];
|
||||
b3 = ((op_t *) srcp2)[0];
|
||||
srcp1 += 2 * OPSIZ;
|
||||
srcp2 += 1 * OPSIZ;
|
||||
len -= 1;
|
||||
if (OP_T_THRES <= 3 * OPSIZ && len == 0)
|
||||
goto do0;
|
||||
/* Fall through. */
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
a0 = ((op_t *) srcp1)[0];
|
||||
b0 = ((op_t *) srcp2)[0];
|
||||
x = MERGE(a2, shl, a3, shr);
|
||||
if (x != b3)
|
||||
return CMP_LT_OR_GT (x, b3);
|
||||
|
||||
do3:
|
||||
a1 = ((op_t *) srcp1)[1];
|
||||
b1 = ((op_t *) srcp2)[1];
|
||||
x = MERGE(a3, shl, a0, shr);
|
||||
if (x != b0)
|
||||
return CMP_LT_OR_GT (x, b0);
|
||||
|
||||
do2:
|
||||
a2 = ((op_t *) srcp1)[2];
|
||||
b2 = ((op_t *) srcp2)[2];
|
||||
x = MERGE(a0, shl, a1, shr);
|
||||
if (x != b1)
|
||||
return CMP_LT_OR_GT (x, b1);
|
||||
|
||||
do1:
|
||||
a3 = ((op_t *) srcp1)[3];
|
||||
b3 = ((op_t *) srcp2)[3];
|
||||
x = MERGE(a1, shl, a2, shr);
|
||||
if (x != b2)
|
||||
return CMP_LT_OR_GT (x, b2);
|
||||
|
||||
srcp1 += 4 * OPSIZ;
|
||||
srcp2 += 4 * OPSIZ;
|
||||
len -= 4;
|
||||
}
|
||||
while (len != 0);
|
||||
|
||||
/* This is the right position for do0. Please don't move
|
||||
it into the loop. */
|
||||
do0:
|
||||
x = MERGE(a2, shl, a3, shr);
|
||||
if (x != b3)
|
||||
return CMP_LT_OR_GT (x, b3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rpl_memcmp (const void *s1, const void *s2, size_t len)
|
||||
{
|
||||
op_t a0;
|
||||
op_t b0;
|
||||
long int srcp1 = (long int) s1;
|
||||
long int srcp2 = (long int) s2;
|
||||
op_t res;
|
||||
|
||||
if (len >= OP_T_THRES)
|
||||
{
|
||||
/* There are at least some bytes to compare. No need to test
|
||||
for LEN == 0 in this alignment loop. */
|
||||
while (srcp2 % OPSIZ != 0)
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
/* SRCP2 is now aligned for memory operations on `op_t'.
|
||||
SRCP1 alignment determines if we can do a simple,
|
||||
aligned compare or need to shuffle bits. */
|
||||
|
||||
if (srcp1 % OPSIZ == 0)
|
||||
res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ);
|
||||
else
|
||||
res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
/* Number of bytes remaining in the interval [0..OPSIZ-1]. */
|
||||
srcp1 += len & -OPSIZ;
|
||||
srcp2 += len & -OPSIZ;
|
||||
len %= OPSIZ;
|
||||
}
|
||||
|
||||
/* There are just a few bytes to compare. Use byte memory operations. */
|
||||
while (len != 0)
|
||||
{
|
||||
a0 = ((byte *) srcp1)[0];
|
||||
b0 = ((byte *) srcp2)[0];
|
||||
srcp1 += 1;
|
||||
srcp2 += 1;
|
||||
res = a0 - b0;
|
||||
if (res != 0)
|
||||
return res;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef weak_alias
|
||||
# undef bcmp
|
||||
weak_alias (memcmp, bcmp)
|
||||
#endif
|
||||
+10
-11
@@ -6,20 +6,19 @@
|
||||
adaptation to memchr suggested by Dick Karpinski ([email protected]),
|
||||
and implemented by Roland McGrath ([email protected]).
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library 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 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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Library General Public License for more details.
|
||||
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 Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
|
||||
+10
-11
@@ -1,20 +1,19 @@
|
||||
/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library 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 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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Library General Public License for more details.
|
||||
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 Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
+24
-22
@@ -1,22 +1,24 @@
|
||||
/* obstack.c - subroutines used implicitly by object stack macros
|
||||
Copyright (C) 1988-1994,96,97,98,99,2000,2001 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1988-1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
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 Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
@@ -53,7 +55,7 @@
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# ifdef __STDC__
|
||||
# define POINTER void *
|
||||
# else
|
||||
# define POINTER char *
|
||||
@@ -84,7 +86,7 @@ union fooround {long x; double d;};
|
||||
abort gracefully or use longjump - but shouldn't return. This
|
||||
variable by default points to the internal function
|
||||
`print_and_abort'. */
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
static void print_and_abort (void);
|
||||
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
||||
# else
|
||||
@@ -112,7 +114,7 @@ struct obstack *_obstack;
|
||||
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
||||
do not allow (expr) ? void : void. */
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
@@ -154,7 +156,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
POINTER (*chunkfun) (long);
|
||||
void (*freefun) (void *);
|
||||
# else
|
||||
@@ -183,7 +185,7 @@ _obstack_begin (h, size, alignment, chunkfun, freefun)
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
# else
|
||||
@@ -212,7 +214,7 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
POINTER (*chunkfun) (POINTER, long);
|
||||
void (*freefun) (POINTER, POINTER);
|
||||
# else
|
||||
@@ -242,7 +244,7 @@ _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
# else
|
||||
@@ -343,7 +345,7 @@ _obstack_newchunk (h, length)
|
||||
This is here for debugging.
|
||||
If you use it in a program, you are probably losing. */
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
||||
obstack.h because it is just for debugging. */
|
||||
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
||||
@@ -505,7 +507,7 @@ print_and_abort ()
|
||||
/* Now define the functional versions of the obstack macros.
|
||||
Define them to simply use the corresponding macros to do the job. */
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
/* These function definitions do not work with non-ANSI preprocessors;
|
||||
they won't pass through the macro names in parentheses. */
|
||||
|
||||
@@ -616,7 +618,7 @@ POINTER (obstack_copy0) (obstack, address, length)
|
||||
return obstack_copy0 (obstack, address, length);
|
||||
}
|
||||
|
||||
# endif /* __STDC__ */
|
||||
# endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */
|
||||
|
||||
# endif /* 0 */
|
||||
|
||||
|
||||
+24
-19
@@ -1,5 +1,7 @@
|
||||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
|
||||
1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
@@ -7,20 +9,19 @@
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
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 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
|
||||
Library General Public License for more details.
|
||||
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 Library 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. */
|
||||
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. */
|
||||
|
||||
/* Summary:
|
||||
|
||||
@@ -123,7 +124,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __INT_TO_PTR
|
||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
# ifdef __STDC__
|
||||
# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0))
|
||||
# else
|
||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
||||
@@ -170,7 +175,7 @@ struct obstack /* control current object in current chunk */
|
||||
char *chunk_limit; /* address of char after current chunk */
|
||||
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
||||
int alignment_mask; /* Mask of alignment for each object. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
/* These prototypes vary based on `use_extra_arg', and we use
|
||||
casts to the prototypeless function type in all assignments,
|
||||
but having prototypes here quiets -Wstrict-prototypes. */
|
||||
@@ -194,7 +199,7 @@ struct obstack /* control current object in current chunk */
|
||||
|
||||
/* Declare the external functions we use; they are in obstack.c. */
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
extern void _obstack_newchunk (struct obstack *, int);
|
||||
extern void _obstack_free (struct obstack *, void *);
|
||||
extern int _obstack_begin (struct obstack *, int, int,
|
||||
@@ -211,7 +216,7 @@ extern int _obstack_begin_1 ();
|
||||
extern int _obstack_memory_used ();
|
||||
#endif
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
|
||||
/* Do the function-declarations after the structs
|
||||
but before defining the macros. */
|
||||
@@ -251,7 +256,7 @@ int obstack_alignment_mask (struct obstack *obstack);
|
||||
int obstack_chunk_size (struct obstack *obstack);
|
||||
int obstack_memory_used (struct obstack *obstack);
|
||||
|
||||
#endif /* __STDC__ */
|
||||
#endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */
|
||||
|
||||
/* Non-ANSI C cannot really support alternative functions for these macros,
|
||||
so we do not declare them. */
|
||||
@@ -260,7 +265,7 @@ int obstack_memory_used (struct obstack *obstack);
|
||||
more memory. This can be set to a user defined function which
|
||||
should either abort gracefully or use longjump - but shouldn't
|
||||
return. The default action is to print a message and abort. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
#if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
extern void (*obstack_alloc_failed_handler) (void);
|
||||
#else
|
||||
extern void (*obstack_alloc_failed_handler) ();
|
||||
@@ -289,7 +294,7 @@ extern int obstack_exit_failure;
|
||||
|
||||
/* To prevent prototype warnings provide complete argument list in
|
||||
standard C version. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
#if PROTOYPES || (defined __STDC__ && __STDC__)
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
@@ -584,7 +589,7 @@ __extension__ \
|
||||
(h)->object_base = (h)->next_free, \
|
||||
__INT_TO_PTR ((h)->temp))
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# if PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
|
||||
+38
-11
@@ -1,5 +1,5 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000, 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
|
||||
@@ -305,6 +305,16 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
c = arg[i];
|
||||
switch (c)
|
||||
{
|
||||
case '\0':
|
||||
if (backslash_escapes)
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0');
|
||||
STORE ('0');
|
||||
c = '0';
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
switch (quoting_style)
|
||||
{
|
||||
@@ -531,14 +541,15 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
p->style, p);
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
/* Use storage slot N to return a quoted version of argument ARG.
|
||||
ARG is of size ARGSIZE, but if that is -1, ARG is a null-terminated string.
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. N is deliberately declared with type "int"
|
||||
to allow for future extensions (using negative values). */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg,
|
||||
quotearg_n_options (int n, char const *arg, size_t argsize,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||
@@ -579,13 +590,13 @@ quotearg_n_options (int n, char const *arg,
|
||||
{
|
||||
size_t size = slotvec[n].size;
|
||||
char *val = slotvec[n].val;
|
||||
size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
size_t qsize = quotearg_buffer (val, size, arg, argsize, options);
|
||||
|
||||
if (size <= qsize)
|
||||
{
|
||||
slotvec[n].size = size = qsize + 1;
|
||||
slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size);
|
||||
quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
quotearg_buffer (val, size, arg, argsize, options);
|
||||
}
|
||||
|
||||
return val;
|
||||
@@ -595,7 +606,7 @@ quotearg_n_options (int n, char const *arg,
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, &default_quoting_options);
|
||||
return quotearg_n_options (n, arg, (size_t) -1, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -604,13 +615,29 @@ quotearg (char const *arg)
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
/* Return quoting options for STYLE, with no extra quoting. */
|
||||
static struct quoting_options
|
||||
quoting_options_from_style (enum quoting_style style)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = style;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return o;
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = s;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return quotearg_n_options (n, arg, &o);
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, (size_t) -1, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, argsize, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -625,7 +652,7 @@ quotearg_char (char const *arg, char ch)
|
||||
struct quoting_options options;
|
||||
options = default_quoting_options;
|
||||
set_char_quoting (&options, ch, 1);
|
||||
return quotearg_n_options (0, arg, &options);
|
||||
return quotearg_n_options (0, arg, (size_t) -1, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
+23
-10
@@ -1,5 +1,7 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 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
|
||||
@@ -17,6 +19,9 @@
|
||||
|
||||
/* Written by Paul Eggert <[email protected]> */
|
||||
|
||||
#ifndef QUOTEARG_H_
|
||||
# define QUOTEARG_H_ 1
|
||||
|
||||
/* Basic quoting styles. */
|
||||
enum quoting_style
|
||||
{
|
||||
@@ -30,9 +35,9 @@ enum quoting_style
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but this may change. */
|
||||
#ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
#endif
|
||||
# ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
# endif
|
||||
|
||||
/* Names of quoting styles and their corresponding values. */
|
||||
extern char const *const quoting_style_args[];
|
||||
@@ -40,13 +45,13 @@ extern enum quoting_style const quoting_style_vals[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || defined __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || defined __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The functions listed below set and use a hidden variable
|
||||
that contains the default quoting style options. */
|
||||
@@ -99,6 +104,12 @@ char *quotearg PARAMS ((char const *arg));
|
||||
options to specify the quoting method. */
|
||||
char *quotearg_n_style PARAMS ((int n, enum quoting_style s, char const *arg));
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the
|
||||
argument ARG of size ARGSIZE. This is like quotearg_n_style
|
||||
(N, S, ARG), except it can quote null bytes. */
|
||||
char *quotearg_n_style_mem PARAMS ((int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize));
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style PARAMS ((enum quoting_style s, char const *arg));
|
||||
|
||||
@@ -107,3 +118,5 @@ char *quotearg_char PARAMS ((char const *arg, char ch));
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon PARAMS ((char const *arg));
|
||||
|
||||
#endif /* !QUOTEARG_H_ */
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* strcasecmp.c -- case insensitive string comparator
|
||||
Copyright (C) 1998, 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LENGTH_LIMIT
|
||||
# define STRXCASECMP_FUNCTION strncasecmp
|
||||
# define STRXCASECMP_DECLARE_N , size_t n
|
||||
# define LENGTH_LIMIT_EXPR(Expr) Expr
|
||||
#else
|
||||
# define STRXCASECMP_FUNCTION strcasecmp
|
||||
# define STRXCASECMP_DECLARE_N /* empty */
|
||||
# define LENGTH_LIMIT_EXPR(Expr) 0
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
|
||||
/* Compare {{no more than N characters of }}strings S1 and S2,
|
||||
ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexicographically less
|
||||
than, equal to or greater than S2. */
|
||||
|
||||
int
|
||||
STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_N)
|
||||
{
|
||||
register const unsigned char *p1 = (const unsigned char *) s1;
|
||||
register const unsigned char *p2 = (const unsigned char *) s2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2 || LENGTH_LIMIT_EXPR (n == 0))
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = TOLOWER (*p1);
|
||||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
+11
-12
@@ -1,19 +1,18 @@
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library 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 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
|
||||
Library General Public License for more details.
|
||||
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 Library General Public
|
||||
License along with this program; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#define LENGTH_LIMIT
|
||||
#include "strcasecmp.c"
|
||||
+15
-12
@@ -1,21 +1,20 @@
|
||||
/* Find the length of STRING, but scan at most MAXLEN characters.
|
||||
Copyright (C) 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997, 1998, 2000-2002 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library 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 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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Library General Public License for more details.
|
||||
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 Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
@@ -25,7 +24,11 @@
|
||||
# if !STDC_HEADERS && HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
/* Temporarily redefine strnlen so that an inconsistent prototype
|
||||
(on at least AIX4.3.2.0 w/gcc-2.95.3) doesn't cause trouble. */
|
||||
# define strnlen system_strnlen
|
||||
# include <string.h>
|
||||
# undef strnlen
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/* Portable version of strrchr().
|
||||
This function is in the public domain. */
|
||||
|
||||
/*
|
||||
|
||||
@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
|
||||
|
||||
Returns a pointer to the last occurrence of the character @var{c} in
|
||||
the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
|
||||
null character, the results are undefined.
|
||||
|
||||
@end deftypefn
|
||||
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
|
||||
char *
|
||||
strrchr (s, c)
|
||||
register const char *s;
|
||||
int c;
|
||||
{
|
||||
char *rtnval = 0;
|
||||
|
||||
do {
|
||||
if (*s == c)
|
||||
rtnval = (char*) s;
|
||||
} while (*s++);
|
||||
return (rtnval);
|
||||
}
|
||||
+11
-12
@@ -3,20 +3,19 @@
|
||||
NOTE: The canonical source of this file is maintained with the GNU
|
||||
C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library 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 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
|
||||
Library General Public License for more details.
|
||||
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 Library General Public
|
||||
License along with this program; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
|
||||
+472
@@ -0,0 +1,472 @@
|
||||
/* Convert string representation of a number into an integer value.
|
||||
Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# define USE_NUMBER_GROUPING
|
||||
# define STDC_HEADERS
|
||||
# define HAVE_LIMITS_H
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stddef.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
# ifndef NULL
|
||||
# define NULL 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
# include "../locale/localeinfo.h"
|
||||
#endif
|
||||
|
||||
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
|
||||
unsigned integers. */
|
||||
#ifndef UNSIGNED
|
||||
# define UNSIGNED 0
|
||||
# define INT LONG int
|
||||
#else
|
||||
# define INT unsigned LONG int
|
||||
#endif
|
||||
|
||||
/* Determine the name. */
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol __wcstoull_l
|
||||
# else
|
||||
# define strtol __wcstoul_l
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol __strtoull_l
|
||||
# else
|
||||
# define strtol __strtoul_l
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol __wcstoll_l
|
||||
# else
|
||||
# define strtol __wcstol_l
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol __strtoll_l
|
||||
# else
|
||||
# define strtol __strtol_l
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoull
|
||||
# else
|
||||
# define strtol wcstoul
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoull
|
||||
# else
|
||||
# define strtol strtoul
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoll
|
||||
# else
|
||||
# define strtol wcstol
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoll
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If QUAD is defined, we are defining `strtoll' or `strtoull',
|
||||
operating on `long long int's. */
|
||||
#ifdef QUAD
|
||||
# define LONG long long
|
||||
# define STRTOL_LONG_MIN LONG_LONG_MIN
|
||||
# define STRTOL_LONG_MAX LONG_LONG_MAX
|
||||
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
|
||||
|
||||
/* The extra casts work around common compiler bugs,
|
||||
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||
# ifndef TYPE_SIGNED
|
||||
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
# endif
|
||||
# ifndef TYPE_MINIMUM
|
||||
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||
: (t) 0))
|
||||
# endif
|
||||
# ifndef TYPE_MAXIMUM
|
||||
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
# endif
|
||||
|
||||
# ifndef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long)
|
||||
# endif
|
||||
# ifndef LONG_LONG_MAX
|
||||
# define LONG_LONG_MAX TYPE_MAXIMUM (long long int)
|
||||
# endif
|
||||
# ifndef LONG_LONG_MIN
|
||||
# define LONG_LONG_MIN TYPE_MINIMUM (long long int)
|
||||
# endif
|
||||
|
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
|
||||
/* Work around gcc bug with using this constant. */
|
||||
static const unsigned long long int maxquad = ULONG_LONG_MAX;
|
||||
# undef STRTOL_ULONG_MAX
|
||||
# define STRTOL_ULONG_MAX maxquad
|
||||
# endif
|
||||
#else
|
||||
# define LONG long
|
||||
|
||||
# ifndef ULONG_MAX
|
||||
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
|
||||
# endif
|
||||
# ifndef LONG_MAX
|
||||
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
|
||||
# endif
|
||||
# define STRTOL_LONG_MIN LONG_MIN
|
||||
# define STRTOL_LONG_MAX LONG_MAX
|
||||
# define STRTOL_ULONG_MAX ULONG_MAX
|
||||
#endif
|
||||
|
||||
|
||||
/* We use this code also for the extended locale handling where the
|
||||
function gets as an additional argument the locale which has to be
|
||||
used. To access the values we have to redefine the _NL_CURRENT
|
||||
macro. */
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# undef _NL_CURRENT
|
||||
# define _NL_CURRENT(category, item) \
|
||||
(current->values[_NL_ITEM_INDEX (item)].string)
|
||||
# define LOCALE_PARAM , loc
|
||||
# define LOCALE_PARAM_DECL __locale_t loc;
|
||||
#else
|
||||
# define LOCALE_PARAM
|
||||
# define LOCALE_PARAM_DECL
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || defined HAVE_WCHAR_H
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIDE_CHAR
|
||||
# include <wctype.h>
|
||||
# define L_(Ch) L##Ch
|
||||
# define UCHAR_TYPE wint_t
|
||||
# define STRING_TYPE wchar_t
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# define ISSPACE(Ch) __iswspace_l ((Ch), loc)
|
||||
# define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
|
||||
# define TOUPPER(Ch) __towupper_l ((Ch), loc)
|
||||
# else
|
||||
# define ISSPACE(Ch) iswspace (Ch)
|
||||
# define ISALPHA(Ch) iswalpha (Ch)
|
||||
# define TOUPPER(Ch) towupper (Ch)
|
||||
# endif
|
||||
#else
|
||||
# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
# else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
# endif
|
||||
# define L_(Ch) Ch
|
||||
# define UCHAR_TYPE unsigned char
|
||||
# define STRING_TYPE char
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# define ISSPACE(Ch) __isspace_l ((Ch), loc)
|
||||
# define ISALPHA(Ch) __isalpha_l ((Ch), loc)
|
||||
# define TOUPPER(Ch) __toupper_l ((Ch), loc)
|
||||
# else
|
||||
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
|
||||
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
|
||||
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* For compilers which are ansi but don't define __STDC__, like SGI
|
||||
Irix-4.0.5 cc, also check whether PROTOTYPES is defined. */
|
||||
#if defined (__STDC__) || defined (PROTOTYPES)
|
||||
# define INTERNAL(X) INTERNAL1(X)
|
||||
# define INTERNAL1(X) __##X##_internal
|
||||
# define WEAKNAME(X) WEAKNAME1(X)
|
||||
#else
|
||||
# define INTERNAL(X) __/**/X/**/_internal
|
||||
#endif
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
/* This file defines a function to check for correct grouping. */
|
||||
# include "grouping.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
|
||||
If BASE is 0 the base is determined by the presence of a leading
|
||||
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
|
||||
If BASE is < 2 or > 36, it is reset to 10.
|
||||
If ENDPTR is not NULL, a pointer to the character after the last
|
||||
one converted is stored in *ENDPTR. */
|
||||
|
||||
INT
|
||||
INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM)
|
||||
const STRING_TYPE *nptr;
|
||||
STRING_TYPE **endptr;
|
||||
int base;
|
||||
int group;
|
||||
LOCALE_PARAM_DECL
|
||||
{
|
||||
int negative;
|
||||
register unsigned LONG int cutoff;
|
||||
register unsigned int cutlim;
|
||||
register unsigned LONG int i;
|
||||
register const STRING_TYPE *s;
|
||||
register UCHAR_TYPE c;
|
||||
const STRING_TYPE *save, *end;
|
||||
int overflow;
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
struct locale_data *current = loc->__locales[LC_NUMERIC];
|
||||
# endif
|
||||
/* The thousands character of the current locale. */
|
||||
wchar_t thousands = L'\0';
|
||||
/* The numeric grouping specification of the current locale,
|
||||
in the format described in <locale.h>. */
|
||||
const char *grouping;
|
||||
|
||||
if (group)
|
||||
{
|
||||
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
||||
if (*grouping <= 0 || *grouping == CHAR_MAX)
|
||||
grouping = NULL;
|
||||
else
|
||||
{
|
||||
/* Figure out the thousands separator character. */
|
||||
# if defined _LIBC || defined _HAVE_BTOWC
|
||||
thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP));
|
||||
if (thousands == WEOF)
|
||||
thousands = L'\0';
|
||||
# endif
|
||||
if (thousands == L'\0')
|
||||
grouping = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
grouping = NULL;
|
||||
#endif
|
||||
|
||||
if (base < 0 || base == 1 || base > 36)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
save = s = nptr;
|
||||
|
||||
/* Skip white space. */
|
||||
while (ISSPACE (*s))
|
||||
++s;
|
||||
if (*s == L_('\0'))
|
||||
goto noconv;
|
||||
|
||||
/* Check for a sign. */
|
||||
if (*s == L_('-'))
|
||||
{
|
||||
negative = 1;
|
||||
++s;
|
||||
}
|
||||
else if (*s == L_('+'))
|
||||
{
|
||||
negative = 0;
|
||||
++s;
|
||||
}
|
||||
else
|
||||
negative = 0;
|
||||
|
||||
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
|
||||
if (*s == L_('0'))
|
||||
{
|
||||
if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X'))
|
||||
{
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
else if (base == 0)
|
||||
base = 8;
|
||||
}
|
||||
else if (base == 0)
|
||||
base = 10;
|
||||
|
||||
/* Save the pointer so we can check later if anything happened. */
|
||||
save = s;
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
if (group)
|
||||
{
|
||||
/* Find the end of the digit string and check its grouping. */
|
||||
end = s;
|
||||
for (c = *end; c != L_('\0'); c = *++end)
|
||||
if ((wchar_t) c != thousands
|
||||
&& ((wchar_t) c < L_('0') || (wchar_t) c > L_('9'))
|
||||
&& (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base))
|
||||
break;
|
||||
if (*s == thousands)
|
||||
end = s;
|
||||
else
|
||||
end = correctly_grouped_prefix (s, end, thousands, grouping);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
end = NULL;
|
||||
|
||||
cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base;
|
||||
cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base;
|
||||
|
||||
overflow = 0;
|
||||
i = 0;
|
||||
for (c = *s; c != L_('\0'); c = *++s)
|
||||
{
|
||||
if (s == end)
|
||||
break;
|
||||
if (c >= L_('0') && c <= L_('9'))
|
||||
c -= L_('0');
|
||||
else if (ISALPHA (c))
|
||||
c = TOUPPER (c) - L_('A') + 10;
|
||||
else
|
||||
break;
|
||||
if ((int) c >= base)
|
||||
break;
|
||||
/* Check for overflow. */
|
||||
if (i > cutoff || (i == cutoff && c > cutlim))
|
||||
overflow = 1;
|
||||
else
|
||||
{
|
||||
i *= (unsigned LONG int) base;
|
||||
i += c;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if anything actually happened. */
|
||||
if (s == save)
|
||||
goto noconv;
|
||||
|
||||
/* Store in ENDPTR the address of one character
|
||||
past the last character we converted. */
|
||||
if (endptr != NULL)
|
||||
*endptr = (STRING_TYPE *) s;
|
||||
|
||||
#if !UNSIGNED
|
||||
/* Check for a value that is within the range of
|
||||
`unsigned LONG int', but outside the range of `LONG int'. */
|
||||
if (overflow == 0
|
||||
&& i > (negative
|
||||
? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
|
||||
: (unsigned LONG int) STRTOL_LONG_MAX))
|
||||
overflow = 1;
|
||||
#endif
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
#if UNSIGNED
|
||||
return STRTOL_ULONG_MAX;
|
||||
#else
|
||||
return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the result of the appropriate sign. */
|
||||
return negative ? -i : i;
|
||||
|
||||
noconv:
|
||||
/* We must handle a special case here: the base is 0 or 16 and the
|
||||
first two characters are '0' and 'x', but the rest are no
|
||||
hexadecimal digits. This is no error case. We return 0 and
|
||||
ENDPTR points to the `x`. */
|
||||
if (endptr != NULL)
|
||||
{
|
||||
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
|
||||
&& save[-2] == L_('0'))
|
||||
*endptr = (STRING_TYPE *) &save[-1];
|
||||
else
|
||||
/* There was no number to convert. */
|
||||
*endptr = (STRING_TYPE *) nptr;
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/* External user entry point. */
|
||||
|
||||
#if _LIBC - 0 == 0
|
||||
# undef PARAMS
|
||||
# if defined (__STDC__) && __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
|
||||
/* Prototype. */
|
||||
INT strtol PARAMS ((const STRING_TYPE *nptr, STRING_TYPE **endptr, int base));
|
||||
#endif
|
||||
|
||||
|
||||
INT
|
||||
#ifdef weak_function
|
||||
weak_function
|
||||
#endif
|
||||
strtol (nptr, endptr, base LOCALE_PARAM)
|
||||
const STRING_TYPE *nptr;
|
||||
STRING_TYPE **endptr;
|
||||
int base;
|
||||
LOCALE_PARAM_DECL
|
||||
{
|
||||
return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
|
||||
}
|
||||
+10
-11
@@ -1,20 +1,19 @@
|
||||
/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
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.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
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 Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 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; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
|
||||
+556
@@ -0,0 +1,556 @@
|
||||
/* Timing variables for measuring compiler performance.
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC 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.
|
||||
|
||||
GCC 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 GCC; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#if IN_GCC
|
||||
|
||||
/* These are the original includes --akim. */
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "intl.h"
|
||||
#include "rtl.h"
|
||||
|
||||
#else
|
||||
|
||||
/* These are my replacements by hand --akim.
|
||||
There is another change below, flag with IN_GCC. */
|
||||
# include "../src/system.h"
|
||||
int time_report = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOCK_T
|
||||
typedef int clock_t;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_TMS
|
||||
struct tms
|
||||
{
|
||||
clock_t tms_utime;
|
||||
clock_t tms_stime;
|
||||
clock_t tms_cutime;
|
||||
clock_t tms_cstime;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
|
||||
extern int getrusage PARAMS ((int, struct rusage *));
|
||||
#endif
|
||||
#if defined HAVE_DECL_TIMES && !HAVE_DECL_TIMES
|
||||
extern clock_t times PARAMS ((struct tms *));
|
||||
#endif
|
||||
#if defined HAVE_DECL_CLOCK && !HAVE_DECL_CLOCK
|
||||
extern clock_t clock PARAMS ((void));
|
||||
#endif
|
||||
|
||||
#ifndef RUSAGE_SELF
|
||||
# define RUSAGE_SELF 0
|
||||
#endif
|
||||
|
||||
/* Calculation of scale factor to convert ticks to microseconds.
|
||||
We mustn't use CLOCKS_PER_SEC except with clock(). */
|
||||
#if HAVE_SYSCONF && defined _SC_CLK_TCK
|
||||
# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
|
||||
#else
|
||||
# ifdef CLK_TCK
|
||||
# define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */
|
||||
# else
|
||||
# ifdef HZ
|
||||
# define TICKS_PER_SECOND HZ /* traditional UNIX */
|
||||
# else
|
||||
# define TICKS_PER_SECOND 100 /* often the correct value */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Prefer times to getrusage to clock (each gives successively less
|
||||
information). */
|
||||
#ifdef HAVE_TIMES
|
||||
# define USE_TIMES
|
||||
# define HAVE_USER_TIME
|
||||
# define HAVE_SYS_TIME
|
||||
# define HAVE_WALL_TIME
|
||||
#else
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
# define USE_GETRUSAGE
|
||||
# define HAVE_USER_TIME
|
||||
# define HAVE_SYS_TIME
|
||||
#else
|
||||
#ifdef HAVE_CLOCK
|
||||
# define USE_CLOCK
|
||||
# define HAVE_USER_TIME
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* libc is very likely to have snuck a call to sysconf() into one of
|
||||
the underlying constants, and that can be very slow, so we have to
|
||||
precompute them. Whose wonderful idea was it to make all those
|
||||
_constants_ variable at run time, anyway? */
|
||||
#ifdef USE_TIMES
|
||||
static float ticks_to_msec;
|
||||
#define TICKS_TO_MSEC (1 / (float)TICKS_PER_SECOND)
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLOCK
|
||||
static float clocks_to_msec;
|
||||
#define CLOCKS_TO_MSEC (1 / (float)CLOCKS_PER_SEC)
|
||||
#endif
|
||||
|
||||
#if IN_GCC
|
||||
#include "flags.h"
|
||||
#endif
|
||||
#include "timevar.h"
|
||||
|
||||
/* See timevar.h for an explanation of timing variables. */
|
||||
|
||||
/* This macro evaluates to non-zero if timing variables are enabled. */
|
||||
#define TIMEVAR_ENABLE (time_report)
|
||||
|
||||
/* A timing variable. */
|
||||
|
||||
struct timevar_def
|
||||
{
|
||||
/* Elapsed time for this variable. */
|
||||
struct timevar_time_def elapsed;
|
||||
|
||||
/* If this variable is timed independently of the timing stack,
|
||||
using timevar_start, this contains the start time. */
|
||||
struct timevar_time_def start_time;
|
||||
|
||||
/* The name of this timing variable. */
|
||||
const char *name;
|
||||
|
||||
/* Non-zero if this timing variable is running as a standalone
|
||||
timer. */
|
||||
unsigned standalone : 1;
|
||||
|
||||
/* Non-zero if this timing variable was ever started or pushed onto
|
||||
the timing stack. */
|
||||
unsigned used : 1;
|
||||
};
|
||||
|
||||
/* An element on the timing stack. Elapsed time is attributed to the
|
||||
topmost timing variable on the stack. */
|
||||
|
||||
struct timevar_stack_def
|
||||
{
|
||||
/* The timing variable at this stack level. */
|
||||
struct timevar_def *timevar;
|
||||
|
||||
/* The next lower timing variable context in the stack. */
|
||||
struct timevar_stack_def *next;
|
||||
};
|
||||
|
||||
/* Declared timing variables. Constructed from the contents of
|
||||
timevar.def. */
|
||||
static struct timevar_def timevars[TIMEVAR_LAST];
|
||||
|
||||
/* The top of the timing stack. */
|
||||
static struct timevar_stack_def *stack;
|
||||
|
||||
/* A list of unused (i.e. allocated and subsequently popped)
|
||||
timevar_stack_def instances. */
|
||||
static struct timevar_stack_def *unused_stack_instances;
|
||||
|
||||
/* The time at which the topmost element on the timing stack was
|
||||
pushed. Time elapsed since then is attributed to the topmost
|
||||
element. */
|
||||
static struct timevar_time_def start_time;
|
||||
|
||||
static void get_time
|
||||
PARAMS ((struct timevar_time_def *));
|
||||
static void timevar_accumulate
|
||||
PARAMS ((struct timevar_time_def *, struct timevar_time_def *,
|
||||
struct timevar_time_def *));
|
||||
|
||||
/* Fill the current times into TIME. The definition of this function
|
||||
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
|
||||
HAVA_WALL_TIME macros. */
|
||||
|
||||
static void
|
||||
get_time (now)
|
||||
struct timevar_time_def *now;
|
||||
{
|
||||
now->user = 0;
|
||||
now->sys = 0;
|
||||
now->wall = 0;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
{
|
||||
#ifdef USE_TIMES
|
||||
struct tms tms;
|
||||
now->wall = times (&tms) * ticks_to_msec;
|
||||
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
|
||||
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
|
||||
#endif
|
||||
#ifdef USE_GETRUSAGE
|
||||
struct rusage rusage;
|
||||
getrusage (RUSAGE_SELF, &rusage);
|
||||
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||
getrusage (RUSAGE_CHILDREN, &rusage);
|
||||
now->user += rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||
now->sys += rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
now->user = clock () * clocks_to_msec;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the difference between STOP_TIME and START_TIME to TIMER. */
|
||||
|
||||
static void
|
||||
timevar_accumulate (timer, start_time, stop_time)
|
||||
struct timevar_time_def *timer;
|
||||
struct timevar_time_def *start_time;
|
||||
struct timevar_time_def *stop_time;
|
||||
{
|
||||
timer->user += stop_time->user - start_time->user;
|
||||
timer->sys += stop_time->sys - start_time->sys;
|
||||
timer->wall += stop_time->wall - start_time->wall;
|
||||
}
|
||||
|
||||
/* Initialize timing variables. */
|
||||
|
||||
void
|
||||
init_timevar ()
|
||||
{
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Zero all elapsed times. */
|
||||
memset ((void *) timevars, 0, sizeof (timevars));
|
||||
|
||||
/* Initialize the names of timing variables. */
|
||||
#define DEFTIMEVAR(identifier__, name__) \
|
||||
timevars[identifier__].name = name__;
|
||||
#include "timevar.def"
|
||||
#undef DEFTIMEVAR
|
||||
|
||||
#ifdef USE_TIMES
|
||||
ticks_to_msec = TICKS_TO_MSEC;
|
||||
#endif
|
||||
#ifdef USE_CLOCK
|
||||
clocks_to_msec = CLOCKS_TO_MSEC;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Push TIMEVAR onto the timing stack. No further elapsed time is
|
||||
attributed to the previous topmost timing variable on the stack;
|
||||
subsequent elapsed time is attributed to TIMEVAR, until it is
|
||||
popped or another element is pushed on top.
|
||||
|
||||
TIMEVAR cannot be running as a standalone timer. */
|
||||
|
||||
void
|
||||
timevar_push (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_stack_def *context;
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Mark this timing variable as used. */
|
||||
tv->used = 1;
|
||||
|
||||
/* Can't push a standalone timer. */
|
||||
if (tv->standalone)
|
||||
abort ();
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* If the stack isn't empty, attribute the current elapsed time to
|
||||
the old topmost element. */
|
||||
if (stack)
|
||||
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to
|
||||
TIMEVAR. */
|
||||
start_time = now;
|
||||
|
||||
/* See if we have a previously-allocated stack instance. If so,
|
||||
take it off the list. If not, malloc a new one. */
|
||||
if (unused_stack_instances != NULL)
|
||||
{
|
||||
context = unused_stack_instances;
|
||||
unused_stack_instances = unused_stack_instances->next;
|
||||
}
|
||||
else
|
||||
context = (struct timevar_stack_def *)
|
||||
xmalloc (sizeof (struct timevar_stack_def));
|
||||
|
||||
/* Fill it in and put it on the stack. */
|
||||
context->timevar = tv;
|
||||
context->next = stack;
|
||||
stack = context;
|
||||
}
|
||||
|
||||
/* Pop the topmost timing variable element off the timing stack. The
|
||||
popped variable must be TIMEVAR. Elapsed time since the that
|
||||
element was pushed on, or since it was last exposed on top of the
|
||||
stack when the element above it was popped off, is credited to that
|
||||
timing variable. */
|
||||
|
||||
void
|
||||
timevar_pop (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_time_def now;
|
||||
struct timevar_stack_def *popped = stack;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
if (&timevars[timevar] != stack->timevar)
|
||||
abort ();
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* Attribute the elapsed time to the element we're popping. */
|
||||
timevar_accumulate (&popped->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to the
|
||||
element just exposed on the stack. */
|
||||
start_time = now;
|
||||
|
||||
/* Take the item off the stack. */
|
||||
stack = stack->next;
|
||||
|
||||
/* Don't delete the stack element; instead, add it to the list of
|
||||
unused elements for later use. */
|
||||
popped->next = unused_stack_instances;
|
||||
unused_stack_instances = popped;
|
||||
}
|
||||
|
||||
/* Start timing TIMEVAR independently of the timing stack. Elapsed
|
||||
time until timevar_stop is called for the same timing variable is
|
||||
attributed to TIMEVAR. */
|
||||
|
||||
void
|
||||
timevar_start (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Mark this timing variable as used. */
|
||||
tv->used = 1;
|
||||
|
||||
/* Don't allow the same timing variable to be started more than
|
||||
once. */
|
||||
if (tv->standalone)
|
||||
abort ();
|
||||
tv->standalone = 1;
|
||||
|
||||
get_time (&tv->start_time);
|
||||
}
|
||||
|
||||
/* Stop timing TIMEVAR. Time elapsed since timevar_start was called
|
||||
is attributed to it. */
|
||||
|
||||
void
|
||||
timevar_stop (timevar)
|
||||
timevar_id_t timevar;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* TIMEVAR must have been started via timevar_start. */
|
||||
if (!tv->standalone)
|
||||
abort ();
|
||||
|
||||
get_time (&now);
|
||||
timevar_accumulate (&tv->elapsed, &tv->start_time, &now);
|
||||
}
|
||||
|
||||
/* Fill the elapsed time for TIMEVAR into ELAPSED. Returns
|
||||
update-to-date information even if TIMEVAR is currently running. */
|
||||
|
||||
void
|
||||
timevar_get (timevar, elapsed)
|
||||
timevar_id_t timevar;
|
||||
struct timevar_time_def *elapsed;
|
||||
{
|
||||
struct timevar_def *tv = &timevars[timevar];
|
||||
struct timevar_time_def now;
|
||||
|
||||
*elapsed = tv->elapsed;
|
||||
|
||||
/* Is TIMEVAR currently running as a standalone timer? */
|
||||
if (tv->standalone)
|
||||
{
|
||||
get_time (&now);
|
||||
timevar_accumulate (elapsed, &tv->start_time, &now);
|
||||
}
|
||||
/* Or is TIMEVAR at the top of the timer stack? */
|
||||
else if (stack->timevar == tv)
|
||||
{
|
||||
get_time (&now);
|
||||
timevar_accumulate (elapsed, &start_time, &now);
|
||||
}
|
||||
}
|
||||
|
||||
/* Summarize timing variables to FP. The timing variable TV_TOTAL has
|
||||
a special meaning -- it's considered to be the total elapsed time,
|
||||
for normalizing the others, and is displayed last. */
|
||||
|
||||
void
|
||||
timevar_print (fp)
|
||||
FILE *fp;
|
||||
{
|
||||
/* Only print stuff if we have some sort of time information. */
|
||||
#if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME)
|
||||
unsigned int /* timevar_id_t */ id;
|
||||
struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed;
|
||||
struct timevar_time_def now;
|
||||
|
||||
if (!TIMEVAR_ENABLE)
|
||||
return;
|
||||
|
||||
/* Update timing information in case we're calling this from GDB. */
|
||||
|
||||
if (fp == 0)
|
||||
fp = stderr;
|
||||
|
||||
/* What time is it? */
|
||||
get_time (&now);
|
||||
|
||||
/* If the stack isn't empty, attribute the current elapsed time to
|
||||
the old topmost element. */
|
||||
if (stack)
|
||||
timevar_accumulate (&stack->timevar->elapsed, &start_time, &now);
|
||||
|
||||
/* Reset the start time; from now on, time is attributed to
|
||||
TIMEVAR. */
|
||||
start_time = now;
|
||||
|
||||
fputs (_("\nExecution times (seconds)\n"), fp);
|
||||
for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id)
|
||||
{
|
||||
struct timevar_def *tv = &timevars[(timevar_id_t) id];
|
||||
const float tiny = 5e-3;
|
||||
|
||||
/* Don't print the total execution time here; that goes at the
|
||||
end. */
|
||||
if ((timevar_id_t) id == TV_TOTAL)
|
||||
continue;
|
||||
|
||||
/* Don't print timing variables that were never used. */
|
||||
if (!tv->used)
|
||||
continue;
|
||||
|
||||
/* Don't print timing variables if we're going to get a row of
|
||||
zeroes. */
|
||||
if (tv->elapsed.user < tiny
|
||||
&& tv->elapsed.sys < tiny
|
||||
&& tv->elapsed.wall < tiny)
|
||||
continue;
|
||||
|
||||
/* The timing variable name. */
|
||||
fprintf (fp, " %-22s:", tv->name);
|
||||
|
||||
#ifdef HAVE_USER_TIME
|
||||
/* Print user-mode time for this process. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
||||
tv->elapsed.user,
|
||||
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
||||
#endif /* HAVE_USER_TIME */
|
||||
|
||||
#ifdef HAVE_SYS_TIME
|
||||
/* Print system-mode time for this process. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
||||
tv->elapsed.sys,
|
||||
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
||||
#endif /* HAVE_SYS_TIME */
|
||||
|
||||
#ifdef HAVE_WALL_TIME
|
||||
/* Print wall clock time elapsed. */
|
||||
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
||||
tv->elapsed.wall,
|
||||
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
||||
#endif /* HAVE_WALL_TIME */
|
||||
|
||||
putc ('\n', fp);
|
||||
}
|
||||
|
||||
/* Print total time. */
|
||||
fputs (_(" TOTAL :"), fp);
|
||||
#ifdef HAVE_USER_TIME
|
||||
fprintf (fp, "%7.2f ", total->user);
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME
|
||||
fprintf (fp, "%7.2f ", total->sys);
|
||||
#endif
|
||||
#ifdef HAVE_WALL_TIME
|
||||
fprintf (fp, "%7.2f\n", total->wall);
|
||||
#endif
|
||||
|
||||
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
||||
|| defined (HAVE_WALL_TIME) */
|
||||
}
|
||||
|
||||
/* Returns time (user + system) used so far by the compiler process,
|
||||
in microseconds. */
|
||||
|
||||
long
|
||||
get_run_time ()
|
||||
{
|
||||
struct timevar_time_def total_elapsed;
|
||||
timevar_get (TV_TOTAL, &total_elapsed);
|
||||
return total_elapsed.user + total_elapsed.sys;
|
||||
}
|
||||
|
||||
/* Prints a message to stderr stating that time elapsed in STR is
|
||||
TOTAL (given in microseconds). */
|
||||
|
||||
void
|
||||
print_time (str, total)
|
||||
const char *str;
|
||||
long total;
|
||||
{
|
||||
long all_time = get_run_time ();
|
||||
fprintf (stderr,
|
||||
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
||||
str, total / 1000000, total % 1000000,
|
||||
all_time == 0 ? 0
|
||||
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* This file contains the definitions for timing variables used to -*- C -*-
|
||||
measure run-time performance of the compiler.
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC 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.
|
||||
|
||||
GCC 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 GCC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file contains timing variable definitions, used by timevar.h
|
||||
and timevar.c.
|
||||
|
||||
Syntax:
|
||||
|
||||
DEFTIMEVAR (id, name)
|
||||
|
||||
where ID is the enumeral value used to identify the timing
|
||||
variable, and NAME is a character string describing its purpose. */
|
||||
|
||||
/* The total execution time. */
|
||||
DEFTIMEVAR (TV_TOTAL , "total time")
|
||||
|
||||
/* Time spent in the reader. */
|
||||
DEFTIMEVAR (TV_READER , "reader")
|
||||
DEFTIMEVAR (TV_SCANNING , "scanner")
|
||||
DEFTIMEVAR (TV_PARSING , "parser")
|
||||
|
||||
/* Time spent handling the grammar. */
|
||||
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
|
||||
DEFTIMEVAR (TV_SETS , "computing the sets")
|
||||
DEFTIMEVAR (TV_LR0 , "LR(0)")
|
||||
DEFTIMEVAR (TV_LALR , "LALR(1)")
|
||||
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
|
||||
|
||||
/* Time spent outputing results. */
|
||||
DEFTIMEVAR (TV_REPORT , "outputing report")
|
||||
DEFTIMEVAR (TV_GRAPH , "outputing graph")
|
||||
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
|
||||
DEFTIMEVAR (TV_PARSER , "outputing parser")
|
||||
DEFTIMEVAR (TV_M4 , "running m4")
|
||||
|
||||
/* Time spent by freeing the memory :). */
|
||||
DEFTIMEVAR (TV_FREE , "freeing")
|
||||
@@ -0,0 +1,91 @@
|
||||
/* Timing variables for measuring compiler performance.
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
Contributed by Alex Samuel <samuel@codesourcery.com>
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC 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.
|
||||
|
||||
GCC 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 GCC; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#ifndef GCC_TIMEVAR_H
|
||||
#define GCC_TIMEVAR_H
|
||||
|
||||
/* Timing variables are used to measure elapsed time in various
|
||||
portions of the compiler. Each measures elapsed user, system, and
|
||||
wall-clock time, as appropriate to and supported by the host
|
||||
system.
|
||||
|
||||
Timing variables are defined using the DEFTIMEVAR macro in
|
||||
timevar.def. Each has an enumeral identifier, used when referring
|
||||
to the timing variable in code, and a character string name.
|
||||
|
||||
Timing variables can be used in two ways:
|
||||
|
||||
- On the timing stack, using timevar_push and timevar_pop.
|
||||
Timing variables may be pushed onto the stack; elapsed time is
|
||||
attributed to the topmost timing variable on the stack. When
|
||||
another variable is pushed on, the previous topmost variable is
|
||||
`paused' until the pushed variable is popped back off.
|
||||
|
||||
- As a standalone timer, using timevar_start and timevar_stop.
|
||||
All time elapsed between the two calls is attributed to the
|
||||
variable.
|
||||
*/
|
||||
|
||||
/* This structure stores the various varieties of time that can be
|
||||
measured. Times are stored in seconds. The time may be an
|
||||
absolute time or a time difference; in the former case, the time
|
||||
base is undefined, except that the difference between two times
|
||||
produces a valid time difference. */
|
||||
|
||||
struct timevar_time_def
|
||||
{
|
||||
/* User time in this process. */
|
||||
float user;
|
||||
|
||||
/* System time (if applicable for this host platform) in this
|
||||
process. */
|
||||
float sys;
|
||||
|
||||
/* Wall clock time. */
|
||||
float wall;
|
||||
};
|
||||
|
||||
/* An enumeration of timing variable identifiers. Constructed from
|
||||
the contents of timevar.def. */
|
||||
|
||||
#define DEFTIMEVAR(identifier__, name__) \
|
||||
identifier__,
|
||||
typedef enum
|
||||
{
|
||||
#include "timevar.def"
|
||||
TIMEVAR_LAST
|
||||
}
|
||||
timevar_id_t;
|
||||
#undef DEFTIMEVAR
|
||||
|
||||
extern void init_timevar PARAMS ((void));
|
||||
extern void timevar_push PARAMS ((timevar_id_t));
|
||||
extern void timevar_pop PARAMS ((timevar_id_t));
|
||||
extern void timevar_start PARAMS ((timevar_id_t));
|
||||
extern void timevar_stop PARAMS ((timevar_id_t));
|
||||
extern void timevar_get PARAMS ((timevar_id_t, struct timevar_time_def *));
|
||||
extern void timevar_print PARAMS ((FILE *));
|
||||
|
||||
/* Provided for backward compatibility. */
|
||||
extern long get_run_time PARAMS ((void));
|
||||
extern void print_time PARAMS ((const char *, long));
|
||||
|
||||
#endif /* ! GCC_TIMEVAR_H */
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef UNLOCKED_IO_H
|
||||
# define UNLOCKED_IO_H 1
|
||||
|
||||
# ifndef USE_UNLOCKED_IO
|
||||
# define USE_UNLOCKED_IO 1
|
||||
# endif
|
||||
|
||||
# if USE_UNLOCKED_IO
|
||||
|
||||
/* These are wrappers for functions/macros from GNU libc.
|
||||
The standard I/O functions are thread-safe. These *_unlocked ones are
|
||||
more efficient but not thread-safe. That they're not thread-safe is
|
||||
fine since all of the applications in this package are single threaded. */
|
||||
|
||||
# if HAVE_DECL_CLEARERR_UNLOCKED
|
||||
# undef clearerr
|
||||
# define clearerr(x) clearerr_unlocked (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FEOF_UNLOCKED
|
||||
# undef feof
|
||||
# define feof(x) feof_unlocked (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FERROR_UNLOCKED
|
||||
# undef ferror
|
||||
# define ferror(x) ferror_unlocked (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FFLUSH_UNLOCKED
|
||||
# undef fflush
|
||||
# define fflush(x) fflush_unlocked (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FGETS_UNLOCKED
|
||||
# undef fgets
|
||||
# define fgets(x,y,z) fgets_unlocked (x,y,z)
|
||||
# endif
|
||||
# if HAVE_DECL_FPUTC_UNLOCKED
|
||||
# undef fputc
|
||||
# define fputc(x,y) fputc_unlocked (x,y)
|
||||
# endif
|
||||
# if HAVE_DECL_FPUTS_UNLOCKED
|
||||
# undef fputs
|
||||
# define fputs(x,y) fputs_unlocked (x,y)
|
||||
# endif
|
||||
# if HAVE_DECL_FREAD_UNLOCKED
|
||||
# undef fread
|
||||
# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
|
||||
# endif
|
||||
# if HAVE_DECL_FWRITE_UNLOCKED
|
||||
# undef fwrite
|
||||
# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
|
||||
# endif
|
||||
# if HAVE_DECL_GETC_UNLOCKED
|
||||
# undef getc
|
||||
# define getc(x) getc_unlocked (x)
|
||||
# endif
|
||||
# if HAVE_DECL_GETCHAR_UNLOCKED
|
||||
# undef getchar
|
||||
# define getchar() getchar_unlocked ()
|
||||
# endif
|
||||
# if HAVE_DECL_PUTC_UNLOCKED
|
||||
# undef putc
|
||||
# define putc(x,y) putc_unlocked (x,y)
|
||||
# endif
|
||||
# if HAVE_DECL_PUTCHAR_UNLOCKED
|
||||
# undef putchar
|
||||
# define putchar(x) putchar_unlocked (x)
|
||||
# endif
|
||||
|
||||
# endif /* USE_UNLOCKED_IO */
|
||||
#endif /* UNLOCKED_IO_H */
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1999, 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
|
||||
@@ -46,12 +46,12 @@ void free ();
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
"you must run the autoconf test for a properly working malloc -- see malloc.m4"
|
||||
#ifndef HAVE_MALLOC
|
||||
"you must run the autoconf test for a properly working malloc"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
"you must run the autoconf test for a properly working realloc --see realloc.m4"
|
||||
#ifndef HAVE_REALLOC
|
||||
"you must run the autoconf test for a properly working realloc"
|
||||
#endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
|
||||
@@ -1,14 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
||||
# From Gettext
|
||||
codeset.m4
|
||||
gettext.m4
|
||||
glibc21.m4
|
||||
iconv.m4
|
||||
isc-posix.m4
|
||||
lcmessage.m4
|
||||
lib-ld.m4
|
||||
lib-link.m4
|
||||
lib-prefix.m4
|
||||
progtest.m4
|
||||
|
||||
+5
-20
@@ -1,21 +1,6 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
EXTRA_DIST = lib-ld.m4 lib-link.m4 lib-prefix.m4 \
|
||||
c-bs-a.m4 \
|
||||
codeset.m4 \
|
||||
dmalloc.m4 \
|
||||
error.m4 \
|
||||
gettext.m4 \
|
||||
glibc21.m4 \
|
||||
iconv.m4 \
|
||||
isc-posix.m4 \
|
||||
lcmessage.m4 \
|
||||
m4.m4 \
|
||||
malloc.m4 \
|
||||
mbrtowc.m4 \
|
||||
mbstate_t.m4 \
|
||||
mkstemp.m4 \
|
||||
prereq.m4 \
|
||||
progtest.m4 \
|
||||
realloc.m4 \
|
||||
strerror_r.m4 \
|
||||
warning.m4
|
||||
EXTRA_DIST = \
|
||||
dmalloc.m4 error.m4 \
|
||||
m4.m4 mbrtowc.m4 memcmp.m4 mkstemp.m4 \
|
||||
prereq.m4 strerror_r.m4 timevar.m4 warning.m4 \
|
||||
gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#serial 4
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
AC_DEFUN([AC_C_BACKSLASH_A],
|
||||
[
|
||||
AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
|
||||
[AC_TRY_COMPILE([],
|
||||
[
|
||||
#if '\a' == 'a'
|
||||
syntax error;
|
||||
#endif
|
||||
char buf['\a' == 'a' ? -1 : 1];
|
||||
buf[0] = '\a';
|
||||
return buf[0] != "\a"[0];
|
||||
],
|
||||
ac_cv_c_backslash_a=yes,
|
||||
ac_cv_c_backslash_a=no)])
|
||||
if test $ac_cv_c_backslash_a = yes; then
|
||||
AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
|
||||
[Define if backslash-a works in C strings.])
|
||||
fi
|
||||
])
|
||||
@@ -1,34 +0,0 @@
|
||||
#serial 5
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether malloc accepts 0 as its argument.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([jm_FUNC_MALLOC],
|
||||
[
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
||||
AC_DEFINE(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
|
||||
[Define if the malloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
||||
[AC_TRY_RUN([
|
||||
char *malloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (malloc (0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_malloc=yes,
|
||||
jm_cv_func_working_malloc=no,
|
||||
dnl When crosscompiling, assume malloc is broken.
|
||||
jm_cv_func_working_malloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_malloc = no; then
|
||||
AC_LIBOBJ(malloc)
|
||||
AC_DEFINE(malloc, rpl_malloc,
|
||||
[Define to rpl_malloc if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
+7
-1
@@ -1,4 +1,10 @@
|
||||
#serial 4
|
||||
# mbrtowc.m4 serial 4 (fileutils-4.1.3)
|
||||
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
|
||||
dnl This file is free software, distributed under the terms of the GNU
|
||||
dnl General Public License. As a special exception to the GNU General
|
||||
dnl Public License, this file may be distributed as part of a program
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
dnl From Paul Eggert
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# serial 9
|
||||
|
||||
# From Paul Eggert.
|
||||
|
||||
# BeOS 5 has <wchar.h> but does not define mbstate_t,
|
||||
# so you can't declare an object of that type.
|
||||
# Check for this incompatibility with Standard C.
|
||||
|
||||
# Include stdlib.h first, because otherwise this test would fail on Linux
|
||||
# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
|
||||
# a syntax error in wchar.h due to the use of undefined __int32_t.
|
||||
|
||||
AC_DEFUN([AC_MBSTATE_T],
|
||||
[
|
||||
AC_CHECK_HEADERS(stdlib.h)
|
||||
|
||||
AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
|
||||
[AC_TRY_COMPILE([
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#include <wchar.h>],
|
||||
[mbstate_t x; return sizeof x;],
|
||||
ac_cv_type_mbstate_t=yes,
|
||||
ac_cv_type_mbstate_t=no)])
|
||||
if test $ac_cv_type_mbstate_t = no; then
|
||||
AC_DEFINE(mbstate_t, int,
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
fi])
|
||||
@@ -0,0 +1,9 @@
|
||||
#serial 7
|
||||
|
||||
AC_DEFUN([jm_FUNC_MEMCMP],
|
||||
[AC_REQUIRE([AC_FUNC_MEMCMP])dnl
|
||||
if test $ac_cv_func_memcmp_working = no; then
|
||||
AC_DEFINE(memcmp, rpl_memcmp,
|
||||
[Define to rpl_memcmp if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
+255
-5
@@ -1,15 +1,265 @@
|
||||
#serial 2
|
||||
#serial 28 -*- Autoconf -*-
|
||||
|
||||
dnl These are the prerequisite macros for files in the lib/
|
||||
dnl directories of Bison.
|
||||
dnl We use jm_ for non Autoconf macros.
|
||||
m4_pattern_forbid([^jm_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
|
||||
|
||||
# These are the prerequisite macros for files in the lib/
|
||||
# directories of the fileutils, sh-utils, and textutils packages.
|
||||
|
||||
AC_DEFUN([jm_PREREQ],
|
||||
[
|
||||
jm_PREREQ_ADDEXT
|
||||
jm_PREREQ_C_STACK
|
||||
jm_PREREQ_CANON_HOST
|
||||
jm_PREREQ_DIRNAME
|
||||
jm_PREREQ_ERROR
|
||||
jm_PREREQ_EXCLUDE
|
||||
jm_PREREQ_GETPAGESIZE
|
||||
jm_PREREQ_HARD_LOCALE
|
||||
jm_PREREQ_HASH
|
||||
jm_PREREQ_HUMAN
|
||||
jm_PREREQ_MBSWIDTH
|
||||
jm_PREREQ_MEMCHR
|
||||
jm_PREREQ_PHYSMEM
|
||||
jm_PREREQ_POSIXVER
|
||||
jm_PREREQ_QUOTEARG
|
||||
jm_PREREQ_READUTMP
|
||||
jm_PREREQ_REGEX
|
||||
jm_PREREQ_STAT
|
||||
jm_PREREQ_STRNLEN
|
||||
jm_PREREQ_TEMPNAME # called by mkstemp
|
||||
jm_PREREQ_XGETCWD
|
||||
jm_PREREQ_XREADLINK
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_ARGMATCH],
|
||||
[
|
||||
AC_REQUIRE([jm_PREREQ_QUOTEARG])
|
||||
AC_REPLACE_FUNCS(strcasecmp strncasecmp)
|
||||
])
|
||||
|
||||
# Ask for argmatch.[ch], and set it up.
|
||||
AC_DEFUN([jm_FUNC_ARGMATCH],
|
||||
[
|
||||
AC_REQUIRE([jm_PREREQ_ARGMATCH])
|
||||
AC_LIBOBJ([argmatch])
|
||||
AC_LIBSOURCES([argmatch.c, argmatch.h])
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_ADDEXT],
|
||||
[
|
||||
dnl For addext.c.
|
||||
AC_SYS_LONG_FILE_NAMES
|
||||
AC_CHECK_FUNCS(pathconf)
|
||||
AC_CHECK_HEADERS(limits.h string.h unistd.h)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_CANON_HOST],
|
||||
[
|
||||
dnl Add any libraries as early as possible.
|
||||
dnl In particular, inet_ntoa needs -lnsl at least on Solaris5.5.1,
|
||||
dnl so we have to add -lnsl to LIBS before checking for that function.
|
||||
AC_SEARCH_LIBS(gethostbyname, [inet nsl])
|
||||
|
||||
dnl These come from -lnsl on Solaris5.5.1.
|
||||
AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
|
||||
|
||||
AC_CHECK_FUNCS(gethostbyname gethostbyaddr inet_ntoa)
|
||||
AC_CHECK_HEADERS(unistd.h string.h netdb.h sys/socket.h \
|
||||
netinet/in.h arpa/inet.h)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_DIRNAME],
|
||||
[
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(string.h)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_EXCLUDE],
|
||||
[
|
||||
AC_FUNC_FNMATCH_GNU
|
||||
AC_HEADER_STDBOOL
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_GETPAGESIZE],
|
||||
[
|
||||
AC_CHECK_FUNCS(getpagesize)
|
||||
AC_CHECK_HEADERS(OS.h unistd.h)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_HARD_LOCALE],
|
||||
[
|
||||
AC_CHECK_HEADERS(locale.h stdlib.h string.h)
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
AM_C_PROTOTYPES
|
||||
])
|
||||
|
||||
# AC_DEFUN([jm_PREREQ_HASH],
|
||||
# [
|
||||
# AC_CHECK_HEADERS(stdlib.h)
|
||||
# AC_HEADER_STDBOOL
|
||||
# AC_REQUIRE([jm_CHECK_DECLS])
|
||||
# ])
|
||||
|
||||
# If you use human.c, you need the following files:
|
||||
# inttypes.m4 ulonglong.m4
|
||||
AC_DEFUN([jm_PREREQ_HUMAN],
|
||||
[
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h string.h)
|
||||
AC_CHECK_DECLS([getenv])
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_MEMCHR],
|
||||
[
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h bp-sym.h)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_PHYSMEM],
|
||||
[
|
||||
AC_CHECK_HEADERS(sys/pstat.h unistd.h)
|
||||
AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_POSIXVER],
|
||||
[
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
AC_CHECK_DECLS([getenv])
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_QUOTEARG],
|
||||
[
|
||||
AC_CHECK_FUNCS(isascii iswprint mbsinit)
|
||||
AC_CHECK_FUNCS(isascii iswprint)
|
||||
jm_FUNC_MBRTOWC
|
||||
jm_FUNC_MEMCMP
|
||||
AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
|
||||
AC_HEADER_STDC
|
||||
AC_C_BACKSLASH_A
|
||||
AC_MBSTATE_T
|
||||
AC_TYPE_MBSTATE_T
|
||||
AM_C_PROTOTYPES
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_READUTMP],
|
||||
[
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(string.h utmp.h utmpx.h sys/param.h)
|
||||
AC_CHECK_FUNCS(utmpname)
|
||||
AC_CHECK_FUNCS(utmpxname)
|
||||
AM_C_PROTOTYPES
|
||||
|
||||
if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
|
||||
utmp_includes="\
|
||||
$ac_includes_default
|
||||
#ifdef HAVE_UTMPX_H
|
||||
# include <utmpx.h>
|
||||
#endif
|
||||
#ifdef HAVE_UTMP_H
|
||||
# include <utmp.h>
|
||||
#endif
|
||||
"
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_user],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_user],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_name],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_name],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_type],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_type],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_pid],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_pid],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_id],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_id],,,[$utmp_includes])
|
||||
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_exit],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_exit],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_exit],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_exit.e_exit],,,[$utmp_includes])
|
||||
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_exit.ut_termination],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_exit.ut_termination],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmpx.ut_exit.e_termination],,,[$utmp_includes])
|
||||
AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
|
||||
AC_LIBOBJ(readutmp)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_REGEX],
|
||||
[
|
||||
dnl FIXME: Maybe provide a btowc replacement someday: solaris-2.5.1 lacks it.
|
||||
dnl FIXME: Check for wctype and iswctype, and and add -lw if necessary
|
||||
dnl to get them.
|
||||
AC_CHECK_FUNCS(bzero bcopy isascii btowc)
|
||||
AC_CHECK_HEADERS(alloca.h libintl.h wctype.h wchar.h)
|
||||
AC_HEADER_STDC
|
||||
AC_FUNC_ALLOCA
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_STAT],
|
||||
[
|
||||
AC_CHECK_HEADERS(sys/sysmacros.h sys/statvfs.h sys/vfs.h inttypes.h)
|
||||
AC_CHECK_HEADERS(sys/param.h sys/mount.h)
|
||||
AC_CHECK_FUNCS(statvfs)
|
||||
jm_AC_TYPE_LONG_LONG
|
||||
|
||||
statxfs_includes="\
|
||||
$ac_includes_default
|
||||
#if HAVE_SYS_STATVFS_H
|
||||
# include <sys/statvfs.h>
|
||||
#endif
|
||||
#if HAVE_SYS_VFS_H
|
||||
# include <sys/vfs.h>
|
||||
#endif
|
||||
#if ( ! HAVE_SYS_STATVFS_H && ! HAVE_SYS_VFS_H && HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H )
|
||||
/* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
|
||||
# include <sys/param.h>
|
||||
# include <sys/mount.h>
|
||||
#endif
|
||||
"
|
||||
AC_CHECK_MEMBERS([struct statfs.f_basetype],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statvfs.f_basetype],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statfs.f_type],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statvfs.f_type],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statfs.f_fsid.__val],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statvfs.f_fsid.__val],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statfs.f_namemax],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statvfs.f_namemax],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statfs.f_namelen],,,[$statxfs_includes])
|
||||
AC_CHECK_MEMBERS([struct statvfs.f_namelen],,,[$statxfs_includes])
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_STRNLEN],
|
||||
[
|
||||
AC_FUNC_STRNLEN
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(memory.h)
|
||||
AC_CHECK_DECLS([memchr])
|
||||
|
||||
# This is necessary because automake-1.6.1 doesn't understand
|
||||
# that the above use of AC_FUNC_STRNLEN means we may have to use
|
||||
# lib/strnlen.c.
|
||||
test $ac_cv_func_strnlen_working = yes \
|
||||
&& AC_LIBOBJ(strnlen)
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_TEMPNAME],
|
||||
[
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_STAT
|
||||
AC_CHECK_HEADERS(fcntl.h sys/time.h stdint.h unistd.h)
|
||||
AC_CHECK_FUNCS(__secure_getenv gettimeofday)
|
||||
AC_CHECK_DECLS([getenv])
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_XGETCWD],
|
||||
[
|
||||
AC_C_PROTOTYPES
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h sys/param.h unistd.h)
|
||||
AC_CHECK_FUNCS(getcwd)
|
||||
AC_FUNC_GETCWD_NULL
|
||||
])
|
||||
|
||||
AC_DEFUN([jm_PREREQ_XREADLINK],
|
||||
[
|
||||
AC_C_PROTOTYPES
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h sys/types.h unistd.h)
|
||||
])
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#serial 5
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether realloc works when both arguments are 0.
|
||||
dnl If it doesn't, arrange to use the replacement function.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([jm_FUNC_REALLOC],
|
||||
[
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
||||
AC_DEFINE(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
|
||||
[Define if the realloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
||||
[AC_TRY_RUN([
|
||||
char *realloc ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
exit (realloc (0, 0) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
jm_cv_func_working_realloc=yes,
|
||||
jm_cv_func_working_realloc=no,
|
||||
dnl When crosscompiling, assume realloc is broken.
|
||||
jm_cv_func_working_realloc=no)
|
||||
])
|
||||
if test $jm_cv_func_working_realloc = no; then
|
||||
AC_LIBOBJ(realloc)
|
||||
AC_DEFINE(realloc, rpl_realloc,
|
||||
[Define to rpl_realloc if the replacement function should be used.])
|
||||
fi
|
||||
])
|
||||
@@ -0,0 +1,47 @@
|
||||
# -*-Autoconf-*-
|
||||
# Checks required to run `stage', a nonportable memory/time tracker.
|
||||
#
|
||||
# Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA
|
||||
# 02111-1307 USA
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN([BISON_PREREQ_TIMEVAR],
|
||||
[AC_CHECK_HEADERS([sys/resource.h sys/times.h])
|
||||
|
||||
AC_CHECK_FUNCS([times])
|
||||
|
||||
AC_CHECK_DECLS([getrusage, times, clock, sysconf], [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
#if HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_CHECK_TYPES([clock_t, struct tms], [], [],
|
||||
[$ac_includes_default
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
#if HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
])
|
||||
])
|
||||
+22
-1
@@ -1,4 +1,25 @@
|
||||
AC_DEFUN(BISON_WARNING,
|
||||
# Finding valid warning flags for the C Compiler. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA
|
||||
# 02111-1307 USA
|
||||
|
||||
# serial 1
|
||||
|
||||
AC_DEFUN([BISON_WARNING],
|
||||
[AC_MSG_CHECKING(whether compiler accepts $1)
|
||||
AC_SUBST(WARNING_CFLAGS)
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2002-08-08 gettextize <[email protected]>
|
||||
|
||||
* Rules-quot: New file, from gettext-0.11.5.
|
||||
* boldquot.sed: New file, from gettext-0.11.5.
|
||||
* [email protected]: New file, from gettext-0.11.5.
|
||||
* [email protected]: New file, from gettext-0.11.5.
|
||||
* insert-header.sin: New file, from gettext-0.11.5.
|
||||
* quot.sed: New file, from gettext-0.11.5.
|
||||
* remove-potcdate.sin: New file, from gettext-0.11.5.
|
||||
|
||||
2001-10-10 gettextize <[email protected]>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.40.
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
de
|
||||
es
|
||||
et
|
||||
fr
|
||||
hr
|
||||
it
|
||||
ja
|
||||
nl
|
||||
pt_BR
|
||||
ru
|
||||
sv
|
||||
tr
|
||||
+10
-2
@@ -1,16 +1,24 @@
|
||||
src/LR0.c
|
||||
src/complain.c
|
||||
src/conflicts.c
|
||||
src/files.c
|
||||
src/getargs.c
|
||||
src/gram.c
|
||||
src/lalr.c
|
||||
src/lex.c
|
||||
src/main.c
|
||||
src/parse-gram.c
|
||||
src/print.c
|
||||
src/reader.c
|
||||
src/reduce.c
|
||||
src/scan-gram.c
|
||||
src/state.c
|
||||
src/symlist.c
|
||||
src/symtab.c
|
||||
|
||||
lib/argmatch.c
|
||||
lib/bitset_stats.c
|
||||
lib/error.c
|
||||
lib/getopt.c
|
||||
lib/obstack.c
|
||||
lib/quotearg.c
|
||||
lib/timevar.c
|
||||
lib/xmalloc.c
|
||||
|
||||
@@ -0,0 +1,876 @@
|
||||
# Translation of bision to Croatian
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
# Denis Lackovic <[email protected]>, 2002.
|
||||
# This file is distributed under the same license as the bison package.
|
||||
# Denis Lackovic <[email protected]>, 2002.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.34a\n"
|
||||
"POT-Creation-Date: 2002-09-27 16:50+0200\n"
|
||||
"PO-Revision-Date: 2002-04-10 22:20+01\n"
|
||||
"Last-Translator: Denis Lackovic <[email protected]>\n"
|
||||
"Language-Team: Croatian <[email protected]>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=iso-8859-2\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n==1 ? 0 : 1);\n"
|
||||
|
||||
#: src/complain.c:89 lib/error.c:128 lib/error.c:156
|
||||
msgid "Unknown system error"
|
||||
msgstr "Nepoznata sistemska gre¹ka"
|
||||
|
||||
#: src/complain.c:123 src/complain.c:152
|
||||
msgid "warning: "
|
||||
msgstr "upozorenje:"
|
||||
|
||||
#: src/complain.c:252 src/complain.c:282
|
||||
msgid "fatal error: "
|
||||
msgstr "fatalna gre¹ka:"
|
||||
|
||||
#: src/conflicts.c:72
|
||||
#, fuzzy, c-format
|
||||
msgid " Conflict between rule %d and token %s resolved as shift"
|
||||
msgstr "Konflikt u stanju %d izmeðu pravila %d i znaka %s razrije¹en kao %s.\n"
|
||||
|
||||
#: src/conflicts.c:80
|
||||
#, fuzzy, c-format
|
||||
msgid " Conflict between rule %d and token %s resolved as reduce"
|
||||
msgstr "Konflikt u stanju %d izmeðu pravila %d i znaka %s razrije¹en kao %s.\n"
|
||||
|
||||
#: src/conflicts.c:87
|
||||
#, fuzzy, c-format
|
||||
msgid " Conflict between rule %d and token %s resolved as an error"
|
||||
msgstr "Konflikt u stanju %d izmeðu pravila %d i znaka %s razrije¹en kao %s.\n"
|
||||
|
||||
#: src/conflicts.c:402
|
||||
#, c-format
|
||||
msgid "%d shift/reduce conflict"
|
||||
msgid_plural "%d shift/reduce conflicts"
|
||||
msgstr[0] "%d pomakni/reduciraj konflikat"
|
||||
msgstr[1] "%d pomakni/reduciraj konflikata"
|
||||
|
||||
#: src/conflicts.c:409
|
||||
msgid "and"
|
||||
msgstr "i"
|
||||
|
||||
#: src/conflicts.c:415
|
||||
#, c-format
|
||||
msgid "%d reduce/reduce conflict"
|
||||
msgid_plural "%d reduce/reduce conflicts"
|
||||
msgstr[0] "%d reduciraj/reduciraj konflikt"
|
||||
msgstr[1] "%d reduciraj/reduciraj konflikata"
|
||||
|
||||
#: src/conflicts.c:435
|
||||
msgid "conflicts: "
|
||||
msgstr "konflikt:"
|
||||
|
||||
#: src/conflicts.c:437
|
||||
#, c-format
|
||||
msgid " %d shift/reduce"
|
||||
msgstr " %d pomakni/reduciraj"
|
||||
|
||||
#: src/conflicts.c:441
|
||||
#, c-format
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d reduviraj/reduciraj"
|
||||
|
||||
#: src/conflicts.c:460
|
||||
#, c-format
|
||||
msgid "State %d contains "
|
||||
msgstr "Stanje %d sadr¾i"
|
||||
|
||||
#: src/conflicts.c:537
|
||||
#, fuzzy, c-format
|
||||
msgid "expected %d shift/reduce conflict"
|
||||
msgid_plural "expected %d shift/reduce conflicts"
|
||||
msgstr[0] "oèekujem %d pomakni/reduciraj konflikt\n"
|
||||
msgstr[1] "oèekujem %d pomakni/reduciraj konflikata\n"
|
||||
|
||||
#: src/files.c:114
|
||||
#, c-format
|
||||
msgid "cannot open file `%s'"
|
||||
msgstr "ne mogu otvoriti datoteku `%s'"
|
||||
|
||||
#: src/files.c:133
|
||||
msgid "cannot close file"
|
||||
msgstr "ne mogu zatvoriti datoteku"
|
||||
|
||||
#: src/getargs.c:157
|
||||
msgid "GNU bison generates parsers for LALR(1) grammars.\n"
|
||||
msgstr "GNU bison generira parsere za LALR(1) gramatike.\n"
|
||||
|
||||
#: src/getargs.c:161
|
||||
#, c-format
|
||||
msgid "Usage: %s [OPTION]... FILE\n"
|
||||
msgstr "Kori¹tenje: %s [OPCIJA]... DATOTEKA\n"
|
||||
|
||||
#: src/getargs.c:165
|
||||
msgid ""
|
||||
"If a long option shows an argument as mandatory, then it is mandatory\n"
|
||||
"for the equivalent short option also. Similarly for optional arguments.\n"
|
||||
msgstr ""
|
||||
"Ako duga opcija ka¾e da je argument obavezan, tada je on obavezan\n"
|
||||
"i za ekvivalentnu kratku opciju. Slièno je i za opcionalne argumente.\n"
|
||||
|
||||
#: src/getargs.c:171
|
||||
msgid ""
|
||||
"Operation modes:\n"
|
||||
" -h, --help display this help and exit\n"
|
||||
" -V, --version output version information and exit\n"
|
||||
" -y, --yacc emulate POSIX yacc\n"
|
||||
msgstr ""
|
||||
"Naèini rada:\n"
|
||||
" -h, --help prika¾i ovu pomoæ i izaði\n"
|
||||
" -V, --version prika¾i verziju i izaði\n"
|
||||
" -y, --yacc emuliraj POSIX yacc\n"
|
||||
|
||||
#: src/getargs.c:178
|
||||
msgid ""
|
||||
"Parser:\n"
|
||||
" -S, --skeleton=FILE specify the skeleton to use\n"
|
||||
" -t, --debug instrument the parser for debugging\n"
|
||||
" --locations enable locations computation\n"
|
||||
" -p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n"
|
||||
" -l, --no-lines don't generate `#line' directives\n"
|
||||
" -n, --no-parser generate the tables only\n"
|
||||
" -k, --token-table include a table of token names\n"
|
||||
msgstr ""
|
||||
"Parser:\n"
|
||||
" -S, --skeleton=DATOTEKA specificiraj kostur za uporabu\n"
|
||||
" -t, --debug pripremi parser za deugiranje\n"
|
||||
" --locations omoguæi izraèunavanje lokacija\n"
|
||||
" -p, --name-prefix=PREFIKS stavi PREFIX ispred vanjskih simbola\n"
|
||||
" -l, --no-lines ne eneriraj `#line' direktive\n"
|
||||
" -n, --no-parser generiraj samo tablice\n"
|
||||
" -k, --token-table ukljuèi tablicu imena znakova\n"
|
||||
|
||||
#: src/getargs.c:190
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Output:\n"
|
||||
" -d, --defines also produce a header file\n"
|
||||
" -r, --report=THINGS also produce details on the automaton\n"
|
||||
" -v, --verbose same as `--report=state'\n"
|
||||
" -b, --file-prefix=PREFIX specify a PREFIX for output files\n"
|
||||
" -o, --output=FILE leave output to FILE\n"
|
||||
" -g, --graph also produce a VCG description of the "
|
||||
"automaton\n"
|
||||
msgstr ""
|
||||
"Izlaz:\n"
|
||||
" -d, --defines takoðer proizvedi header datoteku\n"
|
||||
" -v, --verbose takoðer proizvedi obja¹njenje automata\n"
|
||||
" -b, --file-prefix=PREFIKS specificiraj PREFIKS za izlazne datoteke\n"
|
||||
" -o, --output=DATOTEKA ispi¹i izlaz u DATOTEKU\n"
|
||||
" -g, --graph takoðer proizvedi VCG opis automata\n"
|
||||
|
||||
#: src/getargs.c:201
|
||||
msgid ""
|
||||
"THINGS is a list of comma separated words that can include:\n"
|
||||
" `state' describe the states\n"
|
||||
" `itemset' complete the core item sets with their closure\n"
|
||||
" `lookahead' explicitly associate lookaheads to items\n"
|
||||
" `solved' describe shift/reduce conflicts solving\n"
|
||||
" `all' include all the above information\n"
|
||||
" `none' disable the report\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/getargs.c:212
|
||||
msgid "Report bugs to <[email protected]>.\n"
|
||||
msgstr "Izvjesti o bugovima na <[email protected]>.\n"
|
||||
|
||||
#: src/getargs.c:226
|
||||
#, c-format
|
||||
msgid "bison (GNU Bison) %s"
|
||||
msgstr "bison (GNU Bison) %s"
|
||||
|
||||
#: src/getargs.c:228
|
||||
msgid "Written by Robert Corbett and Richard Stallman.\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/getargs.c:232
|
||||
#, fuzzy, c-format
|
||||
msgid "Copyright (C) %d Free Software Foundation, Inc.\n"
|
||||
msgstr ""
|
||||
"Copyright 1984, 1986, 1989, 1992, 2000, 2001, 2002\n"
|
||||
"Free Software Foundation, Inc.\n"
|
||||
|
||||
#: src/getargs.c:234
|
||||
msgid ""
|
||||
"This is free software; see the source for copying conditions. There is NO\n"
|
||||
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
|
||||
msgstr ""
|
||||
"Ovo je slobodni softver; pogledajte kod kako biste doznali uvjete "
|
||||
"kopiranja. NEMA\n"
|
||||
"garancije; èak ni tvrdnje o ISPLATIVOSTI ili POGODNOSTI ZA NEKU SVRHU.\n"
|
||||
|
||||
#: src/getargs.c:395
|
||||
#, c-format
|
||||
msgid "Try `%s --help' for more information.\n"
|
||||
msgstr "Poku¹aj `%s --help' za vi¹e informacija.\n"
|
||||
|
||||
#: src/getargs.c:402
|
||||
#, c-format
|
||||
msgid "%s: no grammar file given\n"
|
||||
msgstr "%s: nije data datoteka sa gramatikom\n"
|
||||
|
||||
#: src/getargs.c:406
|
||||
#, c-format
|
||||
msgid "%s: extra arguments ignored after `%s'\n"
|
||||
msgstr "%s: dodatni argumenti se ignoriraju nakon `%s'\n"
|
||||
|
||||
#: src/gram.c:139
|
||||
msgid "empty"
|
||||
msgstr "prazno"
|
||||
|
||||
#: src/gram.c:233
|
||||
msgid "Grammar"
|
||||
msgstr "Gramatika"
|
||||
|
||||
#: src/gram.c:321 src/reduce.c:302 src/reduce.c:392
|
||||
#, fuzzy
|
||||
msgid "warning"
|
||||
msgstr "upozorenje:"
|
||||
|
||||
#: src/lalr.c:91
|
||||
#, c-format
|
||||
msgid "too many gotos (max %d)"
|
||||
msgstr "previ¹e goto-a (maksimalno %d)"
|
||||
|
||||
#: src/main.c:117
|
||||
msgid "rule never reduced because of conflicts"
|
||||
msgstr ""
|
||||
|
||||
#: parse-gram.y:347
|
||||
msgid "POSIX forbids declarations in the grammar"
|
||||
msgstr ""
|
||||
|
||||
#: src/print.c:46
|
||||
#, c-format
|
||||
msgid " type %d is %s\n"
|
||||
msgstr " tip %d je %s\n"
|
||||
|
||||
#: src/print.c:162
|
||||
#, fuzzy, c-format
|
||||
msgid "shift, and go to state %d\n"
|
||||
msgstr " %-4s\tpomakni i idi u stanje %d\n"
|
||||
|
||||
#: src/print.c:164
|
||||
#, fuzzy, c-format
|
||||
msgid "go to state %d\n"
|
||||
msgstr " $ \tidu u stanje %d\n"
|
||||
|
||||
#: src/print.c:201
|
||||
#, fuzzy
|
||||
msgid "error (nonassociative)\n"
|
||||
msgstr "%-4s\tgre¹ka (nonassociative)"
|
||||
|
||||
#: src/print.c:290
|
||||
#, fuzzy, c-format
|
||||
msgid "reduce using rule %d (%s)"
|
||||
msgstr "$default\treduciraj koristeæi pravilo %d (%s)"
|
||||
|
||||
#: src/print.c:293
|
||||
msgid "accept"
|
||||
msgstr ""
|
||||
|
||||
#: src/print.c:324 src/print.c:390
|
||||
msgid "$default"
|
||||
msgstr ""
|
||||
|
||||
#: src/print.c:419
|
||||
#, c-format
|
||||
msgid "state %d"
|
||||
msgstr "stanje %d"
|
||||
|
||||
#: src/print.c:453
|
||||
msgid "Terminals, with rules where they appear"
|
||||
msgstr "Zavr¹ni znakovi, sa pravilima gdje se pojavljuju"
|
||||
|
||||
#: src/print.c:480
|
||||
msgid "Nonterminals, with rules where they appear"
|
||||
msgstr "Nezavr¹ni znakovi, sa pravilima gdje se pojavljuju"
|
||||
|
||||
#: src/print.c:509
|
||||
msgid " on left:"
|
||||
msgstr "s lijeva:"
|
||||
|
||||
#: src/print.c:524
|
||||
msgid " on right:"
|
||||
msgstr "s desna:"
|
||||
|
||||
#: src/print.c:552
|
||||
#, fuzzy
|
||||
msgid "Rules never reduced"
|
||||
msgstr "%d pravilo nije nikad reducirano\n"
|
||||
|
||||
#: src/reader.c:52
|
||||
#, c-format
|
||||
msgid "multiple %s declarations"
|
||||
msgstr "vi¹estruke %s deklaracije"
|
||||
|
||||
#: src/reader.c:141
|
||||
#, c-format
|
||||
msgid "result type clash on merge function %s: `%s' vs. `%s'"
|
||||
msgstr ""
|
||||
|
||||
#: src/reader.c:239
|
||||
#, c-format
|
||||
msgid "rule given for %s, which is a token"
|
||||
msgstr "pravilo dato za %s, a to je znak"
|
||||
|
||||
#: src/reader.c:264
|
||||
#, c-format
|
||||
msgid "type clash (`%s' `%s') on default action"
|
||||
msgstr "sudar tipova (`%s' `%s') na deaultnoj akciji"
|
||||
|
||||
#: src/reader.c:272
|
||||
msgid "empty rule for typed nonterminal, and no action"
|
||||
msgstr "prazno pravilo za nezavr¹ni znak, i nema akcije"
|
||||
|
||||
#: src/reader.c:343
|
||||
msgid "two @prec's in a row"
|
||||
msgstr "dva @prec's u retku"
|
||||
|
||||
#: src/reader.c:353
|
||||
#, c-format
|
||||
msgid "%%dprec affects only GLR parsers"
|
||||
msgstr ""
|
||||
|
||||
#: src/reader.c:355
|
||||
#, c-format
|
||||
msgid "%%dprec must be followed by positive number"
|
||||
msgstr ""
|
||||
|
||||
#: src/reader.c:357
|
||||
#, c-format
|
||||
msgid "only one %%dprec allowed per rule"
|
||||
msgstr ""
|
||||
|
||||
#: src/reader.c:368
|
||||
#, c-format
|
||||
msgid "%%merge affects only GLR parsers"
|
||||
msgstr ""
|
||||
|
||||
#: src/reader.c:370
|
||||
#, c-format
|
||||
msgid "only one %%merge allowed per rule"
|
||||
msgstr ""
|
||||
|
||||
#: src/reader.c:513
|
||||
msgid "no rules in the input grammar"
|
||||
msgstr "nema pravila u ulaznoj gramatici"
|
||||
|
||||
#: src/reader.c:545
|
||||
#, c-format
|
||||
msgid "too many symbols (tokens plus nonterminals); maximum %d"
|
||||
msgstr "previ¹e simbola (znakovi plus nezavr¹ni znakovi); maksimalno %d"
|
||||
|
||||
#: src/reduce.c:239
|
||||
#, fuzzy
|
||||
msgid "useless rule"
|
||||
msgstr "%d beskorisno pravilo"
|
||||
|
||||
#: src/reduce.c:302
|
||||
#, fuzzy
|
||||
msgid "useless nonterminal"
|
||||
msgstr "%d beskorisan nezavr¹ni znak"
|
||||
|
||||
#: src/reduce.c:349
|
||||
#, fuzzy
|
||||
msgid "Useless nonterminals"
|
||||
msgstr "Beskorisni nezavr¹ni znakovi:"
|
||||
|
||||
#: src/reduce.c:362
|
||||
#, fuzzy
|
||||
msgid "Terminals which are not used"
|
||||
msgstr "Zavr¹ni znakovi koji nisu kori¹teni:"
|
||||
|
||||
#: src/reduce.c:371
|
||||
#, fuzzy
|
||||
msgid "Useless rules"
|
||||
msgstr "Beskorisna pravila:"
|
||||
|
||||
#: src/reduce.c:387
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d pravilo nije nikad reducirano\n"
|
||||
msgstr[1] "%d pravila nisu nikad reducirana\n"
|
||||
|
||||
#: src/reduce.c:395
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d beskorisan nezavr¹ni znak"
|
||||
msgstr[1] "%d beskorisnih nezavr¹nih znakova"
|
||||
|
||||
#: src/reduce.c:401
|
||||
msgid " and "
|
||||
msgstr " i"
|
||||
|
||||
#: src/reduce.c:404
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d beskorisno pravilo"
|
||||
msgstr[1] "%d beskorisnih pravila"
|
||||
|
||||
#: src/reduce.c:435
|
||||
#, fuzzy, c-format
|
||||
msgid "start symbol %s does not derive any sentence"
|
||||
msgstr "Poèetni simbol %s ne daje niti jednu reèenicu"
|
||||
|
||||
#: scan-gram.l:202
|
||||
#, c-format
|
||||
msgid ": invalid character: `%c'\n"
|
||||
msgstr ""
|
||||
|
||||
#: scan-gram.l:246
|
||||
#, fuzzy
|
||||
msgid ": unexpected end of file in a comment\n"
|
||||
msgstr "neoèekivan kraj datoteke"
|
||||
|
||||
#: scan-gram.l:274 scan-gram.l:412
|
||||
#, fuzzy
|
||||
msgid ": unexpected end of file in a string\n"
|
||||
msgstr "neoèekivan kraj datoteke"
|
||||
|
||||
#: scan-gram.l:311 scan-gram.l:383
|
||||
#, fuzzy
|
||||
msgid ": unexpected end of file in a character\n"
|
||||
msgstr "neoèekivan kraj datoteke"
|
||||
|
||||
#: scan-gram.l:332
|
||||
#, fuzzy, c-format
|
||||
msgid ": invalid escape: %s\n"
|
||||
msgstr "nedozvoljeni ulaz: %s"
|
||||
|
||||
#: scan-gram.l:353
|
||||
#, fuzzy, c-format
|
||||
msgid ": unrecognized escape: %s\n"
|
||||
msgstr "neprepoznati: %s"
|
||||
|
||||
#: scan-gram.l:473
|
||||
#, fuzzy
|
||||
msgid ": unexpected end of file in a braced code\n"
|
||||
msgstr "neoèekivan kraj datoteke"
|
||||
|
||||
#: scan-gram.l:502
|
||||
#, fuzzy
|
||||
msgid ": unexpected end of file in a prologue\n"
|
||||
msgstr "neoèekivan kraj datoteke"
|
||||
|
||||
#: scan-gram.l:560
|
||||
#, c-format
|
||||
msgid "$$ of `%s' has no declared type"
|
||||
msgstr "$$ od `%s' nema deklarirani tip"
|
||||
|
||||
#: scan-gram.l:577 scan-gram.l:664
|
||||
#, fuzzy, c-format
|
||||
msgid "invalid value: %s%d"
|
||||
msgstr "nedozvoljena @ vrijednost"
|
||||
|
||||
#: scan-gram.l:584
|
||||
#, c-format
|
||||
msgid "$%d of `%s' has no declared type"
|
||||
msgstr "$%d od `%s' nema deklarirani tip"
|
||||
|
||||
#: scan-gram.l:595 scan-gram.l:612 scan-gram.l:671 scan-gram.l:688
|
||||
#, c-format
|
||||
msgid "%s is invalid"
|
||||
msgstr "%s je nedozvoljeno"
|
||||
|
||||
#: src/state.c:145
|
||||
#, c-format
|
||||
msgid "too many states (max %d)"
|
||||
msgstr "previ¹e stanja (maks %d)"
|
||||
|
||||
#: src/symlist.c:97 src/symlist.c:109
|
||||
msgid "invalid $ value"
|
||||
msgstr "nedozvoljena $ vrijednost"
|
||||
|
||||
#: src/symtab.c:81
|
||||
#, c-format
|
||||
msgid "type redeclaration for %s"
|
||||
msgstr "ponovna deklaracija za %s"
|
||||
|
||||
#: src/symtab.c:98 src/symtab.c:117
|
||||
#, fuzzy, c-format
|
||||
msgid "%s redeclaration for %s"
|
||||
msgstr "ponovna deklaracija za %s"
|
||||
|
||||
#: src/symtab.c:138
|
||||
#, c-format
|
||||
msgid "redefining precedence of %s"
|
||||
msgstr "ponovno definiran prethodnik od %s"
|
||||
|
||||
#: src/symtab.c:157
|
||||
#, c-format
|
||||
msgid "symbol %s redefined"
|
||||
msgstr "simbol %s ponovo definiran"
|
||||
|
||||
#: src/symtab.c:180
|
||||
#, fuzzy, c-format
|
||||
msgid "redefining user token number of %s"
|
||||
msgstr "ponovno definiran prethodnik od %s"
|
||||
|
||||
#: src/symtab.c:225
|
||||
#, c-format
|
||||
msgid "symbol %s is used, but is not defined as a token and has no rules"
|
||||
msgstr "simbol %s je kori¹ten, ali nije definiran kao znak i nema pravila"
|
||||
|
||||
#: src/symtab.c:244
|
||||
#, c-format
|
||||
msgid "symbol `%s' used more than once as a literal string"
|
||||
msgstr "simbol `%s' kori¹ten vi¹e puta kao znakovni niz"
|
||||
|
||||
#: src/symtab.c:247
|
||||
#, c-format
|
||||
msgid "symbol `%s' given more than one literal string"
|
||||
msgstr "simbolz `%s' dat vi¹e od jednog znakovnog niza"
|
||||
|
||||
#: src/symtab.c:281
|
||||
#, c-format
|
||||
msgid "conflicting precedences for %s and %s"
|
||||
msgstr "konflikt u prethodnici za %s and %s"
|
||||
|
||||
#: src/symtab.c:293
|
||||
#, fuzzy, c-format
|
||||
msgid "conflicting associativities for %s (%s) and %s (%s)"
|
||||
msgstr "konfliktne asocijativne vrijednosti za %s i %s"
|
||||
|
||||
#: src/symtab.c:363
|
||||
#, c-format
|
||||
msgid "tokens %s and %s both assigned number %d"
|
||||
msgstr "objema znakovima %s i %s je pridru¾en broj %d"
|
||||
|
||||
#: src/symtab.c:568
|
||||
#, c-format
|
||||
msgid "the start symbol %s is undefined"
|
||||
msgstr "poèetni simbol %s nije definiran"
|
||||
|
||||
#: src/symtab.c:572
|
||||
#, c-format
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "poèetni simbol %s je znak"
|
||||
|
||||
#: lib/argmatch.c:161
|
||||
#, fuzzy, c-format
|
||||
msgid "invalid argument %s for %s"
|
||||
msgstr "nedozvoljeni ulaz: %s"
|
||||
|
||||
#: lib/argmatch.c:162
|
||||
#, c-format
|
||||
msgid "ambiguous argument %s for %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/argmatch.c:181
|
||||
msgid "Valid arguments are:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:226
|
||||
#, c-format
|
||||
msgid "%d bitset_allocs, %d freed (%.2f%%).\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:229
|
||||
#, c-format
|
||||
msgid "%d bitset_sets, %d cached (%.2f%%)\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:232
|
||||
#, c-format
|
||||
msgid "%d bitset_resets, %d cached (%.2f%%)\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:235
|
||||
#, c-format
|
||||
msgid "%d bitset_tests, %d cached (%.2f%%)\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:239
|
||||
#, c-format
|
||||
msgid "%d bitset_lists\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:241
|
||||
msgid "count log histogram\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:244
|
||||
msgid "size log histogram\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:247
|
||||
msgid "density histogram\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:264
|
||||
msgid ""
|
||||
"Bitset statistics:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:267
|
||||
#, c-format
|
||||
msgid "Accumulated runs = %d\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:311
|
||||
msgid "Could not read stats file."
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:313
|
||||
msgid "Bad stats file size.\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:339
|
||||
msgid "Could not write stats file."
|
||||
msgstr ""
|
||||
|
||||
#: lib/bitset_stats.c:343
|
||||
msgid "Could not open stats file for writing."
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:662
|
||||
#, c-format
|
||||
msgid "%s: option `%s' is ambiguous\n"
|
||||
msgstr "%s: opcija `%s' je nejednoznaèna\n"
|
||||
|
||||
#: lib/getopt.c:687
|
||||
#, c-format
|
||||
msgid "%s: option `--%s' doesn't allow an argument\n"
|
||||
msgstr "%s: opcija `--%s' ne dopu¹ta argument\n"
|
||||
|
||||
#: lib/getopt.c:692
|
||||
#, c-format
|
||||
msgid "%s: option `%c%s' doesn't allow an argument\n"
|
||||
msgstr "%s: opcija `%c%s' ne dopu¹ta argument\n"
|
||||
|
||||
#: lib/getopt.c:710 lib/getopt.c:883
|
||||
#, c-format
|
||||
msgid "%s: option `%s' requires an argument\n"
|
||||
msgstr "%s: opcija `%s' zahtijeva argument\n"
|
||||
|
||||
#: lib/getopt.c:739
|
||||
#, c-format
|
||||
msgid "%s: unrecognized option `--%s'\n"
|
||||
msgstr "%s: neprepoznata opcija `--%s'\n"
|
||||
|
||||
#: lib/getopt.c:743
|
||||
#, c-format
|
||||
msgid "%s: unrecognized option `%c%s'\n"
|
||||
msgstr "%s: neprepoznata opcija `%c%s'\n"
|
||||
|
||||
#: lib/getopt.c:769
|
||||
#, c-format
|
||||
msgid "%s: illegal option -- %c\n"
|
||||
msgstr "%s: nedozvoljena opcija -- %c\n"
|
||||
|
||||
#: lib/getopt.c:772
|
||||
#, c-format
|
||||
msgid "%s: invalid option -- %c\n"
|
||||
msgstr "%s: nedozvoljena opcija -- %c\n"
|
||||
|
||||
#: lib/getopt.c:802 lib/getopt.c:932
|
||||
#, c-format
|
||||
msgid "%s: option requires an argument -- %c\n"
|
||||
msgstr "%s: opcija zahtijeva argument -- %c\n"
|
||||
|
||||
#: lib/getopt.c:849
|
||||
#, c-format
|
||||
msgid "%s: option `-W %s' is ambiguous\n"
|
||||
msgstr "%s: opcija `-W %s' je nejednoznaèna\n"
|
||||
|
||||
#: lib/getopt.c:867
|
||||
#, c-format
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr "%s: opcija `-W %s' ne dopu¹ta argument\n"
|
||||
|
||||
#: lib/obstack.c:496 lib/obstack.c:499 lib/xmalloc.c:66
|
||||
msgid "memory exhausted"
|
||||
msgstr "iscrpljeni memorijski resursi"
|
||||
|
||||
#: lib/quotearg.c:274
|
||||
msgid "`"
|
||||
msgstr "`"
|
||||
|
||||
#: lib/quotearg.c:275
|
||||
msgid "'"
|
||||
msgstr "'"
|
||||
|
||||
#: lib/timevar.c:466
|
||||
msgid ""
|
||||
"\n"
|
||||
"Execution times (seconds)\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/timevar.c:516
|
||||
msgid " TOTAL :"
|
||||
msgstr ""
|
||||
|
||||
#: lib/timevar.c:552
|
||||
#, c-format
|
||||
msgid "time in %s: %ld.%06ld (%ld%%)\n"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "reduce"
|
||||
#~ msgstr "reduciraj"
|
||||
|
||||
#~ msgid "shift"
|
||||
#~ msgstr "pomakni"
|
||||
|
||||
#~ msgid "an error"
|
||||
#~ msgstr "gre¹ka"
|
||||
|
||||
#~ msgid "%s contains "
|
||||
#~ msgstr "%s sadr¾i"
|
||||
|
||||
#~ msgid " %-4s\t[reduce using rule %d (%s)]\n"
|
||||
#~ msgstr " %-4s\t[reduciraj koristeæi pravilo %d (%s)]\n"
|
||||
|
||||
#~ msgid ""
|
||||
#~ " $default\treduce using rule %d (%s)\n"
|
||||
#~ "\n"
|
||||
#~ msgstr ""
|
||||
#~ " $default\treduciraj koristeæi pravilo %d (%s)\n"
|
||||
#~ "\n"
|
||||
|
||||
#~ msgid " %-4s\treduce using rule %d (%s)\n"
|
||||
#~ msgstr " %-4s\treduciraj koristeæi pravilo %d (%s)\n"
|
||||
|
||||
#~ msgid " $default\treduce using rule %d (%s)\n"
|
||||
#~ msgstr " $default\treduciraj koristeæi pravilo %d (%s)\n"
|
||||
|
||||
#~ msgid "`%s' is no longer supported"
|
||||
#~ msgstr "`%s' vi¹e nije podr¾ano"
|
||||
|
||||
#~ msgid "unexpected `/' found and ignored"
|
||||
#~ msgstr "neoèekivan `/' naðen i zanemaren"
|
||||
|
||||
#~ msgid "unterminated comment"
|
||||
#~ msgstr "nezavr¹eni komentar"
|
||||
|
||||
#~ msgid "unescaped newline in constant"
|
||||
#~ msgstr "neoèekivan znak za novu liniju u konstanti"
|
||||
|
||||
#~ msgid "octal value outside range 0...255: `\\%o'"
|
||||
#~ msgstr "oktalna vrijednost izvan dosega 0...255: `\\%o'"
|
||||
|
||||
#~ msgid "hexadecimal value above 255: `\\x%x'"
|
||||
#~ msgstr "heksadecimalna vrijednost vi¹a od 255: `\\x%x'"
|
||||
|
||||
#~ msgid "unknown escape sequence: `\\' followed by `%s'"
|
||||
#~ msgstr "nepoznata escape sekvenca: `\\' koju slijedi `%s'"
|
||||
|
||||
#~ msgid "unterminated type name at end of file"
|
||||
#~ msgstr "nezavr¹eno ime tipa pri kraju datoteke"
|
||||
|
||||
#~ msgid "unterminated type name"
|
||||
#~ msgstr "nezavr¹eno ime tipa"
|
||||
|
||||
#~ msgid "use \"...\" for multi-character literal tokens"
|
||||
#~ msgstr "koristi \"...\" za vi¹ebajtne znakove"
|
||||
|
||||
#~ msgid "`%s' supports no argument: %s"
|
||||
#~ msgstr "`%s' ne podr¾ava argument: %s"
|
||||
|
||||
#~ msgid "`%s' requires an argument"
|
||||
#~ msgstr "`%s' zahtijeva argument"
|
||||
|
||||
#~ msgid "maximum table size (%d) exceeded"
|
||||
#~ msgstr "maksimalna velièina tablice (%d) prekoraèena"
|
||||
|
||||
#~ msgid " (rule %d)"
|
||||
#~ msgstr " (pravilo %d)"
|
||||
|
||||
#~ msgid " $default\taccept\n"
|
||||
#~ msgstr " $default\tprihvati\n"
|
||||
|
||||
#~ msgid " NO ACTIONS\n"
|
||||
#~ msgstr " NEMA AKCIJA\n"
|
||||
|
||||
#~ msgid " %-4s\terror (nonassociative)\n"
|
||||
#~ msgstr " %-4s\tgre¹ka (nonassociative)\n"
|
||||
|
||||
#~ msgid " %-4s\tgo to state %d\n"
|
||||
#~ msgstr " %-4s\tidu u stanje %d\n"
|
||||
|
||||
#~ msgid "Number, Line, Rule"
|
||||
#~ msgstr "Broj, Linija, Pravilo"
|
||||
|
||||
#~ msgid " %3d %3d %s ->"
|
||||
#~ msgstr " %3d %3d %s ->"
|
||||
|
||||
#~ msgid " Skipping to next \\n"
|
||||
#~ msgstr " Preskaèem na slijedeæe \\n"
|
||||
|
||||
#~ msgid " Skipping to next %c"
|
||||
#~ msgstr " Preskaèem na slijedeæi %c"
|
||||
|
||||
#~ msgid "unterminated string at end of file"
|
||||
#~ msgstr "nezavr¹eni znakovni niz na kraju datoteke"
|
||||
|
||||
#~ msgid "unterminated string"
|
||||
#~ msgstr "nezavr¹eni znakovni niz"
|
||||
|
||||
#~ msgid "unterminated `%{' definition"
|
||||
#~ msgstr "nezavr¹ena `%{' definicija"
|
||||
|
||||
#~ msgid "Premature EOF after %s"
|
||||
#~ msgstr "Preuranjeni EOF nakon %s"
|
||||
|
||||
#~ msgid "`%s' is invalid in %s"
|
||||
#~ msgstr "`%s' je nedozvoljen u %s"
|
||||
|
||||
#~ msgid "invalid %s declaration"
|
||||
#~ msgstr "nedozvoljena %s deklaracija"
|
||||
|
||||
#~ msgid "%type declaration has no <typename>"
|
||||
#~ msgstr "%type deklaracija nema <typename>"
|
||||
|
||||
#~ msgid "invalid %%type declaration due to item: %s"
|
||||
#~ msgstr "nedozvoljena %%type deklaracija zbog: %s"
|
||||
|
||||
#~ msgid "invalid text (%s) - number should be after identifier"
|
||||
#~ msgstr "nedozvoljeno tekst (%s) - broj bi trebao biti nakon identifikatora"
|
||||
|
||||
#~ msgid "unexpected item: %s"
|
||||
#~ msgstr "neoèekivani: %s"
|
||||
|
||||
#~ msgid "unmatched %s"
|
||||
#~ msgstr "nije pronaðen %s"
|
||||
|
||||
#~ msgid "argument of %%expect is not an integer"
|
||||
#~ msgstr "argument od %%expect nije cijeli broj"
|
||||
|
||||
#~ msgid "unrecognized item %s, expected an identifier"
|
||||
#~ msgstr "neprepoznati %s, oèekivan nakon identifikatora"
|
||||
|
||||
#~ msgid "expected string constant instead of %s"
|
||||
#~ msgstr "oèekivana znakovna konstana umjesto %s"
|
||||
|
||||
#~ msgid "no input grammar"
|
||||
#~ msgstr "nema ulazne gramatike"
|
||||
|
||||
#~ msgid "unknown character: %s"
|
||||
#~ msgstr "nepoznati znak: %s"
|
||||
|
||||
#~ msgid "unterminated %guard clause"
|
||||
#~ msgstr "nezavr¹ena %guard klauzula"
|
||||
|
||||
#~ msgid "ill-formed rule: initial symbol not followed by colon"
|
||||
#~ msgstr "lo¹e pravilo: zarez ne bi trebao slijediti poèetni simbol"
|
||||
|
||||
#~ msgid "grammar starts with vertical bar"
|
||||
#~ msgstr "gramatika poèinje sa okomitom crtom"
|
||||
|
||||
#~ msgid "previous rule lacks an ending `;'"
|
||||
#~ msgstr "prethodnom pravilu nedostaje zavr¹etak `;'"
|
||||
|
||||
#~ msgid "%%guard present but %%semantic_parser not specified"
|
||||
#~ msgstr "%%guard prisutan ali %%semantic_parser nije specificiran"
|
||||
|
||||
#~ msgid "two actions at end of one rule"
|
||||
#~ msgstr "dvije akcije pri kraju jednog pravila"
|
||||
+812
@@ -0,0 +1,812 @@
|
||||
# bison: translation to Brazilian Portuguese (pt_BR)
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
# Alexandre Folle de Menezes <[email protected]>, 2002.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: bison 1.49b\n"
|
||||
"POT-Creation-Date: 2002-09-27 16:50+0200\n"
|
||||
"PO-Revision-Date: 2002-08-28 00:20-0300\n"
|
||||
"Last-Translator: Alexandre Folle de Menezes <[email protected]>\n"
|
||||
"Language-Team: Brazilian Portuguese <[email protected]>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=ISO-8859-1\n"
|
||||
"Content-Transfer-Encoding: 8-bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: src/complain.c:89 lib/error.c:128 lib/error.c:156
|
||||
msgid "Unknown system error"
|
||||
msgstr "Erro de sistema desconhecido"
|
||||
|
||||
#: src/complain.c:123 src/complain.c:152
|
||||
msgid "warning: "
|
||||
msgstr "aviso: "
|
||||
|
||||
#: src/complain.c:252 src/complain.c:282
|
||||
msgid "fatal error: "
|
||||
msgstr "erro fatal: "
|
||||
|
||||
#: src/conflicts.c:72
|
||||
#, c-format
|
||||
msgid " Conflict between rule %d and token %s resolved as shift"
|
||||
msgstr " Conflito entre a regra %d e a token %s resolvido como `shift`."
|
||||
|
||||
#: src/conflicts.c:80
|
||||
#, c-format
|
||||
msgid " Conflict between rule %d and token %s resolved as reduce"
|
||||
msgstr " Conflito entre a regra %d e a token %s resolvido como `reduce`."
|
||||
|
||||
#: src/conflicts.c:87
|
||||
#, c-format
|
||||
msgid " Conflict between rule %d and token %s resolved as an error"
|
||||
msgstr " Conflito entre a regra %d e a token %s resolvido como um erro."
|
||||
|
||||
#: src/conflicts.c:402
|
||||
#, c-format
|
||||
msgid "%d shift/reduce conflict"
|
||||
msgid_plural "%d shift/reduce conflicts"
|
||||
msgstr[0] "%d conflito de deslocamento/redução"
|
||||
msgstr[1] "%d conflitos de deslocamento/redução"
|
||||
|
||||
#: src/conflicts.c:409
|
||||
msgid "and"
|
||||
msgstr "e"
|
||||
|
||||
#: src/conflicts.c:415
|
||||
#, c-format
|
||||
msgid "%d reduce/reduce conflict"
|
||||
msgid_plural "%d reduce/reduce conflicts"
|
||||
msgstr[0] "%d conflito de redução/redução"
|
||||
msgstr[1] "%d conflitos de redução/redução"
|
||||
|
||||
#: src/conflicts.c:435
|
||||
msgid "conflicts: "
|
||||
msgstr "conflitos: "
|
||||
|
||||
#: src/conflicts.c:437
|
||||
#, c-format
|
||||
msgid " %d shift/reduce"
|
||||
msgstr " %d deslocamento/redução"
|
||||
|
||||
#: src/conflicts.c:441
|
||||
#, c-format
|
||||
msgid " %d reduce/reduce"
|
||||
msgstr " %d redução/redução"
|
||||
|
||||
#: src/conflicts.c:460
|
||||
#, c-format
|
||||
msgid "State %d contains "
|
||||
msgstr "O estado %d contém "
|
||||
|
||||
#: src/conflicts.c:537
|
||||
#, c-format
|
||||
msgid "expected %d shift/reduce conflict"
|
||||
msgid_plural "expected %d shift/reduce conflicts"
|
||||
msgstr[0] "esperado: %d conflito de deslocamento/redução"
|
||||
msgstr[1] "esperados: %d conflitos de deslocamento/redução"
|
||||
|
||||
#: src/files.c:114
|
||||
#, c-format
|
||||
msgid "cannot open file `%s'"
|
||||
msgstr "impossível abrir o arquivo `%s'"
|
||||
|
||||
#: src/files.c:133
|
||||
msgid "cannot close file"
|
||||
msgstr "impossível fechar o arquivo"
|
||||
|
||||
#: src/getargs.c:157
|
||||
msgid "GNU bison generates parsers for LALR(1) grammars.\n"
|
||||
msgstr "GNU bison gera analisadores para gramáticas LALR(1).\n"
|
||||
|
||||
#: src/getargs.c:161
|
||||
#, c-format
|
||||
msgid "Usage: %s [OPTION]... FILE\n"
|
||||
msgstr "Uso: %s [OPCAO]... ARQUIVO\n"
|
||||
|
||||
#: src/getargs.c:165
|
||||
msgid ""
|
||||
"If a long option shows an argument as mandatory, then it is mandatory\n"
|
||||
"for the equivalent short option also. Similarly for optional arguments.\n"
|
||||
msgstr ""
|
||||
"Se uma opção longa mostra um argumento como obrigatório, então ele é\n"
|
||||
"obrigatório para a opção curta equivalente também. Igualmente para os\n"
|
||||
"argumentos opcionais.\n"
|
||||
|
||||
#: src/getargs.c:171
|
||||
msgid ""
|
||||
"Operation modes:\n"
|
||||
" -h, --help display this help and exit\n"
|
||||
" -V, --version output version information and exit\n"
|
||||
" -y, --yacc emulate POSIX yacc\n"
|
||||
msgstr ""
|
||||
"Modos de operação:\n"
|
||||
" -h, --help exibe esta ajuda e sai\n"
|
||||
" -V, --version mostra informações de versão e sai\n"
|
||||
" -y, --yacc emula o yacc POSIX\n"
|
||||
|
||||
#: src/getargs.c:178
|
||||
msgid ""
|
||||
"Parser:\n"
|
||||
" -S, --skeleton=FILE specify the skeleton to use\n"
|
||||
" -t, --debug instrument the parser for debugging\n"
|
||||
" --locations enable locations computation\n"
|
||||
" -p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n"
|
||||
" -l, --no-lines don't generate `#line' directives\n"
|
||||
" -n, --no-parser generate the tables only\n"
|
||||
" -k, --token-table include a table of token names\n"
|
||||
msgstr ""
|
||||
"Analizador:\n"
|
||||
" -S, --skeleton=arquivo especifica o skeleto a ser usado\n"
|
||||
" -t, --debug instrumenta o analisador para depuração\n"
|
||||
" --locations habilita a computação de localizações\n"
|
||||
" -p, --name-prefix=PREFIXO adiciona PREFIXO aos símbolos externos\n"
|
||||
" -l, --no-lines não gera diretivas `#line'\n"
|
||||
" -n, --no-parser apenas gera as tabelas\n"
|
||||
" --k, --token-table inclui uma tabela de nomes de tokens\n"
|
||||
|
||||
#: src/getargs.c:190
|
||||
msgid ""
|
||||
"Output:\n"
|
||||
" -d, --defines also produce a header file\n"
|
||||
" -r, --report=THINGS also produce details on the automaton\n"
|
||||
" -v, --verbose same as `--report=state'\n"
|
||||
" -b, --file-prefix=PREFIX specify a PREFIX for output files\n"
|
||||
" -o, --output=FILE leave output to FILE\n"
|
||||
" -g, --graph also produce a VCG description of the "
|
||||
"automaton\n"
|
||||
msgstr ""
|
||||
"Saída:\n"
|
||||
" -d, --defines também produz um arquivo de cabeçalho\n"
|
||||
" -r, --report=ITENS também produz detalhes do autômato\n"
|
||||
" -v, --verbose o mesmo que `--report=state'\n"
|
||||
" -b, --file-prefix=PREFIXO especifica o PREFIXO para os arquivos de saída\n"
|
||||
" -o, --output=ARQUIVO armazena a saída em ARQUIVO\n"
|
||||
" -g, --graph também produz uma descrição em VCG do autômato\n"
|
||||
|
||||
#: src/getargs.c:201
|
||||
msgid ""
|
||||
"THINGS is a list of comma separated words that can include:\n"
|
||||
" `state' describe the states\n"
|
||||
" `itemset' complete the core item sets with their closure\n"
|
||||
" `lookahead' explicitly associate lookaheads to items\n"
|
||||
" `solved' describe shift/reduce conflicts solving\n"
|
||||
" `all' include all the above information\n"
|
||||
" `none' disable the report\n"
|
||||
msgstr ""
|
||||
"ITENS é uma lista separada por vírgulas, que pode incluir:\n"
|
||||
" `state' descreve os estados\n"
|
||||
" `itemset' completa os conjuntos de ítens básicos com seus "
|
||||
"fechamentos\n"
|
||||
" `lookahead' associa explicitamente as previsões com os ítens\n"
|
||||
" `solved' descreve a solução de conflitos de deslocamento/redução\n"
|
||||
" `all' inclui todas as informações acima\n"
|
||||
" `none' desabilita o relatório\n"
|
||||
|
||||
#: src/getargs.c:212
|
||||
msgid "Report bugs to <[email protected]>.\n"
|
||||
msgstr "Informe os erros para <[email protected]>.\n"
|
||||
|
||||
#: src/getargs.c:226
|
||||
#, c-format
|
||||
msgid "bison (GNU Bison) %s"
|
||||
msgstr "bison (GNU bison) %s"
|
||||
|
||||
#: src/getargs.c:228
|
||||
msgid "Written by Robert Corbett and Richard Stallman.\n"
|
||||
msgstr "Escrito por Robert Corbett e Richard Stallman.\n"
|
||||
|
||||
#: src/getargs.c:232
|
||||
#, c-format
|
||||
msgid "Copyright (C) %d Free Software Foundation, Inc.\n"
|
||||
msgstr "Copyright (C) %d Free Software Foundation, Inc.\n"
|
||||
|
||||
#: src/getargs.c:234
|
||||
msgid ""
|
||||
"This is free software; see the source for copying conditions. There is NO\n"
|
||||
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
|
||||
msgstr ""
|
||||
"Este é um software livre; veja o código fonte para condições de copyright. "
|
||||
"Não\n"
|
||||
"existe NENHUMA garantia; nem mesmo a garantia implícita de COMERCIABILIDADE "
|
||||
"ou\n"
|
||||
"ADEQUAÇÃO À QUALQUER FINALIDADE PARTICULAR.\n"
|
||||
|
||||
#: src/getargs.c:395
|
||||
#, c-format
|
||||
msgid "Try `%s --help' for more information.\n"
|
||||
msgstr "tente `%s --help' para mais informações.\n"
|
||||
|
||||
#: src/getargs.c:402
|
||||
#, c-format
|
||||
msgid "%s: no grammar file given\n"
|
||||
msgstr "%s: nenhum arquivo de gramática foi especificado\n"
|
||||
|
||||
#: src/getargs.c:406
|
||||
#, c-format
|
||||
msgid "%s: extra arguments ignored after `%s'\n"
|
||||
msgstr "%s: os argumentos extra ignorados depois de '%s'\n"
|
||||
|
||||
#: src/gram.c:139
|
||||
msgid "empty"
|
||||
msgstr "vazio"
|
||||
|
||||
#: src/gram.c:233
|
||||
msgid "Grammar"
|
||||
msgstr "Gramática"
|
||||
|
||||
#: src/gram.c:321 src/reduce.c:302 src/reduce.c:392
|
||||
msgid "warning"
|
||||
msgstr "aviso"
|
||||
|
||||
#: src/lalr.c:91
|
||||
#, c-format
|
||||
msgid "too many gotos (max %d)"
|
||||
msgstr "muitos gotos (máximo %d)"
|
||||
|
||||
#: src/main.c:117
|
||||
msgid "rule never reduced because of conflicts"
|
||||
msgstr "regra não reduzida por causa de conflitos"
|
||||
|
||||
#: parse-gram.y:347
|
||||
msgid "POSIX forbids declarations in the grammar"
|
||||
msgstr "o POSIX proíbe declarações na gramática"
|
||||
|
||||
#: src/print.c:46
|
||||
#, c-format
|
||||
msgid " type %d is %s\n"
|
||||
msgstr " tipo %d é %s\n"
|
||||
|
||||
#: src/print.c:162
|
||||
#, c-format
|
||||
msgid "shift, and go to state %d\n"
|
||||
msgstr "deslocar, e ir ao estado %d\n"
|
||||
|
||||
#: src/print.c:164
|
||||
#, c-format
|
||||
msgid "go to state %d\n"
|
||||
msgstr "ir ao estado %d\n"
|
||||
|
||||
#: src/print.c:201
|
||||
msgid "error (nonassociative)\n"
|
||||
msgstr "erro (não associativo)\n"
|
||||
|
||||
#: src/print.c:290
|
||||
#, c-format
|
||||
msgid "reduce using rule %d (%s)"
|
||||
msgstr "reduzir usando a regra %d (%s)"
|
||||
|
||||
#: src/print.c:293
|
||||
msgid "accept"
|
||||
msgstr "aceitar"
|
||||
|
||||
#: src/print.c:324 src/print.c:390
|
||||
msgid "$default"
|
||||
msgstr "$padrão"
|
||||
|
||||
#: src/print.c:419
|
||||
#, c-format
|
||||
msgid "state %d"
|
||||
msgstr "estado %d"
|
||||
|
||||
#: src/print.c:453
|
||||
msgid "Terminals, with rules where they appear"
|
||||
msgstr "Terminais, com as regras onde eles aparecem"
|
||||
|
||||
#: src/print.c:480
|
||||
msgid "Nonterminals, with rules where they appear"
|
||||
msgstr "Não-terminais com as regras onde eles aparecem"
|
||||
|
||||
#: src/print.c:509
|
||||
msgid " on left:"
|
||||
msgstr " à esquerda:"
|
||||
|
||||
#: src/print.c:524
|
||||
msgid " on right:"
|
||||
msgstr " à direita:"
|
||||
|
||||
#: src/print.c:552
|
||||
msgid "Rules never reduced"
|
||||
msgstr "Regras nunca reduzidas"
|
||||
|
||||
#: src/reader.c:52
|
||||
#, c-format
|
||||
msgid "multiple %s declarations"
|
||||
msgstr "declarações de %s múltiplas"
|
||||
|
||||
#: src/reader.c:141
|
||||
#, c-format
|
||||
msgid "result type clash on merge function %s: `%s' vs. `%s'"
|
||||
msgstr "tipo de resultado conflita na fução de mescla %s: `%s' vs. `%s'"
|
||||
|
||||
#: src/reader.c:239
|
||||
#, c-format
|
||||
msgid "rule given for %s, which is a token"
|
||||
msgstr "regra fornecida para %s, que é um token"
|
||||
|
||||
#: src/reader.c:264
|
||||
#, c-format
|
||||
msgid "type clash (`%s' `%s') on default action"
|
||||
msgstr "os tipos (`%s' `%s') não concordam na ação padrão"
|
||||
|
||||
#: src/reader.c:272
|
||||
msgid "empty rule for typed nonterminal, and no action"
|
||||
msgstr "regra vazia para um não-terminal com tipo, e não há ações"
|
||||
|
||||
#: src/reader.c:343
|
||||
msgid "two @prec's in a row"
|
||||
msgstr "dois @prec em uma linha"
|
||||
|
||||
#: src/reader.c:353
|
||||
#, c-format
|
||||
msgid "%%dprec affects only GLR parsers"
|
||||
msgstr "%%dprec afeta apenas analisadores GLR"
|
||||
|
||||
#: src/reader.c:355
|
||||
#, c-format
|
||||
msgid "%%dprec must be followed by positive number"
|
||||
msgstr "%%dprec deve ser seguido por um número positivo"
|
||||
|
||||
#: src/reader.c:357
|
||||
#, c-format
|
||||
msgid "only one %%dprec allowed per rule"
|
||||
msgstr "apenas um %%dprec é permitido por regra"
|
||||
|
||||
#: src/reader.c:368
|
||||
#, c-format
|
||||
msgid "%%merge affects only GLR parsers"
|
||||
msgstr "%%merge afeta apenas analisadores GLR"
|
||||
|
||||
#: src/reader.c:370
|
||||
#, c-format
|
||||
msgid "only one %%merge allowed per rule"
|
||||
msgstr "apenas um %%merge é permitido por regra"
|
||||
|
||||
#: src/reader.c:513
|
||||
msgid "no rules in the input grammar"
|
||||
msgstr "não há regras na gramática de entrada"
|
||||
|
||||
#: src/reader.c:545
|
||||
#, c-format
|
||||
msgid "too many symbols (tokens plus nonterminals); maximum %d"
|
||||
msgstr "muitos símbolos (terminais e não-terminais); máximo %d"
|
||||
|
||||
#: src/reduce.c:239
|
||||
msgid "useless rule"
|
||||
msgstr "regra inútil"
|
||||
|
||||
#: src/reduce.c:302
|
||||
msgid "useless nonterminal"
|
||||
msgstr "não-terminal inútil"
|
||||
|
||||
#: src/reduce.c:349
|
||||
msgid "Useless nonterminals"
|
||||
msgstr "Não-terminais inúteis"
|
||||
|
||||
#: src/reduce.c:362
|
||||
msgid "Terminals which are not used"
|
||||
msgstr "Terminais que não foram usados"
|
||||
|
||||
#: src/reduce.c:371
|
||||
msgid "Useless rules"
|
||||
msgstr "Regras inúteis"
|
||||
|
||||
#: src/reduce.c:387
|
||||
#, c-format
|
||||
msgid "%d rule never reduced\n"
|
||||
msgid_plural "%d rules never reduced\n"
|
||||
msgstr[0] "%d regra que nunca foi reduzida\n"
|
||||
msgstr[1] "%d regras que nunca foram reduzidas\n"
|
||||
|
||||
#: src/reduce.c:395
|
||||
#, c-format
|
||||
msgid "%d useless nonterminal"
|
||||
msgid_plural "%d useless nonterminals"
|
||||
msgstr[0] "%d não-terminal inútil"
|
||||
msgstr[1] "%d não-terminal inútil"
|
||||
|
||||
#: src/reduce.c:401
|
||||
msgid " and "
|
||||
msgstr " e "
|
||||
|
||||
#: src/reduce.c:404
|
||||
#, c-format
|
||||
msgid "%d useless rule"
|
||||
msgid_plural "%d useless rules"
|
||||
msgstr[0] "%d regra inútil"
|
||||
msgstr[1] "%d regras inúteis"
|
||||
|
||||
#: src/reduce.c:435
|
||||
#, c-format
|
||||
msgid "start symbol %s does not derive any sentence"
|
||||
msgstr "símbolo de início %s não deriva nenhuma sentença"
|
||||
|
||||
#: scan-gram.l:202
|
||||
#, c-format
|
||||
msgid ": invalid character: `%c'\n"
|
||||
msgstr ": caractere inválido: `%c'\n"
|
||||
|
||||
#: scan-gram.l:246
|
||||
msgid ": unexpected end of file in a comment\n"
|
||||
msgstr ": fim de arquivo inesperado em um comentário\n"
|
||||
|
||||
#: scan-gram.l:274 scan-gram.l:412
|
||||
msgid ": unexpected end of file in a string\n"
|
||||
msgstr ": fim de arquivo inesperado em uma string\n"
|
||||
|
||||
#: scan-gram.l:311 scan-gram.l:383
|
||||
msgid ": unexpected end of file in a character\n"
|
||||
msgstr ": fim de arquivo inesperado em um caractere\n"
|
||||
|
||||
#: scan-gram.l:332
|
||||
#, c-format
|
||||
msgid ": invalid escape: %s\n"
|
||||
msgstr ": escape inválido: %s\n"
|
||||
|
||||
#: scan-gram.l:353
|
||||
#, c-format
|
||||
msgid ": unrecognized escape: %s\n"
|
||||
msgstr ": escape não reconhecido: %s\n"
|
||||
|
||||
#: scan-gram.l:473
|
||||
msgid ": unexpected end of file in a braced code\n"
|
||||
msgstr ": fim de arquivo inesperado em código entre chaves\n"
|
||||
|
||||
#: scan-gram.l:502
|
||||
msgid ": unexpected end of file in a prologue\n"
|
||||
msgstr ": fim de arquivo inesperado em um prólogo\n"
|
||||
|
||||
#: scan-gram.l:560
|
||||
#, c-format
|
||||
msgid "$$ of `%s' has no declared type"
|
||||
msgstr "$$ de `%s' não tem tipo declarado"
|
||||
|
||||
#: scan-gram.l:577 scan-gram.l:664
|
||||
#, c-format
|
||||
msgid "invalid value: %s%d"
|
||||
msgstr "valor inválido: %s%d"
|
||||
|
||||
#: scan-gram.l:584
|
||||
#, c-format
|
||||
msgid "$%d of `%s' has no declared type"
|
||||
msgstr "$%d de `%s' não tem tipo declarado"
|
||||
|
||||
#: scan-gram.l:595 scan-gram.l:612 scan-gram.l:671 scan-gram.l:688
|
||||
#, c-format
|
||||
msgid "%s is invalid"
|
||||
msgstr "%s é inválido"
|
||||
|
||||
#: src/state.c:145
|
||||
#, c-format
|
||||
msgid "too many states (max %d)"
|
||||
msgstr "muitos estados (máximo %d)"
|
||||
|
||||
#: src/symlist.c:97 src/symlist.c:109
|
||||
msgid "invalid $ value"
|
||||
msgstr "valor $ inválido"
|
||||
|
||||
#: src/symtab.c:81
|
||||
#, c-format
|
||||
msgid "type redeclaration for %s"
|
||||
msgstr "redeclaração de tipo para %s"
|
||||
|
||||
#: src/symtab.c:98 src/symtab.c:117
|
||||
#, c-format
|
||||
msgid "%s redeclaration for %s"
|
||||
msgstr "redeclaração de %s para %s"
|
||||
|
||||
#: src/symtab.c:138
|
||||
#, c-format
|
||||
msgid "redefining precedence of %s"
|
||||
msgstr "redefinindo precedência de %s"
|
||||
|
||||
#: src/symtab.c:157
|
||||
#, c-format
|
||||
msgid "symbol %s redefined"
|
||||
msgstr "símbolo %s redefinido"
|
||||
|
||||
#: src/symtab.c:180
|
||||
#, c-format
|
||||
msgid "redefining user token number of %s"
|
||||
msgstr "redefinindo número de token de usuário de %s"
|
||||
|
||||
#: src/symtab.c:225
|
||||
#, c-format
|
||||
msgid "symbol %s is used, but is not defined as a token and has no rules"
|
||||
msgstr "símbolo %s usado, mas não definido como uma token e não tem regras"
|
||||
|
||||
#: src/symtab.c:244
|
||||
#, c-format
|
||||
msgid "symbol `%s' used more than once as a literal string"
|
||||
msgstr "símbolo `%s' usado mais the uma vez como uma string literal"
|
||||
|
||||
#: src/symtab.c:247
|
||||
#, c-format
|
||||
msgid "symbol `%s' given more than one literal string"
|
||||
msgstr "símbolo `%s' associado a mais de uma string literal"
|
||||
|
||||
#: src/symtab.c:281
|
||||
#, c-format
|
||||
msgid "conflicting precedences for %s and %s"
|
||||
msgstr "precedências conflitantes para %s e %s"
|
||||
|
||||
#: src/symtab.c:293
|
||||
#, c-format
|
||||
msgid "conflicting associativities for %s (%s) and %s (%s)"
|
||||
msgstr "valores associativos conflitantes para %s (%s) e %s (%s)"
|
||||
|
||||
#: src/symtab.c:363
|
||||
#, c-format
|
||||
msgid "tokens %s and %s both assigned number %d"
|
||||
msgstr "tokens %s e %s associadas ao mesmo número %d"
|
||||
|
||||
#: src/symtab.c:568
|
||||
#, c-format
|
||||
msgid "the start symbol %s is undefined"
|
||||
msgstr "o símbolo de início %s não está definido"
|
||||
|
||||
#: src/symtab.c:572
|
||||
#, c-format
|
||||
msgid "the start symbol %s is a token"
|
||||
msgstr "o símbolo de início %s é um terminal"
|
||||
|
||||
#: lib/argmatch.c:161
|
||||
#, c-format
|
||||
msgid "invalid argument %s for %s"
|
||||
msgstr "argumento %s inválido para %s"
|
||||
|
||||
#: lib/argmatch.c:162
|
||||
#, c-format
|
||||
msgid "ambiguous argument %s for %s"
|
||||
msgstr "argumento %s ambíguo para %s"
|
||||
|
||||
#: lib/argmatch.c:181
|
||||
msgid "Valid arguments are:"
|
||||
msgstr "Argumentos válidos são:"
|
||||
|
||||
#: lib/bitset_stats.c:226
|
||||
#, c-format
|
||||
msgid "%d bitset_allocs, %d freed (%.2f%%).\n"
|
||||
msgstr "%d bitset_allocs, %d liberados (%.2f%%).\n"
|
||||
|
||||
#: lib/bitset_stats.c:229
|
||||
#, c-format
|
||||
msgid "%d bitset_sets, %d cached (%.2f%%)\n"
|
||||
msgstr "%d bitset_sets, %d em cache (%.2f%%)\n"
|
||||
|
||||
#: lib/bitset_stats.c:232
|
||||
#, c-format
|
||||
msgid "%d bitset_resets, %d cached (%.2f%%)\n"
|
||||
msgstr "%d bitset_resets, %d em cache (%.2f%%)\n"
|
||||
|
||||
#: lib/bitset_stats.c:235
|
||||
#, c-format
|
||||
msgid "%d bitset_tests, %d cached (%.2f%%)\n"
|
||||
msgstr "%d bitset_tests, %d em cache (%.2f%%)\n"
|
||||
|
||||
#: lib/bitset_stats.c:239
|
||||
#, c-format
|
||||
msgid "%d bitset_lists\n"
|
||||
msgstr "%d bitset_lists\n"
|
||||
|
||||
#: lib/bitset_stats.c:241
|
||||
msgid "count log histogram\n"
|
||||
msgstr "histograma de log de contagens\n"
|
||||
|
||||
#: lib/bitset_stats.c:244
|
||||
msgid "size log histogram\n"
|
||||
msgstr "histograma de log de tamanhos\n"
|
||||
|
||||
#: lib/bitset_stats.c:247
|
||||
msgid "density histogram\n"
|
||||
msgstr "histograma de densidades\n"
|
||||
|
||||
#: lib/bitset_stats.c:264
|
||||
msgid ""
|
||||
"Bitset statistics:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Estatísticas de bitset:\n"
|
||||
"\n"
|
||||
|
||||
#: lib/bitset_stats.c:267
|
||||
#, c-format
|
||||
msgid "Accumulated runs = %d\n"
|
||||
msgstr "Execuções acumuladas = %d\n"
|
||||
|
||||
#: lib/bitset_stats.c:311
|
||||
msgid "Could not read stats file."
|
||||
msgstr "Impossível ler o arquivo de estatísticas."
|
||||
|
||||
#: lib/bitset_stats.c:313
|
||||
msgid "Bad stats file size.\n"
|
||||
msgstr "Tamanho do arquivo de estatísticas com erro.\n"
|
||||
|
||||
#: lib/bitset_stats.c:339
|
||||
msgid "Could not write stats file."
|
||||
msgstr "Impossível de escrever no arquivo de estatísticas."
|
||||
|
||||
#: lib/bitset_stats.c:343
|
||||
msgid "Could not open stats file for writing."
|
||||
msgstr "Impossível abrir arquivo de estatísticas para escrita."
|
||||
|
||||
#: lib/getopt.c:662
|
||||
#, c-format
|
||||
msgid "%s: option `%s' is ambiguous\n"
|
||||
msgstr "%s: a opção `%s' é ambígua\n"
|
||||
|
||||
#: lib/getopt.c:687
|
||||
#, c-format
|
||||
msgid "%s: option `--%s' doesn't allow an argument\n"
|
||||
msgstr "%s: a opção `--%s' no admite nenhum argumento\n"
|
||||
|
||||
#: lib/getopt.c:692
|
||||
#, c-format
|
||||
msgid "%s: option `%c%s' doesn't allow an argument\n"
|
||||
msgstr "%s: a opção `%c%s' não admite nenhum argumento\n"
|
||||
|
||||
#: lib/getopt.c:710 lib/getopt.c:883
|
||||
#, c-format
|
||||
msgid "%s: option `%s' requires an argument\n"
|
||||
msgstr "%s: a opção `%s' exige um argumento\n"
|
||||
|
||||
#: lib/getopt.c:739
|
||||
#, c-format
|
||||
msgid "%s: unrecognized option `--%s'\n"
|
||||
msgstr "%s: opção `--%s' não reconhecida\n"
|
||||
|
||||
#: lib/getopt.c:743
|
||||
#, c-format
|
||||
msgid "%s: unrecognized option `%c%s'\n"
|
||||
msgstr "%s: opção `%c%s' não reconhecida\n"
|
||||
|
||||
#: lib/getopt.c:769
|
||||
#, c-format
|
||||
msgid "%s: illegal option -- %c\n"
|
||||
msgstr "%s: opção -- %c ilegal\n"
|
||||
|
||||
#: lib/getopt.c:772
|
||||
#, c-format
|
||||
msgid "%s: invalid option -- %c\n"
|
||||
msgstr "%s: opção -- %c inválida\n"
|
||||
|
||||
#: lib/getopt.c:802 lib/getopt.c:932
|
||||
#, c-format
|
||||
msgid "%s: option requires an argument -- %c\n"
|
||||
msgstr "%s: a opção -- %c exige um argumento\n"
|
||||
|
||||
#: lib/getopt.c:849
|
||||
#, c-format
|
||||
msgid "%s: option `-W %s' is ambiguous\n"
|
||||
msgstr "%s: a opção `-W %s' é ambígua\n"
|
||||
|
||||
#: lib/getopt.c:867
|
||||
#, c-format
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr "%s: a opção `-W %s' não admite nenhum argumento\n"
|
||||
|
||||
#: lib/obstack.c:496 lib/obstack.c:499 lib/xmalloc.c:66
|
||||
msgid "memory exhausted"
|
||||
msgstr "memória esgotada"
|
||||
|
||||
#: lib/quotearg.c:274
|
||||
msgid "`"
|
||||
msgstr "`"
|
||||
|
||||
#: lib/quotearg.c:275
|
||||
msgid "'"
|
||||
msgstr "'"
|
||||
|
||||
#: lib/timevar.c:466
|
||||
msgid ""
|
||||
"\n"
|
||||
"Execution times (seconds)\n"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"Tempos de execução (segundos)\n"
|
||||
|
||||
#: lib/timevar.c:516
|
||||
msgid " TOTAL :"
|
||||
msgstr " TOTAL :"
|
||||
|
||||
#: lib/timevar.c:552
|
||||
#, c-format
|
||||
msgid "time in %s: %ld.%06ld (%ld%%)\n"
|
||||
msgstr "tempo em %s: %ld.%06ld (%ld%%)\n"
|
||||
|
||||
#~ msgid "state_list_append (state = %d, symbol = %d (%s))\n"
|
||||
#~ msgstr "state_list_append (estado = %d, símbolo = %d (%s))\n"
|
||||
|
||||
#~ msgid "Entering new_itemsets, state = %d\n"
|
||||
#~ msgstr "Entrando new_itemsets, estado = %d\n"
|
||||
|
||||
#~ msgid "Entering get_state, symbol = %d (%s)\n"
|
||||
#~ msgstr "Entrando get_state, símbolo = %d (%s)\n"
|
||||
|
||||
#~ msgid "Exiting get_state => %d\n"
|
||||
#~ msgstr "Saindo get_state => %d\n"
|
||||
|
||||
#~ msgid "Entering append_states, state = %d\n"
|
||||
#~ msgstr "Entrando append_states, estado = %d\n"
|
||||
|
||||
#~ msgid "Processing state %d (reached by %s)\n"
|
||||
#~ msgstr "Processando estado %d (alcançado por %s)\n"
|
||||
|
||||
#~ msgid "undefined associativity"
|
||||
#~ msgstr "associatividade indefinida"
|
||||
|
||||
#~ msgid "Closure: %s\n"
|
||||
#~ msgstr "Fechamento: %s\n"
|
||||
|
||||
#~ msgid " (rule %d)\n"
|
||||
#~ msgstr " (regra %d)\n"
|
||||
|
||||
#~ msgid "RTC: Firsts Input"
|
||||
#~ msgstr "RTC: Entradas Antes"
|
||||
|
||||
#~ msgid "RTC: Firsts Output"
|
||||
#~ msgstr "RTC: Saídas Antes"
|
||||
|
||||
#~ msgid "input"
|
||||
#~ msgstr "entrada"
|
||||
|
||||
#~ msgid "output"
|
||||
#~ msgstr "saída"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Variables\n"
|
||||
#~ "---------\n"
|
||||
#~ "\n"
|
||||
#~ msgstr ""
|
||||
#~ "Variáveis\n"
|
||||
#~ "---------\n"
|
||||
#~ "\n"
|
||||
|
||||
#~ msgid "Value Sprec Sassoc Tag\n"
|
||||
#~ msgstr "Valor Sprec Sassoc Tag\n"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Rules\n"
|
||||
#~ "-----\n"
|
||||
#~ "\n"
|
||||
#~ msgstr ""
|
||||
#~ "Regras\n"
|
||||
#~ "------\n"
|
||||
#~ "\n"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n"
|
||||
#~ msgstr ""
|
||||
#~ "Num (Prec, Assoc, Util, Faixa Ritem) Lhs -> Rhs (Faixa Ritem) [Num]\n"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Rules interpreted\n"
|
||||
#~ "-----------------\n"
|
||||
#~ "\n"
|
||||
#~ msgstr ""
|
||||
#~ "Regras interpretadas\n"
|
||||
#~ "--------------------\n"
|
||||
#~ "\n"
|
||||
|
||||
#~ msgid "Lookaheads: BEGIN\n"
|
||||
#~ msgstr "Previsões: INICIO\n"
|
||||
|
||||
#~ msgid "State %d: %d lookaheads\n"
|
||||
#~ msgstr "Estado %d: %d previsões\n"
|
||||
|
||||
#~ msgid " on %d (%s) -> rule %d\n"
|
||||
#~ msgstr " em %d (%s) -> regra %d\n"
|
||||
|
||||
#~ msgid "Lookaheads: END\n"
|
||||
#~ msgstr "Previsões: FIM\n"
|
||||
|
||||
#~ msgid "relation_transpose: input\n"
|
||||
#~ msgstr "relation_transpose: entrada\n"
|
||||
|
||||
#~ msgid "relation_transpose: output\n"
|
||||
#~ msgstr "relation_transpose: saída\n"
|
||||
|
||||
#~ msgid "growing table and check from: %lu to %lu\n"
|
||||
#~ msgstr "aumentando a tabela e checando origem: %lu para %lu\n"
|
||||
|
||||
#~ msgid "base_t too small to hold %d\n"
|
||||
#~ msgstr "base_t muito pequeno para guardar %d\n"
|
||||
@@ -1,9 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
aclocal -I m4 && \
|
||||
gettextize && \
|
||||
autoconf && \
|
||||
autoheader && \
|
||||
automake -a && \
|
||||
touch stamp-h.in || \
|
||||
exit 1
|
||||
@@ -1,5 +1,7 @@
|
||||
/* Generate the nondeterministic finite state machine for bison,
|
||||
Copyright 1984, 1986, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
@@ -37,40 +39,65 @@
|
||||
#include "lalr.h"
|
||||
#include "reduce.h"
|
||||
|
||||
unsigned int nstates = 0;
|
||||
/* Initialize the final state to -1, otherwise, it might be set to 0
|
||||
by default, and since we don't compute the reductions of the final
|
||||
state, we end up not computing the reductions of the initial state,
|
||||
which is of course needed.
|
||||
typedef struct state_list_s
|
||||
{
|
||||
struct state_list_s *next;
|
||||
state_t *state;
|
||||
} state_list_t;
|
||||
|
||||
FINAL_STATE is properly set by new_state when it recognizes the
|
||||
accessing symbol: EOF. */
|
||||
int final_state = -1;
|
||||
static state_t *first_state = NULL;
|
||||
static state_list_t *first_state = NULL;
|
||||
static state_list_t *last_state = NULL;
|
||||
|
||||
static state_t *this_state = NULL;
|
||||
static state_t *last_state = NULL;
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| A state was just discovered from another state. Queue it for |
|
||||
| later examination, in order to find its transitions. Return it. |
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
static state_t *
|
||||
state_list_append (symbol_number_t symbol,
|
||||
size_t core_size, item_number_t *core)
|
||||
{
|
||||
state_list_t *node = XMALLOC (state_list_t, 1);
|
||||
state_t *state = state_new (symbol, core_size, core);
|
||||
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
||||
nstates, symbol, symbols[symbol]->tag);
|
||||
|
||||
/* If this is the endtoken, and this is not the initial state, then
|
||||
this is the final state. */
|
||||
if (symbol == 0 && first_state)
|
||||
final_state = state;
|
||||
|
||||
node->next = NULL;
|
||||
node->state = state;
|
||||
|
||||
if (!first_state)
|
||||
first_state = node;
|
||||
if (last_state)
|
||||
last_state->next = node;
|
||||
last_state = node;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static int nshifts;
|
||||
static token_number_t *shift_symbol = NULL;
|
||||
static symbol_number_t *shift_symbol = NULL;
|
||||
|
||||
static short *redset = NULL;
|
||||
static short *shiftset = NULL;
|
||||
static rule_t **redset = NULL;
|
||||
static state_t **shiftset = NULL;
|
||||
|
||||
static item_number_t **kernel_base = NULL;
|
||||
static int *kernel_size = NULL;
|
||||
static item_number_t *kernel_items = NULL;
|
||||
|
||||
/* hash table for states, to recognize equivalent ones. */
|
||||
|
||||
#define STATE_HASH_SIZE 1009
|
||||
static state_t **state_hash = NULL;
|
||||
|
||||
|
||||
static void
|
||||
allocate_itemsets (void)
|
||||
{
|
||||
int i, r;
|
||||
symbol_number_t i;
|
||||
rule_number_t r;
|
||||
item_number_t *rhsp;
|
||||
|
||||
/* Count the number of occurrences of all the symbols in RITEMS.
|
||||
@@ -80,7 +107,7 @@ allocate_itemsets (void)
|
||||
int count = 0;
|
||||
short *symbol_count = XCALLOC (short, nsyms + nuseless_nonterminals);
|
||||
|
||||
for (r = 1; r < nrules + 1; ++r)
|
||||
for (r = 0; r < nrules; ++r)
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||
{
|
||||
count++;
|
||||
@@ -90,7 +117,7 @@ allocate_itemsets (void)
|
||||
/* See comments before new_itemsets. All the vectors of items
|
||||
live inside KERNEL_ITEMS. The number of active items after
|
||||
some symbol cannot be more than the number of times that symbol
|
||||
appears as an item, which is symbol_count[symbol].
|
||||
appears as an item, which is SYMBOL_COUNT[SYMBOL].
|
||||
We allocate that much space for each symbol. */
|
||||
|
||||
kernel_base = XCALLOC (item_number_t *, nsyms);
|
||||
@@ -114,10 +141,10 @@ allocate_storage (void)
|
||||
{
|
||||
allocate_itemsets ();
|
||||
|
||||
shiftset = XCALLOC (short, nsyms);
|
||||
redset = XCALLOC (short, nrules + 1);
|
||||
state_hash = XCALLOC (state_t *, STATE_HASH_SIZE);
|
||||
shift_symbol = XCALLOC (token_number_t, nsyms);
|
||||
shiftset = XCALLOC (state_t *, nsyms);
|
||||
redset = XCALLOC (rule_t *, nrules);
|
||||
state_hash_new ();
|
||||
shift_symbol = XCALLOC (symbol_number_t, nsyms);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,31 +157,31 @@ free_storage (void)
|
||||
free (kernel_base);
|
||||
free (kernel_size);
|
||||
XFREE (kernel_items);
|
||||
free (state_hash);
|
||||
state_hash_free ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------.
|
||||
| Find which symbols can be shifted in the current state, and for |
|
||||
| each one record which items would be active after that shift. |
|
||||
| Uses the contents of itemset. |
|
||||
| |
|
||||
| shift_symbol is set to a vector of the symbols that can be |
|
||||
| shifted. For each symbol in the grammar, kernel_base[symbol] |
|
||||
| points to a vector of item numbers activated if that symbol is |
|
||||
| shifted, and kernel_size[symbol] is their numbers. |
|
||||
`----------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------.
|
||||
| Find which symbols can be shifted in STATE, and for each one |
|
||||
| record which items would be active after that shift. Uses the |
|
||||
| contents of itemset. |
|
||||
| |
|
||||
| shift_symbol is set to a vector of the symbols that can be |
|
||||
| shifted. For each symbol in the grammar, kernel_base[symbol] |
|
||||
| points to a vector of item numbers activated if that symbol is |
|
||||
| shifted, and kernel_size[symbol] is their numbers. |
|
||||
`---------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
new_itemsets (void)
|
||||
new_itemsets (state_t *state)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (trace_flag)
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering new_itemsets, state = %d\n",
|
||||
this_state->number);
|
||||
state->number);
|
||||
|
||||
for (i = 0; i < nsyms; i++)
|
||||
kernel_size[i] = 0;
|
||||
@@ -164,8 +191,8 @@ new_itemsets (void)
|
||||
for (i = 0; i < nritemset; ++i)
|
||||
if (ritem[itemset[i]] >= 0)
|
||||
{
|
||||
token_number_t symbol
|
||||
= item_number_as_token_number (ritem[itemset[i]]);
|
||||
symbol_number_t symbol
|
||||
= item_number_as_symbol_number (ritem[itemset[i]]);
|
||||
if (!kernel_size[symbol])
|
||||
{
|
||||
shift_symbol[nshifts] = symbol;
|
||||
@@ -180,129 +207,47 @@ new_itemsets (void)
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------.
|
||||
| Subroutine of get_state. Create a new state for those items, if |
|
||||
| necessary. |
|
||||
| Find the state we would get to (from the current state) by |
|
||||
| shifting SYMBOL. Create a new state if no equivalent one exists |
|
||||
| already. Used by append_states. |
|
||||
`-----------------------------------------------------------------*/
|
||||
|
||||
static state_t *
|
||||
new_state (token_number_t symbol)
|
||||
get_state (symbol_number_t symbol, size_t core_size, item_number_t *core)
|
||||
{
|
||||
state_t *p;
|
||||
|
||||
if (trace_flag)
|
||||
fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
|
||||
nstates, symbol, quotearg_style (escape_quoting_style,
|
||||
symbols[symbol]->tag));
|
||||
|
||||
if (nstates >= SHRT_MAX)
|
||||
fatal (_("too many states (max %d)"), SHRT_MAX);
|
||||
|
||||
p = STATE_ALLOC (kernel_size[symbol]);
|
||||
p->accessing_symbol = symbol;
|
||||
p->number = nstates;
|
||||
p->nitems = kernel_size[symbol];
|
||||
|
||||
memcpy (p->items, kernel_base[symbol],
|
||||
kernel_size[symbol] * sizeof (kernel_base[symbol][0]));
|
||||
|
||||
/* If this is the eoftoken, and this is not the initial state, then
|
||||
this is the final state. */
|
||||
if (symbol == 0 && first_state)
|
||||
final_state = p->number;
|
||||
|
||||
if (!first_state)
|
||||
first_state = p;
|
||||
if (last_state)
|
||||
last_state->next = p;
|
||||
last_state = p;
|
||||
|
||||
nstates++;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------.
|
||||
| Find the state number for the state we would get to (from the |
|
||||
| current state) by shifting symbol. Create a new state if no |
|
||||
| equivalent one exists already. Used by append_states. |
|
||||
`--------------------------------------------------------------*/
|
||||
|
||||
static int
|
||||
get_state (token_number_t symbol)
|
||||
{
|
||||
int key;
|
||||
int i;
|
||||
state_t *sp;
|
||||
|
||||
if (trace_flag)
|
||||
fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
|
||||
this_state->number, symbol, quotearg_style (escape_quoting_style,
|
||||
symbols[symbol]->tag));
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
||||
symbol, symbols[symbol]->tag);
|
||||
|
||||
/* Add up the target state's active item numbers to get a hash key.
|
||||
*/
|
||||
key = 0;
|
||||
for (i = 0; i < kernel_size[symbol]; ++i)
|
||||
key += kernel_base[symbol][i];
|
||||
key = key % STATE_HASH_SIZE;
|
||||
sp = state_hash[key];
|
||||
sp = state_hash_lookup (core_size, core);
|
||||
if (!sp)
|
||||
sp = state_list_append (symbol, core_size, core);
|
||||
|
||||
if (sp)
|
||||
{
|
||||
int found = 0;
|
||||
while (!found)
|
||||
{
|
||||
if (sp->nitems == kernel_size[symbol])
|
||||
{
|
||||
found = 1;
|
||||
for (i = 0; i < kernel_size[symbol]; ++i)
|
||||
if (kernel_base[symbol][i] != sp->items[i])
|
||||
found = 0;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
if (sp->link)
|
||||
{
|
||||
sp = sp->link;
|
||||
}
|
||||
else /* bucket exhausted and no match */
|
||||
{
|
||||
sp = sp->link = new_state (symbol);
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* bucket is empty */
|
||||
{
|
||||
state_hash[key] = sp = new_state (symbol);
|
||||
}
|
||||
|
||||
if (trace_flag)
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Exiting get_state => %d\n", sp->number);
|
||||
|
||||
return sp->number;
|
||||
return sp;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Use the information computed by new_itemsets to find the state |
|
||||
| numbers reached by each shift transition from the current state. |
|
||||
| |
|
||||
| shiftset is set up as a vector of state numbers of those states. |
|
||||
`------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------.
|
||||
| Use the information computed by new_itemsets to find the state |
|
||||
| numbers reached by each shift transition from STATE. |
|
||||
| |
|
||||
| SHIFTSET is set up as a vector of those states. |
|
||||
`---------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
append_states (void)
|
||||
append_states (state_t *state)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
token_number_t symbol;
|
||||
symbol_number_t symbol;
|
||||
|
||||
if (trace_flag)
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering append_states, state = %d\n",
|
||||
this_state->number);
|
||||
state->number);
|
||||
|
||||
/* first sort shift_symbol into increasing order */
|
||||
|
||||
@@ -319,30 +264,11 @@ append_states (void)
|
||||
}
|
||||
|
||||
for (i = 0; i < nshifts; i++)
|
||||
shiftset[i] = get_state (shift_symbol[i]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
new_states (void)
|
||||
{
|
||||
/* The 0 at the lhs is the index of the item of this initial rule. */
|
||||
kernel_base[0][0] = 0;
|
||||
kernel_size[0] = 1;
|
||||
this_state = new_state (0);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------.
|
||||
| Save the NSHIFTS of SHIFTSET into the current linked list. |
|
||||
`------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
save_shifts (void)
|
||||
{
|
||||
shifts *p = shifts_new (nshifts);
|
||||
memcpy (p->shifts, shiftset, nshifts * sizeof (shiftset[0]));
|
||||
this_state->shifts = p;
|
||||
{
|
||||
symbol = shift_symbol[i];
|
||||
shiftset[i] = get_state (symbol,
|
||||
kernel_size[symbol], kernel_base[symbol]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -353,27 +279,21 @@ save_shifts (void)
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
save_reductions (void)
|
||||
save_reductions (state_t *state)
|
||||
{
|
||||
int count = 0;
|
||||
int i;
|
||||
|
||||
/* If this is the final state, we want it to have no reductions at
|
||||
all, although it has one for `START_SYMBOL EOF .'. */
|
||||
if (this_state->number == final_state)
|
||||
return;
|
||||
|
||||
/* Find and count the active items that represent ends of rules. */
|
||||
for (i = 0; i < nritemset; ++i)
|
||||
{
|
||||
int item = ritem[itemset[i]];
|
||||
if (item < 0)
|
||||
redset[count++] = -item;
|
||||
redset[count++] = &rules[item_number_as_rule_number (item)];
|
||||
}
|
||||
|
||||
/* Make a reductions structure and copy the data into it. */
|
||||
this_state->reductions = reductions_new (count);
|
||||
memcpy (this_state->reductions->rules, redset, count * sizeof (redset[0]));
|
||||
state_reductions_set (state, count, redset);
|
||||
}
|
||||
|
||||
|
||||
@@ -384,25 +304,32 @@ save_reductions (void)
|
||||
static void
|
||||
set_states (void)
|
||||
{
|
||||
state_t *sp;
|
||||
states = XCALLOC (state_t *, nstates);
|
||||
|
||||
for (sp = first_state; sp; sp = sp->next)
|
||||
while (first_state)
|
||||
{
|
||||
/* Pessimization, but simplification of the code: make sure all
|
||||
the states have a shifts, errs, and reductions, even if
|
||||
reduced to 0. */
|
||||
if (!sp->shifts)
|
||||
sp->shifts = shifts_new (0);
|
||||
if (!sp->errs)
|
||||
sp->errs = errs_new (0);
|
||||
if (!sp->reductions)
|
||||
sp->reductions = reductions_new (0);
|
||||
state_list_t *this = first_state;
|
||||
|
||||
states[sp->number] = sp;
|
||||
/* Pessimization, but simplification of the code: make sure all
|
||||
the states have valid transitions and reductions members,
|
||||
even if reduced to 0. It is too soon for errs, which are
|
||||
computed later, but set_conflicts. */
|
||||
state_t *state = this->state;
|
||||
if (!state->transitions)
|
||||
state_transitions_set (state, 0, 0);
|
||||
if (!state->reductions)
|
||||
state_reductions_set (state, 0, 0);
|
||||
|
||||
states[state->number] = state;
|
||||
|
||||
first_state = this->next;
|
||||
free (this);
|
||||
}
|
||||
first_state = NULL;
|
||||
last_state = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------.
|
||||
| Compute the nondeterministic finite state machine (see state.h for |
|
||||
| details) from the grammar. |
|
||||
@@ -411,35 +338,44 @@ set_states (void)
|
||||
void
|
||||
generate_states (void)
|
||||
{
|
||||
state_list_t *list = NULL;
|
||||
allocate_storage ();
|
||||
new_closure (nritems);
|
||||
new_states ();
|
||||
|
||||
while (this_state)
|
||||
/* Create the initial state. The 0 at the lhs is the index of the
|
||||
item of this initial rule. */
|
||||
kernel_base[0][0] = 0;
|
||||
kernel_size[0] = 1;
|
||||
state_list_append (0, kernel_size[0], kernel_base[0]);
|
||||
|
||||
list = first_state;
|
||||
|
||||
while (list)
|
||||
{
|
||||
if (trace_flag)
|
||||
state_t *state = list->state;
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
||||
this_state->number,
|
||||
quotearg_style (escape_quoting_style,
|
||||
symbols[this_state->accessing_symbol]->tag));
|
||||
state->number,
|
||||
symbols[state->accessing_symbol]->tag);
|
||||
/* Set up ruleset and itemset for the transitions out of this
|
||||
state. ruleset gets a 1 bit for each rule that could reduce
|
||||
now. itemset gets a vector of all the items that could be
|
||||
accepted next. */
|
||||
closure (this_state->items, this_state->nitems);
|
||||
/* record the reductions allowed out of this state */
|
||||
save_reductions ();
|
||||
/* find the itemsets of the states that shifts can reach */
|
||||
new_itemsets ();
|
||||
/* find or create the core structures for those states */
|
||||
append_states ();
|
||||
closure (state->items, state->nitems);
|
||||
/* Record the reductions allowed out of this state. */
|
||||
save_reductions (state);
|
||||
/* Find the itemsets of the states that shifts can reach. */
|
||||
new_itemsets (state);
|
||||
/* Find or create the core structures for those states. */
|
||||
append_states (state);
|
||||
|
||||
/* create the shifts structures for the shifts to those states,
|
||||
now that the state numbers transitioning to are known */
|
||||
save_shifts ();
|
||||
/* Create the shifts structures for the shifts to those states,
|
||||
now that the state numbers transitioning to are known. */
|
||||
state_transitions_set (state, nshifts, shiftset);
|
||||
|
||||
/* states are queued when they are created; process them all */
|
||||
this_state = this_state->next;
|
||||
/* States are queued when they are created; process them all.
|
||||
*/
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
/* discard various storage */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user