fix one of the bugs in this code… still the one I’m looking for left

This commit is contained in:
tg 2008-03-01 17:14:17 +00:00
parent 707a787edc
commit 16dd1d3c8f
2 changed files with 11 additions and 3 deletions

View File

@ -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:

8
eval.c
View File

@ -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*