fix
This commit is contained in:
parent
85b0cb20eb
commit
8aa54e42a9
10
check.t
10
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.148 2008/02/27 11:24:11 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.149 2008/02/27 12:49:53 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 $
|
||||
@ -1024,7 +1024,9 @@ stdin:
|
||||
echo 23: ${x//#1/9}
|
||||
echo 24: ${x//%1/9}
|
||||
echo 25: ${x//\%1/9}
|
||||
# echo 26: ${x//\%1/9}
|
||||
echo 26: ${x//\\%1/9}
|
||||
echo 27: ${x//\a/9}
|
||||
echo 28: ${x//\\a/9}
|
||||
expected-stdout:
|
||||
1: 122321_ab/cde_b/c_1221
|
||||
2: 131_ab/cde_b/c_11
|
||||
@ -1051,7 +1053,9 @@ expected-stdout:
|
||||
23: 9222321_ab/cde_b/c_1221
|
||||
24: 1222321_ab/cde_b/c_1229
|
||||
25: 1222321_ab/cde_b/c_1229
|
||||
# 26: 1222321_ab/cde_b/c_1221
|
||||
26: 1222321_ab/cde_b/c_1221
|
||||
27: 1222321_9b/cde_b/c_1221
|
||||
28: 1222321_9b/cde_b/c_1221
|
||||
---
|
||||
name: glob-bad-1
|
||||
description:
|
||||
|
43
eval.c
43
eval.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.38 2008/02/27 11:24:11 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.39 2008/02/27 12:49:53 tg Exp $");
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#define MKSH_NOPWNAM
|
||||
@ -166,7 +166,7 @@ expand(const char *cp, /* input word */
|
||||
int newlines = 0; /* For trailing newlines in COMSUB */
|
||||
int saw_eq, tilde_ok;
|
||||
int make_magic;
|
||||
int sqchar = 0; /* char to keep bksl before (${…/…\/…/…}) */
|
||||
int sqmode = 0; /* keep backslashes before [\\/%#] */
|
||||
size_t len;
|
||||
|
||||
if (cp == NULL)
|
||||
@ -379,7 +379,7 @@ expand(const char *cp, /* input word */
|
||||
f = DOPAT | (f&DONTRUNCOMMAND) |
|
||||
DOTEMP_;
|
||||
quote = 0;
|
||||
sqchar = 0x100 | '/';
|
||||
sqmode = 2;
|
||||
break;
|
||||
case '=':
|
||||
/* Enabling tilde expansion
|
||||
@ -424,7 +424,7 @@ expand(const char *cp, /* input word */
|
||||
tilde_ok = 0; /* in case of ${unset:-} */
|
||||
*dp = '\0';
|
||||
quote = st->quote;
|
||||
sqchar = 0;
|
||||
sqmode = 0;
|
||||
f = st->f;
|
||||
if (f&DOBLANK)
|
||||
doblank--;
|
||||
@ -600,15 +600,17 @@ expand(const char *cp, /* input word */
|
||||
break;
|
||||
}
|
||||
|
||||
if (sqchar) {
|
||||
/* keep backslash before backslash or sqchar */
|
||||
if (quote || c == '\\')
|
||||
if (sqmode) {
|
||||
/* keep backslash before backslash or C_SUBOP2 char */
|
||||
if ((c == '\\') ||
|
||||
(quote && c == '/') ||
|
||||
(quote && sqmode == 2 && ctype(c, C_SUBOP2)))
|
||||
*dp++ = '\\';
|
||||
if (sqchar & 0x100 && (quote || (sqchar & 0xFF) != c)) {
|
||||
/* beginning of string, ign. leading sqchars */
|
||||
sqchar &= 0xFF;
|
||||
} else if ((sqchar & 0xFF) == c && !quote)
|
||||
sqchar = 0;
|
||||
if (sqmode == 2 && (quote || c != '/'))
|
||||
/* beginning of string, ign. leading chars */
|
||||
sqmode = 1;
|
||||
else if (!quote && c == '/')
|
||||
sqmode = 0;
|
||||
}
|
||||
|
||||
/* check for end of word or IFS separation */
|
||||
@ -1019,6 +1021,8 @@ trimsub(char *str, char *pat, int how)
|
||||
s = d = rpat = str_save(pat, ATEMP);
|
||||
while ((c = *s++))
|
||||
if (c == '\\') {
|
||||
if (s[0] == '\\' && s[1] != '/')
|
||||
++s;
|
||||
if (!(*d++ = *s++))
|
||||
break;
|
||||
} else if (c == '/') {
|
||||
@ -1040,17 +1044,16 @@ trimsub(char *str, char *pat, int how)
|
||||
|
||||
/* first see if we have any match at all */
|
||||
tpat0 = rpat;
|
||||
if (*rpat == '\\' && (rpat[1] == '#' || rpat[1] == '%'))
|
||||
tpat0++;
|
||||
if (*tpat0 == '#') {
|
||||
d = pat;
|
||||
if (*d == '\\')
|
||||
++d;
|
||||
if (*d == '#') {
|
||||
/* anchor at the beginning */
|
||||
tpat0++;
|
||||
tpat1 = shf_smprintf("%s%c*", tpat0, MAGIC);
|
||||
tpat1 = shf_smprintf("%s%c*", ++tpat0, MAGIC);
|
||||
tpat2 = tpat1;
|
||||
} else if (*tpat0 == '%') {
|
||||
} else if (*d == '%') {
|
||||
/* anchor at the end */
|
||||
tpat0++;
|
||||
tpat1 = shf_smprintf("%c*%s", MAGIC, tpat0);
|
||||
tpat1 = shf_smprintf("%c*%s", MAGIC, ++tpat0);
|
||||
tpat2 = tpat0;
|
||||
} else {
|
||||
/* float */
|
||||
|
4
sh.h
4
sh.h
@ -8,7 +8,7 @@
|
||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||
|
||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.189 2008/02/27 11:24:12 tg Exp $"
|
||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.190 2008/02/27 12:49:54 tg Exp $"
|
||||
#define MKSH_VERSION "R33 2008/02/27"
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
@ -538,7 +538,7 @@ EXTERN int really_exit;
|
||||
#define C_SUBOP1 BIT(5) /* "=-+?" */
|
||||
#define C_QUOTE BIT(6) /* \n\t"#$&'()*;<>?[]\`| (needing quoting) */
|
||||
#define C_IFS BIT(7) /* $IFS */
|
||||
#define C_SUBOP2 BIT(8) /* "#%" (magic, see below) */
|
||||
#define C_SUBOP2 BIT(8) /* "#%/" (magic, see below) */
|
||||
|
||||
extern unsigned char chtypes[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user