[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
--print-datadir
From: |
Joel E. Denny |
Subject: |
--print-datadir |
Date: |
Sat, 29 Sep 2007 21:03:21 -0400 (EDT) |
It seems convenient to be able to write scripts such as:
bison --report=all --xml test.y
xsltproc `bison --print-datadir`/xslt/xml2xhtml.xsl test.xml > test.html
I wrote the following patch to implement --print-datadir, but I haven't
yet committed it. Does anyone see a better way to do this?
By the way, I combine --report=all and --xml to get the full report in XML
format, but why should the .output file be generated at the same time?
Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1730
diff -p -u -r1.1730 ChangeLog
--- ChangeLog 29 Sep 2007 22:36:37 -0000 1.1730
+++ ChangeLog 30 Sep 2007 00:45:21 -0000
@@ -1,5 +1,18 @@
2007-09-29 Joel E. Denny <address@hidden>
+ Implement --print-datadir.
+ * src/getargs.c (usage): Mention.
+ (PRINT_DATADIR_OPTION): New anonymous enum member.
+ (long_options): Add entry for it.
+ (getargs): Add case for it calling compute_pkgdatadir.
+ * src/output.c (output_skeleton): Encapsulate data directory
+ computation from here...
+ (prepare): ... and from here...
+ (compute_pkgdatadir): ... into here.
+ *src/output.h (compute_pkgdatadir): Prototype.
+
+2007-09-29 Joel E. Denny <address@hidden>
+
* src/print-xml.c (escape_bufs): New static global variable
replacing...
(xml_escape_n): ... the static local variable buf here.
Index: src/getargs.c
===================================================================
RCS file: /sources/bison/bison/src/getargs.c,v
retrieving revision 1.96
diff -p -u -r1.96 getargs.c
--- src/getargs.c 25 Sep 2007 05:47:26 -0000 1.96
+++ src/getargs.c 30 Sep 2007 00:45:21 -0000
@@ -21,6 +21,7 @@
#include <config.h>
#include "system.h"
#include "revision.h"
+#include "output.h"
#include <argmatch.h>
#include <c-strcase.h>
@@ -261,6 +262,7 @@ Operation modes:\n\
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
--print-localedir output directory containing locale-dependent
data\n\
+ --print-datadir output directory containing skeletons and XSLT\n\
-y, --yacc emulate POSIX Yacc\n\
\n\
"), stdout);
@@ -393,7 +395,8 @@ static char const short_options[] = "yve
enum
{
LOCATIONS_OPTION = CHAR_MAX + 1,
- PRINT_LOCALEDIR_OPTION
+ PRINT_LOCALEDIR_OPTION,
+ PRINT_DATADIR_OPTION
};
static struct option const long_options[] =
@@ -402,6 +405,7 @@ static struct option const long_options[
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'V' },
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
+ { "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
{ "warnings", optional_argument, 0, 'W' },
/* Parser. */
@@ -555,6 +559,10 @@ getargs (int argc, char *argv[])
printf ("%s\n", LOCALEDIR);
exit (EXIT_SUCCESS);
+ case PRINT_DATADIR_OPTION:
+ printf ("%s\n", compute_pkgdatadir ());
+ exit (EXIT_SUCCESS);
+
default:
usage (EXIT_FAILURE);
}
Index: src/output.c
===================================================================
RCS file: /sources/bison/bison/src/output.c,v
retrieving revision 1.269
diff -p -u -r1.269 output.c
--- src/output.c 25 Sep 2007 05:47:26 -0000 1.269
+++ src/output.c 30 Sep 2007 00:45:21 -0000
@@ -482,7 +482,7 @@ output_skeleton (void)
char *full_skeleton;
char const *p;
char const *m4 = (p = getenv ("M4")) ? p : M4;
- char const *pkgdatadir = (p = getenv ("BISON_PKGDATADIR")) ? p : PKGDATADIR;
+ char const *pkgdatadir = compute_pkgdatadir ();
size_t skeleton_size = strlen (skeleton) + 1;
size_t pkgdatadirlen = strlen (pkgdatadir);
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
@@ -602,12 +602,10 @@ prepare (void)
/* About the skeletons. */
{
- char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
would never be expanded. Hopefully no one has M4-special characters in
his Bison installation path. */
- MUSCLE_INSERT_STRING_RAW ("pkgdatadir",
- pkgdatadir ? pkgdatadir : PKGDATADIR);
+ MUSCLE_INSERT_STRING_RAW ("pkgdatadir", compute_pkgdatadir ());
}
}
@@ -633,3 +631,10 @@ output (void)
obstack_free (&format_obstack, NULL);
}
+
+char const *
+compute_pkgdatadir (void)
+{
+ char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
+ return pkgdatadir ? pkgdatadir : PKGDATADIR;
+}
Index: src/output.h
===================================================================
RCS file: /sources/bison/bison/src/output.h,v
retrieving revision 1.16
diff -p -u -r1.16 output.h
--- src/output.h 15 Aug 2007 20:21:30 -0000 1.16
+++ src/output.h 30 Sep 2007 00:45:21 -0000
@@ -21,5 +21,6 @@
/* Output the parsing tables and the parser code to FTABLE. */
void output (void);
+char const *compute_pkgdatadir (void);
#endif /* !OUTPUT_H_ */
- --print-datadir,
Joel E. Denny <=