diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-06-24 13:25:23 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-06-24 13:25:23 +0300 |
commit | 558fcc76286852c2dc360e32287aff8410de04f0 (patch) | |
tree | d4dca00a9db849d0d9e231ea95366e3c62bcbcb7 /include/smap | |
parent | c0e1d8a2cfa7dce23c0f3366de392dda2de4ce77 (diff) | |
download | smap-558fcc76286852c2dc360e32287aff8410de04f0.tar.gz smap-558fcc76286852c2dc360e32287aff8410de04f0.tar.bz2 |
Fix quote removal in wordsplit.
* include/smap/wordsplit.h (WRDSF_CESCAPES): New flag.
(wordsplit_unquote_char): Rename to
(wordsplit_quote_char): Rename to wordsplit_c_quote_char.
(wordsplit_quoted_length): Rename to wordsplit_c_quoted_length.
(wordsplit_quote_copy): Rename to wordsplit_c_quote_copy.
(wordsplit_unquote_copy): Rename to wordsplit_c_unquote_copy.
(wordsplit_sh_unquote_copy): New prototype.
* lib/wordsplit.c (wsnode_quoteremoval): New function.
(wsnode_coalesce): Only coalesce adjacent nodes, do not modify them.
(wordsplit_len): Introduce quote removal (actually, unescaping) pass.
Diffstat (limited to 'include/smap')
-rw-r--r-- | include/smap/wordsplit.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/include/smap/wordsplit.h b/include/smap/wordsplit.h index 04c5e65..ced28f3 100644 --- a/include/smap/wordsplit.h +++ b/include/smap/wordsplit.h @@ -92,10 +92,12 @@ struct wordsplit /* Keep undefined variables in place, instead of expanding them to empty string */ #define WRDSF_KEEPUNDEF 0x200000 +/* Handle C escapes */ +#define WRDSF_CESCAPES 0x400000 #define WRDSF_DEFFLAGS \ (WRDSF_NOVAR | WRDSF_NOCMD | \ - WRDSF_WS | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS) + WRDSF_WS | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | WRDSF_CESCAPES) #define WRDSE_EOF 0 #define WRDSE_QUOTE 1 @@ -107,11 +109,12 @@ struct wordsplit int wordsplit(const char *s, struct wordsplit *p, int flags); void wordsplit_free(struct wordsplit *p); -int wordsplit_unquote_char(int c); -int wordsplit_quote_char(int c); -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); +int wordsplit_c_unquote_char(int c); +int wordsplit_c_quote_char(int c); +size_t wordsplit_c_quoted_length(const char *str, int quote_hex, int *quote); +void wordsplit_sh_unquote_copy(char *dst, const char *src, size_t n); +void wordsplit_c_unquote_copy(char *dst, const char *src, size_t n); +void wordsplit_c_quote_copy(char *dst, const char *src, int quote_hex); void wordsplit_perror(struct wordsplit *ws); const char *wordsplit_strerror(struct wordsplit *ws); |