OSSP CVS Repository

ossp - Check-in [1727]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1727
Date: 2002-Jan-30 20:37:14 (local)
2002-Jan-30 19:37:14 (UTC)
User:rse
Branch:
Comment: add optional OSSP ex based exception handling support
Tickets:
Inspections:
Files:
ossp-pkg/var/acconfig.h      added-> 1.1
ossp-pkg/var/aclocal.m4      added-> 1.1
ossp-pkg/var/configure.ac      1.3 -> 1.4     4 inserted, 1 deleted
ossp-pkg/var/var.c      1.59 -> 1.60     26 inserted, 8 deleted
ossp-pkg/var/var.h      1.21 -> 1.22     4 inserted, 1 deleted

ossp-pkg/var/acconfig.h -> 1.1

*** /dev/null    Sat Nov 23 00:53:10 2024
--- -    Sat Nov 23 00:53:16 2024
***************
*** 0 ****
--- 1,4 ----
+ 
+ /* whether to use OSSP ex */
+ #undef WITH_EX
+ 


ossp-pkg/var/aclocal.m4 -> 1.1

*** /dev/null    Sat Nov 23 00:53:10 2024
--- -    Sat Nov 23 00:53:16 2024
***************
*** 0 ****
--- 1,230 ----
+ dnl ##
+ dnl ##  val - OSSP Value Library
+ dnl ##  Copyright (c) 2002 Ralf S. Engelschall <rse@engelschall.com>
+ dnl ##  Copyright (c) 2002 The OSSP Project <http://www.ossp.org/>
+ dnl ##  Copyright (c) 2002 Cable & Wireless Deutschland <http://www.cw.com/de/>
+ dnl ##
+ dnl ##  This file is part of OSSP val, a Value library which
+ dnl ##  can be found at http://www.ossp.org/pkg/val/.
+ dnl ##
+ dnl ##  Permission to use, copy, modify, and distribute this software for
+ dnl ##  any purpose with or without fee is hereby granted, provided that
+ dnl ##  the above copyright notice and this permission notice appear in all
+ dnl ##  copies.
+ dnl ##
+ dnl ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ dnl ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ dnl ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ dnl ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ dnl ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ dnl ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ dnl ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ dnl ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ dnl ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ dnl ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ dnl ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ dnl ##  SUCH DAMAGE.
+ dnl ##
+ dnl ##  aclocal.m4: GNU Autoconf local macro definitions
+ dnl ##
+ 
+ dnl ##
+ dnl ##  Check whether compiler option works
+ dnl ##
+ dnl ##  configure.in:
+ dnl ##    AC_COMPILER_OPTION(<name>, <display>, <option>,
+ dnl ##                       <action-success>, <action-failure>)
+ dnl ##
+ 
+ AC_DEFUN(AC_COMPILER_OPTION,[dnl
+ AC_MSG_CHECKING(whether compiler option(s) $2 work)
+ AC_CACHE_VAL(ac_cv_compiler_option_$1,[
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $3"
+ AC_TRY_COMPILE([],[], ac_cv_compiler_option_$1=yes, ac_cv_compiler_option_$1=no)
+ CFLAGS="$SAVE_CFLAGS"
+ ])dnl
+ if test ".$ac_cv_compiler_option_$1" = .yes; then
+     ifelse([$4], , :, [$4])
+ else
+     ifelse([$5], , :, [$5])
+ fi
+ AC_MSG_RESULT([$ac_cv_compiler_option_$1])
+ ])dnl
+ 
+ dnl ##
+ dnl ##  Debugging Support
+ dnl ##
+ dnl ##  configure.in:
+ dnl ##    AC_CHECK_DEBUGGING
+ dnl ##
+ 
+ AC_DEFUN(AC_CHECK_DEBUGGING,[dnl
+ AC_ARG_ENABLE(debug,dnl
+ [  --enable-debug          build for debugging (default=no)],
+ [dnl
+ if test ".$ac_cv_prog_gcc" = ".yes"; then
+     case "$CFLAGS" in
+         *-O* ) ;;
+            * ) CFLAGS="$CFLAGS -O2" ;;
+     esac
+     case "$CFLAGS" in
+         *-g* ) ;;
+            * ) CFLAGS="$CFLAGS -g" ;;
+     esac
+     case "$CFLAGS" in
+         *-pipe* ) ;;
+               * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
+     esac
+     AC_COMPILER_OPTION(defdbg, -DDEBUG, -DDEBUG, CFLAGS="$CFLAGS -DDEBUG")
+     AC_COMPILER_OPTION(ggdb3, -ggdb3, -ggdb3, CFLAGS="$CFLAGS -ggdb3")
+     CFLAGS="$CFLAGS -pedantic"
+     CFLAGS="$CFLAGS -Wall"
+     WMORE="-Wshadow -Wpointer-arith -Wcast-align -Winline"
+     WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
+     AC_COMPILER_OPTION(wmore, -W<xxx>, $WMORE, CFLAGS="$CFLAGS $WMORE")
+     AC_COMPILER_OPTION(wnolonglong, -Wno-long-long, -Wno-long-long, CFLAGS="$CFLAGS -Wno-long-long")
+ else
+     case "$CFLAGS" in
+         *-g* ) ;;
+            * ) CFLAGS="$CFLAGS -g" ;;
+     esac
+ fi
+ msg="enabled"
+ ],[
+ if test ".$ac_cv_prog_gcc" = ".yes"; then
+ case "$CFLAGS" in
+     *-pipe* ) ;;
+           * ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
+ esac
+ fi
+ case "$CFLAGS" in
+     *-g* ) CFLAGS=`echo "$CFLAGS" |\
+                    sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
+ esac
+ case "$CXXFLAGS" in
+     *-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
+                      sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
+ esac
+ msg=disabled
+ ])dnl
+ AC_MSG_CHECKING(for compilation debug mode)
+ AC_MSG_RESULT([$msg])
+ if test ".$msg" = .enabled; then
+     enable_shared=no
+ fi
+ ])
+ 
+ dnl ##
+ dnl ##  Check for an external/extension library.
+ dnl ##  - is aware of <libname>-config style scripts
+ dnl ##  - searches under standard paths include, lib, etc.
+ dnl ##  - searches under subareas like .libs, etc.
+ dnl ##
+ dnl ##  configure.in:
+ dnl ##      AC_CHECK_EXTLIB(<realname>, <libname>, <func>, <header>,
+ dnl ##                      [<success-action> [, <fail-action>]])
+ dnl ##  Makefile.in:
+ dnl ##      CFLAGS  = @CFLAGS@
+ dnl ##      LDFLAGS = @LDFLAGS@
+ dnl ##      LIBS    = @LIBS@
+ dnl ##  shell:
+ dnl ##      $ ./configure --with-<libname>[=DIR]
+ dnl ##
+ 
+ AC_DEFUN(AC_CHECK_EXTLIB,[dnl
+ AC_ARG_WITH($2, [dnl
+ [  --with-]m4_substr([$2[[=DIR]]                     ], 0, 19)[build with external $1 library (default=no)]], [dnl
+     if test ".$with_$2" = .yes; then
+         #   via config script in PATH
+         $2_version=`($2-config --version) 2>/dev/null`
+         if test ".$$2_version" != .; then
+             CPPFLAGS="$CPPFLAGS `$2-config --cflags`"
+             CFLAGS="$CFLAGS `$2-config --cflags`"
+             LDFLAGS="$LDFLAGS `$2-config --ldflags`"
+         fi
+     else
+         if test -d "$with_$2"; then
+             found=0
+             #   via config script
+             for dir in $with_$2/bin $with_$2; do
+                 if test -f "$dir/$2-config" && test ! -f "$dir/$2-config.in"; then
+                     $2_version=`($dir/$2-config --version) 2>/dev/null`
+                     if test ".$$2_version" != .; then
+                         CPPFLAGS="$CPPFLAGS `$dir/$2-config --cflags`"
+                         CFLAGS="$CFLAGS `$dir/$2-config --cflags`"
+                         LDFLAGS="$LDFLAGS `$dir/$2-config --ldflags`"
+                         found=1
+                         break
+                     fi
+                 fi
+             done
+             #   in standard sub-areas
+             if test ".$found" = .0; then
+                 for dir in $with_$2/include/$2 $with_$2/include $with_$2; do
+                     if test -f "$dir/$4"; then
+                         CPPFLAGS="$CPPFLAGS -I$dir"
+                         CFLAGS="$CFLAGS -I$dir"
+                         found=1
+                         break
+                     fi
+                 done
+                 for dir in $with_$2/lib/$2 $with_$2/lib $with_$2; do
+                     if test -f "$dir/lib$2.la" && test -d "$dir/.libs"; then
+                         LDFLAGS="$LDFLAGS -L$dir -L$dir/.libs"
+                         found=1
+                         break
+                     elif test -f "$dir/lib$2.a" || test -f "$dir/lib$2.so"; then
+                         LDFLAGS="$LDFLAGS -L$dir"
+                         found=1
+                         break
+                     fi
+                 done
+             fi
+             #   in any sub-area
+             if test ".$found" = .0; then
+ changequote(, )dnl
+                 for file in x `find $with_$2 -name "$4" -type f -print`; do
+                     test .$file = .x && continue
+                     dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
+                     CPPFLAGS="$CPPFLAGS -I$dir"
+                     CFLAGS="$CFLAGS -I$dir"
+                 done
+                 for file in x `find $with_$2 -name "lib$2.[aso]" -type f -print`; do
+                     test .$file = .x && continue
+                     dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
+                     LDFLAGS="$LDFLAGS -L$dir"
+                 done
+ changequote([, ])dnl
+             fi
+         fi
+     fi
+     AC_HAVE_HEADERS($4)
+     AC_CHECK_LIB($2, $3)
+     with_$2=yes
+     ac_var="ac_cv_header_`echo $4 | sed 'y%./+-%__p_%'`"
+     eval "ac_val=\$$ac_var"
+     if test ".$ac_val" != .yes; then
+         with_$2=no
+     fi
+     if test ".$ac_cv_lib_$2_$3" != .yes; then
+         with_$2=no
+     fi
+     if test ".$with_$2" = .no; then
+         AC_ERROR([Unable to find $1 library])
+     fi
+     ], [dnl
+ if test ".$with_$2" = .; then
+     with_$2=no
+ fi
+     ])dnl
+ AC_MSG_CHECKING(whether to build against external $1 library)
+ if test ".$with_$2" = .yes; then
+     ifelse([$5], , :, [$5])
+ else
+     ifelse([$6], , :, [$6])
+ fi
+ AC_MSG_RESULT([$with_$2])
+ ])dnl
+ 
+ 


ossp-pkg/var/configure.ac 1.3 -> 1.4

--- configure.ac 2002/01/02 17:12:18     1.3
+++ configure.ac 2002/01/30 19:37:14     1.4
@@ -33,15 +33,18 @@
 
 AC_DIVERT_PUSH(NOTICE)
 V=`./shtool version -l txt -d long VERSION`
-./shtool echo -e "Configuring %BOSSP Var%b (Variable Expansion), Version %B${V}%b"
+./shtool echo -e "Configuring %BOSSP var%b (Variable Expansion Library), Version %B${V}%b"
 AC_DIVERT_POP()
 
 AC_SET_MAKE
 AC_PROG_CC
+AC_CHECK_DEBUGGING
 
 sinclude(libtool.m4)
 AC_PROG_LIBTOOL
 
+AC_CHECK_EXTLIB([OSSP ex], ex, __ex_ctx, ex.h, [AC_DEFINE(WITH_EX)])
+
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES(Makefile var-config)
 AC_OUTPUT


ossp-pkg/var/var.c 1.59 -> 1.60

--- var.c        2002/01/09 11:27:07     1.59
+++ var.c        2002/01/30 19:37:14     1.60
@@ -27,6 +27,10 @@
 **  var.c: VAR library implementation.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <ctype.h>
 #include <string.h>
 #include <stdio.h>
@@ -39,6 +43,19 @@
 #endif
 #include "var.h"
 
+/* unique library identifier */
+const char var_id[] = "OSSP var";
+        
+/* support for OSSP ex based exception throwing */
+#ifdef WITH_EX
+#include "ex.h"
+#define VAR_RC(rv) \
+    (  (rv) != VAR_OK && (ex_catching && !ex_shielding) \
+     ? (ex_throw(var_id, NULL, (rv)), (rv)) : (rv) )
+#else
+#define VAR_RC(rv) (rv)
+#endif /* WITH_EX */
+
 /* The default configuration for the parser. */
 
 const var_config_t var_config_default = {
@@ -54,7 +71,7 @@
 
 /* The var_strerror() routine will map a var_rc_t into a text message. */
 
-const char* var_strerror(var_rc_t rc)
+const char *var_strerror(var_rc_t rc)
 {
     static char *var_errors[] = {
         "OK",                                                                   /* VAR_OK = 0 */
@@ -377,7 +394,7 @@
     while (src < end) {
         if (*src == '\\') {
             if (++src == end)
-                return VAR_ERR_INCOMPLETE_NAMED_CHARACTER;
+                return VAR_RC(VAR_ERR_INCOMPLETE_NAMED_CHARACTER);
             switch (*src) {
             case '\\':
                 if (!unescape_all) {
@@ -397,7 +414,7 @@
             case 'x':
                 ++src;
                 if ((rc = expand_hex(&src, &dst, end)) != VAR_OK)
-                    return rc;
+                    return VAR_RC(rc);
                 break;
             case '0':
             case '1':
@@ -411,7 +428,7 @@
             case '9':
                 if (end - src >= 3 && isdigit((int)src[1]) && isdigit((int)src[2])) {
                     if ((rc = expand_octal(&src, &dst, end)) != 0)
-                        return rc;
+                        return VAR_RC(rc);
                     break;
                 }
             default:
@@ -2038,7 +2055,7 @@
     if (input_buf == NULL || input_len == 0 ||
         result == NULL ||
         lookup == NULL)
-        return VAR_ERR_INVALID_ARGUMENT;
+        return VAR_RC(VAR_ERR_INVALID_ARGUMENT);
 
     /* Optionally use default configuration */
     if (config == NULL)
@@ -2050,7 +2067,7 @@
 
     /* Expand the class description for valid variable names. */
     if ((rc = expand_character_class(config->namechars, nameclass)) != VAR_OK)
-        return rc;
+        return VAR_RC(rc);
 
     /* Make sure that the specials defined in the configuration do not
        appear in the character name class. */
@@ -2058,7 +2075,7 @@
         nameclass[(int)config->startdelim] ||
         nameclass[(int)config->enddelim] ||
         nameclass[(int)config->escape])
-        return VAR_ERR_INVALID_CONFIGURATION;
+        return VAR_RC(VAR_ERR_INVALID_CONFIGURATION);
 
     /* Call the parser. */
     tokenbuf_init(&output);
@@ -2089,5 +2106,6 @@
             *result_len = output.end - output.begin;
     }
 
-    return rc;
+    return VAR_RC(rc);
 }
+


ossp-pkg/var/var.h 1.21 -> 1.22

--- var.h        2002/01/02 17:12:18     1.21
+++ var.h        2002/01/30 19:37:14     1.22
@@ -116,7 +116,10 @@
 
 /* Map an error code to a text message. */
 
-const char* var_strerror(var_rc_t rc);
+const char *var_strerror(var_rc_t rc);
+
+/* unique library identifier */
+extern const char var_id[];
 
 #endif /* __VAR_H__ */
 

CVSTrac 2.0.1