[Top][All Lists]

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

PATCH: make sub-includes easier with custom skeletons

From: Anthony Heading
Subject: PATCH: make sub-includes easier with custom skeletons
Date: Sun, 03 Jul 2022 17:15:46 -0400
User-agent: Cyrus-JMAP/3.7.0-alpha0-713-g1f035dc716-fm-20220617.001-g1f035dc7

Another patch I've had lying around for a while...   It's easy to use a custom 
skeleton, just by using the '-S <skeleton>' flag.   But it's harder to 
customize their sub-includes because they have fixed paths, for example in 


Attached patch sets the directory of any custom skeleton, and then the 
b4_skeletonsdir,  as '-I' search-path flags to m4, and makes the c++.m4 include 
path unqualified.

If it makes sense for adoption,  I can change all the various other system 
skeleton files similarly and submit a larger patch as github PR,  but hopefully 
attached (which is all I personally use) is enough to explain the idea.


commit 137b4cacfd100ece3873b974f0ef50ad484cc35b
Author: Anthony Heading <anthony.heading@localhost>
Date:   Fri Aug 27 02:46:29 2021 -0400

    Add the directory of the default system skeleton file to the m4 search path.
    When a user-defined skeleton is used, prepend that path also.  Change
    lalr1.cpp to search for c++.m4 instead of using only the system dir.

diff --git data/skeletons/lalr1.cc data/skeletons/lalr1.cc
index 7cb69d3d..ec0a68ee 100644
--- data/skeletons/lalr1.cc
+++ data/skeletons/lalr1.cc
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # api.value.type=variant is valid.
diff --git src/output.c src/output.c
index 4b1bb0d8..b0c074d7 100644
--- src/output.c
+++ src/output.c
@@ -29,6 +29,7 @@
 #include <spawn-pipe.h>
 #include <timevar.h>
 #include <wait-process.h>
+#include <dirname.h>
 #include "complain.h"
 #include "files.h"
@@ -757,6 +758,13 @@ output_skeleton (void)
     if (*M4_GNU_OPTION)
       argv[i++] = M4_GNU_OPTION;
+    char *userdir = dir_name(skel);
+    if (strcmp(userdir, skeldir)) {
+       argv[i++] = "-I";
+       argv[i++] = userdir;
+    }
+    argv[i++] = "-I";
+    argv[i++] = skeldir;
     argv[i++] = "-I";
     argv[i++] = datadir;
     /* Some future version of GNU M4 (most likely 1.6) may treat the

Attachment: skel.patch
Description: Text Data

reply via email to

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