OSSP CVS Repository

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

Check-in Number: 1362
Date: 2001-Nov-19 15:10:48 (local)
2001-Nov-19 14:10:48 (UTC)
User:simons
Branch:
Comment: Implemented the error-reporting semantics specified in the man page: If var_expand() fails with an error, "result" will contain a pointer to the construct in the input buffer, which's expansion caused the failure.
Tickets:
Inspections:
Files:
ossp-pkg/var/var.c      1.20 -> 1.21     8 inserted, 7 deleted

ossp-pkg/var/var.c 1.20 -> 1.21

--- var.c        2001/11/16 16:01:20     1.20
+++ var.c        2001/11/19 14:10:48     1.21
@@ -1512,6 +1512,7 @@
                       void *lookup_context, int force_expand,
                       tokenbuf_t *output)
 {
+    const char* p = begin;
     int rc;
     tokenbuf_t result;
 
@@ -1550,7 +1551,11 @@
     return VAR_OK;
 
   error_return:
+    tokenbuf_free(output);
     tokenbuf_free(&result);
+    output->begin = p;
+    output->end = begin;
+    output->buffer_size = 0;
     return rc;
 }
 
@@ -1587,13 +1592,9 @@
 
     /* Call the parser. */
     tokenbuf_init(&output);
-    if ((rc = input(input_buf, input_buf + input_len, config, nameclass,
-                    lookup, lookup_context, force_expand, &output)) != VAR_OK) {
-        tokenbuf_free(&output);
-        return rc;
-    }
+    rc = input(input_buf, input_buf + input_len, config, nameclass,
+               lookup, lookup_context, force_expand, &output);
     *result = (char *)output.begin;
     *result_len = output.end - output.begin;
-
-    return VAR_OK;
+    return rc;
 }

CVSTrac 2.0.1