summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2004-01-15 16:42:22 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2004-01-15 16:42:22 (GMT)
commitbe52cc0eba0149beb088a03c2a9d1530971f911b (patch)
tree72ff56da1610b9321b0bf68c9f02b844f8ec3312 /tools/lib
parentc4d9f6ae104e886d7dc6c69567d661989b662e5c (diff)
downloadhdf5-be52cc0eba0149beb088a03c2a9d1530971f911b.zip
hdf5-be52cc0eba0149beb088a03c2a9d1530971f911b.tar.gz
hdf5-be52cc0eba0149beb088a03c2a9d1530971f911b.tar.bz2
[svn-r8067] *** empty log message ***
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools_str.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index b3ee8e3..0ed66b4 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -962,15 +962,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;
@@ -986,11 +995,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 {
@@ -1007,10 +1016,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 */
}
}