--- var.c 2002/02/28 11:54:25 1.66
+++ var.c 2002/02/28 11:59:29 1.67
@@ -2158,61 +2158,61 @@
return rc;
}
+static char *var_errors[] = {
+ "everything ok", /* VAR_OK = 0 */
+ "incomplete named character", /* VAR_ERR_INCOMPLETE_NAMED_CHARACTER */
+ "incomplete hexadecimal value", /* VAR_ERR_INCOMPLETE_HEX */
+ "invalid hexadecimal value", /* VAR_ERR_INVALID_HEX */
+ "octal value too large", /* VAR_ERR_OCTAL_TOO_LARGE */
+ "invalid octal value", /* VAR_ERR_INVALID_OCTAL */
+ "incomplete octal value", /* VAR_ERR_INCOMPLETE_OCTAL */
+ "incomplete grouped hexadecimal value", /* VAR_ERR_INCOMPLETE_GROUPED_HEX */
+ "incorrect character class specification", /* VAR_ERR_INCORRECT_CLASS_SPEC */
+ "invalid expansion configuration", /* VAR_ERR_INVALID_CONFIGURATION */
+ "out of memory", /* VAR_ERR_OUT_OF_MEMORY */
+ "incomplete variable specification", /* VAR_ERR_INCOMPLETE_VARIABLE_SPEC */
+ "undefined variable", /* VAR_ERR_UNDEFINED_VARIABLE */
+ "input is neither text nor variable", /* VAR_ERR_INPUT_ISNT_TEXT_NOR_VARIABLE */
+ "unknown command character in variable", /* VAR_ERR_UNKNOWN_COMMAND_CHAR */
+ "malformatted search and replace operation", /* VAR_ERR_MALFORMATTED_REPLACE */
+ "unknown flag in search and replace operation", /* VAR_ERR_UNKNOWN_REPLACE_FLAG */
+ "invalid regex in search and replace operation", /* VAR_ERR_INVALID_REGEX_IN_REPLACE */
+ "missing parameter in command", /* VAR_ERR_MISSING_PARAMETER_IN_COMMAND */
+ "empty search string in search and replace operation", /* VAR_ERR_EMPTY_SEARCH_STRING */
+ "start offset missing in cut operation", /* VAR_ERR_MISSING_START_OFFSET */
+ "offsets in cut operation delimited by unknown character", /* VAR_ERR_INVALID_OFFSET_DELIMITER */
+ "range out of bounds in cut operation", /* VAR_ERR_RANGE_OUT_OF_BOUNDS */
+ "offset out of bounds in cut operation", /* VAR_ERR_OFFSET_OUT_OF_BOUNDS */
+ "logic error in cut operation", /* VAR_ERR_OFFSET_LOGIC */
+ "malformatted transpose operation", /* VAR_ERR_MALFORMATTED_TRANSPOSE */
+ "source and target class mismatch in transpose operation", /* VAR_ERR_TRANSPOSE_CLASSES_MISMATCH */
+ "empty character class in transpose operation", /* VAR_ERR_EMPTY_TRANSPOSE_CLASS */
+ "incorrect character class in transpose operation", /* VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC */
+ "malformatted padding operation", /* VAR_ERR_MALFORMATTED_PADDING */
+ "width parameter missing in padding operation", /* VAR_ERR_MISSING_PADDING_WIDTH */
+ "fill string missing in padding operation", /* VAR_ERR_EMPTY_PADDING_FILL_STRING */
+ "unknown quoted pair in search and replace operation", /* VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE */
+ "sub-matching reference out of range", /* VAR_ERR_SUBMATCH_OUT_OF_RANGE */
+ "invalid argument", /* VAR_ERR_INVALID_ARGUMENT */
+ "incomplete quoted pair", /* VAR_ERR_INCOMPLETE_QUOTED_PAIR */
+ "lookup function does not support variable arrays", /* VAR_ERR_ARRAY_LOOKUPS_ARE_UNSUPPORTED */
+ "index of array variable contains an invalid character", /* VAR_ERR_INVALID_CHAR_IN_INDEX_SPEC */
+ "index of array variable is incomplete", /* VAR_ERR_INCOMPLETE_INDEX_SPEC */
+ "bracket expression in array variable's index not closed", /* VAR_ERR_UNCLOSED_BRACKET_IN_INDEX */
+ "division by zero error in index specification", /* VAR_ERR_DIVISION_BY_ZERO_IN_INDEX */
+ "unterminated loop construct", /* VAR_ERR_UNTERMINATED_LOOP_CONSTRUCT */
+ "invalid character in loop limits" /* VAR_ERR_INVALID_CHAR_IN_LOOP_LIMITS */
+};
+
var_rc_t var_strerror(var_t *var, var_rc_t rc, char **str)
{
- static char *errors[] = {
- "everything ok", /* VAR_OK = 0 */
- "incomplete named character", /* VAR_ERR_INCOMPLETE_NAMED_CHARACTER */
- "incomplete hexadecimal value", /* VAR_ERR_INCOMPLETE_HEX */
- "invalid hexadecimal value", /* VAR_ERR_INVALID_HEX */
- "octal value too large", /* VAR_ERR_OCTAL_TOO_LARGE */
- "invalid octal value", /* VAR_ERR_INVALID_OCTAL */
- "incomplete octal value", /* VAR_ERR_INCOMPLETE_OCTAL */
- "incomplete grouped hexadecimal value", /* VAR_ERR_INCOMPLETE_GROUPED_HEX */
- "incorrect character class specification", /* VAR_ERR_INCORRECT_CLASS_SPEC */
- "invalid expansion configuration", /* VAR_ERR_INVALID_CONFIGURATION */
- "out of memory", /* VAR_ERR_OUT_OF_MEMORY */
- "incomplete variable specification", /* VAR_ERR_INCOMPLETE_VARIABLE_SPEC */
- "undefined variable", /* VAR_ERR_UNDEFINED_VARIABLE */
- "input is neither text nor variable", /* VAR_ERR_INPUT_ISNT_TEXT_NOR_VARIABLE */
- "unknown command character in variable", /* VAR_ERR_UNKNOWN_COMMAND_CHAR */
- "malformatted search and replace operation", /* VAR_ERR_MALFORMATTED_REPLACE */
- "unknown flag in search and replace operation", /* VAR_ERR_UNKNOWN_REPLACE_FLAG */
- "invalid regular expression in search and replace operation", /* VAR_ERR_INVALID_REGEX_IN_REPLACE */
- "missing parameter in command", /* VAR_ERR_MISSING_PARAMETER_IN_COMMAND */
- "empty search string in search and replace operation", /* VAR_ERR_EMPTY_SEARCH_STRING */
- "start offset missing in cut operation", /* VAR_ERR_MISSING_START_OFFSET */
- "offsets in cut operation delimited by unknown character", /* VAR_ERR_INVALID_OFFSET_DELIMITER */
- "range out of bounds in cut operation", /* VAR_ERR_RANGE_OUT_OF_BOUNDS */
- "offset out of bounds in cut operation", /* VAR_ERR_OFFSET_OUT_OF_BOUNDS */
- "logic error in cut operation", /* VAR_ERR_OFFSET_LOGIC */
- "malformatted transpose operation", /* VAR_ERR_MALFORMATTED_TRANSPOSE */
- "source and destination classes do not match in transpose operation", /* VAR_ERR_TRANSPOSE_CLASSES_MISMATCH */
- "empty character class in transpose operation", /* VAR_ERR_EMPTY_TRANSPOSE_CLASS */
- "incorrect character class in transpose operation", /* VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC */
- "malformatted padding operation", /* VAR_ERR_MALFORMATTED_PADDING */
- "width parameter missing in padding operation", /* VAR_ERR_MISSING_PADDING_WIDTH */
- "fill string missing in padding operation", /* VAR_ERR_EMPTY_PADDING_FILL_STRING */
- "unknown quoted pair in search and replace operation", /* VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE */
- "sub-matching reference out of range", /* VAR_ERR_SUBMATCH_OUT_OF_RANGE */
- "invalid argument", /* VAR_ERR_INVALID_ARGUMENT */
- "incomplete quoted pair", /* VAR_ERR_INCOMPLETE_QUOTED_PAIR */
- "lookup function does not support variable arrays", /* VAR_ERR_ARRAY_LOOKUPS_ARE_UNSUPPORTED */
- "index specification of array variable contains an invalid character", /* VAR_ERR_INVALID_CHAR_IN_INDEX_SPEC */
- "index specification of array variable is incomplete", /* VAR_ERR_INCOMPLETE_INDEX_SPEC */
- "bracket expression in array variable's index is not closed", /* VAR_ERR_UNCLOSED_BRACKET_IN_INDEX */
- "division by zero error in index specification", /* VAR_ERR_DIVISION_BY_ZERO_IN_INDEX */
- "unterminated loop construct", /* VAR_ERR_UNTERMINATED_LOOP_CONSTRUCT */
- "invalid character in loop limits" /* VAR_ERR_INVALID_CHAR_IN_LOOP_LIMITS */
- };
-
if (str == NULL)
return VAR_RC(VAR_ERR_INVALID_ARGUMENT);
rc = 0 - rc;
- if (rc < 0 || rc >= sizeof(errors) / sizeof(char *))
+ if (rc < 0 || rc >= sizeof(var_errors) / sizeof(char *))
*str = "unknown error";
else
- *str = errors[rc];
+ *str = var_errors[rc];
return VAR_OK;
}
|