diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2001-12-07 07:24:22 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2001-12-07 07:24:22 +0000 |
commit | 8b13540fb8c860e643e14893a460fb8fec7240f6 (patch) | |
tree | eec817b8f9df4eb7f95b8d8bb76ccaaf145f5d7c | |
parent | [w3m-dev 02638] (diff) | |
download | w3m-8b13540fb8c860e643e14893a460fb8fec7240f6.tar.gz w3m-8b13540fb8c860e643e14893a460fb8fec7240f6.zip |
[w3m-dev 02640]
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | linein.c | 43 |
2 files changed, 35 insertions, 16 deletions
@@ -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 @ @@ -1080,4 +1086,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.112 2001/12/07 07:20:26 ukai Exp $ +$Id: ChangeLog,v 1.113 2001/12/07 07:24:22 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: linein.c,v 1.13 2001/12/07 07:20:26 ukai Exp $ */ +/* $Id: linein.c,v 1.14 2001/12/07 07:24:22 ukai Exp $ */ #include "fm.h" #include "local.h" #include "myctype.h" @@ -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; } |