I _think_ this implements ${foo/bar/baz} logic (bar is a glob pattern)

todo tomorrow:
• test case (compare with e.g. GNU bash)
• manpage
• version bump

sqchar is a bit ugly, but \/ must be preserved, as we don’t get wdencoded
strings later on in the process (eval.c CSUBST) and I didn’t want to have
an implementation like ${foo: 2: 3} this time
This commit is contained in:
tg
2008-02-27 01:00:10 +00:00
parent 0f1501326b
commit 01b54f1fd5
4 changed files with 97 additions and 14 deletions

8
misc.c
View File

@ -6,7 +6,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.67 2007/10/25 15:19:16 tg Exp $\t"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.68 2008/02/27 01:00:09 tg Exp $\t"
MKSH_SH_H_ID);
#undef USE_CHVT
@ -38,12 +38,12 @@ setctypes(const char *s, int t)
unsigned i;
if (t & C_IFS) {
for (i = 0; i < UCHAR_MAX+1; i++)
for (i = 0; i < UCHAR_MAX + 1; i++)
chtypes[i] &= ~C_IFS;
chtypes[0] |= C_IFS; /* include \0 in C_IFS */
}
while (*s != 0)
chtypes[(unsigned char) *s++] |= t;
chtypes[(unsigned char)*s++] |= t;
}
void
@ -499,7 +499,7 @@ bi_getn(const char *as, int *ai)
*/
int
gmatchx(const char *s, const char *p, int isfile)
gmatchx(const char *s, const char *p, bool isfile)
{
const char *se, *pe;