[Gd-chatter] r11165 - in trunk/fundev/tools/gema: . doc examples src test
housel at gwydiondylan.org
housel at gwydiondylan.org
Thu Feb 8 05:57:31 CET 2007
Author: housel
Date: Thu Feb 8 05:57:26 2007
New Revision: 11165
Added:
trunk/fundev/tools/gema/src/gemabuild (contents, props changed)
trunk/fundev/tools/gema/test/gematest (contents, props changed)
trunk/fundev/tools/gema/test/gematest.bat (contents, props changed)
trunk/fundev/tools/gema/test/test6in.dat (contents, props changed)
trunk/fundev/tools/gema/test/test6out.dat (contents, props changed)
trunk/fundev/tools/gema/test/test6pat.dat (contents, props changed)
Modified:
trunk/fundev/tools/gema/README
trunk/fundev/tools/gema/doc/Makefile
trunk/fundev/tools/gema/doc/conclude.tex
trunk/fundev/tools/gema/doc/doc.tex
trunk/fundev/tools/gema/doc/function.tex
trunk/fundev/tools/gema/doc/gema.1
trunk/fundev/tools/gema/doc/notation.tex
trunk/fundev/tools/gema/doc/overview.tex
trunk/fundev/tools/gema/examples/c2dyl.dat (contents, props changed)
trunk/fundev/tools/gema/examples/cpp-dyla.dat (contents, props changed)
trunk/fundev/tools/gema/examples/ht.dat (props changed)
trunk/fundev/tools/gema/examples/html-sty.dat (props changed)
trunk/fundev/tools/gema/examples/htmlrtf.pat (props changed)
trunk/fundev/tools/gema/examples/latex.dat (props changed)
trunk/fundev/tools/gema/examples/lspdyl.pat (props changed)
trunk/fundev/tools/gema/examples/man-html.dat (contents, props changed)
trunk/fundev/tools/gema/examples/tex.dat (props changed)
trunk/fundev/tools/gema/src/Makefile
trunk/fundev/tools/gema/src/action.c
trunk/fundev/tools/gema/src/bool.h
trunk/fundev/tools/gema/src/cstream.c
trunk/fundev/tools/gema/src/cstream.h
trunk/fundev/tools/gema/src/gema.c
trunk/fundev/tools/gema/src/match.c
trunk/fundev/tools/gema/src/patimp.h
trunk/fundev/tools/gema/src/pattern.h
trunk/fundev/tools/gema/src/read.c
trunk/fundev/tools/gema/src/reg-expr.c
trunk/fundev/tools/gema/src/reg-expr.h
trunk/fundev/tools/gema/src/util.c
trunk/fundev/tools/gema/src/util.h
trunk/fundev/tools/gema/src/var.c
trunk/fundev/tools/gema/src/version.c
trunk/fundev/tools/gema/test/test
trunk/fundev/tools/gema/test/test.bat
trunk/fundev/tools/gema/test/test2.dat (props changed)
trunk/fundev/tools/gema/test/test2out.dat (props changed)
trunk/fundev/tools/gema/test/test3.dat (props changed)
trunk/fundev/tools/gema/test/test3out.dat (props changed)
trunk/fundev/tools/gema/test/test5in.dat (props changed)
trunk/fundev/tools/gema/test/test5out.dat (props changed)
trunk/fundev/tools/gema/test/testin.dat (props changed)
trunk/fundev/tools/gema/test/testout.dat (props changed)
trunk/fundev/tools/gema/test/testpat.dat (contents, props changed)
trunk/fundev/tools/gema/test/testtok.dat (contents, props changed)
trunk/fundev/tools/gema/test/testtw.dat (props changed)
Log:
Job: fd
Update to gema 1.4.1 (from a snapshot of gema.cvs.sourceforge.net).
Modified: trunk/fundev/tools/gema/README
==============================================================================
--- trunk/fundev/tools/gema/README (original)
+++ trunk/fundev/tools/gema/README Thu Feb 8 05:57:26 2007
@@ -7,29 +7,39 @@
examples sample applications, including LaTeX to HTML conversion.
test script and data for verification of build
- This description applies to version 1.2.
+ This description applies to version 1.4.
- The program currently works on Unix, MS-DOS, Windows NT, and
- Macintosh. It may need some modification for use on other systems,
- particular in regard to pathname syntax and accessing file attributes;
- see the places where ``#ifdef unix'', ``#ifdef MSDOS'', and ``#ifdef
- MACOS'' are used.
-
- To build the program, you just need to use an ANSI C compiler to compile
- all of the ".c" files and link the resulting object files together. An
- example "Makefile" for Unix is provided, and a "gema.mak" file from
- Microsoft Quick C. Normally you should compile with optimization and
- with the option "-DNDEBUG" to omit internal debugging checks. You may
- also want to use "-DTRACE" to enable the experimental diagnostic trace
- option. For MS-DOS, you'll need to specify a stack size somewhere in the
- range of 4000 to 6000 bytes; I'm currently using 5600. So far, this has
- been successfully built with the following brands of compilers:
- Microsoft, Borland, Sun, Gnu, Lucid, and MPW.
-
- After building the program, you can verify that it works correctly by
- running the test script in the "test" directory -- "test" for Unix, or
- "test.bat" for MS-DOS or Windows. The test passes if no file comparison
- differences are reported.
+ The program currently works on several varieties of Unix, MS-DOS,
+ Microsoft Windows, and Macintosh (both OS-X and earlier MACOS with
+ MPW). It may need some modification for use on other systems, particular
+ in regard to pathname syntax and accessing file attributes; see the
+ places where ``#ifdef unix'', ``#ifdef MSDOS'', and ``#ifdef MACOS'' are
+ used.
+
+ On most systems, you can build the program by just cd-ing to the "src"
+ directory and then running the command "gemabuild". This will build and
+ test the program, automatically selecting the appropriate compiler
+ options for any of many common operating systems. (There are actually
+ two script files, "gemabuild" for Unix and "gemabuild.bat" for Windows.)
+
+ Further build details if needed:
+
+ To build the program, you just need to use an ANSI C compiler to
+ compile all of the ".c" files and link the resulting object files
+ together. An example "Makefile" for Unix is provided. Normally you
+ should compile with optimization and with the option "-DNDEBUG" to omit
+ internal debugging checks. You may also want to use "-DTRACE" to
+ enable the experimental diagnostic trace option.
+
+ For MS-DOS (16-bit mode), there is a "gema.mak" file from Microsoft
+ Quick C. It builds using the "small memory model". You'll need to
+ specify a stack size somewhere in the range of 4000 to 6000 bytes; I'm
+ currently using 5600.
+
+ After building the program, you can verify that it works correctly by
+ running the command "gematest" in the "test" directory (script file
+ "gematest" for Unix or "gematest.bat" for Windows.) The test passes if
+ no file comparison differences are reported.
The "examples" directory includes the following non-trivial pattern files
for document conversion:
@@ -68,7 +78,8 @@
e-mail: DGray at acm.org
- 850 Roble Ave., Apt. G
- Menlo Park, CA 94025
+ 175 Dalma Drive
+ Mountain View, CA 94041
+
+ February, 2002
- August 19, 1995
Modified: trunk/fundev/tools/gema/doc/Makefile
==============================================================================
--- trunk/fundev/tools/gema/doc/Makefile (original)
+++ trunk/fundev/tools/gema/doc/Makefile Thu Feb 8 05:57:26 2007
@@ -1,5 +1,5 @@
-# $Id: Makefile,v 1.1 2004/03/12 00:42:06 cgay Exp $
+# $Id: Makefile,v 1.6 2003/12/28 02:15:03 dngray Exp $
all: doc.ps gema.ps doc.html gema.html gema.lpr
@@ -7,16 +7,16 @@
TEXFILES = doc.tex overview.tex notation.tex function.tex conclude.tex
-doc.dvi: ${TEXFILES}
+doc.dvi: $(TEXFILES)
latex doc.tex || rm -f doc.dvi
doc.ps: doc.dvi
- dvi2ps doc.dvi > $@
+ dvi2ps doc.dvi > $@ || dvips doc.dvi -o $@
view: doc.dvi
xtex doc.dvi &
-doc.html: ${TEXFILES} latex-to-html
+doc.html: $(TEXFILES) latex-to-html
./latex-to-html doc.tex $@
latex-to-html:
@@ -39,19 +39,6 @@
# ------------------------------------------------------------------
-# RTF files for Windows Help
-
-gema.hpj: top.html gema.html doc.html ../examples/htmlrtf.pat
- gema -f ../examples/htmlrtf.pat -makefile $@ \
- -helpfile gema.hlp -title gema \
- top.html gema.html doc.html overview.html notation.html \
- function.html conclude.html overview-footnotes.html \
- function-footnotes.html conclude-footnotes.html
-
-rtf: gema.hpj
-
-# ------------------------------------------------------------------
-
# remove all generated files:
clean:
rm -f *.aux doc.dvi doc.ps doc.toc doc.*log *.html *.bak \
Modified: trunk/fundev/tools/gema/doc/conclude.tex
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/doc/doc.tex
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/doc/function.tex
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/doc/gema.1
==============================================================================
--- trunk/fundev/tools/gema/doc/gema.1 (original)
+++ trunk/fundev/tools/gema/doc/gema.1 Thu Feb 8 05:57:26 2007
@@ -1,6 +1,6 @@
.\" @(#)gema.1
-.\" $Id: gema.1,v 1.1 2004/03/12 00:42:07 cgay Exp $
-.TH GEMA 1 "31 Mar 1996" "version 1.3" " "
+.\" $Id: gema.1,v 1.6 2003/12/28 02:18:03 dngray Exp $
+.TH GEMA 1 "26 Dec 2003" "version 1.4" " "
.SH NAME
gema \- general purpose macro processor
.SH SYNOPSIS
@@ -21,6 +21,7 @@
\fB\-idchars \fP\fIcharset\fP |
\fB\-filechars \fP\fIcharset\fP |
\fB\-literal \fP\fIcharset\fP |
+.BR \-ml " | "
.BR \-trace " | "
\fB\-arglen \fP\fInum\fP
.de QX
@@ -95,7 +96,8 @@
because it is more general than that.)
The presence of the equal sign serves to distinguish a pattern argument
from a file name. Note that pattern arguments will usually need to be
-enclosed in single quotes on Unix, or double quotes on MS-DOS.
+enclosed in single quotes on Unix (as shown in the example), or double
+quotes on MS-DOS or Windows.
.LP
Patterns can also be defined in one or more files loaded with the
.B \-f
@@ -383,6 +385,11 @@
or beginning with
.QX @
is automatically recognized as a pattern argument.
+Any number of
+.B \-f
+and/or
+.B \-p
+options may be given.
.TP
.BI \-in " file"
Explicitly specifies the input file pathname. If the file name is
@@ -408,6 +415,9 @@
.br
\ \ \fBgema -match -p 'Copyright *\\n=@file\\: $0' -out - *.c\fP
.br
+(The special notation
+.QX $0
+copies all of the matched text into the output.)
.TP
.BI \-odir " directory"
Specifies the output directory. For each input file that follows, a
@@ -445,7 +455,7 @@
.B \-b
Binary. With this option, all input and output files are opened in
binary mode instead of text mode. This makes no difference on most Unix
-systems, but on MS-DOS it changes the meaning of the new line character and
+systems, but on Windows it changes the meaning of the new line character and
doesn't treat Control-Z as the end of the file.
.TP
.B \-k
@@ -523,7 +533,7 @@
as being file name constituents, in addition to letters and digits.
The default value is
.QX "./\-_~#@%+="
-for Unix. On MS-DOS, colon and backslash are also included in the
+for Unix. On Windows, colon and backslash are also included in the
default set.
.TP
.BI \-literal " charset"
@@ -538,6 +548,33 @@
.br
\ \ \ \fBgema -literal / '/usr/foo/<F>=/usr/bar/$1'\fP \fI...\fP
.TP
+.B \-ml
+For convenience in processing Markup Languages (HTML, XML, etc.), this
+option (which is new in version 1.4)
+changes the syntax so that the characters
+.QX < ,
+.QX >
+and
+.QX /
+are taken as literals, using
+.QX [ ,
+.QX ]
+and
+.QX |
+respectively in their places.
+For example:
+.br
+ \ \ \ \fBgema -ml -p '<i>[T]</i>=<em>$1</em>'\fP \fI...\fP
+.br
+has the same effect as:
+.br
+ \ \ \ \fBgema -p '\\<i\\><T>\\<\\/i\\>=\\<em\\>$1\\<\\/em\\>'\fP \fI...\fP
+.br
+The
+.QX -ml
+option is an abbreviation for
+.QX @set-syntax{</>LLL;[|]</>} .
+.TP
.BI \-arglen " number"
Specify the maximum length of a
.QX *
@@ -651,7 +688,7 @@
Also, as a special case, the first line of a pattern file is ignored if the
first two characters are
.QX #! .
-This allows a pattern file to be made directly executable by putting
+This allows a pattern file to be made directly executable on Unix by putting
something like "\fB#!/usr/local/bin/gema -f\fP" as the first line.
.LP
.ne 6
@@ -932,7 +969,7 @@
Specify exit code to return when the program terminates. No return value.
.TP
.BI @expand-wild{ path }
-Expand wild card pathname on MS-DOS.
+Expand wild card pathname on MS-DOS or Windows.
.TP
.B @fail{}
Signal translation failure; causes failed match of recursive argument.
@@ -1180,13 +1217,12 @@
.B gema
user manual and the example pattern files provided.
.LP
-All source files and documentation are available by anonymous FTP from
-directory
-.QX /pub/gema
-at
-.QX ftp.harlequin.com .
-WWW documentation is at URL:
-.QX ftp://ftp.harlequin.com/pub/gema/www/top.html .
+The source files and documentation can be downloaded from
+.QX http://sourceforge.net/projects/gema/
+or
+.QX http://www.cbayona.com/pub/Macro%20Languages/Gema/ .
+The documentation can be read at
+.QX http://gema.sourceforge.net/ .
.LP
.SH AUTHORS
.PP
Modified: trunk/fundev/tools/gema/doc/notation.tex
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/doc/overview.tex
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/examples/c2dyl.dat
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/examples/cpp-dyla.dat
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/examples/man-html.dat
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/src/Makefile
==============================================================================
--- trunk/fundev/tools/gema/src/Makefile (original)
+++ trunk/fundev/tools/gema/src/Makefile Thu Feb 8 05:57:26 2007
@@ -4,17 +4,20 @@
# use "make gcc" to build with the Gnu C compiler
# or "make acc" to build with the Solaris ANSI C compiler
# or "make lcc" to build with the Lucid C compiler.
+# or "make cc" to use a compiler named "cc".
#
# (An ANSI-C compiler is required.)
-# $Id: Makefile,v 1.1 2004/03/12 00:42:08 cgay Exp $
+# $Id: Makefile,v 1.6 2003/11/02 00:37:06 gray Exp $
INSTALLDIR = /usr/local
-all: gcc
+# The default build target runs a script to determine the appropriate options.
+default:
+ gemabuild
gcc:
- ${MAKE} CC=gcc CCFLAGS="-Wall -O2 -DNDEBUG" gema
+ ${MAKE} CC=gcc CCFLAGS="-ansi -Wall -O2 -DNDEBUG" gema
lcc:
${MAKE} CC=lcc CCFLAGS="-XG -O -Xa -DNDEBUG" gema
@@ -22,14 +25,17 @@
acc:
${MAKE} CC=acc CCFLAGS="-O -DNDEBUG" gema
+cc:
+ ${MAKE} CC=cc CCFLAGS="-O -DNDEBUG" gema
+
debug:
- ${MAKE} CC=lcc CCFLAGS="-g -Xa -wucpd" gema
+ ${MAKE} CCFLAGS="-g" gema
OBJS = version.o gema.o reg-expr.o var.o util.o read.o match.o \
cstream.o action.o
-CC = lcc
-CCFLAGS = -XG -O -Xa
+CC = cc
+CCFLAGS = -O -DNDEBUG
clean:
rm -f ${OBJS} gema
Modified: trunk/fundev/tools/gema/src/action.c
==============================================================================
--- trunk/fundev/tools/gema/src/action.c (original)
+++ trunk/fundev/tools/gema/src/action.c Thu Feb 8 05:57:26 2007
@@ -1,7 +1,7 @@
/* execute the action for a matched template */
-/* $Id: action.c,v 1.1 2004/03/12 00:42:08 cgay Exp $ */
+/* $Id: action.c,v 1.15 2004/12/29 00:10:15 dngray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
@@ -12,10 +12,27 @@
/*
* $Log: action.c,v $
- * Revision 1.1 2004/03/12 00:42:08 cgay
- * Initial revision
+ * Revision 1.15 2004/12/29 00:10:15 dngray
+ * Extend range of @radix by using strtoul instead of strtol.
+ * (Suggested by Alex Karahalios.)
*
- * Revision 1.9 1996/04/21 00:27:23 gray
+ * Revision 1.14 2004/09/18 22:57:05 dngray
+ * Allow MAX_DOMAINS to be larger than 255
+ * (merged changes contributed by Alex Karahalios).
+ *
+ * Revision 1.13 2003/12/01 18:58:16 gray
+ * Fix a flaw in @set-syntax that affects optimized Microsoft compile.
+ *
+ * Revision 1.12 2003/11/02 00:03:56 gray
+ * Add trace printout of domain call.
+ *
+ * Revision 1.11 2001/12/31 01:35:22 gray
+ * Flush stdout before invoking @shell command.
+ *
+ * Revision 1.10 2001/12/15 20:21:06 gray
+ * Clean up compiler warnings.
+ *
+ * Revision 1.9 1996/04/08 05:04:50 gray
* Fix @wrap to do nothing if the argument is empty, and to not wrap when the
* current column is less than the margin.
*
@@ -24,8 +41,7 @@
* introduce spaces that were not present in the original text.
*
* Revision 1.7 1995/07/04 23:36:22 gray
- * Use separate segment on Macintosh --
- * from David A. Mundie <mundie at telerama.lm.com>
+ * Use separate segment on Macintosh -- from David A. Mundie
*
* Revision 1.6 1995/06/12 02:58:25 gray
* Add OP_OUTCOL and OP_GET_SWITCH.
@@ -313,7 +329,11 @@
break;
case PT_DOMAIN:
+#if MAX_DOMAINS < 256
as = skip_action( as+1 );
+#else
+ as = skip_action( as+2 ); /* +2 since domains take up 2 bytes */
+#endif
break;
case PT_OP: {
int n;
@@ -383,7 +403,13 @@
case PT_DOMAIN: {
CIStream inbuf;
Pattern save_rule = current_rule;
+#if MAX_DOMAINS < 256
int domain = *as++ - 1;
+#else
+ /* Get domain index as 14 bit little endian number */
+ int domain = ((unsigned char)*as++)&0x7f;
+ domain = ((((unsigned char)*as++)&0x7f)<<7) | domain;
+#endif
if ( as[0] == PT_VAR1 ||
( as[0] == PT_OP &&
( as[1] == OP_VAR || as[1] == OP_VAR_DFLT ) ) ) {
@@ -396,9 +422,34 @@
}
else /* optimized operand access */
inbuf = function_operand( &as, args );
+#ifdef TRACE
+ if ( trace_switch ) {
+ int n;
+ fprintf( stderr, "%12ld,%2d ",
+ cis_line(input_stream), cis_column(input_stream));
+ for ( n = trace_indent ; n > 0 ; n-- )
+ fputc(' ',stderr);
+ if ( cis_is_file(inbuf) ) {
+ const char* inpath = cis_pathname(inbuf);
+ if ( inpath == NULL )
+ inpath = "-";
+ fprintf( stderr, "@%s{@read{%s}}\n",
+ domains[domain]->name, inpath);
+ }
+ else
+ fprintf( stderr, "@%s{%.60s}\n",
+ domains[domain]->name, cis_whole_string(inbuf));
+ ++trace_indent;
+ }
+#endif
if ( !translate( inbuf, domains[domain], out, NULL ) &&
cis_is_file(inbuf) && exit_status < EXS_FAIL )
exit_status = EXS_FAIL;
+#ifdef TRACE
+ if ( trace_switch ) {
+ --trace_indent;
+ }
+#endif
current_rule = save_rule;
cis_close(inbuf);
break;
@@ -421,9 +472,14 @@
break;
case PT_SPECIAL_ARG:
+#if MAX_DOMAINS >= 256 /* advance one more since 2 bytes for domain index */
+ case PT_RECUR:
+#endif
as++;
case PT_REGEXP:
+#if MAX_DOMAINS < 256
case PT_RECUR:
+#endif
as++;
case PT_MATCH_ANY:
case PT_MATCH_ONE: {
@@ -704,6 +760,7 @@
case OP_OR: z = x | y; break;
default: /* can't happen; just to avoid compiler warning */
assert(FALSE);
+ z = 0;
break;
}
put_number(out,z);
@@ -715,16 +772,16 @@
case OP_RADIX: {
int from, to;
- long value;
+ unsigned long value;
char* string;
char* end;
const char* fmt;
- char buf[20];
+ char buf[24]; /* enough for 64 bits in octal */
from = (int)numeric_operand( &as, args );
to = (int)numeric_operand( &as, args );
inbuf = function_operand( &as, args );
string = cis_whole_string(inbuf);
- value = strtol( string, &end, from );
+ value = strtoul( string, &end, from );
if ( *end != '\0' )
input_error ( input_stream, EXS_NUM,
"Invalid argument for radix %d conversion: \"%.99s\"\n",
@@ -737,7 +794,9 @@
if ( to != 10 )
input_error ( input_stream, EXS_NUM,
"Unsupported radix: %d\n", to);
- fmt = "%ld";
+ while ( isspace(string[0]) )
+ string++;
+ fmt = (string[0]=='-') ? "%ld" : "%lu";
}
sprintf(buf, fmt, value);
cos_puts(out, buf);
@@ -919,6 +978,7 @@
const char* command;
inbuf = function_operand( &as, args );
command = cis_whole_string(inbuf);
+ fflush(stdout);
if ( system( command ) < 0 ) {
input_error ( input_stream, EXS_SHELL,
"Failed shell command \"%.20s...\":\n", command );
@@ -994,10 +1054,10 @@
charset = cis_whole_string(val);
for ( type = cis_whole_string(inbuf) ; *type != '\0' ; type++ ) {
const char* chars;
+ char c[2];
if ( type[1] == '\0' )
chars = charset;
else {
- char c[2];
c[0] = *charset++;
c[1] = '\0';
chars = c;
@@ -1088,4 +1148,6 @@
cos_putch(out, ac);
} /* end switch ac */
} /* end for */
+ /* can't ever get here, but return to avoid Gnu compiler warning. */
+ return as;
}
Modified: trunk/fundev/tools/gema/src/bool.h
==============================================================================
--- trunk/fundev/tools/gema/src/bool.h (original)
+++ trunk/fundev/tools/gema/src/bool.h Thu Feb 8 05:57:26 2007
@@ -1,8 +1,19 @@
-#ifndef TRUE
+#ifndef MY_BOOL_H
+#define MY_BOOL_H
+#ifdef _AIX
+#include <sys/types.h>
+#define boolean boolean_t
+#else
typedef int boolean;
+#endif
+
+#ifndef TRUE
+
#define TRUE 1
#define FALSE 0
#endif
+
+#endif
Modified: trunk/fundev/tools/gema/src/cstream.c
==============================================================================
--- trunk/fundev/tools/gema/src/cstream.c (original)
+++ trunk/fundev/tools/gema/src/cstream.c Thu Feb 8 05:57:26 2007
@@ -1,21 +1,29 @@
/* character stream functions */
-/* $Id: cstream.c,v 1.1 2004/03/12 00:42:08 cgay Exp $ */
+/* $Id: cstream.c,v 1.12 2002/02/17 01:17:58 gray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
written by David N. Gray <dgray at acm.org> in 1994 and 1995.
- Adapted for the Macintosh by David A. Mundie <mundie at telerama.lm.com>.
+ Adapted for the Macintosh by David A. Mundie <mundie at anthus.com>.
You may do whatever you like with this, so long as you retain
an acknowledgment of the original source.
*********************************************************************/
/*
* $Log: cstream.c,v $
- * Revision 1.1 2004/03/12 00:42:08 cgay
- * Initial revision
+ * Revision 1.12 2002/02/17 01:17:58 gray
+ * Prevent a reference outside of array -- fix contributed by Alex Karahalios.
*
- * Revision 1.9 1996/04/21 00:30:34 gray
+ * Revision 1.11 2002/02/17 00:29:39 gray
+ * On Windows 95 and later, append ".bak" like on Unix instead of replacing
+ * the extension like on MS-DOS.
+ *
+ * Revision 1.10 2001/12/15 20:22:01 gray
+ * Update directory check to be more portable.
+ * Clean up compiler warnings.
+ *
+ * Revision 1.9 1996/04/08 05:09:02 gray
* Fix `extend_buffer' to correctly handle binary files on MS-DOS.
* Modify `open_output_file' to facilitate better error message when input and
* output files are the same and non-existent.
@@ -168,7 +176,7 @@
}
return EOF;
}
- if ( s->next[-1] == '\n' ) {
+ if ( s->next == s->start || s->next[-1] == '\n' ) {
s->line++;
s->column = 1;
}
@@ -412,7 +420,13 @@
#else
struct stat sbuf;
if ( stat( pathname, &sbuf ) == 0 ) {
- if ( sbuf.st_mode & S_IFDIR )
+ int isdir;
+#ifdef S_ISDIR /* POSIX */
+ isdir = S_ISDIR(sbuf.st_mode);
+#else /* older way */
+ isdir = sbuf.st_mode & S_IFDIR;
+#endif
+ if ( isdir )
return 'D'; /* directory */
else if ( sbuf.st_mode & S_IFREG )
return 'F'; /* file */
@@ -747,13 +761,13 @@
COStream outbuf;
const char* backup_pathname;
outbuf = make_buffer_output_stream();
-#if defined(unix) | defined(__unix__) | defined(__unix)
- /* on Unix, append ".bak" to the file name */
+#if defined(MSDOS) && !defined(_WIN32)
+ /* on MS-DOS (8.3 filenames), replace any previous extension */
+ merge_pathnames( outbuf, FALSE, NULL, pathname, backup_suffix);
+#else
+ /* on Unix or Win32, append ".bak" to the file name */
cos_puts(outbuf,pathname);
cos_puts(outbuf,backup_suffix);
-#else
- /* on MS-DOS, replace any previous extension */
- merge_pathnames( outbuf, FALSE, NULL, pathname, backup_suffix);
#endif
bakpath = convert_output_to_input( outbuf );
backup_pathname = cis_whole_string(bakpath);
@@ -769,9 +783,10 @@
if ( outfs == NULL ) {
input_error(input_stream, EXS_OUTPUT, "Can't open output file:\n");
perror(pathname);
- if ( keep_going )
- return NULL;
- else exit(EXS_OUTPUT);
+ if ( ! keep_going ) {
+ exit(EXS_OUTPUT);
+ }
+ return NULL;
}
else {
current_output = make_file_output_stream(outfs,pathname);
@@ -865,7 +880,7 @@
}
void cos_copy_input_stream(COStream out, CIStream in) {
- if ( in != NULL )
+ if ( in != NULL ) {
if ( is_file_stream(in) ) {
int ch;
while ( (ch = cis_getch(in)) != EOF )
@@ -875,5 +890,6 @@
cos_put_len(out, (const char*)in->next, in->end - in->next);
in->next = in->end;
}
+ }
}
Modified: trunk/fundev/tools/gema/src/cstream.h
==============================================================================
--- trunk/fundev/tools/gema/src/cstream.h (original)
+++ trunk/fundev/tools/gema/src/cstream.h Thu Feb 8 05:57:26 2007
@@ -1,6 +1,6 @@
/* character stream functions */
-/* $Id: cstream.h,v 1.1 2004/03/12 00:42:08 cgay Exp $ */
+/* $Id: cstream.h,v 1.4 1996/04/08 05:05:37 gray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
Modified: trunk/fundev/tools/gema/src/gema.c
==============================================================================
--- trunk/fundev/tools/gema/src/gema.c (original)
+++ trunk/fundev/tools/gema/src/gema.c Thu Feb 8 05:57:26 2007
@@ -1,7 +1,7 @@
/* generalized macro processor */
-/* $Id: gema.c,v 1.1 2004/03/12 00:42:08 cgay Exp $ */
+/* $Id: gema.c,v 1.14 2001/12/15 20:22:13 gray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
@@ -12,10 +12,11 @@
/*
* $Log: gema.c,v $
- * Revision 1.1 2004/03/12 00:42:08 cgay
- * Initial revision
+ * Revision 1.14 2001/12/15 20:22:13 gray
+ * Add new convenience option "-ml" for using "[...]" instead of "<...>"
+ * with HTML, XML, etc.
*
- * Revision 1.13 1995/10/01 23:29:44 gray
+ * Revision 1.13 1995/10/01 23:29:44 gray
* Fix to support MS-DOS wild card expansion with a full pathname.
*
* Revision 1.12 1995/09/29 05:42:18 gray
@@ -257,6 +258,7 @@
#endif
CI "\\N-line\\n=@set-switch{line;1}\n"
CI "\\N-match\\n=@set-switch{match;1}\n"
+CI "\\N-ml\\n=@set-syntax{</>LLL;[|]</>}\n" /* for Markup Language (XML,HTML)*/
#ifdef MSDOS
#if 0 /* doesn't work because causes "\Z" action to be invoked. */
"\\N\\/<L1>\\n=@ARGV{-$1\\n}\n" /* allow "/" instead of "-" */
Added: trunk/fundev/tools/gema/src/gemabuild
==============================================================================
--- (empty file)
+++ trunk/fundev/tools/gema/src/gemabuild Thu Feb 8 05:57:26 2007
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Unix shell script to build "gema", using the compiler options
+# appropriate for the current system.
+
+# $Id: gemabuild,v 1.1 2003/11/02 00:35:35 gray Exp $
+
+if [ "$1" = "clean" -o "$1" = "-clean" ]
+then
+ echo '+ make -f Makefile clean'
+ make -f Makefile clean
+ shift
+fi
+compiler='cc'
+compflags='-O -DNDEBUG'
+sysname=`uname`
+case "$sysname" in
+ AIX*) compiler='cc' ;;
+ OSF1) compiler='cc' ;;
+ IRIX*) compiler='cc' ;;
+ HP-UX*) compiler='cc' ;;
+ SunOS*) if [ -x /opt/SUNWspro/bin/cc ];then compiler='/opt/SUNWspro/bin/cc';else compiler='acc';fi ;;
+ Linux*) compiler='gcc' ; compflags='-Wall -O2 -DNDEBUG' ;;
+ Darwin) compiler='cc' ; compflags='-ansi -Wall -O2 -DNDEBUG' ;;
+ *) echo 'Unrecognized system "'$sysname'"; trying using "gcc".'; compiler=gcc;;
+esac
+uname -a
+date
+set -x
+make -f Makefile "CC=$compiler" "CCFLAGS=$compflags" gema "$@"
+if [ -x gema ]
+then
+ GEMA=`pwd`/gema
+ cd ../test
+ ./gematest $GEMA
+else
+ echo Build failed.
+fi
Modified: trunk/fundev/tools/gema/src/match.c
==============================================================================
--- trunk/fundev/tools/gema/src/match.c (original)
+++ trunk/fundev/tools/gema/src/match.c Thu Feb 8 05:57:26 2007
@@ -1,7 +1,7 @@
/* pattern matching */
-/* $Id: match.c,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: match.c,v 1.21 2004/09/18 22:57:06 dngray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
@@ -10,21 +10,32 @@
an acknowledgment of the original source.
*********************************************************************/
-/* $Log: match.c,v $
- * Revision 1.1 2004/03/12 00:42:09 cgay
- * Initial revision
- *
-/* Revision 1.17 1996/04/21 00:34:48 gray
-/* Use new `goal_state' structure to pass additional context information for
-/* goal match; this allows access to previous arguments and the correct local
-/* mode for case sensitivity. New function `match_to_stream' combines common
-/* code for matching on variables and previous arguments; fixed to respect
-/* case-insensitive option. Also support case-insensitive comparison for the
-/* terminator of a recognizer or recursive argument. Don't automatically skip
-/* whitespace at the beginning of a template. For domain with default rule
-/* ``=@fail'', don't match an empty string if delimiter found immediately.
-/* Minor improvement of trace messages.
/*
+ * $Log: match.c,v $
+ * Revision 1.21 2004/09/18 22:57:06 dngray
+ * Allow MAX_DOMAINS to be larger than 255
+ * (merged changes contributed by Alex Karahalios).
+ *
+ * Revision 1.20 2003/11/02 00:03:46 gray
+ * Moved some trace-related variable declarations to "pattern.h".
+ *
+ * Revision 1.19 2003/09/06 00:36:03 gray
+ * Don't match empty string at EOF when default rule is ``=@fail''.
+ *
+ * Revision 1.18 2001/12/15 20:22:23 gray
+ * Clean up compiler warnings.
+ *
+ * Revision 1.17 1996/04/08 05:23:04 gray
+ * Use new `goal_state' structure to pass additional context information for
+ * goal match; this allows access to previous arguments and the correct local
+ * mode for case sensitivity. New function `match_to_stream' combines common
+ * code for matching on variables and previous arguments; fixed to respect
+ * case-insensitive option. Also support case-insensitive comparison for the
+ * terminator of a recognizer or recursive argument. Don't automatically skip
+ * whitespace at the beginning of a template. For domain with default rule
+ * ``=@fail'', don't match an empty string if delimiter found immediately.
+ * Minor improvement of trace messages.
+ *
* Revision 1.16 1995/09/29 04:09:44 gray
* Fix `trace' format on MS-DOS.
*
@@ -183,9 +194,8 @@
#include <stdarg.h>
#include <limits.h>
-static int trace_indent = 0;
-static struct { int level; long line; int column; int ch; int domain; }
- trace_enter = {INT_MAX,0,0,0,-1};
+int trace_indent = 0;
+struct trace_enter_struct trace_enter = {INT_MAX,0,0,0,-1};
static char*
show_char(int ch) {
static char buf[6];
@@ -251,7 +261,6 @@
#define TRACE_FAILURE(string) if(trace_switch) trace(&marker,FAIL,string)
#else
-#define trace_switch FALSE
#define TRACE_FAILURE(string)
#endif
@@ -388,7 +397,13 @@
goto success;
assert( next_arg[0] == NULL );
outbuf = make_buffer_output_stream();
+#if MAX_DOMAINS < 256
domain = *++ps - 1;
+#else
+ /* Get domain index as 14 bit little endian number */
+ domain = ((unsigned char)*++ps)&0x7f;
+ domain = ((((unsigned char)*++ps)&0x7f)<<7) | domain;
+#endif
if ( !marker.marked ) {
cis_mark(in,&marker.start);
marker.marked = TRUE;
@@ -856,6 +871,20 @@
static int global_options;
Pattern current_rule = NULL;
+/* does the domain have a default rule "=@fail"? */
+static boolean
+default_fail( Domain domainpt )
+{
+ Pattern tailpat;
+ tailpat = domainpt->patterns.tail;
+ if ( tailpat == NULL ) {
+ return FALSE;
+ }
+ else return ( tailpat->pattern[0] == PT_END && /* empty template */
+ tailpat->action[0] == PT_OP &&
+ tailpat->action[1] == OP_FAIL );
+}
+
static boolean
try_match( CIStream in, Pattern pat, COStream out, Goal goal )
{
@@ -986,6 +1015,7 @@
if ( goal_info == NULL ) {
goal = NULL;
goal_char = ENDOP;
+ alt_goal_char = ENDOP; /* just to avoid warning from Gnu compiler */
}
else {
goal = goal_info->template;
@@ -1026,8 +1056,14 @@
for ( ; translation_status == Translate_Complete ; ) {
Domain idp;
ch = cis_peek(in);
- if ( ch == EOF )
- break; /* done */
+ if ( ch == EOF ) {
+ /* For a domain whose default rule is ``=@fail'',
+ an argument should not match an empty string just
+ because the end of file is found before starting. */
+ if( !( beginning && default_fail(domainpt) ) ) {
+ break; /* done */
+ }
+ }
else if ( goal_char != ENDOP ) {
if ( ((unsigned)ch) == goal_char || ((unsigned)ch) == alt_goal_char ||
(goal_char == UPOP(PT_SPACE) && isspace(ch) &&
@@ -1039,19 +1075,15 @@
|| /* use general pattern matching */
try_pattern( in, goal, NULL, goal_info->args,
goal_info->options, NULL ) ) {
- Pattern tailpat;
/* For a domain whose default rule is ``=@fail'',
an argument should not match an empty string just
because the terminator is found before starting. */
- if( !( beginning && NULL != ( tailpat = domainpt->patterns.tail ) &&
- tailpat->pattern[0] == PT_END && /* empty template */
- tailpat->action[0] == PT_OP &&
- tailpat->action[1] == OP_FAIL ) )
+ if( !( beginning && default_fail(domainpt) ) )
break;
}
}
- beginning = FALSE;
}
+ beginning = FALSE;
for ( idp = domainpt ; idp != NULL ; idp = idp->inherits )
if ( try_patterns( ch, in, NULL, &idp->patterns, out, goal_info ) ) {
/* match found */
Modified: trunk/fundev/tools/gema/src/patimp.h
==============================================================================
--- trunk/fundev/tools/gema/src/patimp.h (original)
+++ trunk/fundev/tools/gema/src/patimp.h Thu Feb 8 05:57:26 2007
@@ -1,7 +1,7 @@
/* pattern implementation internal declarations */
-/* $Id: patimp.h,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: patimp.h,v 1.10 2004/09/18 22:58:58 dngray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
@@ -26,29 +26,29 @@
#define PT_SKIP_WHITE_SPACE '\6' /* skip optional white space */
#define PT_SPECIAL_ARG '\7' /* predefined recognition domains */
/* note: skip over codes 08..0D for whitspace control */
-#define PT_WORD_DELIM '\x0E' /* word delimiter */
-#define PT_ID_DELIM '\x0F' /* identifier delimiter */
-#define PT_AUX '\x10' /* extended opcode PTX_... */
-#define PT_REGEXP '\x11' /* argument as regular expression */
-#define PT_MATCH_ONE '\x12' /* match a single character */
+#define PT_WORD_DELIM ((char)0x0E) /* word delimiter */
+#define PT_ID_DELIM ((char)0x0F) /* identifier delimiter */
+#define PT_AUX ((char)0x10) /* extended opcode PTX_... */
+#define PT_REGEXP ((char)0x11) /* argument as regular expression */
+#define PT_MATCH_ONE ((char)0x12) /* match a single character */
#if 0
-#define PT_ARG_DELIM '\x13' /* command line argument delimiter */
+#define PT_ARG_DELIM ((char)0x13) /* command line argument delimiter */
#endif
/* operations in actions: */
-#define PT_PUT_ARG '\x14' /* output argument value */
- /* skip over '\x15' for EBCDIC NewLine */
-#define PT_DOMAIN '\x16' /* translate argument in another domain */
-#define PT_SEPARATOR '\x17' /* separates arguments */
-#define PT_OP '\x18' /* operator prefix, followed by OP_... */
-#define PT_VAR1 '\x19' /* value of variable with 1 letter name */
-#define PT_MATCHED_TEXT '\x1A' /* output all the matched text */
- /* note: skip over '\x1B' for Escape character */
+#define PT_PUT_ARG ((char)0x14) /* output argument value */
+ /* skip over ((char)0x15) for EBCDIC NewLine */
+#define PT_DOMAIN ((char)0x16) /* translate argument in another domain */
+#define PT_SEPARATOR ((char)0x17) /* separates arguments */
+#define PT_OP ((char)0x18) /* operator prefix, followed by OP_... */
+#define PT_VAR1 ((char)0x19) /* value of variable with 1 letter name */
+#define PT_MATCHED_TEXT ((char)0x1A) /* output all the matched text */
+ /* note: skip over ((char)0x1B) for Escape character */
-#define PT_ONE_OPT '\x1C' /* optimized "?" argument */
+#define PT_ONE_OPT ((char)0x1C) /* optimized "?" argument */
/* special flag used during undefinition: */
-#define PT_UNDEF '\x1F' /* undefine the pattern */
+#define PT_UNDEF ((char)0x1F) /* undefine the pattern */
/* extended template opcodes following PT_AUX: */
#define PTX_INIT '\1' /* beginning-of-domain processing */
@@ -58,8 +58,8 @@
#define PTX_ONE_LINE '\5' /* set line mode for this template */
#define PTX_NO_CASE '\6' /* case insensitive mode for this template */
#define PTX_POSITION '\7' /* mark ending position of input stream */
-#define PTX_NO_GOAL '\x08' /* don't use rest as argument terminator */
-#define PTX_JOIN '\x09' /* concatenate (override token mode) */
+#define PTX_NO_GOAL ((char)0x08)/* don't use rest as argument terminator */
+#define PTX_JOIN ((char)0x09) /* concatenate (override token mode) */
enum Operators {
OP_NONE, /* skip 0 */
@@ -190,7 +190,10 @@
Domain inherits;
};
-#define MAX_DOMAINS 200
+/* Maximum number of domains. This may be modified as needed. */
+#ifndef MAX_DOMAINS
+#define MAX_DOMAINS 240
+#endif
extern int ndomains;
Modified: trunk/fundev/tools/gema/src/pattern.h
==============================================================================
--- trunk/fundev/tools/gema/src/pattern.h (original)
+++ trunk/fundev/tools/gema/src/pattern.h Thu Feb 8 05:57:26 2007
@@ -1,4 +1,4 @@
-/* $Id: pattern.h,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: pattern.h,v 1.6 2003/11/02 00:03:37 gray Exp $ */
#ifndef PATTERN_H
#define PATTERN_H
@@ -49,6 +49,17 @@
boolean set_syntax( int type, const char* char_set );
+#ifdef TRACE
+/* Compile with -DTRACE to enable use of the -trace option */
+extern boolean trace_switch;
+extern int trace_indent;
+struct trace_enter_struct
+{ int level; long line; int column; int ch; int domain; };
+extern struct trace_enter_struct trace_enter;
+#else
+#define trace_switch FALSE
+#endif
+
#if 0
#define Arg_Delim '\0'
#endif
Modified: trunk/fundev/tools/gema/src/read.c
==============================================================================
--- trunk/fundev/tools/gema/src/read.c (original)
+++ trunk/fundev/tools/gema/src/read.c Thu Feb 8 05:57:26 2007
@@ -1,7 +1,7 @@
/* read pattern definitions */
-/* $Id: read.c,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: read.c,v 1.20 2004/09/18 22:57:06 dngray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
@@ -10,18 +10,27 @@
an acknowledgment of the original source.
*********************************************************************/
-/* $Log: read.c,v $
- * Revision 1.1 2004/03/12 00:42:09 cgay
- * Initial revision
+/*
+ * $Log: read.c,v $
+ * Revision 1.20 2004/09/18 22:57:06 dngray
+ * Allow MAX_DOMAINS to be larger than 255
+ * (merged changes contributed by Alex Karahalios).
+ *
+ * Revision 1.19 2001/12/15 20:22:44 gray
+ * Modify use of hex character constants to work-around a compiler bug on
+ * DEC Alpha OSF1. Clean up compiler warnings..
+ *
+ * Revision 1.18 2001/09/30 23:10:20 gray
+ * Fix uninitialized variable in skip_comment.
+ *
+ * Revision 1.17 1996/04/08 05:29:56 gray
+ * Fixed initialization of `fnnargs' so that ${varname} always works even when
+ * @var has never been used. Fixed interaction of comment and continuation
+ * lines. If the first line of a pattern file begins with "#!", ignore that
+ * line so that pattern files can be made directly executable. When '=' is
+ * missing, discard incomplete rule to avoid other errors. Warn when template
+ * begins with recursive argument in same domain (will just overflow stack).
*
-/* Revision 1.17 1996/04/21 00:37:37 gray
-/* Fixed initialization of `fnnargs' so that ${varname} always works even when
-/* @var has never been used. Fixed interaction of comment and continuation
-/* lines. If the first line of a pattern file begins with "#!", ignore that
-/* line so that pattern files can be made directly executable. When '=' is
-/* missing, discard incomplete rule to avoid other errors. Warn when template
-/* begins with recursive argument in same domain (will just overflow stack).
-/*
* Revision 1.16 1995/08/27 21:03:46 gray
* Fix handling of space between identifiers with "-t" or "-w".
* Fix to not be prevented from using dispatch table when template begins with
@@ -250,7 +259,9 @@
#endif
int ndomains = 0;
-
+#if MAX_DOMAINS > (1<<14)
+ #error "MAX_DOMAINS is too large; must fit in 14 bits."
+#endif
Domain domains[MAX_DOMAINS] = { NULL };
char* trim_name( unsigned char* x ) {
@@ -282,6 +293,7 @@
if ( ndomains >= MAX_DOMAINS ) {
fprintf(stderr,"More than %d domain names; aborting.\n", MAX_DOMAINS);
exit((int)EXS_SYNTAX);
+ return -1; /* just to avoid warning from SGI compiler */
}
else {
Patterns p;
@@ -464,23 +476,23 @@
case 'r': pc = '\r'; break;
case 'v': pc = '\v'; break;
case 's': pc = ' '; break;
-#if 'A' == '\x41'
- case 'e': pc = '\x1B' ; break; /* ASCII Escape */
- case 'd': pc = '\x7F' ; break; /* ASCII Delete */
+#if 'A' == 0x41
+ case 'e': pc = ((char)0x1B) ; break; /* ASCII Escape */
+ case 'd': pc = ((char)0x7F) ; break; /* ASCII Delete */
case 'c': { /* control */
int xc;
xc = cis_getch(s);
pc = toupper(xc) ^ 0x40;
break;
}
-#elif 'A' == '\xC1'
- case 'e': pc = '\x27' ; break; /* EBCDIC Escape */
- case 'd': pc = '\x07' ; break; /* EBCDIC Delete */
+#elif 'A' == 0xC1
+ case 'e': pc = ((char)0x27) ; break; /* EBCDIC Escape */
+ case 'd': pc = ((char)0x07) ; break; /* EBCDIC Delete */
#endif
#if 0 /* not needed */
/* the following two are the same in ASCI and EBCDIC */
- case 'o': pc = '\x0E' ; break; /* shift out */
- case 'i': pc = '\x0F' ; break; /* shift in */
+ case 'o': pc = ((char)0x0E) ; break; /* shift out */
+ case 'i': pc = ((char)0x0F) ; break; /* shift in */
#endif
case 'x': {
char cbuf[4];
@@ -572,6 +584,7 @@
input_error(in, EXS_SYNTAX, "More than %d unique regular expressions.\n",
MAX_NUM_REGEXP);
exit(exit_status);
+ return -1; /* just to avoid warning from SGI compiler */
}
else {
struct regex_struct* p;
@@ -596,9 +609,10 @@
}
else {
input_error(in, EXS_SYNTAX, "Error in regular expression: %s\n", msg);
- if ( keep_going )
- return intern_regexp( (unsigned char*)"\1", in );
- else exit(exit_status);
+ if ( ! keep_going ) {
+ exit(exit_status);
+ }
+ return intern_regexp( (unsigned char*)"\1", in );
}
}
return last_regex;
@@ -831,6 +845,7 @@
static boolean
skip_comment( CIStream s ) {
int ch;
+ ch = 0;
for ( ; ; ) {
int nc;
nc = cis_getch(s);
@@ -854,11 +869,13 @@
read_action( CIStream s, unsigned char* bp, int nargs,
unsigned char* arg_keys ) {
unsigned char* ap;
- int ch; /* character read */
- int pc; /* code for action */
enum char_kinds kind;
for ( ap = bp ; ; ) {
+ int pc; /* code for action */
+ int ch; /* character read */
+
ch = cis_getch(s);
+ pc = ch; /* just to avoid warning from Gnu compiler */
kind = char_kind(ch);
dispatch:
switch ( kind ) {
@@ -935,7 +952,12 @@
#if 1
int domain = find_domain(name);
*ap++ = PT_DOMAIN;
+#if MAX_DOMAINS < 256
*ap++ = (unsigned char)(domain + 1);
+#else
+ *ap++ = (unsigned char)((domain & 0x7f)|0x80);
+ *ap++ = (unsigned char)(((domain>>7) & 0x7f)|0x80);
+#endif
if ( char_kind(xc) == PI_BEGIN_ARG ) {
int term_kind;
int term_char;
@@ -1119,7 +1141,7 @@
ap = &bp[BUFSIZE/2];
}
*ap++ = (unsigned char)pc;
- }
+ } /* end for */
} /* end read_action */
static unsigned char*
@@ -1178,6 +1200,7 @@
prev_bp = start_bp;
start_bp = bp;
ch = cis_getch(s);
+ pc = ch; /* just to avoid warning from Gnu compiler */
kind = char_kind(ch);
dispatch:
switch (kind) {
@@ -1256,7 +1279,11 @@
"Domain change \"%s%c\" not allowed in temporary pattern.\n",
name, ch);
else
+#if MAX_DOMAINS < 256
*domainpt = name[0] == PT_RECUR ? name[1]-1 : find_domain( name );
+#else
+ *domainpt = name[0] == PT_RECUR ? (unsigned int)(name[1]&0x7f) | (unsigned int)((name[2]&0x7f)<<7) : find_domain( name );
+#endif
bp = pbuf;
domain_seen = TRUE;
continue;
@@ -1298,15 +1325,30 @@
nargs++;
arg_keys[nargs] = (unsigned char)ch;
if ( kind == PI_RARG ) {
- pc = *domainpt + 1;
+ int domain = *domainpt;
*bp++ = PT_RECUR;
+#if MAX_DOMAINS < 256
+ pc = domain + 1;
+#else
+ /* Save low byte of domain index */
+ *bp++ = (unsigned char)((domain &0x7f)|0x80);
+ pc = ((domain>>7) & 0x7f)|0x80;
+#endif
}
else if ( kind == PI_ABBREV_DOMAIN ) {
+ int domain;
char aname[2];
aname[0] = ch;
aname[1] = '\0';
- pc = 1 + find_domain(aname);
+ domain = find_domain(aname);
*bp++ = PT_RECUR;
+#if MAX_DOMAINS < 256
+ pc = 1 + domain;
+#else
+ /* Save low byte of domain index */
+ *bp++ = (unsigned char)((domain &0x7f)|0x80);
+ pc = (((unsigned int)domain>>7) & 0x7f)|0x80;
+#endif
}
else if ( kind == PI_BEGIN_DOMAIN_ARG ) {
int xc;
@@ -1350,8 +1392,15 @@
*bp++ = parms;
}
else { /* user-defined domain */
- pc = 1 + find_domain( dname );
+ int domain = find_domain( dname );
*bp++ = PT_RECUR;
+#if MAX_DOMAINS < 256
+ pc = 1 + domain;
+#else
+ /* Save low byte of domain index */
+ *bp++ = (unsigned char)((domain & 0x7f)|0x80);
+ pc = ((domain>>7) & 0x7f)|0x80;
+#endif
}
break;
}
@@ -1359,7 +1408,6 @@
input_error(s, EXS_SYNTAX, "Error: unmatched '%c'\n", ch);
bp = xp;
goto done;
- break;
}
*xp = (unsigned char)xc;
}
@@ -1418,7 +1466,7 @@
case PI_QUOTE:
case PI_ESC: {
bp = escaped_char(ch,bp,s);
- if ( start_bp > pbuf )
+ if ( start_bp > pbuf ) {
if ( *start_bp == PT_AUX ) {
if ( start_bp[1] == PTX_INIT || start_bp[1] == PTX_BEGIN_FILE )
input_error(s, EXS_SYNTAX,
@@ -1431,6 +1479,7 @@
else if ( *start_bp == *prev_bp && *prev_bp == PT_ID_DELIM )
/* delete redundancy */
bp = start_bp;
+ }
continue;
}
@@ -1859,7 +1908,14 @@
if ( key == PT_QUOTE )
key = *rest++;
else if ( is_operator(key) ) {
- if ( key == PT_RECUR && patset == &domains[rest[0]-1]->patterns )
+ if ( key == PT_RECUR
+#if MAX_DOMAINS < 256
+ && patset == &domains[rest[0]-1]->patterns
+#else
+ && patset == &domains[(unsigned int)(rest[0]&0x7f)
+ |(unsigned int)((rest[1]&0x7f)<<7)]->patterns
+#endif
+ )
/* template beginning with recursive arg in same domain is
going to get stack overflow */
input_error(input_stream, EXS_SYNTAX, "Unbounded recursion.\n");
Modified: trunk/fundev/tools/gema/src/reg-expr.c
==============================================================================
--- trunk/fundev/tools/gema/src/reg-expr.c (original)
+++ trunk/fundev/tools/gema/src/reg-expr.c Thu Feb 8 05:57:26 2007
@@ -253,9 +253,10 @@
tagc = 1, /* actual tag count */
n, c1, c2;
- if (pat==NULL || *pat=='\0')
+ if (pat==NULL || *pat=='\0') {
if (pattern_compiled) CHECK_RETURN();
else badpat("No previous regular expression");
+ }
pattern_compiled = FALSE;
for (p = pat; *p; p++)
@@ -281,7 +282,7 @@
p++;
c1 = *(p-2) +1; /* 'b' since 'a' already put into bittab */
c2 = *p++; /* 'z' */
- /* if (c1>c2) badpat("Empty set"); /* tried something like z-a */
+ /* if (c1>c2) badpat("Empty set"); */ /* tried something like z-a */
while (c1<=c2) chset(c1++); /* build bit table */
}
#ifdef EXTEND
@@ -455,7 +456,7 @@
#define CHRSKIP 3 /* CLO CHR chr END ... */
#define SETSKIP (2 +BITBLK) /* CLO SET 16bytes END ... */
-static CHAR *pmatch (CHAR *lp, char *dfa)
+static CHAR *pmatch (CHAR *lp, CHAR *dfa)
{
CHAR
*e, /* extra pointer for CLO */
@@ -527,11 +528,12 @@
dfa += n;
while (lp >= are) /* backup up till match next pattern */
{
- if (e = pmatch(lp,dfa)) return e;
+ e = pmatch(lp,dfa);
+ if ( e ) return e;
--lp;
}
return NULL;
- default: regexp_fail((unsigned char*)"regexp_exec: bad dfa.",op);
+ default: regexp_fail((unsigned char*)"regexp_exec: bad dfa.",(CHAR)op);
return NULL;
}
return lp;
@@ -554,7 +556,7 @@
if (!regexp_bopat[0]) return FALSE;
- while (c = *src++)
+ while ( (c = *src++) )
{
switch(c)
{
Modified: trunk/fundev/tools/gema/src/reg-expr.h
==============================================================================
--- trunk/fundev/tools/gema/src/reg-expr.h (original)
+++ trunk/fundev/tools/gema/src/reg-expr.h Thu Feb 8 05:57:26 2007
@@ -143,7 +143,7 @@
* matches: foo-foo fo-fo fob-fob foobar-foobar ...
*/
-/* $Id: reg-expr.h,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: reg-expr.h,v 1.2 1993/05/07 06:59:27 hbs Exp $ */
#ifndef REG_EXPR_DOT_H
#define REG_EXPR_DOT_H
Modified: trunk/fundev/tools/gema/src/util.c
==============================================================================
--- trunk/fundev/tools/gema/src/util.c (original)
+++ trunk/fundev/tools/gema/src/util.c Thu Feb 8 05:57:26 2007
@@ -1,5 +1,5 @@
-/* $Id: util.c,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: util.c,v 1.3 1995/02/27 23:29:14 gray Exp $ */
#include <stdio.h>
#include <stdlib.h>
Modified: trunk/fundev/tools/gema/src/util.h
==============================================================================
--- trunk/fundev/tools/gema/src/util.h (original)
+++ trunk/fundev/tools/gema/src/util.h Thu Feb 8 05:57:26 2007
@@ -1,12 +1,12 @@
-/* $Id: util.h,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: util.h,v 1.7 2001/12/15 20:23:20 gray Exp $ */
/*
* $Log: util.h,v $
- * Revision 1.1 2004/03/12 00:42:09 cgay
- * Initial revision
+ * Revision 1.7 2001/12/15 20:23:20 gray
+ * Work around a name conflict on Linux.
*
- * Revision 1.6 1995/07/04 23:43:33 gray
+ * Revision 1.6 1995/07/04 23:43:33 gray
* When on Macintosh, use ':' as the directory delimiter.
*
* Revision 1.5 1995/05/22 02:52:28 gray
@@ -32,6 +32,12 @@
MemoryVar, MemoryPath, MemoryRegexp, MemoryDispatch
} Memory_Kinds;
+#ifdef __linux__
+/* On Linux, change the name of this to avoid some sort of compiler or
+ linker confusion when optimized. */
+#define allocate gema_mem_alloc
+#endif
+
/* allocate memory space; does not return unless succesful */
void* allocate( size_t size, Memory_Kinds what );
Modified: trunk/fundev/tools/gema/src/var.c
==============================================================================
--- trunk/fundev/tools/gema/src/var.c (original)
+++ trunk/fundev/tools/gema/src/var.c Thu Feb 8 05:57:26 2007
@@ -1,7 +1,7 @@
/* variables */
-/* $Id: var.c,v 1.1 2004/03/12 00:42:09 cgay Exp $ */
+/* $Id: var.c,v 1.3 1996/04/08 05:24:06 gray Exp $ */
/*********************************************************************
This file is part of "gema", the general-purpose macro translator,
Modified: trunk/fundev/tools/gema/src/version.c
==============================================================================
--- trunk/fundev/tools/gema/src/version.c (original)
+++ trunk/fundev/tools/gema/src/version.c Thu Feb 8 05:57:26 2007
@@ -1,4 +1,4 @@
-/* $Id: version.c,v 1.1 2004/03/12 00:42:10 cgay Exp $ */
+/* $Id: version.c,v 1.24 2004/12/29 00:11:26 dngray Exp $ */
/* Version identification string
@@ -11,9 +11,7 @@
can be distinguished from the original version.
*/
-const char what_string [] = "@(#)gema 1.3 April 7, 1996";
+const char what_string [] = "@(#)gema 1.3.4 Dec 28, 2004";
-
-/* this is just so it will appear in "strings" output: */
-const char author [] = "David N. Gray <DGray at acm.org>";
+const char author [] = "@(#) David N. Gray <DGray at acm.org>";
Added: trunk/fundev/tools/gema/test/gematest
==============================================================================
--- (empty file)
+++ trunk/fundev/tools/gema/test/gematest Thu Feb 8 05:57:26 2007
@@ -0,0 +1,21 @@
+
+# test script for gema on Unix
+# $Id: gematest,v 1.1 2003/11/02 00:22:37 gray Exp $
+
+GEMA=${1:-./gema}
+rm -f /tmp/pattest*.out
+$GEMA -version -f testpat.dat testin.dat /tmp/pattest.out
+diff testout.dat /tmp/pattest.out
+$GEMA -f testpat.dat -i -idchars "-_" -out /tmp/pattest2.out test2.dat
+diff test2out.dat /tmp/pattest2.out
+echo '@Cgroups(foo.c,v )' | \
+ $GEMA -f testpat.dat -filechars '.,:/\\-_' -out /tmp/pattest3.out -in -
+diff test3out.dat /tmp/pattest3.out
+$GEMA -t -f testtok.dat testin.dat /tmp/pattest4.out
+diff testout.dat /tmp/pattest4.out
+$GEMA -t -w -match -f testtw.dat -odir /tmp -otyp .out test5in.dat
+diff test5out.dat /tmp/test5in.out
+
+# test 6 is for new features and bug fixes since version 1.3
+$GEMA -ml -f test6pat.dat test6in.dat > /tmp/pattest6.out
+diff test6out.dat /tmp/pattest6.out
Added: trunk/fundev/tools/gema/test/gematest.bat
==============================================================================
--- (empty file)
+++ trunk/fundev/tools/gema/test/gematest.bat Thu Feb 8 05:57:26 2007
@@ -0,0 +1,17 @@
+ at echo off
+REM "gema" test script for MS-DOS or Windows
+REM $Id: gematest.bat,v 1.1 2003/11/02 00:22:47 gray Exp $
+erase test.out
+erase test2.out
+erase test3.out
+erase test4.out
+gema -version -f testpat.dat testin.dat test.out
+fc testout.dat test.out
+gema -f testpat.dat -i -idchars "-_" -out test2.out test2.dat
+fc test2out.dat test2.out
+gema -f testpat.dat -filechars ".,:/\\-_" -out test3.out -in - < test3.dat
+fc test3out.dat test3.out
+gema -t -f testtok.dat testin.dat test4.out
+fc testout.dat test4.out
+GEMA -T -W -MATCH -F TESTTW.DAT -ODIR %TEMP% -OTYP .OUT TEST5IN.DAT
+fc test5out.dat %TEMP%\test5in.out
Modified: trunk/fundev/tools/gema/test/test
==============================================================================
--- trunk/fundev/tools/gema/test/test (original)
+++ trunk/fundev/tools/gema/test/test Thu Feb 8 05:57:26 2007
@@ -1,6 +1,6 @@
# test script for Unix
-# $Header: /scm/cvs/fundev/tools/gema/test/test,v 1.1 2004/03/12 00:42:10 cgay Exp $
+# $Header: /cvsroot/gema/gema/test/test,v 1.3 1995/07/27 05:39:54 gray Exp $
rm -f /tmp/pattest*.out
./gema -version -f testpat.dat testin.dat /tmp/pattest.out
Modified: trunk/fundev/tools/gema/test/test.bat
==============================================================================
--- trunk/fundev/tools/gema/test/test.bat (original)
+++ trunk/fundev/tools/gema/test/test.bat Thu Feb 8 05:57:26 2007
@@ -1,5 +1,5 @@
REM "gema" test script for MS-DOS
-REM $Id: test.bat,v 1.1 2004/03/12 00:42:10 cgay Exp $
+REM $Id: test.bat,v 1.3 1995/08/07 03:24:31 gray Exp $
erase test.out
erase test2.out
erase test3.out
Added: trunk/fundev/tools/gema/test/test6in.dat
==============================================================================
--- (empty file)
+++ trunk/fundev/tools/gema/test/test6in.dat Thu Feb 8 05:57:26 2007
@@ -0,0 +1,4 @@
+
+int foo(int a);
+
+apple orange
Added: trunk/fundev/tools/gema/test/test6out.dat
==============================================================================
--- (empty file)
+++ trunk/fundev/tools/gema/test/test6out.dat Thu Feb 8 05:57:26 2007
@@ -0,0 +1,4 @@
+
+int <font color=red>foo</font>(int a);
+
+apple orange
Added: trunk/fundev/tools/gema/test/test6pat.dat
==============================================================================
--- (empty file)
+++ trunk/fundev/tools/gema/test/test6pat.dat Thu Feb 8 05:57:26 2007
@@ -0,0 +1,18 @@
+
+! this pattern file assumes that the "-ml" option is in effect.
+
+[I] [I]\W[arglist][body]=$1 <font color\=red>$2</font>$3$4
+
+arglist:([matchparen])=$0 at end
+arglist:=@fail
+
+body:[S]=$1
+body:\;=\;@end
+body:\{[matchparen]\}=$0 at end
+
+matchparen:(#)=(#)
+matchparen:\[#\]=\[#\]
+
+[I]=$1
+[S]=$1
+
Modified: trunk/fundev/tools/gema/test/testpat.dat
==============================================================================
Binary files. No diff available.
Modified: trunk/fundev/tools/gema/test/testtok.dat
==============================================================================
Binary files. No diff available.
More information about the chatter
mailing list