OSSP CVS Repository

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

ossp-pkg/var/var.c 1.14 -> 1.15

--- var.c        2001/11/14 11:11:01     1.14
+++ var.c        2001/11/14 12:02:40     1.15
@@ -1557,34 +1557,36 @@
     var_rc_t rc;
     tokenbuf_t output;
 
-    /* Expand the class description for valid variable names. */
+    /* Argument sanity checks */
+    if (input_buf == NULL || input_len == 0 || 
+        result == NULL || result_len == NULL ||
+        lookup == NULL || lookup_context == NULL)
+        return VAR_ERR_INVALID_ARGUMENT;
 
+    /* Optionally use default configuration */
     if (config == NULL)
         config = &var_config_default;
-    rc = expand_character_class(config->namechars, nameclass);
-    if (rc != VAR_OK)
+
+    /* Expand the class description for valid variable names. */
+    if ((rc = expand_character_class(config->namechars, nameclass)) != VAR_OK)
         return rc;
 
     /* Make sure that the specials defined in the configuration do not
        appear in the character name class. */
-
-    if (nameclass[(int) config->varinit] ||
-        nameclass[(int) config->startdelim] ||
-        nameclass[(int) config->enddelim] ||
-        nameclass[(int) config->escape])
+    if (nameclass[(int)config->varinit] ||
+        nameclass[(int)config->startdelim] ||
+        nameclass[(int)config->enddelim] ||
+        nameclass[(int)config->escape])
         return VAR_ERR_INVALID_CONFIGURATION;
 
     /* Call the parser. */
-
-    output.begin = output.end = NULL;
-    output.buffer_size = 0;
-    rc = input(input_buf, input_buf + input_len, config, nameclass,
-               lookup, lookup_context, force_expand, &output);
-    if (rc != VAR_OK) {
+    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;
     }
-    *result = (char *) output.begin;
+    *result = (char *)output.begin;
     *result_len = output.end - output.begin;
 
     return VAR_OK;

CVSTrac 2.0.1