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.
-# Copyright © 2018, 2021 Nick Bowler
+# Copyright © 2018, 2021, 2023 Nick Bowler
#
# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
# This is free software: you are free to do what the fuck you want to.
#
# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
# This is free software: you are free to do what the fuck you want to.
-slotifier_SOURCES = src/slotifier.c src/options.h \
- common/src/help.c common/src/help.h
+noinst_HEADERS = common/src/help.h common/src/xtra.h
+slotifier_SOURCES = src/slotifier.c src/options.h common/src/help.c
slotifier_LDADD = $(LIBGERBV_LIBS) $(CNEARTREE_LIBS) libgnu.a \
$(LTLIBICONV) $(LTLIBINTL) $(HYPOT_LIBM)
$(slotifier_OBJECTS): $(gnulib_headers)
slotifier_LDADD = $(LIBGERBV_LIBS) $(CNEARTREE_LIBS) libgnu.a \
$(LTLIBICONV) $(LTLIBINTL) $(HYPOT_LIBM)
$(slotifier_OBJECTS): $(gnulib_headers)
-Subproject commit 6bba07ea3a95f69fcb47457dde0970a72eecbcee
+Subproject commit e599119f0492b01f1f21a8cce8d695c314dab3b1
/*
* Utility to convert overlapping Excellon drill hits into drill slots.
/*
* Utility to convert overlapping Excellon drill hits into drill slots.
- * Copyright © 2018, 2021 Nick Bowler
+ * Copyright © 2018, 2021, 2023 Nick Bowler
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <locale.h>
#include <assert.h>
#include <locale.h>
#include <CNearTree.h>
#include <gerbv.h>
#include <CNearTree.h>
#include <gerbv.h>
#if !ENABLE_NLS
# undef ENABLE_NLS
#if !ENABLE_NLS
# undef ENABLE_NLS
static const char *progname = "slotifier";
static unsigned verbose;
static const char *progname = "slotifier";
static unsigned verbose;
-#include "options.h"
-static const char sopts[] = SOPT_STRING;
-static const struct option lopts[] = {
- LOPTS_INITIALIZER,
- {0}
-};
-
static void print_version(void)
{
const char *copysign = "(C)";
static void print_version(void)
{
const char *copysign = "(C)";
- printf("Copyright %s 2021 Nick Bowler.\n", copysign);
+ printf("Copyright %s 2023 Nick Bowler.\n", copysign);
puts("License GPLv3+: GNU GPL version 3 or any later version.");
puts("This is free software: you are free to change and redistribute it.");
puts("There is NO WARRANTY, to the extent permitted by law.");
puts("License GPLv3+: GNU GPL version 3 or any later version.");
puts("This is free software: you are free to change and redistribute it.");
puts("There is NO WARRANTY, to the extent permitted by law.");
-static void print_help(void)
+static void print_help(const struct option *lopts)
{
const struct option *opt;
{
const struct option *opt;
-int main(int argc, char **argv)
+static int do_cmdline(int argc, char **argv, const char **outfile)
- const char *outfile = "/dev/stdout";
- gerbv_project_t *gp;
- gerbv_image_t *drill;
- int opt, ret = 0;
+ const char *sopts = SOPT_STRING;
+ int opt;
+
+ XTRA_PACKED_LOPTS(lopts);
if (argc > 0)
progname = argv[0];
if (argc > 0)
progname = argv[0];
while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (opt) {
case 'o':
while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (opt) {
case 'o':
break;
case 'v':
verbose++;
break;
case 'V':
print_version();
break;
case 'v':
verbose++;
break;
case 'V':
print_version();
- print_help();
- return EXIT_SUCCESS;
+ print_help(lopts);
+ return 1;
default:
print_usage(stderr);
default:
print_usage(stderr);
fprintf(stderr, _("%s: error: must specify a filename\n"),
progname);
print_usage(stderr);
fprintf(stderr, _("%s: error: must specify a filename\n"),
progname);
print_usage(stderr);
}
if (optind + 1 < argc) {
fprintf(stderr, _("%s: error: excess command-line arguments\n"),
progname);
print_usage(stderr);
}
if (optind + 1 < argc) {
fprintf(stderr, _("%s: error: excess command-line arguments\n"),
progname);
print_usage(stderr);
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ const char *outfile = "/dev/stdout";
+ gerbv_project_t *gp;
+ gerbv_image_t *drill;
+ int ret = 0;
+
+ init_i18n();
+ switch (do_cmdline(argc, argv, &outfile)) {
+ case -1: return EXIT_FAILURE;
+ case 1: return EXIT_SUCCESS;
}
gp = gerbv_create_project();
}
gp = gerbv_create_project();