summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libopts/COPYING.gplv32
-rw-r--r--src/libopts/COPYING.lgplv32
-rw-r--r--src/libopts/Makefile.am29
-rw-r--r--src/libopts/README2
-rw-r--r--src/libopts/ag-char-map.h227
-rw-r--r--src/libopts/alias.c108
-rw-r--r--src/libopts/ao-strs.c323
-rw-r--r--src/libopts/ao-strs.h251
-rw-r--r--src/libopts/autoopts.c28
-rw-r--r--src/libopts/autoopts.h8
-rw-r--r--src/libopts/autoopts/options.h50
-rw-r--r--src/libopts/autoopts/usage-txt.h6
-rw-r--r--src/libopts/boolean.c2
-rw-r--r--src/libopts/check.c2
-rw-r--r--src/libopts/compat/compat.h6
-rw-r--r--src/libopts/compat/windows-config.h2
-rw-r--r--src/libopts/configfile.c28
-rw-r--r--src/libopts/cook.c24
-rw-r--r--src/libopts/enum.c67
-rw-r--r--src/libopts/env.c2
-rw-r--r--src/libopts/file.c2
-rw-r--r--src/libopts/find.c74
-rw-r--r--src/libopts/genshell.c10
-rw-r--r--src/libopts/genshell.h8
-rw-r--r--src/libopts/libopts.c10
-rw-r--r--src/libopts/load.c21
-rw-r--r--src/libopts/m4/libopts.m423
-rw-r--r--src/libopts/m4/liboptschk.m42
-rw-r--r--src/libopts/makeshell.c562
-rw-r--r--src/libopts/nested.c105
-rw-r--r--src/libopts/numeric.c20
-rw-r--r--src/libopts/parse-duration.c2
-rw-r--r--src/libopts/parse-duration.h4
-rw-r--r--src/libopts/pgusage.c17
-rw-r--r--src/libopts/proto.h2
-rw-r--r--src/libopts/putshell.c55
-rw-r--r--src/libopts/reset.c2
-rw-r--r--src/libopts/restore.c2
-rw-r--r--src/libopts/save.c180
-rw-r--r--src/libopts/sort.c2
-rw-r--r--src/libopts/stack.c12
-rw-r--r--src/libopts/streqvcmp.c12
-rw-r--r--src/libopts/text_mmap.c14
-rw-r--r--src/libopts/time.c6
-rw-r--r--src/libopts/tokenize.c10
-rw-r--r--src/libopts/usage.c18
-rw-r--r--src/libopts/value-type.h2
-rw-r--r--src/libopts/version.c35
-rw-r--r--src/libopts/xat-attribute.h2
49 files changed, 1412 insertions, 971 deletions
diff --git a/src/libopts/COPYING.gplv3 b/src/libopts/COPYING.gplv3
index 6c1b848d6b..f22cdbb209 100644
--- a/src/libopts/COPYING.gplv3
+++ b/src/libopts/COPYING.gplv3
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
diff --git a/src/libopts/COPYING.lgplv3 b/src/libopts/COPYING.lgplv3
index c7759a01b2..a1bc40ddf8 100644
--- a/src/libopts/COPYING.lgplv3
+++ b/src/libopts/COPYING.lgplv3
@@ -1,7 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
diff --git a/src/libopts/Makefile.am b/src/libopts/Makefile.am
index 84595b0d67..80b01e346b 100644
--- a/src/libopts/Makefile.am
+++ b/src/libopts/Makefile.am
@@ -7,21 +7,22 @@ noinst_LTLIBRARIES = libopts.la
endif
libopts_la_SOURCES = libopts.c
libopts_la_CPPFLAGS = -I$(top_srcdir)
-libopts_la_LDFLAGS = -version-info 36:1:11
+libopts_la_LDFLAGS = -version-info 36:2:11
EXTRA_DIST = \
- COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd \
- MakeDefs.inc README ag-char-map.h \
- autoopts/project.h autoopts/options.h autoopts/usage-txt.h \
- autoopts.c autoopts.h boolean.c \
- check.c compat/pathfind.c compat/strchr.c \
- compat/windows-config.h compat/snprintf.c compat/compat.h \
- compat/strdup.c configfile.c cook.c \
- enum.c env.c file.c \
- find.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 \
+ ag-char-map.h alias.c ao-strs.c \
+ ao-strs.h autoopts/options.h autoopts/project.h \
+ autoopts/usage-txt.h autoopts.c autoopts.h \
+ boolean.c check.c compat/strchr.c \
+ compat/pathfind.c compat/strdup.c compat/windows-config.h \
+ compat/snprintf.c compat/compat.h configfile.c \
+ cook.c COPYING.gplv3 COPYING.lgplv3 \
+ COPYING.mbsd enum.c env.c \
+ file.c find.c genshell.c \
+ genshell.h load.c m4/liboptschk.m4 \
+ m4/libopts.m4 MakeDefs.inc makeshell.c \
+ nested.c numeric.c parse-duration.c \
+ parse-duration.h pgusage.c proto.h \
+ putshell.c README reset.c \
restore.c save.c sort.c \
stack.c streqvcmp.c text_mmap.c \
time.c tokenize.c usage.c \
diff --git a/src/libopts/README b/src/libopts/README
index afa5409874..0d9ac649f6 100644
--- a/src/libopts/README
+++ b/src/libopts/README
@@ -115,7 +115,7 @@ These macros work as follows:
LICENSING:
-This material is Copyright (c) 1992-2011 by Bruce Korb. You are
+This material is Copyright (c) 1992-2012 by Bruce Korb. You are
licensed to use this under the terms of either the GNU Lesser General
Public License (see: COPYING.lgpl), or, at your option, the modified
Berkeley Software Distribution License (see: COPYING.mbsd). Both of
diff --git a/src/libopts/ag-char-map.h b/src/libopts/ag-char-map.h
index 0fb9794d41..2a9105ff27 100644
--- a/src/libopts/ag-char-map.h
+++ b/src/libopts/ag-char-map.h
@@ -1,17 +1,22 @@
/*
- * Character mapping generated 12/29/11 12:02:33
+ * Character mapping generated 02/10/12 19:53:35
*
* This file contains the character classifications
* used by AutoGen and AutoOpts for identifying tokens.
+ * The table is static scope, so %guard is empty.
+ *
* This file is part of AutoGen.
- * Copyright (c) 1992-2011 Bruce Korb - all rights reserved
+ * Copyright (c) 1992-2012 Bruce Korb - all rights reserved
+ *
* AutoGen is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
+ *
* AutoGen is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -20,76 +25,49 @@
#ifdef HAVE_CONFIG_H
# if defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
+# include <inttypes.h>
# elif defined(HAVE_STDINT_H)
-# include <stdint.h>
+# include <stdint.h>
# else
-# ifndef HAVE_INT8_T
- typedef signed char int8_t;
-# endif
# ifndef HAVE_UINT8_T
typedef unsigned char uint8_t;
# endif
-# ifndef HAVE_INT16_T
- typedef signed short int16_t;
-# endif
# ifndef HAVE_UINT16_T
typedef unsigned short uint16_t;
# endif
-# ifndef HAVE_UINT_T
- typedef unsigned int uint_t;
-# endif
-
-# ifndef HAVE_INT32_T
-# if SIZEOF_INT == 4
- typedef signed int int32_t;
-# elif SIZEOF_LONG == 4
- typedef signed long int32_t;
-# endif
-# endif
# ifndef HAVE_UINT32_T
-# if SIZEOF_INT == 4
+# if SIZEOF_INT == 4
typedef unsigned int uint32_t;
-# elif SIZEOF_LONG == 4
+# elif SIZEOF_LONG == 4
typedef unsigned long uint32_t;
-# endif
+# endif
+# endif
+
+# ifndef HAVE_UINT64_T
+# if SIZEOF_LONG == 8
+ typedef unsigned long uint64_t;
+# elif SIZEOF_LONG_LONG == 8
+ typedef unsigned long long uint64_t;
+# endif
# endif
# endif /* HAVE_*INT*_H header */
#else /* not HAVE_CONFIG_H -- */
# ifdef __sun
-# include <inttypes.h>
+# include <inttypes.h>
# else
-# include <stdint.h>
+# include <stdint.h>
# endif
#endif /* HAVE_CONFIG_H */
#if 0 /* mapping specification source (from autogen.map) */
//
-// %guard autoopts_internal
+// %guard
// %file ag-char-map.h
-// %static-table option-char-category
//
-// %comment
-// This file contains the character classifications
-// used by AutoGen and AutoOpts for identifying tokens.
-//
-// This file is part of AutoGen.
-// Copyright (c) 1992-2011 Bruce Korb - all rights reserved
-//
-// AutoGen is free software: you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the Free Software
-// Foundation, either version 3 of the License, or (at your option) any later
-// version.
-//
-// AutoGen is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-// A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program. If not, see <http://www.gnu.org/licenses/>.
+// %comment -- see above
// %
//
// lower-case "a-z"
@@ -104,7 +82,8 @@
// option-name "^-" +variable-name
// value-name ":" +option-name
// horiz-white "\t "
-// compound-name "[.]" +value-name +horiz-white
+// name-sep "[.]"
+// compound-name +value-name +name-sep +horiz-white
// whitespace "\v\f\r\n\b" +horiz-white
// unquotable "!-~" -"\"#(),;<=>[\\]`{}?*'"
// end-xml-token "/>" +whitespace
@@ -117,55 +96,106 @@
// file-name "/" +suffix
// end-token "\x00" +whitespace
// end-list-entry "," +end-token
+// set-separator "|+" +end-list-entry
//
#endif /* 0 -- mapping spec. source */
-typedef uint32_t option_char_category_mask_t;
-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 < 128) && ((option_char_category[ix] & mask) != 0)); }
+typedef uint32_t ag_char_map_mask_t;
-#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)
-#define IS_ALPHABETIC_CHAR(_c) is_option_char_category_char((_c), 0x000003)
-#define IS_OCT_DIGIT_CHAR(_c) is_option_char_category_char((_c), 0x000004)
-#define IS_DEC_DIGIT_CHAR(_c) is_option_char_category_char((_c), 0x00000C)
-#define IS_HEX_DIGIT_CHAR(_c) is_option_char_category_char((_c), 0x00001C)
-#define IS_ALPHANUMERIC_CHAR(_c) is_option_char_category_char((_c), 0x00000F)
-#define IS_VAR_FIRST_CHAR(_c) is_option_char_category_char((_c), 0x000023)
-#define IS_VARIABLE_NAME_CHAR(_c) is_option_char_category_char((_c), 0x00002F)
-#define IS_OPTION_NAME_CHAR(_c) is_option_char_category_char((_c), 0x00006F)
-#define IS_VALUE_NAME_CHAR(_c) is_option_char_category_char((_c), 0x0000EF)
-#define IS_HORIZ_WHITE_CHAR(_c) is_option_char_category_char((_c), 0x000100)
-#define IS_COMPOUND_NAME_CHAR(_c) is_option_char_category_char((_c), 0x0003EF)
-#define IS_WHITESPACE_CHAR(_c) is_option_char_category_char((_c), 0x000500)
-#define IS_UNQUOTABLE_CHAR(_c) is_option_char_category_char((_c), 0x000800)
-#define IS_END_XML_TOKEN_CHAR(_c) is_option_char_category_char((_c), 0x001500)
-#define IS_GRAPHIC_CHAR(_c) is_option_char_category_char((_c), 0x002000)
-#define IS_PLUS_N_SPACE_CHAR(_c) is_option_char_category_char((_c), 0x004500)
-#define IS_PUNCTUATION_CHAR(_c) is_option_char_category_char((_c), 0x008000)
-#define IS_SUFFIX_CHAR(_c) is_option_char_category_char((_c), 0x01000F)
-#define IS_SUFFIX_FMT_CHAR(_c) is_option_char_category_char((_c), 0x03000F)
-#define IS_FALSE_TYPE_CHAR(_c) is_option_char_category_char((_c), 0x040000)
-#define IS_FILE_NAME_CHAR(_c) is_option_char_category_char((_c), 0x09000F)
-#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)
+#define IS_LOWER_CASE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000001)
+#define SPN_LOWER_CASE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000001)
+#define BRK_LOWER_CASE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000001)
+#define IS_UPPER_CASE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000002)
+#define SPN_UPPER_CASE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000002)
+#define BRK_UPPER_CASE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000002)
+#define IS_ALPHABETIC_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000003)
+#define SPN_ALPHABETIC_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000003)
+#define BRK_ALPHABETIC_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000003)
+#define IS_OCT_DIGIT_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000004)
+#define SPN_OCT_DIGIT_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000004)
+#define BRK_OCT_DIGIT_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000004)
+#define IS_DEC_DIGIT_CHAR( _c) is_ag_char_map_char((char)( _c), 0x00000C)
+#define SPN_DEC_DIGIT_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x00000C)
+#define BRK_DEC_DIGIT_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x00000C)
+#define IS_HEX_DIGIT_CHAR( _c) is_ag_char_map_char((char)( _c), 0x00001C)
+#define SPN_HEX_DIGIT_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x00001C)
+#define BRK_HEX_DIGIT_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x00001C)
+#define IS_ALPHANUMERIC_CHAR( _c) is_ag_char_map_char((char)( _c), 0x00000F)
+#define SPN_ALPHANUMERIC_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x00000F)
+#define BRK_ALPHANUMERIC_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x00000F)
+#define IS_VAR_FIRST_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000023)
+#define SPN_VAR_FIRST_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000023)
+#define BRK_VAR_FIRST_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000023)
+#define IS_VARIABLE_NAME_CHAR( _c) is_ag_char_map_char((char)( _c), 0x00002F)
+#define SPN_VARIABLE_NAME_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x00002F)
+#define BRK_VARIABLE_NAME_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x00002F)
+#define IS_OPTION_NAME_CHAR( _c) is_ag_char_map_char((char)( _c), 0x00006F)
+#define SPN_OPTION_NAME_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x00006F)
+#define BRK_OPTION_NAME_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x00006F)
+#define IS_VALUE_NAME_CHAR( _c) is_ag_char_map_char((char)( _c), 0x0000EF)
+#define SPN_VALUE_NAME_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x0000EF)
+#define BRK_VALUE_NAME_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x0000EF)
+#define IS_HORIZ_WHITE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000100)
+#define SPN_HORIZ_WHITE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000100)
+#define BRK_HORIZ_WHITE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000100)
+#define IS_NAME_SEP_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000200)
+#define SPN_NAME_SEP_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000200)
+#define BRK_NAME_SEP_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000200)
+#define IS_COMPOUND_NAME_CHAR( _c) is_ag_char_map_char((char)( _c), 0x0003EF)
+#define SPN_COMPOUND_NAME_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x0003EF)
+#define BRK_COMPOUND_NAME_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x0003EF)
+#define IS_WHITESPACE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000500)
+#define SPN_WHITESPACE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000500)
+#define BRK_WHITESPACE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000500)
+#define IS_UNQUOTABLE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x000800)
+#define SPN_UNQUOTABLE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x000800)
+#define BRK_UNQUOTABLE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x000800)
+#define IS_END_XML_TOKEN_CHAR( _c) is_ag_char_map_char((char)( _c), 0x001500)
+#define SPN_END_XML_TOKEN_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x001500)
+#define BRK_END_XML_TOKEN_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x001500)
+#define IS_GRAPHIC_CHAR( _c) is_ag_char_map_char((char)( _c), 0x002000)
+#define SPN_GRAPHIC_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x002000)
+#define BRK_GRAPHIC_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x002000)
+#define IS_PLUS_N_SPACE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x004500)
+#define SPN_PLUS_N_SPACE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x004500)
+#define BRK_PLUS_N_SPACE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x004500)
+#define IS_PUNCTUATION_CHAR( _c) is_ag_char_map_char((char)( _c), 0x008000)
+#define SPN_PUNCTUATION_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x008000)
+#define BRK_PUNCTUATION_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x008000)
+#define IS_SUFFIX_CHAR( _c) is_ag_char_map_char((char)( _c), 0x01000F)
+#define SPN_SUFFIX_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x01000F)
+#define BRK_SUFFIX_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x01000F)
+#define IS_SUFFIX_FMT_CHAR( _c) is_ag_char_map_char((char)( _c), 0x03000F)
+#define SPN_SUFFIX_FMT_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x03000F)
+#define BRK_SUFFIX_FMT_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x03000F)
+#define IS_FALSE_TYPE_CHAR( _c) is_ag_char_map_char((char)( _c), 0x040000)
+#define SPN_FALSE_TYPE_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x040000)
+#define BRK_FALSE_TYPE_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x040000)
+#define IS_FILE_NAME_CHAR( _c) is_ag_char_map_char((char)( _c), 0x09000F)
+#define SPN_FILE_NAME_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x09000F)
+#define BRK_FILE_NAME_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x09000F)
+#define IS_END_TOKEN_CHAR( _c) is_ag_char_map_char((char)( _c), 0x100500)
+#define SPN_END_TOKEN_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x100500)
+#define BRK_END_TOKEN_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x100500)
+#define IS_END_LIST_ENTRY_CHAR( _c) is_ag_char_map_char((char)( _c), 0x300500)
+#define SPN_END_LIST_ENTRY_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x300500)
+#define BRK_END_LIST_ENTRY_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x300500)
+#define IS_SET_SEPARATOR_CHAR( _c) is_ag_char_map_char((char)( _c), 0x700500)
+#define SPN_SET_SEPARATOR_CHARS(_s) spn_ag_char_map_chars((char *)_s, 0x700500)
+#define BRK_SET_SEPARATOR_CHARS(_s) brk_ag_char_map_chars((char *)_s, 0x700500)
-#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,
- /*\f */ 0x000400, /*\r */ 0x000400, /*x0E*/ 0x000000, /*x0F*/ 0x000000,
+static ag_char_map_mask_t const ag_char_map_table[128] = {
+ /*NUL*/ 0x140000, /*x01*/ 0x000000, /*x02*/ 0x000000, /*x03*/ 0x000000,
+ /*x04*/ 0x000000, /*x05*/ 0x000000, /*x06*/ 0x000000, /*BEL*/ 0x000000,
+ /* BS*/ 0x000400, /* HT*/ 0x000100, /* NL*/ 0x000400, /* VT*/ 0x000400,
+ /* FF*/ 0x000400, /* CR*/ 0x000400, /*x0E*/ 0x000000, /*x0F*/ 0x000000,
/*x10*/ 0x000000, /*x11*/ 0x000000, /*x12*/ 0x000000, /*x13*/ 0x000000,
/*x14*/ 0x000000, /*x15*/ 0x000000, /*x16*/ 0x000000, /*x17*/ 0x000000,
- /*x18*/ 0x000000, /*x19*/ 0x000000, /*x1A*/ 0x000000, /*x1B*/ 0x000000,
+ /*x18*/ 0x000000, /*x19*/ 0x000000, /*x1A*/ 0x000000, /*ESC*/ 0x000000,
/*x1C*/ 0x000000, /*x1D*/ 0x000000, /*x1E*/ 0x000000, /*x1F*/ 0x000000,
/* */ 0x000100, /* ! */ 0x00A800, /* " */ 0x00A000, /* # */ 0x00A000,
/* $ */ 0x00A800, /* % */ 0x02A800, /* & */ 0x00A800, /* ' */ 0x00A000,
- /* ( */ 0x00A000, /* ) */ 0x00A000, /* * */ 0x00A000, /* + */ 0x00E800,
+ /* ( */ 0x00A000, /* ) */ 0x00A000, /* * */ 0x00A000, /* + */ 0x40E800,
/* , */ 0x20A000, /* - */ 0x01A840, /* . */ 0x01AA00, /* / */ 0x0AB800,
/* 0 */ 0x042804, /* 1 */ 0x002804, /* 2 */ 0x002804, /* 3 */ 0x002804,
/* 4 */ 0x002804, /* 5 */ 0x002804, /* 6 */ 0x002804, /* 7 */ 0x002804,
@@ -186,7 +216,28 @@ static option_char_category_mask_t const option_char_category[128] = {
/* p */ 0x002801, /* q */ 0x002801, /* r */ 0x002801, /* s */ 0x002801,
/* t */ 0x002801, /* u */ 0x002801, /* v */ 0x002801, /* w */ 0x002801,
/* x */ 0x002801, /* y */ 0x002801, /* z */ 0x002801, /* { */ 0x00A000,
- /* | */ 0x00A800, /* } */ 0x00A000, /* ~ */ 0x00A800, /*x7F*/ 0x000000
+ /* | */ 0x40A800, /* } */ 0x00A000, /* ~ */ 0x00A800, /*x7F*/ 0x000000
};
-#endif /* AUTOOPTS_INTERNAL */
+
+static inline int
+is_ag_char_map_char(char ch, ag_char_map_mask_t mask)
+{
+ unsigned int ix = (unsigned char)ch;
+ return ((ix < 128) && ((ag_char_map_table[ix] & mask) != 0));
+}
+
+static inline char *
+spn_ag_char_map_chars(char * p, ag_char_map_mask_t mask)
+{
+ while ((*p != '\0') && is_ag_char_map_char(*p, mask)) p++;
+ return p;
+}
+
+static inline char *
+brk_ag_char_map_chars(char * p, ag_char_map_mask_t mask)
+{
+ while ((*p != '\0') && (! is_ag_char_map_char(*p, mask))) p++;
+ return p;
+}
+
#endif /* AG_CHAR_MAP_H_GUARD */
diff --git a/src/libopts/alias.c b/src/libopts/alias.c
new file mode 100644
index 0000000000..ad9606b409
--- /dev/null
+++ b/src/libopts/alias.c
@@ -0,0 +1,108 @@
+
+/**
+ * \file alias.c
+ *
+ * Time-stamp: "2012-02-10 19:41:42 bkorb"
+ *
+ * Automated Options Paged Usage module.
+ *
+ * This routine will forward an option alias to the correct option code.
+ *
+ * This file is part of AutoOpts, a companion to AutoGen.
+ * AutoOpts is free software.
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
+ *
+ * AutoOpts is available under any one of two licenses. The license
+ * in use must be one of these two and the choice is under the control
+ * of the user of the license.
+ *
+ * The GNU Lesser General Public License, version 3 or later
+ * See the files "COPYING.lgplv3" and "COPYING.gplv3"
+ *
+ * The Modified Berkeley Software Distribution License
+ * See the file "COPYING.mbsd"
+ *
+ * These files have the following md5sums:
+ *
+ * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
+ * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
+ * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+ */
+
+/*=export_func optionAlias
+ * private:
+ *
+ * what: relay an option to its alias
+ * arg: + tOptions* + pOpts + program options descriptor +
+ * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
+ * arg: + unsigned int + alias + the aliased-to option index +
+ * ret-type: int
+ *
+ * doc:
+ * Handle one option as if it had been specified as another. Exactly.
+ * Returns "-1" if the aliased-to option has appeared too many times.
+=*/
+int
+optionAlias(tOptions * pOpts, tOptDesc * pOldOD, unsigned int alias)
+{
+ tOptDesc * pOD;
+
+ if (pOpts == OPTPROC_EMIT_USAGE)
+ return 0;
+
+ pOD = pOpts->pOptDesc + alias;
+ if ((unsigned)pOpts->optCt <= alias) {
+ fwrite(zAliasRange, strlen (zAliasRange), 1, stderr);
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Copy over the option instance flags
+ */
+ pOD->fOptState &= OPTST_PERSISTENT_MASK;
+ pOD->fOptState |= (pOldOD->fOptState & ~OPTST_PERSISTENT_MASK);
+ pOD->optArg.argString = pOldOD->optArg.argString;
+
+ /*
+ * Keep track of count only for DEFINED (command line) options.
+ * IF we have too many, build up an error message and bail.
+ */
+ if ( (pOD->fOptState & OPTST_DEFINED)
+ && (++pOD->optOccCt > pOD->optMaxCt) ) {
+
+ if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+ char const * pzEqv =
+ (pOD->optEquivIndex != NO_EQUIVALENT) ? zEquiv : zNil;
+
+ fputs(zErrOnly, stderr);
+
+ if (pOD->optMaxCt > 1)
+ fprintf(stderr, zAtMost, pOD->optMaxCt, pOD->pz_Name, pzEqv);
+ else
+ fprintf(stderr, zOnlyOne, pOD->pz_Name, pzEqv);
+ }
+
+ return -1;
+ }
+
+ /*
+ * Clear the state bits and counters
+ */
+ pOldOD->fOptState &= OPTST_PERSISTENT_MASK;
+ pOldOD->optOccCt = 0;
+
+ /*
+ * If there is a procedure to call, call it
+ */
+ if (pOD->pOptProc != NULL)
+ (*pOD->pOptProc)(pOpts, pOD);
+ return 0;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/alias.c */
diff --git a/src/libopts/ao-strs.c b/src/libopts/ao-strs.c
new file mode 100644
index 0000000000..f6e835e20d
--- /dev/null
+++ b/src/libopts/ao-strs.c
@@ -0,0 +1,323 @@
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * DO NOT EDIT THIS FILE (ao-strs.c)
+ *
+ * It has been AutoGen-ed February 10, 2012 at 07:53:35 PM by AutoGen 5.15pre7
+ * From the definitions ao-strs.def
+ * and the template file strings
+ *
+ * Copyright (C) 2011-2012 Bruce Korb, all rights reserved.
+ * This is free software. It is licensed for use, modification and
+ * redistribution under the terms of the
+ * Modified (3 clause) Berkeley Software Distribution License
+ * <http://www.xfree86.org/3.3.6/COPYRIGHT2.html>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ * contributor may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * strings IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "ao-strs.h"
+
+char const ao_strs_strtable[6266] =
+/* 0 */ " \t\n"
+ ":=\0"
+/* 6 */ "INVALID-%d\0"
+/* 17 */ "*INVALID*\0"
+/* 27 */ "none\0"
+/* 32 */ " + \0"
+/* 36 */ " | \0"
+/* 40 */ "%s\n\0"
+/* 44 */ "PAGER\0"
+/* 50 */ "/tmp/use.%lu\0"
+/* 63 */ "more\0"
+/* 68 */ " --* )\n\0"
+/* 79 */ "%s\n"
+ " \0"
+/* 85 */ " \0"
+/* 88 */ " -* )\n\0"
+/* 98 */ " ;;\n\n\0"
+/* 111 */ "stdout\0"
+/* 118 */ "%A %B %e, %Y at %r %Z\0"
+/* 140 */ "#! %s\n\0"
+/* 147 */ "%s_%s=\0"
+/* 154 */ "\n"
+ "export %s_%s\n\0"
+/* 169 */ "''\0"
+/* 172 */ "\\'\0"
+/* 175 */ "'%s'\0"
+/* 180 */ "%s_%s_%d=\0"
+/* 190 */ "\n"
+ "export %s_%s_%d\n\0"
+/* 208 */ "set --\0"
+/* 215 */ " '%s'\0"
+/* 221 */ "'\\''\0"
+/* 226 */ "\n"
+ "OPTION_CT=0\n\0"
+/* 240 */ "=%1$lu # 0x%1$lX\n\0"
+/* 258 */ "true\0"
+/* 263 */ "false\0"
+/* 269 */ "VERSION\0"
+/* 277 */ "OPT_ARG_NEEDED=OK\0"
+/* 295 */ "OPT_ARG_NEEDED=NO\0"
+/* 313 */ "OPT_ARG_NEEDED=YES\0"
+/* 332 */ "LONGUSAGE\0"
+/* 342 */ "flag\0"
+/* 347 */ "%s_%s_TEXT='\0"
+/* 360 */ "'\n\n\0"
+/* 364 */ "option\0"
+/* 371 */ "\n"
+ "env | grep '^%s_'\n\0"
+/* 391 */ " -- %s\0"
+/* 398 */ "--\0"
+/* 401 */ "\t\t\t\t- \0"
+/* 408 */ "\t\t\t\t \0"
+/* 415 */ "\t\0"
+/* 417 */ " * )\n"
+ " OPT_PROCESS=false\n"
+ " ;;\n"
+ " esac\n\0"
+/* 474 */ " %s\n\0"
+/* 480 */ "%%-%ds\0"
+/* 487 */ "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu\0"
+/* 530 */ "# # # # # # # # # # -- do not modify this marker --\n"
+ "#\n"
+ "# DO NOT EDIT THIS SECTION\n\0"
+/* 613 */ "%s OF %s\n"
+ "#\n"
+ "# From here to the next `-- do not modify this marker --',\n"
+ "# the text has been generated %s\n\0"
+/* 719 */ "# From the %s option definitions\n"
+ "#\n\0"
+/* 756 */ "\n"
+ "if test -z \"${%1$s_%2$s}\"\n"
+ "then\n"
+ " %1$s_%2$s_CT=0\n"
+ "else\n"
+ " %1$s_%2$s_CT=1\n"
+ " %1$s_%2$s_1=${%1$s_%2$s}\n"
+ "fi\n"
+ "export %1$s_%2$s_CT\0"
+/* 877 */ "\n"
+ "%1$s_%2$s=${%1$s_%2$s-'%3$s'}\n"
+ "%1$s_%2$s_set=false\n"
+ "export %1$s_%2$s\0"
+/* 945 */ "\n"
+ "%1$s_%2$s=${%1$s_%2$s}\n"
+ "%1$s_%2$s_set=false\n"
+ "export %1$s_%2$s\n\0"
+/* 1007 */ "\n"
+ "OPT_PROCESS=true\n"
+ "OPT_ARG=$1\n"
+ "while ${OPT_PROCESS} && [ $# -gt 0 ]\n"
+ "do\n"
+ " OPT_ELEMENT=''\n"
+ " OPT_ARG_VAL=''\n\n"
+ " case \"${OPT_ARG}\" in\n"
+ " -- )\n"
+ " OPT_PROCESS=false\n"
+ " shift\n"
+ " ;;\n\0"
+/* 1201 */ "\n"
+ "OPT_ARG=$1\n"
+ "while [ $# -gt 0 ]\n"
+ "do\n"
+ " OPT_ELEMENT=''\n"
+ " OPT_ARG_VAL=''\n"
+ " OPT_ARG=${1}\n\0"
+/* 1291 */ " if [ -n \"${OPT_ARG_VAL}\" ]\n"
+ " then\n"
+ " eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
+ " export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
+ " fi\n"
+ "done\n"
+ "unset OPT_PROCESS || :\n"
+ "unset OPT_ELEMENT || :\n"
+ "unset OPT_ARG || :\n"
+ "unset OPT_ARG_NEEDED || :\n"
+ "unset OPT_NAME || :\n"
+ "unset OPT_CODE || :\n"
+ "unset OPT_ARG_VAL || :\n"
+ "%2$s\0"
+/* 1621 */ "\n"
+ "# # # # # # # # # #\n"
+ "#\n"
+ "# END OF AUTOMATED OPTION PROCESSING\n"
+ "#\n"
+ "# # # # # # # # # # -- do not modify this marker --\n\0"
+/* 1737 */ " case \"${OPT_CODE}\" in\n\0"
+/* 1768 */ " '%s' | \\\n\0"
+/* 1786 */ " '%s' )\n\0"
+/* 1802 */ " '%c' )\n\0"
+/* 1818 */ " ;;\n\n\0"
+/* 1835 */ " * )\n"
+ " echo Unknown %s: \"${OPT_CODE}\" >&2\n"
+ " echo \"$%s_USAGE_TEXT\"\n"
+ " exit 1\n"
+ " ;;\n"
+ " esac\n\n\0"
+/* 1977 */ " echo \"$%s_%s_TEXT\"\n"
+ " exit 0\n\0"
+/* 2028 */ " echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
+ " exit 0\n\0"
+/* 2102 */ " %s\n\0"
+/* 2118 */ " if [ $%1$s_%2$s_CT -ge %3$d ] ; then\n"
+ " echo Error: more than %3$d %2$s options >&2\n"
+ " echo \"$%1$s_USAGE_TEXT\"\n"
+ " exit 1 ; fi\n\0"
+/* 2297 */ " %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
+ " OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
+ " OPT_NAME='%2$s'\n\0"
+/* 2421 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+ " echo Error: duplicate %2$s option >&2\n"
+ " echo \"$%1$s_USAGE_TEXT\"\n"
+ " exit 1 ; fi\n"
+ " %1$s_%2$s_set=true\n"
+ " OPT_NAME='%2$s'\n\0"
+/* 2668 */ " %1$s_%2$s_CT=0\n"
+ " OPT_ELEMENT=''\n"
+ " %1$s_%2$s='%3$s'\n"
+ " export %1$s_%2$s\n"
+ " OPT_NAME='%2$s'\n\0"
+/* 2809 */ " if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+ " echo 'Error: duplicate %2$s option' >&2\n"
+ " echo \"$%1$s_USAGE_TEXT\"\n"
+ " exit 1 ; fi\n"
+ " %1$s_%2$s_set=true\n"
+ " %1$s_%2$s='%3$s'\n"
+ " export %1$s_%2$s\n"
+ " OPT_NAME='%2$s'\n\0"
+/* 3116 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+ " export %1$s_%2$s${OPT_ELEMENT}\n"
+ " OPT_ARG_NEEDED=OK\n\0"
+/* 3236 */ " OPT_ARG_NEEDED=YES\n\0"
+/* 3268 */ " eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+ " export %1$s_%2$s${OPT_ELEMENT}\n"
+ " OPT_ARG_NEEDED=NO\n\0"
+/* 3388 */ " OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
+ " shift\n"
+ " OPT_ARG=$1\n"
+ " case \"${OPT_CODE}\" in *=* )\n"
+ " OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
+ " OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\0"
+/* 3639 */ " case \"${OPT_ARG_NEEDED}\" in\n"
+ " NO )\n"
+ " OPT_ARG_VAL=''\n"
+ " ;;\n"
+ " YES )\n"
+ " if [ -z \"${OPT_ARG_VAL}\" ]\n"
+ " then\n"
+ " if [ $# -eq 0 ]\n"
+ " then\n"
+ " echo No argument provided for ${OPT_NAME} option >&2\n"
+ " echo \"$%s_USAGE_TEXT\"\n"
+ " exit 1\n"
+ " fi\n"
+ " OPT_ARG_VAL=${OPT_ARG}\n"
+ " shift\n"
+ " OPT_ARG=$1\n"
+ " fi\n"
+ " ;;\n"
+ " OK )\n"
+ " if [ -z \"${OPT_ARG_VAL}\" ] && [ $# -gt 0 ]\n"
+ " then\n"
+ " case \"${OPT_ARG}\" in -* ) ;; * )\n"
+ " OPT_ARG_VAL=${OPT_ARG}\n"
+ " shift\n"
+ " OPT_ARG=$1 ;; esac\n"
+ " fi\n"
+ " ;;\n"
+ " esac\n\0"
+/* 4418 */ " OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
+ " OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0"
+/* 4535 */ " case \"${OPT_ARG_NEEDED}\" in\n"
+ " NO )\n"
+ " if [ -n \"${OPT_ARG}\" ]\n"
+ " then\n"
+ " OPT_ARG=-${OPT_ARG}\n"
+ " else\n"
+ " shift\n"
+ " OPT_ARG=$1\n"
+ " fi\n"
+ " ;;\n"
+ " YES )\n"
+ " if [ -n \"${OPT_ARG}\" ]\n"
+ " then\n"
+ " OPT_ARG_VAL=${OPT_ARG}\n"
+ " else\n"
+ " if [ $# -eq 0 ]\n"
+ " then\n"
+ " echo No argument provided for ${OPT_NAME} option >&2\n"
+ " echo \"$%s_USAGE_TEXT\"\n"
+ " exit 1\n"
+ " fi\n"
+ " shift\n"
+ " OPT_ARG_VAL=$1\n"
+ " fi\n"
+ " shift\n"
+ " OPT_ARG=$1\n"
+ " ;;\n"
+ " OK )\n"
+ " if [ -n \"${OPT_ARG}\" ]\n"
+ " then\n"
+ " OPT_ARG_VAL=${OPT_ARG}\n"
+ " shift\n"
+ " OPT_ARG=$1\n"
+ " else\n"
+ " shift\n"
+ " if [ $# -gt 0 ]\n"
+ " then\n"
+ " case \"$1\" in -* ) ;; * )\n"
+ " OPT_ARG_VAL=$1\n"
+ " shift ;; esac\n"
+ " OPT_ARG=$1\n"
+ " fi\n"
+ " fi\n"
+ " ;;\n"
+ " esac\n\0"
+/* 5689 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
+ "export %1$s_%2$s\n\0"
+/* 5731 */ "%1$s_%2$s_CT=%3$d\n"
+ "export %1$s_%2$s_CT\n\0"
+/* 5770 */ "OPTION_CT=%d\n"
+ "export OPTION_CT\n\0"
+/* 5801 */ "%1$s_%2$s=%3$s\n"
+ "export %1$s_%2$s\n\0"
+/* 5834 */ "%1$s_%2$s='%3$s'\n"
+ "export %1$s_%2$s\n\0"
+/* 5869 */ "%1$s_%2$s_MODE='%3$s'\n"
+ "export %1$s_%2$s_MODE\n\0"
+/* 5914 */ "echo 'Warning: Cannot load options files' >&2\0"
+/* 5961 */ "echo 'Warning: Cannot save options files' >&2\0"
+/* 6008 */ "echo 'Warning: Cannot suppress the loading of options files' >&2\0"
+/* 6074 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
+/* 6105 */ "%s WARNING: cannot save options - \0"
+/* 6141 */ "<%s/>\n\0"
+/* 6148 */ "<%s>\0"
+/* 6153 */ "</%s>\n\0"
+/* 6160 */ "<%s type=%s>\0"
+/* 6173 */ "<%s type=nested>\n\0"
+/* 6191 */ "#x%02X;\0"
+/* 6199 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
+/* 6231 */ "<%1$s type=integer>0x%2$lX</%1$s>\n";
+
+/* end of ao-strs.c */
diff --git a/src/libopts/ao-strs.h b/src/libopts/ao-strs.h
new file mode 100644
index 0000000000..96f37504ca
--- /dev/null
+++ b/src/libopts/ao-strs.h
@@ -0,0 +1,251 @@
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * DO NOT EDIT THIS FILE (ao-strs.h)
+ *
+ * It has been AutoGen-ed February 10, 2012 at 07:53:35 PM by AutoGen 5.15pre7
+ * From the definitions ao-strs.def
+ * and the template file strings
+ *
+ * Copyright (C) 2011-2012 Bruce Korb, all rights reserved.
+ * This is free software. It is licensed for use, modification and
+ * redistribution under the terms of the
+ * Modified (3 clause) Berkeley Software Distribution License
+ * <http://www.xfree86.org/3.3.6/COPYRIGHT2.html>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ * contributor may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * strings IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef STRINGS_AO_STRS_H_GUARD
+#define STRINGS_AO_STRS_H_GUARD 1
+/*
+ * 102 strings in ao_strs_strtable string table
+ */
+#define ARG_BREAK_STR (ao_strs_strtable+0)
+#define ARG_BREAK_STR_LEN 5
+#define INVALID_FMT (ao_strs_strtable+6)
+#define INVALID_FMT_LEN 10
+#define INVALID_STR (ao_strs_strtable+17)
+#define INVALID_STR_LEN 9
+#define NONE_STR (ao_strs_strtable+27)
+#define NONE_STR_LEN 4
+#define PLUS_STR (ao_strs_strtable+32)
+#define PLUS_STR_LEN 3
+#define OR_STR (ao_strs_strtable+36)
+#define OR_STR_LEN 3
+#define NLSTR_FMT (ao_strs_strtable+40)
+#define NLSTR_FMT_LEN 3
+#define PAGER_NAME (ao_strs_strtable+44)
+#define PAGER_NAME_LEN 5
+#define TMP_USAGE_FMT (ao_strs_strtable+50)
+#define TMP_USAGE_FMT_LEN 12
+#define MORE_STR (ao_strs_strtable+63)
+#define MORE_STR_LEN 4
+#define LONG_OPT_MARK (ao_strs_strtable+68)
+#define LONG_OPT_MARK_LEN 10
+#define NLSTR_SPACE_FMT (ao_strs_strtable+79)
+#define NLSTR_SPACE_FMT_LEN 5
+#define TWO_SPACES_STR (ao_strs_strtable+85)
+#define TWO_SPACES_STR_LEN 2
+#define FLAG_OPT_MARK (ao_strs_strtable+88)
+#define FLAG_OPT_MARK_LEN 9
+#define END_OPT_SEL_STR (ao_strs_strtable+98)
+#define END_OPT_SEL_STR_LEN 12
+#define STDOUT (ao_strs_strtable+111)
+#define STDOUT_LEN 6
+#define TIME_FMT (ao_strs_strtable+118)
+#define TIME_FMT_LEN 21
+#define SHELL_MAGIC (ao_strs_strtable+140)
+#define SHELL_MAGIC_LEN 6
+#define OPT_VAL_FMT (ao_strs_strtable+147)
+#define OPT_VAL_FMT_LEN 6
+#define OPT_END_FMT (ao_strs_strtable+154)
+#define OPT_END_FMT_LEN 14
+#define EMPTY_ARG (ao_strs_strtable+169)
+#define EMPTY_ARG_LEN 2
+#define QUOT_APOS (ao_strs_strtable+172)
+#define QUOT_APOS_LEN 2
+#define QUOT_ARG_FMT (ao_strs_strtable+175)
+#define QUOT_ARG_FMT_LEN 4
+#define ARG_BY_NUM_FMT (ao_strs_strtable+180)
+#define ARG_BY_NUM_FMT_LEN 9
+#define EXPORT_ARG_FMT (ao_strs_strtable+190)
+#define EXPORT_ARG_FMT_LEN 17
+#define set_dash (ao_strs_strtable+208)
+#define set_dash_LEN 6
+#define arg_fmt (ao_strs_strtable+215)
+#define arg_fmt_LEN 5
+#define apostrophy (ao_strs_strtable+221)
+#define apostrophy_LEN 4
+#define init_optct (ao_strs_strtable+226)
+#define init_optct_LEN 13
+#define SHOW_VAL_FMT (ao_strs_strtable+240)
+#define SHOW_VAL_FMT_LEN 17
+#define TRUE_STR (ao_strs_strtable+258)
+#define TRUE_STR_LEN 4
+#define FALSE_STR (ao_strs_strtable+263)
+#define FALSE_STR_LEN 5
+#define VER_STR (ao_strs_strtable+269)
+#define VER_STR_LEN 7
+#define OK_NEED_OPT_ARG (ao_strs_strtable+277)
+#define OK_NEED_OPT_ARG_LEN 17
+#define NO_ARG_NEEDED (ao_strs_strtable+295)
+#define NO_ARG_NEEDED_LEN 17
+#define YES_NEED_OPT_ARG (ao_strs_strtable+313)
+#define YES_NEED_OPT_ARG_LEN 18
+#define LONG_USE_STR (ao_strs_strtable+332)
+#define LONG_USE_STR_LEN 9
+#define FLAG_STR (ao_strs_strtable+342)
+#define FLAG_STR_LEN 4
+#define SET_TEXT_FMT (ao_strs_strtable+347)
+#define SET_TEXT_FMT_LEN 12
+#define END_SET_TEXT (ao_strs_strtable+360)
+#define END_SET_TEXT_LEN 3
+#define OPTION_STR (ao_strs_strtable+364)
+#define OPTION_STR_LEN 6
+#define SHOW_PROG_ENV (ao_strs_strtable+371)
+#define SHOW_PROG_ENV_LEN 19
+#define SET_OFF_FMT (ao_strs_strtable+391)
+#define SET_OFF_FMT_LEN 6
+#define LONG_OPT_MARKER (ao_strs_strtable+398)
+#define LONG_OPT_MARKER_LEN 2
+#define BULLET_STR (ao_strs_strtable+401)
+#define BULLET_STR_LEN 6
+#define DEEP_INDENT_STR (ao_strs_strtable+408)
+#define DEEP_INDENT_STR_LEN 6
+#define ONE_TAB_STR (ao_strs_strtable+415)
+#define ONE_TAB_STR_LEN 1
+#define NOT_FOUND_STR (ao_strs_strtable+417)
+#define NOT_FOUND_STR_LEN 56
+#define ENUM_ERR_SEP_LINE_FMT (ao_strs_strtable+474)
+#define ENUM_ERR_SEP_LINE_FMT_LEN 5
+#define ENUM_ERR_STR_WIDTH_FMT (ao_strs_strtable+480)
+#define ENUM_ERR_STR_WIDTH_FMT_LEN 6
+#define PAGE_USAGE_FMT (ao_strs_strtable+487)
+#define PAGE_USAGE_FMT_LEN 42
+#define START_MARK (ao_strs_strtable+530)
+#define START_MARK_LEN 82
+#define PREAMBLE_FMT (ao_strs_strtable+613)
+#define PREAMBLE_FMT_LEN 105
+#define END_PRE_FMT (ao_strs_strtable+719)
+#define END_PRE_FMT_LEN 36
+#define MULTI_DEF_FMT (ao_strs_strtable+756)
+#define MULTI_DEF_FMT_LEN 120
+#define SGL_DEF_FMT (ao_strs_strtable+877)
+#define SGL_DEF_FMT_LEN 67
+#define SGL_NO_DEF_FMT (ao_strs_strtable+945)
+#define SGL_NO_DEF_FMT_LEN 61
+#define LOOP_STR (ao_strs_strtable+1007)
+#define LOOP_STR_LEN 193
+#define ONLY_OPTS_LOOP (ao_strs_strtable+1201)
+#define ONLY_OPTS_LOOP_LEN 89
+#define zLoopEnd (ao_strs_strtable+1291)
+#define zLoopEnd_LEN 329
+#define END_MARK (ao_strs_strtable+1621)
+#define END_MARK_LEN 115
+#define zOptionCase (ao_strs_strtable+1737)
+#define zOptionCase_LEN 30
+#define zOptionPartName (ao_strs_strtable+1768)
+#define zOptionPartName_LEN 17
+#define zOptionFullName (ao_strs_strtable+1786)
+#define zOptionFullName_LEN 15
+#define zOptionFlag (ao_strs_strtable+1802)
+#define zOptionFlag_LEN 15
+#define zOptionEndSelect (ao_strs_strtable+1818)
+#define zOptionEndSelect_LEN 16
+#define UNK_OPT_FMT (ao_strs_strtable+1835)
+#define UNK_OPT_FMT_LEN 141
+#define zTextExit (ao_strs_strtable+1977)
+#define zTextExit_LEN 50
+#define zPagedUsageExit (ao_strs_strtable+2028)
+#define zPagedUsageExit_LEN 73
+#define zCmdFmt (ao_strs_strtable+2102)
+#define zCmdFmt_LEN 15
+#define zCountTest (ao_strs_strtable+2118)
+#define zCountTest_LEN 178
+#define MULTI_ARG_FMT (ao_strs_strtable+2297)
+#define MULTI_ARG_FMT_LEN 123
+#define SGL_ARG_FMT (ao_strs_strtable+2421)
+#define SGL_ARG_FMT_LEN 246
+#define NO_MULTI_ARG_FMT (ao_strs_strtable+2668)
+#define NO_MULTI_ARG_FMT_LEN 140
+#define NO_SGL_ARG_FMT (ao_strs_strtable+2809)
+#define NO_SGL_ARG_FMT_LEN 306
+#define zMayArg (ao_strs_strtable+3116)
+#define zMayArg_LEN 119
+#define zMustArg (ao_strs_strtable+3236)
+#define zMustArg_LEN 31
+#define zCantArg (ao_strs_strtable+3268)
+#define zCantArg_LEN 119
+#define INIT_LOPT_STR (ao_strs_strtable+3388)
+#define INIT_LOPT_STR_LEN 250
+#define LOPT_ARG_FMT (ao_strs_strtable+3639)
+#define LOPT_ARG_FMT_LEN 778
+#define INIT_OPT_STR (ao_strs_strtable+4418)
+#define INIT_OPT_STR_LEN 116
+#define OPT_ARG_FMT (ao_strs_strtable+4535)
+#define OPT_ARG_FMT_LEN 1153
+#define zOptNumFmt (ao_strs_strtable+5689)
+#define zOptNumFmt_LEN 41
+#define zOptCookieCt (ao_strs_strtable+5731)
+#define zOptCookieCt_LEN 38
+#define zOptCtFmt (ao_strs_strtable+5770)
+#define zOptCtFmt_LEN 30
+#define zOptDisabl (ao_strs_strtable+5801)
+#define zOptDisabl_LEN 32
+#define zFullOptFmt (ao_strs_strtable+5834)
+#define zFullOptFmt_LEN 34
+#define zEquivMode (ao_strs_strtable+5869)
+#define zEquivMode_LEN 44
+#define NO_LOAD_WARN (ao_strs_strtable+5914)
+#define NO_LOAD_WARN_LEN 46
+#define NO_SAVE_OPTS (ao_strs_strtable+5961)
+#define NO_SAVE_OPTS_LEN 46
+#define NO_SUPPRESS_LOAD (ao_strs_strtable+6008)
+#define NO_SUPPRESS_LOAD_LEN 65
+#define SET_NO_TEXT_FMT (ao_strs_strtable+6074)
+#define SET_NO_TEXT_FMT_LEN 30
+#define SAVE_WARN (ao_strs_strtable+6105)
+#define SAVE_WARN_LEN 35
+#define OPEN_CLOSE_FMT (ao_strs_strtable+6141)
+#define OPEN_CLOSE_FMT_LEN 6
+#define OPEN_XML_FMT (ao_strs_strtable+6148)
+#define OPEN_XML_FMT_LEN 4
+#define END_XML_FMT (ao_strs_strtable+6153)
+#define END_XML_FMT_LEN 6
+#define TYPE_ATR_FMT (ao_strs_strtable+6160)
+#define TYPE_ATR_FMT_LEN 12
+#define NULL_ATR_FMT (ao_strs_strtable+6141)
+#define NULL_ATR_FMT_LEN 6
+#define NESTED_OPT_FMT (ao_strs_strtable+6173)
+#define NESTED_OPT_FMT_LEN 17
+#define XML_HEX_BYTE_FMT (ao_strs_strtable+6191)
+#define XML_HEX_BYTE_FMT_LEN 7
+#define BOOL_ATR_FMT (ao_strs_strtable+6199)
+#define BOOL_ATR_FMT_LEN 31
+#define NUMB_ATR_FMT (ao_strs_strtable+6231)
+#define NUMB_ATR_FMT_LEN 34
+
+extern char const ao_strs_strtable[6266];
+
+#endif /* STRINGS_AO_STRS_H_GUARD */
diff --git a/src/libopts/autoopts.c b/src/libopts/autoopts.c
index c1129f2a01..df9e3cb927 100644
--- a/src/libopts/autoopts.c
+++ b/src/libopts/autoopts.c
@@ -2,7 +2,7 @@
/**
* \file autoopts.c
*
- * Time-stamp: "2011-08-07 14:31:49 bkorb"
+ * Time-stamp: "2012-01-29 09:58:30 bkorb"
*
* This file contains all of the routines that must be linked into
* an executable to use the generated option processing. The optional
@@ -11,7 +11,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -36,7 +36,7 @@
static char const zNil[] = "";
static arg_types_t argTypes = { NULL };
-static char zOptFmtLine[32] = { NUL };
+static char line_fmt_buf[32];
static ag_bool displayEnum = AG_FALSE;
static char const pkgdatadir_default[] = PKGDATADIR;
static char const * program_pkgdatadir = pkgdatadir_default;
@@ -452,9 +452,9 @@ immediate_opts(tOptions * pOpts)
* are marked for immediate processing.
*/
for (;;) {
- tOptState optState = OPTSTATE_INITIALIZER(PRESET);
+ tOptState opt_st = OPTSTATE_INITIALIZER(PRESET);
- res = next_opt(pOpts, &optState);
+ res = next_opt(pOpts, &opt_st);
switch (res) {
case FAILURE: goto failed_option;
case PROBLEM: res = SUCCESS; goto leave;
@@ -464,10 +464,10 @@ immediate_opts(tOptions * pOpts)
/*
* IF this is an immediate-attribute option, then do it.
*/
- if (! DO_IMMEDIATELY(optState.flags))
+ if (! DO_IMMEDIATELY(opt_st.flags))
continue;
- if (! SUCCESSFUL(handle_opt(pOpts, &optState)))
+ if (! SUCCESSFUL(handle_opt(pOpts, &opt_st)))
break;
} failed_option:;
@@ -494,9 +494,9 @@ regular_opts(tOptions * pOpts)
{
/* assert: pOpts->fOptSet & OPTPROC_IMMEDIATE == 0 */
for (;;) {
- tOptState optState = OPTSTATE_INITIALIZER(DEFINED);
+ tOptState opt_st = OPTSTATE_INITIALIZER(DEFINED);
- switch (next_opt(pOpts, &optState)) {
+ switch (next_opt(pOpts, &opt_st)) {
case FAILURE: goto failed_option;
case PROBLEM: return SUCCESS; /* no more args */
case SUCCESS: break;
@@ -506,13 +506,13 @@ regular_opts(tOptions * pOpts)
* IF this is an immediate action option,
* THEN skip it (unless we are supposed to do it a second time).
*/
- if (! DO_NORMALLY(optState.flags)) {
- if (! DO_SECOND_TIME(optState.flags))
+ if (! DO_NORMALLY(opt_st.flags)) {
+ if (! DO_SECOND_TIME(opt_st.flags))
continue;
- optState.pOD->optOccCt--; /* don't count this repetition */
+ opt_st.pOD->optOccCt--; /* don't count this repetition */
}
- if (! SUCCESSFUL(handle_opt(pOpts, &optState)))
+ if (! SUCCESSFUL(handle_opt(pOpts, &opt_st)))
break;
} failed_option:;
@@ -640,7 +640,7 @@ optionProcess(tOptions * pOpts, int argCt, char ** argVect)
* and do all the presetting the first time thru only.
*/
if ((pOpts->fOptSet & OPTPROC_INITDONE) == 0) {
- pOpts->origArgCt = argCt;
+ pOpts->origArgCt = (unsigned int)argCt;
pOpts->origArgVect = argVect;
pOpts->fOptSet |= OPTPROC_INITDONE;
if (HAS_pzPkgDataDir(pOpts))
diff --git a/src/libopts/autoopts.h b/src/libopts/autoopts.h
index 831a52b188..14cbbf1650 100644
--- a/src/libopts/autoopts.h
+++ b/src/libopts/autoopts.h
@@ -2,14 +2,14 @@
/*
* \file autoopts.h
*
- * Time-stamp: "2011-03-25 17:51:34 bkorb"
+ * Time-stamp: "2012-02-10 19:04:40 bkorb"
*
* This file defines all the global structures and special values
* used in the automated option processing library.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -69,6 +69,8 @@
# define EX_CONFIG 78
#endif
+#define NL '\n'
+
/*
* Convert the number to a list usable in a printf call
*/
@@ -77,7 +79,7 @@
#define NAMED_OPTS(po) \
(((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0)
-#define SKIP_OPT(p) (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0)
+#define SKIP_OPT(p) (((p)->fOptState & OPTST_IMMUTABLE_MASK) != 0)
typedef int tDirection;
#define DIRECTION_PRESET -1
diff --git a/src/libopts/autoopts/options.h b/src/libopts/autoopts/options.h
index 1e59faa61b..d4256118f4 100644
--- a/src/libopts/autoopts/options.h
+++ b/src/libopts/autoopts/options.h
@@ -2,14 +2,14 @@
*
* DO NOT EDIT THIS FILE (options.h)
*
- * It has been AutoGen-ed December 29, 2011 at 12:02:36 PM by AutoGen 5.14
+ * It has been AutoGen-ed February 10, 2012 at 07:53:40 PM by AutoGen 5.15pre7
* From the definitions funcs.def
* and the template file options_h
*
* This file defines all the global structures and special values
* used in the automated option processing library.
*
- * Automated Options Copyright (C) 1992-2011 by Bruce Korb
+ * Automated Options Copyright (C) 1992-2012 by Bruce Korb
*
* * AutoOpts is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
@@ -65,8 +65,8 @@
* See the relevant generated header file to determine which and what
* values for "opt_name" are available.
*/
-#define OPTIONS_STRUCT_VERSION 147457
-#define OPTIONS_VERSION_STRING "36:1:11"
+#define OPTIONS_STRUCT_VERSION 147458
+#define OPTIONS_VERSION_STRING "36:2:11"
#define OPTIONS_MINIMUM_VERSION 102400
#define OPTIONS_MIN_VER_STRING "25:0:0"
#define OPTIONS_VER_TO_NUM(_v, _r) (((_v) * 4096) + (_r))
@@ -154,7 +154,8 @@ typedef enum {
OPTST_DISABLE_TWICE_ID = 23, /* process disabled option twice */
OPTST_SCALED_NUM_ID = 24, /* scaled integer value */
OPTST_NO_COMMAND_ID = 25, /* disable from cmd line */
- OPTST_DEPRECATED_ID = 26 /* support is being removed */
+ OPTST_DEPRECATED_ID = 26, /* support is being removed */
+ OPTST_ALIAS_ID = 27 /* alias for other option */
} opt_state_enum_t;
#define OPTST_INIT 0U
@@ -184,7 +185,8 @@ typedef enum {
#define OPTST_SCALED_NUM (1U << OPTST_SCALED_NUM_ID)
#define OPTST_NO_COMMAND (1U << OPTST_NO_COMMAND_ID)
#define OPTST_DEPRECATED (1U << OPTST_DEPRECATED_ID)
-#define OPT_STATE_MASK 0x07FFFF7FU
+#define OPTST_ALIAS (1U << OPTST_ALIAS_ID)
+#define OPT_STATE_MASK 0x0FFFFF7FU
#define OPTST_SET_MASK ( \
OPTST_DEFINED | OPTST_PRESET | OPTST_RESET | \
@@ -207,13 +209,21 @@ typedef enum {
OPTST_ARG_TYPE_4 \
/* 0x0000F000U */ )
+#define OPTST_NO_USAGE_MASK ( \
+ OPTST_DEPRECATED | OPTST_NO_COMMAND | OPTST_OMITTED \
+ /* 0x06080000U */ )
+
+#define OPTST_IMMUTABLE_MASK ( \
+ OPTST_DOCUMENT | OPTST_OMITTED \
+ /* 0x00280000U */ )
+
#define OPTST_DO_NOT_SAVE_MASK ( \
OPTST_DOCUMENT | OPTST_NO_INIT | OPTST_OMITTED \
/* 0x00280100U */ )
-#define OPTST_NO_USAGE_MASK ( \
- OPTST_DEPRECATED | OPTST_NO_COMMAND | OPTST_OMITTED \
- /* 0x06080000U */ )
+#define OPTST_NO_OUTPUT_MASK ( \
+ OPTST_ALIAS | OPTST_DOCUMENT | OPTST_OMITTED \
+ /* 0x08280000U */ )
#ifdef NO_OPTIONAL_OPT_ARGS
# undef OPTST_ARG_OPTIONAL
@@ -339,7 +349,7 @@ typedef tOptProc* tpOptProc;
*/
// coverity[+kill]
typedef void (tUsageProc)(tOptions* pOpts, int exitCode);
-typedef tUsageProc* tpUsageProc;
+typedef tUsageProc * tpUsageProc;
/*
* Special definitions. "NOLIMIT" is the 'max' value to use when
@@ -419,7 +429,7 @@ typedef void (tOptionXlateProc)(void);
*/
struct options {
int const structVersion;
- int origArgCt;
+ unsigned int origArgCt;
char** origArgVect;
unsigned int fOptSet;
unsigned int curOptIdx;
@@ -588,7 +598,7 @@ extern token_list_t* ao_string_tokenize(char const*);
extern const tOptionValue* configFileLoad(char const*);
-/* From: configfile.c line 1057
+/* From: configfile.c line 1059
*
* optionFileLoad - Load the locatable config files, in order
*
@@ -618,7 +628,7 @@ extern const tOptionValue* configFileLoad(char const*);
extern int optionFileLoad(tOptions*, char const*);
-/* From: configfile.c line 209
+/* From: configfile.c line 211
*
* optionFindNextValue - find a hierarcicaly valued option instance
*
@@ -637,7 +647,7 @@ extern int optionFileLoad(tOptions*, char const*);
extern const tOptionValue* optionFindNextValue(const tOptDesc*, const tOptionValue*, char const*, char const*);
-/* From: configfile.c line 135
+/* From: configfile.c line 137
*
* optionFindValue - find a hierarcicaly valued option instance
*
@@ -667,7 +677,7 @@ extern const tOptionValue* optionFindValue(const tOptDesc*, char const*, char co
extern void optionFree(tOptions*);
-/* From: configfile.c line 278
+/* From: configfile.c line 280
*
* optionGetValue - get a specific value from a hierarcical list
*
@@ -687,7 +697,7 @@ extern void optionFree(tOptions*);
extern const tOptionValue* optionGetValue(const tOptionValue*, char const*);
-/* From: load.c line 477
+/* From: load.c line 476
*
* optionLoadLine - process a string for an option name and value
*
@@ -711,7 +721,7 @@ extern const tOptionValue* optionGetValue(const tOptionValue*, char const*);
extern void optionLoadLine(tOptions*, char const*);
-/* From: configfile.c line 338
+/* From: configfile.c line 340
*
* optionNextValue - get the next value from a hierarchical list
*
@@ -792,7 +802,7 @@ extern int optionProcess(tOptions*, int, char**);
extern void optionRestore(tOptions*);
-/* From: save.c line 664
+/* From: save.c line 648
*
* optionSaveFile - saves the option state to a file
*
@@ -839,7 +849,7 @@ extern void optionSaveFile(tOptions*);
extern void optionSaveState(tOptions*);
-/* From: nested.c line 551
+/* From: nested.c line 562
*
* optionUnloadNested - Deallocate the memory for a nested value
*
@@ -1018,6 +1028,8 @@ extern unsigned int ao_string_cook_escape_char(char const*, char*, unsigned int)
extern void genshelloptUsage(tOptions*, int);
+extern int optionAlias(tOptions*, tOptDesc*, unsigned int);
+
extern void optionBooleanVal(tOptions*, tOptDesc*);
extern uintptr_t optionEnumerationVal(tOptions*, tOptDesc*, char const * const *, unsigned int);
diff --git a/src/libopts/autoopts/usage-txt.h b/src/libopts/autoopts/usage-txt.h
index 20492a4666..0e29fc1810 100644
--- a/src/libopts/autoopts/usage-txt.h
+++ b/src/libopts/autoopts/usage-txt.h
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (usage-txt.h)
*
- * It has been AutoGen-ed December 29, 2011 at 12:02:34 PM by AutoGen 5.14
+ * It has been AutoGen-ed February 10, 2012 at 07:53:38 PM by AutoGen 5.15pre7
* From the definitions usage-txt.def
* and the template file usage-txt.tpl
*
@@ -13,7 +13,7 @@
* they may substitute translated strings using a procedure that steps through
* all the string pointers.
*
- * Copyright (C) 1992-2011 Bruce Korb, all rights reserved.
+ * Copyright (C) 1992-2012 Bruce Korb, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the
* GNU Lesser General Public License, version 3 or later
@@ -232,7 +232,7 @@ static char const usage_txt[4619] =
/* 260 */ "\tThis is less than the minimum library version: \0"
/* 310 */ "strdup of %d byte string failed\n\0"
/* 343 */ "Automated Options version %s\n"
- "\tcopyright (c) 1999-2011 by Bruce Korb - all rights reserved\n\0"
+ "\tcopyright (c) 1999-2012 by Bruce Korb - all rights reserved\n\0"
/* 434 */ "AutoOpts lib error: defaulted to option with optional arg\n\0"
/* 493 */ "(AutoOpts bug): Aliasing option is out of range.\0"
/* 543 */ "all\0"
diff --git a/src/libopts/boolean.c b/src/libopts/boolean.c
index 8079231105..37d18e12b3 100644
--- a/src/libopts/boolean.c
+++ b/src/libopts/boolean.c
@@ -11,7 +11,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/check.c b/src/libopts/check.c
index b4355b4557..003fe1363e 100644
--- a/src/libopts/check.c
+++ b/src/libopts/check.c
@@ -10,7 +10,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/compat/compat.h b/src/libopts/compat/compat.h
index b288a7c2a3..24abed2aee 100644
--- a/src/libopts/compat/compat.h
+++ b/src/libopts/compat/compat.h
@@ -3,12 +3,12 @@
/**
* \file compat.h --- fake the preprocessor into handlng portability
*
- * Time-stamp: "2010-07-16 15:11:57 bkorb"
+ * Time-stamp: "2012-02-10 17:00:09 bkorb"
*
* compat.h is free software.
* This file is part of AutoGen.
*
- * AutoGen Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoGen is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -83,7 +83,7 @@
#endif
#include <sys/stat.h>
#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
+# include <sys/wait.h>
#endif
#if defined( HAVE_SOLARIS_SYSINFO )
diff --git a/src/libopts/compat/windows-config.h b/src/libopts/compat/windows-config.h
index 360af1098c..076c046602 100644
--- a/src/libopts/compat/windows-config.h
+++ b/src/libopts/compat/windows-config.h
@@ -4,7 +4,7 @@
*
* This file is part of AutoGen.
*
- * AutoGen Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoGen is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
diff --git a/src/libopts/configfile.c b/src/libopts/configfile.c
index 758ce272da..40d31c6bbf 100644
--- a/src/libopts/configfile.c
+++ b/src/libopts/configfile.c
@@ -1,13 +1,13 @@
/**
* \file configfile.c
*
- * Time-stamp: "2011-12-17 12:51:30 bkorb"
+ * Time-stamp: "2012-01-29 15:57:40 bkorb"
*
* configuration/rc/ini file handling.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -97,7 +97,9 @@ skip_unkn(char* pzText);
* @code{mmap(2)} or other file system calls, or it may be:
* @itemize @bullet
* @item
- * @code{ENOENT} - the file was empty.
+ * @code{ENOENT} - the file was not found.
+ * @item
+ * @code{ENOMSG} - the file was empty.
* @item
* @code{EINVAL} - the file contents are invalid -- not properly formed.
* @item
@@ -463,7 +465,7 @@ file_preset(tOptions * opts, char const * fname, int dir)
break;
case '#':
- ftext = strchr(ftext + 1, '\n');
+ ftext = strchr(ftext + 1, NL);
break;
default:
@@ -501,7 +503,7 @@ static char *
handle_cfg(tOptions * pOpts, tOptState * pOS, char * pzText, int dir)
{
char* pzName = pzText++;
- char* pzEnd = strchr(pzText, '\n');
+ char* pzEnd = strchr(pzText, NL);
if (pzEnd == NULL)
return pzText + strlen(pzText);
@@ -541,13 +543,13 @@ handle_cfg(tOptions * pOpts, tOptState * pOS, char * pzText, int dir)
case NUL:
pcS = NULL;
- case '\n':
+ case NL:
*pcD = NUL;
pzEnd = pcS;
goto copy_done;
case '\\':
- if (*pcS == '\n') {
+ if (*pcS == NL) {
ch = *(pcS++);
}
/* FALLTHROUGH */
@@ -700,7 +702,7 @@ handle_section(tOptions * pOpts, char * pzText)
size_t len = strlen(pOpts->pzPROGNAME);
if ( (strncmp(pzText+1, pOpts->pzPROGNAME, len) == 0)
&& (pzText[len+1] == ']'))
- return strchr(pzText + len + 2, '\n');
+ return strchr(pzText + len + 2, NL);
if (len > 16)
return NULL;
@@ -712,7 +714,7 @@ handle_section(tOptions * pOpts, char * pzText)
}
if (pzText != NULL)
- pzText = strchr(pzText, '\n');
+ pzText = strchr(pzText, NL);
return pzText;
}
@@ -731,7 +733,7 @@ parse_xml_encoding(char ** ppz)
_xmlNm_(cr, '\r') \
_xmlNm_(vt, '\v') \
_xmlNm_(bel, '\a') \
- _xmlNm_(nl, '\n') \
+ _xmlNm_(nl, NL) \
_xmlNm_(space, ' ') \
_xmlNm_(quot, '"') \
_xmlNm_(apos, '\'')
@@ -849,8 +851,8 @@ cook_xml_text(char * pzData)
return;
case '&':
- *(pzd++) = \
- ch = parse_xml_encoding(&pzs);
+ ch = parse_xml_encoding(&pzs);
+ *(pzd++) = (char)ch;
if (ch == NUL)
return;
break;
@@ -867,7 +869,7 @@ cook_xml_text(char * pzData)
/* FALLTHROUGH */
default:
- *(pzd++) = ch;
+ *(pzd++) = (char)ch;
}
}
}
diff --git a/src/libopts/cook.c b/src/libopts/cook.c
index 49c12a3294..a81ce91b09 100644
--- a/src/libopts/cook.c
+++ b/src/libopts/cook.c
@@ -1,14 +1,14 @@
/**
* \file cook.c
*
- * Time-stamp: "2011-03-12 15:05:26 bkorb"
+ * Time-stamp: "2012-02-10 17:00:47 bkorb"
*
* This file contains the routines that deal with processing quoted strings
* into an internal format.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -59,7 +59,7 @@ contiguous_quote(char ** pps, char * pq, int * lnct_p);
* err: @code{NULL} is returned if the string is mal-formed.
=*/
unsigned int
-ao_string_cook_escape_char( char const* pzIn, char* pRes, unsigned nl )
+ao_string_cook_escape_char( char const* pzIn, char* pRes, uint_t nl )
{
unsigned int res = 1;
@@ -67,18 +67,18 @@ ao_string_cook_escape_char( char const* pzIn, char* pRes, unsigned nl )
case NUL: /* NUL - end of input string */
return 0;
case '\r':
- if (*pzIn != '\n')
+ if (*pzIn != NL)
return 1;
res++;
/* FALLTHROUGH */
- case '\n': /* NL - emit newline */
+ case NL: /* NL - emit newline */
*pRes = (char)nl;
return res;
case 'a': *pRes = '\a'; break;
case 'b': *pRes = '\b'; break;
case 'f': *pRes = '\f'; break;
- case 'n': *pRes = '\n'; break;
+ case 'n': *pRes = NL; break;
case 'r': *pRes = '\r'; break;
case 't': *pRes = '\t'; break;
case 'v': *pRes = '\v'; break;
@@ -137,7 +137,7 @@ contiguous_quote(char ** pps, char * pq, int * lnct_p)
for (;;) {
while (IS_WHITESPACE_CHAR(*ps))
- if (*(ps++) == '\n')
+ if (*(ps++) == NL)
(*lnct_p)++;
/*
@@ -164,7 +164,7 @@ contiguous_quote(char ** pps, char * pq, int * lnct_p)
/*
* Skip to end of line
*/
- ps = strchr(ps, '\n');
+ ps = strchr(ps, NL);
if (ps == NULL) {
*pps = NULL;
return AG_FALSE;
@@ -183,7 +183,7 @@ contiguous_quote(char ** pps, char * pq, int * lnct_p)
}
while (ps < p) {
- if (*(ps++) == '\n')
+ if (*(ps++) == NL)
(*lnct_p)++;
}
@@ -261,7 +261,7 @@ ao_string_cook(char * pzScan, int * lnct_p)
case NUL:
return NULL;
- case '\n':
+ case NL:
(*lnct_p)++;
break;
@@ -271,7 +271,7 @@ ao_string_cook(char * pzScan, int * lnct_p)
* THEN drop both the escape and the newline from
* the result string.
*/
- if (*pzS == '\n') {
+ if (*pzS == NL) {
pzS++;
pzD--;
(*lnct_p)++;
@@ -282,7 +282,7 @@ ao_string_cook(char * pzScan, int * lnct_p)
* THEN we do the full escape character processing
*/
else if (q != '\'') {
- int ct = ao_string_cook_escape_char( pzS, pzD-1, (unsigned)'\n' );
+ int ct = ao_string_cook_escape_char(pzS, pzD-1, (uint_t)NL);
if (ct == 0)
return NULL;
diff --git a/src/libopts/enum.c b/src/libopts/enum.c
index a79a32e5d3..6ce6b4bfb9 100644
--- a/src/libopts/enum.c
+++ b/src/libopts/enum.c
@@ -2,7 +2,7 @@
/**
* \file enumeration.c
*
- * Time-stamp: "2011-04-06 10:48:22 bkorb"
+ * Time-stamp: "2012-01-29 19:07:59 bkorb"
*
* Automated Options Paged Usage module.
*
@@ -11,7 +11,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -105,7 +105,7 @@ enum_err(tOptions * pOpts, tOptDesc * pOD,
*/
if (max_len > 35) {
do {
- fprintf(option_usage_fp, " %s\n", *(paz_names++));
+ fprintf(option_usage_fp, ENUM_ERR_SEP_LINE_FMT, *(paz_names++));
} while (--ct_down > 0);
}
@@ -118,19 +118,19 @@ enum_err(tOptions * pOpts, tOptDesc * pOD,
fputc(' ', option_usage_fp);
fputs(*(paz_names++), option_usage_fp);
} while (--ct_down > 0);
- fputc('\n', option_usage_fp);
+ fputc(NL, option_usage_fp);
}
/*
* Otherwise, columnize the output
*/
else {
- int ent_no = 0;
+ unsigned int ent_no = 0;
char zFmt[16]; /* format for all-but-last entries on a line */
- sprintf(zFmt, "%%-%ds", (int)max_len);
+ sprintf(zFmt, ENUM_ERR_STR_WIDTH_FMT, (int)max_len);
max_len = 78 / max_len; /* max_len is now max entries on a line */
- fputs(" ", option_usage_fp);
+ fputs(TWO_SPACES_STR, option_usage_fp);
/*
* Loop through all but the last entry
@@ -141,14 +141,14 @@ enum_err(tOptions * pOpts, tOptDesc * pOD,
/*
* Last entry on a line. Start next line, too.
*/
- fprintf(option_usage_fp, "%s\n ", *(paz_names++));
+ fprintf(option_usage_fp, NLSTR_SPACE_FMT, *(paz_names++));
ent_no = 0;
}
else
fprintf(option_usage_fp, zFmt, *(paz_names++) );
}
- fprintf(option_usage_fp, "%s\n", *paz_names);
+ fprintf(option_usage_fp, NLSTR_FMT, *paz_names);
}
if (pOpts > OPTPROC_EMIT_LIMIT) {
@@ -277,7 +277,7 @@ optionEnumerationVal(tOptions * pOpts, tOptDesc * pOD,
* print the name string.
*/
if (ix >= name_ct)
- printf("INVALID-%d", ix);
+ printf(INVALID_FMT, ix);
else
fputs(paz_names[ ix ], stdout);
@@ -286,13 +286,12 @@ optionEnumerationVal(tOptions * pOpts, tOptDesc * pOD,
case (uintptr_t)OPTPROC_RETURN_VALNAME:
{
- tSCC zInval[] = "*INVALID*";
unsigned int ix = pOD->optArg.argEnum;
/*
* Replace the enumeration value with the name string.
*/
if (ix >= name_ct)
- return (uintptr_t)zInval;
+ return (uintptr_t)INVALID_STR;
pOD->optArg.argString = paz_names[ix];
break;
@@ -328,15 +327,15 @@ set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
/*
* print the name string.
*/
- int ix = 0;
- uintptr_t bits = (uintptr_t)pOD->optCookie;
- size_t len = 0;
+ unsigned int ix = 0;
+ uintptr_t bits = (uintptr_t)pOD->optCookie;
+ size_t len = 0;
bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
while (bits != 0) {
if (bits & 1) {
- if (len++ > 0) fputs(" | ", stdout);
+ if (len++ > 0) fputs(OR_STR, stdout);
fputs(paz_names[ix], stdout);
}
if (++ix >= name_ct) break;
@@ -348,13 +347,10 @@ static void
set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
unsigned int name_ct)
{
- 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 = sizeof(none);
+ char * pz;
+ uintptr_t bits = (uintptr_t)pOD->optCookie;
+ unsigned int ix = 0;
+ size_t len = NONE_STR_LEN + 1;
bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
@@ -364,20 +360,20 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
*/
while (bits != 0) {
if (bits & 1)
- len += strlen(paz_names[ix]) + sizeof(plus);
+ len += strlen(paz_names[ix]) + PLUS_STR_LEN + 1;
if (++ix >= name_ct) break;
bits >>= 1;
}
- pOD->optArg.argString = pz = AGALOC(len, "enum name");
+ pOD->optArg.argString = pz = AGALOC(len, "enum");
/*
* Start by clearing all the bits. We want to turn off any defaults
* because we will be restoring to current state, not adding to
* the default set of bits.
*/
- memcpy(pz, none, sizeof(none)-1);
- pz += sizeof(none)-1;
+ memcpy(pz, NONE_STR, NONE_STR_LEN);
+ pz += NONE_STR_LEN;
bits = (uintptr_t)pOD->optCookie;
bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
ix = 0;
@@ -385,9 +381,9 @@ set_memb_names(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
while (bits != 0) {
if (bits & 1) {
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;
+ memcpy(pz, PLUS_STR, PLUS_STR_LEN);
+ memcpy(pz+PLUS_STR_LEN, paz_names[ix], nln);
+ pz += nln + PLUS_STR_LEN;
}
if (++ix >= name_ct) break;
bits >>= 1;
@@ -440,7 +436,7 @@ optionSetMembers(tOptions * pOpts, tOptDesc * pOD,
return;
{
- char const* pzArg = pOD->optArg.argString;
+ char const * pzArg = pOD->optArg.argString;
uintptr_t res;
if ((pzArg == NULL) || (*pzArg == NUL)) {
pOD->optCookie = (void*)0;
@@ -449,15 +445,14 @@ optionSetMembers(tOptions * pOpts, tOptDesc * pOD,
res = (uintptr_t)pOD->optCookie;
for (;;) {
- tSCC zSpn[] = " ,|+\t\r\f\n";
int iv, len;
- pzArg += strspn(pzArg, zSpn);
+ pzArg = SPN_SET_SEPARATOR_CHARS(pzArg);
iv = (*pzArg == '!');
if (iv)
- pzArg += strspn(pzArg+1, zSpn) + 1;
+ pzArg = SPN_WHITESPACE_CHARS(pzArg+1);
- len = strcspn(pzArg, zSpn);
+ len = BRK_SET_SEPARATOR_CHARS(pzArg) - pzArg;
if (len == 0)
break;
@@ -477,7 +472,7 @@ optionSetMembers(tOptions * pOpts, tOptDesc * pOD,
if (pz != pzArg + len) {
char z[ AO_NAME_SIZE ];
char const* p;
- int shift_ct;
+ unsigned int shift_ct;
if (*pz != NUL) {
if (len >= AO_NAME_LIMIT)
diff --git a/src/libopts/env.c b/src/libopts/env.c
index c8e9154af4..60e8a037f7 100644
--- a/src/libopts/env.c
+++ b/src/libopts/env.c
@@ -11,7 +11,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/file.c b/src/libopts/file.c
index 23994748ca..5a5b3eb53f 100644
--- a/src/libopts/file.c
+++ b/src/libopts/file.c
@@ -6,7 +6,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/find.c b/src/libopts/find.c
index 7a9ba175c1..aa730c6fd9 100644
--- a/src/libopts/find.c
+++ b/src/libopts/find.c
@@ -3,14 +3,14 @@
*
* @brief Hunt for options in the option descriptor list
*
- * Time-stamp: "2011-08-07 13:15:45 bkorb"
+ * Time-stamp: "2012-01-29 19:07:30 bkorb"
*
* This file contains the routines that deal with processing quoted strings
* into an internal format.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -44,7 +44,7 @@ parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz)
case NUL: return res;
case '=':
- if (res >= bufsz)
+ if (res >= (int)bufsz)
return -1;
memcpy(buf, *nm_pp, res);
@@ -70,7 +70,7 @@ static void
opt_ambiguities(tOptions * opts, char const * name, int nm_len)
{
char const * const hyph =
- NAMED_OPTS(opts) ? "" : "--";
+ NAMED_OPTS(opts) ? "" : LONG_OPT_MARKER;
tOptDesc * pOD = opts->pOptDesc;
int idx = 0;
@@ -183,8 +183,8 @@ opt_set(tOptions * opts, char * arg, int idx, ag_bool disable, tOptState * st)
fprintf(stderr, zDisabledErr, opts->pzProgName, pOD->pz_Name);
if (pOD->pzText != NULL)
- fprintf(stderr, " -- %s", pOD->pzText);
- fputc('\n', stderr);
+ fprintf(stderr, SET_OFF_FMT, pOD->pzText);
+ fputc(NL, stderr);
(*opts->pUsageProc)(opts, EXIT_FAILURE);
/* NOTREACHED */
_exit(EXIT_FAILURE); /* to be certain */
@@ -284,47 +284,37 @@ void
optionVendorOption(tOptions * pOpts, tOptDesc * pOD)
{
tOptState opt_st = OPTSTATE_INITIALIZER(PRESET);
- unsigned long st_flags = opt_st.flags;
- tSuccess res;
char const * vopt_str = pOD->optArg.argString;
- if ((pOpts->fOptSet & OPTPROC_VENDOR_OPT) == 0)
- goto illegal;
-
if ((pOD->fOptState & OPTPROC_IMMEDIATE) == 0)
- st_flags = OPTST_DEFINED;
- res = opt_find_long(pOpts, vopt_str, &opt_st);
+ opt_st.flags = OPTST_DEFINED;
- switch (res) {
- case FAILURE:
- case PROBLEM:
- illegal:
+ if ( ((pOpts->fOptSet & OPTPROC_VENDOR_OPT) == 0)
+ || ! SUCCESSFUL(opt_find_long(pOpts, vopt_str, &opt_st))
+ || ! SUCCESSFUL(get_opt_arg(pOpts, &opt_st)) )
+ {
fprintf(stderr, zIllVendOptStr, vopt_str);
(*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
/* NOTREACHED */
+ }
- case SUCCESS:
- if (! SUCCESSFUL(get_opt_arg(pOpts, &opt_st)))
- goto illegal;
-
+ /*
+ * See if we are in immediate handling state.
+ */
+ if (pOpts->fOptSet & OPTPROC_IMMEDIATE) {
/*
- * See if we are in immediate handling state.
+ * See if the enclosed option is okay with that state.
*/
- if (pOpts->fOptSet & OPTPROC_IMMEDIATE) {
- /*
- * See if the enclosed option is okay with that state.
- */
- if (DO_IMMEDIATELY(opt_st.flags))
- (void)handle_opt(pOpts, &opt_st);
+ if (DO_IMMEDIATELY(opt_st.flags))
+ (void)handle_opt(pOpts, &opt_st);
- } else {
- /*
- * non-immediate direction.
- * See if the enclosed option is okay with that state.
- */
- if (DO_NORMALLY(opt_st.flags) || DO_SECOND_TIME(opt_st.flags))
- (void)handle_opt(pOpts, &opt_st);
- }
+ } else {
+ /*
+ * non-immediate direction.
+ * See if the enclosed option is okay with that state.
+ */
+ if (DO_NORMALLY(opt_st.flags) || DO_SECOND_TIME(opt_st.flags))
+ (void)handle_opt(pOpts, &opt_st);
}
}
@@ -385,8 +375,8 @@ opt_find_short(tOptions* pOpts, uint_t optValue, tOptState* pOptState)
&& (pRes->pz_Name != NULL)) {
fprintf(stderr, zDisabledErr, pOpts->pzProgPath, pRes->pz_Name);
if (pRes->pzText != NULL)
- fprintf(stderr, " -- %s", pRes->pzText);
- fputc('\n', stderr);
+ fprintf(stderr, SET_OFF_FMT, pRes->pzText);
+ fputc(NL, stderr);
(*pOpts->pUsageProc)(pOpts, EXIT_FAILURE);
/* NOTREACHED */
_exit(EXIT_FAILURE); /* to be certain */
@@ -566,3 +556,11 @@ find_opt(tOptions * pOpts, tOptState * pOptState)
return opt_find_long(pOpts, pOpts->pzCurOpt, pOptState);
}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/find.c */
diff --git a/src/libopts/genshell.c b/src/libopts/genshell.c
index 230b13de62..71e2c7d891 100644
--- a/src/libopts/genshell.c
+++ b/src/libopts/genshell.c
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (genshell.c)
*
- * It has been AutoGen-ed December 29, 2011 at 12:02:33 PM by AutoGen 5.14
+ * It has been AutoGen-ed February 10, 2012 at 07:53:37 PM by AutoGen 5.15pre7
* From the definitions genshell.def
* and the template file options
*
- * Generated from AutoOpts 36:1:11 templates.
+ * Generated from AutoOpts 36:2:11 templates.
*
* AutoOpts is a copyrighted work. This source file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -19,7 +19,7 @@
* The genshellopt program is copyrighted and licensed
* under the following terms:
*
- * Copyright (C) 1999-2011 Bruce Korb, all rights reserved.
+ * Copyright (C) 1999-2012 Bruce Korb, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the
* GNU General Public License, version 3 or later
@@ -68,7 +68,7 @@ extern tUsageProc genshelloptUsage;
*/
static char const genshellopt_opt_strs[1691] =
/* 0 */ "genshellopt 1\n"
- "Copyright (C) 1999-2011 Bruce Korb, all rights reserved.\n"
+ "Copyright (C) 1999-2012 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"
@@ -269,7 +269,7 @@ doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
(void)pOptions;
GENSHELL_USAGE(GENSHELLOPT_EXIT_SUCCESS);
}
-/* extracted from optmain.tlib near line 1148 */
+/* extracted from optmain.tlib near line 1133 */
#ifndef PKGDATADIR
# define PKGDATADIR ""
diff --git a/src/libopts/genshell.h b/src/libopts/genshell.h
index 2718bbf7cf..eecbe44bf4 100644
--- a/src/libopts/genshell.h
+++ b/src/libopts/genshell.h
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (genshell.h)
*
- * It has been AutoGen-ed December 29, 2011 at 12:02:33 PM by AutoGen 5.14
+ * It has been AutoGen-ed February 10, 2012 at 07:53:37 PM by AutoGen 5.15pre7
* From the definitions genshell.def
* and the template file options
*
- * Generated from AutoOpts 36:1:11 templates.
+ * Generated from AutoOpts 36:2:11 templates.
*
* AutoOpts is a copyrighted work. This header file is not encumbered
* by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -19,7 +19,7 @@
* The genshellopt program is copyrighted and licensed
* under the following terms:
*
- * Copyright (C) 1999-2011 Bruce Korb, all rights reserved.
+ * Copyright (C) 1999-2012 Bruce Korb, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the
* GNU General Public License, version 3 or later
@@ -55,7 +55,7 @@
* tolerable version is at least as old as what was current when the header
* template was released.
*/
-#define AO_TEMPLATE_VERSION 147457
+#define AO_TEMPLATE_VERSION 147458
#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
|| (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
# error option template version mismatches autoopts/options.h header
diff --git a/src/libopts/libopts.c b/src/libopts/libopts.c
index ca256eb7ef..bd5f87244f 100644
--- a/src/libopts/libopts.c
+++ b/src/libopts/libopts.c
@@ -2,23 +2,27 @@
#define AUTOOPTS_INTERNAL 1
#include "compat/compat.h"
#define LOCAL static
+#include "ao-strs.h"
#include "autoopts/options.h"
#include "autoopts/usage-txt.h"
#include "genshell.h"
#include "xat-attribute.h"
#include "value-type.h"
+#include "ao-strs.h"
#include "ag-char-map.h"
#include "autoopts.h"
-#include "proto.h"
#include "parse-duration.h"
+#include "proto.h"
#include "parse-duration.c"
+#include "ao-strs.c"
#include "value-type.c"
#include "xat-attribute.c"
#include "autoopts.c"
+#include "alias.c"
#include "boolean.c"
+#include "check.c"
#include "configfile.c"
#include "cook.c"
-#include "check.c"
#include "enum.c"
#include "env.c"
#include "file.c"
@@ -37,7 +41,7 @@
#include "stack.c"
#include "streqvcmp.c"
#include "text_mmap.c"
-#include "tokenize.c"
#include "time.c"
+#include "tokenize.c"
#include "usage.c"
#include "version.c"
diff --git a/src/libopts/load.c b/src/libopts/load.c
index e4f231d4b7..a1380709bb 100644
--- a/src/libopts/load.c
+++ b/src/libopts/load.c
@@ -1,7 +1,7 @@
/**
* \file load.c
- * Time-stamp: "2011-12-17 12:53:04 bkorb"
+ * Time-stamp: "2012-01-29 19:37:15 bkorb"
*
* This file contains the routines that deal with processing text strings
* for options, either from a NUL-terminated string passed in or from an
@@ -9,7 +9,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -37,8 +37,8 @@ static ag_bool
add_env_val(char * pzBuf, int bufSize, char const * pzName,
char const * pzProgPath);
-static char*
-assemble_arg_val(char* pzTxt, tOptionLoadMode mode);
+static char *
+assemble_arg_val(char * pzTxt, tOptionLoadMode mode);
/* = = = END-STATIC-FORWARD = = = */
/*=export_func optionMakePath
@@ -98,7 +98,7 @@ optionMakePath(char * pzBuf, int bufSize, char const * pzName,
{
size_t name_len = strlen(pzName);
- if ((bufSize <= name_len) || (name_len == 0))
+ if (((size_t)bufSize <= name_len) || (name_len == 0))
return AG_FALSE;
/*
@@ -225,7 +225,7 @@ add_prog_path(char * pzBuf, int bufSize, char const * pzName,
* Concatenate the file name to the end of the executable path.
* The result may be either a file or a directory.
*/
- if ((pz - pzPath)+1 + strlen(pzName) >= bufSize)
+ if ((pz - pzPath)+1 + strlen(pzName) >= (unsigned)bufSize)
return AG_FALSE;
memcpy(pzBuf, pzPath, (size_t)((pz - pzPath)+1));
@@ -267,7 +267,7 @@ add_env_val(char * pzBuf, int bufSize, char const * pzName,
if (pzDir == NULL)
return AG_FALSE;
- if (strlen(pzDir) + 1 + strlen(pzName) >= bufSize)
+ if (strlen(pzDir) + 1 + strlen(pzName) >= (unsigned)bufSize)
return AG_FALSE;
sprintf(pzBuf, "%s%s", pzDir, pzName);
@@ -314,11 +314,10 @@ mungeString(char* pzTxt, tOptionLoadMode mode)
}
-static char*
-assemble_arg_val(char* pzTxt, tOptionLoadMode mode)
+static char *
+assemble_arg_val(char * pzTxt, tOptionLoadMode mode)
{
- static char const zBrk[] = " \t\n:=";
- char* pzEnd = strpbrk(pzTxt, zBrk);
+ char* pzEnd = strpbrk(pzTxt, ARG_BREAK_STR);
int space_break;
/*
diff --git a/src/libopts/m4/libopts.m4 b/src/libopts/m4/libopts.m4
index bb8da673d9..1f981aaefe 100644
--- a/src/libopts/m4/libopts.m4
+++ b/src/libopts/m4/libopts.m4
@@ -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 December 29, 2011 at 12:02:31 PM by AutoGen 5.14
+dnl It has been AutoGen-ed February 10, 2012 at 07:53:33 PM by AutoGen 5.15pre7
dnl From the definitions libopts.def
dnl and the template file conftest.tpl
dnl
@@ -78,16 +78,16 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
# ----------------------------------------------------------------------
AC_CHECK_TYPES(wchar_t)
AC_CHECK_TYPES(wint_t, [], [], [
- AC_INCLUDES_DEFAULT
- #if HAVE_RUNETYPE_H
- # include <runetype.h>
- #endif
- #if HAVE_WCHAR_H
- # include <wchar.h>
- #endif
+ AC_INCLUDES_DEFAULT
+ #if HAVE_RUNETYPE_H
+ # include <runetype.h>
+ #endif
+ #if HAVE_WCHAR_H
+ # include <wchar.h>
+ #endif
])
AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
- intptr_t, uintptr_t, uint_t, pid_t, size_t])
+ intptr_t, uintptr_t, uint_t, pid_t, size_t])
# =====
# sizes
@@ -454,7 +454,7 @@ dnl the config tests that the library needs. Invoke the
dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
dnl
dnl This file is part of AutoGen.
-dnl AutoGen Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+dnl AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
dnl
dnl AutoGen is free software: you can redistribute it and/or modify it
dnl under the terms of the GNU General Public License as published by the
@@ -574,9 +574,8 @@ AC_DEFUN([LIBOPTS_CHECK], [
LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
AM_COND_IF([NEED_LIBOPTS], [
INVOKE_LIBOPTS_MACROS
+ AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
])dnl
-
- AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
m4_popdef([AO_Libopts_Dir])dnl
# end of AC_DEFUN of LIBOPTS_CHECK
])
diff --git a/src/libopts/m4/liboptschk.m4 b/src/libopts/m4/liboptschk.m4
index 48e4ceb7a1..4a45bdefc6 100644
--- a/src/libopts/m4/liboptschk.m4
+++ b/src/libopts/m4/liboptschk.m4
@@ -1,5 +1,5 @@
# liboptschk.m4 serial 2 (autogen - 5.11.4)
-dnl Copyright (c) 2005-2011 by Bruce Korb - all rights reserved
+dnl Copyright (c) 2005-2012 by Bruce Korb - all rights reserved
dnl
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
diff --git a/src/libopts/makeshell.c b/src/libopts/makeshell.c
index 20964ff316..1730c8176d 100644
--- a/src/libopts/makeshell.c
+++ b/src/libopts/makeshell.c
@@ -2,14 +2,14 @@
/**
* \file makeshell.c
*
- * Time-stamp: "2011-04-20 11:06:57 bkorb"
+ * Time-stamp: "2012-01-29 19:01:07 bkorb"
*
* This module will interpret the options set in the tOptions
* structure and create a Bourne shell script capable of parsing them.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -30,347 +30,40 @@
tOptions * optionParseShellOptions = NULL;
-/* * * * * * * * * * * * * * * * * * * * *
- *
- * Setup Format Strings
- */
-static char const zStartMarker[] =
-"# # # # # # # # # # -- do not modify this marker --\n#\n"
-"# DO NOT EDIT THIS SECTION";
-
-static char const zPreamble[] =
-"%s OF %s\n#\n"
-"# From here to the next `-- do not modify this marker --',\n"
-"# the text has been generated %s\n";
-
-static char const zEndPreamble[] =
-"# From the %s option definitions\n#\n";
-
-static char const zMultiDef[] = "\n"
-"if test -z \"${%1$s_%2$s}\"\n"
-"then\n"
-" %1$s_%2$s_CT=0\n"
-"else\n"
-" %1$s_%2$s_CT=1\n"
-" %1$s_%2$s_1=\"${%1$s_%2$s}\"\n"
-"fi\n"
-"export %1$s_%2$s_CT";
-
-static char const zSingleDef[] = "\n"
-"%1$s_%2$s=\"${%1$s_%2$s-'%3$s'}\"\n"
-"%1$s_%2$s_set=false\n"
-"export %1$s_%2$s\n";
-
-static char const zSingleNoDef[] = "\n"
-"%1$s_%2$s=\"${%1$s_%2$s}\"\n"
-"%1$s_%2$s_set=false\n"
-"export %1$s_%2$s\n";
-
-/* * * * * * * * * * * * * * * * * * * * *
- *
- * LOOP START
- *
- * The loop may run in either of two modes:
- * all options are named options (loop only)
- * regular, marked option processing.
- */
-static char const zLoopCase[] = "\n"
-"OPT_PROCESS=true\n"
-"OPT_ARG=\"$1\"\n\n"
-"while ${OPT_PROCESS} && [ $# -gt 0 ]\ndo\n"
-" OPT_ELEMENT=''\n"
-" OPT_ARG_VAL=''\n\n"
- /*
- * 'OPT_ARG' may or may not match the current $1
- */
-" case \"${OPT_ARG}\" in\n"
-" -- )\n"
-" OPT_PROCESS=false\n"
-" shift\n"
-" ;;\n\n";
-
-static char const zLoopOnly[] = "\n"
-"OPT_ARG=\"$1\"\n\n"
-"while [ $# -gt 0 ]\ndo\n"
-" OPT_ELEMENT=''\n"
-" OPT_ARG_VAL=''\n\n"
-" OPT_ARG=\"${1}\"\n";
-
-/* * * * * * * * * * * * * * * *
- *
- * CASE SELECTORS
- *
- * If the loop runs as a regular option loop,
- * then we must have selectors for each acceptable option
- * type (long option, flag character and non-option)
- */
-static char const zLongSelection[] =
-" --* )\n";
-
-static char const zFlagSelection[] =
-" -* )\n";
-
-static char const zEndSelection[] =
-" ;;\n\n";
-
-static char const zNoSelection[] =
-" * )\n"
-" OPT_PROCESS=false\n"
-" ;;\n"
-" esac\n\n";
-
-/* * * * * * * * * * * * * * * *
- *
- * LOOP END
- */
-static char const zLoopEnd[] =
-" if [ -n \"${OPT_ARG_VAL}\" ]\n"
-" then\n"
-" eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
-" export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
-" fi\n"
-"done\n\n"
-"unset OPT_PROCESS || :\n"
-"unset OPT_ELEMENT || :\n"
-"unset OPT_ARG || :\n"
-"unset OPT_ARG_NEEDED || :\n"
-"unset OPT_NAME || :\n"
-"unset OPT_CODE || :\n"
-"unset OPT_ARG_VAL || :\n%2$s";
-
-static char const zTrailerMarker[] = "\n"
-"# # # # # # # # # #\n#\n"
-"# END OF AUTOMATED OPTION PROCESSING\n"
-"#\n# # # # # # # # # # -- do not modify this marker --\n";
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * OPTION SELECTION
- */
-static char const zOptionCase[] =
-" case \"${OPT_CODE}\" in\n";
-
-static char const zOptionPartName[] =
-" '%s' | \\\n";
-
-static char const zOptionFullName[] =
-" '%s' )\n";
-
-static char const zOptionFlag[] =
-" '%c' )\n";
-
-static char const zOptionEndSelect[] =
-" ;;\n\n";
-
-static char const zOptionUnknown[] =
-" * )\n"
-" echo Unknown %s: \"${OPT_CODE}\" >&2\n"
-" echo \"$%s_USAGE_TEXT\"\n"
-" exit 1\n"
-" ;;\n"
-" esac\n\n";
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * OPTION PROCESSING
- *
- * Formats for emitting the text for handling particular options
- */
-static char const zTextExit[] =
-" echo \"$%s_%s_TEXT\"\n"
-" exit 0\n";
-
-static char const zPagedUsageExit[] =
-" echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
-" exit 0\n";
-
-static char const zCmdFmt[] =
-" %s\n";
-
-static char const zCountTest[] =
-" if [ $%1$s_%2$s_CT -ge %3$d ] ; then\n"
-" echo Error: more than %3$d %2$s options >&2\n"
-" echo \"$%1$s_USAGE_TEXT\"\n"
-" exit 1 ; fi\n";
-
-static char const zMultiArg[] =
-" %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
-" OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
-" OPT_NAME='%2$s'\n";
-
-static char const zSingleArg[] =
-" if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
-" echo Error: duplicate %2$s option >&2\n"
-" echo \"$%1$s_USAGE_TEXT\"\n"
-" exit 1 ; fi\n"
-" %1$s_%2$s_set=true\n"
-" OPT_NAME='%2$s'\n";
-
-static char const zNoMultiArg[] =
-" %1$s_%2$s_CT=0\n"
-" OPT_ELEMENT=''\n"
-" %1$s_%2$s='%3$s'\n"
-" export %1$s_%2$s\n"
-" OPT_NAME='%2$s'\n";
-
-static char const zNoSingleArg[] =
-" if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
-" echo Error: duplicate %2$s option >&2\n"
-" echo \"$%1$s_USAGE_TEXT\"\n"
-" exit 1 ; fi\n"
-" %1$s_%2$s_set=true\n"
-" %1$s_%2$s='%3$s'\n"
-" export %1$s_%2$s\n"
-" OPT_NAME='%2$s'\n";
-
-static char const zMayArg[] =
-" eval %1$s_%2$s${OPT_ELEMENT}=true\n"
-" export %1$s_%2$s${OPT_ELEMENT}\n"
-" OPT_ARG_NEEDED=OK\n";
-
-static char const zMustArg[] =
-" OPT_ARG_NEEDED=YES\n";
-
-static char const zCantArg[] =
-" eval %1$s_%2$s${OPT_ELEMENT}=true\n"
-" export %1$s_%2$s${OPT_ELEMENT}\n"
-" OPT_ARG_NEEDED=NO\n";
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * LONG OPTION PROCESSING
- *
- * Formats for emitting the text for handling long option types
- */
-static char const zLongOptInit[] =
-" OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
-" shift\n"
-" OPT_ARG=\"$1\"\n\n"
-" case \"${OPT_CODE}\" in *=* )\n"
-" OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
-" OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\n";
-
-static char const zLongOptArg[] =
-" case \"${OPT_ARG_NEEDED}\" in\n"
-" NO )\n"
-" OPT_ARG_VAL=''\n"
-" ;;\n\n"
-" YES )\n"
-" if [ -z \"${OPT_ARG_VAL}\" ]\n"
-" then\n"
-" if [ $# -eq 0 ]\n"
-" then\n"
-" echo No argument provided for ${OPT_NAME} option >&2\n"
-" echo \"$%s_USAGE_TEXT\"\n"
-" exit 1\n"
-" fi\n\n"
-" OPT_ARG_VAL=\"${OPT_ARG}\"\n"
-" shift\n"
-" OPT_ARG=\"$1\"\n"
-" fi\n"
-" ;;\n\n"
-" OK )\n"
-" if [ -z \"${OPT_ARG_VAL}\" ] && [ $# -gt 0 ]\n"
-" then\n"
-" case \"${OPT_ARG}\" in -* ) ;; * )\n"
-" OPT_ARG_VAL=\"${OPT_ARG}\"\n"
-" shift\n"
-" OPT_ARG=\"$1\" ;; esac\n"
-" fi\n"
-" ;;\n"
-" esac\n";
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * FLAG OPTION PROCESSING
- *
- * Formats for emitting the text for handling flag option types
- */
-static char const zFlagOptInit[] =
-" OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
-" OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\n";
-
-static char const zFlagOptArg[] =
-" case \"${OPT_ARG_NEEDED}\" in\n"
-" NO )\n"
-" if [ -n \"${OPT_ARG}\" ]\n"
-" then\n"
-" OPT_ARG=-\"${OPT_ARG}\"\n"
-" else\n"
-" shift\n"
-" OPT_ARG=\"$1\"\n"
-" fi\n"
-" ;;\n\n"
-" YES )\n"
-" if [ -n \"${OPT_ARG}\" ]\n"
-" then\n"
-" OPT_ARG_VAL=\"${OPT_ARG}\"\n\n"
-" else\n"
-" if [ $# -eq 0 ]\n"
-" then\n"
-" echo No argument provided for ${OPT_NAME} option >&2\n"
-" echo \"$%s_USAGE_TEXT\"\n"
-" exit 1\n"
-" fi\n"
-" shift\n"
-" OPT_ARG_VAL=\"$1\"\n"
-" fi\n\n"
-" shift\n"
-" OPT_ARG=\"$1\"\n"
-" ;;\n\n"
-" OK )\n"
-" if [ -n \"${OPT_ARG}\" ]\n"
-" then\n"
-" OPT_ARG_VAL=\"${OPT_ARG}\"\n"
-" shift\n"
-" OPT_ARG=\"$1\"\n\n"
-" else\n"
-" shift\n"
-" if [ $# -gt 0 ]\n"
-" then\n"
-" case \"$1\" in -* ) ;; * )\n"
-" OPT_ARG_VAL=\"$1\"\n"
-" shift ;; esac\n"
-" OPT_ARG=\"$1\"\n"
-" fi\n"
-" fi\n"
-" ;;\n"
-" esac\n";
-
-tSCC* pzShell = NULL;
-static char* pzLeader = NULL;
-static char* pzTrailer = NULL;
+static char const * shell_prog = NULL;
+static char * script_leader = NULL;
+static char * script_trailer = NULL;
/* = = = START-STATIC-FORWARD = = = */
static void
emit_var_text(char const * prog, char const * var, int fdin);
static void
-textToVariable(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD);
+text_to_var(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD);
static void
-emitUsage(tOptions* pOpts);
+emit_usage(tOptions * pOpts);
static void
-emitSetup(tOptions* pOpts);
+emit_setup(tOptions * pOpts);
static void
-printOptionAction(tOptions* pOpts, tOptDesc* pOptDesc);
+emit_action(tOptions * pOpts, tOptDesc* pOptDesc);
static void
-printOptionInaction(tOptions* pOpts, tOptDesc* pOptDesc);
+emit_inaction(tOptions * pOpts, tOptDesc* pOptDesc);
static void
-emitFlag(tOptions* pOpts);
+emit_flag(tOptions * pOpts);
static void
-emitMatchExpr(tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts);
+emit_match_expr(char const * pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts);
static void
-emitLong(tOptions* pOpts);
+emitLong(tOptions * pOpts);
static void
-openOutput(char const* pzFile);
+open_out(char const * pzFile);
/* = = = END-STATIC-FORWARD = = = */
/*=export_func optionParseShell
@@ -383,7 +76,7 @@ openOutput(char const* pzFile);
* Emit a shell script that will parse the command line options.
=*/
void
-optionParseShell(tOptions* pOpts)
+optionParseShell(tOptions * pOpts)
{
/*
* Check for our SHELL option now.
@@ -391,89 +84,87 @@ optionParseShell(tOptions* pOpts)
* it will override anything we do here.
*/
if (HAVE_GENSHELL_OPT(SHELL))
- pzShell = GENSHELL_OPT_ARG(SHELL);
+ shell_prog = GENSHELL_OPT_ARG(SHELL);
else if (! ENABLED_GENSHELL_OPT(SHELL))
- pzShell = NULL;
+ shell_prog = NULL;
- else if ((pzShell = getenv("SHELL")),
- pzShell == NULL)
+ else if ((shell_prog = getenv("SHELL")),
+ shell_prog == NULL)
- pzShell = POSIX_SHELL;
+ shell_prog = POSIX_SHELL;
/*
* Check for a specified output file
*/
if (HAVE_GENSHELL_OPT(SCRIPT))
- openOutput(GENSHELL_OPT_ARG(SCRIPT));
+ open_out(GENSHELL_OPT_ARG(SCRIPT));
- emitUsage(pOpts);
- emitSetup(pOpts);
+ emit_usage(pOpts);
+ emit_setup(pOpts);
/*
* There are four modes of option processing.
*/
switch (pOpts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) {
case OPTPROC_LONGOPT:
- fputs(zLoopCase, stdout);
+ fputs(LOOP_STR, stdout);
- fputs(zLongSelection, stdout);
- fputs(zLongOptInit, stdout);
+ fputs(LONG_OPT_MARK, stdout);
+ fputs(INIT_LOPT_STR, stdout);
emitLong(pOpts);
- printf(zLongOptArg, pOpts->pzPROGNAME);
- fputs(zEndSelection, stdout);
+ printf(LOPT_ARG_FMT, pOpts->pzPROGNAME);
+ fputs(END_OPT_SEL_STR, stdout);
- fputs(zNoSelection, stdout);
+ fputs(NOT_FOUND_STR, stdout);
break;
case 0:
- fputs(zLoopOnly, stdout);
- fputs(zLongOptInit, stdout);
+ fputs(ONLY_OPTS_LOOP, stdout);
+ fputs(INIT_LOPT_STR, stdout);
emitLong(pOpts);
- printf(zLongOptArg, pOpts->pzPROGNAME);
+ printf(LOPT_ARG_FMT, pOpts->pzPROGNAME);
break;
case OPTPROC_SHORTOPT:
- fputs(zLoopCase, stdout);
+ fputs(LOOP_STR, stdout);
- fputs(zFlagSelection, stdout);
- fputs(zFlagOptInit, stdout);
- emitFlag(pOpts);
- printf(zFlagOptArg, pOpts->pzPROGNAME);
- fputs(zEndSelection, stdout);
+ fputs(FLAG_OPT_MARK, stdout);
+ fputs(INIT_OPT_STR, stdout);
+ emit_flag(pOpts);
+ printf(OPT_ARG_FMT, pOpts->pzPROGNAME);
+ fputs(END_OPT_SEL_STR, stdout);
- fputs(zNoSelection, stdout);
+ fputs(NOT_FOUND_STR, stdout);
break;
case OPTPROC_LONGOPT|OPTPROC_SHORTOPT:
- fputs(zLoopCase, stdout);
+ fputs(LOOP_STR, stdout);
- fputs(zLongSelection, stdout);
- fputs(zLongOptInit, stdout);
+ fputs(LONG_OPT_MARK, stdout);
+ fputs(INIT_LOPT_STR, stdout);
emitLong(pOpts);
- printf(zLongOptArg, pOpts->pzPROGNAME);
- fputs(zEndSelection, stdout);
+ printf(LOPT_ARG_FMT, pOpts->pzPROGNAME);
+ fputs(END_OPT_SEL_STR, stdout);
- fputs(zFlagSelection, stdout);
- fputs(zFlagOptInit, stdout);
- emitFlag(pOpts);
- printf(zFlagOptArg, pOpts->pzPROGNAME);
- fputs(zEndSelection, stdout);
+ fputs(FLAG_OPT_MARK, stdout);
+ fputs(INIT_OPT_STR, stdout);
+ emit_flag(pOpts);
+ printf(OPT_ARG_FMT, pOpts->pzPROGNAME);
+ fputs(END_OPT_SEL_STR, stdout);
- fputs(zNoSelection, stdout);
+ fputs(NOT_FOUND_STR, stdout);
break;
}
- printf(zLoopEnd, pOpts->pzPROGNAME, zTrailerMarker);
- if ((pzTrailer != NULL) && (*pzTrailer != '\0'))
- fputs(pzTrailer, stdout);
+ printf(zLoopEnd, pOpts->pzPROGNAME, END_MARK);
+ if ((script_trailer != NULL) && (*script_trailer != NUL))
+ fputs(script_trailer, stdout);
else if (ENABLED_GENSHELL_OPT(SHELL))
- printf("\nenv | grep '^%s_'\n", pOpts->pzPROGNAME);
+ printf(SHOW_PROG_ENV, pOpts->pzPROGNAME);
fflush(stdout);
-#ifdef HAVE_FCHMOD
fchmod(STDOUT_FILENO, 0755);
-#endif
fclose(stdout);
if (ferror(stdout)) {
fputs(zOutputFail, stderr);
@@ -488,7 +179,7 @@ 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);
+ printf(SET_TEXT_FMT, prog, var);
if (fp == NULL)
goto skip_text;
@@ -496,16 +187,16 @@ emit_var_text(char const * prog, char const * var, int fdin)
int ch = fgetc(fp);
switch (ch) {
- case '\n':
+ case NL:
nlct++;
break;
case '\'':
while (nlct > 0) {
- fputc('\n', stdout);
+ fputc(NL, stdout);
nlct--;
}
- fputs("'\\''", stdout);
+ fputs(apostrophy, stdout);
break;
case EOF:
@@ -513,7 +204,7 @@ emit_var_text(char const * prog, char const * var, int fdin)
default:
while (nlct > 0) {
- fputc('\n', stdout);
+ fputc(NL, stdout);
nlct--;
}
fputc(ch, stdout);
@@ -525,7 +216,7 @@ emit_var_text(char const * prog, char const * var, int fdin)
skip_text:
- fputs("'\n\n", stdout);
+ fputs(END_SET_TEXT, stdout);
}
#endif
@@ -538,7 +229,7 @@ skip_text:
* capture the output in the parent process.
*/
static void
-textToVariable(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD)
+text_to_var(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD)
{
# define _TT_(n) static char const z ## n [] = #n;
TEXTTO_TABLE
@@ -548,8 +239,7 @@ textToVariable(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD)
# undef _TT_
#if ! defined(HAVE_WORKING_FORK)
- printf("%1$s_%2$s_TEXT='no %2$s text'\n",
- pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
+ printf(SET_NO_TEXT_FMT, pOpts->pzPROGNAME, apzTTNames[ whichVar]);
#else
int pipeFd[2];
@@ -608,7 +298,7 @@ textToVariable(tOptions * pOpts, teTextTo whichVar, tOptDesc * pOD)
static void
-emitUsage(tOptions* pOpts)
+emit_usage(tOptions * pOpts)
{
char zTimeBuf[AO_NAME_SIZE];
@@ -618,30 +308,29 @@ emitUsage(tOptions* pOpts)
* by the definitions (rather than the current
* executable name). Down case the upper cased name.
*/
- if (pzLeader != NULL)
- fputs(pzLeader, stdout);
+ if (script_leader != NULL)
+ fputs(script_leader, stdout);
{
- tSCC zStdout[] = "stdout";
- tCC* pzOutName;
+ char const * out_nm;
{
- time_t curTime = time(NULL);
- struct tm* pTime = localtime(&curTime);
- strftime(zTimeBuf, AO_NAME_SIZE, "%A %B %e, %Y at %r %Z", pTime );
+ time_t c_tim = time(NULL);
+ struct tm * ptm = localtime(&c_tim);
+ strftime(zTimeBuf, AO_NAME_SIZE, TIME_FMT, ptm );
}
if (HAVE_GENSHELL_OPT(SCRIPT))
- pzOutName = GENSHELL_OPT_ARG(SCRIPT);
- else pzOutName = zStdout;
+ out_nm = GENSHELL_OPT_ARG(SCRIPT);
+ else out_nm = STDOUT;
- if ((pzLeader == NULL) && (pzShell != NULL))
- printf("#! %s\n", pzShell);
+ if ((script_leader == NULL) && (shell_prog != NULL))
+ printf(SHELL_MAGIC, shell_prog);
- printf(zPreamble, zStartMarker, pzOutName, zTimeBuf);
+ printf(PREAMBLE_FMT, START_MARK, out_nm, zTimeBuf);
}
- printf(zEndPreamble, pOpts->pzPROGNAME);
+ printf(END_PRE_FMT, pOpts->pzPROGNAME);
/*
* Get a copy of the original program name in lower case and
@@ -653,7 +342,7 @@ emitUsage(tOptions* pOpts)
char ** pp;
for (;;) {
- if ((*pzPN++ = tolower(*pz++)) == '\0')
+ if ((*pzPN++ = (char)tolower(*pz++)) == NUL)
break;
}
@@ -663,8 +352,8 @@ emitUsage(tOptions* pOpts)
*pp = zTimeBuf;
}
- textToVariable(pOpts, TT_LONGUSAGE, NULL);
- textToVariable(pOpts, TT_USAGE, NULL);
+ text_to_var(pOpts, TT_LONGUSAGE, NULL);
+ text_to_var(pOpts, TT_USAGE, NULL);
{
tOptDesc* pOptDesc = pOpts->pOptDesc;
@@ -672,7 +361,7 @@ emitUsage(tOptions* pOpts)
for (;;) {
if (pOptDesc->pOptProc == optionPrintVersion) {
- textToVariable(pOpts, TT_VERSION, pOptDesc);
+ text_to_var(pOpts, TT_VERSION, pOptDesc);
break;
}
@@ -685,15 +374,15 @@ emitUsage(tOptions* pOpts)
static void
-emitSetup(tOptions* pOpts)
+emit_setup(tOptions * pOpts)
{
- tOptDesc* pOptDesc = pOpts->pOptDesc;
- int optionCt = pOpts->presetOptCt;
- char const* pzFmt;
- char const* pzDefault;
+ tOptDesc * pOptDesc = pOpts->pOptDesc;
+ int optionCt = pOpts->presetOptCt;
+ char const * pzFmt;
+ char const * pzDefault;
for (;optionCt > 0; pOptDesc++, --optionCt) {
- char zVal[16];
+ char zVal[32];
/*
* Options that are either usage documentation or are compiled out
@@ -703,8 +392,8 @@ emitSetup(tOptions* pOpts)
continue;
if (pOptDesc->optMaxCt > 1)
- pzFmt = zMultiDef;
- else pzFmt = zSingleDef;
+ pzFmt = MULTI_DEF_FMT;
+ else pzFmt = SGL_DEF_FMT;
/*
* IF this is an enumeration/bitmask option, then convert the value
@@ -732,13 +421,13 @@ emitSetup(tOptions* pOpts)
break;
case OPARG_TYPE_BOOLEAN:
- pzDefault = (pOptDesc->optArg.argBool) ? "true" : "false";
+ pzDefault = (pOptDesc->optArg.argBool) ? TRUE_STR : FALSE_STR;
break;
default:
if (pOptDesc->optArg.argString == NULL) {
- if (pzFmt == zSingleDef)
- pzFmt = zSingleNoDef;
+ if (pzFmt == SGL_DEF_FMT)
+ pzFmt = SGL_NO_DEF_FMT;
pzDefault = NULL;
}
else
@@ -749,38 +438,36 @@ emitSetup(tOptions* pOpts)
}
}
-
static void
-printOptionAction(tOptions* pOpts, tOptDesc* pOptDesc)
+emit_action(tOptions * pOpts, tOptDesc* pOptDesc)
{
if (pOptDesc->pOptProc == optionPrintVersion)
- printf(zTextExit, pOpts->pzPROGNAME, "VERSION");
+ printf(zTextExit, pOpts->pzPROGNAME, VER_STR);
else if (pOptDesc->pOptProc == optionPagedUsage)
printf(zPagedUsageExit, pOpts->pzPROGNAME);
else if (pOptDesc->pOptProc == optionLoadOpt) {
- printf(zCmdFmt, "echo 'Warning: Cannot load options files' >&2");
- printf(zCmdFmt, "OPT_ARG_NEEDED=YES");
+ printf(zCmdFmt, NO_LOAD_WARN);
+ printf(zCmdFmt, YES_NEED_OPT_ARG);
} else if (pOptDesc->pz_NAME == NULL) {
if (pOptDesc->pOptProc == NULL) {
- printf(zCmdFmt, "echo 'Warning: Cannot save options files' "
- ">&2");
- printf(zCmdFmt, "OPT_ARG_NEEDED=OK");
+ printf(zCmdFmt, NO_SAVE_OPTS);
+ printf(zCmdFmt, OK_NEED_OPT_ARG);
} else
- printf(zTextExit, pOpts->pzPROGNAME, "LONGUSAGE");
+ printf(zTextExit, pOpts->pzPROGNAME, LONG_USE_STR);
} else {
if (pOptDesc->optMaxCt == 1)
- printf(zSingleArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
+ printf(SGL_ARG_FMT, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
else {
if ((unsigned)pOptDesc->optMaxCt < NOLIMIT)
printf(zCountTest, pOpts->pzPROGNAME,
pOptDesc->pz_NAME, pOptDesc->optMaxCt);
- printf(zMultiArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
+ printf(MULTI_ARG_FMT, pOpts->pzPROGNAME, pOptDesc->pz_NAME);
}
/*
@@ -801,26 +488,25 @@ printOptionAction(tOptions* pOpts, tOptDesc* pOptDesc)
static void
-printOptionInaction(tOptions* pOpts, tOptDesc* pOptDesc)
+emit_inaction(tOptions * pOpts, tOptDesc* pOptDesc)
{
if (pOptDesc->pOptProc == optionLoadOpt) {
- printf(zCmdFmt, "echo 'Warning: Cannot suppress the loading of "
- "options files' >&2");
+ printf(zCmdFmt, NO_SUPPRESS_LOAD);
} else if (pOptDesc->optMaxCt == 1)
- printf(zNoSingleArg, pOpts->pzPROGNAME,
+ printf(NO_SGL_ARG_FMT, pOpts->pzPROGNAME,
pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx);
else
- printf(zNoMultiArg, pOpts->pzPROGNAME,
+ printf(NO_MULTI_ARG_FMT, pOpts->pzPROGNAME,
pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx);
- printf(zCmdFmt, "OPT_ARG_NEEDED=NO");
+ printf(zCmdFmt, NO_ARG_NEEDED);
fputs(zOptionEndSelect, stdout);
}
static void
-emitFlag(tOptions* pOpts)
+emit_flag(tOptions * pOpts)
{
tOptDesc* pOptDesc = pOpts->pOptDesc;
int optionCt = pOpts->optCt;
@@ -834,10 +520,10 @@ emitFlag(tOptions* pOpts)
if (IS_GRAPHIC_CHAR(pOptDesc->optValue)) {
printf(zOptionFlag, pOptDesc->optValue);
- printOptionAction(pOpts, pOptDesc);
+ emit_action(pOpts, pOptDesc);
}
}
- printf(zOptionUnknown, "flag", pOpts->pzPROGNAME);
+ printf(UNK_OPT_FMT, FLAG_STR, pOpts->pzPROGNAME);
}
@@ -845,7 +531,7 @@ emitFlag(tOptions* pOpts)
* Emit the match text for a long option
*/
static void
-emitMatchExpr(tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts)
+emit_match_expr(char const * pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts)
{
tOptDesc* pOD = pOpts->pOptDesc;
int oCt = pOpts->optCt;
@@ -925,7 +611,7 @@ emitMatchExpr(tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts)
* Emit GNU-standard long option handling code
*/
static void
-emitLong(tOptions* pOpts)
+emitLong(tOptions * pOpts)
{
tOptDesc* pOD = pOpts->pOptDesc;
int ct = pOpts->optCt;
@@ -942,24 +628,24 @@ emitLong(tOptions* pOpts)
if (SKIP_OPT(pOD))
continue;
- emitMatchExpr(pOD->pz_Name, pOD, pOpts);
- printOptionAction(pOpts, pOD);
+ emit_match_expr(pOD->pz_Name, pOD, pOpts);
+ emit_action(pOpts, pOD);
/*
* Now, do the same thing for the disablement version of the option.
*/
if (pOD->pz_DisableName != NULL) {
- emitMatchExpr(pOD->pz_DisableName, pOD, pOpts);
- printOptionInaction(pOpts, pOD);
+ emit_match_expr(pOD->pz_DisableName, pOD, pOpts);
+ emit_inaction(pOpts, pOD);
}
} while (pOD++, --ct > 0);
- printf(zOptionUnknown, "option", pOpts->pzPROGNAME);
+ printf(UNK_OPT_FMT, OPTION_STR, pOpts->pzPROGNAME);
}
static void
-openOutput(char const* pzFile)
+open_out(char const * pzFile)
{
FILE* fp;
char* pzData = NULL;
@@ -985,7 +671,7 @@ openOutput(char const* pzFile)
exit(EXIT_FAILURE);
}
- pzData = AGALOC(stbf.st_size + 1, "file data");
+ pzData = AGALOC(stbf.st_size + 1, "f data");
fp = fopen(pzFile, "r" FOPEN_BINARY_FLAG);
sizeLeft = (unsigned)stbf.st_size;
@@ -1009,18 +695,18 @@ openOutput(char const* pzFile)
/*
* NUL-terminate the leader and look for the trailer
*/
- *pzScan = '\0';
+ *pzScan = NUL;
fclose(fp);
- pzScan = strstr(pzData, zStartMarker);
+ pzScan = strstr(pzData, START_MARK);
if (pzScan == NULL) {
- pzTrailer = pzData;
+ script_trailer = pzData;
break;
}
*(pzScan++) = NUL;
- pzScan = strstr(pzScan, zTrailerMarker);
+ pzScan = strstr(pzScan, END_MARK);
if (pzScan == NULL) {
- pzTrailer = pzData;
+ script_trailer = pzData;
break;
}
@@ -1028,8 +714,8 @@ openOutput(char const* pzFile)
* Check to see if the data contains our marker.
* If it does, then we will skip over it
*/
- pzTrailer = pzScan + sizeof(zTrailerMarker) - 1;
- pzLeader = pzData;
+ script_trailer = pzScan + END_MARK_LEN;
+ script_leader = pzData;
} while (AG_FALSE);
if (freopen(pzFile, "w" FOPEN_BINARY_FLAG, stdout) != stdout) {
@@ -1100,7 +786,7 @@ genshelloptUsage(tOptions * pOpts, int exitCode)
{
char * pz;
char ** pp = (char **)(void *)&(optionParseShellOptions->pzProgName);
- AGDUPSTR(pz, optionParseShellOptions->pzPROGNAME, "program name");
+ AGDUPSTR(pz, optionParseShellOptions->pzPROGNAME, "prog name");
*pp = pz;
while (*pz != NUL) {
*pz = tolower(*pz);
diff --git a/src/libopts/nested.c b/src/libopts/nested.c
index f9f7e7ae7b..b7f15866e1 100644
--- a/src/libopts/nested.c
+++ b/src/libopts/nested.c
@@ -2,13 +2,13 @@
/**
* \file nested.c
*
- * Time-stamp: "2010-08-22 11:17:56 bkorb"
+ * Time-stamp: "2012-01-29 07:00:04 bkorb"
*
* Automated Options Nested Values module.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -41,6 +41,10 @@ static xml_xlate_t const xml_xlate[] = {
{ '\'',5, "apos;" }
};
+#ifndef ENOMSG
+#define ENOMSG ENOENT
+#endif
+
/* = = = START-STATIC-FORWARD = = = */
static void
remove_continuation(char* pzSrc);
@@ -48,12 +52,12 @@ remove_continuation(char* pzSrc);
static char const*
scan_q_str(char const* pzTxt);
-static tOptionValue*
-add_string(void** pp, char const* pzName, size_t nameLen,
- char const* pzValue, size_t dataLen);
+static tOptionValue *
+add_string(void ** pp, char const * pzName, size_t nameLen,
+ char const* pzValue, size_t dataLen);
-static tOptionValue*
-add_bool(void** pp, char const* pzName, size_t nameLen,
+static tOptionValue *
+add_bool(void ** pp, char const * pzName, size_t nameLen,
char const* pzValue, size_t dataLen);
static tOptionValue*
@@ -84,8 +88,8 @@ remove_continuation(char* pzSrc)
char* pzD;
do {
- while (*pzSrc == '\n') pzSrc++;
- pzD = strchr(pzSrc, '\n');
+ while (*pzSrc == NL) pzSrc++;
+ pzD = strchr(pzSrc, NL);
if (pzD == NULL)
return;
@@ -107,7 +111,7 @@ remove_continuation(char* pzSrc)
switch (ch) {
case NUL: return;
case '\\':
- if (*pzSrc == '\n')
+ if (*pzSrc == NL)
--pzD; /* rewrite on next iteration */
}
}
@@ -153,9 +157,9 @@ scan_q_str(char const* pzTxt)
/**
* Associate a name with either a string or no value.
*/
-static tOptionValue*
-add_string(void** pp, char const* pzName, size_t nameLen,
- char const* pzValue, size_t dataLen)
+static tOptionValue *
+add_string(void ** pp, char const * pzName, size_t nameLen,
+ char const* pzValue, size_t dataLen)
{
tOptionValue* pNV;
size_t sz = nameLen + dataLen + sizeof(*pNV);
@@ -179,7 +183,7 @@ add_string(void** pp, char const* pzName, size_t nameLen,
if (ch == NUL) goto data_copy_done;
if (ch == '&')
ch = get_special_char(&pzSrc, &ct);
- *(pzDst++) = ch;
+ *(pzDst++) = (char)ch;
} while (--ct > 0);
data_copy_done:
*pzDst = NUL;
@@ -200,19 +204,23 @@ add_string(void** pp, char const* pzName, size_t nameLen,
/**
* Associate a name with either a string or no value.
*/
-static tOptionValue*
-add_bool(void** pp, char const* pzName, size_t nameLen,
+static tOptionValue *
+add_bool(void ** pp, char const * pzName, size_t nameLen,
char const* pzValue, size_t dataLen)
{
- tOptionValue* pNV;
- size_t sz = nameLen + sizeof(*pNV) + 1;
+ tOptionValue * pNV;
- pNV = AGALOC(sz, "option name/bool value pair");
- if (pNV == NULL)
- return NULL;
- while (IS_WHITESPACE_CHAR(*pzValue) && (dataLen > 0)) {
- dataLen--; pzValue++;
+ {
+ size_t sz = nameLen + sizeof(tOptionValue) + 1;
+ pNV = AGALOC(sz, "name/bool value");
}
+
+ {
+ char * p = SPN_WHITESPACE_CHARS(pzValue);
+ dataLen -= p - pzValue;
+ pzValue = p;
+ }
+
if (dataLen == 0)
pNV->v.boolVal = 0;
@@ -305,21 +313,24 @@ scan_name(char const* pzName, tOptionValue* pRes)
* Scan over characters that name a value. These names may not end
* with a colon, but they may contain colons.
*/
- while (IS_VALUE_NAME_CHAR(*pzScan)) { pzScan++; nameLen++; }
- if (pzScan[-1] == ':') { pzScan--; nameLen--; }
- while (IS_HORIZ_WHITE_CHAR(*pzScan)) pzScan++;
+ pzScan = SPN_VALUE_NAME_CHARS(pzName + 1);
+ if (pzScan[-1] == ':')
+ pzScan--;
+ nameLen = pzScan - pzName;
+
+ pzScan = SPN_HORIZ_WHITE_CHARS(pzScan);
re_switch:
switch (*pzScan) {
case '=':
case ':':
- while (IS_HORIZ_WHITE_CHAR((int)*++pzScan)) ;
+ pzScan = SPN_HORIZ_WHITE_CHARS(pzScan + 1);
if ((*pzScan == '=') || (*pzScan == ':'))
goto default_char;
goto re_switch;
- case '\n':
+ case NL:
case ',':
pzScan++;
/* FALLTHROUGH */
@@ -334,7 +345,7 @@ scan_name(char const* pzName, tOptionValue* pRes)
pzScan = scan_q_str(pzScan);
dataLen = pzScan - pzVal;
pNV = add_string(&(pRes->v.nestVal), pzName, nameLen, pzVal,
- dataLen);
+ dataLen);
if ((pNV != NULL) && (option_load_mode == OPTION_LOAD_COOKED))
ao_string_cook(pNV->v.strVal, NULL);
break;
@@ -355,7 +366,7 @@ scan_name(char const* pzName, tOptionValue* pRes)
goto string_done;
/* FALLTHROUGH */
- case '\n':
+ case NL:
if ( (pzScan > pzVal + 2)
&& (pzScan[-2] == '\\')
&& (pzScan[ 0] != NUL))
@@ -611,7 +622,7 @@ sort_list(tArgList* pAL)
}
}
-/* optionLoadNested
+/*=
* private:
*
* what: parse a hierarchical option argument
@@ -626,7 +637,17 @@ sort_list(tArgList* pAL)
* A block of text represents a series of values. It may be an
* entire configuration file, or it may be an argument to an
* option that takes a hierarchical value.
- */
+ *
+ * If NULL is returned, errno will be set:
+ * @itemize @bullet
+ * @item
+ * @code{EINVAL} the input text was NULL.
+ * @item
+ * @code{ENOMEM} the storage structures could not be allocated
+ * @item
+ * @code{ENOMSG} no configuration values were found
+ * @end itemize
+=*/
LOCAL tOptionValue*
optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
{
@@ -639,9 +660,9 @@ optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
errno = EINVAL;
return NULL;
}
- while (IS_WHITESPACE_CHAR(*pzTxt)) pzTxt++;
+ pzTxt = SPN_WHITESPACE_CHARS(pzTxt);
if (*pzTxt == NUL) {
- errno = ENOENT;
+ errno = ENOMSG;
return NULL;
}
pRes = AGALOC(sizeof(*pRes) + nameLen + 1, "nested args");
@@ -670,23 +691,27 @@ optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
* Scan until we hit a NUL.
*/
do {
- while (IS_WHITESPACE_CHAR((int)*pzTxt)) pzTxt++;
- if (IS_VAR_FIRST_CHAR((int)*pzTxt)) {
+ pzTxt = SPN_WHITESPACE_CHARS(pzTxt);
+ if (IS_VAR_FIRST_CHAR(*pzTxt))
pzTxt = scan_name(pzTxt, pRes);
- }
+
else switch (*pzTxt) {
case NUL: goto scan_done;
case '<': pzTxt = scan_xml(pzTxt, pRes);
if (pzTxt == NULL) goto woops;
if (*pzTxt == ',') pzTxt++; break;
- case '#': pzTxt = strchr(pzTxt, '\n'); break;
+ case '#': pzTxt = strchr(pzTxt, NL); break;
default: goto woops;
}
} while (pzTxt != NULL); scan_done:;
{
tArgList * al = pRes->v.nestVal;
- if (al->useCt != 0)
+ if (al->useCt == 0) {
+ errno = ENOMSG;
+ goto woops;
+ }
+ if (al->useCt > 1)
sort_list(al);
}
@@ -811,7 +836,7 @@ emit_special_char(FILE * fp, int ch)
break;
xlatp++;
}
- fprintf(fp, "#x%02X;", (ch & 0xFF));
+ fprintf(fp, XML_HEX_BYTE_FMT, (ch & 0xFF));
}
/*
diff --git a/src/libopts/numeric.c b/src/libopts/numeric.c
index ff6b2a50f2..c6e6ba7007 100644
--- a/src/libopts/numeric.c
+++ b/src/libopts/numeric.c
@@ -2,11 +2,11 @@
/**
* \file numeric.c
*
- * Time-stamp: "2011-03-25 16:26:10 bkorb"
+ * Time-stamp: "2012-01-29 19:10:40 bkorb"
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -38,15 +38,11 @@
* Show information about a numeric option with range constraints.
=*/
void
-optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct)
+optionShowRange(tOptions * pOpts, tOptDesc * pOD, void * rng_table, int rng_ct)
{
- static char const bullet[] = "\t\t\t\t- ";
- static char const deepin[] = "\t\t\t\t ";
- static char const onetab[] = "\t";
-
const struct {long const rmin, rmax;} * rng = rng_table;
- char const * pz_indent = bullet;
+ char const * pz_indent = BULLET_STR;
/*
* The range is shown only for full usage requests and an error
@@ -55,7 +51,7 @@ optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct)
if (pOpts != OPTPROC_EMIT_USAGE) {
if (pOpts <= OPTPROC_EMIT_LIMIT)
return;
- pz_indent = onetab;
+ pz_indent = ONE_TAB_STR;
fprintf(option_usage_fp, zRangeErr, pOpts->pzProgName,
pOD->pz_Name, pOD->optArg.argString);
@@ -66,7 +62,7 @@ optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct)
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;
+ pz_indent = (pOpts != OPTPROC_EMIT_USAGE) ? ONE_TAB_STR : DEEP_INDENT_STR;
for (;;) {
if (rng->rmax == LONG_MIN)
@@ -80,7 +76,7 @@ optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct)
rng->rmax);
if (--rng_ct <= 0) {
- fputc('\n', option_usage_fp);
+ fputc(NL, option_usage_fp);
break;
}
fputs(zRangeOr, option_usage_fp);
@@ -125,7 +121,7 @@ optionNumericVal(tOptions* pOpts, tOptDesc* pOD )
if ((pOD->fOptState & OPTST_SCALED_NUM) != 0)
switch (*(pz++)) {
- case '\0': pz--; break;
+ case NUL: pz--; break;
case 't': val *= 1000;
case 'g': val *= 1000;
case 'm': val *= 1000;
diff --git a/src/libopts/parse-duration.c b/src/libopts/parse-duration.c
index 0a8c4ada84..e49060aec3 100644
--- a/src/libopts/parse-duration.c
+++ b/src/libopts/parse-duration.c
@@ -1,5 +1,5 @@
/* Parse a time duration and return a seconds count
- Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ Copyright (C) 2008-2012 Free Software Foundation, Inc.
Written by Bruce Korb <bkorb@gnu.org>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/src/libopts/parse-duration.h b/src/libopts/parse-duration.h
index 9fd2a364cd..caefb759b4 100644
--- a/src/libopts/parse-duration.h
+++ b/src/libopts/parse-duration.h
@@ -1,5 +1,5 @@
/* Parse a time duration and return a seconds count
- Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ Copyright (C) 2008-2012 Free Software Foundation, Inc.
Written by Bruce Korb <bkorb@gnu.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@
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.
+ The embedded 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.
diff --git a/src/libopts/pgusage.c b/src/libopts/pgusage.c
index 2e2194867e..4dbbd53be1 100644
--- a/src/libopts/pgusage.c
+++ b/src/libopts/pgusage.c
@@ -2,7 +2,7 @@
/**
* \file pgusage.c
*
- * Time-stamp: "2011-03-25 17:54:41 bkorb"
+ * Time-stamp: "2012-01-29 16:09:14 bkorb"
*
* Automated Options Paged Usage module.
*
@@ -11,7 +11,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -67,9 +67,9 @@ optionPagedUsage(tOptions* pOptions, tOptDesc* pOD)
my_pid = getpid();
#ifdef HAVE_SNPRINTF
- snprintf(zPageUsage, sizeof(zPageUsage), "/tmp/use.%lu", (tAoUL)my_pid);
+ snprintf(zPageUsage, sizeof(zPageUsage), TMP_USAGE_FMT, (tAoUL)my_pid);
#else
- sprintf(zPageUsage, "/tmp/use.%lu", (tAoUL)my_pid);
+ sprintf(zPageUsage, TMP_USAGE_FMT, (tAoUL)my_pid);
#endif
unlink(zPageUsage);
@@ -99,22 +99,21 @@ optionPagedUsage(tOptions* pOptions, tOptDesc* pOD)
case PAGER_STATE_READY:
{
- tSCC zPage[] = "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu";
- tCC* pzPager = (tCC*)getenv("PAGER");
+ tCC* pzPager = (tCC*)getenv(PAGER_NAME);
/*
* Use the "more(1)" program if "PAGER" has not been defined
*/
if (pzPager == NULL)
- pzPager = "more";
+ pzPager = MORE_STR;
/*
* Page the file and remove it when done.
*/
#ifdef HAVE_SNPRINTF
- snprintf(zPageUsage, sizeof(zPageUsage), zPage, pzPager, (tAoUL)my_pid);
+ snprintf(zPageUsage, sizeof(zPageUsage), PAGE_USAGE_FMT, pzPager, (tAoUL)my_pid);
#else
- sprintf(zPageUsage, zPage, pzPager, (tAoUL)my_pid);
+ sprintf(zPageUsage, PAGE_USAGE_FMT, pzPager, (tAoUL)my_pid);
#endif
fclose(stderr);
dup2(STDOUT_FILENO, STDERR_FILENO);
diff --git a/src/libopts/proto.h b/src/libopts/proto.h
index 48746f19f6..3f77b2cfc5 100644
--- a/src/libopts/proto.h
+++ b/src/libopts/proto.h
@@ -1,7 +1,7 @@
/* -*- buffer-read-only: t -*- vi: set ro:
*
* Prototypes for autoopts
- * Generated Thu Dec 29 12:02:41 PST 2011
+ * Generated Fri Feb 10 19:53:45 PST 2012
*/
#ifndef AUTOOPTS_PROTO_H_GUARD
#define AUTOOPTS_PROTO_H_GUARD 1
diff --git a/src/libopts/putshell.c b/src/libopts/putshell.c
index f15284f6b9..10d14bd9af 100644
--- a/src/libopts/putshell.c
+++ b/src/libopts/putshell.c
@@ -2,7 +2,7 @@
/**
* \file putshell.c
*
- * Time-stamp: "2010-09-05 06:10:56 bkorb"
+ * Time-stamp: "2012-02-10 19:14:49 bkorb"
*
* This module will interpret the options set in the tOptions
* structure and print them to standard out in a fashion that
@@ -10,7 +10,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -28,13 +28,10 @@
* 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
* 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
*/
-static char const zOptValFmt[] = "%s_%s=";
-static char const zOptEnd[] = "\nexport %s_%s\n";
-static char const zOptNumFmt[] = "%1$s_%2$s=%3$d # 0x%3$X\nexport %1$s_%2$s\n";
/* = = = START-STATIC-FORWARD = = = */
static void
-print_quot_str(tCC* pzStr);
+print_quot_str(char const * pzStr);
static void
print_enumeration(tOptions * pOpts, tOptDesc * pOD);
@@ -54,13 +51,13 @@ print_reordering(tOptions * pOpts);
* been emitted and the closing quote will be upon return.
*/
static void
-print_quot_str(tCC* pzStr)
+print_quot_str(char const * pzStr)
{
/*
* Handle empty strings to make the rest of the logic simpler.
*/
if ((pzStr == NULL) || (*pzStr == NUL)) {
- fputs("''", stdout);
+ fputs(EMPTY_ARG, stdout);
return;
}
@@ -69,7 +66,7 @@ print_quot_str(tCC* pzStr)
* bail if that is all we need to do.
*/
while (*pzStr == '\'') {
- fputs("\\'", stdout);
+ fputs(QUOT_APOS, stdout);
pzStr++;
}
if (*pzStr == NUL)
@@ -80,7 +77,7 @@ print_quot_str(tCC* pzStr)
*/
fputc('\'', stdout);
for (;;) {
- tCC* pz = strchr(pzStr, '\'');
+ char const * pz = strchr(pzStr, '\'');
if (pz == NULL)
break;
@@ -114,18 +111,18 @@ static void
print_enumeration(tOptions * pOpts, tOptDesc * pOD)
{
uintptr_t e_val = pOD->optArg.argEnum;
- printf(zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME);
+ printf(OPT_VAL_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
/*
* Convert value to string, print that and restore numeric value.
*/
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
- printf("'%s'", pOD->optArg.argString);
+ printf(QUOT_ARG_FMT, pOD->optArg.argString);
if (pOD->fOptState & OPTST_ALLOC_ARG)
AGFREE(pOD->optArg.argString);
pOD->optArg.argEnum = e_val;
- printf(zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME);
+ printf(OPT_END_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
}
static void
@@ -155,7 +152,7 @@ print_membership(tOptions * pOpts, tOptDesc * pOD)
else if (ch == NUL) { pz--; goto name_done; }
else fputc('_', stdout);
} name_done:;
- printf("=%1$lu # 0x%1$lX\n", (unsigned long)val);
+ printf(SHOW_VAL_FMT, (unsigned long)val);
val <<= 1;
}
@@ -167,8 +164,6 @@ print_membership(tOptions * pOpts, tOptDesc * pOD)
static void
print_stacked_arg(tOptions * pOpts, tOptDesc * pOD)
{
- tSCC zOptCookieCt[] = "%1$s_%2$s_CT=%3$d\nexport %1$s_%2$s_CT\n";
-
tArgList* pAL = (tArgList*)pOD->optCookie;
tCC** ppz = pAL->apzArgs;
int ct = pAL->useCt;
@@ -176,13 +171,10 @@ print_stacked_arg(tOptions * pOpts, tOptDesc * pOD)
printf(zOptCookieCt, pOpts->pzPROGNAME, pOD->pz_NAME, ct);
while (--ct >= 0) {
- tSCC numarg_z[] = "%s_%s_%d=";
- tSCC end_z[] = "\nexport %s_%s_%d\n";
-
- printf(numarg_z, pOpts->pzPROGNAME, pOD->pz_NAME,
+ printf(ARG_BY_NUM_FMT, pOpts->pzPROGNAME, pOD->pz_NAME,
pAL->useCt - ct);
print_quot_str(*(ppz++));
- printf(end_z, pOpts->pzPROGNAME, pOD->pz_NAME,
+ printf(EXPORT_ARG_FMT, pOpts->pzPROGNAME, pOD->pz_NAME,
pAL->useCt - ct);
}
}
@@ -192,21 +184,21 @@ print_reordering(tOptions * pOpts)
{
int optIx;
- fputs("set --", stdout);
+ fputs(set_dash, stdout);
for (optIx = pOpts->curOptIdx; optIx < pOpts->origArgCt; optIx++) {
char* pzArg = pOpts->origArgVect[ optIx ];
if (strchr(pzArg, '\'') == NULL)
- printf(" '%s'", pzArg);
+ printf(arg_fmt, pzArg);
else {
fputs(" '", stdout);
for (;;) {
char ch = *(pzArg++);
switch (ch) {
- case '\'': fputs("'\\''", stdout); break;
+ case '\'': fputs(apostrophy, stdout); break;
case NUL: goto arg_done;
default: fputc(ch, stdout); break;
}
@@ -214,7 +206,7 @@ print_reordering(tOptions * pOpts)
fputc('\'', stdout);
}
}
- fputs("\nOPTION_CT=0\n", stdout);
+ fputs(init_optct, stdout);
}
/*=export_func optionPutShell
@@ -228,17 +220,13 @@ void
optionPutShell(tOptions* pOpts)
{
int optIx = 0;
- tSCC zOptCtFmt[] = "OPTION_CT=%d\nexport OPTION_CT\n";
- tSCC zOptDisabl[] = "%1$s_%2$s=%3$s\nexport %1$s_%2$s\n";
- tSCC zFullOptFmt[]= "%1$s_%2$s='%3$s'\nexport %1$s_%2$s\n";
- tSCC zEquivMode[] = "%1$s_%2$s_MODE='%3$s'\nexport %1$s_%2$s_MODE\n";
printf(zOptCtFmt, pOpts->curOptIdx-1);
do {
tOptDesc* pOD = pOpts->pOptDesc + optIx;
- if (SKIP_OPT(pOD))
+ if ((pOD->fOptState & OPTST_NO_OUTPUT_MASK) != 0)
continue;
/*
@@ -281,9 +269,8 @@ optionPutShell(tOptions* pOpts)
* The idea is that if someone defines an option to initialize
* enabled, we should tell our shell script that it is enabled.
*/
- if (UNUSED_OPT(pOD) && DISABLED_OPT(pOD)) {
+ if (UNUSED_OPT(pOD) && DISABLED_OPT(pOD))
continue;
- }
/*
* Handle stacked arguments
@@ -350,9 +337,9 @@ optionPutShell(tOptions* pOpts)
/*
* This option has a text value
*/
- printf(zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME);
+ printf(OPT_VAL_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
print_quot_str(pOD->optArg.argString);
- printf(zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME);
+ printf(OPT_END_FMT, pOpts->pzPROGNAME, pOD->pz_NAME);
} while (++optIx < pOpts->presetOptCt );
diff --git a/src/libopts/reset.c b/src/libopts/reset.c
index 59850fe76f..2345d51e3c 100644
--- a/src/libopts/reset.c
+++ b/src/libopts/reset.c
@@ -6,7 +6,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/restore.c b/src/libopts/restore.c
index f55f3d2499..4fd76f88e1 100644
--- a/src/libopts/restore.c
+++ b/src/libopts/restore.c
@@ -10,7 +10,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/save.c b/src/libopts/save.c
index 9c36bc83fd..a1357ffece 100644
--- a/src/libopts/save.c
+++ b/src/libopts/save.c
@@ -2,7 +2,7 @@
/*
* \file save.c
*
- * Time-stamp: "2011-04-06 09:21:44 bkorb"
+ * Time-stamp: "2012-01-29 19:30:39 bkorb"
*
* This module's routines will take the currently set options and
* store them into an ".rc" file for re-interpretation the next
@@ -10,7 +10,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -29,57 +29,51 @@
* 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
*/
-static char const zWarn[] = "%s WARNING: cannot save options - ";
-static char const close_xml[] = "</%s>\n";
-
/* = = = START-STATIC-FORWARD = = = */
-static tCC*
-findDirName(tOptions* pOpts, int* p_free);
+static char const *
+find_dir_name(tOptions * pOpts, int * p_free);
static char const *
-findFileName(tOptions * pOpts, int * p_free_name);
+find_file_name(tOptions * pOpts, int * p_free_name);
static void
-printEntry(
- FILE * fp,
- tOptDesc * p,
- tCC* pzLA );
+prt_entry(FILE * fp, tOptDesc * p, char const * pzLA);
static void
-print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp);
+prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp);
static void
-print_a_string(FILE * fp, char const * name, char const * pz);
+prt_string(FILE * fp, char const * name, char const * pz);
static void
-printValueList(FILE * fp, char const * name, tArgList * al);
+prt_val_list(FILE * fp, char const * name, tArgList * al);
static void
-printHierarchy(FILE * fp, tOptDesc * p);
+prt_nested(FILE * fp, tOptDesc * p);
static FILE *
-openSaveFile(tOptions* pOpts);
+open_sv_file(tOptions* pOpts);
static void
-printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD);
+prt_no_arg_opt(FILE * fp, tOptDesc * p, tOptDesc * pOD);
static void
-printStringArg(FILE * fp, tOptDesc * pOD);
+prt_str_arg(FILE * fp, tOptDesc * pOD);
static void
-printEnumArg(FILE * fp, tOptDesc * pOD);
+prt_enum_arg(FILE * fp, tOptDesc * pOD);
static void
-printSetMemberArg(FILE * fp, tOptDesc * pOD);
+prt_set_arg(FILE * fp, tOptDesc * pOD);
static void
-printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts);
+prt_file_arg(FILE * fp, tOptDesc * pOD, tOptions* pOpts);
/* = = = END-STATIC-FORWARD = = = */
-static tCC*
-findDirName(tOptions* pOpts, int* p_free)
+static char const *
+find_dir_name(tOptions * pOpts, int * p_free)
{
- tCC* pzDir;
+ char const * pzDir;
if ( (pOpts->specOptIdx.save_opts == NO_EQUIVALENT)
|| (pOpts->specOptIdx.save_opts == 0))
@@ -94,7 +88,7 @@ findDirName(tOptions* pOpts, int* p_free)
* we can stash the RC (INI) file.
*/
{
- tCC* const* papz = pOpts->papzHomeList;
+ char const * const* papz = pOpts->papzHomeList;
if (papz == NULL)
return NULL;
@@ -109,9 +103,9 @@ findDirName(tOptions* pOpts, int* p_free)
return pzDir;
{
- tCC* pzEndDir = strchr(++pzDir, DIRCH);
- char* pzFileName;
- char* pzEnv;
+ char const * pzEndDir = strchr(++pzDir, DIRCH);
+ char * pzFileName;
+ char * pzEnv;
if (pzEndDir != NULL) {
char z[ AO_NAME_SIZE ];
@@ -130,7 +124,7 @@ findDirName(tOptions* pOpts, int* p_free)
}
if (pzEnv == NULL) {
- fprintf(stderr, zWarn, pOpts->pzProgName);
+ fprintf(stderr, SAVE_WARN, pOpts->pzProgName);
fprintf(stderr, zNotDef, pzDir);
return NULL;
}
@@ -158,12 +152,12 @@ findDirName(tOptions* pOpts, int* p_free)
static char const *
-findFileName(tOptions * pOpts, int * p_free_name)
+find_file_name(tOptions * pOpts, int * p_free_name)
{
struct stat stBuf;
int free_dir_name = 0;
- char const * pzDir = findDirName(pOpts, &free_dir_name);
+ char const * pzDir = find_dir_name(pOpts, &free_dir_name);
if (pzDir == NULL)
return NULL;
@@ -181,7 +175,7 @@ findFileName(tOptions * pOpts, int * p_free_name)
*/
if (errno != ENOENT) {
bogus_name:
- fprintf(stderr, zWarn, pOpts->pzProgName);
+ fprintf(stderr, SAVE_WARN, pOpts->pzProgName);
fprintf(stderr, zNoStat, errno, strerror(errno), pzDir);
if (free_dir_name)
AGFREE((void*)pzDir);
@@ -217,7 +211,7 @@ findFileName(tOptions * pOpts, int * p_free_name)
size_t sz = strlen(pzDir) + strlen(pOpts->pzRcName) + 2;
{
- char* pzPath = (char*)AGALOC(sz, "file name");
+ char * pzPath = (char*)AGALOC(sz, "file name");
#ifdef HAVE_SNPRINTF
snprintf(pzPath, sz, "%s/%s", pzDir, pOpts->pzRcName);
#else
@@ -235,7 +229,7 @@ findFileName(tOptions * pOpts, int * p_free_name)
*/
if (stat(pzDir, &stBuf) != 0) {
if (errno != ENOENT) {
- fprintf(stderr, zWarn, pOpts->pzProgName);
+ fprintf(stderr, SAVE_WARN, pOpts->pzProgName);
fprintf(stderr, zNoStat, errno, strerror(errno),
pzDir);
AGFREE((void*)pzDir);
@@ -254,7 +248,7 @@ findFileName(tOptions * pOpts, int * p_free_name)
* or will soon be a file.
*/
if (! S_ISREG(stBuf.st_mode)) {
- fprintf(stderr, zWarn, pOpts->pzProgName);
+ fprintf(stderr, SAVE_WARN, pOpts->pzProgName);
fprintf(stderr, zNotFile, pzDir);
if (free_dir_name)
AGFREE((void*)pzDir);
@@ -271,10 +265,7 @@ findFileName(tOptions * pOpts, int * p_free_name)
static void
-printEntry(
- FILE * fp,
- tOptDesc * p,
- tCC* pzLA )
+prt_entry(FILE * fp, tOptDesc * p, char const * pzLA)
{
/*
* There is an argument. Pad the name so values line up.
@@ -302,12 +293,12 @@ printEntry(
* OTHERWISE, FOR each line of the value text, ...
*/
else if (pzLA == NULL)
- fputc('\n', fp);
+ fputc(NL, fp);
else {
fputc(' ', fp); fputc(' ', fp);
for (;;) {
- tCC* pzNl = strchr(pzLA, '\n');
+ char const * pzNl = strchr(pzLA, NL);
/*
* IF this is the last line
@@ -328,30 +319,25 @@ printEntry(
* Terminate the entry
*/
fputs(pzLA, fp);
- fputc('\n', fp);
+ fputc(NL, fp);
}
}
static void
-print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
+prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
{
- static char const bool_atr[] = "<%1$s type=boolean>%2$s</%1$s>\n";
- static char const numb_atr[] = "<%1$s type=integer>0x%2$lX</%1$s>\n";
- static char const type_atr[] = "<%s type=%s>";
- static char const null_atr[] = "<%s/>\n";
-
while (--depth >= 0)
putc(' ', fp), putc(' ', fp);
switch (ovp->valType) {
default:
case OPARG_TYPE_NONE:
- fprintf(fp, null_atr, ovp->pzName);
+ fprintf(fp, NULL_ATR_FMT, ovp->pzName);
break;
case OPARG_TYPE_STRING:
- print_a_string(fp, ovp->pzName, ovp->v.strVal);
+ prt_string(fp, ovp->pzName, ovp->v.strVal);
break;
case OPARG_TYPE_ENUMERATION:
@@ -362,7 +348,7 @@ print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
char const * typ = (ovp->valType == OPARG_TYPE_ENUMERATION)
? "keyword" : "set-membership";
- fprintf(fp, type_atr, ovp->pzName, typ);
+ fprintf(fp, TYPE_ATR_FMT, ovp->pzName, typ);
/*
* This is a magic incantation that will convert the
@@ -382,33 +368,31 @@ print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
pOD->optArg.argEnum = val;
pOD->fOptState = opt_state;
- fprintf(fp, close_xml, ovp->pzName);
+ fprintf(fp, END_XML_FMT, ovp->pzName);
break;
}
/* FALLTHROUGH */
case OPARG_TYPE_NUMERIC:
- fprintf(fp, numb_atr, ovp->pzName, ovp->v.longVal);
+ fprintf(fp, NUMB_ATR_FMT, ovp->pzName, ovp->v.longVal);
break;
case OPARG_TYPE_BOOLEAN:
- fprintf(fp, bool_atr, ovp->pzName,
+ fprintf(fp, BOOL_ATR_FMT, ovp->pzName,
ovp->v.boolVal ? "true" : "false");
break;
case OPARG_TYPE_HIERARCHY:
- printValueList(fp, ovp->pzName, ovp->v.nestVal);
+ prt_val_list(fp, ovp->pzName, ovp->v.nestVal);
break;
}
}
static void
-print_a_string(FILE * fp, char const * name, char const * pz)
+prt_string(FILE * fp, char const * name, char const * pz)
{
- static char const open_atr[] = "<%s>";
-
- fprintf(fp, open_atr, name);
+ fprintf(fp, OPEN_XML_FMT, name);
for (;;) {
int ch = ((int)*(pz++)) & 0xFF;
@@ -436,12 +420,12 @@ print_a_string(FILE * fp, char const * name, char const * pz)
putc(ch, fp);
}
} string_done:;
- fprintf(fp, close_xml, name);
+ fprintf(fp, END_XML_FMT, name);
}
static void
-printValueList(FILE * fp, char const * name, tArgList * al)
+prt_val_list(FILE * fp, char const * name, tArgList * al)
{
static int depth = 1;
@@ -455,17 +439,17 @@ printValueList(FILE * fp, char const * name, tArgList * al)
opt_list = (void **)al->apzArgs;
if (opt_ct <= 0) {
- fprintf(fp, "<%s/>\n", name);
+ fprintf(fp, OPEN_CLOSE_FMT, name);
return;
}
- fprintf(fp, "<%s type=nested>\n", name);
+ fprintf(fp, NESTED_OPT_FMT, name);
depth++;
while (--opt_ct >= 0) {
tOptionValue const * ovp = *(opt_list++);
- print_a_value(fp, depth, NULL, ovp);
+ prt_value(fp, depth, NULL, ovp);
}
depth--;
@@ -476,7 +460,7 @@ printValueList(FILE * fp, char const * name, tArgList * al)
static void
-printHierarchy(FILE * fp, tOptDesc * p)
+prt_nested(FILE * fp, tOptDesc * p)
{
int opt_ct;
tArgList * al = p->optCookie;
@@ -498,10 +482,10 @@ printHierarchy(FILE * fp, tOptDesc * p)
if (ovp == NULL)
continue;
- fprintf(fp, "<%s type=nested>\n", p->pz_Name);
+ fprintf(fp, NESTED_OPT_FMT, p->pz_Name);
do {
- print_a_value(fp, 1, p, ovp);
+ prt_value(fp, 1, p, ovp);
} while (ovp = optionNextValue(base, ovp),
ovp != NULL);
@@ -512,19 +496,19 @@ printHierarchy(FILE * fp, tOptDesc * p)
static FILE *
-openSaveFile(tOptions* pOpts)
+open_sv_file(tOptions* pOpts)
{
- FILE* fp;
+ FILE * fp;
{
int free_name = 0;
- tCC* pzFName = findFileName(pOpts, &free_name);
+ char const * pzFName = find_file_name(pOpts, &free_name);
if (pzFName == NULL)
return NULL;
fp = fopen(pzFName, "w" FOPEN_BINARY_FLAG);
if (fp == NULL) {
- fprintf(stderr, zWarn, pOpts->pzProgName);
+ fprintf(stderr, SAVE_WARN, pOpts->pzProgName);
fprintf(stderr, zNoCreat, errno, strerror(errno), pzFName);
if (free_name)
AGFREE((void*) pzFName );
@@ -536,14 +520,14 @@ openSaveFile(tOptions* pOpts)
}
{
- char const* pz = pOpts->pzUsageTitle;
+ char const * pz = pOpts->pzUsageTitle;
fputs("# ", fp);
- do { fputc(*pz, fp); } while (*(pz++) != '\n');
+ do { fputc(*pz, fp); } while (*(pz++) != NL);
}
{
time_t timeVal = time(NULL);
- char* pzTime = ctime(&timeVal);
+ char * pzTime = ctime(&timeVal);
fprintf(fp, zPresetFile, pzTime);
#ifdef HAVE_ALLOCATED_CTIME
@@ -560,7 +544,7 @@ openSaveFile(tOptions* pOpts)
}
static void
-printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD)
+prt_no_arg_opt(FILE * fp, tOptDesc * p, tOptDesc * pOD)
{
/*
* The aliased to argument indicates whether or not the option
@@ -581,12 +565,12 @@ printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD)
}
static void
-printStringArg(FILE * fp, tOptDesc * pOD)
+prt_str_arg(FILE * fp, tOptDesc * pOD)
{
if (pOD->fOptState & OPTST_STACKED) {
- tArgList* pAL = (tArgList*)pOD->optCookie;
+ tArgList * pAL = (tArgList*)pOD->optCookie;
int uct = pAL->useCt;
- tCC** ppz = pAL->apzArgs;
+ char const ** ppz = pAL->apzArgs;
/*
* un-disable multiple copies of disabled options.
@@ -595,14 +579,14 @@ printStringArg(FILE * fp, tOptDesc * pOD)
pOD->fOptState &= ~OPTST_DISABLED;
while (uct-- > 0)
- printEntry(fp, pOD, *(ppz++));
+ prt_entry(fp, pOD, *(ppz++));
} else {
- printEntry(fp, pOD, pOD->optArg.argString);
+ prt_entry(fp, pOD, pOD->optArg.argString);
}
}
static void
-printEnumArg(FILE * fp, tOptDesc * pOD)
+prt_enum_arg(FILE * fp, tOptDesc * pOD)
{
uintptr_t val = pOD->optArg.argEnum;
@@ -611,13 +595,13 @@ printEnumArg(FILE * fp, tOptDesc * pOD)
* bit flag values back into a string suitable for printing.
*/
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
- printEntry(fp, pOD, (void*)(pOD->optArg.argString));
+ prt_entry(fp, pOD, (void*)(pOD->optArg.argString));
pOD->optArg.argEnum = val;
}
static void
-printSetMemberArg(FILE * fp, tOptDesc * pOD)
+prt_set_arg(FILE * fp, tOptDesc * pOD)
{
uintptr_t val = pOD->optArg.argEnum;
@@ -626,7 +610,7 @@ printSetMemberArg(FILE * fp, tOptDesc * pOD)
* bit flag values back into a string suitable for printing.
*/
(*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
- printEntry(fp, pOD, (void*)(pOD->optArg.argString));
+ prt_entry(fp, pOD, (void*)(pOD->optArg.argString));
if (pOD->optArg.argString != NULL) {
/*
@@ -640,14 +624,14 @@ printSetMemberArg(FILE * fp, tOptDesc * pOD)
}
static void
-printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts)
+prt_file_arg(FILE * fp, tOptDesc * pOD, tOptions* pOpts)
{
/*
* If the cookie is not NULL, then it has the file name, period.
* Otherwise, if we have a non-NULL string argument, then....
*/
if (pOD->optCookie != NULL)
- printEntry(fp, pOD, pOD->optCookie);
+ prt_entry(fp, pOD, pOD->optCookie);
else if (HAS_originalOptArgArray(pOpts)) {
char const * orig =
@@ -656,7 +640,7 @@ printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts)
if (pOD->optArg.argString == orig)
return;
- printEntry(fp, pOD, pOD->optArg.argString);
+ prt_entry(fp, pOD, pOD->optArg.argString);
}
}
@@ -695,7 +679,7 @@ optionSaveFile(tOptions* pOpts)
{
tOptDesc* pOD;
int ct;
- FILE* fp = openSaveFile(pOpts);
+ FILE * fp = open_sv_file(pOpts);
if (fp == NULL)
return;
@@ -706,7 +690,7 @@ optionSaveFile(tOptions* pOpts)
ct = pOpts->presetOptCt;
pOD = pOpts->pOptDesc;
do {
- tOptDesc* p;
+ tOptDesc * p;
/*
* IF the option has not been defined
@@ -737,35 +721,35 @@ optionSaveFile(tOptions* pOpts)
switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
case OPARG_TYPE_NONE:
- printNoArgOpt(fp, p, pOD);
+ prt_no_arg_opt(fp, p, pOD);
break;
case OPARG_TYPE_NUMERIC:
- printEntry(fp, p, (void*)(p->optArg.argInt));
+ prt_entry(fp, p, (void*)(p->optArg.argInt));
break;
case OPARG_TYPE_STRING:
- printStringArg(fp, p);
+ prt_str_arg(fp, p);
break;
case OPARG_TYPE_ENUMERATION:
- printEnumArg(fp, p);
+ prt_enum_arg(fp, p);
break;
case OPARG_TYPE_MEMBERSHIP:
- printSetMemberArg(fp, p);
+ prt_set_arg(fp, p);
break;
case OPARG_TYPE_BOOLEAN:
- printEntry(fp, p, p->optArg.argBool ? "true" : "false");
+ prt_entry(fp, p, p->optArg.argBool ? "true" : "false");
break;
case OPARG_TYPE_HIERARCHY:
- printHierarchy(fp, p);
+ prt_nested(fp, p);
break;
case OPARG_TYPE_FILE:
- printFileArg(fp, p, pOpts);
+ prt_file_arg(fp, p, pOpts);
break;
default:
diff --git a/src/libopts/sort.c b/src/libopts/sort.c
index 89d716a9bb..a05588dd1b 100644
--- a/src/libopts/sort.c
+++ b/src/libopts/sort.c
@@ -8,7 +8,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
diff --git a/src/libopts/stack.c b/src/libopts/stack.c
index d930772b7d..bb962f78a2 100644
--- a/src/libopts/stack.c
+++ b/src/libopts/stack.c
@@ -2,14 +2,14 @@
/**
* \file stack.c
*
- * Time-stamp: "2010-07-17 10:42:27 bkorb"
+ * Time-stamp: "2012-01-29 09:42:12 bkorb"
*
* This is a special option processing routine that will save the
* argument to an option in a FIFO queue.
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -47,8 +47,6 @@ optionUnstackArg(
tOptions* pOpts,
tOptDesc* pOptDesc )
{
- int res;
-
tArgList* pAL;
if ((pOptDesc->fOptState & OPTST_RESET) != 0)
@@ -81,8 +79,10 @@ optionUnstackArg(
* we are keeping a define.
*/
for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) {
- tCC* pzSrc = pAL->apzArgs[ i ];
- char* pzEq = strchr(pzSrc, '=');
+ char const * pzSrc = pAL->apzArgs[ i ];
+ char * pzEq = strchr(pzSrc, '=');
+ int res;
+
if (pzEq != NULL)
*pzEq = NUL;
diff --git a/src/libopts/streqvcmp.c b/src/libopts/streqvcmp.c
index d2cb65de63..d08f9c9dc1 100644
--- a/src/libopts/streqvcmp.c
+++ b/src/libopts/streqvcmp.c
@@ -2,7 +2,7 @@
/**
* \file streqvcmp.c
*
- * Time-stamp: "2010-07-17 10:16:24 bkorb"
+ * Time-stamp: "2012-01-29 19:03:24 bkorb"
*
* String Equivalence Comparison
*
@@ -13,7 +13,7 @@
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -36,8 +36,8 @@
* based upon ascii character sequences.
*/
static unsigned char charmap[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, '\a',
- '\b', '\t', '\n', '\v', '\f', '\r', 0x0E, 0x0F,
+ NUL, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, '\a',
+ '\b', '\t', NL, '\v', '\f', '\r', 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
@@ -187,7 +187,7 @@ streqvmap(char From, char To, int ct)
if (ct == 0) {
ct = sizeof(charmap) - 1;
do {
- charmap[ ct ] = ct;
+ charmap[ct] = (unsigned char)ct;
} while (--ct >= 0);
}
@@ -196,7 +196,7 @@ streqvmap(char From, char To, int ct)
int chFrom = (int)From & 0xFF;
do {
- charmap[ chFrom ] = (unsigned)chTo;
+ charmap[chFrom] = (unsigned char)chTo;
chFrom++;
chTo++;
if ((chFrom >= sizeof(charmap)) || (chTo >= sizeof(charmap)))
diff --git a/src/libopts/text_mmap.c b/src/libopts/text_mmap.c
index e46d594690..4a7aa1a238 100644
--- a/src/libopts/text_mmap.c
+++ b/src/libopts/text_mmap.c
@@ -3,11 +3,11 @@
*
* Map a text file, ensuring the text always has an ending NUL byte.
*
- * Time-stamp: "2011-06-25 11:42:22 bkorb"
+ * Time-stamp: "2012-01-29 09:40:21 bkorb"
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -76,9 +76,11 @@
*
* @param mapinfo a structure holding everything we need to know
* about the mapping.
+ *
+ * @param pzFile name of the file, for error reporting.
*/
static void
-load_text_file(tmap_info_t * mapinfo)
+load_text_file(tmap_info_t * mapinfo, char const * pzFile)
{
#if ! defined(HAVE_MMAP)
mapinfo->txt_data = AGALOC(mapinfo->txt_size+1, "file text");
@@ -96,7 +98,7 @@ load_text_file(tmap_info_t * mapinfo)
if (rdct <= 0) {
mapinfo->txt_errno = errno;
fprintf(stderr, zFSErrReadFile,
- errno, strerror(errno), "mapped file");
+ errno, strerror(errno), pzFile);
free(mapinfo->txt_data);
return;
}
@@ -114,6 +116,8 @@ load_text_file(tmap_info_t * mapinfo)
size_t const pgsz = GETPAGESIZE();
void * map_addr = NULL;
+ (void)pzFile;
+
mapinfo->txt_full_size = (mapinfo->txt_size + pgsz) & ~(pgsz - 1);
if (mapinfo->txt_full_size == (mapinfo->txt_size + pgsz)) {
/*
@@ -297,7 +301,7 @@ text_mmap(char const * pzFile, int prot, int flags, tmap_info_t * mi)
if (mi->txt_errno != 0)
return MAP_FAILED_PTR;
- load_text_file(mi);
+ load_text_file(mi, pzFile);
if (mi->txt_errno == 0)
return mi->txt_data;
diff --git a/src/libopts/time.c b/src/libopts/time.c
index 656c78d601..7348bdb406 100644
--- a/src/libopts/time.c
+++ b/src/libopts/time.c
@@ -2,11 +2,11 @@
/**
* \file time.c
*
- * Time-stamp: "2011-03-06 11:52:23 bkorb"
+ * Time-stamp: "2012-01-29 12:52:31 bkorb"
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -55,7 +55,7 @@ optionTimeVal(tOptions * pOpts, tOptDesc * pOD)
pOD->fOptState &= ~OPTST_ALLOC_ARG;
}
- pOD->optArg.argInt = val;
+ pOD->optArg.argInt = (unsigned long)val;
}
/*=export_func optionTimeDate
diff --git a/src/libopts/tokenize.c b/src/libopts/tokenize.c
index 4ca1245cf0..ca0ad53ab3 100644
--- a/src/libopts/tokenize.c
+++ b/src/libopts/tokenize.c
@@ -1,10 +1,10 @@
/*
* This file defines the string_tokenize interface
- * Time-stamp: "2010-07-17 10:40:26 bkorb"
+ * Time-stamp: "2012-01-29 19:02:51 bkorb"
*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -87,11 +87,11 @@ copy_raw(ch_t** ppDest, char const ** ppSrc)
switch (*pSrc) {
case NUL: *ppSrc = NULL; return;
case '\r':
- if (*(++pSrc) == '\n')
+ if (*(++pSrc) == NL)
++pSrc;
continue;
- case '\n':
+ case NL:
++pSrc;
continue;
@@ -281,7 +281,7 @@ ao_string_tokenize(char const* str)
default:
str++;
- *(pzDest++) = ch;
+ *(pzDest++) = (unsigned char)ch;
}
} copy_done:;
diff --git a/src/libopts/usage.c b/src/libopts/usage.c
index e2751cb6e7..8634cfce53 100644
--- a/src/libopts/usage.c
+++ b/src/libopts/usage.c
@@ -2,7 +2,7 @@
/*
* \file usage.c
*
- * Time-stamp: "2011-11-22 11:41:18 bkorb"
+ * Time-stamp: "2012-01-29 09:57:43 bkorb"
*
* This module implements the default usage procedure for
* Automated Options. It may be overridden, of course.
@@ -16,7 +16,7 @@
/*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -248,12 +248,12 @@ print_usage_details(tOptions * opts, int exit_code)
*/
if (do_gnu_usage(opts)) {
int flen = setGnuOptFmts(opts, &pOptTitle);
- sprintf(zOptFmtLine, zFmtFmt, flen);
- fputc('\n', option_usage_fp);
+ sprintf(line_fmt_buf, zFmtFmt, flen);
+ fputc(NL, option_usage_fp);
}
else {
int flen = setStdOptFmts(opts, &pOptTitle);
- sprintf(zOptFmtLine, zFmtFmt, flen);
+ sprintf(line_fmt_buf, zFmtFmt, flen);
/*
* When we exit with EXIT_SUCCESS and the first option is a doc
@@ -716,7 +716,7 @@ prt_ini_list(char const * const * papz, ag_bool * pInitIntro,
}
}
- fputc('\n', option_usage_fp);
+ fputc(NL, option_usage_fp);
}
}
@@ -787,7 +787,7 @@ prt_one_usage(tOptions * pOptions, tOptDesc * pOD, arg_types_t * pAT)
snprintf(z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name,
(pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt);
- fprintf(option_usage_fp, zOptFmtLine, z, pOD->pzText);
+ fprintf(option_usage_fp, line_fmt_buf, z, pOD->pzText);
switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
case OPARG_TYPE_ENUMERATION:
@@ -884,7 +884,7 @@ prt_opt_usage(tOptions * pOpts, int ex_code, char const * pOptTitle)
} while (pOD++, optNo++, (--ct > 0));
- fputc('\n', option_usage_fp);
+ fputc(NL, option_usage_fp);
}
@@ -923,7 +923,7 @@ prt_prog_detail(tOptions* pOptions)
int optNo = 0;
tOptDesc* pOD = pOptions->pOptDesc;
- fputc('\n', option_usage_fp);
+ fputc(NL, option_usage_fp);
fflush(option_usage_fp);
do {
switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
diff --git a/src/libopts/value-type.h b/src/libopts/value-type.h
index 28ee23ed51..a2ca5ad566 100644
--- a/src/libopts/value-type.h
+++ b/src/libopts/value-type.h
@@ -1,5 +1,5 @@
/*
- * Generated header for gperf generated source Thu Dec 29 12:02:33 PST 2011
+ * Generated header for gperf generated source Fri Feb 10 19:53:37 PST 2012
* This file enumerates the list of names and declares the
* procedure for mapping string names to the enum value.
*/
diff --git a/src/libopts/version.c b/src/libopts/version.c
index 1ebf93f26f..24041b2013 100644
--- a/src/libopts/version.c
+++ b/src/libopts/version.c
@@ -1,6 +1,6 @@
/*
- * Time-stamp: "2011-05-02 12:04:47 bkorb"
+ * Time-stamp: "2012-01-29 19:44:24 bkorb"
*
* This module implements the default usage procedure for
* Automated Options. It may be overridden, of course.
@@ -9,7 +9,7 @@
/*
* This file is part of AutoOpts, a companion to AutoGen.
* AutoOpts is free software.
- * AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
+ * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
*
* AutoOpts is available under any one of two licenses. The license
* in use must be one of these two and the choice is under the control
@@ -46,26 +46,41 @@ optionVersion(void)
return zVersion;
}
+/**
+ * Select among various ways to emit version information.
+ *
+ * @param pOpts the option descriptor
+ * @param fp the output stream
+ */
static void
emit_simple_ver(tOptions * pOpts, FILE * fp)
{
+ /*
+ * Use the supplied string
+ */
if (pOpts->pzFullVersion != NULL)
fputs(pOpts->pzFullVersion, fp);
+ /*
+ * Extract the interesting part of the copyright string
+ */
else if (pOpts->pzCopyright != NULL) {
- char const * pe = strchr(pOpts->pzCopyright, '\n');
+ char const * pe = strchr(pOpts->pzCopyright, NL);
if (pe == NULL)
pe = pOpts->pzCopyright + strlen(pOpts->pzCopyright);
fwrite(pOpts->pzCopyright, 1, pe - pOpts->pzCopyright, fp);
}
+ /*
+ * Extract the interesting part of the usage title string
+ */
else {
- char const * pe = strchr(pOpts->pzUsageTitle, '\n');
+ char const * pe = strchr(pOpts->pzUsageTitle, NL);
if (pe == NULL)
pe = pOpts->pzUsageTitle + strlen(pOpts->pzUsageTitle);
- fwrite(pOpts->pzUsageTitle, 1, pe - pOpts->pzCopyright, fp);
+ fwrite(pOpts->pzUsageTitle, 1, pe - pOpts->pzUsageTitle, fp);
}
- fputc('\n', fp);
+ fputc(NL, fp);
}
static void
@@ -78,13 +93,13 @@ emit_copy_ver(tOptions * pOpts, FILE * fp)
fputs(pOpts->pzFullVersion, fp);
else {
- char const * pe = strchr(pOpts->pzUsageTitle, '\n');
+ char const * pe = strchr(pOpts->pzUsageTitle, NL);
if (pe == NULL)
pe = pOpts->pzUsageTitle + strlen(pOpts->pzUsageTitle);
fwrite(pOpts->pzUsageTitle, 1, pe - pOpts->pzCopyright, fp);
}
- fputc('\n', fp);
+ fputc(NL, fp);
if (HAS_pzPkgDataDir(pOpts) && (pOpts->pzPackager != NULL))
fputs(pOpts->pzPackager, fp);
@@ -98,12 +113,12 @@ emit_copy_note(tOptions * pOpts, FILE * fp)
{
if (pOpts->pzCopyright != NULL) {
fputs(pOpts->pzCopyright, fp);
- fputc('\n', fp);
+ fputc(NL, fp);
}
if (pOpts->pzCopyNotice != NULL) {
fputs(pOpts->pzCopyNotice, fp);
- fputc('\n', fp);
+ fputc(NL, fp);
}
fprintf(fp, zAO_Ver, optionVersion());
diff --git a/src/libopts/xat-attribute.h b/src/libopts/xat-attribute.h
index cbcf6e5ac4..b452b309be 100644
--- a/src/libopts/xat-attribute.h
+++ b/src/libopts/xat-attribute.h
@@ -1,5 +1,5 @@
/*
- * Generated header for gperf generated source Thu Dec 29 12:02:33 PST 2011
+ * Generated header for gperf generated source Fri Feb 10 19:53:37 PST 2012
* This file enumerates the list of names and declares the
* procedure for mapping string names to the enum value.
*/