commit b40f73fb28daa9f4a654cfc582f4336315c4767d
parent 1df8ab7e4530cb5a506ccb769528799b14150db3
Author: ukai <ukai>
Date: Fri, 7 Dec 2001 07:24:22 +0000
[w3m-dev 02640]
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat:
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,9 @@
+2001-12-07 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
+
+ * [w3m-dev 02640]
+ * linein.c (escape_spaces): rewrite
+ * linein.c (unescape_spaces): rewrite
+
2001-12-07 Tsutomu Okada <okada@furuno.co.jp>
* [w3m-dev 02638] completion for ! and/or @
diff --git a/linein.c b/linein.c
@@ -855,37 +855,50 @@ next_dcompl(int next)
}
}
+
Str
escape_spaces(Str s)
{
+ Str tmp = NULL;
char *p;
if (s == NULL)
- return;
- p = s->ptr;
- s = Strnew();
- while(*p) {
- if (*p == ' ')
- Strcat_char(s, '\\');
- Strcat_char(s, *p++);
+ return s;
+ for (p = s->ptr; *p; p++) {
+ if (*p == ' ' || *p == CTRL_I) {
+ if (tmp == NULL)
+ tmp = Strnew_charp_n(s->ptr, (int)(p - s->ptr));
+ Strcat_char(tmp, '\\');
+ }
+ if (tmp)
+ Strcat_char(tmp, *p);
}
+ if (tmp)
+ return tmp;
return s;
}
+
Str
unescape_spaces(Str s)
{
+ Str tmp = NULL;
char *p;
if (s == NULL)
- return;
- p = s->ptr;
- s = Strnew();
- while (*p) {
- if (!(*p == '\\' && *(p+1) && *(p+1) == ' '))
- Strcat_char(s, *p);
- p++;
+ return s;
+ for (p = s->ptr; *p; p++) {
+ if (*p == '\\' && (*(p+1) == ' ' || *(p+1) == CTRL_I)) {
+ if (tmp == NULL)
+ tmp = Strnew_charp_n(s->ptr, (int)(p - s->ptr));
+ }
+ else {
+ if (tmp)
+ Strcat_char(tmp, *p);
+ }
}
+ if (tmp)
+ return tmp;
return s;
}