diff options
author | 2013-11-24 23:21:00 -0800 | |
---|---|---|
committer | 2013-11-24 23:21:00 -0800 | |
commit | 34540babdb6cc527a53003dcb5a13c961bf6ddc7 (patch) | |
tree | 2ceea618983a029e1634cd4bd389d626d3d74d3f /common.h | |
parent | 5d84e86d89e532d1a6979e2ed8528a05a7b7de9a (diff) | |
parent | 9f6223311e7ae6a9d6d21e33bf0fa67822da6fb6 (diff) |
Merge branch 'master' into ast
Conflicts:
complete.cpp
fish_tests.cpp
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -59,15 +59,19 @@ typedef std::vector<wcstring> wcstring_list_t; */ #define BYTE_MAX 0xffu -/** - Escape special fish syntax characters like the semicolon - */ -#define UNESCAPE_SPECIAL 1 +/* Flags for unescape_string functions */ +enum +{ + /* Default behavior */ + UNESCAPE_DEFAULT = 0, -/** - Allow incomplete escape sequences - */ -#define UNESCAPE_INCOMPLETE 2 + /* Escape special fish syntax characters like the semicolon */ + UNESCAPE_SPECIAL = 1 << 0, + + /* Allow incomplete escape sequences */ + UNESCAPE_INCOMPLETE = 1 << 1 +}; +typedef unsigned int unescape_flags_t; /* Flags for the escape() and escape_string() functions */ enum @@ -715,16 +719,14 @@ wcstring escape_string(const wcstring &in, escape_flags_t flags); character and a few more into constants which are defined in a private use area of Unicode. This assumes wchar_t is a unicode character set. - - The result must be free()d. The original string is not modified. If - an invalid sequence is specified, 0 is returned. - */ -wchar_t *unescape(const wchar_t * in, - int escape_special); -bool unescape_string(wcstring &str, - int escape_special); +/** Unescapes a string in-place. A true result indicates the string was unescaped, a false result indicates the string was unmodified. */ +bool unescape_string_in_place(wcstring *str, unescape_flags_t escape_special); + +/** Unescapes a string, returning the unescaped value by reference. On failure, the output is set to an empty string. */ +bool unescape_string(const wchar_t *input, wcstring *output, unescape_flags_t escape_special); +bool unescape_string(const wcstring &input, wcstring *output, unescape_flags_t escape_special); /** |