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

@@ -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;
}