aboutsummaryrefslogtreecommitdiff
path: root/include/smap
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-06-20 09:45:03 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-06-20 09:58:05 +0300
commit9fd53c66bea84680ac782879c5095608c14d9f4a (patch)
treeded282a00341d32ddab43b6ab694197ef96eceae /include/smap
parent681919ac19e607566def43cf319e65213fc4cf6d (diff)
downloadsmap-9fd53c66bea84680ac782879c5095608c14d9f4a.tar.gz
smap-9fd53c66bea84680ac782879c5095608c14d9f4a.tar.bz2
Improve wordsplit.
* include/smap/wordsplit.h (wordsplit)<ws_errno>: New member. (WRDSE_NOSUPP): New define. (wordsplit_perror,wordsplit_strerror): New prototypes. * lib/wordsplit.c (all functions): use wordsplit_perror for diagnostics if WRDSF_SHOWERR is set; set ws_errno to the actual error code before returning error. (scan_word): Revise and fix return values. (wordsplit_len): Correctly handle errors, in particular WRDSE_QUOTE. (wordsplit_perror, wordsplit_strerror): New functions. * src/cfg.c (parse_config_loop): Use wordsplit_strerror for diagnostics. * src/module.c (smap_modules_init): Likewise. * src/smapc.c (read_eval_loop): Use wordsplit_perror for diagnostics.
Diffstat (limited to 'include/smap')
-rw-r--r--include/smap/wordsplit.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/smap/wordsplit.h b/include/smap/wordsplit.h
index 59c3ca3..92eb264 100644
--- a/include/smap/wordsplit.h
+++ b/include/smap/wordsplit.h
@@ -34,6 +34,7 @@ struct wordsplit
const char *ws_input;
size_t ws_len;
size_t ws_endp;
+ int ws_errno;
};
/* Append the words found to the array resulting from a previous
@@ -85,6 +86,7 @@ struct wordsplit
#define WRDSE_EOF 0
#define WRDSE_QUOTE 1
#define WRDSE_NOSPACE 2
+#define WRDSE_NOSUPP 3
int wordsplit(const char *s, struct wordsplit *p, int flags);
void wordsplit_free(struct wordsplit *p);
@@ -95,4 +97,8 @@ size_t wordsplit_quoted_length(const char *str, int quote_hex, int *quote);
void wordsplit_unquote_copy(char *dst, const char *src, size_t n);
void wordsplit_quote_copy(char *dst, const char *src, int quote_hex);
+void wordsplit_perror(struct wordsplit *ws);
+const char *wordsplit_strerror(struct wordsplit *ws);
+
+
#endif

Return to:

Send suggestions and report system problems to the System administrator.