aboutsummaryrefslogtreecommitdiff
path: root/devel/lemon
diff options
context:
space:
mode:
authorMikhail Teterin <mi@FreeBSD.org>2001-06-08 01:17:53 +0000
committerMikhail Teterin <mi@FreeBSD.org>2001-06-08 01:17:53 +0000
commit53211d2b0d2527da0be385c3550f9c159c88d84a (patch)
treee7a59e6020a8bcdd3c7c51b8b277f0bf619e0cc2 /devel/lemon
parent63fd13b8493decb68a5d31ac5d6f8bdd81ed6e02 (diff)
downloadports-53211d2b0d2527da0be385c3550f9c159c88d84a.tar.gz
ports-53211d2b0d2527da0be385c3550f9c159c88d84a.zip
Make this into a more general tool. Allow to specify the names of the
output files and the location of the template on command line. (Submitting the patches to the author)
Notes
Notes: svn path=/head/; revision=43623
Diffstat (limited to 'devel/lemon')
-rw-r--r--devel/lemon/Makefile1
-rw-r--r--devel/lemon/files/patch-aa110
2 files changed, 95 insertions, 16 deletions
diff --git a/devel/lemon/Makefile b/devel/lemon/Makefile
index b356ade89c08..d69c1560c072 100644
--- a/devel/lemon/Makefile
+++ b/devel/lemon/Makefile
@@ -7,6 +7,7 @@
PORTNAME= lemon
PORTVERSION= 1.0
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://www.hwaci.com/sw/lemon/
DISTFILES= lemon.c lempar.c
diff --git a/devel/lemon/files/patch-aa b/devel/lemon/files/patch-aa
index 663a90cf1cb2..2e4e46d78555 100644
--- a/devel/lemon/files/patch-aa
+++ b/devel/lemon/files/patch-aa
@@ -1,21 +1,93 @@
---- /usr/ports/distfiles/lemon.c Tue Dec 5 20:52:24 2000
-+++ ./lemon.c Mon Jun 4 23:35:15 2001
-@@ -31,2 +31,5 @@
+--- lemon.c Tue Dec 5 20:52:24 2000
++++ lemon.c Thu Jun 7 21:13:39 2001
+@@ -30,10 +30,11 @@
+ #include <string.h>
#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/param.h>
-@@ -35,4 +38,2 @@
+ extern void qsort();
+ extern double strtod();
extern long strtol();
-extern void free();
-extern int access();
extern int atoi();
-@@ -55,3 +56,2 @@
+
+@@ -54,5 +55,4 @@
+
char *msort();
-extern void *malloc();
-@@ -2525,45 +2525,13 @@
+ /******** From the file "action.h" *************************************/
+@@ -1168,4 +1168,26 @@
+ }
+
++static char *lempar_locations[] = {
++ NULL, "lempar.c", LEMPAR
++};
++
++void setlempar(lempar)
++char *lempar;
++{
++ if (access(lempar, R_OK)) {
++ perror(lempar);
++ exit(1);
++ }
++ lempar_locations[0] = lempar;
++}
++
++static char *output_file = NULL;
++
++void setoutput(base)
++char *base;
++{
++ if (output_file = malloc(strlen(base) + 1))
++ sprintf(output_file, "%s.", base);
++}
+
+ /* The main program. Parse the command line and do it... */
+@@ -1185,7 +1207,12 @@
+ {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
+ {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
+- {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file"},
++ {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."},
++ {OPT_FSTR, "o", (char*)setoutput, "Set the dirname/basename for the "
++ "output file(s)."},
+ {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."},
+ {OPT_FLAG, "s", (char*)&statistics, "Print parser stats to standard output."},
++ {OPT_FSTR, "t", (char*)setlempar, "An alternative template -- instead of"
++ " ``./lempar.c''\n\t\tor the system wide ``"
++ LEMPAR"''."},
+ {OPT_FLAG, "x", (char*)&version, "Print the version number."},
+ {OPT_FLAG,0,0,0}
+@@ -2305,4 +2332,5 @@
+ }
+ }
++
+ /*********************** From the file "report.c" **************************/
+ /*
+@@ -2318,13 +2346,14 @@
+ char *suffix;
+ {
+- char *name;
+- char *cp;
++ char *name = NULL;
++ char *cp, *fname;
+
+- name = malloc( strlen(lemp->filename) + strlen(suffix) + 5 );
++ fname = output_file ? output_file : lemp->filename;
++ name = malloc( strlen(fname) + strlen(suffix));
+ if( name==0 ){
+ fprintf(stderr,"Can't allocate space for a filename.\n");
+ exit(1);
+ }
+- strcpy(name,lemp->filename);
++ strcpy(name, fname);
+ cp = strrchr(name,'.');
+ if( cp ) *cp = 0;
+@@ -2524,47 +2553,14 @@
+ }
-/* Search for the file "name" which is in the same directory as
-** the exacutable */
@@ -29,7 +101,8 @@
- char *path,*cp;
- char c;
- extern int access();
-+ const char *path;
++ int i;
++ const char *path = NULL;
-#ifdef __WIN32__
- cp = strrchr(argv0,'\\');
@@ -62,15 +135,15 @@
- }
- }
- return path;
-+ path = getenv("LEMPAR");
-+
-+ if (path)
-+ if (access(path, R_OK)) perror(path);
-+ else return(path);
++ for (i = 0; i < sizeof(lempar_locations)/sizeof(char *); i++)
++ if (lempar_locations[i] && access(lempar_locations[i], R_OK) == 0)
++ return lempar_locations[i];
+
-+ return(LEMPAR);
++ return(NULL);
}
-@@ -2631,6 +2599,5 @@
+
+@@ -2630,8 +2626,7 @@
+ struct lemon *lemp;
{
- static char templatename[] = "lempar.c";
- char buf[1000];
@@ -79,7 +152,9 @@
- char *tpltname;
+ const char *tpltname;
char *cp;
-@@ -2643,10 +2610,9 @@
+
+@@ -2642,12 +2637,11 @@
+ sprintf(buf,"%s.lt",lemp->filename);
}
- if( access(buf,004)==0 ){
+ if( access(buf, R_OK)==0 ){
@@ -93,8 +168,11 @@
- templatename);
+ fprintf(stderr,"Can't find the parser driver template file.\n");
lemp->errorcnt++;
-@@ -2656,3 +2622,3 @@
+ return 0;
+@@ -2655,5 +2649,5 @@
+ in = fopen(tpltname,"r");
if( in==0 ){
- fprintf(stderr,"Can't open the template file \"%s\".\n",templatename);
+ fprintf(stderr,"Can't open the template file \"%s\".\n", tpltname);
lemp->errorcnt++;
+ return 0;