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 this new function.
* src/output.h (compute_pkgdatadir): Prototype.
This commit is contained in:
Joel E. Denny
2007-10-05 02:54:33 +00:00
parent 34cdeddfa5
commit d4bd229569
4 changed files with 34 additions and 6 deletions

View File

@@ -1,3 +1,16 @@
2007-10-04 Joel E. Denny <jdenny@ces.clemson.edu>
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 this new function.
* src/output.h (compute_pkgdatadir): Prototype.
2007-09-29 Joel E. Denny <jdenny@ces.clemson.edu> 2007-09-29 Joel E. Denny <jdenny@ces.clemson.edu>
* src/print-xml.c (escape_bufs): New static global variable * src/print-xml.c (escape_bufs): New static global variable

View File

@@ -21,6 +21,7 @@
#include <config.h> #include <config.h>
#include "system.h" #include "system.h"
#include "revision.h" #include "revision.h"
#include "output.h"
#include <argmatch.h> #include <argmatch.h>
#include <c-strcase.h> #include <c-strcase.h>
@@ -261,6 +262,7 @@ Operation modes:\n\
-h, --help display this help and exit\n\ -h, --help display this help and exit\n\
-V, --version output version information and exit\n\ -V, --version output version information and exit\n\
--print-localedir output directory containing locale-dependent data\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\ -y, --yacc emulate POSIX Yacc\n\
\n\ \n\
"), stdout); "), stdout);
@@ -393,7 +395,8 @@ static char const short_options[] = "yvegxdhr:L:ltknVo:b:p:S:T::W";
enum enum
{ {
LOCATIONS_OPTION = CHAR_MAX + 1, LOCATIONS_OPTION = CHAR_MAX + 1,
PRINT_LOCALEDIR_OPTION PRINT_LOCALEDIR_OPTION,
PRINT_DATADIR_OPTION
}; };
static struct option const long_options[] = static struct option const long_options[] =
@@ -402,6 +405,7 @@ static struct option const long_options[] =
{ "help", no_argument, 0, 'h' }, { "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'V' }, { "version", no_argument, 0, 'V' },
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION }, { "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
{ "warnings", optional_argument, 0, 'W' }, { "warnings", optional_argument, 0, 'W' },
/* Parser. */ /* Parser. */
@@ -555,6 +559,10 @@ getargs (int argc, char *argv[])
printf ("%s\n", LOCALEDIR); printf ("%s\n", LOCALEDIR);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
case PRINT_DATADIR_OPTION:
printf ("%s\n", compute_pkgdatadir ());
exit (EXIT_SUCCESS);
default: default:
usage (EXIT_FAILURE); usage (EXIT_FAILURE);
} }

View File

@@ -482,7 +482,7 @@ output_skeleton (void)
char *full_skeleton; char *full_skeleton;
char const *p; char const *p;
char const *m4 = (p = getenv ("M4")) ? p : M4; 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 skeleton_size = strlen (skeleton) + 1;
size_t pkgdatadirlen = strlen (pkgdatadir); size_t pkgdatadirlen = strlen (pkgdatadir);
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/') while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
@@ -602,12 +602,10 @@ prepare (void)
/* About the skeletons. */ /* About the skeletons. */
{ {
char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
/* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs /* b4_pkgdatadir is used inside m4_include in the skeletons, so digraphs
would never be expanded. Hopefully no one has M4-special characters in would never be expanded. Hopefully no one has M4-special characters in
his Bison installation path. */ his Bison installation path. */
MUSCLE_INSERT_STRING_RAW ("pkgdatadir", MUSCLE_INSERT_STRING_RAW ("pkgdatadir", compute_pkgdatadir ());
pkgdatadir ? pkgdatadir : PKGDATADIR);
} }
} }
@@ -633,3 +631,10 @@ output (void)
obstack_free (&format_obstack, NULL); obstack_free (&format_obstack, NULL);
} }
char const *
compute_pkgdatadir (void)
{
char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
return pkgdatadir ? pkgdatadir : PKGDATADIR;
}

View File

@@ -1,5 +1,6 @@
/* Output the generated parsing program for bison, /* Output the generated parsing program for bison,
Copyright (C) 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002, 2003, 2006, 2007 Free Software Foundation,
Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -21,5 +22,6 @@
/* Output the parsing tables and the parser code to FTABLE. */ /* Output the parsing tables and the parser code to FTABLE. */
void output (void); void output (void);
char const *compute_pkgdatadir (void);
#endif /* !OUTPUT_H_ */ #endif /* !OUTPUT_H_ */