]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8
authorHarlan Stenn <stenn@ntp.org>
Sun, 1 May 2011 06:41:53 +0000 (02:41 -0400)
committerHarlan Stenn <stenn@ntp.org>
Sun, 1 May 2011 06:41:53 +0000 (02:41 -0400)
bk: 4dbd00b1vj8fGpXXPfDZvvthalEWtg

27 files changed:
ChangeLog
sntp/libopts/Makefile.am
sntp/libopts/ag-char-map.h
sntp/libopts/autoopts.c
sntp/libopts/autoopts.h
sntp/libopts/autoopts/options.h
sntp/libopts/autoopts/project.h [new file with mode: 0644]
sntp/libopts/autoopts/usage-txt.h
sntp/libopts/configfile.c
sntp/libopts/cook.c
sntp/libopts/enumeration.c
sntp/libopts/environment.c
sntp/libopts/genshell.c
sntp/libopts/genshell.h
sntp/libopts/libopts.c
sntp/libopts/m4/libopts.m4
sntp/libopts/makeshell.c
sntp/libopts/numeric.c
sntp/libopts/parse-duration.c
sntp/libopts/parse-duration.h
sntp/libopts/pgusage.c
sntp/libopts/proto.h
sntp/libopts/save.c
sntp/libopts/time.c
sntp/libopts/value-type.h
sntp/libopts/version.c
sntp/libopts/xat-attribute.h

index 6f62d09d61cd1925bc9d90893fa065daf04b418e..b095d6c3ae48f1c71a9d2dc4df93b91a95f0cb06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+
+* Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8.
+
 ---
 (4.2.6p3) 2011/01/03 Released by Harlan Stenn <stenn@ntp.org>
 
index 5241c6b656ea1670e3c05d9e43832dcee6105220..a94972e057718eb441f93ec420781471cb58c38d 100644 (file)
@@ -7,22 +7,22 @@ noinst_LTLIBRARIES      = libopts.la
 endif
 libopts_la_SOURCES      = libopts.c
 libopts_la_CPPFLAGS     = -I$(top_srcdir)
-libopts_la_LDFLAGS      = -version-info  34:0:9
+libopts_la_LDFLAGS      = -version-info  35:0:10
 EXTRA_DIST              = \
     COPYING.gplv3           COPYING.lgplv3          COPYING.mbsd  \
     MakeDefs.inc            README                  ag-char-map.h  \
-    autoopts/options.h      autoopts/usage-txt.h    autoopts.c  \
-    autoopts.h              boolean.c               compat/strchr.c  \
-    compat/strdup.c         compat/compat.h         compat/snprintf.c  \
-    compat/pathfind.c       compat/windows-config.h configfile.c  \
-    cook.c                  enumeration.c           environment.c  \
-    file.c                  genshell.c              genshell.h  \
-    load.c                  m4/liboptschk.m4        m4/libopts.m4  \
-    makeshell.c             nested.c                numeric.c  \
-    parse-duration.c        parse-duration.h        pgusage.c  \
-    proto.h                 putshell.c              reset.c  \
-    restore.c               save.c                  sort.c  \
-    stack.c                 streqvcmp.c             text_mmap.c  \
-    time.c                  tokenize.c              usage.c  \
-    value-type.c            value-type.h            version.c  \
-    xat-attribute.c         xat-attribute.h
+    autoopts/usage-txt.h    autoopts/options.h      autoopts/project.h  \
+    autoopts.c              autoopts.h              boolean.c  \
+    compat/strdup.c         compat/compat.h         compat/windows-config.h  \
+    compat/snprintf.c       compat/strchr.c         compat/pathfind.c  \
+    configfile.c            cook.c                  enumeration.c  \
+    environment.c           file.c                  genshell.c  \
+    genshell.h              load.c                  m4/liboptschk.m4  \
+    m4/libopts.m4           makeshell.c             nested.c  \
+    numeric.c               parse-duration.c        parse-duration.h  \
+    pgusage.c               proto.h                 putshell.c  \
+    reset.c                 restore.c               save.c  \
+    sort.c                  stack.c                 streqvcmp.c  \
+    text_mmap.c             time.c                  tokenize.c  \
+    usage.c                 value-type.c            value-type.h  \
+    version.c               xat-attribute.c         xat-attribute.h
index da53091b4f8b9eaabafd1348c41b660e3296939e..b4f088ef3a4baa3c425a26988401c523f119cf4f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *   Character mapping generated 02/17/11 16:58:35
+ *   Character mapping generated 04/29/11 15:43:58
  *
  *  This file contains the character classifications
  *  used by AutoGen and AutoOpts for identifying tokens.
@@ -70,7 +70,7 @@
 // 
 // %guard          autoopts_internal
 // %file           ag-char-map.h
-// %table          option-char-category
+// %static-table   option-char-category
 // 
 // %comment
 //   This file contains the character classifications
 #endif /* 0 -- mapping spec. source */
 
 typedef uint32_t option_char_category_mask_t;
-extern option_char_category_mask_t const option_char_category[128];
+static option_char_category_mask_t const option_char_category[128];
 
 static inline int is_option_char_category_char(char ch, option_char_category_mask_t mask) {
     unsigned int ix = (unsigned char)ch;
-    return ((ix < 0x7F) && ((option_char_category[ix] & mask) != 0)); }
+    return ((ix < 128) && ((option_char_category[ix] & mask) != 0)); }
 
 #define IS_LOWER_CASE_CHAR(_c)      is_option_char_category_char((_c), 0x000001)
 #define IS_UPPER_CASE_CHAR(_c)      is_option_char_category_char((_c), 0x000002)
@@ -153,8 +153,8 @@ static inline int is_option_char_category_char(char ch, option_char_category_mas
 #define IS_END_TOKEN_CHAR(_c)       is_option_char_category_char((_c), 0x100500)
 #define IS_END_LIST_ENTRY_CHAR(_c)  is_option_char_category_char((_c), 0x300500)
 
-#ifdef AUTOOPTS_INTERNAL
-option_char_category_mask_t const option_char_category[128] = {
+#if 1 /* def AUTOOPTS_INTERNAL */
+static option_char_category_mask_t const option_char_category[128] = {
   /*x00*/ 0x140000, /*x01*/ 0x000000, /*x02*/ 0x000000, /*x03*/ 0x000000,
   /*x04*/ 0x000000, /*x05*/ 0x000000, /*x06*/ 0x000000, /*\a */ 0x000000,
   /*\b */ 0x000400, /*\t */ 0x000100, /*\n */ 0x000400, /*\v */ 0x000400,
index ad03df685ccd4eb3149c2affdf4c02dd4821c7bf..657818181b82b7a8590fc61398dc209cad2aa12e 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file autoopts.c
  *
- *  Time-stamp:      "2011-01-06 12:44:21 bkorb"
+ *  Time-stamp:      "2011-03-25 17:55:07 bkorb"
  *
  *  This file contains all of the routines that must be linked into
  *  an executable to use the generated option processing.  The optional
@@ -41,6 +41,7 @@ static ag_bool      displayEnum          = AG_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;
 
@@ -93,17 +94,6 @@ ao_realloc(void *p, size_t sz)
 #undef  realloc
 #define realloc(_p,_s) ao_realloc(_p,_s)
 
-
-LOCAL void
-ao_free(void *p)
-{
-    if (p != NULL)
-        free(p);
-}
-#undef  free
-#define free(_p) ao_free(_p)
-
-
 LOCAL char *
 ao_strdup(char const *str)
 {
index 2aaadf19cdf0d458e3c73bb97c708bbcdf9de0fe..831a52b1880859acf831909699711d876a1b78a8 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  \file autoopts.h
  *
- *  Time-stamp:      "2010-12-18 11:53:11 bkorb"
+ *  Time-stamp:      "2011-03-25 17:51:34 bkorb"
  *
  *  This file defines all the global structures and special values
  *  used in the automated option processing library.
@@ -87,37 +87,6 @@ typedef int tDirection;
 #define PROCESSING(d)           ((d)>0)
 #define PRESETTING(d)           ((d)<0)
 
-/*
- *  Procedure success codes
- *
- *  USAGE:  define procedures to return "tSuccess".  Test their results
- *          with the SUCCEEDED, FAILED and HADGLITCH macros.
- *
- *  Microsoft sticks its nose into user space here, so for Windows' sake,
- *  make sure all of these are undefined.
- */
-#undef  SUCCESS
-#undef  FAILURE
-#undef  PROBLEM
-#undef  SUCCEEDED
-#undef  SUCCESSFUL
-#undef  FAILED
-#undef  HADGLITCH
-
-#define SUCCESS                 ((tSuccess) 0)
-#define FAILURE                 ((tSuccess)-1)
-#define PROBLEM                 ((tSuccess) 1)
-
-typedef int tSuccess;
-
-#define SUCCEEDED(p)          ((p) == SUCCESS)
-#define SUCCESSFUL(p)         SUCCEEDED(p)
-#define FAILED(p)             ((p) <  SUCCESS)
-#define HADGLITCH(p)          ((p) >  SUCCESS)
-
-#define ShellAsString(_s)  #_s
-#define DEFAULT_SHELL ShellAsString(CONFIG_SHELL)
-
 /*
  *  When loading a line (or block) of text as an option, the value can
  *  be processed in any of several modes:
@@ -161,8 +130,6 @@ typedef enum {
     PAGER_STATE_CHILD
 } tePagerState;
 
-extern tePagerState pagerState;
-
 typedef enum {
     ENV_ALL,
     ENV_IMM,
@@ -216,7 +183,7 @@ typedef struct {
 
 #define AGALOC(c, w)          ao_malloc((size_t)c)
 #define AGREALOC(p, c, w)     ao_realloc((void*)p, (size_t)c)
-#define AGFREE(_p)            do{void*X=(void*)_p;ao_free(X);}while(0)
+#define AGFREE(_p)            free((void *)_p)
 #define AGDUPSTR(p, s, w)     (p = ao_strdup(s))
 
 static void *
@@ -225,8 +192,7 @@ ao_malloc(size_t sz);
 static void *
 ao_realloc(void *p, size_t sz);
 
-static void
-ao_free(void *p);
+#define ao_free(_p) free((void *)_p)
 
 static char *
 ao_strdup(char const *str);
index af60c44a290a5cf49fc5031797406c19ebd3459a..c2925e7999bf22638e3d0922b3a564d2dd01c60e 100644 (file)
@@ -2,7 +2,7 @@
  *  
  *  DO NOT EDIT THIS FILE   (options.h)
  *  
- *  It has been AutoGen-ed  February 17, 2011 at 04:58:38 PM by AutoGen 5.11.6
+ *  It has been AutoGen-ed  April 29, 2011 at 03:44:02 PM by AutoGen 5.11.9
  *  From the definitions    funcs.def
  *  and the template file   options_h
  *
@@ -22,7 +22,8 @@
  *  See the GNU Lesser General Public License for more details.
  *  
  *  You should have received a copy of the GNU Lesser General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.";
+
  */
 #ifndef AUTOOPTS_OPTIONS_H_GUARD
 #define AUTOOPTS_OPTIONS_H_GUARD 1
@@ -65,8 +66,8 @@
  *  See the relevant generated header file to determine which and what
  *  values for "opt_name" are available.
  */
-#define  OPTIONS_STRUCT_VERSION  139264
-#define  OPTIONS_VERSION_STRING  "34:0:9"
+#define  OPTIONS_STRUCT_VERSION  143360
+#define  OPTIONS_VERSION_STRING  "35:0:10"
 #define  OPTIONS_MINIMUM_VERSION 102400
 #define  OPTIONS_MIN_VER_STRING  "25:0:0"
 
@@ -115,6 +116,15 @@ typedef union {
     char const *    file_mode;
 } tuFileMode;
 
+typedef struct argList tArgList;
+#define MIN_ARG_ALLOC_CT   6
+#define INCR_ARG_ALLOC_CT  8
+struct argList {
+    int             useCt;
+    int             allocCt;
+    char const *    apzArgs[MIN_ARG_ALLOC_CT];
+};
+
 /*
  *  Bits in the fOptState option descriptor field.
  */
@@ -334,21 +344,6 @@ typedef tUsageProc* tpUsageProc;
 #define OPTION_LIMIT     SHRT_MAX
 #define NO_EQUIVALENT    (OPTION_LIMIT+1)
 
-/*
- *  Special values for optValue.  It must not be generatable from the
- *  computation "optIndex +96".  Since "optIndex" is limited to 100, ...
- */
-#define NUMBER_OPTION    '#'
-
-typedef struct argList tArgList;
-#define MIN_ARG_ALLOC_CT   6
-#define INCR_ARG_ALLOC_CT  8
-struct argList {
-    int             useCt;
-    int             allocCt;
-    tCC*            apzArgs[ MIN_ARG_ALLOC_CT ];
-};
-
 typedef union {
     char const *    argString;
     uintptr_t       argEnum;
@@ -356,7 +351,7 @@ typedef union {
     long            argInt;
     unsigned long   argUint;
     unsigned int    argBool;
-    FILE          argFp;
+    FILE *          argFp;
     int             argFd;
 } optArgBucket_t;
 
@@ -512,7 +507,8 @@ typedef struct {
 #define TEXT_MMAP_FAILED_ADDR(a)  ((void*)(a) ==  (void*)MAP_FAILED)
 
 #ifdef  __cplusplus
-extern "C" {
+#define CPLUSPLUS_OPENER extern "C" {
+CPLUSPLUS_OPENER
 #define CPLUSPLUS_CLOSER }
 #else
 #define CPLUSPLUS_CLOSER
@@ -741,7 +737,7 @@ extern const tOptionValue* optionNextValue(const tOptionValue*, const tOptionVal
 extern void optionOnlyUsage(tOptions*, int);
 
 
-/* From: autoopts.c line 1075
+/* From: autoopts.c line 1065
  *
  * optionProcess - this is the main option processing routine
  *
@@ -788,7 +784,7 @@ extern int optionProcess(tOptions*, int, char**);
 extern void optionRestore(tOptions*);
 
 
-/* From: save.c line 671
+/* From: save.c line 664
  *
  * optionSaveFile - saves the option state to a file
  *
@@ -1046,6 +1042,8 @@ extern void optionShowRange(tOptions*, tOptDesc*, void *, int);
 
 extern void optionStackArg(tOptions*, tOptDesc*);
 
+extern void optionTimeDate(tOptions*, tOptDesc*);
+
 extern void optionTimeVal(tOptions*, tOptDesc*);
 
 extern void optionUnstackArg(tOptions*, tOptDesc*);
diff --git a/sntp/libopts/autoopts/project.h b/sntp/libopts/autoopts/project.h
new file mode 100644 (file)
index 0000000..b01affb
--- /dev/null
@@ -0,0 +1,50 @@
+
+#ifndef AUTOGEN_PROJECT_H
+#define AUTOGEN_PROJECT_H
+
+#include "config.h"
+
+/*
+ *  Procedure success codes
+ *
+ *  USAGE:  define procedures to return "tSuccess".  Test their results
+ *          with the SUCCEEDED, FAILED and HADGLITCH macros.
+ *
+ *  Microsoft sticks its nose into user space here, so for Windows' sake,
+ *  make sure all of these are undefined.
+ */
+#undef  SUCCESS
+#undef  FAILURE
+#undef  PROBLEM
+#undef  SUCCEEDED
+#undef  SUCCESSFUL
+#undef  FAILED
+#undef  HADGLITCH
+
+#define SUCCESS  ((tSuccess) 0)
+#define FAILURE  ((tSuccess)-1)
+#define PROBLEM  ((tSuccess) 1)
+
+typedef int tSuccess;
+
+#define SUCCEEDED(p)    ((p) == SUCCESS)
+#define SUCCESSFUL(p)   SUCCEEDED(p)
+#define FAILED(p)       ((p) <  SUCCESS)
+#define HADGLITCH(p)    ((p) >  SUCCESS)
+
+#ifndef STR
+#  define __STR(s)      #s
+#  define STR(s)        __STR(s)
+#endif
+
+#define STRSIZE(s)      (sizeof(s)-1)
+
+#ifdef DEFINING
+#  define VALUE(s)      = s
+#  define MODE
+#else
+#  define VALUE(s)
+#  define MODE extern
+#endif
+
+#endif /* AUTOGEN_PROJECT_H */
index 41edba7cde37e579f092500b1d3c6762e2cd62d8..de92663424b938ee1d538fdd7972811b07305b13 100644 (file)
@@ -2,12 +2,12 @@
  *  
  *  DO NOT EDIT THIS FILE   (usage-txt.h)
  *  
- *  It has been AutoGen-ed  February 17, 2011 at 04:58:36 PM by AutoGen 5.11.6
+ *  It has been AutoGen-ed  April 29, 2011 at 03:44:00 PM by AutoGen 5.11.9
  *  From the definitions    usage-txt.def
  *  and the template file   usage-txt.tpl
  *
  *  This file handles all the bookkeeping required for tracking all the little
- *  tiny strings used by the AutoOpts library.  There are 140
+ *  tiny strings used by the AutoOpts library.  There are 142
  *  of them.  This is not versioned because it is entirely internal to the
  *  library and accessed by client code only in a very well-controlled way:
  *  they may substitute translated strings using a procedure that steps through
@@ -24,7 +24,8 @@
  *  See the GNU Lesser General Public License for more details.
  *  
  *  You should have received a copy of the GNU Lesser General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.";
+
  */
 #ifndef AUTOOPTS_USAGE_TXT_H_GUARD
 #define AUTOOPTS_USAGE_TXT_H_GUARD 1
@@ -44,7 +45,7 @@ typedef struct {
   char*     utpz_GnuTimeArg;
   char*     utpz_GnuNumArg;
   char*     utpz_GnuStrArg;
-  cch_t*    apz_str[ 133 ];
+  cch_t*    apz_str[ 135 ];
 } usage_text_t;
 
 /*
@@ -128,75 +129,77 @@ extern usage_text_t option_usage_text;
 #define zMust                 (option_usage_text.apz_str[ 61])
 #define zNeedOne              (option_usage_text.apz_str[ 62])
 #define zNoArg                (option_usage_text.apz_str[ 63])
-#define zNoArgs               (option_usage_text.apz_str[ 64])
-#define zNoCreat              (option_usage_text.apz_str[ 65])
-#define zNoFlags              (option_usage_text.apz_str[ 66])
-#define zNoKey                (option_usage_text.apz_str[ 67])
-#define zNoLim                (option_usage_text.apz_str[ 68])
-#define zNoPreset             (option_usage_text.apz_str[ 69])
-#define zNoResetArg           (option_usage_text.apz_str[ 70])
-#define zNoRq_NoShrtTtl       (option_usage_text.apz_str[ 71])
-#define zNoRq_ShrtTtl         (option_usage_text.apz_str[ 72])
-#define zNoStat               (option_usage_text.apz_str[ 73])
-#define zNoState              (option_usage_text.apz_str[ 74])
-#define zNone                 (option_usage_text.apz_str[ 75])
-#define zNotDef               (option_usage_text.apz_str[ 76])
-#define zNotCmdOpt            (option_usage_text.apz_str[ 77])
-#define zNotEnough            (option_usage_text.apz_str[ 78])
-#define zNotFile              (option_usage_text.apz_str[ 79])
-#define zNotNumber            (option_usage_text.apz_str[ 80])
-#define zNrmOptFmt            (option_usage_text.apz_str[ 81])
-#define zNumberOpt            (option_usage_text.apz_str[ 82])
-#define zOneSpace             (option_usage_text.apz_str[ 83])
-#define zOnlyOne              (option_usage_text.apz_str[ 84])
-#define zOptsOnly             (option_usage_text.apz_str[ 85])
-#define zOutputFail           (option_usage_text.apz_str[ 86])
-#define zPathFmt              (option_usage_text.apz_str[ 87])
-#define zPlsSendBugs          (option_usage_text.apz_str[ 88])
-#define zPreset               (option_usage_text.apz_str[ 89])
-#define zPresetFile           (option_usage_text.apz_str[ 90])
-#define zPresetIntro          (option_usage_text.apz_str[ 91])
-#define zProhib               (option_usage_text.apz_str[ 92])
-#define zReorder              (option_usage_text.apz_str[ 93])
-#define zRange                (option_usage_text.apz_str[ 94])
-#define zRangeAbove           (option_usage_text.apz_str[ 95])
-#define zRangeLie             (option_usage_text.apz_str[ 96])
-#define zRangeBadLie          (option_usage_text.apz_str[ 97])
-#define zRangeOnly            (option_usage_text.apz_str[ 98])
-#define zRangeOr              (option_usage_text.apz_str[ 99])
-#define zRangeErr             (option_usage_text.apz_str[100])
-#define zRangeExact           (option_usage_text.apz_str[101])
-#define zRangeScaled          (option_usage_text.apz_str[102])
-#define zRangeUpto            (option_usage_text.apz_str[103])
-#define zResetNotConfig       (option_usage_text.apz_str[104])
-#define zReqFmt               (option_usage_text.apz_str[105])
-#define zReqOptFmt            (option_usage_text.apz_str[106])
-#define zReqThese             (option_usage_text.apz_str[107])
-#define zReq_NoShrtTtl        (option_usage_text.apz_str[108])
-#define zReq_ShrtTtl          (option_usage_text.apz_str[109])
-#define zSepChars             (option_usage_text.apz_str[110])
-#define zSetMemberSettings    (option_usage_text.apz_str[111])
-#define zShrtGnuOptFmt        (option_usage_text.apz_str[112])
-#define zSixSpaces            (option_usage_text.apz_str[113])
-#define zStdBoolArg           (option_usage_text.apz_str[114])
-#define zStdBreak             (option_usage_text.apz_str[115])
-#define zStdFileArg           (option_usage_text.apz_str[116])
-#define zStdKeyArg            (option_usage_text.apz_str[117])
-#define zStdKeyLArg           (option_usage_text.apz_str[118])
-#define zStdTimeArg           (option_usage_text.apz_str[119])
-#define zStdNestArg           (option_usage_text.apz_str[120])
-#define zStdNoArg             (option_usage_text.apz_str[121])
-#define zStdNumArg            (option_usage_text.apz_str[122])
-#define zStdOptArg            (option_usage_text.apz_str[123])
-#define zStdReqArg            (option_usage_text.apz_str[124])
-#define zStdStrArg            (option_usage_text.apz_str[125])
-#define zTabHyp               (option_usage_text.apz_str[126])
-#define zTabHypAnd            (option_usage_text.apz_str[127])
-#define zTabout               (option_usage_text.apz_str[128])
-#define zThreeSpaces          (option_usage_text.apz_str[129])
-#define zTwoSpaces            (option_usage_text.apz_str[130])
-#define zUpTo                 (option_usage_text.apz_str[131])
-#define zValidKeys            (option_usage_text.apz_str[132])
+#define zNoArgv               (option_usage_text.apz_str[ 64])
+#define zNoArgs               (option_usage_text.apz_str[ 65])
+#define zNoCreat              (option_usage_text.apz_str[ 66])
+#define zNoFlags              (option_usage_text.apz_str[ 67])
+#define zNoKey                (option_usage_text.apz_str[ 68])
+#define zNoLim                (option_usage_text.apz_str[ 69])
+#define zNoPreset             (option_usage_text.apz_str[ 70])
+#define zNoResetArg           (option_usage_text.apz_str[ 71])
+#define zNoRq_NoShrtTtl       (option_usage_text.apz_str[ 72])
+#define zNoRq_ShrtTtl         (option_usage_text.apz_str[ 73])
+#define zNoStat               (option_usage_text.apz_str[ 74])
+#define zNoState              (option_usage_text.apz_str[ 75])
+#define zNone                 (option_usage_text.apz_str[ 76])
+#define zNotDef               (option_usage_text.apz_str[ 77])
+#define zNotCmdOpt            (option_usage_text.apz_str[ 78])
+#define zNotEnough            (option_usage_text.apz_str[ 79])
+#define zNotFile              (option_usage_text.apz_str[ 80])
+#define zNotNumber            (option_usage_text.apz_str[ 81])
+#define zNotDate              (option_usage_text.apz_str[ 82])
+#define zNotDuration          (option_usage_text.apz_str[ 83])
+#define zNrmOptFmt            (option_usage_text.apz_str[ 84])
+#define zNumberOpt            (option_usage_text.apz_str[ 85])
+#define zOneSpace             (option_usage_text.apz_str[ 86])
+#define zOnlyOne              (option_usage_text.apz_str[ 87])
+#define zOptsOnly             (option_usage_text.apz_str[ 88])
+#define zOutputFail           (option_usage_text.apz_str[ 89])
+#define zPathFmt              (option_usage_text.apz_str[ 90])
+#define zPlsSendBugs          (option_usage_text.apz_str[ 91])
+#define zPreset               (option_usage_text.apz_str[ 92])
+#define zPresetFile           (option_usage_text.apz_str[ 93])
+#define zPresetIntro          (option_usage_text.apz_str[ 94])
+#define zProhib               (option_usage_text.apz_str[ 95])
+#define zReorder              (option_usage_text.apz_str[ 96])
+#define zRange                (option_usage_text.apz_str[ 97])
+#define zRangeAbove           (option_usage_text.apz_str[ 98])
+#define zRangeLie             (option_usage_text.apz_str[ 99])
+#define zRangeOnly            (option_usage_text.apz_str[100])
+#define zRangeOr              (option_usage_text.apz_str[101])
+#define zRangeErr             (option_usage_text.apz_str[102])
+#define zRangeExact           (option_usage_text.apz_str[103])
+#define zRangeScaled          (option_usage_text.apz_str[104])
+#define zRangeUpto            (option_usage_text.apz_str[105])
+#define zResetNotConfig       (option_usage_text.apz_str[106])
+#define zReqFmt               (option_usage_text.apz_str[107])
+#define zReqOptFmt            (option_usage_text.apz_str[108])
+#define zReqThese             (option_usage_text.apz_str[109])
+#define zReq_NoShrtTtl        (option_usage_text.apz_str[110])
+#define zReq_ShrtTtl          (option_usage_text.apz_str[111])
+#define zSepChars             (option_usage_text.apz_str[112])
+#define zSetMemberSettings    (option_usage_text.apz_str[113])
+#define zShrtGnuOptFmt        (option_usage_text.apz_str[114])
+#define zSixSpaces            (option_usage_text.apz_str[115])
+#define zStdBoolArg           (option_usage_text.apz_str[116])
+#define zStdBreak             (option_usage_text.apz_str[117])
+#define zStdFileArg           (option_usage_text.apz_str[118])
+#define zStdKeyArg            (option_usage_text.apz_str[119])
+#define zStdKeyLArg           (option_usage_text.apz_str[120])
+#define zStdTimeArg           (option_usage_text.apz_str[121])
+#define zStdNestArg           (option_usage_text.apz_str[122])
+#define zStdNoArg             (option_usage_text.apz_str[123])
+#define zStdNumArg            (option_usage_text.apz_str[124])
+#define zStdOptArg            (option_usage_text.apz_str[125])
+#define zStdReqArg            (option_usage_text.apz_str[126])
+#define zStdStrArg            (option_usage_text.apz_str[127])
+#define zTabHyp               (option_usage_text.apz_str[128])
+#define zTabHypAnd            (option_usage_text.apz_str[129])
+#define zTabout               (option_usage_text.apz_str[130])
+#define zThreeSpaces          (option_usage_text.apz_str[131])
+#define zTwoSpaces            (option_usage_text.apz_str[132])
+#define zUpTo                 (option_usage_text.apz_str[133])
+#define zValidKeys            (option_usage_text.apz_str[134])
 
   /*
    *  First, set up the strings.  Some of these are writable.  These are all in
@@ -211,7 +214,7 @@ extern usage_text_t option_usage_text;
   static char    eng_zGnuTimeArg[] = "=Tim";
   static char    eng_zGnuNumArg[] = "=num";
   static char    eng_zGnuStrArg[] = "=str";
-static char const usage_txt[4326] =
+static char const usage_txt[4435] =
     "malloc of %d bytes failed\n\0"
     "AutoOpts function called without option descriptor\n\0"
     "\tThis exceeds the compiled library version:  \0"
@@ -287,6 +290,7 @@ static char const usage_txt[4326] =
     "\t\t\t\t- must appear between %d and %d times\n\0"
     "ERROR:  The %s option is required\n\0"
     "%s: option `%s' cannot have an argument\n\0"
+    "%s: cannot allocate new argument vector\n\0"
     "%s: Command line arguments not allowed\n\0"
     "error %d (%s) creating %s\n\0"
     "Options are specified by single or double hyphens and their name.\n\0"
@@ -304,6 +308,8 @@ static char const usage_txt[4326] =
     "ERROR:  The %s option must appear %d times\n\0"
     "error:  cannot load options from non-regular file %s\n\0"
     "%s error:  `%s' is not a recognizable number\n\0"
+    "%s error:  `%s' is not a recognizable date/time\n\0"
+    "%s error:  `%s' is not a recognizable time duration\n\0"
     " %3s %s\0"
     "The '-#<number>' option may omit the hash char\n\0"
     " \0"
@@ -323,8 +329,7 @@ static char const usage_txt[4326] =
     "%s%ld to %ld\0"
     "%sgreater than or equal to %ld\0"
     "%sIt must lie in one of the ranges:\n\0"
-    "%sThis option must lie in one of the ranges:\n\0"
-    "%sit must be:  \0"
+    "%sIt must be in the range:\n\0"
     ", or\n\0"
     "%s error:  %s option value ``%s'' is out of range.\n\0"
     "%s%ld exactly\0"
@@ -371,7 +376,7 @@ static char const usage_txt[4326] =
    *  Aren't you glad you don't maintain this by hand?
    */
   usage_text_t option_usage_text = {
-    140,
+    142,
     eng_zGnuBoolArg, eng_zGnuKeyArg,  eng_zGnuFileArg, eng_zGnuKeyLArg,
     eng_zGnuTimeArg, eng_zGnuNumArg,  eng_zGnuStrArg,
     {
@@ -391,24 +396,24 @@ static char const usage_txt[4326] =
       usage_txt +1920, usage_txt +1946, usage_txt +1972, usage_txt +1980,
       usage_txt +2016, usage_txt +2067, usage_txt +2123, usage_txt +2157,
       usage_txt +2195, usage_txt +2260, usage_txt +2303, usage_txt +2338,
-      usage_txt +2379, usage_txt +2419, usage_txt +2446, usage_txt +2513,
-      usage_txt +2561, usage_txt +2594, usage_txt +2619, usage_txt +2667,
-      usage_txt +2702, usage_txt +2740, usage_txt +2767, usage_txt +2816,
-      usage_txt +2821, usage_txt +2839, usage_txt +2874, usage_txt +2918,
-      usage_txt +2972, usage_txt +3018, usage_txt +3026, usage_txt +3074,
-      usage_txt +3076, usage_txt +3101, usage_txt +3135, usage_txt +3164,
-      usage_txt +3183, usage_txt +3217, usage_txt +3253, usage_txt +3291,
-      usage_txt +3347, usage_txt +3373, usage_txt +3439, usage_txt +3452,
-      usage_txt +3483, usage_txt +3520, usage_txt +3566, usage_txt +3582,
-      usage_txt +3588, usage_txt +3640, usage_txt +3654, usage_txt +3700,
-      usage_txt +3728, usage_txt +3773, usage_txt +3815, usage_txt +3829,
-      usage_txt +3854, usage_txt +3894, usage_txt +3937, usage_txt +3941,
-      usage_txt +4160, usage_txt +4163, usage_txt +4170, usage_txt +4174,
-      usage_txt +4182, usage_txt +4186, usage_txt +4190, usage_txt +4194,
-      usage_txt +4198, usage_txt +4202, usage_txt +4206, usage_txt +4210,
-      usage_txt +4214, usage_txt +4218, usage_txt +4222, usage_txt +4229,
-      usage_txt +4241, usage_txt +4249, usage_txt +4253, usage_txt +4256,
-      usage_txt +4289
+      usage_txt +2379, usage_txt +2420, usage_txt +2460, usage_txt +2487,
+      usage_txt +2554, usage_txt +2602, usage_txt +2635, usage_txt +2660,
+      usage_txt +2708, usage_txt +2743, usage_txt +2781, usage_txt +2808,
+      usage_txt +2857, usage_txt +2862, usage_txt +2880, usage_txt +2915,
+      usage_txt +2959, usage_txt +3013, usage_txt +3059, usage_txt +3108,
+      usage_txt +3161, usage_txt +3169, usage_txt +3217, usage_txt +3219,
+      usage_txt +3244, usage_txt +3278, usage_txt +3307, usage_txt +3326,
+      usage_txt +3360, usage_txt +3396, usage_txt +3434, usage_txt +3490,
+      usage_txt +3516, usage_txt +3582, usage_txt +3595, usage_txt +3626,
+      usage_txt +3663, usage_txt +3691, usage_txt +3697, usage_txt +3749,
+      usage_txt +3763, usage_txt +3809, usage_txt +3837, usage_txt +3882,
+      usage_txt +3924, usage_txt +3938, usage_txt +3963, usage_txt +4003,
+      usage_txt +4046, usage_txt +4050, usage_txt +4269, usage_txt +4272,
+      usage_txt +4279, usage_txt +4283, usage_txt +4291, usage_txt +4295,
+      usage_txt +4299, usage_txt +4303, usage_txt +4307, usage_txt +4311,
+      usage_txt +4315, usage_txt +4319, usage_txt +4323, usage_txt +4327,
+      usage_txt +4331, usage_txt +4338, usage_txt +4350, usage_txt +4358,
+      usage_txt +4362, usage_txt +4365, usage_txt +4398
     }
   };
 
index b07c043b90d4c58512c2dbcccd81adae0b84aba1..35e82d591f9f234830b2c017feee0e72b59dc5fa 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * \file configfile.c
  *
- *  Time-stamp:      "2011-01-06 16:11:24 bkorb"
+ *  Time-stamp:      "2011-04-06 09:31:24 bkorb"
  *
  *  configuration/rc/ini file handling.
  *
@@ -662,7 +662,7 @@ program_directive(tOptions * pOpts, char * pzText)
     size_t name_len = strlen(pOpts->pzProgName);
 
     memcpy(ttl, ttlfmt, sizeof(ttlfmt) - 1);
-    strcpy(ttl + sizeof(ttlfmt) - 1, zCfgProg);
+    memcpy(ttl + sizeof(ttlfmt) - 1, zCfgProg, ttl_len - (sizeof(ttlfmt) - 1));
 
     do  {
         while (IS_WHITESPACE_CHAR(*++pzText))  ;
@@ -1026,15 +1026,15 @@ internalFileLoad(tOptions* pOpts)
 
         if (S_ISDIR(StatBuf.st_mode)) {
             size_t len = strlen(zFileName);
-            char* pz;
+            size_t nln = strlen(pOpts->pzRcName) + 1;
+            char * pz  = zFileName + len;
 
-            if (len + 1 + strlen(pOpts->pzRcName) >= sizeof(zFileName))
+            if (len + 1 + nln >= sizeof(zFileName))
                 continue;
 
-            pz = zFileName + len;
             if (pz[-1] != DIRCH)
                 *(pz++) = DIRCH;
-            strcpy(pz, pOpts->pzRcName);
+            memcpy(pz, pOpts->pzRcName, nln);
         }
 
         file_preset(pOpts, zFileName, inc);
@@ -1362,6 +1362,8 @@ validateOptionsStruct(tOptions* pOpts, char const* pzProgram)
        && (  (pOpts->structVersion > OPTIONS_STRUCT_VERSION  )
           || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION )
        )  )  {
+        static char const aover[] =
+            __STR(AO_CURRENT)":"__STR(AO_REVISION)":"__STR(AO_AGE)"\n";
 
         fprintf(stderr, zAO_Err, pzProgram, NUM_TO_VER(pOpts->structVersion));
         if (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
@@ -1369,9 +1371,7 @@ validateOptionsStruct(tOptions* pOpts, char const* pzProgram)
         else
             fputs(zAO_Sml, stderr);
 
-        fputs(ShellAsString(AO_CURRENT)  ":"
-              ShellAsString(AO_REVISION) ":"
-              ShellAsString(AO_AGE)      "\n", stderr);
+        fwrite(aover, sizeof(aover) - 1, 1, stderr);
         return FAILURE;
     }
 
index 6c57b04d3ac6d6f949f64a3fa5ac5f7a7fa017ed..811ce593080a9e56f42eacd7f11f4feab31c7d4a 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * \file cook.c
  *
- *  Time-stamp:      "2010-07-10 11:01:32 bkorb"
+ *  Time-stamp:      "2011-03-12 15:05:26 bkorb"
  *
  *  This file contains the routines that deal with processing quoted strings
  *  into an internal format.
@@ -28,6 +28,8 @@
  */
 
 /* = = = START-STATIC-FORWARD = = = */
+static ag_bool
+contiguous_quote(char ** pps, char * pq, int * lnct_p);
 /* = = = END-STATIC-FORWARD = = = */
 
 /*=export_func  ao_string_cook_escape_char
@@ -128,12 +130,85 @@ ao_string_cook_escape_char( char const* pzIn, char* pRes, u_int nl )
  *  A quoted string has been found.
  *  Find the end of it and compress any escape sequences.
  */
+static ag_bool
+contiguous_quote(char ** pps, char * pq, int * lnct_p)
+{
+    char * ps = *pps + 1;
+
+    for (;;) {
+        while (IS_WHITESPACE_CHAR(*ps))
+            if (*(ps++) == '\n')
+                (*lnct_p)++;
+
+        /*
+         *  IF the next character is a quote character,
+         *  THEN we will concatenate the strings.
+         */
+        switch (*ps) {
+        case '"':
+        case '\'':
+            *pq  = *(ps++);  /* assign new quote character and return */
+            *pps = ps;
+            return AG_TRUE;
+
+        case '/':
+            /*
+             *  Allow for a comment embedded in the concatenated string.
+             */
+            switch (ps[1]) {
+            default:
+                *pps = NULL;
+                return AG_FALSE;
+
+            case '/':
+                /*
+                 *  Skip to end of line
+                 */
+                ps = strchr(ps, '\n');
+                if (ps == NULL) {
+                    *pps = NULL;
+                    return AG_FALSE;
+                }
+                break;
+
+            case '*':
+            {
+                char* p = strstr( ps+2, "*/" );
+                /*
+                 *  Skip to terminating star slash
+                 */
+                if (p == NULL) {
+                    *pps = NULL;
+                    return AG_FALSE;
+                }
+
+                while (ps < p) {
+                    if (*(ps++) == '\n')
+                        (*lnct_p)++;
+                }
+
+                ps = p + 2;
+            }
+            }
+            continue;
+
+        default:
+            /*
+             *  The next non-whitespace character is not a quote.
+             *  The series of quoted strings has come to an end.
+             */
+            *pps = ps;
+            return AG_FALSE;
+        }
+    }
+}
+
 /*=export_func  ao_string_cook
  * private:
  *
  * what:  concatenate and escape-process strings
- * arg:   + char* + pzScan     + The *MODIFIABLE* input buffer +
- * arg:   + int*  + pLineCt    + The (possibly NULL) pointer to a line count +
+ * arg:   + char* + pzScan  + The *MODIFIABLE* input buffer +
+ * arg:   + int*  + lnct_p  + The (possibly NULL) pointer to a line count +
  *
  * ret-type: char*
  * ret-desc: The address of the text following the processed strings.
@@ -149,8 +224,8 @@ ao_string_cook_escape_char( char const* pzIn, char* pRes, u_int nl )
  *
  * err:  @code{NULL} is returned if the string(s) is/are mal-formed.
 =*/
-char*
-ao_string_cook( char* pzScan, int* pLineCt )
+char *
+ao_string_cook(char * pzScan, int * lnct_p)
 {
     int   l = 0;
     char  q = *pzScan;
@@ -162,8 +237,8 @@ ao_string_cook( char* pzScan, int* pLineCt )
     char* pzD = pzScan++;
     char* pzS = pzScan;
 
-    if (pLineCt == NULL)
-        pLineCt = &l;
+    if (lnct_p == NULL)
+        lnct_p = &l;
 
     for (;;) {
         /*
@@ -175,65 +250,8 @@ ao_string_cook( char* pzScan, int* pLineCt )
          */
         while (*pzS == q) {
             *pzD = NUL; /* This is probably the end of the line */
-            pzS++;
-
-        scan_for_quote:
-            while (IS_WHITESPACE_CHAR(*pzS))
-                if (*(pzS++) == '\n')
-                    (*pLineCt)++;
-
-            /*
-             *  IF the next character is a quote character,
-             *  THEN we will concatenate the strings.
-             */
-            switch (*pzS) {
-            case '"':
-            case '\'':
-                break;
-
-            case '/':
-                /*
-                 *  Allow for a comment embedded in the concatenated string.
-                 */
-                switch (pzS[1]) {
-                default:  return NULL;
-                case '/':
-                    /*
-                     *  Skip to end of line
-                     */
-                    pzS = strchr( pzS, '\n' );
-                    if (pzS == NULL)
-                        return NULL;
-                    (*pLineCt)++;
-                    break;
-
-                case '*':
-                {
-                    char* p = strstr( pzS+2, "*/" );
-                    /*
-                     *  Skip to terminating star slash
-                     */
-                    if (p == NULL)
-                        return NULL;
-                    while (pzS < p) {
-                        if (*(pzS++) == '\n')
-                            (*pLineCt)++;
-                    }
-
-                    pzS = p + 2;
-                }
-                }
-                goto scan_for_quote;
-
-            default:
-                /*
-                 *  The next non-whitespace character is not a quote.
-                 *  The series of quoted strings has come to an end.
-                 */
+            if (! contiguous_quote(&pzS, &q, lnct_p))
                 return pzS;
-            }
-
-            q = *(pzS++);  /* assign new quote character and advance scan */
         }
 
         /*
@@ -244,7 +262,7 @@ ao_string_cook( char* pzScan, int* pLineCt )
             return NULL;
 
         case '\n':
-            (*pLineCt)++;
+            (*lnct_p)++;
             break;
 
         case '\\':
@@ -256,7 +274,7 @@ ao_string_cook( char* pzScan, int* pLineCt )
             if (*pzS == '\n') {
                 pzS++;
                 pzD--;
-                (*pLineCt)++;
+                (*lnct_p)++;
             }
 
             /*
index 5244e2d651fb6cb678f1f0db35bd778eddcd3dcb..a79a32e5d31cdfd3383f547921df99c400e618a7 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file enumeration.c
  *
- * Time-stamp:      "2010-08-22 15:36:14 bkorb"
+ * Time-stamp:      "2011-04-06 10:48:22 bkorb"
  *
  *   Automated Options Paged Usage module.
  *
@@ -30,7 +30,7 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
 
-tSCC*  pz_enum_err_fmt;
+static char const * pz_enum_err_fmt;
 
 /* = = = START-STATIC-FORWARD = = = */
 static void
@@ -348,10 +348,13 @@ static void
 set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
                unsigned int name_ct)
 {
-    char*     pz;
+    static char const none[]  = "none";
+    static char const plus[3] = " + ";
+
+    char *    pz;
     uintptr_t bits = (uintptr_t)pOD->optCookie;
     int       ix   = 0;
-    size_t    len  = 5;
+    size_t    len  = sizeof(none);
 
     bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
 
@@ -361,7 +364,7 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
      */
     while (bits != 0) {
         if (bits & 1)
-            len += strlen(paz_names[ix]) + 8;
+            len += strlen(paz_names[ix]) + sizeof(plus);
         if (++ix >= name_ct) break;
         bits >>= 1;
     }
@@ -373,21 +376,23 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
      *  because we will be restoring to current state, not adding to
      *  the default set of bits.
      */
-    strcpy(pz, "none");
-    pz += 4;
+    memcpy(pz, none, sizeof(none)-1);
+    pz += sizeof(none)-1;
     bits = (uintptr_t)pOD->optCookie;
     bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
     ix = 0;
 
     while (bits != 0) {
         if (bits & 1) {
-            strcpy(pz, " + ");
-            strcpy(pz+3, paz_names[ix]);
+            size_t nln = strlen(paz_names[ix]);
+            memcpy(pz, plus, sizeof(plus));
+            memcpy(pz+sizeof(plus), paz_names[ix], nln);
             pz += strlen(paz_names[ix]) + 3;
         }
         if (++ix >= name_ct) break;
         bits >>= 1;
     }
+    *pz = NUL;
 }
 
 /*=export_func  optionSetMembers
@@ -477,7 +482,7 @@ optionSetMembers(tOptions * pOpts, tOptDesc * pOD,
                     if (*pz != NUL) {
                         if (len >= AO_NAME_LIMIT)
                             break;
-                        strncpy(z, pzArg, (size_t)len);
+                        memcpy(z, pzArg, (size_t)len);
                         z[len] = NUL;
                         p = z;
                     } else {
index 63a90c590749e355a83ee634b61f6b4ddf593195..8530230ea7e6e5a118d3ad51735408cd5390b232 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file environment.c
  *
- * Time-stamp:      "2010-12-06 15:01:45 bkorb"
+ * Time-stamp:      "2011-04-06 09:35:55 bkorb"
  *
  *  This file contains all of the routines that must be linked into
  *  an executable to use the generated option processing.  The optional
@@ -206,6 +206,8 @@ doEnvPresets(tOptions* pOpts, teEnvPresetType type)
     spaceLeft = AO_NAME_SIZE - (pzFlagName - zEnvName) - 1;
 
     for (;ct-- > 0; st.pOD++) {
+        size_t nln;
+
         /*
          *  If presetting is disallowed, then skip this entry
          */
@@ -217,14 +219,14 @@ doEnvPresets(tOptions* pOpts, teEnvPresetType type)
          *  IF there is no such environment variable,
          *  THEN skip this entry, too.
          */
-        if (strlen(st.pOD->pz_NAME) >= spaceLeft)
-            continue;
-
-        /*
-         *  Set up the option state
-         */
-        strcpy(pzFlagName, st.pOD->pz_NAME);
-        do_env_opt(&st, zEnvName, pOpts, type);
+        nln = strlen(st.pOD->pz_NAME) + 1;
+        if (nln <= spaceLeft) {
+            /*
+             *  Set up the option state
+             */
+            memcpy(pzFlagName, st.pOD->pz_NAME, nln);
+            do_env_opt(&st, zEnvName, pOpts, type);
+        }
     }
 
     /*
@@ -232,12 +234,19 @@ doEnvPresets(tOptions* pOpts, teEnvPresetType type)
      */
     if (  (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
        && (pOpts->specOptIdx.save_opts != 0)) {
+        size_t nln;
         st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
 
-        if (st.pOD->pz_NAME != NULL) {
-            strcpy(pzFlagName, st.pOD->pz_NAME);
-            do_env_opt(&st, zEnvName, pOpts, type);
-        }
+        if (st.pOD->pz_NAME == NULL)
+            return;
+
+        nln = strlen(st.pOD->pz_NAME) + 1;
+            
+        if (nln > spaceLeft)
+            return;
+
+        memcpy(pzFlagName, st.pOD->pz_NAME, nln);
+        do_env_opt(&st, zEnvName, pOpts, type);
     }
 }
 
index 6146514671af18301b905dc078fa7d611dbbc1c2..05f2f1da46bbf511cef8418f4fb32f2b8a635821 100644 (file)
@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (genshell.c)
  *  
- *  It has been AutoGen-ed  February 17, 2011 at 04:58:35 PM by AutoGen 5.11.6
+ *  It has been AutoGen-ed  April 29, 2011 at 03:43:59 PM by AutoGen 5.11.9
  *  From the definitions    genshell.def
  *  and the template file   options
  *
- * Generated from AutoOpts 34:0:9 templates.
+ * Generated from AutoOpts 35:0:10 templates.
  *
  *  AutoOpts is a copyrighted work.  This source file is not encumbered
  *  by AutoOpts licensing, but is provided under the licensing terms chosen
  * 
  * You should have received a copy of the GNU General Public License along
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
+
  */
 
 #include <sys/types.h>
+
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef  __cplusplus
 extern "C" {
 #endif
+extern FILE * option_usage_fp;
 
 /* TRANSLATORS: choose the translation for option names wisely because you
                 cannot ever change your mind. */
-tSCC zCopyright[] =
-       "genshellopt copyright (c) 1999-2011 Bruce Korb, all rights reserved";
-tSCC zCopyrightNotice[610] =
-"genshellopt is free software: you can redistribute it and/or modify it under\n\
-the terms of the GNU General Public License as published by the Free Software\n\
-Foundation, either version 3 of the License, or (at your option) any later\n\
-version.\n\n\
-genshellopt is distributed in the hope that it will be useful, but WITHOUT ANY\n\
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n\
-PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\n\
-You should have received a copy of the GNU General Public License along with\n\
-this program.  If not, see <http://www.gnu.org/licenses/>.";
+static char const zCopyright[260] =
+"genshellopt 1\n\
+Copyright (C) 1999-2011 Bruce Korb, all rights reserved.\n\
+This is free software. It is licensed for use, modification and\n\
+redistribution under the terms of the\n\
+GNU General Public License, version 3 or later\n\
+    <http://gnu.org/licenses/gpl.html>\n";
+static char const zCopyrightNotice[611] =
+"genshellopt is free software: you can redistribute it and/or modify it\n\
+under the terms of the GNU General Public License as published by the\n\
+Free Software Foundation, either version 3 of the License, or (at your\n\
+option) any later version.\n\n\
+genshellopt is distributed in the hope that it will be useful, but WITHOUT\n\
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n\
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n\
+for more details.\n\n\
+You should have received a copy of the GNU General Public License along\n\
+with this program.  If not, see <http://www.gnu.org/licenses/>.\n";
 
 extern tUsageProc genshelloptUsage;
 
 #ifndef NULL
 #  define NULL 0
 #endif
-#ifndef EXIT_SUCCESS
-#  define  EXIT_SUCCESS 0
-#endif
-#ifndef EXIT_FAILURE
-#  define  EXIT_FAILURE 1
-#endif
 
 /*
  *  Script option description:
@@ -124,8 +127,8 @@ static char const zVersion_Name[]      = "version";
 extern tOptProc
     optionBooleanVal,    optionNestedVal,     optionNumericVal,
     optionPagedUsage,    optionPrintVersion,  optionResetOpt,
-    optionStackArg,      optionTimeVal,       optionUnstackArg,
-    optionVersionStderr;
+    optionStackArg,      optionTimeDate,      optionTimeVal,
+    optionUnstackArg,    optionVersionStderr;
 static tOptProc
     doUsageOpt;
 
@@ -133,9 +136,9 @@ static tOptProc
  *
  *  Define the Genshellopt Option Descriptions.
  */
-static tOptDesc optDesc[ OPTION_CT ] = {
-  {  /* entry idx, value */ 0, VALUE_OPT_SCRIPT,
-     /* equiv idx, value */ 0, VALUE_OPT_SCRIPT,
+static tOptDesc optDesc[GENSHELL_OPTION_CT] = {
+  {  /* entry idx, value */ 0, VALUE_GENSHELL_OPT_SCRIPT,
+     /* equiv idx, value */ 0, VALUE_GENSHELL_OPT_SCRIPT,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ SCRIPT_FLAGS, 0,
@@ -146,8 +149,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zScriptText, zScript_NAME, zScript_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 1, VALUE_OPT_SHELL,
-     /* equiv idx, value */ 1, VALUE_OPT_SHELL,
+  {  /* entry idx, value */ 1, VALUE_GENSHELL_OPT_SHELL,
+     /* equiv idx, value */ 1, VALUE_GENSHELL_OPT_SHELL,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ SHELL_FLAGS, 0,
@@ -158,7 +161,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name,
      /* disablement strs */ zNotShell_Name, zNotShell_Pfx },
 
-  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+  {  /* entry idx, value */ INDEX_GENSHELL_OPT_VERSION, VALUE_GENSHELL_OPT_VERSION,
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
@@ -172,7 +175,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
 
 
 
-  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+  {  /* entry idx, value */ INDEX_GENSHELL_OPT_HELP, VALUE_GENSHELL_OPT_HELP,
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
@@ -184,7 +187,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+  {  /* entry idx, value */ INDEX_GENSHELL_OPT_MORE_HELP, VALUE_GENSHELL_OPT_MORE_HELP,
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
@@ -218,7 +221,7 @@ If the script file already exists and contains Automated Option Processing\n\
 text, the second line of the file through the ending tag will be replaced\n\
 by the newly generated text.  The first ``#!''  line will be regenerated.\n";
 static char const zFullVersion[] = GENSHELLOPT_FULL_VERSION;
-/* extracted from optcode.tlib near line 504 */
+/* extracted from optcode.tlib near line 515 */
 
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -273,7 +276,7 @@ tOptions genshelloptOptions = {
     /*
      *  Indexes to special options
      */
-    { INDEX_OPT_MORE_HELP, /* more-help option index */
+    { INDEX_GENSHELL_OPT_MORE_HELP, /* more-help option index */
       NO_EQUIVALENT, /* save option index */
       NO_EQUIVALENT, /* '-#' option index */
       NO_EQUIVALENT /* index of default opt */
@@ -288,14 +291,12 @@ tOptions genshelloptOptions = {
  *  Create the static procedure(s) declared above.
  */
 static void
-doUsageOpt(
-    tOptions*   pOptions,
-    tOptDesc*   pOptDesc )
+doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
 {
     (void)pOptions;
-    USAGE(EXIT_SUCCESS);
+    GENSHELL_USAGE(GENSHELLOPT_EXIT_SUCCESS);
 }
-/* extracted from optcode.tlib near line 657 */
+/* extracted from optcode.tlib near line 666 */
 
 #if ENABLE_NLS
 #include <stdio.h>
@@ -319,14 +320,13 @@ AO_gettext(char const* pz)
     pzRes = strdup(pzRes);
     if (pzRes == NULL) {
         fputs(_("No memory for duping translated strings\n"), stderr);
-        exit(EXIT_FAILURE);
+        exit(GENSHELLOPT_EXIT_FAILURE);
     }
     return pzRes;
 }
 
-static void coerce_it(void** s) { *s = AO_gettext(*s); }
-#define COERSION(_f) \
-  coerce_it((void*)&(genshelloptOptions._f))
+static void coerce_it(void** s) { *s = AO_gettext(*s);
+}
 
 /*
  *  This invokes the translation code (e.g. gettext(3)).
@@ -334,6 +334,8 @@ static void coerce_it(void** s) { *s = AO_gettext(*s); }
 static void
 translate_option_strings(void)
 {
+    tOptions * const pOpt = &genshelloptOptions;
+
     /*
      *  Guard against re-translation.  It won't work.  The strings will have
      *  been changed by the first pass through this code.  One shot only.
@@ -343,33 +345,33 @@ translate_option_strings(void)
          *  Do the translations.  The first pointer follows the field count
          *  field.  The field count field is the size of a pointer.
          */
-        tOptDesc* pOD = genshelloptOptions.pOptDesc;
-        char**    ppz = (char**)(void*)&(option_usage_text);
-        int       ix  = option_usage_text.field_ct;
+        tOptDesc * pOD = pOpt->pOptDesc;
+        char **    ppz = (char**)(void*)&(option_usage_text);
+        int        ix  = option_usage_text.field_ct;
 
         do {
             ppz++;
             *ppz = AO_gettext(*ppz);
         } while (--ix > 0);
 
-        COERSION(pzCopyright);
-        COERSION(pzCopyNotice);
-        COERSION(pzFullVersion);
-        COERSION(pzUsageTitle);
-        COERSION(pzExplain);
-        COERSION(pzDetail);
-        COERSION(pzPackager);
+        coerce_it((void*)&(pOpt->pzCopyright));
+        coerce_it((void*)&(pOpt->pzCopyNotice));
+        coerce_it((void*)&(pOpt->pzFullVersion));
+        coerce_it((void*)&(pOpt->pzUsageTitle));
+        coerce_it((void*)&(pOpt->pzExplain));
+        coerce_it((void*)&(pOpt->pzDetail));
+        coerce_it((void*)&(pOpt->pzPackager));
         option_usage_text.field_ct = 0;
 
-        for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++)
+        for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
             coerce_it((void*)&(pOD->pzText));
     }
 
-    if ((genshelloptOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
-        tOptDesc* pOD = genshelloptOptions.pOptDesc;
-        int       ix;
+    if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
+        tOptDesc * pOD = pOpt->pOptDesc;
+        int        ix;
 
-        for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++) {
+        for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
             coerce_it((void*)&(pOD->pz_Name));
             coerce_it((void*)&(pOD->pz_DisableName));
             coerce_it((void*)&(pOD->pz_DisablePfx));
index 583233b822759f933cfcf3e39bb52fa02161690f..e5457a764090ff56d27d85f53608396536861352 100644 (file)
@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (genshell.h)
  *  
- *  It has been AutoGen-ed  February 17, 2011 at 04:58:35 PM by AutoGen 5.11.6
+ *  It has been AutoGen-ed  April 29, 2011 at 03:43:59 PM by AutoGen 5.11.9
  *  From the definitions    genshell.def
  *  and the template file   options
  *
- * Generated from AutoOpts 34:0:9 templates.
+ * Generated from AutoOpts 35:0:10 templates.
  *
  *  AutoOpts is a copyrighted work.  This header file is not encumbered
  *  by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -32,6 +32,7 @@
  * 
  * You should have received a copy of the GNU General Public License along
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
+
  */
 /*
  *  This file contains the programmatic interface to the Automated
@@ -50,7 +51,7 @@
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  */
-#define AO_TEMPLATE_VERSION 139264
+#define AO_TEMPLATE_VERSION 143360
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
  *  Enumeration of each option:
  */
 typedef enum {
-    INDEX_OPT_SCRIPT      =  0,
-    INDEX_OPT_SHELL       =  1,
-    INDEX_OPT_VERSION     =  2,
-    INDEX_OPT_HELP        =  3,
-    INDEX_OPT_MORE_HELP   =  4
-} teOptIndex;
+    INDEX_GENSHELL_OPT_SCRIPT      =  0,
+    INDEX_GENSHELL_OPT_SHELL       =  1,
+    INDEX_GENSHELL_OPT_VERSION     =  2,
+    INDEX_GENSHELL_OPT_HELP        =  3,
+    INDEX_GENSHELL_OPT_MORE_HELP   =  4
+} teGenshell_OptIndex;
 
-#define OPTION_CT    5
+#define GENSHELL_OPTION_CT    5
 #define GENSHELLOPT_VERSION       "1"
-#define GENSHELLOPT_FULL_VERSION  "genshellopt - Generate Shell Option Processing Script - Ver. 1"
+#define GENSHELLOPT_FULL_VERSION  "genshellopt 1"
 
 /*
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
- *  option name (as in the teOptIndex enumeration above).
- *  e.g. HAVE_OPT(SCRIPT)
+ *  option name (as in the teGenshell_OptIndex enumeration above).
+ *  e.g. HAVE_GENSHELL_OPT(SCRIPT)
  */
-#define         DESC(n) (genshelloptOptions.pOptDesc[INDEX_OPT_## n])
-#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
-#define      OPT_ARG(n) (DESC(n).optArg.argString)
-#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
-#define    COUNT_OPT(n) (DESC(n).optOccCt)
-#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
-#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
-#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
-#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
-#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
-#define    CLEAR_OPT(n) STMTS( \
-                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
-                if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
-                    DESC(n).fOptState |= OPTST_DISABLED; \
-                DESC(n).optCookie = NULL )
+#define GENSHELL_DESC(n) (genshelloptOptions.pOptDesc[INDEX_GENSHELL_OPT_## n])
+#define     HAVE_GENSHELL_OPT(n) (! UNUSED_OPT(& GENSHELL_DESC(n)))
+#define      GENSHELL_OPT_ARG(n) (GENSHELL_DESC(n).optArg.argString)
+#define    STATE_GENSHELL_OPT(n) (GENSHELL_DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_GENSHELL_OPT(n) (GENSHELL_DESC(n).optOccCt)
+#define    ISSEL_GENSHELL_OPT(n) (SELECTED_OPT(&GENSHELL_DESC(n)))
+#define ISUNUSED_GENSHELL_OPT(n) (UNUSED_OPT(& GENSHELL_DESC(n)))
+#define  ENABLED_GENSHELL_OPT(n) (! DISABLED_OPT(& GENSHELL_DESC(n)))
+#define  STACKCT_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->useCt)
+#define STACKLST_GENSHELL_OPT(n) (((tArgList*)(GENSHELL_DESC(n).optCookie))->apzArgs)
+#define    CLEAR_GENSHELL_OPT(n) STMTS( \
+                GENSHELL_DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ((GENSHELL_DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    GENSHELL_DESC(n).fOptState |= OPTST_DISABLED; \
+                GENSHELL_DESC(n).optCookie = NULL )
 
 /* * * * * *
  *
@@ -101,37 +102,36 @@ typedef enum {
     GENSHELLOPT_EXIT_SUCCESS = 0,
     GENSHELLOPT_EXIT_FAILURE = 1
 } genshellopt_exit_code_t;
-
 /* * * * * *
  *
  *  Interface defines for specific options.
  */
-#define VALUE_OPT_SCRIPT         'o'
-#define VALUE_OPT_SHELL          's'
-#define VALUE_OPT_HELP          '?'
-#define VALUE_OPT_MORE_HELP     '!'
-#define VALUE_OPT_VERSION       'v'
+#define VALUE_GENSHELL_OPT_SCRIPT 'o'
+#define VALUE_GENSHELL_OPT_SHELL 's'
+#define VALUE_GENSHELL_OPT_HELP '?'
+#define VALUE_GENSHELL_OPT_MORE_HELP '!'
+#define VALUE_GENSHELL_OPT_VERSION 'v'
 /*
  *  Interface defines not associated with particular options
  */
-#define ERRSKIP_OPTERR  STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP)
-#define ERRSTOP_OPTERR  STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP)
-#define RESTART_OPT(n)  STMTS( \
+#define ERRSKIP_GENSHELL_OPTERR  STMTS(genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP)
+#define ERRSTOP_GENSHELL_OPTERR  STMTS(genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP)
+#define RESTART_GENSHELL_OPT(n)  STMTS( \
                 genshelloptOptions.curOptIdx = (n); \
-                genshelloptOptions.pzCurOpt  = NULL)
-#define START_OPT       RESTART_OPT(1)
-#define USAGE(c)        (*genshelloptOptions.pUsageProc)(&genshelloptOptions, c)
-/* extracted from opthead.tlib near line 435 */
+                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 451 */
 
-/* * * * * *
- *
- *  Declare the genshellopt option descriptor.
- */
 #ifdef  __cplusplus
 extern "C" {
 #endif
 
-extern tOptions   genshelloptOptions;
+/* * * * * *
+ *
+ *  Declare the genshellopt option descriptor.
+ */
+extern tOptions genshelloptOptions;
 
 #if defined(ENABLE_NLS)
 # ifndef _
index 2ca83e34e87ec2ac29d53c605f7ac73391fd38da..15a070d928c5e15bc547605eae6337baff630939 100644 (file)
@@ -1,6 +1,7 @@
-#define AUTOOPTS_INTERNAL
+#include "autoopts/project.h"
+#define  AUTOOPTS_INTERNAL 1
 #include "compat/compat.h"
-#define LOCAL static
+#define  LOCAL static
 #include "autoopts/options.h"
 #include "autoopts/usage-txt.h"
 #include "genshell.h"
@@ -9,6 +10,8 @@
 #include "ag-char-map.h"
 #include "autoopts.h"
 #include "proto.h"
+#include "parse-duration.h"
+#include "parse-duration.c"
 #include "value-type.c"
 #include "xat-attribute.c"
 #include "autoopts.c"
index db4bb06c9a9a55a2f3cc95fadc7d9bf1921da0ee..7a52b5e33dbd126dca8560257dbc9edb9f1b2ade 100644 (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  February 17, 2011 at 04:58:33 PM by AutoGen 5.11.6
+dnl It has been AutoGen-ed  April 29, 2011 at 03:43:56 PM by AutoGen 5.11.9
 dnl From the definitions    libopts.def
 dnl and the template file   conftest.tpl
 dnl
@@ -92,9 +92,9 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
   # =====
   # sizes
   # =====
-  AC_CHECK_SIZEOF(char*, 4)
+  AC_CHECK_SIZEOF(char*, 8)
   AC_CHECK_SIZEOF(int,   4)
-  AC_CHECK_SIZEOF(long,  4)
+  AC_CHECK_SIZEOF(long,  8)
   AC_CHECK_SIZEOF(short, 2)
   
   # ----------------------------------------------------------------------
@@ -105,6 +105,25 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
   AC_FUNC_FORK
   AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
                  strrchr strsignal])
+  AC_PROG_SED
+  [while :
+  do
+      POSIX_SHELL=`which bash`
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=`which dash`
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=/usr/xpg4/bin/sh
+      test -x "$POSIX_SHELL" && break
+      POSIX_SHELL=`/bin/sh -c '
+          exec 2>/dev/null
+          if ! true ; then exit 1 ; fi
+          echo /bin/sh'`
+      test -x "$POSIX_SHELL" && break
+      ]AC_ERROR([Cannot locate a working POSIX shell])[
+  done]
+  AC_DEFINE_UNQUOTED([POSIX_SHELL], ["${POSIX_SHELL}"],
+           [define to a working POSIX compliant shell])
+  AC_SUBST([POSIX_SHELL])
 ])
 
 dnl
index 4c52a807cdfbc4025137232cfc516cb52c6d806e..7b9b6cdde1798425ffc7001e0d43a225c64f9e2f 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file makeshell.c
  *
- * Time-stamp:      "2010-12-16 14:09:32 bkorb"
+ * Time-stamp:      "2011-04-20 11:06:57 bkorb"
  *
  *  This module will interpret the options set in the tOptions
  *  structure and create a Bourne shell script capable of parsing them.
@@ -28,7 +28,7 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
 
-tOptions*  pShellParseOptions = NULL;
+tOptions * optionParseShellOptions = NULL;
 
 /* * * * * * * * * * * * * * * * * * * * *
  *
@@ -343,7 +343,10 @@ static char*  pzTrailer = NULL;
 
 /* = = = START-STATIC-FORWARD = = = */
 static void
-textToVariable(tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD);
+emit_var_text(char const * prog, char const * var, int fdin);
+
+static void
+textToVariable(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD);
 
 static void
 emitUsage(tOptions* pOpts);
@@ -387,22 +390,22 @@ optionParseShell(tOptions* pOpts)
      *  IF the output file contains the "#!" magic marker,
      *  it will override anything we do here.
      */
-    if (HAVE_OPT(SHELL))
-        pzShell = OPT_ARG(SHELL);
+    if (HAVE_GENSHELL_OPT(SHELL))
+        pzShell = GENSHELL_OPT_ARG(SHELL);
 
-    else if (! ENABLED_OPT(SHELL))
+    else if (! ENABLED_GENSHELL_OPT(SHELL))
         pzShell = NULL;
 
     else if ((pzShell = getenv("SHELL")),
              pzShell == NULL)
 
-        pzShell = DEFAULT_SHELL;
+        pzShell = POSIX_SHELL;
 
     /*
      *  Check for a specified output file
      */
-    if (HAVE_OPT(SCRIPT))
-        openOutput(OPT_ARG(SCRIPT));
+    if (HAVE_GENSHELL_OPT(SCRIPT))
+        openOutput(GENSHELL_OPT_ARG(SCRIPT));
 
     emitUsage(pOpts);
     emitSetup(pOpts);
@@ -464,7 +467,7 @@ optionParseShell(tOptions* pOpts)
     printf(zLoopEnd, pOpts->pzPROGNAME, zTrailerMarker);
     if ((pzTrailer != NULL) && (*pzTrailer != '\0'))
         fputs(pzTrailer, stdout);
-    else if (ENABLED_OPT(SHELL))
+    else if (ENABLED_GENSHELL_OPT(SHELL))
         printf("\nenv | grep '^%s_'\n", pOpts->pzPROGNAME);
 
     fflush(stdout);
@@ -476,27 +479,80 @@ optionParseShell(tOptions* pOpts)
     }
 }
 
+#ifdef HAVE_WORKING_FORK
+static void
+emit_var_text(char const * prog, char const * var, int fdin)
+{
+    FILE * fp   = fdopen(fdin, "r" FOPEN_BINARY_FLAG);
+    int    nlct = 0; /* defer newlines and skip trailing ones */
+
+    printf("%s_%s_TEXT='", prog, var);
+    if (fp == NULL)
+        goto skip_text;
+
+    for (;;) {
+        int  ch = fgetc(fp);
+        switch (ch) {
+
+        case '\n':
+            nlct++;
+            break;
+
+        case '\'':
+            while (nlct > 0) {
+                fputc('\n', stdout);
+                nlct--;
+            }
+            fputs("'\\''", stdout);
+            break;
+
+        case EOF:
+            goto endCharLoop;
+
+        default:
+            while (nlct > 0) {
+                fputc('\n', stdout);
+                nlct--;
+            }
+            fputc(ch, stdout);
+            break;
+        }
+    } endCharLoop:;
+
+    fclose(fp);
+
+skip_text:
+
+    fputs("'\n\n", stdout);
+}
+
+#endif
 
+/*
+ *  The purpose of this function is to assign "long usage", short usage
+ *  and version information to a shell variable.  Rather than wind our
+ *  way through all the logic necessary to emit the text directly, we
+ *  fork(), have our child process emit the text the normal way and
+ *  capture the output in the parent process.
+ */
 static void
-textToVariable(tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD)
+textToVariable(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD)
 {
-#   define _TT_(n) tSCC z ## n [] = #n;
+#   define _TT_(n) static char const z ## n [] = #n;
     TEXTTO_TABLE
 #   undef _TT_
 #   define _TT_(n) z ## n ,
-      static char const apzTTNames[] = { TEXTTO_TABLE };
+      static char const * apzTTNames[] = { TEXTTO_TABLE };
 #   undef _TT_
 
 #if ! defined(HAVE_WORKING_FORK)
     printf("%1$s_%2$s_TEXT='no %2$s text'\n",
            pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
 #else
-    int  nlHoldCt = 0;
     int  pipeFd[2];
-    FILE* fp;
 
-    printf("%s_%s_TEXT='", pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
     fflush(stdout);
+    fflush(stderr);
 
     if (pipe(pipeFd) != 0) {
         fprintf(stderr, zBadPipe, errno, strerror(errno));
@@ -510,6 +566,10 @@ textToVariable(tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD)
         break;
 
     case 0:
+        /*
+         * Send both stderr and stdout to the pipe.  No matter which
+         * descriptor is used, we capture the output on the read end.
+         */
         dup2(pipeFd[1], STDERR_FILENO);
         dup2(pipeFd[1], STDOUT_FILENO);
         close(pipeFd[0]);
@@ -518,12 +578,10 @@ textToVariable(tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD)
         case TT_LONGUSAGE:
             (*(pOpts->pUsageProc))(pOpts, EXIT_SUCCESS);
             /* NOTREACHED */
-            exit(EXIT_FAILURE);
 
         case TT_USAGE:
             (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
             /* NOTREACHED */
-            exit(EXIT_FAILURE);
 
         case TT_VERSION:
             if (pOD->fOptState & OPTST_ALLOC_ARG) {
@@ -540,40 +598,9 @@ textToVariable(tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD)
 
     default:
         close(pipeFd[1]);
-        fp = fdopen(pipeFd[0], "r" FOPEN_BINARY_FLAG);
     }
 
-    for (;;) {
-        int  ch = fgetc(fp);
-        switch (ch) {
-
-        case '\n':
-            nlHoldCt++;
-            break;
-
-        case '\'':
-            while (nlHoldCt > 0) {
-                fputc('\n', stdout);
-                nlHoldCt--;
-            }
-            fputs("'\\''", stdout);
-            break;
-
-        case EOF:
-            goto endCharLoop;
-
-        default:
-            while (nlHoldCt > 0) {
-                fputc('\n', stdout);
-                nlHoldCt--;
-            }
-            fputc(ch, stdout);
-            break;
-        }
-    } endCharLoop:;
-
-    fputs("'\n\n", stdout);
-    close(pipeFd[0]);
+    emit_var_text(pOpts->pzPROGNAME, apzTTNames[whichVar], pipeFd[0]);
 #endif
 }
 
@@ -602,8 +629,8 @@ emitUsage(tOptions* pOpts)
             strftime(zTimeBuf, AO_NAME_SIZE, "%A %B %e, %Y at %r %Z", pTime );
         }
 
-        if (HAVE_OPT(SCRIPT))
-             pzOutName = OPT_ARG(SCRIPT);
+        if (HAVE_GENSHELL_OPT(SCRIPT))
+             pzOutName = GENSHELL_OPT_ARG(SCRIPT);
         else pzOutName = zStdout;
 
         if ((pzLeader == NULL) && (pzShell != NULL))
@@ -1025,7 +1052,7 @@ openOutput(char const* pzFile)
  *  and create shell script variables containing the two types of text.
 =*/
 void
-genshelloptUsage(tOptions pOpts, int exitCode)
+genshelloptUsage(tOptions * pOpts, int exitCode)
 {
 #if ! defined(HAVE_WORKING_FORK)
     optionUsage(pOpts, exitCode);
@@ -1050,7 +1077,6 @@ genshelloptUsage(tOptions*  pOpts, int exitCode)
     case -1:
         optionUsage(pOpts, EXIT_FAILURE);
         /* NOTREACHED */
-        _exit(EXIT_FAILURE);
 
     case 0:
         pagerState = PAGER_STATE_CHILD;
@@ -1071,8 +1097,8 @@ genshelloptUsage(tOptions*  pOpts, int exitCode)
      */
     {
         char *  pz;
-        char ** pp = (char **)(void *)&(pShellParseOptions->pzProgName);
-        AGDUPSTR(pz, pShellParseOptions->pzPROGNAME, "program name");
+        char ** pp = (char **)(void *)&(optionParseShellOptions->pzProgName);
+        AGDUPSTR(pz, optionParseShellOptions->pzPROGNAME, "program name");
         *pp = pz;
         while (*pz != NUL) {
             *pz = tolower(*pz);
@@ -1083,7 +1109,7 @@ genshelloptUsage(tOptions*  pOpts, int exitCode)
     /*
      *  Separate the makeshell usage from the client usage
      */
-    fprintf(option_usage_fp, zGenshell, pShellParseOptions->pzProgName);
+    fprintf(option_usage_fp, zGenshell, optionParseShellOptions->pzProgName);
     fflush(option_usage_fp);
 
     /*
@@ -1094,7 +1120,7 @@ genshelloptUsage(tOptions*  pOpts, int exitCode)
         pagerState = PAGER_STATE_CHILD;
         /*FALLTHROUGH*/
     case -1:
-        optionUsage(pShellParseOptions, EXIT_FAILURE);
+        optionUsage(optionParseShellOptions, EXIT_FAILURE);
 
     default:
     {
index db3648e3a9ac5e73c8df9468289dfb4f43574cf2..ff6b2a50f2792d1081118d6acd7e4743382e9710 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file numeric.c
  *
- *  Time-stamp:      "2010-07-10 10:57:10 bkorb"
+ *  Time-stamp:      "2011-03-25 16:26:10 bkorb"
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
@@ -46,59 +46,50 @@ optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct)
 
     const struct {long const rmin, rmax;} * rng = rng_table;
 
-    char const * pz_indent =
-        (pOpts != OPTPROC_EMIT_USAGE) ? onetab : bullet;
+    char const * pz_indent    = bullet;
 
-    if ((pOpts == OPTPROC_EMIT_USAGE) || (pOpts > OPTPROC_EMIT_LIMIT)) {
-        char const * lie_in_range = zRangeLie;
-
-        if (pOpts > OPTPROC_EMIT_LIMIT) {
-            fprintf(option_usage_fp, zRangeErr,
-                    pOpts->pzProgName, pOD->pz_Name, pOD->optArg.argString);
-            fprintf(option_usage_fp, "The %s option:\n", pOD->pz_Name);
-            lie_in_range = zRangeBadLie;
-            pz_indent = "";
-        }
-
-        if (pOD->fOptState & OPTST_SCALED_NUM)
-            fprintf(option_usage_fp, zRangeScaled, pz_indent);
-
-        if (rng_ct > 1) {
-            fprintf(option_usage_fp, lie_in_range, pz_indent);
-            pz_indent =
-                (pOpts != OPTPROC_EMIT_USAGE) ? onetab : deepin;
-
-        } else {
-            fprintf(option_usage_fp, zRangeOnly, pz_indent);
-            pz_indent = onetab + 1; /* empty string */
-        }
+    /*
+     * The range is shown only for full usage requests and an error
+     * in this particular option.
+     */
+    if (pOpts != OPTPROC_EMIT_USAGE) {
+        if (pOpts <= OPTPROC_EMIT_LIMIT)
+            return;
+        pz_indent = onetab;
+
+        fprintf(option_usage_fp, zRangeErr, pOpts->pzProgName,
+                pOD->pz_Name, pOD->optArg.argString);
+        pz_indent = "";
+    }
 
-        for (;;) {
-            if (rng->rmax == LONG_MIN)
-                fprintf(option_usage_fp, zRangeExact, pz_indent, rng->rmin);
-            else if (rng->rmin == LONG_MIN)
-                fprintf(option_usage_fp, zRangeUpto, pz_indent, rng->rmax);
-            else if (rng->rmax == LONG_MAX)
-                fprintf(option_usage_fp, zRangeAbove, pz_indent, rng->rmin);
-            else
-                fprintf(option_usage_fp, zRange, pz_indent, rng->rmin,
-                        rng->rmax);
-
-            if  (--rng_ct <= 0) {
-                fputc('\n', option_usage_fp);
-                break;
-            }
-            fputs(zRangeOr, option_usage_fp);
-            rng++;
-            pz_indent =
-                (pOpts != OPTPROC_EMIT_USAGE) ? onetab : deepin;
+    if (pOD->fOptState & OPTST_SCALED_NUM)
+        fprintf(option_usage_fp, zRangeScaled, pz_indent);
+
+    fprintf(option_usage_fp, (rng_ct > 1) ? zRangeLie : zRangeOnly, pz_indent);
+    pz_indent = (pOpts != OPTPROC_EMIT_USAGE) ? onetab : deepin;
+
+    for (;;) {
+        if (rng->rmax == LONG_MIN)
+            fprintf(option_usage_fp, zRangeExact, pz_indent, rng->rmin);
+        else if (rng->rmin == LONG_MIN)
+            fprintf(option_usage_fp, zRangeUpto, pz_indent, rng->rmax);
+        else if (rng->rmax == LONG_MAX)
+            fprintf(option_usage_fp, zRangeAbove, pz_indent, rng->rmin);
+        else
+            fprintf(option_usage_fp, zRange, pz_indent, rng->rmin,
+                    rng->rmax);
+
+        if  (--rng_ct <= 0) {
+            fputc('\n', option_usage_fp);
+            break;
         }
-
-        if (pOpts > OPTPROC_EMIT_LIMIT)
-            pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+        fputs(zRangeOr, option_usage_fp);
+        rng++;
     }
-}
 
+    if (pOpts > OPTPROC_EMIT_LIMIT)
+        pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+}
 
 /*=export_func  optionNumericVal
  * private:
@@ -165,6 +156,7 @@ optionNumericVal(tOptions* pOpts, tOptDesc* pOD )
     if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
         (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
 
+    errno = EINVAL;
     pOD->optArg.argInt = ~0;
 }
 
index 2570299d48887c8c2d1c8912aadb1d3ca8ab5c78..0a8c4ada8408e187952e636b4441409cd36f4669 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <config.h>
 
+/* Specification.  */
+#include "parse-duration.h"
+
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "parse-duration.h"
-
-#ifndef _
-#define _(_s)  _s
-#endif
-
 #ifndef NUL
 #define NUL '\0'
 #endif
@@ -56,18 +53,23 @@ typedef enum {
 
 #define TIME_MAX        0x7FFFFFFF
 
+/* Wrapper around strtoul that does not require a cast.  */
 static unsigned long inline
 str_const_to_ul (cch_t * str, cch_t ** ppz, int base)
 {
   return strtoul (str, (char **)ppz, base);
 }
 
+/* Wrapper around strtol that does not require a cast.  */
 static long inline
 str_const_to_l (cch_t * str, cch_t ** ppz, int base)
 {
   return strtol (str, (char **)ppz, base);
 }
 
+/* Returns BASE + VAL * SCALE, interpreting BASE = BAD_TIME
+   with errno set as an error situation, and returning BAD_TIME
+   with errno set in an error situation.  */
 static time_t inline
 scale_n_add (time_t base, time_t val, int scale)
 {
@@ -94,6 +96,7 @@ scale_n_add (time_t base, time_t val, int scale)
   return base + val;
 }
 
+/* After a number HH has been parsed, parse subsequent :MM or :MM:SS.  */
 static time_t
 parse_hr_min_sec (time_t start, cch_t * pz)
 {
@@ -117,7 +120,8 @@ parse_hr_min_sec (time_t start, cch_t * pz)
     }
 
   /* allow for trailing spaces */
-  while (isspace ((unsigned char)*pz))   pz++;
+  while (isspace ((unsigned char)*pz))
+    pz++;
   if (*pz != NUL)
     {
       errno = EINVAL;
@@ -127,6 +131,9 @@ parse_hr_min_sec (time_t start, cch_t * pz)
   return start;
 }
 
+/* Parses a value and returns BASE + value * SCALE, interpreting
+   BASE = BAD_TIME with errno set as an error situation, and returning
+   BAD_TIME with errno set in an error situation.  */
 static time_t
 parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale)
 {
@@ -140,17 +147,20 @@ parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale)
   val = str_const_to_ul (pz, &pz, 10);
   if (errno != 0)
     return BAD_TIME;
-  while (isspace ((unsigned char)*pz))   pz++;
+  while (isspace ((unsigned char)*pz))
+    pz++;
   if (pz != endp)
     {
       errno = EINVAL;
       return BAD_TIME;
     }
 
-  *ppz =  pz;
+  *ppz = pz;
   return scale_n_add (base, val, scale);
 }
 
+/* Parses the syntax YEAR-MONTH-DAY.
+   PS points into the string, after "YEAR", before "-MONTH-DAY".  */
 static time_t
 parse_year_month_day (cch_t * pz, cch_t * ps)
 {
@@ -158,7 +168,8 @@ parse_year_month_day (cch_t * pz, cch_t * ps)
 
   res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR);
 
-  ps = strchr (++pz, '-');
+  pz++; /* over the first '-' */
+  ps = strchr (pz, '-');
   if (ps == NULL)
     {
       errno = EINVAL;
@@ -166,11 +177,12 @@ parse_year_month_day (cch_t * pz, cch_t * ps)
     }
   res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH);
 
-  pz++;
+  pz++; /* over the second '-' */
   ps = pz + strlen (pz);
   return parse_scaled_value (res, &pz, ps, SEC_PER_DAY);
 }
 
+/* Parses the syntax YYYYMMDD.  */
 static time_t
 parse_yearmonthday (cch_t * in_pz)
 {
@@ -200,6 +212,7 @@ parse_yearmonthday (cch_t * in_pz)
   return parse_scaled_value (res, &pz, buf + 2, SEC_PER_DAY);
 }
 
+/* Parses the syntax yy Y mm M ww W dd D.  */
 static time_t
 parse_YMWD (cch_t * pz)
 {
@@ -232,7 +245,8 @@ parse_YMWD (cch_t * pz)
       pz++;
     }
 
-  while (isspace ((unsigned char)*pz))   pz++;
+  while (isspace ((unsigned char)*pz))
+    pz++;
   if (*pz != NUL)
     {
       errno = EINVAL;
@@ -242,6 +256,8 @@ parse_YMWD (cch_t * pz)
   return res;
 }
 
+/* Parses the syntax HH:MM:SS.
+   PS points into the string, after "HH", before ":MM:SS".  */
 static time_t
 parse_hour_minute_second (cch_t * pz, cch_t * ps)
 {
@@ -249,7 +265,8 @@ parse_hour_minute_second (cch_t * pz, cch_t * ps)
 
   res = parse_scaled_value (0, &pz, ps, SEC_PER_HR);
 
-  ps = strchr (++pz, ':');
+  pz++;
+  ps = strchr (pz, ':');
   if (ps == NULL)
     {
       errno = EINVAL;
@@ -263,6 +280,7 @@ parse_hour_minute_second (cch_t * pz, cch_t * ps)
   return parse_scaled_value (res, &pz, ps, 1);
 }
 
+/* Parses the syntax HHMMSS.  */
 static time_t
 parse_hourminutesecond (cch_t * in_pz)
 {
@@ -292,6 +310,7 @@ parse_hourminutesecond (cch_t * in_pz)
   return parse_scaled_value (res, &pz, buf + 2, 1);
 }
 
+/* Parses the syntax hh H mm M ss S.  */
 static time_t
 parse_HMS (cch_t * pz)
 {
@@ -317,7 +336,8 @@ parse_HMS (cch_t * pz)
       pz++;
     }
 
-  while (isspace ((unsigned char)*pz))   pz++;
+  while (isspace ((unsigned char)*pz))
+    pz++;
   if (*pz != NUL)
     {
       errno = EINVAL;
@@ -327,6 +347,7 @@ parse_HMS (cch_t * pz)
   return res;
 }
 
+/* Parses a time (hours, minutes, seconds) specification in either syntax.  */
 static time_t
 parse_time (cch_t * pz)
 {
@@ -358,16 +379,20 @@ parse_time (cch_t * pz)
   return res;
 }
 
+/* Returns a substring of the given string, with spaces at the beginning and at
+   the end destructively removed, per SNOBOL.  */
 static char *
-trim(char * pz)
+trim (char * pz)
 {
   /* trim leading white space */
-  while (isspace ((unsigned char)*pz))  pz++;
+  while (isspace ((unsigned char)*pz))
+    pz++;
 
   /* trim trailing white space */
   {
     char * pe = pz + strlen (pz);
-    while ((pe > pz) && isspace ((unsigned char)pe[-1])) pe--;
+    while ((pe > pz) && isspace ((unsigned char)pe[-1]))
+      pe--;
     *pe = NUL;
   }
 
@@ -380,13 +405,20 @@ trim(char * pz)
 static time_t
 parse_period (cch_t * in_pz)
 {
-  char * pz   = xstrdup (in_pz);
-  char * pT   = strchr (pz, 'T');
+  char * pT;
   char * ps;
+  char * pz   = strdup (in_pz);
   void * fptr = pz;
   time_t res  = 0;
 
-  if (pT != NUL)
+  if (pz == NULL)
+    {
+      errno = ENOMEM;
+      return BAD_TIME;
+    }
+
+  pT = strchr (pz, 'T');
+  if (pT != NULL)
     {
       *(pT++) = NUL;
       pz = trim (pz);
@@ -426,7 +458,7 @@ parse_period (cch_t * in_pz)
 }
 
 static time_t
-parse_non_iso8601(cch_t * pz)
+parse_non_iso8601 (cch_t * pz)
 {
   whats_done_t whatd_we_do = NOTHING_IS_DONE;
 
@@ -461,7 +493,8 @@ parse_non_iso8601(cch_t * pz)
       unsigned int mult;
 
       /*  Skip over white space following the number we just parsed. */
-      while (isspace ((unsigned char)*pz))   pz++;
+      while (isspace ((unsigned char)*pz))
+        pz++;
 
       switch (*pz)
         {
@@ -519,7 +552,9 @@ parse_non_iso8601(cch_t * pz)
 
       res = scale_n_add (res, val, mult);
 
-      while (isspace ((unsigned char)*++pz))   ;
+      pz++;
+      while (isspace ((unsigned char)*pz))
+        pz++;
       if (*pz == NUL)
         return res;
 
@@ -537,40 +572,24 @@ parse_non_iso8601(cch_t * pz)
 time_t
 parse_duration (char const * pz)
 {
-  time_t res = 0;
+  while (isspace ((unsigned char)*pz))
+    pz++;
 
-  while (isspace ((unsigned char)*pz)) pz++;
-
-  do {
-    if (*pz == 'P')
-      {
-        res = parse_period (pz + 1);
-        if ((errno != 0) || (res == BAD_TIME))
-          break;
-        return res;
-      }
-
-    if (*pz == 'T')
-      {
-        res = parse_time (pz + 1);
-        if ((errno != 0) || (res == BAD_TIME))
-          break;
-        return res;
-      }
-
-    if (! isdigit ((unsigned char)*pz))
-      break;
+  switch (*pz)
+    {
+    case 'P':
+      return parse_period (pz + 1);
 
-    res = parse_non_iso8601 (pz);
-    if ((errno == 0) && (res != BAD_TIME))
-      return res;
+    case 'T':
+      return parse_time (pz + 1);
 
-  } while (0);
+    default:
+      if (isdigit ((unsigned char)*pz))
+        return parse_non_iso8601 (pz);
 
-  fprintf (stderr, _("Invalid time duration:  %s\n"), pz);
-  if (errno == 0)
-    errno = EINVAL;
-  return BAD_TIME;
+      errno = EINVAL;
+      return BAD_TIME;
+    }
 }
 
 /*
@@ -579,4 +598,4 @@ parse_duration (char const * pz)
  * c-file-style: "gnu"
  * indent-tabs-mode: nil
  * End:
- * end of autoopts/parse-duration.c */
+ * end of parse-duration.c */
index 583adc726e68edf8cb4a2750c5b1de06dd081460..9fd2a364cdb1ac00ed4083f5465c926eb40e37b2 100644 (file)
 
   ==== if it is a digit
 
-  the string may contain:  NNN d NNN h NNN m NNN s
-  This represents NNN days, NNN hours, NNN minutes and NNN seconds.
+  the string may contain:  NNN Y NNN M NNN W NNN d NNN h NNN m NNN s
+  This represents NNN years, NNN months, NNN weeks, NNN days, NNN hours,
+    NNN minutes and NNN seconds.
   The embeded white space is optional.
   These terms must appear in this order.
+  Case is significant:  'M' is months and 'm' is minutes.
   The final "s" is optional.
   All of the terms ("NNN" plus designator) are optional.
   Minutes and seconds may optionally be represented as NNN:NNN.
     yy Y mm M ww W dd D
 
   or it may be empty and followed by a 'T'.  The "yyyymmdd" must be eight
-  digits long.  Note:  months are always 30 days and years are always 365
-  days long.  5 years is always 1825, not 1826 or 1827 depending on leap
-  year considerations.  3 months is always 90 days.  There is no consideration
+  digits long.
+
+  NOTE!  Months are always 30 days and years are always 365 days long.
+  5 years is always 1825 days, not 1826 or 1827 depending on leap year
+  considerations.  3 months is always 90 days.  There is no consideration
   for how many days are in the current, next or previous months.
 
   For the final format:
 
 #include <time.h>
 
+/* Return value when a valid duration cannot be parsed.  */
 #define BAD_TIME        ((time_t)~0)
 
-extern time_t parse_duration(char const * in_pz);
+/* Parses the given string.  If it has the syntax of a valid duration,
+   this duration is returned.  Otherwise, the return value is BAD_TIME,
+   and errno is set to either EINVAL (bad syntax) or ERANGE (out of range).  */
+extern time_t parse_duration (char const * in_pz);
 
 #endif /* GNULIB_PARSE_DURATION_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-file-style: "gnu"
- * indent-tabs-mode: nil
- * End:
- * end of autoopts/parse-duration.h */
index aa897e10363a170026616887a680f2ad490727a9..2e2194867e38852cfea15c908f512a1a86aa40a7 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file pgusage.c
  *
- * Time-stamp:      "2010-07-17 10:42:53 bkorb"
+ * Time-stamp:      "2011-03-25 17:54:41 bkorb"
  *
  *   Automated Options Paged Usage module.
  *
@@ -30,8 +30,6 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
 
-tePagerState pagerState = PAGER_STATE_INITIAL;
-
 /*=export_func  optionPagedUsage
  * private:
  *
index 80dacd163b038ad40cf0c5d38f86e4e5e5ae96ca..13843c8b620ca7a9cd21e53d335a6a8afc8dfe9e 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- buffer-read-only: t -*- vi: set ro:
  *
  * Prototypes for autoopts
- * Generated Thu Feb 17 16:58:43 PST 2011
+ * Generated Fri Apr 29 15:44:06 PDT 2011
  */
 #ifndef AUTOOPTS_PROTO_H_GUARD
 #define AUTOOPTS_PROTO_H_GUARD 1
@@ -21,9 +21,6 @@ ao_malloc(size_t sz);
 LOCAL void *
 ao_realloc(void *p, size_t sz);
 
-LOCAL void
-ao_free(void *p);
-
 LOCAL char *
 ao_strdup(char const *str);
 
index b9f154bf5ff92e9c2e22bf401d79128d1445649d..9c36bc83fdbfcf6ae9714eb3be29d8142c45f9cf 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * \file save.c
  *
- * Time-stamp:      "2010-07-17 10:27:48 bkorb"
+ * Time-stamp:      "2011-04-06 09:21:44 bkorb"
  *
  *  This module's routines will take the currently set options and
  *  store them into an ".rc" file for re-interpretation the next
@@ -36,8 +36,8 @@ static char const close_xml[] = "</%s>\n";
 static tCC*
 findDirName(tOptions* pOpts, int* p_free);
 
-static tCC*
-findFileName(tOptions* pOpts, int* p_free_name);
+static char const *
+findFileName(tOptions * pOpts, int * p_free_name);
 
 static void
 printEntry(
@@ -117,8 +117,8 @@ findDirName(tOptions* pOpts, int* p_free)
             char z[ AO_NAME_SIZE ];
             if ((pzEndDir - pzDir) > AO_NAME_LIMIT )
                 return NULL;
-            strncpy(z, pzDir, (size_t)(pzEndDir - pzDir));
-            z[ (pzEndDir - pzDir) ] = NUL;
+            memcpy(z, pzDir, (size_t)(pzEndDir - pzDir));
+            z[pzEndDir - pzDir] = NUL;
             pzEnv = getenv(z);
         } else {
 
@@ -157,14 +157,13 @@ findDirName(tOptions* pOpts, int* p_free)
 }
 
 
-static tCC*
-findFileName(tOptions* pOpts, int* p_free_name)
+static char const *
+findFileName(tOptions * pOpts, int * p_free_name)
 {
-    tCC*   pzDir;
     struct stat stBuf;
     int    free_dir_name = 0;
 
-    pzDir = findDirName(pOpts, &free_dir_name);
+    char const * pzDir = findDirName(pOpts, &free_dir_name);
     if (pzDir == NULL)
         return NULL;
 
@@ -173,47 +172,41 @@ findFileName(tOptions* pOpts, int* p_free_name)
      *  structure so we can bail out early.
      */
     if (stat(pzDir, &stBuf) != 0) do {
+        char z[AG_PATH_MAX];
+        char * dirchp;
 
         /*
          *  IF we could not, check to see if we got a full
          *  path to a file name that has not been created yet.
          */
-        if (errno == ENOENT) {
-            char z[AG_PATH_MAX];
-
-            /*
-             *  Strip off the last component, stat the remaining string and
-             *  that string must name a directory
-             */
-            char* pzDirCh = strrchr(pzDir, DIRCH);
-            if (pzDirCh == NULL) {
-                stBuf.st_mode = S_IFREG;
-                continue;  /* bail out of error condition */
-            }
-
-            strncpy(z, pzDir, (size_t)(pzDirCh - pzDir));
-            z[ pzDirCh - pzDir ] = NUL;
-
-            if (  (stat(z, &stBuf) == 0)
-               && S_ISDIR(stBuf.st_mode)) {
-
-                /*
-                 *  We found the directory.  Restore the file name and
-                 *  mark the full name as a regular file
-                 */
-                stBuf.st_mode = S_IFREG;
-                continue;  /* bail out of error condition */
-            }
+        if (errno != ENOENT) {
+        bogus_name:
+            fprintf(stderr, zWarn, pOpts->pzProgName);
+            fprintf(stderr, zNoStat, errno, strerror(errno), pzDir);
+            if (free_dir_name)
+                AGFREE((void*)pzDir);
+            return NULL;
         }
 
         /*
-         *  We got a bogus name.
+         *  Strip off the last component, stat the remaining string and
+         *  that string must name a directory
          */
-        fprintf(stderr, zWarn, pOpts->pzProgName);
-        fprintf(stderr, zNoStat, errno, strerror(errno), pzDir);
-        if (free_dir_name)
-            AGFREE((void*)pzDir);
-        return NULL;
+        dirchp = strrchr(pzDir, DIRCH);
+        if (dirchp == NULL) {
+            stBuf.st_mode = S_IFREG;
+            break; /* found directory -- viz.,  "." */
+        }
+
+        if ((dirchp - pzDir) >= sizeof(z))
+            goto bogus_name;
+
+        memcpy(z, pzDir, (size_t)(dirchp - pzDir));
+        z[dirchp - pzDir] = NUL;
+
+        if ((stat(z, &stBuf) != 0) || ! S_ISDIR(stBuf.st_mode))
+            goto bogus_name;
+        stBuf.st_mode = S_IFREG; /* file within this directory */
     } while (0);
 
     /*
index e8e4d8d78a314c352081c70f40ebc7c7ff8e7329..656c78d60130f8c5fe3ee239805a4017647de2e0 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * \file time.c
  *
- *  Time-stamp:      "2010-07-17 10:36:19 bkorb"
+ *  Time-stamp:      "2011-03-06 11:52:23 bkorb"
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
 
-#ifndef HAVE_PARSE_DURATION
-#include <time.h>
-
-static inline char *
-ao_xstrdup(char const * pz)
-{
-    char * str;
-    AGDUPSTR(str, pz, "time val str");
-    return str;
-}
-
-#define xstrdup(_s) ao_xstrdup(_s)
-
-#include "parse-duration.c"
-
-#undef xstrdup
-#endif
-
 /*=export_func  optionTimeVal
  * private:
  *
- * what:  process an option with a time value.
+ * what:  process an option with a time duration.
  * arg:   + tOptions* + pOpts    + program options descriptor +
  * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
  *
@@ -54,16 +36,19 @@ ao_xstrdup(char const * pz)
  *  Decipher a time duration value.
 =*/
 void
-optionTimeVal(tOptions* pOpts, tOptDesc* pOD )
+optionTimeVal(tOptions * pOpts, tOptDesc * pOD)
 {
-    long  val;
+    time_t val;
 
     if ((pOD->fOptState & OPTST_RESET) != 0)
         return;
 
     val = parse_duration(pOD->optArg.argString);
-    if (errno != 0)
-        goto bad_time;
+    if (val == BAD_TIME) {
+        fprintf(stderr, zNotDuration, pOpts->pzProgName, pOD->optArg.argString);
+        if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+            (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+    }
 
     if (pOD->fOptState & OPTST_ALLOC_ARG) {
         AGFREE(pOD->optArg.argString);
@@ -71,14 +56,77 @@ optionTimeVal(tOptions* pOpts, tOptDesc* pOD )
     }
 
     pOD->optArg.argInt = val;
+}
+
+/*=export_func  optionTimeDate
+ * private:
+ *
+ * what:  process an option with a time and date.
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Decipher a time and date value.
+=*/
+void
+optionTimeDate(tOptions * pOpts, tOptDesc * pOD)
+{
+#if defined(HAVE_GETDATE_R) && defined(HAVE_PUTENV)
+    if ((! HAS_pzPkgDataDir(pOpts)) || (pOpts->pzPkgDataDir == NULL))
+        goto default_action;
+
+    /*
+     *  Export the DATEMSK environment variable.  getdate_r() uses it to
+     *  find the file with the strptime formats.  If we cannot find the file
+     *  we need ($PKGDATADIR/datemsk), then fall back to just a time duration.
+     */
+    {
+        static char * envptr = NULL;
+
+        if (envptr == NULL) {
+            static char const fmt[] = "DATEMSK=%s/datemsk";
+            envptr = AGALOC(sizeof(fmt) + strlen(pOpts->pzPkgDataDir), fmt);
+            sprintf(envptr, fmt, pOpts->pzPkgDataDir);
+
+            putenv(envptr);
+        }
+
+        if (access(envptr+8, R_OK) != 0)
+            goto default_action;
+    }
+
+    /*
+     *  Convert the date to a time since the epoch and stash it in a long int.
+     */
+    {
+        struct tm stm;
+        time_t tm;
+
+        if (getdate_r(pOD->optArg.argString, &stm) != 0) {
+            fprintf(stderr, zNotDate, pOpts->pzProgName,
+                    pOD->optArg.argString);
+            if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+                (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+            return;
+        }
+
+        tm = mktime(&stm);
+
+        if (pOD->fOptState & OPTST_ALLOC_ARG) {
+            AGFREE(pOD->optArg.argString);
+            pOD->fOptState &= ~OPTST_ALLOC_ARG;
+        }
+
+        pOD->optArg.argInt = tm;
+    }
     return;
 
-bad_time:
-    fprintf(stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString);
-    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
-        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+default_action:
 
-    pOD->optArg.argInt = ~0;
+#endif
+    optionTimeVal(pOpts, pOD);
+    if (pOD->optArg.argInt != BAD_TIME)
+        pOD->optArg.argInt += (unsigned long)time(NULL);
 }
 /*
  * Local Variables:
index 2a95f7b9068c0d56a905ac55747749255959c97f..5ff917cb9e7c3b8c26b11124ff1cac551ab6b6d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Generated header for gperf generated source Thu Feb 17 16:58:35 PST 2011
+ *  Generated header for gperf generated source Fri Apr 29 15:43:59 PDT 2011
  *  This file enumerates the list of names and declares the
  *  procedure for mapping string names to the enum value.
  */
index b819f3e54ee482a464a50311fa9853edd769b49b..aae1b87485c8a7321e54ac38bdb7e937b8bb4db1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Time-stamp:      "2011-02-01 13:20:14 bkorb"
+ * Time-stamp:      "2011-04-22 12:54:28 bkorb"
  *
  *  This module implements the default usage procedure for
  *  Automated Options.  It may be overridden, of course.
@@ -47,65 +47,96 @@ optionVersion(void)
 }
 
 static void
-print_ver(tOptions* pOpts, tOptDesc* pOD, FILE* fp)
+emit_simple_ver(tOptions * pOpts, FILE * fp)
 {
-    char swCh;
+    if (pOpts->pzFullVersion != NULL)
+        fputs(pOpts->pzFullVersion, fp);
 
-    /*
-     *  IF the optional argument flag is off, or the argument is not provided,
-     *  then just print the version.
-     */
-    if (  ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0)
-       || (pOD->optArg.argString == NULL))
-         swCh = 'v';
-    else swCh = tolower(pOD->optArg.argString[0]);
+    else if (pOpts->pzCopyright != NULL) {
+        char const * pe = strchr(pOpts->pzCopyright, '\n');
+        if (pe == NULL)
+            pe = pOpts->pzCopyright + strlen(pOpts->pzCopyright);
+        fwrite(pOpts->pzCopyright, 1, pe - pOpts->pzCopyright, fp);
+    }
+
+    else {
+        char const * pe = strchr(pOpts->pzUsageTitle, '\n');
+        if (pe == NULL)
+            pe = pOpts->pzUsageTitle + strlen(pOpts->pzUsageTitle);
+        fwrite(pOpts->pzUsageTitle, 1, pe - pOpts->pzCopyright, fp);
+    }
+    fputc('\n', fp);
+}
 
-    if (pOpts->pzFullVersion != NULL) {
+static void
+emit_copy_ver(tOptions * pOpts, FILE * fp)
+{
+    if (pOpts->pzCopyright != NULL)
+        fputs(pOpts->pzCopyright, fp);
+
+    else if (pOpts->pzFullVersion != NULL)
         fputs(pOpts->pzFullVersion, fp);
+
+    else {
+        char const * pe = strchr(pOpts->pzUsageTitle, '\n');
+        if (pe == NULL)
+            pe = pOpts->pzUsageTitle + strlen(pOpts->pzUsageTitle);
+        fwrite(pOpts->pzUsageTitle, 1, pe - pOpts->pzCopyright, fp);
+    }
+
+    fputc('\n', fp);
+
+    if (HAS_pzPkgDataDir(pOpts) && (pOpts->pzPackager != NULL))
+        fputs(pOpts->pzPackager, fp);
+
+    else if (pOpts->pzBugAddr != NULL)
+        fprintf(fp, zPlsSendBugs, pOpts->pzBugAddr);
+}
+
+static void
+emit_copy_note(tOptions * pOpts, FILE * fp)
+{
+    if (pOpts->pzCopyright != NULL) {
+        fputs(pOpts->pzCopyright, fp);
         fputc('\n', fp);
+    }
 
-    } else {
-        char const *pz = pOpts->pzUsageTitle;
-        do { fputc(*pz, fp); } while (*(pz++) != '\n');
+    if (pOpts->pzCopyNotice != NULL) {
+        fputs(pOpts->pzCopyNotice, fp);
+        fputc('\n', fp);
     }
 
-    switch (swCh) {
+    fprintf(fp, zAO_Ver, optionVersion());
+
+    if (HAS_pzPkgDataDir(pOpts) && (pOpts->pzPackager != NULL))
+        fputs(pOpts->pzPackager, fp);
+
+    else if (pOpts->pzBugAddr != NULL)
+        fprintf(fp, zPlsSendBugs, pOpts->pzBugAddr);
+}
+
+static void
+print_ver(tOptions * pOpts, tOptDesc * pOD, FILE * fp)
+{
+    char ch;
+
+    /*
+     *  IF the optional argument flag is off, or the argument
+     *  is not provided, then just print the version.
+     */
+    if (  ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0)
+       || (pOD->optArg.argString == NULL))
+         ch = 'v';
+    else ch = pOD->optArg.argString[0];
+
+    switch (ch) {
     case NUL: /* arg provided, but empty */
-    case 'v':
-        break;
-
-    case 'c':
-        if (pOpts->pzCopyright != NULL) {
-            fputs(pOpts->pzCopyright, fp);
-            fputc('\n', fp);
-        }
-        fprintf(fp, zAO_Ver, optionVersion());
-        if (pOpts->pzBugAddr != NULL)
-            fprintf(fp, zPlsSendBugs, pOpts->pzBugAddr);
-        break;
-
-    case 'n':
-        if (pOpts->pzCopyright != NULL) {
-            fputs(pOpts->pzCopyright, fp);
-            fputc('\n', fp);
-            fputc('\n', fp);
-        }
-
-        if (pOpts->pzCopyNotice != NULL) {
-            fputs(pOpts->pzCopyNotice, fp);
-            fputc('\n', fp);
-        }
-
-        fprintf(fp, zAO_Ver, optionVersion());
-
-        if (HAS_pzPkgDataDir(pOpts) && (pOpts->pzPackager != NULL))
-            fputs(pOpts->pzPackager, fp);
-        else if (pOpts->pzBugAddr != NULL)
-            fprintf(fp, zPlsSendBugs, pOpts->pzBugAddr);
-        break;
+    case 'v': case 'V': emit_simple_ver(pOpts, fp); break;
+    case 'c': case 'C': emit_copy_ver(pOpts, fp);   break;
+    case 'n': case 'N': emit_copy_note(pOpts, fp);  break;
 
     default:
-        fprintf(stderr, zBadVerArg, swCh);
+        fprintf(stderr, zBadVerArg, ch);
         exit(EXIT_FAILURE);
     }
 
@@ -128,7 +159,7 @@ print_ver(tOptions* pOpts, tOptDesc* pOD, FILE* fp)
  *  This routine will print the version to stdout.
 =*/
 void
-optionPrintVersion(tOptions*  pOpts, tOptDesc*  pOD)
+optionPrintVersion(tOptions * pOpts, tOptDesc * pOD)
 {
     print_ver(pOpts, pOD, stdout);
 }
@@ -144,7 +175,7 @@ optionPrintVersion(tOptions*  pOpts, tOptDesc*  pOD)
  *  This routine will print the version to stderr.
 =*/
 void
-optionVersionStderr(tOptions*  pOpts, tOptDesc*  pOD)
+optionVersionStderr(tOptions * pOpts, tOptDesc * pOD)
 {
     print_ver(pOpts, pOD, stderr);
 }
index d8e09318240e1dfd5e611d78ebc1736e0b54ff3a..079c59a3d0ac0d2f1f2acbc486c817a382505483 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Generated header for gperf generated source Thu Feb 17 16:58:35 PST 2011
+ *  Generated header for gperf generated source Fri Apr 29 15:43:59 PDT 2011
  *  This file enumerates the list of names and declares the
  *  procedure for mapping string names to the enum value.
  */