bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoiding confusion with local skeleton


From: Paul Hilfinger
Subject: Avoiding confusion with local skeleton
Date: Fri, 24 May 2002 20:50:48 -0700

Here's a small issue I raised awhile ago.  If one happens to be a
bison developer and has a file named bison.simple in one's directory,
m4 goes for it rather than the installed skeleton.  Assuming this to 
undesirable, I suggest the following patch.  I haven't addressed the 
handling of m4sugar.m4 because it is not clear to me how I should handle 
m4sugar/version.m4, which is included by that name from the middle of
m4sugar/m4sugar.m4 (and therefore uses the -I directory).

I had thought of using chdir to switch the current directory to
bison_pkgdatadir, but it occurs to me that this might change the
handling of TMPDIR, if present.

OK to commit?

Paul Hilfinger

2002-05-24  Paul Hilfinger  <address@hidden>

        * src/output.c (output_skeleton): Put an explicit path in front of
        the skeleton file name, rather than relying on the -I directory,
        to partially alleviate effects of having a skeleton file lying around
        in the current directory.

Index: 2.39/src/output.c
--- 2.39/src/output.c Thu, 16 May 2002 16:30:36 -0700 hilfingr 
(glrbison/48_output.c 1.1.1.5 644)
+++ 2.39(w)/src/output.c Fri, 24 May 2002 20:38:10 -0700 hilfingr 
(glrbison/48_output.c 1.1.1.5 644)
@@ -1150,20 +1150,30 @@ output_skeleton (void)
   {
     const char *bison_pkgdatadir = getenv ("BISON_PKGDATADIR");
     const char *m4 = getenv ("M4");
+    int pkg_data_len;
+    char *full_skeleton;
+
     if (!m4)
       m4 = M4;
     if (!bison_pkgdatadir)
       bison_pkgdatadir = PKGDATADIR;
+    pkg_data_len = strlen (bison_pkgdatadir);
+    full_skeleton = XMALLOC (char, pkg_data_len + strlen (skeleton) + 1);
+    if (bison_pkgdatadir[pkg_data_len-1] == '/')
+      sprintf (full_skeleton, "%s%s", bison_pkgdatadir, skeleton);
+    else
+      sprintf (full_skeleton, "%s/%s", bison_pkgdatadir, skeleton);
     if (trace_flag)
       fprintf (stderr,
               "running: %s -I %s m4sugar/m4sugar.m4 %s %s\n",
-              m4, bison_pkgdatadir, tempfile, skeleton);
+              m4, bison_pkgdatadir, tempfile, full_skeleton);
     skel_in = readpipe (m4,
                        "-I", bison_pkgdatadir,
                        "m4sugar/m4sugar.m4",
                        tempfile,
-                       skeleton,
+                       full_skeleton,
                        NULL);
+    XFREE (full_skeleton);
     if (!skel_in)
       error (EXIT_FAILURE, errno, "cannot run m4");
     skel_lex ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]