Import flex 2.6.4.
This commit is contained in:
parent
c4cb121a57
commit
764685116c
206
FlexLexer.h
206
FlexLexer.h
@ -1,206 +0,0 @@
|
||||
// -*-C++-*-
|
||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
||||
// by flex
|
||||
|
||||
// Copyright (c) 1993 The Regents of the University of California.
|
||||
// All rights reserved.
|
||||
//
|
||||
// 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 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 file defines FlexLexer, an abstract class which specifies the
|
||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
||||
// which defines a particular lexer class.
|
||||
//
|
||||
// If you want to create multiple lexer classes, you use the -P flag
|
||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define __FLEX_LEXER_H
|
||||
|
||||
#include <iostream>
|
||||
# ifndef FLEX_STD
|
||||
# define FLEX_STD std::
|
||||
# endif
|
||||
|
||||
extern "C++" {
|
||||
|
||||
struct yy_buffer_state;
|
||||
typedef int yy_state_type;
|
||||
|
||||
class FlexLexer {
|
||||
public:
|
||||
virtual ~FlexLexer() { }
|
||||
|
||||
const char* YYText() const { return yytext; }
|
||||
int YYLeng() const { return yyleng; }
|
||||
|
||||
virtual void
|
||||
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
|
||||
virtual struct yy_buffer_state*
|
||||
yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
||||
virtual void yyrestart( FLEX_STD istream* s ) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( FLEX_STD istream* new_in = 0,
|
||||
FLEX_STD ostream* new_out = 0 ) = 0;
|
||||
|
||||
int lineno() const { return yylineno; }
|
||||
|
||||
int debug() const { return yy_flex_debug; }
|
||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
||||
|
||||
protected:
|
||||
char* yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
};
|
||||
|
||||
}
|
||||
#endif // FLEXLEXER_H
|
||||
|
||||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
||||
// or this is a repeated include to define a different flavor of
|
||||
// yyFlexLexer, as discussed in the flex manual.
|
||||
#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( 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( FLEX_STD istream* s, int size );
|
||||
void yy_delete_buffer( struct yy_buffer_state* b );
|
||||
void yyrestart( FLEX_STD istream* s );
|
||||
|
||||
void yypush_buffer_state( struct yy_buffer_state* new_buffer );
|
||||
void yypop_buffer_state();
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
|
||||
virtual int yywrap();
|
||||
|
||||
protected:
|
||||
virtual int LexerInput( char* buf, int max_size );
|
||||
virtual void LexerOutput( const char* buf, int size );
|
||||
virtual void LexerError( const char* msg );
|
||||
|
||||
void yyunput( int c, char* buf_ptr );
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
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;
|
||||
int yy_start_stack_depth;
|
||||
int* yy_start_stack;
|
||||
|
||||
void yy_push_state( int new_state );
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_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;
|
||||
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
|
||||
// Points to current character in buffer.
|
||||
char* yy_c_buf_p;
|
||||
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// 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()).
|
||||
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char* yy_last_accepting_cpos;
|
||||
|
||||
yy_state_type* yy_state_buf;
|
||||
yy_state_type* yy_state_ptr;
|
||||
|
||||
char* yy_full_match;
|
||||
int* yy_full_state;
|
||||
int yy_full_lp;
|
||||
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // yyFlexLexer || ! yyFlexLexerOnce
|
||||
|
365
INSTALL
365
INSTALL
@ -1,365 +0,0 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
||||
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the `README' file for
|
||||
instructions specific to this package. Some packages provide this
|
||||
`INSTALL' file but do not implement all of the features documented
|
||||
below. The lack of an optional feature in a given package is not
|
||||
necessarily a bug. More recommendations for GNU packages can be found
|
||||
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||
|
||||
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').
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||
you want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system.
|
||||
|
||||
Running `configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the `make install' phase executed with root
|
||||
privileges.
|
||||
|
||||
5. Optionally, type `make installcheck' to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior `make install' required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
6. 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.
|
||||
|
||||
7. Often, you can also type `make uninstall' to remove the installed
|
||||
files again. In practice, not all packages have tested that
|
||||
uninstallation works correctly, even though it is required by the
|
||||
GNU Coding Standards.
|
||||
|
||||
8. Some packages, particularly those that use Automake, provide `make
|
||||
distcheck', which can by used by developers to test that all other
|
||||
targets like `make install' and `make uninstall' work correctly.
|
||||
This target is generally not run by end users.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
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.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
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 can use 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 `..'. This
|
||||
is known as a "VPATH" build.
|
||||
|
||||
With a non-GNU `make', it is safer 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.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple `-arch' options to the
|
||||
compiler but only a single `-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the `lipo' tool if you have problems.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' 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. In general, the
|
||||
default for these options is expressed in terms of `${prefix}', so that
|
||||
specifying just `--prefix' will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to `configure'; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
`make install' command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, `make install
|
||||
prefix=/alternate/directory' will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
`${prefix}'. Any directories that were specified during `configure',
|
||||
but not in terms of `${prefix}', must each be overridden at install
|
||||
time for the entire installation to be relocated. The approach of
|
||||
makefile variable overrides for each directory variable is required by
|
||||
the GNU Coding Standards, and ideally causes no recompilation.
|
||||
However, some platforms have known limitations with the semantics of
|
||||
shared libraries that end up requiring recompilation when using this
|
||||
method, particularly noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the `DESTDIR' variable. For
|
||||
example, `make install DESTDIR=/alternate/directory' will prepend
|
||||
`/alternate/directory' before all installation names. The approach of
|
||||
`DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of `${prefix}'
|
||||
at `configure' time.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
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'.
|
||||
|
||||
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.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of `make' will be. For these packages, running `./configure
|
||||
--enable-silent-rules' sets the default to minimal output, which can be
|
||||
overridden with `make V=1'; while running `./configure
|
||||
--disable-silent-rules' sets the default to verbose, which can be
|
||||
overridden with `make V=0'.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||
CC is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
|
||||
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||
to try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
|
||||
directory contains several dysfunctional programs; working variants of
|
||||
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
|
||||
in your `PATH', put it _after_ `/usr/bin'.
|
||||
|
||||
On Haiku, software installed for all users goes in `/boot/common',
|
||||
not `/usr/local'. It is recommended to use the following options:
|
||||
|
||||
./configure --prefix=/boot/common
|
||||
|
||||
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 option `--target=TYPE' 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
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of all of the options to `configure', and exit.
|
||||
|
||||
`--help=short'
|
||||
`--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
`configure', and exit. The `short' variant lists options used
|
||||
only in the top level, while the `recursive' variant lists options
|
||||
also present in any nested packages.
|
||||
|
||||
`--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.
|
||||
|
||||
`--prefix=DIR'
|
||||
Use DIR as the installation prefix. *note Installation Names::
|
||||
for more details, including other options available for fine-tuning
|
||||
the installation locations.
|
||||
|
||||
`--no-create'
|
||||
`-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
166
Makefile.am
166
Makefile.am
@ -27,136 +27,27 @@
|
||||
# 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@
|
||||
|
||||
bin_PROGRAMS = flex
|
||||
lib_LIBRARIES = \
|
||||
libfl.a \
|
||||
libfl_pic.a
|
||||
|
||||
flex_SOURCES = \
|
||||
ccl.c \
|
||||
dfa.c \
|
||||
ecs.c \
|
||||
scanflags.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
|
||||
|
||||
|
||||
LDADD = lib/libcompat.a
|
||||
|
||||
libfl_a_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
|
||||
libfl_pic_a_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
|
||||
libfl_pic_a_CFLAGS = \
|
||||
-fPIC \
|
||||
$(AM_CFLAGS)
|
||||
|
||||
noinst_HEADERS = \
|
||||
flexdef.h \
|
||||
flexint.h \
|
||||
version.h \
|
||||
options.h \
|
||||
scanopt.h \
|
||||
tables.h \
|
||||
tables_shared.h
|
||||
|
||||
include_HEADERS = \
|
||||
FlexLexer.h
|
||||
|
||||
dist_doc_DATA = \
|
||||
AUTHORS \
|
||||
COPYING \
|
||||
NEWS \
|
||||
ONEWS \
|
||||
README \
|
||||
README.cvs \
|
||||
TODO
|
||||
README.md
|
||||
|
||||
EXTRA_DIST = \
|
||||
.indent.pro \
|
||||
ABOUT-NLS \
|
||||
INSTALL \
|
||||
autogen.sh \
|
||||
flex.skl \
|
||||
mkskel.sh \
|
||||
config.rpath \
|
||||
gettext.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
skel.c
|
||||
autogen.sh
|
||||
|
||||
SUBDIRS = \
|
||||
lib \
|
||||
. \
|
||||
src \
|
||||
doc \
|
||||
examples \
|
||||
po \
|
||||
tools \
|
||||
tests
|
||||
|
||||
localedir = $(datadir)/locale
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -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
|
||||
scanflags.o: scanflags.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
|
||||
tests \
|
||||
tools
|
||||
|
||||
# Create the ChangeLog, but only if we're inside a git working directory
|
||||
|
||||
@ -165,52 +56,11 @@ ChangeLog: $(srcdir)/tools/git2cl
|
||||
$(srcdir)/tools/git2cl > $@ \
|
||||
; 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 \
|
||||
scanflags.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
|
||||
cd src && $(MAKE) $(AM_MAKEFLAGS) indent
|
||||
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)/$(bindir) && \
|
||||
cd $(DESTDIR)$(bindir) && \
|
||||
$(LN_S) -f flex$(EXEEXT) flex++$(EXEEXT)
|
||||
|
||||
.PHONY: ChangeLog tags indent
|
||||
.PHONY: ChangeLog indent
|
||||
|
968
Makefile.in
968
Makefile.in
File diff suppressed because it is too large
Load Diff
234
NEWS
234
NEWS
@ -1,7 +1,233 @@
|
||||
This is the file NEWS for the flex package. It records user -visible
|
||||
changes between releases of flex.
|
||||
flex NEWS
|
||||
|
||||
See the file COPYING for copying conditions.
|
||||
* Noteworthy changes in release 2.6.4 (2017-05-06) [stable]
|
||||
|
||||
** build
|
||||
|
||||
*** The indent target now knows about flex's new (as of 2.6.0)
|
||||
layout. The indent rules it would apply are not correct and do
|
||||
need to be fixed.
|
||||
|
||||
*** The files included in the flex distribution are now built by the
|
||||
version of flex that is included in the distribution.
|
||||
|
||||
*** The configure script has a better idea of which headers are
|
||||
required to build flex. It will also error when missing functions
|
||||
are detected.
|
||||
|
||||
*** We have lowered the versions of automake and gettext that
|
||||
configure.ac lists as required for building flex. In autogen.sh,
|
||||
we now check for how to call libtoolize and use what we find in
|
||||
the rest of the script.
|
||||
|
||||
*** Since files in lib/ are picked up as needed by src/, we no longer
|
||||
generate a Makefile for that directory.
|
||||
|
||||
*** Flex can be cross compiled.
|
||||
|
||||
** documentation
|
||||
|
||||
*** Some typos were removed from the manual.
|
||||
|
||||
** scanner
|
||||
|
||||
*** Some minor performance enhancements.
|
||||
|
||||
*** We honor user defined yy_* macros again. We are also more careful
|
||||
to not leak macro definitions into header files.
|
||||
|
||||
*** A number of portability fixes were introduced so building flex is
|
||||
more reliable on more platforms. Additionally, outdated function
|
||||
calls were removed.
|
||||
|
||||
*** When building the flex executable itself, %# comments from
|
||||
flex.skl are removed when generating the C source code array. This
|
||||
reduces the size of flex.
|
||||
|
||||
** test suite
|
||||
|
||||
*** All scripts in the test suite are now run by $(SHELL) and the
|
||||
needed portability fixes have been included.
|
||||
|
||||
*** Test suite dependencies are handled much better. This only matters
|
||||
if you are actively developing flex or its test suite.
|
||||
|
||||
*** Tests that depend on platform dependent features now properly skip
|
||||
when those platforms are not present.
|
||||
|
||||
*** When running "make check", you can now pas V=0 to silence more of
|
||||
the build. This is useful when you're less connncerned about the
|
||||
details of building and linking the test programs themselves.
|
||||
|
||||
* Noteworthy changes in release 2.6.3 (2016-12-30) [stable]
|
||||
|
||||
** scanner
|
||||
|
||||
*** several bug fixes resolved problems introduced in recent flex
|
||||
versions regarding processing of comments, literals and various
|
||||
quoting scenarios.
|
||||
|
||||
*** If the path to m4 was sufficiently long, a buffer overflow could
|
||||
occur. This has been resolved. The fix also removes dependence on
|
||||
the constant PATH_MAX.
|
||||
|
||||
** build
|
||||
|
||||
*** A new configure option --disable-bootstrap changes the behavior of
|
||||
the build system when building flex. The default
|
||||
"--enable-bootstrap" behavior is to build flex, then to use that
|
||||
flex to build flex again. With --disable-bootstrap, the scanner is
|
||||
simply built by sedding the scanner source. This is friendlier to
|
||||
cross compilation.
|
||||
|
||||
*** The compatibility functions in lib/ are no longer built as a
|
||||
library. Instead, they are built as $(LIBOBJ) objects. This is
|
||||
simpler and friendlier to cross compilation.
|
||||
|
||||
*** It is now possible to build flex without building the accompanying
|
||||
libfl. This is friendlier to cross compilation. See the
|
||||
--disable-libfl option to configure. Resolves #99.
|
||||
|
||||
*** the PIC version of libfl was not correctly built. It is no longer
|
||||
included in the build/installation targets of flex since it was
|
||||
unused.
|
||||
|
||||
*** the distributed man page is only rebuilt when the relevant source
|
||||
files change or when the binary doesn't exist. In particular, this
|
||||
is friendlier to cross compilation. Resolves #108
|
||||
|
||||
** test
|
||||
|
||||
*** the shell scripts in the test suite are more portable across different shell implementations.
|
||||
|
||||
* version 2.6.2 released 2016-10-24
|
||||
|
||||
** flex internals
|
||||
|
||||
*** a segfalt involving yyrestart(NULL) has been fixed
|
||||
|
||||
*** flex should now handle quoting when mixed with m4 processing correctly
|
||||
|
||||
*** flex handles `[[' and `]]' correctly
|
||||
|
||||
*** flex no longer generates non-ANSI code
|
||||
|
||||
*** more compilation warnings were squashed in generated scanners
|
||||
|
||||
*** prevented a buffer overflow that could occur when input buffers were the exact wrong size
|
||||
|
||||
** test suite
|
||||
|
||||
*** input filenames on MSWindows are now calculated correctly
|
||||
|
||||
*** general code cleanups in a number of tests now make the test suite compile much more cleanly
|
||||
|
||||
** build system
|
||||
|
||||
*** the xz archive has been replaced with an lzip archive
|
||||
|
||||
*** a new option to configure --enable-warnings to encapsulate passing
|
||||
of warning-related flags which is useful in testing flex
|
||||
|
||||
*** make indent now works for out of source builds
|
||||
|
||||
*** Portability warnings when generating Makefile.in files are now suppressed; they were just noise and the use of GNU extensions in Makefile.{am,in,} was intentional and well known.
|
||||
|
||||
** bugs
|
||||
|
||||
*** resolved gh#67
|
||||
|
||||
** new sv translation from the translation project
|
||||
|
||||
* version 2.6.1 released 2016-03-01
|
||||
|
||||
** flex resources
|
||||
|
||||
*** The flex project is now hosted at github. Consider this a "period of transition". In particular, you should start at https://github.com/westes/flex for the flex codebase, issue tracking and pull requests.
|
||||
|
||||
*** New releases of flex are to be found at https://github.com/westes/flex/releases.
|
||||
|
||||
** flex internals
|
||||
|
||||
*** Flex now uses more modern and more standard names for variable types. There's more work to be done on that front yet, though.
|
||||
|
||||
*** A number of compiler warnings have been remedied.
|
||||
|
||||
*** Line directives should now work as expected and be absent when that is expected.
|
||||
|
||||
** test suite
|
||||
|
||||
*** When running the test suite, c++ files are compiled with the c++ header inside the flex distribution, rather than relying on the build system's flex header , which might not be installed yet or which might be out of date with respect to what flex tests expect.
|
||||
|
||||
*** Some portability fixes in the test suite such as opening files for reading in binary mode
|
||||
|
||||
** Building flex
|
||||
|
||||
*** The file src/scan.c asdistributed with flex source is now built with the current version of flex. Occasionally this had to be done manually to pick up new flex features. It's now just a part of flex's build system.
|
||||
|
||||
*** The pdf version of the manual is no longer distributed with flex, although if you have the texinfo package installed, you can still build it.
|
||||
|
||||
*** lots of general build system cleanup
|
||||
|
||||
*** the build system tries a bit harder to find libtoolize and texi2dvi.
|
||||
|
||||
*** When help2man and texi2dvi are missing, the error messages are now much more helpful.
|
||||
|
||||
** bug fixes
|
||||
|
||||
*** resolved github issues #53, #54, #55, #61.
|
||||
|
||||
*** Resolved sf bugs #128, #129, #155, #160, #184, #187, #195.
|
||||
|
||||
* version 2.6.0 released 2015-11-17
|
||||
|
||||
** User Visible Changes
|
||||
|
||||
*** C++ scanners now use references instead of pointers. See the manual for details.
|
||||
|
||||
*** A number of compiler warnings were addressed, so flex generated scanners should be quieter under compiler warning scenarios.
|
||||
|
||||
*** Allow error reporting routines to accept varying number of arguments
|
||||
|
||||
*** Removed deprecated 'register' storage class specifier
|
||||
|
||||
*** Changeed output formats from octal to hexadecimal
|
||||
|
||||
*** check limits before using array index cclp; resolves sf-166
|
||||
|
||||
*** Suppress clang warning about empty @param paragraph; resolves sf#158
|
||||
|
||||
*** Fixed malloc/realloc replacement, resolves sf bug#151.
|
||||
|
||||
*** Adjusted buffer sizes on ia64.
|
||||
|
||||
*** various documentation and code clean up fixes: resolves sf bugs #167, #168, among other patches.
|
||||
|
||||
** Flex Internals
|
||||
|
||||
*** flex is now organized into subdirectories. This keeps the tree neater at the top level and puts like things near each other and unlike things away from each other.
|
||||
|
||||
*** The test suite has been reorganized and is now run with the parallel test suite harness from automake.
|
||||
|
||||
*** Cleaned up the automake parts of the build system to better reflect what automake does on its own. Also added a call to libtoolize in autogen.sh because autoreconf gets confused without a prior run of libtoolize.
|
||||
|
||||
*** po/Makefile now includes a rule to fetch the latest translations from the translation project. "make -f po/Makefile getpo" from the top level of the flex tree will fetch the files.
|
||||
|
||||
*** New da translation from the translation project
|
||||
|
||||
* flex version 2.5.39 released 2014-03-26
|
||||
|
||||
** no user visible changes in this release
|
||||
|
||||
* version 2.5.38 released 2014-02-14
|
||||
|
||||
** internationalization
|
||||
|
||||
*** add sr translation from the translation project
|
||||
|
||||
*** update da, es, ko, nl, pt_BR, ro, ru, sv, tr, vi, zh_CN translations from the translation project
|
||||
|
||||
*** rename zh_tw to its proper zh_TW name
|
||||
|
||||
* version 2.5.37 released 2012-08-03
|
||||
|
||||
@ -512,6 +738,8 @@ But the inverse is still true
|
||||
|
||||
See the file ONEWS for changes in earlier releases.
|
||||
|
||||
See the file COPYING for copying conditions.
|
||||
|
||||
Local Variables:
|
||||
mode: text
|
||||
mode: outline-minor
|
||||
|
79
README
79
README
@ -1,79 +0,0 @@
|
||||
This is flex, the fast lexical analyzer generator.
|
||||
|
||||
flex is a tool for generating scanners: programs which recognize
|
||||
lexical patterns in text.
|
||||
|
||||
More information about flex as well as the latest official release of
|
||||
flex can be found at:
|
||||
|
||||
http://flex.sourceforge.net/
|
||||
|
||||
Bug reports should be submitted using the SourceForge Bug Tracker
|
||||
facilities which can be found from flex's SourceForge project page at:
|
||||
|
||||
http://sourceforge.net/projects/flex
|
||||
|
||||
There are several mailing lists available as well:
|
||||
|
||||
flex-announce@lists.sourceforge.net - where posts will be made
|
||||
announcing new releases of flex.
|
||||
|
||||
flex-help@lists.sourceforge.net - where you can post questions about
|
||||
using flex
|
||||
|
||||
flex-devel@lists.sourceforge.net - where you can discuss development of
|
||||
flex itself
|
||||
|
||||
Note that flex is distributed under a copyright very similar to that of
|
||||
BSD Unix, and not under the GNU General Public License (GPL).
|
||||
|
||||
This file is part of flex.
|
||||
|
||||
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 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.
|
||||
|
||||
The flex distribution contains the following files which may be of interest:
|
||||
|
||||
README - This file.
|
||||
|
||||
NEWS - current version number and list of user-visible changes.
|
||||
|
||||
INSTALL - basic installation information.
|
||||
|
||||
ABOUT-NLS - description of internationalization support in flex.
|
||||
|
||||
COPYING - flex's copyright and license.
|
||||
|
||||
doc/ - user documentation.
|
||||
|
||||
examples/ - containing examples of some possible flex scanners and a
|
||||
few other things. See the file examples/README for more details.
|
||||
|
||||
TODO - outstanding bug reports, desired features, etc.
|
||||
|
||||
tests/ - regression tests. See TESTS/README for details.
|
||||
|
||||
po/ - internationalization support files.
|
@ -1,2 +0,0 @@
|
||||
Beta versions and cvs snapshots of flex can be had at
|
||||
ftp://ftp.uncg.edu/people/wlestes/.
|
46
README.cvs
46
README.cvs
@ -1,46 +0,0 @@
|
||||
This file gives information regarding the cvs tree of flex. The cvs
|
||||
tree of flex contains the files which are under version control by
|
||||
the flex maintainers for the flex project.
|
||||
|
||||
You can learn about the details of retrieving a copy of the cvs flex
|
||||
tree from flex's SourceForge project page at:
|
||||
|
||||
http://sourceforge.net/projects/flex
|
||||
|
||||
If you are not interested in flex development or you are not in need
|
||||
of the latest bleeding-edge features, then the cvs flex tree is
|
||||
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 the cvs tree.
|
||||
|
||||
You will need various external tools in order to build the distribution. Here is
|
||||
a (hopefully complete and correct) 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 GNU autoconf (yes, it *must* be GNU m4)
|
||||
GNU autoconf 2.60 and GNU automake 1.10; for generating Makefiles etc.
|
||||
GNU gettext 0.14.5; for i18n
|
||||
flex (latest beta release); for bootstrap of scan.l
|
||||
help2man 1.36; to generate the flex man page
|
||||
tar, gzip, etc.; for packaging of the source distribution
|
||||
GNU texinfo 4.8; 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.
|
109
README.md
Normal file
109
README.md
Normal file
@ -0,0 +1,109 @@
|
||||
This is flex, the fast lexical analyzer generator.
|
||||
|
||||
flex is a tool for generating scanners: programs which recognize
|
||||
lexical patterns in text.
|
||||
|
||||
The flex codebase is kept in
|
||||
[Git on GitHub.](https://github.com/westes/flex)
|
||||
|
||||
Use GitHub's [issues](https://github.com/westes/flex/issues) and
|
||||
[pull request](https://github.com/westes/flex) features to file bugs
|
||||
and submit patches.
|
||||
|
||||
There are several mailing lists available as well:
|
||||
|
||||
* flex-announce@lists.sourceforge.net - where posts will be made
|
||||
announcing new releases of flex.
|
||||
* flex-help@lists.sourceforge.net - where you can post questions about
|
||||
using flex
|
||||
* flex-devel@lists.sourceforge.net - where you can discuss development
|
||||
of flex itself
|
||||
|
||||
Find information on subscribing to the mailing lists at:
|
||||
|
||||
http://sourceforge.net/mail/?group_id=97492
|
||||
|
||||
The flex distribution contains the following files which may be of
|
||||
interest:
|
||||
|
||||
* README - This file.
|
||||
* NEWS - current version number and list of user-visible changes.
|
||||
* INSTALL - basic installation information.
|
||||
* ABOUT-NLS - description of internationalization support in flex.
|
||||
* COPYING - flex's copyright and license.
|
||||
* doc/ - user documentation.
|
||||
* examples/ - containing examples of some possible flex scanners and a
|
||||
few other things. See the file examples/README for more
|
||||
details.
|
||||
* tests/ - regression tests. See TESTS/README for details.
|
||||
* po/ - internationalization support files.
|
||||
|
||||
You need the following tools to build flex from the maintainer's
|
||||
repository:
|
||||
|
||||
* compiler suite - flex is built with gcc
|
||||
* bash, or a good Bourne-style shell
|
||||
* m4 - m4 -p needs to work; GNU m4 and a few others are suitable
|
||||
* GNU bison; to generate parse.c from parse.y
|
||||
* autoconf; for handling the build system
|
||||
* automake; for Makefile generation
|
||||
* gettext; for i18n support
|
||||
* help2man; to generate the flex man page
|
||||
* tar, gzip, lzip, etc.; for packaging of the source distribution
|
||||
* GNU texinfo; to build and test the flex manual. Note that if you want
|
||||
to build the dvi/ps/pdf versions of the documentation you will need
|
||||
texi2dvi and related programs, along with a sufficiently powerful
|
||||
implementation of TeX to process them. See your operating system
|
||||
documentation for how to achieve this. The printable versions of the
|
||||
manual are not built unless specifically requested, but the targets
|
||||
are included by automake.
|
||||
* GNU indent; for indenting the flex source the way we want it done
|
||||
|
||||
In cases where the versions of the above tools matter, the file
|
||||
configure.ac will specify the minimum required versions.
|
||||
|
||||
Once you have all the necessary tools installed, life becomes
|
||||
simple. To prepare the flex tree for building, run the script:
|
||||
|
||||
```bash
|
||||
./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 routine:
|
||||
|
||||
```bash
|
||||
configure && make && make install
|
||||
```
|
||||
|
||||
This file is part of flex.
|
||||
|
||||
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 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.
|
101
TODO
101
TODO
@ -1,101 +0,0 @@
|
||||
* 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:
|
23
autogen.sh
23
autogen.sh
@ -24,9 +24,28 @@
|
||||
# If you see no configure script, then run ./autogen.sh to create it
|
||||
# and procede with the "normal" build procedures.
|
||||
|
||||
# use LIBTOOLIZE, if set
|
||||
LIBTOOLIZE_ORIG="$LIBTOOLIZE";
|
||||
if test "x$LIBTOOLIZE" = "x"; then LIBTOOLIZE=libtoolize; fi
|
||||
|
||||
# test libtoolize
|
||||
$LIBTOOLIZE --version 2>/dev/null
|
||||
if test "$?" -ne 0; then
|
||||
LIBTOOLIZE=glibtoolize
|
||||
$LIBTOOLIZE --version 2>/dev/null
|
||||
if test "$?" -ne 0; then
|
||||
echo "error: libtoolize not working, re-run with LIBTOOLIZE=/path/to/libtoolize"
|
||||
echo " LIBTOOLIZE is currently \"$LIBTOOLIZE_ORIG\""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#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
|
||||
if ! test -f ChangeLog; then
|
||||
touch ChangeLog
|
||||
fi
|
||||
"$LIBTOOLIZE" --install --force
|
||||
autoreconf --install --force
|
||||
|
143
compile
143
compile
@ -1,143 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand `-c -o'.
|
||||
|
||||
scriptversion=2009-10-06.20; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand `-c -o'.
|
||||
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file `INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
eat=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as `compile cc -o foo foo.c'.
|
||||
# So we strip `-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no `-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# `.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use `[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1533
config.guess
vendored
1533
config.guess
vendored
File diff suppressed because it is too large
Load Diff
548
config.rpath
548
config.rpath
@ -1,548 +0,0 @@
|
||||
#! /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
|
1693
config.sub
vendored
1693
config.sub
vendored
File diff suppressed because it is too large
Load Diff
184
configure.ac
Normal file
184
configure.ac
Normal file
@ -0,0 +1,184 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# 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.
|
||||
|
||||
# autoconf requirements and initialization
|
||||
|
||||
AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex])
|
||||
AC_CONFIG_SRCDIR([src/scan.l])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
LT_INIT
|
||||
AM_INIT_AUTOMAKE([1.11.3 -Wno-portability foreign check-news std-options dist-lzip parallel-tests subdir-objects])
|
||||
AC_CONFIG_HEADER([src/config.h])
|
||||
AC_CONFIG_LIBOBJ_DIR([lib])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
SHARED_VERSION_INFO="2:0:0"
|
||||
AC_SUBST(SHARED_VERSION_INFO)
|
||||
|
||||
# checks for programs
|
||||
|
||||
AM_GNU_GETTEXT([external])
|
||||
AM_GNU_GETTEXT_VERSION([0.18])
|
||||
AC_PROG_YACC
|
||||
AS_IF([test "$YACC" != 'bison -y'], [
|
||||
YACC="\${top_srcdir}/build-aux/missing bison -y"
|
||||
AC_MSG_NOTICE(no bison program found: only required for maintainers)
|
||||
])
|
||||
AM_CONDITIONAL([HAVE_BISON], [test "$YACC" = 'bison -y'])
|
||||
AM_PROG_LEX
|
||||
AC_PROG_CC
|
||||
AX_PROG_CC_FOR_BUILD
|
||||
AC_PROG_CXX
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
|
||||
# allow passing a variable `WARNINGFLAGS',
|
||||
# either when invoking `configure', or when invoking `make'
|
||||
# default to something useful if GCC was detected
|
||||
|
||||
AC_ARG_ENABLE([warnings],
|
||||
[AS_HELP_STRING([--enable-warnings],
|
||||
[enable a bunch of compiler warning flags (defaults to GCC warning flags).])],
|
||||
[AS_IF([test "x$GCC" = xyes],
|
||||
[ : ${WARNINGFLAGS="-Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wconversion -Wno-unused-but-set-variable"} ])])
|
||||
|
||||
AC_SUBST([WARNINGFLAGS])
|
||||
|
||||
AC_ARG_ENABLE([libfl],
|
||||
[AS_HELP_STRING([--disable-libfl],
|
||||
[do not build -lfl runtime support library])],
|
||||
[], [enable_libfl=yes])
|
||||
AM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes])
|
||||
|
||||
# --disable-bootstrap is intended only to workaround problems with bootstrap
|
||||
# (e.g. when cross-compiling flex or when bootstrapping has bugs).
|
||||
# Ideally we should be able to bootstrap even when cross-compiling.
|
||||
AC_ARG_ENABLE([bootstrap],
|
||||
[AS_HELP_STRING([--disable-bootstrap],
|
||||
[don't perform a bootstrap when building flex])],
|
||||
[], [enable_bootstrap=yes])
|
||||
AM_CONDITIONAL([ENABLE_BOOTSTRAP], [test "x$enable_bootstrap" = xyes])
|
||||
|
||||
AM_CONDITIONAL([CROSS], [test "x$cross_compiling" = xyes])
|
||||
|
||||
AC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man])
|
||||
AS_IF([test "$HELP2MAN" = "\${top_srcdir}/build-aux/missing help2man"],
|
||||
AC_MSG_WARN(help2man: program not found: building man page will not work)
|
||||
)
|
||||
|
||||
AC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi])
|
||||
AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"],
|
||||
AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work)
|
||||
)
|
||||
|
||||
# Check for a m4 that supports -P
|
||||
|
||||
AC_CACHE_CHECK([for m4 that supports -P], [ac_cv_path_M4],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([M4], [gm4 gnum4 m4],
|
||||
[[m4out=`echo 'm''4_divnum' | $ac_path_M4 -P`]
|
||||
[test "x$m4out" = x0 \
|
||||
&& ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
|
||||
[AC_MSG_ERROR([could not find m4 that supports -P])])])
|
||||
AC_SUBST([M4], [$ac_cv_path_M4])
|
||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the m4 executable name.])
|
||||
|
||||
AC_PATH_PROG([INDENT], indent, [\${top_srcdir}/build-aux/missing indent])
|
||||
AC_MSG_CHECKING(if $INDENT is GNU indent)
|
||||
AS_IF([$INDENT --version 2>/dev/null | head -n 1 | grep "GNU indent" >/dev/null],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_MSG_WARN($INDENT does not appear to be GNU indent; 'make indent' may not function properly)
|
||||
])
|
||||
|
||||
# checks for headers
|
||||
|
||||
AC_CHECK_HEADERS([regex.h strings.h sys/stat.h sys/wait.h unistd.h], [],
|
||||
[AC_MSG_ERROR(required header not found on your system)])
|
||||
|
||||
AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h])
|
||||
|
||||
# checks for libraries
|
||||
|
||||
# The test test-pthread uses libpthread, so we check for it here, but
|
||||
# all we need is the preprocessor symbol defined since we don't need
|
||||
# LIBS to include libpthread for building flex.
|
||||
|
||||
LIBPTHREAD=''
|
||||
AC_CHECK_LIB(pthread, pthread_mutex_lock,
|
||||
[AC_CHECK_HEADERS([pthread.h], [LIBPTHREAD=-lpthread],
|
||||
[AC_MSG_WARN([pthread tests will be skipped])])],
|
||||
[AC_MSG_WARN([pthread tests will be skipped])])
|
||||
AC_SUBST([LIBPTHREAD])
|
||||
|
||||
AC_CHECK_LIB(m, log10)
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
|
||||
AC_HEADER_STDBOOL
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
# Checks for library functions.
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_FORK
|
||||
dnl Autoconf bug: AC_FUNC_MALLOC and AC_FUNC_REALLOC might not warn of cross
|
||||
dnl compilation. Workaround this.
|
||||
AC_FUNC_MALLOC
|
||||
AS_IF([test "$cross_compiling" = yes],
|
||||
AC_MSG_WARN([result $ac_cv_func_malloc_0_nonnull guessed because of cross compilation]))
|
||||
AC_FUNC_REALLOC
|
||||
AS_IF([test "$cross_compiling" = yes],
|
||||
AC_MSG_WARN([result $ac_cv_func_realloc_0_nonnull guessed because of cross compilation]))
|
||||
|
||||
AC_CHECK_FUNCS([dup2 dnl
|
||||
memset dnl
|
||||
regcomp dnl
|
||||
strcasecmp dnl
|
||||
strchr dnl
|
||||
strdup dnl
|
||||
strtol dnl
|
||||
], [], [AC_MSG_ERROR(required library function not found on your system)])
|
||||
|
||||
# Optional library functions
|
||||
AC_CHECK_FUNCS([dnl
|
||||
pow dnl Used only by "examples/manual/expr"
|
||||
setlocale dnl Needed only if NLS is enabled
|
||||
reallocarray dnl OpenBSD function. We have replacement if not available.
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
Makefile
|
||||
doc/Makefile
|
||||
examples/Makefile
|
||||
examples/fastwc/Makefile
|
||||
examples/manual/Makefile
|
||||
po/Makefile.in
|
||||
src/Makefile
|
||||
tools/Makefile
|
||||
tests/Makefile
|
||||
)
|
||||
|
||||
AC_OUTPUT
|
170
configure.in
170
configure.in
@ -1,170 +0,0 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
# 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.
|
||||
|
||||
# autoconf requirements and initialization
|
||||
|
||||
AC_INIT([the fast lexical analyser generator], [2.5.37],
|
||||
[flex-help@lists.sourceforge.net], [flex])
|
||||
AC_CONFIG_SRCDIR([scan.l])
|
||||
AM_INIT_AUTOMAKE([gnits dist-bzip2 1.10])
|
||||
AC_CONFIG_HEADER([config.h:conf.in])
|
||||
AC_CONFIG_LIBOBJ_DIR([lib])
|
||||
|
||||
# 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
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_PATH_PROG(BISON, bison,bison)
|
||||
AC_PATH_PROG(HELP2MAN, help2man, help2man)
|
||||
|
||||
# Check for a m4 that supports -P
|
||||
|
||||
AC_CACHE_CHECK([for m4 that supports -P], [ac_cv_path_M4],
|
||||
[AC_PATH_PROGS_FEATURE_CHECK([M4], [gm4 gnum4 m4],
|
||||
[[m4out=`echo 'm''4_divnum' | $ac_path_M4 -P`]
|
||||
[test "x$m4out" = x0 \
|
||||
&& ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
|
||||
[AC_MSG_ERROR([could not find m4 that supports -P])])])
|
||||
AC_SUBST([M4], [$ac_cv_path_M4])
|
||||
AC_DEFINE_UNQUOTED([M4], ["$M4"], [Define to the m4 executable name.])
|
||||
|
||||
AC_PATH_PROG(INDENT, indent, indent)
|
||||
# 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
|
||||
|
||||
# checks for headers
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h regex.h stddef.h stdlib.h string.h strings.h unistd.h])
|
||||
|
||||
# checks for libraries
|
||||
|
||||
# The test test-pthread uses libpthread, so we check for it here, but
|
||||
# all we need is the preprocessor symbol defined since we don't need
|
||||
# LIBS to include libpthread for building flex.
|
||||
|
||||
AC_CHECK_LIB(pthread, pthread_mutex_lock,
|
||||
AC_DEFINE([HAVE_LIBPTHREAD], 1, [pthread library] ),
|
||||
AC_DEFINE([HAVE_LIBPTHREAD], 0, [pthread library] )
|
||||
)
|
||||
AC_CHECK_HEADERS([pthread.h])
|
||||
|
||||
AC_CHECK_LIB(m, log10)
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
|
||||
AC_HEADER_STDBOOL
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
# Checks for library functions.
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_FORK
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_REALLOC
|
||||
AC_CHECK_FUNCS([dup2 isascii memset pow regcomp setlocale strchr strtol])
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
Makefile
|
||||
doc/Makefile
|
||||
examples/Makefile
|
||||
examples/fastwc/Makefile
|
||||
examples/manual/Makefile
|
||||
lib/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-alloc-extra/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
|
||||
tests/test-quotes/Makefile
|
||||
tests/test-ccl/Makefile
|
||||
tests/test-extended/Makefile
|
||||
tests/test-c++-yywrap/Makefile
|
||||
tests/test-concatenated-options/Makefile
|
||||
dnl --new-test-here-- This line is processed by tests/create-test.
|
||||
)
|
||||
|
||||
AC_OUTPUT
|
630
depcomp
630
depcomp
@ -1,630 +0,0 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
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
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
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
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u="sed s,\\\\\\\\,/,g"
|
||||
depmode=msvisualcpp
|
||||
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.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
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. In older versions, 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.
|
||||
# Version 6 uses the directory in both cases.
|
||||
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$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
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,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$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)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 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:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: 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',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
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$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
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
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space 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 preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--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 "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
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.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$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 preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--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 -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [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 preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# 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
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
520
install-sh
520
install-sh
@ -1,520 +0,0 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# 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.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$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 $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# 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.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
376
missing
376
missing
@ -1,376 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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=:
|
||||
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||
|
||||
# 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
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-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'
|
||||
autom4te touch the output file, or create a stub one
|
||||
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]
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
|
||||
\`g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar*)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case $program in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
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' $msg. 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 test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex*|flex*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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 test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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 "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. 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."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar*)
|
||||
shift
|
||||
|
||||
# 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 is $msg.
|
||||
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 prerequisites 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
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
111
mkinstalldirs
111
mkinstalldirs
@ -1,111 +0,0 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
errstatus=0
|
||||
dirmode=""
|
||||
|
||||
usage="\
|
||||
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
|
||||
|
||||
# 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 file
|
||||
do
|
||||
if test -d "$file"; then
|
||||
shift
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
case $# in
|
||||
0) exit 0 ;;
|
||||
esac
|
||||
|
||||
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
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# End:
|
||||
# mkinstalldirs ends here
|
220
src/FlexLexer.h
Normal file
220
src/FlexLexer.h
Normal file
@ -0,0 +1,220 @@
|
||||
// -*-C++-*-
|
||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
||||
// by flex
|
||||
|
||||
// Copyright (c) 1993 The Regents of the University of California.
|
||||
// All rights reserved.
|
||||
//
|
||||
// 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 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 file defines FlexLexer, an abstract class which specifies the
|
||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
||||
// which defines a particular lexer class.
|
||||
//
|
||||
// If you want to create multiple lexer classes, you use the -P flag
|
||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define __FLEX_LEXER_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
extern "C++" {
|
||||
|
||||
struct yy_buffer_state;
|
||||
typedef int yy_state_type;
|
||||
|
||||
class FlexLexer
|
||||
{
|
||||
public:
|
||||
virtual ~FlexLexer() { }
|
||||
|
||||
const char* YYText() const { return yytext; }
|
||||
int YYLeng() const { return yyleng; }
|
||||
|
||||
virtual void
|
||||
yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0;
|
||||
virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0;
|
||||
virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( yy_buffer_state* b ) = 0;
|
||||
virtual void yyrestart( std::istream* s ) = 0;
|
||||
virtual void yyrestart( std::istream& s ) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( std::istream& new_in, std::ostream& new_out )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
int yylex( std::istream* new_in, std::ostream* new_out = 0)
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( std::istream* new_in,
|
||||
std::ostream* new_out ) = 0;
|
||||
virtual void switch_streams( std::istream& new_in,
|
||||
std::ostream& new_out ) = 0;
|
||||
|
||||
int lineno() const { return yylineno; }
|
||||
|
||||
int debug() const { return yy_flex_debug; }
|
||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
||||
|
||||
protected:
|
||||
char* yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
};
|
||||
|
||||
}
|
||||
#endif // FLEXLEXER_H
|
||||
|
||||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
||||
// or this is a repeated include to define a different flavor of
|
||||
// yyFlexLexer, as discussed in the flex manual.
|
||||
# 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( std::istream& arg_yyin, std::ostream& arg_yyout );
|
||||
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
|
||||
private:
|
||||
void ctor_common();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~yyFlexLexer();
|
||||
|
||||
void yy_switch_to_buffer( yy_buffer_state* new_buffer );
|
||||
yy_buffer_state* yy_create_buffer( std::istream* s, int size );
|
||||
yy_buffer_state* yy_create_buffer( std::istream& s, int size );
|
||||
void yy_delete_buffer( yy_buffer_state* b );
|
||||
void yyrestart( std::istream* s );
|
||||
void yyrestart( std::istream& s );
|
||||
|
||||
void yypush_buffer_state( yy_buffer_state* new_buffer );
|
||||
void yypop_buffer_state();
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( std::istream& new_in, std::ostream& new_out );
|
||||
virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 );
|
||||
virtual int yywrap();
|
||||
|
||||
protected:
|
||||
virtual int LexerInput( char* buf, int max_size );
|
||||
virtual void LexerOutput( const char* buf, int size );
|
||||
virtual void LexerError( const char* msg );
|
||||
|
||||
void yyunput( int c, char* buf_ptr );
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer( yy_buffer_state* b, std::istream& s );
|
||||
void yy_flush_buffer( yy_buffer_state* b );
|
||||
|
||||
int yy_start_stack_ptr;
|
||||
int yy_start_stack_depth;
|
||||
int* yy_start_stack;
|
||||
|
||||
void yy_push_state( int new_state );
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_buffer();
|
||||
|
||||
std::istream yyin; // input source for default LexerInput
|
||||
std::ostream yyout; // output sink for default LexerOutput
|
||||
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
|
||||
// Points to current character in buffer.
|
||||
char* yy_c_buf_p;
|
||||
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// 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. */
|
||||
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()).
|
||||
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char* yy_last_accepting_cpos;
|
||||
|
||||
yy_state_type* yy_state_buf;
|
||||
yy_state_type* yy_state_ptr;
|
||||
|
||||
char* yy_full_match;
|
||||
int* yy_full_state;
|
||||
int yy_full_lp;
|
||||
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // yyFlexLexer || ! yyFlexLexerOnce
|
168
src/Makefile.am
Normal file
168
src/Makefile.am
Normal file
@ -0,0 +1,168 @@
|
||||
AM_YFLAGS = -d
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
|
||||
LIBS = @LIBS@
|
||||
|
||||
m4 = @M4@
|
||||
|
||||
bin_PROGRAMS = flex
|
||||
if ENABLE_BOOTSTRAP
|
||||
noinst_PROGRAMS = stage1flex
|
||||
endif
|
||||
|
||||
if ENABLE_LIBFL
|
||||
lib_LTLIBRARIES = libfl.la
|
||||
endif
|
||||
libfl_la_SOURCES = \
|
||||
libmain.c \
|
||||
libyywrap.c
|
||||
libfl_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
|
||||
|
||||
stage1flex_SOURCES = \
|
||||
scan.l \
|
||||
$(COMMON_SOURCES)
|
||||
|
||||
if CROSS
|
||||
stage1flex_LDADD =
|
||||
stage1flex_SOURCES += \
|
||||
../lib/malloc.c \
|
||||
../lib/realloc.c
|
||||
stage1flex_LINK = $(LIBTOOL) --tag=CC --mode=link $(CC_FOR_BUILD) \
|
||||
$(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
|
||||
|
||||
$(stage1flex_OBJECTS): CC=$(CC_FOR_BUILD)
|
||||
$(stage1flex_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
|
||||
$(stage1flex_OBJECTS): CPP=$(CPP_FOR_BUILD)
|
||||
$(stage1flex_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
|
||||
$(stage1flex_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD)
|
||||
else
|
||||
stage1flex_LDADD = $(LDADD)
|
||||
stage1flex_LINK = $(LINK)
|
||||
stage1flex_CFLAGS = $(AM_CFLAGS)
|
||||
endif
|
||||
|
||||
flex_SOURCES = \
|
||||
$(COMMON_SOURCES)
|
||||
|
||||
nodist_flex_SOURCES = \
|
||||
stage1scan.c
|
||||
|
||||
flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS)
|
||||
|
||||
COMMON_SOURCES = \
|
||||
buf.c \
|
||||
ccl.c \
|
||||
dfa.c \
|
||||
ecs.c \
|
||||
filter.c \
|
||||
flexdef.h \
|
||||
flexint.h \
|
||||
gen.c \
|
||||
main.c \
|
||||
misc.c \
|
||||
nfa.c \
|
||||
options.c \
|
||||
options.h \
|
||||
parse.y \
|
||||
regex.c \
|
||||
scanflags.c \
|
||||
scanopt.c \
|
||||
scanopt.h \
|
||||
skel.c \
|
||||
sym.c \
|
||||
tables.c \
|
||||
tables.h \
|
||||
tables_shared.c \
|
||||
tables_shared.h \
|
||||
tblcmp.c \
|
||||
version.h \
|
||||
yylex.c
|
||||
|
||||
LDADD = $(LIBOBJS) @LIBINTL@
|
||||
|
||||
include_HEADERS = \
|
||||
FlexLexer.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
flex.skl \
|
||||
mkskel.sh \
|
||||
gettext.h
|
||||
|
||||
CLEANFILES = stage1scan.c stage1flex$(EXEEXT)
|
||||
|
||||
MAINTAINERCLEANFILES = skel.c
|
||||
|
||||
skel.c: flex.skl mkskel.sh flexint.h tables_shared.h tables_shared.c
|
||||
$(SHELL) $(srcdir)/mkskel.sh $(srcdir) $(m4) $(VERSION) > $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
if ENABLE_BOOTSTRAP
|
||||
stage1scan.c: scan.l stage1flex$(EXEEXT)
|
||||
./stage1flex$(EXEEXT) $(AM_LFLAGS) $(LFLAGS) -o $@ $(srcdir)/scan.l
|
||||
else
|
||||
stage1scan.c: scan.c
|
||||
sed 's|^\(#line .*\)"'`printf %s $< | sed 's|[][\\\\.*]|\\\\&|g'`'"|\1"$@"|g' $< > $@
|
||||
endif
|
||||
|
||||
dist-hook: scan.l flex$(EXEEXT)
|
||||
chmod u+w $(distdir)/scan.c && \
|
||||
./flex$(EXEEXT) -o scan.c $< && \
|
||||
mv scan.c $(distdir)
|
||||
|
||||
# make needs to be told to make parse.h so that parallelized runs will
|
||||
# not fail.
|
||||
|
||||
stage1flex-main.$(OBJEXT): parse.h
|
||||
flex-main.$(OBJEXT): parse.h
|
||||
|
||||
stage1flex-yylex.$(OBJEXT): parse.h
|
||||
flex-yylex.$(OBJEXT): parse.h
|
||||
|
||||
stage1flex-scan.$(OBJEXT): parse.h
|
||||
flex-stage1scan.$(OBJEXT): parse.h
|
||||
|
||||
# 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 \
|
||||
scanflags.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: $(top_srcdir)/.indent.pro
|
||||
cd $(top_srcdir) && \
|
||||
for f in $(indentfiles); do \
|
||||
f=src/$$f; \
|
||||
echo indenting $$f; \
|
||||
INDENT_PROFILE=.indent.pro $(INDENT) <$$f >/dev/null && \
|
||||
INDENT_PROFILE=.indent.pro $(INDENT) $$f || \
|
||||
echo $$f FAILED to indent; \
|
||||
done;
|
||||
|
||||
.PHONY: indent
|
1731
src/Makefile.in
Normal file
1731
src/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
@ -73,12 +73,13 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
|
||||
char *t;
|
||||
size_t tsz;
|
||||
|
||||
t = flex_alloc (tsz = strlen (fmt) + strlen (s) + 1);
|
||||
tsz = strlen(fmt) + strlen(s) + 1;
|
||||
t = malloc(tsz);
|
||||
if (!t)
|
||||
flexfatal (_("Allocation of buffer to print string failed"));
|
||||
snprintf (t, tsz, fmt, s);
|
||||
buf = buf_strappend (buf, t);
|
||||
flex_free (t);
|
||||
free(t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -90,22 +91,28 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
|
||||
*/
|
||||
struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
|
||||
{
|
||||
char *dst, *src, *t;
|
||||
char *dst, *t;
|
||||
const char *src;
|
||||
size_t tsz;
|
||||
|
||||
t = flex_alloc (strlen ("#line \"\"\n") + /* constant parts */
|
||||
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
|
||||
(int) (1 + log10 (abs (lineno))) + /* line number */
|
||||
1); /* NUL */
|
||||
if (gen_line_dirs)
|
||||
return buf;
|
||||
|
||||
tsz = strlen("#line \"\"\n") + /* constant parts */
|
||||
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
|
||||
(size_t) (1 + ceil (log10 (abs (lineno)))) + /* line number */
|
||||
1; /* NUL */
|
||||
t = malloc(tsz);
|
||||
if (!t)
|
||||
flexfatal (_("Allocation of buffer for line directive failed"));
|
||||
for (dst = t + sprintf (t, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
|
||||
for (dst = t + snprintf (t, tsz, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
|
||||
if (*src == '\\') /* escape backslashes */
|
||||
*dst++ = '\\';
|
||||
*dst++ = '"';
|
||||
*dst++ = '\n';
|
||||
*dst = '\0';
|
||||
buf = buf_strappend (buf, t);
|
||||
flex_free (t);
|
||||
free(t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -123,10 +130,7 @@ struct Buf *buf_concat(struct Buf* dest, const struct Buf* src)
|
||||
|
||||
|
||||
/* Appends n characters in str to buf. */
|
||||
struct Buf *buf_strnappend (buf, str, n)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
int n;
|
||||
struct Buf *buf_strnappend (struct Buf *buf, const char *str, int n)
|
||||
{
|
||||
buf_append (buf, str, n + 1);
|
||||
|
||||
@ -137,18 +141,13 @@ struct Buf *buf_strnappend (buf, str, n)
|
||||
}
|
||||
|
||||
/* Appends characters in str to buf. */
|
||||
struct Buf *buf_strappend (buf, str)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
struct Buf *buf_strappend (struct Buf *buf, const char *str)
|
||||
{
|
||||
return buf_strnappend (buf, str, strlen (str));
|
||||
return buf_strnappend (buf, str, (int) strlen (str));
|
||||
}
|
||||
|
||||
/* appends "#define str def\n" */
|
||||
struct Buf *buf_strdefine (buf, str, def)
|
||||
struct Buf *buf;
|
||||
const char *str;
|
||||
const char *def;
|
||||
struct Buf *buf_strdefine (struct Buf *buf, const char *str, const char *def)
|
||||
{
|
||||
buf_strappend (buf, "#define ");
|
||||
buf_strappend (buf, " ");
|
||||
@ -167,12 +166,13 @@ struct Buf *buf_strdefine (buf, str, def)
|
||||
*/
|
||||
struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
|
||||
{
|
||||
const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
|
||||
const char * fmt = "m4_define( [[%s]], [[[[%s]]]])m4_dnl\n";
|
||||
char * str;
|
||||
size_t strsz;
|
||||
|
||||
val = val?val:"";
|
||||
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + strlen(val) + 2);
|
||||
strsz = strlen(fmt) + strlen(def) + strlen(val) + 2;
|
||||
str = malloc(strsz);
|
||||
if (!str)
|
||||
flexfatal (_("Allocation of buffer for m4 def failed"));
|
||||
|
||||
@ -192,7 +192,8 @@ struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
|
||||
char * str;
|
||||
size_t strsz;
|
||||
|
||||
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + 2);
|
||||
strsz = strlen(fmt) + strlen(def) + 2;
|
||||
str = malloc(strsz);
|
||||
if (!str)
|
||||
flexfatal (_("Allocation of buffer for m4 undef failed"));
|
||||
|
||||
@ -202,23 +203,21 @@ struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
|
||||
}
|
||||
|
||||
/* create buf with 0 elements, each of size elem_size. */
|
||||
void buf_init (buf, elem_size)
|
||||
struct Buf *buf;
|
||||
size_t elem_size;
|
||||
void buf_init (struct Buf *buf, size_t elem_size)
|
||||
{
|
||||
buf->elts = (void *) 0;
|
||||
buf->elts = NULL;
|
||||
buf->nelts = 0;
|
||||
buf->elt_size = elem_size;
|
||||
buf->nmax = 0;
|
||||
}
|
||||
|
||||
/* frees memory */
|
||||
void buf_destroy (buf)
|
||||
struct Buf *buf;
|
||||
void buf_destroy (struct Buf *buf)
|
||||
{
|
||||
if (buf && buf->elts)
|
||||
flex_free (buf->elts);
|
||||
buf->elts = (void *) 0;
|
||||
if (buf) {
|
||||
free(buf->elts);
|
||||
buf->elts = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -228,10 +227,7 @@ void buf_destroy (buf)
|
||||
* We grow by mod(512) boundaries.
|
||||
*/
|
||||
|
||||
struct Buf *buf_append (buf, ptr, n_elem)
|
||||
struct Buf *buf;
|
||||
const void *ptr;
|
||||
int n_elem;
|
||||
struct Buf *buf_append (struct Buf *buf, const void *ptr, int n_elem)
|
||||
{
|
||||
int n_alloc = 0;
|
||||
|
||||
@ -241,30 +237,30 @@ struct Buf *buf_append (buf, ptr, n_elem)
|
||||
/* May need to alloc more. */
|
||||
if (n_elem + buf->nelts > buf->nmax) {
|
||||
|
||||
/* exact amount needed... */
|
||||
n_alloc = (n_elem + buf->nelts) * buf->elt_size;
|
||||
/* exact count needed... */
|
||||
n_alloc = n_elem + buf->nelts;
|
||||
|
||||
/* ...plus some extra */
|
||||
if (((n_alloc * buf->elt_size) % 512) != 0
|
||||
if ((((size_t) n_alloc * buf->elt_size) % 512) != 0
|
||||
&& buf->elt_size < 512)
|
||||
n_alloc +=
|
||||
(512 -
|
||||
((n_alloc * buf->elt_size) % 512)) /
|
||||
buf->elt_size;
|
||||
n_alloc += (int)
|
||||
((512 -
|
||||
(((size_t) n_alloc * buf->elt_size) % 512)) /
|
||||
buf->elt_size);
|
||||
|
||||
if (!buf->elts)
|
||||
buf->elts =
|
||||
allocate_array (n_alloc, buf->elt_size);
|
||||
allocate_array ((int) n_alloc, buf->elt_size);
|
||||
else
|
||||
buf->elts =
|
||||
reallocate_array (buf->elts, n_alloc,
|
||||
reallocate_array (buf->elts, (int) n_alloc,
|
||||
buf->elt_size);
|
||||
|
||||
buf->nmax = n_alloc;
|
||||
}
|
||||
|
||||
memcpy ((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
|
||||
n_elem * buf->elt_size);
|
||||
memcpy ((char *) buf->elts + (size_t) buf->nelts * buf->elt_size, ptr,
|
||||
(size_t) n_elem * buf->elt_size);
|
||||
buf->nelts += n_elem;
|
||||
|
||||
return buf;
|
@ -52,9 +52,7 @@ ccl_contains (const int cclp, const int ch)
|
||||
|
||||
/* ccladd - add a single character to a ccl */
|
||||
|
||||
void ccladd (cclp, ch)
|
||||
int cclp;
|
||||
int ch;
|
||||
void ccladd (int cclp, int ch)
|
||||
{
|
||||
int ind, len, newpos, i;
|
||||
|
||||
@ -85,20 +83,20 @@ void ccladd (cclp, ch)
|
||||
}
|
||||
|
||||
ccllen[cclp] = len + 1;
|
||||
ccltbl[newpos] = ch;
|
||||
ccltbl[newpos] = (unsigned char) ch;
|
||||
}
|
||||
|
||||
/* dump_cclp - same thing as list_character_set, but for cclps. */
|
||||
|
||||
static void dump_cclp (FILE* file, int cclp)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
putc ('[', file);
|
||||
|
||||
for (i = 0; i < csize; ++i) {
|
||||
if (ccl_contains(cclp, i)){
|
||||
register int start_char = i;
|
||||
int start_char = i;
|
||||
|
||||
putc (' ', file);
|
||||
|
||||
@ -185,7 +183,7 @@ ccl_set_union (int a, int b)
|
||||
|
||||
/* cclinit - return an empty ccl */
|
||||
|
||||
int cclinit ()
|
||||
int cclinit (void)
|
||||
{
|
||||
if (++lastccl >= current_maxccls) {
|
||||
current_maxccls += MAX_CCLS_INCREMENT;
|
||||
@ -225,8 +223,7 @@ int cclinit ()
|
||||
|
||||
/* cclnegate - negate the given ccl */
|
||||
|
||||
void cclnegate (cclp)
|
||||
int cclp;
|
||||
void cclnegate (int cclp)
|
||||
{
|
||||
cclng[cclp] = 1;
|
||||
ccl_has_nl[cclp] = !ccl_has_nl[cclp];
|
||||
@ -240,17 +237,15 @@ void cclnegate (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 *file, int cset[])
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
putc ('[', file);
|
||||
|
||||
for (i = 0; i < csize; ++i) {
|
||||
if (cset[i]) {
|
||||
register int start_char = i;
|
||||
int start_char = i;
|
||||
|
||||
putc (' ', file);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* conf.in. Generated from configure.in by autoheader. */
|
||||
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
@ -19,27 +19,59 @@
|
||||
*/
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the `available.' function. */
|
||||
#undef HAVE_AVAILABLE_
|
||||
|
||||
/* Define to 1 if you have the `by' function. */
|
||||
#undef HAVE_BY
|
||||
|
||||
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
|
||||
CoreFoundation framework. */
|
||||
#undef HAVE_CFLOCALECOPYCURRENT
|
||||
|
||||
/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
|
||||
the CoreFoundation framework. */
|
||||
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
|
||||
|
||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||
*/
|
||||
#undef HAVE_DCGETTEXT
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the `dnl' function. */
|
||||
#undef HAVE_DNL
|
||||
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define to 1 if you have the `enabled' function. */
|
||||
#undef HAVE_ENABLED
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `function.' function. */
|
||||
#undef HAVE_FUNCTION_
|
||||
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
#undef HAVE_GETTEXT
|
||||
|
||||
/* Define if you have the iconv() function. */
|
||||
/* Define to 1 if you have the `have' function. */
|
||||
#undef HAVE_HAVE
|
||||
|
||||
/* Define if you have the iconv() function and it works. */
|
||||
#undef HAVE_ICONV
|
||||
|
||||
/* Define to 1 if you have the `if' function. */
|
||||
#undef HAVE_IF
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#undef HAVE_ISASCII
|
||||
/* Define to 1 if you have the `is' function. */
|
||||
#undef HAVE_IS
|
||||
|
||||
/* Define to 1 if you have the <libintl.h> header file. */
|
||||
#undef HAVE_LIBINTL_H
|
||||
@ -47,9 +79,6 @@
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
/* pthread library */
|
||||
#undef HAVE_LIBPTHREAD
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
@ -69,9 +98,24 @@
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the `Needed' function. */
|
||||
#undef HAVE_NEEDED
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the `NLS' function. */
|
||||
#undef HAVE_NLS
|
||||
|
||||
/* Define to 1 if you have the `not' function. */
|
||||
#undef HAVE_NOT
|
||||
|
||||
/* Define to 1 if you have the `only' function. */
|
||||
#undef HAVE_ONLY
|
||||
|
||||
/* Define to 1 if you have the `OpenBSD' function. */
|
||||
#undef HAVE_OPENBSD
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#undef HAVE_POW
|
||||
|
||||
@ -82,30 +126,39 @@
|
||||
and to 0 otherwise. */
|
||||
#undef HAVE_REALLOC
|
||||
|
||||
/* Define to 1 if you have the `reallocarray' function. */
|
||||
#undef HAVE_REALLOCARRAY
|
||||
|
||||
/* Define to 1 if you have the `regcomp' function. */
|
||||
#undef HAVE_REGCOMP
|
||||
|
||||
/* Define to 1 if you have the <regex.h> header file. */
|
||||
#undef HAVE_REGEX_H
|
||||
|
||||
/* Define to 1 if you have the `replacement' function. */
|
||||
#undef HAVE_REPLACEMENT
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define to 1 if stdbool.h conforms to C99. */
|
||||
#undef HAVE_STDBOOL_H
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_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 `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
@ -121,18 +174,24 @@
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `Used' function. */
|
||||
#undef HAVE_USED
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to 1 if you have the `We' function. */
|
||||
#undef HAVE_WE
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
@ -142,12 +201,12 @@
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
#undef HAVE__BOOL
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to the m4 executable name. */
|
||||
#undef M4
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
@ -34,10 +34,10 @@
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
void dump_associated_rules PROTO ((FILE *, int));
|
||||
void dump_transitions PROTO ((FILE *, int[]));
|
||||
void sympartition PROTO ((int[], int, int[], int[]));
|
||||
int symfollowset PROTO ((int[], int, int, int[]));
|
||||
void dump_associated_rules(FILE *, int);
|
||||
void dump_transitions(FILE *, int[]);
|
||||
void sympartition(int[], int, int[], int[]);
|
||||
int symfollowset(int[], int, int, int[]);
|
||||
|
||||
|
||||
/* check_for_backing_up - check a DFA state for backing up
|
||||
@ -49,9 +49,7 @@ int symfollowset PROTO ((int[], int, int, int[]));
|
||||
* indexed by equivalence class.
|
||||
*/
|
||||
|
||||
void check_for_backing_up (ds, state)
|
||||
int ds;
|
||||
int state[];
|
||||
void check_for_backing_up (int ds, int state[])
|
||||
{
|
||||
if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */
|
||||
++num_backing_up;
|
||||
@ -96,17 +94,14 @@ void check_for_backing_up (ds, state)
|
||||
* accset[1 .. nacc] is the list of accepting numbers for the DFA state.
|
||||
*/
|
||||
|
||||
void check_trailing_context (nfa_states, num_states, accset, nacc)
|
||||
int *nfa_states, num_states;
|
||||
int *accset;
|
||||
int nacc;
|
||||
void check_trailing_context (int *nfa_states, int num_states, int *accset, int nacc)
|
||||
{
|
||||
register int i, j;
|
||||
int i, j;
|
||||
|
||||
for (i = 1; i <= num_states; ++i) {
|
||||
int ns = nfa_states[i];
|
||||
register int type = state_type[ns];
|
||||
register int ar = assoc_rule[ns];
|
||||
int type = state_type[ns];
|
||||
int ar = assoc_rule[ns];
|
||||
|
||||
if (type == STATE_NORMAL || rule_type[ar] != RULE_VARIABLE) { /* do nothing */
|
||||
}
|
||||
@ -137,18 +132,16 @@ void check_trailing_context (nfa_states, num_states, accset, nacc)
|
||||
* and writes a report to the given file.
|
||||
*/
|
||||
|
||||
void dump_associated_rules (file, ds)
|
||||
FILE *file;
|
||||
int ds;
|
||||
void dump_associated_rules (FILE *file, int ds)
|
||||
{
|
||||
register int i, j;
|
||||
register int num_associated_rules = 0;
|
||||
int rule_set[MAX_ASSOC_RULES + 1];
|
||||
int *dset = dss[ds];
|
||||
int size = dfasiz[ds];
|
||||
int i, j;
|
||||
int num_associated_rules = 0;
|
||||
int rule_set[MAX_ASSOC_RULES + 1];
|
||||
int *dset = dss[ds];
|
||||
int size = dfasiz[ds];
|
||||
|
||||
for (i = 1; i <= size; ++i) {
|
||||
register int rule_num = rule_linenum[assoc_rule[dset[i]]];
|
||||
int rule_num = rule_linenum[assoc_rule[dset[i]]];
|
||||
|
||||
for (j = 1; j <= num_associated_rules; ++j)
|
||||
if (rule_num == rule_set[j])
|
||||
@ -161,7 +154,7 @@ void dump_associated_rules (file, ds)
|
||||
}
|
||||
}
|
||||
|
||||
qsort (&rule_set [1], num_associated_rules, sizeof (rule_set [1]), intcmp);
|
||||
qsort (&rule_set [1], (size_t) num_associated_rules, sizeof (rule_set [1]), intcmp);
|
||||
|
||||
fprintf (file, _(" associated rule line numbers:"));
|
||||
|
||||
@ -187,12 +180,10 @@ void dump_associated_rules (file, ds)
|
||||
* is done to the given file.
|
||||
*/
|
||||
|
||||
void dump_transitions (file, state)
|
||||
FILE *file;
|
||||
int state[];
|
||||
void dump_transitions (FILE *file, int state[])
|
||||
{
|
||||
register int i, ec;
|
||||
int out_char_set[CSIZE];
|
||||
int i, ec;
|
||||
int out_char_set[CSIZE];
|
||||
|
||||
for (i = 0; i < csize; ++i) {
|
||||
ec = ABS (ecgroup[i]);
|
||||
@ -235,10 +226,9 @@ void dump_transitions (file, state)
|
||||
* hashval is the hash value for the dfa corresponding to the state set.
|
||||
*/
|
||||
|
||||
int *epsclosure (t, ns_addr, accset, nacc_addr, hv_addr)
|
||||
int *t, *ns_addr, accset[], *nacc_addr, *hv_addr;
|
||||
int *epsclosure (int *t, int *ns_addr, int accset[], int *nacc_addr, int *hv_addr)
|
||||
{
|
||||
register int stkpos, ns, tsp;
|
||||
int stkpos, ns, tsp;
|
||||
int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum;
|
||||
int stkend, nstate;
|
||||
static int did_stk_init = false, *stk;
|
||||
@ -351,7 +341,7 @@ ADD_STATE(state); \
|
||||
|
||||
/* increase_max_dfas - increase the maximum number of DFAs */
|
||||
|
||||
void increase_max_dfas ()
|
||||
void increase_max_dfas (void)
|
||||
{
|
||||
current_max_dfas += MAX_DFAS_INCREMENT;
|
||||
|
||||
@ -378,7 +368,7 @@ void increase_max_dfas ()
|
||||
* dfa starts out in state #1.
|
||||
*/
|
||||
|
||||
void ntod ()
|
||||
void ntod (void)
|
||||
{
|
||||
int *accset, ds, nacc, newds;
|
||||
int sym, hashval, numstates, dsize;
|
||||
@ -400,7 +390,7 @@ void ntod ()
|
||||
* from 1 to CSIZE, so their size must be CSIZE + 1.
|
||||
*/
|
||||
int duplist[CSIZE + 1], state[CSIZE + 1];
|
||||
int targfreq[CSIZE + 1], targstate[CSIZE + 1];
|
||||
int targfreq[CSIZE + 1] = {0}, targstate[CSIZE + 1];
|
||||
|
||||
/* accset needs to be large enough to hold all of the rules present
|
||||
* in the input, *plus* their YY_TRAILING_HEAD_MASK variants.
|
||||
@ -473,14 +463,9 @@ void ntod ()
|
||||
/* We still may want to use the table if numecs
|
||||
* is a power of 2.
|
||||
*/
|
||||
int power_of_two;
|
||||
|
||||
for (power_of_two = 1; power_of_two <= csize;
|
||||
power_of_two *= 2)
|
||||
if (numecs == power_of_two) {
|
||||
use_NUL_table = true;
|
||||
break;
|
||||
}
|
||||
if (numecs <= csize && is_power_of_2(numecs)) {
|
||||
use_NUL_table = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (use_NUL_table)
|
||||
@ -521,15 +506,13 @@ void ntod ()
|
||||
* So we'll have to realloc() on the way...
|
||||
* we'll wait until we can calculate yynxt_tbl->td_hilen.
|
||||
*/
|
||||
yynxt_tbl =
|
||||
(struct yytbl_data *) calloc (1,
|
||||
sizeof (struct
|
||||
yytbl_data));
|
||||
yynxt_tbl = calloc(1, sizeof (struct yytbl_data));
|
||||
|
||||
yytbl_data_init (yynxt_tbl, YYTD_ID_NXT);
|
||||
yynxt_tbl->td_hilen = 1;
|
||||
yynxt_tbl->td_lolen = num_full_table_rows;
|
||||
yynxt_tbl->td_lolen = (flex_uint32_t) num_full_table_rows;
|
||||
yynxt_tbl->td_data = yynxt_data =
|
||||
(flex_int32_t *) calloc (yynxt_tbl->td_lolen *
|
||||
calloc(yynxt_tbl->td_lolen *
|
||||
yynxt_tbl->td_hilen,
|
||||
sizeof (flex_int32_t));
|
||||
yynxt_curr = 0;
|
||||
@ -543,12 +526,12 @@ void ntod ()
|
||||
*/
|
||||
if (gentables)
|
||||
out_str_dec
|
||||
("static yyconst %s yy_nxt[][%d] =\n {\n",
|
||||
("static const %s yy_nxt[][%d] =\n {\n",
|
||||
long_align ? "flex_int32_t" : "flex_int16_t",
|
||||
num_full_table_rows);
|
||||
else {
|
||||
out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows);
|
||||
out_str ("static yyconst %s *yy_nxt =0;\n",
|
||||
out_str ("static const %s *yy_nxt =0;\n",
|
||||
long_align ? "flex_int32_t" : "flex_int16_t");
|
||||
}
|
||||
|
||||
@ -713,7 +696,7 @@ void ntod ()
|
||||
/* Each time we hit here, it's another td_hilen, so we realloc. */
|
||||
yynxt_tbl->td_hilen++;
|
||||
yynxt_tbl->td_data = yynxt_data =
|
||||
(flex_int32_t *) realloc (yynxt_data,
|
||||
realloc (yynxt_data,
|
||||
yynxt_tbl->td_hilen *
|
||||
yynxt_tbl->td_lolen *
|
||||
sizeof (flex_int32_t));
|
||||
@ -805,8 +788,8 @@ void ntod ()
|
||||
mkdeftbl ();
|
||||
}
|
||||
|
||||
flex_free ((void *) accset);
|
||||
flex_free ((void *) nset);
|
||||
free(accset);
|
||||
free(nset);
|
||||
}
|
||||
|
||||
|
||||
@ -820,12 +803,11 @@ void ntod ()
|
||||
* On return, the dfa state number is in newds.
|
||||
*/
|
||||
|
||||
int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
int sns[], numstates, accset[], nacc, hashval, *newds_addr;
|
||||
int snstods (int sns[], int numstates, int accset[], int nacc, int hashval, int *newds_addr)
|
||||
{
|
||||
int didsort = 0;
|
||||
register int i, j;
|
||||
int newds, *oldsns;
|
||||
int didsort = 0;
|
||||
int i, j;
|
||||
int newds, *oldsns;
|
||||
|
||||
for (i = 1; i <= lastdfa; ++i)
|
||||
if (hashval == dhash[i]) {
|
||||
@ -836,7 +818,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
/* We sort the states in sns so we
|
||||
* can compare it to oldsns quickly.
|
||||
*/
|
||||
qsort (&sns [1], numstates, sizeof (sns [1]), intcmp);
|
||||
qsort (&sns [1], (size_t) numstates, sizeof (sns [1]), intcmp);
|
||||
didsort = 1;
|
||||
}
|
||||
|
||||
@ -871,7 +853,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
*/
|
||||
|
||||
if (!didsort)
|
||||
qsort (&sns [1], numstates, sizeof (sns [1]), intcmp);
|
||||
qsort (&sns [1], (size_t) numstates, sizeof (sns [1]), intcmp);
|
||||
|
||||
for (i = 1; i <= numstates; ++i)
|
||||
dss[newds][i] = sns[i];
|
||||
@ -881,7 +863,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
|
||||
if (nacc == 0) {
|
||||
if (reject)
|
||||
dfaacc[newds].dfaacc_set = (int *) 0;
|
||||
dfaacc[newds].dfaacc_set = NULL;
|
||||
else
|
||||
dfaacc[newds].dfaacc_state = 0;
|
||||
|
||||
@ -894,7 +876,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
* match in the event of ties will work.
|
||||
*/
|
||||
|
||||
qsort (&accset [1], nacc, sizeof (accset [1]), intcmp);
|
||||
qsort (&accset [1], (size_t) nacc, sizeof (accset [1]), intcmp);
|
||||
|
||||
dfaacc[newds].dfaacc_set =
|
||||
allocate_integer_array (nacc + 1);
|
||||
@ -942,8 +924,7 @@ int snstods (sns, numstates, accset, nacc, hashval, newds_addr)
|
||||
* int transsym, int nset[current_max_dfa_size] );
|
||||
*/
|
||||
|
||||
int symfollowset (ds, dsize, transsym, nset)
|
||||
int ds[], dsize, transsym, nset[];
|
||||
int symfollowset (int ds[], int dsize, int transsym, int nset[])
|
||||
{
|
||||
int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist;
|
||||
|
||||
@ -1020,9 +1001,7 @@ int symfollowset (ds, dsize, transsym, nset)
|
||||
* int symlist[numecs], int duplist[numecs] );
|
||||
*/
|
||||
|
||||
void sympartition (ds, numstates, symlist, duplist)
|
||||
int ds[], numstates;
|
||||
int symlist[], duplist[];
|
||||
void sympartition (int ds[], int numstates, int symlist[], int duplist[])
|
||||
{
|
||||
int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich;
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
/* ccl2ecl - convert character classes to set of equivalence classes */
|
||||
|
||||
void ccl2ecl ()
|
||||
void ccl2ecl (void)
|
||||
{
|
||||
int i, ich, newlen, cclp, ccls, cclmec;
|
||||
|
||||
@ -56,7 +56,8 @@ void ccl2ecl ()
|
||||
cclmec = ecgroup[ich];
|
||||
|
||||
if (cclmec > 0) {
|
||||
ccltbl[cclp + newlen] = cclmec;
|
||||
/* Note: range 1..256 is mapped to 1..255,0 */
|
||||
ccltbl[cclp + newlen] = (unsigned char) cclmec;
|
||||
++newlen;
|
||||
}
|
||||
}
|
||||
@ -74,8 +75,7 @@ void ccl2ecl ()
|
||||
* Returned is the number of classes.
|
||||
*/
|
||||
|
||||
int cre8ecs (fwd, bck, num)
|
||||
int fwd[], bck[], num;
|
||||
int cre8ecs (int fwd[], int bck[], int num)
|
||||
{
|
||||
int i, j, numcl;
|
||||
|
||||
@ -100,9 +100,9 @@ int cre8ecs (fwd, bck, num)
|
||||
/* mkeccl - update equivalence classes based on character class xtions
|
||||
*
|
||||
* synopsis
|
||||
* Char ccls[];
|
||||
* unsigned char ccls[];
|
||||
* int lenccl, fwd[llsiz], bck[llsiz], llsiz, NUL_mapping;
|
||||
* void mkeccl( Char ccls[], int lenccl, int fwd[llsiz], int bck[llsiz],
|
||||
* void mkeccl( unsigned char ccls[], int lenccl, int fwd[llsiz], int bck[llsiz],
|
||||
* int llsiz, int NUL_mapping );
|
||||
*
|
||||
* ccls contains the elements of the character class, lenccl is the
|
||||
@ -112,9 +112,7 @@ int cre8ecs (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;
|
||||
void mkeccl (unsigned char ccls[], int lenccl, int fwd[], int bck[], int llsiz, int NUL_mapping)
|
||||
{
|
||||
int cclp, oldec, newec;
|
||||
int cclm, i, j;
|
||||
@ -139,7 +137,7 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping)
|
||||
|
||||
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;
|
||||
int ccl_char;
|
||||
|
||||
if (NUL_mapping && ccls[j] == 0)
|
||||
ccl_char = NUL_mapping;
|
||||
@ -191,7 +189,7 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping)
|
||||
|
||||
/* Find next ccl member to process. */
|
||||
|
||||
for (++cclp; cclflags[cclp] && cclp < lenccl; ++cclp) {
|
||||
for (++cclp; cclp < lenccl && cclflags[cclp]; ++cclp) {
|
||||
/* Reset "doesn't need processing" flag. */
|
||||
cclflags[cclp] = 0;
|
||||
}
|
||||
@ -201,8 +199,7 @@ void mkeccl (ccls, lenccl, fwd, bck, llsiz, NUL_mapping)
|
||||
|
||||
/* mkechar - create equivalence class for single character */
|
||||
|
||||
void mkechar (tch, fwd, bck)
|
||||
int tch, fwd[], bck[];
|
||||
void mkechar (int tch, int fwd[], int bck[])
|
||||
{
|
||||
/* If until now the character has been a proper subset of
|
||||
* an equivalence class, break it away to create a new ec
|
@ -47,9 +47,9 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
|
||||
va_list ap;
|
||||
|
||||
/* allocate and initialize new filter */
|
||||
f = (struct filter *) flex_alloc (sizeof (struct filter));
|
||||
f = malloc(sizeof(struct filter));
|
||||
if (!f)
|
||||
flexerror (_("flex_alloc failed (f) in filter_create_ext"));
|
||||
flexerror(_("malloc failed (f) in filter_create_ext"));
|
||||
memset (f, 0, sizeof (*f));
|
||||
f->filter_func = NULL;
|
||||
f->extra = NULL;
|
||||
@ -66,23 +66,16 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
|
||||
|
||||
/* 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 = malloc(sizeof(char *) * (size_t) (max_args + 1));
|
||||
if (!f->argv)
|
||||
flexerror (_("flex_alloc failed (f->argv) in filter_create_ext"));
|
||||
flexerror(_("malloc failed (f->argv) in filter_create_ext"));
|
||||
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 = realloc(f->argv, sizeof(char*) * (size_t) (max_args + 1));
|
||||
}
|
||||
f->argv[f->argc++] = s;
|
||||
}
|
||||
@ -107,9 +100,9 @@ struct filter *filter_create_int (struct filter *chain,
|
||||
struct filter *f;
|
||||
|
||||
/* allocate and initialize new filter */
|
||||
f = (struct filter *) flex_alloc (sizeof (struct filter));
|
||||
f = malloc(sizeof(struct filter));
|
||||
if (!f)
|
||||
flexerror (_("flex_alloc failed in filter_create_int"));
|
||||
flexerror(_("malloc failed in filter_create_int"));
|
||||
memset (f, 0, sizeof (*f));
|
||||
f->next = NULL;
|
||||
f->argc = 0;
|
||||
@ -135,9 +128,6 @@ struct filter *filter_create_int (struct filter *chain,
|
||||
bool filter_apply_chain (struct filter * chain)
|
||||
{
|
||||
int pid, pipes[2];
|
||||
int r;
|
||||
const int readsz = 512;
|
||||
char *buf;
|
||||
|
||||
|
||||
/* Tricky recursion, since we want to begin the chain
|
||||
@ -177,6 +167,8 @@ clearerr(stdin);
|
||||
flexfatal (_("dup2(pipes[0],0)"));
|
||||
close (pipes[0]);
|
||||
fseek (stdin, 0, SEEK_CUR);
|
||||
ungetc(' ', stdin); /* still an evil hack, but one that works better */
|
||||
(void)fgetc(stdin); /* on NetBSD than the fseek attempt does */
|
||||
|
||||
/* run as a filter, either internally or by exec */
|
||||
if (chain->filter_func) {
|
||||
@ -184,16 +176,16 @@ clearerr(stdin);
|
||||
|
||||
if ((r = chain->filter_func (chain)) == -1)
|
||||
flexfatal (_("filter_func failed"));
|
||||
exit (0);
|
||||
FLEX_EXIT (0);
|
||||
}
|
||||
else {
|
||||
execvp (chain->argv[0],
|
||||
(char **const) (chain->argv));
|
||||
lerrsf_fatal ( _("exec of %s failed"),
|
||||
lerr_fatal ( _("exec of %s failed"),
|
||||
chain->argv[0]);
|
||||
}
|
||||
|
||||
exit (1);
|
||||
FLEX_EXIT (1);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
@ -291,9 +283,9 @@ int filter_tee_header (struct filter *chain)
|
||||
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
buf = (char *) flex_alloc (readsz);
|
||||
buf = malloc((size_t) readsz);
|
||||
if (!buf)
|
||||
flexerror (_("flex_alloc failed in filter_tee_header"));
|
||||
flexerror(_("malloc failed in filter_tee_header"));
|
||||
while (fgets (buf, readsz, stdin)) {
|
||||
fputs (buf, to_c);
|
||||
if (write_header)
|
||||
@ -304,7 +296,8 @@ int filter_tee_header (struct filter *chain)
|
||||
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");
|
||||
if (gen_line_dirs)
|
||||
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);
|
||||
@ -312,26 +305,26 @@ int filter_tee_header (struct filter *chain)
|
||||
|
||||
fflush (to_h);
|
||||
if (ferror (to_h))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
lerr (_("error writing output file %s"),
|
||||
(char *) chain->extra);
|
||||
|
||||
else if (fclose (to_h))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
lerr (_("error closing output file %s"),
|
||||
(char *) chain->extra);
|
||||
}
|
||||
|
||||
fflush (to_c);
|
||||
if (ferror (to_c))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
lerr (_("error writing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
else if (fclose (to_c))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
lerr (_("error closing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
while (wait (0) > 0) ;
|
||||
|
||||
exit (0);
|
||||
FLEX_EXIT (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -344,7 +337,7 @@ int filter_tee_header (struct filter *chain)
|
||||
int filter_fix_linedirs (struct filter *chain)
|
||||
{
|
||||
char *buf;
|
||||
const int readsz = 512;
|
||||
const size_t readsz = 512;
|
||||
int lineno = 1;
|
||||
bool in_gen = true; /* in generated code */
|
||||
bool last_was_blank = false;
|
||||
@ -352,11 +345,11 @@ int filter_fix_linedirs (struct filter *chain)
|
||||
if (!chain)
|
||||
return 0;
|
||||
|
||||
buf = (char *) flex_alloc (readsz);
|
||||
buf = malloc(readsz);
|
||||
if (!buf)
|
||||
flexerror (_("flex_alloc failed in filter_fix_linedirs"));
|
||||
flexerror(_("malloc failed in filter_fix_linedirs"));
|
||||
|
||||
while (fgets (buf, readsz, stdin)) {
|
||||
while (fgets (buf, (int) readsz, stdin)) {
|
||||
|
||||
regmatch_t m[10];
|
||||
|
||||
@ -364,11 +357,9 @@ int filter_fix_linedirs (struct filter *chain)
|
||||
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,
|
||||
@ -400,7 +391,7 @@ int filter_fix_linedirs (struct filter *chain)
|
||||
/* Adjust the line directives. */
|
||||
in_gen = true;
|
||||
snprintf (buf, readsz, "#line %d \"%s\"\n",
|
||||
lineno + 1, filename);
|
||||
lineno, filename);
|
||||
}
|
||||
else {
|
||||
/* it's a #line directive for code we didn't write */
|
||||
@ -431,11 +422,11 @@ int filter_fix_linedirs (struct filter *chain)
|
||||
}
|
||||
fflush (stdout);
|
||||
if (ferror (stdout))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
lerr (_("error writing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
else if (fclose (stdout))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
lerr (_("error closing output file %s"),
|
||||
outfilename ? outfilename : "<stdout>");
|
||||
|
||||
return 0;
|
File diff suppressed because it is too large
Load Diff
@ -39,30 +39,15 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#ifndef __GNUC__
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
#pragma alloca
|
||||
# else
|
||||
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
||||
char *alloca ();
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <setjmp.h>
|
||||
#include <ctype.h>
|
||||
#include <libgen.h> /* for XPG version of basename(3) */
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASSERT_H
|
||||
#include <assert.h>
|
||||
#else
|
||||
@ -72,28 +57,24 @@ char *alloca ();
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
/* Required: dup() and dup2() in <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
|
||||
/* Required: stat() in <sys/stat.h> */
|
||||
#include <sys/stat.h>
|
||||
/* Required: wait() in <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
|
||||
#ifdef HAVE_REGEX_H
|
||||
#include <stdarg.h>
|
||||
/* Required: regcomp(), regexec() and regerror() in <regex.h> */
|
||||
#include <regex.h>
|
||||
#endif
|
||||
/* Required: strcasecmp() in <strings.h> */
|
||||
#include <strings.h>
|
||||
#include "flexint.h"
|
||||
|
||||
/* We use gettext. So, when we write strings which should be translated, we mark them with _() */
|
||||
@ -109,33 +90,12 @@ char *alloca ();
|
||||
|
||||
/* Always be prepared to generate an 8-bit scanner. */
|
||||
#define CSIZE 256
|
||||
#define Char unsigned char
|
||||
|
||||
/* Size of input alphabet - should be size of ASCII set. */
|
||||
#ifndef DEFAULT_CSIZE
|
||||
#define DEFAULT_CSIZE 128
|
||||
#endif
|
||||
|
||||
#ifndef PROTO
|
||||
#if defined(__STDC__)
|
||||
#define PROTO(proto) proto
|
||||
#else
|
||||
#define PROTO(proto) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
#ifndef __VMS_POSIX
|
||||
#define unlink remove
|
||||
#define SHORT_FILE_NAMES
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MS_DOS
|
||||
#define SHORT_FILE_NAMES
|
||||
#endif
|
||||
|
||||
|
||||
/* Maximum line length we'll have to deal with. */
|
||||
#define MAXLINE 2048
|
||||
|
||||
@ -149,11 +109,8 @@ char *alloca ();
|
||||
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||
#endif
|
||||
|
||||
|
||||
/* ANSI C does not guarantee that isascii() is defined */
|
||||
#ifndef isascii
|
||||
#define isascii(c) ((c) <= 0177)
|
||||
#endif
|
||||
/* Whether an integer is a power of two */
|
||||
#define is_power_of_2(n) ((n) > 0 && ((n) & ((n) - 1)) == 0)
|
||||
|
||||
#define unspecified -1
|
||||
|
||||
@ -395,6 +352,7 @@ char *alloca ();
|
||||
* yymore_really_used - whether to treat yymore() as really used, regardless
|
||||
* of what we think based on references to it in the user's actions.
|
||||
* reject_really_used - same for REJECT
|
||||
* trace_hex - use hexadecimal numbers in trace/debug outputs instead of octals
|
||||
*/
|
||||
|
||||
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
|
||||
@ -403,13 +361,12 @@ extern int interactive, 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;
|
||||
|
||||
extern int yymore_really_used, reject_really_used;
|
||||
|
||||
extern int trace_hex;
|
||||
|
||||
/* Variables used in the flex input routines:
|
||||
* datapos - characters on current output line
|
||||
@ -444,7 +401,7 @@ extern int yymore_really_used, reject_really_used;
|
||||
*/
|
||||
|
||||
extern int datapos, dataline, linenum;
|
||||
extern FILE *skelfile, *yyin, *backing_up_file;
|
||||
extern FILE *skelfile, *backing_up_file;
|
||||
extern const char *skel[];
|
||||
extern int skel_ind;
|
||||
extern char *infilename, *outfilename, *headerfilename;
|
||||
@ -646,7 +603,7 @@ extern int end_of_buffer_state;
|
||||
|
||||
extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
|
||||
extern int current_maxccls, current_max_ccl_tbl_size;
|
||||
extern Char *ccltbl;
|
||||
extern unsigned char *ccltbl;
|
||||
|
||||
|
||||
/* Variables for miscellaneous information:
|
||||
@ -674,62 +631,54 @@ 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));
|
||||
#ifndef HAVE_REALLOCARRAY
|
||||
void *reallocarray(void *, size_t, size_t);
|
||||
#endif
|
||||
|
||||
void *flex_alloc PROTO ((size_t));
|
||||
void *flex_realloc PROTO ((void *, size_t));
|
||||
void flex_free PROTO ((void *));
|
||||
void *allocate_array(int, size_t);
|
||||
void *reallocate_array(void *, int, size_t);
|
||||
|
||||
#define allocate_integer_array(size) \
|
||||
(int *) allocate_array( size, sizeof( int ) )
|
||||
allocate_array(size, sizeof(int))
|
||||
|
||||
#define reallocate_integer_array(array,size) \
|
||||
(int *) reallocate_array( (void *) array, size, sizeof( int ) )
|
||||
reallocate_array((void *) array, size, sizeof(int))
|
||||
|
||||
#define allocate_bool_array(size) \
|
||||
(bool *) allocate_array( size, sizeof( bool ) )
|
||||
allocate_array(size, sizeof(bool))
|
||||
|
||||
#define reallocate_bool_array(array,size) \
|
||||
(bool *) reallocate_array( (void *) array, size, sizeof( bool ) )
|
||||
reallocate_array((void *) array, size, sizeof(bool))
|
||||
|
||||
#define allocate_int_ptr_array(size) \
|
||||
(int **) allocate_array( size, sizeof( int * ) )
|
||||
allocate_array(size, sizeof(int *))
|
||||
|
||||
#define allocate_char_ptr_array(size) \
|
||||
(char **) allocate_array( size, sizeof( char * ) )
|
||||
allocate_array(size, sizeof(char *))
|
||||
|
||||
#define allocate_dfaacc_union(size) \
|
||||
(union dfaacc_union *) \
|
||||
allocate_array( size, sizeof( union dfaacc_union ) )
|
||||
allocate_array(size, sizeof(union dfaacc_union))
|
||||
|
||||
#define reallocate_int_ptr_array(array,size) \
|
||||
(int **) reallocate_array( (void *) array, size, sizeof( int * ) )
|
||||
reallocate_array((void *) array, size, sizeof(int *))
|
||||
|
||||
#define reallocate_char_ptr_array(array,size) \
|
||||
(char **) reallocate_array( (void *) array, size, sizeof( char * ) )
|
||||
reallocate_array((void *) array, size, sizeof(char *))
|
||||
|
||||
#define reallocate_dfaacc_union(array, size) \
|
||||
(union dfaacc_union *) \
|
||||
reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
|
||||
reallocate_array((void *) array, size, sizeof(union dfaacc_union))
|
||||
|
||||
#define allocate_character_array(size) \
|
||||
(char *) allocate_array( size, sizeof( char ) )
|
||||
allocate_array( size, sizeof(char))
|
||||
|
||||
#define reallocate_character_array(array,size) \
|
||||
(char *) reallocate_array( (void *) array, size, sizeof( char ) )
|
||||
reallocate_array((void *) array, size, sizeof(char))
|
||||
|
||||
#define allocate_Character_array(size) \
|
||||
(Char *) allocate_array( size, sizeof( Char ) )
|
||||
allocate_array(size, sizeof(unsigned char))
|
||||
|
||||
#define reallocate_Character_array(array,size) \
|
||||
(Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
|
||||
|
||||
|
||||
/* Used to communicate between scanner and parser. The type should really
|
||||
* be YYSTYPE, but we can't easily get our hands on it.
|
||||
*/
|
||||
extern int yylval;
|
||||
reallocate_array((void *) array, size, sizeof(unsigned char))
|
||||
|
||||
|
||||
/* External functions that are cross-referenced among the flex source files. */
|
||||
@ -737,146 +686,143 @@ 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(int, int); /* add a single character to a ccl */
|
||||
extern int cclinit(void); /* make an empty ccl */
|
||||
extern void cclnegate(int); /* negate a ccl */
|
||||
extern int ccl_set_diff (int a, int b); /* set difference of two ccls. */
|
||||
extern int ccl_set_union (int a, int b); /* set union of two ccls. */
|
||||
|
||||
/* List the members of a set of characters in CCL form. */
|
||||
extern void list_character_set PROTO ((FILE *, int[]));
|
||||
extern void list_character_set(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(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(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(int *, int *, int[], int *, int *);
|
||||
|
||||
/* Increase the maximum number of dfas. */
|
||||
extern void increase_max_dfas PROTO ((void));
|
||||
extern void increase_max_dfas(void);
|
||||
|
||||
extern void ntod PROTO ((void)); /* convert a ndfa to a dfa */
|
||||
extern void ntod(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(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(void);
|
||||
|
||||
/* Associate equivalence class numbers with class members. */
|
||||
extern int cre8ecs PROTO ((int[], int[], int));
|
||||
extern int cre8ecs(int[], int[], int);
|
||||
|
||||
/* Update equivalence classes based on character class transitions. */
|
||||
extern void mkeccl PROTO ((Char[], int, int[], int[], int, int));
|
||||
extern void mkeccl(unsigned char[], int, int[], int[], int, int);
|
||||
|
||||
/* Create equivalence class for single character. */
|
||||
extern void mkechar PROTO ((int, int[], int[]));
|
||||
extern void mkechar(int, int[], int[]);
|
||||
|
||||
|
||||
/* from file gen.c */
|
||||
|
||||
extern void do_indent PROTO ((void)); /* indent to the current level */
|
||||
extern void do_indent(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(void);
|
||||
|
||||
/* Generate the code to perform the backing up. */
|
||||
extern void gen_bu_action PROTO ((void));
|
||||
extern void gen_bu_action(void);
|
||||
|
||||
/* Generate full speed compressed transition table. */
|
||||
extern void genctbl PROTO ((void));
|
||||
extern void genctbl(void);
|
||||
|
||||
/* Generate the code to find the action number. */
|
||||
extern void gen_find_action PROTO ((void));
|
||||
extern void gen_find_action(void);
|
||||
|
||||
extern void genftbl PROTO ((void)); /* generate full transition table */
|
||||
extern void genftbl(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(char *);
|
||||
|
||||
/* Generate the code to find the next match. */
|
||||
extern void gen_next_match PROTO ((void));
|
||||
extern void gen_next_match(void);
|
||||
|
||||
/* Generate the code to find the next state. */
|
||||
extern void gen_next_state PROTO ((int));
|
||||
extern void gen_next_state(int);
|
||||
|
||||
/* Generate the code to make a NUL transition. */
|
||||
extern void gen_NUL_trans PROTO ((void));
|
||||
extern void gen_NUL_trans(void);
|
||||
|
||||
/* Generate the code to find the start state. */
|
||||
extern void gen_start_state PROTO ((void));
|
||||
extern void gen_start_state(void);
|
||||
|
||||
/* Generate data statements for the transition tables. */
|
||||
extern void gentabs PROTO ((void));
|
||||
extern void gentabs(void);
|
||||
|
||||
/* Write out a formatted string at the current indentation level. */
|
||||
extern void indent_put2s PROTO ((const char *, const char *));
|
||||
extern void indent_put2s(const char *, const char *);
|
||||
|
||||
/* Write out a string + newline at the current indentation level. */
|
||||
extern void indent_puts PROTO ((const char *));
|
||||
extern void indent_puts(const char *);
|
||||
|
||||
extern void make_tables PROTO ((void)); /* generate transition tables */
|
||||
extern void make_tables(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(void);
|
||||
extern void flexend(int);
|
||||
extern void usage(void);
|
||||
|
||||
|
||||
/* from file misc.c */
|
||||
|
||||
/* Add a #define to the action file. */
|
||||
extern void action_define PROTO ((const char *defname, int value));
|
||||
extern void action_define(const char *defname, int value);
|
||||
|
||||
/* Add the given text to the stored actions. */
|
||||
extern void add_action PROTO ((const char *new_text));
|
||||
extern void add_action(const char *new_text);
|
||||
|
||||
/* True if a string is all lower case. */
|
||||
extern int all_lower PROTO ((register char *));
|
||||
extern int all_lower(char *);
|
||||
|
||||
/* True if a string is all upper case. */
|
||||
extern int all_upper PROTO ((register char *));
|
||||
extern int all_upper(char *);
|
||||
|
||||
/* Compare two integers for use by qsort. */
|
||||
extern int intcmp PROTO ((const void *, const void *));
|
||||
extern int intcmp(const void *, const void *);
|
||||
|
||||
/* Check a character to make sure it's in the expected range. */
|
||||
extern void check_char PROTO ((int c));
|
||||
extern void check_char(int c);
|
||||
|
||||
/* Replace upper-case letter to lower-case. */
|
||||
extern Char clower PROTO ((int));
|
||||
extern unsigned char clower(int);
|
||||
|
||||
/* Returns a dynamically allocated copy of a string. */
|
||||
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 *));
|
||||
/* strdup() that fails fatally on allocation failures. */
|
||||
extern char *xstrdup(const char *);
|
||||
|
||||
/* Compare two characters for use by qsort with '\0' sorting last. */
|
||||
extern int cclcmp PROTO ((const void *, const void *));
|
||||
extern int cclcmp(const void *, const void *);
|
||||
|
||||
/* Finish up a block of data declarations. */
|
||||
extern void dataend PROTO ((void));
|
||||
extern void dataend(void);
|
||||
|
||||
/* Flush generated data statements. */
|
||||
extern void dataflush PROTO ((void));
|
||||
extern void dataflush(void);
|
||||
|
||||
/* Report an error message and terminate. */
|
||||
extern void flexerror PROTO ((const char *));
|
||||
extern void flexerror(const char *);
|
||||
|
||||
/* Report a fatal error message and terminate. */
|
||||
extern void flexfatal PROTO ((const char *));
|
||||
extern void flexfatal(const char *);
|
||||
|
||||
/* Report a fatal error with a pinpoint, and terminate */
|
||||
#if HAVE_DECL___FUNC__
|
||||
@ -899,203 +845,195 @@ extern void flexfatal PROTO ((const char *));
|
||||
}while(0)
|
||||
#endif /* ! HAVE_DECL___func__ */
|
||||
|
||||
/* Convert a hexadecimal digit string to an integer value. */
|
||||
extern int htoi PROTO ((Char[]));
|
||||
/* Report an error message formatted */
|
||||
extern void lerr(const char *, ...)
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__format__(__printf__, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Report an error message formatted with one integer argument. */
|
||||
extern void lerrif PROTO ((const char *, int));
|
||||
|
||||
/* Report an error message formatted with one string argument. */
|
||||
extern void lerrsf PROTO ((const char *, const char *));
|
||||
|
||||
/* Like lerrsf, but also exit after displaying message. */
|
||||
extern void lerrsf_fatal PROTO ((const char *, const char *));
|
||||
/* Like lerr, but also exit after displaying message. */
|
||||
extern void lerr_fatal(const char *, ...)
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__format__(__printf__, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Spit out a "#line" statement. */
|
||||
extern void line_directive_out PROTO ((FILE *, int));
|
||||
extern void line_directive_out(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(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(void);
|
||||
|
||||
/* Generate a data statment for a two-dimensional array. */
|
||||
extern void mk2data PROTO ((int));
|
||||
extern void mk2data(int);
|
||||
|
||||
extern void mkdata PROTO ((int)); /* generate a data statement */
|
||||
extern void mkdata(int); /* generate a data statement */
|
||||
|
||||
/* Return the integer represented by a string of digits. */
|
||||
extern int myctoi PROTO ((const char *));
|
||||
extern int myctoi(const char *);
|
||||
|
||||
/* Return character corresponding to escape sequence. */
|
||||
extern Char myesc PROTO ((Char[]));
|
||||
|
||||
/* Convert an octal digit string to an integer value. */
|
||||
extern int otoi PROTO ((Char[]));
|
||||
extern unsigned char myesc(unsigned 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_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 *));
|
||||
extern void out_m4_define (const char* def, const char* val);
|
||||
extern void out(const char *);
|
||||
extern void out_dec(const char *, int);
|
||||
extern void out_dec2(const char *, int, int);
|
||||
extern void out_hex(const char *, unsigned int);
|
||||
extern void out_str(const char *, const char *);
|
||||
extern void out_str3(const char *, const char *, const char *, const char *);
|
||||
extern void out_str_dec(const char *, const char *, int);
|
||||
extern void outc(int);
|
||||
extern void outn(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(int);
|
||||
|
||||
/* Write out one section of the skeleton file. */
|
||||
extern void skelout PROTO ((void));
|
||||
extern void skelout(void);
|
||||
|
||||
/* Output a yy_trans_info structure. */
|
||||
extern void transition_struct_out PROTO ((int, int));
|
||||
extern void transition_struct_out(int, int);
|
||||
|
||||
/* Only needed when using certain broken versions of bison to build parse.c. */
|
||||
extern void *yy_flex_xmalloc PROTO ((int));
|
||||
|
||||
/* Set a region of memory to 0. */
|
||||
extern void zero_out PROTO ((char *, size_t));
|
||||
extern void *yy_flex_xmalloc(int);
|
||||
|
||||
|
||||
/* from file nfa.c */
|
||||
|
||||
/* Add an accepting state to a machine. */
|
||||
extern void add_accept PROTO ((int, int));
|
||||
extern void add_accept(int, int);
|
||||
|
||||
/* Make a given number of copies of a singleton machine. */
|
||||
extern int copysingl PROTO ((int, int));
|
||||
extern int copysingl(int, int);
|
||||
|
||||
/* Debugging routine to write out an nfa. */
|
||||
extern void dumpnfa PROTO ((int));
|
||||
extern void dumpnfa(int);
|
||||
|
||||
/* Finish up the processing for a rule. */
|
||||
extern void finish_rule PROTO ((int, int, int, int, int));
|
||||
extern void finish_rule(int, int, int, int, int);
|
||||
|
||||
/* Connect two machines together. */
|
||||
extern int link_machines PROTO ((int, int));
|
||||
extern int link_machines(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(int);
|
||||
|
||||
/* Make a machine that branches to two machines. */
|
||||
extern int mkbranch PROTO ((int, int));
|
||||
extern int mkbranch(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(int); /* convert a machine into a closure */
|
||||
extern int mkopt(int); /* make a machine optional */
|
||||
|
||||
/* Make a machine that matches either one of two machines. */
|
||||
extern int mkor PROTO ((int, int));
|
||||
extern int mkor(int, int);
|
||||
|
||||
/* Convert a machine into a positive closure. */
|
||||
extern int mkposcl PROTO ((int));
|
||||
extern int mkposcl(int);
|
||||
|
||||
extern int mkrep PROTO ((int, int, int)); /* make a replicated machine */
|
||||
extern int mkrep(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(int);
|
||||
|
||||
extern void new_rule PROTO ((void)); /* initialize for a new rule */
|
||||
extern void new_rule(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(void);
|
||||
|
||||
/* Write out a message formatted with one string, pinpointing its location. */
|
||||
extern void format_pinpoint_message PROTO ((const char *, const char *));
|
||||
extern void format_pinpoint_message(const char *, const char *);
|
||||
|
||||
/* Write out a message, pinpointing its location. */
|
||||
extern void pinpoint_message PROTO ((const char *));
|
||||
extern void pinpoint_message(const char *);
|
||||
|
||||
/* Write out a warning, pinpointing it at the given line. */
|
||||
extern void line_warning PROTO ((const char *, int));
|
||||
extern void line_warning(const char *, int);
|
||||
|
||||
/* Write out a message, pinpointing it at the given line. */
|
||||
extern void line_pinpoint PROTO ((const char *, int));
|
||||
extern void line_pinpoint(const char *, int);
|
||||
|
||||
/* Report a formatted syntax error. */
|
||||
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 */
|
||||
extern void format_synerr(const char *, const char *);
|
||||
extern void synerr(const char *); /* report a syntax error */
|
||||
extern void format_warn(const char *, const char *);
|
||||
extern void lwarn(const char *); /* report a warning */
|
||||
extern void yyerror(const char *); /* report a parse error */
|
||||
extern int yyparse(void); /* the YACC parser */
|
||||
|
||||
|
||||
/* from file scan.l */
|
||||
|
||||
/* The Flex-generated scanner for flex. */
|
||||
extern int flexscan PROTO ((void));
|
||||
extern int flexscan(void);
|
||||
|
||||
/* Open the given file (if NULL, stdin) for scanning. */
|
||||
extern void set_input_file PROTO ((char *));
|
||||
|
||||
/* Wrapup a file in the lexical analyzer. */
|
||||
extern int yywrap PROTO ((void));
|
||||
extern void set_input_file(char *);
|
||||
|
||||
|
||||
/* from file sym.c */
|
||||
|
||||
/* Save the text of a character class. */
|
||||
extern void cclinstal PROTO ((Char[], int));
|
||||
extern void cclinstal(char[], int);
|
||||
|
||||
/* Lookup the number associated with character class. */
|
||||
extern int ccllookup PROTO ((Char[]));
|
||||
extern int ccllookup(char[]);
|
||||
|
||||
extern void ndinstal PROTO ((const char *, Char[])); /* install a name definition */
|
||||
extern Char *ndlookup PROTO ((const char *)); /* lookup a name definition */
|
||||
extern void ndinstal(const char *, char[]); /* install a name definition */
|
||||
extern char *ndlookup(const char *); /* lookup a name definition */
|
||||
|
||||
/* Increase maximum number of SC's. */
|
||||
extern void scextend PROTO ((void));
|
||||
extern void scinstal PROTO ((const char *, int)); /* make a start condition */
|
||||
extern void scextend(void);
|
||||
extern void scinstal(const char *, int); /* make a start condition */
|
||||
|
||||
/* Lookup the number associated with a start condition. */
|
||||
extern int sclookup PROTO ((const char *));
|
||||
extern int sclookup(const char *);
|
||||
|
||||
|
||||
/* from file tblcmp.c */
|
||||
|
||||
/* Build table entries for dfa state. */
|
||||
extern void bldtbl PROTO ((int[], int, int, int, int));
|
||||
extern void bldtbl(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(void); /* compress template table entries */
|
||||
extern void expand_nxt_chk(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(int *, int);
|
||||
extern void inittbl(void); /* initialize transition tables */
|
||||
|
||||
/* Make the default, "jam" table entries. */
|
||||
extern void mkdeftbl PROTO ((void));
|
||||
extern void mkdeftbl(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(int, int, int, int);
|
||||
|
||||
/* Place a state into full speed transition table. */
|
||||
extern void place_state PROTO ((int *, int, int));
|
||||
extern void place_state(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(int, int, int, int);
|
||||
|
||||
|
||||
/* from file yylex.c */
|
||||
|
||||
extern int yylex PROTO ((void));
|
||||
extern int yylex(void);
|
||||
|
||||
/* A growable array. See buf.c. */
|
||||
struct Buf {
|
||||
@ -1105,30 +1043,28 @@ struct Buf {
|
||||
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 void buf_init(struct Buf * buf, size_t elem_size);
|
||||
extern void buf_destroy(struct Buf * buf);
|
||||
extern struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem);
|
||||
extern struct Buf *buf_concat(struct Buf* dest, const struct Buf* src);
|
||||
extern struct Buf *buf_strappend(struct Buf *, const char *str);
|
||||
extern struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars);
|
||||
extern struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def);
|
||||
extern struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s);
|
||||
extern struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val);
|
||||
extern struct Buf *buf_m4_undefine(struct Buf *buf, const char* def);
|
||||
extern struct Buf *buf_print_strings(struct Buf * buf, FILE* out);
|
||||
extern struct Buf *buf_linedir(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. */
|
||||
extern bool no_section3_escape; /* True if the undocumented option --unsafe-no-m4-sect3-escape was passed */
|
||||
|
||||
/* For blocking out code from the header file. */
|
||||
#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[")
|
||||
#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[m4_dnl")
|
||||
#define OUT_END_CODE() outn("]])")
|
||||
|
||||
/* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */
|
||||
@ -1181,14 +1117,14 @@ struct filter {
|
||||
|
||||
/* 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,
|
||||
extern struct filter *filter_create_ext (struct filter * chain, const char *cmd, ...);
|
||||
struct filter *filter_create_int(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));
|
||||
void *extra);
|
||||
extern bool filter_apply_chain(struct filter * chain);
|
||||
extern int filter_truncate(struct filter * chain, int max_len);
|
||||
extern int filter_tee_header(struct filter *chain);
|
||||
extern int filter_fix_linedirs(struct filter *chain);
|
||||
|
||||
|
||||
/*
|
||||
@ -1208,9 +1144,9 @@ bool regmatch_empty (regmatch_t * m);
|
||||
typedef unsigned int scanflags_t;
|
||||
extern scanflags_t* _sf_stk;
|
||||
extern size_t _sf_top_ix, _sf_max; /**< stack of scanner flags. */
|
||||
#define _SF_CASE_INS 0x0001
|
||||
#define _SF_DOT_ALL 0x0002
|
||||
#define _SF_SKIP_WS 0x0004
|
||||
#define _SF_CASE_INS ((scanflags_t) 0x0001)
|
||||
#define _SF_DOT_ALL ((scanflags_t) 0x0002)
|
||||
#define _SF_SKIP_WS ((scanflags_t) 0x0004)
|
||||
#define sf_top() (_sf_stk[_sf_top_ix])
|
||||
#define sf_case_ins() (sf_top() & _SF_CASE_INS)
|
||||
#define sf_dot_all() (sf_top() & _SF_DOT_ALL)
|
@ -58,6 +58,10 @@ typedef unsigned int flex_uint32_t;
|
||||
#define UINT32_MAX (4294967295U)
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX (~(size_t)0)
|
||||
#endif
|
||||
|
||||
#endif /* ! C99 */
|
||||
|
||||
#endif /* ! FLEXINT_H */
|
File diff suppressed because it is too large
Load Diff
@ -21,13 +21,16 @@
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
extern int yylex ();
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
extern int yylex (void);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
while (yylex () != 0) ;
|
||||
|
||||
return 0;
|
||||
exit(0);
|
||||
}
|
@ -21,6 +21,8 @@
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
int yywrap (void);
|
||||
|
||||
int yywrap (void)
|
||||
{
|
||||
return 1;
|
@ -36,15 +36,15 @@
|
||||
#include "version.h"
|
||||
#include "options.h"
|
||||
#include "tables.h"
|
||||
#include "parse.h"
|
||||
|
||||
static char flex_version[] = FLEX_VERSION;
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
void flexinit PROTO ((int, char **));
|
||||
void readin PROTO ((void));
|
||||
void set_up_initial_allocations PROTO ((void));
|
||||
static char *basename2 PROTO ((char *path, int should_strip_ext));
|
||||
void flexinit(int, char **);
|
||||
void readin(void);
|
||||
void set_up_initial_allocations(void);
|
||||
|
||||
|
||||
/* these globals are all defined and commented in flexdef.h */
|
||||
@ -57,6 +57,7 @@ int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap,
|
||||
int reentrant, bison_bridge_lval, bison_bridge_lloc;
|
||||
int yymore_used, reject, real_reject, continued_action, in_rule;
|
||||
int yymore_really_used, reject_really_used;
|
||||
int trace_hex = 0;
|
||||
int datapos, dataline, linenum;
|
||||
FILE *skelfile = NULL;
|
||||
int skel_ind = 0;
|
||||
@ -93,7 +94,7 @@ int *accsiz, *dhash, numas;
|
||||
int numsnpairs, jambase, jamstate;
|
||||
int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
|
||||
int current_maxccls, current_max_ccl_tbl_size;
|
||||
Char *ccltbl;
|
||||
unsigned char *ccltbl;
|
||||
char nmstr[MAXLINE];
|
||||
int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
|
||||
int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
|
||||
@ -105,7 +106,6 @@ int num_input_files;
|
||||
jmp_buf flex_main_jmp_buf;
|
||||
bool *rule_has_nl, *ccl_has_nl;
|
||||
int nlch = '\n';
|
||||
bool ansi_func_defs, ansi_func_protos;
|
||||
|
||||
bool tablesext, tablesverify, gentables;
|
||||
char *tablesfilename=0,*tablesname=0;
|
||||
@ -116,19 +116,9 @@ struct yytbl_writer tableswr;
|
||||
*/
|
||||
char *program_name = "flex";
|
||||
|
||||
#ifndef SHORT_FILE_NAMES
|
||||
static char *outfile_template = "lex.%s.%s";
|
||||
static char *backing_name = "lex.backup";
|
||||
static char *tablesfile_template = "lex.%s.tables";
|
||||
#else
|
||||
static char *outfile_template = "lex%s.%s";
|
||||
static char *backing_name = "lex.bck";
|
||||
static char *tablesfile_template = "lex%s.tbl";
|
||||
#endif
|
||||
|
||||
#ifdef MS_DOS
|
||||
extern unsigned _stklen = 16384;
|
||||
#endif
|
||||
static const char outfile_template[] = "lex.%s.%s";
|
||||
static const char backing_name[] = "lex.backup";
|
||||
static const char tablesfile_template[] = "lex.%s.tables";
|
||||
|
||||
/* From scan.l */
|
||||
extern FILE* yyout;
|
||||
@ -137,18 +127,15 @@ static char outfile_path[MAXLINE];
|
||||
static int outfile_created = 0;
|
||||
static char *skelname = NULL;
|
||||
static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */
|
||||
const char *escaped_qstart = "[[]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[]]";
|
||||
const char *escaped_qend = "[[]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[]]";
|
||||
const char *escaped_qstart = "]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[";
|
||||
const char *escaped_qend = "]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[";
|
||||
|
||||
/* For debugging. The max number of filters to apply to skeleton. */
|
||||
static int preproc_level = 1000;
|
||||
|
||||
int flex_main PROTO ((int argc, char *argv[]));
|
||||
int main PROTO ((int argc, char *argv[]));
|
||||
int flex_main (int argc, char *argv[]);
|
||||
|
||||
int flex_main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int flex_main (int argc, char *argv[])
|
||||
{
|
||||
int i, exit_status, child_status;
|
||||
|
||||
@ -208,9 +195,7 @@ int flex_main (argc, argv)
|
||||
}
|
||||
|
||||
/* Wrapper around flex_main, so flex_main can be built as a library. */
|
||||
int main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
#if ENABLE_NLS
|
||||
#if HAVE_LOCALE_H
|
||||
@ -226,7 +211,7 @@ int main (argc, argv)
|
||||
|
||||
/* check_options - check user-specified options */
|
||||
|
||||
void check_options ()
|
||||
void check_options (void)
|
||||
{
|
||||
int i;
|
||||
const char * m4 = NULL;
|
||||
@ -291,7 +276,7 @@ void check_options ()
|
||||
flexerror (_("Can't use -+ with -CF option"));
|
||||
|
||||
if (C_plus_plus && yytext_is_array) {
|
||||
warn (_("%array incompatible with -+ option"));
|
||||
lwarn (_("%array incompatible with -+ option"));
|
||||
yytext_is_array = false;
|
||||
}
|
||||
|
||||
@ -325,14 +310,8 @@ void check_options ()
|
||||
}
|
||||
}
|
||||
|
||||
if (!ansi_func_defs)
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_DEFS", NULL);
|
||||
|
||||
if (!ansi_func_protos)
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_PROTOS", NULL);
|
||||
|
||||
if (extra_type)
|
||||
buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type);
|
||||
if (extra_type)
|
||||
buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type);
|
||||
|
||||
if (!use_stdout) {
|
||||
FILE *prev_stdout;
|
||||
@ -354,7 +333,7 @@ void check_options ()
|
||||
prev_stdout = freopen (outfilename, "w+", stdout);
|
||||
|
||||
if (prev_stdout == NULL)
|
||||
lerrsf (_("could not create %s"), outfilename);
|
||||
lerr (_("could not create %s"), outfilename);
|
||||
|
||||
outfile_created = 1;
|
||||
}
|
||||
@ -362,8 +341,45 @@ void check_options ()
|
||||
|
||||
/* Setup the filter chain. */
|
||||
output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
|
||||
if ( !(m4 = getenv("M4")))
|
||||
m4 = M4;
|
||||
if ( !(m4 = getenv("M4"))) {
|
||||
char *slash;
|
||||
m4 = M4;
|
||||
if ((slash = strrchr(M4, '/')) != NULL) {
|
||||
m4 = slash+1;
|
||||
/* break up $PATH */
|
||||
const char *path = getenv("PATH");
|
||||
if (!path) {
|
||||
m4 = M4;
|
||||
} else {
|
||||
int m4_length = strlen(m4);
|
||||
do {
|
||||
size_t length = strlen(path);
|
||||
struct stat sbuf;
|
||||
|
||||
const char *endOfDir = strchr(path, ':');
|
||||
if (!endOfDir)
|
||||
endOfDir = path+length;
|
||||
|
||||
{
|
||||
char *m4_path = calloc(endOfDir-path + 1 + m4_length + 1, 1);
|
||||
|
||||
memcpy(m4_path, path, endOfDir-path);
|
||||
m4_path[endOfDir-path] = '/';
|
||||
memcpy(m4_path + (endOfDir-path) + 1, m4, m4_length + 1);
|
||||
if (stat(m4_path, &sbuf) == 0 &&
|
||||
(S_ISREG(sbuf.st_mode)) && sbuf.st_mode & S_IXUSR) {
|
||||
m4 = m4_path;
|
||||
break;
|
||||
}
|
||||
free(m4_path);
|
||||
}
|
||||
path = endOfDir+1;
|
||||
} while (path[0]);
|
||||
if (!path[0])
|
||||
m4 = M4;
|
||||
}
|
||||
}
|
||||
}
|
||||
filter_create_ext(output_chain, m4, "-P", 0);
|
||||
filter_create_int(output_chain, filter_fix_linedirs, NULL);
|
||||
|
||||
@ -389,26 +405,25 @@ void check_options ()
|
||||
FILE *tablesout;
|
||||
struct yytbl_hdr hdr;
|
||||
char *pname = 0;
|
||||
int nbytes = 0;
|
||||
size_t nbytes = 0;
|
||||
|
||||
buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL);
|
||||
|
||||
if (!tablesfilename) {
|
||||
nbytes = strlen (prefix) + strlen (tablesfile_template) + 2;
|
||||
tablesfilename = pname = (char *) calloc (nbytes, 1);
|
||||
tablesfilename = pname = calloc(nbytes, 1);
|
||||
snprintf (pname, nbytes, tablesfile_template, prefix);
|
||||
}
|
||||
|
||||
if ((tablesout = fopen (tablesfilename, "w")) == NULL)
|
||||
lerrsf (_("could not create %s"), tablesfilename);
|
||||
if (pname)
|
||||
free (pname);
|
||||
lerr (_("could not create %s"), tablesfilename);
|
||||
free(pname);
|
||||
tablesfilename = 0;
|
||||
|
||||
yytbl_writer_init (&tableswr, tablesout);
|
||||
|
||||
nbytes = strlen (prefix) + strlen ("tables") + 2;
|
||||
tablesname = (char *) calloc (nbytes, 1);
|
||||
tablesname = calloc(nbytes, 1);
|
||||
snprintf (tablesname, nbytes, "%stables", prefix);
|
||||
yytbl_hdr_init (&hdr, flex_version, tablesname);
|
||||
|
||||
@ -417,7 +432,7 @@ void check_options ()
|
||||
}
|
||||
|
||||
if (skelname && (skelfile = fopen (skelname, "r")) == NULL)
|
||||
lerrsf (_("can't open skeleton file %s"), skelname);
|
||||
lerr (_("can't open skeleton file %s"), skelname);
|
||||
|
||||
if (reentrant) {
|
||||
buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
|
||||
@ -431,6 +446,8 @@ void check_options ()
|
||||
if ( bison_bridge_lloc)
|
||||
buf_m4_define (&m4defs_buf, "<M4_YY_BISON_LLOC>", NULL);
|
||||
|
||||
if (strchr(prefix, '[') || strchr(prefix, ']'))
|
||||
flexerror(_("Prefix cannot include '[' or ']'"));
|
||||
buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
|
||||
|
||||
if (did_outfilename)
|
||||
@ -451,7 +468,8 @@ void check_options ()
|
||||
char *str, *fmt = "#define %s %d\n";
|
||||
size_t strsz;
|
||||
|
||||
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + (int)(1 + log10(i)) + 2);
|
||||
strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2;
|
||||
str = malloc(strsz);
|
||||
if (!str)
|
||||
flexfatal(_("allocation of macro definition failed"));
|
||||
snprintf(str, strsz, fmt, scname[i], i - 1);
|
||||
@ -473,7 +491,8 @@ void check_options ()
|
||||
m4defs_buf.nelts = 0; /* memory leak here. */
|
||||
|
||||
/* Place a bogus line directive, it will be fixed in the filter. */
|
||||
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
|
||||
if (gen_line_dirs)
|
||||
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
|
||||
|
||||
/* Dump the user defined preproc directives. */
|
||||
if (userdef_buf.elts)
|
||||
@ -489,9 +508,7 @@ void check_options ()
|
||||
* This routine does not return.
|
||||
*/
|
||||
|
||||
void flexend (exit_status)
|
||||
int exit_status;
|
||||
|
||||
void flexend (int exit_status)
|
||||
{
|
||||
static int called_before = -1; /* prevent infinite recursion. */
|
||||
int tblsiz;
|
||||
@ -501,11 +518,11 @@ void flexend (exit_status)
|
||||
|
||||
if (skelfile != NULL) {
|
||||
if (ferror (skelfile))
|
||||
lerrsf (_("input error reading skeleton file %s"),
|
||||
lerr (_("input error reading skeleton file %s"),
|
||||
skelname);
|
||||
|
||||
else if (fclose (skelfile))
|
||||
lerrsf (_("error closing skeleton file %s"),
|
||||
lerr (_("error closing skeleton file %s"),
|
||||
skelname);
|
||||
}
|
||||
|
||||
@ -538,7 +555,6 @@ void flexend (exit_status)
|
||||
"EOB_ACT_END_OF_FILE",
|
||||
"EOB_ACT_LAST_MATCH",
|
||||
"FLEX_SCANNER",
|
||||
"FLEX_STD",
|
||||
"REJECT",
|
||||
"YYFARGS0",
|
||||
"YYFARGS1",
|
||||
@ -625,7 +641,7 @@ void flexend (exit_status)
|
||||
"yypop_buffer_state",
|
||||
"yyensure_buffer_stack",
|
||||
"yyalloc",
|
||||
"yyconst",
|
||||
"const",
|
||||
"yyextra",
|
||||
"yyfree",
|
||||
"yyget_debug",
|
||||
@ -690,7 +706,7 @@ void flexend (exit_status)
|
||||
fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix);
|
||||
|
||||
if (ferror (header_out))
|
||||
lerrsf (_("error creating header file %s"),
|
||||
lerr (_("error creating header file %s"),
|
||||
headerfilename);
|
||||
fflush (header_out);
|
||||
fclose (header_out);
|
||||
@ -698,15 +714,15 @@ void flexend (exit_status)
|
||||
|
||||
if (exit_status != 0 && outfile_created) {
|
||||
if (ferror (stdout))
|
||||
lerrsf (_("error writing output file %s"),
|
||||
lerr (_("error writing output file %s"),
|
||||
outfilename);
|
||||
|
||||
else if ((_stdout_closed = 1) && fclose (stdout))
|
||||
lerrsf (_("error closing output file %s"),
|
||||
lerr (_("error closing output file %s"),
|
||||
outfilename);
|
||||
|
||||
else if (unlink (outfilename))
|
||||
lerrsf (_("error deleting output file %s"),
|
||||
lerr (_("error deleting output file %s"),
|
||||
outfilename);
|
||||
}
|
||||
|
||||
@ -724,11 +740,11 @@ void flexend (exit_status)
|
||||
_("Compressed tables always back up.\n"));
|
||||
|
||||
if (ferror (backing_up_file))
|
||||
lerrsf (_("error writing backup file %s"),
|
||||
lerr (_("error writing backup file %s"),
|
||||
backing_name);
|
||||
|
||||
else if (fclose (backing_up_file))
|
||||
lerrsf (_("error closing backup file %s"),
|
||||
lerr (_("error closing backup file %s"),
|
||||
backing_name);
|
||||
}
|
||||
|
||||
@ -925,9 +941,7 @@ void flexend (exit_status)
|
||||
|
||||
/* flexinit - initialize flex */
|
||||
|
||||
void flexinit (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
void flexinit (int argc, char **argv)
|
||||
{
|
||||
int i, sawcmpflag, rv, optind;
|
||||
char *arg;
|
||||
@ -952,7 +966,6 @@ void flexinit (argc, argv)
|
||||
tablesext = tablesverify = false;
|
||||
gentables = true;
|
||||
tablesfilename = tablesname = NULL;
|
||||
ansi_func_defs = ansi_func_protos = true;
|
||||
|
||||
sawcmpflag = false;
|
||||
|
||||
@ -981,9 +994,9 @@ void flexinit (argc, argv)
|
||||
flex_init_regex();
|
||||
|
||||
/* Enable C++ if program name ends with '+'. */
|
||||
program_name = basename2 (argv[0], 0);
|
||||
program_name = basename (argv[0]);
|
||||
|
||||
if (program_name[0] != '\0' &&
|
||||
if (program_name != NULL &&
|
||||
program_name[strlen (program_name) - 1] == '+')
|
||||
C_plus_plus = true;
|
||||
|
||||
@ -1058,9 +1071,9 @@ void flexinit (argc, argv)
|
||||
break;
|
||||
|
||||
default:
|
||||
lerrif (_
|
||||
lerr (_
|
||||
("unknown -C option '%c'"),
|
||||
(int) arg[i]);
|
||||
arg[i]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -1104,7 +1117,7 @@ void flexinit (argc, argv)
|
||||
break;
|
||||
|
||||
case OPT_PREPROC_LEVEL:
|
||||
preproc_level = strtol(arg,NULL,0);
|
||||
preproc_level = (int) strtol(arg,NULL,0);
|
||||
break;
|
||||
|
||||
case OPT_MAIN:
|
||||
@ -1267,7 +1280,7 @@ void flexinit (argc, argv)
|
||||
}
|
||||
else {
|
||||
buf_strnappend (&userdef_buf, arg,
|
||||
def - arg);
|
||||
(int) (def - arg));
|
||||
buf_strappend (&userdef_buf, " ");
|
||||
buf_strappend (&userdef_buf,
|
||||
def + 1);
|
||||
@ -1329,14 +1342,6 @@ void flexinit (argc, argv)
|
||||
reject_really_used = false;
|
||||
break;
|
||||
|
||||
case OPT_NO_ANSI_FUNC_DEFS:
|
||||
ansi_func_defs = false;
|
||||
break;
|
||||
|
||||
case OPT_NO_ANSI_FUNC_PROTOS:
|
||||
ansi_func_protos = false;
|
||||
break;
|
||||
|
||||
case OPT_NO_YY_PUSH_STATE:
|
||||
//buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE", "1");
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0);
|
||||
@ -1421,7 +1426,12 @@ void flexinit (argc, argv)
|
||||
//buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1");
|
||||
buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
|
||||
break;
|
||||
|
||||
case OPT_HEX:
|
||||
trace_hex = 1;
|
||||
break;
|
||||
case OPT_NO_SECT3_ESCAPE:
|
||||
no_section3_escape = true;
|
||||
break;
|
||||
} /* switch */
|
||||
} /* while scanopt() */
|
||||
|
||||
@ -1454,13 +1464,13 @@ void flexinit (argc, argv)
|
||||
|
||||
/* readin - read in the rules section of the input file(s) */
|
||||
|
||||
void readin ()
|
||||
void readin (void)
|
||||
{
|
||||
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
|
||||
static char yy_nostdinit[] =
|
||||
"FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;";
|
||||
"FILE *yyin = NULL, *yyout = NULL;";
|
||||
|
||||
line_directive_out ((FILE *) 0, 1);
|
||||
line_directive_out(NULL, 1);
|
||||
|
||||
if (yyparse ()) {
|
||||
pinpoint_message (_("fatal parse error"));
|
||||
@ -1494,7 +1504,7 @@ void readin ()
|
||||
if (backing_up_report) {
|
||||
backing_up_file = fopen (backing_name, "w");
|
||||
if (backing_up_file == NULL)
|
||||
lerrsf (_
|
||||
lerr (_
|
||||
("could not create backing-up info file %s"),
|
||||
backing_name);
|
||||
}
|
||||
@ -1575,11 +1585,12 @@ void readin ()
|
||||
}
|
||||
|
||||
if (!do_yywrap) {
|
||||
if (!C_plus_plus)
|
||||
if (!C_plus_plus) {
|
||||
if (reentrant)
|
||||
outn ("\n#define yywrap(yyscanner) 1");
|
||||
out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix);
|
||||
else
|
||||
outn ("\n#define yywrap() 1");
|
||||
out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix);
|
||||
}
|
||||
outn ("#define YY_SKIP_YYWRAP");
|
||||
}
|
||||
|
||||
@ -1587,10 +1598,7 @@ void readin ()
|
||||
outn ("\n#define FLEX_DEBUG");
|
||||
|
||||
OUT_BEGIN_CODE ();
|
||||
if (csize == 256)
|
||||
outn ("typedef unsigned char YY_CHAR;");
|
||||
else
|
||||
outn ("typedef char YY_CHAR;");
|
||||
outn ("typedef flex_uint8_t YY_CHAR;");
|
||||
OUT_END_CODE ();
|
||||
|
||||
if (C_plus_plus) {
|
||||
@ -1634,7 +1642,7 @@ void readin ()
|
||||
|
||||
OUT_BEGIN_CODE ();
|
||||
if (fullspd)
|
||||
outn ("typedef yyconst struct yy_trans_info *yy_state_type;");
|
||||
outn ("typedef const struct yy_trans_info *yy_state_type;");
|
||||
else if (!C_plus_plus)
|
||||
outn ("typedef int yy_state_type;");
|
||||
OUT_END_CODE ();
|
||||
@ -1683,6 +1691,10 @@ void readin ()
|
||||
}
|
||||
else {
|
||||
outn ("extern char *yytext;");
|
||||
|
||||
outn("#ifdef yytext_ptr");
|
||||
outn("#undef yytext_ptr");
|
||||
outn("#endif");
|
||||
outn ("#define yytext_ptr yytext");
|
||||
}
|
||||
}
|
||||
@ -1708,7 +1720,7 @@ void readin ()
|
||||
|
||||
/* set_up_initial_allocations - allocate memory for internal tables */
|
||||
|
||||
void set_up_initial_allocations ()
|
||||
void set_up_initial_allocations (void)
|
||||
{
|
||||
maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS);
|
||||
current_mns = INITIAL_MNS;
|
||||
@ -1762,31 +1774,11 @@ void set_up_initial_allocations ()
|
||||
dss = allocate_int_ptr_array (current_max_dfas);
|
||||
dfaacc = allocate_dfaacc_union (current_max_dfas);
|
||||
|
||||
nultrans = (int *) 0;
|
||||
nultrans = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* extracts basename from path, optionally stripping the extension "\.*"
|
||||
* (same concept as /bin/sh `basename`, but different handling of extension). */
|
||||
static char *basename2 (path, strip_ext)
|
||||
char *path;
|
||||
int strip_ext; /* boolean */
|
||||
{
|
||||
char *b, *e = 0;
|
||||
|
||||
b = path;
|
||||
for (b = path; *path; path++)
|
||||
if (*path == '/')
|
||||
b = path + 1;
|
||||
else if (*path == '.')
|
||||
e = path;
|
||||
|
||||
if (strip_ext && e && e > b)
|
||||
*e = '\0';
|
||||
return b;
|
||||
}
|
||||
|
||||
void usage ()
|
||||
void usage (void)
|
||||
{
|
||||
FILE *f = stdout;
|
||||
|
||||
@ -1818,6 +1810,7 @@ void usage ()
|
||||
" -T, --trace %s should run in trace mode\n"
|
||||
" -w, --nowarn do not generate warnings\n"
|
||||
" -v, --verbose write summary of scanner statistics to stdout\n"
|
||||
" --hex use hexadecimal numbers instead of octal in debug outputs\n"
|
||||
"\n" "Files:\n"
|
||||
" -o, --outfile=FILE specify output filename\n"
|
||||
" -S, --skel=FILE specify skeleton file\n"
|
||||
@ -1843,8 +1836,6 @@ void usage ()
|
||||
" --bison-bridge scanner for bison pure parser.\n"
|
||||
" --bison-locations include yylloc support.\n"
|
||||
" --stdinit initialize yyin/yyout to stdin/stdout\n"
|
||||
" --noansi-definitions old-style function definitions\n"
|
||||
" --noansi-prototypes empty parameter list in prototypes\n"
|
||||
" --nounistd do not include <unistd.h>\n"
|
||||
" --noFUNCTION do not generate a particular FUNCTION\n"
|
||||
"\n" "Miscellaneous:\n"
|
@ -30,7 +30,6 @@
|
||||
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
|
||||
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
|
||||
/* PURPOSE. */
|
||||
|
||||
#include "flexdef.h"
|
||||
#include "tables.h"
|
||||
|
||||
@ -60,14 +59,15 @@ static void sko_push(bool dc)
|
||||
{
|
||||
if(!sko_stack){
|
||||
sko_sz = 1;
|
||||
sko_stack = (struct sko_state*)flex_alloc(sizeof(struct sko_state)*sko_sz);
|
||||
sko_stack = malloc(sizeof(struct sko_state) * (size_t) sko_sz);
|
||||
if (!sko_stack)
|
||||
flexfatal(_("allocation of sko_stack failed"));
|
||||
sko_len = 0;
|
||||
}
|
||||
if(sko_len >= sko_sz){
|
||||
sko_sz *= 2;
|
||||
sko_stack = (struct sko_state*)flex_realloc(sko_stack,sizeof(struct sko_state)*sko_sz);
|
||||
sko_stack = realloc(sko_stack,
|
||||
sizeof(struct sko_state) * (size_t) sko_sz);
|
||||
}
|
||||
|
||||
/* initialize to zero and push */
|
||||
@ -90,9 +90,7 @@ static void sko_pop(bool* dc)
|
||||
}
|
||||
|
||||
/* Append "#define defname value\n" to the running buffer. */
|
||||
void action_define (defname, value)
|
||||
const char *defname;
|
||||
int value;
|
||||
void action_define (const char *defname, int value)
|
||||
{
|
||||
char buf[MAXLINE];
|
||||
char *cpy;
|
||||
@ -108,37 +106,14 @@ void action_define (defname, value)
|
||||
add_action (buf);
|
||||
|
||||
/* track #defines so we can undef them when we're done. */
|
||||
cpy = copy_string (defname);
|
||||
cpy = xstrdup(defname);
|
||||
buf_append (&defs_buf, &cpy, 1);
|
||||
}
|
||||
|
||||
|
||||
/** Append "m4_define([[defname]],[[value]])m4_dnl\n" to the running buffer.
|
||||
* @param defname The macro name.
|
||||
* @param value The macro value, can be NULL, which is the same as the empty string.
|
||||
*/
|
||||
void action_m4_define (const char *defname, const char * value)
|
||||
{
|
||||
char buf[MAXLINE];
|
||||
|
||||
flexfatal ("DO NOT USE THIS FUNCTION!");
|
||||
|
||||
if ((int) strlen (defname) > MAXLINE / 2) {
|
||||
format_pinpoint_message (_
|
||||
("name \"%s\" ridiculously long"),
|
||||
defname);
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf (buf, sizeof(buf), "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value?value:"");
|
||||
add_action (buf);
|
||||
}
|
||||
|
||||
/* Append "new_text" to the running buffer. */
|
||||
void add_action (new_text)
|
||||
const char *new_text;
|
||||
void add_action (const char *new_text)
|
||||
{
|
||||
int len = strlen (new_text);
|
||||
int len = (int) strlen (new_text);
|
||||
|
||||
while (len + action_index >= action_size - 10 /* slop */ ) {
|
||||
int new_size = action_size * 2;
|
||||
@ -164,14 +139,17 @@ void add_action (new_text)
|
||||
|
||||
/* allocate_array - allocate memory for an integer array of the given size */
|
||||
|
||||
void *allocate_array (size, element_size)
|
||||
int size;
|
||||
size_t element_size;
|
||||
void *allocate_array (int size, size_t element_size)
|
||||
{
|
||||
register void *mem;
|
||||
size_t num_bytes = element_size * size;
|
||||
|
||||
mem = flex_alloc (num_bytes);
|
||||
void *mem;
|
||||
#if HAVE_REALLOCARRAY
|
||||
/* reallocarray has built-in overflow detection */
|
||||
mem = reallocarray(NULL, (size_t) size, element_size);
|
||||
#else
|
||||
size_t num_bytes = (size_t) size * element_size;
|
||||
mem = (size && SIZE_MAX / (size_t) size < element_size) ? NULL :
|
||||
malloc(num_bytes);
|
||||
#endif
|
||||
if (!mem)
|
||||
flexfatal (_
|
||||
("memory allocation failed in allocate_array()"));
|
||||
@ -182,11 +160,10 @@ void *allocate_array (size, element_size)
|
||||
|
||||
/* all_lower - true if a string is all lower-case */
|
||||
|
||||
int all_lower (str)
|
||||
register char *str;
|
||||
int all_lower (char *str)
|
||||
{
|
||||
while (*str) {
|
||||
if (!isascii ((Char) * str) || !islower ((Char) * str))
|
||||
if (!isascii ((unsigned char) * str) || !islower ((unsigned char) * str))
|
||||
return 0;
|
||||
++str;
|
||||
}
|
||||
@ -197,11 +174,10 @@ int all_lower (str)
|
||||
|
||||
/* all_upper - true if a string is all upper-case */
|
||||
|
||||
int all_upper (str)
|
||||
register char *str;
|
||||
int all_upper (char *str)
|
||||
{
|
||||
while (*str) {
|
||||
if (!isascii ((Char) * str) || !isupper ((Char) * str))
|
||||
if (!isascii ((unsigned char) * str) || !isupper ((unsigned char) * str))
|
||||
return 0;
|
||||
++str;
|
||||
}
|
||||
@ -223,15 +199,14 @@ int intcmp (const void *a, const void *b)
|
||||
* and exits.
|
||||
*/
|
||||
|
||||
void check_char (c)
|
||||
int c;
|
||||
void check_char (int c)
|
||||
{
|
||||
if (c >= CSIZE)
|
||||
lerrsf (_("bad character '%s' detected in check_char()"),
|
||||
lerr (_("bad character '%s' detected in check_char()"),
|
||||
readable_form (c));
|
||||
|
||||
if (c >= csize)
|
||||
lerrsf (_
|
||||
lerr (_
|
||||
("scanner requires -8 flag to use the character %s"),
|
||||
readable_form (c));
|
||||
}
|
||||
@ -240,57 +215,20 @@ void check_char (c)
|
||||
|
||||
/* clower - replace upper-case letter to lower-case */
|
||||
|
||||
Char clower (c)
|
||||
register int c;
|
||||
unsigned char clower (int c)
|
||||
{
|
||||
return (Char) ((isascii (c) && isupper (c)) ? tolower (c) : c);
|
||||
return (unsigned char) ((isascii (c) && isupper (c)) ? tolower (c) : c);
|
||||
}
|
||||
|
||||
|
||||
/* copy_string - returns a dynamically allocated copy of a string */
|
||||
|
||||
char *copy_string (str)
|
||||
register const char *str;
|
||||
char *xstrdup(const char *s)
|
||||
{
|
||||
register const char *c1;
|
||||
register char *c2;
|
||||
char *copy;
|
||||
unsigned int size;
|
||||
char *s2;
|
||||
|
||||
/* find length */
|
||||
for (c1 = str; *c1; ++c1) ;
|
||||
if ((s2 = strdup(s)) == NULL)
|
||||
flexfatal (_("memory allocation failure in xstrdup()"));
|
||||
|
||||
size = (c1 - str + 1) * sizeof (char);
|
||||
|
||||
copy = (char *) flex_alloc (size);
|
||||
|
||||
if (copy == NULL)
|
||||
flexfatal (_("dynamic memory failure in copy_string()"));
|
||||
|
||||
for (c2 = copy; (*c2++ = *str++) != 0;) ;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
/* copy_unsigned_string -
|
||||
* returns a dynamically allocated copy of a (potentially) unsigned string
|
||||
*/
|
||||
|
||||
Char *copy_unsigned_string (str)
|
||||
register Char *str;
|
||||
{
|
||||
register Char *c;
|
||||
Char *copy;
|
||||
|
||||
/* find length */
|
||||
for (c = str; *c; ++c) ;
|
||||
|
||||
copy = allocate_Character_array (c - str + 1);
|
||||
|
||||
for (c = copy; (*c++ = *str++) != 0;) ;
|
||||
|
||||
return copy;
|
||||
return s2;
|
||||
}
|
||||
|
||||
|
||||
@ -298,19 +236,19 @@ Char *copy_unsigned_string (str)
|
||||
|
||||
int cclcmp (const void *a, const void *b)
|
||||
{
|
||||
if (!*(const Char *) a)
|
||||
if (!*(const unsigned char *) a)
|
||||
return 1;
|
||||
else
|
||||
if (!*(const Char *) b)
|
||||
if (!*(const unsigned char *) b)
|
||||
return - 1;
|
||||
else
|
||||
return *(const Char *) a - *(const Char *) b;
|
||||
return *(const unsigned char *) a - *(const unsigned char *) b;
|
||||
}
|
||||
|
||||
|
||||
/* dataend - finish up a block of data declarations */
|
||||
|
||||
void dataend ()
|
||||
void dataend (void)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (gentables) {
|
||||
@ -328,7 +266,7 @@ void dataend ()
|
||||
|
||||
/* dataflush - flush generated data statements */
|
||||
|
||||
void dataflush ()
|
||||
void dataflush (void)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (!gentables)
|
||||
@ -351,8 +289,7 @@ void dataflush ()
|
||||
|
||||
/* flexerror - report an error message and terminate */
|
||||
|
||||
void flexerror (msg)
|
||||
const char *msg;
|
||||
void flexerror (const char *msg)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", program_name, msg);
|
||||
flexend (1);
|
||||
@ -361,8 +298,7 @@ void flexerror (msg)
|
||||
|
||||
/* flexfatal - report a fatal error message and terminate */
|
||||
|
||||
void flexfatal (msg)
|
||||
const char *msg;
|
||||
void flexfatal (const char *msg)
|
||||
{
|
||||
fprintf (stderr, _("%s: fatal internal error, %s\n"),
|
||||
program_name, msg);
|
||||
@ -370,67 +306,41 @@ void flexfatal (msg)
|
||||
}
|
||||
|
||||
|
||||
/* htoi - convert a hexadecimal digit string to an integer value */
|
||||
/* lerr - report an error message */
|
||||
|
||||
int htoi (str)
|
||||
Char str[];
|
||||
{
|
||||
unsigned int result;
|
||||
|
||||
(void) sscanf ((char *) str, "%x", &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* lerrif - report an error message formatted with one integer argument */
|
||||
|
||||
void lerrif (msg, arg)
|
||||
const char *msg;
|
||||
int arg;
|
||||
void lerr (const char *msg, ...)
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
va_list args;
|
||||
|
||||
snprintf (errmsg, sizeof(errmsg), msg, arg);
|
||||
va_start(args, msg);
|
||||
vsnprintf (errmsg, sizeof(errmsg), msg, args);
|
||||
va_end(args);
|
||||
flexerror (errmsg);
|
||||
}
|
||||
|
||||
|
||||
/* lerrsf - report an error message formatted with one string argument */
|
||||
/* lerr_fatal - as lerr, but call flexfatal */
|
||||
|
||||
void lerrsf (msg, arg)
|
||||
const char *msg, arg[];
|
||||
void lerr_fatal (const char *msg, ...)
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
||||
snprintf (errmsg, sizeof(errmsg)-1, msg, arg);
|
||||
errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */
|
||||
flexerror (errmsg);
|
||||
}
|
||||
|
||||
|
||||
/* lerrsf_fatal - as lerrsf, but call flexfatal */
|
||||
|
||||
void lerrsf_fatal (msg, arg)
|
||||
const char *msg, arg[];
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
snprintf (errmsg, sizeof(errmsg)-1, msg, arg);
|
||||
errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */
|
||||
vsnprintf (errmsg, sizeof(errmsg), msg, args);
|
||||
va_end(args);
|
||||
flexfatal (errmsg);
|
||||
}
|
||||
|
||||
|
||||
/* line_directive_out - spit out a "#line" statement */
|
||||
|
||||
void line_directive_out (output_file, do_infile)
|
||||
FILE *output_file;
|
||||
int do_infile;
|
||||
void line_directive_out (FILE *output_file, int do_infile)
|
||||
{
|
||||
char directive[MAXLINE], filename[MAXLINE];
|
||||
char *s1, *s2, *s3;
|
||||
static const char *line_fmt = "#line %d \"%s\"\n";
|
||||
static const char line_fmt[] = "#line %d \"%s\"\n";
|
||||
|
||||
if (!gen_line_dirs)
|
||||
return;
|
||||
@ -444,8 +354,8 @@ void line_directive_out (output_file, do_infile)
|
||||
s3 = &filename[sizeof (filename) - 2];
|
||||
|
||||
while (s2 < s3 && *s1) {
|
||||
if (*s1 == '\\')
|
||||
/* Escape the '\' */
|
||||
if (*s1 == '\\' || *s1 == '"')
|
||||
/* Escape the '\' or '"' */
|
||||
*s2++ = '\\';
|
||||
|
||||
*s2++ = *s1++;
|
||||
@ -474,7 +384,7 @@ void line_directive_out (output_file, do_infile)
|
||||
* representing where the user's section 1 definitions end
|
||||
* and the prolog begins
|
||||
*/
|
||||
void mark_defs1 ()
|
||||
void mark_defs1 (void)
|
||||
{
|
||||
defs1_offset = 0;
|
||||
action_array[action_index++] = '\0';
|
||||
@ -486,7 +396,7 @@ void mark_defs1 ()
|
||||
/* mark_prolog - mark the current position in the action array as
|
||||
* representing the end of the action prolog
|
||||
*/
|
||||
void mark_prolog ()
|
||||
void mark_prolog (void)
|
||||
{
|
||||
action_array[action_index++] = '\0';
|
||||
action_offset = action_index;
|
||||
@ -498,8 +408,7 @@ void mark_prolog ()
|
||||
*
|
||||
* Generates a data statement initializing the current 2-D array to "value".
|
||||
*/
|
||||
void mk2data (value)
|
||||
int value;
|
||||
void mk2data (int value)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (!gentables)
|
||||
@ -528,8 +437,7 @@ void mk2data (value)
|
||||
* Generates a data statement initializing the current array element to
|
||||
* "value".
|
||||
*/
|
||||
void mkdata (value)
|
||||
int value;
|
||||
void mkdata (int value)
|
||||
{
|
||||
/* short circuit any output */
|
||||
if (!gentables)
|
||||
@ -554,8 +462,7 @@ void mkdata (value)
|
||||
|
||||
/* myctoi - return the integer represented by a string of digits */
|
||||
|
||||
int myctoi (array)
|
||||
const char *array;
|
||||
int myctoi (const char *array)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
@ -567,10 +474,9 @@ int myctoi (array)
|
||||
|
||||
/* myesc - return character corresponding to escape sequence */
|
||||
|
||||
Char myesc (array)
|
||||
Char array[];
|
||||
unsigned char myesc (unsigned char array[])
|
||||
{
|
||||
Char c, esc_char;
|
||||
unsigned char c, esc_char;
|
||||
|
||||
switch (array[1]) {
|
||||
case 'b':
|
||||
@ -583,19 +489,10 @@ Char myesc (array)
|
||||
return '\r';
|
||||
case 't':
|
||||
return '\t';
|
||||
|
||||
#if defined (__STDC__)
|
||||
case 'a':
|
||||
return '\a';
|
||||
case 'v':
|
||||
return '\v';
|
||||
#else
|
||||
case 'a':
|
||||
return '\007';
|
||||
case 'v':
|
||||
return '\013';
|
||||
#endif
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
@ -607,18 +504,15 @@ Char myesc (array)
|
||||
{ /* \<octal> */
|
||||
int sptr = 1;
|
||||
|
||||
while (isascii (array[sptr]) &&
|
||||
isdigit (array[sptr]))
|
||||
/* Don't increment inside loop control
|
||||
* because if isdigit() is a macro it might
|
||||
* expand into multiple increments ...
|
||||
*/
|
||||
while (sptr <= 3 &&
|
||||
array[sptr] >= '0' && array[sptr] <= '7') {
|
||||
++sptr;
|
||||
}
|
||||
|
||||
c = array[sptr];
|
||||
array[sptr] = '\0';
|
||||
|
||||
esc_char = otoi (array + 1);
|
||||
esc_char = (unsigned char) strtoul (array + 1, NULL, 8);
|
||||
|
||||
array[sptr] = c;
|
||||
|
||||
@ -629,18 +523,18 @@ Char myesc (array)
|
||||
{ /* \x<hex> */
|
||||
int sptr = 2;
|
||||
|
||||
while (isascii (array[sptr]) &&
|
||||
isxdigit (array[sptr]))
|
||||
while (sptr <= 3 && isxdigit (array[sptr])) {
|
||||
/* Don't increment inside loop control
|
||||
* because if isdigit() is a macro it might
|
||||
* because if isxdigit() is a macro it might
|
||||
* expand into multiple increments ...
|
||||
*/
|
||||
++sptr;
|
||||
}
|
||||
|
||||
c = array[sptr];
|
||||
array[sptr] = '\0';
|
||||
|
||||
esc_char = htoi (array + 2);
|
||||
esc_char = (unsigned char) strtoul (array + 2, NULL, 16);
|
||||
|
||||
array[sptr] = c;
|
||||
|
||||
@ -653,76 +547,51 @@ Char myesc (array)
|
||||
}
|
||||
|
||||
|
||||
/* otoi - convert an octal digit string to an integer value */
|
||||
|
||||
int otoi (str)
|
||||
Char str[];
|
||||
{
|
||||
unsigned int result;
|
||||
|
||||
(void) sscanf ((char *) str, "%o", &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* out - various flavors of outputing a (possibly formatted) string for the
|
||||
* generated scanner, keeping track of the line count.
|
||||
*/
|
||||
|
||||
void out (str)
|
||||
const char *str;
|
||||
void out (const char *str)
|
||||
{
|
||||
fputs (str, stdout);
|
||||
}
|
||||
|
||||
void out_dec (fmt, n)
|
||||
const char *fmt;
|
||||
int n;
|
||||
void out_dec (const char *fmt, int n)
|
||||
{
|
||||
fprintf (stdout, fmt, n);
|
||||
}
|
||||
|
||||
void out_dec2 (fmt, n1, n2)
|
||||
const char *fmt;
|
||||
int n1, n2;
|
||||
void out_dec2 (const char *fmt, int n1, int n2)
|
||||
{
|
||||
fprintf (stdout, fmt, n1, n2);
|
||||
}
|
||||
|
||||
void out_hex (fmt, x)
|
||||
const char *fmt;
|
||||
unsigned int x;
|
||||
void out_hex (const char *fmt, unsigned int x)
|
||||
{
|
||||
fprintf (stdout, fmt, x);
|
||||
}
|
||||
|
||||
void out_str (fmt, str)
|
||||
const char *fmt, str[];
|
||||
void out_str (const char *fmt, const char str[])
|
||||
{
|
||||
fprintf (stdout,fmt, str);
|
||||
}
|
||||
|
||||
void out_str3 (fmt, s1, s2, s3)
|
||||
const char *fmt, s1[], s2[], s3[];
|
||||
void out_str3 (const char *fmt, const char s1[], const char s2[], const char s3[])
|
||||
{
|
||||
fprintf (stdout,fmt, s1, s2, s3);
|
||||
}
|
||||
|
||||
void out_str_dec (fmt, str, n)
|
||||
const char *fmt, str[];
|
||||
int n;
|
||||
void out_str_dec (const char *fmt, const char str[], int n)
|
||||
{
|
||||
fprintf (stdout,fmt, str, n);
|
||||
}
|
||||
|
||||
void outc (c)
|
||||
int c;
|
||||
void outc (int c)
|
||||
{
|
||||
fputc (c, stdout);
|
||||
}
|
||||
|
||||
void outn (str)
|
||||
const char *str;
|
||||
void outn (const char *str)
|
||||
{
|
||||
fputs (str,stdout);
|
||||
fputc('\n',stdout);
|
||||
@ -731,7 +600,6 @@ void outn (str)
|
||||
/** Print "m4_define( [[def]], [[val]])m4_dnl\n".
|
||||
* @param def The m4 symbol to define.
|
||||
* @param val The definition; may be NULL.
|
||||
* @return buf
|
||||
*/
|
||||
void out_m4_define (const char* def, const char* val)
|
||||
{
|
||||
@ -745,10 +613,9 @@ void out_m4_define (const char* def, const char* val)
|
||||
* The returned string is in static storage.
|
||||
*/
|
||||
|
||||
char *readable_form (c)
|
||||
register int c;
|
||||
char *readable_form (int c)
|
||||
{
|
||||
static char rform[10];
|
||||
static char rform[20];
|
||||
|
||||
if ((c >= 0 && c < 32) || c >= 127) {
|
||||
switch (c) {
|
||||
@ -762,16 +629,15 @@ char *readable_form (c)
|
||||
return "\\r";
|
||||
case '\t':
|
||||
return "\\t";
|
||||
|
||||
#if defined (__STDC__)
|
||||
case '\a':
|
||||
return "\\a";
|
||||
case '\v':
|
||||
return "\\v";
|
||||
#endif
|
||||
|
||||
default:
|
||||
snprintf (rform, sizeof(rform), "\\%.3o", (unsigned int) c);
|
||||
if(trace_hex)
|
||||
snprintf (rform, sizeof(rform), "\\x%.2x", (unsigned int) c);
|
||||
else
|
||||
snprintf (rform, sizeof(rform), "\\%.3o", (unsigned int) c);
|
||||
return rform;
|
||||
}
|
||||
}
|
||||
@ -780,7 +646,7 @@ char *readable_form (c)
|
||||
return "' '";
|
||||
|
||||
else {
|
||||
rform[0] = c;
|
||||
rform[0] = (char) c;
|
||||
rform[1] = '\0';
|
||||
|
||||
return rform;
|
||||
@ -790,15 +656,17 @@ char *readable_form (c)
|
||||
|
||||
/* reallocate_array - increase the size of a dynamic array */
|
||||
|
||||
void *reallocate_array (array, size, element_size)
|
||||
void *array;
|
||||
int size;
|
||||
size_t element_size;
|
||||
void *reallocate_array (void *array, int size, size_t element_size)
|
||||
{
|
||||
register void *new_array;
|
||||
size_t num_bytes = element_size * size;
|
||||
|
||||
new_array = flex_realloc (array, num_bytes);
|
||||
void *new_array;
|
||||
#if HAVE_REALLOCARRAY
|
||||
/* reallocarray has built-in overflow detection */
|
||||
new_array = reallocarray(array, (size_t) size, element_size);
|
||||
#else
|
||||
size_t num_bytes = (size_t) size * element_size;
|
||||
new_array = (size && SIZE_MAX / (size_t) size < element_size) ? NULL :
|
||||
realloc(array, num_bytes);
|
||||
#endif
|
||||
if (!new_array)
|
||||
flexfatal (_("attempt to increase array size failed"));
|
||||
|
||||
@ -812,7 +680,7 @@ void *reallocate_array (array, size, element_size)
|
||||
* Copies skelfile or skel array to stdout until a line beginning with
|
||||
* "%%" or EOF is found.
|
||||
*/
|
||||
void skelout ()
|
||||
void skelout (void)
|
||||
{
|
||||
char buf_storage[MAXLINE];
|
||||
char *buf = buf_storage;
|
||||
@ -923,9 +791,6 @@ void skelout ()
|
||||
/* %e end linkage-only code. */
|
||||
OUT_END_CODE ();
|
||||
}
|
||||
else if (buf[1] == '#') {
|
||||
/* %# a comment in the skel. ignore. */
|
||||
}
|
||||
else {
|
||||
flexfatal (_("bad line in skeleton file"));
|
||||
}
|
||||
@ -943,8 +808,7 @@ void skelout ()
|
||||
* element_n. Formats the output with spaces and carriage returns.
|
||||
*/
|
||||
|
||||
void transition_struct_out (element_v, element_n)
|
||||
int element_v, element_n;
|
||||
void transition_struct_out (int element_v, int element_n)
|
||||
{
|
||||
|
||||
/* short circuit any output */
|
||||
@ -968,12 +832,14 @@ void transition_struct_out (element_v, element_n)
|
||||
|
||||
/* The following is only needed when building flex's parser using certain
|
||||
* broken versions of bison.
|
||||
*
|
||||
* XXX: this is should go soon
|
||||
*/
|
||||
void *yy_flex_xmalloc (size)
|
||||
int size;
|
||||
void *yy_flex_xmalloc (int size)
|
||||
{
|
||||
void *result = flex_alloc ((size_t) size);
|
||||
void *result;
|
||||
|
||||
result = malloc((size_t) size);
|
||||
if (!result)
|
||||
flexfatal (_
|
||||
("memory allocation failed in yy_flex_xmalloc()"));
|
||||
@ -982,29 +848,10 @@ void *yy_flex_xmalloc (size)
|
||||
}
|
||||
|
||||
|
||||
/* zero_out - set a region of memory to 0
|
||||
*
|
||||
* Sets region_ptr[0] through region_ptr[size_in_bytes - 1] to zero.
|
||||
*/
|
||||
|
||||
void zero_out (region_ptr, size_in_bytes)
|
||||
char *region_ptr;
|
||||
size_t size_in_bytes;
|
||||
{
|
||||
register char *rp, *rp_end;
|
||||
|
||||
rp = region_ptr;
|
||||
rp_end = region_ptr + size_in_bytes;
|
||||
|
||||
while (rp < rp_end)
|
||||
*rp++ = 0;
|
||||
}
|
||||
|
||||
/* Remove all '\n' and '\r' characters, if any, from the end of str.
|
||||
* str can be any null-terminated string, or NULL.
|
||||
* returns str. */
|
||||
char *chomp (str)
|
||||
char *str;
|
||||
char *chomp (char *str)
|
||||
{
|
||||
char *p = str;
|
||||
|
@ -21,17 +21,34 @@
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
|
||||
cat <<!
|
||||
/* File created from flex.skl via mkskel.sh */
|
||||
if test ! $# = 3; then
|
||||
echo 'Usage: mkskel.sh srcdir m4 version' >&2
|
||||
exit 1
|
||||
fi
|
||||
echo '/* File created from flex.skl via mkskel.sh */
|
||||
|
||||
#include "flexdef.h"
|
||||
|
||||
const char *skel[] = {
|
||||
!
|
||||
const char *skel[] = {'
|
||||
srcdir=$1
|
||||
m4=$2
|
||||
VERSION=$3
|
||||
case $VERSION in
|
||||
*[!0-9.]*) echo 'Invalid version number' >&2; exit 1;;
|
||||
esac
|
||||
IFS=.
|
||||
set $VERSION
|
||||
sed 's/4_/a4_/g
|
||||
s/m4preproc_/m4_/g
|
||||
' "$srcdir/flex.skl" |
|
||||
"$m4" -P -I "$srcdir" "-DFLEX_MAJOR_VERSION=$1" \
|
||||
"-DFLEX_MINOR_VERSION=$2" \
|
||||
"-DFLEX_SUBMINOR_VERSION=$3" |
|
||||
sed '/^%#/d
|
||||
s/m4_/m4preproc_/g
|
||||
s/a4_/4_/g
|
||||
s/[\\"]/\\&/g
|
||||
s/.*/ "&",/'
|
||||
|
||||
sed 's/\\/&&/g' | sed 's/"/\\"/g' | sed 's/.*/ "&",/'
|
||||
|
||||
cat <<!
|
||||
0
|
||||
};
|
||||
!
|
||||
echo ' 0
|
||||
};'
|
@ -36,8 +36,8 @@
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
int dupmachine PROTO ((int));
|
||||
void mkxtion PROTO ((int, int));
|
||||
int dupmachine(int);
|
||||
void mkxtion(int, int);
|
||||
|
||||
|
||||
/* add_accept - add an accepting state to a machine
|
||||
@ -45,8 +45,7 @@ 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 (int mach, int 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
|
||||
@ -77,8 +76,7 @@ void add_accept (mach, accepting_number)
|
||||
* num - the number of copies of singl to be present in newsng
|
||||
*/
|
||||
|
||||
int copysingl (singl, num)
|
||||
int singl, num;
|
||||
int copysingl (int singl, int num)
|
||||
{
|
||||
int copy, i;
|
||||
|
||||
@ -93,9 +91,7 @@ int copysingl (singl, num)
|
||||
|
||||
/* dumpnfa - debugging routine to write out an nfa */
|
||||
|
||||
void dumpnfa (state1)
|
||||
int state1;
|
||||
|
||||
void dumpnfa (int state1)
|
||||
{
|
||||
int sym, tsp1, tsp2, anum, ns;
|
||||
|
||||
@ -148,8 +144,7 @@ void dumpnfa (state1)
|
||||
* states accessible by the arrays firstst and lastst
|
||||
*/
|
||||
|
||||
int dupmachine (mach)
|
||||
int mach;
|
||||
int dupmachine (int mach)
|
||||
{
|
||||
int i, init, state_offset;
|
||||
int state = 0;
|
||||
@ -196,9 +191,8 @@ int dupmachine (mach)
|
||||
* context has variable length.
|
||||
*/
|
||||
|
||||
void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
|
||||
pcont_act)
|
||||
int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
|
||||
void finish_rule (int mach, int variable_trail_rule, int headcnt, int trailcnt,
|
||||
int pcont_act)
|
||||
{
|
||||
char action_text[MAXLINE];
|
||||
|
||||
@ -257,12 +251,23 @@ void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
|
||||
("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n");
|
||||
|
||||
if (headcnt > 0) {
|
||||
if (rule_has_nl[num_rules]) {
|
||||
snprintf (action_text, sizeof(action_text),
|
||||
"YY_LINENO_REWIND_TO(%s + %d);\n", scanner_bp, headcnt);
|
||||
add_action (action_text);
|
||||
}
|
||||
snprintf (action_text, sizeof(action_text), "%s = %s + %d;\n",
|
||||
scanner_cp, scanner_bp, headcnt);
|
||||
add_action (action_text);
|
||||
}
|
||||
|
||||
else {
|
||||
if (rule_has_nl[num_rules]) {
|
||||
snprintf (action_text, sizeof(action_text),
|
||||
"YY_LINENO_REWIND_TO(yy_cp - %d);\n", trailcnt);
|
||||
add_action (action_text);
|
||||
}
|
||||
|
||||
snprintf (action_text, sizeof(action_text), "%s -= %d;\n",
|
||||
scanner_cp, trailcnt);
|
||||
add_action (action_text);
|
||||
@ -281,7 +286,8 @@ void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
|
||||
if (!continued_action)
|
||||
add_action ("YY_RULE_SETUP\n");
|
||||
|
||||
line_directive_out ((FILE *) 0, 1);
|
||||
line_directive_out(NULL, 1);
|
||||
add_action("[[");
|
||||
}
|
||||
|
||||
|
||||
@ -301,8 +307,7 @@ void finish_rule (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;
|
||||
int link_machines (int first, int last)
|
||||
{
|
||||
if (first == NIL)
|
||||
return last;
|
||||
@ -328,8 +333,7 @@ int link_machines (first, last)
|
||||
* The "beginning" states are the epsilon closure of the first state
|
||||
*/
|
||||
|
||||
void mark_beginning_as_normal (mach)
|
||||
register int mach;
|
||||
void mark_beginning_as_normal (int mach)
|
||||
{
|
||||
switch (state_type[mach]) {
|
||||
case STATE_NORMAL:
|
||||
@ -370,8 +374,7 @@ void mark_beginning_as_normal (mach)
|
||||
* more mkbranch's. Compare with mkor()
|
||||
*/
|
||||
|
||||
int mkbranch (first, second)
|
||||
int first, second;
|
||||
int mkbranch (int first, int second)
|
||||
{
|
||||
int eps;
|
||||
|
||||
@ -398,8 +401,7 @@ int mkbranch (first, second)
|
||||
* new - a new state which matches the closure of "state"
|
||||
*/
|
||||
|
||||
int mkclos (state)
|
||||
int state;
|
||||
int mkclos (int state)
|
||||
{
|
||||
return mkopt (mkposcl (state));
|
||||
}
|
||||
@ -419,8 +421,7 @@ int mkclos (state)
|
||||
* 2. mach is destroyed by the call
|
||||
*/
|
||||
|
||||
int mkopt (mach)
|
||||
int mach;
|
||||
int mkopt (int mach)
|
||||
{
|
||||
int eps;
|
||||
|
||||
@ -456,8 +457,7 @@ int mkopt (mach)
|
||||
* the number of epsilon states needed
|
||||
*/
|
||||
|
||||
int mkor (first, second)
|
||||
int first, second;
|
||||
int mkor (int first, int second)
|
||||
{
|
||||
int eps, orend;
|
||||
|
||||
@ -512,8 +512,7 @@ int mkor (first, second)
|
||||
* new - a machine matching the positive closure of "state"
|
||||
*/
|
||||
|
||||
int mkposcl (state)
|
||||
int state;
|
||||
int mkposcl (int state)
|
||||
{
|
||||
int eps;
|
||||
|
||||
@ -542,8 +541,7 @@ int mkposcl (state)
|
||||
* if "ub" is INFINITE_REPEAT then "new" matches "lb" or more occurrences of "mach"
|
||||
*/
|
||||
|
||||
int mkrep (mach, lb, ub)
|
||||
int mach, lb, ub;
|
||||
int mkrep (int mach, int lb, int ub)
|
||||
{
|
||||
int base_mach, tail, copy, i;
|
||||
|
||||
@ -589,12 +587,11 @@ int mkrep (mach, lb, ub)
|
||||
* that it admittedly is)
|
||||
*/
|
||||
|
||||
int mkstate (sym)
|
||||
int sym;
|
||||
int mkstate (int sym)
|
||||
{
|
||||
if (++lastnfa >= current_mns) {
|
||||
if ((current_mns += MNS_INCREMENT) >= maximum_mns)
|
||||
lerrif (_
|
||||
lerr(_
|
||||
("input rules are too complicated (>= %d NFA states)"),
|
||||
current_mns);
|
||||
|
||||
@ -666,8 +663,7 @@ current_mns);
|
||||
* stateto - the state to which the transition is to be made
|
||||
*/
|
||||
|
||||
void mkxtion (statefrom, stateto)
|
||||
int statefrom, stateto;
|
||||
void mkxtion (int statefrom, int stateto)
|
||||
{
|
||||
if (trans1[statefrom] == NO_TRANSITION)
|
||||
trans1[statefrom] = stateto;
|
||||
@ -684,7 +680,7 @@ void mkxtion (statefrom, stateto)
|
||||
|
||||
/* new_rule - initialize for a new rule */
|
||||
|
||||
void new_rule ()
|
||||
void new_rule (void)
|
||||
{
|
||||
if (++num_rules >= current_max_rules) {
|
||||
++num_reallocs;
|
||||
@ -700,7 +696,7 @@ void new_rule ()
|
||||
}
|
||||
|
||||
if (num_rules > MAX_RULE)
|
||||
lerrif (_("too many rules (> %d)!"), MAX_RULE);
|
||||
lerr (_("too many rules (> %d)!"), MAX_RULE);
|
||||
|
||||
rule_linenum[num_rules] = linenum;
|
||||
rule_useful[num_rules] = false;
|
@ -117,6 +117,8 @@ optspec_t flexopts[] = {
|
||||
,
|
||||
{"--help", OPT_HELP, 0}
|
||||
, /* Produce this help message. */
|
||||
{"--hex", OPT_HEX, 0}
|
||||
, /* Use hexadecimals in debug/trace outputs */
|
||||
{"-I", OPT_INTERACTIVE, 0}
|
||||
,
|
||||
{"--interactive", OPT_INTERACTIVE, 0}
|
||||
@ -211,10 +213,6 @@ optspec_t flexopts[] = {
|
||||
,
|
||||
{"--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}
|
||||
@ -273,7 +271,8 @@ optspec_t flexopts[] = {
|
||||
,
|
||||
{"--noyyset_lloc", OPT_NO_YYSET_LLOC, 0}
|
||||
,
|
||||
|
||||
{"--unsafe-no-m4-sect3-escape", OPT_NO_SECT3_ESCAPE, 0}
|
||||
,
|
||||
{0, 0, 0} /* required final NULL entry. */
|
||||
};
|
||||
|
@ -60,6 +60,7 @@ enum flexopt_flag_t {
|
||||
OPT_FULL,
|
||||
OPT_HEADER_FILE,
|
||||
OPT_HELP,
|
||||
OPT_HEX,
|
||||
OPT_INTERACTIVE,
|
||||
OPT_LEX_COMPAT,
|
||||
OPT_POSIX_COMPAT,
|
||||
@ -67,8 +68,6 @@ enum flexopt_flag_t {
|
||||
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,
|
||||
@ -126,7 +125,8 @@ enum flexopt_flag_t {
|
||||
OPT_YYCLASS,
|
||||
OPT_YYLINENO,
|
||||
OPT_YYMORE,
|
||||
OPT_YYWRAP
|
||||
OPT_YYWRAP,
|
||||
OPT_NO_SECT3_ESCAPE,
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,19 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
@ -28,63 +26,71 @@
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef YY_YY_PARSE_H_INCLUDED
|
||||
# define YY_YY_PARSE_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int yydebug;
|
||||
#endif
|
||||
|
||||
/* Tokens. */
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
CHAR = 258,
|
||||
NUMBER = 259,
|
||||
SECTEND = 260,
|
||||
SCDECL = 261,
|
||||
XSCDECL = 262,
|
||||
NAME = 263,
|
||||
PREVCCL = 264,
|
||||
EOF_OP = 265,
|
||||
OPTION_OP = 266,
|
||||
OPT_OUTFILE = 267,
|
||||
OPT_PREFIX = 268,
|
||||
OPT_YYCLASS = 269,
|
||||
OPT_HEADER = 270,
|
||||
OPT_EXTRA_TYPE = 271,
|
||||
OPT_TABLES = 272,
|
||||
CCE_ALNUM = 273,
|
||||
CCE_ALPHA = 274,
|
||||
CCE_BLANK = 275,
|
||||
CCE_CNTRL = 276,
|
||||
CCE_DIGIT = 277,
|
||||
CCE_GRAPH = 278,
|
||||
CCE_LOWER = 279,
|
||||
CCE_PRINT = 280,
|
||||
CCE_PUNCT = 281,
|
||||
CCE_SPACE = 282,
|
||||
CCE_UPPER = 283,
|
||||
CCE_XDIGIT = 284,
|
||||
CCE_NEG_ALNUM = 285,
|
||||
CCE_NEG_ALPHA = 286,
|
||||
CCE_NEG_BLANK = 287,
|
||||
CCE_NEG_CNTRL = 288,
|
||||
CCE_NEG_DIGIT = 289,
|
||||
CCE_NEG_GRAPH = 290,
|
||||
CCE_NEG_LOWER = 291,
|
||||
CCE_NEG_PRINT = 292,
|
||||
CCE_NEG_PUNCT = 293,
|
||||
CCE_NEG_SPACE = 294,
|
||||
CCE_NEG_UPPER = 295,
|
||||
CCE_NEG_XDIGIT = 296,
|
||||
CCL_OP_UNION = 297,
|
||||
CCL_OP_DIFF = 298,
|
||||
BEGIN_REPEAT_POSIX = 299,
|
||||
END_REPEAT_POSIX = 300,
|
||||
BEGIN_REPEAT_FLEX = 301,
|
||||
END_REPEAT_FLEX = 302
|
||||
};
|
||||
enum yytokentype
|
||||
{
|
||||
CHAR = 258,
|
||||
NUMBER = 259,
|
||||
SECTEND = 260,
|
||||
SCDECL = 261,
|
||||
XSCDECL = 262,
|
||||
NAME = 263,
|
||||
PREVCCL = 264,
|
||||
EOF_OP = 265,
|
||||
TOK_OPTION = 266,
|
||||
TOK_OUTFILE = 267,
|
||||
TOK_PREFIX = 268,
|
||||
TOK_YYCLASS = 269,
|
||||
TOK_HEADER_FILE = 270,
|
||||
TOK_EXTRA_TYPE = 271,
|
||||
TOK_TABLES_FILE = 272,
|
||||
CCE_ALNUM = 273,
|
||||
CCE_ALPHA = 274,
|
||||
CCE_BLANK = 275,
|
||||
CCE_CNTRL = 276,
|
||||
CCE_DIGIT = 277,
|
||||
CCE_GRAPH = 278,
|
||||
CCE_LOWER = 279,
|
||||
CCE_PRINT = 280,
|
||||
CCE_PUNCT = 281,
|
||||
CCE_SPACE = 282,
|
||||
CCE_UPPER = 283,
|
||||
CCE_XDIGIT = 284,
|
||||
CCE_NEG_ALNUM = 285,
|
||||
CCE_NEG_ALPHA = 286,
|
||||
CCE_NEG_BLANK = 287,
|
||||
CCE_NEG_CNTRL = 288,
|
||||
CCE_NEG_DIGIT = 289,
|
||||
CCE_NEG_GRAPH = 290,
|
||||
CCE_NEG_LOWER = 291,
|
||||
CCE_NEG_PRINT = 292,
|
||||
CCE_NEG_PUNCT = 293,
|
||||
CCE_NEG_SPACE = 294,
|
||||
CCE_NEG_UPPER = 295,
|
||||
CCE_NEG_XDIGIT = 296,
|
||||
CCL_OP_DIFF = 297,
|
||||
CCL_OP_UNION = 298,
|
||||
BEGIN_REPEAT_POSIX = 299,
|
||||
END_REPEAT_POSIX = 300,
|
||||
BEGIN_REPEAT_FLEX = 301,
|
||||
END_REPEAT_FLEX = 302
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define CHAR 258
|
||||
@ -95,13 +101,13 @@
|
||||
#define NAME 263
|
||||
#define PREVCCL 264
|
||||
#define EOF_OP 265
|
||||
#define OPTION_OP 266
|
||||
#define OPT_OUTFILE 267
|
||||
#define OPT_PREFIX 268
|
||||
#define OPT_YYCLASS 269
|
||||
#define OPT_HEADER 270
|
||||
#define OPT_EXTRA_TYPE 271
|
||||
#define OPT_TABLES 272
|
||||
#define TOK_OPTION 266
|
||||
#define TOK_OUTFILE 267
|
||||
#define TOK_PREFIX 268
|
||||
#define TOK_YYCLASS 269
|
||||
#define TOK_HEADER_FILE 270
|
||||
#define TOK_EXTRA_TYPE 271
|
||||
#define TOK_TABLES_FILE 272
|
||||
#define CCE_ALNUM 273
|
||||
#define CCE_ALPHA 274
|
||||
#define CCE_BLANK 275
|
||||
@ -126,23 +132,23 @@
|
||||
#define CCE_NEG_SPACE 294
|
||||
#define CCE_NEG_UPPER 295
|
||||
#define CCE_NEG_XDIGIT 296
|
||||
#define CCL_OP_UNION 297
|
||||
#define CCL_OP_DIFF 298
|
||||
#define CCL_OP_DIFF 297
|
||||
#define CCL_OP_UNION 298
|
||||
#define BEGIN_REPEAT_POSIX 299
|
||||
#define END_REPEAT_POSIX 300
|
||||
#define BEGIN_REPEAT_FLEX 301
|
||||
#define END_REPEAT_FLEX 302
|
||||
|
||||
|
||||
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef int YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
#endif /* !YY_YY_PARSE_H_INCLUDED */
|
@ -1,8 +1,8 @@
|
||||
/* 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 OPT_HEADER OPT_EXTRA_TYPE
|
||||
%token OPT_TABLES
|
||||
%token TOK_OPTION TOK_OUTFILE TOK_PREFIX TOK_YYCLASS TOK_HEADER_FILE TOK_EXTRA_TYPE
|
||||
%token TOK_TABLES_FILE
|
||||
|
||||
%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
|
||||
@ -80,7 +80,7 @@ int previous_continued_action; /* whether the previous rule's action was '|' */
|
||||
do{ \
|
||||
char fw3_msg[MAXLINE];\
|
||||
snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\
|
||||
warn( fw3_msg );\
|
||||
lwarn( fw3_msg );\
|
||||
}while(0)
|
||||
|
||||
/* Expand a POSIX character class expression. */
|
||||
@ -140,7 +140,7 @@ goal : initlex sect1 sect1end sect2 initforrule
|
||||
else
|
||||
add_action( "ECHO" );
|
||||
|
||||
add_action( ";\n\tYY_BREAK\n" );
|
||||
add_action( ";\n\tYY_BREAK]]\n" );
|
||||
}
|
||||
;
|
||||
|
||||
@ -184,28 +184,30 @@ namelist1 : namelist1 NAME
|
||||
{ synerr( _("bad start condition list") ); }
|
||||
;
|
||||
|
||||
options : OPTION_OP optionlist
|
||||
options : TOK_OPTION optionlist
|
||||
;
|
||||
|
||||
optionlist : optionlist option
|
||||
|
|
||||
;
|
||||
|
||||
option : OPT_OUTFILE '=' NAME
|
||||
option : TOK_OUTFILE '=' NAME
|
||||
{
|
||||
outfilename = copy_string( nmstr );
|
||||
outfilename = xstrdup(nmstr);
|
||||
did_outfilename = 1;
|
||||
}
|
||||
| OPT_EXTRA_TYPE '=' NAME
|
||||
{ extra_type = copy_string( nmstr ); }
|
||||
| OPT_PREFIX '=' 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 ); }
|
||||
| TOK_EXTRA_TYPE '=' NAME
|
||||
{ extra_type = xstrdup(nmstr); }
|
||||
| TOK_PREFIX '=' NAME
|
||||
{ prefix = xstrdup(nmstr);
|
||||
if (strchr(prefix, '[') || strchr(prefix, ']'))
|
||||
flexerror(_("Prefix must not contain [ or ]")); }
|
||||
| TOK_YYCLASS '=' NAME
|
||||
{ yyclass = xstrdup(nmstr); }
|
||||
| TOK_HEADER_FILE '=' NAME
|
||||
{ headerfilename = xstrdup(nmstr); }
|
||||
| TOK_TABLES_FILE '=' NAME
|
||||
{ tablesext = true; tablesfilename = xstrdup(nmstr); }
|
||||
;
|
||||
|
||||
sect2 : sect2 scon initforrule flexrule '\n'
|
||||
@ -303,7 +305,7 @@ flexrule : '^' rule
|
||||
scon_stk[++scon_stk_ptr] = i;
|
||||
|
||||
if ( scon_stk_ptr == 0 )
|
||||
warn(
|
||||
lwarn(
|
||||
"all start conditions already have <<EOF>> rules" );
|
||||
|
||||
else
|
||||
@ -398,7 +400,7 @@ rule : re2 re
|
||||
* erroneously.
|
||||
*/
|
||||
if ( ! varlength || headcnt != 0 )
|
||||
warn(
|
||||
lwarn(
|
||||
"trailing context made variable due to preceding '|' action" );
|
||||
|
||||
/* Mark as variable. */
|
||||
@ -453,7 +455,7 @@ rule : re2 re
|
||||
/* See the comment in the rule for "re2 re"
|
||||
* above.
|
||||
*/
|
||||
warn(
|
||||
lwarn(
|
||||
"trailing context made variable due to preceding '|' action" );
|
||||
|
||||
varlength = true;
|
||||
@ -725,7 +727,7 @@ singleton : singleton '*'
|
||||
{
|
||||
/* Sort characters for fast searching.
|
||||
*/
|
||||
qsort( ccltbl + cclmap[$1], ccllen[$1], sizeof (*ccltbl), cclcmp );
|
||||
qsort( ccltbl + cclmap[$1], (size_t) ccllen[$1], sizeof (*ccltbl), cclcmp );
|
||||
|
||||
if ( useecs )
|
||||
mkeccl( ccltbl + cclmap[$1], ccllen[$1],
|
||||
@ -913,13 +915,13 @@ ccl_expr:
|
||||
| CCE_NEG_XDIGIT { CCL_NEG_EXPR(isxdigit); }
|
||||
| CCE_NEG_LOWER {
|
||||
if ( sf_case_ins() )
|
||||
warn(_("[:^lower:] is ambiguous in case insensitive scanner"));
|
||||
lwarn(_("[:^lower:] is ambiguous in case insensitive scanner"));
|
||||
else
|
||||
CCL_NEG_EXPR(islower);
|
||||
}
|
||||
| CCE_NEG_UPPER {
|
||||
if ( sf_case_ins() )
|
||||
warn(_("[:^upper:] ambiguous in case insensitive scanner"));
|
||||
lwarn(_("[:^upper:] ambiguous in case insensitive scanner"));
|
||||
else
|
||||
CCL_NEG_EXPR(isupper);
|
||||
}
|
||||
@ -951,9 +953,9 @@ string : string CHAR
|
||||
* conditions
|
||||
*/
|
||||
|
||||
void build_eof_action()
|
||||
void build_eof_action(void)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
char action_text[MAXLINE];
|
||||
|
||||
for ( i = 1; i <= scon_stk_ptr; ++i )
|
||||
@ -976,7 +978,8 @@ void build_eof_action()
|
||||
}
|
||||
}
|
||||
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
line_directive_out(NULL, 1);
|
||||
add_action("[[");
|
||||
|
||||
/* This isn't a normal rule after all - don't count it as
|
||||
* such, so we don't have any holes in the rule numbering
|
||||
@ -990,8 +993,7 @@ void build_eof_action()
|
||||
|
||||
/* format_synerr - write out formatted syntax error */
|
||||
|
||||
void format_synerr( msg, arg )
|
||||
const char *msg, arg[];
|
||||
void format_synerr( const char *msg, const char arg[] )
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
@ -1002,8 +1004,7 @@ const char *msg, arg[];
|
||||
|
||||
/* synerr - report a syntax error */
|
||||
|
||||
void synerr( str )
|
||||
const char *str;
|
||||
void synerr( const char *str )
|
||||
{
|
||||
syntaxerror = true;
|
||||
pinpoint_message( str );
|
||||
@ -1012,20 +1013,18 @@ const char *str;
|
||||
|
||||
/* format_warn - write out formatted warning */
|
||||
|
||||
void format_warn( msg, arg )
|
||||
const char *msg, arg[];
|
||||
void format_warn( const char *msg, const char arg[] )
|
||||
{
|
||||
char warn_msg[MAXLINE];
|
||||
|
||||
snprintf( warn_msg, sizeof(warn_msg), msg, arg );
|
||||
warn( warn_msg );
|
||||
lwarn( warn_msg );
|
||||
}
|
||||
|
||||
|
||||
/* warn - report a warning, unless -w was given */
|
||||
/* lwarn - report a warning, unless -w was given */
|
||||
|
||||
void warn( str )
|
||||
const char *str;
|
||||
void lwarn( const char *str )
|
||||
{
|
||||
line_warning( str, linenum );
|
||||
}
|
||||
@ -1034,8 +1033,7 @@ const char *str;
|
||||
* pinpointing its location
|
||||
*/
|
||||
|
||||
void format_pinpoint_message( msg, arg )
|
||||
const char *msg, arg[];
|
||||
void format_pinpoint_message( const char *msg, const char arg[] )
|
||||
{
|
||||
char errmsg[MAXLINE];
|
||||
|
||||
@ -1046,8 +1044,7 @@ const char *msg, arg[];
|
||||
|
||||
/* pinpoint_message - write out a message, pinpointing its location */
|
||||
|
||||
void pinpoint_message( str )
|
||||
const char *str;
|
||||
void pinpoint_message( const char *str )
|
||||
{
|
||||
line_pinpoint( str, linenum );
|
||||
}
|
||||
@ -1055,9 +1052,7 @@ const char *str;
|
||||
|
||||
/* line_warning - report a warning at a given line, unless -w was given */
|
||||
|
||||
void line_warning( str, line )
|
||||
const char *str;
|
||||
int line;
|
||||
void line_warning( const char *str, int line )
|
||||
{
|
||||
char warning[MAXLINE];
|
||||
|
||||
@ -1071,9 +1066,7 @@ int line;
|
||||
|
||||
/* line_pinpoint - write out a message, pinpointing it at the given line */
|
||||
|
||||
void line_pinpoint( str, line )
|
||||
const char *str;
|
||||
int line;
|
||||
void line_pinpoint( const char *str, int line )
|
||||
{
|
||||
fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
|
||||
}
|
||||
@ -1083,7 +1076,7 @@ int line;
|
||||
* currently, messages are ignore
|
||||
*/
|
||||
|
||||
void yyerror( msg )
|
||||
const char *msg;
|
||||
void yyerror( const char *msg )
|
||||
{
|
||||
(void)msg;
|
||||
}
|
@ -54,21 +54,17 @@ void flex_regcomp(regex_t *preg, const char *regex, int cflags)
|
||||
memset (preg, 0, sizeof (regex_t));
|
||||
|
||||
if ((err = regcomp (preg, regex, cflags)) != 0) {
|
||||
const int errbuf_sz = 200;
|
||||
char *errbuf, *rxerr;
|
||||
const size_t errbuf_sz = 200;
|
||||
char *errbuf;
|
||||
int n;
|
||||
|
||||
errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
|
||||
errbuf = malloc(errbuf_sz * sizeof(char));
|
||||
if (!errbuf)
|
||||
flexfatal(_("Unable to allocate buffer to report regcomp"));
|
||||
rxerr = (char*)flex_alloc(errbuf_sz *sizeof(char));
|
||||
if (!rxerr)
|
||||
flexfatal(_("Unable to allocate buffer for regerror"));
|
||||
regerror (err, preg, rxerr, errbuf_sz);
|
||||
snprintf (errbuf, errbuf_sz, "regcomp for \"%s\" failed: %s", regex, rxerr);
|
||||
n = snprintf(errbuf, errbuf_sz, "regcomp for \"%s\" failed: ", regex);
|
||||
regerror(err, preg, errbuf+n, errbuf_sz-(size_t)n);
|
||||
|
||||
flexfatal (errbuf);
|
||||
free(errbuf);
|
||||
free(rxerr);
|
||||
flexfatal (errbuf); /* never returns - no need to free(errbuf) */
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,12 +76,12 @@ void flex_regcomp(regex_t *preg, const char *regex, int cflags)
|
||||
char *regmatch_dup (regmatch_t * m, const char *src)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (m == NULL || m->rm_so < 0)
|
||||
if (m == NULL || m->rm_so < 0 || m->rm_eo < m->rm_so)
|
||||
return NULL;
|
||||
len = m->rm_eo - m->rm_so;
|
||||
str = (char *) flex_alloc ((len + 1) * sizeof (char));
|
||||
len = (size_t) (m->rm_eo - m->rm_so);
|
||||
str = malloc((len + 1) * sizeof(char));
|
||||
if (!str)
|
||||
flexfatal(_("Unable to allocate a copy of the match"));
|
||||
strncpy (str, src + m->rm_so, len);
|
||||
@ -107,13 +103,12 @@ char *regmatch_cpy (regmatch_t * m, char *dest, const char *src)
|
||||
return dest;
|
||||
}
|
||||
|
||||
snprintf (dest, regmatch_len(m), "%s", src + m->rm_so);
|
||||
snprintf (dest, (size_t) 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)
|
||||
@ -151,7 +146,7 @@ int regmatch_strtol (regmatch_t * m, const char *src, char **endptr,
|
||||
else
|
||||
s = regmatch_dup (m, src);
|
||||
|
||||
n = strtol (s, endptr, base);
|
||||
n = (int) strtol (s, endptr, base);
|
||||
|
||||
if (s != buf)
|
||||
free (s);
|
5235
src/scan.c
Normal file
5235
src/scan.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -38,6 +38,12 @@ extern bool tablesverify, tablesext;
|
||||
extern int trlcontxt; /* Set in parse.y for each rule. */
|
||||
extern const char *escaped_qstart, *escaped_qend;
|
||||
|
||||
#define M4QSTART "[""["
|
||||
#define M4QEND "]""]"
|
||||
|
||||
#define ESCAPED_QSTART "[" M4QEND M4QSTART "[" M4QEND M4QSTART
|
||||
#define ESCAPED_QEND M4QEND "]" M4QSTART M4QEND "]" M4QSTART
|
||||
|
||||
#define ACTION_ECHO add_action( yytext )
|
||||
#define ACTION_IFDEF(def, should_define) \
|
||||
{ \
|
||||
@ -45,8 +51,8 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
action_define( def, 1 ); \
|
||||
}
|
||||
|
||||
#define ACTION_ECHO_QSTART add_action (escaped_qstart)
|
||||
#define ACTION_ECHO_QEND add_action (escaped_qend)
|
||||
#define ACTION_ECHO_QSTART add_action (ESCAPED_QSTART)
|
||||
#define ACTION_ECHO_QEND add_action (ESCAPED_QEND)
|
||||
|
||||
#define ACTION_M4_IFDEF(def, should_define) \
|
||||
do{ \
|
||||
@ -59,7 +65,7 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
#define MARK_END_OF_PROLOG mark_prolog();
|
||||
|
||||
#define YY_DECL \
|
||||
int flexscan()
|
||||
int flexscan(void)
|
||||
|
||||
#define RETURNCHAR \
|
||||
yylval = (unsigned char) yytext[0]; \
|
||||
@ -68,18 +74,20 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
#define RETURNNAME \
|
||||
if(yyleng < MAXLINE) \
|
||||
{ \
|
||||
strcpy( nmstr, yytext ); \
|
||||
strncpy( nmstr, yytext, sizeof(nmstr) ); \
|
||||
return NAME; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
do { \
|
||||
synerr(_("Input line too long\n")); \
|
||||
FLEX_EXIT(EXIT_FAILURE); \
|
||||
} \
|
||||
return NAME;
|
||||
} while (0)
|
||||
|
||||
#define PUT_BACK_STRING(str, start) \
|
||||
for ( i = strlen( str ) - 1; i >= start; --i ) \
|
||||
unput((str)[i])
|
||||
{ size_t i = strlen( str ); \
|
||||
while ( i > start ) \
|
||||
unput((str)[--i]); \
|
||||
}
|
||||
|
||||
#define CHECK_REJECT(str) \
|
||||
if ( all_upper( str ) ) \
|
||||
@ -93,9 +101,26 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
if ( getenv("POSIXLY_CORRECT") ) \
|
||||
posix_compat = true;
|
||||
|
||||
#define START_CODEBLOCK(x) do { \
|
||||
/* Emit the needed line directive... */\
|
||||
if (indented_code == false) { \
|
||||
linenum++; \
|
||||
line_directive_out(NULL, 1); \
|
||||
} \
|
||||
add_action(M4QSTART); \
|
||||
yy_push_state(CODEBLOCK); \
|
||||
if ((indented_code = x)) ACTION_ECHO; \
|
||||
} while(0)
|
||||
|
||||
#define END_CODEBLOCK do { \
|
||||
yy_pop_state();\
|
||||
add_action(M4QEND); \
|
||||
if (!indented_code) line_directive_out(NULL, 0);\
|
||||
} while (0)
|
||||
|
||||
%}
|
||||
|
||||
%option caseless nodefault stack noyy_top_state
|
||||
%option caseless nodefault noreject stack noyy_top_state
|
||||
%option nostdinit
|
||||
|
||||
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
|
||||
@ -104,7 +129,9 @@ extern const char *escaped_qstart, *escaped_qend;
|
||||
%x GROUP_WITH_PARAMS
|
||||
%x GROUP_MINUS_PARAMS
|
||||
%x EXTENDED_COMMENT
|
||||
%x COMMENT_DISCARD
|
||||
%x COMMENT_DISCARD CODE_COMMENT
|
||||
%x SECT3_NOESCAPE
|
||||
%x CHARACTER_CONSTANT
|
||||
|
||||
WS [[:blank:]]+
|
||||
OPTWS [[:blank:]]*
|
||||
@ -125,8 +152,8 @@ CCL_EXPR ("[:"^?[[:alpha:]]+":]")
|
||||
|
||||
LEXOPT [aceknopr]
|
||||
|
||||
M4QSTART "[["
|
||||
M4QEND "]]"
|
||||
M4QSTART "[""["
|
||||
M4QEND "]""]"
|
||||
|
||||
%%
|
||||
static int bracelevel, didadef, indented_code;
|
||||
@ -134,22 +161,17 @@ M4QEND "]]"
|
||||
static int option_sense;
|
||||
|
||||
int doing_codeblock = false;
|
||||
int i, brace_depth=0, brace_start_line=0;
|
||||
Char nmdef[MAXLINE];
|
||||
int brace_depth=0, brace_start_line=0;
|
||||
char nmdef[MAXLINE];
|
||||
|
||||
|
||||
<INITIAL>{
|
||||
^{WS} indented_code = true; BEGIN(CODEBLOCK);
|
||||
^"/*" ACTION_ECHO; yy_push_state( COMMENT );
|
||||
^{WS} START_CODEBLOCK(true);
|
||||
^"/*" add_action("/*[""["); yy_push_state( COMMENT );
|
||||
^#{OPTWS}line{WS} yy_push_state( LINEDIR );
|
||||
^"%s"{NAME}? return SCDECL;
|
||||
^"%x"{NAME}? return XSCDECL;
|
||||
^"%{".*{NL} {
|
||||
++linenum;
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
indented_code = false;
|
||||
BEGIN(CODEBLOCK);
|
||||
}
|
||||
^"%{".*{NL} START_CODEBLOCK(false);
|
||||
^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
|
||||
brace_start_line = linenum;
|
||||
++linenum;
|
||||
@ -166,7 +188,7 @@ M4QEND "]]"
|
||||
sectnum = 2;
|
||||
bracelevel = 0;
|
||||
mark_defs1();
|
||||
line_directive_out( (FILE *) 0, 1 );
|
||||
line_directive_out(NULL, 1);
|
||||
BEGIN(SECT2PROLOG);
|
||||
return SECTEND;
|
||||
}
|
||||
@ -174,7 +196,7 @@ M4QEND "]]"
|
||||
^"%pointer".*{NL} yytext_is_array = false; ++linenum;
|
||||
^"%array".*{NL} yytext_is_array = true; ++linenum;
|
||||
|
||||
^"%option" BEGIN(OPTION); return OPTION_OP;
|
||||
^"%option" BEGIN(OPTION); return TOK_OPTION;
|
||||
|
||||
^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
|
||||
^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
|
||||
@ -185,7 +207,7 @@ M4QEND "]]"
|
||||
^{NAME} {
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext );
|
||||
strncpy( nmstr, yytext, sizeof(nmstr) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -203,14 +225,18 @@ M4QEND "]]"
|
||||
}
|
||||
|
||||
|
||||
<COMMENT>{
|
||||
"*/" ACTION_ECHO; yy_pop_state();
|
||||
"*" ACTION_ECHO;
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
[^*\n] ACTION_ECHO;
|
||||
<COMMENT,CODE_COMMENT>{ /* */
|
||||
[^\[\]\*\n]* ACTION_ECHO;
|
||||
. ACTION_ECHO;
|
||||
|
||||
{NL} ++linenum; ACTION_ECHO;
|
||||
}
|
||||
<COMMENT>{
|
||||
"*/" add_action("*/]""]"); yy_pop_state();
|
||||
}
|
||||
<CODE_COMMENT>{
|
||||
"*/" ACTION_ECHO; yy_pop_state();
|
||||
}
|
||||
|
||||
<COMMENT_DISCARD>{
|
||||
/* This is the same as COMMENT, but is discarded rather than output. */
|
||||
@ -223,7 +249,7 @@ M4QEND "]]"
|
||||
<EXTENDED_COMMENT>{
|
||||
")" yy_pop_state();
|
||||
[^\n\)]+ ;
|
||||
{NL} ++linenum;
|
||||
{NL} ++linenum;
|
||||
}
|
||||
|
||||
<LINEDIR>{
|
||||
@ -231,25 +257,25 @@ M4QEND "]]"
|
||||
[[:digit:]]+ linenum = myctoi( yytext );
|
||||
|
||||
\"[^"\n]*\" {
|
||||
flex_free( (void *) infilename );
|
||||
infilename = copy_string( yytext + 1 );
|
||||
free(infilename);
|
||||
infilename = xstrdup(yytext + 1);
|
||||
infilename[strlen( infilename ) - 1] = '\0';
|
||||
}
|
||||
. /* ignore spurious characters */
|
||||
}
|
||||
<ACTION,CODEBLOCK,ACTION_STRING,PERCENT_BRACE_ACTION,CHARACTER_CONSTANT,COMMENT,CODE_COMMENT>{
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
}
|
||||
|
||||
<CODEBLOCK>{
|
||||
^"%}".*{NL} ++linenum; BEGIN(INITIAL);
|
||||
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
. ACTION_ECHO;
|
||||
|
||||
^"%}".*{NL} ++linenum; END_CODEBLOCK;
|
||||
[^\n%\[\]]* ACTION_ECHO;
|
||||
. ACTION_ECHO;
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if ( indented_code )
|
||||
BEGIN(INITIAL);
|
||||
if ( indented_code ) END_CODEBLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,12 +298,11 @@ M4QEND "]]"
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
{M4QSTART} buf_strnappend(&top_buf, escaped_qstart, strlen(escaped_qstart));
|
||||
{M4QEND} buf_strnappend(&top_buf, escaped_qend, strlen(escaped_qend));
|
||||
|
||||
[^{}\r\n] {
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
{M4QSTART} buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart));
|
||||
{M4QEND} buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend));
|
||||
([^{}\r\n\[\]]+)|[^{}\r\n] {
|
||||
buf_strnappend(&top_buf, yytext, yyleng);
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
linenum = brace_start_line;
|
||||
@ -293,7 +318,7 @@ M4QEND "]]"
|
||||
{NOT_WS}[^\r\n]* {
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( (char *) nmdef, yytext );
|
||||
strncpy( nmdef, yytext, sizeof(nmdef) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -301,12 +326,12 @@ M4QEND "]]"
|
||||
FLEX_EXIT(EXIT_FAILURE);
|
||||
}
|
||||
/* Skip trailing whitespace. */
|
||||
for ( i = strlen( (char *) nmdef ) - 1;
|
||||
i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t');
|
||||
--i )
|
||||
;
|
||||
|
||||
nmdef[i + 1] = '\0';
|
||||
{
|
||||
size_t i = strlen( nmdef );
|
||||
while (i > 0 && (nmdef[i-1] == ' ' || nmdef[i-1] == '\t'))
|
||||
--i;
|
||||
nmdef[i] = '\0';
|
||||
}
|
||||
|
||||
ndinstal( nmstr, nmdef );
|
||||
didadef = true;
|
||||
@ -338,8 +363,6 @@ M4QEND "]]"
|
||||
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;
|
||||
@ -364,6 +387,7 @@ M4QEND "]]"
|
||||
interactive interactive = option_sense;
|
||||
lex-compat lex_compat = option_sense;
|
||||
posix-compat posix_compat = option_sense;
|
||||
line gen_line_dirs = option_sense;
|
||||
main {
|
||||
ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
|
||||
/* Override yywrap */
|
||||
@ -420,12 +444,12 @@ M4QEND "]]"
|
||||
yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense);
|
||||
yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense);
|
||||
|
||||
extra-type return OPT_EXTRA_TYPE;
|
||||
outfile return OPT_OUTFILE;
|
||||
prefix return OPT_PREFIX;
|
||||
yyclass return OPT_YYCLASS;
|
||||
header(-file)? return OPT_HEADER;
|
||||
tables-file return OPT_TABLES;
|
||||
extra-type return TOK_EXTRA_TYPE;
|
||||
outfile return TOK_OUTFILE;
|
||||
prefix return TOK_PREFIX;
|
||||
yyclass return TOK_YYCLASS;
|
||||
header(-file)? return TOK_HEADER_FILE;
|
||||
tables-file return TOK_TABLES_FILE;
|
||||
tables-verify {
|
||||
tablesverify = option_sense;
|
||||
if(!tablesext && option_sense)
|
||||
@ -436,7 +460,7 @@ M4QEND "]]"
|
||||
\"[^"\n]*\" {
|
||||
if(yyleng-1 < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext + 1 );
|
||||
strncpy( nmstr, yytext + 1, sizeof(nmstr) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -461,19 +485,20 @@ M4QEND "]]"
|
||||
^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
|
||||
^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
|
||||
|
||||
^{WS}.* ACTION_ECHO; /* indented code in prolog */
|
||||
^{WS} START_CODEBLOCK(true); /* indented code in prolog */
|
||||
|
||||
^{NOT_WS}.* { /* non-indented code */
|
||||
if ( bracelevel <= 0 )
|
||||
{ /* not in %{ ... %} */
|
||||
yyless( 0 ); /* put it all back */
|
||||
yy_set_bol( 1 );
|
||||
mark_prolog();
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
else
|
||||
ACTION_ECHO;
|
||||
}
|
||||
^{NOT_WS}.* {
|
||||
/* non-indented code */
|
||||
if ( bracelevel <= 0 ) {
|
||||
/* not in %{ ... %} */
|
||||
yyless( 0 ); /* put it all back */
|
||||
yy_set_bol( 1 );
|
||||
mark_prolog();
|
||||
BEGIN(SECT2);
|
||||
} else {
|
||||
START_CODEBLOCK(true);
|
||||
}
|
||||
}
|
||||
|
||||
. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO;
|
||||
@ -527,11 +552,11 @@ M4QEND "]]"
|
||||
if (sf_skip_ws()){
|
||||
/* We're in the middle of a (?x: ) pattern. */
|
||||
/* Push back everything starting at the "|" */
|
||||
size_t amt;
|
||||
amt = strchr (yytext, '|') - yytext;
|
||||
int amt = (int) (strchr (yytext, '|') - yytext);
|
||||
yyless(amt);
|
||||
}
|
||||
else {
|
||||
add_action("]""]");
|
||||
continued_action = true;
|
||||
++linenum;
|
||||
return '\n';
|
||||
@ -601,9 +626,10 @@ M4QEND "]]"
|
||||
|
||||
^"%%".* {
|
||||
sectnum = 3;
|
||||
BEGIN(SECT3);
|
||||
BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3);
|
||||
outn("/* Begin user sect3 */");
|
||||
yyterminate(); /* to stop the parser */
|
||||
|
||||
}
|
||||
|
||||
"["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
|
||||
@ -611,7 +637,7 @@ M4QEND "]]"
|
||||
|
||||
if(yyleng < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext );
|
||||
strncpy( nmstr, yytext, sizeof(nmstr) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -627,7 +653,7 @@ M4QEND "]]"
|
||||
* The reason it was disabled is so yacc/bison can parse
|
||||
* ccl operations, such as ccl difference and union.
|
||||
*/
|
||||
&& (cclval = ccllookup( (Char *) nmstr )) != 0 )
|
||||
&& (cclval = ccllookup( nmstr )) != 0 )
|
||||
{
|
||||
if ( input() != ']' )
|
||||
synerr( _( "bad character class" ) );
|
||||
@ -641,7 +667,7 @@ M4QEND "]]"
|
||||
/* We fudge a bit. We know that this ccl will
|
||||
* soon be numbered as lastccl + 1 by cclinit.
|
||||
*/
|
||||
cclinstal( (Char *) nmstr, lastccl + 1 );
|
||||
cclinstal( nmstr, lastccl + 1 );
|
||||
|
||||
/* Push back everything but the leading bracket
|
||||
* so the ccl can be rescanned.
|
||||
@ -661,7 +687,7 @@ M4QEND "]]"
|
||||
* context.
|
||||
*/
|
||||
"{"{NAME}"}"[[:space:]]? {
|
||||
register Char *nmdefptr;
|
||||
char *nmdefptr;
|
||||
int end_is_ws, end_ch;
|
||||
|
||||
end_ch = yytext[yyleng-1];
|
||||
@ -669,7 +695,7 @@ M4QEND "]]"
|
||||
|
||||
if(yyleng-1 < MAXLINE)
|
||||
{
|
||||
strcpy( nmstr, yytext + 1 );
|
||||
strncpy( nmstr, yytext + 1, sizeof(nmstr) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -685,7 +711,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
|
||||
else
|
||||
{ /* push back name surrounded by ()'s */
|
||||
int len = strlen( (char *) nmdefptr );
|
||||
size_t len = strlen( nmdefptr );
|
||||
if (end_is_ws)
|
||||
unput(end_ch);
|
||||
|
||||
@ -693,7 +719,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
(len > 0 && nmdefptr[len - 1] == '$')
|
||||
|| (end_is_ws && trlcontxt && !sf_skip_ws()))
|
||||
{ /* don't use ()'s after all */
|
||||
PUT_BACK_STRING((char *) nmdefptr, 0);
|
||||
PUT_BACK_STRING(nmdefptr, 0);
|
||||
|
||||
if ( nmdefptr[0] == '^' )
|
||||
BEGIN(CARETISBOL);
|
||||
@ -702,7 +728,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
else
|
||||
{
|
||||
unput(')');
|
||||
PUT_BACK_STRING((char *) nmdefptr, 0);
|
||||
PUT_BACK_STRING(nmdefptr, 0);
|
||||
unput('(');
|
||||
}
|
||||
}
|
||||
@ -738,7 +764,13 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
return '(';
|
||||
}
|
||||
"(" sf_push(); return '(';
|
||||
")" sf_pop(); return ')';
|
||||
")" {
|
||||
if (_sf_top_ix > 0) {
|
||||
sf_pop();
|
||||
return ')';
|
||||
} else
|
||||
synerr(_("unbalanced parenthesis"));
|
||||
}
|
||||
|
||||
[/|*+?.(){}] return (unsigned char) yytext[0];
|
||||
. RETURNCHAR;
|
||||
@ -870,35 +902,31 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
<PERCENT_BRACE_ACTION>{
|
||||
{OPTWS}"%}".* bracelevel = 0;
|
||||
|
||||
<ACTION>"/*" ACTION_ECHO; yy_push_state( COMMENT );
|
||||
<ACTION>"/*" ACTION_ECHO; yy_push_state( CODE_COMMENT );
|
||||
|
||||
<CODEBLOCK,ACTION>{
|
||||
"reject" {
|
||||
ACTION_ECHO;
|
||||
CHECK_REJECT(yytext);
|
||||
}
|
||||
"yymore" {
|
||||
ACTION_ECHO;
|
||||
CHECK_YYMORE(yytext);
|
||||
}
|
||||
"reject" {
|
||||
ACTION_ECHO;
|
||||
CHECK_REJECT(yytext);
|
||||
}
|
||||
"yymore" {
|
||||
ACTION_ECHO;
|
||||
CHECK_YYMORE(yytext);
|
||||
}
|
||||
}
|
||||
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
. ACTION_ECHO;
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if ( bracelevel == 0 ||
|
||||
(doing_codeblock && indented_code) )
|
||||
{
|
||||
if ( doing_rule_action )
|
||||
add_action( "\tYY_BREAK\n" );
|
||||
. ACTION_ECHO;
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if (bracelevel <= 0 || (doing_codeblock && indented_code)) {
|
||||
if ( doing_rule_action )
|
||||
add_action( "\tYY_BREAK]""]\n" );
|
||||
|
||||
doing_rule_action = doing_codeblock = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
doing_rule_action = doing_codeblock = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -906,37 +934,41 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
<ACTION>{
|
||||
"{" ACTION_ECHO; ++bracelevel;
|
||||
"}" ACTION_ECHO; --bracelevel;
|
||||
{M4QSTART} ACTION_ECHO_QSTART;
|
||||
{M4QEND} ACTION_ECHO_QEND;
|
||||
[^[:alpha:]_{}"'/\n\[\]]+ ACTION_ECHO;
|
||||
[\[\]] ACTION_ECHO;
|
||||
{NAME} ACTION_ECHO;
|
||||
"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */
|
||||
[^[:alpha:]_{}\"'/\n\[\]]+ ACTION_ECHO;
|
||||
{NAME} ACTION_ECHO;
|
||||
"'"([^\'\\\n]|\\.)"'" ACTION_ECHO; /* character constant */
|
||||
"'" ACTION_ECHO; BEGIN(CHARACTER_CONSTANT);
|
||||
\" ACTION_ECHO; BEGIN(ACTION_STRING);
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if ( bracelevel == 0 )
|
||||
{
|
||||
if ( doing_rule_action )
|
||||
add_action( "\tYY_BREAK\n" );
|
||||
{NL} {
|
||||
++linenum;
|
||||
ACTION_ECHO;
|
||||
if (bracelevel <= 0) {
|
||||
if ( doing_rule_action )
|
||||
add_action( "\tYY_BREAK]""]\n" );
|
||||
|
||||
doing_rule_action = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
. ACTION_ECHO;
|
||||
doing_rule_action = false;
|
||||
BEGIN(SECT2);
|
||||
}
|
||||
}
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
|
||||
<ACTION_STRING>{
|
||||
[^"\\\n]+ ACTION_ECHO;
|
||||
\\. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO; BEGIN(ACTION);
|
||||
[^\[\]\"\\\n]+ ACTION_ECHO;
|
||||
\" ACTION_ECHO; BEGIN(ACTION);
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
<CHARACTER_CONSTANT>{
|
||||
[^\[\]\'\\\n]+ ACTION_ECHO;
|
||||
\' ACTION_ECHO; BEGIN(ACTION);
|
||||
}
|
||||
<ACTION_STRING,CHARACTER_CONSTANT>{
|
||||
(\\\n)* ACTION_ECHO;
|
||||
\\(\\\n)*. ACTION_ECHO;
|
||||
{NL} ++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); } else { BEGIN(ACTION); }
|
||||
. ACTION_ECHO;
|
||||
}
|
||||
|
||||
<COMMENT,COMMENT_DISCARD,ACTION,ACTION_STRING><<EOF>> {
|
||||
<COMMENT,CODE_COMMENT,COMMENT_DISCARD,ACTION,ACTION_STRING,CHARACTER_CONSTANT><<EOF>> {
|
||||
synerr( _( "EOF encountered inside an action" ) );
|
||||
yyterminate();
|
||||
}
|
||||
@ -947,7 +979,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
}
|
||||
|
||||
<SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
|
||||
yylval = myesc( (Char *) yytext );
|
||||
yylval = myesc( (unsigned char *) yytext );
|
||||
|
||||
if ( YY_START == FIRSTCCL )
|
||||
BEGIN(CCL);
|
||||
@ -955,21 +987,32 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
|
||||
return CHAR;
|
||||
}
|
||||
|
||||
|
||||
<SECT3>{
|
||||
{M4QSTART} fwrite (escaped_qstart, 1, strlen(escaped_qstart), yyout);
|
||||
{M4QEND} fwrite (escaped_qend, 1, strlen(escaped_qend), yyout);
|
||||
[^\[\]\n]*(\n?) ECHO;
|
||||
(.|\n) ECHO;
|
||||
<<EOF>> sectnum = 0; yyterminate();
|
||||
{M4QSTART} fputs(escaped_qstart, yyout);
|
||||
{M4QEND} fputs(escaped_qend, yyout);
|
||||
[^\[\]]* ECHO;
|
||||
[][] ECHO;
|
||||
<<EOF>> {
|
||||
sectnum = 0;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
<SECT3_NOESCAPE>{
|
||||
{M4QSTART} fprintf(yyout, "[""[%s]""]", escaped_qstart);
|
||||
{M4QEND} fprintf(yyout, "[""[%s]""]", escaped_qend);
|
||||
[^][]* ECHO;
|
||||
[][] ECHO;
|
||||
<<EOF>> {
|
||||
sectnum = 0;
|
||||
yyterminate();
|
||||
}
|
||||
}
|
||||
|
||||
<*>.|\n format_synerr( _( "bad character: %s" ), yytext );
|
||||
|
||||
%%
|
||||
|
||||
|
||||
int yywrap()
|
||||
int yywrap(void)
|
||||
{
|
||||
if ( --num_input_files > 0 )
|
||||
{
|
||||
@ -984,46 +1027,22 @@ int yywrap()
|
||||
|
||||
/* set_input_file - open the given file (if NULL, stdin) for scanning */
|
||||
|
||||
void set_input_file( file )
|
||||
char *file;
|
||||
void set_input_file( char *file )
|
||||
{
|
||||
if ( file && strcmp( file, "-" ) )
|
||||
{
|
||||
infilename = copy_string( file );
|
||||
infilename = xstrdup(file);
|
||||
yyin = fopen( infilename, "r" );
|
||||
|
||||
if ( yyin == NULL )
|
||||
lerrsf( _( "can't open %s" ), file );
|
||||
lerr( _( "can't open %s" ), file );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
yyin = stdin;
|
||||
infilename = copy_string( "<stdin>" );
|
||||
infilename = xstrdup("<stdin>");
|
||||
}
|
||||
|
||||
linenum = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Wrapper routines for accessing the scanner's malloc routines. */
|
||||
|
||||
void *flex_alloc( size )
|
||||
size_t size;
|
||||
{
|
||||
return (void *) malloc( size );
|
||||
}
|
||||
|
||||
void *flex_realloc( ptr, size )
|
||||
void *ptr;
|
||||
size_t size;
|
||||
{
|
||||
return (void *) realloc( ptr, size );
|
||||
}
|
||||
|
||||
void flex_free( ptr )
|
||||
void *ptr;
|
||||
{
|
||||
if ( ptr )
|
||||
free( ptr );
|
||||
}
|
@ -39,8 +39,10 @@ size_t _sf_top_ix=0, _sf_max=0;
|
||||
void
|
||||
sf_push (void)
|
||||
{
|
||||
if (_sf_top_ix + 1 >= _sf_max)
|
||||
_sf_stk = (scanflags_t*) flex_realloc ( (void*) _sf_stk, sizeof(scanflags_t) * (_sf_max += 32));
|
||||
if (_sf_top_ix + 1 >= _sf_max) {
|
||||
_sf_max += 32;
|
||||
_sf_stk = realloc(_sf_stk, sizeof(scanflags_t) * _sf_max);
|
||||
}
|
||||
|
||||
// copy the top element
|
||||
_sf_stk[_sf_top_ix + 1] = _sf_stk[_sf_top_ix];
|
||||
@ -59,10 +61,10 @@ void
|
||||
sf_init (void)
|
||||
{
|
||||
assert(_sf_stk == NULL);
|
||||
_sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32));
|
||||
_sf_max = 32;
|
||||
_sf_stk = malloc(sizeof(scanflags_t) * _sf_max);
|
||||
if (!_sf_stk)
|
||||
lerrsf_fatal(_("Unable to allocate %ld of stack"),
|
||||
(long)sizeof(scanflags_t));
|
||||
lerr_fatal(_("Unable to allocate %zu of stack"), sizeof(scanflags_t));
|
||||
_sf_stk[_sf_top_ix] = 0;
|
||||
}
|
||||
|
@ -37,20 +37,6 @@
|
||||
|
||||
/* 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
|
||||
@ -77,56 +63,45 @@ struct _scanopt_t {
|
||||
};
|
||||
|
||||
/* 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(struct _scanopt_t *, int);
|
||||
static int PRINTLEN(struct _scanopt_t *, int);
|
||||
static int RVAL(struct _scanopt_t *, int);
|
||||
static int FLAGS(struct _scanopt_t *, int);
|
||||
static const char *DESC(struct _scanopt_t *, int);
|
||||
static int scanopt_err(struct _scanopt_t *, int, int);
|
||||
static int matchlongopt(char *, char **, int *, char **, int *);
|
||||
static int find_opt(struct _scanopt_t *, int, char *, int, int *, int *opt_offset);
|
||||
|
||||
static const char *NAME (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static const char *NAME (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;
|
||||
static int PRINTLEN (struct _scanopt_t *s, int i)
|
||||
{
|
||||
return s->aux[i].printlen;
|
||||
}
|
||||
|
||||
static int RVAL (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static int RVAL (struct _scanopt_t *s, int i)
|
||||
{
|
||||
return s->options[i].r_val;
|
||||
}
|
||||
|
||||
static int FLAGS (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static int FLAGS (struct _scanopt_t *s, int i)
|
||||
{
|
||||
return s->aux[i].flags;
|
||||
}
|
||||
|
||||
static const char *DESC (s, i)
|
||||
struct _scanopt_t *s;
|
||||
int i;
|
||||
static const char *DESC (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 (void);
|
||||
|
||||
static int get_cols ()
|
||||
static int get_cols (void)
|
||||
{
|
||||
char *env;
|
||||
int cols = 80; /* default */
|
||||
@ -159,15 +134,11 @@ static int get_cols ()
|
||||
(s)->subscript= 0; \
|
||||
}while(0)
|
||||
|
||||
scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
const optspec_t *options;
|
||||
int argc;
|
||||
char **argv;
|
||||
int flags;
|
||||
scanopt_t *scanopt_init (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 = malloc(sizeof (struct _scanopt_t));
|
||||
|
||||
s->options = options;
|
||||
s->optc = 0;
|
||||
@ -186,10 +157,10 @@ scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
s->optc++;
|
||||
|
||||
/* Build auxiliary data */
|
||||
s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux));
|
||||
s->aux = malloc((size_t) s->optc * sizeof (struct _aux));
|
||||
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
const Char *p, *pname;
|
||||
const unsigned char *p, *pname;
|
||||
const struct optspec_t *opt;
|
||||
struct _aux *aux;
|
||||
|
||||
@ -200,36 +171,36 @@ scanopt_t *scanopt_init (options, argc, argv, flags)
|
||||
|
||||
if (opt->opt_fmt[0] == '-' && opt->opt_fmt[1] == '-') {
|
||||
aux->flags |= IS_LONG;
|
||||
pname = (const Char *)(opt->opt_fmt + 2);
|
||||
pname = (const unsigned char *)(opt->opt_fmt + 2);
|
||||
s->has_long = 1;
|
||||
}
|
||||
else {
|
||||
pname = (const Char *)(opt->opt_fmt + 1);
|
||||
pname = (const unsigned char *)(opt->opt_fmt + 1);
|
||||
s->has_short = 1;
|
||||
}
|
||||
aux->printlen = strlen (opt->opt_fmt);
|
||||
aux->printlen = (int) strlen (opt->opt_fmt);
|
||||
|
||||
aux->namelen = 0;
|
||||
for (p = pname + 1; *p; p++) {
|
||||
/* detect required arg */
|
||||
if (*p == '=' || isspace (*p)
|
||||
if (*p == '=' || isspace ((unsigned char)*p)
|
||||
|| !(aux->flags & IS_LONG)) {
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
aux->namelen = (int) (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->namelen = (int) (p - pname);
|
||||
aux->flags &= ~(ARG_REQ | ARG_NONE);
|
||||
aux->flags |= ARG_OPT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (aux->namelen == 0)
|
||||
aux->namelen = p - pname;
|
||||
aux->namelen = (int) (p - pname);
|
||||
}
|
||||
return (scanopt_t *) s;
|
||||
}
|
||||
@ -255,10 +226,7 @@ typedef struct usg_elem usg_elem;
|
||||
[indent][option, alias1, alias2...][indent][description line1
|
||||
description line2...]
|
||||
*/
|
||||
int scanopt_usage (scanner, fp, usage)
|
||||
scanopt_t *scanner;
|
||||
FILE *fp;
|
||||
const char *usage;
|
||||
int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage)
|
||||
{
|
||||
struct _scanopt_t *s;
|
||||
int i, columns, indent = 2;
|
||||
@ -293,7 +261,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
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));
|
||||
store = malloc((size_t) s->optc * sizeof (usg_elem));
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
|
||||
/* grab the next preallocate node. */
|
||||
@ -319,7 +287,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
}
|
||||
if (!ptr_if_no_alias
|
||||
&&
|
||||
STRCASECMP (NAME (s, (*ue_curr)->idx),
|
||||
strcasecmp (NAME (s, (*ue_curr)->idx),
|
||||
NAME (s, ue->idx)) > 0) {
|
||||
ptr_if_no_alias = ue_curr;
|
||||
}
|
||||
@ -391,7 +359,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
maxlen[0] = len;
|
||||
|
||||
/* It's much easier to calculate length for description column! */
|
||||
len = strlen (DESC (s, ue->idx));
|
||||
len = (int) strlen (DESC (s, ue->idx));
|
||||
if (len > maxlen[1])
|
||||
maxlen[1] = len;
|
||||
}
|
||||
@ -481,7 +449,7 @@ int scanopt_usage (scanner, fp, usage)
|
||||
|
||||
while (*p && n < maxlen[1]
|
||||
&& *p != '\n') {
|
||||
if (isspace ((Char)(*p))
|
||||
if (isspace ((unsigned char)(*p))
|
||||
|| *p == '-') lastws =
|
||||
p;
|
||||
n++;
|
||||
@ -529,18 +497,10 @@ int scanopt_usage (scanner, fp, usage)
|
||||
#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;
|
||||
static int scanopt_err (struct _scanopt_t *s, 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) {
|
||||
|
||||
@ -592,16 +552,11 @@ static int scanopt_err (s, opt_offset, is_short, err)
|
||||
* optname will point to str + 2
|
||||
*
|
||||
*/
|
||||
static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
char *str;
|
||||
char **optname;
|
||||
int *optlen;
|
||||
char **arg;
|
||||
int *arglen;
|
||||
static int matchlongopt (char *str, char **optname, int *optlen, char **arg, int *arglen)
|
||||
{
|
||||
char *p;
|
||||
|
||||
*optname = *arg = (char *) 0;
|
||||
*optname = *arg = NULL;
|
||||
*optlen = *arglen = 0;
|
||||
|
||||
/* Match regex /--./ */
|
||||
@ -610,13 +565,13 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
return 0;
|
||||
|
||||
p += 2;
|
||||
*optname = (char *) p;
|
||||
*optname = p;
|
||||
|
||||
/* find the end of optname */
|
||||
while (*p && *p != '=')
|
||||
++p;
|
||||
|
||||
*optlen = p - *optname;
|
||||
*optlen = (int) (p - *optname);
|
||||
|
||||
if (!*p)
|
||||
/* an option with no '=...' part. */
|
||||
@ -628,7 +583,7 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
*arg = p;
|
||||
while (*p)
|
||||
++p;
|
||||
*arglen = p - *arg;
|
||||
*arglen = (int) (p - *arg);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -639,13 +594,8 @@ static int matchlongopt (str, optname, optlen, arg, arglen)
|
||||
* 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;
|
||||
static int find_opt (struct _scanopt_t *s, int lookup_long, char *optstart, int
|
||||
len, int *err_code, int *opt_offset)
|
||||
{
|
||||
int nmatch = 0, lastr_val = 0, i;
|
||||
|
||||
@ -656,17 +606,15 @@ static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < s->optc; i++) {
|
||||
char *optname;
|
||||
const char *optname;
|
||||
|
||||
optname =
|
||||
(char *) (s->options[i].opt_fmt +
|
||||
(lookup_long ? 2 : 1));
|
||||
optname = 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) {
|
||||
if (strncmp (optname, optstart, (size_t) len) == 0) {
|
||||
nmatch++;
|
||||
*opt_offset = i;
|
||||
|
||||
@ -704,10 +652,7 @@ static int find_opt (s, lookup_long, optstart, len, err_code, opt_offset)
|
||||
}
|
||||
|
||||
|
||||
int scanopt (svoid, arg, optindex)
|
||||
scanopt_t *svoid;
|
||||
char **arg;
|
||||
int *optindex;
|
||||
int scanopt (scanopt_t *svoid, char **arg, int *optindex)
|
||||
{
|
||||
char *optname = NULL, *optarg = NULL, *pstart;
|
||||
int namelen = 0, arglen = 0;
|
||||
@ -749,7 +694,7 @@ int scanopt (svoid, arg, optindex)
|
||||
if (!find_opt
|
||||
(s, 1, optname, namelen, &errcode,
|
||||
&opt_offset)) {
|
||||
scanopt_err (s, opt_offset, 0, errcode);
|
||||
scanopt_err (s, 0, errcode);
|
||||
return errcode;
|
||||
}
|
||||
/* We handle this below. */
|
||||
@ -784,7 +729,7 @@ int scanopt (svoid, arg, optindex)
|
||||
|
||||
if (!find_opt
|
||||
(s, 0, pstart, namelen, &errcode, &opt_offset)) {
|
||||
return scanopt_err (s, opt_offset, 1, errcode);
|
||||
return scanopt_err (s, 1, errcode);
|
||||
}
|
||||
|
||||
optarg = pstart + 1;
|
||||
@ -793,7 +738,7 @@ int scanopt (svoid, arg, optindex)
|
||||
arglen = 0;
|
||||
}
|
||||
else
|
||||
arglen = strlen (optarg);
|
||||
arglen = (int) strlen (optarg);
|
||||
}
|
||||
|
||||
/* At this point, we have a long or short option matched at opt_offset into
|
||||
@ -812,8 +757,7 @@ int scanopt (svoid, arg, optindex)
|
||||
/* case: no args allowed */
|
||||
if (auxp->flags & ARG_NONE) {
|
||||
if (optarg && !is_short) {
|
||||
scanopt_err (s, opt_offset, is_short, errcode =
|
||||
SCANOPT_ERR_ARG_NOT_ALLOWED);
|
||||
scanopt_err (s, is_short, errcode = SCANOPT_ERR_ARG_NOT_ALLOWED);
|
||||
INC_INDEX (s, 1);
|
||||
return errcode;
|
||||
}
|
||||
@ -827,8 +771,7 @@ int scanopt (svoid, arg, optindex)
|
||||
/* case: required */
|
||||
if (auxp->flags & ARG_REQ) {
|
||||
if (!optarg && !has_next)
|
||||
return scanopt_err (s, opt_offset, is_short,
|
||||
SCANOPT_ERR_ARG_NOT_FOUND);
|
||||
return scanopt_err (s, is_short, SCANOPT_ERR_ARG_NOT_FOUND);
|
||||
|
||||
if (!optarg) {
|
||||
/* Let the next argv element become the argument. */
|
||||
@ -855,16 +798,14 @@ int scanopt (svoid, arg, optindex)
|
||||
}
|
||||
|
||||
|
||||
int scanopt_destroy (svoid)
|
||||
scanopt_t *svoid;
|
||||
int scanopt_destroy (scanopt_t *svoid)
|
||||
{
|
||||
struct _scanopt_t *s;
|
||||
|
||||
s = (struct _scanopt_t *) svoid;
|
||||
if (s) {
|
||||
if (s->aux)
|
||||
free (s->aux);
|
||||
free (s);
|
||||
if (s != NULL) {
|
||||
free(s->aux);
|
||||
free(s);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -47,9 +47,6 @@
|
||||
#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. */
|
||||
@ -85,12 +82,12 @@ extern "C" {
|
||||
* flags - Control behavior.
|
||||
* Return: A malloc'd pointer .
|
||||
*/
|
||||
scanopt_t *scanopt_init PROTO ((const optspec_t * options,
|
||||
int argc, char **argv, int flags));
|
||||
scanopt_t *scanopt_init (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));
|
||||
int scanopt_destroy (scanopt_t * scanner);
|
||||
|
||||
#ifndef NO_SCANOPT_USAGE
|
||||
/* Prints a usage message based on contents of optlist.
|
||||
@ -100,10 +97,7 @@ extern "C" {
|
||||
* 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));
|
||||
int scanopt_usage (scanopt_t * scanner, FILE * fp, const char *usage);
|
||||
#endif
|
||||
|
||||
/* Scans command-line options in argv[].
|
||||
@ -120,10 +114,7 @@ extern "C" {
|
||||
* < 0 on error (return value is an error code).
|
||||
*
|
||||
*/
|
||||
int scanopt
|
||||
PROTO (
|
||||
(scanopt_t * scanner, char **optarg,
|
||||
int *optindex));
|
||||
int scanopt (scanopt_t * scanner, char **optarg, int *optindex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
1359
skel.c → src/skel.c
1359
skel.c → src/skel.c
File diff suppressed because it is too large
Load Diff
@ -59,12 +59,10 @@ static struct hash_entry *ccltab[CCL_HASH_SIZE];
|
||||
|
||||
/* declare functions that have forward references */
|
||||
|
||||
static int addsym PROTO ((register char[], char *, int, hash_table, int));
|
||||
static struct hash_entry *findsym PROTO ((register const char *sym,
|
||||
hash_table table,
|
||||
|
||||
int table_size));
|
||||
static int hashfunct PROTO ((register const char *, int));
|
||||
static int addsym(char[], char *, int, hash_table, int);
|
||||
static struct hash_entry *findsym (const char *sym, hash_table table,
|
||||
int table_size);
|
||||
static int hashfunct(const char *, int);
|
||||
|
||||
|
||||
/* addsym - add symbol and definitions to symbol table
|
||||
@ -72,17 +70,12 @@ static int hashfunct PROTO ((register const char *, int));
|
||||
* -1 is returned if the symbol already exists, and the change not made.
|
||||
*/
|
||||
|
||||
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;
|
||||
static int addsym (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;
|
||||
int hash_val = hashfunct (sym, table_size);
|
||||
struct hash_entry *sym_entry = table[hash_val];
|
||||
struct hash_entry *new_entry;
|
||||
struct hash_entry *successor;
|
||||
|
||||
while (sym_entry) {
|
||||
if (!strcmp (sym, sym_entry->name)) { /* entry already exists */
|
||||
@ -93,8 +86,7 @@ static int addsym (sym, str_def, int_def, table, table_size)
|
||||
}
|
||||
|
||||
/* create new entry */
|
||||
new_entry = (struct hash_entry *)
|
||||
flex_alloc (sizeof (struct hash_entry));
|
||||
new_entry = malloc(sizeof(struct hash_entry));
|
||||
|
||||
if (new_entry == NULL)
|
||||
flexfatal (_("symbol table memory allocation failed"));
|
||||
@ -119,15 +111,13 @@ static int addsym (sym, str_def, int_def, table, table_size)
|
||||
|
||||
/* cclinstal - save the text of a character class */
|
||||
|
||||
void cclinstal (ccltxt, cclnum)
|
||||
Char ccltxt[];
|
||||
int cclnum;
|
||||
void cclinstal (char ccltxt[], int cclnum)
|
||||
{
|
||||
/* We don't bother checking the return status because we are not
|
||||
* called unless the symbol is new.
|
||||
*/
|
||||
|
||||
(void) addsym ((char *) copy_unsigned_string (ccltxt),
|
||||
(void) addsym (xstrdup(ccltxt),
|
||||
(char *) 0, cclnum, ccltab, CCL_HASH_SIZE);
|
||||
}
|
||||
|
||||
@ -137,25 +127,20 @@ void cclinstal (ccltxt, cclnum)
|
||||
* Returns 0 if there's no CCL associated with the text.
|
||||
*/
|
||||
|
||||
int ccllookup (ccltxt)
|
||||
Char ccltxt[];
|
||||
int ccllookup (char ccltxt[])
|
||||
{
|
||||
return findsym ((char *) ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
|
||||
return findsym (ccltxt, ccltab, CCL_HASH_SIZE)->int_val;
|
||||
}
|
||||
|
||||
|
||||
/* findsym - find symbol in symbol table */
|
||||
|
||||
static struct hash_entry *findsym (sym, table, table_size)
|
||||
register const char *sym;
|
||||
hash_table table;
|
||||
int table_size;
|
||||
static struct hash_entry *findsym (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,
|
||||
NULL, NULL, NULL, NULL, 0,
|
||||
};
|
||||
register struct hash_entry *sym_entry =
|
||||
struct hash_entry *sym_entry =
|
||||
|
||||
table[hashfunct (sym, table_size)];
|
||||
|
||||
@ -170,12 +155,10 @@ static struct hash_entry *findsym (sym, table, table_size)
|
||||
|
||||
/* hashfunct - compute the hash value for "str" and hash size "hash_size" */
|
||||
|
||||
static int hashfunct (str, hash_size)
|
||||
register const char *str;
|
||||
int hash_size;
|
||||
static int hashfunct (const char *str, int hash_size)
|
||||
{
|
||||
register int hashval;
|
||||
register int locstr;
|
||||
int hashval;
|
||||
int locstr;
|
||||
|
||||
hashval = 0;
|
||||
locstr = 0;
|
||||
@ -191,13 +174,11 @@ static int hashfunct (str, hash_size)
|
||||
|
||||
/* ndinstal - install a name definition */
|
||||
|
||||
void ndinstal (name, definition)
|
||||
const char *name;
|
||||
Char definition[];
|
||||
void ndinstal (const char *name, char definition[])
|
||||
{
|
||||
|
||||
if (addsym (copy_string (name),
|
||||
(char *) copy_unsigned_string (definition), 0,
|
||||
if (addsym (xstrdup(name),
|
||||
xstrdup(definition), 0,
|
||||
ndtbl, NAME_TABLE_HASH_SIZE))
|
||||
synerr (_("name defined twice"));
|
||||
}
|
||||
@ -208,16 +189,15 @@ void ndinstal (name, definition)
|
||||
* Returns a nil pointer if the name definition does not exist.
|
||||
*/
|
||||
|
||||
Char *ndlookup (nd)
|
||||
const char *nd;
|
||||
char *ndlookup (const char *nd)
|
||||
{
|
||||
return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
|
||||
return findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val;
|
||||
}
|
||||
|
||||
|
||||
/* scextend - increase the maximum number of start conditions */
|
||||
|
||||
void scextend ()
|
||||
void scextend (void)
|
||||
{
|
||||
current_max_scs += MAX_SCS_INCREMENT;
|
||||
|
||||
@ -237,17 +217,15 @@ void scextend ()
|
||||
* The start condition is "exclusive" if xcluflg is true.
|
||||
*/
|
||||
|
||||
void scinstal (str, xcluflg)
|
||||
const char *str;
|
||||
int xcluflg;
|
||||
void scinstal (const char *str, int xcluflg)
|
||||
{
|
||||
|
||||
if (++lastsc >= current_max_scs)
|
||||
scextend ();
|
||||
|
||||
scname[lastsc] = copy_string (str);
|
||||
scname[lastsc] = xstrdup(str);
|
||||
|
||||
if (addsym (scname[lastsc], (char *) 0, lastsc,
|
||||
if (addsym(scname[lastsc], NULL, lastsc,
|
||||
sctbl, START_COND_HASH_SIZE))
|
||||
format_pinpoint_message (_
|
||||
("start condition %s declared twice"),
|
||||
@ -265,8 +243,7 @@ str);
|
||||
* Returns 0 if no such start condition.
|
||||
*/
|
||||
|
||||
int sclookup (str)
|
||||
const char *str;
|
||||
int sclookup (const char *str)
|
||||
{
|
||||
return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val;
|
||||
}
|
@ -55,7 +55,7 @@
|
||||
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);
|
||||
int yytbl_writen (struct yytbl_writer *wr, void *v, int len);
|
||||
static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i);
|
||||
/* XXX Not used
|
||||
static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
|
||||
@ -65,7 +65,7 @@ static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i,
|
||||
|
||||
/** Initialize the table writer.
|
||||
* @param wr an uninitialized writer
|
||||
* @param the output file
|
||||
* @param out the output file
|
||||
* @return 0 on success
|
||||
*/
|
||||
int yytbl_writer_init (struct yytbl_writer *wr, FILE * out)
|
||||
@ -86,17 +86,17 @@ int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
|
||||
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 = (flex_uint32_t) (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);
|
||||
th->th_version = xstrdup(version_str);
|
||||
th->th_name = xstrdup(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Allocate and initialize a table data structure.
|
||||
* @param tbl a pointer to an uninitialized table
|
||||
* @param td a pointer to an uninitialized table
|
||||
* @param id the table identifier
|
||||
* @return 0 on success
|
||||
*/
|
||||
@ -115,8 +115,7 @@ int yytbl_data_init (struct yytbl_data *td, enum yytbl_id id)
|
||||
*/
|
||||
int yytbl_data_destroy (struct yytbl_data *td)
|
||||
{
|
||||
if (td->td_data)
|
||||
free (td->td_data);
|
||||
free(td->td_data);
|
||||
td->td_data = 0;
|
||||
free (td);
|
||||
return 0;
|
||||
@ -137,7 +136,7 @@ static int yytbl_write_pad64 (struct yytbl_writer *wr)
|
||||
}
|
||||
|
||||
/** write the header.
|
||||
* @param out the output stream
|
||||
* @param wr the output stream
|
||||
* @param th table header to be written
|
||||
* @return -1 on error, or bytes written on success.
|
||||
*/
|
||||
@ -159,12 +158,12 @@ int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th)
|
||||
flex_die (_("th_ssize|th_flags write failed"));
|
||||
bwritten += 6;
|
||||
|
||||
sz = strlen (th->th_version) + 1;
|
||||
sz = (int) 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;
|
||||
sz = (int) strlen (th->th_name) + 1;
|
||||
if ((rv = yytbl_writen (wr, th->th_name, sz)) != sz)
|
||||
flex_die (_("th_name writen failed"));
|
||||
bwritten += rv;
|
||||
@ -183,7 +182,7 @@ int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th)
|
||||
|
||||
|
||||
/** Write this table.
|
||||
* @param out the file writer
|
||||
* @param wr the file writer
|
||||
* @param td table data to be written
|
||||
* @return -1 on error, or bytes written on success.
|
||||
*/
|
||||
@ -214,13 +213,13 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *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));
|
||||
rv = yytbl_write8 (wr, (flex_uint8_t) yytbl_data_geti (td, i));
|
||||
break;
|
||||
case sizeof (flex_int16_t):
|
||||
rv = yytbl_write16 (wr, yytbl_data_geti (td, i));
|
||||
rv = yytbl_write16 (wr, (flex_uint16_t) yytbl_data_geti (td, i));
|
||||
break;
|
||||
case sizeof (flex_int32_t):
|
||||
rv = yytbl_write32 (wr, yytbl_data_geti (td, i));
|
||||
rv = yytbl_write32 (wr, (flex_uint32_t) yytbl_data_geti (td, i));
|
||||
break;
|
||||
default:
|
||||
flex_die (_("invalid td_flags detected"));
|
||||
@ -233,7 +232,7 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
}
|
||||
|
||||
/* Sanity check */
|
||||
if (bwritten != (int) (12 + total_len * YYTDFLAGS2BYTES (td->td_flags))) {
|
||||
if (bwritten != (12 + total_len * (int) YYTDFLAGS2BYTES (td->td_flags))) {
|
||||
flex_die (_("insanity detected"));
|
||||
return -1;
|
||||
}
|
||||
@ -248,14 +247,14 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
/* 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
|
||||
|| yytbl_write32 (wr, (flex_uint32_t) 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);
|
||||
wr->total_written -= (int) sizeof (flex_int32_t);
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
@ -265,11 +264,11 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td)
|
||||
* @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)
|
||||
int yytbl_writen (struct yytbl_writer *wr, void *v, int len)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fwrite (v, 1, len, wr->out);
|
||||
rv = (int) fwrite (v, 1, (size_t) len, wr->out);
|
||||
if (rv != len)
|
||||
return -1;
|
||||
wr->total_written += len;
|
||||
@ -284,11 +283,11 @@ int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len)
|
||||
int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v)
|
||||
{
|
||||
flex_uint32_t vnet;
|
||||
size_t bytes, rv;
|
||||
int bytes, rv;
|
||||
|
||||
vnet = htonl (v);
|
||||
bytes = sizeof (flex_uint32_t);
|
||||
rv = fwrite (&vnet, bytes, 1, wr->out);
|
||||
bytes = (int) sizeof (flex_uint32_t);
|
||||
rv = (int) fwrite (&vnet, (size_t) bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
@ -303,11 +302,11 @@ int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v)
|
||||
int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v)
|
||||
{
|
||||
flex_uint16_t vnet;
|
||||
size_t bytes, rv;
|
||||
int bytes, rv;
|
||||
|
||||
vnet = htons (v);
|
||||
bytes = sizeof (flex_uint16_t);
|
||||
rv = fwrite (&vnet, bytes, 1, wr->out);
|
||||
bytes = (int) sizeof (flex_uint16_t);
|
||||
rv = (int) fwrite (&vnet, (size_t) bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
@ -321,10 +320,10 @@ int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v)
|
||||
*/
|
||||
int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v)
|
||||
{
|
||||
size_t bytes, rv;
|
||||
int bytes, rv;
|
||||
|
||||
bytes = sizeof (flex_uint8_t);
|
||||
rv = fwrite (&v, bytes, 1, wr->out);
|
||||
bytes = (int) sizeof (flex_uint8_t);
|
||||
rv = (int) fwrite (&v, (size_t) bytes, 1, wr->out);
|
||||
if (rv != 1)
|
||||
return -1;
|
||||
wr->total_written += bytes;
|
||||
@ -428,7 +427,7 @@ static void yytbl_data_seti (const struct yytbl_data *tbl, int i,
|
||||
*/
|
||||
static size_t min_int_size (struct yytbl_data *tbl)
|
||||
{
|
||||
flex_uint32_t i, total_len;
|
||||
flex_int32_t i, total_len;
|
||||
flex_int32_t max = 0;
|
||||
|
||||
total_len = yytbl_calc_total_len (tbl);
|
||||
@ -438,7 +437,7 @@ static size_t min_int_size (struct yytbl_data *tbl)
|
||||
|
||||
n = abs (yytbl_data_geti (tbl, i));
|
||||
|
||||
if (n > max)
|
||||
if (max < n)
|
||||
max = n;
|
||||
}
|
||||
|
||||
@ -461,7 +460,8 @@ static size_t min_int_size (struct yytbl_data *tbl)
|
||||
*/
|
||||
void yytbl_data_compress (struct yytbl_data *tbl)
|
||||
{
|
||||
flex_int32_t i, newsz, total_len;
|
||||
flex_int32_t i, total_len;
|
||||
size_t newsz;
|
||||
struct yytbl_data newtbl;
|
||||
|
||||
yytbl_data_init (&newtbl, tbl->td_id);
|
||||
@ -472,19 +472,19 @@ void yytbl_data_compress (struct yytbl_data *tbl)
|
||||
newsz = min_int_size (tbl);
|
||||
|
||||
|
||||
if (newsz == (int) YYTDFLAGS2BYTES (tbl->td_flags))
|
||||
if (newsz == YYTDFLAGS2BYTES (tbl->td_flags))
|
||||
/* No change in this table needed. */
|
||||
return;
|
||||
|
||||
if (newsz > (int) YYTDFLAGS2BYTES (tbl->td_flags)) {
|
||||
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);
|
||||
newtbl.td_data = calloc ((size_t) total_len, newsz);
|
||||
newtbl.td_flags = (flex_uint16_t)
|
||||
(TFLAGS_CLRDATA (newtbl.td_flags) | BYTES2TFLAG (newsz));
|
||||
|
||||
for (i = 0; i < total_len; i++) {
|
||||
flex_int32_t g;
|
@ -45,7 +45,7 @@ extern "C" {
|
||||
#include "tables_shared.h"
|
||||
struct yytbl_writer {
|
||||
FILE *out;
|
||||
flex_uint32_t total_written;
|
||||
int total_written;
|
||||
/**< bytes written so far */
|
||||
fpos_t th_ssize_pos;
|
||||
/**< position of th_ssize */
|
@ -52,12 +52,12 @@ dnl
|
||||
|
||||
/** Get the number of integers in this table. This is NOT the
|
||||
* same thing as the number of elements.
|
||||
* @param td the table
|
||||
* @param tbl 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;
|
||||
flex_uint32_t n;
|
||||
|
||||
/* total number of ints */
|
||||
n = tbl->td_lolen;
|
||||
@ -66,5 +66,5 @@ yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl)
|
||||
|
||||
if (tbl->td_id == YYTD_ID_TRANSITION)
|
||||
n *= 2;
|
||||
return n;
|
||||
return (flex_int32_t) n;
|
||||
}
|
@ -36,11 +36,11 @@
|
||||
|
||||
/* declarations for functions that have forward references */
|
||||
|
||||
void mkentry PROTO ((register int *, int, int, int, int));
|
||||
void mkprot PROTO ((int[], int, int));
|
||||
void mktemplate PROTO ((int[], int, int));
|
||||
void mv2front PROTO ((int));
|
||||
int tbldiff PROTO ((int[], int, int[]));
|
||||
void mkentry(int *, int, int, int, int);
|
||||
void mkprot(int[], int, int);
|
||||
void mktemplate(int[], int, int);
|
||||
void mv2front(int);
|
||||
int tbldiff(int[], int, int[]);
|
||||
|
||||
|
||||
/* bldtbl - build table entries for dfa state
|
||||
@ -78,8 +78,7 @@ int tbldiff PROTO ((int[], int, int[]));
|
||||
* cost only one difference.
|
||||
*/
|
||||
|
||||
void bldtbl (state, statenum, totaltrans, comstate, comfreq)
|
||||
int state[], statenum, totaltrans, comstate, comfreq;
|
||||
void bldtbl (int state[], int statenum, int totaltrans, int comstate, int comfreq)
|
||||
{
|
||||
int extptr, extrct[2][CSIZE + 1];
|
||||
int mindiff, minprot, i, d;
|
||||
@ -221,11 +220,11 @@ void bldtbl (state, statenum, totaltrans, comstate, comfreq)
|
||||
* classes.
|
||||
*/
|
||||
|
||||
void cmptmps ()
|
||||
void cmptmps (void)
|
||||
{
|
||||
int tmpstorage[CSIZE + 1];
|
||||
register int *tmp = tmpstorage, i, j;
|
||||
int totaltrans, trans;
|
||||
int tmpstorage[CSIZE + 1];
|
||||
int *tmp = tmpstorage, i, j;
|
||||
int totaltrans, trans;
|
||||
|
||||
peakpairs = numtemps * numecs + tblend;
|
||||
|
||||
@ -289,9 +288,9 @@ void cmptmps ()
|
||||
|
||||
/* expand_nxt_chk - expand the next check arrays */
|
||||
|
||||
void expand_nxt_chk ()
|
||||
void expand_nxt_chk (void)
|
||||
{
|
||||
register int old_max = current_max_xpairs;
|
||||
int old_max = current_max_xpairs;
|
||||
|
||||
current_max_xpairs += MAX_XPAIRS_INCREMENT;
|
||||
|
||||
@ -300,8 +299,7 @@ void expand_nxt_chk ()
|
||||
nxt = reallocate_integer_array (nxt, current_max_xpairs);
|
||||
chk = reallocate_integer_array (chk, current_max_xpairs);
|
||||
|
||||
zero_out ((char *) (chk + old_max),
|
||||
(size_t) (MAX_XPAIRS_INCREMENT * sizeof (int)));
|
||||
memset(chk + old_max, 0, MAX_XPAIRS_INCREMENT * sizeof(int));
|
||||
}
|
||||
|
||||
|
||||
@ -324,15 +322,14 @@ void expand_nxt_chk ()
|
||||
* and an action number will be added in [-1].
|
||||
*/
|
||||
|
||||
int find_table_space (state, numtrans)
|
||||
int *state, numtrans;
|
||||
int find_table_space (int *state, int numtrans)
|
||||
{
|
||||
/* Firstfree is the position of the first possible occurrence of two
|
||||
* consecutive unused records in the chk and nxt arrays.
|
||||
*/
|
||||
register int i;
|
||||
register int *state_ptr, *chk_ptr;
|
||||
register int *ptr_to_last_entry_in_state;
|
||||
int i;
|
||||
int *state_ptr, *chk_ptr;
|
||||
int *ptr_to_last_entry_in_state;
|
||||
|
||||
/* If there are too many out-transitions, put the state at the end of
|
||||
* nxt and chk.
|
||||
@ -419,13 +416,11 @@ int find_table_space (state, numtrans)
|
||||
* Initializes "firstfree" to be one beyond the end of the table. Initializes
|
||||
* all "chk" entries to be zero.
|
||||
*/
|
||||
void inittbl ()
|
||||
void inittbl (void)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
zero_out ((char *) chk,
|
||||
|
||||
(size_t) (current_max_xpairs * sizeof (int)));
|
||||
memset(chk, 0, (size_t) current_max_xpairs * sizeof(int));
|
||||
|
||||
tblend = 0;
|
||||
firstfree = tblend + 1;
|
||||
@ -451,7 +446,7 @@ void inittbl ()
|
||||
|
||||
/* mkdeftbl - make the default, "jam" table entries */
|
||||
|
||||
void mkdeftbl ()
|
||||
void mkdeftbl (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -500,12 +495,11 @@ void mkdeftbl ()
|
||||
* state array.
|
||||
*/
|
||||
|
||||
void mkentry (state, numchars, statenum, deflink, totaltrans)
|
||||
register int *state;
|
||||
int numchars, statenum, deflink, totaltrans;
|
||||
void mkentry (int *state, int numchars, int statenum, int deflink,
|
||||
int totaltrans)
|
||||
{
|
||||
register int minec, maxec, i, baseaddr;
|
||||
int tblbase, tbllast;
|
||||
int minec, maxec, i, baseaddr;
|
||||
int tblbase, tbllast;
|
||||
|
||||
if (totaltrans == 0) { /* there are no out-transitions */
|
||||
if (deflink == JAMSTATE)
|
||||
@ -616,8 +610,7 @@ void mkentry (state, numchars, statenum, deflink, totaltrans)
|
||||
* has only one out-transition
|
||||
*/
|
||||
|
||||
void mk1tbl (state, sym, onenxt, onedef)
|
||||
int state, sym, onenxt, onedef;
|
||||
void mk1tbl (int state, int sym, int onenxt, int onedef)
|
||||
{
|
||||
if (firstfree < sym)
|
||||
firstfree = sym;
|
||||
@ -642,8 +635,7 @@ void mk1tbl (state, sym, onenxt, onedef)
|
||||
|
||||
/* mkprot - create new proto entry */
|
||||
|
||||
void mkprot (state, statenum, comstate)
|
||||
int state[], statenum, comstate;
|
||||
void mkprot (int state[], int statenum, int comstate)
|
||||
{
|
||||
int i, slot, tblbase;
|
||||
|
||||
@ -680,11 +672,10 @@ void mkprot (state, statenum, comstate)
|
||||
* to it
|
||||
*/
|
||||
|
||||
void mktemplate (state, statenum, comstate)
|
||||
int state[], statenum, comstate;
|
||||
void mktemplate (int state[], int statenum, int comstate)
|
||||
{
|
||||
int i, numdiff, tmpbase, tmp[CSIZE + 1];
|
||||
Char transset[CSIZE + 1];
|
||||
unsigned char transset[CSIZE + 1];
|
||||
int tsptr;
|
||||
|
||||
++numtemps;
|
||||
@ -712,7 +703,8 @@ void mktemplate (state, statenum, comstate)
|
||||
if (state[i] == 0)
|
||||
tnxt[tmpbase + i] = 0;
|
||||
else {
|
||||
transset[tsptr++] = i;
|
||||
/* Note: range 1..256 is mapped to 1..255,0 */
|
||||
transset[tsptr++] = (unsigned char) i;
|
||||
tnxt[tmpbase + i] = comstate;
|
||||
}
|
||||
|
||||
@ -732,8 +724,7 @@ void mktemplate (state, statenum, comstate)
|
||||
|
||||
/* mv2front - move proto queue element to front of queue */
|
||||
|
||||
void mv2front (qelm)
|
||||
int qelm;
|
||||
void mv2front (int qelm)
|
||||
{
|
||||
if (firstprot != qelm) {
|
||||
if (qelm == lastprot)
|
||||
@ -759,12 +750,11 @@ void mv2front (qelm)
|
||||
* Transnum is the number of out-transitions for the state.
|
||||
*/
|
||||
|
||||
void place_state (state, statenum, transnum)
|
||||
int *state, statenum, transnum;
|
||||
void place_state (int *state, int statenum, int transnum)
|
||||
{
|
||||
register int i;
|
||||
register int *state_ptr;
|
||||
int position = find_table_space (state, transnum);
|
||||
int i;
|
||||
int *state_ptr;
|
||||
int position = find_table_space (state, transnum);
|
||||
|
||||
/* "base" is the table of start positions. */
|
||||
base[statenum] = position;
|
||||
@ -802,8 +792,7 @@ void place_state (state, statenum, transnum)
|
||||
* no room, we process the sucker right now.
|
||||
*/
|
||||
|
||||
void stack1 (statenum, sym, nextstate, deflink)
|
||||
int statenum, sym, nextstate, deflink;
|
||||
void stack1 (int statenum, int sym, int nextstate, int deflink)
|
||||
{
|
||||
if (onesp >= ONE_STACK_SIZE - 1)
|
||||
mk1tbl (statenum, sym, nextstate, deflink);
|
||||
@ -832,11 +821,10 @@ void stack1 (statenum, sym, nextstate, deflink)
|
||||
* number is "numecs" minus the number of "SAME_TRANS" entries in "ext".
|
||||
*/
|
||||
|
||||
int tbldiff (state, pr, ext)
|
||||
int state[], pr, ext[];
|
||||
int tbldiff (int state[], int pr, int ext[])
|
||||
{
|
||||
register int i, *sp = state, *ep = ext, *protp;
|
||||
register int numdiff = 0;
|
||||
int i, *sp = state, *ep = ext, *protp;
|
||||
int numdiff = 0;
|
||||
|
||||
protp = &protsave[numecs * (pr - 1)];
|
||||
|
@ -37,18 +37,19 @@
|
||||
|
||||
|
||||
/* yylex - scan for a regular expression token */
|
||||
|
||||
int yylex ()
|
||||
extern char *yytext;
|
||||
extern FILE *yyout;
|
||||
bool no_section3_escape = false;
|
||||
int yylex (void)
|
||||
{
|
||||
int toktype;
|
||||
static int beglin = false;
|
||||
extern char *yytext;
|
||||
|
||||
if (eofseen)
|
||||
if (eofseen) {
|
||||
toktype = EOF;
|
||||
else
|
||||
} else {
|
||||
toktype = flexscan ();
|
||||
|
||||
}
|
||||
if (toktype == EOF || toktype == 0) {
|
||||
eofseen = 1;
|
||||
|
||||
@ -150,11 +151,12 @@ int yylex ()
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!isascii (yylval) || !isprint (yylval))
|
||||
fprintf (stderr,
|
||||
"\\%.3o",
|
||||
(unsigned int) yylval);
|
||||
else
|
||||
if (!isascii (yylval) || !isprint (yylval)) {
|
||||
if(trace_hex)
|
||||
fprintf (stderr, "\\x%02x", (unsigned int) yylval);
|
||||
else
|
||||
fprintf (stderr, "\\%.3o", (unsigned int) yylval);
|
||||
} else
|
||||
(void) putc (yylval, stderr);
|
||||
break;
|
||||
}
|
||||
@ -173,12 +175,12 @@ int yylex ()
|
||||
fprintf (stderr, "<<EOF>>");
|
||||
break;
|
||||
|
||||
case OPTION_OP:
|
||||
case TOK_OPTION:
|
||||
fprintf (stderr, "%s ", yytext);
|
||||
break;
|
||||
|
||||
case OPT_OUTFILE:
|
||||
case OPT_PREFIX:
|
||||
case TOK_OUTFILE:
|
||||
case TOK_PREFIX:
|
||||
case CCE_ALNUM:
|
||||
case CCE_ALPHA:
|
||||
case CCE_BLANK:
|
222
ylwrap
222
ylwrap
@ -1,222 +0,0 @@
|
||||
#! /bin/sh
|
||||
# ylwrap - wrapper for lex/yacc invocations.
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
|
||||
# 2007, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
case "$1" in
|
||||
'')
|
||||
echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1
|
||||
;;
|
||||
--basedir)
|
||||
basedir=$2
|
||||
shift 2
|
||||
;;
|
||||
-h|--h*)
|
||||
cat <<\EOF
|
||||
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
|
||||
|
||||
Wrapper for lex/yacc invocations, renaming files as desired.
|
||||
|
||||
INPUT is the input file
|
||||
OUTPUT is one file PROG generates
|
||||
DESIRED is the file we actually want instead of OUTPUT
|
||||
PROGRAM is program to run
|
||||
ARGS are passed to PROG
|
||||
|
||||
Any number of OUTPUT,DESIRED pairs may be used.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v|--v*)
|
||||
echo "ylwrap $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# The input.
|
||||
input="$1"
|
||||
shift
|
||||
case "$input" in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
# Absolute path; do nothing.
|
||||
;;
|
||||
*)
|
||||
# Relative path. Make it absolute.
|
||||
input="`pwd`/$input"
|
||||
;;
|
||||
esac
|
||||
|
||||
pairlist=
|
||||
while test "$#" -ne 0; do
|
||||
if test "$1" = "--"; then
|
||||
shift
|
||||
break
|
||||
fi
|
||||
pairlist="$pairlist $1"
|
||||
shift
|
||||
done
|
||||
|
||||
# The program to run.
|
||||
prog="$1"
|
||||
shift
|
||||
# Make any relative path in $prog absolute.
|
||||
case "$prog" in
|
||||
[\\/]* | ?:[\\/]*) ;;
|
||||
*[\\/]*) prog="`pwd`/$prog" ;;
|
||||
esac
|
||||
|
||||
# FIXME: add hostname here for parallel makes that run commands on
|
||||
# other machines. But that might take us over the 14-char limit.
|
||||
dirname=ylwrap$$
|
||||
trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
|
||||
mkdir $dirname || exit 1
|
||||
|
||||
cd $dirname
|
||||
|
||||
case $# in
|
||||
0) "$prog" "$input" ;;
|
||||
*) "$prog" "$@" "$input" ;;
|
||||
esac
|
||||
ret=$?
|
||||
|
||||
if test $ret -eq 0; then
|
||||
set X $pairlist
|
||||
shift
|
||||
first=yes
|
||||
# Since DOS filename conventions don't allow two dots,
|
||||
# the DOS version of Bison writes out y_tab.c instead of y.tab.c
|
||||
# and y_tab.h instead of y.tab.h. Test to see if this is the case.
|
||||
y_tab_nodot="no"
|
||||
if test -f y_tab.c || test -f y_tab.h; then
|
||||
y_tab_nodot="yes"
|
||||
fi
|
||||
|
||||
# The directory holding the input.
|
||||
input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
|
||||
# Quote $INPUT_DIR so we can use it in a regexp.
|
||||
# FIXME: really we should care about more than `.' and `\'.
|
||||
input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
|
||||
|
||||
while test "$#" -ne 0; do
|
||||
from="$1"
|
||||
# Handle y_tab.c and y_tab.h output by DOS
|
||||
if test $y_tab_nodot = "yes"; then
|
||||
if test $from = "y.tab.c"; then
|
||||
from="y_tab.c"
|
||||
else
|
||||
if test $from = "y.tab.h"; then
|
||||
from="y_tab.h"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test -f "$from"; then
|
||||
# If $2 is an absolute path name, then just use that,
|
||||
# otherwise prepend `../'.
|
||||
case "$2" in
|
||||
[\\/]* | ?:[\\/]*) target="$2";;
|
||||
*) target="../$2";;
|
||||
esac
|
||||
|
||||
# We do not want to overwrite a header file if it hasn't
|
||||
# changed. This avoid useless recompilations. However the
|
||||
# parser itself (the first file) should always be updated,
|
||||
# because it is the destination of the .y.c rule in the
|
||||
# Makefile. Divert the output of all other files to a temporary
|
||||
# file so we can compare them to existing versions.
|
||||
if test $first = no; then
|
||||
realtarget="$target"
|
||||
target="tmp-`echo $target | sed s/.*[\\/]//g`"
|
||||
fi
|
||||
# Edit out `#line' or `#' directives.
|
||||
#
|
||||
# We don't want the resulting debug information to point at
|
||||
# an absolute srcdir; it is better for it to just mention the
|
||||
# .y file with no path.
|
||||
#
|
||||
# We want to use the real output file name, not yy.lex.c for
|
||||
# instance.
|
||||
#
|
||||
# We want the include guards to be adjusted too.
|
||||
FROM=`echo "$from" | sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
|
||||
TARGET=`echo "$2" | sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
|
||||
|
||||
sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
|
||||
-e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
|
||||
|
||||
# Check whether header files must be updated.
|
||||
if test $first = no; then
|
||||
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
|
||||
echo "$2" is unchanged
|
||||
rm -f "$target"
|
||||
else
|
||||
echo updating "$2"
|
||||
mv -f "$target" "$realtarget"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# A missing file is only an error for the first file. This
|
||||
# is a blatant hack to let us support using "yacc -d". If -d
|
||||
# is not specified, we don't want an error when the header
|
||||
# file is "missing".
|
||||
if test $first = yes; then
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
first=no
|
||||
done
|
||||
else
|
||||
ret=$?
|
||||
fi
|
||||
|
||||
# Remove the directory.
|
||||
cd ..
|
||||
rm -rf $dirname
|
||||
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
Loading…
Reference in New Issue
Block a user