updated libopts to 5.18

This commit is contained in:
Nikos Mavrogiannopoulos
2013-11-05 21:04:56 +01:00
parent 6cfa963a1b
commit e7e29b8396
34 changed files with 1152 additions and 926 deletions
+6 -6
View File
@@ -8,16 +8,16 @@ libopts_a_CPPFLAGS = -I$(top_srcdir)
EXTRA_DIST = \
ag-char-map.h alias.c ao-strs.c \
ao-strs.h autoopts/options.h autoopts/project.h \
autoopts/usage-txt.h autoopts.c autoopts.h \
boolean.c check.c compat/strchr.c \
compat/snprintf.c compat/compat.h compat/windows-config.h \
compat/pathfind.c compat/strdup.c configfile.c \
ao-strs.h autoopts/options.h autoopts/usage-txt.h \
autoopts/project.h autoopts.c autoopts.h \
boolean.c check.c compat/strdup.c \
compat/strchr.c compat/snprintf.c compat/compat.h \
compat/pathfind.c compat/windows-config.h configfile.c \
cook.c COPYING.gplv3 COPYING.lgplv3 \
COPYING.mbsd enum.c env.c \
file.c find.c genshell.c \
genshell.h gettext.h init.c \
load.c m4/libopts.m4 m4/liboptschk.m4 \
load.c m4/liboptschk.m4 m4/libopts.m4 \
MakeDefs.inc makeshell.c nested.c \
numeric.c option-value-type.c option-value-type.h \
option-xat-attribute.c option-xat-attribute.h parse-duration.c \
+6 -6
View File
@@ -1,6 +1,6 @@
/*
* 29 bits for 46 character classifications
* generated by char-mapper on 03/31/13 at 10:41:23
* generated by char-mapper on 07/14/13 at 17:37:05
*
* This file contains the character classifications
* used by AutoGen and AutoOpts for identifying tokens.
@@ -103,7 +103,7 @@
// file-name +dir-sep +suffix
// end-token +nul-byte +whitespace
// end-list-entry +comma +end-token
// set-separator "|+" +end-list-entry
// set-separator "|+-!" +end-list-entry
// signed-number +inversion +dec-digit
// make-script +dollar +newline
// load-line-skip +horiz-white +option-marker
@@ -489,7 +489,7 @@ spn_ag_char_map_chars(char const * p, unsigned int mask_ix)
unsigned char const * v = ag_char_map_spanners[mask_ix];
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
while (v[(unsigned char)*p]) p++;
while (v[(unsigned)*p]) p++;
return (char *)(uintptr_t)p;
}
@@ -499,7 +499,7 @@ brk_ag_char_map_chars(char const * p, unsigned int mask_ix)
unsigned char const * v = ag_char_map_spanners[mask_ix];
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
while ((*p != '\0') && (! v[(unsigned char)*p])) p++;
while ((*p != '\0') && (! v[(unsigned)*p])) p++;
return (char *)(uintptr_t)p;
}
@@ -510,7 +510,7 @@ spn_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix)
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
if (s >= e) e = s + strlen(s);
while ((e > s) && v[(unsigned char)e[-1]]) e--;
while ((e > s) && v[(unsigned)e[-1]]) e--;
return (char *)(uintptr_t)e;
}
@@ -521,7 +521,7 @@ brk_ag_char_map_back(char const * s, char const * e, unsigned int mask_ix)
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
if (s == e) e += strlen(e);
while ((e > s) && (! v[(unsigned char)e[-1]])) e--;
while ((e > s) && (! v[(unsigned)e[-1]])) e--;
return (char *)(uintptr_t)e;
}
#endif /* AG_CHAR_MAP_H_GUARD */
+1 -1
View File
@@ -74,7 +74,7 @@ optionAlias(tOptions * opts, tOptDesc * old_od, unsigned int alias)
new_od = opts->pOptDesc + alias;
if ((unsigned)opts->optCt <= alias) {
fputs(zbad_alias_id, stderr);
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
}
/*
+58 -56
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (ao-strs.c)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:23 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:05 PM by AutoGen 5.18
* From the definitions ao-strs.def
* and the template file strings
*
@@ -38,7 +38,7 @@
*/
#include "ao-strs.h"
char const ao_strs_strtable[6637] =
char const ao_strs_strtable[6633] =
/* 0 */ "-_^\0"
/* 4 */ " %s%s\n\0"
/* 12 */ "auto-options\0"
@@ -130,65 +130,67 @@ char const ao_strs_strtable[6637] =
/* 625 */ "=%1$lu # 0x%1$lX\n\0"
/* 643 */ "stdout\0"
/* 650 */ "%A %B %e, %Y at %r %Z\0"
/* 672 */ "/tmp/use.%lu\0"
/* 685 */ "true\0"
/* 690 */ "<%s type=%s>\0"
/* 703 */ "VERSION\0"
/* 711 */ "#x%02X;\0"
/* 719 */ "OPT_ARG_NEEDED=YES\0"
/* 738 */ "'\\''\0"
/* 743 */ " '%s'\0"
/* 749 */ "\n"
/* 672 */ "%s/use-%u.XXXXXX\0"
/* 689 */ "true\0"
/* 694 */ "<%s type=%s>\0"
/* 707 */ "VERSION\0"
/* 715 */ "#x%02X;\0"
/* 723 */ "OPT_ARG_NEEDED=YES\0"
/* 742 */ "'\\''\0"
/* 747 */ " '%s'\0"
/* 753 */ "\n"
"OPTION_CT=0\n\0"
/* 763 */ "set --\0"
/* 770 */ " ;;\n\n\0"
/* 787 */ " '%c' )\n\0"
/* 803 */ " '%s' )\n\0"
/* 819 */ " '%s' | \\\n\0"
/* 837 */ "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu\0"
/* 880 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
/* 912 */ "# From the %s option definitions\n"
/* 767 */ "set --\0"
/* 774 */ " ;;\n\n\0"
/* 791 */ " '%c' )\n\0"
/* 807 */ " '%s' )\n\0"
/* 823 */ " '%s' | \\\n\0"
/* 841 */ "TMPDIR\0"
/* 848 */ "/tmp\0"
/* 853 */ "%1$s %2$s ; rm -f %2$s\0"
/* 876 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
/* 908 */ "# From the %s option definitions\n"
"#\n\0"
/* 949 */ "echo 'Warning: Cannot load options files' >&2\0"
/* 996 */ "echo 'Warning: Cannot save options files' >&2\0"
/* 1043 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0"
/* 1109 */ "<%1$s type=integer>0x%2$lX</%1$s>\n\0"
/* 1144 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
/* 1175 */ "%1$s_%2$s_MODE='%3$s'\n"
/* 945 */ "echo 'Warning: Cannot load options files' >&2\0"
/* 992 */ "echo 'Warning: Cannot save options files' >&2\0"
/* 1039 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0"
/* 1105 */ "<%1$s type=integer>0x%2$lX</%1$s>\n\0"
/* 1140 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
/* 1171 */ "%1$s_%2$s_MODE='%3$s'\n"
"export %1$s_%2$s_MODE\n\0"
/* 1220 */ "%1$s_%2$s='%3$s'\n"
/* 1216 */ "%1$s_%2$s='%3$s'\n"
"export %1$s_%2$s\n\0"
/* 1255 */ "%1$s_%2$s_CT=%3$d\n"
/* 1251 */ "%1$s_%2$s_CT=%3$d\n"
"export %1$s_%2$s_CT\n\0"
/* 1294 */ "OPTION_CT=%d\n"
/* 1290 */ "OPTION_CT=%d\n"
"export OPTION_CT\n\0"
/* 1325 */ "%1$s_%2$s=%3$s\n"
/* 1321 */ "%1$s_%2$s=%3$s\n"
"export %1$s_%2$s\n\0"
/* 1358 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
/* 1354 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
"export %1$s_%2$s\n\0"
/* 1400 */ " case \"${OPT_CODE}\" in\n\0"
/* 1431 */ " if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n"
/* 1396 */ " case \"${OPT_CODE}\" in\n\0"
/* 1427 */ " if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n"
" echo 'Error: more than %3$d %2$s options'\n"
" echo \"$%1$s_USAGE_TEXT\"\n"
" exit 1\n"
" fi >&2\n\0"
/* 1622 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n"
/* 1618 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n"
" echo %1$s_%2$s has not been set\n"
" exit 1\n"
"} 1>&2\n\0"
/* 1714 */ "test -n \"$%1$s_%2$s\" || {\n"
/* 1710 */ "test -n \"$%1$s_%2$s\" || {\n"
" echo %1$s_%2$s has not been set\n"
" exit 1\n"
"} 1>&2\n\0"
/* 1795 */ " echo \"$%s_%s_TEXT\"\n"
/* 1791 */ " echo \"$%s_%s_TEXT\"\n"
" exit 0\n\0"
/* 1846 */ "\n"
/* 1842 */ "\n"
"# # # # # # # # # #\n"
"#\n"
"# END OF AUTOMATED OPTION PROCESSING\n"
"#\n"
"# # # # # # # # # # -- do not modify this marker --\n\0"
/* 1962 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n"
/* 1958 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n"
" then\n"
" eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
" export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
@@ -203,15 +205,15 @@ char const ao_strs_strtable[6637] =
"unset OPT_NAME || :\n"
"unset OPT_CODE || :\n"
"unset OPT_ARG_VAL || :\n\0"
/* 2341 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
/* 2337 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
" shift\n"
" OPT_ARG=$1\n"
" case \"${OPT_CODE}\" in *=* )\n"
" OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
" OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\0"
/* 2592 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
/* 2588 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
" OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0"
/* 2709 */ "\n"
/* 2705 */ "\n"
"ARG_COUNT=$#\n"
"OPT_PROCESS=true\n"
"OPT_ARG=$1\n"
@@ -224,7 +226,7 @@ char const ao_strs_strtable[6637] =
" OPT_PROCESS=false\n"
" shift\n"
" ;;\n\0"
/* 2916 */ " case \"${OPT_ARG_NEEDED}\" in\n"
/* 2912 */ " case \"${OPT_ARG_NEEDED}\" in\n"
" NO )\n"
" OPT_ARG_VAL=''\n"
" ;;\n"
@@ -252,10 +254,10 @@ char const ao_strs_strtable[6637] =
" fi\n"
" ;;\n"
" esac\n\0"
/* 3695 */ " %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
/* 3691 */ " %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
" OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
" OPT_NAME='%2$s'\n\0"
/* 3819 */ "\n"
/* 3815 */ "\n"
"if test -z \"${%1$s_%2$s}\"\n"
"then\n"
" %1$s_%2$s_CT=0\n"
@@ -265,16 +267,16 @@ char const ao_strs_strtable[6637] =
" %1$s_%2$s_1=${%1$s_%2$s}\n"
" export %1$s_%2$s_CT %1$s_%2$s_1\n"
"fi\n\0"
/* 3977 */ " * )\n"
/* 3973 */ " * )\n"
" OPT_PROCESS=false\n"
" ;;\n"
" esac\n\0"
/* 4034 */ " %1$s_%2$s_CT=0\n"
/* 4030 */ " %1$s_%2$s_CT=0\n"
" OPT_ELEMENT=''\n"
" %1$s_%2$s='%3$s'\n"
" export %1$s_%2$s\n"
" OPT_NAME='%2$s'\n\0"
/* 4175 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
/* 4171 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
" echo 'Error: duplicate %2$s option'\n"
" echo \"$%1$s_USAGE_TEXT\"\n"
" exit 1\n"
@@ -283,7 +285,7 @@ char const ao_strs_strtable[6637] =
" %1$s_%2$s='%3$s'\n"
" export %1$s_%2$s\n"
" OPT_NAME='%2$s'\n\0"
/* 4492 */ "\n"
/* 4488 */ "\n"
"ARG_COUNT=$#\n"
"OPT_ARG=$1\n"
"while [ $# -gt 0 ]\n"
@@ -291,7 +293,7 @@ char const ao_strs_strtable[6637] =
" OPT_ELEMENT=''\n"
" OPT_ARG_VAL=''\n"
" OPT_ARG=${1}\n\0"
/* 4595 */ " case \"${OPT_ARG_NEEDED}\" in\n"
/* 4591 */ " case \"${OPT_ARG_NEEDED}\" in\n"
" NO )\n"
" if [ -n \"${OPT_ARG}\" ]\n"
" then\n"
@@ -336,33 +338,33 @@ char const ao_strs_strtable[6637] =
" fi\n"
" ;;\n"
" esac\n\0"
/* 5749 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
/* 5745 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
" exit 0\n\0"
/* 5823 */ "%s OF %s\n"
/* 5819 */ "%s OF %s\n"
"#\n"
"# From here to the next `-- do not modify this marker --',\n"
"# the text has been generated %s\n\0"
/* 5929 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
/* 5925 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
" export %1$s_%2$s${OPT_ELEMENT}\n\0"
/* 6019 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
/* 6015 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
" echo 'Error: duplicate %2$s option'\n"
" echo \"$%1$s_USAGE_TEXT\"\n"
" exit 1\n"
" fi >&2\n"
" %1$s_%2$s_set=true\n"
" OPT_NAME='%2$s'\n\0"
/* 6278 */ "\n"
/* 6274 */ "\n"
"%1$s_%2$s=${%1$s_%2$s-'%3$s'}\n"
"%1$s_%2$s_set=false\n"
"export %1$s_%2$s\n\0"
/* 6347 */ "\n"
/* 6343 */ "\n"
"%1$s_%2$s=${%1$s_%2$s}\n"
"%1$s_%2$s_set=false\n"
"export %1$s_%2$s\n\0"
/* 6409 */ "# # # # # # # # # # -- do not modify this marker --\n"
/* 6405 */ "# # # # # # # # # # -- do not modify this marker --\n"
"#\n"
"# DO NOT EDIT THIS SECTION\n\0"
/* 6492 */ " * )\n"
/* 6488 */ " * )\n"
" echo Unknown %s: \"${OPT_CODE}\" >&2\n"
" echo \"$%s_USAGE_TEXT\" >&2\n"
" exit 1\n"
+64 -60
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (ao-strs.h)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:23 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:05 PM by AutoGen 5.18
* From the definitions ao-strs.def
* and the template file strings
*
@@ -39,29 +39,29 @@
#ifndef STRINGS_AO_STRS_H_GUARD
#define STRINGS_AO_STRS_H_GUARD 1
/*
* 140 strings in ao_strs_strtable string table
* 142 strings in ao_strs_strtable string table
*/
#define ARG_BREAK_STR (ao_strs_strtable+261)
#define ARG_BREAK_STR_LEN 5
#define ARG_BY_NUM_FMT (ao_strs_strtable+267)
#define ARG_BY_NUM_FMT_LEN 9
#define BOOL_ATR_FMT (ao_strs_strtable+880)
#define BOOL_ATR_FMT (ao_strs_strtable+876)
#define BOOL_ATR_FMT_LEN 31
#define CHK_MAX_COUNT (ao_strs_strtable+1431)
#define CHK_MAX_COUNT (ao_strs_strtable+1427)
#define CHK_MAX_COUNT_LEN 190
#define CHK_MIN_COUNT (ao_strs_strtable+1622)
#define CHK_MIN_COUNT (ao_strs_strtable+1618)
#define CHK_MIN_COUNT_LEN 91
#define CHK_ONE_REQUIRED (ao_strs_strtable+1714)
#define CHK_ONE_REQUIRED (ao_strs_strtable+1710)
#define CHK_ONE_REQUIRED_LEN 80
#define ECHO_N_EXIT (ao_strs_strtable+1795)
#define ECHO_N_EXIT (ao_strs_strtable+1791)
#define ECHO_N_EXIT_LEN 50
#define EMPTY_ARG (ao_strs_strtable+277)
#define EMPTY_ARG_LEN 2
#define END_MARK (ao_strs_strtable+1846)
#define END_MARK (ao_strs_strtable+1842)
#define END_MARK_LEN 115
#define END_OPT_SEL_STR (ao_strs_strtable+280)
#define END_OPT_SEL_STR_LEN 12
#define END_PRE_FMT (ao_strs_strtable+912)
#define END_PRE_FMT (ao_strs_strtable+908)
#define END_PRE_FMT_LEN 36
#define END_SET_TEXT (ao_strs_strtable+293)
#define END_SET_TEXT_LEN 3
@@ -75,15 +75,15 @@
#define EXPORT_ARG_FMT_LEN 17
#define FALSE_STR (ao_strs_strtable+335)
#define FALSE_STR_LEN 5
#define FINISH_LOOP (ao_strs_strtable+1962)
#define FINISH_LOOP (ao_strs_strtable+1958)
#define FINISH_LOOP_LEN 378
#define FLAG_OPT_MARK (ao_strs_strtable+341)
#define FLAG_OPT_MARK_LEN 9
#define FLAG_STR (ao_strs_strtable+351)
#define FLAG_STR_LEN 4
#define INIT_LOPT_STR (ao_strs_strtable+2341)
#define INIT_LOPT_STR (ao_strs_strtable+2337)
#define INIT_LOPT_STR_LEN 250
#define INIT_OPT_STR (ao_strs_strtable+2592)
#define INIT_OPT_STR (ao_strs_strtable+2588)
#define INIT_OPT_STR_LEN 116
#define INVALID_FMT (ao_strs_strtable+356)
#define INVALID_FMT_LEN 10
@@ -97,9 +97,9 @@
#define LONG_OPT_MARK_LEN 10
#define LONG_USE_STR (ao_strs_strtable+396)
#define LONG_USE_STR_LEN 9
#define LOOP_STR (ao_strs_strtable+2709)
#define LOOP_STR (ao_strs_strtable+2705)
#define LOOP_STR_LEN 206
#define LOPT_ARG_FMT (ao_strs_strtable+2916)
#define LOPT_ARG_FMT (ao_strs_strtable+2912)
#define LOPT_ARG_FMT_LEN 778
#define LVL3_CMD (ao_strs_strtable+406)
#define LVL3_CMD_LEN 15
@@ -107,9 +107,9 @@
#define MK_STR_OCT_FMT_LEN 5
#define MORE_STR (ao_strs_strtable+428)
#define MORE_STR_LEN 4
#define MULTI_ARG_FMT (ao_strs_strtable+3695)
#define MULTI_ARG_FMT (ao_strs_strtable+3691)
#define MULTI_ARG_FMT_LEN 123
#define MULTI_DEF_FMT (ao_strs_strtable+3819)
#define MULTI_DEF_FMT (ao_strs_strtable+3815)
#define MULTI_DEF_FMT_LEN 157
#define NESTED_OPT_FMT (ao_strs_strtable+433)
#define NESTED_OPT_FMT_LEN 17
@@ -119,29 +119,29 @@
#define NLSTR_SPACE_FMT_LEN 5
#define NONE_STR (ao_strs_strtable+91)
#define NONE_STR_LEN 4
#define NOT_FOUND_STR (ao_strs_strtable+3977)
#define NOT_FOUND_STR (ao_strs_strtable+3973)
#define NOT_FOUND_STR_LEN 56
#define NO_ARG_NEEDED (ao_strs_strtable+461)
#define NO_ARG_NEEDED_LEN 17
#define NO_LOAD_WARN (ao_strs_strtable+949)
#define NO_LOAD_WARN (ao_strs_strtable+945)
#define NO_LOAD_WARN_LEN 46
#define NO_MULTI_ARG_FMT (ao_strs_strtable+4034)
#define NO_MULTI_ARG_FMT (ao_strs_strtable+4030)
#define NO_MULTI_ARG_FMT_LEN 140
#define NO_SAVE_OPTS (ao_strs_strtable+996)
#define NO_SAVE_OPTS (ao_strs_strtable+992)
#define NO_SAVE_OPTS_LEN 46
#define NO_SGL_ARG_FMT (ao_strs_strtable+4175)
#define NO_SGL_ARG_FMT (ao_strs_strtable+4171)
#define NO_SGL_ARG_FMT_LEN 316
#define NO_SUPPRESS_LOAD (ao_strs_strtable+1043)
#define NO_SUPPRESS_LOAD (ao_strs_strtable+1039)
#define NO_SUPPRESS_LOAD_LEN 65
#define NULL_ATR_FMT (ao_strs_strtable+479)
#define NULL_ATR_FMT_LEN 6
#define NUMB_ATR_FMT (ao_strs_strtable+1109)
#define NUMB_ATR_FMT (ao_strs_strtable+1105)
#define NUMB_ATR_FMT_LEN 34
#define OK_NEED_OPT_ARG (ao_strs_strtable+486)
#define OK_NEED_OPT_ARG_LEN 17
#define ONE_TAB_STR (ao_strs_strtable+504)
#define ONE_TAB_STR_LEN 1
#define ONLY_OPTS_LOOP (ao_strs_strtable+4492)
#define ONLY_OPTS_LOOP (ao_strs_strtable+4488)
#define ONLY_OPTS_LOOP_LEN 102
#define OPEN_CLOSE_FMT (ao_strs_strtable+479)
#define OPEN_CLOSE_FMT_LEN 6
@@ -149,7 +149,7 @@
#define OPEN_XML_FMT_LEN 4
#define OPTION_STR (ao_strs_strtable+511)
#define OPTION_STR_LEN 6
#define OPT_ARG_FMT (ao_strs_strtable+4595)
#define OPT_ARG_FMT (ao_strs_strtable+4591)
#define OPT_ARG_FMT_LEN 1153
#define OPT_END_FMT (ao_strs_strtable+518)
#define OPT_END_FMT_LEN 14
@@ -159,15 +159,13 @@
#define OR_STR_LEN 3
#define PAGER_NAME (ao_strs_strtable+544)
#define PAGER_NAME_LEN 5
#define PAGE_USAGE_FMT (ao_strs_strtable+837)
#define PAGE_USAGE_FMT (ao_strs_strtable+837)
#define PAGE_USAGE_FMT_LEN 42
#define PAGE_USAGE_FMT_LEN 42
#define PAGE_USAGE_TEXT (ao_strs_strtable+5749)
#define PAGE_USAGE_FMT (ao_strs_strtable+853)
#define PAGE_USAGE_FMT_LEN 22
#define PAGE_USAGE_TEXT (ao_strs_strtable+5745)
#define PAGE_USAGE_TEXT_LEN 73
#define PLUS_STR (ao_strs_strtable+550)
#define PLUS_STR_LEN 3
#define PREAMBLE_FMT (ao_strs_strtable+5823)
#define PREAMBLE_FMT (ao_strs_strtable+5819)
#define PREAMBLE_FMT_LEN 105
#define PUTS_FMT (ao_strs_strtable+554)
#define PUTS_FMT_LEN 15
@@ -175,19 +173,19 @@
#define QUOT_APOS_LEN 2
#define QUOT_ARG_FMT (ao_strs_strtable+573)
#define QUOT_ARG_FMT_LEN 4
#define SET_MULTI_ARG (ao_strs_strtable+5929)
#define SET_MULTI_ARG (ao_strs_strtable+5925)
#define SET_MULTI_ARG_LEN 89
#define SET_NO_TEXT_FMT (ao_strs_strtable+1144)
#define SET_NO_TEXT_FMT (ao_strs_strtable+1140)
#define SET_NO_TEXT_FMT_LEN 30
#define SET_OFF_FMT (ao_strs_strtable+578)
#define SET_OFF_FMT_LEN 6
#define SET_TEXT_FMT (ao_strs_strtable+585)
#define SET_TEXT_FMT_LEN 12
#define SGL_ARG_FMT (ao_strs_strtable+6019)
#define SGL_ARG_FMT (ao_strs_strtable+6015)
#define SGL_ARG_FMT_LEN 258
#define SGL_DEF_FMT (ao_strs_strtable+6278)
#define SGL_DEF_FMT (ao_strs_strtable+6274)
#define SGL_DEF_FMT_LEN 68
#define SGL_NO_DEF_FMT (ao_strs_strtable+6347)
#define SGL_NO_DEF_FMT (ao_strs_strtable+6343)
#define SGL_NO_DEF_FMT_LEN 61
#define SHELL_MAGIC (ao_strs_strtable+598)
#define SHELL_MAGIC_LEN 6
@@ -195,49 +193,55 @@
#define SHOW_PROG_ENV_LEN 19
#define SHOW_VAL_FMT (ao_strs_strtable+625)
#define SHOW_VAL_FMT_LEN 17
#define START_MARK (ao_strs_strtable+6409)
#define START_MARK (ao_strs_strtable+6405)
#define START_MARK_LEN 82
#define STDOUT (ao_strs_strtable+643)
#define STDOUT_LEN 6
#define TIME_FMT (ao_strs_strtable+650)
#define TIME_FMT_LEN 21
#define TMPDIR (ao_strs_strtable+841)
#define TMPDIR_LEN 6
#define TMP_FILE_FMT (ao_strs_strtable+672)
#define TMP_FILE_FMT_LEN 16
#define TMP_USAGE_FMT (ao_strs_strtable+672)
#define TMP_USAGE_FMT_LEN 12
#define TRUE_STR (ao_strs_strtable+685)
#define TMP_USAGE_FMT_LEN 16
#define TRUE_STR (ao_strs_strtable+689)
#define TRUE_STR_LEN 4
#define TWO_SPACES_STR (ao_strs_strtable+254)
#define TWO_SPACES_STR_LEN 2
#define TYPE_ATR_FMT (ao_strs_strtable+690)
#define TYPE_ATR_FMT (ao_strs_strtable+694)
#define TYPE_ATR_FMT_LEN 12
#define UNK_OPT_FMT (ao_strs_strtable+6492)
#define UNK_OPT_FMT (ao_strs_strtable+6488)
#define UNK_OPT_FMT_LEN 144
#define VER_STR (ao_strs_strtable+703)
#define VER_STR (ao_strs_strtable+707)
#define VER_STR_LEN 7
#define XML_HEX_BYTE_FMT (ao_strs_strtable+711)
#define XML_HEX_BYTE_FMT (ao_strs_strtable+715)
#define XML_HEX_BYTE_FMT_LEN 7
#define YES_NEED_OPT_ARG (ao_strs_strtable+719)
#define YES_NEED_OPT_ARG (ao_strs_strtable+723)
#define YES_NEED_OPT_ARG_LEN 18
#define apostrophe (ao_strs_strtable+738)
#define apostrophe (ao_strs_strtable+742)
#define apostrophe_LEN 4
#define arg_fmt (ao_strs_strtable+743)
#define arg_fmt (ao_strs_strtable+747)
#define arg_fmt_LEN 5
#define init_optct (ao_strs_strtable+749)
#define init_optct (ao_strs_strtable+753)
#define init_optct_LEN 13
#define set_dash (ao_strs_strtable+763)
#define set_dash (ao_strs_strtable+767)
#define set_dash_LEN 6
#define tmp_dir (ao_strs_strtable+848)
#define tmp_dir_LEN 4
#define zAll (ao_strs_strtable+257)
#define zAll_LEN 3
#define zCfgAO_Flags (ao_strs_strtable+12)
#define zCfgAO_Flags_LEN 12
#define zCfgProg (ao_strs_strtable+25)
#define zCfgProg_LEN 7
#define zEquivMode (ao_strs_strtable+1175)
#define zEquivMode (ao_strs_strtable+1171)
#define zEquivMode_LEN 44
#define zFiveSpaces (ao_strs_strtable+244)
#define zFiveSpaces_LEN 5
#define zFmtFmt (ao_strs_strtable+33)
#define zFmtFmt_LEN 11
#define zFullOptFmt (ao_strs_strtable+1220)
#define zFullOptFmt (ao_strs_strtable+1216)
#define zFullOptFmt_LEN 34
#define zGnuBreak (ao_strs_strtable+45)
#define zGnuBreak_LEN 5
@@ -255,23 +259,23 @@
#define zGnuTimeArg_LEN 4
#define zNone (ao_strs_strtable+91)
#define zNone_LEN 4
#define zOptCookieCt (ao_strs_strtable+1255)
#define zOptCookieCt (ao_strs_strtable+1251)
#define zOptCookieCt_LEN 38
#define zOptCtFmt (ao_strs_strtable+1294)
#define zOptCtFmt (ao_strs_strtable+1290)
#define zOptCtFmt_LEN 30
#define zOptDisabl (ao_strs_strtable+1325)
#define zOptDisabl (ao_strs_strtable+1321)
#define zOptDisabl_LEN 32
#define zOptNumFmt (ao_strs_strtable+1358)
#define zOptNumFmt (ao_strs_strtable+1354)
#define zOptNumFmt_LEN 41
#define zOptionCase (ao_strs_strtable+1400)
#define zOptionCase (ao_strs_strtable+1396)
#define zOptionCase_LEN 30
#define zOptionEndSelect (ao_strs_strtable+770)
#define zOptionEndSelect (ao_strs_strtable+774)
#define zOptionEndSelect_LEN 16
#define zOptionFlag (ao_strs_strtable+787)
#define zOptionFlag (ao_strs_strtable+791)
#define zOptionFlag_LEN 15
#define zOptionFullName (ao_strs_strtable+803)
#define zOptionFullName (ao_strs_strtable+807)
#define zOptionFullName_LEN 15
#define zOptionPartName (ao_strs_strtable+819)
#define zOptionPartName (ao_strs_strtable+823)
#define zOptionPartName_LEN 17
#define zPresetFile (ao_strs_strtable+96)
#define zPresetFile_LEN 37
@@ -321,6 +325,6 @@
#define zTwoSpaces_LEN 2
#define zambig_file (ao_strs_strtable+4)
#define zambig_file_LEN 7
extern char const ao_strs_strtable[6637];
extern char const ao_strs_strtable[6633];
#endif /* STRINGS_AO_STRS_H_GUARD */
+40 -55
View File
@@ -32,65 +32,11 @@
* 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
*/
#ifndef PKGDATADIR
# define PKGDATADIR ""
#endif
static char const zNil[] = "";
static arg_types_t argTypes = { NULL };
static char line_fmt_buf[32];
static bool displayEnum = false;
static char const pkgdatadir_default[] = PKGDATADIR;
static char const * program_pkgdatadir = pkgdatadir_default;
static tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
static tePagerState pagerState = PAGER_STATE_INITIAL;
FILE * option_usage_fp = NULL;
/**
* The number of tab characters to skip when printing continuation lines.
*/
static unsigned int tab_skip_ct = 0;
LOCAL void *
ao_malloc(size_t sz)
{
void * res = malloc(sz);
if (res == NULL) {
fprintf(stderr, zalloc_fail, (int)sz);
exit(EXIT_FAILURE);
}
return res;
}
#undef malloc
#define malloc(_s) ao_malloc(_s)
LOCAL void *
ao_realloc(void *p, size_t sz)
{
void * res = (p == NULL) ? malloc(sz) : realloc(p, sz);
if (res == NULL) {
fprintf(stderr, zrealloc_fail, (int)sz, p);
exit(EXIT_FAILURE);
}
return res;
}
#undef realloc
#define realloc(_p,_s) ao_realloc(_p,_s)
LOCAL char *
ao_strdup(char const *str)
{
char * res = strdup(str);
if (res == NULL) {
fprintf(stderr, zalloc_fail, (int)strlen(str));
exit(EXIT_FAILURE);
}
return res;
}
#undef strdup
#define strdup(_p) ao_strdup(_p)
#ifndef HAVE_PATHFIND
# define pathfind(_p, _n, _m) option_pathfind(_p, _n, _m)
# include "compat/pathfind.c"
@@ -113,6 +59,45 @@ ao_strdup(char const *str)
# include "compat/strchr.c"
#endif
LOCAL void *
ao_malloc(size_t sz)
{
void * res = malloc(sz);
if (res == NULL) {
fprintf(stderr, zalloc_fail, (int)sz);
option_exits(EXIT_FAILURE);
}
return res;
}
#undef malloc
#define malloc(_s) ao_malloc(_s)
LOCAL void *
ao_realloc(void *p, size_t sz)
{
void * res = (p == NULL) ? malloc(sz) : realloc(p, sz);
if (res == NULL) {
fprintf(stderr, zrealloc_fail, (int)sz, p);
option_exits(EXIT_FAILURE);
}
return res;
}
#undef realloc
#define realloc(_p,_s) ao_realloc(_p,_s)
LOCAL char *
ao_strdup(char const *str)
{
char * res = strdup(str);
if (res == NULL) {
fprintf(stderr, zalloc_fail, (int)strlen(str));
option_exits(EXIT_FAILURE);
}
return res;
}
#undef strdup
#define strdup(_p) ao_strdup(_p)
/**
* handle an option.
*
@@ -386,7 +371,7 @@ optionProcess(tOptions * opts, int a_ct, char ** a_v)
if (SELECTED_OPT(od)) {
optionSaveFile(opts);
exit(EXIT_SUCCESS);
option_exits(EXIT_SUCCESS);
}
}
}
+70
View File
@@ -129,8 +129,19 @@
#define SKIP_OPT(p) (((p)->fOptState & OPTST_IMMUTABLE_MASK) != 0)
typedef int tDirection;
/**
* handling option presets. Start with command line and work through
* config settings in reverse order.
*/
#define DIRECTION_PRESET -1
/**
* handling normal options. Start with first config file, then environment
* variables and finally the command line.
*/
#define DIRECTION_PROCESS 1
/**
* An initialzation phase or an option being loaded from program sources.
*/
#define DIRECTION_CALLED 0
#define PROCESSING(d) ((d)>0)
@@ -392,6 +403,65 @@ static char const * program_pkgdatadir;
*/
extern tOptProc optionPrintVersion, optionPagedUsage, optionLoadOpt;
#ifdef AUTOOPTS_INTERNAL
#ifndef PKGDATADIR
# define PKGDATADIR ""
#endif
#define APOSTROPHE '\''
#define OPTPROC_L_N_S (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)
#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
# include <libintl.h>
#endif
typedef struct {
size_t fnm_len;
uint32_t fnm_mask;
char const * fnm_name;
} ao_flag_names_t;
/**
* Automated Options Usage Flags.
* NB: no entry may be a prefix of another entry
*/
#define AOFLAG_TABLE \
_aof_(gnu, OPTPROC_GNUUSAGE ) \
_aof_(autoopts, ~OPTPROC_GNUUSAGE) \
_aof_(no_misuse_usage, OPTPROC_MISUSE ) \
_aof_(misuse_usage, ~OPTPROC_MISUSE ) \
_aof_(compute, OPTPROC_COMPUTE )
#define _aof_(_n, _f) AOUF_ ## _n ## _ID,
typedef enum { AOFLAG_TABLE AOUF_COUNT } ao_flag_id_t;
#undef _aof_
#define _aof_(_n, _f) AOUF_ ## _n = (1 << AOUF_ ## _n ## _ID),
typedef enum { AOFLAG_TABLE } ao_flags_t;
#undef _aof_
static char const zNil[] = "";
static arg_types_t argTypes = { NULL };
static char line_fmt_buf[32];
static bool displayEnum = false;
static char const pkgdatadir_default[] = PKGDATADIR;
static char const * program_pkgdatadir = pkgdatadir_default;
static tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
static tePagerState pagerState = PAGER_STATE_INITIAL;
FILE * option_usage_fp = NULL;
static char const * pz_enum_err_fmt;
tOptions * optionParseShellOptions = NULL;
static char const * shell_prog = NULL;
static char * script_leader = NULL;
static char * script_trailer = NULL;
static char * script_text = NULL;
static bool print_exit = false;
#endif /* AUTOOPTS_INTERNAL */
#endif /* AUTOGEN_AUTOOPTS_H */
/**
* @}
+22 -6
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (options.h)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:30 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:12 PM by AutoGen 5.18
* From the definitions funcs.def
* and the template file options_h
*
@@ -101,15 +101,15 @@
* @{
*/
/// autoopts structure version
#define OPTIONS_STRUCT_VERSION 155648
#define OPTIONS_STRUCT_VERSION 163840
/// autoopts structure version string
#define OPTIONS_VERSION_STRING "38:0:13"
#define OPTIONS_VERSION_STRING "40:0:15"
/// minimum version the autoopts library supports
#define OPTIONS_MINIMUM_VERSION 102400
/// minimum version the autoopts library supports as a string
#define OPTIONS_MIN_VER_STRING "25:0:0"
/// the display version of the autoopts library, as a string
#define OPTIONS_DOTTED_VERSION "38.0"
#define OPTIONS_DOTTED_VERSION "40.0"
/// convert a version/release number pair to an integer value
#define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r))
/// @}
@@ -375,13 +375,16 @@ typedef uint32_t proc_state_mask_t;
#define OPTPROC_PRESETTING 0x080000U
/** proc_state_mask_t - Ignore pzFullUsage, compute usage text */
#define OPTPROC_COMPUTE 0x100000U
/** proc_state_mask_t - Program outputs digested option state for shell scripts.
Usage text always written to stderr */
#define OPTPROC_SHELL_OUTPUT 0x200000U
/** bits in NO_XLAT mask:
* nxlat_opt_cfg nxlat_opt */
#define OPTPROC_NO_XLAT_MASK 0x030000U
/** all bits in proc_state_mask_t masks */
#define OPTPROC_MASK_ALL 0x1FFFFFU
#define OPTPROC_MASK_ALL 0x3FFFFFU
/** no bits in proc_state_mask_t */
#define OPTPROC_NONE 0x000000U
@@ -911,6 +914,19 @@ extern const tOptionValue* optionGetValue(const tOptionValue*, char const*);
extern void optionLoadLine(tOptions*, char const*);
/**
* optionMemberList - Get the list of members of a bit mask set
*
* This converts the OPT_VALUE_name mask value to a allocated string.
* It is the caller's responsibility to free the string.
*
* @param od the set membership option description
*
* @return char* - the names of the set bits
*/
extern char* optionMemberList(tOptDesc *);
/**
* optionNextValue - get the next value from a hierarchical list
*
@@ -1167,7 +1183,7 @@ extern void optionNestedVal(tOptions*, tOptDesc*);
extern void optionNumericVal(tOptions*, tOptDesc*);
extern void optionPagedUsage(tOptions*, tOptDesc*);
extern void optionPagedUsage(tOptions *, tOptDesc *);
extern void optionParseShell(tOptions*);
+2
View File
@@ -71,5 +71,7 @@ typedef int tSuccess;
# define MODE extern
#endif
#define parse_duration option_parse_duration
#endif /* AUTOGEN_PROJECT_H */
/* end of project.h */
+91 -91
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (usage-txt.h)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:28 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:10 PM by AutoGen 5.18
* From the definitions usage-txt.def
* and the template file usage-txt.tpl
*
@@ -362,51 +362,51 @@ do not compile this section.
*/
static void dummy_func(void) {
/* LIBOPTS-MESSAGES: */
#line 60 "../autoopts.c"
#line 67 "../autoopts.c"
puts(_("allocation of %d bytes failed\n"));
#line 86 "../autoopts.c"
#line 93 "../autoopts.c"
puts(_("allocation of %d bytes failed\n"));
#line 53 "../init.c"
puts(_("AutoOpts function called without option descriptor\n"));
#line 89 "../init.c"
#line 90 "../init.c"
puts(_("\tThis exceeds the compiled library version: "));
#line 87 "../init.c"
#line 88 "../init.c"
puts(_("Automated Options Processing Error!\n"
"\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
#line 73 "../autoopts.c"
#line 80 "../autoopts.c"
puts(_("realloc of %d bytes at 0x%p failed\n"));
#line 91 "../init.c"
#line 92 "../init.c"
puts(_("\tThis is less than the minimum library version: "));
#line 121 "../version.c"
puts(_("Automated Options version %s\n"
"\tCopyright (C) 1999-2013 by Bruce Korb - all rights reserved\n"));
#line 310 "../usage.c"
#line 82 "../makeshell.c"
puts(_("(AutoOpts bug): %s.\n"));
#line 90 "../reset.c"
puts(_("optionResetOpt() called, but reset-option not configured"));
#line 329 "../usage.c"
#line 292 "../usage.c"
puts(_("could not locate the 'help' option"));
#line 351 "../autoopts.c"
#line 336 "../autoopts.c"
puts(_("optionProcess() was called with invalid data"));
#line 783 "../usage.c"
#line 747 "../usage.c"
puts(_("invalid argument type specified"));
#line 589 "../find.c"
#line 598 "../find.c"
puts(_("defaulted to option with optional arg"));
#line 76 "../alias.c"
puts(_("aliasing option is out of range."));
#line 229 "../enum.c"
#line 234 "../enum.c"
puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
#line 108 "../find.c"
puts(_(" The following options match:\n"));
#line 290 "../find.c"
#line 293 "../find.c"
puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
#line 161 "../check.c"
puts(_("%s: Command line arguments required\n"));
#line 43 "../alias.c"
puts(_("%d %s%s options allowed\n"));
#line 81 "../makeshell.c"
#line 89 "../makeshell.c"
puts(_("%s error %d (%s) calling %s for '%s'\n"));
#line 293 "../makeshell.c"
#line 301 "../makeshell.c"
puts(_("interprocess pipe"));
#line 168 "../version.c"
puts(_("error: version option argument '%c' invalid. Use:\n"
@@ -415,48 +415,48 @@ static void dummy_func(void) {
"\t'n' - version and full copyright notice\n"));
#line 58 "../check.c"
puts(_("%s error: the '%s' and '%s' options conflict\n"));
#line 214 "../find.c"
#line 217 "../find.c"
puts(_("%s: The '%s' option has been disabled."));
#line 421 "../find.c"
#line 430 "../find.c"
puts(_("%s: The '%s' option has been disabled."));
#line 38 "../alias.c"
puts(_("-equivalence"));
#line 460 "../find.c"
#line 469 "../find.c"
puts(_("%s: illegal option -- %c\n"));
#line 110 "../reset.c"
puts(_("%s: illegal option -- %c\n"));
#line 268 "../find.c"
#line 271 "../find.c"
puts(_("%s: illegal option -- %s\n"));
#line 746 "../find.c"
#line 755 "../find.c"
puts(_("%s: illegal option -- %s\n"));
#line 118 "../reset.c"
puts(_("%s: illegal option -- %s\n"));
#line 332 "../find.c"
#line 335 "../find.c"
puts(_("%s: unknown vendor extension option -- %s\n"));
#line 154 "../enum.c"
#line 159 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
#line 164 "../enum.c"
#line 169 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
#line 782 "../usage.c"
#line 746 "../usage.c"
puts(_("%s error: invalid option descriptor for %s\n"));
#line 1110 "../usage.c"
#line 1080 "../usage.c"
puts(_("%s error: invalid option descriptor for %s\n"));
#line 379 "../find.c"
#line 385 "../find.c"
puts(_("%s: invalid option name: %s\n"));
#line 518 "../find.c"
#line 527 "../find.c"
puts(_("%s: The '%s' option requires an argument.\n"));
#line 171 "../autoopts.c"
#line 156 "../autoopts.c"
puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
"\t'%s' and '%s'."));
#line 94 "../check.c"
puts(_("%s error: The %s option is required\n"));
#line 623 "../find.c"
#line 632 "../find.c"
puts(_("%s: The '%s' option cannot have an argument.\n"));
#line 151 "../check.c"
puts(_("%s: Command line arguments are not allowed.\n"));
#line 531 "../save.c"
#line 535 "../save.c"
puts(_("error %d (%s) creating %s\n"));
#line 229 "../enum.c"
#line 234 "../enum.c"
puts(_("%s error: '%s' does not match any %s keywords.\n"));
#line 93 "../reset.c"
puts(_("%s error: The '%s' option requires an argument.\n"));
@@ -466,7 +466,7 @@ static void dummy_func(void) {
puts(_("error %d (%s) stat-ing %s\n"));
#line 143 "../restore.c"
puts(_("%s error: no saved option state\n"));
#line 246 "../autoopts.c"
#line 231 "../autoopts.c"
puts(_("'%s' is not a command line option.\n"));
#line 114 "../time.c"
puts(_("%s error: '%s' is not a recognizable date/time.\n"));
@@ -478,41 +478,41 @@ static void dummy_func(void) {
puts(_("%s error: The %s option must appear %d times.\n"));
#line 157 "../numeric.c"
puts(_("%s error: '%s' is not a recognizable number.\n"));
#line 195 "../enum.c"
#line 200 "../enum.c"
puts(_("%s error: %s exceeds %s keyword count\n"));
#line 366 "../usage.c"
#line 329 "../usage.c"
puts(_("Try '%s %s' for more information.\n"));
#line 45 "../alias.c"
puts(_("one %s%s option allowed\n"));
#line 195 "../makeshell.c"
#line 203 "../makeshell.c"
puts(_("standard output"));
#line 930 "../makeshell.c"
#line 938 "../makeshell.c"
puts(_("standard output"));
#line 304 "../usage.c"
#line 274 "../usage.c"
puts(_("standard output"));
#line 451 "../usage.c"
#line 414 "../usage.c"
puts(_("standard output"));
#line 660 "../usage.c"
#line 624 "../usage.c"
puts(_("standard output"));
#line 175 "../version.c"
puts(_("standard output"));
#line 304 "../usage.c"
#line 274 "../usage.c"
puts(_("standard error"));
#line 451 "../usage.c"
#line 414 "../usage.c"
puts(_("standard error"));
#line 660 "../usage.c"
#line 624 "../usage.c"
puts(_("standard error"));
#line 175 "../version.c"
puts(_("standard error"));
#line 195 "../makeshell.c"
#line 203 "../makeshell.c"
puts(_("write"));
#line 930 "../makeshell.c"
#line 938 "../makeshell.c"
puts(_("write"));
#line 303 "../usage.c"
#line 273 "../usage.c"
puts(_("write"));
#line 450 "../usage.c"
#line 413 "../usage.c"
puts(_("write"));
#line 659 "../usage.c"
#line 623 "../usage.c"
puts(_("write"));
#line 174 "../version.c"
puts(_("write"));
@@ -528,70 +528,70 @@ static void dummy_func(void) {
puts(_("%s warning: cannot save options - %s not regular file\n"));
#line 256 "../save.c"
puts(_("%s warning: cannot save options - %s not regular file\n"));
#line 530 "../save.c"
#line 534 "../save.c"
puts(_("%s warning: cannot save options - %s not regular file\n"));
/* END-LIBOPTS-MESSAGES */
/* USAGE-TEXT: */
#line 908 "../usage.c"
puts(_("\t\t\t\t- an alternate for '%s'\n"));
#line 1177 "../usage.c"
puts(_("Version, usage and configuration options:"));
#line 959 "../usage.c"
puts(_("\t\t\t\t- default option for unnamed options\n"));
#line 872 "../usage.c"
puts(_("\t\t\t\t- an alternate for '%s'\n"));
#line 1147 "../usage.c"
puts(_("Version, usage and configuration options:"));
#line 923 "../usage.c"
puts(_("\t\t\t\t- default option for unnamed options\n"));
#line 836 "../usage.c"
puts(_("\t\t\t\t- disabled as '--%s'\n"));
#line 1146 "../usage.c"
#line 1116 "../usage.c"
puts(_(" --- %-14s %s\n"));
#line 1144 "../usage.c"
#line 1114 "../usage.c"
puts(_("This option has been disabled"));
#line 899 "../usage.c"
#line 863 "../usage.c"
puts(_("\t\t\t\t- enabled by default\n"));
#line 40 "../alias.c"
puts(_("%s error: only "));
#line 1221 "../usage.c"
#line 1193 "../usage.c"
puts(_(" - examining environment variables named %s_*\n"));
#line 168 "../file.c"
puts(_("\t\t\t\t- file must not pre-exist\n"));
#line 172 "../file.c"
puts(_("\t\t\t\t- file must pre-exist\n"));
#line 416 "../usage.c"
#line 379 "../usage.c"
puts(_("Options are specified by doubled hyphens and their name or by a single\n"
"hyphen and the flag character.\n"));
#line 908 "../makeshell.c"
#line 916 "../makeshell.c"
puts(_("\n"
"= = = = = = = =\n\n"
"This incarnation of genshell will produce\n"
"a shell script to parse the options for %s:\n\n"));
#line 161 "../enum.c"
#line 166 "../enum.c"
puts(_(" or an integer mask with any of the lower %d bits set\n"));
#line 932 "../usage.c"
#line 896 "../usage.c"
puts(_("\t\t\t\t- is a set membership option\n"));
#line 953 "../usage.c"
#line 917 "../usage.c"
puts(_("\t\t\t\t- must appear between %d and %d times\n"));
#line 418 "../usage.c"
#line 381 "../usage.c"
puts(_("Options are specified by single or double hyphens and their name.\n"));
#line 939 "../usage.c"
#line 903 "../usage.c"
puts(_("\t\t\t\t- may appear multiple times\n"));
#line 926 "../usage.c"
#line 890 "../usage.c"
puts(_("\t\t\t\t- may not be preset\n"));
#line 1336 "../usage.c"
#line 1308 "../usage.c"
puts(_(" Arg Option-Name Description\n"));
#line 1272 "../usage.c"
#line 1244 "../usage.c"
puts(_(" Flg Arg Option-Name Description\n"));
#line 1330 "../usage.c"
#line 1302 "../usage.c"
puts(_(" Flg Arg Option-Name Description\n"));
#line 1331 "../usage.c"
#line 1303 "../usage.c"
puts(_(" %3s %s"));
#line 1337 "../usage.c"
#line 1309 "../usage.c"
puts(_(" %3s %s"));
#line 423 "../usage.c"
#line 386 "../usage.c"
puts(_("The '-#<number>' option may omit the hash char\n"));
#line 419 "../usage.c"
#line 382 "../usage.c"
puts(_("All arguments are named options.\n"));
#line 1006 "../usage.c"
#line 970 "../usage.c"
puts(_(" - reading file %s"));
#line 445 "../usage.c"
#line 408 "../usage.c"
puts(_("\n"
"Please send bug reports to: <%s>\n"));
#line 100 "../version.c"
@@ -600,17 +600,17 @@ static void dummy_func(void) {
#line 129 "../version.c"
puts(_("\n"
"Please send bug reports to: <%s>\n"));
#line 938 "../usage.c"
#line 902 "../usage.c"
puts(_("\t\t\t\t- may NOT appear - preset only\n"));
#line 978 "../usage.c"
#line 943 "../usage.c"
puts(_("\n"
"The following option preset mechanisms are supported:\n"));
#line 1219 "../usage.c"
#line 1191 "../usage.c"
puts(_("\n"
"The following option preset mechanisms are supported:\n"));
#line 717 "../usage.c"
#line 681 "../usage.c"
puts(_("prohibits these options:\n"));
#line 712 "../usage.c"
#line 676 "../usage.c"
puts(_("prohibits the option '%s'\n"));
#line 81 "../numeric.c"
puts(_("%s%ld to %ld"));
@@ -628,28 +628,28 @@ static void dummy_func(void) {
puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
#line 77 "../numeric.c"
puts(_("%sless than or equal to %ld"));
#line 426 "../usage.c"
#line 389 "../usage.c"
puts(_("Operands and options may be intermixed. They will be reordered.\n"));
#line 687 "../usage.c"
#line 651 "../usage.c"
puts(_("requires the option '%s'\n"));
#line 690 "../usage.c"
#line 654 "../usage.c"
puts(_("requires these options:\n"));
#line 1348 "../usage.c"
#line 1320 "../usage.c"
puts(_(" Arg Option-Name Req? Description\n"));
#line 1342 "../usage.c"
#line 1314 "../usage.c"
puts(_(" Flg Arg Option-Name Req? Description\n"));
#line 162 "../enum.c"
#line 167 "../enum.c"
puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
"will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
"will set them all. Multiple entries may be passed as an option\n"
"argument list.\n"));
#line 945 "../usage.c"
#line 909 "../usage.c"
puts(_("\t\t\t\t- may appear up to %d times\n"));
#line 72 "../enum.c"
#line 77 "../enum.c"
puts(_("The valid \"%s\" option keywords are:\n"));
#line 1181 "../usage.c"
#line 1151 "../usage.c"
puts(_("The next option supports vendor supported extra options:"));
#line 808 "../usage.c"
#line 772 "../usage.c"
puts(_("These additional options are:"));
/* END-USAGE-TEXT */
}
+19 -73
View File
@@ -8,7 +8,7 @@
static char *
pathfind( char const * path,
char const * fileName,
char const * fname,
char const * mode );
#include "compat.h"
@@ -16,10 +16,10 @@ pathfind( char const * path,
#if defined(__windows__) && !defined(__CYGWIN__)
static char *
pathfind( char const * path,
char const * fileName,
char const * fname,
char const * mode )
{
return NULL;
return strdup(fname);
}
#else
@@ -27,69 +27,21 @@ static char* make_absolute( char const *string, char const *dot_path );
static char* canonicalize_pathname( char *path );
static char* extract_colon_unit( char* dir, char const *string, int *p_index );
/*=export_func pathfind
*
* what: fild a file in a list of directories
*
* ifndef: HAVE_PATHFIND
*
* arg: + char const* + path + colon separated list of search directories +
* arg: + char const* + file + the name of the file to look for +
* arg: + char const* + mode + the mode bits that must be set to match +
*
* ret_type: char*
* ret_desc: the path to the located file
*
* doc:
*
* pathfind looks for a a file with name "FILE" and "MODE" access
* along colon delimited "PATH", and returns the full pathname as a
* string, or NULL if not found. If "FILE" contains a slash, then
* it is treated as a relative or absolute path and "PATH" is ignored.
*
* @strong{NOTE}: this function is compiled into @file{libopts} only if
* it is not natively supplied.
*
* The "MODE" argument is a string of option letters chosen from the
* list below:
* @example
* Letter Meaning
* r readable
* w writable
* x executable
* f normal file (NOT IMPLEMENTED)
* b block special (NOT IMPLEMENTED)
* c character special (NOT IMPLEMENTED)
* d directory (NOT IMPLEMENTED)
* p FIFO (pipe) (NOT IMPLEMENTED)
* u set user ID bit (NOT IMPLEMENTED)
* g set group ID bit (NOT IMPLEMENTED)
* k sticky bit (NOT IMPLEMENTED)
* s size nonzero (NOT IMPLEMENTED)
* @end example
*
* example:
* To find the "ls" command using the "PATH" environment variable:
* @example
* #include <stdlib.h>
* char* pz_ls = pathfind( getenv("PATH"), "ls", "rx" );
* <<do whatever with pz_ls>>
* free( pz_ls );
* @end example
* The path is allocated with @code{malloc(3C)}, so you must @code{free(3C)}
* the result. Also, do not use unimplemented file modes. :-)
*
* err: returns NULL if the file is not found.
=*/
/**
* local implementation of pathfind.
* @param[in] path colon separated list of directories
* @param[in] fname the name we are hunting for
* @param[in] mode the required file mode
* @returns an allocated string with the full path, or NULL
*/
static char *
pathfind( char const * path,
char const * fileName,
char const * fname,
char const * mode )
{
int p_index = 0;
int mode_bits = 0;
char* pathName = NULL;
char * res_path = NULL;
char zPath[ AG_PATH_MAX + 1 ];
if (strchr( mode, 'r' )) mode_bits |= R_OK;
@@ -103,9 +55,6 @@ pathfind( char const * path,
DIR* dirP;
char* colon_unit = extract_colon_unit( zPath, path, &p_index );
/*
* IF no more entries, THEN quit
*/
if (colon_unit == NULL)
break;
@@ -117,9 +66,6 @@ pathfind( char const * path,
if (dirP == NULL)
continue;
/*
* FOR every entry in the given directory, ...
*/
for (;;) {
struct dirent *entP = readdir( dirP );
@@ -129,31 +75,31 @@ pathfind( char const * path,
/*
* IF the file name matches the one we are looking for, ...
*/
if (strcmp( entP->d_name, fileName ) == 0) {
char* pzFullName = make_absolute( fileName, colon_unit);
if (strcmp(entP->d_name, fname) == 0) {
char * abs_name = make_absolute(fname, colon_unit);
/*
* Make sure we can access it in the way we want
*/
if (access( pzFullName, mode_bits ) >= 0) {
if (access(abs_name, mode_bits) >= 0) {
/*
* We can, so normalize the name and return it below
*/
pathName = canonicalize_pathname( pzFullName );
res_path = canonicalize_pathname(abs_name);
}
free( (void*)pzFullName );
free(abs_name);
break;
}
}
closedir( dirP );
if (pathName != NULL)
if (res_path != NULL)
break;
}
return pathName;
return res_path;
}
/*
+5 -5
View File
@@ -519,7 +519,7 @@ handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir)
if (txt > pzEnd) {
name_only:
*pzEnd++ = NUL;
loadOptionLine(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
load_opt_line(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
return pzEnd;
}
@@ -575,7 +575,7 @@ handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir)
* "pzName" points to what looks like text for one option/configurable.
* It is NUL terminated. Process it.
*/
loadOptionLine(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
load_opt_line(opts, ost, pzName, dir, OPTION_LOAD_UNCOOKED);
return pzEnd;
}
@@ -939,7 +939,7 @@ handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir)
return NULL;
*txt = NUL;
txt += 2;
loadOptionLine(opts, ost, pzName, dir, mode);
load_opt_line(opts, ost, pzName, dir, mode);
return txt;
case '>':
@@ -963,7 +963,7 @@ handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir)
return txt;
/*
* Rejoin the name and value for parsing by "loadOptionLine()".
* Rejoin the name and value for parsing by "load_opt_line()".
* Erase any attributes parsed by "parse_attrs()".
*/
memset(pcNulPoint, ' ', (size_t)(pzData - pcNulPoint));
@@ -980,7 +980,7 @@ handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir)
* "pzName" points to what looks like text for one option/configurable.
* It is NUL terminated. Process it.
*/
loadOptionLine(opts, ost, pzName, dir, mode);
load_opt_line(opts, ost, pzName, dir, mode);
return txt;
}
+210 -94
View File
@@ -33,8 +33,6 @@
* 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
*/
static char const * pz_enum_err_fmt;
/* = = = START-STATIC-FORWARD = = = */
static void
enum_err(tOptions * pOpts, tOptDesc * pOD,
@@ -49,8 +47,15 @@ set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
unsigned int name_ct);
static void
set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
unsigned int name_ct);
set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
unsigned int nm_ct);
static uintptr_t
check_membership_start(tOptDesc * od, char const ** argp, bool * invert);
static uintptr_t
find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
char const * const * nm_list, unsigned int nm_ct);
/* = = = END-STATIC-FORWARD = = = */
static void
@@ -360,16 +365,14 @@ set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
}
static void
set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
unsigned int name_ct)
set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
unsigned int nm_ct)
{
char * pz;
uintptr_t bits = (uintptr_t)pOD->optCookie;
uintptr_t mask = (1UL << (uintptr_t)nm_ct) - 1UL;
uintptr_t bits = (uintptr_t)od->optCookie & mask;
unsigned int ix = 0;
size_t len = NONE_STR_LEN + 1;
(void)pOpts;
bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
size_t len = 1;
/*
* Replace the enumeration value with the name string.
@@ -377,46 +380,161 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
*/
while (bits != 0) {
if (bits & 1)
len += strlen(paz_names[ix]) + PLUS_STR_LEN + 1;
if (++ix >= name_ct) break;
len += strlen(nm_list[ix]) + PLUS_STR_LEN + 1;
if (++ix >= nm_ct) break;
bits >>= 1;
}
pOD->optArg.argString = pz = AGALOC(len, "enum");
od->optArg.argString = pz = AGALOC(len, "enum");
bits = (uintptr_t)od->optCookie & mask;
if (bits == 0) {
*pz = NUL;
return;
}
/*
* Start by clearing all the bits. We want to turn off any defaults
* because we will be restoring to current state, not adding to
* the default set of bits.
*/
memcpy(pz, NONE_STR, NONE_STR_LEN);
pz += NONE_STR_LEN;
bits = (uintptr_t)pOD->optCookie;
bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
ix = 0;
for (ix = 0; ; ix++) {
size_t nln;
int doit = bits & 1;
while (bits != 0) {
if (bits & 1) {
size_t nln = strlen(paz_names[ix]);
bits >>= 1;
if (doit == 0)
continue;
nln = strlen(nm_list[ix]);
memcpy(pz, nm_list[ix], nln);
pz += nln;
if (bits == 0)
break;
memcpy(pz, PLUS_STR, PLUS_STR_LEN);
memcpy(pz+PLUS_STR_LEN, paz_names[ix], nln);
pz += nln + PLUS_STR_LEN;
}
if (++ix >= name_ct) break;
bits >>= 1;
pz += PLUS_STR_LEN;
}
*pz = NUL;
(void)opts;
}
/**
* Check membership start conditions. An equal character (@samp{=}) says to
* clear the result and not carry over any residual value. A carat
* (@samp{^}), which may follow the equal character, says to invert the
* result. The scanning pointer is advanced past these characters and any
* leading white space. Invalid sequences are indicated by setting the
* scanning pointer to NULL.
*
* @param od the set membership option description
* @param argp a pointer to the string scanning pointer
* @param invert a pointer to the boolean inversion indicator
*
* @returns either zero or the original value for the optCookie.
*/
static uintptr_t
check_membership_start(tOptDesc * od, char const ** argp, bool * invert)
{
uintptr_t res = (uintptr_t)od->optCookie;
char const * arg = SPN_WHITESPACE_CHARS(od->optArg.argString);
if ((arg == NULL) || (*arg == NUL))
goto member_start_fail;
*invert = false;
switch (*arg) {
case '=':
res = 0UL;
arg = SPN_WHITESPACE_CHARS(arg + 1);
switch (*arg) {
case '=': case ',':
goto member_start_fail;
case '^':
goto inversion;
default:
break;
}
break;
case '^':
inversion:
*invert = true;
arg = SPN_WHITESPACE_CHARS(arg + 1);
if (*arg != ',')
break;
/* FALLTHROUGH */
case ',':
goto member_start_fail;
default:
break;
}
*argp = arg;
return res;
member_start_fail:
*argp = NULL;
return 0UL;
}
/**
* convert a name to a bit. Look up a name string to get a bit number
* and shift the value "1" left that number of bits.
*
* @param opts program options descriptor
* @param od the set membership option description
* @param pz address of the start of the bit name
* @param nm_list the list of names for this option
* @param nm_ct the number of entries in this list
*
* @returns 0UL on error, other an unsigned long with the correct bit set.
*/
static uintptr_t
find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
char const * const * nm_list, unsigned int nm_ct)
{
char nm_buf[ AO_NAME_SIZE ];
memcpy(nm_buf, pz, len);
nm_buf[len] = NUL;
{
unsigned int shift_ct = (unsigned int)
find_name(nm_buf, opts, od, nm_list, nm_ct);
if (shift_ct >= nm_ct)
return 0UL;
return 1UL << shift_ct;
}
}
/*=export_func optionMemberList
* what: Get the list of members of a bit mask set
*
* arg: tOptDesc *, od, the set membership option description
*
* ret_type: char*
* ret_desc: the names of the set bits
*
* doc: This converts the OPT_VALUE_name mask value to a allocated string.
* It is the caller's responsibility to free the string.
=*/
char *
optionMemberList(tOptDesc * od)
{
uintptr_t sv = od->optArg.argIntptr;
char * res;
(*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od);
res = (void *)od->optArg.argString;
od->optArg.argIntptr = sv;
return res;
}
/*=export_func optionSetMembers
* what: Convert between bit flag values and strings
* private:
*
* arg: tOptions*, pOpts, the program options descriptor
* arg: tOptDesc*, pOD, enumeration option description
* arg: tOptions*, opts, the program options descriptor
* arg: tOptDesc*, od, the set membership option description
* arg: char const * const *,
* paz_names, list of enumeration names
* arg: unsigned int, name_ct, number of names in list
* nm_list, list of enumeration names
* arg: unsigned int, nm_ct, number of names in list
*
* doc: This converts the optArg.argString string from the option description
* into the index corresponding to an entry in the name list.
@@ -425,105 +543,103 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
* if there is only one partial match.
=*/
void
optionSetMembers(tOptions * pOpts, tOptDesc * pOD,
char const* const * paz_names, unsigned int name_ct)
optionSetMembers(tOptions * opts, tOptDesc * od,
char const * const * nm_list, unsigned int nm_ct)
{
/*
* IF the program option descriptor pointer is invalid,
* then it is some sort of special request.
*/
switch ((uintptr_t)pOpts) {
switch ((uintptr_t)opts) {
case (uintptr_t)OPTPROC_EMIT_USAGE:
enum_err(OPTPROC_EMIT_USAGE, pOD, paz_names, name_ct);
enum_err(OPTPROC_EMIT_USAGE, od, nm_list, nm_ct);
return;
case (uintptr_t)OPTPROC_EMIT_SHELL:
set_memb_shell(pOpts, pOD, paz_names, name_ct);
set_memb_shell(opts, od, nm_list, nm_ct);
return;
case (uintptr_t)OPTPROC_RETURN_VALNAME:
set_memb_names(pOpts, pOD, paz_names, name_ct);
set_memb_names(opts, od, nm_list, nm_ct);
return;
default:
break;
}
if ((pOD->fOptState & OPTST_RESET) != 0)
if ((od->fOptState & OPTST_RESET) != 0)
return;
{
char const * pzArg = pOD->optArg.argString;
uintptr_t res;
if ((pzArg == NULL) || (*pzArg == NUL)) {
pOD->optCookie = (void*)0;
return;
char const * arg;
bool invert;
uintptr_t res = check_membership_start(od, &arg, &invert);
if (arg == NULL)
goto fail_return;
while (*arg != NUL) {
bool inv_val = false;
int len;
switch (*arg) {
case ',':
arg = SPN_WHITESPACE_CHARS(arg+1);
if ((*arg == ',') || (*arg == '|'))
goto fail_return;
continue;
case '-':
case '!':
inv_val = true;
/* FALLTHROUGH */
case '+':
case '|':
arg = SPN_WHITESPACE_CHARS(arg+1);
}
res = (uintptr_t)pOD->optCookie;
for (;;) {
int iv, len;
pzArg = SPN_SET_SEPARATOR_CHARS(pzArg);
iv = (*pzArg == '!');
if (iv)
pzArg = SPN_WHITESPACE_CHARS(pzArg+1);
len = (int)(BRK_SET_SEPARATOR_CHARS(pzArg) - pzArg);
len = (int)(BRK_SET_SEPARATOR_CHARS(arg) - arg);
if (len == 0)
break;
if ((len == 3) && (strncmp(pzArg, zAll, 3) == 0)) {
if (iv)
if ((len == 3) && (strncmp(arg, zAll, 3) == 0)) {
if (inv_val)
res = 0;
else res = ~0UL;
}
else if ((len == 4) && (strncmp(pzArg, zNone, 4) == 0)) {
if (! iv)
else if ((len == 4) && (strncmp(arg, zNone, 4) == 0)) {
if (! inv_val)
res = 0;
}
else do {
char* pz;
uintptr_t bit = strtoul(pzArg, &pz, 0);
char * pz;
uintptr_t bit = strtoul(arg, &pz, 0);
if (pz != pzArg + len) {
char z[ AO_NAME_SIZE ];
char const* p;
unsigned int shift_ct;
if (*pz != NUL) {
if (len >= AO_NAME_LIMIT)
break;
memcpy(z, pzArg, (size_t)len);
z[len] = NUL;
p = z;
} else {
p = pzArg;
if (pz != arg + len) {
bit = find_member_bit(opts, od, pz, len, nm_list, nm_ct);
if (bit == 0UL)
goto fail_return;
}
shift_ct = (unsigned int)
find_name(p, pOpts, pOD, paz_names, name_ct);
if (shift_ct >= name_ct) {
pOD->optCookie = (void*)0;
return;
}
bit = 1UL << shift_ct;
}
if (iv)
if (inv_val)
res &= ~bit;
else res |= bit;
} while (false);
if (pzArg[len] == NUL)
break;
pzArg += len + 1;
}
if (name_ct < (8 * sizeof(uintptr_t))) {
res &= (1UL << name_ct) - 1UL;
arg = SPN_WHITESPACE_CHARS(arg + len);
}
pOD->optCookie = (void*)res;
if (invert)
res ^= ~0UL;
if (nm_ct < (8 * sizeof(uintptr_t)))
res &= (1UL << nm_ct) - 1UL;
od->optCookie = (void *)res;
}
return;
fail_return:
od->optCookie = (void *)0;
}
/** @}
+11 -2
View File
@@ -107,6 +107,9 @@ opt_ambiguities(tOptions * opts, char const * name, int nm_len)
fputs(zambig_list_msg, stderr);
do {
if (pOD->pz_Name == NULL)
continue; /* doc option */
if (strneqvcmp(name, pOD->pz_Name, nm_len) == 0)
fprintf(stderr, zambig_file, hyph, pOD->pz_Name);
@@ -375,7 +378,10 @@ opt_find_long(tOptions * opts, char const * opt_name, tOptState * state)
bool disable = false;
int ct;
if (nm_len <= 0) {
if (nm_len <= 1) {
if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0)
return FAILURE;
fprintf(stderr, zInvalOptName, opts->pzProgName, opt_name);
(*opts->pUsageProc)(opts, EXIT_FAILURE);
/* NOTREACHED */
@@ -418,6 +424,9 @@ opt_find_short(tOptions* pOpts, uint_t optValue, tOptState* pOptState)
if (SKIP_OPT(pRes)) {
if ( (pRes->fOptState == (OPTST_OMITTED | OPTST_NO_INIT))
&& (pRes->pz_Name != NULL)) {
if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
return FAILURE;
fprintf(stderr, zDisabledErr, pOpts->pzProgPath, pRes->pz_Name);
if (pRes->pzText != NULL)
fprintf(stderr, SET_OFF_FMT, pRes->pzText);
@@ -500,7 +509,7 @@ get_opt_arg_must(tOptions * opts, tOptState * o_st)
default:
#ifdef DEBUG
fputs("AutoOpts lib error: option type not selected\n", stderr);
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
#endif
case TOPT_DEFAULT:
+108 -106
View File
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (genshell.c)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:27 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:09 PM by AutoGen 5.18
* From the definitions genshell.def
* and the template file options
*
* Generated from AutoOpts 38:0:13 templates.
* Generated from AutoOpts 40:0:15 templates.
*
* AutoOpts is a copyrighted work. This source file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -146,8 +146,8 @@ static char const genshellopt_opt_strs[1769] =
#define MORE_HELP_name (genshellopt_opt_strs+1134)
#define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
#else
#define MORE_HELP_DESC NULL
#define MORE_HELP_name NULL
#define MORE_HELP_DESC HELP_DESC
#define MORE_HELP_name HELP_name
#define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
#endif
#ifdef NO_OPTIONAL_OPT_ARGS
@@ -258,7 +258,7 @@ static tOptDesc optDesc[GENSHELL_OPTION_CT] = {
#define zDetail (genshellopt_opt_strs+1534)
/** The full version string for genshellopt. */
#define zFullVersion (genshellopt_opt_strs+1755)
/* extracted from optcode.tlib near line 371 */
/* extracted from optcode.tlib near line 364 */
#if defined(ENABLE_NLS)
# define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -279,19 +279,21 @@ static tOptDesc optDesc[GENSHELL_OPTION_CT] = {
/**
* The callout function that invokes the genshelloptUsage function.
*
* @param[in] pOptions the AutoOpts option description structure
* @param[in] pOptDesc the descriptor for the "help" (usage) option.
* @param[in] opts the AutoOpts option description structure
* @param[in] od the descriptor for the "help" (usage) option.
* @noreturn
*/
static void
doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
doUsageOpt(tOptions * opts, tOptDesc * od)
{
genshelloptUsage(&genshelloptOptions, GENSHELLOPT_EXIT_SUCCESS);
int ex_code;
ex_code = GENSHELLOPT_EXIT_SUCCESS;
genshelloptUsage(&genshelloptOptions, ex_code);
/* NOTREACHED */
(void)pOptDesc;
(void)pOptions;
(void)opts;
(void)od;
}
/* extracted from optmain.tlib near line 1254 */
/* extracted from optmain.tlib near line 1266 */
/**
* The directory containing the data associated with genshellopt.
@@ -474,10 +476,10 @@ translate_option_strings(void)
static void bogus_function(void) {
/* TRANSLATORS:
The following dummy function was crated solely so that xgettext can extract
the correct strings. These strings are actually referenced by a field name
in the genshelloptOptions structure noted in the comments below. The
literal text is defined in genshellopt_opt_strs.
The following dummy function was crated solely so that xgettext can
extract the correct strings. These strings are actually referenced
by a field name in the genshelloptOptions structure noted in the
comments below. The literal text is defined in genshellopt_opt_strs.
NOTE: the strings below are segmented with respect to the source string
genshellopt_opt_strs. The strings above are handed off for translation
@@ -546,51 +548,51 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
/* referenced via genshelloptOptions.pzShortUsage */
puts(_("<<<NOT-FOUND>>>"));
/* LIBOPTS-MESSAGES: */
#line 60 "../autoopts.c"
#line 67 "../autoopts.c"
puts(_("allocation of %d bytes failed\n"));
#line 86 "../autoopts.c"
#line 93 "../autoopts.c"
puts(_("allocation of %d bytes failed\n"));
#line 53 "../init.c"
puts(_("AutoOpts function called without option descriptor\n"));
#line 89 "../init.c"
#line 90 "../init.c"
puts(_("\tThis exceeds the compiled library version: "));
#line 87 "../init.c"
#line 88 "../init.c"
puts(_("Automated Options Processing Error!\n"
"\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
#line 73 "../autoopts.c"
#line 80 "../autoopts.c"
puts(_("realloc of %d bytes at 0x%p failed\n"));
#line 91 "../init.c"
#line 92 "../init.c"
puts(_("\tThis is less than the minimum library version: "));
#line 121 "../version.c"
puts(_("Automated Options version %s\n"
"\tCopyright (C) 1999-2013 by Bruce Korb - all rights reserved\n"));
#line 310 "../usage.c"
#line 82 "../makeshell.c"
puts(_("(AutoOpts bug): %s.\n"));
#line 90 "../reset.c"
puts(_("optionResetOpt() called, but reset-option not configured"));
#line 329 "../usage.c"
#line 292 "../usage.c"
puts(_("could not locate the 'help' option"));
#line 351 "../autoopts.c"
#line 336 "../autoopts.c"
puts(_("optionProcess() was called with invalid data"));
#line 783 "../usage.c"
#line 747 "../usage.c"
puts(_("invalid argument type specified"));
#line 589 "../find.c"
#line 598 "../find.c"
puts(_("defaulted to option with optional arg"));
#line 76 "../alias.c"
puts(_("aliasing option is out of range."));
#line 229 "../enum.c"
#line 234 "../enum.c"
puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
#line 108 "../find.c"
puts(_(" The following options match:\n"));
#line 290 "../find.c"
#line 293 "../find.c"
puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
#line 161 "../check.c"
puts(_("%s: Command line arguments required\n"));
#line 43 "../alias.c"
puts(_("%d %s%s options allowed\n"));
#line 81 "../makeshell.c"
#line 89 "../makeshell.c"
puts(_("%s error %d (%s) calling %s for '%s'\n"));
#line 293 "../makeshell.c"
#line 301 "../makeshell.c"
puts(_("interprocess pipe"));
#line 168 "../version.c"
puts(_("error: version option argument '%c' invalid. Use:\n"
@@ -599,48 +601,48 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
"\t'n' - version and full copyright notice\n"));
#line 58 "../check.c"
puts(_("%s error: the '%s' and '%s' options conflict\n"));
#line 214 "../find.c"
#line 217 "../find.c"
puts(_("%s: The '%s' option has been disabled."));
#line 421 "../find.c"
#line 430 "../find.c"
puts(_("%s: The '%s' option has been disabled."));
#line 38 "../alias.c"
puts(_("-equivalence"));
#line 460 "../find.c"
#line 469 "../find.c"
puts(_("%s: illegal option -- %c\n"));
#line 110 "../reset.c"
puts(_("%s: illegal option -- %c\n"));
#line 268 "../find.c"
#line 271 "../find.c"
puts(_("%s: illegal option -- %s\n"));
#line 746 "../find.c"
#line 755 "../find.c"
puts(_("%s: illegal option -- %s\n"));
#line 118 "../reset.c"
puts(_("%s: illegal option -- %s\n"));
#line 332 "../find.c"
#line 335 "../find.c"
puts(_("%s: unknown vendor extension option -- %s\n"));
#line 154 "../enum.c"
#line 159 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
#line 164 "../enum.c"
#line 169 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
#line 782 "../usage.c"
#line 746 "../usage.c"
puts(_("%s error: invalid option descriptor for %s\n"));
#line 1110 "../usage.c"
#line 1080 "../usage.c"
puts(_("%s error: invalid option descriptor for %s\n"));
#line 379 "../find.c"
#line 385 "../find.c"
puts(_("%s: invalid option name: %s\n"));
#line 518 "../find.c"
#line 527 "../find.c"
puts(_("%s: The '%s' option requires an argument.\n"));
#line 171 "../autoopts.c"
#line 156 "../autoopts.c"
puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
"\t'%s' and '%s'."));
#line 94 "../check.c"
puts(_("%s error: The %s option is required\n"));
#line 623 "../find.c"
#line 632 "../find.c"
puts(_("%s: The '%s' option cannot have an argument.\n"));
#line 151 "../check.c"
puts(_("%s: Command line arguments are not allowed.\n"));
#line 531 "../save.c"
#line 535 "../save.c"
puts(_("error %d (%s) creating %s\n"));
#line 229 "../enum.c"
#line 234 "../enum.c"
puts(_("%s error: '%s' does not match any %s keywords.\n"));
#line 93 "../reset.c"
puts(_("%s error: The '%s' option requires an argument.\n"));
@@ -650,7 +652,7 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
puts(_("error %d (%s) stat-ing %s\n"));
#line 143 "../restore.c"
puts(_("%s error: no saved option state\n"));
#line 246 "../autoopts.c"
#line 231 "../autoopts.c"
puts(_("'%s' is not a command line option.\n"));
#line 114 "../time.c"
puts(_("%s error: '%s' is not a recognizable date/time.\n"));
@@ -662,41 +664,41 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
puts(_("%s error: The %s option must appear %d times.\n"));
#line 157 "../numeric.c"
puts(_("%s error: '%s' is not a recognizable number.\n"));
#line 195 "../enum.c"
#line 200 "../enum.c"
puts(_("%s error: %s exceeds %s keyword count\n"));
#line 366 "../usage.c"
#line 329 "../usage.c"
puts(_("Try '%s %s' for more information.\n"));
#line 45 "../alias.c"
puts(_("one %s%s option allowed\n"));
#line 195 "../makeshell.c"
#line 203 "../makeshell.c"
puts(_("standard output"));
#line 930 "../makeshell.c"
#line 938 "../makeshell.c"
puts(_("standard output"));
#line 304 "../usage.c"
#line 274 "../usage.c"
puts(_("standard output"));
#line 451 "../usage.c"
#line 414 "../usage.c"
puts(_("standard output"));
#line 660 "../usage.c"
#line 624 "../usage.c"
puts(_("standard output"));
#line 175 "../version.c"
puts(_("standard output"));
#line 304 "../usage.c"
#line 274 "../usage.c"
puts(_("standard error"));
#line 451 "../usage.c"
#line 414 "../usage.c"
puts(_("standard error"));
#line 660 "../usage.c"
#line 624 "../usage.c"
puts(_("standard error"));
#line 175 "../version.c"
puts(_("standard error"));
#line 195 "../makeshell.c"
#line 203 "../makeshell.c"
puts(_("write"));
#line 930 "../makeshell.c"
#line 938 "../makeshell.c"
puts(_("write"));
#line 303 "../usage.c"
#line 273 "../usage.c"
puts(_("write"));
#line 450 "../usage.c"
#line 413 "../usage.c"
puts(_("write"));
#line 659 "../usage.c"
#line 623 "../usage.c"
puts(_("write"));
#line 174 "../version.c"
puts(_("write"));
@@ -712,70 +714,70 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
puts(_("%s warning: cannot save options - %s not regular file\n"));
#line 256 "../save.c"
puts(_("%s warning: cannot save options - %s not regular file\n"));
#line 530 "../save.c"
#line 534 "../save.c"
puts(_("%s warning: cannot save options - %s not regular file\n"));
/* END-LIBOPTS-MESSAGES */
/* USAGE-TEXT: */
#line 908 "../usage.c"
puts(_("\t\t\t\t- an alternate for '%s'\n"));
#line 1177 "../usage.c"
puts(_("Version, usage and configuration options:"));
#line 959 "../usage.c"
puts(_("\t\t\t\t- default option for unnamed options\n"));
#line 872 "../usage.c"
puts(_("\t\t\t\t- an alternate for '%s'\n"));
#line 1147 "../usage.c"
puts(_("Version, usage and configuration options:"));
#line 923 "../usage.c"
puts(_("\t\t\t\t- default option for unnamed options\n"));
#line 836 "../usage.c"
puts(_("\t\t\t\t- disabled as '--%s'\n"));
#line 1146 "../usage.c"
#line 1116 "../usage.c"
puts(_(" --- %-14s %s\n"));
#line 1144 "../usage.c"
#line 1114 "../usage.c"
puts(_("This option has been disabled"));
#line 899 "../usage.c"
#line 863 "../usage.c"
puts(_("\t\t\t\t- enabled by default\n"));
#line 40 "../alias.c"
puts(_("%s error: only "));
#line 1221 "../usage.c"
#line 1193 "../usage.c"
puts(_(" - examining environment variables named %s_*\n"));
#line 168 "../file.c"
puts(_("\t\t\t\t- file must not pre-exist\n"));
#line 172 "../file.c"
puts(_("\t\t\t\t- file must pre-exist\n"));
#line 416 "../usage.c"
#line 379 "../usage.c"
puts(_("Options are specified by doubled hyphens and their name or by a single\n"
"hyphen and the flag character.\n"));
#line 908 "../makeshell.c"
#line 916 "../makeshell.c"
puts(_("\n"
"= = = = = = = =\n\n"
"This incarnation of genshell will produce\n"
"a shell script to parse the options for %s:\n\n"));
#line 161 "../enum.c"
#line 166 "../enum.c"
puts(_(" or an integer mask with any of the lower %d bits set\n"));
#line 932 "../usage.c"
#line 896 "../usage.c"
puts(_("\t\t\t\t- is a set membership option\n"));
#line 953 "../usage.c"
#line 917 "../usage.c"
puts(_("\t\t\t\t- must appear between %d and %d times\n"));
#line 418 "../usage.c"
#line 381 "../usage.c"
puts(_("Options are specified by single or double hyphens and their name.\n"));
#line 939 "../usage.c"
#line 903 "../usage.c"
puts(_("\t\t\t\t- may appear multiple times\n"));
#line 926 "../usage.c"
#line 890 "../usage.c"
puts(_("\t\t\t\t- may not be preset\n"));
#line 1336 "../usage.c"
#line 1308 "../usage.c"
puts(_(" Arg Option-Name Description\n"));
#line 1272 "../usage.c"
#line 1244 "../usage.c"
puts(_(" Flg Arg Option-Name Description\n"));
#line 1330 "../usage.c"
#line 1302 "../usage.c"
puts(_(" Flg Arg Option-Name Description\n"));
#line 1331 "../usage.c"
#line 1303 "../usage.c"
puts(_(" %3s %s"));
#line 1337 "../usage.c"
#line 1309 "../usage.c"
puts(_(" %3s %s"));
#line 423 "../usage.c"
#line 386 "../usage.c"
puts(_("The '-#<number>' option may omit the hash char\n"));
#line 419 "../usage.c"
#line 382 "../usage.c"
puts(_("All arguments are named options.\n"));
#line 1006 "../usage.c"
#line 970 "../usage.c"
puts(_(" - reading file %s"));
#line 445 "../usage.c"
#line 408 "../usage.c"
puts(_("\n"
"Please send bug reports to: <%s>\n"));
#line 100 "../version.c"
@@ -784,17 +786,17 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
#line 129 "../version.c"
puts(_("\n"
"Please send bug reports to: <%s>\n"));
#line 938 "../usage.c"
#line 902 "../usage.c"
puts(_("\t\t\t\t- may NOT appear - preset only\n"));
#line 978 "../usage.c"
#line 943 "../usage.c"
puts(_("\n"
"The following option preset mechanisms are supported:\n"));
#line 1219 "../usage.c"
#line 1191 "../usage.c"
puts(_("\n"
"The following option preset mechanisms are supported:\n"));
#line 717 "../usage.c"
#line 681 "../usage.c"
puts(_("prohibits these options:\n"));
#line 712 "../usage.c"
#line 676 "../usage.c"
puts(_("prohibits the option '%s'\n"));
#line 81 "../numeric.c"
puts(_("%s%ld to %ld"));
@@ -812,28 +814,28 @@ by the newly generated text. The first '#!' line will be regenerated.\n"));
puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
#line 77 "../numeric.c"
puts(_("%sless than or equal to %ld"));
#line 426 "../usage.c"
#line 389 "../usage.c"
puts(_("Operands and options may be intermixed. They will be reordered.\n"));
#line 687 "../usage.c"
#line 651 "../usage.c"
puts(_("requires the option '%s'\n"));
#line 690 "../usage.c"
#line 654 "../usage.c"
puts(_("requires these options:\n"));
#line 1348 "../usage.c"
#line 1320 "../usage.c"
puts(_(" Arg Option-Name Req? Description\n"));
#line 1342 "../usage.c"
#line 1314 "../usage.c"
puts(_(" Flg Arg Option-Name Req? Description\n"));
#line 162 "../enum.c"
#line 167 "../enum.c"
puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
"will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
"will set them all. Multiple entries may be passed as an option\n"
"argument list.\n"));
#line 945 "../usage.c"
#line 909 "../usage.c"
puts(_("\t\t\t\t- may appear up to %d times\n"));
#line 72 "../enum.c"
#line 77 "../enum.c"
puts(_("The valid \"%s\" option keywords are:\n"));
#line 1181 "../usage.c"
#line 1151 "../usage.c"
puts(_("The next option supports vendor supported extra options:"));
#line 808 "../usage.c"
#line 772 "../usage.c"
puts(_("These additional options are:"));
/* END-USAGE-TEXT */
}
+5 -7
View File
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (genshell.h)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:27 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:09 PM by AutoGen 5.18
* From the definitions genshell.def
* and the template file options
*
* Generated from AutoOpts 38:0:13 templates.
* Generated from AutoOpts 40:0:15 templates.
*
* AutoOpts is a copyrighted work. This header file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -55,7 +55,7 @@
* tolerable version is at least as old as what was current when the header
* template was released.
*/
#define AO_TEMPLATE_VERSION 155648
#define AO_TEMPLATE_VERSION 163840
#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
|| (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
# error option template version mismatches autoopts/options.h header
@@ -87,7 +87,7 @@ typedef enum {
#define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n])
/** 'true' if an option has been specified in any way */
#define HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n)))
/** The string argument to an option. The argument type must be "string". */
/** The string argument to an option. The argument type must be \"string\". */
#define GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString)
/** Mask the option state revealing how an option was specified.
* It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
@@ -114,7 +114,6 @@ typedef enum {
if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \
GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \
GENSHELL_DESC(n).optCookie = NULL )
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Enumeration of genshellopt exit codes
@@ -125,7 +124,6 @@ typedef enum {
GENSHELLOPT_EXIT_USAGE_ERROR = 64,
GENSHELLOPT_EXIT_LIBOPTS_FAILURE = 70
} genshellopt_exit_code_t;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Interface defines for specific options.
* @{
@@ -148,7 +146,6 @@ typedef enum {
genshelloptOptions.pzCurOpt = NULL )
#define START_GENSHELL_OPT RESTART_GENSHELL_OPT(1)
#define GENSHELL_USAGE(c) (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c)
/* extracted from opthead.tlib near line 538 */
#ifdef __cplusplus
extern "C" {
@@ -203,4 +200,5 @@ static inline char* aoGetsText(char const* pz) {
}
#endif
#endif /* AUTOOPTS_GENSHELL_H_GUARD */
/* genshell.h ends here */
+1
View File
@@ -20,6 +20,7 @@
/* NLS can be disabled through the configure --disable-nls option. */
#if ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
+4 -3
View File
@@ -53,6 +53,7 @@ validate_struct(tOptions * opts, char const * pname)
fputs(zno_opt_arg, stderr);
return FAILURE;
}
print_exit = ((opts->fOptSet & OPTPROC_SHELL_OUTPUT) != 0);
/*
* IF the client has enabled translation and the translation procedure
@@ -103,14 +104,14 @@ validate_struct(tOptions * opts, char const * pname)
char const ** pp =
(char const **)(void **)&(opts->pzProgName);
if (pz != NULL) {
if (pz != NULL)
*pp = pz+1;
} else {
else
*pp = pname;
pz = pathfind(getenv("PATH"), (char *)pname, "rx");
if (pz != NULL)
pname = (void *)pz;
}
pp = (char const **)(void **)&(opts->pzProgPath);
*pp = pname;
+209 -152
View File
@@ -33,24 +33,71 @@
/* = = = START-STATIC-FORWARD = = = */
static bool
add_prog_path(char * pzBuf, int b_sz, char const * pzName,
char const * pzProgPath);
get_realpath(char * buf, size_t b_sz);
static bool
add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path);
static bool
add_env_val(char * buf, int buf_sz, char const * name);
static char *
assemble_arg_val(char * txt, tOptionLoadMode mode);
static char *
trim_quotes(char * arg);
static bool
direction_ok(opt_state_mask_t f, int dir);
/* = = = END-STATIC-FORWARD = = = */
static bool
get_realpath(char * buf, size_t b_sz)
{
#if defined(HAVE_CANONICALIZE_FILE_NAME)
{
size_t name_len;
char * pz = canonicalize_file_name(buf);
if (pz == NULL)
return false;
name_len = strlen(pz);
if (name_len >= (size_t)b_sz) {
free(pz);
return false;
}
memcpy(buf, pz, name_len + 1);
free(pz);
}
#elif defined(HAVE_REALPATH)
{
size_t name_len;
char z[PATH_MAX+1];
if (realpath(buf, z) == NULL)
return false;
name_len = strlen(z);
if (name_len >= b_sz)
return false;
memcpy(buf, z, name_len + 1);
}
#endif
return true;
}
/*=export_func optionMakePath
* private:
*
* what: translate and construct a path
* arg: + char* + pzBuf + The result buffer +
* arg: + int + bufSize + The size of this buffer +
* arg: + char const* + pzName + The input name +
* arg: + char const* + pzProgPath + The full path of the current program +
* arg: + char* + p_buf + The result buffer +
* arg: + int + b_sz + The size of this buffer +
* arg: + char const* + fname + The input name +
* arg: + char const* + prg_path + The full path of the current program +
*
* ret-type: bool
* ret-desc: true if the name was handled, otherwise false.
@@ -95,24 +142,25 @@ assemble_arg_val(char * txt, tOptionLoadMode mode);
* errors (cannot resolve the resulting path).
=*/
bool
optionMakePath(char * pzBuf, int b_sz, char const * pzName,
char const * pzProgPath)
optionMakePath(char * p_buf, int b_sz, char const * fname, char const * prg_path)
{
size_t name_len = strlen(pzName);
{
size_t len = strlen(fname);
if (((size_t)b_sz <= name_len) || (name_len == 0))
if (((size_t)b_sz <= len) || (len == 0))
return false;
}
/*
* IF not an environment variable, just copy the data
*/
if (*pzName != '$') {
char const* pzS = pzName;
char* pzD = pzBuf;
if (*fname != '$') {
char const * src = fname;
char * dst = p_buf;
int ct = b_sz;
for (;;) {
if ( (*(pzD++) = *(pzS++)) == NUL)
if ( (*(dst++) = *(src++)) == NUL)
break;
if (--ct <= 0)
return false;
@@ -124,12 +172,12 @@ optionMakePath(char * pzBuf, int b_sz, char const * pzName,
* it must start with "$$/". In either event, replace the "$$"
* with the path to the executable and append a "/" character.
*/
else switch (pzName[1]) {
else switch (fname[1]) {
case NUL:
return false;
case '$':
if (! add_prog_path(pzBuf, b_sz, pzName, pzProgPath))
if (! add_prog_path(p_buf, b_sz, fname, prg_path))
return false;
break;
@@ -137,59 +185,30 @@ optionMakePath(char * pzBuf, int b_sz, char const * pzName,
if (program_pkgdatadir[0] == NUL)
return false;
if (snprintf(pzBuf, (size_t)b_sz, "%s%s",
program_pkgdatadir, pzName + 2) >= b_sz)
if (snprintf(p_buf, (size_t)b_sz, "%s%s",
program_pkgdatadir, fname + 2) >= b_sz)
return false;
break;
default:
if (! add_env_val(pzBuf, b_sz, pzName))
if (! add_env_val(p_buf, b_sz, fname))
return false;
}
#if defined(HAVE_CANONICALIZE_FILE_NAME)
{
char * pz = canonicalize_file_name(pzBuf);
if (pz == NULL)
return false;
name_len = strlen(pz);
if (name_len >= (size_t)b_sz) {
free(pz);
return false;
}
memcpy(pzBuf, pz, name_len + 1);
free(pz);
}
#elif defined(HAVE_REALPATH)
{
char z[PATH_MAX+1];
if (realpath(pzBuf, z) == NULL)
return false;
name_len = strlen(z);
if (name_len >= b_sz)
return false;
memcpy(pzBuf, z, name_len + 1);
}
#endif
return true;
return get_realpath(p_buf, b_sz);
}
/**
* convert a leading "$$" into a path to the executable.
*/
static bool
add_prog_path(char * pzBuf, int b_sz, char const * pzName,
char const * pzProgPath)
add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path)
{
char const* pzPath;
char const* pz;
char const * path;
char const * pz;
int skip = 2;
switch (pzName[2]) {
switch (fname[2]) {
case DIRCH:
skip = 3;
case NUL:
@@ -203,16 +222,16 @@ add_prog_path(char * pzBuf, int b_sz, char const * pzName,
* If it is, we're done. Otherwise, we have to hunt
* for the program using "pathfind".
*/
if (strchr(pzProgPath, DIRCH) != NULL)
pzPath = pzProgPath;
if (strchr(prg_path, DIRCH) != NULL)
path = prg_path;
else {
pzPath = pathfind(getenv("PATH"), (char*)pzProgPath, "rx");
path = pathfind(getenv("PATH"), (char*)prg_path, "rx");
if (pzPath == NULL)
if (path == NULL)
return false;
}
pz = strrchr(pzPath, DIRCH);
pz = strrchr(path, DIRCH);
/*
* IF we cannot find a directory name separator,
@@ -221,27 +240,30 @@ add_prog_path(char * pzBuf, int b_sz, char const * pzName,
if (pz == NULL)
return false;
pzName += skip;
fname += skip;
/*
* Concatenate the file name to the end of the executable path.
* The result may be either a file or a directory.
*/
if ((unsigned)(pz - pzPath) + 1 + strlen(pzName) >= (unsigned)b_sz)
if ((unsigned)(pz - path) + 1 + strlen(fname) >= (unsigned)b_sz)
return false;
memcpy(pzBuf, pzPath, (size_t)((pz - pzPath)+1));
strcpy(pzBuf + (pz - pzPath) + 1, pzName);
memcpy(buf, path, (size_t)((pz - path)+1));
strcpy(buf + (pz - path) + 1, fname);
/*
* If the "pzPath" path was gotten from "pathfind()", then it was
* If the "path" path was gotten from "pathfind()", then it was
* allocated and we need to deallocate it.
*/
if (pzPath != pzProgPath)
AGFREE(pzPath);
if (path != prg_path)
AGFREE(path);
return true;
}
/**
* Add an environment variable value.
*/
static bool
add_env_val(char * buf, int buf_sz, char const * name)
{
@@ -291,9 +313,9 @@ munge_str(char * txt, tOptionLoadMode mode)
return;
if (IS_WHITESPACE_CHAR(*txt)) {
char * pzS = SPN_WHITESPACE_CHARS(txt+1);
size_t l = strlen(pzS) + 1;
memmove(txt, pzS, l);
char * src = SPN_WHITESPACE_CHARS(txt+1);
size_t l = strlen(src) + 1;
memmove(txt, src, l);
pzE = txt + l - 1;
} else
@@ -323,13 +345,13 @@ munge_str(char * txt, tOptionLoadMode mode)
static char *
assemble_arg_val(char * txt, tOptionLoadMode mode)
{
char* pzEnd = strpbrk(txt, ARG_BREAK_STR);
char * end = strpbrk(txt, ARG_BREAK_STR);
int space_break;
/*
* Not having an argument to a configurable name is okay.
*/
if (pzEnd == NULL)
if (end == NULL)
return txt + strlen(txt);
/*
@@ -338,8 +360,8 @@ assemble_arg_val(char * txt, tOptionLoadMode mode)
* of which character caused it.
*/
if (mode == OPTION_LOAD_KEEP) {
*(pzEnd++) = NUL;
return pzEnd;
*(end++) = NUL;
return end;
}
/*
@@ -347,14 +369,99 @@ assemble_arg_val(char * txt, tOptionLoadMode mode)
* because we'll have to skip over an immediately following ':' or '='
* (and the white space following *that*).
*/
space_break = IS_WHITESPACE_CHAR(*pzEnd);
*(pzEnd++) = NUL;
space_break = IS_WHITESPACE_CHAR(*end);
*(end++) = NUL;
pzEnd = SPN_WHITESPACE_CHARS(pzEnd);
if (space_break && ((*pzEnd == ':') || (*pzEnd == '=')))
pzEnd = SPN_WHITESPACE_CHARS(pzEnd+1);
end = SPN_WHITESPACE_CHARS(end);
if (space_break && ((*end == ':') || (*end == '=')))
end = SPN_WHITESPACE_CHARS(end+1);
return pzEnd;
return end;
}
static char *
trim_quotes(char * arg)
{
switch (*arg) {
case '"':
case '\'':
ao_string_cook(arg, NULL);
}
return arg;
}
/**
* See if the option is to be processed in the current scan direction
* (-1 or +1).
*/
static bool
direction_ok(opt_state_mask_t f, int dir)
{
if (dir == 0)
return true;
switch (f & (OPTST_IMM|OPTST_DISABLE_IMM)) {
case 0:
/*
* The selected option has no immediate action.
* THEREFORE, if the direction is PRESETTING
* THEN we skip this option.
*/
if (PRESETTING(dir))
return false;
break;
case OPTST_IMM:
if (PRESETTING(dir)) {
/*
* We are in the presetting direction with an option we handle
* immediately for enablement, but normally for disablement.
* Therefore, skip if disabled.
*/
if ((f & OPTST_DISABLED) == 0)
return false;
} else {
/*
* We are in the processing direction with an option we handle
* immediately for enablement, but normally for disablement.
* Therefore, skip if NOT disabled.
*/
if ((f & OPTST_DISABLED) != 0)
return false;
}
break;
case OPTST_DISABLE_IMM:
if (PRESETTING(dir)) {
/*
* We are in the presetting direction with an option we handle
* immediately for disablement, but normally for disablement.
* Therefore, skip if NOT disabled.
*/
if ((f & OPTST_DISABLED) != 0)
return false;
} else {
/*
* We are in the processing direction with an option we handle
* immediately for disablement, but normally for disablement.
* Therefore, skip if disabled.
*/
if ((f & OPTST_DISABLED) == 0)
return false;
}
break;
case OPTST_IMM|OPTST_DISABLE_IMM:
/*
* The selected option is always for immediate action.
* THEREFORE, if the direction is PROCESSING
* THEN we skip this option.
*/
if (PROCESSING(dir))
return false;
break;
}
return true;
}
/**
@@ -370,88 +477,35 @@ assemble_arg_val(char * txt, tOptionLoadMode mode)
* @param[in] load_mode option loading mode (OPTION_LOAD_*)
*/
LOCAL void
loadOptionLine(
tOptions * opts,
tOptState * opt_state,
char * line,
tDirection direction,
tOptionLoadMode load_mode )
load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
tDirection direction, tOptionLoadMode load_mode )
{
/*
* When parsing a stored line, we only look at the characters after
* a hyphen. Long names must always be at least two characters and
* short options are always exactly one character long.
*/
line = SPN_LOAD_LINE_SKIP_CHARS(line);
{
char * arg = assemble_arg_val(line, load_mode);
if (IS_OPTION_NAME_CHAR(line[1])) {
if (! SUCCESSFUL(opt_find_long(opts, line, opt_state)))
return;
if (opt_state->flags & OPTST_NO_INIT)
} else if (! SUCCESSFUL(opt_find_short(opts, *line, opt_state)))
return;
opt_state->pzOptArg = arg;
if ((! CALLED(direction)) && (opt_state->flags & OPTST_NO_INIT))
return;
opt_state->pzOptArg = trim_quotes(arg);
}
switch (opt_state->flags & (OPTST_IMM|OPTST_DISABLE_IMM)) {
case 0:
/*
* The selected option has no immediate action.
* THEREFORE, if the direction is PRESETTING
* THEN we skip this option.
*/
if (PRESETTING(direction))
if (! direction_ok(opt_state->flags, direction))
return;
break;
case OPTST_IMM:
if (PRESETTING(direction)) {
/*
* We are in the presetting direction with an option we handle
* immediately for enablement, but normally for disablement.
* Therefore, skip if disabled.
*/
if ((opt_state->flags & OPTST_DISABLED) == 0)
return;
} else {
/*
* We are in the processing direction with an option we handle
* immediately for enablement, but normally for disablement.
* Therefore, skip if NOT disabled.
*/
if ((opt_state->flags & OPTST_DISABLED) != 0)
return;
}
break;
case OPTST_DISABLE_IMM:
if (PRESETTING(direction)) {
/*
* We are in the presetting direction with an option we handle
* immediately for disablement, but normally for disablement.
* Therefore, skip if NOT disabled.
*/
if ((opt_state->flags & OPTST_DISABLED) != 0)
return;
} else {
/*
* We are in the processing direction with an option we handle
* immediately for disablement, but normally for disablement.
* Therefore, skip if disabled.
*/
if ((opt_state->flags & OPTST_DISABLED) == 0)
return;
}
break;
case OPTST_IMM|OPTST_DISABLE_IMM:
/*
* The selected option is always for immediate action.
* THEREFORE, if the direction is PROCESSING
* THEN we skip this option.
*/
if (PROCESSING(direction))
return;
break;
}
/*
* Fix up the args.
@@ -516,10 +570,13 @@ void
optionLoadLine(tOptions * opts, char const * line)
{
tOptState st = OPTSTATE_INITIALIZER(SET);
char* pz;
AGDUPSTR(pz, line, "user option line");
loadOptionLine(opts, &st, pz, DIRECTION_PROCESS, OPTION_LOAD_COOKED);
char * pz;
proc_state_mask_t sv_flags = opts->fOptSet;
opts->fOptSet &= ~OPTPROC_ERRSTOP;
AGDUPSTR(pz, line, "opt line");
load_opt_line(opts, &st, pz, DIRECTION_CALLED, OPTION_LOAD_COOKED);
AGFREE(pz);
opts->fOptSet = sv_flags;
}
/** @}
*
+10 -12
View File
@@ -2,7 +2,7 @@ dnl -*- buffer-read-only: t -*- vi: set ro:
dnl
dnl DO NOT EDIT THIS FILE (libopts.m4)
dnl
dnl It has been AutoGen-ed March 31, 2013 at 10:41:19 AM by AutoGen 5.17.3
dnl It has been AutoGen-ed July 14, 2013 at 05:37:02 PM by AutoGen 5.18
dnl From the definitions libopts.def
dnl and the template file conftest.tpl
dnl
@@ -72,8 +72,7 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
${lo_have_typ_hdr} || \
]AC_MSG_ERROR([you must have inttypes.h or stdint.h on your system])[
for f in sys_types sys_param sys_stat \
string errno stdlib memory setjmp
for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
do eval as_ac_var=\${ac_cv_header_${f}_h}
test "X${as_ac_var}" = Xyes || {
]AC_MSG_ERROR([you must have ${f}.h on your system])[
@@ -102,10 +101,11 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
AC_CHECK_SIZEOF(long, 8)
AC_CHECK_SIZEOF(short, 2)
# ----------------------------------------------------------------------
# AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
# ----------------------------------------------------------------------
# ------------
# AC_CHECK_LIB
# ------------
AC_CHECK_LIB(gen, pathfind)
AC_CHECK_LIB(intl,gettext)
AC_FUNC_VPRINTF
AC_FUNC_FORK
AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
@@ -200,7 +200,6 @@ AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
esac
libopts_save_CPPFLAGS="${CPPFLAGS}"
libopts_save_LIBS="${LIBS}"
case "X${libopts_cv_with_libregex_cflags}" in
Xyes|Xno|X )
libopts_cv_with_libregex_cflags="" ;;
@@ -239,9 +238,8 @@ int main() {
[libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
[libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
AC_MSG_RESULT([${libopts_cv_with_libregex}])
fi ## disabled by request
AC_MSG_RESULT([${libopts_cv_with_libregex}])
if test "X${libopts_cv_with_libregex}" != Xno
then
AC_DEFINE([WITH_LIBREGEX],[1],
@@ -250,9 +248,9 @@ int main() {
CPPFLAGS="${libopts_save_CPPFLAGS}"
LIBS="${libopts_save_LIBS}"
libopts_cv_with_libregex_root=no
libopts_cv_with_libregex_cflags=no
libopts_cv_with_libregex_libs=no
AC_MSG_RESULT([the regex library does not work and will not be used])
libopts_cv_with_libregex_cflags=no
libopts_cv_with_libregex_libs=no
libopts_cv_with_libregex=no
fi
]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
+19 -11
View File
@@ -30,13 +30,6 @@
* 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
*/
tOptions * optionParseShellOptions = NULL;
static char const * shell_prog = NULL;
static char * script_leader = NULL;
static char * script_trailer = NULL;
static char * script_text = NULL;
/* = = = START-STATIC-FORWARD = = = */
static void
emit_var_text(char const * prog, char const * var, int fdin);
@@ -75,6 +68,21 @@ static void
open_out(char const * fname, char const * pname);
/* = = = END-STATIC-FORWARD = = = */
LOCAL void
option_exits(int exit_code)
{
if (print_exit)
printf("\nexit %d\n", exit_code);
exit(exit_code);
}
LOCAL void
ao_bug(char const * msg)
{
fprintf(stderr, zao_bug_msg, msg);
option_exits(EX_SOFTWARE);
}
LOCAL void
fserr_warn(char const * prog, char const * op, char const * fname)
{
@@ -86,7 +94,7 @@ LOCAL void
fserr_exit(char const * prog, char const * op, char const * fname)
{
fserr_warn(prog, op, fname);
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
}
/*=export_func optionParseShell
@@ -325,7 +333,7 @@ text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
/* NOTREACHED */
default:
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
/* NOTREACHED */
}
/* NOTREACHED */
@@ -862,7 +870,7 @@ genshelloptUsage(tOptions * opts, int exit_cd)
fflush(stderr);
fflush(stdout);
if (ferror(stdout) || ferror(stderr))
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
option_usage_fp = stdout;
@@ -929,7 +937,7 @@ genshelloptUsage(tOptions * opts, int exit_cd)
if (ferror(stdout))
fserr_exit(opts->pzProgName, zwriting, zstdout_name);
exit(EXIT_SUCCESS);
option_exits(EXIT_SUCCESS);
#endif
}
+1 -1
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (stdin.c)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:26 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:08 PM by AutoGen 5.18
* From the definitions stdin
* and the template file str2enum
*
+1 -1
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (stdin.h)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:25 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:08 PM by AutoGen 5.18
* From the definitions stdin
* and the template file str2enum
*
+1 -1
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (stdin.c)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:24 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:07 PM by AutoGen 5.18
* From the definitions stdin
* and the template file str2enum
*
+1 -1
View File
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (stdin.h)
*
* It has been AutoGen-ed March 31, 2013 at 10:41:24 AM by AutoGen 5.17.3
* It has been AutoGen-ed July 14, 2013 at 05:37:07 PM by AutoGen 5.18
* From the definitions stdin
* and the template file str2enum
*
+77 -30
View File
@@ -32,12 +32,70 @@
* 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
*/
#if defined(HAVE_WORKING_FORK)
static FILE *
open_tmp_usage(char ** buf)
{
char * bf;
size_t bfsz;
{
unsigned int my_pid = (unsigned int)getpid();
char const * tmpdir = getenv(TMPDIR);
if (tmpdir == NULL)
tmpdir = tmp_dir;
bfsz = TMP_FILE_FMT_LEN + strlen(tmpdir) + 10;
bf = AGALOC(bfsz, "tmp fil");
snprintf(bf, bfsz, TMP_FILE_FMT, tmpdir, my_pid);
}
{
int fd = mkstemp(bf);
if (fd < 0) {
AGFREE(bf);
return NULL;
}
*buf = bf;
return fdopen(fd, "w");
}
}
static char *
mk_pager_cmd(char const * fname)
{
/*
* Page the file and remove it when done. For shell script processing,
* we must redirect the output to the current stderr, otherwise stdout.
*/
fclose(option_usage_fp);
option_usage_fp = NULL;
{
char const * pager = (char const *)getenv(PAGER_NAME);
size_t bfsz;
char * res;
/*
* Use the "more(1)" program if "PAGER" has not been defined
*/
if (pager == NULL)
pager = MORE_STR;
bfsz = strlen(fname) + strlen(pager) + PAGE_USAGE_FMT_LEN;
res = AGALOC(bfsz, "more cmd");
snprintf(res, bfsz, PAGE_USAGE_FMT, pager, fname);
AGFREE((void*)fname);
return res;
}
}
#endif
/*=export_func optionPagedUsage
* private:
*
* what: Decipher a boolean value
* arg: + tOptions* + opts + program options descriptor +
* arg: + tOptDesc* + od + the descriptor for this arg +
* what: emit help text and pass through a pager program.
* arg: + tOptions * + opts + program options descriptor +
* arg: + tOptDesc * + od + the descriptor for this arg +
*
* doc:
* Run the usage output through a pager.
@@ -53,8 +111,8 @@ optionPagedUsage(tOptions * opts, tOptDesc * od)
(*opts->pUsageProc)(opts, EXIT_SUCCESS);
#else
static pid_t my_pid;
char fil_name[1024];
static bool sv_print_exit = false;
static char * fil_name = NULL;
/*
* IF we are being called after the usage proc is done
@@ -66,20 +124,12 @@ optionPagedUsage(tOptions * opts, tOptDesc * od)
{
if ((od->fOptState & OPTST_RESET) != 0)
return;
my_pid = getpid();
snprintf(fil_name, sizeof(fil_name), TMP_USAGE_FMT,
(unsigned long)my_pid);
unlink(fil_name);
/*
* Set usage output to this temporary file
*/
option_usage_fp = fopen(fil_name, "w" FOPEN_BINARY_FLAG);
option_usage_fp = open_tmp_usage(&fil_name);
if (option_usage_fp == NULL)
_exit(EXIT_FAILURE);
(*opts->pUsageProc)(opts, EXIT_SUCCESS);
pagerState = PAGER_STATE_READY;
sv_print_exit = print_exit;
/*
* Set up so this routine gets called during the exit logic
@@ -88,8 +138,10 @@ optionPagedUsage(tOptions * opts, tOptDesc * od)
/*
* The usage procedure will now put the usage information into
* the temporary file we created above.
* the temporary file we created above. Keep any shell commands
* out of the result.
*/
print_exit = false;
(*opts->pUsageProc)(opts, EXIT_SUCCESS);
/* NOTREACHED */
@@ -97,25 +149,20 @@ optionPagedUsage(tOptions * opts, tOptDesc * od)
}
case PAGER_STATE_READY:
{
char const * pager = (char const *)getenv(PAGER_NAME);
fil_name = mk_pager_cmd(fil_name);
/*
* Use the "more(1)" program if "PAGER" has not been defined
*/
if (pager == NULL)
pager = MORE_STR;
if (sv_print_exit) {
fputs("\nexit 0\n", stdout);
fclose(stdout);
dup2(STDERR_FILENO, STDOUT_FILENO);
/*
* Page the file and remove it when done.
*/
snprintf(fil_name, sizeof(fil_name), PAGE_USAGE_FMT, pager,
(unsigned long)my_pid);
} else {
fclose(stderr);
dup2(STDOUT_FILENO, STDERR_FILENO);
}
ignore_val( system( fil_name));
}
AGFREE(fil_name);
case PAGER_STATE_CHILD:
/*
+9 -10
View File
@@ -1,7 +1,7 @@
/* -*- buffer-read-only: t -*- vi: set ro:
*
* Prototypes for autoopts
* Generated Sun Mar 31 10:41:38 PDT 2013
* Generated Sun Jul 14 17:37:20 PDT 2013
*/
#ifndef AUTOOPTS_PROTO_H_GUARD
#define AUTOOPTS_PROTO_H_GUARD 1
@@ -92,16 +92,18 @@ static void
munge_str(char * txt, tOptionLoadMode mode);
static void
loadOptionLine(
tOptions * opts,
tOptState * opt_state,
char * line,
tDirection direction,
tOptionLoadMode load_mode );
load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
tDirection direction, tOptionLoadMode load_mode );
/*
* Extracted from makeshell.c
*/
static void
option_exits(int exit_code);
static void
ao_bug(char const * msg);
static void
fserr_warn(char const * prog, char const * op, char const * fname);
@@ -141,7 +143,4 @@ addArgListEntry(void** ppAL, void* entry);
static void
set_usage_flags(tOptions * opts, char const * flg_txt);
static void
ao_bug(char const * msg);
#endif /* AUTOOPTS_PROTO_H_GUARD */
+4 -9
View File
@@ -30,7 +30,6 @@
* 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
* 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
*/
#define APOSTROPHE '\''
/* = = = START-STATIC-FORWARD = = = */
static size_t
@@ -292,6 +291,7 @@ print_enumeration(tOptions * pOpts, tOptDesc * pOD)
static void
print_membership(tOptions * pOpts, tOptDesc * pOD)
{
char const * svstr = pOD->optArg.argString;
char const * pz;
uintptr_t val = 1;
printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
@@ -299,13 +299,9 @@ print_membership(tOptions * pOpts, tOptDesc * pOD)
pOD->optCookie = (void*)(uintptr_t)~0UL;
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
/*
* We are building the typeset list. The list returned starts with
* 'none + ' for use by option saving stuff. We must ignore that.
*/
pz = pOD->optArg.argString + 7;
pz = pOD->optArg.argString;
while (*pz != NUL) {
printf("typeset -x -i %s_", pOD->pz_NAME);
printf("readonly %s_", pOD->pz_NAME);
pz = SPN_PLUS_N_SPACE_CHARS(pz);
for (;;) {
@@ -321,8 +317,7 @@ print_membership(tOptions * pOpts, tOptDesc * pOD)
}
AGFREE(pOD->optArg.argString);
pOD->optArg.argString = NULL;
pOD->fOptState &= ~OPTST_ALLOC_ARG;
pOD->optArg.argString = svstr;
}
static void
+1 -1
View File
@@ -141,7 +141,7 @@ optionRestore(tOptions* pOpts)
pzName = zNil;
}
fprintf(stderr, zNoState, pzName);
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
}
pOpts->pSavedState = NULL;
+39 -41
View File
@@ -63,7 +63,7 @@ static void
prt_str_arg(FILE * fp, tOptDesc * pOD);
static void
prt_enum_arg(FILE * fp, tOptDesc * pOD);
prt_enum_arg(FILE * fp, tOptDesc * od);
static void
prt_set_arg(FILE * fp, tOptDesc * od);
@@ -138,7 +138,7 @@ find_dir_name(tOptions * opts, int * p_free)
{
size_t sz = strlen(pzEnv) + strlen(pzEndDir) + 2;
pzFileName = (char*)AGALOC(sz, "dir name");
pzFileName = (char *)AGALOC(sz, "dir name");
}
if (pzFileName == NULL)
@@ -277,6 +277,8 @@ find_file_name(tOptions * opts, int * p_free_name)
static void
prt_entry(FILE * fp, tOptDesc * od, char const * l_arg)
{
int space_ct;
/*
* There is an argument. Pad the name so values line up.
* Not disabled *OR* this got equivalenced to another opt,
@@ -284,29 +286,29 @@ prt_entry(FILE * fp, tOptDesc * od, char const * l_arg)
* Otherwise, there must be a disablement name.
*/
{
char const * pz;
if (! DISABLED_OPT(od) || (od->optEquivIndex != NO_EQUIVALENT))
pz = od->pz_Name;
else
pz = od->pz_DisableName;
fprintf(fp, "%-18s", pz);
char const * pz =
(! DISABLED_OPT(od) || (od->optEquivIndex != NO_EQUIVALENT))
? od->pz_Name
: od->pz_DisableName;
space_ct = 17 - strlen(pz);
fputs(pz, fp);
}
if ( (l_arg == NULL)
&& (OPTST_GET_ARGTYPE(od->fOptState) != OPARG_TYPE_NUMERIC))
goto end_entry;
fputs(" = ", fp);
while (space_ct-- > 0) fputc(' ', fp);
/*
* IF the option is numeric only,
* THEN the char pointer is really the number
*/
if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_NUMERIC)
fprintf(fp, " %d\n", (int)(t_word)l_arg);
/*
* OTHERWISE, FOR each line of the value text, ...
*/
else if (l_arg == NULL)
fputc(NL, fp);
fprintf(fp, "%d", (int)(t_word)l_arg);
else {
fputc(' ', fp); fputc(' ', fp);
for (;;) {
char const * eol = strchr(l_arg, NL);
@@ -329,8 +331,10 @@ prt_entry(FILE * fp, tOptDesc * od, char const * l_arg)
* Terminate the entry
*/
fputs(l_arg, fp);
fputc(NL, fp);
}
end_entry:
fputc(NL, fp);
}
/**
@@ -610,20 +614,24 @@ prt_str_arg(FILE * fp, tOptDesc * pOD)
}
/**
* print the string value of an enumeration.
*
* @param[in] fp the file pointer to write to
* @param[in] od the option descriptor with the enumerated value
*/
static void
prt_enum_arg(FILE * fp, tOptDesc * pOD)
prt_enum_arg(FILE * fp, tOptDesc * od)
{
uintptr_t val = pOD->optArg.argEnum;
uintptr_t val = od->optArg.argEnum;
/*
* This is a magic incantation that will convert the
* bit flag values back into a string suitable for printing.
*/
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
prt_entry(fp, pOD, (void*)(pOD->optArg.argString));
(*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od);
prt_entry(fp, od, (void*)(od->optArg.argString));
pOD->optArg.argEnum = val;
od->optArg.argEnum = val;
}
/**
@@ -638,24 +646,14 @@ prt_enum_arg(FILE * fp, tOptDesc * pOD)
static void
prt_set_arg(FILE * fp, tOptDesc * od)
{
uintptr_t val = od->optArg.argEnum;
/*
* This is a magic incantation that will convert the
* bit flag values back into a string suitable for printing.
*/
(*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od);
prt_entry(fp, od, (void*)(od->optArg.argString));
if (od->optArg.argString != NULL) {
/*
* set membership strings get allocated
*/
AGFREE((void*)od->optArg.argString);
od->fOptState &= ~OPTST_ALLOC_ARG;
}
od->optArg.argEnum = val;
char * list = optionMemberList(od);
size_t len = strlen(list);
char * buf = (char *)AGALOC(len + 3, "dir name");
*buf= '=';
memcpy(buf+1, list, len + 1);
prt_entry(fp, od, buf);
AGFREE(buf);
AGFREE(list);
}
/**
+1 -1
View File
@@ -133,7 +133,7 @@ optionUnstackArg(tOptions * pOpts, tOptDesc * pOptDesc)
* we are keeping a define.
*/
for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) {
const char ** pzSrc = pAL->apzArgs[ i ];
const char * pzSrc = pAL->apzArgs[ i ];
char * pzEq = strchr(pzSrc, '=');
if (pzEq != NULL)
+1 -1
View File
@@ -233,7 +233,7 @@ close_mmap_files(tmap_info_t * mi)
close(mi->txt_fd);
mi->txt_fd = AO_INVALID_FD;
#if ! defined(MAP_ANONYMOUS)
#if defined(HAVE_MMAP) && ! defined(MAP_ANONYMOUS)
if (mi->txt_zero_fd == AO_INVALID_FD)
return;
+34 -62
View File
@@ -37,36 +37,6 @@
* 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
*/
#define OPTPROC_L_N_S (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)
#if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
# include <libintl.h>
#endif
typedef struct {
size_t fnm_len;
uint32_t fnm_mask;
char const * fnm_name;
} ao_flag_names_t;
/**
* Automated Options Usage Flags.
* NB: no entry may be a prefix of another entry
*/
#define AOFLAG_TABLE \
_aof_(gnu, OPTPROC_GNUUSAGE ) \
_aof_(autoopts, ~OPTPROC_GNUUSAGE) \
_aof_(no_misuse_usage, OPTPROC_MISUSE ) \
_aof_(misuse_usage, ~OPTPROC_MISUSE ) \
_aof_(compute, OPTPROC_COMPUTE )
#define _aof_(_n, _f) AOUF_ ## _n ## _ID,
typedef enum { AOFLAG_TABLE AOUF_COUNT } ao_flag_id_t;
#undef _aof_
#define _aof_(_n, _f) AOUF_ ## _n = (1 << AOUF_ ## _n ## _ID),
typedef enum { AOFLAG_TABLE } ao_flags_t;
#undef _aof_
/* = = = START-STATIC-FORWARD = = = */
static unsigned int
parse_usage_flags(ao_flag_names_t const * fnt, char const * txt);
@@ -100,8 +70,8 @@ static void
prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title);
static void
prt_ini_list(char const * const * papz, bool * need_intro,
char const * ini_file, char const * path_nm);
prt_ini_list(char const * const * papz, char const * ini_file,
char const * path_nm);
static void
prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at);
@@ -304,13 +274,6 @@ optionOnlyUsage(tOptions * pOpts, int ex_code)
? zstderr_name : zstdout_name);
}
LOCAL void
ao_bug(char const * msg)
{
fprintf(stderr, zao_bug_msg, msg);
exit(EX_SOFTWARE);
}
/**
* Print a message suggesting how to get help.
*
@@ -626,7 +589,8 @@ optionUsage(tOptions * opts, int usage_exit_code)
? opts->pzFullUsage : NULL;
if (option_usage_fp == NULL)
option_usage_fp = stdout;
option_usage_fp = print_exit ? stderr : stdout;
} else {
pz = (opts->structVersion >= 30 * 4096)
? opts->pzShortUsage : NULL;
@@ -659,7 +623,7 @@ optionUsage(tOptions * opts, int usage_exit_code)
fserr_exit(opts->pzProgName, zwriting, (option_usage_fp == stdout)
? zstdout_name : zstderr_name);
exit(exit_code);
option_exits(exit_code);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -959,24 +923,24 @@ prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title)
fputs(zDefaultOpt + tab_skip_ct, option_usage_fp);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Figure out where all the initialization files might live. This requires
* translating some environment variables and testing to see if a name is a
* directory or a file. It's squishy, but important to tell users how to
* find these files.
*
* Figure out where all the initialization files might live.
* This requires translating some environment variables and
* testing to see if a name is a directory or a file. It's
* squishy, but important to tell users how to find these files.
* @param[in] papz search path
* @param[out] ini_file an output buffer of AG_PATH_MAX+1 bytes
* @param[in] path_nm the name of the file we're hunting for
*/
static void
prt_ini_list(char const * const * papz, bool * need_intro,
char const * ini_file, char const * path_nm)
prt_ini_list(char const * const * papz, char const * ini_file,
char const * path_nm)
{
char pth_buf[AG_PATH_MAX+1];
if (papz == NULL)
return;
fputs(zPresetIntro, option_usage_fp);
*need_intro = false;
for (;;) {
char const * path = *(papz++);
@@ -1021,7 +985,13 @@ prt_ini_list(char const * const * papz, bool * need_intro,
}
}
/**
* Print the usage line preamble text
*
* @param opts the program option descriptor
* @param od the option descriptor
* @param at names of the option argument types
*/
static void
prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at)
{
@@ -1108,10 +1078,10 @@ prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at)
bogus_desc:
fprintf(stderr, zbad_od, opts->pzProgName, od->pz_Name);
exit(EX_SOFTWARE);
option_exits(EX_SOFTWARE);
}
/*
/**
* Print out the usage information for just the options.
*/
static void
@@ -1196,20 +1166,22 @@ prt_opt_usage(tOptions * opts, int ex_code, char const * title)
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* PROGRAM DETAILS
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* Print program details.
* @param[in] opts the program option descriptor
*/
static void
prt_prog_detail(tOptions * opts)
{
bool need_intro = true;
bool need_intro = (opts->papzHomeList == NULL);
/*
* Display all the places we look for config files
* Display all the places we look for config files, if we have
* a list of directories to search.
*/
prt_ini_list(opts->papzHomeList, &need_intro,
opts->pzRcName, opts->pzProgPath);
if (! need_intro)
prt_ini_list(opts->papzHomeList, opts->pzRcName, opts->pzProgPath);
/*
* Let the user know about environment variable settings
+3 -3
View File
@@ -166,7 +166,7 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp)
default:
fprintf(stderr, zBadVerArg, ch);
exit(EXIT_FAILURE);
option_exits(EXIT_FAILURE);
}
fflush(fp);
@@ -174,7 +174,7 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp)
fserr_exit(opts->pzProgName, zwriting,
(fp == stdout) ? zstdout_name : zstderr_name);
exit(EXIT_SUCCESS);
option_exits(EXIT_SUCCESS);
}
/*=export_func optionPrintVersion
@@ -190,7 +190,7 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp)
void
optionPrintVersion(tOptions * opts, tOptDesc * od)
{
print_ver(opts, od, stdout);
print_ver(opts, od, print_exit ? stderr : stdout);
}
/*=export_func optionVersionStderr