diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2004-01-15 20:41:42 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2004-01-15 20:41:42 (GMT) |
commit | ca6c8cbeae6d8ea1465f898966e388536f4996e1 (patch) | |
tree | 03009040dc5fa9e4cfce4d2b2e85440f42c72eaa /tools/lib | |
parent | c516bc9a85b1d98ddb3bb728a79cb8b81f3e27ed (diff) | |
download | hdf5-ca6c8cbeae6d8ea1465f898966e388536f4996e1.zip hdf5-ca6c8cbeae6d8ea1465f898966e388536f4996e1.tar.gz hdf5-ca6c8cbeae6d8ea1465f898966e388536f4996e1.tar.bz2 |
[svn-r8072] *** empty log message ***
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_str.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index e38e8fd..1053b60 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -963,15 +963,24 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) size_t n = strlen(s); const char *escape; char octal[8]; - + for (i = 0; i < n; i++) { switch (s[i]) { - case '"': + case '\'': + escape = "\\\'"; + break; + case '\"': escape = "\\\""; break; case '\\': escape = "\\\\"; break; + case '\?': + escape = "\\\?"; + break; + case '\a': + escape = "\\a"; + break; case '\b': escape = "\\b"; break; @@ -987,11 +996,11 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) case '\t': escape = "\\t"; break; - case ' ': - escape = escape_spaces ? "\\ " : NULL; + case '\v': + escape = "\\v"; break; default: - if (!isprint((int)*s)) { + if (!isprint(s[i])) { sprintf(octal, "\\%03o", (unsigned char)s[i]); escape = octal; } else { @@ -1008,10 +1017,10 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) /*would overflow*/ return NULL; - memmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/ + memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ memcpy(s + i, escape, esc_size); /*insert*/ - n += esc_size; - i += esc_size - 1; + n += esc_size - 1; /* adjust total string size */ + i += esc_size; /* adjust string position */ } } |