endif
libopts_la_SOURCES = libopts.c
libopts_la_CPPFLAGS = -I$(top_srcdir)
-libopts_la_LDFLAGS = -version-info 39:0:14
+libopts_la_LDFLAGS = -version-info 40:1:15
EXTRA_DIST = \
COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd \
MakeDefs.inc README ag-char-map.h \
alias.c ao-strs.c ao-strs.h \
- autoopts/options.h autoopts/project.h autoopts/usage-txt.h \
+ autoopts/usage-txt.h autoopts/project.h autoopts/options.h \
autoopts.c autoopts.h boolean.c \
- check.c compat/compat.h compat/snprintf.c \
- compat/pathfind.c compat/strdup.c compat/windows-config.h \
- compat/strchr.c configfile.c cook.c \
+ check.c compat/windows-config.h compat/pathfind.c \
+ compat/snprintf.c compat/strchr.c compat/compat.h \
+ compat/strdup.c configfile.c cook.c \
enum.c env.c file.c \
find.c genshell.c genshell.h \
gettext.h init.c load.c \
- m4/libopts.m4 m4/liboptschk.m4 makeshell.c \
+ m4/liboptschk.m4 m4/libopts.m4 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 parse-duration.h pgusage.c \
/*
* 29 bits for 46 character classifications
- * generated by char-mapper on 07/05/13 at 20:32:35
+ * generated by char-mapper on 07/28/13 at 08:25:15
*
* This file contains the character classifications
* used by AutoGen and AutoOpts for identifying tokens.
unsigned char const * v = ag_char_map_spanners[mask_ix];
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
- while (v[(unsigned)*p]) p++;
+ while (v[(unsigned char)*p]) p++;
return (char *)(uintptr_t)p;
}
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)*p])) p++;
+ while ((*p != '\0') && (! v[(unsigned char)*p])) p++;
return (char *)(uintptr_t)p;
}
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
if (s >= e) e = s + strlen(s);
- while ((e > s) && v[(unsigned)e[-1]]) e--;
+ while ((e > s) && v[(unsigned char)e[-1]]) e--;
return (char *)(uintptr_t)e;
}
if (v == NULL)
v = calc_ag_char_map_spanners(mask_ix);
if (s == e) e += strlen(e);
- while ((e > s) && (! v[(unsigned)e[-1]])) e--;
+ while ((e > s) && (! v[(unsigned char)e[-1]])) e--;
return (char *)(uintptr_t)e;
}
#endif /* AG_CHAR_MAP_H_GUARD */
*
* DO NOT EDIT THIS FILE (ao-strs.c)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:35 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:16 AM by AutoGen 5.18.1pre2
* From the definitions ao-strs.def
* and the template file strings
*
*
* DO NOT EDIT THIS FILE (ao-strs.h)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:35 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:16 AM by AutoGen 5.18.1pre2
* From the definitions ao-strs.def
* and the template file strings
*
*/
static unsigned int tab_skip_ct = 0;
+#ifndef HAVE_PATHFIND
+# define pathfind(_p, _n, _m) option_pathfind(_p, _n, _m)
+# include "compat/pathfind.c"
+#endif
+
+#ifndef HAVE_SNPRINTF
+# define vsnprintf option_vsnprintf
+# define snprintf option_snprintf
+# include "compat/snprintf.c"
+#endif
+
+#ifndef HAVE_STRDUP
+# define strdup(_s) option_strdup(_s)
+# include "compat/strdup.c"
+#endif
+
+#ifndef HAVE_STRCHR
+# define strrchr(_s, _c) option_strrchr(_s, _c)
+# define strchr(_s, _c) option_strchr(_s, _c)
+# include "compat/strchr.c"
+#endif
+
LOCAL void *
ao_malloc(size_t sz)
{
#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"
-#endif
-
-#ifndef HAVE_SNPRINTF
-# define vsnprintf option_vsnprintf
-# define snprintf option_snprintf
-# include "compat/snprintf.c"
-#endif
-
-#ifndef HAVE_STRDUP
-# define strdup(_s) option_strdup(_s)
-# include "compat/strdup.c"
-#endif
-
-#ifndef HAVE_STRCHR
-# define strrchr(_s, _c) option_strrchr(_s, _c)
-# define strchr(_s, _c) option_strchr(_s, _c)
-# include "compat/strchr.c"
-#endif
-
/**
* handle an option.
*
#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)
*
* DO NOT EDIT THIS FILE (options.h)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:42 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:23 AM by AutoGen 5.18.1pre2
* From the definitions funcs.def
* and the template file options_h
*
* @{
*/
/// autoopts structure version
-#define OPTIONS_STRUCT_VERSION 159744
+#define OPTIONS_STRUCT_VERSION 163841
/// autoopts structure version string
-#define OPTIONS_VERSION_STRING "39:0:14"
+#define OPTIONS_VERSION_STRING "40:1: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 "39.0"
+#define OPTIONS_DOTTED_VERSION "40.1"
/// convert a version/release number pair to an integer value
#define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r))
/// @}
*
* DO NOT EDIT THIS FILE (usage-txt.h)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:40 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:20 AM by AutoGen 5.18.1pre2
* From the definitions usage-txt.def
* and the template file usage-txt.tpl
*
*/
static void dummy_func(void) {
/* LIBOPTS-MESSAGES: */
-#line 45 "../autoopts.c"
+#line 67 "../autoopts.c"
puts(_("allocation of %d bytes failed\n"));
-#line 71 "../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 88 "../init.c"
puts(_("Automated Options Processing Error!\n"
"\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
-#line 58 "../autoopts.c"
+#line 80 "../autoopts.c"
puts(_("realloc of %d bytes at 0x%p failed\n"));
#line 92 "../init.c"
puts(_("\tThis is less than the minimum library version: "));
puts(_("could not locate the 'help' option"));
#line 336 "../autoopts.c"
puts(_("optionProcess() was called with invalid data"));
-#line 747 "../usage.c"
+#line 748 "../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."));
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"));
"\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 159 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
#line 169 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
-#line 746 "../usage.c"
+#line 747 "../usage.c"
puts(_("%s error: invalid option descriptor for %s\n"));
-#line 1080 "../usage.c"
+#line 1081 "../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 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"));
puts(_("%s error: '%s' is not a recognizable number.\n"));
#line 200 "../enum.c"
puts(_("%s error: %s exceeds %s keyword count\n"));
-#line 329 "../usage.c"
+#line 330 "../usage.c"
puts(_("Try '%s %s' for more information.\n"));
#line 45 "../alias.c"
puts(_("one %s%s option allowed\n"));
puts(_("standard output"));
#line 274 "../usage.c"
puts(_("standard output"));
-#line 414 "../usage.c"
+#line 415 "../usage.c"
puts(_("standard output"));
-#line 624 "../usage.c"
+#line 625 "../usage.c"
puts(_("standard output"));
#line 175 "../version.c"
puts(_("standard output"));
#line 274 "../usage.c"
puts(_("standard error"));
-#line 414 "../usage.c"
+#line 415 "../usage.c"
puts(_("standard error"));
-#line 624 "../usage.c"
+#line 625 "../usage.c"
puts(_("standard error"));
#line 175 "../version.c"
puts(_("standard error"));
puts(_("write"));
#line 273 "../usage.c"
puts(_("write"));
-#line 413 "../usage.c"
+#line 414 "../usage.c"
puts(_("write"));
-#line 623 "../usage.c"
+#line 624 "../usage.c"
puts(_("write"));
#line 174 "../version.c"
puts(_("write"));
/* END-LIBOPTS-MESSAGES */
/* USAGE-TEXT: */
-#line 872 "../usage.c"
+#line 873 "../usage.c"
puts(_("\t\t\t\t- an alternate for '%s'\n"));
-#line 1147 "../usage.c"
+#line 1148 "../usage.c"
puts(_("Version, usage and configuration options:"));
-#line 923 "../usage.c"
+#line 924 "../usage.c"
puts(_("\t\t\t\t- default option for unnamed options\n"));
-#line 836 "../usage.c"
+#line 837 "../usage.c"
puts(_("\t\t\t\t- disabled as '--%s'\n"));
-#line 1116 "../usage.c"
+#line 1117 "../usage.c"
puts(_(" --- %-14s %s\n"));
-#line 1114 "../usage.c"
+#line 1115 "../usage.c"
puts(_("This option has been disabled"));
-#line 863 "../usage.c"
+#line 864 "../usage.c"
puts(_("\t\t\t\t- enabled by default\n"));
#line 40 "../alias.c"
puts(_("%s error: only "));
-#line 1193 "../usage.c"
+#line 1194 "../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 379 "../usage.c"
+#line 380 "../usage.c"
puts(_("Options are specified by doubled hyphens and their name or by a single\n"
"hyphen and the flag character.\n"));
#line 916 "../makeshell.c"
"a shell script to parse the options for %s:\n\n"));
#line 166 "../enum.c"
puts(_(" or an integer mask with any of the lower %d bits set\n"));
-#line 896 "../usage.c"
+#line 897 "../usage.c"
puts(_("\t\t\t\t- is a set membership option\n"));
-#line 917 "../usage.c"
+#line 918 "../usage.c"
puts(_("\t\t\t\t- must appear between %d and %d times\n"));
-#line 381 "../usage.c"
+#line 382 "../usage.c"
puts(_("Options are specified by single or double hyphens and their name.\n"));
-#line 903 "../usage.c"
+#line 904 "../usage.c"
puts(_("\t\t\t\t- may appear multiple times\n"));
-#line 890 "../usage.c"
+#line 891 "../usage.c"
puts(_("\t\t\t\t- may not be preset\n"));
-#line 1308 "../usage.c"
+#line 1309 "../usage.c"
puts(_(" Arg Option-Name Description\n"));
-#line 1244 "../usage.c"
- puts(_(" Flg Arg Option-Name Description\n"));
-#line 1302 "../usage.c"
+#line 1245 "../usage.c"
puts(_(" Flg Arg Option-Name Description\n"));
#line 1303 "../usage.c"
+ puts(_(" Flg Arg Option-Name Description\n"));
+#line 1304 "../usage.c"
puts(_(" %3s %s"));
-#line 1309 "../usage.c"
+#line 1310 "../usage.c"
puts(_(" %3s %s"));
-#line 386 "../usage.c"
+#line 387 "../usage.c"
puts(_("The '-#<number>' option may omit the hash char\n"));
-#line 382 "../usage.c"
+#line 383 "../usage.c"
puts(_("All arguments are named options.\n"));
-#line 970 "../usage.c"
+#line 971 "../usage.c"
puts(_(" - reading file %s"));
-#line 408 "../usage.c"
+#line 409 "../usage.c"
puts(_("\n"
"Please send bug reports to: <%s>\n"));
#line 100 "../version.c"
#line 129 "../version.c"
puts(_("\n"
"Please send bug reports to: <%s>\n"));
-#line 902 "../usage.c"
+#line 903 "../usage.c"
puts(_("\t\t\t\t- may NOT appear - preset only\n"));
-#line 943 "../usage.c"
+#line 944 "../usage.c"
puts(_("\n"
"The following option preset mechanisms are supported:\n"));
-#line 1191 "../usage.c"
+#line 1192 "../usage.c"
puts(_("\n"
"The following option preset mechanisms are supported:\n"));
-#line 681 "../usage.c"
+#line 682 "../usage.c"
puts(_("prohibits these options:\n"));
-#line 676 "../usage.c"
+#line 677 "../usage.c"
puts(_("prohibits the option '%s'\n"));
#line 81 "../numeric.c"
puts(_("%s%ld to %ld"));
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 389 "../usage.c"
+#line 390 "../usage.c"
puts(_("Operands and options may be intermixed. They will be reordered.\n"));
-#line 651 "../usage.c"
+#line 652 "../usage.c"
puts(_("requires the option '%s'\n"));
-#line 654 "../usage.c"
+#line 655 "../usage.c"
puts(_("requires these options:\n"));
-#line 1320 "../usage.c"
+#line 1321 "../usage.c"
puts(_(" Arg Option-Name Req? Description\n"));
-#line 1314 "../usage.c"
+#line 1315 "../usage.c"
puts(_(" Flg Arg Option-Name Req? Description\n"));
#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 909 "../usage.c"
+#line 910 "../usage.c"
puts(_("\t\t\t\t- may appear up to %d times\n"));
#line 77 "../enum.c"
puts(_("The valid \"%s\" option keywords are:\n"));
-#line 1151 "../usage.c"
+#line 1152 "../usage.c"
puts(_("The next option supports vendor supported extra options:"));
-#line 772 "../usage.c"
+#line 773 "../usage.c"
puts(_("These additional options are:"));
/* END-USAGE-TEXT */
}
static char *
pathfind( char const * path,
- char const * fileName,
+ char const * fname,
char const * mode );
#include "compat.h"
#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
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 zPath[ AG_PATH_MAX + 1 ];
+ int p_index = 0;
+ int mode_bits = 0;
+ char * res_path = NULL;
+ char zPath[ AG_PATH_MAX + 1 ];
if (strchr( mode, 'r' )) mode_bits |= R_OK;
if (strchr( mode, 'w' )) mode_bits |= W_OK;
DIR* dirP;
char* colon_unit = extract_colon_unit( zPath, path, &p_index );
- /*
- * IF no more entries, THEN quit
- */
if (colon_unit == NULL)
break;
if (dirP == NULL)
continue;
- /*
- * FOR every entry in the given directory, ...
- */
for (;;) {
struct dirent *entP = readdir( dirP );
/*
* 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;
}
/*
strchr(char const *s, int c)
{
do {
- if ((unsigned)*s == (unsigned)c)
+ if ((unsigned char)*s == (unsigned char)c)
return s;
} while (*(++s) != NUL);
if (--e < s)
break;
- if ((unsigned)*e == (unsigned)c)
+ if ((unsigned char)*e == (unsigned char)c)
return e;
}
return NULL;
tmap_info_t cfgfile;
tOptState optst = OPTSTATE_INITIALIZER(PRESET);
opt_state_mask_t st_flags = optst.flags;
+ opt_state_mask_t fl_save = opts->fOptSet;
char * ftext =
text_mmap(fname, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile);
if (TEXT_MMAP_FAILED_ADDR(ftext))
return;
+ /*
+ * While processing config files, we ignore errors.
+ */
+ opts->fOptSet &= ~OPTPROC_ERRSTOP;
+
if (dir == DIRECTION_CALLED) {
st_flags = OPTST_DEFINED;
dir = DIRECTION_PROCESS;
all_done:
text_munmap(&cfgfile);
+ opts->fOptSet = fl_save;
}
/**
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;
}
* "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;
}
return NULL;
*txt = NUL;
txt += 2;
- loadOptionLine(opts, ost, pzName, dir, mode);
+ load_opt_line(opts, ost, pzName, dir, mode);
return txt;
case '>':
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));
* "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;
}
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);
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 */
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);
*
* DO NOT EDIT THIS FILE (genshell.c)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:39 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:19 AM by AutoGen 5.18.1pre2
* From the definitions genshell.def
* and the template file options
*
- * Generated from AutoOpts 39:0:14 templates.
+ * Generated from AutoOpts 40:1:15 templates.
*
* AutoOpts is a copyrighted work. This source file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
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
/* referenced via genshelloptOptions.pzShortUsage */
puts(_("<<<NOT-FOUND>>>"));
/* LIBOPTS-MESSAGES: */
-#line 45 "../autoopts.c"
+#line 67 "../autoopts.c"
puts(_("allocation of %d bytes failed\n"));
-#line 71 "../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 88 "../init.c"
puts(_("Automated Options Processing Error!\n"
"\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
-#line 58 "../autoopts.c"
+#line 80 "../autoopts.c"
puts(_("realloc of %d bytes at 0x%p failed\n"));
#line 92 "../init.c"
puts(_("\tThis is less than the minimum library version: "));
puts(_("optionProcess() was called with invalid data"));
#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."));
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"));
"\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 159 "../enum.c"
puts(_(" or an integer from %d through %d\n"));
puts(_("%s error: invalid option descriptor for %s\n"));
#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 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"));
*
* DO NOT EDIT THIS FILE (genshell.h)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:39 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:19 AM by AutoGen 5.18.1pre2
* From the definitions genshell.def
* and the template file options
*
- * Generated from AutoOpts 39:0:14 templates.
+ * Generated from AutoOpts 40:1:15 templates.
*
* AutoOpts is a copyrighted work. This header file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
* tolerable version is at least as old as what was current when the header
* template was released.
*/
-#define AO_TEMPLATE_VERSION 159744
+#define AO_TEMPLATE_VERSION 163841
#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
|| (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
# error option template version mismatches autoopts/options.h header
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;
- }
+
+ pz = pathfind(getenv("PATH"), (char *)pname, "rx");
+ if (pz != NULL)
+ pname = (void *)pz;
pp = (char const **)(void **)&(opts->pzProgPath);
*pp = pname;
/* = = = 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 *
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.
* 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))
- return false;
+ 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;
- int ct = b_sz;
+ 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;
* 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;
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))
- return false;
- }
-
-#if defined(HAVE_CANONICALIZE_FILE_NAME)
- {
- char * pz = canonicalize_file_name(pzBuf);
- if (pz == NULL)
+ if (! add_env_val(p_buf, b_sz, fname))
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:
* 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,
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)
{
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
}
/**
- * Load an option from a block of text. The text must start with the
- * configurable/option name and be followed by its associated value.
- * That value may be processed in any of several ways. See "tOptionLoadMode"
- * in autoopts.h.
- *
- * @param[in,out] opts program options descriptor
- * @param[in,out] opt_state option processing state
- * @param[in,out] line source line with long option name in it
- * @param[in] direction current processing direction (preset or not)
- * @param[in] load_mode option loading mode (OPTION_LOAD_*)
+ * See if the option is to be processed in the current scan direction
+ * (-1 or +1).
*/
-LOCAL void
-loadOptionLine(tOptions * opts, tOptState * opt_state, char * line,
- tDirection direction, tOptionLoadMode load_mode )
+static bool
+direction_ok(opt_state_mask_t f, int dir)
{
- line = SPN_LOAD_LINE_SKIP_CHARS(line);
-
- {
- char * arg = assemble_arg_val(line, load_mode);
-
- if (! SUCCESSFUL(opt_find_long(opts, line, opt_state)))
- return;
-
- if (opt_state->flags & OPTST_NO_INIT)
- return;
+ if (dir == 0)
+ return true;
- opt_state->pzOptArg = trim_quotes(arg);
- }
-
- switch (opt_state->flags & (OPTST_IMM|OPTST_DISABLE_IMM)) {
+ 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(direction))
- return;
+ if (PRESETTING(dir))
+ return false;
break;
case OPTST_IMM:
- if (PRESETTING(direction)) {
+ 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 ((opt_state->flags & OPTST_DISABLED) == 0)
- return;
+ 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 ((opt_state->flags & OPTST_DISABLED) != 0)
- return;
+ if ((f & OPTST_DISABLED) != 0)
+ return false;
}
break;
case OPTST_DISABLE_IMM:
- if (PRESETTING(direction)) {
+ 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 ((opt_state->flags & OPTST_DISABLED) != 0)
- return;
+ 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 ((opt_state->flags & OPTST_DISABLED) == 0)
- return;
+ if ((f & OPTST_DISABLED) == 0)
+ return false;
}
break;
* THEREFORE, if the direction is PROCESSING
* THEN we skip this option.
*/
- if (PROCESSING(direction))
- return;
+ if (PROCESSING(dir))
+ return false;
break;
}
+ return true;
+}
+
+/**
+ * Load an option from a block of text. The text must start with the
+ * configurable/option name and be followed by its associated value.
+ * That value may be processed in any of several ways. See "tOptionLoadMode"
+ * in autoopts.h.
+ *
+ * @param[in,out] opts program options descriptor
+ * @param[in,out] opt_state option processing state
+ * @param[in,out] line source line with long option name in it
+ * @param[in] direction current processing direction (preset or not)
+ * @param[in] load_mode option loading mode (OPTION_LOAD_*)
+ */
+LOCAL void
+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;
+
+ } else if (! SUCCESSFUL(opt_find_short(opts, *line, opt_state)))
+ return;
+
+ if ((! CALLED(direction)) && (opt_state->flags & OPTST_NO_INIT))
+ return;
+
+ opt_state->pzOptArg = trim_quotes(arg);
+ }
+
+ if (! direction_ok(opt_state->flags, direction))
+ return;
/*
* Fix up the args.
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;
}
/** @}
*
dnl
dnl DO NOT EDIT THIS FILE (libopts.m4)
dnl
-dnl It has been AutoGen-ed July 5, 2013 at 08:32:31 PM by AutoGen 5.17.5pre9
+dnl It has been AutoGen-ed July 28, 2013 at 08:25:12 AM by AutoGen 5.18.1pre2
dnl From the definitions libopts.def
dnl and the template file conftest.tpl
dnl
*
* DO NOT EDIT THIS FILE (stdin.c)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:38 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:18 AM by AutoGen 5.18.1pre2
* From the definitions stdin
* and the template file str2enum
*
*
* DO NOT EDIT THIS FILE (stdin.h)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:37 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:18 AM by AutoGen 5.18.1pre2
* From the definitions stdin
* and the template file str2enum
*
*
* DO NOT EDIT THIS FILE (stdin.c)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:36 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:17 AM by AutoGen 5.18.1pre2
* From the definitions stdin
* and the template file str2enum
*
*
* DO NOT EDIT THIS FILE (stdin.h)
*
- * It has been AutoGen-ed July 5, 2013 at 08:32:36 PM by AutoGen 5.17.5pre9
+ * It has been AutoGen-ed July 28, 2013 at 08:25:17 AM by AutoGen 5.18.1pre2
* From the definitions stdin
* and the template file str2enum
*
}
{
+ static mode_t const cmask = S_IRWXO | S_IRWXG;
+ mode_t svmsk = umask(cmask);
int fd = mkstemp(bf);
+ (void)umask(svmsk);
+
if (fd < 0) {
AGFREE(bf);
return NULL;
/* -*- buffer-read-only: t -*- vi: set ro:
*
* Prototypes for autoopts
- * Generated Fri Jul 5 20:32:50 PDT 2013
+ * Generated Sun Jul 28 08:25:30 PDT 2013
*/
#ifndef AUTOOPTS_PROTO_H_GUARD
#define AUTOOPTS_PROTO_H_GUARD 1
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
if ((s != NULL) && (*s != NUL)) {
unsigned char equiv = (unsigned char)*s;
while (*s != NUL)
- charmap[ (unsigned)*(s++) ] = equiv;
+ charmap[(unsigned char)*(s++)] = equiv;
}
}
strtransform(char* d, char const* s)
{
do {
- *(d++) = (char)charmap[ (unsigned)*s ];
+ *(d++) = (char)charmap[(unsigned char)*s];
} while (*(s++) != NUL);
}
mapinfo->txt_prot = prot;
mapinfo->txt_flags = flags;
- /*
- * Make sure we can stat the regular file. Save the file size.
- */
- {
- struct stat sb;
- if (stat(fname, &sb) != 0) {
- mapinfo->txt_errno = errno;
- return;
- }
-
- if (! S_ISREG(sb.st_mode)) {
- mapinfo->txt_errno = errno = EINVAL;
- return;
- }
-
- mapinfo->txt_size = (size_t)sb.st_size;
- }
-
/*
* Map mmap flags and protections into open flags and do the open.
*/
o_flag |= O_EXCL;
mapinfo->txt_fd = open(fname, o_flag);
+ if (mapinfo->txt_fd < 0) {
+ mapinfo->txt_errno = errno;
+ mapinfo->txt_fd = AO_INVALID_FD;
+ return;
+ }
+ }
+
+ /*
+ * Make sure we can stat the regular file. Save the file size.
+ */
+ {
+ struct stat sb;
+ if (fstat(mapinfo->txt_fd, &sb) != 0) {
+ mapinfo->txt_errno = errno;
+ close(mapinfo->txt_fd);
+ return;
+ }
+
+ if (! S_ISREG(sb.st_mode)) {
+ mapinfo->txt_errno = errno = EINVAL;
+ close(mapinfo->txt_fd);
+ return;
+ }
+
+ mapinfo->txt_size = (size_t)sb.st_size;
}
if (mapinfo->txt_fd == AO_INVALID_FD)
case OPTPROC_LONGOPT:
case (OPTPROC_LONGOPT | OPTPROC_SHORTOPT):
strcpy(help, "--help");
+ break;
case 0:
strcpy(help, "help");