]> git.draconx.ca Git - rrace.git/commitdiff
Use new packed option format from gen-options.awk.
authorNick Bowler <nbowler@draconx.ca>
Sun, 8 Jan 2023 05:41:32 +0000 (00:41 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 9 Jan 2023 03:41:09 +0000 (22:41 -0500)
This new format uses a compact, fully constant array to generate the
real struct option array at runtime.  This allows the full-sized array
to be dropped after command-line processing is finished, and with
position-independent executables, reduces the amount of relocation
processing needed.

Makefile.am
common
src/curses.c
src/motif.c

index 88fde3c718a5872bef7f4bf7b662bd8578b91c18..d9c0c445a44ce16412d57c40c0b5380872f6059a 100644 (file)
@@ -34,7 +34,8 @@ endif
 
 EXTRA_DIST += doc/rrace-motif.1
 
-noinst_HEADERS = conf_post.h src/version.h src/icon.h src/ewmhicon.h
+noinst_HEADERS = conf_post.h src/version.h src/icon.h src/ewmhicon.h \
+                 common/src/xtra.h
 
 rrace_curses_SOURCES = common/src/help.c src/game.c src/version.c
 rrace_curses_LDADD = $(libcursesmain_a_OBJECTS) $(CURSES_LIBS) $(GNULIB)
diff --git a/common b/common
index 203a69fab1ff61e958dfb88599fd5d7f24648abf..e599119f0492b01f1f21a8cce8d695c314dab3b1 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 203a69fab1ff61e958dfb88599fd5d7f24648abf
+Subproject commit e599119f0492b01f1f21a8cce8d695c314dab3b1
index 2d9ef64a64aceb3075608ef6ed91cd6c3dc28e90..46f0d7e8f29f476d5e716275603996a50584a88a 100644 (file)
@@ -24,6 +24,7 @@
 #include <curses.h>
 
 #include "help.h"
+#include "xtra.h"
 #include "version.h"
 
 #include "cursesui.h"
@@ -34,7 +35,6 @@ enum {
 };
 
 static const char *progname = "rrace";
-static const struct option lopts[] = { LOPTS_INITIALIZER, {0} };
 
 static struct app_state state;
 
@@ -53,7 +53,7 @@ static void print_usage(FILE *f)
                fprintf(f, "Try %s --help for more information.\n", progname);
 }
 
-static void print_help(void)
+static void print_help(const struct option *lopts)
 {
        struct lopt_help help = {0};
        const struct option *opt;
@@ -292,6 +292,8 @@ static void app_initialize(int argc, char **argv)
        int enable_mouse = 1;
        int opt;
 
+       XTRA_PACKED_LOPTS(lopts);
+
        if (argc > 0)
                progname = argv[0];
 
@@ -307,7 +309,7 @@ static void app_initialize(int argc, char **argv)
                        print_version();
                        exit(EXIT_SUCCESS);
                case LOPT_HELP:
-                       print_help();
+                       print_help(lopts);
                        exit(EXIT_SUCCESS);
                default:
                        print_usage(stderr);
index e3ff6c22c587337792b36afc621a49c8511404cf..8b0fa4113d9139e6019abc8ced27fac3485b8859 100644 (file)
@@ -25,6 +25,7 @@
 #include <Xm/XmAll.h>
 
 #include "help.h"
+#include "xtra.h"
 #include "motif.h"
 #include "ewmhicon.h"
 #include "motifopt.h"
@@ -40,7 +41,6 @@
 
 #define PROGNAME "rrace"
 static const char *progname = PROGNAME;
-static const struct option lopts[] = { LOPTS_INITIALIZER, {0} };
 
 static char * const default_resources[] = {
        "*title: RRace",
@@ -76,7 +76,7 @@ static void print_usage(FILE *f)
                fprintf(f, "Try %s --help for more information.\n", progname);
 }
 
-static void print_help(void)
+static void print_help(const struct option *lopts)
 {
        struct lopt_help help = {0};
        const struct option *opt;
@@ -100,6 +100,8 @@ static Widget early_setup(XtAppContext *app, int argc, char **argv)
        Widget shell;
        int opt;
 
+       XTRA_PACKED_LOPTS(lopts);
+
        /* Check for --help/--version early (before X connection) */
        opterr = 0;
        while ((opt = getopt_long_only(argc, argv, "", lopts, NULL)) != -1) {
@@ -108,7 +110,7 @@ static Widget early_setup(XtAppContext *app, int argc, char **argv)
                        print_version();
                        exit(EXIT_SUCCESS);
                case LOPT_HELP:
-                       print_help();
+                       print_help(lopts);
                        exit(EXIT_SUCCESS);
                }
        }