OSSP CVS Repository

ossp - Difference in ossp-pkg/var/var.c versions 1.59 and 1.60
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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);
 }
+

CVSTrac 2.0.1