From 16dd1d3c8f0ae329ee4ecd37b9a4d846f81b5349 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 1 Mar 2008 17:14:17 +0000 Subject: [PATCH] =?UTF-8?q?fix=20one=20of=20the=20bugs=20in=20this=20code?= =?UTF-8?q?=E2=80=A6=20still=20the=20one=20I=E2=80=99m=20looking=20for=20l?= =?UTF-8?q?eft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check.t | 6 +++++- eval.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/check.t b/check.t index e03b463..1feb5d3 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.153 2008/03/01 16:40:57 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.154 2008/03/01 17:14:17 tg Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ @@ -1083,8 +1083,12 @@ stdin: pfx=/home/user wd=/home/user/tmp echo ${wd/#$pfx/~} + echo ${wd/#"$pfx"/~} + echo ${wd/#'$pfx'/~} expected-stdout: ~/tmp + ~/tmp + /home/user/tmp --- name: glob-bad-1 description: diff --git a/eval.c b/eval.c index 6056569..6201eb9 100644 --- a/eval.c +++ b/eval.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.41 2008/02/29 11:51:21 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.42 2008/03/01 17:14:17 tg Exp $"); #ifdef MKSH_SMALL #define MKSH_NOPWNAM @@ -1026,11 +1026,11 @@ trimsub(char *str, char *pat, int how) if (!(*d++ = *s++)) break; } else if (c == '/') { - *d++ = '\0'; rrep = s; break; } else *d++ = c; + *d++ = '\0'; /* do not accept empty pattern */ if (!*rpat) { afree(rpat, ATEMP); @@ -1058,6 +1058,10 @@ trimsub(char *str, char *pat, int how) tpat1 = shf_smprintf("%c*%s%c*", MAGIC, rpat, MAGIC); tpat2 = tpat1 + 2; } +#if 0 + fprintf(stderr, "D: 「%s」 → 〔%s|%s〕\n", pat, tpat0, rrep); + fflush(stderr); +#endif again_repl: /* this would not be necessary if gmatchx would return * the start and end values of a match found, like re*