--- var.c 2001/12/17 09:03:58 1.55
+++ var.c 2001/12/17 10:29:43 1.56
@@ -788,15 +788,11 @@
else {
rc = (*lookup) (lookup_context, name.begin, name.end - name.begin, idx,
&data, &len, &buffer_size);
- if (rc < 0)
- goto error_return;
- if (rc == 0) {
+ if (rc == VAR_ERR_UNDEFINED_VARIABLE) {
/* The variable is undefined. What we'll do now depends on the
force_expand flag. */
- if (force_expand) {
- rc = VAR_ERR_UNDEFINED_VARIABLE;
+ if (force_expand)
goto error_return;
- }
/* Initialize result to point back to the original text in
the buffer. */
@@ -805,6 +801,9 @@
result->buffer_size = 0;
failed = 1;
}
+ else if (rc < 0 /* != VAR_OK */) {
+ goto error_return;
+ }
else {
/* The preliminary result is the contents of the variable.
This may be modified by the commands that may follow. */
@@ -892,16 +891,14 @@
return rc;
if (rc > 0) {
rc2 = (*lookup)(lookup_context, p, rc, 0, &data, &len, &buffer_size);
- if (rc2 < 0)
- return rc2;
- if (rc2 == 0) {
- if (force_expand)
- return VAR_ERR_UNDEFINED_VARIABLE;
+ if (rc2 == VAR_ERR_UNDEFINED_VARIABLE && !force_expand) {
result->begin = begin;
result->end = begin + 1 + rc;
result->buffer_size = 0;
return 1 + rc;
}
+ if (rc2 < 0 /* != VAR_OK */)
+ return rc2;
result->begin = data;
result->end = data + len;
result->buffer_size = buffer_size;
@@ -1777,15 +1774,14 @@
rc = (*wcon->lookup)(wcon->context, name, name_len,
idx, data, data_len, buffer_size);
- if (rc == 0) {
+ if (rc == VAR_ERR_UNDEFINED_VARIABLE) {
(*wcon->rel_lookup_flag)--;
*data = buf;
*data_len = 0;
*buffer_size = 0;
- return 1;
+ return VAR_OK;
}
- else
- return rc;
+ return rc;
}
static var_rc_t loop_limits(const char *begin, const char *end,
|