updated flex to 2.5.33, it now uses m4
tested on Qemu with aslcompiler.l => it takes more than 1m30s here, and shows a bottleneck in the kernel (the use of pipes) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20025 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
54acbf6a87
commit
d09c0ef980
625
src/bin/flex/ABOUT-NLS
Normal file
625
src/bin/flex/ABOUT-NLS
Normal file
@ -0,0 +1,625 @@
|
||||
Notes on the Free Translation Project
|
||||
*************************************
|
||||
|
||||
Free software is going international! The Free Translation Project
|
||||
is a way to get maintainers of free software, translators, and users all
|
||||
together, so that will gradually become able to speak many languages.
|
||||
A few packages already provide translations for their messages.
|
||||
|
||||
If you found this `ABOUT-NLS' file inside a distribution, you may
|
||||
assume that the distributed package does use GNU `gettext' internally,
|
||||
itself available at your nearest GNU archive site. But you do _not_
|
||||
need to install GNU `gettext' prior to configuring, installing or using
|
||||
this package with messages translated.
|
||||
|
||||
Installers will find here some useful hints. These notes also
|
||||
explain how users should proceed for getting the programs to use the
|
||||
available translations. They tell how people wanting to contribute and
|
||||
work at translations should contact the appropriate team.
|
||||
|
||||
When reporting bugs in the `intl/' directory or bugs which may be
|
||||
related to internationalization, you should tell about the version of
|
||||
`gettext' which is used. The information can be found in the
|
||||
`intl/VERSION' file, in internationalized packages.
|
||||
|
||||
Quick configuration advice
|
||||
==========================
|
||||
|
||||
If you want to exploit the full power of internationalization, you
|
||||
should configure it using
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to force usage of internationalizing routines provided within this
|
||||
package, despite the existence of internationalizing capabilities in the
|
||||
operating system where this package is being installed. So far, only
|
||||
the `gettext' implementation in the GNU C library version 2 provides as
|
||||
many features (such as locale alias, message inheritance, automatic
|
||||
charset conversion or plural form handling) as the implementation here.
|
||||
It is also not possible to offer this additional functionality on top
|
||||
of a `catgets' implementation. Future versions of GNU `gettext' will
|
||||
very likely convey even more functionality. So it might be a good idea
|
||||
to change to GNU `gettext' as soon as possible.
|
||||
|
||||
So you need _not_ provide this option if you are using GNU libc 2 or
|
||||
you have installed a recent copy of the GNU gettext package with the
|
||||
included `libintl'.
|
||||
|
||||
INSTALL Matters
|
||||
===============
|
||||
|
||||
Some packages are "localizable" when properly installed; the
|
||||
programs they contain can be made to speak your own native language.
|
||||
Most such packages use GNU `gettext'. Other packages have their own
|
||||
ways to internationalization, predating GNU `gettext'.
|
||||
|
||||
By default, this package will be installed to allow translation of
|
||||
messages. It will automatically detect whether the system already
|
||||
provides the GNU `gettext' functions. If not, the GNU `gettext' own
|
||||
library will be used. This library is wholly contained within this
|
||||
package, usually in the `intl/' subdirectory, so prior installation of
|
||||
the GNU `gettext' package is _not_ required. Installers may use
|
||||
special options at configuration time for changing the default
|
||||
behaviour. The commands:
|
||||
|
||||
./configure --with-included-gettext
|
||||
./configure --disable-nls
|
||||
|
||||
will respectively bypass any pre-existing `gettext' to use the
|
||||
internationalizing routines provided within this package, or else,
|
||||
_totally_ disable translation of messages.
|
||||
|
||||
When you already have GNU `gettext' installed on your system and run
|
||||
configure without an option for your new package, `configure' will
|
||||
probably detect the previously built and installed `libintl.a' file and
|
||||
will decide to use this. This might be not what is desirable. You
|
||||
should use the more recent version of the GNU `gettext' library. I.e.
|
||||
if the file `intl/VERSION' shows that the library which comes with this
|
||||
package is more recent, you should use
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to prevent auto-detection.
|
||||
|
||||
The configuration process will not test for the `catgets' function
|
||||
and therefore it will not be used. The reason is that even an
|
||||
emulation of `gettext' on top of `catgets' could not provide all the
|
||||
extensions of the GNU `gettext' library.
|
||||
|
||||
Internationalized packages have usually many `po/LL.po' files, where
|
||||
LL gives an ISO 639 two-letter code identifying the language. Unless
|
||||
translations have been forbidden at `configure' time by using the
|
||||
`--disable-nls' switch, all available translations are installed
|
||||
together with the package. However, the environment variable `LINGUAS'
|
||||
may be set, prior to configuration, to limit the installed set.
|
||||
`LINGUAS' should then contain a space separated list of two-letter
|
||||
codes, stating which languages are allowed.
|
||||
|
||||
Using This Package
|
||||
==================
|
||||
|
||||
As a user, if your language has been installed for this package, you
|
||||
only have to set the `LANG' environment variable to the appropriate
|
||||
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
|
||||
and `CC' is an ISO 3166 two-letter country code. For example, let's
|
||||
suppose that you speak German and live in Germany. At the shell
|
||||
prompt, merely execute `setenv LANG de_DE' (in `csh'),
|
||||
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
|
||||
This can be done from your `.login' or `.profile' file, once and for
|
||||
all.
|
||||
|
||||
You might think that the country code specification is redundant.
|
||||
But in fact, some languages have dialects in different countries. For
|
||||
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
|
||||
country code serves to distinguish the dialects.
|
||||
|
||||
The locale naming convention of `LL_CC', with `LL' denoting the
|
||||
language and `CC' denoting the country, is the one use on systems based
|
||||
on GNU libc. On other systems, some variations of this scheme are
|
||||
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
|
||||
locales supported by your system for your country by running the command
|
||||
`locale -a | grep '^LL''.
|
||||
|
||||
Not all programs have translations for all languages. By default, an
|
||||
English message is shown in place of a nonexistent translation. If you
|
||||
understand other languages, you can set up a priority list of languages.
|
||||
This is done through a different environment variable, called
|
||||
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
|
||||
for the purpose of message handling, but you still need to have `LANG'
|
||||
set to the primary language; this is required by other parts of the
|
||||
system libraries. For example, some Swedish users who would rather
|
||||
read translations in German than English for when Swedish is not
|
||||
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
|
||||
|
||||
In the `LANGUAGE' environment variable, but not in the `LANG'
|
||||
environment variable, `LL_CC' combinations can be abbreviated as `LL'
|
||||
to denote the language's main dialect. For example, `de' is equivalent
|
||||
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
|
||||
(Portuguese as spoken in Portugal) in this context.
|
||||
|
||||
Translating Teams
|
||||
=================
|
||||
|
||||
For the Free Translation Project to be a success, we need interested
|
||||
people who like their own language and write it well, and who are also
|
||||
able to synergize with other translators speaking the same language.
|
||||
Each translation team has its own mailing list. The up-to-date list of
|
||||
teams can be found at the Free Translation Project's homepage,
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
|
||||
area.
|
||||
|
||||
If you'd like to volunteer to _work_ at translating messages, you
|
||||
should become a member of the translating team for your own language.
|
||||
The subscribing address is _not_ the same as the list itself, it has
|
||||
`-request' appended. For example, speakers of Swedish can send a
|
||||
message to `sv-request@li.org', having this message body:
|
||||
|
||||
subscribe
|
||||
|
||||
Keep in mind that team members are expected to participate
|
||||
_actively_ in translations, or at solving translational difficulties,
|
||||
rather than merely lurking around. If your team does not exist yet and
|
||||
you want to start one, or if you are unsure about what to do or how to
|
||||
get started, please write to `translation@iro.umontreal.ca' to reach the
|
||||
coordinator for all translator teams.
|
||||
|
||||
The English team is special. It works at improving and uniformizing
|
||||
the terminology in use. Proven linguistic skill are praised more than
|
||||
programming skill, here.
|
||||
|
||||
Available Packages
|
||||
==================
|
||||
|
||||
Languages are not equally supported in all packages. The following
|
||||
matrix shows the current state of internationalization, as of May 2003.
|
||||
The matrix shows, in regard of each package, for which languages PO
|
||||
files have been submitted to translation coordination, with a
|
||||
translation percentage of at least 50%.
|
||||
|
||||
Ready PO files am az be bg ca cs da de el en en_GB eo es
|
||||
+-------------------------------------------+
|
||||
a2ps | [] [] [] [] |
|
||||
aegis | () |
|
||||
anubis | |
|
||||
ap-utils | |
|
||||
bash | [] [] [] |
|
||||
batchelor | |
|
||||
bfd | [] [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] |
|
||||
bluez-pin | [] [] |
|
||||
clisp | |
|
||||
clisp | [] [] [] |
|
||||
coreutils | [] [] [] [] |
|
||||
cpio | [] [] [] |
|
||||
darkstat | () [] |
|
||||
diffutils | [] [] [] [] [] [] [] |
|
||||
e2fsprogs | [] [] |
|
||||
enscript | [] [] [] [] |
|
||||
error | [] [] [] [] [] |
|
||||
fetchmail | [] () [] [] [] [] |
|
||||
fileutils | [] [] [] |
|
||||
findutils | [] [] [] [] [] [] |
|
||||
flex | [] [] [] [] |
|
||||
gas | [] |
|
||||
gawk | [] [] [] [] |
|
||||
gcal | [] |
|
||||
gcc | [] [] |
|
||||
gettext | [] [] [] [] [] |
|
||||
gettext-runtime | [] [] [] [] [] |
|
||||
gettext-tools | [] [] |
|
||||
gimp-print | [] [] [] [] [] |
|
||||
gliv | |
|
||||
glunarclock | [] [] [] |
|
||||
gnucash | () [] |
|
||||
gnucash-glossary | [] () [] |
|
||||
gnupg | [] () [] [] [] [] |
|
||||
gpe-calendar | [] |
|
||||
gpe-conf | [] |
|
||||
gpe-contacts | [] |
|
||||
gpe-edit | |
|
||||
gpe-login | [] |
|
||||
gpe-ownerinfo | [] |
|
||||
gpe-sketchbook | [] |
|
||||
gpe-timesheet | |
|
||||
gpe-today | [] |
|
||||
gpe-todo | [] |
|
||||
gphoto2 | [] [] [] [] |
|
||||
gprof | [] [] |
|
||||
gpsdrive | () () () |
|
||||
grep | [] [] [] [] [] |
|
||||
gretl | [] |
|
||||
hello | [] [] [] [] [] [] |
|
||||
id-utils | [] [] |
|
||||
indent | [] [] [] [] |
|
||||
jpilot | [] [] [] [] |
|
||||
jwhois | [] |
|
||||
kbd | [] [] [] [] [] |
|
||||
ld | [] [] |
|
||||
libc | [] [] [] [] [] [] |
|
||||
libgpewidget | [] |
|
||||
libiconv | [] [] [] [] [] |
|
||||
lifelines | [] () |
|
||||
lilypond | [] |
|
||||
lingoteach | |
|
||||
lingoteach_lessons | () () |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | [] [] |
|
||||
make | [] [] [] |
|
||||
man-db | [] () [] [] () |
|
||||
mysecretdiary | [] [] [] |
|
||||
nano | [] () [] [] [] |
|
||||
nano_1_0 | [] () [] [] [] |
|
||||
opcodes | [] [] |
|
||||
parted | [] [] [] [] [] |
|
||||
ptx | [] [] [] [] [] |
|
||||
python | |
|
||||
radius | |
|
||||
recode | [] [] [] [] [] [] |
|
||||
screem | |
|
||||
sed | [] [] [] [] [] |
|
||||
sh-utils | [] [] [] |
|
||||
sharutils | [] [] [] [] [] [] |
|
||||
sketch | [] () [] |
|
||||
soundtracker | [] [] [] |
|
||||
sp | [] |
|
||||
tar | [] [] [] [] |
|
||||
texinfo | [] [] [] [] |
|
||||
textutils | [] [] [] [] |
|
||||
tin | () () |
|
||||
util-linux | [] [] [] [] [] |
|
||||
vorbis-tools | [] [] [] |
|
||||
wastesedge | () |
|
||||
wdiff | [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] [] |
|
||||
xchat | [] [] [] |
|
||||
xpad | |
|
||||
+-------------------------------------------+
|
||||
am az be bg ca cs da de el en en_GB eo es
|
||||
0 1 4 2 31 17 54 60 14 1 4 12 56
|
||||
|
||||
et fa fi fr ga gl he hr hu id it ja ko
|
||||
+----------------------------------------+
|
||||
a2ps | [] [] [] () () |
|
||||
aegis | |
|
||||
anubis | [] |
|
||||
ap-utils | [] |
|
||||
bash | [] [] |
|
||||
batchelor | [] |
|
||||
bfd | [] [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] [] |
|
||||
bluez-pin | [] [] [] [] |
|
||||
clisp | |
|
||||
clisp | [] |
|
||||
coreutils | [] [] [] [] |
|
||||
cpio | [] [] [] [] |
|
||||
darkstat | () [] [] [] |
|
||||
diffutils | [] [] [] [] [] [] [] |
|
||||
e2fsprogs | |
|
||||
enscript | [] [] |
|
||||
error | [] [] [] [] |
|
||||
fetchmail | [] |
|
||||
fileutils | [] [] [] [] [] |
|
||||
findutils | [] [] [] [] [] [] [] [] [] [] [] |
|
||||
flex | [] [] |
|
||||
gas | [] |
|
||||
gawk | [] [] |
|
||||
gcal | [] |
|
||||
gcc | [] |
|
||||
gettext | [] [] [] |
|
||||
gettext-runtime | [] [] [] [] |
|
||||
gettext-tools | [] |
|
||||
gimp-print | [] [] |
|
||||
gliv | () |
|
||||
glunarclock | [] [] [] [] |
|
||||
gnucash | [] |
|
||||
gnucash-glossary | [] |
|
||||
gnupg | [] [] [] [] [] [] [] |
|
||||
gpe-calendar | [] |
|
||||
gpe-conf | |
|
||||
gpe-contacts | [] |
|
||||
gpe-edit | [] [] |
|
||||
gpe-login | [] |
|
||||
gpe-ownerinfo | [] [] [] |
|
||||
gpe-sketchbook | [] |
|
||||
gpe-timesheet | [] [] [] |
|
||||
gpe-today | [] [] |
|
||||
gpe-todo | [] [] |
|
||||
gphoto2 | [] [] [] |
|
||||
gprof | [] [] |
|
||||
gpsdrive | () [] () () |
|
||||
grep | [] [] [] [] [] [] [] [] [] [] [] |
|
||||
gretl | [] |
|
||||
hello | [] [] [] [] [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] |
|
||||
indent | [] [] [] [] [] [] [] [] |
|
||||
jpilot | [] () |
|
||||
jwhois | [] [] [] [] |
|
||||
kbd | [] |
|
||||
ld | [] |
|
||||
libc | [] [] [] [] [] [] |
|
||||
libgpewidget | [] [] [] |
|
||||
libiconv | [] [] [] [] [] [] [] [] |
|
||||
lifelines | () |
|
||||
lilypond | [] |
|
||||
lingoteach | [] [] |
|
||||
lingoteach_lessons | |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | |
|
||||
make | [] [] [] [] [] [] |
|
||||
man-db | [] () () |
|
||||
mysecretdiary | [] [] |
|
||||
nano | [] [] [] [] |
|
||||
nano_1_0 | [] [] [] [] |
|
||||
opcodes | [] [] |
|
||||
parted | [] [] [] |
|
||||
ptx | [] [] [] [] [] [] [] |
|
||||
python | |
|
||||
radius | |
|
||||
recode | [] [] [] [] [] [] |
|
||||
screem | |
|
||||
sed | [] [] [] [] [] [] [] [] |
|
||||
sh-utils | [] [] [] [] [] [] |
|
||||
sharutils | [] [] [] [] [] |
|
||||
sketch | [] |
|
||||
soundtracker | [] [] [] |
|
||||
sp | [] () |
|
||||
tar | [] [] [] [] [] [] [] [] [] |
|
||||
texinfo | [] [] [] [] |
|
||||
textutils | [] [] [] [] [] |
|
||||
tin | [] () |
|
||||
util-linux | [] [] [] [] () [] |
|
||||
vorbis-tools | [] |
|
||||
wastesedge | () |
|
||||
wdiff | [] [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] [] [] |
|
||||
xchat | [] [] [] |
|
||||
xpad | |
|
||||
+----------------------------------------+
|
||||
et fa fi fr ga gl he hr hu id it ja ko
|
||||
20 1 15 73 14 24 8 10 30 31 19 31 9
|
||||
|
||||
lg lt lv ms nb nl nn no pl pt pt_BR ro
|
||||
+----------------------------------------+
|
||||
a2ps | [] [] () () () [] [] |
|
||||
aegis | () |
|
||||
anubis | [] [] |
|
||||
ap-utils | () |
|
||||
bash | [] |
|
||||
batchelor | |
|
||||
bfd | |
|
||||
binutils | |
|
||||
bison | [] [] [] [] |
|
||||
bluez-pin | [] |
|
||||
clisp | |
|
||||
clisp | [] |
|
||||
coreutils | [] |
|
||||
cpio | [] [] [] |
|
||||
darkstat | [] [] [] [] |
|
||||
diffutils | [] [] [] |
|
||||
e2fsprogs | |
|
||||
enscript | [] [] |
|
||||
error | [] [] |
|
||||
fetchmail | () () |
|
||||
fileutils | [] |
|
||||
findutils | [] [] [] [] |
|
||||
flex | [] |
|
||||
gas | |
|
||||
gawk | [] |
|
||||
gcal | |
|
||||
gcc | |
|
||||
gettext | [] |
|
||||
gettext-runtime | [] |
|
||||
gettext-tools | |
|
||||
gimp-print | [] |
|
||||
gliv | [] |
|
||||
glunarclock | [] |
|
||||
gnucash | |
|
||||
gnucash-glossary | [] [] |
|
||||
gnupg | |
|
||||
gpe-calendar | [] [] |
|
||||
gpe-conf | [] [] |
|
||||
gpe-contacts | [] |
|
||||
gpe-edit | [] [] |
|
||||
gpe-login | [] [] |
|
||||
gpe-ownerinfo | [] [] |
|
||||
gpe-sketchbook | [] [] |
|
||||
gpe-timesheet | [] [] |
|
||||
gpe-today | [] [] |
|
||||
gpe-todo | [] [] |
|
||||
gphoto2 | |
|
||||
gprof | [] |
|
||||
gpsdrive | () () () |
|
||||
grep | [] [] [] [] |
|
||||
gretl | |
|
||||
hello | [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] |
|
||||
indent | [] [] [] |
|
||||
jpilot | () () |
|
||||
jwhois | [] [] [] |
|
||||
kbd | |
|
||||
ld | |
|
||||
libc | [] [] [] [] |
|
||||
libgpewidget | [] [] |
|
||||
libiconv | [] [] |
|
||||
lifelines | |
|
||||
lilypond | [] |
|
||||
lingoteach | |
|
||||
lingoteach_lessons | |
|
||||
lynx | [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | |
|
||||
make | [] [] |
|
||||
man-db | [] |
|
||||
mysecretdiary | [] |
|
||||
nano | [] [] [] [] |
|
||||
nano_1_0 | [] [] [] [] |
|
||||
opcodes | [] [] [] |
|
||||
parted | [] [] [] |
|
||||
ptx | [] [] [] [] [] [] [] |
|
||||
python | |
|
||||
radius | |
|
||||
recode | [] [] [] |
|
||||
screem | |
|
||||
sed | [] [] |
|
||||
sh-utils | [] |
|
||||
sharutils | [] |
|
||||
sketch | [] |
|
||||
soundtracker | |
|
||||
sp | |
|
||||
tar | [] [] [] [] [] [] |
|
||||
texinfo | [] |
|
||||
textutils | [] |
|
||||
tin | |
|
||||
util-linux | [] [] |
|
||||
vorbis-tools | [] [] |
|
||||
wastesedge | |
|
||||
wdiff | [] [] [] [] |
|
||||
wget | [] [] [] |
|
||||
xchat | [] [] |
|
||||
xpad | [] |
|
||||
+----------------------------------------+
|
||||
lg lt lv ms nb nl nn no pl pt pt_BR ro
|
||||
0 0 2 11 7 26 3 4 18 15 34 34
|
||||
|
||||
ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW
|
||||
+-------------------------------------------+
|
||||
a2ps | [] [] [] [] [] | 16
|
||||
aegis | () | 0
|
||||
anubis | [] [] | 5
|
||||
ap-utils | () | 1
|
||||
bash | [] | 7
|
||||
batchelor | | 1
|
||||
bfd | [] [] [] | 7
|
||||
binutils | [] [] [] | 7
|
||||
bison | [] [] | 13
|
||||
bluez-pin | | 7
|
||||
clisp | | 0
|
||||
clisp | | 5
|
||||
coreutils | [] [] [] [] [] | 14
|
||||
cpio | [] [] [] | 13
|
||||
darkstat | [] () () | 9
|
||||
diffutils | [] [] [] [] | 21
|
||||
e2fsprogs | [] | 3
|
||||
enscript | [] [] [] | 11
|
||||
error | [] [] [] | 14
|
||||
fetchmail | [] | 7
|
||||
fileutils | [] [] [] [] [] [] | 15
|
||||
findutils | [] [] [] [] [] [] | 27
|
||||
flex | [] [] [] | 10
|
||||
gas | [] | 3
|
||||
gawk | [] [] | 9
|
||||
gcal | [] [] | 4
|
||||
gcc | [] | 4
|
||||
gettext | [] [] [] [] [] [] | 15
|
||||
gettext-runtime | [] [] [] [] [] [] | 16
|
||||
gettext-tools | [] [] | 5
|
||||
gimp-print | [] [] | 10
|
||||
gliv | | 1
|
||||
glunarclock | [] [] [] | 11
|
||||
gnucash | [] [] | 4
|
||||
gnucash-glossary | [] [] [] | 8
|
||||
gnupg | [] [] [] [] | 16
|
||||
gpe-calendar | [] | 5
|
||||
gpe-conf | | 3
|
||||
gpe-contacts | [] | 4
|
||||
gpe-edit | [] | 5
|
||||
gpe-login | [] | 5
|
||||
gpe-ownerinfo | [] | 7
|
||||
gpe-sketchbook | [] | 5
|
||||
gpe-timesheet | [] | 6
|
||||
gpe-today | [] | 6
|
||||
gpe-todo | [] | 6
|
||||
gphoto2 | [] [] | 9
|
||||
gprof | [] [] | 7
|
||||
gpsdrive | [] [] | 3
|
||||
grep | [] [] [] [] | 24
|
||||
gretl | | 2
|
||||
hello | [] [] [] [] [] | 33
|
||||
id-utils | [] [] [] | 11
|
||||
indent | [] [] [] [] | 19
|
||||
jpilot | [] [] [] [] [] | 10
|
||||
jwhois | () () [] [] | 10
|
||||
kbd | [] [] | 8
|
||||
ld | [] [] | 5
|
||||
libc | [] [] [] [] | 20
|
||||
libgpewidget | | 6
|
||||
libiconv | [] [] [] [] [] [] | 21
|
||||
lifelines | [] | 2
|
||||
lilypond | [] | 4
|
||||
lingoteach | | 2
|
||||
lingoteach_lessons | () | 0
|
||||
lynx | [] [] [] [] | 14
|
||||
m4 | [] [] [] | 15
|
||||
mailutils | | 2
|
||||
make | [] [] [] [] | 15
|
||||
man-db | [] | 6
|
||||
mysecretdiary | [] [] | 8
|
||||
nano | [] [] [] | 15
|
||||
nano_1_0 | [] [] [] | 15
|
||||
opcodes | [] [] | 9
|
||||
parted | [] [] | 13
|
||||
ptx | [] [] [] | 22
|
||||
python | | 0
|
||||
radius | | 0
|
||||
recode | [] [] [] [] | 19
|
||||
screem | [] | 1
|
||||
sed | [] [] [] [] [] | 20
|
||||
sh-utils | [] [] [] | 13
|
||||
sharutils | [] [] [] [] | 16
|
||||
sketch | [] | 5
|
||||
soundtracker | [] | 7
|
||||
sp | [] | 3
|
||||
tar | [] [] [] [] [] | 24
|
||||
texinfo | [] [] [] [] | 13
|
||||
textutils | [] [] [] [] [] | 15
|
||||
tin | | 1
|
||||
util-linux | [] [] | 14
|
||||
vorbis-tools | [] | 7
|
||||
wastesedge | | 0
|
||||
wdiff | [] [] [] [] | 17
|
||||
wget | [] [] [] [] [] [] [] | 25
|
||||
xchat | [] [] [] | 11
|
||||
xpad | | 1
|
||||
+-------------------------------------------+
|
||||
50 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW
|
||||
97 domains 32 19 16 0 56 0 48 10 1 1 12 23 913
|
||||
|
||||
Some counters in the preceding matrix are higher than the number of
|
||||
visible blocks let us expect. This is because a few extra PO files are
|
||||
used for implementing regional variants of languages, or language
|
||||
dialects.
|
||||
|
||||
For a PO file in the matrix above to be effective, the package to
|
||||
which it applies should also have been internationalized and
|
||||
distributed as such by its maintainer. There might be an observable
|
||||
lag between the mere existence a PO file and its wide availability in a
|
||||
distribution.
|
||||
|
||||
If May 2003 seems to be old, you may fetch a more recent copy of
|
||||
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
|
||||
matrix with full percentage details can be found at
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
|
||||
|
||||
Using `gettext' in new packages
|
||||
===============================
|
||||
|
||||
If you are writing a freely available program and want to
|
||||
internationalize it you are welcome to use GNU `gettext' in your
|
||||
package. Of course you have to respect the GNU Library General Public
|
||||
License which covers the use of the GNU `gettext' library. This means
|
||||
in particular that even non-free programs can use `libintl' as a shared
|
||||
library, whereas only free software can use `libintl' as a static
|
||||
library or use modified versions of `libintl'.
|
||||
|
||||
Once the sources are changed appropriately and the setup can handle
|
||||
the use of `gettext' the only thing missing are the translations. The
|
||||
Free Translation Project is also available for packages which are not
|
||||
developed inside the GNU project. Therefore the information given above
|
||||
applies also for every other Free Software Project. Contact
|
||||
`translation@iro.umontreal.ca' to make the `.pot' files available to
|
||||
the translation teams.
|
||||
|
13
src/bin/flex/AUTHORS
Normal file
13
src/bin/flex/AUTHORS
Normal file
@ -0,0 +1,13 @@
|
||||
Vern Paxson wrote flex with the help of many ideas and much
|
||||
inspiration from Van Jacobson. Original version by Jef Poskanzer.
|
||||
|
||||
The fast table representation is a partial implementation of a design
|
||||
done by Van Jacobson. The implementation was done by Kevin Gong and
|
||||
Vern Paxson.
|
||||
|
||||
In 2001, W. L. Estes took over as maintainer of flex.
|
||||
|
||||
John Millaway is a co-author of the current version of flex. He has
|
||||
contributed a large number of new features, fixed a large number of
|
||||
outstanding bugs and has made significant contributions to the flex
|
||||
documentation.
|
@ -2,32 +2,36 @@ Flex carries the copyright used for BSD software, slightly modified
|
||||
because it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
|
||||
which operates under a contract with the Department of Energy:
|
||||
|
||||
Copyright (c) 1990 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
Copyright (c) 2001 by W. L. Estes <wlestes@uncg.edu>
|
||||
|
||||
This code is derived from software contributed to Berkeley by
|
||||
Vern Paxson.
|
||||
Copyright (c) 1990, 1997 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
The United States Government has rights in this work pursuant
|
||||
to contract no. DE-AC03-76SF00098 between the United States
|
||||
Department of Energy and the University of California.
|
||||
This code is derived from software contributed to Berkeley by
|
||||
Vern Paxson.
|
||||
|
||||
Redistribution and use in source and binary forms with or without
|
||||
modification are permitted provided that: (1) source distributions
|
||||
retain this entire copyright notice and comment, and (2)
|
||||
distributions including binaries display the following
|
||||
acknowledgement: ``This product includes software developed by the
|
||||
University of California, Berkeley and its contributors'' in the
|
||||
documentation or other materials provided with the distribution and
|
||||
in all advertising materials mentioning features or use of this
|
||||
software. Neither the name of the University nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
The United States Government has rights in this work pursuant
|
||||
to contract no. DE-AC03-76SF00098 between the United States
|
||||
Department of Energy and the University of California.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
Neither the name of the University nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
|
||||
This basically says "do whatever you please with this software except
|
||||
remove this notice or take advantage of the University's (or the flex
|
||||
|
0
src/bin/flex/ChangeLog
Normal file
0
src/bin/flex/ChangeLog
Normal file
@ -1,7 +1,6 @@
|
||||
// $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/FlexLexer.h,v 1.1 2004/06/14 09:18:17 korli Exp $
|
||||
|
||||
// -*-C++-*-
|
||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
||||
// by flex
|
||||
// by flex
|
||||
|
||||
// Copyright (c) 1993 The Regents of the University of California.
|
||||
// All rights reserved.
|
||||
@ -9,20 +8,24 @@
|
||||
// This code is derived from software contributed to Berkeley by
|
||||
// Kent Williams and Tom Epperly.
|
||||
//
|
||||
// Redistribution and use in source and binary forms with or without
|
||||
// modification are permitted provided that: (1) source distributions retain
|
||||
// this entire copyright notice and comment, and (2) distributions including
|
||||
// binaries display the following acknowledgement: ``This product includes
|
||||
// software developed by the University of California, Berkeley and its
|
||||
// contributors'' in the documentation or other materials provided with the
|
||||
// distribution and in all advertising materials mentioning features or use
|
||||
// of this software. Neither the name of the University nor the names of
|
||||
// its contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
|
||||
// Neither the name of the University nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
|
||||
// This file defines FlexLexer, an abstract class which specifies the
|
||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
||||
@ -44,7 +47,11 @@
|
||||
#ifndef __FLEX_LEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define __FLEX_LEXER_H
|
||||
#include <iostream.h>
|
||||
|
||||
#include <iostream>
|
||||
# ifndef FLEX_STD
|
||||
# define FLEX_STD std::
|
||||
# endif
|
||||
|
||||
extern "C++" {
|
||||
|
||||
@ -61,14 +68,14 @@ public:
|
||||
virtual void
|
||||
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
|
||||
virtual struct yy_buffer_state*
|
||||
yy_create_buffer( istream* s, int size ) = 0;
|
||||
yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
||||
virtual void yyrestart( istream* s ) = 0;
|
||||
virtual void yyrestart( FLEX_STD istream* s ) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( istream* new_in, ostream* new_out = 0 )
|
||||
int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
@ -76,8 +83,8 @@ public:
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( istream* new_in = 0,
|
||||
ostream* new_out = 0 ) = 0;
|
||||
virtual void switch_streams( FLEX_STD istream* new_in = 0,
|
||||
FLEX_STD ostream* new_out = 0 ) = 0;
|
||||
|
||||
int lineno() const { return yylineno; }
|
||||
|
||||
@ -100,21 +107,26 @@ protected:
|
||||
// yyFlexLexer, as discussed in the flex man page.
|
||||
#define yyFlexLexerOnce
|
||||
|
||||
extern "C++" {
|
||||
|
||||
class yyFlexLexer : public FlexLexer {
|
||||
public:
|
||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
||||
// only make that assignment when initializing in yylex().
|
||||
yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
|
||||
yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
|
||||
|
||||
virtual ~yyFlexLexer();
|
||||
|
||||
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
|
||||
struct yy_buffer_state* yy_create_buffer( istream* s, int size );
|
||||
struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
|
||||
void yy_delete_buffer( struct yy_buffer_state* b );
|
||||
void yyrestart( istream* s );
|
||||
void yyrestart( FLEX_STD istream* s );
|
||||
|
||||
void yypush_buffer_state( struct yy_buffer_state* new_buffer );
|
||||
void yypop_buffer_state(void);
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( istream* new_in, ostream* new_out );
|
||||
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out );
|
||||
|
||||
protected:
|
||||
virtual int LexerInput( char* buf, int max_size );
|
||||
@ -125,7 +137,7 @@ protected:
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer( struct yy_buffer_state* b, istream* s );
|
||||
void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
|
||||
void yy_flush_buffer( struct yy_buffer_state* b );
|
||||
|
||||
int yy_start_stack_ptr;
|
||||
@ -140,10 +152,8 @@ protected:
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_buffer();
|
||||
|
||||
istream* yyin; // input source for default LexerInput
|
||||
ostream* yyout; // output sink for default LexerOutput
|
||||
|
||||
struct yy_buffer_state* yy_current_buffer;
|
||||
FLEX_STD istream* yyin; // input source for default LexerInput
|
||||
FLEX_STD ostream* yyout; // output sink for default LexerOutput
|
||||
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
@ -161,6 +171,12 @@ protected:
|
||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
||||
int yy_did_buffer_switch_on_eof;
|
||||
|
||||
|
||||
size_t yy_buffer_stack_top; /**< index of top of stack. */
|
||||
size_t yy_buffer_stack_max; /**< capacity of stack. */
|
||||
struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
|
||||
void yyensure_buffer_stack(void);
|
||||
|
||||
// The following are not always needed, but may be depending
|
||||
// on use of certain flex features (like REJECT or yymore()).
|
||||
|
||||
@ -183,4 +199,6 @@ protected:
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,117 +1,229 @@
|
||||
This is a generic INSTALL file for utilities distributions.
|
||||
If this package does not come with, e.g., installable documentation or
|
||||
data files, please ignore the references to them below.
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
To compile this package:
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
1. Configure the package for your system. In the directory that this
|
||||
file is in, type `./configure'. If you're using `csh' on an old
|
||||
version of System V, you might need to type `sh configure' instead to
|
||||
prevent `csh' from trying to execute `configure' itself.
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation, and
|
||||
creates the Makefile(s) (one in each subdirectory of the source
|
||||
directory). In some packages it creates a C header file containing
|
||||
system-dependent definitions. It also creates a file `config.status'
|
||||
that you can run in the future to recreate the current configuration.
|
||||
These are generic installation instructions.
|
||||
|
||||
Running `configure' takes a minute or two. While it is running, it
|
||||
prints some messages that tell what it is doing. If you don't want to
|
||||
see the messages, run `configure' with its standard output redirected
|
||||
to `/dev/null'; for example, `./configure >/dev/null'.
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
To compile the package in a different directory from the one
|
||||
containing the source code, you must use a version of `make' that
|
||||
supports the VPATH variable, such as GNU `make'. `cd' to the directory
|
||||
where you want the object files and executables to go and run
|
||||
`configure'. `configure' automatically checks for the source code in
|
||||
the directory that `configure' is in and in `..'. If for some reason
|
||||
`configure' is not in the source code directory that you are
|
||||
configuring, then it will report that it can't find the source code.
|
||||
In that case, run `configure' with the option `--srcdir=DIR', where
|
||||
DIR is the directory that contains the source code.
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify
|
||||
an installation prefix other than /usr/local by giving `configure' the
|
||||
option `--prefix=PATH'. Alternately, you can do so by giving a value
|
||||
for the `prefix' variable when you run `make', e.g.,
|
||||
make prefix=/usr/gnu
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If
|
||||
you give `configure' the option `--exec-prefix=PATH' or set the
|
||||
`make' variable `exec_prefix' to PATH, the package will use PATH as
|
||||
the prefix for installing programs and libraries. Data files and
|
||||
documentation will still use the regular prefix. Normally, all files
|
||||
are installed using the regular prefix.
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
Another `configure' option is useful mainly in `Makefile' rules for
|
||||
updating `config.status' and `Makefile'. The `--no-create' option
|
||||
figures out the configuration for your system and records it in
|
||||
`config.status', without actually configuring the package (creating
|
||||
`Makefile's and perhaps a configuration header file). Later, you can
|
||||
run `./config.status' to actually configure the package. You can also
|
||||
give `config.status' the `--recheck' option, which makes it re-run
|
||||
`configure' with the same arguments you used before. This option is
|
||||
useful if you change `configure'.
|
||||
The simplest way to compile this package is:
|
||||
|
||||
Some packages pay attention to `--with-PACKAGE' options to `configure',
|
||||
where PACKAGE is something like `gnu-libc' or `x' (for X windows).
|
||||
The README should mention any --with- options that the package recognizes.
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
`configure' ignores any other arguments that you give it.
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
If your system requires unusual options for compilation or linking
|
||||
that `configure' doesn't know about, you can give `configure' initial
|
||||
values for some variables by setting them in the environment. In
|
||||
Bourne-compatible shells, you can do that on the command line like
|
||||
this:
|
||||
CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
The `make' variables that you might want to override with environment
|
||||
variables when running `configure' are:
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
(For these variables, any value given in the environment overrides the
|
||||
value that `configure' would choose:)
|
||||
CC C compiler program.
|
||||
Default is `cc', or `gcc' if `gcc' is in your PATH.
|
||||
INSTALL Program to use to install files.
|
||||
Default is `install' if you have it, `cp' otherwise.
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
(For these variables, any value given in the environment is added to
|
||||
the value that `configure' chooses:)
|
||||
DEFS Configuration options, in the form `-Dfoo -Dbar ...'
|
||||
Do not use this variable in packages that create a
|
||||
configuration header file.
|
||||
LIBS Libraries to link with, in the form `-lfoo -lbar ...'
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
If you need to do unusual things to compile the package, we encourage
|
||||
you to figure out how `configure' could check whether to do them, and
|
||||
mail diffs or instructions to the address given in the README so we
|
||||
can include them in the next release.
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
2. Type `make' to compile the package. If you want, you can override
|
||||
the `make' variables CFLAGS and LDFLAGS like this:
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
make CFLAGS=-O2 LDFLAGS=-s
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
3. If the package comes with self-tests and you want to run them,
|
||||
type `make check'. If you're not sure whether there are any, try it;
|
||||
if `make' responds with something like
|
||||
make: *** No way to make target `check'. Stop.
|
||||
then the package does not come with self-tests.
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
4. Type `make install' to install programs, data files, and
|
||||
documentation.
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source directory by typing `make clean'. To also remove the
|
||||
Makefile(s), the header file containing system-dependent definitions
|
||||
(if the package uses one), and `config.status' (all the files that
|
||||
`configure' created), type `make distclean'.
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
The file `configure.in' is used as a template to create `configure' by
|
||||
a program called `autoconf'. You will only need it if you want to
|
||||
regenerate `configure' using a newer version of `autoconf'.
|
||||
|
@ -13,12 +13,17 @@ BinCommand flex :
|
||||
misc.c
|
||||
nfa.c
|
||||
parse.y
|
||||
initscan.c
|
||||
scan.l
|
||||
skel.c
|
||||
sym.c
|
||||
tblcmp.c
|
||||
yylex.c
|
||||
# libmain.c
|
||||
# libyywrap.c
|
||||
options.c
|
||||
scanopt.c
|
||||
buf.c
|
||||
tables.c
|
||||
tables_shared.c
|
||||
filter.c
|
||||
regex.c
|
||||
:
|
||||
: flex.rdef ;
|
||||
|
@ -1,262 +0,0 @@
|
||||
# Generated automatically from Makefile.in by configure.
|
||||
# @(#) $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/Makefile,v 1.1 2004/06/14 09:18:17 korli Exp $ (LBL)
|
||||
|
||||
|
||||
|
||||
# Possible values for DEFS:
|
||||
#
|
||||
# By default, flex generates 8-bit scanners when using table compression,
|
||||
# and 7-bit scanners when using uncompressed tables (-f or -F options).
|
||||
# For flex to always generate 8-bit scanners, add "-DDEFAULT_CSIZE=256"
|
||||
# to DEFS.
|
||||
#
|
||||
# For Vax/VMS, add "-DVMS" to DEFS.
|
||||
#
|
||||
# For MS-DOS, add "-DMS_DOS" to DEFS. See the directory MISC/MSDOS for
|
||||
# additional info.
|
||||
|
||||
CFLAGS = -g -O
|
||||
CPPFLAGS =
|
||||
DEFS = -DHAVE_CONFIG_H
|
||||
LDFLAGS =
|
||||
LIBS =
|
||||
|
||||
# Installation targeting. Files will be installed under the tree
|
||||
# rooted at prefix. flex will be installed in bindir, libfl.a in
|
||||
# libdir, FlexLexer.h will be installed in includedir, and the manual
|
||||
# pages will be installed in mandir with extension manext.
|
||||
#
|
||||
# Raw, unformatted troff source will be installed if INSTALLMAN=man,
|
||||
# nroff preformatted versions will be installed if INSTALLMAN=cat.
|
||||
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
bindir = $(exec_prefix)/bin
|
||||
libdir = $(exec_prefix)/lib
|
||||
includedir = $(prefix)/include
|
||||
manext = 1
|
||||
mandir = $(prefix)/man/man$(manext)
|
||||
|
||||
# You can define these to be "lex" and "libl.a" if you want to replace
|
||||
# lex at your site.
|
||||
FLEX = flex
|
||||
FLEXLIB = libfl.a
|
||||
|
||||
INSTALLMAN = man
|
||||
|
||||
SHELL = /bin/sh
|
||||
srcdir = .
|
||||
|
||||
LN_S = ln -s
|
||||
YACC = bison -y
|
||||
CC = gcc
|
||||
AR = ar
|
||||
RANLIB = ranlib
|
||||
INSTALL = /bin/install -c
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
INSTALL_PROGRAM = ${INSTALL}
|
||||
|
||||
# You normally do not need to modify anything below this point.
|
||||
# ------------------------------------------------------------
|
||||
|
||||
CPPFLAGS = -I. -I$(srcdir)
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||
|
||||
HEADERS = flexdef.h version.h
|
||||
|
||||
SOURCES = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.y \
|
||||
scan.l skel.c sym.c tblcmp.c yylex.c
|
||||
OBJECTS = ccl.o dfa.o ecs.o gen.o main.o misc.o nfa.o parse.o \
|
||||
scan.o skel.o sym.o tblcmp.o yylex.o
|
||||
|
||||
LIBSRCS = libmain.c libyywrap.c
|
||||
LIBOBJS = libmain.o libyywrap.o
|
||||
|
||||
LINTSRCS = ccl.c dfa.c ecs.c gen.c main.c misc.c nfa.c parse.c \
|
||||
scan.c skel.c sym.c tblcmp.c yylex.c
|
||||
|
||||
DISTFILES = README NEWS COPYING INSTALL FlexLexer.h \
|
||||
configure.in conf.in Makefile.in mkskel.sh flex.skl \
|
||||
$(HEADERS) $(SOURCES) $(LIBSRCS) MISC \
|
||||
flex.1 scan.c install.sh mkinstalldirs configure
|
||||
|
||||
DIST_NAME = flex
|
||||
|
||||
# which "flex" to use to generate scan.c from scan.l
|
||||
FLEX_EXEC = ./$(FLEX)
|
||||
FLEX_FLAGS = -t $(PERF_REPORT)
|
||||
COMPRESSION =
|
||||
PERF_REPORT = -p
|
||||
|
||||
|
||||
all: $(FLEX)
|
||||
|
||||
$(FLEX): .bootstrap $(OBJECTS) $(FLEXLIB)
|
||||
$(CC) $(CFLAGS) -o $(FLEX) $(LDFLAGS) $(OBJECTS) $(FLEXLIB) $(LIBS)
|
||||
|
||||
.bootstrap: initscan.c
|
||||
@rm -f scan.c
|
||||
cp $(srcdir)/initscan.c scan.c
|
||||
touch .bootstrap
|
||||
|
||||
parse.c: parse.y
|
||||
$(YACC) -d $(srcdir)/parse.y
|
||||
sed '/extern char.*malloc/d' <y.tab.c >parse.tmp
|
||||
mv parse.tmp parse.c
|
||||
mv y.tab.h parse.h
|
||||
rm -f y.tab.c
|
||||
|
||||
parse.h: parse.c
|
||||
|
||||
scan.c: scan.l
|
||||
$(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l >scan.c
|
||||
sed s,\"$(srcdir)/scan.l\",\"scan.l\", <scan.c >scan.tmp
|
||||
mv scan.tmp scan.c
|
||||
|
||||
scan.o: scan.c parse.h flexdef.h config.h
|
||||
yylex.o: yylex.c parse.h flexdef.h config.h
|
||||
|
||||
skel.c: flex.skl mkskel.sh
|
||||
$(SHELL) $(srcdir)/mkskel.sh $(srcdir)/flex.skl >skel.c
|
||||
|
||||
main.o: main.c flexdef.h config.h version.h
|
||||
ccl.o: ccl.c flexdef.h config.h
|
||||
dfa.o: dfa.c flexdef.h config.h
|
||||
ecs.o: ecs.c flexdef.h config.h
|
||||
gen.o: gen.c flexdef.h config.h
|
||||
misc.o: misc.c flexdef.h config.h
|
||||
nfa.o: nfa.c flexdef.h config.h
|
||||
parse.o: parse.c flexdef.h config.h
|
||||
skel.o: skel.c flexdef.h config.h
|
||||
sym.o: sym.c flexdef.h config.h
|
||||
tblcmp.o: tblcmp.c flexdef.h config.h
|
||||
|
||||
alloca.o: alloca.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -Dxmalloc=yy_flex_xmalloc alloca.c
|
||||
|
||||
alloca.c: $(srcdir)/MISC/alloca.c
|
||||
@rm -f alloca.c
|
||||
cp $(srcdir)/MISC/alloca.c .
|
||||
|
||||
test: check
|
||||
check: $(FLEX)
|
||||
$(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l \
|
||||
| sed s,\"$(srcdir)/scan.l\",\"scan.l\", \
|
||||
| diff scan.c -
|
||||
@echo "Check successful, using COMPRESSION=\"$(COMPRESSION)\""
|
||||
|
||||
bigcheck:
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-C" check
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" check
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" check
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-f" check
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-Cfea" check
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-CFer" check
|
||||
rm -f scan.c ; $(MAKE) COMPRESSION="-l" PERF_REPORT="" check
|
||||
rm -f scan.c ; $(MAKE)
|
||||
@echo "All checks successful"
|
||||
|
||||
$(FLEXLIB): $(LIBOBJS)
|
||||
$(AR) cru $(FLEXLIB) $(LIBOBJS)
|
||||
-$(RANLIB) $(FLEXLIB)
|
||||
|
||||
$(FLEX).man: flex.1
|
||||
cd $(srcdir) && nroff -man flex.1 >$(FLEX).man
|
||||
|
||||
install: $(FLEX) $(FLEXLIB) installdirs install.$(INSTALLMAN)
|
||||
$(INSTALL_PROGRAM) $(FLEX) $(bindir)/$(FLEX)
|
||||
@rm -f $(bindir)/$(FLEX)++
|
||||
cd $(bindir) && $(LN_S) $(FLEX) $(FLEX)++
|
||||
$(INSTALL_DATA) $(FLEXLIB) $(libdir)/$(FLEXLIB)
|
||||
-cd $(libdir) && $(RANLIB) $(FLEXLIB)
|
||||
$(INSTALL_DATA) $(srcdir)/FlexLexer.h $(includedir)/FlexLexer.h
|
||||
|
||||
# Note, the following rules delete any vestigial flexdoc installed
|
||||
# for a prior flex release.
|
||||
install.man: flex.1
|
||||
rm -f $(mandir)/$(FLEX)doc.$(manext)
|
||||
$(INSTALL_DATA) $(srcdir)/flex.1 $(mandir)/$(FLEX).$(manext)
|
||||
|
||||
install.cat: $(FLEX).man
|
||||
rm -f $(mandir)/$(FLEX)doc.$(manext)
|
||||
$(INSTALL_DATA) $(srcdir)/$(FLEX).man $(mandir)/$(FLEX).$(manext)
|
||||
|
||||
installdirs:
|
||||
$(SHELL) $(srcdir)/mkinstalldirs \
|
||||
$(bindir) $(libdir) $(includedir) $(mandir)
|
||||
|
||||
uninstall:
|
||||
rm -f $(bindir)/$(FLEX) $(bindir)/$(FLEX)++
|
||||
rm -f $(libdir)/$(FLEXLIB)
|
||||
rm -f $(includedir)/FlexLexer.h
|
||||
rm -f $(mandir)/$(FLEX).$(manext) $(mandir)/$(FLEX)doc.$(manext)
|
||||
|
||||
tags: $(SOURCES)
|
||||
ctags $(SOURCES)
|
||||
|
||||
TAGS: $(SOURCES)
|
||||
etags $(SOURCES)
|
||||
|
||||
lint: $(LINTSRCS)
|
||||
lint -Dconst= $(LINTSRCS) > flex.lint
|
||||
|
||||
gcc-lint: $(LINTSRCS)
|
||||
gcc -Dlint -Wall $(LINTSRCS) >flex.gcc-lint 2>&1
|
||||
|
||||
mostlyclean:
|
||||
rm -f a.out *.bak core errs scan.tmp
|
||||
|
||||
clean: mostlyclean
|
||||
rm -f flex parse.c parse.h *.o alloca.c *.lint lex.yy.c lex.yy.cc \
|
||||
$(FLEXLIB) config.log config.cache
|
||||
|
||||
distclean: clean
|
||||
rm -f .bootstrap $(FLEX) scan.c tags TAGS Makefile config.status \
|
||||
config.h stamp-h config.log config.cache
|
||||
|
||||
maintainer-clean: distclean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
rm -f $(FLEX).man skel.c flex*.tar.gz flex*.tar.Z
|
||||
|
||||
dist: $(FLEX) $(DISTFILES) parse.c parse.h $(srcdir)/$(FLEX).man
|
||||
$(MAKE) DIST_NAME=flex-`sed <version.h 's/[^"]*"//' | sed 's/"//'` dist2
|
||||
|
||||
dist2:
|
||||
@rm -rf $(DIST_NAME)
|
||||
@rm -f $(DIST_NAME).tar $(DIST_NAME).tar.Z $(DIST_NAME).tar.gz
|
||||
@mkdir $(DIST_NAME)
|
||||
tar cf - $(DISTFILES) | (cd $(DIST_NAME) && tar xfB -)
|
||||
@mv $(DIST_NAME)/scan.c $(DIST_NAME)/initscan.c
|
||||
@chmod 444 $(DIST_NAME)/initscan.c
|
||||
@chmod +w $(DIST_NAME)/Makefile.in
|
||||
@cp parse.c parse.h $(DIST_NAME)/MISC
|
||||
@col -b <$(srcdir)/$(FLEX).man >$(DIST_NAME)/MISC/flex.man
|
||||
tar chf $(DIST_NAME).tar $(DIST_NAME)
|
||||
compress <$(DIST_NAME).tar >$(DIST_NAME).tar.Z
|
||||
gzip <$(DIST_NAME).tar >$(DIST_NAME).tar.gz
|
||||
@rm $(DIST_NAME).tar
|
||||
|
||||
# For an explanation of the following Makefile rules, see node
|
||||
# `Automatic Remaking' in GNU Autoconf documentation.
|
||||
Makefile: $(srcdir)/Makefile.in config.status
|
||||
CONFIG_FILES=$@ CONFIG_HEADERS= ./config.status
|
||||
config.status: configure
|
||||
./config.status --recheck
|
||||
configure: configure.in
|
||||
cd $(srcdir) && autoconf
|
||||
config.h: stamp-h
|
||||
stamp-h: conf.in config.status
|
||||
CONFIG_FILES= CONFIG_HEADERS=config.h:conf.in ./config.status
|
||||
echo timestamp >stamp-h
|
||||
# conf.in: stamp-h.in
|
||||
# stamp-h.in: configure.in acconfig.h
|
||||
# cd $(srcdir) && autoheader
|
||||
# config.h.in conf.in
|
||||
# cho timestamp > $(srcdir)/stamp-h.in
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
229
src/bin/flex/Makefile.am
Normal file
229
src/bin/flex/Makefile.am
Normal file
@ -0,0 +1,229 @@
|
||||
# This file is part of flex.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# Neither the name of the University nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
|
||||
# Notes on building:
|
||||
|
||||
# Possible values for DEFS:
|
||||
#
|
||||
# By default, flex generates 8-bit scanners when using table compression,
|
||||
# and 7-bit scanners when using uncompressed tables (-f or -F options).
|
||||
# For flex to always generate 8-bit scanners, add "-DDEFAULT_CSIZE=256"
|
||||
# to DEFS.
|
||||
#
|
||||
# For Vax/VMS, add "-DVMS" to DEFS.
|
||||
#
|
||||
# For MS-DOS, add "-DMS_DOS" to DEFS. See the directory MISC/MSDOS for
|
||||
# additional info.
|
||||
|
||||
AM_YFLAGS = -d
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
m4 = @M4@
|
||||
indent = @INDENT@
|
||||
|
||||
AUTOMAKE_OPTIONS = \
|
||||
gnits \
|
||||
check-news \
|
||||
dist-bzip2 \
|
||||
1.7
|
||||
|
||||
bin_PROGRAMS = flex
|
||||
lib_LIBRARIES = libfl.a
|
||||
|
||||
flex_SOURCES = \
|
||||
ccl.c \
|
||||
dfa.c \
|
||||
ecs.c \
|
||||
gen.c \
|
||||
main.c \
|
||||
misc.c \
|
||||
nfa.c \
|
||||
parse.y \
|
||||
scan.l \
|
||||
skel.c \
|
||||
sym.c \
|
||||
tblcmp.c \
|
||||
yylex.c \
|
||||
options.c \
|
||||
scanopt.c \
|
||||
buf.c \
|
||||
tables.c \
|
||||
tables_shared.c \
|
||||
filter.c \
|
||||
regex.c
|
||||
|
||||
libfl_a_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
flexdef.h \
|
||||
flexint.h \
|
||||
version.h \
|
||||
options.h \
|
||||
scanopt.h \
|
||||
tables.h \
|
||||
tables_shared.h
|
||||
|
||||
include_HEADERS = \
|
||||
FlexLexer.h
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
ABOUT-NLS \
|
||||
config.rpath \
|
||||
config.sub \
|
||||
config.guess \
|
||||
configure \
|
||||
config.sub \
|
||||
config.guess \
|
||||
depcomp \
|
||||
mkinstalldirs \
|
||||
install-sh \
|
||||
ABOUT-NLS \
|
||||
ChangeLog \
|
||||
INSTALL \
|
||||
conf.in \
|
||||
aclocal.m4 \
|
||||
Makefile.in \
|
||||
mdate-sh \
|
||||
missing
|
||||
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
flex.spec.in \
|
||||
flex.spec \
|
||||
.indent.pro \
|
||||
AUTHORS \
|
||||
COPYING \
|
||||
INSTALL \
|
||||
NEWS \
|
||||
ONEWS \
|
||||
README \
|
||||
README.cvs-snapshot \
|
||||
THANKS \
|
||||
TODO \
|
||||
autogen.sh \
|
||||
flex.skl \
|
||||
mkskel.sh \
|
||||
ABOUT-NLS \
|
||||
config.rpath \
|
||||
gettext.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
skel.c
|
||||
|
||||
SUBDIRS = \
|
||||
. \
|
||||
doc \
|
||||
m4 \
|
||||
examples \
|
||||
po \
|
||||
tools \
|
||||
tests
|
||||
|
||||
localedir = $(datadir)/locale
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I@includedir@ -I$(top_srcdir)/intl
|
||||
LIBS = @LIBINTL@ @LIBS@
|
||||
|
||||
skel.c: flex.skl mkskel.sh flexint.h tables_shared.h
|
||||
sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' $(srcdir)/flex.skl | $(m4) -P -DFLEX_MAJOR_VERSION=`echo $(VERSION)|cut -f 1 -d .` -DFLEX_MINOR_VERSION=`echo $(VERSION)|cut -f 2 -d .` -DFLEX_SUBMINOR_VERSION=`echo $(VERSION)|cut -f 3 -d .` | sed 's/m4postproc_/m4_/g' | $(SHELL) $(srcdir)/mkskel.sh >skel.c
|
||||
|
||||
# Explicitly describe dependencies.
|
||||
# You can recreate this with `gcc -I. -MM *.c'
|
||||
buf.o: buf.c flexdef.h flexint.h
|
||||
ccl.o: ccl.c flexdef.h flexint.h
|
||||
dfa.o: dfa.c flexdef.h flexint.h tables.h tables_shared.h
|
||||
ecs.o: ecs.c flexdef.h flexint.h
|
||||
gen.o: gen.c flexdef.h flexint.h tables.h tables_shared.h
|
||||
libmain.o: libmain.c
|
||||
libyywrap.o: libyywrap.c
|
||||
main.o: main.c flexdef.h flexint.h version.h options.h scanopt.h \
|
||||
tables.h tables_shared.h
|
||||
misc.o: misc.c flexdef.h flexint.h tables.h tables_shared.h
|
||||
nfa.o: nfa.c flexdef.h flexint.h
|
||||
options.o: options.c options.h scanopt.h flexdef.h flexint.h
|
||||
parse.o: parse.c flexdef.h flexint.h tables.h tables_shared.h
|
||||
scan.o: scan.c flexdef.h flexint.h parse.h
|
||||
scanopt.o: scanopt.c flexdef.h flexint.h scanopt.h
|
||||
skel.o: skel.c flexdef.h flexint.h
|
||||
sym.o: sym.c flexdef.h flexint.h
|
||||
tables.o: tables.c flexdef.h flexint.h tables.h tables_shared.h
|
||||
tables_shared.o: tables_shared.c flexdef.h flexint.h tables.h \
|
||||
tables_shared.h
|
||||
tblcmp.o: tblcmp.c flexdef.h flexint.h
|
||||
yylex.o: yylex.c flexdef.h flexint.h parse.h
|
||||
filter.o: filter.c flexdef.h flexint.h
|
||||
|
||||
# Create a tags file.
|
||||
tags:
|
||||
ctags --c-types='defgmstuv' $(srcdir)/*.[ch]
|
||||
|
||||
# Create the ChangeLog, but only if we're inside a cvs working directory
|
||||
|
||||
ChangeLog:
|
||||
if [ -d CVS ] ; then \
|
||||
sh $(srcdir)/tools/cvs2cl.pl -F trunk -U $(srcdir)/tools/cvsauthors \
|
||||
; fi
|
||||
|
||||
# Run GNU indent on sources. Don't run this unless all the sources compile cleanly.
|
||||
#
|
||||
# Whole idea:
|
||||
# 1. Check for .indent.pro, otherwise indent will use unknown
|
||||
# settings, or worse, the GNU defaults.)
|
||||
# 2. Check that this is GNU indent.
|
||||
# 3. Make sure to process only the NON-generated .c and .h files.
|
||||
# 4. Run indent twice per file. The first time is a test.
|
||||
# Otherwise, indent overwrites your file even if it fails!
|
||||
indentfiles = \
|
||||
buf.c \
|
||||
ccl.c \
|
||||
dfa.c \
|
||||
ecs.c \
|
||||
filter.c \
|
||||
flexdef.h \
|
||||
gen.c \
|
||||
libmain.c \
|
||||
libyywrap.c \
|
||||
main.c \
|
||||
misc.c \
|
||||
nfa.c \
|
||||
options.c \
|
||||
options.h \
|
||||
regex.c \
|
||||
scanopt.c \
|
||||
scanopt.h \
|
||||
sym.c \
|
||||
tables.c \
|
||||
tables.h \
|
||||
tables_shared.c \
|
||||
tables_shared.h \
|
||||
tblcmp.c
|
||||
|
||||
indent:
|
||||
if [ -f .indent.pro ] ; then \
|
||||
for f in $(indentfiles);\
|
||||
do\
|
||||
echo indenting $$f ;\
|
||||
$(indent) < $$f >/dev/null && indent $$f || echo $$f FAILED to indent ;\
|
||||
done \
|
||||
fi
|
||||
|
||||
.PHONY: ChangeLog tags indent
|
File diff suppressed because it is too large
Load Diff
1307
src/bin/flex/NEWS
1307
src/bin/flex/NEWS
File diff suppressed because it is too large
Load Diff
1233
src/bin/flex/ONEWS
Normal file
1233
src/bin/flex/ONEWS
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,60 +1,69 @@
|
||||
This is release 2.5 of flex. See "version.h" for the exact patch-level.
|
||||
This is flex, the fast lexical analyzer generator.
|
||||
|
||||
See the file "NEWS" to find out what is new in this Flex release.
|
||||
flex is a tool for generating scanners: programs which recognize
|
||||
lexical patterns in text.
|
||||
|
||||
Read the file "INSTALL" for general installation directives. Peek near
|
||||
the beginning of the file "Makefile.in" for special DEFS values. On most
|
||||
systems, you can just run the "configure" script and type "make" to build
|
||||
flex; then "make check" to test whether it built correctly; and if it did,
|
||||
then "make install" to install it.
|
||||
More information about flex as well as the latest official release of
|
||||
flex can be found at:
|
||||
|
||||
If you're feeling adventurous, you can also issue "make bigcheck" (be
|
||||
prepared to wait a while).
|
||||
http://flex.sourceforge.net/
|
||||
|
||||
Of particular interest is the mailing list
|
||||
flex-announce@lists.sourceforge.net as that is where posts will be made
|
||||
announcing new releases of flex.
|
||||
|
||||
Note that flex is distributed under a copyright very similar to that of
|
||||
BSD Unix, and not under the GNU General Public License (GPL), except for
|
||||
the "configure" script, which is covered by the GPL.
|
||||
BSD Unix, and not under the GNU General Public License (GPL).
|
||||
|
||||
Many thanks to the 2.5 beta-testers for finding bugs and helping test and
|
||||
increase portability: Stan Adermann, Scott David Daniels, Charles Elliott,
|
||||
Joe Gayda, Chris Meier, James Nordby, Terrence O'Kane, Karsten Pahnke,
|
||||
Francois Pinard, Pat Rankin, Andreas Scherer, Marc Wiese, Nathan Zelle.
|
||||
This file is part of flex.
|
||||
|
||||
Please send bug reports and feedback to: Vern Paxson (vern@ee.lbl.gov).
|
||||
This code is derived from software contributed to Berkeley by
|
||||
Vern Paxson.
|
||||
|
||||
The United States Government has rights in this work pursuant
|
||||
to contract no. DE-AC03-76SF00098 between the United States
|
||||
Department of Energy and the University of California.
|
||||
|
||||
The flex distribution consists of the following files:
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
README This message
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
NEWS Differences between the various releases
|
||||
Neither the name of the University nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
INSTALL General installation information
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
|
||||
COPYING flex's copyright
|
||||
Please send bug reports and feedback to flex-help@lists.sourceforge.net.
|
||||
|
||||
conf.in, configure.in, configure, Makefile.in, install.sh,
|
||||
mkinstalldirs
|
||||
elements of the "autoconf" auto-configuration process
|
||||
The flex distribution contains the following files which may be of interest:
|
||||
|
||||
flexdef.h, parse.y, scan.l, ccl.c, dfa.c, ecs.c, gen.c, main.c,
|
||||
misc.c, nfa.c, sym.c, tblcmp.c, yylex.c
|
||||
source files
|
||||
README - This file.
|
||||
|
||||
version.h version of this flex release
|
||||
NEWS - current version number and list of user-visible changes.
|
||||
|
||||
flex.skl flex scanner skeleton
|
||||
mkskel.sh script for converting flex.skl to C source file skel.c
|
||||
skel.c pre-converted C version of flex.skl
|
||||
INSTALL - basic installation information.
|
||||
|
||||
libmain.c flex library (-lfl) sources
|
||||
libyywrap.c
|
||||
ABOUT-NLS - description of internationalization support in flex.
|
||||
|
||||
initscan.c pre-flex'd version of scan.l
|
||||
COPYING - flex's copyright and license.
|
||||
|
||||
FlexLexer.h header file for C++ lexer class
|
||||
doc/ - user documentation.
|
||||
|
||||
flex.1 user documentation
|
||||
examples/ - containing examples of some possible flex scanners and a
|
||||
few other things. See the file examples/README for more details.
|
||||
|
||||
MISC/ a directory containing miscellaneous contributions.
|
||||
See MISC/README for details.
|
||||
TODO - outstanding bug reports, desired features, etc.
|
||||
|
||||
tests/ - regression tests. See TESTS/README for details.
|
||||
|
||||
po/ - internationalization support files.
|
||||
|
2
src/bin/flex/README-alpha
Normal file
2
src/bin/flex/README-alpha
Normal file
@ -0,0 +1,2 @@
|
||||
Beta versions and cvs snapshots of flex can be had at
|
||||
ftp://ftp.uncg.edu/people/wlestes/.
|
46
src/bin/flex/README.cvs-snapshot
Normal file
46
src/bin/flex/README.cvs-snapshot
Normal file
@ -0,0 +1,46 @@
|
||||
This file gives information regarding cvs snapshots of flex. cvs
|
||||
snapshots of flex contain the files which are under version control by
|
||||
the flex maintainers for the flex project. These snapshots can be
|
||||
found at:
|
||||
|
||||
ftp://ftp.uncg.edu/people/wlestes/
|
||||
|
||||
If you are not interested in flex development or you are not in need
|
||||
of the latest bleeding-edge features, then cvs snapshots of flex are
|
||||
not for you.
|
||||
|
||||
When you get a distribution of flex, a large number of intermediate
|
||||
files needed to make building flex easy are included. You don't have
|
||||
that in a cvs snapshot.
|
||||
|
||||
You will need various external tools in order to build the distribution. Here is
|
||||
a (possibly incomplete) list of the required tools. Always get the latest
|
||||
version of each tool; we list the versions used in development of
|
||||
flex, but the listed versions may not work for you.
|
||||
|
||||
compiler suite; e.g., gcc
|
||||
bash or some other fairly robust sh-style shell
|
||||
GNU bison; to generate parse.c from parse.y
|
||||
GNU m4 1.4; required by BNU autoconf (yes, it *must* be GNU m4)
|
||||
GNU autoconf 2.54 and GNU automake 1.7; for generating Makefiles etc.
|
||||
GNU gettext 0.11.5; for i18n
|
||||
flex (latest beta release); for bootstrap of scan.l
|
||||
help2man 1.27; to generate man page
|
||||
tar, gzip, etc.; for packaging of the source distribution
|
||||
GNU texinfo 4.3d; to build and test the flex manual
|
||||
perl; GNU automake and GNU autoconf now depend on perl to run
|
||||
GNU indent 2.8; for indenting the flex source the way we want it done
|
||||
|
||||
ONce you have all the necessary tools installed, life becomes
|
||||
simple. To prepare the flex tree for building, run the script:
|
||||
|
||||
$ ./autogen.sh
|
||||
|
||||
in the top level of the flex source tree.
|
||||
This script calls the various tools needed to get flex ready for the
|
||||
GNU-style configure script to be able to work.
|
||||
|
||||
From this point on, building flex follows the usual configure, make,
|
||||
make install routine, almost. When configuring the flex tree, pass the
|
||||
--enable-maintainer-mode option to configure. If you forget, you will
|
||||
see errors about a missing file `version.texi'.
|
53
src/bin/flex/THANKS
Normal file
53
src/bin/flex/THANKS
Normal file
@ -0,0 +1,53 @@
|
||||
Vern had the following things to say:
|
||||
|
||||
Many thanks to the 2.5 beta-testers for finding bugs and helping test and
|
||||
increase portability: Stan Adermann, Scott David Daniels, Charles Elliott,
|
||||
Joe Gayda, Chris Meier, James Nordby, Terrence O'Kane, Karsten Pahnke,
|
||||
Francois Pinard, Pat Rankin, Andreas Scherer, Marc Wiese, Nathan Zelle.
|
||||
|
||||
Thanks to the many flex beta-testers, feedbackers, and contributors,
|
||||
especially Francois Pinard, Casey Leedom, Robert Abramovitz, Stan
|
||||
Adermann, Terry Allen, David Barker-Plummer, John Basrai, Neal Becker,
|
||||
Nelson H.F. Beebe, benson@odi.com, Karl Berry, Peter A. Bigot, Simon
|
||||
Blanchard, Keith Bostic, Frederic Brehm, Ian Brockbank, Kin Cho, Nick
|
||||
Christopher, Brian Clapper, J.T. Conklin, Jason Coughlin, Bill Cox,
|
||||
Nick Cropper, Dave Curtis, Scott David Daniels, Chris G. Demetriou,
|
||||
Theo Deraadt, Mike Donahue, Chuck Doucette, Tom Epperly, Leo Eskin,
|
||||
Chris Faylor, Chris Flatters, Jon Forrest, Jeffrey Friedl, Joe Gayda,
|
||||
Kaveh R. Ghazi, Wolfgang Glunz, Eric Goldman, Christopher M. Gould,
|
||||
Ulrich Grepel, Peer Griebel, Jan Hajic, Charles Hemphill, NORO Hideo,
|
||||
Jarkko Hietaniemi, Scott Hofmann, Jeff Honig, Dana Hudes, Eric Hughes,
|
||||
John Interrante, Ceriel Jacobs, Michal Jaegermann, Sakari Jalovaara,
|
||||
Jeffrey R. Jones, Henry Juengst, Klaus Kaempf, Jonathan I. Kamens,
|
||||
Terrence O Kane, Amir Katz, ken@ken.hilco.com, Kevin B. Kenny, Steve
|
||||
Kirsch, Winfried Koenig, Marq Kole, Ronald Lamprecht, Greg Lee, Rohan
|
||||
Lenard, Craig Leres, John Levine, Steve Liddle, David Loffredo, Mike
|
||||
Long, Mohamed el Lozy, Brian Madsen, Malte, Joe Marshall, Bengt
|
||||
Martensson, Chris Metcalf, Luke Mewburn, Jim Meyering, R. Alexander
|
||||
Milowski, Erik Naggum, G.T. Nicol, Landon Noll, James Nordby, Marc
|
||||
Nozell, Richard Ohnemus, Karsten Pahnke, Sven Panne, Roland Pesch,
|
||||
Walter Pelissero, Gaumond Pierre, Esmond Pitt, Jef Poskanzer, Joe
|
||||
Rahmeh, Jarmo Raiha, Frederic Raimbault, Pat Rankin, Rick Richardson,
|
||||
Kevin Rodgers, Kai Uwe Rommel, Jim Roskind, Alberto Santini, Andreas
|
||||
Scherer, Darrell Schiebel, Raf Schietekat, Doug Schmidt, Philippe
|
||||
Schnoebelen, Andreas Schwab, Larry Schwimmer, Alex Siegel, Eckehard
|
||||
Stolz, Jan-Erik Strvmquist, Mike Stump, Paul Stuart, Dave Tallman, Ian
|
||||
Lance Taylor, Chris Thewalt, Richard M. Timoney, Jodi Tsai, Paul
|
||||
Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams,
|
||||
Ken Yap, Ron Zellar, Nathan Zelle, David Zuhn, and those whose names
|
||||
have slipped my marginal mail-archiving skills but whose contributions
|
||||
are appreciated all the same.
|
||||
|
||||
Thanks to Keith Bostic, Jon Forrest, Noah Friedman,
|
||||
John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T.
|
||||
Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various
|
||||
distribution headaches.
|
||||
|
||||
Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to
|
||||
Benson Margulies and Fred Burke for C++ support; to Kent Williams and Tom
|
||||
Epperly for C++ class support; to Ove Ewerlid for support of NUL's; and to
|
||||
Eric Hughes for support of multiple buffers.
|
||||
|
||||
This work was primarily done when I was with the Real Time Systems Group
|
||||
at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks to all there
|
||||
for the support I received.
|
101
src/bin/flex/TODO
Normal file
101
src/bin/flex/TODO
Normal file
@ -0,0 +1,101 @@
|
||||
* sourceforge migration
|
||||
|
||||
** Move CVS to sourceforge (estes) %%
|
||||
|
||||
** test the mailing lists (estes) %%
|
||||
|
||||
** inform GNU folks about changeover (estes) %%
|
||||
|
||||
* resolve the items in the to.do directory
|
||||
|
||||
** expand the above into individual requests and handle those requests
|
||||
|
||||
** transfer to.do/Wishlist contents to top level TODO file
|
||||
|
||||
* the manual:
|
||||
|
||||
** do an end-to-end proofread of the manual (this is under way, but is
|
||||
going slowly)
|
||||
|
||||
** pretty up the dvi output; overflows, etc.
|
||||
|
||||
** faq
|
||||
|
||||
*** clean up the faqs section. The information is good; the texinfo
|
||||
could use some touching up.
|
||||
|
||||
*** index the faq entries
|
||||
|
||||
*** mention that it's possible to use a variable to scan matching
|
||||
brackets, nested comments etc.
|
||||
|
||||
*** include something about lexing/parsing fortran
|
||||
|
||||
** create a section on flex design, features, etc.
|
||||
|
||||
* address lex-replacement: document or provide an option through
|
||||
configure for creating lex and libl.a files (but remember this has
|
||||
posix implications)
|
||||
|
||||
* getext
|
||||
|
||||
** make sure all flex modules use gettext translation facilities
|
||||
|
||||
*subdirectories
|
||||
|
||||
** in examples/manual, integrate the Makefile.examples into the
|
||||
Makefile.am
|
||||
|
||||
* test suite
|
||||
|
||||
** integrate the test suite into automake's framework (note that the
|
||||
test suite can be run from the top level directory with "make
|
||||
check". Still, we want to get it completely under automake's control.)
|
||||
|
||||
** make test suite more complete
|
||||
|
||||
* generic coding
|
||||
|
||||
** move as much skeleton code as possible out of gen.c and into
|
||||
flex.skl
|
||||
|
||||
** figure out whether we want to add the capability to have
|
||||
auto-generated backout rules
|
||||
|
||||
** token-type and token buffer support
|
||||
|
||||
** check if we still need to #undef macros at the end of a header
|
||||
|
||||
** merge yylineno into support for location tracking
|
||||
|
||||
** bug where yylineno is not decremented on REJECT
|
||||
|
||||
** bug where yylineno is counted in trailing context
|
||||
|
||||
* C++
|
||||
|
||||
** have a separate skeleton for c++
|
||||
|
||||
** c++ is getting so broken and different from C, that we need to
|
||||
reevaluate the usefuleness of c++ in flex
|
||||
|
||||
** revisit the C++ API. We get requests to make it more complete.
|
||||
|
||||
* distribution
|
||||
|
||||
** use bootstrapper
|
||||
|
||||
** remove texinfo.tex from the cvs tree; it only needs to be present
|
||||
on the system where the flex release is put together
|
||||
|
||||
** use clcommit to manage ChangeLog
|
||||
|
||||
Legend:
|
||||
|
||||
*, **, ***: outline depth
|
||||
%% at end of item: must be adressed before next major release
|
||||
|
||||
Local Variables:
|
||||
Mode: text
|
||||
mode: outline-minor
|
||||
End:
|
2898
src/bin/flex/aclocal.m4
vendored
Normal file
2898
src/bin/flex/aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
32
src/bin/flex/autogen.sh
Executable file
32
src/bin/flex/autogen.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is part of flex.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# Neither the name of the University nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
|
||||
# If you see no configure script, then run ./autogen.sh to create it
|
||||
# and procede with the "normal" build procedures.
|
||||
|
||||
#if we pretend to have a ChangeLog, then automake is less
|
||||
#worried. (Don't worry, we *do* have a ChangeLog, we just need the
|
||||
#Makefile first.)
|
||||
|
||||
touch ChangeLog
|
||||
autoreconf --install --verbose
|
254
src/bin/flex/buf.c
Normal file
254
src/bin/flex/buf.c
Normal file
@ -0,0 +1,254 @@
|
||||
/* flex - tool to generate fast lexical analyzers */
|
||||
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
/* Take note: The buffer object is sometimes used as a String buffer (one
|
||||
* continuous string), and sometimes used as a list of strings, usually line by
|
||||
* line.
|
||||
*
|
||||
* The type is specified in buf_init by the elt_size. If the elt_size is
|
||||
* sizeof(char), then the buffer should be treated as string buffer. If the
|
||||
* elt_size is sizeof(char*), then the buffer should be treated as a list of
|
||||
* strings.
|
||||
*
|
||||
* Certain functions are only appropriate for one type or the other.
|
||||
*/
|
||||
|
||||
/* global buffers. */
|
||||
struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */
|
||||
struct Buf defs_buf; /**< for #define's autogenerated. List of strings. */
|
||||
struct Buf yydmap_buf; /**< string buffer to hold yydmap elements */
|
||||
struct Buf m4defs_buf; /**< m4 definitions. List of strings. */
|
||||
struct Buf top_buf; /**< contains %top code. String buffer. */
|
||||
|
||||
struct Buf *buf_print_strings(struct Buf * buf, FILE* out)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!buf || !out)
|
||||
return buf;
|
||||
|
||||
for (i=0; i < buf->nelts; i++){
|
||||
const char * s = ((char**)buf->elts)[i];
|
||||
if(s)
|
||||
fprintf(out, "%s", s);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Append a "%s" formatted string to a string buffer */
|
||||
struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
|
||||
{
|
||||
char *t;
|
||||
|
||||
t = flex_alloc (strlen (fmt) + strlen (s) + 1);
|
||||
sprintf (t, fmt, s);
|
||||
buf = buf_strappend (buf, t);
|
||||
flex_free (t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** Append a line directive to the string buffer.
|
||||
* @param buf A string buffer.
|
||||
* @param filename file name
|
||||
* @param lineno line number
|
||||
* @return buf
|
||||
*/
|
||||
struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
|
||||
{
|
||||
char *t, *fmt = "#line %d \"%s\"\n";
|
||||
|
||||
t = flex_alloc (strlen (fmt) + strlen (filename) + (int)(1 + log10(lineno>=0?lineno:-lineno)) + 1);
|
||||
sprintf (t, fmt, lineno, filename);
|
||||
buf = buf_strappend (buf, t);
|
||||
flex_free (t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/** Append the contents of @a src to @a dest.
|
||||
* @param @a dest the destination buffer
|
||||
* @param @a dest the source buffer
|
||||
* @return @a dest
|
||||
*/
|
||||
struct Buf *buf_concat(struct Buf* dest, const struct Buf* src)
|
||||
{
|
||||
buf_append(dest, src->elts, src->nelts);
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/* Appends n characters in str to buf. */
|
||||
struct Buf *buf_strnappend (buf, str, n)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
int n;
|
||||
{
|
||||
buf_append (buf, str, n + 1);
|
||||
|
||||
/* "undo" the '\0' character that buf_append() already copied. */
|
||||
buf->nelts--;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Appends characters in str to buf. */
|
||||
struct Buf *buf_strappend (buf, str)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
{
|
||||
return buf_strnappend (buf, str, strlen (str));
|
||||
}
|
||||
|
||||
/* appends "#define str def\n" */
|
||||
struct Buf *buf_strdefine (buf, str, def)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
const char *def;
|
||||
{
|
||||
buf_strappend (buf, "#define ");
|
||||
buf_strappend (buf, " ");
|
||||
buf_strappend (buf, str);
|
||||
buf_strappend (buf, " ");
|
||||
buf_strappend (buf, def);
|
||||
buf_strappend (buf, "\n");
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** Pushes "m4_define( [[def]], [[val]])m4_dnl" to end of buffer.
|
||||
* @param buf A buffer as a list of strings.
|
||||
* @param def The m4 symbol to define.
|
||||
* @param val The definition; may be NULL.
|
||||
* @return buf
|
||||
*/
|
||||
struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
|
||||
{
|
||||
const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
|
||||
char * str;
|
||||
|
||||
val = val?val:"";
|
||||
str = (char*)flex_alloc(strlen(fmt) + strlen(def) + strlen(val) + 2);
|
||||
|
||||
sprintf(str, fmt, def, val);
|
||||
buf_append(buf, &str, 1);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer.
|
||||
* @param buf A buffer as a list of strings.
|
||||
* @param def The m4 symbol to undefine.
|
||||
* @return buf
|
||||
*/
|
||||
struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
|
||||
{
|
||||
const char * fmt = "m4_undefine( [[%s]])m4_dnl\n";
|
||||
char * str;
|
||||
|
||||
str = (char*)flex_alloc(strlen(fmt) + strlen(def) + 2);
|
||||
|
||||
sprintf(str, fmt, def);
|
||||
buf_append(buf, &str, 1);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* create buf with 0 elements, each of size elem_size. */
|
||||
void buf_init (buf, elem_size)
|
||||
struct Buf *buf;
|
||||
size_t elem_size;
|
||||
{
|
||||
buf->elts = (void *) 0;
|
||||
buf->nelts = 0;
|
||||
buf->elt_size = elem_size;
|
||||
buf->nmax = 0;
|
||||
}
|
||||
|
||||
/* frees memory */
|
||||
void buf_destroy (buf)
|
||||
struct Buf *buf;
|
||||
{
|
||||
if (buf && buf->elts)
|
||||
flex_free (buf->elts);
|
||||
buf->elts = (void *) 0;
|
||||
}
|
||||
|
||||
|
||||
/* appends ptr[] to buf, grow if necessary.
|
||||
* n_elem is number of elements in ptr[], NOT bytes.
|
||||
* returns buf.
|
||||
* We grow by mod(512) boundaries.
|
||||
*/
|
||||
|
||||
struct Buf *buf_append (buf, ptr, n_elem)
|
||||
struct Buf *buf;
|
||||
const void *ptr;
|
||||
int n_elem;
|
||||
{
|
||||
int n_alloc = 0;
|
||||
|
||||
if (!ptr || n_elem == 0)
|
||||
return buf;
|
||||
|
||||
/* May need to alloc more. */
|
||||
if (n_elem + buf->nelts > buf->nmax) {
|
||||
|
||||
/* exact amount needed... */
|
||||
n_alloc = (n_elem + buf->nelts) * buf->elt_size;
|
||||
|
||||
/* ...plus some extra */
|
||||
if (((n_alloc * buf->elt_size) % 512) != 0
|
||||
&& buf->elt_size < 512)
|
||||
n_alloc +=
|
||||
(512 -
|
||||
((n_alloc * buf->elt_size) % 512)) /
|
||||
buf->elt_size;
|
||||
|
||||
if (!buf->elts)
|
||||
buf->elts =
|
||||
allocate_array (n_alloc, buf->elt_size);
|
||||
else
|
||||
buf->elts =
|
||||
reallocate_array (buf->elts, n_alloc,
|
||||
buf->elt_size);
|
||||
|
||||
buf->nmax = n_alloc;
|
||||
}
|
||||
|
||||
memcpy ((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
|
||||
n_elem * buf->elt_size);
|
||||
buf->nelts += n_elem;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
|
@ -1,87 +1,97 @@
|
||||
/* ccl - routines for character classes */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/ccl.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
/* ccladd - add a single character to a ccl */
|
||||
|
||||
void ccladd( cclp, ch )
|
||||
int cclp;
|
||||
int ch;
|
||||
{
|
||||
int ind, len, newpos, i;
|
||||
void ccladd (cclp, ch)
|
||||
int cclp;
|
||||
int ch;
|
||||
{
|
||||
int ind, len, newpos, i;
|
||||
|
||||
check_char( ch );
|
||||
check_char (ch);
|
||||
|
||||
len = ccllen[cclp];
|
||||
ind = cclmap[cclp];
|
||||
|
||||
/* check to see if the character is already in the ccl */
|
||||
|
||||
for ( i = 0; i < len; ++i )
|
||||
if ( ccltbl[ind + i] == ch )
|
||||
for (i = 0; i < len; ++i)
|
||||
if (ccltbl[ind + i] == ch)
|
||||
return;
|
||||
|
||||
/* mark newlines */
|
||||
if (ch == nlch)
|
||||
ccl_has_nl[cclp] = true;
|
||||
|
||||
newpos = ind + len;
|
||||
|
||||
if ( newpos >= current_max_ccl_tbl_size )
|
||||
{
|
||||
if (newpos >= current_max_ccl_tbl_size) {
|
||||
current_max_ccl_tbl_size += MAX_CCL_TBL_SIZE_INCREMENT;
|
||||
|
||||
++num_reallocs;
|
||||
|
||||
ccltbl = reallocate_Character_array( ccltbl,
|
||||
current_max_ccl_tbl_size );
|
||||
}
|
||||
ccltbl = reallocate_Character_array (ccltbl,
|
||||
current_max_ccl_tbl_size);
|
||||
}
|
||||
|
||||
ccllen[cclp] = len + 1;
|
||||
ccltbl[newpos] = ch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cclinit - return an empty ccl */
|
||||
|
||||
int cclinit()
|
||||
{
|
||||
if ( ++lastccl >= current_maxccls )
|
||||
{
|
||||
int cclinit ()
|
||||
{
|
||||
if (++lastccl >= current_maxccls) {
|
||||
current_maxccls += MAX_CCLS_INCREMENT;
|
||||
|
||||
++num_reallocs;
|
||||
|
||||
cclmap = reallocate_integer_array( cclmap, current_maxccls );
|
||||
ccllen = reallocate_integer_array( ccllen, current_maxccls );
|
||||
cclng = reallocate_integer_array( cclng, current_maxccls );
|
||||
}
|
||||
cclmap =
|
||||
reallocate_integer_array (cclmap, current_maxccls);
|
||||
ccllen =
|
||||
reallocate_integer_array (ccllen, current_maxccls);
|
||||
cclng = reallocate_integer_array (cclng, current_maxccls);
|
||||
ccl_has_nl =
|
||||
reallocate_bool_array (ccl_has_nl,
|
||||
current_maxccls);
|
||||
}
|
||||
|
||||
if ( lastccl == 1 )
|
||||
if (lastccl == 1)
|
||||
/* we're making the first ccl */
|
||||
cclmap[lastccl] = 0;
|
||||
|
||||
@ -91,22 +101,25 @@ int cclinit()
|
||||
* ccl, adding the length of the ccl to the cclmap pointer
|
||||
* will produce a cursor to the first free space.
|
||||
*/
|
||||
cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1];
|
||||
cclmap[lastccl] =
|
||||
cclmap[lastccl - 1] + ccllen[lastccl - 1];
|
||||
|
||||
ccllen[lastccl] = 0;
|
||||
cclng[lastccl] = 0; /* ccl's start out life un-negated */
|
||||
ccl_has_nl[lastccl] = false;
|
||||
|
||||
return lastccl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cclnegate - negate the given ccl */
|
||||
|
||||
void cclnegate( cclp )
|
||||
int cclp;
|
||||
{
|
||||
void cclnegate (cclp)
|
||||
int cclp;
|
||||
{
|
||||
cclng[cclp] = 1;
|
||||
}
|
||||
ccl_has_nl[cclp] = !ccl_has_nl[cclp];
|
||||
}
|
||||
|
||||
|
||||
/* list_character_set - list the members of a set of characters in CCL form
|
||||
@ -116,34 +129,71 @@ int cclp;
|
||||
* has a non-zero value in the cset array.
|
||||
*/
|
||||
|
||||
void list_character_set( file, cset )
|
||||
FILE *file;
|
||||
int cset[];
|
||||
{
|
||||
void list_character_set (file, cset)
|
||||
FILE *file;
|
||||
int cset[];
|
||||
{
|
||||
register int i;
|
||||
|
||||
putc( '[', file );
|
||||
putc ('[', file);
|
||||
|
||||
for ( i = 0; i < csize; ++i )
|
||||
{
|
||||
if ( cset[i] )
|
||||
{
|
||||
for (i = 0; i < csize; ++i) {
|
||||
if (cset[i]) {
|
||||
register int start_char = i;
|
||||
|
||||
putc( ' ', file );
|
||||
putc (' ', file);
|
||||
|
||||
fputs( readable_form( i ), file );
|
||||
fputs (readable_form (i), file);
|
||||
|
||||
while ( ++i < csize && cset[i] )
|
||||
;
|
||||
while (++i < csize && cset[i]) ;
|
||||
|
||||
if ( i - 1 > start_char )
|
||||
if (i - 1 > start_char)
|
||||
/* this was a run */
|
||||
fprintf( file, "-%s", readable_form( i - 1 ) );
|
||||
fprintf (file, "-%s",
|
||||
readable_form (i - 1));
|
||||
|
||||
putc( ' ', file );
|
||||
}
|
||||
putc (' ', file);
|
||||
}
|
||||
|
||||
putc( ']', file );
|
||||
}
|
||||
|
||||
putc (']', file);
|
||||
}
|
||||
|
||||
/** Determines if the range [c1-c2] is unambiguous in a case-insensitive
|
||||
* scanner. Specifically, if a lowercase or uppercase character, x, is in the
|
||||
* range [c1-c2], then we require that UPPERCASE(x) and LOWERCASE(x) must also
|
||||
* be in the range. If not, then this range is ambiguous, and the function
|
||||
* returns false. For example, [@-_] spans [a-z] but not [A-Z]. Beware that
|
||||
* [a-z] will be labeled ambiguous because it does not include [A-Z].
|
||||
*
|
||||
* @param c1 the lower end of the range
|
||||
* @param c2 the upper end of the range
|
||||
* @return true if [c1-c2] is not ambiguous for a caseless scanner.
|
||||
*/
|
||||
bool range_covers_case (int c1, int c2)
|
||||
{
|
||||
int i, o;
|
||||
|
||||
for (i = c1; i <= c2; i++) {
|
||||
if (has_case (i)) {
|
||||
o = reverse_case (i);
|
||||
if (o < c1 || c2 < o)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Reverse the case of a character, if possible.
|
||||
* @return c if case-reversal does not apply.
|
||||
*/
|
||||
int reverse_case (int c)
|
||||
{
|
||||
return isupper (c) ? tolower (c) : (islower (c) ? toupper (c) : c);
|
||||
}
|
||||
|
||||
/** Return true if c is uppercase or lowercase. */
|
||||
bool has_case (int c)
|
||||
{
|
||||
return (isupper (c) || islower (c)) ? true : false;
|
||||
}
|
||||
|
@ -1,25 +1,110 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/conf.in,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* conf.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
/* Define to 1 if you have the <cunistd> header file. */
|
||||
#undef HAVE_CUNISTD
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||
*/
|
||||
#undef HAVE_DCGETTEXT
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
/* Define to 1 if you have the declaration of `__func__', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL___FUNC__
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
#undef HAVE_GETTEXT
|
||||
|
||||
/* Define if you have the iconv() function. */
|
||||
#undef HAVE_ICONV
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
#undef HAVE_LIBINTL_H
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the <regex.h> header file. */
|
||||
#undef HAVE_REGEX_H
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#undef HAVE_STDBOOL_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define if you have the <sys/types.h> header file. */
|
||||
/* Define to 1 if you have the <sys/params.h> header file. */
|
||||
#undef HAVE_SYS_PARAMS_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#undef HAVE_ALLOCA_H
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if platform-specific command line handling is necessary. */
|
||||
#undef NEED_ARGV_FIXUP
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the GNU M4 executable name. */
|
||||
#undef M4
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#undef YYTEXT_POINTER
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
1388
src/bin/flex/config.guess
vendored
Executable file
1388
src/bin/flex/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,111 @@
|
||||
/* config.h. Generated automatically by configure. */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/config.h,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* config.h. Generated by configure. */
|
||||
/* conf.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #undef const */
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
/* #undef ENABLE_NLS */
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
/* Define to 1 if you have the <cunistd> header file. */
|
||||
/* #undef HAVE_CUNISTD */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||
*/
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
/* Define to 1 if you have the declaration of `__func__', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL___FUNC__ 1
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
/* #undef HAVE_GETTEXT */
|
||||
|
||||
/* Define if you have the iconv() function. */
|
||||
/* #undef HAVE_ICONV */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
#define HAVE_LIBINTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#define HAVE_LIBM 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <regex.h> header file. */
|
||||
#define HAVE_REGEX_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define if you have the <sys/types.h> header file. */
|
||||
/* Define to 1 if you have the <sys/params.h> header file. */
|
||||
/* #undef HAVE_SYS_PARAMS_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#define HAVE_ALLOCA_H 1
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define if platform-specific command line handling is necessary. */
|
||||
/* #undef NEED_ARGV_FIXUP */
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the GNU M4 executable name. */
|
||||
#define M4 "/bin/m4"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "flex"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "flex-help@lists.sourceforge.net"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "flex"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "flex 2.5.33"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "flex"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.5.33"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "2.5.33"
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#define YYTEXT_POINTER 1
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
548
src/bin/flex/config.rpath
Executable file
548
src/bin/flex/config.rpath
Executable file
@ -0,0 +1,548 @@
|
||||
#! /bin/sh
|
||||
# Output a system dependent set of variables, describing how to set the
|
||||
# run time search path of shared libraries in an executable.
|
||||
#
|
||||
# Copyright 1996-2003 Free Software Foundation, Inc.
|
||||
# Taken from GNU libtool, 2001
|
||||
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
#
|
||||
# The first argument passed to this file is the canonical host specification,
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
|
||||
# should be set by the caller.
|
||||
#
|
||||
# The set of defined variables is at the end of this script.
|
||||
|
||||
# Known limitations:
|
||||
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
|
||||
# than 256 bytes, otherwise the compiler driver will dump core. The only
|
||||
# known workaround is to choose shorter directory names for the build
|
||||
# directory and/or the installation directory.
|
||||
|
||||
# All known linkers require a `.a' archive for static linking (except M$VC,
|
||||
# which needs '.lib').
|
||||
libext=a
|
||||
shrext=.so
|
||||
|
||||
host="$1"
|
||||
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
|
||||
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
|
||||
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
|
||||
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
|
||||
|
||||
wl=
|
||||
if test "$GCC" = yes; then
|
||||
wl='-Wl,'
|
||||
else
|
||||
case "$host_os" in
|
||||
aix*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
mingw* | pw32* | os2*)
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
linux*)
|
||||
case $CC in
|
||||
icc|ecc)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
ccc)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sco3.2v5*)
|
||||
;;
|
||||
solaris*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sunos4*)
|
||||
wl='-Qoption ld '
|
||||
;;
|
||||
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sysv4*MP*)
|
||||
;;
|
||||
uts4*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
|
||||
|
||||
hardcode_libdir_flag_spec=
|
||||
hardcode_libdir_separator=
|
||||
hardcode_direct=no
|
||||
hardcode_minus_L=no
|
||||
|
||||
case "$host_os" in
|
||||
cygwin* | mingw* | pw32*)
|
||||
# FIXME: the MSVC++ port hasn't been tested in a loooong time
|
||||
# When not using gcc, we currently assume that we are using
|
||||
# Microsoft Visual C++.
|
||||
if test "$GCC" != yes; then
|
||||
with_gnu_ld=no
|
||||
fi
|
||||
;;
|
||||
openbsd*)
|
||||
with_gnu_ld=no
|
||||
;;
|
||||
esac
|
||||
|
||||
ld_shlibs=yes
|
||||
if test "$with_gnu_ld" = yes; then
|
||||
case "$host_os" in
|
||||
aix3* | aix4* | aix5*)
|
||||
# On AIX/PPC, the GNU linker is very broken
|
||||
if test "$host_cpu" != ia64; then
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
|
||||
# that the semantics of dynamic libraries on AmigaOS, at least up
|
||||
# to version 4, is to share data among multiple programs linked
|
||||
# with the same dynamic library. Since this doesn't match the
|
||||
# behavior of shared libraries on other platforms, we can use
|
||||
# them.
|
||||
ld_shlibs=no
|
||||
;;
|
||||
beos*)
|
||||
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
cygwin* | mingw* | pw32*)
|
||||
# hardcode_libdir_flag_spec is actually meaningless, as there is
|
||||
# no search path for DLLs.
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
netbsd*)
|
||||
;;
|
||||
solaris* | sysv5*)
|
||||
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
|
||||
ld_shlibs=no
|
||||
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
sunos4*)
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
*)
|
||||
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if test "$ld_shlibs" = yes; then
|
||||
# Unlike libtool, we use -rpath here, not --rpath, since the documented
|
||||
# option of GNU ld is called -rpath, not --rpath.
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
fi
|
||||
else
|
||||
case "$host_os" in
|
||||
aix3*)
|
||||
# Note: this linker hardcodes the directories in LIBPATH if there
|
||||
# are no directories specified by -L.
|
||||
hardcode_minus_L=yes
|
||||
if test "$GCC" = yes; then
|
||||
# Neither direct hardcoding nor static linking is supported with a
|
||||
# broken collect2.
|
||||
hardcode_direct=unsupported
|
||||
fi
|
||||
;;
|
||||
aix4* | aix5*)
|
||||
if test "$host_cpu" = ia64; then
|
||||
# On IA64, the linker does run time linking by default, so we don't
|
||||
# have to do anything special.
|
||||
aix_use_runtimelinking=no
|
||||
else
|
||||
aix_use_runtimelinking=no
|
||||
# Test if we are trying to use run time linking or normal
|
||||
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
|
||||
# need to do runtime linking.
|
||||
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
|
||||
for ld_flag in $LDFLAGS; do
|
||||
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
|
||||
aix_use_runtimelinking=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
esac
|
||||
fi
|
||||
hardcode_direct=yes
|
||||
hardcode_libdir_separator=':'
|
||||
if test "$GCC" = yes; then
|
||||
case $host_os in aix4.[012]|aix4.[012].*)
|
||||
collect2name=`${CC} -print-prog-name=collect2`
|
||||
if test -f "$collect2name" && \
|
||||
strings "$collect2name" | grep resolve_lib_name >/dev/null
|
||||
then
|
||||
# We have reworked collect2
|
||||
hardcode_direct=yes
|
||||
else
|
||||
# We have old collect2
|
||||
hardcode_direct=unsupported
|
||||
hardcode_minus_L=yes
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_libdir_separator=
|
||||
fi
|
||||
esac
|
||||
fi
|
||||
# Begin _LT_AC_SYS_LIBPATH_AIX.
|
||||
echo 'int main () { return 0; }' > conftest.c
|
||||
${CC} ${LDFLAGS} conftest.c -o conftest
|
||||
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
|
||||
}'`
|
||||
if test -z "$aix_libpath"; then
|
||||
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
|
||||
}'`
|
||||
fi
|
||||
if test -z "$aix_libpath"; then
|
||||
aix_libpath="/usr/lib:/lib"
|
||||
fi
|
||||
rm -f conftest.c conftest
|
||||
# End _LT_AC_SYS_LIBPATH_AIX.
|
||||
if test "$aix_use_runtimelinking" = yes; then
|
||||
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
|
||||
else
|
||||
if test "$host_cpu" = ia64; then
|
||||
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
|
||||
else
|
||||
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
# see comment about different semantics on the GNU ld section
|
||||
ld_shlibs=no
|
||||
;;
|
||||
bsdi4*)
|
||||
;;
|
||||
cygwin* | mingw* | pw32*)
|
||||
# When not using gcc, we currently assume that we are using
|
||||
# Microsoft Visual C++.
|
||||
# hardcode_libdir_flag_spec is actually meaningless, as there is
|
||||
# no search path for DLLs.
|
||||
hardcode_libdir_flag_spec=' '
|
||||
libext=lib
|
||||
;;
|
||||
darwin* | rhapsody*)
|
||||
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
|
||||
hardcode_direct=no
|
||||
fi
|
||||
;;
|
||||
dgux*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
freebsd1*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
freebsd2.2*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
freebsd2*)
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
freebsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
hpux9*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
hpux10* | hpux11*)
|
||||
if test "$with_gnu_ld" = no; then
|
||||
case "$host_cpu" in
|
||||
hppa*64*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=no
|
||||
;;
|
||||
ia64*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_direct=no
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
netbsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
newsos6)
|
||||
hardcode_direct=yes
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
openbsd*)
|
||||
hardcode_direct=yes
|
||||
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
else
|
||||
case "$host_os" in
|
||||
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
os2*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
osf3*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
osf4* | osf5*)
|
||||
if test "$GCC" = yes; then
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
else
|
||||
# Both cc and cxx compiler support -rpath directly
|
||||
hardcode_libdir_flag_spec='-rpath $libdir'
|
||||
fi
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
sco3.2v5*)
|
||||
;;
|
||||
solaris*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
sunos4*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
sysv4)
|
||||
case $host_vendor in
|
||||
sni)
|
||||
hardcode_direct=yes # is this really true???
|
||||
;;
|
||||
siemens)
|
||||
hardcode_direct=no
|
||||
;;
|
||||
motorola)
|
||||
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
sysv4.3*)
|
||||
;;
|
||||
sysv4*MP*)
|
||||
if test -d /usr/nec; then
|
||||
ld_shlibs=yes
|
||||
fi
|
||||
;;
|
||||
sysv4.2uw2*)
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=no
|
||||
;;
|
||||
sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
|
||||
;;
|
||||
sysv5*)
|
||||
hardcode_libdir_flag_spec=
|
||||
;;
|
||||
uts4*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Check dynamic linker characteristics
|
||||
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
|
||||
libname_spec='lib$name'
|
||||
case "$host_os" in
|
||||
aix3*)
|
||||
;;
|
||||
aix4* | aix5*)
|
||||
;;
|
||||
amigaos*)
|
||||
;;
|
||||
beos*)
|
||||
;;
|
||||
bsdi4*)
|
||||
;;
|
||||
cygwin* | mingw* | pw32*)
|
||||
shrext=.dll
|
||||
;;
|
||||
darwin* | rhapsody*)
|
||||
shrext=.dylib
|
||||
;;
|
||||
dgux*)
|
||||
;;
|
||||
freebsd1*)
|
||||
;;
|
||||
freebsd*)
|
||||
;;
|
||||
gnu*)
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
case "$host_cpu" in
|
||||
ia64*)
|
||||
shrext=.so
|
||||
;;
|
||||
hppa*64*)
|
||||
shrext=.sl
|
||||
;;
|
||||
*)
|
||||
shrext=.sl
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
case "$host_os" in
|
||||
irix5* | nonstopux*)
|
||||
libsuff= shlibsuff=
|
||||
;;
|
||||
*)
|
||||
case $LD in
|
||||
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
|
||||
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
|
||||
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
|
||||
*) libsuff= shlibsuff= ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
linux*oldld* | linux*aout* | linux*coff*)
|
||||
;;
|
||||
linux*)
|
||||
;;
|
||||
netbsd*)
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
nto-qnx)
|
||||
;;
|
||||
openbsd*)
|
||||
;;
|
||||
os2*)
|
||||
libname_spec='$name'
|
||||
shrext=.dll
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
;;
|
||||
sco3.2v5*)
|
||||
;;
|
||||
solaris*)
|
||||
;;
|
||||
sunos4*)
|
||||
;;
|
||||
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
|
||||
;;
|
||||
sysv4*MP*)
|
||||
;;
|
||||
uts4*)
|
||||
;;
|
||||
esac
|
||||
|
||||
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
|
||||
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
|
||||
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
|
||||
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
|
||||
|
||||
# How to pass a linker flag through the compiler.
|
||||
wl="$escaped_wl"
|
||||
|
||||
# Static library suffix (normally "a").
|
||||
libext="$libext"
|
||||
|
||||
# Shared library suffix (normally "so").
|
||||
shlibext="$shlibext"
|
||||
|
||||
# Flag to hardcode \$libdir into a binary during linking.
|
||||
# This must work even if \$libdir does not exist.
|
||||
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
|
||||
|
||||
# Whether we need a single -rpath flag with a separated argument.
|
||||
hardcode_libdir_separator="$hardcode_libdir_separator"
|
||||
|
||||
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
|
||||
# resulting binary.
|
||||
hardcode_direct="$hardcode_direct"
|
||||
|
||||
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
|
||||
# resulting binary.
|
||||
hardcode_minus_L="$hardcode_minus_L"
|
||||
|
||||
EOF
|
@ -1,195 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Generated automatically by configure.
|
||||
# Run this file to recreate the current configuration.
|
||||
# This directory was configured as follows,
|
||||
# on host KORLIP:
|
||||
#
|
||||
# ./configure
|
||||
#
|
||||
# Compiler output produced by configure, useful for debugging
|
||||
# configure, is in ./config.log if it exists.
|
||||
|
||||
ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]"
|
||||
for ac_option
|
||||
do
|
||||
case "$ac_option" in
|
||||
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
|
||||
echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion"
|
||||
exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;;
|
||||
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||
echo "./config.status generated by autoconf version 2.1"
|
||||
exit 0 ;;
|
||||
-help | --help | --hel | --he | --h)
|
||||
echo "$ac_cs_usage"; exit 0 ;;
|
||||
*) echo "$ac_cs_usage"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
ac_given_srcdir=.
|
||||
ac_given_INSTALL="/bin/install -c"
|
||||
|
||||
trap 'rm -fr Makefile config.h:conf.in conftest*; exit 1' 1 2 15
|
||||
|
||||
# Protect against being on the right side of a sed subst in config.status.
|
||||
sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g;
|
||||
s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
|
||||
/^[ ]*VPATH[ ]*=[^:]*$/d
|
||||
|
||||
s%@CFLAGS@%-g -O%g
|
||||
s%@CPPFLAGS@%%g
|
||||
s%@CXXFLAGS@%%g
|
||||
s%@DEFS@%-DHAVE_CONFIG_H%g
|
||||
s%@LDFLAGS@%%g
|
||||
s%@LIBS@%%g
|
||||
s%@exec_prefix@%${prefix}%g
|
||||
s%@prefix@%/usr/local%g
|
||||
s%@program_transform_name@%s,x,x,%g
|
||||
s%@LN_S@%ln -s%g
|
||||
s%@YACC@%bison -y%g
|
||||
s%@CC@%gcc%g
|
||||
s%@RANLIB@%ranlib%g
|
||||
s%@INSTALL_PROGRAM@%${INSTALL}%g
|
||||
s%@INSTALL_DATA@%${INSTALL} -m 644%g
|
||||
s%@SET_MAKE@%%g
|
||||
s%@CPP@%gcc -E%g
|
||||
s%@ALLOCA@%%g
|
||||
|
||||
CEOF
|
||||
|
||||
CONFIG_FILES=${CONFIG_FILES-"Makefile"}
|
||||
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
# Adjust relative srcdir, etc. for subdirectories.
|
||||
|
||||
# Remove last slash and all that follows it. Not all systems have dirname.
|
||||
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
|
||||
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
|
||||
# The file is in a subdirectory.
|
||||
test ! -d "$ac_dir" && mkdir "$ac_dir"
|
||||
ac_dir_suffix="/$ac_dir"
|
||||
# A "../" for each directory in $ac_dir_suffix.
|
||||
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
|
||||
else
|
||||
ac_dir_suffix= ac_dots=
|
||||
fi
|
||||
|
||||
case "$ac_given_srcdir" in
|
||||
.) srcdir=.
|
||||
if test -z "$ac_dots"; then top_srcdir=.
|
||||
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
|
||||
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
|
||||
*) # Relative path.
|
||||
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
|
||||
top_srcdir="$ac_dots$ac_given_srcdir" ;;
|
||||
esac
|
||||
|
||||
case "$ac_given_INSTALL" in
|
||||
[/$]*) INSTALL="$ac_given_INSTALL" ;;
|
||||
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
|
||||
esac
|
||||
echo creating "$ac_file"
|
||||
rm -f "$ac_file"
|
||||
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
|
||||
case "$ac_file" in
|
||||
*Makefile*) ac_comsub="1i\\
|
||||
# $configure_input" ;;
|
||||
*) ac_comsub= ;;
|
||||
esac
|
||||
sed -e "$ac_comsub
|
||||
s%@configure_input@%$configure_input%g
|
||||
s%@srcdir@%$srcdir%g
|
||||
s%@top_srcdir@%$top_srcdir%g
|
||||
s%@INSTALL@%$INSTALL%g
|
||||
" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
|
||||
fi; done
|
||||
rm -f conftest.subs
|
||||
|
||||
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
|
||||
# NAME is the cpp macro being defined and VALUE is the value it is being given.
|
||||
#
|
||||
# ac_d sets the value in "#define NAME VALUE" lines.
|
||||
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
|
||||
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
|
||||
ac_dC='\3'
|
||||
ac_dD='%g'
|
||||
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
|
||||
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_uB='\([ ]\)%\1#\2define\3'
|
||||
ac_uC=' '
|
||||
ac_uD='\4%g'
|
||||
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
|
||||
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_eB='$%\1#\2define\3'
|
||||
ac_eC=' '
|
||||
ac_eD='%g'
|
||||
|
||||
CONFIG_HEADERS=${CONFIG_HEADERS-"config.h:conf.in"}
|
||||
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
echo creating $ac_file
|
||||
|
||||
rm -f conftest.frag conftest.in conftest.out
|
||||
cp $ac_given_srcdir/$ac_file_in conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
|
||||
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
|
||||
${ac_eA}STDC_HEADERS${ac_eB}STDC_HEADERS${ac_eC}1${ac_eD}
|
||||
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
|
||||
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
|
||||
${ac_eA}STDC_HEADERS${ac_eB}STDC_HEADERS${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRING_H${ac_dB}HAVE_STRING_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRING_H${ac_uB}HAVE_STRING_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRING_H${ac_eB}HAVE_STRING_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_MALLOC_H${ac_dB}HAVE_MALLOC_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_MALLOC_H${ac_uB}HAVE_MALLOC_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_MALLOC_H${ac_eB}HAVE_MALLOC_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SYS_TYPES_H${ac_dB}HAVE_SYS_TYPES_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_TYPES_H${ac_uB}HAVE_SYS_TYPES_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_TYPES_H${ac_eB}HAVE_SYS_TYPES_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_ALLOCA_H${ac_dB}HAVE_ALLOCA_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_ALLOCA_H${ac_uB}HAVE_ALLOCA_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_ALLOCA_H${ac_eB}HAVE_ALLOCA_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_ALLOCA${ac_dB}HAVE_ALLOCA${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_ALLOCA${ac_uB}HAVE_ALLOCA${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_ALLOCA${ac_eB}HAVE_ALLOCA${ac_eC}1${ac_eD}
|
||||
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
rm -f conftest.frag conftest.h
|
||||
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
|
||||
cat conftest.in >> conftest.h
|
||||
rm -f conftest.in
|
||||
if cmp -s $ac_file conftest.h 2>/dev/null; then
|
||||
echo "$ac_file is unchanged"
|
||||
rm -f conftest.h
|
||||
else
|
||||
rm -f $ac_file
|
||||
mv conftest.h $ac_file
|
||||
fi
|
||||
fi; done
|
||||
|
||||
|
||||
test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
|
||||
exit 0
|
1492
src/bin/flex/config.sub
vendored
Executable file
1492
src/bin/flex/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
9983
src/bin/flex/configure
vendored
9983
src/bin/flex/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,151 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
AC_INIT(initscan.c)
|
||||
|
||||
dnl This file is part of flex.
|
||||
|
||||
dnl Redistribution and use in source and binary forms, with or without
|
||||
dnl modification, are permitted provided that the following conditions
|
||||
dnl are met:
|
||||
|
||||
dnl 1. Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl 2. Redistributions in binary form must reproduce the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer in the
|
||||
dnl documentation and/or other materials provided with the distribution.
|
||||
|
||||
dnl Neither the name of the University nor the names of its contributors
|
||||
dnl may be used to endorse or promote products derived from this software
|
||||
dnl without specific prior written permission.
|
||||
|
||||
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
dnl IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
dnl PURPOSE.
|
||||
|
||||
dnl autoconf requirements and initialization
|
||||
|
||||
AC_PREREQ(2.54)
|
||||
AC_INIT(flex,2.5.33,flex-help@lists.sourceforge.net)
|
||||
AC_CONFIG_SRCDIR(scan.l)
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_HEADER(config.h:conf.in)
|
||||
|
||||
AC_LN_S
|
||||
dnl checks for programs
|
||||
|
||||
AM_GNU_GETTEXT([external])
|
||||
AM_GNU_GETTEXT_VERSION(0.12)
|
||||
|
||||
AC_PROG_YACC
|
||||
AM_PROG_LEX
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
AC_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
AC_PATH_PROG(BISON, bison,bison)
|
||||
AC_PATH_PROG(HELP2MAN, help2man, help2man)
|
||||
|
||||
|
||||
# Check for a GNU m4 that supports --prefix-builtins
|
||||
AC_PATH_PROGS(M4, gm4 gnum4 m4, m4)
|
||||
if test x"$M4" != x; then
|
||||
AC_MSG_CHECKING([for GNU m4])
|
||||
case `$M4 --help < /dev/null 2>&1` in
|
||||
*prefix-builtins*) AC_MSG_RESULT(yes) ;;
|
||||
*) AC_MSG_RESULT(no) ;
|
||||
AC_MSG_ERROR([GNU M4 1.4 is required]) ;;
|
||||
esac
|
||||
else
|
||||
AC_MSG_ERROR([GNU M4 1.4 is required]) ;
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the GNU M4 executable name.])
|
||||
|
||||
AC_PATH_PROG(INDENT, indent, indent)
|
||||
dnl if INDENT is set to 'indent' then we didn't find indent
|
||||
if test "$INDENT" != indent ; then
|
||||
AC_MSG_CHECKING(if $INDENT is GNU indent)
|
||||
if $INDENT --version 2>/dev/null | head -n 1|grep "GNU indent" > /dev/null ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_WARN($INDENT does not appear to be GNU indent.)
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN(no indent program found: make indent target will not function)
|
||||
fi
|
||||
|
||||
dnl checks for libraries
|
||||
AC_CHECK_LIB(m, log)
|
||||
|
||||
dnl checks for header files
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_HAVE_HEADERS(string.h malloc.h sys/types.h)
|
||||
AC_CHECK_HEADERS(unistd.h stdbool.h netinet/in.h limits.h)
|
||||
AC_CHECK_HEADERS( sys/wait.h sys/params.h)
|
||||
AC_CHECK_HEADERS(cunistd)
|
||||
AC_CHECK_HEADERS(locale.h libintl.h)
|
||||
AC_CHECK_HEADERS(regex.h)
|
||||
|
||||
case "$YACC" in
|
||||
*bison*)
|
||||
AC_ALLOCA
|
||||
;;
|
||||
esac
|
||||
dnl checks for types
|
||||
|
||||
AC_OUTPUT(Makefile,
|
||||
[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
dnl checks for functions
|
||||
|
||||
AC_CHECK_DECLS(__func__)
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
flex.spec
|
||||
Makefile
|
||||
doc/Makefile
|
||||
examples/Makefile
|
||||
examples/fastwc/Makefile
|
||||
examples/manual/Makefile
|
||||
m4/Makefile
|
||||
po/Makefile.in
|
||||
tools/Makefile
|
||||
tests/Makefile
|
||||
tests/TEMPLATE/Makefile
|
||||
tests/test-array-nr/Makefile
|
||||
tests/test-array-r/Makefile
|
||||
tests/test-basic-nr/Makefile
|
||||
tests/test-basic-r/Makefile
|
||||
tests/test-bison-yylloc/Makefile
|
||||
tests/test-bison-yylval/Makefile
|
||||
tests/test-c-cpp-nr/Makefile
|
||||
tests/test-c-cpp-r/Makefile
|
||||
tests/test-header-nr/Makefile
|
||||
tests/test-header-r/Makefile
|
||||
tests/test-include-by-buffer/Makefile
|
||||
tests/test-include-by-push/Makefile
|
||||
tests/test-include-by-reentrant/Makefile
|
||||
tests/test-multiple-scanners-nr/Makefile
|
||||
tests/test-multiple-scanners-r/Makefile
|
||||
tests/test-noansi-nr/Makefile
|
||||
tests/test-noansi-r/Makefile
|
||||
tests/test-prefix-nr/Makefile
|
||||
tests/test-prefix-r/Makefile
|
||||
tests/test-pthread/Makefile
|
||||
tests/test-string-nr/Makefile
|
||||
tests/test-string-r/Makefile
|
||||
tests/test-yyextra/Makefile
|
||||
tests/test-lineno-nr/Makefile
|
||||
tests/test-lineno-r/Makefile
|
||||
tests/test-linedir-r/Makefile
|
||||
tests/test-debug-r/Makefile
|
||||
tests/test-debug-nr/Makefile
|
||||
tests/test-mem-nr/Makefile
|
||||
tests/test-mem-r/Makefile
|
||||
tests/test-posix/Makefile
|
||||
tests/test-posixly-correct/Makefile
|
||||
tests/test-table-opts/Makefile
|
||||
tests/test-c++-basic/Makefile
|
||||
tests/test-bison-nr/Makefile
|
||||
tests/test-reject/Makefile
|
||||
tests/test-c++-multiple-scanners/Makefile
|
||||
tests/test-top/Makefile
|
||||
tests/test-rescan-nr/Makefile
|
||||
tests/test-rescan-r/Makefile
|
||||
dnl --new-test-here-- This line is processed by tests/create-test.
|
||||
)
|
||||
|
||||
AC_OUTPUT
|
||||
|
464
src/bin/flex/depcomp
Executable file
464
src/bin/flex/depcomp
Executable file
@ -0,0 +1,464 @@
|
||||
#! /bin/sh
|
||||
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
# Copyright 1999, 2000 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 to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
# `libtool' can also be set to `yes' or `no'.
|
||||
|
||||
if test -z "$depfile"; then
|
||||
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
|
||||
dir=`echo "$object" | sed 's,/.*$,/,'`
|
||||
if test "$dir" = "$object"; then
|
||||
dir=
|
||||
fi
|
||||
# FIXME: should be _deps on DOS.
|
||||
depfile="$dir.deps/$base"
|
||||
fi
|
||||
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. This file always lives in the current directory.
|
||||
# Also, the AIX compiler puts `$object:' at the start of each line;
|
||||
# $object doesn't have directory information.
|
||||
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
outname="$stripped.o"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
"$@" -M
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Must come before tru64.
|
||||
|
||||
# Intel's C compiler understands `-MD -MF file'. However
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# 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
|
||||
# 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$//'`
|
||||
|
||||
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
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile1"; then
|
||||
tmpdepfile="$tmpdepfile1"
|
||||
else
|
||||
tmpdepfile="$tmpdepfile2"
|
||||
fi
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a space and a tab in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# 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'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# 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 ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
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 ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# 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
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
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.
|
||||
"$@" || 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"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
File diff suppressed because it is too large
Load Diff
@ -1,43 +1,46 @@
|
||||
/* ecs - equivalence class routines */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/ecs.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
/* ccl2ecl - convert character classes to set of equivalence classes */
|
||||
|
||||
void ccl2ecl()
|
||||
{
|
||||
int i, ich, newlen, cclp, ccls, cclmec;
|
||||
void ccl2ecl ()
|
||||
{
|
||||
int i, ich, newlen, cclp, ccls, cclmec;
|
||||
|
||||
for ( i = 1; i <= lastccl; ++i )
|
||||
{
|
||||
for (i = 1; i <= lastccl; ++i) {
|
||||
/* We loop through each character class, and for each character
|
||||
* in the class, add the character's equivalence class to the
|
||||
* new "character" class we are creating. Thus when we are all
|
||||
@ -48,21 +51,19 @@ void ccl2ecl()
|
||||
newlen = 0;
|
||||
cclp = cclmap[i];
|
||||
|
||||
for ( ccls = 0; ccls < ccllen[i]; ++ccls )
|
||||
{
|
||||
for (ccls = 0; ccls < ccllen[i]; ++ccls) {
|
||||
ich = ccltbl[cclp + ccls];
|
||||
cclmec = ecgroup[ich];
|
||||
|
||||
if ( cclmec > 0 )
|
||||
{
|
||||
if (cclmec > 0) {
|
||||
ccltbl[cclp + newlen] = cclmec;
|
||||
++newlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ccllen[i] = newlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cre8ecs - associate equivalence class numbers with class members
|
||||
@ -73,10 +74,10 @@ void ccl2ecl()
|
||||
* Returned is the number of classes.
|
||||
*/
|
||||
|
||||
int cre8ecs( fwd, bck, num )
|
||||
int fwd[], bck[], num;
|
||||
{
|
||||
int i, j, numcl;
|
||||
int cre8ecs (fwd, bck, num)
|
||||
int fwd[], bck[], num;
|
||||
{
|
||||
int i, j, numcl;
|
||||
|
||||
numcl = 0;
|
||||
|
||||
@ -85,16 +86,15 @@ int fwd[], bck[], num;
|
||||
* is positive, then x is the representative of its equivalence
|
||||
* class.
|
||||
*/
|
||||
for ( i = 1; i <= num; ++i )
|
||||
if ( bck[i] == NIL )
|
||||
{
|
||||
for (i = 1; i <= num; ++i)
|
||||
if (bck[i] == NIL) {
|
||||
bck[i] = ++numcl;
|
||||
for ( j = fwd[i]; j != NIL; j = fwd[j] )
|
||||
for (j = fwd[i]; j != NIL; j = fwd[j])
|
||||
bck[j] = -numcl;
|
||||
}
|
||||
}
|
||||
|
||||
return numcl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkeccl - update equivalence classes based on character class xtions
|
||||
@ -112,12 +112,12 @@ int fwd[], bck[], num;
|
||||
* NUL_mapping is the value which NUL (0) should be mapped to.
|
||||
*/
|
||||
|
||||
void mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping )
|
||||
Char ccls[];
|
||||
int lenccl, fwd[], bck[], llsiz, NUL_mapping;
|
||||
{
|
||||
int cclp, oldec, newec;
|
||||
int cclm, i, j;
|
||||
void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping)
|
||||
Char ccls[];
|
||||
int lenccl, fwd[], bck[], llsiz, NUL_mapping;
|
||||
{
|
||||
int cclp, oldec, newec;
|
||||
int cclm, i, j;
|
||||
static unsigned char cclflags[CSIZE]; /* initialized to all '\0' */
|
||||
|
||||
/* Note that it doesn't matter whether or not the character class is
|
||||
@ -126,11 +126,10 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
|
||||
|
||||
cclp = 0;
|
||||
|
||||
while ( cclp < lenccl )
|
||||
{
|
||||
while (cclp < lenccl) {
|
||||
cclm = ccls[cclp];
|
||||
|
||||
if ( NUL_mapping && cclm == 0 )
|
||||
if (NUL_mapping && cclm == 0)
|
||||
cclm = NUL_mapping;
|
||||
|
||||
oldec = bck[cclm];
|
||||
@ -138,22 +137,19 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
|
||||
|
||||
j = cclp + 1;
|
||||
|
||||
for ( i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i] )
|
||||
{ /* look for the symbol in the character class */
|
||||
for ( ; j < lenccl; ++j )
|
||||
{
|
||||
for (i = fwd[cclm]; i != NIL && i <= llsiz; i = fwd[i]) { /* look for the symbol in the character class */
|
||||
for (; j < lenccl; ++j) {
|
||||
register int ccl_char;
|
||||
|
||||
if ( NUL_mapping && ccls[j] == 0 )
|
||||
if (NUL_mapping && ccls[j] == 0)
|
||||
ccl_char = NUL_mapping;
|
||||
else
|
||||
ccl_char = ccls[j];
|
||||
|
||||
if ( ccl_char > i )
|
||||
if (ccl_char > i)
|
||||
break;
|
||||
|
||||
if ( ccl_char == i && ! cclflags[j] )
|
||||
{
|
||||
if (ccl_char == i && !cclflags[j]) {
|
||||
/* We found an old companion of cclm
|
||||
* in the ccl. Link it into the new
|
||||
* equivalence class and flag it as
|
||||
@ -169,8 +165,8 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
|
||||
/* Get next equivalence class member. */
|
||||
/* continue 2 */
|
||||
goto next_pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Symbol isn't in character class. Put it in the old
|
||||
* equivalence class.
|
||||
@ -178,48 +174,46 @@ int lenccl, fwd[], bck[], llsiz, NUL_mapping;
|
||||
|
||||
bck[i] = oldec;
|
||||
|
||||
if ( oldec != NIL )
|
||||
if (oldec != NIL)
|
||||
fwd[oldec] = i;
|
||||
|
||||
oldec = i;
|
||||
|
||||
next_pt: ;
|
||||
}
|
||||
next_pt:;
|
||||
}
|
||||
|
||||
if ( bck[cclm] != NIL || oldec != bck[cclm] )
|
||||
{
|
||||
if (bck[cclm] != NIL || oldec != bck[cclm]) {
|
||||
bck[cclm] = NIL;
|
||||
fwd[oldec] = NIL;
|
||||
}
|
||||
}
|
||||
|
||||
fwd[newec] = NIL;
|
||||
|
||||
/* Find next ccl member to process. */
|
||||
|
||||
for ( ++cclp; cclflags[cclp] && cclp < lenccl; ++cclp )
|
||||
{
|
||||
for (++cclp; cclflags[cclp] && cclp < lenccl; ++cclp) {
|
||||
/* Reset "doesn't need processing" flag. */
|
||||
cclflags[cclp] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkechar - create equivalence class for single character */
|
||||
|
||||
void mkechar( tch, fwd, bck )
|
||||
int tch, fwd[], bck[];
|
||||
{
|
||||
void mkechar (tch, fwd, bck)
|
||||
int tch, fwd[], bck[];
|
||||
{
|
||||
/* If until now the character has been a proper subset of
|
||||
* an equivalence class, break it away to create a new ec
|
||||
*/
|
||||
|
||||
if ( fwd[tch] != NIL )
|
||||
if (fwd[tch] != NIL)
|
||||
bck[fwd[tch]] = bck[tch];
|
||||
|
||||
if ( bck[tch] != NIL )
|
||||
if (bck[tch] != NIL)
|
||||
fwd[bck[tch]] = fwd[tch];
|
||||
|
||||
fwd[tch] = NIL;
|
||||
bck[tch] = NIL;
|
||||
}
|
||||
}
|
||||
|
405
src/bin/flex/filter.c
Normal file
405
src/bin/flex/filter.c
Normal file
@ -0,0 +1,405 @@
|
||||
/* filter - postprocessing of flex output through filters */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
static const char * check_4_gnu_m4 =
|
||||
"m4_dnl ifdef(`__gnu__', ,"
|
||||
"`errprint(Flex requires GNU M4. Set the PATH or set the M4 environment variable to its path name.)"
|
||||
" m4exit(2)')\n";
|
||||
|
||||
|
||||
/** global chain. */
|
||||
struct filter *output_chain = NULL;
|
||||
|
||||
/* Allocate and initialize an external filter.
|
||||
* @param chain the current chain or NULL for new chain
|
||||
* @param cmd the command to execute.
|
||||
* @param ... a NULL terminated list of (const char*) arguments to command,
|
||||
* not including argv[0].
|
||||
* @return newest filter in chain
|
||||
*/
|
||||
struct filter *filter_create_ext (struct filter *chain, const char *cmd,
|
||||
...)
|
||||
{
|
||||
struct filter *f;
|
||||
int max_args;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
/* allocate and initialize new filter */
|
||||
f = (struct filter *) flex_alloc (sizeof (struct filter));
|
||||
memset (f, 0, sizeof (*f));
|
||||
f->filter_func = NULL;
|
||||
f->extra = NULL;
|
||||
f->next = NULL;
|
||||
f->argc = 0;
|
||||
|
||||
if (chain != NULL) {
|
||||
/* append f to end of chain */
|
||||
while (chain->next)
|
||||
chain = chain->next;
|
||||
chain->next = f;
|
||||
}
|
||||
|
||||
|
||||
/* allocate argv, and populate it with the argument list. */
|
||||
max_args = 8;
|
||||
f->argv =
|
||||
(const char **) flex_alloc (sizeof (char *) *
|
||||
(max_args + 1));
|
||||
f->argv[f->argc++] = cmd;
|
||||
|
||||
va_start (ap, cmd);
|
||||
while ((s = va_arg (ap, const char *)) != NULL) {
|
||||
if (f->argc >= max_args) {
|
||||
max_args += 8;
|
||||
f->argv =
|
||||
(const char **) flex_realloc (f->argv,
|
||||
sizeof (char
|
||||
*) *
|
||||
(max_args +
|
||||
1));
|
||||
}
|
||||
f->argv[f->argc++] = s;
|
||||
}
|
||||
f->argv[f->argc] = NULL;
|
||||
|
||||
va_end (ap);
|
||||
return f;
|
||||
}
|
||||
|
||||
/* Allocate and initialize an internal filter.
|
||||
* @param chain the current chain or NULL for new chain
|
||||
* @param filter_func The function that will perform the filtering.
|
||||
* filter_func should return 0 if successful, and -1
|
||||
* if an error occurs -- or it can simply exit().
|
||||
* @param extra optional user-defined data to pass to the filter.
|
||||
* @return newest filter in chain
|
||||
*/
|
||||
struct filter *filter_create_int (struct filter *chain,
|
||||
int (*filter_func) (struct filter *),
|
||||
void *extra)
|
||||
{
|
||||
struct filter *f;
|
||||
|
||||
/* allocate and initialize new filter */
|
||||
f = (struct filter *) flex_alloc (sizeof (struct filter));
|
||||
memset (f, 0, sizeof (*f));
|
||||
f->next = NULL;
|
||||
f->argc = 0;
|
||||
f->argv = NULL;
|
||||
|
||||
f->filter_func = filter_func;
|
||||
f->extra = extra;
|
||||
|
||||
if (chain != NULL) {
|
||||
/* append f to end of chain */
|
||||
while (chain->next)
|
||||
chain = chain->next;
|
||||
chain->next = f;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/** Fork and exec entire filter chain.
|
||||
* @param chain The head of the chain.
|
||||
* @return true on success.
|
||||
*/
|
||||
bool filter_apply_chain (struct filter * chain)
|
||||
{
|
||||
int pid, pipes[2];
|
||||
|
||||
/* Tricky recursion, since we want to begin the chain
|
||||
* at the END. Why? Because we need all the forked processes
|
||||
* to be children of the main flex process.
|
||||
*/
|
||||
if (chain)
|
||||
filter_apply_chain (chain->next);
|
||||
else
|
||||
return true;
|
||||
|
||||
/* Now we are the right-most unprocessed link in the chain.
|
||||
*/
|
||||
|
||||
fflush (stdout);
|
||||
fflush (stderr);
|
||||
|
||||
if (pipe (pipes) == -1)
|
||||
flexerror (_("pipe failed"));
|
||||
|
||||
if ((pid = fork ()) == -1)
|
||||
flexerror (_("fork failed"));
|
||||
|
||||
if (pid == 0) {
|
||||
/* child */
|
||||
close (pipes[1]);
|
||||
if (dup2 (pipes[0], 0) == -1)
|
||||
flexfatal (_("dup2(pipes[0],0)"));
|
||||
close (pipes[0]);
|
||||
|
||||
/* run as a filter, either internally or by exec */
|
||||
if (chain->filter_func) {
|
||||
int r;
|
||||
|
||||
/* setup streams again */
|
||||
if ( ! fdopen (0, "r"))
|
||||
flexfatal (_("fdopen(0) failed"));
|
||||
if (!fdopen (1, "w"))
|
||||
flexfatal (_("fdopen(1) failed"));
|
||||
|
||||
if ((r = chain->filter_func (chain)) == -1)
|
||||
flexfatal (_("filter_func failed"));
|
||||
exit (0);
|
||||
}
|
||||
else {
|
||||
execvp (chain->argv[0],
|
||||
(char **const) (chain->argv));
|
||||
flexfatal (_(chain->argv[0]));
|
||||
}
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
close (pipes[0]);
|
||||
if (dup2 (pipes[1], 1) == -1)
|
||||
flexfatal (_("dup2(pipes[1],1)"));
|
||||
close (pipes[1]);
|
||||
if ( !fdopen (1, "w"))
|
||||
flexfatal (_("fdopen(1) failed"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Truncate the chain to max_len number of filters.
|
||||
* @param chain the current chain.
|
||||
* @param max_len the maximum length of the chain.
|
||||
* @return the resulting length of the chain.
|
||||
*/
|
||||
int filter_truncate (struct filter *chain, int max_len)
|
||||
{
|
||||
int len = 1;
|
||||
|
||||
if (!chain)
|
||||
return 0;
|
||||
|
||||
while (chain->next && len < max_len) {
|
||||
chain = chain->next;
|
||||
++len;
|
||||
}
|
||||
|
||||
chain->next = NULL;
|
||||
return len;
|
||||
}
|
||||
|
||||
/** Splits the chain in order to write to a header file.
|
||||
* Similar in spirit to the 'tee' program.
|
||||
* The header file name is in extra.
|
||||
* @return 0 (zero) on success, and -1 on failure.
|
||||
*/
|
||||
int filter_tee_header (struct filter *chain)
|
||||
{
|
||||
/* This function reads from stdin and writes to both the C file and the
|
||||
* header file at the same time.
|
||||
*/
|
||||
|
||||
const int readsz = 512;
|
||||
char *buf;
|
||||
int to_cfd = -1;
|
||||
FILE *to_c = NULL, *to_h = NULL;
|
||||
bool write_header;
|
||||
|
||||
write_header = (chain->extra != NULL);
|
||||
|
||||
/* Store a copy of the stdout pipe, which is already piped to C file
|
||||
* through the running chain. Then create a new pipe to the H file as
|
||||
* stdout, and fork the rest of the chain again.
|
||||
*/
|
||||
|
||||
if ((to_cfd = dup (1)) == -1)
|
||||
flexfatal (_("dup(1) failed"));
|
||||
to_c = fdopen (to_cfd, "w");
|
||||
|
||||
if (write_header) {
|
||||
if (freopen ((char *) chain->extra, "w", stdout) == NULL)
|
||||
flexfatal (_("freopen(headerfilename) failed"));
|
||||
|
||||
filter_apply_chain (chain->next);
|
||||
to_h = stdout;
|
||||
}
|
||||
|
||||
/* Now to_c is a pipe to the C branch, and to_h is a pipe to the H branch.
|
||||
*/
|
||||
|
||||
if (write_header) {
|
||||
fputs (check_4_gnu_m4, to_h);
|
||||
fputs ("m4_changecom`'m4_dnl\n", to_h);
|
||||
fputs ("m4_changequote`'m4_dnl\n", to_h);
|
||||
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h);
|
||||
fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n",
|
||||
to_h);
|
||||
fprintf (to_h, "#ifndef %sHEADER_H\n", prefix);
|
||||
fprintf (to_h, "#define %sHEADER_H 1\n", prefix);
|
||||
fprintf (to_h, "#define %sIN_HEADER 1\n\n", prefix);
|
||||
fprintf (to_h,
|
||||
"m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
|
||||
headerfilename ? headerfilename : "<stdout>");
|
||||
|
||||
}
|
||||
|
||||
fputs (check_4_gnu_m4, to_c);
|
||||
fputs ("m4_changecom`'m4_dnl\n", to_c);
|
||||
fputs ("m4_changequote`'m4_dnl\n", to_c);
|
||||
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c);
|
||||
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
buf = (char *) flex_alloc (readsz);
|
||||
while (fgets (buf, readsz, stdin)) {
|
||||
fputs (buf, to_c);
|
||||
if (write_header)
|
||||
fputs (buf, to_h);
|
||||
}
|
||||
|
||||
if (write_header) {
|
||||
fprintf (to_h, "\n");
|
||||
|
||||
/* write a fake line number. It will get fixed by the linedir filter. */
|
||||
fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n");
|
||||
|
||||
fprintf (to_h, "#undef %sIN_HEADER\n", prefix);
|
||||
fprintf (to_h, "#endif /* %sHEADER_H */\n", prefix);
|
||||
fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h);
|
||||
|
||||
fflush (to_h);
|
||||
if (ferror (to_h))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
(char *) chain->extra);
|
||||
|
||||
else if (fclose (to_h))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
(char *) chain->extra);
|
||||
}
|
||||
|
||||
fflush (to_c);
|
||||
if (ferror (to_c))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
else if (fclose (to_c))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
while (wait (0) > 0) ;
|
||||
|
||||
exit (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Adjust the line numbers in the #line directives of the generated scanner.
|
||||
* After the m4 expansion, the line numbers are incorrect since the m4 macros
|
||||
* can add or remove lines. This only adjusts line numbers for generated code,
|
||||
* not user code. This also happens to be a good place to squeeze multiple
|
||||
* blank lines into a single blank line.
|
||||
*/
|
||||
int filter_fix_linedirs (struct filter *chain)
|
||||
{
|
||||
char *buf;
|
||||
const int readsz = 512;
|
||||
int lineno = 1;
|
||||
bool in_gen = true; /* in generated code */
|
||||
bool last_was_blank = false;
|
||||
|
||||
if (!chain)
|
||||
return 0;
|
||||
|
||||
buf = (char *) flex_alloc (readsz);
|
||||
|
||||
while (fgets (buf, readsz, stdin)) {
|
||||
|
||||
regmatch_t m[10];
|
||||
|
||||
/* Check for #line directive. */
|
||||
if (buf[0] == '#'
|
||||
&& regexec (®ex_linedir, buf, 3, m, 0) == 0) {
|
||||
|
||||
int num;
|
||||
char *fname;
|
||||
|
||||
/* extract the line number and filename */
|
||||
num = regmatch_strtol (&m[1], buf, NULL, 0);
|
||||
fname = regmatch_dup (&m[2], buf);
|
||||
|
||||
if (strcmp
|
||||
(fname, outfilename ? outfilename : "<stdout>")
|
||||
== 0
|
||||
|| strcmp (fname,
|
||||
headerfilename ? headerfilename :
|
||||
"<stdout>") == 0) {
|
||||
/* Adjust the line directives. */
|
||||
in_gen = true;
|
||||
sprintf (buf, "#line %d \"%s\"\n",
|
||||
lineno + 1, fname);
|
||||
free (fname);
|
||||
|
||||
}
|
||||
else {
|
||||
/* it's a #line directive for code we didn't write */
|
||||
in_gen = false;
|
||||
}
|
||||
|
||||
last_was_blank = false;
|
||||
}
|
||||
|
||||
/* squeeze blank lines from generated code */
|
||||
else if (in_gen
|
||||
&& regexec (®ex_blank_line, buf, 0, NULL,
|
||||
0) == 0) {
|
||||
if (last_was_blank)
|
||||
continue;
|
||||
else
|
||||
last_was_blank = true;
|
||||
}
|
||||
|
||||
else {
|
||||
/* it's a line of normal, non-empty code. */
|
||||
last_was_blank = false;
|
||||
}
|
||||
|
||||
fputs (buf, stdout);
|
||||
lineno++;
|
||||
}
|
||||
fflush (stdout);
|
||||
if (ferror (stdout))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
else if (fclose (stdout))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */
|
4060
src/bin/flex/flex.1
4060
src/bin/flex/flex.1
File diff suppressed because it is too large
Load Diff
@ -2,10 +2,10 @@ resource app_version
|
||||
{
|
||||
major = 2,
|
||||
middle = 5,
|
||||
minor = 4,
|
||||
variety = 5,
|
||||
minor = 33,
|
||||
variety = B_APPV_FINAL,
|
||||
internal = 0,
|
||||
short_info = "2.5.4a",
|
||||
long_info = "2.5.4a ©1997 The Free Software Foundation"
|
||||
short_info = "flex",
|
||||
long_info = "flex from http://flex.sourceforge.net/"
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
54
src/bin/flex/flex.spec
Normal file
54
src/bin/flex/flex.spec
Normal file
@ -0,0 +1,54 @@
|
||||
Summary: fast lexical analyzer generator
|
||||
Name: flex
|
||||
Version: 2.5.33
|
||||
Release: 0
|
||||
License: BSD style
|
||||
Group: Development/Tools
|
||||
Source: ftp://ftp.ee.lbl.gov/%{name}-%{version}.tar.gz
|
||||
Prefix: %{_prefix}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}
|
||||
Prereq: /sbin/install-info
|
||||
|
||||
%description
|
||||
The flex program generates scanners. Scanners are programs which can
|
||||
recognize lexical patterns in text. Flex takes pairs of regular
|
||||
expressions and C code as input and generates a C source file as
|
||||
output. The output file is compiled and linked with a library to
|
||||
produce an executable. The executable searches through its input for
|
||||
occurrences of the regular expressions. When a match is found, it
|
||||
executes the corresponding C code. Flex was designed to work with
|
||||
both Yacc and Bison, and is used by many programs as part of their
|
||||
build process.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
|
||||
%build
|
||||
%configure
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%makeinstall
|
||||
rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir
|
||||
|
||||
%clean
|
||||
rm -rf ${RPM_BUILD_ROOT}
|
||||
|
||||
%post
|
||||
/sbin/install-info %{_infodir}/flex.info.gz %{_infodir}/dir
|
||||
|
||||
%postun
|
||||
if [ "$1" = 0 ]; then
|
||||
/sbin/install-info --del %{_infodir}/flex.info.gz %{_infodir}/dir
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc COPYING NEWS README
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man1/*
|
||||
%{_libdir}/*
|
||||
%{_includedir}/FlexLexer.h
|
||||
%{_infodir}/flex.info*
|
||||
%{_datadir}/locale/*
|
54
src/bin/flex/flex.spec.in
Normal file
54
src/bin/flex/flex.spec.in
Normal file
@ -0,0 +1,54 @@
|
||||
Summary: fast lexical analyzer generator
|
||||
Name: flex
|
||||
Version: @VERSION@
|
||||
Release: 0
|
||||
License: BSD style
|
||||
Group: Development/Tools
|
||||
Source: ftp://ftp.ee.lbl.gov/%{name}-%{version}.tar.gz
|
||||
Prefix: %{_prefix}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}
|
||||
Prereq: /sbin/install-info
|
||||
|
||||
%description
|
||||
The flex program generates scanners. Scanners are programs which can
|
||||
recognize lexical patterns in text. Flex takes pairs of regular
|
||||
expressions and C code as input and generates a C source file as
|
||||
output. The output file is compiled and linked with a library to
|
||||
produce an executable. The executable searches through its input for
|
||||
occurrences of the regular expressions. When a match is found, it
|
||||
executes the corresponding C code. Flex was designed to work with
|
||||
both Yacc and Bison, and is used by many programs as part of their
|
||||
build process.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
|
||||
%build
|
||||
%configure
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%makeinstall
|
||||
rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir
|
||||
|
||||
%clean
|
||||
rm -rf ${RPM_BUILD_ROOT}
|
||||
|
||||
%post
|
||||
/sbin/install-info %{_infodir}/flex.info.gz %{_infodir}/dir
|
||||
|
||||
%postun
|
||||
if [ "$1" = 0 ]; then
|
||||
/sbin/install-info --del %{_infodir}/flex.info.gz %{_infodir}/dir
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc COPYING NEWS README
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man1/*
|
||||
%{_libdir}/*
|
||||
%{_includedir}/FlexLexer.h
|
||||
%{_infodir}/flex.info*
|
||||
%{_datadir}/locale/*
|
@ -1,74 +1,88 @@
|
||||
|
||||
/* flexdef - definitions file for flex */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* @(#) $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/flexdef.h,v 1.1 2004/06/14 09:18:17 korli Exp $ (LBL) */
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#ifndef FLEXDEF_H
|
||||
#define FLEXDEF_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#define HAVE_STRING_H 1
|
||||
#define MS_DOS 1
|
||||
#ifndef __STDC__
|
||||
#define __STDC__ 1
|
||||
#endif
|
||||
#pragma warn -pro
|
||||
#pragma warn -rch
|
||||
#pragma warn -use
|
||||
#pragma warn -aus
|
||||
#pragma warn -par
|
||||
#pragma warn -pia
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <setjmp.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAMS_H
|
||||
#include <sys/params.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#define bool int
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
#include <regex.h>
|
||||
#include "flexint.h"
|
||||
|
||||
/* As an aid for the internationalization patch to flex, which
|
||||
* is maintained outside this distribution for copyright reasons.
|
||||
*/
|
||||
#define _(String) (String)
|
||||
/* We use gettext. So, when we write strings which should be translated, we mark them with _() */
|
||||
#ifdef ENABLE_NLS
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif /* HAVE_LOCALE_H */
|
||||
#include "gettext.h"
|
||||
#define _(String) gettext (String)
|
||||
#else
|
||||
#define _(STRING) STRING
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
/* Always be prepared to generate an 8-bit scanner. */
|
||||
#define CSIZE 256
|
||||
@ -118,12 +132,8 @@
|
||||
#define isascii(c) ((c) <= 0177)
|
||||
#endif
|
||||
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define unspecified -1
|
||||
|
||||
|
||||
/* Special chk[] values marking the slots taking by end-of-buffer and action
|
||||
* numbers.
|
||||
*/
|
||||
@ -189,10 +199,10 @@
|
||||
*/
|
||||
#define NIL 0
|
||||
|
||||
#define JAM -1 /* to mark a missing DFA transition */
|
||||
#define JAM -1 /* to mark a missing DFA transition */
|
||||
#define NO_TRANSITION NIL
|
||||
#define UNIQUE -1 /* marks a symbol as an e.c. representative */
|
||||
#define INFINITY -1 /* for x{5,} constructions */
|
||||
#define UNIQUE -1 /* marks a symbol as an e.c. representative */
|
||||
#define INFINITE_REPEAT -1 /* for x{5,} constructions */
|
||||
|
||||
#define INITIAL_MAX_CCLS 100 /* max number of unique character classes */
|
||||
#define MAX_CCLS_INCREMENT 100
|
||||
@ -210,15 +220,16 @@
|
||||
#define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */
|
||||
#define MAX_DFAS_INCREMENT 1000
|
||||
|
||||
#define JAMSTATE -32766 /* marks a reference to the state that always jams */
|
||||
#define JAMSTATE -32766 /* marks a reference to the state that always jams */
|
||||
|
||||
/* Maximum number of NFA states. */
|
||||
#define MAXIMUM_MNS 31999
|
||||
#define MAXIMUM_MNS_LONG 1999999999
|
||||
|
||||
/* Enough so that if it's subtracted from an NFA state number, the result
|
||||
* is guaranteed to be negative.
|
||||
*/
|
||||
#define MARKER_DIFFERENCE (MAXIMUM_MNS+2)
|
||||
#define MARKER_DIFFERENCE (maximum_mns+2)
|
||||
|
||||
/* Maximum number of nxt/chk pairs for non-templates. */
|
||||
#define INITIAL_MAX_XPAIRS 2000
|
||||
@ -234,7 +245,7 @@
|
||||
#define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */
|
||||
|
||||
#define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */
|
||||
#define SAME_TRANS -1 /* transition is the same as "default" entry for state */
|
||||
#define SAME_TRANS -1 /* transition is the same as "default" entry for state */
|
||||
|
||||
/* The following percentages are used to tune table compression:
|
||||
|
||||
@ -288,7 +299,7 @@
|
||||
*/
|
||||
#define PROT_SAVE_SIZE 2000
|
||||
|
||||
#define MSP 50 /* maximum number of saved protos (protos on the proto queue) */
|
||||
#define MSP 50 /* maximum number of saved protos (protos on the proto queue) */
|
||||
|
||||
/* Maximum number of out-transitions a state can have that we'll rummage
|
||||
* around through the interior of the internal fast table looking for a
|
||||
@ -314,30 +325,6 @@
|
||||
|
||||
/* Declarations for global variables. */
|
||||
|
||||
/* Variables for symbol tables:
|
||||
* sctbl - start-condition symbol table
|
||||
* ndtbl - name-definition symbol table
|
||||
* ccltab - character class text symbol table
|
||||
*/
|
||||
|
||||
struct hash_entry
|
||||
{
|
||||
struct hash_entry *prev, *next;
|
||||
char *name;
|
||||
char *str_val;
|
||||
int int_val;
|
||||
} ;
|
||||
|
||||
typedef struct hash_entry **hash_table;
|
||||
|
||||
#define NAME_TABLE_HASH_SIZE 101
|
||||
#define START_COND_HASH_SIZE 101
|
||||
#define CCL_HASH_SIZE 101
|
||||
|
||||
extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
|
||||
extern struct hash_entry *sctbl[START_COND_HASH_SIZE];
|
||||
extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
|
||||
|
||||
/* Variables for flags:
|
||||
* printstats - if true (-v), dump statistics
|
||||
@ -350,6 +337,7 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
* interactive - if true (-I), generate an interactive scanner
|
||||
* caseins - if true (-i), generate a case-insensitive scanner
|
||||
* lex_compat - if true (-l), maximize compatibility with AT&T lex
|
||||
* posix_compat - if true (-X), maximize compatibility with POSIX lex
|
||||
* do_yylineno - if true, generate code to maintain yylineno
|
||||
* useecs - if true (-Ce flag), use equivalence classes
|
||||
* fulltbl - if true (-Cf flag), don't compress the DFA state table
|
||||
@ -363,6 +351,9 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
* listing backing-up states
|
||||
* C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
|
||||
* otherwise, a standard C scanner
|
||||
* reentrant - if true (-R), generate a reentrant C scanner.
|
||||
* bison_bridge_lval - if true (--bison-bridge), bison pure calling convention.
|
||||
* bison_bridge_lloc - if true (--bison-locations), bison yylloc.
|
||||
* long_align - if true (-Ca flag), favor long-word alignment.
|
||||
* use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
|
||||
* otherwise, use fread().
|
||||
@ -384,10 +375,13 @@ extern struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
* reject_really_used - same for REJECT
|
||||
*/
|
||||
|
||||
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
|
||||
extern int interactive, caseins, lex_compat, do_yylineno;
|
||||
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
|
||||
spprdflt;
|
||||
extern int interactive, caseins, lex_compat, posix_compat, do_yylineno;
|
||||
extern int useecs, fulltbl, usemecs, fullspd;
|
||||
extern int gen_line_dirs, performance_report, backing_up_report;
|
||||
extern int reentrant, bison_bridge_lval, bison_bridge_lloc;
|
||||
extern bool ansi_func_defs, ansi_func_protos;
|
||||
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
|
||||
extern int csize;
|
||||
extern int yymore_used, reject, real_reject, continued_action, in_rule;
|
||||
@ -408,6 +402,7 @@ extern int yymore_really_used, reject_really_used;
|
||||
* backing_up_file - file to summarize backing-up states to
|
||||
* infilename - name of input file
|
||||
* outfilename - name of output file
|
||||
* headerfilename - name of the .h file to generate
|
||||
* did_outfilename - whether outfilename was explicitly set
|
||||
* prefix - the prefix used for externally visible names ("yy" by default)
|
||||
* yyclass - yyFlexLexer subclass to use for YY_DECL
|
||||
@ -431,7 +426,7 @@ extern int datapos, dataline, linenum, out_linenum;
|
||||
extern FILE *skelfile, *yyin, *backing_up_file;
|
||||
extern const char *skel[];
|
||||
extern int skel_ind;
|
||||
extern char *infilename, *outfilename;
|
||||
extern char *infilename, *outfilename, *headerfilename;
|
||||
extern int did_outfilename;
|
||||
extern char *prefix, *yyclass;
|
||||
extern int do_stdinit, use_stdout;
|
||||
@ -457,6 +452,7 @@ extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
|
||||
|
||||
|
||||
/* Variables for nfa machine data:
|
||||
* maximum_mns - maximal number of NFA states supported by tables
|
||||
* current_mns - current maximum on number of NFA states
|
||||
* num_rules - number of the last accepting state; also is number of
|
||||
* rules created so far
|
||||
@ -483,13 +479,18 @@ extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
|
||||
* context
|
||||
* rule_linenum - line number associated with rule
|
||||
* rule_useful - true if we've determined that the rule can be matched
|
||||
* rule_has_nl - true if rule could possibly match a newline
|
||||
* ccl_has_nl - true if current ccl could match a newline
|
||||
* nlch - default eol char
|
||||
*/
|
||||
|
||||
extern int current_mns, current_max_rules;
|
||||
extern int maximum_mns, current_mns, current_max_rules;
|
||||
extern int num_rules, num_eof_rules, default_rule, lastnfa;
|
||||
extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
|
||||
extern int *accptnum, *assoc_rule, *state_type;
|
||||
extern int *rule_type, *rule_linenum, *rule_useful;
|
||||
extern bool *rule_has_nl, *ccl_has_nl;
|
||||
extern int nlch;
|
||||
|
||||
/* Different types of states; values are useful as masks, as well, for
|
||||
* routines like check_trailing_context().
|
||||
@ -600,12 +601,12 @@ extern char **scname;
|
||||
extern int current_max_dfa_size, current_max_xpairs;
|
||||
extern int current_max_template_xpairs, current_max_dfas;
|
||||
extern int lastdfa, *nxt, *chk, *tnxt;
|
||||
extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
|
||||
extern union dfaacc_union
|
||||
{
|
||||
int *dfaacc_set;
|
||||
int dfaacc_state;
|
||||
} *dfaacc;
|
||||
extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss,
|
||||
*dfasiz;
|
||||
extern union dfaacc_union {
|
||||
int *dfaacc_set;
|
||||
int dfaacc_state;
|
||||
} *dfaacc;
|
||||
extern int *accsiz, *dhash, numas;
|
||||
extern int numsnpairs, jambase, jamstate;
|
||||
extern int end_of_buffer_state;
|
||||
@ -652,12 +653,12 @@ extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
|
||||
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
|
||||
extern int num_backing_up, bol_needed;
|
||||
|
||||
void *allocate_array PROTO((int, size_t));
|
||||
void *reallocate_array PROTO((void*, int, size_t));
|
||||
void *allocate_array PROTO ((int, size_t));
|
||||
void *reallocate_array PROTO ((void *, int, size_t));
|
||||
|
||||
void *flex_alloc PROTO((size_t));
|
||||
void *flex_realloc PROTO((void*, size_t));
|
||||
void flex_free PROTO((void*));
|
||||
void *flex_alloc PROTO ((size_t));
|
||||
void *flex_realloc PROTO ((void *, size_t));
|
||||
void flex_free PROTO ((void *));
|
||||
|
||||
#define allocate_integer_array(size) \
|
||||
(int *) allocate_array( size, sizeof( int ) )
|
||||
@ -665,6 +666,12 @@ void flex_free PROTO((void*));
|
||||
#define reallocate_integer_array(array,size) \
|
||||
(int *) reallocate_array( (void *) array, size, sizeof( int ) )
|
||||
|
||||
#define allocate_bool_array(size) \
|
||||
(bool *) allocate_array( size, sizeof( bool ) )
|
||||
|
||||
#define reallocate_bool_array(array,size) \
|
||||
(bool *) reallocate_array( (void *) array, size, sizeof( bool ) )
|
||||
|
||||
#define allocate_int_ptr_array(size) \
|
||||
(int **) allocate_array( size, sizeof( int * ) )
|
||||
|
||||
@ -709,340 +716,467 @@ extern int yylval;
|
||||
|
||||
/* from file ccl.c */
|
||||
|
||||
extern void ccladd PROTO((int, int)); /* add a single character to a ccl */
|
||||
extern int cclinit PROTO((void)); /* make an empty ccl */
|
||||
extern void cclnegate PROTO((int)); /* negate a ccl */
|
||||
extern void ccladd PROTO ((int, int)); /* add a single character to a ccl */
|
||||
extern int cclinit PROTO ((void)); /* make an empty ccl */
|
||||
extern void cclnegate PROTO ((int)); /* negate a ccl */
|
||||
|
||||
/* List the members of a set of characters in CCL form. */
|
||||
extern void list_character_set PROTO((FILE*, int[]));
|
||||
extern void list_character_set PROTO ((FILE *, int[]));
|
||||
|
||||
|
||||
/* from file dfa.c */
|
||||
|
||||
/* Check a DFA state for backing up. */
|
||||
extern void check_for_backing_up PROTO((int, int[]));
|
||||
extern void check_for_backing_up PROTO ((int, int[]));
|
||||
|
||||
/* Check to see if NFA state set constitutes "dangerous" trailing context. */
|
||||
extern void check_trailing_context PROTO((int*, int, int*, int));
|
||||
extern void check_trailing_context PROTO ((int *, int, int *, int));
|
||||
|
||||
/* Construct the epsilon closure of a set of ndfa states. */
|
||||
extern int *epsclosure PROTO((int*, int*, int[], int*, int*));
|
||||
extern int *epsclosure PROTO ((int *, int *, int[], int *, int *));
|
||||
|
||||
/* Increase the maximum number of dfas. */
|
||||
extern void increase_max_dfas PROTO((void));
|
||||
extern void increase_max_dfas PROTO ((void));
|
||||
|
||||
extern void ntod PROTO((void)); /* convert a ndfa to a dfa */
|
||||
extern void ntod PROTO ((void)); /* convert a ndfa to a dfa */
|
||||
|
||||
/* Converts a set of ndfa states into a dfa state. */
|
||||
extern int snstods PROTO((int[], int, int[], int, int, int*));
|
||||
extern int snstods PROTO ((int[], int, int[], int, int, int *));
|
||||
|
||||
|
||||
/* from file ecs.c */
|
||||
|
||||
/* Convert character classes to set of equivalence classes. */
|
||||
extern void ccl2ecl PROTO((void));
|
||||
extern void ccl2ecl PROTO ((void));
|
||||
|
||||
/* Associate equivalence class numbers with class members. */
|
||||
extern int cre8ecs PROTO((int[], int[], int));
|
||||
extern int cre8ecs PROTO ((int[], int[], int));
|
||||
|
||||
/* Update equivalence classes based on character class transitions. */
|
||||
extern void mkeccl PROTO((Char[], int, int[], int[], int, int));
|
||||
extern void mkeccl PROTO ((Char[], int, int[], int[], int, int));
|
||||
|
||||
/* Create equivalence class for single character. */
|
||||
extern void mkechar PROTO((int, int[], int[]));
|
||||
extern void mkechar PROTO ((int, int[], int[]));
|
||||
|
||||
|
||||
/* from file gen.c */
|
||||
|
||||
extern void do_indent PROTO((void)); /* indent to the current level */
|
||||
extern void do_indent PROTO ((void)); /* indent to the current level */
|
||||
|
||||
/* Generate the code to keep backing-up information. */
|
||||
extern void gen_backing_up PROTO((void));
|
||||
extern void gen_backing_up PROTO ((void));
|
||||
|
||||
/* Generate the code to perform the backing up. */
|
||||
extern void gen_bu_action PROTO((void));
|
||||
extern void gen_bu_action PROTO ((void));
|
||||
|
||||
/* Generate full speed compressed transition table. */
|
||||
extern void genctbl PROTO((void));
|
||||
extern void genctbl PROTO ((void));
|
||||
|
||||
/* Generate the code to find the action number. */
|
||||
extern void gen_find_action PROTO((void));
|
||||
extern void gen_find_action PROTO ((void));
|
||||
|
||||
extern void genftbl PROTO((void)); /* generate full transition table */
|
||||
extern void genftbl PROTO ((void)); /* generate full transition table */
|
||||
|
||||
/* Generate the code to find the next compressed-table state. */
|
||||
extern void gen_next_compressed_state PROTO((char*));
|
||||
extern void gen_next_compressed_state PROTO ((char *));
|
||||
|
||||
/* Generate the code to find the next match. */
|
||||
extern void gen_next_match PROTO((void));
|
||||
extern void gen_next_match PROTO ((void));
|
||||
|
||||
/* Generate the code to find the next state. */
|
||||
extern void gen_next_state PROTO((int));
|
||||
extern void gen_next_state PROTO ((int));
|
||||
|
||||
/* Generate the code to make a NUL transition. */
|
||||
extern void gen_NUL_trans PROTO((void));
|
||||
extern void gen_NUL_trans PROTO ((void));
|
||||
|
||||
/* Generate the code to find the start state. */
|
||||
extern void gen_start_state PROTO((void));
|
||||
extern void gen_start_state PROTO ((void));
|
||||
|
||||
/* Generate data statements for the transition tables. */
|
||||
extern void gentabs PROTO((void));
|
||||
extern void gentabs PROTO ((void));
|
||||
|
||||
/* Write out a formatted string at the current indentation level. */
|
||||
extern void indent_put2s PROTO((char[], char[]));
|
||||
extern void indent_put2s PROTO ((const char *, const char *));
|
||||
|
||||
/* Write out a string + newline at the current indentation level. */
|
||||
extern void indent_puts PROTO((char[]));
|
||||
extern void indent_puts PROTO ((const char *));
|
||||
|
||||
extern void make_tables PROTO((void)); /* generate transition tables */
|
||||
extern void make_tables PROTO ((void)); /* generate transition tables */
|
||||
|
||||
|
||||
/* from file main.c */
|
||||
|
||||
extern void check_options PROTO((void));
|
||||
extern void flexend PROTO((int));
|
||||
extern void usage PROTO((void));
|
||||
extern void check_options PROTO ((void));
|
||||
extern void flexend PROTO ((int));
|
||||
extern void usage PROTO ((void));
|
||||
|
||||
|
||||
/* from file misc.c */
|
||||
|
||||
/* Add a #define to the action file. */
|
||||
extern void action_define PROTO(( char *defname, int value ));
|
||||
extern void action_define PROTO ((const char *defname, int value));
|
||||
|
||||
/* Add the given text to the stored actions. */
|
||||
extern void add_action PROTO(( char *new_text ));
|
||||
extern void add_action PROTO ((char *new_text));
|
||||
|
||||
/* True if a string is all lower case. */
|
||||
extern int all_lower PROTO((register char *));
|
||||
extern int all_lower PROTO ((register char *));
|
||||
|
||||
/* True if a string is all upper case. */
|
||||
extern int all_upper PROTO((register char *));
|
||||
extern int all_upper PROTO ((register char *));
|
||||
|
||||
/* Bubble sort an integer array. */
|
||||
extern void bubble PROTO((int [], int));
|
||||
extern void bubble PROTO ((int[], int));
|
||||
|
||||
/* Check a character to make sure it's in the expected range. */
|
||||
extern void check_char PROTO((int c));
|
||||
extern void check_char PROTO ((int c));
|
||||
|
||||
/* Replace upper-case letter to lower-case. */
|
||||
extern Char clower PROTO((int));
|
||||
extern Char clower PROTO ((int));
|
||||
|
||||
/* Returns a dynamically allocated copy of a string. */
|
||||
extern char *copy_string PROTO((register const char *));
|
||||
extern char *copy_string PROTO ((register const char *));
|
||||
|
||||
/* Returns a dynamically allocated copy of a (potentially) unsigned string. */
|
||||
extern Char *copy_unsigned_string PROTO((register Char *));
|
||||
extern Char *copy_unsigned_string PROTO ((register Char *));
|
||||
|
||||
/* Shell sort a character array. */
|
||||
extern void cshell PROTO((Char [], int, int));
|
||||
extern void cshell PROTO ((Char[], int, int));
|
||||
|
||||
/* Finish up a block of data declarations. */
|
||||
extern void dataend PROTO((void));
|
||||
extern void dataend PROTO ((void));
|
||||
|
||||
/* Flush generated data statements. */
|
||||
extern void dataflush PROTO((void));
|
||||
extern void dataflush PROTO ((void));
|
||||
|
||||
/* Report an error message and terminate. */
|
||||
extern void flexerror PROTO((const char[]));
|
||||
extern void flexerror PROTO ((const char *));
|
||||
|
||||
/* Report a fatal error message and terminate. */
|
||||
extern void flexfatal PROTO((const char[]));
|
||||
extern void flexfatal PROTO ((const char *));
|
||||
|
||||
/* Report a fatal error with a pinpoint, and terminate */
|
||||
#if HAVE_DECL___FUNC__
|
||||
#define flex_die(msg) \
|
||||
do{ \
|
||||
fprintf (stderr,\
|
||||
_("%s: fatal internal error at %s:%d (%s): %s\n"),\
|
||||
program_name, __FILE__, (int)__LINE__,\
|
||||
__func__,msg);\
|
||||
FLEX_EXIT(1);\
|
||||
}while(0)
|
||||
#else /* ! HAVE_DECL___FUNC__ */
|
||||
#define flex_die(msg) \
|
||||
do{ \
|
||||
fprintf (stderr,\
|
||||
_("%s: fatal internal error at %s:%d %s\n"),\
|
||||
program_name, __FILE__, (int)__LINE__,\
|
||||
msg);\
|
||||
FLEX_EXIT(1);\
|
||||
}while(0)
|
||||
#endif /* ! HAVE_DECL___func__ */
|
||||
|
||||
/* Convert a hexadecimal digit string to an integer value. */
|
||||
extern int htoi PROTO((Char[]));
|
||||
extern int htoi PROTO ((Char[]));
|
||||
|
||||
/* Report an error message formatted with one integer argument. */
|
||||
extern void lerrif PROTO((const char[], int));
|
||||
extern void lerrif PROTO ((const char *, int));
|
||||
|
||||
/* Report an error message formatted with one string argument. */
|
||||
extern void lerrsf PROTO((const char[], const char[]));
|
||||
extern void lerrsf PROTO ((const char *, const char *));
|
||||
|
||||
/* Spit out a "#line" statement. */
|
||||
extern void line_directive_out PROTO((FILE*, int));
|
||||
extern void line_directive_out PROTO ((FILE *, int));
|
||||
|
||||
/* Mark the current position in the action array as the end of the section 1
|
||||
* user defs.
|
||||
*/
|
||||
extern void mark_defs1 PROTO((void));
|
||||
extern void mark_defs1 PROTO ((void));
|
||||
|
||||
/* Mark the current position in the action array as the end of the prolog. */
|
||||
extern void mark_prolog PROTO((void));
|
||||
extern void mark_prolog PROTO ((void));
|
||||
|
||||
/* Generate a data statment for a two-dimensional array. */
|
||||
extern void mk2data PROTO((int));
|
||||
extern void mk2data PROTO ((int));
|
||||
|
||||
extern void mkdata PROTO((int)); /* generate a data statement */
|
||||
extern void mkdata PROTO ((int)); /* generate a data statement */
|
||||
|
||||
/* Return the integer represented by a string of digits. */
|
||||
extern int myctoi PROTO((char []));
|
||||
extern int myctoi PROTO ((const char *));
|
||||
|
||||
/* Return character corresponding to escape sequence. */
|
||||
extern Char myesc PROTO((Char[]));
|
||||
extern Char myesc PROTO ((Char[]));
|
||||
|
||||
/* Convert an octal digit string to an integer value. */
|
||||
extern int otoi PROTO((Char [] ));
|
||||
extern int otoi PROTO ((Char[]));
|
||||
|
||||
/* Output a (possibly-formatted) string to the generated scanner. */
|
||||
extern void out PROTO((const char []));
|
||||
extern void out_dec PROTO((const char [], int));
|
||||
extern void out_dec2 PROTO((const char [], int, int));
|
||||
extern void out_hex PROTO((const char [], unsigned int));
|
||||
extern void out_line_count PROTO((const char []));
|
||||
extern void out_str PROTO((const char [], const char []));
|
||||
extern void out PROTO ((const char *));
|
||||
extern void out_dec PROTO ((const char *, int));
|
||||
extern void out_dec2 PROTO ((const char *, int, int));
|
||||
extern void out_hex PROTO ((const char *, unsigned int));
|
||||
extern void out_line_count PROTO ((const char *));
|
||||
extern void out_str PROTO ((const char *, const char *));
|
||||
extern void out_str3
|
||||
PROTO((const char [], const char [], const char [], const char []));
|
||||
extern void out_str_dec PROTO((const char [], const char [], int));
|
||||
extern void outc PROTO((int));
|
||||
extern void outn PROTO((const char []));
|
||||
PROTO ((const char *, const char *, const char *, const char *));
|
||||
extern void out_str_dec PROTO ((const char *, const char *, int));
|
||||
extern void outc PROTO ((int));
|
||||
extern void outn PROTO ((const char *));
|
||||
extern void out_m4_define (const char* def, const char* val);
|
||||
|
||||
/* Return a printable version of the given character, which might be
|
||||
* 8-bit.
|
||||
*/
|
||||
extern char *readable_form PROTO((int));
|
||||
extern char *readable_form PROTO ((int));
|
||||
|
||||
/* Write out one section of the skeleton file. */
|
||||
extern void skelout PROTO((void));
|
||||
extern void skelout PROTO ((void));
|
||||
|
||||
/* Output a yy_trans_info structure. */
|
||||
extern void transition_struct_out PROTO((int, int));
|
||||
extern void transition_struct_out PROTO ((int, int));
|
||||
|
||||
/* Only needed when using certain broken versions of bison to build parse.c. */
|
||||
extern void *yy_flex_xmalloc PROTO(( int ));
|
||||
extern void *yy_flex_xmalloc PROTO ((int));
|
||||
|
||||
/* Set a region of memory to 0. */
|
||||
extern void zero_out PROTO((char *, size_t));
|
||||
extern void zero_out PROTO ((char *, size_t));
|
||||
|
||||
|
||||
/* from file nfa.c */
|
||||
|
||||
/* Add an accepting state to a machine. */
|
||||
extern void add_accept PROTO((int, int));
|
||||
extern void add_accept PROTO ((int, int));
|
||||
|
||||
/* Make a given number of copies of a singleton machine. */
|
||||
extern int copysingl PROTO((int, int));
|
||||
extern int copysingl PROTO ((int, int));
|
||||
|
||||
/* Debugging routine to write out an nfa. */
|
||||
extern void dumpnfa PROTO((int));
|
||||
extern void dumpnfa PROTO ((int));
|
||||
|
||||
/* Finish up the processing for a rule. */
|
||||
extern void finish_rule PROTO((int, int, int, int));
|
||||
extern void finish_rule PROTO ((int, int, int, int, int));
|
||||
|
||||
/* Connect two machines together. */
|
||||
extern int link_machines PROTO((int, int));
|
||||
extern int link_machines PROTO ((int, int));
|
||||
|
||||
/* Mark each "beginning" state in a machine as being a "normal" (i.e.,
|
||||
* not trailing context associated) state.
|
||||
*/
|
||||
extern void mark_beginning_as_normal PROTO((register int));
|
||||
extern void mark_beginning_as_normal PROTO ((register int));
|
||||
|
||||
/* Make a machine that branches to two machines. */
|
||||
extern int mkbranch PROTO((int, int));
|
||||
extern int mkbranch PROTO ((int, int));
|
||||
|
||||
extern int mkclos PROTO((int)); /* convert a machine into a closure */
|
||||
extern int mkopt PROTO((int)); /* make a machine optional */
|
||||
extern int mkclos PROTO ((int)); /* convert a machine into a closure */
|
||||
extern int mkopt PROTO ((int)); /* make a machine optional */
|
||||
|
||||
/* Make a machine that matches either one of two machines. */
|
||||
extern int mkor PROTO((int, int));
|
||||
extern int mkor PROTO ((int, int));
|
||||
|
||||
/* Convert a machine into a positive closure. */
|
||||
extern int mkposcl PROTO((int));
|
||||
extern int mkposcl PROTO ((int));
|
||||
|
||||
extern int mkrep PROTO((int, int, int)); /* make a replicated machine */
|
||||
extern int mkrep PROTO ((int, int, int)); /* make a replicated machine */
|
||||
|
||||
/* Create a state with a transition on a given symbol. */
|
||||
extern int mkstate PROTO((int));
|
||||
extern int mkstate PROTO ((int));
|
||||
|
||||
extern void new_rule PROTO((void)); /* initialize for a new rule */
|
||||
extern void new_rule PROTO ((void)); /* initialize for a new rule */
|
||||
|
||||
|
||||
/* from file parse.y */
|
||||
|
||||
/* Build the "<<EOF>>" action for the active start conditions. */
|
||||
extern void build_eof_action PROTO((void));
|
||||
extern void build_eof_action PROTO ((void));
|
||||
|
||||
/* Write out a message formatted with one string, pinpointing its location. */
|
||||
extern void format_pinpoint_message PROTO((char[], char[]));
|
||||
extern void format_pinpoint_message PROTO ((const char *, const char *));
|
||||
|
||||
/* Write out a message, pinpointing its location. */
|
||||
extern void pinpoint_message PROTO((char[]));
|
||||
extern void pinpoint_message PROTO ((const char *));
|
||||
|
||||
/* Write out a warning, pinpointing it at the given line. */
|
||||
extern void line_warning PROTO(( char[], int ));
|
||||
extern void line_warning PROTO ((const char *, int));
|
||||
|
||||
/* Write out a message, pinpointing it at the given line. */
|
||||
extern void line_pinpoint PROTO(( char[], int ));
|
||||
extern void line_pinpoint PROTO ((const char *, int));
|
||||
|
||||
/* Report a formatted syntax error. */
|
||||
extern void format_synerr PROTO((char [], char[]));
|
||||
extern void synerr PROTO((char [])); /* report a syntax error */
|
||||
extern void format_warn PROTO((char [], char[]));
|
||||
extern void warn PROTO((char [])); /* report a warning */
|
||||
extern void yyerror PROTO((char [])); /* report a parse error */
|
||||
extern int yyparse PROTO((void)); /* the YACC parser */
|
||||
extern void format_synerr PROTO ((const char *, const char *));
|
||||
extern void synerr PROTO ((const char *)); /* report a syntax error */
|
||||
extern void format_warn PROTO ((const char *, const char *));
|
||||
extern void warn PROTO ((const char *)); /* report a warning */
|
||||
extern void yyerror PROTO ((const char *)); /* report a parse error */
|
||||
extern int yyparse PROTO ((void)); /* the YACC parser */
|
||||
|
||||
|
||||
/* from file scan.l */
|
||||
|
||||
/* The Flex-generated scanner for flex. */
|
||||
extern int flexscan PROTO((void));
|
||||
extern int flexscan PROTO ((void));
|
||||
|
||||
/* Open the given file (if NULL, stdin) for scanning. */
|
||||
extern void set_input_file PROTO((char*));
|
||||
extern void set_input_file PROTO ((char *));
|
||||
|
||||
/* Wrapup a file in the lexical analyzer. */
|
||||
extern int yywrap PROTO((void));
|
||||
extern int yywrap PROTO ((void));
|
||||
|
||||
|
||||
/* from file sym.c */
|
||||
|
||||
/* Add symbol and definitions to symbol table. */
|
||||
extern int addsym PROTO((register char[], char*, int, hash_table, int));
|
||||
|
||||
/* Save the text of a character class. */
|
||||
extern void cclinstal PROTO ((Char [], int));
|
||||
extern void cclinstal PROTO ((Char[], int));
|
||||
|
||||
/* Lookup the number associated with character class. */
|
||||
extern int ccllookup PROTO((Char []));
|
||||
extern int ccllookup PROTO ((Char[]));
|
||||
|
||||
/* Find symbol in symbol table. */
|
||||
extern struct hash_entry *findsym PROTO((register char[], hash_table, int ));
|
||||
|
||||
extern void ndinstal PROTO((char[], Char[])); /* install a name definition */
|
||||
extern Char *ndlookup PROTO((char[])); /* lookup a name definition */
|
||||
extern void ndinstal PROTO ((const char *, Char[])); /* install a name definition */
|
||||
extern Char *ndlookup PROTO ((const char *)); /* lookup a name definition */
|
||||
|
||||
/* Increase maximum number of SC's. */
|
||||
extern void scextend PROTO((void));
|
||||
extern void scinstal PROTO((char[], int)); /* make a start condition */
|
||||
extern void scextend PROTO ((void));
|
||||
extern void scinstal PROTO ((const char *, int)); /* make a start condition */
|
||||
|
||||
/* Lookup the number associated with a start condition. */
|
||||
extern int sclookup PROTO((char[]));
|
||||
extern int sclookup PROTO ((const char *));
|
||||
|
||||
|
||||
/* from file tblcmp.c */
|
||||
|
||||
/* Build table entries for dfa state. */
|
||||
extern void bldtbl PROTO((int[], int, int, int, int));
|
||||
extern void bldtbl PROTO ((int[], int, int, int, int));
|
||||
|
||||
extern void cmptmps PROTO ((void)); /* compress template table entries */
|
||||
extern void expand_nxt_chk PROTO ((void)); /* increase nxt/chk arrays */
|
||||
|
||||
extern void cmptmps PROTO((void)); /* compress template table entries */
|
||||
extern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */
|
||||
/* Finds a space in the table for a state to be placed. */
|
||||
extern int find_table_space PROTO((int*, int));
|
||||
extern void inittbl PROTO((void)); /* initialize transition tables */
|
||||
extern int find_table_space PROTO ((int *, int));
|
||||
extern void inittbl PROTO ((void)); /* initialize transition tables */
|
||||
|
||||
/* Make the default, "jam" table entries. */
|
||||
extern void mkdeftbl PROTO((void));
|
||||
extern void mkdeftbl PROTO ((void));
|
||||
|
||||
/* Create table entries for a state (or state fragment) which has
|
||||
* only one out-transition.
|
||||
*/
|
||||
extern void mk1tbl PROTO((int, int, int, int));
|
||||
extern void mk1tbl PROTO ((int, int, int, int));
|
||||
|
||||
/* Place a state into full speed transition table. */
|
||||
extern void place_state PROTO((int*, int, int));
|
||||
extern void place_state PROTO ((int *, int, int));
|
||||
|
||||
/* Save states with only one out-transition to be processed later. */
|
||||
extern void stack1 PROTO((int, int, int, int));
|
||||
extern void stack1 PROTO ((int, int, int, int));
|
||||
|
||||
|
||||
/* from file yylex.c */
|
||||
|
||||
extern int yylex PROTO((void));
|
||||
extern int yylex PROTO ((void));
|
||||
|
||||
/* A growable array. See buf.c. */
|
||||
struct Buf {
|
||||
void *elts; /* elements. */
|
||||
int nelts; /* number of elements. */
|
||||
size_t elt_size; /* in bytes. */
|
||||
int nmax; /* max capacity of elements. */
|
||||
};
|
||||
|
||||
extern void buf_init PROTO ((struct Buf * buf, size_t elem_size));
|
||||
extern void buf_destroy PROTO ((struct Buf * buf));
|
||||
extern struct Buf *buf_append
|
||||
PROTO ((struct Buf * buf, const void *ptr, int n_elem));
|
||||
extern struct Buf *buf_concat PROTO((struct Buf* dest, const struct Buf* src));
|
||||
extern struct Buf *buf_strappend PROTO ((struct Buf *, const char *str));
|
||||
extern struct Buf *buf_strnappend
|
||||
PROTO ((struct Buf *, const char *str, int nchars));
|
||||
extern struct Buf *buf_strdefine
|
||||
PROTO ((struct Buf * buf, const char *str, const char *def));
|
||||
extern struct Buf *buf_prints PROTO((struct Buf *buf, const char *fmt, const char* s));
|
||||
extern struct Buf *buf_m4_define PROTO((struct Buf *buf, const char* def, const char* val));
|
||||
extern struct Buf *buf_m4_undefine PROTO((struct Buf *buf, const char* def));
|
||||
extern struct Buf *buf_print_strings PROTO((struct Buf * buf, FILE* out));
|
||||
extern struct Buf *buf_linedir PROTO((struct Buf *buf, const char* filename, int lineno));
|
||||
|
||||
extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */
|
||||
extern struct Buf defs_buf; /* a char* buffer to save #define'd some symbols generated by flex. */
|
||||
extern struct Buf yydmap_buf; /* a string buffer to hold yydmap elements */
|
||||
extern struct Buf m4defs_buf; /* Holds m4 definitions. */
|
||||
extern struct Buf top_buf; /* contains %top code. String buffer. */
|
||||
|
||||
/* For blocking out code from the header file. */
|
||||
#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[")
|
||||
#define OUT_END_CODE() outn("]])")
|
||||
|
||||
/* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */
|
||||
extern jmp_buf flex_main_jmp_buf;
|
||||
|
||||
#define FLEX_EXIT(status) longjmp(flex_main_jmp_buf,(status)+1)
|
||||
|
||||
/* Removes all \n and \r chars from tail of str. returns str. */
|
||||
extern char *chomp (char *str);
|
||||
|
||||
/* ctype functions forced to return boolean */
|
||||
#define b_isalnum(c) (isalnum(c)?true:false)
|
||||
#define b_isalpha(c) (isalpha(c)?true:false)
|
||||
#define b_isascii(c) (isascii(c)?true:false)
|
||||
#define b_isblank(c) (isblank(c)?true:false)
|
||||
#define b_iscntrl(c) (iscntrl(c)?true:false)
|
||||
#define b_isdigit(c) (isdigit(c)?true:false)
|
||||
#define b_isgraph(c) (isgraph(c)?true:false)
|
||||
#define b_islower(c) (islower(c)?true:false)
|
||||
#define b_isprint(c) (isprint(c)?true:false)
|
||||
#define b_ispunct(c) (ispunct(c)?true:false)
|
||||
#define b_isspace(c) (isspace(c)?true:false)
|
||||
#define b_isupper(c) (isupper(c)?true:false)
|
||||
#define b_isxdigit(c) (isxdigit(c)?true:false)
|
||||
|
||||
/* return true if char is uppercase or lowercase. */
|
||||
bool has_case(int c);
|
||||
|
||||
/* Change case of character if possible. */
|
||||
int reverse_case(int c);
|
||||
|
||||
/* return false if [c1-c2] is ambiguous for a caseless scanner. */
|
||||
bool range_covers_case (int c1, int c2);
|
||||
|
||||
/*
|
||||
* From "filter.c"
|
||||
*/
|
||||
|
||||
/** A single stdio filter to execute.
|
||||
* The filter may be external, such as "sed", or it
|
||||
* may be internal, as a function call.
|
||||
*/
|
||||
struct filter {
|
||||
int (*filter_func)(struct filter*); /**< internal filter function */
|
||||
void * extra; /**< extra data passed to filter_func */
|
||||
int argc; /**< arg count */
|
||||
const char ** argv; /**< arg vector, \0-terminated */
|
||||
struct filter * next; /**< next filter or NULL */
|
||||
};
|
||||
|
||||
/* output filter chain */
|
||||
extern struct filter * output_chain;
|
||||
extern struct filter *filter_create_ext PROTO((struct filter * chain, const char *cmd, ...));
|
||||
struct filter *filter_create_int PROTO((struct filter *chain,
|
||||
int (*filter_func) (struct filter *),
|
||||
void *extra));
|
||||
extern bool filter_apply_chain PROTO((struct filter * chain));
|
||||
extern int filter_truncate (struct filter * chain, int max_len);
|
||||
extern int filter_tee_header PROTO((struct filter *chain));
|
||||
extern int filter_fix_linedirs PROTO((struct filter *chain));
|
||||
|
||||
|
||||
/*
|
||||
* From "regex.c"
|
||||
*/
|
||||
|
||||
extern regex_t regex_linedir, regex_blank_line;
|
||||
bool flex_init_regex(void);
|
||||
void flex_regcomp(regex_t *preg, const char *regex, int cflags);
|
||||
char *regmatch_dup (regmatch_t * m, const char *src);
|
||||
char *regmatch_cpy (regmatch_t * m, char *dest, const char *src);
|
||||
int regmatch_len (regmatch_t * m);
|
||||
int regmatch_strtol (regmatch_t * m, const char *src, char **endptr, int base);
|
||||
bool regmatch_empty (regmatch_t * m);
|
||||
|
||||
#endif /* not defined FLEXDEF_H */
|
||||
|
63
src/bin/flex/flexint.h
Normal file
63
src/bin/flex/flexint.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* flex integer type definitions */
|
||||
|
||||
#ifndef FLEXINT_H
|
||||
#define FLEXINT_H
|
||||
|
||||
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
|
||||
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
|
||||
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
|
||||
* if you want the limit (max/min) macros for int types.
|
||||
*/
|
||||
#ifndef __STDC_LIMIT_MACROS
|
||||
#define __STDC_LIMIT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
typedef int8_t flex_int8_t;
|
||||
typedef uint8_t flex_uint8_t;
|
||||
typedef int16_t flex_int16_t;
|
||||
typedef uint16_t flex_uint16_t;
|
||||
typedef int32_t flex_int32_t;
|
||||
typedef uint32_t flex_uint32_t;
|
||||
#else
|
||||
typedef signed char flex_int8_t;
|
||||
typedef short int flex_int16_t;
|
||||
typedef int flex_int32_t;
|
||||
typedef unsigned char flex_uint8_t;
|
||||
typedef unsigned short int flex_uint16_t;
|
||||
typedef unsigned int flex_uint32_t;
|
||||
#endif /* ! C99 */
|
||||
|
||||
/* Limits of integral types. */
|
||||
#ifndef INT8_MIN
|
||||
#define INT8_MIN (-128)
|
||||
#endif
|
||||
#ifndef INT16_MIN
|
||||
#define INT16_MIN (-32767-1)
|
||||
#endif
|
||||
#ifndef INT32_MIN
|
||||
#define INT32_MIN (-2147483647-1)
|
||||
#endif
|
||||
#ifndef INT8_MAX
|
||||
#define INT8_MAX (127)
|
||||
#endif
|
||||
#ifndef INT16_MAX
|
||||
#define INT16_MAX (32767)
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX (2147483647)
|
||||
#endif
|
||||
#ifndef UINT8_MAX
|
||||
#define UINT8_MAX (255U)
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX (65535U)
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX (4294967295U)
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! FLEXINT_H */
|
2730
src/bin/flex/gen.c
2730
src/bin/flex/gen.c
File diff suppressed because it is too large
Load Diff
59
src/bin/flex/gettext.h
Normal file
59
src/bin/flex/gettext.h
Normal file
@ -0,0 +1,59 @@
|
||||
/* 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)
|
||||
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.
|
||||
|
||||
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. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
File diff suppressed because it is too large
Load Diff
294
src/bin/flex/install-sh
Executable file
294
src/bin/flex/install-sh
Executable file
@ -0,0 +1,294 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
#
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd=$cpprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd=$stripprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "$0: no input file specified" >&2
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d "$dst" ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f "$src" ] || [ -d "$src" ]
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "$0: $src does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "$0: no destination specified" >&2
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d "$dst" ]
|
||||
then
|
||||
dst=$dst/`basename "$src"`
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS=$oIFS
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp=$pathcomp$1
|
||||
shift
|
||||
|
||||
if [ ! -d "$pathcomp" ] ;
|
||||
then
|
||||
$mkdirprog "$pathcomp"
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd "$dst" &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename "$dst"`
|
||||
else
|
||||
dstfile=`basename "$dst" $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename "$dst"`
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
rmtmp=$dstdir/#rm.$$#
|
||||
|
||||
# Trap to clean up temp files at exit.
|
||||
|
||||
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd "$src" "$dsttmp" &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
|
||||
|
||||
# Now remove or move aside any old file at destination location. We try this
|
||||
# two ways since rm can't unlink itself on some systems and the destination
|
||||
# file might be busy for other reasons. In this case, the final cleanup
|
||||
# might fail but the new file should still install successfully.
|
||||
|
||||
{
|
||||
if [ -f "$dstdir/$dstfile" ]
|
||||
then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
|
||||
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
|
||||
{
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
|
||||
fi &&
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
|
||||
{
|
||||
(exit 0); exit
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5; it is not part of GNU.
|
||||
#
|
||||
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
|
||||
instcmd="$mvprog"
|
||||
chmodcmd=""
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dstdir=`dirname $dst`
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd $dst
|
||||
$doit $mvcmd $dsttmp $dst
|
||||
|
||||
|
||||
exit 0
|
@ -1,15 +1,33 @@
|
||||
/* libmain - flex run-time support library "main" function */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/libmain.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This file is part of flex. */
|
||||
|
||||
extern int yylex();
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
int main( argc, argv )
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
while ( yylex() != 0 )
|
||||
;
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
extern int yylex ();
|
||||
|
||||
int main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
while (yylex () != 0) ;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,27 @@
|
||||
/* libyywrap - flex run-time support library "yywrap" function */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/libyywrap.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This file is part of flex. */
|
||||
|
||||
int yywrap()
|
||||
{
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
int yywrap (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
2402
src/bin/flex/main.c
2402
src/bin/flex/main.c
File diff suppressed because it is too large
Load Diff
1177
src/bin/flex/misc.c
1177
src/bin/flex/misc.c
File diff suppressed because it is too large
Load Diff
336
src/bin/flex/missing
Executable file
336
src/bin/flex/missing
Executable file
@ -0,0 +1,336 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# 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 to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing 0.4 - GNU automake"
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aclocal*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and you do not seem to have it handy on your
|
||||
system. You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1Help2man' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
|
||||
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
|
||||
fi
|
||||
if [ -f "$file" ]; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
|
||||
# We have makeinfo, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
|
||||
fi
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar)
|
||||
shift
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case "$firstarg" in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case "$firstarg" in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and you do not seem to have it handy on your
|
||||
system. You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequirements for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -1,35 +1,111 @@
|
||||
#!/bin/sh
|
||||
# Make directory hierarchy.
|
||||
# Written by Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Public domain.
|
||||
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
errstatus=0
|
||||
dirmode=""
|
||||
|
||||
for file in ${1+"$@"} ; do
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
usage="\
|
||||
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
|
||||
|
||||
pathcomp=''
|
||||
# process command line arguments
|
||||
while test $# -gt 0 ; do
|
||||
case $1 in
|
||||
-h | --help | --h*) # -h for help
|
||||
echo "$usage" 1>&2
|
||||
exit 0
|
||||
;;
|
||||
-m) # -m PERM arg
|
||||
shift
|
||||
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
|
||||
dirmode=$1
|
||||
shift
|
||||
;;
|
||||
--) # stop option processing
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*) # unknown option
|
||||
echo "$usage" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
*) # first non-opt arg
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for d in ${1+"$@"} ; do
|
||||
pathcomp="${pathcomp}${d}"
|
||||
for file
|
||||
do
|
||||
if test -d "$file"; then
|
||||
shift
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if test ! -d "${pathcomp}"; then
|
||||
echo "mkdir $pathcomp" 1>&2
|
||||
mkdir "${pathcomp}" || errstatus=$?
|
||||
fi
|
||||
case $# in
|
||||
0) exit 0 ;;
|
||||
esac
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
case $dirmode in
|
||||
'')
|
||||
if mkdir -p -- . 2>/dev/null; then
|
||||
echo "mkdir -p -- $*"
|
||||
exec mkdir -p -- "$@"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
|
||||
echo "mkdir -m $dirmode -p -- $*"
|
||||
exec mkdir -m "$dirmode" -p -- "$@"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case $pathcomp in
|
||||
-*) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
else
|
||||
if test ! -z "$dirmode"; then
|
||||
echo "chmod $dirmode $pathcomp"
|
||||
lasterr=""
|
||||
chmod "$dirmode" "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -z "$lasterr"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# eof
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# End:
|
||||
# mkinstalldirs ends here
|
||||
|
@ -1,5 +1,26 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This file is part of flex.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
|
||||
# Neither the name of the University nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
|
||||
cat <<!
|
||||
/* File created from flex.skl via mkskel.sh */
|
||||
|
||||
@ -8,7 +29,7 @@ cat <<!
|
||||
const char *skel[] = {
|
||||
!
|
||||
|
||||
sed 's/\\/&&/g' $* | sed 's/"/\\"/g' | sed 's/.*/ "&",/'
|
||||
sed 's/\\/&&/g' | sed 's/"/\\"/g' | sed 's/.*/ "&",/'
|
||||
|
||||
cat <<!
|
||||
0
|
||||
|
@ -1,40 +1,43 @@
|
||||
/* nfa - NFA construction routines */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/nfa.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
int dupmachine PROTO((int));
|
||||
void mkxtion PROTO((int, int));
|
||||
int dupmachine PROTO ((int));
|
||||
void mkxtion PROTO ((int, int));
|
||||
|
||||
|
||||
/* add_accept - add an accepting state to a machine
|
||||
@ -42,25 +45,25 @@ void mkxtion PROTO((int, int));
|
||||
* accepting_number becomes mach's accepting number.
|
||||
*/
|
||||
|
||||
void add_accept( mach, accepting_number )
|
||||
int mach, accepting_number;
|
||||
{
|
||||
void add_accept (mach, accepting_number)
|
||||
int mach, accepting_number;
|
||||
{
|
||||
/* Hang the accepting number off an epsilon state. if it is associated
|
||||
* with a state that has a non-epsilon out-transition, then the state
|
||||
* will accept BEFORE it makes that transition, i.e., one character
|
||||
* too soon.
|
||||
*/
|
||||
|
||||
if ( transchar[finalst[mach]] == SYM_EPSILON )
|
||||
if (transchar[finalst[mach]] == SYM_EPSILON)
|
||||
accptnum[finalst[mach]] = accepting_number;
|
||||
|
||||
else
|
||||
{
|
||||
int astate = mkstate( SYM_EPSILON );
|
||||
else {
|
||||
int astate = mkstate (SYM_EPSILON);
|
||||
|
||||
accptnum[astate] = accepting_number;
|
||||
(void) link_machines( mach, astate );
|
||||
}
|
||||
(void) link_machines (mach, astate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* copysingl - make a given number of copies of a singleton machine
|
||||
@ -74,31 +77,32 @@ int mach, accepting_number;
|
||||
* num - the number of copies of singl to be present in newsng
|
||||
*/
|
||||
|
||||
int copysingl( singl, num )
|
||||
int singl, num;
|
||||
{
|
||||
int copy, i;
|
||||
int copysingl (singl, num)
|
||||
int singl, num;
|
||||
{
|
||||
int copy, i;
|
||||
|
||||
copy = mkstate( SYM_EPSILON );
|
||||
copy = mkstate (SYM_EPSILON);
|
||||
|
||||
for ( i = 1; i <= num; ++i )
|
||||
copy = link_machines( copy, dupmachine( singl ) );
|
||||
for (i = 1; i <= num; ++i)
|
||||
copy = link_machines (copy, dupmachine (singl));
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* dumpnfa - debugging routine to write out an nfa */
|
||||
|
||||
void dumpnfa( state1 )
|
||||
int state1;
|
||||
void dumpnfa (state1)
|
||||
int state1;
|
||||
|
||||
{
|
||||
int sym, tsp1, tsp2, anum, ns;
|
||||
{
|
||||
int sym, tsp1, tsp2, anum, ns;
|
||||
|
||||
fprintf( stderr,
|
||||
_( "\n\n********** beginning dump of nfa with start state %d\n" ),
|
||||
state1 );
|
||||
fprintf (stderr,
|
||||
_
|
||||
("\n\n********** beginning dump of nfa with start state %d\n"),
|
||||
state1);
|
||||
|
||||
/* We probably should loop starting at firstst[state1] and going to
|
||||
* lastst[state1], but they're not maintained properly when we "or"
|
||||
@ -107,26 +111,25 @@ int state1;
|
||||
*/
|
||||
|
||||
/* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
|
||||
for ( ns = 1; ns <= lastnfa; ++ns )
|
||||
{
|
||||
fprintf( stderr, _( "state # %4d\t" ), ns );
|
||||
for (ns = 1; ns <= lastnfa; ++ns) {
|
||||
fprintf (stderr, _("state # %4d\t"), ns);
|
||||
|
||||
sym = transchar[ns];
|
||||
tsp1 = trans1[ns];
|
||||
tsp2 = trans2[ns];
|
||||
anum = accptnum[ns];
|
||||
|
||||
fprintf( stderr, "%3d: %4d, %4d", sym, tsp1, tsp2 );
|
||||
fprintf (stderr, "%3d: %4d, %4d", sym, tsp1, tsp2);
|
||||
|
||||
if ( anum != NIL )
|
||||
fprintf( stderr, " [%d]", anum );
|
||||
if (anum != NIL)
|
||||
fprintf (stderr, " [%d]", anum);
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
}
|
||||
|
||||
fprintf( stderr, _( "********** end of dump\n" ) );
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
fprintf (stderr, _("********** end of dump\n"));
|
||||
}
|
||||
|
||||
|
||||
/* dupmachine - make a duplicate of a given machine
|
||||
*
|
||||
@ -145,32 +148,30 @@ int state1;
|
||||
* states accessible by the arrays firstst and lastst
|
||||
*/
|
||||
|
||||
int dupmachine( mach )
|
||||
int mach;
|
||||
{
|
||||
int i, init, state_offset;
|
||||
int state = 0;
|
||||
int last = lastst[mach];
|
||||
int dupmachine (mach)
|
||||
int mach;
|
||||
{
|
||||
int i, init, state_offset;
|
||||
int state = 0;
|
||||
int last = lastst[mach];
|
||||
|
||||
for ( i = firstst[mach]; i <= last; ++i )
|
||||
{
|
||||
state = mkstate( transchar[i] );
|
||||
for (i = firstst[mach]; i <= last; ++i) {
|
||||
state = mkstate (transchar[i]);
|
||||
|
||||
if ( trans1[i] != NO_TRANSITION )
|
||||
{
|
||||
mkxtion( finalst[state], trans1[i] + state - i );
|
||||
if (trans1[i] != NO_TRANSITION) {
|
||||
mkxtion (finalst[state], trans1[i] + state - i);
|
||||
|
||||
if ( transchar[i] == SYM_EPSILON &&
|
||||
trans2[i] != NO_TRANSITION )
|
||||
mkxtion( finalst[state],
|
||||
trans2[i] + state - i );
|
||||
}
|
||||
|
||||
accptnum[state] = accptnum[i];
|
||||
if (transchar[i] == SYM_EPSILON &&
|
||||
trans2[i] != NO_TRANSITION)
|
||||
mkxtion (finalst[state],
|
||||
trans2[i] + state - i);
|
||||
}
|
||||
|
||||
if ( state == 0 )
|
||||
flexfatal( _( "empty machine in dupmachine()" ) );
|
||||
accptnum[state] = accptnum[i];
|
||||
}
|
||||
|
||||
if (state == 0)
|
||||
flexfatal (_("empty machine in dupmachine()"));
|
||||
|
||||
state_offset = state - i + 1;
|
||||
|
||||
@ -180,7 +181,7 @@ int mach;
|
||||
lastst[init] = lastst[mach] + state_offset;
|
||||
|
||||
return init;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* finish_rule - finish up the processing for a rule
|
||||
@ -195,12 +196,13 @@ int mach;
|
||||
* context has variable length.
|
||||
*/
|
||||
|
||||
void finish_rule( mach, variable_trail_rule, headcnt, trailcnt )
|
||||
int mach, variable_trail_rule, headcnt, trailcnt;
|
||||
{
|
||||
char action_text[MAXLINE];
|
||||
void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
|
||||
pcont_act)
|
||||
int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
|
||||
{
|
||||
char action_text[MAXLINE];
|
||||
|
||||
add_accept( mach, num_rules );
|
||||
add_accept (mach, num_rules);
|
||||
|
||||
/* We did this in new_rule(), but it often gets the wrong
|
||||
* number because we do it before we start parsing the current rule.
|
||||
@ -210,68 +212,77 @@ int mach, variable_trail_rule, headcnt, trailcnt;
|
||||
/* If this is a continued action, then the line-number has already
|
||||
* been updated, giving us the wrong number.
|
||||
*/
|
||||
if ( continued_action )
|
||||
if (continued_action)
|
||||
--rule_linenum[num_rules];
|
||||
|
||||
sprintf( action_text, "case %d:\n", num_rules );
|
||||
add_action( action_text );
|
||||
|
||||
if ( variable_trail_rule )
|
||||
{
|
||||
/* If the previous rule was continued action, then we inherit the
|
||||
* previous newline flag, possibly overriding the current one.
|
||||
*/
|
||||
if (pcont_act && rule_has_nl[num_rules - 1])
|
||||
rule_has_nl[num_rules] = true;
|
||||
|
||||
sprintf (action_text, "case %d:\n", num_rules);
|
||||
add_action (action_text);
|
||||
if (rule_has_nl[num_rules]) {
|
||||
sprintf (action_text, "/* rule %d can match eol */\n",
|
||||
num_rules);
|
||||
add_action (action_text);
|
||||
}
|
||||
|
||||
|
||||
if (variable_trail_rule) {
|
||||
rule_type[num_rules] = RULE_VARIABLE;
|
||||
|
||||
if ( performance_report > 0 )
|
||||
fprintf( stderr,
|
||||
_( "Variable trailing context rule at line %d\n" ),
|
||||
rule_linenum[num_rules] );
|
||||
if (performance_report > 0)
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Variable trailing context rule at line %d\n"),
|
||||
rule_linenum[num_rules]);
|
||||
|
||||
variable_trailing_context_rules = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
else {
|
||||
rule_type[num_rules] = RULE_NORMAL;
|
||||
|
||||
if ( headcnt > 0 || trailcnt > 0 )
|
||||
{
|
||||
if (headcnt > 0 || trailcnt > 0) {
|
||||
/* Do trailing context magic to not match the trailing
|
||||
* characters.
|
||||
*/
|
||||
char *scanner_cp = "yy_c_buf_p = yy_cp";
|
||||
char *scanner_bp = "yy_bp";
|
||||
char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp";
|
||||
char *scanner_bp = "yy_bp";
|
||||
|
||||
add_action(
|
||||
"*yy_cp = yy_hold_char; /* undo effects of setting up yytext */\n" );
|
||||
add_action
|
||||
("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n");
|
||||
|
||||
if ( headcnt > 0 )
|
||||
{
|
||||
sprintf( action_text, "%s = %s + %d;\n",
|
||||
scanner_cp, scanner_bp, headcnt );
|
||||
add_action( action_text );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sprintf( action_text, "%s -= %d;\n",
|
||||
scanner_cp, trailcnt );
|
||||
add_action( action_text );
|
||||
}
|
||||
|
||||
add_action(
|
||||
"YY_DO_BEFORE_ACTION; /* set up yytext again */\n" );
|
||||
if (headcnt > 0) {
|
||||
sprintf (action_text, "%s = %s + %d;\n",
|
||||
scanner_cp, scanner_bp, headcnt);
|
||||
add_action (action_text);
|
||||
}
|
||||
|
||||
else {
|
||||
sprintf (action_text, "%s -= %d;\n",
|
||||
scanner_cp, trailcnt);
|
||||
add_action (action_text);
|
||||
}
|
||||
|
||||
add_action
|
||||
("YY_DO_BEFORE_ACTION; /* set up yytext again */\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Okay, in the action code at this point yytext and yyleng have
|
||||
* their proper final values for this rule, so here's the point
|
||||
* to do any user action. But don't do it for continued actions,
|
||||
* as that'll result in multiple YY_RULE_SETUP's.
|
||||
*/
|
||||
if ( ! continued_action )
|
||||
add_action( "YY_RULE_SETUP\n" );
|
||||
if (!continued_action)
|
||||
add_action ("YY_RULE_SETUP\n");
|
||||
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
}
|
||||
line_directive_out ((FILE *) 0, 1);
|
||||
}
|
||||
|
||||
|
||||
/* link_machines - connect two machines together
|
||||
@ -290,25 +301,24 @@ int mach, variable_trail_rule, headcnt, trailcnt;
|
||||
* FIRST is set to new by the operation. last is unmolested.
|
||||
*/
|
||||
|
||||
int link_machines( first, last )
|
||||
int first, last;
|
||||
{
|
||||
if ( first == NIL )
|
||||
int link_machines (first, last)
|
||||
int first, last;
|
||||
{
|
||||
if (first == NIL)
|
||||
return last;
|
||||
|
||||
else if ( last == NIL )
|
||||
else if (last == NIL)
|
||||
return first;
|
||||
|
||||
else
|
||||
{
|
||||
mkxtion( finalst[first], last );
|
||||
else {
|
||||
mkxtion (finalst[first], last);
|
||||
finalst[first] = finalst[last];
|
||||
lastst[first] = MAX( lastst[first], lastst[last] );
|
||||
firstst[first] = MIN( firstst[first], firstst[last] );
|
||||
lastst[first] = MAX (lastst[first], lastst[last]);
|
||||
firstst[first] = MIN (firstst[first], firstst[last]);
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mark_beginning_as_normal - mark each "beginning" state in a machine
|
||||
@ -318,36 +328,32 @@ int first, last;
|
||||
* The "beginning" states are the epsilon closure of the first state
|
||||
*/
|
||||
|
||||
void mark_beginning_as_normal( mach )
|
||||
register int mach;
|
||||
{
|
||||
switch ( state_type[mach] )
|
||||
{
|
||||
case STATE_NORMAL:
|
||||
/* Oh, we've already visited here. */
|
||||
return;
|
||||
void mark_beginning_as_normal (mach)
|
||||
register int mach;
|
||||
{
|
||||
switch (state_type[mach]) {
|
||||
case STATE_NORMAL:
|
||||
/* Oh, we've already visited here. */
|
||||
return;
|
||||
|
||||
case STATE_TRAILING_CONTEXT:
|
||||
state_type[mach] = STATE_NORMAL;
|
||||
case STATE_TRAILING_CONTEXT:
|
||||
state_type[mach] = STATE_NORMAL;
|
||||
|
||||
if ( transchar[mach] == SYM_EPSILON )
|
||||
{
|
||||
if ( trans1[mach] != NO_TRANSITION )
|
||||
mark_beginning_as_normal(
|
||||
trans1[mach] );
|
||||
if (transchar[mach] == SYM_EPSILON) {
|
||||
if (trans1[mach] != NO_TRANSITION)
|
||||
mark_beginning_as_normal (trans1[mach]);
|
||||
|
||||
if ( trans2[mach] != NO_TRANSITION )
|
||||
mark_beginning_as_normal(
|
||||
trans2[mach] );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
flexerror(
|
||||
_( "bad state type in mark_beginning_as_normal()" ) );
|
||||
break;
|
||||
if (trans2[mach] != NO_TRANSITION)
|
||||
mark_beginning_as_normal (trans2[mach]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
flexerror (_
|
||||
("bad state type in mark_beginning_as_normal()"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkbranch - make a machine that branches to two machines
|
||||
@ -364,24 +370,24 @@ register int mach;
|
||||
* more mkbranch's. Compare with mkor()
|
||||
*/
|
||||
|
||||
int mkbranch( first, second )
|
||||
int first, second;
|
||||
{
|
||||
int eps;
|
||||
int mkbranch (first, second)
|
||||
int first, second;
|
||||
{
|
||||
int eps;
|
||||
|
||||
if ( first == NO_TRANSITION )
|
||||
if (first == NO_TRANSITION)
|
||||
return second;
|
||||
|
||||
else if ( second == NO_TRANSITION )
|
||||
else if (second == NO_TRANSITION)
|
||||
return first;
|
||||
|
||||
eps = mkstate( SYM_EPSILON );
|
||||
eps = mkstate (SYM_EPSILON);
|
||||
|
||||
mkxtion( eps, first );
|
||||
mkxtion( eps, second );
|
||||
mkxtion (eps, first);
|
||||
mkxtion (eps, second);
|
||||
|
||||
return eps;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkclos - convert a machine into a closure
|
||||
@ -392,11 +398,11 @@ int first, second;
|
||||
* new - a new state which matches the closure of "state"
|
||||
*/
|
||||
|
||||
int mkclos( state )
|
||||
int state;
|
||||
{
|
||||
return mkopt( mkposcl( state ) );
|
||||
}
|
||||
int mkclos (state)
|
||||
int state;
|
||||
{
|
||||
return mkopt (mkposcl (state));
|
||||
}
|
||||
|
||||
|
||||
/* mkopt - make a machine optional
|
||||
@ -413,28 +419,27 @@ int state;
|
||||
* 2. mach is destroyed by the call
|
||||
*/
|
||||
|
||||
int mkopt( mach )
|
||||
int mach;
|
||||
{
|
||||
int eps;
|
||||
int mkopt (mach)
|
||||
int mach;
|
||||
{
|
||||
int eps;
|
||||
|
||||
if ( ! SUPER_FREE_EPSILON(finalst[mach]) )
|
||||
{
|
||||
eps = mkstate( SYM_EPSILON );
|
||||
mach = link_machines( mach, eps );
|
||||
}
|
||||
if (!SUPER_FREE_EPSILON (finalst[mach])) {
|
||||
eps = mkstate (SYM_EPSILON);
|
||||
mach = link_machines (mach, eps);
|
||||
}
|
||||
|
||||
/* Can't skimp on the following if FREE_EPSILON(mach) is true because
|
||||
* some state interior to "mach" might point back to the beginning
|
||||
* for a closure.
|
||||
*/
|
||||
eps = mkstate( SYM_EPSILON );
|
||||
mach = link_machines( eps, mach );
|
||||
eps = mkstate (SYM_EPSILON);
|
||||
mach = link_machines (eps, mach);
|
||||
|
||||
mkxtion( mach, finalst[mach] );
|
||||
mkxtion (mach, finalst[mach]);
|
||||
|
||||
return mach;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkor - make a machine that matches either one of two machines
|
||||
@ -451,56 +456,52 @@ int mach;
|
||||
* the number of epsilon states needed
|
||||
*/
|
||||
|
||||
int mkor( first, second )
|
||||
int first, second;
|
||||
{
|
||||
int eps, orend;
|
||||
int mkor (first, second)
|
||||
int first, second;
|
||||
{
|
||||
int eps, orend;
|
||||
|
||||
if ( first == NIL )
|
||||
if (first == NIL)
|
||||
return second;
|
||||
|
||||
else if ( second == NIL )
|
||||
else if (second == NIL)
|
||||
return first;
|
||||
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* See comment in mkopt() about why we can't use the first
|
||||
* state of "first" or "second" if they satisfy "FREE_EPSILON".
|
||||
*/
|
||||
eps = mkstate( SYM_EPSILON );
|
||||
eps = mkstate (SYM_EPSILON);
|
||||
|
||||
first = link_machines( eps, first );
|
||||
first = link_machines (eps, first);
|
||||
|
||||
mkxtion( first, second );
|
||||
mkxtion (first, second);
|
||||
|
||||
if ( SUPER_FREE_EPSILON(finalst[first]) &&
|
||||
accptnum[finalst[first]] == NIL )
|
||||
{
|
||||
if (SUPER_FREE_EPSILON (finalst[first]) &&
|
||||
accptnum[finalst[first]] == NIL) {
|
||||
orend = finalst[first];
|
||||
mkxtion( finalst[second], orend );
|
||||
}
|
||||
|
||||
else if ( SUPER_FREE_EPSILON(finalst[second]) &&
|
||||
accptnum[finalst[second]] == NIL )
|
||||
{
|
||||
orend = finalst[second];
|
||||
mkxtion( finalst[first], orend );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
eps = mkstate( SYM_EPSILON );
|
||||
|
||||
first = link_machines( first, eps );
|
||||
orend = finalst[first];
|
||||
|
||||
mkxtion( finalst[second], orend );
|
||||
}
|
||||
mkxtion (finalst[second], orend);
|
||||
}
|
||||
|
||||
else if (SUPER_FREE_EPSILON (finalst[second]) &&
|
||||
accptnum[finalst[second]] == NIL) {
|
||||
orend = finalst[second];
|
||||
mkxtion (finalst[first], orend);
|
||||
}
|
||||
|
||||
else {
|
||||
eps = mkstate (SYM_EPSILON);
|
||||
|
||||
first = link_machines (first, eps);
|
||||
orend = finalst[first];
|
||||
|
||||
mkxtion (finalst[second], orend);
|
||||
}
|
||||
}
|
||||
|
||||
finalst[first] = orend;
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkposcl - convert a machine into a positive closure
|
||||
@ -511,25 +512,23 @@ int first, second;
|
||||
* new - a machine matching the positive closure of "state"
|
||||
*/
|
||||
|
||||
int mkposcl( state )
|
||||
int state;
|
||||
{
|
||||
int eps;
|
||||
int mkposcl (state)
|
||||
int state;
|
||||
{
|
||||
int eps;
|
||||
|
||||
if ( SUPER_FREE_EPSILON(finalst[state]) )
|
||||
{
|
||||
mkxtion( finalst[state], state );
|
||||
if (SUPER_FREE_EPSILON (finalst[state])) {
|
||||
mkxtion (finalst[state], state);
|
||||
return state;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
eps = mkstate( SYM_EPSILON );
|
||||
mkxtion( eps, state );
|
||||
return link_machines( state, eps );
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
eps = mkstate (SYM_EPSILON);
|
||||
mkxtion (eps, state);
|
||||
return link_machines (state, eps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkrep - make a replicated machine
|
||||
*
|
||||
@ -540,38 +539,38 @@ int state;
|
||||
* number of times to "ub" number of times
|
||||
*
|
||||
* note
|
||||
* if "ub" is INFINITY then "new" matches "lb" or more occurrences of "mach"
|
||||
* if "ub" is INFINITE_REPEAT then "new" matches "lb" or more occurrences of "mach"
|
||||
*/
|
||||
|
||||
int mkrep( mach, lb, ub )
|
||||
int mach, lb, ub;
|
||||
{
|
||||
int base_mach, tail, copy, i;
|
||||
int mkrep (mach, lb, ub)
|
||||
int mach, lb, ub;
|
||||
{
|
||||
int base_mach, tail, copy, i;
|
||||
|
||||
base_mach = copysingl( mach, lb - 1 );
|
||||
base_mach = copysingl (mach, lb - 1);
|
||||
|
||||
if ( ub == INFINITY )
|
||||
{
|
||||
copy = dupmachine( mach );
|
||||
mach = link_machines( mach,
|
||||
link_machines( base_mach, mkclos( copy ) ) );
|
||||
if (ub == INFINITE_REPEAT) {
|
||||
copy = dupmachine (mach);
|
||||
mach = link_machines (mach,
|
||||
link_machines (base_mach,
|
||||
mkclos (copy)));
|
||||
}
|
||||
|
||||
else {
|
||||
tail = mkstate (SYM_EPSILON);
|
||||
|
||||
for (i = lb; i < ub; ++i) {
|
||||
copy = dupmachine (mach);
|
||||
tail = mkopt (link_machines (copy, tail));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
tail = mkstate( SYM_EPSILON );
|
||||
|
||||
for ( i = lb; i < ub; ++i )
|
||||
{
|
||||
copy = dupmachine( mach );
|
||||
tail = mkopt( link_machines( copy, tail ) );
|
||||
}
|
||||
|
||||
mach = link_machines( mach, link_machines( base_mach, tail ) );
|
||||
}
|
||||
mach =
|
||||
link_machines (mach,
|
||||
link_machines (base_mach, tail));
|
||||
}
|
||||
|
||||
return mach;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkstate - create a state with a transition on a given symbol
|
||||
@ -590,30 +589,31 @@ int mach, lb, ub;
|
||||
* that it admittedly is)
|
||||
*/
|
||||
|
||||
int mkstate( sym )
|
||||
int sym;
|
||||
{
|
||||
if ( ++lastnfa >= current_mns )
|
||||
{
|
||||
if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS )
|
||||
lerrif(
|
||||
_( "input rules are too complicated (>= %d NFA states)" ),
|
||||
current_mns );
|
||||
int mkstate (sym)
|
||||
int sym;
|
||||
{
|
||||
if (++lastnfa >= current_mns) {
|
||||
if ((current_mns += MNS_INCREMENT) >= maximum_mns)
|
||||
lerrif (_
|
||||
("input rules are too complicated (>= %d NFA states)"),
|
||||
current_mns);
|
||||
|
||||
++num_reallocs;
|
||||
|
||||
firstst = reallocate_integer_array( firstst, current_mns );
|
||||
lastst = reallocate_integer_array( lastst, current_mns );
|
||||
finalst = reallocate_integer_array( finalst, current_mns );
|
||||
transchar = reallocate_integer_array( transchar, current_mns );
|
||||
trans1 = reallocate_integer_array( trans1, current_mns );
|
||||
trans2 = reallocate_integer_array( trans2, current_mns );
|
||||
accptnum = reallocate_integer_array( accptnum, current_mns );
|
||||
firstst = reallocate_integer_array (firstst, current_mns);
|
||||
lastst = reallocate_integer_array (lastst, current_mns);
|
||||
finalst = reallocate_integer_array (finalst, current_mns);
|
||||
transchar =
|
||||
reallocate_integer_array (transchar, current_mns);
|
||||
trans1 = reallocate_integer_array (trans1, current_mns);
|
||||
trans2 = reallocate_integer_array (trans2, current_mns);
|
||||
accptnum =
|
||||
reallocate_integer_array (accptnum, current_mns);
|
||||
assoc_rule =
|
||||
reallocate_integer_array( assoc_rule, current_mns );
|
||||
reallocate_integer_array (assoc_rule, current_mns);
|
||||
state_type =
|
||||
reallocate_integer_array( state_type, current_mns );
|
||||
}
|
||||
reallocate_integer_array (state_type, current_mns);
|
||||
}
|
||||
|
||||
firstst[lastnfa] = lastnfa;
|
||||
finalst[lastnfa] = lastnfa;
|
||||
@ -634,28 +634,26 @@ int sym;
|
||||
* elsewhere in the input).
|
||||
*/
|
||||
|
||||
if ( sym < 0 )
|
||||
{
|
||||
if (sym < 0) {
|
||||
/* We don't have to update the equivalence classes since
|
||||
* that was already done when the ccl was created for the
|
||||
* first time.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
else if ( sym == SYM_EPSILON )
|
||||
else if (sym == SYM_EPSILON)
|
||||
++numeps;
|
||||
|
||||
else
|
||||
{
|
||||
check_char( sym );
|
||||
else {
|
||||
check_char (sym);
|
||||
|
||||
if ( useecs )
|
||||
if (useecs)
|
||||
/* Map NUL's to csize. */
|
||||
mkechar( sym ? sym : csize, nextecm, ecgroup );
|
||||
}
|
||||
mkechar (sym ? sym : csize, nextecm, ecgroup);
|
||||
}
|
||||
|
||||
return lastnfa;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* mkxtion - make a transition from one state to another
|
||||
@ -668,42 +666,43 @@ int sym;
|
||||
* stateto - the state to which the transition is to be made
|
||||
*/
|
||||
|
||||
void mkxtion( statefrom, stateto )
|
||||
int statefrom, stateto;
|
||||
{
|
||||
if ( trans1[statefrom] == NO_TRANSITION )
|
||||
void mkxtion (statefrom, stateto)
|
||||
int statefrom, stateto;
|
||||
{
|
||||
if (trans1[statefrom] == NO_TRANSITION)
|
||||
trans1[statefrom] = stateto;
|
||||
|
||||
else if ( (transchar[statefrom] != SYM_EPSILON) ||
|
||||
(trans2[statefrom] != NO_TRANSITION) )
|
||||
flexfatal( _( "found too many transitions in mkxtion()" ) );
|
||||
else if ((transchar[statefrom] != SYM_EPSILON) ||
|
||||
(trans2[statefrom] != NO_TRANSITION))
|
||||
flexfatal (_("found too many transitions in mkxtion()"));
|
||||
|
||||
else
|
||||
{ /* second out-transition for an epsilon state */
|
||||
else { /* second out-transition for an epsilon state */
|
||||
++eps2;
|
||||
trans2[statefrom] = stateto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* new_rule - initialize for a new rule */
|
||||
|
||||
void new_rule()
|
||||
{
|
||||
if ( ++num_rules >= current_max_rules )
|
||||
{
|
||||
void new_rule ()
|
||||
{
|
||||
if (++num_rules >= current_max_rules) {
|
||||
++num_reallocs;
|
||||
current_max_rules += MAX_RULES_INCREMENT;
|
||||
rule_type = reallocate_integer_array( rule_type,
|
||||
current_max_rules );
|
||||
rule_linenum = reallocate_integer_array( rule_linenum,
|
||||
current_max_rules );
|
||||
rule_useful = reallocate_integer_array( rule_useful,
|
||||
current_max_rules );
|
||||
}
|
||||
rule_type = reallocate_integer_array (rule_type,
|
||||
current_max_rules);
|
||||
rule_linenum = reallocate_integer_array (rule_linenum,
|
||||
current_max_rules);
|
||||
rule_useful = reallocate_integer_array (rule_useful,
|
||||
current_max_rules);
|
||||
rule_has_nl = reallocate_bool_array (rule_has_nl,
|
||||
current_max_rules);
|
||||
}
|
||||
|
||||
if ( num_rules > MAX_RULE )
|
||||
lerrif( _( "too many rules (> %d)!" ), MAX_RULE );
|
||||
if (num_rules > MAX_RULE)
|
||||
lerrif (_("too many rules (> %d)!"), MAX_RULE);
|
||||
|
||||
rule_linenum[num_rules] = linenum;
|
||||
rule_useful[num_rules] = false;
|
||||
}
|
||||
rule_has_nl[num_rules] = false;
|
||||
}
|
||||
|
280
src/bin/flex/options.c
Normal file
280
src/bin/flex/options.c
Normal file
@ -0,0 +1,280 @@
|
||||
/* flex - tool to generate fast lexical analyzers */
|
||||
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "options.h"
|
||||
|
||||
/* Be sure to synchronize these options with those defined in "options.h",
|
||||
* the giant switch() statement in "main.c", and the %option processing in
|
||||
* "scan.l".
|
||||
*/
|
||||
|
||||
|
||||
/* The command-line options, passed to scanopt_init() */
|
||||
optspec_t flexopts[] = {
|
||||
|
||||
{"-7", OPT_7BIT, 0}
|
||||
,
|
||||
{"--7bit", OPT_7BIT, 0}
|
||||
, /* Generate 7-bit scanner. */
|
||||
{"-8", OPT_8BIT, 0}
|
||||
,
|
||||
{"--8bit", OPT_8BIT, 0}
|
||||
, /* Generate 8-bit scanner. */
|
||||
{"--align", OPT_ALIGN, 0}
|
||||
, /* Trade off larger tables for better memory alignment. */
|
||||
{"--noalign", OPT_NO_ALIGN, 0}
|
||||
,
|
||||
{"--always-interactive", OPT_ALWAYS_INTERACTIVE, 0}
|
||||
,
|
||||
{"--array", OPT_ARRAY, 0}
|
||||
,
|
||||
{"-b", OPT_BACKUP, 0}
|
||||
,
|
||||
{"--backup", OPT_BACKUP, 0}
|
||||
, /* Generate backing-up information to lex.backup. */
|
||||
{"-B", OPT_BATCH, 0}
|
||||
,
|
||||
{"--batch", OPT_BATCH, 0}
|
||||
, /* Generate batch scanner (opposite of -I). */
|
||||
{"--bison-bridge", OPT_BISON_BRIDGE, 0}
|
||||
, /* Scanner to be called by a bison pure parser. */
|
||||
{"--bison-locations", OPT_BISON_BRIDGE_LOCATIONS, 0}
|
||||
, /* Scanner to be called by a bison pure parser. */
|
||||
{"-i", OPT_CASE_INSENSITIVE, 0}
|
||||
,
|
||||
{"--case-insensitive", OPT_CASE_INSENSITIVE, 0}
|
||||
, /* Generate case-insensitive scanner. */
|
||||
|
||||
{"-C[aefFmr]", OPT_COMPRESSION,
|
||||
"Specify degree of table compression (default is -Cem)"},
|
||||
{"-+", OPT_CPLUSPLUS, 0}
|
||||
,
|
||||
{"--c++", OPT_CPLUSPLUS, 0}
|
||||
, /* Generate C++ scanner class. */
|
||||
{"-d", OPT_DEBUG, 0}
|
||||
,
|
||||
{"--debug", OPT_DEBUG, 0}
|
||||
, /* Turn on debug mode in generated scanner. */
|
||||
{"--nodebug", OPT_NO_DEBUG, 0}
|
||||
,
|
||||
{"-s", OPT_NO_DEFAULT, 0}
|
||||
,
|
||||
{"--nodefault", OPT_NO_DEFAULT, 0}
|
||||
, /* Suppress default rule to ECHO unmatched text. */
|
||||
{"--default", OPT_DEFAULT, 0}
|
||||
,
|
||||
{"-c", OPT_DONOTHING, 0}
|
||||
, /* For POSIX lex compatibility. */
|
||||
{"-n", OPT_DONOTHING, 0}
|
||||
, /* For POSIX lex compatibility. */
|
||||
{"--ecs", OPT_ECS, 0}
|
||||
, /* Construct equivalence classes. */
|
||||
{"--noecs", OPT_NO_ECS, 0}
|
||||
,
|
||||
{"-F", OPT_FAST, 0}
|
||||
,
|
||||
{"--fast", OPT_FAST, 0}
|
||||
, /* Same as -CFr. */
|
||||
{"-f", OPT_FULL, 0}
|
||||
,
|
||||
{"--full", OPT_FULL, 0}
|
||||
, /* Same as -Cfr. */
|
||||
{"--header-file[=FILE]", OPT_HEADER_FILE, 0}
|
||||
,
|
||||
{"-?", OPT_HELP, 0}
|
||||
,
|
||||
{"-h", OPT_HELP, 0}
|
||||
,
|
||||
{"--help", OPT_HELP, 0}
|
||||
, /* Produce this help message. */
|
||||
{"-I", OPT_INTERACTIVE, 0}
|
||||
,
|
||||
{"--interactive", OPT_INTERACTIVE, 0}
|
||||
, /* Generate interactive scanner (opposite of -B). */
|
||||
{"-l", OPT_LEX_COMPAT, 0}
|
||||
,
|
||||
{"--lex-compat", OPT_LEX_COMPAT, 0}
|
||||
, /* Maximal compatibility with original lex. */
|
||||
{"-X", OPT_POSIX_COMPAT, 0}
|
||||
,
|
||||
{"--posix-compat", OPT_POSIX_COMPAT, 0}
|
||||
, /* Maximal compatibility with POSIX lex. */
|
||||
{"--preproc=NUM", OPT_PREPROC_LEVEL, 0}
|
||||
,
|
||||
{"-L", OPT_NO_LINE, 0}
|
||||
, /* Suppress #line directives in scanner. */
|
||||
{"--noline", OPT_NO_LINE, 0}
|
||||
, /* Suppress #line directives in scanner. */
|
||||
{"--main", OPT_MAIN, 0}
|
||||
, /* use built-in main() function. */
|
||||
{"--nomain", OPT_NO_MAIN, 0}
|
||||
,
|
||||
{"--meta-ecs", OPT_META_ECS, 0}
|
||||
, /* Construct meta-equivalence classes. */
|
||||
{"--nometa-ecs", OPT_NO_META_ECS, 0}
|
||||
,
|
||||
{"--never-interactive", OPT_NEVER_INTERACTIVE, 0}
|
||||
,
|
||||
{"-o FILE", OPT_OUTFILE, 0}
|
||||
,
|
||||
{"--outfile=FILE", OPT_OUTFILE, 0}
|
||||
, /* Write to FILE (default is lex.yy.c) */
|
||||
{"-p", OPT_PERF_REPORT, 0}
|
||||
,
|
||||
{"--perf-report", OPT_PERF_REPORT, 0}
|
||||
, /* Generate performance report to stderr. */
|
||||
{"--pointer", OPT_POINTER, 0}
|
||||
,
|
||||
{"-P PREFIX", OPT_PREFIX, 0}
|
||||
,
|
||||
{"--prefix=PREFIX", OPT_PREFIX, 0}
|
||||
, /* Use PREFIX (default is yy) */
|
||||
{"-Dmacro", OPT_PREPROCDEFINE, 0}
|
||||
, /* Define a preprocessor symbol. */
|
||||
{"--read", OPT_READ, 0}
|
||||
, /* Use read(2) instead of stdio. */
|
||||
{"-R", OPT_REENTRANT, 0}
|
||||
,
|
||||
{"--reentrant", OPT_REENTRANT, 0}
|
||||
, /* Generate a reentrant C scanner. */
|
||||
{"--noreentrant", OPT_NO_REENTRANT, 0}
|
||||
,
|
||||
{"--reject", OPT_REJECT, 0}
|
||||
,
|
||||
{"--noreject", OPT_NO_REJECT, 0}
|
||||
,
|
||||
{"-S FILE", OPT_SKEL, 0}
|
||||
,
|
||||
{"--skel=FILE", OPT_SKEL, 0}
|
||||
, /* Use skeleton from FILE */
|
||||
{"--stack", OPT_STACK, 0}
|
||||
,
|
||||
{"--stdinit", OPT_STDINIT, 0}
|
||||
,
|
||||
{"--nostdinit", OPT_NO_STDINIT, 0}
|
||||
,
|
||||
{"-t", OPT_STDOUT, 0}
|
||||
,
|
||||
{"--stdout", OPT_STDOUT, 0}
|
||||
, /* Write generated scanner to stdout. */
|
||||
{"-T", OPT_TRACE, 0}
|
||||
,
|
||||
{"--trace", OPT_TRACE, 0}
|
||||
, /* Flex should run in trace mode. */
|
||||
{"--tables-file[=FILE]", OPT_TABLES_FILE, 0}
|
||||
, /* Save tables to FILE */
|
||||
{"--tables-verify", OPT_TABLES_VERIFY, 0}
|
||||
, /* Tables integrity check */
|
||||
{"--nounistd", OPT_NO_UNISTD_H, 0}
|
||||
, /* Do not include unistd.h */
|
||||
{"-v", OPT_VERBOSE, 0}
|
||||
,
|
||||
{"--verbose", OPT_VERBOSE, 0}
|
||||
, /* Write summary of scanner statistics to stdout. */
|
||||
{"-V", OPT_VERSION, 0}
|
||||
,
|
||||
{"--version", OPT_VERSION, 0}
|
||||
, /* Report flex version. */
|
||||
{"--warn", OPT_WARN, 0}
|
||||
,
|
||||
{"-w", OPT_NO_WARN, 0}
|
||||
,
|
||||
{"--nowarn", OPT_NO_WARN, 0}
|
||||
, /* Suppress warning messages. */
|
||||
{"--noansi-definitions", OPT_NO_ANSI_FUNC_DEFS, 0}
|
||||
,
|
||||
{"--noansi-prototypes", OPT_NO_ANSI_FUNC_PROTOS, 0}
|
||||
,
|
||||
{"--yyclass=NAME", OPT_YYCLASS, 0}
|
||||
,
|
||||
{"--yylineno", OPT_YYLINENO, 0}
|
||||
,
|
||||
{"--noyylineno", OPT_NO_YYLINENO, 0}
|
||||
,
|
||||
|
||||
{"--yymore", OPT_YYMORE, 0}
|
||||
,
|
||||
{"--noyymore", OPT_NO_YYMORE, 0}
|
||||
,
|
||||
{"--noyywrap", OPT_NO_YYWRAP, 0}
|
||||
,
|
||||
{"--yywrap", OPT_YYWRAP, 0}
|
||||
,
|
||||
|
||||
{"--nounput", OPT_NO_UNPUT, 0}
|
||||
,
|
||||
{"--noyy_push_state", OPT_NO_YY_PUSH_STATE, 0}
|
||||
,
|
||||
{"--noyy_pop_state", OPT_NO_YY_POP_STATE, 0}
|
||||
,
|
||||
{"--noyy_top_state", OPT_NO_YY_TOP_STATE, 0}
|
||||
,
|
||||
{"--noyy_scan_buffer", OPT_NO_YY_SCAN_BUFFER, 0}
|
||||
,
|
||||
{"--noyy_scan_bytes", OPT_NO_YY_SCAN_BYTES, 0}
|
||||
,
|
||||
{"--noyy_scan_string", OPT_NO_YY_SCAN_STRING, 0}
|
||||
,
|
||||
{"--noyyget_extra", OPT_NO_YYGET_EXTRA, 0}
|
||||
,
|
||||
{"--noyyset_extra", OPT_NO_YYSET_EXTRA, 0}
|
||||
,
|
||||
{"--noyyget_leng", OPT_NO_YYGET_LENG, 0}
|
||||
,
|
||||
{"--noyyget_text", OPT_NO_YYGET_TEXT, 0}
|
||||
,
|
||||
{"--noyyget_lineno", OPT_NO_YYGET_LINENO, 0}
|
||||
,
|
||||
{"--noyyset_lineno", OPT_NO_YYSET_LINENO, 0}
|
||||
,
|
||||
{"--noyyget_in", OPT_NO_YYGET_IN, 0}
|
||||
,
|
||||
{"--noyyset_in", OPT_NO_YYSET_IN, 0}
|
||||
,
|
||||
{"--noyyget_out", OPT_NO_YYGET_OUT, 0}
|
||||
,
|
||||
{"--noyyset_out", OPT_NO_YYSET_OUT, 0}
|
||||
,
|
||||
{"--noyyget_lval", OPT_NO_YYGET_LVAL, 0}
|
||||
,
|
||||
{"--noyyset_lval", OPT_NO_YYSET_LVAL, 0}
|
||||
,
|
||||
{"--noyyget_lloc", OPT_NO_YYGET_LLOC, 0}
|
||||
,
|
||||
{"--noyyset_lloc", OPT_NO_YYSET_LLOC, 0}
|
||||
,
|
||||
|
||||
{0, 0, 0} /* required final NULL entry. */
|
||||
};
|
||||
|
||||
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
|
134
src/bin/flex/options.h
Normal file
134
src/bin/flex/options.h
Normal file
@ -0,0 +1,134 @@
|
||||
/* flex - tool to generate fast lexical analyzers */
|
||||
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#ifndef OPTIONS_H
|
||||
#define OPTIONS_H
|
||||
#include "scanopt.h"
|
||||
|
||||
extern optspec_t flexopts[];
|
||||
|
||||
enum flexopt_flag_t {
|
||||
/* Use positive integers only, since they are return codes for scanopt.
|
||||
* Order is not important. */
|
||||
OPT_7BIT = 1,
|
||||
OPT_8BIT,
|
||||
OPT_ALIGN,
|
||||
OPT_ALWAYS_INTERACTIVE,
|
||||
OPT_ARRAY,
|
||||
OPT_BACKUP,
|
||||
OPT_BATCH,
|
||||
OPT_BISON_BRIDGE,
|
||||
OPT_BISON_BRIDGE_LOCATIONS,
|
||||
OPT_CASE_INSENSITIVE,
|
||||
OPT_COMPRESSION,
|
||||
OPT_CPLUSPLUS,
|
||||
OPT_DEBUG,
|
||||
OPT_DEFAULT,
|
||||
OPT_DONOTHING,
|
||||
OPT_ECS,
|
||||
OPT_FAST,
|
||||
OPT_FULL,
|
||||
OPT_HEADER_FILE,
|
||||
OPT_HELP,
|
||||
OPT_INTERACTIVE,
|
||||
OPT_LEX_COMPAT,
|
||||
OPT_POSIX_COMPAT,
|
||||
OPT_MAIN,
|
||||
OPT_META_ECS,
|
||||
OPT_NEVER_INTERACTIVE,
|
||||
OPT_NO_ALIGN,
|
||||
OPT_NO_ANSI_FUNC_DEFS,
|
||||
OPT_NO_ANSI_FUNC_PROTOS,
|
||||
OPT_NO_DEBUG,
|
||||
OPT_NO_DEFAULT,
|
||||
OPT_NO_ECS,
|
||||
OPT_NO_LINE,
|
||||
OPT_NO_MAIN,
|
||||
OPT_NO_META_ECS,
|
||||
OPT_NO_REENTRANT,
|
||||
OPT_NO_REJECT,
|
||||
OPT_NO_STDINIT,
|
||||
OPT_NO_UNPUT,
|
||||
OPT_NO_WARN,
|
||||
OPT_NO_YYGET_EXTRA,
|
||||
OPT_NO_YYGET_IN,
|
||||
OPT_NO_YYGET_LENG,
|
||||
OPT_NO_YYGET_LINENO,
|
||||
OPT_NO_YYGET_LLOC,
|
||||
OPT_NO_YYGET_LVAL,
|
||||
OPT_NO_YYGET_OUT,
|
||||
OPT_NO_YYGET_TEXT,
|
||||
OPT_NO_YYLINENO,
|
||||
OPT_NO_YYMORE,
|
||||
OPT_NO_YYSET_EXTRA,
|
||||
OPT_NO_YYSET_IN,
|
||||
OPT_NO_YYSET_LINENO,
|
||||
OPT_NO_YYSET_LLOC,
|
||||
OPT_NO_YYSET_LVAL,
|
||||
OPT_NO_YYSET_OUT,
|
||||
OPT_NO_YYWRAP,
|
||||
OPT_NO_YY_POP_STATE,
|
||||
OPT_NO_YY_PUSH_STATE,
|
||||
OPT_NO_YY_SCAN_BUFFER,
|
||||
OPT_NO_YY_SCAN_BYTES,
|
||||
OPT_NO_YY_SCAN_STRING,
|
||||
OPT_NO_YY_TOP_STATE,
|
||||
OPT_OUTFILE,
|
||||
OPT_PERF_REPORT,
|
||||
OPT_POINTER,
|
||||
OPT_PREFIX,
|
||||
OPT_PREPROCDEFINE,
|
||||
OPT_PREPROC_LEVEL,
|
||||
OPT_READ,
|
||||
OPT_REENTRANT,
|
||||
OPT_REJECT,
|
||||
OPT_SKEL,
|
||||
OPT_STACK,
|
||||
OPT_STDINIT,
|
||||
OPT_STDOUT,
|
||||
OPT_TABLES_FILE,
|
||||
OPT_TABLES_VERIFY,
|
||||
OPT_TRACE,
|
||||
OPT_NO_UNISTD_H,
|
||||
OPT_VERBOSE,
|
||||
OPT_VERSION,
|
||||
OPT_WARN,
|
||||
OPT_YYCLASS,
|
||||
OPT_YYLINENO,
|
||||
OPT_YYMORE,
|
||||
OPT_YYWRAP
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4 textwidth=0: */
|
2103
src/bin/flex/parse.c
Normal file
2103
src/bin/flex/parse.c
Normal file
File diff suppressed because it is too large
Load Diff
36
src/bin/flex/parse.h
Normal file
36
src/bin/flex/parse.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef YYSTYPE
|
||||
#define YYSTYPE int
|
||||
#endif
|
||||
#define CHAR 257
|
||||
#define NUMBER 258
|
||||
#define SECTEND 259
|
||||
#define SCDECL 260
|
||||
#define XSCDECL 261
|
||||
#define NAME 262
|
||||
#define PREVCCL 263
|
||||
#define EOF_OP 264
|
||||
#define OPTION_OP 265
|
||||
#define OPT_OUTFILE 266
|
||||
#define OPT_PREFIX 267
|
||||
#define OPT_YYCLASS 268
|
||||
#define OPT_HEADER 269
|
||||
#define OPT_TABLES 270
|
||||
#define CCE_ALNUM 271
|
||||
#define CCE_ALPHA 272
|
||||
#define CCE_BLANK 273
|
||||
#define CCE_CNTRL 274
|
||||
#define CCE_DIGIT 275
|
||||
#define CCE_GRAPH 276
|
||||
#define CCE_LOWER 277
|
||||
#define CCE_PRINT 278
|
||||
#define CCE_PUNCT 279
|
||||
#define CCE_SPACE 280
|
||||
#define CCE_UPPER 281
|
||||
#define CCE_XDIGIT 282
|
||||
#define BEGIN_REPEAT_POSIX 283
|
||||
#define END_REPEAT_POSIX 284
|
||||
#define BEGIN_REPEAT_FLEX 285
|
||||
#define END_REPEAT_FLEX 286
|
||||
|
||||
|
||||
extern YYSTYPE yylval;
|
@ -1,41 +1,63 @@
|
||||
/* parse.y - parser for flex input */
|
||||
|
||||
%token CHAR NUMBER SECTEND SCDECL XSCDECL NAME PREVCCL EOF_OP
|
||||
%token OPTION_OP OPT_OUTFILE OPT_PREFIX OPT_YYCLASS
|
||||
%token OPTION_OP OPT_OUTFILE OPT_PREFIX OPT_YYCLASS OPT_HEADER
|
||||
%token OPT_TABLES
|
||||
|
||||
%token CCE_ALNUM CCE_ALPHA CCE_BLANK CCE_CNTRL CCE_DIGIT CCE_GRAPH
|
||||
%token CCE_LOWER CCE_PRINT CCE_PUNCT CCE_SPACE CCE_UPPER CCE_XDIGIT
|
||||
|
||||
%{
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
/*
|
||||
*POSIX and AT&T lex place the
|
||||
* precedence of the repeat operator, {}, below that of concatenation.
|
||||
* Thus, ab{3} is ababab. Most other POSIX utilities use an Extended
|
||||
* Regular Expression (ERE) precedence that has the repeat operator
|
||||
* higher than concatenation. This causes ab{3} to yield abbb.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* In order to support the POSIX and AT&T precedence and the flex
|
||||
* precedence we define two token sets for the begin and end tokens of
|
||||
* the repeat operator, '{' and '}'. The lexical scanner chooses
|
||||
* which tokens to return based on whether posix_compat or lex_compat
|
||||
* are specified. Specifying either posix_compat or lex_compat will
|
||||
* cause flex to parse scanner files as per the AT&T and
|
||||
* POSIX-mandated behavior.
|
||||
*/
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/parse.y,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
%token BEGIN_REPEAT_POSIX END_REPEAT_POSIX BEGIN_REPEAT_FLEX END_REPEAT_FLEX
|
||||
|
||||
|
||||
%{
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
/* Some versions of bison are broken in that they use alloca() but don't
|
||||
* declare it properly. The following is the patented (just kidding!)
|
||||
* #ifdef chud to fix the problem, courtesy of Francois Pinard.
|
||||
@ -48,6 +70,7 @@
|
||||
#endif
|
||||
|
||||
#include "flexdef.h"
|
||||
#include "tables.h"
|
||||
|
||||
/* The remainder of the alloca() cruft has to come after including flexdef.h,
|
||||
* so HAVE_ALLOCA_H is (possibly) defined.
|
||||
@ -86,14 +109,21 @@ int scon_stk_ptr;
|
||||
static int madeany = false; /* whether we've made the '.' character class */
|
||||
int previous_continued_action; /* whether the previous rule's action was '|' */
|
||||
|
||||
#define format_warn3(fmt, a1, a2) \
|
||||
do{ \
|
||||
char fw3_msg[MAXLINE];\
|
||||
snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\
|
||||
warn( fw3_msg );\
|
||||
}while(0)
|
||||
|
||||
/* Expand a POSIX character class expression. */
|
||||
#define CCL_EXPR(func) \
|
||||
{ \
|
||||
do{ \
|
||||
int c; \
|
||||
for ( c = 0; c < csize; ++c ) \
|
||||
if ( isascii(c) && func(c) ) \
|
||||
ccladd( currccl, c ); \
|
||||
}
|
||||
}while(0)
|
||||
|
||||
/* While POSIX defines isblank(), it's not ANSI C. */
|
||||
#define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
|
||||
@ -123,7 +153,7 @@ goal : initlex sect1 sect1end sect2 initforrule
|
||||
*/
|
||||
default_rule = num_rules;
|
||||
|
||||
finish_rule( def_rule, false, 0, 0 );
|
||||
finish_rule( def_rule, false, 0, 0, 0);
|
||||
|
||||
for ( i = 1; i <= lastsc; ++i )
|
||||
scset[i] = mkbranch( scset[i], def_rule );
|
||||
@ -150,7 +180,7 @@ sect1 : sect1 startconddecl namelist1
|
||||
| sect1 options
|
||||
|
|
||||
| error
|
||||
{ synerr( "unknown error processing section 1" ); }
|
||||
{ synerr( _("unknown error processing section 1") ); }
|
||||
;
|
||||
|
||||
sect1end : SECTEND
|
||||
@ -175,7 +205,7 @@ namelist1 : namelist1 NAME
|
||||
{ scinstal( nmstr, xcluflg ); }
|
||||
|
||||
| error
|
||||
{ synerr( "bad start condition list" ); }
|
||||
{ synerr( _("bad start condition list") ); }
|
||||
;
|
||||
|
||||
options : OPTION_OP optionlist
|
||||
@ -194,6 +224,10 @@ option : OPT_OUTFILE '=' NAME
|
||||
{ prefix = copy_string( nmstr ); }
|
||||
| OPT_YYCLASS '=' NAME
|
||||
{ yyclass = copy_string( nmstr ); }
|
||||
| OPT_HEADER '=' NAME
|
||||
{ headerfilename = copy_string( nmstr ); }
|
||||
| OPT_TABLES '=' NAME
|
||||
{ tablesext = true; tablesfilename = copy_string( nmstr ); }
|
||||
;
|
||||
|
||||
sect2 : sect2 scon initforrule flexrule '\n'
|
||||
@ -220,7 +254,7 @@ flexrule : '^' rule
|
||||
{
|
||||
pat = $2;
|
||||
finish_rule( pat, variable_trail_rule,
|
||||
headcnt, trailcnt );
|
||||
headcnt, trailcnt , previous_continued_action);
|
||||
|
||||
if ( scon_stk_ptr > 0 )
|
||||
{
|
||||
@ -256,7 +290,7 @@ flexrule : '^' rule
|
||||
{
|
||||
pat = $1;
|
||||
finish_rule( pat, variable_trail_rule,
|
||||
headcnt, trailcnt );
|
||||
headcnt, trailcnt , previous_continued_action);
|
||||
|
||||
if ( scon_stk_ptr > 0 )
|
||||
{
|
||||
@ -300,7 +334,7 @@ flexrule : '^' rule
|
||||
}
|
||||
|
||||
| error
|
||||
{ synerr( "unrecognized rule" ); }
|
||||
{ synerr( _("unrecognized rule") ); }
|
||||
;
|
||||
|
||||
scon_stk_ptr :
|
||||
@ -336,7 +370,7 @@ namelist2 : namelist2 ',' sconname
|
||||
| sconname
|
||||
|
||||
| error
|
||||
{ synerr( "bad start condition list" ); }
|
||||
{ synerr( _("bad start condition list") ); }
|
||||
;
|
||||
|
||||
sconname : NAME
|
||||
@ -392,6 +426,7 @@ rule : re2 re
|
||||
/* Mark as variable. */
|
||||
varlength = true;
|
||||
headcnt = 0;
|
||||
|
||||
}
|
||||
|
||||
if ( lex_compat || (varlength && headcnt == 0) )
|
||||
@ -418,7 +453,7 @@ rule : re2 re
|
||||
}
|
||||
|
||||
| re2 re '$'
|
||||
{ synerr( "trailing context used twice" ); }
|
||||
{ synerr( _("trailing context used twice") ); }
|
||||
|
||||
| re '$'
|
||||
{
|
||||
@ -431,7 +466,7 @@ rule : re2 re
|
||||
|
||||
if ( trlcontxt )
|
||||
{
|
||||
synerr( "trailing context used twice" );
|
||||
synerr( _("trailing context used twice") );
|
||||
$$ = mkstate( SYM_EPSILON );
|
||||
}
|
||||
|
||||
@ -500,7 +535,7 @@ re2 : re '/'
|
||||
*/
|
||||
|
||||
if ( trlcontxt )
|
||||
synerr( "trailing context used twice" );
|
||||
synerr( _("trailing context used twice") );
|
||||
else
|
||||
trlcontxt = true;
|
||||
|
||||
@ -529,6 +564,69 @@ series : series singleton
|
||||
|
||||
| singleton
|
||||
{ $$ = $1; }
|
||||
|
||||
| series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX
|
||||
{
|
||||
varlength = true;
|
||||
|
||||
if ( $3 > $5 || $3 < 0 )
|
||||
{
|
||||
synerr( _("bad iteration values") );
|
||||
$$ = $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $3 == 0 )
|
||||
{
|
||||
if ( $5 <= 0 )
|
||||
{
|
||||
synerr(
|
||||
_("bad iteration values") );
|
||||
$$ = $1;
|
||||
}
|
||||
else
|
||||
$$ = mkopt(
|
||||
mkrep( $1, 1, $5 ) );
|
||||
}
|
||||
else
|
||||
$$ = mkrep( $1, $3, $5 );
|
||||
}
|
||||
}
|
||||
|
||||
| series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX
|
||||
{
|
||||
varlength = true;
|
||||
|
||||
if ( $3 <= 0 )
|
||||
{
|
||||
synerr( _("iteration value must be positive") );
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
else
|
||||
$$ = mkrep( $1, $3, INFINITE_REPEAT );
|
||||
}
|
||||
|
||||
| series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX
|
||||
{
|
||||
/* The series could be something like "(foo)",
|
||||
* in which case we have no idea what its length
|
||||
* is, so we punt here.
|
||||
*/
|
||||
varlength = true;
|
||||
|
||||
if ( $3 <= 0 )
|
||||
{
|
||||
synerr( _("iteration value must be positive")
|
||||
);
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
else
|
||||
$$ = link_machines( $1,
|
||||
copysingl( $1, $3 - 1 ) );
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
singleton : singleton '*'
|
||||
@ -550,13 +648,13 @@ singleton : singleton '*'
|
||||
$$ = mkopt( $1 );
|
||||
}
|
||||
|
||||
| singleton '{' NUMBER ',' NUMBER '}'
|
||||
| singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX
|
||||
{
|
||||
varlength = true;
|
||||
|
||||
if ( $3 > $5 || $3 < 0 )
|
||||
{
|
||||
synerr( "bad iteration values" );
|
||||
synerr( _("bad iteration values") );
|
||||
$$ = $1;
|
||||
}
|
||||
else
|
||||
@ -566,7 +664,7 @@ singleton : singleton '*'
|
||||
if ( $5 <= 0 )
|
||||
{
|
||||
synerr(
|
||||
"bad iteration values" );
|
||||
_("bad iteration values") );
|
||||
$$ = $1;
|
||||
}
|
||||
else
|
||||
@ -578,21 +676,21 @@ singleton : singleton '*'
|
||||
}
|
||||
}
|
||||
|
||||
| singleton '{' NUMBER ',' '}'
|
||||
| singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX
|
||||
{
|
||||
varlength = true;
|
||||
|
||||
if ( $3 <= 0 )
|
||||
{
|
||||
synerr( "iteration value must be positive" );
|
||||
synerr( _("iteration value must be positive") );
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
else
|
||||
$$ = mkrep( $1, $3, INFINITY );
|
||||
$$ = mkrep( $1, $3, INFINITE_REPEAT );
|
||||
}
|
||||
|
||||
| singleton '{' NUMBER '}'
|
||||
| singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX
|
||||
{
|
||||
/* The singleton could be something like "(foo)",
|
||||
* in which case we have no idea what its length
|
||||
@ -602,7 +700,7 @@ singleton : singleton '*'
|
||||
|
||||
if ( $3 <= 0 )
|
||||
{
|
||||
synerr( "iteration value must be positive" );
|
||||
synerr( _("iteration value must be positive") );
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
@ -648,6 +746,9 @@ singleton : singleton '*'
|
||||
|
||||
++rulelen;
|
||||
|
||||
if (ccl_has_nl[$1])
|
||||
rule_has_nl[num_rules] = true;
|
||||
|
||||
$$ = mkstate( -$1 );
|
||||
}
|
||||
|
||||
@ -655,6 +756,9 @@ singleton : singleton '*'
|
||||
{
|
||||
++rulelen;
|
||||
|
||||
if (ccl_has_nl[$1])
|
||||
rule_has_nl[num_rules] = true;
|
||||
|
||||
$$ = mkstate( -$1 );
|
||||
}
|
||||
|
||||
@ -671,6 +775,9 @@ singleton : singleton '*'
|
||||
if ( caseins && $1 >= 'A' && $1 <= 'Z' )
|
||||
$1 = clower( $1 );
|
||||
|
||||
if ($1 == nlch)
|
||||
rule_has_nl[num_rules] = true;
|
||||
|
||||
$$ = mkstate( $1 );
|
||||
}
|
||||
;
|
||||
@ -687,16 +794,42 @@ fullccl : '[' ccl ']'
|
||||
|
||||
ccl : ccl CHAR '-' CHAR
|
||||
{
|
||||
if ( caseins )
|
||||
{
|
||||
if ( $2 >= 'A' && $2 <= 'Z' )
|
||||
$2 = clower( $2 );
|
||||
if ( $4 >= 'A' && $4 <= 'Z' )
|
||||
$4 = clower( $4 );
|
||||
}
|
||||
|
||||
if (caseins)
|
||||
{
|
||||
/* Squish the character range to lowercase only if BOTH
|
||||
* ends of the range are uppercase.
|
||||
*/
|
||||
if (isupper ($2) && isupper ($4))
|
||||
{
|
||||
$2 = tolower ($2);
|
||||
$4 = tolower ($4);
|
||||
}
|
||||
|
||||
/* If one end of the range has case and the other
|
||||
* does not, or the cases are different, then we're not
|
||||
* sure what range the user is trying to express.
|
||||
* Examples: [@-z] or [S-t]
|
||||
*/
|
||||
else if (has_case ($2) != has_case ($4)
|
||||
|| (has_case ($2) && (b_islower ($2) != b_islower ($4))))
|
||||
format_warn3 (
|
||||
_("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
|
||||
$2, $4);
|
||||
|
||||
/* If the range spans uppercase characters but not
|
||||
* lowercase (or vice-versa), then should we automatically
|
||||
* include lowercase characters in the range?
|
||||
* Example: [@-_] spans [a-z] but not [A-Z]
|
||||
*/
|
||||
else if (!has_case ($2) && !has_case ($4) && !range_covers_case ($2, $4))
|
||||
format_warn3 (
|
||||
_("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
|
||||
$2, $4);
|
||||
}
|
||||
|
||||
if ( $2 > $4 )
|
||||
synerr( "negative range in character class" );
|
||||
synerr( _("negative range in character class") );
|
||||
|
||||
else
|
||||
{
|
||||
@ -739,23 +872,23 @@ ccl : ccl CHAR '-' CHAR
|
||||
}
|
||||
;
|
||||
|
||||
ccl_expr: CCE_ALNUM { CCL_EXPR(isalnum) }
|
||||
| CCE_ALPHA { CCL_EXPR(isalpha) }
|
||||
| CCE_BLANK { CCL_EXPR(IS_BLANK) }
|
||||
| CCE_CNTRL { CCL_EXPR(iscntrl) }
|
||||
| CCE_DIGIT { CCL_EXPR(isdigit) }
|
||||
| CCE_GRAPH { CCL_EXPR(isgraph) }
|
||||
| CCE_LOWER { CCL_EXPR(islower) }
|
||||
| CCE_PRINT { CCL_EXPR(isprint) }
|
||||
| CCE_PUNCT { CCL_EXPR(ispunct) }
|
||||
| CCE_SPACE { CCL_EXPR(isspace) }
|
||||
ccl_expr: CCE_ALNUM { CCL_EXPR(isalnum); }
|
||||
| CCE_ALPHA { CCL_EXPR(isalpha); }
|
||||
| CCE_BLANK { CCL_EXPR(IS_BLANK); }
|
||||
| CCE_CNTRL { CCL_EXPR(iscntrl); }
|
||||
| CCE_DIGIT { CCL_EXPR(isdigit); }
|
||||
| CCE_GRAPH { CCL_EXPR(isgraph); }
|
||||
| CCE_LOWER { CCL_EXPR(islower); }
|
||||
| CCE_PRINT { CCL_EXPR(isprint); }
|
||||
| CCE_PUNCT { CCL_EXPR(ispunct); }
|
||||
| CCE_SPACE { CCL_EXPR(isspace); }
|
||||
| CCE_UPPER {
|
||||
if ( caseins )
|
||||
CCL_EXPR(islower)
|
||||
CCL_EXPR(islower);
|
||||
else
|
||||
CCL_EXPR(isupper)
|
||||
CCL_EXPR(isupper);
|
||||
}
|
||||
| CCE_XDIGIT { CCL_EXPR(isxdigit) }
|
||||
| CCE_XDIGIT { CCL_EXPR(isxdigit); }
|
||||
;
|
||||
|
||||
string : string CHAR
|
||||
@ -763,6 +896,9 @@ string : string CHAR
|
||||
if ( caseins && $2 >= 'A' && $2 <= 'Z' )
|
||||
$2 = clower( $2 );
|
||||
|
||||
if ( $2 == nlch )
|
||||
rule_has_nl[num_rules] = true;
|
||||
|
||||
++rulelen;
|
||||
|
||||
$$ = link_machines( $1, mkstate( $2 ) );
|
||||
@ -815,7 +951,7 @@ void build_eof_action()
|
||||
/* format_synerr - write out formatted syntax error */
|
||||
|
||||
void format_synerr( msg, arg )
|
||||
char msg[], arg[];
|
||||
const char *msg, arg[];
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
@ -827,7 +963,7 @@ char msg[], arg[];
|
||||
/* synerr - report a syntax error */
|
||||
|
||||
void synerr( str )
|
||||
char str[];
|
||||
const char *str;
|
||||
{
|
||||
syntaxerror = true;
|
||||
pinpoint_message( str );
|
||||
@ -837,7 +973,7 @@ char str[];
|
||||
/* format_warn - write out formatted warning */
|
||||
|
||||
void format_warn( msg, arg )
|
||||
char msg[], arg[];
|
||||
const char *msg, arg[];
|
||||
{
|
||||
char warn_msg[MAXLINE];
|
||||
|
||||
@ -849,7 +985,7 @@ char msg[], arg[];
|
||||
/* warn - report a warning, unless -w was given */
|
||||
|
||||
void warn( str )
|
||||
char str[];
|
||||
const char *str;
|
||||
{
|
||||
line_warning( str, linenum );
|
||||
}
|
||||
@ -859,7 +995,7 @@ char str[];
|
||||
*/
|
||||
|
||||
void format_pinpoint_message( msg, arg )
|
||||
char msg[], arg[];
|
||||
const char *msg, arg[];
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
@ -871,7 +1007,7 @@ char msg[], arg[];
|
||||
/* pinpoint_message - write out a message, pinpointing its location */
|
||||
|
||||
void pinpoint_message( str )
|
||||
char str[];
|
||||
const char *str;
|
||||
{
|
||||
line_pinpoint( str, linenum );
|
||||
}
|
||||
@ -880,7 +1016,7 @@ char str[];
|
||||
/* line_warning - report a warning at a given line, unless -w was given */
|
||||
|
||||
void line_warning( str, line )
|
||||
char str[];
|
||||
const char *str;
|
||||
int line;
|
||||
{
|
||||
char warning[MAXLINE];
|
||||
@ -896,10 +1032,10 @@ int line;
|
||||
/* line_pinpoint - write out a message, pinpointing it at the given line */
|
||||
|
||||
void line_pinpoint( str, line )
|
||||
char str[];
|
||||
const char *str;
|
||||
int line;
|
||||
{
|
||||
fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str );
|
||||
fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
|
||||
}
|
||||
|
||||
|
||||
@ -908,6 +1044,6 @@ int line;
|
||||
*/
|
||||
|
||||
void yyerror( msg )
|
||||
char msg[];
|
||||
const char *msg;
|
||||
{
|
||||
}
|
||||
|
164
src/bin/flex/regex.c
Normal file
164
src/bin/flex/regex.c
Normal file
@ -0,0 +1,164 @@
|
||||
/** regex - regular expression functions related to POSIX regex lib. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
|
||||
static const char* REGEXP_LINEDIR = "^#line ([[:digit:]]+) \"(.*)\"";
|
||||
static const char* REGEXP_BLANK_LINE = "^[[:space:]]*$";
|
||||
|
||||
regex_t regex_linedir; /**< matches line directives */
|
||||
regex_t regex_blank_line; /**< matches blank lines */
|
||||
|
||||
|
||||
/** Initialize the regular expressions.
|
||||
* @return true upon success.
|
||||
*/
|
||||
bool flex_init_regex(void)
|
||||
{
|
||||
flex_regcomp(®ex_linedir, REGEXP_LINEDIR, REG_EXTENDED);
|
||||
flex_regcomp(®ex_blank_line, REGEXP_BLANK_LINE, REG_EXTENDED);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Compiles a regular expression or dies trying.
|
||||
* @param preg Same as for regcomp().
|
||||
* @param regex Same as for regcomp().
|
||||
* @param cflags Same as for regcomp().
|
||||
*/
|
||||
void flex_regcomp(regex_t *preg, const char *regex, int cflags)
|
||||
{
|
||||
int err;
|
||||
|
||||
memset (preg, 0, sizeof (regex_t));
|
||||
|
||||
if ((err = regcomp (preg, regex, cflags)) != 0) {
|
||||
const int errbuf_sz = 200;
|
||||
char * errbuf=0;
|
||||
|
||||
errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
|
||||
regerror (err, preg, errbuf, errbuf_sz);
|
||||
sprintf (errbuf, "regcomp failed: %s\n", errbuf);
|
||||
|
||||
flexfatal (errbuf);
|
||||
free(errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/** Extract a copy of the match, or NULL if no match.
|
||||
* @param m A match as returned by regexec().
|
||||
* @param src The source string that was passed to regexec().
|
||||
* @return The allocated string.
|
||||
*/
|
||||
char *regmatch_dup (regmatch_t * m, const char *src)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
|
||||
if (m == NULL || m->rm_so < 0)
|
||||
return NULL;
|
||||
len = m->rm_eo - m->rm_so;
|
||||
str = (char *) flex_alloc ((len + 1) * sizeof (char));
|
||||
strncpy (str, src + m->rm_so, len);
|
||||
str[len] = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
/** Copy the match.
|
||||
* @param m A match as returned by regexec().
|
||||
* @param dest The destination buffer.
|
||||
* @param src The source string that was passed to regexec().
|
||||
* @return dest
|
||||
*/
|
||||
char *regmatch_cpy (regmatch_t * m, char *dest, const char *src)
|
||||
{
|
||||
if (m == NULL || m->rm_so < 0) {
|
||||
if (dest)
|
||||
dest[0] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
snprintf (dest, regmatch_len(m), "%s", src + m->rm_so);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/** Get the length in characters of the match.
|
||||
* @param m A match as returned by regexec().
|
||||
* @param src The source string that was passed to regexec().
|
||||
* @return The length of the match.
|
||||
*/
|
||||
int regmatch_len (regmatch_t * m)
|
||||
{
|
||||
if (m == NULL || m->rm_so < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m->rm_eo - m->rm_so;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Convert a regmatch_t object to an integer using the strtol() function.
|
||||
* @param m A match as returned by regexec().
|
||||
* @param src The source string that was passed to regexec().
|
||||
* @param endptr Same as the second argument to strtol().
|
||||
* @param base Same as the third argument to strtol().
|
||||
* @return The converted integer or error (Return value is the same as for strtol()).
|
||||
*/
|
||||
int regmatch_strtol (regmatch_t * m, const char *src, char **endptr,
|
||||
int base)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
#define bufsz 20
|
||||
char buf[bufsz];
|
||||
char *s;
|
||||
|
||||
if (m == NULL || m->rm_so < 0)
|
||||
return 0;
|
||||
|
||||
if (regmatch_len (m) < bufsz)
|
||||
s = regmatch_cpy (m, buf, src);
|
||||
else
|
||||
s = regmatch_dup (m, src);
|
||||
|
||||
n = strtol (s, endptr, base);
|
||||
|
||||
if (s != buf)
|
||||
free (s);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/** Check for empty or non-existent match.
|
||||
* @param m A match as returned by regexec().
|
||||
* @return false if match length is non-zero.
|
||||
* Note that reg_empty returns true even if match did not occur at all.
|
||||
*/
|
||||
bool regmatch_empty (regmatch_t * m)
|
||||
{
|
||||
return (m == NULL || m->rm_so < 0 || m->rm_so == m->rm_eo);
|
||||
}
|
||||
|
||||
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */
|
4232
src/bin/flex/scan.c
4232
src/bin/flex/scan.c
File diff suppressed because it is too large
Load Diff
@ -1,36 +1,41 @@
|
||||
/* scan.l - scanner for flex input */
|
||||
/* scan.l - scanner for flex input -*-C-*- */
|
||||
|
||||
%{
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/scan.l,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
#include "parse.h"
|
||||
extern bool tablesverify, tablesext;
|
||||
extern int trlcontxt; /* Set in parse.y for each rule. */
|
||||
|
||||
#define ACTION_ECHO add_action( yytext )
|
||||
#define ACTION_IFDEF(def, should_define) \
|
||||
@ -39,6 +44,14 @@
|
||||
action_define( def, 1 ); \
|
||||
}
|
||||
|
||||
#define ACTION_M4_IFDEF(def, should_define) \
|
||||
do{ \
|
||||
if ( should_define ) \
|
||||
buf_m4_define( &m4defs_buf, def, NULL);\
|
||||
else \
|
||||
buf_m4_undefine( &m4defs_buf, def);\
|
||||
} while(0)
|
||||
|
||||
#define MARK_END_OF_PROLOG mark_prolog();
|
||||
|
||||
#define YY_DECL \
|
||||
@ -49,7 +62,15 @@
|
||||
return CHAR;
|
||||
|
||||
#define RETURNNAME \
|
||||
if(yyleng < MAXLINE) \
|
||||
{ \
|
||||
strcpy( nmstr, yytext ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
synerr(_("Input line too long\n")); \
|
||||
FLEX_EXIT(EXIT_FAILURE); \
|
||||
} \
|
||||
return NAME;
|
||||
|
||||
#define PUT_BACK_STRING(str, start) \
|
||||
@ -63,18 +84,23 @@
|
||||
#define CHECK_YYMORE(str) \
|
||||
if ( all_lower( str ) ) \
|
||||
yymore_used = true;
|
||||
|
||||
#define YY_USER_INIT \
|
||||
if ( getenv("POSIXLY_CORRECT") ) \
|
||||
posix_compat = true;
|
||||
|
||||
%}
|
||||
|
||||
%option caseless nodefault outfile="scan.c" stack noyy_top_state
|
||||
%option caseless nodefault stack noyy_top_state
|
||||
%option nostdinit
|
||||
|
||||
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
|
||||
%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
|
||||
%x OPTION LINEDIR
|
||||
%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE
|
||||
|
||||
WS [[:blank:]]+
|
||||
OPTWS [[:blank:]]*
|
||||
NOT_WS [^[:blank:]\n]
|
||||
NOT_WS [^[:blank:]\r\n]
|
||||
|
||||
NL \r?\n
|
||||
|
||||
@ -97,8 +123,8 @@ LEXOPT [aceknopr]
|
||||
static int option_sense;
|
||||
|
||||
int doing_codeblock = false;
|
||||
int i;
|
||||
Char nmdef[MAXLINE], myesc();
|
||||
int i, brace_depth=0, brace_start_line=0;
|
||||
Char nmdef[MAXLINE];
|
||||
|
||||
|
||||
<INITIAL>{
|
||||
@ -113,6 +139,15 @@ LEXOPT [aceknopr]
|
||||
indented_code = false;
|
||||
BEGIN(CODEBLOCK);
|
||||
}
|
||||
^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
|
||||
brace_start_line = linenum;
|
||||
++linenum;
|
||||
buf_linedir( &top_buf, infilename?infilename:"<stdin>", linenum);
|
||||
brace_depth = 1;
|
||||
yy_push_state(CODEBLOCK_MATCH_BRACE);
|
||||
}
|
||||
|
||||
^"%top".* synerr( _("malformed '%top' directive") );
|
||||
|
||||
{WS} /* discard */
|
||||
|
||||
@ -133,10 +168,20 @@ LEXOPT [aceknopr]
|
||||
^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
|
||||
^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
|
||||
|
||||
/* xgettext: no-c-format */
|
||||
^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) );
|
||||
|
||||
^{NAME} {
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext );
|
||||
}
|
||||
else
|
||||
{
|
||||
synerr( _("Input line too long\n"));
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
didadef = false;
|
||||
BEGIN(PICKUPDEF);
|
||||
}
|
||||
@ -179,13 +224,50 @@ LEXOPT [aceknopr]
|
||||
}
|
||||
}
|
||||
|
||||
<CODEBLOCK_MATCH_BRACE>{
|
||||
"}" {
|
||||
if( --brace_depth == 0){
|
||||
/* TODO: Matched. */
|
||||
yy_pop_state();
|
||||
}else
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
"{" {
|
||||
brace_depth++;
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
{NL} {
|
||||
++linenum;
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
[^{}\r\n]+ {
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
linenum = brace_start_line;
|
||||
synerr(_("Unmatched '{'"));
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<PICKUPDEF>{
|
||||
{WS} /* separates name and definition */
|
||||
|
||||
{NOT_WS}.* {
|
||||
{NOT_WS}[^\r\n]* {
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( (char *) nmdef, yytext );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
synerr( _("Input line too long\n"));
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
/* Skip trailing whitespace. */
|
||||
for ( i = strlen( (char *) nmdef ) - 1;
|
||||
i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
|
||||
@ -220,11 +302,18 @@ LEXOPT [aceknopr]
|
||||
|
||||
align long_align = option_sense;
|
||||
always-interactive {
|
||||
action_define( "YY_ALWAYS_INTERACTIVE", option_sense );
|
||||
ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
|
||||
interactive = option_sense;
|
||||
}
|
||||
array yytext_is_array = option_sense;
|
||||
ansi-definitions ansi_func_defs = option_sense;
|
||||
ansi-prototypes ansi_func_protos = option_sense;
|
||||
backup backing_up_report = option_sense;
|
||||
batch interactive = ! option_sense;
|
||||
bison-bridge bison_bridge_lval = option_sense;
|
||||
bison-locations { if((bison_bridge_lloc = option_sense))
|
||||
bison_bridge_lval = true;
|
||||
}
|
||||
"c++" C_plus_plus = option_sense;
|
||||
caseful|case-sensitive caseins = ! option_sense;
|
||||
caseless|case-insensitive caseins = option_sense;
|
||||
@ -242,42 +331,85 @@ LEXOPT [aceknopr]
|
||||
input ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
|
||||
interactive interactive = option_sense;
|
||||
lex-compat lex_compat = option_sense;
|
||||
posix-compat posix_compat = option_sense;
|
||||
main {
|
||||
action_define( "YY_MAIN", option_sense );
|
||||
do_yywrap = ! option_sense;
|
||||
ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
|
||||
/* Override yywrap */
|
||||
if( option_sense == true )
|
||||
do_yywrap = false;
|
||||
}
|
||||
meta-ecs usemecs = option_sense;
|
||||
never-interactive {
|
||||
action_define( "YY_NEVER_INTERACTIVE", option_sense );
|
||||
ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense );
|
||||
interactive = !option_sense;
|
||||
}
|
||||
perf-report performance_report += option_sense ? 1 : -1;
|
||||
pointer yytext_is_array = ! option_sense;
|
||||
read use_read = option_sense;
|
||||
reentrant reentrant = option_sense;
|
||||
reject reject_really_used = option_sense;
|
||||
stack action_define( "YY_STACK_USED", option_sense );
|
||||
stack ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense );
|
||||
stdinit do_stdinit = option_sense;
|
||||
stdout use_stdout = option_sense;
|
||||
unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense);
|
||||
unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense);
|
||||
unput ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense);
|
||||
verbose printstats = option_sense;
|
||||
warn nowarn = ! option_sense;
|
||||
yylineno do_yylineno = option_sense;
|
||||
yylineno do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense);
|
||||
yymore yymore_really_used = option_sense;
|
||||
yywrap do_yywrap = option_sense;
|
||||
yywrap do_yywrap = option_sense;
|
||||
|
||||
yy_push_state ACTION_IFDEF("YY_NO_PUSH_STATE", ! option_sense);
|
||||
yy_pop_state ACTION_IFDEF("YY_NO_POP_STATE", ! option_sense);
|
||||
yy_top_state ACTION_IFDEF("YY_NO_TOP_STATE", ! option_sense);
|
||||
yy_push_state ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense);
|
||||
yy_pop_state ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense);
|
||||
yy_top_state ACTION_M4_IFDEF("M4""_YY_NO_TOP_STATE", ! option_sense);
|
||||
|
||||
yy_scan_buffer ACTION_IFDEF("YY_NO_SCAN_BUFFER", ! option_sense);
|
||||
yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
|
||||
yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
|
||||
yy_scan_buffer ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BUFFER", ! option_sense);
|
||||
yy_scan_bytes ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense);
|
||||
yy_scan_string ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense);
|
||||
|
||||
yyalloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense);
|
||||
yyrealloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense);
|
||||
yyfree ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense);
|
||||
|
||||
yyget_debug ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense);
|
||||
yyset_debug ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense);
|
||||
yyget_extra ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense);
|
||||
yyset_extra ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense);
|
||||
yyget_leng ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense);
|
||||
yyget_text ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense);
|
||||
yyget_lineno ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense);
|
||||
yyset_lineno ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense);
|
||||
yyget_in ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense);
|
||||
yyset_in ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense);
|
||||
yyget_out ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense);
|
||||
yyset_out ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense);
|
||||
yyget_lval ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense);
|
||||
yyset_lval ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense);
|
||||
yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense);
|
||||
yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense);
|
||||
|
||||
outfile return OPT_OUTFILE;
|
||||
prefix return OPT_PREFIX;
|
||||
yyclass return OPT_YYCLASS;
|
||||
header(-file)? return OPT_HEADER;
|
||||
tables-file return OPT_TABLES;
|
||||
tables-verify {
|
||||
tablesverify = option_sense;
|
||||
if(!tablesext && option_sense)
|
||||
tablesext = true;
|
||||
}
|
||||
|
||||
|
||||
\"[^"\n]*\" {
|
||||
if(yyleng-1 < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
synerr( _("Input line too long\n"));
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
nmstr[strlen( nmstr ) - 1] = '\0';
|
||||
return NAME;
|
||||
}
|
||||
@ -333,7 +465,13 @@ LEXOPT [aceknopr]
|
||||
^{OPTWS}"<" BEGIN(SC); return '<';
|
||||
^{OPTWS}"^" return '^';
|
||||
\" BEGIN(QUOTE); return '"';
|
||||
"{"/[[:digit:]] BEGIN(NUM); return '{';
|
||||
"{"/[[:digit:]] {
|
||||
BEGIN(NUM);
|
||||
if ( lex_compat || posix_compat )
|
||||
return BEGIN_REPEAT_POSIX;
|
||||
else
|
||||
return BEGIN_REPEAT_FLEX;
|
||||
}
|
||||
"$"/([[:blank:]]|{NL}) return '$';
|
||||
|
||||
{WS}"%{" {
|
||||
@ -395,13 +533,22 @@ LEXOPT [aceknopr]
|
||||
^"%%".* {
|
||||
sectnum = 3;
|
||||
BEGIN(SECT3);
|
||||
outn("/* Begin user sect3 */");
|
||||
yyterminate(); /* to stop the parser */
|
||||
}
|
||||
|
||||
"["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
|
||||
int cclval;
|
||||
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext );
|
||||
}
|
||||
else
|
||||
{
|
||||
synerr( _("Input line too long\n"));
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Check to see if we've already encountered this
|
||||
* ccl.
|
||||
@ -432,12 +579,27 @@ LEXOPT [aceknopr]
|
||||
}
|
||||
}
|
||||
|
||||
"{"{NAME}"}" {
|
||||
/* Check for :space: at the end of the rule so we don't
|
||||
* wrap the expanded regex in '(' ')' -- breaking trailing
|
||||
* context.
|
||||
*/
|
||||
"{"{NAME}"}"[[:space:]]? {
|
||||
register Char *nmdefptr;
|
||||
Char *ndlookup();
|
||||
int end_is_ws, end_ch;
|
||||
|
||||
end_ch = yytext[yyleng-1];
|
||||
end_is_ws = end_ch != '}' ? 1 : 0;
|
||||
|
||||
if(yyleng-1 < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext + 1 );
|
||||
nmstr[yyleng - 2] = '\0'; /* chop trailing brace */
|
||||
}
|
||||
else
|
||||
{
|
||||
synerr( _("Input line too long\n"));
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
|
||||
if ( (nmdefptr = ndlookup( nmstr )) == 0 )
|
||||
format_synerr(
|
||||
@ -447,9 +609,12 @@ LEXOPT [aceknopr]
|
||||
else
|
||||
{ /* push back name surrounded by ()'s */
|
||||
int len = strlen( (char *) nmdefptr );
|
||||
if (end_is_ws)
|
||||
unput(end_ch);
|
||||
|
||||
if ( lex_compat || nmdefptr[0] == '^' ||
|
||||
(len > 0 && nmdefptr[len - 1] == '$') )
|
||||
(len > 0 && nmdefptr[len - 1] == '$')
|
||||
|| (end_is_ws && trlcontxt))
|
||||
{ /* don't use ()'s after all */
|
||||
PUT_BACK_STRING((char *) nmdefptr, 0);
|
||||
|
||||
@ -472,6 +637,7 @@ LEXOPT [aceknopr]
|
||||
|
||||
|
||||
<SC>{
|
||||
{OPTWS}{NL}{OPTWS} ++linenum; /* Allow blank lines & continuations */
|
||||
[,*] return (unsigned char) yytext[0];
|
||||
">" BEGIN(SECT2); return '>';
|
||||
">"/^ BEGIN(CARETISBOL); return '>';
|
||||
@ -543,7 +709,13 @@ LEXOPT [aceknopr]
|
||||
}
|
||||
|
||||
"," return ',';
|
||||
"}" BEGIN(SECT2); return '}';
|
||||
"}" {
|
||||
BEGIN(SECT2);
|
||||
if ( lex_compat || posix_compat )
|
||||
return END_REPEAT_POSIX;
|
||||
else
|
||||
return END_REPEAT_FLEX;
|
||||
}
|
||||
|
||||
. {
|
||||
synerr( _( "bad character inside {}'s" ) );
|
||||
@ -619,7 +791,7 @@ LEXOPT [aceknopr]
|
||||
<ACTION_STRING>{
|
||||
[^"\\\n]+ ACTION_ECHO;
|
||||
\\. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO; BEGIN(ACTION);
|
||||
\" ACTION_ECHO; BEGIN(ACTION);
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
|
871
src/bin/flex/scanopt.c
Normal file
871
src/bin/flex/scanopt.c
Normal file
@ -0,0 +1,871 @@
|
||||
/* flex - tool to generate fast lexical analyzers */
|
||||
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
#include "scanopt.h"
|
||||
|
||||
|
||||
/* Internal structures */
|
||||
|
||||
#ifdef HAVE_STRCASECMP
|
||||
#define STRCASECMP(a,b) strcasecmp(a,b)
|
||||
#else
|
||||
static int STRCASECMP PROTO ((const char *, const char *));
|
||||
|
||||
static int STRCASECMP (a, b)
|
||||
const char *a;
|
||||
const char *b;
|
||||
{
|
||||
while (tolower (*a++) == tolower (*b++)) ;
|
||||
return b - a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ARG_NONE 0x01
|
||||
#define ARG_REQ 0x02
|
||||
#define ARG_OPT 0x04
|
||||
#define IS_LONG 0x08
|
||||
|
||||
struct _aux {
|
||||
int flags; /* The above hex flags. */
|
||||
int namelen; /* Length of the actual option word, e.g., "--file[=foo]" is 4 */
|
||||
int printlen; /* Length of entire string, e.g., "--file[=foo]" is 12 */
|
||||
};
|
||||
|
||||
|
||||
struct _scanopt_t {
|
||||
const optspec_t *options; /* List of options. */
|
||||
struct _aux *aux; /* Auxiliary data about options. */
|
||||
int optc; /* Number of options. */
|
||||
int argc; /* Number of args. */
|
||||
char **argv; /* Array of strings. */
|
||||
int index; /* Used as: argv[index][subscript]. */
|
||||
int subscript;
|
||||
char no_err_msg; /* If true, do not print errors. */
|
||||
char has_long;
|
||||
char has_short;
|
||||
};
|
||||
|
||||
/* Accessor functions. These WOULD be one-liners, but portability calls. */
|
||||
static const char *NAME PROTO ((struct _scanopt_t *, int));
|
||||
static int PRINTLEN PROTO ((struct _scanopt_t *, int));
|
||||
static int RVAL PROTO ((struct _scanopt_t *, int));
|
||||
static int FLAGS PROTO ((struct _scanopt_t *, int));
|
||||
static const char *DESC PROTO ((struct _scanopt_t *, int));
|
||||
static int scanopt_err PROTO ((struct _scanopt_t *, int, int, int));
|
||||
static int matchlongopt PROTO ((char *, char **, int *, char **, int *));
|
||||
static int find_opt
|
||||
PROTO ((struct _scanopt_t *, int, char *, int, int *, int *opt_offset));
|
||||
|
||||
static const char *NAME (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
{
|
||||
return s->options[i].opt_fmt +
|
||||
((s->aux[i].flags & IS_LONG) ? 2 : 1);
|
||||
}
|
||||
|
||||
static int PRINTLEN (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
{
|
||||
return s->aux[i].printlen;
|
||||
}
|
||||
|
||||
static int RVAL (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
{
|
||||
return s->options[i].r_val;
|
||||
}
|
||||
|
||||
static int FLAGS (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
{
|
||||
return s->aux[i].flags;
|
||||
}
|
||||
|
||||
static const char *DESC (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
{
|
||||
return s->options[i].desc ? s->options[i].desc : "";
|
||||
}
|
||||
|
||||
#ifndef NO_SCANOPT_USAGE
|
||||
static int get_cols PROTO ((void));
|
||||
|
||||
static int get_cols ()
|
||||
{
|
||||
char *env;
|
||||
int cols = 80; /* default */
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
initscr ();
|
||||
endwin ();
|
||||
if (COLS > 0)
|
||||
return COLS;
|
||||
#endif
|
||||
|
||||
if ((env = getenv ("COLUMNS")) != NULL)
|
||||
cols = atoi (env);
|
||||
|
||||
return cols;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Macro to check for NULL before assigning a value. */
|
||||
#define SAFE_ASSIGN(ptr,val) \
|
||||
do{ \
|
||||
if((ptr)!=NULL) \
|
||||
*(ptr) = val; \
|
||||
}while(0)
|
||||
|
||||
/* Macro to assure we reset subscript whenever we adjust s->index.*/
|
||||
#define INC_INDEX(s,n) \
|
||||
do{ \
|
||||
(s)->index += (n); \
|
||||
(s)->subscript= 0; \
|
||||
}while(0)
|
||||
|
||||
scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
const optspec_t *options;
|
||||
int argc;
|
||||
char **argv;
|
||||
int flags;
|
||||
{
|
||||
int i;
|
||||
struct _scanopt_t *s;
|
||||
s = (struct _scanopt_t *) malloc (sizeof (struct _scanopt_t));
|
||||
|
||||
s->options = options;
|
||||
s->optc = 0;
|
||||
s->argc = argc;
|
||||
s->argv = (char **) argv;
|
||||
s->index = 1;
|
||||
s->subscript = 0;
|
||||
s->no_err_msg = (flags & SCANOPT_NO_ERR_MSG);
|
||||
s->has_long = 0;
|
||||
s->has_short = 0;
|
||||
|
||||
/* Determine option count. (Find entry with all zeros). */
|
||||
s->optc = 0;
|
||||
while (options[s->optc].opt_fmt
|
||||
|| options[s->optc].r_val || options[s->optc].desc)
|
||||
s->optc++;
|
||||
|
||||
/* Build auxiliary data */
|
||||
s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux));
|
||||
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
const char *p, *pname;
|
||||
const struct optspec_t *opt;
|
||||
struct _aux *aux;
|
||||
|
||||
opt = s->options + i;
|
||||
aux = s->aux + i;
|
||||
|
||||
aux->flags = ARG_NONE;
|
||||
|
||||
if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
|
||||
aux->flags |= IS_LONG;
|
||||
pname = opt->opt_fmt + 2;
|
||||
s->has_long = 1;
|
||||
}
|
||||
else {
|
||||
pname = opt->opt_fmt + 1;
|
||||
s->has_short = 1;
|
||||
}
|
||||
aux->printlen = strlen (opt->opt_fmt);
|
||||
|
||||
aux->namelen = 0;
|
||||
for (p = pname + 1; *p; p++) {
|
||||
/* detect required arg */
|
||||
if (*p == '=' || isspace (*p)
|
||||
|| !(aux->flags & IS_LONG)) {
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
aux->flags |= ARG_REQ;
|
||||
aux->flags &= ~ARG_NONE;
|
||||
}
|
||||
/* detect optional arg. This overrides required arg. */
|
||||
if (*p == '[') {
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
aux->flags &= ~(ARG_REQ | ARG_NONE);
|
||||
aux->flags |= ARG_OPT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
}
|
||||
return (scanopt_t *) s;
|
||||
}
|
||||
|
||||
#ifndef NO_SCANOPT_USAGE
|
||||
/* these structs are for scanopt_usage(). */
|
||||
struct usg_elem {
|
||||
int idx;
|
||||
struct usg_elem *next;
|
||||
struct usg_elem *alias;
|
||||
};
|
||||
typedef struct usg_elem usg_elem;
|
||||
|
||||
|
||||
/* Prints a usage message based on contents of optlist.
|
||||
* Parameters:
|
||||
* scanner - The scanner, already initialized with scanopt_init().
|
||||
* fp - The file stream to write to.
|
||||
* usage - Text to be prepended to option list.
|
||||
* Return: Always returns 0 (zero).
|
||||
* The output looks something like this:
|
||||
|
||||
[indent][option, alias1, alias2...][indent][description line1
|
||||
description line2...]
|
||||
*/
|
||||
int scanopt_usage (scanner, fp, usage)
|
||||
scanopt_t *scanner;
|
||||
FILE *fp;
|
||||
const char *usage;
|
||||
{
|
||||
struct _scanopt_t *s;
|
||||
int i, columns, indent = 2;
|
||||
usg_elem *byr_val = NULL; /* option indices sorted by r_val */
|
||||
usg_elem *store; /* array of preallocated elements. */
|
||||
int store_idx = 0;
|
||||
usg_elem *ue;
|
||||
int maxlen[2];
|
||||
int desccol = 0;
|
||||
int print_run = 0;
|
||||
|
||||
maxlen[0] = 0;
|
||||
maxlen[1] = 0;
|
||||
|
||||
s = (struct _scanopt_t *) scanner;
|
||||
|
||||
if (usage) {
|
||||
fprintf (fp, "%s\n", usage);
|
||||
}
|
||||
else {
|
||||
/* Find the basename of argv[0] */
|
||||
const char *p;
|
||||
|
||||
p = s->argv[0] + strlen (s->argv[0]);
|
||||
while (p != s->argv[0] && *p != '/')
|
||||
--p;
|
||||
if (*p == '/')
|
||||
p++;
|
||||
|
||||
fprintf (fp, _("Usage: %s [OPTIONS]...\n"), p);
|
||||
}
|
||||
fprintf (fp, "\n");
|
||||
|
||||
/* Sort by r_val and string. Yes, this is O(n*n), but n is small. */
|
||||
store = (usg_elem *) malloc (s->optc * sizeof (usg_elem));
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
|
||||
/* grab the next preallocate node. */
|
||||
ue = store + store_idx++;
|
||||
ue->idx = i;
|
||||
ue->next = ue->alias = NULL;
|
||||
|
||||
/* insert into list. */
|
||||
if (!byr_val)
|
||||
byr_val = ue;
|
||||
else {
|
||||
int found_alias = 0;
|
||||
usg_elem **ue_curr, **ptr_if_no_alias = NULL;
|
||||
|
||||
ue_curr = &byr_val;
|
||||
while (*ue_curr) {
|
||||
if (RVAL (s, (*ue_curr)->idx) ==
|
||||
RVAL (s, ue->idx)) {
|
||||
/* push onto the alias list. */
|
||||
ue_curr = &((*ue_curr)->alias);
|
||||
found_alias = 1;
|
||||
break;
|
||||
}
|
||||
if (!ptr_if_no_alias
|
||||
&&
|
||||
STRCASECMP (NAME (s, (*ue_curr)->idx),
|
||||
NAME (s, ue->idx)) > 0) {
|
||||
ptr_if_no_alias = ue_curr;
|
||||
}
|
||||
ue_curr = &((*ue_curr)->next);
|
||||
}
|
||||
if (!found_alias && ptr_if_no_alias)
|
||||
ue_curr = ptr_if_no_alias;
|
||||
ue->next = *ue_curr;
|
||||
*ue_curr = ue;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (1) {
|
||||
printf ("ORIGINAL:\n");
|
||||
for (i = 0; i < s->optc; i++)
|
||||
printf ("%2d: %s\n", i, NAME (s, i));
|
||||
printf ("SORTED:\n");
|
||||
ue = byr_val;
|
||||
while (ue) {
|
||||
usg_elem *ue2;
|
||||
|
||||
printf ("%2d: %s\n", ue->idx, NAME (s, ue->idx));
|
||||
for (ue2 = ue->alias; ue2; ue2 = ue2->next)
|
||||
printf (" +---> %2d: %s\n", ue2->idx,
|
||||
NAME (s, ue2->idx));
|
||||
ue = ue->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now build each row of output. */
|
||||
|
||||
/* first pass calculate how much room we need. */
|
||||
for (ue = byr_val; ue; ue = ue->next) {
|
||||
usg_elem *ap;
|
||||
int len = 0;
|
||||
int nshort = 0, nlong = 0;
|
||||
|
||||
|
||||
#define CALC_LEN(i) do {\
|
||||
if(FLAGS(s,i) & IS_LONG) \
|
||||
len += (nlong++||nshort) ? 2+PRINTLEN(s,i) : PRINTLEN(s,i);\
|
||||
else\
|
||||
len += (nshort++||nlong)? 2+PRINTLEN(s,i) : PRINTLEN(s,i);\
|
||||
}while(0)
|
||||
|
||||
if (!(FLAGS (s, ue->idx) & IS_LONG))
|
||||
CALC_LEN (ue->idx);
|
||||
|
||||
/* do short aliases first. */
|
||||
for (ap = ue->alias; ap; ap = ap->next) {
|
||||
if (FLAGS (s, ap->idx) & IS_LONG)
|
||||
continue;
|
||||
CALC_LEN (ap->idx);
|
||||
}
|
||||
|
||||
if (FLAGS (s, ue->idx) & IS_LONG)
|
||||
CALC_LEN (ue->idx);
|
||||
|
||||
/* repeat the above loop, this time for long aliases. */
|
||||
for (ap = ue->alias; ap; ap = ap->next) {
|
||||
if (!(FLAGS (s, ap->idx) & IS_LONG))
|
||||
continue;
|
||||
CALC_LEN (ap->idx);
|
||||
}
|
||||
|
||||
if (len > maxlen[0])
|
||||
maxlen[0] = len;
|
||||
|
||||
/* It's much easier to calculate length for description column! */
|
||||
len = strlen (DESC (s, ue->idx));
|
||||
if (len > maxlen[1])
|
||||
maxlen[1] = len;
|
||||
}
|
||||
|
||||
/* Determine how much room we have, and how much we will allocate to each col.
|
||||
* Do not address pathological cases. Output will just be ugly. */
|
||||
columns = get_cols () - 1;
|
||||
if (maxlen[0] + maxlen[1] + indent * 2 > columns) {
|
||||
/* col 0 gets whatever it wants. we'll wrap the desc col. */
|
||||
maxlen[1] = columns - (maxlen[0] + indent * 2);
|
||||
if (maxlen[1] < 14) /* 14 is arbitrary lower limit on desc width. */
|
||||
maxlen[1] = INT_MAX;
|
||||
}
|
||||
desccol = maxlen[0] + indent * 2;
|
||||
|
||||
#define PRINT_SPACES(fp,n)\
|
||||
do{\
|
||||
int _n;\
|
||||
_n=(n);\
|
||||
while(_n-- > 0)\
|
||||
fputc(' ',(fp));\
|
||||
}while(0)
|
||||
|
||||
|
||||
/* Second pass (same as above loop), this time we print. */
|
||||
/* Sloppy hack: We iterate twice. The first time we print short and long options.
|
||||
The second time we print those lines that have ONLY long options. */
|
||||
while (print_run++ < 2) {
|
||||
for (ue = byr_val; ue; ue = ue->next) {
|
||||
usg_elem *ap;
|
||||
int nwords = 0, nchars = 0, has_short = 0;
|
||||
|
||||
/* TODO: get has_short schtick to work */
|
||||
has_short = !(FLAGS (s, ue->idx) & IS_LONG);
|
||||
for (ap = ue->alias; ap; ap = ap->next) {
|
||||
if (!(FLAGS (s, ap->idx) & IS_LONG)) {
|
||||
has_short = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((print_run == 1 && !has_short) ||
|
||||
(print_run == 2 && has_short))
|
||||
continue;
|
||||
|
||||
PRINT_SPACES (fp, indent);
|
||||
nchars += indent;
|
||||
|
||||
/* Print, adding a ", " between aliases. */
|
||||
#define PRINT_IT(i) do{\
|
||||
if(nwords++)\
|
||||
nchars+=fprintf(fp,", ");\
|
||||
nchars+=fprintf(fp,"%s",s->options[i].opt_fmt);\
|
||||
}while(0)
|
||||
|
||||
if (!(FLAGS (s, ue->idx) & IS_LONG))
|
||||
PRINT_IT (ue->idx);
|
||||
|
||||
/* print short aliases first. */
|
||||
for (ap = ue->alias; ap; ap = ap->next) {
|
||||
if (!(FLAGS (s, ap->idx) & IS_LONG))
|
||||
PRINT_IT (ap->idx);
|
||||
}
|
||||
|
||||
|
||||
if (FLAGS (s, ue->idx) & IS_LONG)
|
||||
PRINT_IT (ue->idx);
|
||||
|
||||
/* repeat the above loop, this time for long aliases. */
|
||||
for (ap = ue->alias; ap; ap = ap->next) {
|
||||
if (FLAGS (s, ap->idx) & IS_LONG)
|
||||
PRINT_IT (ap->idx);
|
||||
}
|
||||
|
||||
/* pad to desccol */
|
||||
PRINT_SPACES (fp, desccol - nchars);
|
||||
|
||||
/* Print description, wrapped to maxlen[1] columns. */
|
||||
if (1) {
|
||||
const char *pstart;
|
||||
|
||||
pstart = DESC (s, ue->idx);
|
||||
while (1) {
|
||||
int n = 0;
|
||||
const char *lastws = NULL, *p;
|
||||
|
||||
p = pstart;
|
||||
|
||||
while (*p && n < maxlen[1]
|
||||
&& *p != '\n') {
|
||||
if (isspace (*p)
|
||||
|| *p == '-') lastws =
|
||||
p;
|
||||
n++;
|
||||
p++;
|
||||
}
|
||||
|
||||
if (!*p) { /* hit end of desc. done. */
|
||||
fprintf (fp, "%s\n",
|
||||
pstart);
|
||||
break;
|
||||
}
|
||||
else if (*p == '\n') { /* print everything up to here then wrap. */
|
||||
fprintf (fp, "%.*s\n", n,
|
||||
pstart);
|
||||
PRINT_SPACES (fp, desccol);
|
||||
pstart = p + 1;
|
||||
continue;
|
||||
}
|
||||
else { /* we hit the edge of the screen. wrap at space if possible. */
|
||||
if (lastws) {
|
||||
fprintf (fp,
|
||||
"%.*s\n",
|
||||
lastws -
|
||||
pstart,
|
||||
pstart);
|
||||
pstart =
|
||||
lastws + 1;
|
||||
}
|
||||
else {
|
||||
fprintf (fp,
|
||||
"%.*s\n",
|
||||
n,
|
||||
pstart);
|
||||
pstart = p + 1;
|
||||
}
|
||||
PRINT_SPACES (fp, desccol);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* end while */
|
||||
free (store);
|
||||
return 0;
|
||||
}
|
||||
#endif /* no scanopt_usage */
|
||||
|
||||
|
||||
static int scanopt_err (s, opt_offset, is_short, err)
|
||||
struct _scanopt_t *s;
|
||||
int opt_offset;
|
||||
int is_short;
|
||||
int err;
|
||||
{
|
||||
const char *optname = "";
|
||||
char optchar[2];
|
||||
const optspec_t *opt = NULL;
|
||||
|
||||
if (opt_offset >= 0)
|
||||
opt = s->options + opt_offset;
|
||||
|
||||
if (!s->no_err_msg) {
|
||||
|
||||
if (s->index > 0 && s->index < s->argc) {
|
||||
if (is_short) {
|
||||
optchar[0] =
|
||||
s->argv[s->index][s->subscript];
|
||||
optchar[1] = '\0';
|
||||
optname = optchar;
|
||||
}
|
||||
else {
|
||||
optname = s->argv[s->index];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s: ", s->argv[0]);
|
||||
switch (err) {
|
||||
case SCANOPT_ERR_ARG_NOT_ALLOWED:
|
||||
fprintf (stderr,
|
||||
_
|
||||
("option `%s' doesn't allow an argument\n"),
|
||||
optname);
|
||||
break;
|
||||
case SCANOPT_ERR_ARG_NOT_FOUND:
|
||||
fprintf (stderr,
|
||||
_("option `%s' requires an argument\n"),
|
||||
optname);
|
||||
break;
|
||||
case SCANOPT_ERR_OPT_AMBIGUOUS:
|
||||
fprintf (stderr, _("option `%s' is ambiguous\n"),
|
||||
optname);
|
||||
break;
|
||||
case SCANOPT_ERR_OPT_UNRECOGNIZED:
|
||||
fprintf (stderr, _("Unrecognized option `%s'\n"),
|
||||
optname);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, _("Unknown error=(%d)\n"), err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Internal. Match str against the regex ^--([^=]+)(=(.*))?
|
||||
* return 1 if *looks* like a long option.
|
||||
* 'str' is the only input argument, the rest of the arguments are output only.
|
||||
* optname will point to str + 2
|
||||
*
|
||||
*/
|
||||
static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
char *str;
|
||||
char **optname;
|
||||
int *optlen;
|
||||
char **arg;
|
||||
int *arglen;
|
||||
{
|
||||
char *p;
|
||||
|
||||
*optname = *arg = (char *) 0;
|
||||
*optlen = *arglen = 0;
|
||||
|
||||
/* Match regex /--./ */
|
||||
p = str;
|
||||
if (p[0] != '-' || p[1] != '-' || !p[2])
|
||||
return 0;
|
||||
|
||||
p += 2;
|
||||
*optname = (char *) p;
|
||||
|
||||
/* find the end of optname */
|
||||
while (*p && *p != '=')
|
||||
++p;
|
||||
|
||||
*optlen = p - *optname;
|
||||
|
||||
if (!*p)
|
||||
/* an option with no '=...' part. */
|
||||
return 1;
|
||||
|
||||
|
||||
/* We saw an '=' char. The rest of p is the arg. */
|
||||
p++;
|
||||
*arg = p;
|
||||
while (*p)
|
||||
++p;
|
||||
*arglen = p - *arg;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Internal. Look up long or short option by name.
|
||||
* Long options must match a non-ambiguous prefix, or exact match.
|
||||
* Short options must be exact.
|
||||
* Return boolean true if found and no error.
|
||||
* Error stored in err_code or zero if no error. */
|
||||
static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
|
||||
struct _scanopt_t *s;
|
||||
int lookup_long;
|
||||
char *optstart;
|
||||
int len;
|
||||
int *err_code;
|
||||
int *opt_offset;
|
||||
{
|
||||
int nmatch = 0, lastr_val = 0, i;
|
||||
|
||||
*err_code = 0;
|
||||
*opt_offset = -1;
|
||||
|
||||
if (!optstart)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
char *optname;
|
||||
|
||||
optname =
|
||||
(char *) (s->options[i].opt_fmt +
|
||||
(lookup_long ? 2 : 1));
|
||||
|
||||
if (lookup_long && (s->aux[i].flags & IS_LONG)) {
|
||||
if (len > s->aux[i].namelen)
|
||||
continue;
|
||||
|
||||
if (strncmp (optname, optstart, len) == 0) {
|
||||
nmatch++;
|
||||
*opt_offset = i;
|
||||
|
||||
/* exact match overrides all. */
|
||||
if (len == s->aux[i].namelen) {
|
||||
nmatch = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* ambiguity is ok between aliases. */
|
||||
if (lastr_val
|
||||
&& lastr_val ==
|
||||
s->options[i].r_val) nmatch--;
|
||||
lastr_val = s->options[i].r_val;
|
||||
}
|
||||
}
|
||||
else if (!lookup_long && !(s->aux[i].flags & IS_LONG)) {
|
||||
if (optname[0] == optstart[0]) {
|
||||
nmatch++;
|
||||
*opt_offset = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nmatch == 0) {
|
||||
*err_code = SCANOPT_ERR_OPT_UNRECOGNIZED;
|
||||
*opt_offset = -1;
|
||||
}
|
||||
else if (nmatch > 1) {
|
||||
*err_code = SCANOPT_ERR_OPT_AMBIGUOUS;
|
||||
*opt_offset = -1;
|
||||
}
|
||||
|
||||
return *err_code ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
int scanopt (svoid, arg, optindex)
|
||||
scanopt_t *svoid;
|
||||
char **arg;
|
||||
int *optindex;
|
||||
{
|
||||
char *optname = NULL, *optarg = NULL, *pstart;
|
||||
int namelen = 0, arglen = 0;
|
||||
int errcode = 0, has_next;
|
||||
const optspec_t *optp;
|
||||
struct _scanopt_t *s;
|
||||
struct _aux *auxp;
|
||||
int is_short;
|
||||
int opt_offset = -1;
|
||||
|
||||
s = (struct _scanopt_t *) svoid;
|
||||
|
||||
/* Normalize return-parameters. */
|
||||
SAFE_ASSIGN (arg, NULL);
|
||||
SAFE_ASSIGN (optindex, s->index);
|
||||
|
||||
if (s->index >= s->argc)
|
||||
return 0;
|
||||
|
||||
/* pstart always points to the start of our current scan. */
|
||||
pstart = s->argv[s->index] + s->subscript;
|
||||
if (!pstart)
|
||||
return 0;
|
||||
|
||||
if (s->subscript == 0) {
|
||||
|
||||
/* test for exact match of "--" */
|
||||
if (pstart[0] == '-' && pstart[1] == '-' && !pstart[2]) {
|
||||
SAFE_ASSIGN (optindex, s->index + 1);
|
||||
INC_INDEX (s, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Match an opt. */
|
||||
if (matchlongopt
|
||||
(pstart, &optname, &namelen, &optarg, &arglen)) {
|
||||
|
||||
/* it LOOKS like an opt, but is it one?! */
|
||||
if (!find_opt
|
||||
(s, 1, optname, namelen, &errcode,
|
||||
&opt_offset)) {
|
||||
scanopt_err (s, opt_offset, 0, errcode);
|
||||
return errcode;
|
||||
}
|
||||
/* We handle this below. */
|
||||
is_short = 0;
|
||||
|
||||
/* Check for short opt. */
|
||||
}
|
||||
else if (pstart[0] == '-' && pstart[1]) {
|
||||
/* Pass through to below. */
|
||||
is_short = 1;
|
||||
s->subscript++;
|
||||
pstart++;
|
||||
}
|
||||
|
||||
else {
|
||||
/* It's not an option. We're done. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* We have to re-check the subscript status because it
|
||||
* may have changed above. */
|
||||
|
||||
if (s->subscript != 0) {
|
||||
|
||||
/* we are somewhere in a run of short opts,
|
||||
* e.g., at the 'z' in `tar -xzf` */
|
||||
|
||||
optname = pstart;
|
||||
namelen = 1;
|
||||
is_short = 1;
|
||||
|
||||
if (!find_opt
|
||||
(s, 0, pstart, namelen, &errcode, &opt_offset)) {
|
||||
return scanopt_err (s, opt_offset, 1, errcode);
|
||||
}
|
||||
|
||||
optarg = pstart + 1;
|
||||
arglen = 0;
|
||||
while (optarg[arglen])
|
||||
arglen++;
|
||||
|
||||
if (arglen == 0)
|
||||
optarg = NULL;
|
||||
}
|
||||
|
||||
/* At this point, we have a long or short option matched at opt_offset into
|
||||
* the s->options array (and corresponding aux array).
|
||||
* A trailing argument is in {optarg,arglen}, if any.
|
||||
*/
|
||||
|
||||
/* Look ahead in argv[] to see if there is something
|
||||
* that we can use as an argument (if needed). */
|
||||
has_next = s->index + 1 < s->argc
|
||||
&& strcmp ("--", s->argv[s->index + 1]) != 0;
|
||||
|
||||
optp = s->options + opt_offset;
|
||||
auxp = s->aux + opt_offset;
|
||||
|
||||
/* case: no args allowed */
|
||||
if (auxp->flags & ARG_NONE) {
|
||||
if (optarg) {
|
||||
scanopt_err (s, opt_offset, is_short, errcode =
|
||||
SCANOPT_ERR_ARG_NOT_ALLOWED);
|
||||
INC_INDEX (s, 1);
|
||||
return errcode;
|
||||
}
|
||||
INC_INDEX (s, 1);
|
||||
return optp->r_val;
|
||||
}
|
||||
|
||||
/* case: required */
|
||||
if (auxp->flags & ARG_REQ) {
|
||||
if (!optarg && !has_next)
|
||||
return scanopt_err (s, opt_offset, is_short,
|
||||
SCANOPT_ERR_ARG_NOT_FOUND);
|
||||
|
||||
if (!optarg) {
|
||||
/* Let the next argv element become the argument. */
|
||||
SAFE_ASSIGN (arg, s->argv[s->index + 1]);
|
||||
INC_INDEX (s, 2);
|
||||
}
|
||||
else {
|
||||
SAFE_ASSIGN (arg, (char *) optarg);
|
||||
INC_INDEX (s, 1);
|
||||
}
|
||||
return optp->r_val;
|
||||
}
|
||||
|
||||
/* case: optional */
|
||||
if (auxp->flags & ARG_OPT) {
|
||||
SAFE_ASSIGN (arg, optarg);
|
||||
INC_INDEX (s, 1);
|
||||
return optp->r_val;
|
||||
}
|
||||
|
||||
|
||||
/* Should not reach here. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int scanopt_destroy (svoid)
|
||||
scanopt_t *svoid;
|
||||
{
|
||||
struct _scanopt_t *s;
|
||||
|
||||
s = (struct _scanopt_t *) svoid;
|
||||
if (s) {
|
||||
if (s->aux)
|
||||
free (s->aux);
|
||||
free (s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
|
132
src/bin/flex/scanopt.h
Normal file
132
src/bin/flex/scanopt.h
Normal file
@ -0,0 +1,132 @@
|
||||
/* flex - tool to generate fast lexical analyzers */
|
||||
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#ifndef SCANOPT_H
|
||||
#define SCANOPT_H
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
|
||||
#ifndef NO_SCANOPT_USAGE
|
||||
/* Used by scanopt_usage for pretty-printing. */
|
||||
#ifdef HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef PROTO
|
||||
#define PROTO(args) args
|
||||
#endif
|
||||
/* Error codes. */ enum scanopt_err_t {
|
||||
SCANOPT_ERR_OPT_UNRECOGNIZED = -1, /* Unrecognized option. */
|
||||
SCANOPT_ERR_OPT_AMBIGUOUS = -2, /* It matched more than one option name. */
|
||||
SCANOPT_ERR_ARG_NOT_FOUND = -3, /* The required arg was not found. */
|
||||
SCANOPT_ERR_ARG_NOT_ALLOWED = -4 /* Option does not take an argument. */
|
||||
};
|
||||
|
||||
|
||||
/* flags passed to scanopt_init */
|
||||
enum scanopt_flag_t {
|
||||
SCANOPT_NO_ERR_MSG = 0x01 /* Suppress printing to stderr. */
|
||||
};
|
||||
|
||||
/* Specification for a single option. */
|
||||
struct optspec_t {
|
||||
const char *opt_fmt; /* e.g., "--foo=FILE", "-f FILE", "-n [NUM]" */
|
||||
int r_val; /* Value to be returned by scanopt_ex(). */
|
||||
const char *desc; /* Brief description of this option, or NULL. */
|
||||
};
|
||||
typedef struct optspec_t optspec_t;
|
||||
|
||||
|
||||
/* Used internally by scanopt() to maintain state. */
|
||||
/* Never modify these value directly. */
|
||||
typedef void *scanopt_t;
|
||||
|
||||
|
||||
/* Initializes scanner and checks option list for errors.
|
||||
* Parameters:
|
||||
* options - Array of options.
|
||||
* argc - Same as passed to main().
|
||||
* argv - Same as passed to main(). First element is skipped.
|
||||
* flags - Control behavior.
|
||||
* Return: A malloc'd pointer .
|
||||
*/
|
||||
scanopt_t *scanopt_init PROTO ((const optspec_t * options,
|
||||
int argc, char **argv, int flags));
|
||||
|
||||
/* Frees memory used by scanner.
|
||||
* Always returns 0. */
|
||||
int scanopt_destroy PROTO ((scanopt_t * scanner));
|
||||
|
||||
#ifndef NO_SCANOPT_USAGE
|
||||
/* Prints a usage message based on contents of optlist.
|
||||
* Parameters:
|
||||
* scanner - The scanner, already initialized with scanopt_init().
|
||||
* fp - The file stream to write to.
|
||||
* usage - Text to be prepended to option list. May be NULL.
|
||||
* Return: Always returns 0 (zero).
|
||||
*/
|
||||
int scanopt_usage
|
||||
PROTO (
|
||||
(scanopt_t * scanner, FILE * fp,
|
||||
const char *usage));
|
||||
#endif
|
||||
|
||||
/* Scans command-line options in argv[].
|
||||
* Parameters:
|
||||
* scanner - The scanner, already initialized with scanopt_init().
|
||||
* optarg - Return argument, may be NULL.
|
||||
* On success, it points to start of an argument.
|
||||
* optindex - Return argument, may be NULL.
|
||||
* On success or failure, it is the index of this option.
|
||||
* If return is zero, then optindex is the NEXT valid option index.
|
||||
*
|
||||
* Return: > 0 on success. Return value is from optspec_t->rval.
|
||||
* == 0 if at end of options.
|
||||
* < 0 on error (return value is an error code).
|
||||
*
|
||||
*/
|
||||
int scanopt
|
||||
PROTO (
|
||||
(scanopt_t * scanner, char **optarg,
|
||||
int *optindex));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
|
3391
src/bin/flex/skel.c
3391
src/bin/flex/skel.c
File diff suppressed because it is too large
Load Diff
@ -1,46 +1,70 @@
|
||||
/* sym - symbol table routines */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/sym.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
/* Variables for symbol tables:
|
||||
* sctbl - start-condition symbol table
|
||||
* ndtbl - name-definition symbol table
|
||||
* ccltab - character class text symbol table
|
||||
*/
|
||||
|
||||
struct hash_entry {
|
||||
struct hash_entry *prev, *next;
|
||||
char *name;
|
||||
char *str_val;
|
||||
int int_val;
|
||||
};
|
||||
|
||||
typedef struct hash_entry **hash_table;
|
||||
|
||||
#define NAME_TABLE_HASH_SIZE 101
|
||||
#define START_COND_HASH_SIZE 101
|
||||
#define CCL_HASH_SIZE 101
|
||||
|
||||
static struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
|
||||
static struct hash_entry *sctbl[START_COND_HASH_SIZE];
|
||||
static struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
int hashfunct PROTO((register char[], int));
|
||||
static int addsym PROTO ((register char[], char *, int, hash_table, int));
|
||||
static struct hash_entry *findsym PROTO ((register const char *sym,
|
||||
hash_table table,
|
||||
|
||||
|
||||
struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
|
||||
struct hash_entry *sctbl[START_COND_HASH_SIZE];
|
||||
struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
|
||||
struct hash_entry *findsym();
|
||||
int table_size));
|
||||
static int hashfunct PROTO ((register const char *, int));
|
||||
|
||||
|
||||
/* addsym - add symbol and definitions to symbol table
|
||||
@ -48,40 +72,37 @@ struct hash_entry *findsym();
|
||||
* -1 is returned if the symbol already exists, and the change not made.
|
||||
*/
|
||||
|
||||
int addsym( sym, str_def, int_def, table, table_size )
|
||||
register char sym[];
|
||||
char *str_def;
|
||||
int int_def;
|
||||
hash_table table;
|
||||
int table_size;
|
||||
{
|
||||
int hash_val = hashfunct( sym, table_size );
|
||||
static int addsym (sym, str_def, int_def, table, table_size)
|
||||
register char sym[];
|
||||
char *str_def;
|
||||
int int_def;
|
||||
hash_table table;
|
||||
int table_size;
|
||||
{
|
||||
int hash_val = hashfunct (sym, table_size);
|
||||
register struct hash_entry *sym_entry = table[hash_val];
|
||||
register struct hash_entry *new_entry;
|
||||
register struct hash_entry *successor;
|
||||
|
||||
while ( sym_entry )
|
||||
{
|
||||
if ( ! strcmp( sym, sym_entry->name ) )
|
||||
{ /* entry already exists */
|
||||
while (sym_entry) {
|
||||
if (!strcmp (sym, sym_entry->name)) { /* entry already exists */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
sym_entry = sym_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* create new entry */
|
||||
new_entry = (struct hash_entry *)
|
||||
flex_alloc( sizeof( struct hash_entry ) );
|
||||
flex_alloc (sizeof (struct hash_entry));
|
||||
|
||||
if ( new_entry == NULL )
|
||||
flexfatal( _( "symbol table memory allocation failed" ) );
|
||||
if (new_entry == NULL)
|
||||
flexfatal (_("symbol table memory allocation failed"));
|
||||
|
||||
if ( (successor = table[hash_val]) != 0 )
|
||||
{
|
||||
if ((successor = table[hash_val]) != 0) {
|
||||
new_entry->next = successor;
|
||||
successor->prev = new_entry;
|
||||
}
|
||||
}
|
||||
else
|
||||
new_entry->next = NULL;
|
||||
|
||||
@ -93,24 +114,22 @@ int table_size;
|
||||
table[hash_val] = new_entry;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cclinstal - save the text of a character class */
|
||||
|
||||
void cclinstal( ccltxt, cclnum )
|
||||
Char ccltxt[];
|
||||
int cclnum;
|
||||
{
|
||||
void cclinstal (ccltxt, cclnum)
|
||||
Char ccltxt[];
|
||||
int cclnum;
|
||||
{
|
||||
/* We don't bother checking the return status because we are not
|
||||
* called unless the symbol is new.
|
||||
*/
|
||||
Char *copy_unsigned_string();
|
||||
|
||||
(void) addsym( (char *) copy_unsigned_string( ccltxt ),
|
||||
(char *) 0, cclnum,
|
||||
ccltab, CCL_HASH_SIZE );
|
||||
}
|
||||
(void) addsym ((char *) copy_unsigned_string (ccltxt),
|
||||
(char *) 0, cclnum, ccltab, CCL_HASH_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/* ccllookup - lookup the number associated with character class text
|
||||
@ -118,75 +137,71 @@ int cclnum;
|
||||
* Returns 0 if there's no CCL associated with the text.
|
||||
*/
|
||||
|
||||
int ccllookup( ccltxt )
|
||||
Char ccltxt[];
|
||||
{
|
||||
return findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val;
|
||||
}
|
||||
int ccllookup (ccltxt)
|
||||
Char ccltxt[];
|
||||
{
|
||||
return findsym ((char *) ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
|
||||
}
|
||||
|
||||
|
||||
/* findsym - find symbol in symbol table */
|
||||
|
||||
struct hash_entry *findsym( sym, table, table_size )
|
||||
register char sym[];
|
||||
hash_table table;
|
||||
int table_size;
|
||||
{
|
||||
static struct hash_entry empty_entry =
|
||||
{
|
||||
static struct hash_entry *findsym (sym, table, table_size)
|
||||
register const char *sym;
|
||||
hash_table table;
|
||||
int table_size;
|
||||
{
|
||||
static struct hash_entry empty_entry = {
|
||||
(struct hash_entry *) 0, (struct hash_entry *) 0,
|
||||
(char *) 0, (char *) 0, 0,
|
||||
} ;
|
||||
};
|
||||
register struct hash_entry *sym_entry =
|
||||
table[hashfunct( sym, table_size )];
|
||||
|
||||
while ( sym_entry )
|
||||
{
|
||||
if ( ! strcmp( sym, sym_entry->name ) )
|
||||
table[hashfunct (sym, table_size)];
|
||||
|
||||
while (sym_entry) {
|
||||
if (!strcmp (sym, sym_entry->name))
|
||||
return sym_entry;
|
||||
sym_entry = sym_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
return &empty_entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
|
||||
|
||||
int hashfunct( str, hash_size )
|
||||
register char str[];
|
||||
int hash_size;
|
||||
{
|
||||
static int hashfunct (str, hash_size)
|
||||
register const char *str;
|
||||
int hash_size;
|
||||
{
|
||||
register int hashval;
|
||||
register int locstr;
|
||||
|
||||
hashval = 0;
|
||||
locstr = 0;
|
||||
|
||||
while ( str[locstr] )
|
||||
{
|
||||
while (str[locstr]) {
|
||||
hashval = (hashval << 1) + (unsigned char) str[locstr++];
|
||||
hashval %= hash_size;
|
||||
}
|
||||
}
|
||||
|
||||
return hashval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ndinstal - install a name definition */
|
||||
|
||||
void ndinstal( name, definition )
|
||||
char name[];
|
||||
Char definition[];
|
||||
{
|
||||
char *copy_string();
|
||||
Char *copy_unsigned_string();
|
||||
void ndinstal (name, definition)
|
||||
const char *name;
|
||||
Char definition[];
|
||||
{
|
||||
|
||||
if ( addsym( copy_string( name ),
|
||||
(char *) copy_unsigned_string( definition ), 0,
|
||||
ndtbl, NAME_TABLE_HASH_SIZE ) )
|
||||
synerr( _( "name defined twice" ) );
|
||||
}
|
||||
if (addsym (copy_string (name),
|
||||
(char *) copy_unsigned_string (definition), 0,
|
||||
ndtbl, NAME_TABLE_HASH_SIZE))
|
||||
synerr (_("name defined twice"));
|
||||
}
|
||||
|
||||
|
||||
/* ndlookup - lookup a name definition
|
||||
@ -194,27 +209,27 @@ Char definition[];
|
||||
* Returns a nil pointer if the name definition does not exist.
|
||||
*/
|
||||
|
||||
Char *ndlookup( nd )
|
||||
char nd[];
|
||||
{
|
||||
return (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val;
|
||||
}
|
||||
Char *ndlookup (nd)
|
||||
const char *nd;
|
||||
{
|
||||
return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
|
||||
}
|
||||
|
||||
|
||||
/* scextend - increase the maximum number of start conditions */
|
||||
|
||||
void scextend()
|
||||
{
|
||||
void scextend ()
|
||||
{
|
||||
current_max_scs += MAX_SCS_INCREMENT;
|
||||
|
||||
++num_reallocs;
|
||||
|
||||
scset = reallocate_integer_array( scset, current_max_scs );
|
||||
scbol = reallocate_integer_array( scbol, current_max_scs );
|
||||
scxclu = reallocate_integer_array( scxclu, current_max_scs );
|
||||
sceof = reallocate_integer_array( sceof, current_max_scs );
|
||||
scname = reallocate_char_ptr_array( scname, current_max_scs );
|
||||
}
|
||||
scset = reallocate_integer_array (scset, current_max_scs);
|
||||
scbol = reallocate_integer_array (scbol, current_max_scs);
|
||||
scxclu = reallocate_integer_array (scxclu, current_max_scs);
|
||||
sceof = reallocate_integer_array (sceof, current_max_scs);
|
||||
scname = reallocate_char_ptr_array (scname, current_max_scs);
|
||||
}
|
||||
|
||||
|
||||
/* scinstal - make a start condition
|
||||
@ -223,31 +238,27 @@ void scextend()
|
||||
* The start condition is "exclusive" if xcluflg is true.
|
||||
*/
|
||||
|
||||
void scinstal( str, xcluflg )
|
||||
char str[];
|
||||
int xcluflg;
|
||||
{
|
||||
char *copy_string();
|
||||
void scinstal (str, xcluflg)
|
||||
const char *str;
|
||||
int xcluflg;
|
||||
{
|
||||
|
||||
/* Generate start condition definition, for use in BEGIN et al. */
|
||||
action_define( str, lastsc );
|
||||
if (++lastsc >= current_max_scs)
|
||||
scextend ();
|
||||
|
||||
if ( ++lastsc >= current_max_scs )
|
||||
scextend();
|
||||
scname[lastsc] = copy_string (str);
|
||||
|
||||
scname[lastsc] = copy_string( str );
|
||||
if (addsym (scname[lastsc], (char *) 0, lastsc,
|
||||
sctbl, START_COND_HASH_SIZE))
|
||||
format_pinpoint_message (_
|
||||
("start condition %s declared twice"),
|
||||
str);
|
||||
|
||||
if ( addsym( scname[lastsc], (char *) 0, lastsc,
|
||||
sctbl, START_COND_HASH_SIZE ) )
|
||||
format_pinpoint_message(
|
||||
_( "start condition %s declared twice" ),
|
||||
str );
|
||||
|
||||
scset[lastsc] = mkstate( SYM_EPSILON );
|
||||
scbol[lastsc] = mkstate( SYM_EPSILON );
|
||||
scset[lastsc] = mkstate (SYM_EPSILON);
|
||||
scbol[lastsc] = mkstate (SYM_EPSILON);
|
||||
scxclu[lastsc] = xcluflg;
|
||||
sceof[lastsc] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* sclookup - lookup the number associated with a start condition
|
||||
@ -255,8 +266,8 @@ int xcluflg;
|
||||
* Returns 0 if no such start condition.
|
||||
*/
|
||||
|
||||
int sclookup( str )
|
||||
char str[];
|
||||
{
|
||||
return findsym( str, sctbl, START_COND_HASH_SIZE )->int_val;
|
||||
}
|
||||
int sclookup (str)
|
||||
const char *str;
|
||||
{
|
||||
return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val;
|
||||
}
|
||||
|
497
src/bin/flex/tables.c
Normal file
497
src/bin/flex/tables.c
Normal file
@ -0,0 +1,497 @@
|
||||
/* tables.c - tables serialization code
|
||||
*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* This file is part of flex.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
*/
|
||||
|
||||
|
||||
#include "flexdef.h"
|
||||
#include "tables.h"
|
||||
|
||||
/** Convert size_t to t_flag.
|
||||
* @param n in {1,2,4}
|
||||
* @return YYTD_DATA*.
|
||||
*/
|
||||
#define BYTES2TFLAG(n)\
|
||||
(((n) == sizeof(flex_int8_t))\
|
||||
? YYTD_DATA8\
|
||||
:(((n)== sizeof(flex_int16_t))\
|
||||
? YYTD_DATA16\
|
||||
: YYTD_DATA32))
|
||||
|
||||
/** Clear YYTD_DATA* bit flags
|
||||
* @return the flag with the YYTD_DATA* bits cleared
|
||||
*/
|
||||
#define TFLAGS_CLRDATA(flg) ((flg) & ~(YYTD_DATA8 | YYTD_DATA16 | YYTD_DATA32))
|
||||
|
||||
int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v);
|
||||
int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v);
|
||||
int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v);
|
||||
int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len);
|
||||
static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i);
|
||||
static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
|
||||
int j, int k);
|
||||
|
||||
|
||||
/** Initialize the table writer.
|
||||
* @param wr an uninitialized writer
|
||||
* @param the output file
|
||||
* @return 0 on success
|
||||
*/
|
||||
int yytbl_writer_init (struct yytbl_writer *wr, FILE * out)
|
||||
{
|
||||
wr->out = out;
|
||||
wr->total_written = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Initialize a table header.
|
||||
* @param th The uninitialized structure
|
||||
* @param version_str the version string
|
||||
* @param name the name of this table set
|
||||
*/
|
||||
int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
|
||||
const char *name)
|
||||
{
|
||||
memset (th, 0, sizeof (struct yytbl_hdr));
|
||||
|
||||
th->th_magic = YYTBL_MAGIC;
|
||||
th->th_hsize = 14 + strlen (version_str) + 1 + strlen (name) + 1;
|
||||
th->th_hsize += yypad64 (th->th_hsize);
|
||||
th->th_ssize = 0; // Not known at this point.
|
||||
th->th_flags = 0;
|
||||
th->th_version = copy_string (version_str);
|
||||
th->th_name = copy_string (name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Allocate and initialize a table data structure.
|
||||
* @param tbl a pointer to an uninitialized table
|
||||
* @param id the table identifier
|
||||
* @return 0 on success
|
||||
*/
|
||||
int yytbl_data_init (struct yytbl_data *td, enum yytbl_id id)
|
||||
{
|
||||
|
||||
memset (td, 0, sizeof (struct yytbl_data));
|
||||
td->td_id = id;
|
||||
td->td_flags = YYTD_DATA32;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Clean up table and data array.
|
||||
* @param td will be destroyed
|
||||
* @return 0 on success
|
||||
*/
|
||||
int yytbl_data_destroy (struct yytbl_data *td)
|
||||
{
|
||||
if (td->td_data)
|
||||
free (td->td_data);
|
||||
td->td_data = 0;
|
||||
free (td);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Write enough padding to bring the file pointer to a 64-bit boundary. */
|
||||
static int yytbl_write_pad64 (struct yytbl_writer *wr)
|
||||
{
|
||||
int pad, bwritten = 0;
|
||||
|
||||
pad = yypad64 (wr->total_written);
|
||||
while (pad-- > 0)
|
||||
if (yytbl_write8 (wr, 0) < 0)
|
||||
return -1;
|
||||
else
|
||||
bwritten++;
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
/** write the header.
|
||||
* @param out the output stream
|
||||
* @param th table header to be written
|
||||
* @return -1 on error, or bytes written on success.
|
||||
*/
|
||||
int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th)
|
||||
{
|
||||
size_t sz, rv;
|
||||
int bwritten = 0;
|
||||
|
||||
if (yytbl_write32 (wr, th->th_magic) < 0
|
||||
|| yytbl_write32 (wr, th->th_hsize) < 0)
|
||||
flex_die (_("th_magic|th_hsize write32 failed"));
|
||||
bwritten += 8;
|
||||
|
||||
if (fgetpos (wr->out, &(wr->th_ssize_pos)) != 0)
|
||||
flex_die (_("fgetpos failed"));
|
||||
|
||||
if (yytbl_write32 (wr, th->th_ssize) < 0
|
||||
|| yytbl_write16 (wr, th->th_flags) < 0)
|
||||
flex_die (_("th_ssize|th_flags write failed"));
|
||||
bwritten += 6;
|
||||
|
||||
sz = strlen (th->th_version) + 1;
|
||||
if ((rv = yytbl_writen (wr, th->th_version, sz)) != sz)
|
||||
flex_die (_("th_version writen failed"));
|
||||
bwritten += rv;
|
||||
|
||||
sz = strlen (th->th_name) + 1;
|
||||
if ((rv = yytbl_writen (wr, th->th_name, sz)) != sz)
|
||||
flex_die (_("th_name writen failed"));
|
||||
bwritten += rv;
|
||||
|
||||
/* add padding */
|
||||
if ((rv = yytbl_write_pad64 (wr)) < 0)
|
||||
flex_die (_("pad64 failed"));
|
||||
bwritten += rv;
|
||||
|
||||
/* Sanity check */
|
||||
if (bwritten != th->th_hsize)
|
||||
flex_die (_("pad64 failed"));
|
||||
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
|
||||
/** Write this table.
|
||||
* @param out the file writer
|
||||
* @param td table data to be written
|
||||
* @return -1 on error, or bytes written on success.
|
||||
*/
|
||||
int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
{
|
||||
size_t rv;
|
||||
flex_int32_t bwritten = 0;
|
||||
flex_int32_t i, total_len;
|
||||
fpos_t pos;
|
||||
|
||||
if ((rv = yytbl_write16 (wr, td->td_id)) < 0)
|
||||
return -1;
|
||||
bwritten += rv;
|
||||
|
||||
if ((rv = yytbl_write16 (wr, td->td_flags)) < 0)
|
||||
return -1;
|
||||
bwritten += rv;
|
||||
|
||||
if ((rv = yytbl_write32 (wr, td->td_hilen)) < 0)
|
||||
return -1;
|
||||
bwritten += rv;
|
||||
|
||||
if ((rv = yytbl_write32 (wr, td->td_lolen)) < 0)
|
||||
return -1;
|
||||
bwritten += rv;
|
||||
|
||||
total_len = yytbl_calc_total_len (td);
|
||||
for (i = 0; i < total_len; i++) {
|
||||
switch (YYTDFLAGS2BYTES (td->td_flags)) {
|
||||
case sizeof (flex_int8_t):
|
||||
rv = yytbl_write8 (wr, yytbl_data_geti (td, i));
|
||||
break;
|
||||
case sizeof (flex_int16_t):
|
||||
rv = yytbl_write16 (wr, yytbl_data_geti (td, i));
|
||||
break;
|
||||
case sizeof (flex_int32_t):
|
||||
rv = yytbl_write32 (wr, yytbl_data_geti (td, i));
|
||||
break;
|
||||
default:
|
||||
flex_die (_("invalid td_flags detected"));
|
||||
}
|
||||
if (rv < 0) {
|
||||
flex_die (_("error while writing tables"));
|
||||
return -1;
|
||||
}
|
||||
bwritten += rv;
|
||||
}
|
||||
|
||||
/* Sanity check */
|
||||
if (bwritten != (12 + total_len * YYTDFLAGS2BYTES (td->td_flags))) {
|
||||
flex_die (_("insanity detected"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* add padding */
|
||||
if ((rv = yytbl_write_pad64 (wr)) < 0) {
|
||||
flex_die (_("pad64 failed"));
|
||||
return -1;
|
||||
}
|
||||
bwritten += rv;
|
||||
|
||||
/* Now go back and update the th_hsize member */
|
||||
if (fgetpos (wr->out, &pos) != 0
|
||||
|| fsetpos (wr->out, &(wr->th_ssize_pos)) != 0
|
||||
|| yytbl_write32 (wr, wr->total_written) < 0
|
||||
|| fsetpos (wr->out, &pos)) {
|
||||
flex_die (_("get|set|fwrite32 failed"));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
/* Don't count the int we just wrote. */
|
||||
wr->total_written -= sizeof (flex_int32_t);
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
/** Write n bytes.
|
||||
* @param wr the table writer
|
||||
* @param v data to be written
|
||||
* @param len number of bytes
|
||||
* @return -1 on error. number of bytes written on success.
|
||||
*/
|
||||
int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len)
|
||||
{
|
||||
size_t rv;
|
||||
|
||||
rv = fwrite (v, 1, len, wr->out);
|
||||
if (rv != len)
|
||||
return -1;
|
||||
wr->total_written += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
/** Write four bytes in network byte order
|
||||
* @param wr the table writer
|
||||
* @param v a dword in host byte order
|
||||
* @return -1 on error. number of bytes written on success.
|
||||
*/
|
||||
int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v)
|
||||
{
|
||||
flex_uint32_t vnet;
|
||||
size_t bytes, rv;
|
||||
|
||||
vnet = htonl (v);
|
||||
bytes = sizeof (flex_uint32_t);
|
||||
rv = fwrite (&vnet, bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/** Write two bytes in network byte order.
|
||||
* @param wr the table writer
|
||||
* @param v a word in host byte order
|
||||
* @return -1 on error. number of bytes written on success.
|
||||
*/
|
||||
int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v)
|
||||
{
|
||||
flex_uint16_t vnet;
|
||||
size_t bytes, rv;
|
||||
|
||||
vnet = htons (v);
|
||||
bytes = sizeof (flex_uint16_t);
|
||||
rv = fwrite (&vnet, bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/** Write a byte.
|
||||
* @param wr the table writer
|
||||
* @param v the value to be written
|
||||
* @return -1 on error. number of bytes written on success.
|
||||
*/
|
||||
int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v)
|
||||
{
|
||||
size_t bytes, rv;
|
||||
|
||||
bytes = sizeof (flex_uint8_t);
|
||||
rv = fwrite (&v, bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
/** Extract data element [i][j] from array data tables.
|
||||
* @param tbl data table
|
||||
* @param i index into higher dimension array. i should be zero for one-dimensional arrays.
|
||||
* @param j index into lower dimension array.
|
||||
* @param k index into struct, must be 0 or 1. Only valid for YYTD_ID_TRANSITION table
|
||||
* @return data[i][j + k]
|
||||
*/
|
||||
static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
|
||||
int j, int k)
|
||||
{
|
||||
flex_int32_t lo;
|
||||
|
||||
k %= 2;
|
||||
lo = tbl->td_lolen;
|
||||
|
||||
switch (YYTDFLAGS2BYTES (tbl->td_flags)) {
|
||||
case sizeof (flex_int8_t):
|
||||
return ((flex_int8_t *) (tbl->td_data))[(i * lo + j) * (k + 1) +
|
||||
k];
|
||||
case sizeof (flex_int16_t):
|
||||
return ((flex_int16_t *) (tbl->td_data))[(i * lo + j) * (k +
|
||||
1) +
|
||||
k];
|
||||
case sizeof (flex_int32_t):
|
||||
return ((flex_int32_t *) (tbl->td_data))[(i * lo + j) * (k +
|
||||
1) +
|
||||
k];
|
||||
default:
|
||||
flex_die (_("invalid td_flags detected"));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Extract data element [i] from array data tables treated as a single flat array of integers.
|
||||
* Be careful for 2-dimensional arrays or for YYTD_ID_TRANSITION, which is an array
|
||||
* of structs.
|
||||
* @param tbl data table
|
||||
* @param i index into array.
|
||||
* @return data[i]
|
||||
*/
|
||||
static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i)
|
||||
{
|
||||
|
||||
switch (YYTDFLAGS2BYTES (tbl->td_flags)) {
|
||||
case sizeof (flex_int8_t):
|
||||
return ((flex_int8_t *) (tbl->td_data))[i];
|
||||
case sizeof (flex_int16_t):
|
||||
return ((flex_int16_t *) (tbl->td_data))[i];
|
||||
case sizeof (flex_int32_t):
|
||||
return ((flex_int32_t *) (tbl->td_data))[i];
|
||||
default:
|
||||
flex_die (_("invalid td_flags detected"));
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set data element [i] in array data tables treated as a single flat array of integers.
|
||||
* Be careful for 2-dimensional arrays or for YYTD_ID_TRANSITION, which is an array
|
||||
* of structs.
|
||||
* @param tbl data table
|
||||
* @param i index into array.
|
||||
* @param newval new value for data[i]
|
||||
*/
|
||||
static void yytbl_data_seti (const struct yytbl_data *tbl, int i,
|
||||
flex_int32_t newval)
|
||||
{
|
||||
|
||||
switch (YYTDFLAGS2BYTES (tbl->td_flags)) {
|
||||
case sizeof (flex_int8_t):
|
||||
((flex_int8_t *) (tbl->td_data))[i] = (flex_int8_t) newval;
|
||||
break;
|
||||
case sizeof (flex_int16_t):
|
||||
((flex_int16_t *) (tbl->td_data))[i] = (flex_int16_t) newval;
|
||||
break;
|
||||
case sizeof (flex_int32_t):
|
||||
((flex_int32_t *) (tbl->td_data))[i] = (flex_int32_t) newval;
|
||||
break;
|
||||
default:
|
||||
flex_die (_("invalid td_flags detected"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Calculate the number of bytes needed to hold the largest
|
||||
* absolute value in this data array.
|
||||
* @param tbl the data table
|
||||
* @return sizeof(n) where n in {flex_int8_t, flex_int16_t, flex_int32_t}
|
||||
*/
|
||||
static size_t min_int_size (struct yytbl_data *tbl)
|
||||
{
|
||||
flex_uint32_t i, total_len;
|
||||
flex_int32_t max = 0;
|
||||
|
||||
total_len = yytbl_calc_total_len (tbl);
|
||||
|
||||
for (i = 0; i < total_len; i++) {
|
||||
flex_int32_t n;
|
||||
|
||||
n = abs (yytbl_data_geti (tbl, i));
|
||||
|
||||
if (n > max)
|
||||
max = n;
|
||||
}
|
||||
|
||||
if (max <= INT8_MAX)
|
||||
return sizeof (flex_int8_t);
|
||||
else if (max <= INT16_MAX)
|
||||
return sizeof (flex_int16_t);
|
||||
else
|
||||
return sizeof (flex_int32_t);
|
||||
}
|
||||
|
||||
/** Transform data to smallest possible of (int32, int16, int8).
|
||||
* For example, we may have generated an int32 array due to user options
|
||||
* (e.g., %option align), but if the maximum value in that array
|
||||
* is 80 (for example), then we can serialize it with only 1 byte per int.
|
||||
* This is NOT the same as compressed DFA tables. We're just trying
|
||||
* to save storage space here.
|
||||
*
|
||||
* @param tbl the table to be compressed
|
||||
*/
|
||||
void yytbl_data_compress (struct yytbl_data *tbl)
|
||||
{
|
||||
flex_int32_t i, newsz, total_len;
|
||||
struct yytbl_data newtbl;
|
||||
|
||||
yytbl_data_init (&newtbl, tbl->td_id);
|
||||
newtbl.td_hilen = tbl->td_hilen;
|
||||
newtbl.td_lolen = tbl->td_lolen;
|
||||
newtbl.td_flags = tbl->td_flags;
|
||||
|
||||
newsz = min_int_size (tbl);
|
||||
|
||||
|
||||
if (newsz == YYTDFLAGS2BYTES (tbl->td_flags))
|
||||
/* No change in this table needed. */
|
||||
return;
|
||||
|
||||
if (newsz > YYTDFLAGS2BYTES (tbl->td_flags)) {
|
||||
flex_die (_("detected negative compression"));
|
||||
return;
|
||||
}
|
||||
|
||||
total_len = yytbl_calc_total_len (tbl);
|
||||
newtbl.td_data = calloc (total_len, newsz);
|
||||
newtbl.td_flags =
|
||||
TFLAGS_CLRDATA (newtbl.td_flags) | BYTES2TFLAG (newsz);
|
||||
|
||||
for (i = 0; i < total_len; i++) {
|
||||
flex_int32_t g;
|
||||
|
||||
g = yytbl_data_geti (tbl, i);
|
||||
yytbl_data_seti (&newtbl, i, g);
|
||||
}
|
||||
|
||||
|
||||
/* Now copy over the old table */
|
||||
free (tbl->td_data);
|
||||
*tbl = newtbl;
|
||||
}
|
||||
|
||||
/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */
|
85
src/bin/flex/tables.h
Normal file
85
src/bin/flex/tables.h
Normal file
@ -0,0 +1,85 @@
|
||||
/* tables.h - tables serialization code
|
||||
*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* This file is part of flex.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef TABLES_H
|
||||
#define TABLES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/* Tables serialization API declarations. */
|
||||
#include "tables_shared.h"
|
||||
struct yytbl_writer {
|
||||
FILE *out;
|
||||
flex_uint32_t total_written;
|
||||
/**< bytes written so far */
|
||||
fpos_t th_ssize_pos;
|
||||
/**< position of th_ssize */
|
||||
};
|
||||
|
||||
/* These are used by main.c, gen.c, etc.
|
||||
* tablesext - if true, create external tables
|
||||
* tablesfilename - filename for external tables
|
||||
* tablesname - name that goes in serialized data, e.g., "yytables"
|
||||
* tableswr - writer for external tables
|
||||
* tablesverify - true if tables-verify option specified
|
||||
* gentables - true if we should spit out the normal C tables
|
||||
*/
|
||||
extern bool tablesext, tablesverify,gentables;
|
||||
extern char *tablesfilename, *tablesname;
|
||||
extern struct yytbl_writer tableswr;
|
||||
|
||||
int yytbl_writer_init (struct yytbl_writer *, FILE *);
|
||||
int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
|
||||
const char *name);
|
||||
int yytbl_data_init (struct yytbl_data *tbl, enum yytbl_id id);
|
||||
int yytbl_data_destroy (struct yytbl_data *td);
|
||||
int yytbl_hdr_fwrite (struct yytbl_writer *wr,
|
||||
const struct yytbl_hdr *th);
|
||||
int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td);
|
||||
void yytbl_data_compress (struct yytbl_data *tbl);
|
||||
struct yytbl_data *mkftbl (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */
|
70
src/bin/flex/tables_shared.c
Normal file
70
src/bin/flex/tables_shared.c
Normal file
@ -0,0 +1,70 @@
|
||||
#ifdef FLEX_SCANNER
|
||||
/*
|
||||
dnl tables_shared.c - tables serialization code
|
||||
dnl
|
||||
dnl Copyright (c) 1990 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl
|
||||
dnl This code is derived from software contributed to Berkeley by
|
||||
dnl Vern Paxson.
|
||||
dnl
|
||||
dnl The United States Government has rights in this work pursuant
|
||||
dnl to contract no. DE-AC03-76SF00098 between the United States
|
||||
dnl Department of Energy and the University of California.
|
||||
dnl
|
||||
dnl This file is part of flex.
|
||||
dnl
|
||||
dnl Redistribution and use in source and binary forms, with or without
|
||||
dnl modification, are permitted provided that the following conditions
|
||||
dnl are met:
|
||||
dnl
|
||||
dnl 1. Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl 2. Redistributions in binary form must reproduce the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer in the
|
||||
dnl documentation and/or other materials provided with the distribution.
|
||||
dnl
|
||||
dnl Neither the name of the University nor the names of its contributors
|
||||
dnl may be used to endorse or promote products derived from this software
|
||||
dnl without specific prior written permission.
|
||||
dnl
|
||||
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
dnl IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
dnl PURPOSE.
|
||||
dnl
|
||||
*/
|
||||
|
||||
/* This file is meant to be included in both the skeleton and the actual
|
||||
* flex code (hence the name "_shared").
|
||||
*/
|
||||
#ifndef yyskel_static
|
||||
#define yyskel_static static
|
||||
#endif
|
||||
#else
|
||||
#include "flexdef.h"
|
||||
#include "tables.h"
|
||||
#ifndef yyskel_static
|
||||
#define yyskel_static
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/** Get the number of integers in this table. This is NOT the
|
||||
* same thing as the number of elements.
|
||||
* @param td the table
|
||||
* @return the number of integers in the table
|
||||
*/
|
||||
yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl)
|
||||
{
|
||||
flex_int32_t n;
|
||||
|
||||
/* total number of ints */
|
||||
n = tbl->td_lolen;
|
||||
if (tbl->td_hilen > 0)
|
||||
n *= tbl->td_hilen;
|
||||
|
||||
if (tbl->td_id == YYTD_ID_TRANSITION)
|
||||
n *= 2;
|
||||
return n;
|
||||
}
|
144
src/bin/flex/tables_shared.h
Normal file
144
src/bin/flex/tables_shared.h
Normal file
@ -0,0 +1,144 @@
|
||||
#ifdef FLEX_SCANNER
|
||||
/*
|
||||
dnl tables_shared.h - tables serialization header
|
||||
dnl
|
||||
dnl Copyright (c) 1990 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl
|
||||
dnl This code is derived from software contributed to Berkeley by
|
||||
dnl Vern Paxson.
|
||||
dnl
|
||||
dnl The United States Government has rights in this work pursuant
|
||||
dnl to contract no. DE-AC03-76SF00098 between the United States
|
||||
dnl Department of Energy and the University of California.
|
||||
dnl
|
||||
dnl This file is part of flex.
|
||||
dnl
|
||||
dnl Redistribution and use in source and binary forms, with or without
|
||||
dnl modification, are permitted provided that the following conditions
|
||||
dnl are met:
|
||||
dnl
|
||||
dnl 1. Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl 2. Redistributions in binary form must reproduce the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer in the
|
||||
dnl documentation and/or other materials provided with the distribution.
|
||||
dnl
|
||||
dnl Neither the name of the University nor the names of its contributors
|
||||
dnl may be used to endorse or promote products derived from this software
|
||||
dnl without specific prior written permission.
|
||||
dnl
|
||||
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
dnl IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
dnl PURPOSE.
|
||||
|
||||
dnl
|
||||
dnl This file is meant to be included in both the skeleton and the actual
|
||||
dnl flex code (hence the name "_shared").
|
||||
*/
|
||||
#ifndef yyskel_static
|
||||
#define yyskel_static static
|
||||
#endif
|
||||
#else
|
||||
#ifndef yyskel_static
|
||||
#define yyskel_static
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Structures and prototypes for serializing flex tables. The
|
||||
* binary format is documented in the manual.
|
||||
*
|
||||
* Design considerations:
|
||||
*
|
||||
* - The format allows many tables per file.
|
||||
* - The tables can be streamed.
|
||||
* - All data is stored in network byte order.
|
||||
* - We do not hinder future unicode support.
|
||||
* - We can lookup tables by name.
|
||||
*/
|
||||
|
||||
/** Magic number for serialized format. */
|
||||
#ifndef YYTBL_MAGIC
|
||||
#define YYTBL_MAGIC 0xF13C57B1
|
||||
#endif
|
||||
|
||||
/** Calculate (0-7) = number bytes needed to pad n to next 64-bit boundary. */
|
||||
#ifndef yypad64
|
||||
#define yypad64(n) ((8-((n)%8))%8)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef YYTABLES_TYPES
|
||||
#define YYTABLES_TYPES
|
||||
/** Possible values for td_id field. Each one corresponds to a
|
||||
* scanner table of the same name.
|
||||
*/
|
||||
enum yytbl_id {
|
||||
YYTD_ID_ACCEPT = 0x01, /**< 1-dim ints */
|
||||
YYTD_ID_BASE = 0x02, /**< 1-dim ints */
|
||||
YYTD_ID_CHK = 0x03, /**< 1-dim ints */
|
||||
YYTD_ID_DEF = 0x04, /**< 1-dim ints */
|
||||
YYTD_ID_EC = 0x05, /**< 1-dim ints */
|
||||
YYTD_ID_META = 0x06, /**< 1-dim ints */
|
||||
YYTD_ID_NUL_TRANS = 0x07, /**< 1-dim ints, maybe indices */
|
||||
YYTD_ID_NXT = 0x08, /**< may be 2 dimensional ints */
|
||||
YYTD_ID_RULE_CAN_MATCH_EOL = 0x09, /**< 1-dim ints */
|
||||
YYTD_ID_START_STATE_LIST = 0x0A, /**< 1-dim indices into trans tbl */
|
||||
YYTD_ID_TRANSITION = 0x0B, /**< structs */
|
||||
YYTD_ID_ACCLIST = 0x0C /**< 1-dim ints */
|
||||
};
|
||||
|
||||
/** bit flags for t_flags field of struct yytbl_data */
|
||||
enum yytbl_flags {
|
||||
/* These first three are mutually exclusive */
|
||||
YYTD_DATA8 = 0x01, /**< data is an array of type flex_int8_t */
|
||||
YYTD_DATA16 = 0x02, /**< data is an array of type flex_int16_t */
|
||||
YYTD_DATA32 = 0x04, /**< data is an array of type flex_int32_t */
|
||||
|
||||
/* These two are mutually exclusive. */
|
||||
YYTD_PTRANS = 0x08, /**< data is a list of indexes of entries
|
||||
into the expanded `yy_transition'
|
||||
array. See notes in manual. */
|
||||
YYTD_STRUCT = 0x10 /**< data consists of yy_trans_info structs */
|
||||
};
|
||||
|
||||
/* The serialized tables header. */
|
||||
struct yytbl_hdr {
|
||||
flex_uint32_t th_magic; /**< Must be 0xF13C57B1 (comes from "Flex Table") */
|
||||
flex_uint32_t th_hsize; /**< Size of this header in bytes. */
|
||||
flex_uint32_t th_ssize; /**< Size of this dataset, in bytes, including header. */
|
||||
flex_uint16_t th_flags; /**< Currently unused, must be 0 */
|
||||
char *th_version; /**< Flex version string. NUL terminated. */
|
||||
char *th_name; /**< The name of this table set. NUL terminated. */
|
||||
};
|
||||
|
||||
/** A single serialized table */
|
||||
struct yytbl_data {
|
||||
flex_uint16_t td_id; /**< enum yytbl_id table identifier */
|
||||
flex_uint16_t td_flags; /**< how to interpret this data */
|
||||
flex_uint32_t td_hilen; /**< num elements in highest dimension array */
|
||||
flex_uint32_t td_lolen; /**< num elements in lowest dimension array */
|
||||
void *td_data; /**< table data */
|
||||
};
|
||||
#endif
|
||||
|
||||
/** Extract corresponding data size_t from td_flags */
|
||||
#ifndef YYTDFLAGS2BYTES
|
||||
#define YYTDFLAGS2BYTES(td_flags)\
|
||||
(((td_flags) & YYTD_DATA8)\
|
||||
? sizeof(flex_int8_t)\
|
||||
:(((td_flags) & YYTD_DATA16)\
|
||||
? sizeof(flex_int16_t)\
|
||||
:sizeof(flex_int32_t)))
|
||||
#endif
|
||||
|
||||
#ifdef FLEX_SCANNER
|
||||
%not-for-header
|
||||
#endif
|
||||
yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl);
|
||||
#ifdef FLEX_SCANNER
|
||||
%ok-for-header
|
||||
#endif
|
||||
|
||||
/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */
|
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
#define FLEX_VERSION "2.5.4"
|
||||
#define FLEX_VERSION VERSION
|
||||
|
@ -1,32 +1,35 @@
|
||||
/* yylex - scanner front-end for flex */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Vern Paxson.
|
||||
*
|
||||
* The United States Government has rights in this work pursuant
|
||||
* to contract no. DE-AC03-76SF00098 between the United States
|
||||
* Department of Energy and the University of California.
|
||||
*
|
||||
* Redistribution and use in source and binary forms with or without
|
||||
* modification are permitted provided that: (1) source distributions retain
|
||||
* this entire copyright notice and comment, and (2) distributions including
|
||||
* binaries display the following acknowledgement: ``This product includes
|
||||
* software developed by the University of California, Berkeley and its
|
||||
* contributors'' in the documentation or other materials provided with the
|
||||
* distribution and in all advertising materials mentioning features or use
|
||||
* of this software. Neither the name of the University nor the names of
|
||||
* its contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
/* Copyright (c) 1990 The Regents of the University of California. */
|
||||
/* All rights reserved. */
|
||||
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/apps/bin/flex/yylex.c,v 1.1 2004/06/14 09:18:17 korli Exp $ */
|
||||
/* This code is derived from software contributed to Berkeley by */
|
||||
/* Vern Paxson. */
|
||||
|
||||
/* The United States Government has rights in this work pursuant */
|
||||
/* to contract no. DE-AC03-76SF00098 between the United States */
|
||||
/* Department of Energy and the University of California. */
|
||||
|
||||
/* This file is part of flex. */
|
||||
|
||||
/* Redistribution and use in source and binary forms, with or without */
|
||||
/* modification, are permitted provided that the following conditions */
|
||||
/* are met: */
|
||||
|
||||
/* 1. Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* 2. Redistributions in binary form must reproduce the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
|
||||
/* Neither the name of the University nor the names of its contributors */
|
||||
/* may be used to endorse or promote products derived from this software */
|
||||
/* without specific prior written permission. */
|
||||
|
||||
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include <ctype.h>
|
||||
#include "flexdef.h"
|
||||
@ -35,42 +38,94 @@
|
||||
|
||||
/* yylex - scan for a regular expression token */
|
||||
|
||||
int yylex()
|
||||
{
|
||||
int toktype;
|
||||
int yylex ()
|
||||
{
|
||||
int toktype;
|
||||
static int beglin = false;
|
||||
extern char *yytext;
|
||||
|
||||
if ( eofseen )
|
||||
if (eofseen)
|
||||
toktype = EOF;
|
||||
else
|
||||
toktype = flexscan();
|
||||
toktype = flexscan ();
|
||||
|
||||
if ( toktype == EOF || toktype == 0 )
|
||||
{
|
||||
if (toktype == EOF || toktype == 0) {
|
||||
eofseen = 1;
|
||||
|
||||
if ( sectnum == 1 )
|
||||
{
|
||||
synerr( _( "premature EOF" ) );
|
||||
if (sectnum == 1) {
|
||||
synerr (_("premature EOF"));
|
||||
sectnum = 2;
|
||||
toktype = SECTEND;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
toktype = 0;
|
||||
}
|
||||
|
||||
if (trace) {
|
||||
if (beglin) {
|
||||
fprintf (stderr, "%d\t", num_rules + 1);
|
||||
beglin = 0;
|
||||
}
|
||||
|
||||
if ( trace )
|
||||
{
|
||||
if ( beglin )
|
||||
{
|
||||
fprintf( stderr, "%d\t", num_rules + 1 );
|
||||
beglin = 0;
|
||||
}
|
||||
switch (toktype) {
|
||||
case '<':
|
||||
case '>':
|
||||
case '^':
|
||||
case '$':
|
||||
case '"':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '|':
|
||||
case '(':
|
||||
case ')':
|
||||
case '-':
|
||||
case '/':
|
||||
case '\\':
|
||||
case '?':
|
||||
case '.':
|
||||
case '*':
|
||||
case '+':
|
||||
case ',':
|
||||
(void) putc (toktype, stderr);
|
||||
break;
|
||||
|
||||
switch ( toktype )
|
||||
{
|
||||
case '\n':
|
||||
(void) putc ('\n', stderr);
|
||||
|
||||
if (sectnum == 2)
|
||||
beglin = 1;
|
||||
|
||||
break;
|
||||
|
||||
case SCDECL:
|
||||
fputs ("%s", stderr);
|
||||
break;
|
||||
|
||||
case XSCDECL:
|
||||
fputs ("%x", stderr);
|
||||
break;
|
||||
|
||||
case SECTEND:
|
||||
fputs ("%%\n", stderr);
|
||||
|
||||
/* We set beglin to be true so we'll start
|
||||
* writing out numbers as we echo rules.
|
||||
* flexscan() has already assigned sectnum.
|
||||
*/
|
||||
if (sectnum == 2)
|
||||
beglin = 1;
|
||||
|
||||
break;
|
||||
|
||||
case NAME:
|
||||
fprintf (stderr, "'%s'", nmstr);
|
||||
break;
|
||||
|
||||
case CHAR:
|
||||
switch (yylval) {
|
||||
case '<':
|
||||
case '>':
|
||||
case '^':
|
||||
@ -91,126 +146,66 @@ int yylex()
|
||||
case '*':
|
||||
case '+':
|
||||
case ',':
|
||||
(void) putc( toktype, stderr );
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
(void) putc( '\n', stderr );
|
||||
|
||||
if ( sectnum == 2 )
|
||||
beglin = 1;
|
||||
|
||||
break;
|
||||
|
||||
case SCDECL:
|
||||
fputs( "%s", stderr );
|
||||
break;
|
||||
|
||||
case XSCDECL:
|
||||
fputs( "%x", stderr );
|
||||
break;
|
||||
|
||||
case SECTEND:
|
||||
fputs( "%%\n", stderr );
|
||||
|
||||
/* We set beglin to be true so we'll start
|
||||
* writing out numbers as we echo rules.
|
||||
* flexscan() has already assigned sectnum.
|
||||
*/
|
||||
if ( sectnum == 2 )
|
||||
beglin = 1;
|
||||
|
||||
break;
|
||||
|
||||
case NAME:
|
||||
fprintf( stderr, "'%s'", nmstr );
|
||||
break;
|
||||
|
||||
case CHAR:
|
||||
switch ( yylval )
|
||||
{
|
||||
case '<':
|
||||
case '>':
|
||||
case '^':
|
||||
case '$':
|
||||
case '"':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '|':
|
||||
case '(':
|
||||
case ')':
|
||||
case '-':
|
||||
case '/':
|
||||
case '\\':
|
||||
case '?':
|
||||
case '.':
|
||||
case '*':
|
||||
case '+':
|
||||
case ',':
|
||||
fprintf( stderr, "\\%c",
|
||||
yylval );
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( ! isascii( yylval ) ||
|
||||
! isprint( yylval ) )
|
||||
fprintf( stderr,
|
||||
"\\%.3o",
|
||||
(unsigned int) yylval );
|
||||
else
|
||||
(void) putc( yylval,
|
||||
stderr );
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NUMBER:
|
||||
fprintf( stderr, "%d", yylval );
|
||||
break;
|
||||
|
||||
case PREVCCL:
|
||||
fprintf( stderr, "[%d]", yylval );
|
||||
break;
|
||||
|
||||
case EOF_OP:
|
||||
fprintf( stderr, "<<EOF>>" );
|
||||
break;
|
||||
|
||||
case OPTION_OP:
|
||||
fprintf( stderr, "%s ", yytext );
|
||||
break;
|
||||
|
||||
case OPT_OUTFILE:
|
||||
case OPT_PREFIX:
|
||||
case CCE_ALNUM:
|
||||
case CCE_ALPHA:
|
||||
case CCE_BLANK:
|
||||
case CCE_CNTRL:
|
||||
case CCE_DIGIT:
|
||||
case CCE_GRAPH:
|
||||
case CCE_LOWER:
|
||||
case CCE_PRINT:
|
||||
case CCE_PUNCT:
|
||||
case CCE_SPACE:
|
||||
case CCE_UPPER:
|
||||
case CCE_XDIGIT:
|
||||
fprintf( stderr, "%s", yytext );
|
||||
break;
|
||||
|
||||
case 0:
|
||||
fprintf( stderr, _( "End Marker\n" ) );
|
||||
fprintf (stderr, "\\%c", yylval);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr,
|
||||
_( "*Something Weird* - tok: %d val: %d\n" ),
|
||||
toktype, yylval );
|
||||
if (!isascii (yylval) || !isprint (yylval))
|
||||
fprintf (stderr,
|
||||
"\\%.3o",
|
||||
(unsigned int) yylval);
|
||||
else
|
||||
(void) putc (yylval, stderr);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NUMBER:
|
||||
fprintf (stderr, "%d", yylval);
|
||||
break;
|
||||
|
||||
case PREVCCL:
|
||||
fprintf (stderr, "[%d]", yylval);
|
||||
break;
|
||||
|
||||
case EOF_OP:
|
||||
fprintf (stderr, "<<EOF>>");
|
||||
break;
|
||||
|
||||
case OPTION_OP:
|
||||
fprintf (stderr, "%s ", yytext);
|
||||
break;
|
||||
|
||||
case OPT_OUTFILE:
|
||||
case OPT_PREFIX:
|
||||
case CCE_ALNUM:
|
||||
case CCE_ALPHA:
|
||||
case CCE_BLANK:
|
||||
case CCE_CNTRL:
|
||||
case CCE_DIGIT:
|
||||
case CCE_GRAPH:
|
||||
case CCE_LOWER:
|
||||
case CCE_PRINT:
|
||||
case CCE_PUNCT:
|
||||
case CCE_SPACE:
|
||||
case CCE_UPPER:
|
||||
case CCE_XDIGIT:
|
||||
fprintf (stderr, "%s", yytext);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
fprintf (stderr, _("End Marker\n"));
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf (stderr,
|
||||
_
|
||||
("*Something Weird* - tok: %d val: %d\n"),
|
||||
toktype, yylval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return toktype;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user