Date: Sun, 13 Sep 1998 07:38:31 +0200 From: Tor.Egge@fast.no To: seggers@semyam.dinoco.de Cc: eculp@webwizard.org.mx, cr@photox.jcmax.com, freebsd-current@FreeBSD.ORG Subject: Re: updatedb ? Message-ID: <199809130538.HAA29647@midten.fast.no> In-Reply-To: Your message of "Sat, 12 Sep 1998 23:12:38 %2B0200" References: <199809122112.XAA28964@semyam.dinoco.de>
next in thread | previous in thread | raw e-mail | index | archive | help
> > I changed the #!/bin/sh to #!/usr/local/bin/ksh and it seems to work fine,
> > although I still don't understand why the problem with sh.
>
> The change from 1.22 to 1.23 in parser.c of /bin/sh seems to cause
> this malfunction. I removed it, recompiled sh, installed it and then
> called 310.locate manually. Now it worked for me.
Try this patch. It also contains a fix for variable expansion in
here documents:
#!/bin/sh
unset A
B=bval
cat <<EOF
${A-"should not have quotes"}
${A-'$B'}
EOF
I've started a small regression test (make world) using a /bin/sh with
this patch applied.
Index: expand.c
===================================================================
RCS file: /home/ncvs/src/bin/sh/expand.c,v
retrieving revision 1.23
diff -u -r1.23 expand.c
--- expand.c 1998/09/06 21:13:09 1.23
+++ expand.c 1998/09/13 04:57:09
@@ -142,8 +142,7 @@
{
herefd = fd;
expandarg(arg, (struct arglist *)NULL, 0);
- xwrite(fd, stackblock(),
- rmquotes(stackblock(), expdest - stackblock()));
+ xwrite(fd, stackblock(), expdest - stackblock());
}
@@ -185,8 +184,6 @@
} else {
if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */
rmescapes(p);
- else
- rmquotes0(p);
sp = (struct strlist *)stalloc(sizeof (struct strlist));
sp->text = p;
*exparg.lastp = sp;
@@ -235,7 +232,8 @@
/* "$@" syntax adherence hack */
if (p[0] == CTLVAR && p[2] == '@' && p[3] == '=')
break;
- STPUTC(c, expdest);
+ if ((flag & EXP_FULL) != 0)
+ STPUTC(c, expdest);
break;
case CTLESC:
if (quotes)
@@ -292,6 +290,8 @@
switch(c) {
case CTLESC:
return (startp);
+ case CTLQUOTEMARK:
+ return (startp);
case ':':
if (flag & EXP_VARTILDE)
goto done;
@@ -1462,58 +1462,6 @@
*q++ = *p++;
}
*q = '\0';
-}
-
-void rmquotes0(str)
- char *str;
-{
- char *p, *q;
-
- p = str;
- while (*p != CTLQUOTEMARK) {
- if (*p == CTLESC) {
- p++;
- p++;
- continue;
- }
- if (*p++ == '\0')
- return;
- }
- q = p;
- while (*p) {
- if (*p == CTLQUOTEMARK) {
- p++;
- continue;
- }
- if (*p == CTLESC)
- *q++ = *p++;
- *q++ = *p++;
- }
- *q = '\0';
-}
-
-int
-rmquotes(str, len)
- char *str;
- int len;
-{
- char *p, *q, *pe;
-
- p = str;
- pe = str + len;
- while (*p != CTLQUOTEMARK) {
- if (++p == pe)
- return len;
- }
- q = p;
- while (p < pe) {
- if (*p == CTLQUOTEMARK) {
- p++;
- continue;
- }
- *q++ = *p++;
- }
- return q - str;
}
Index: expand.h
===================================================================
RCS file: /home/ncvs/src/bin/sh/expand.h,v
retrieving revision 1.6
diff -u -r1.6 expand.h
--- expand.h 1998/09/06 21:13:09 1.6
+++ expand.h 1998/09/13 04:57:09
@@ -64,6 +64,4 @@
void expari __P((int));
int patmatch __P((char *, char *));
void rmescapes __P((char *));
-void rmquotes0 __P((char *));
-int rmquotes __P((char *, int));
int casematch __P((union node *, char *));
Index: memalloc.c
===================================================================
RCS file: /home/ncvs/src/bin/sh/memalloc.c,v
retrieving revision 1.11
diff -u -r1.11 memalloc.c
--- memalloc.c 1998/09/10 14:51:06 1.11
+++ memalloc.c 1998/09/13 04:57:09
@@ -269,7 +269,7 @@
growstackstr() {
int len = stackblocksize();
if (herefd >= 0 && len >= 1024) {
- xwrite(herefd, stackblock(), rmquotes(stackblock(), len));
+ xwrite(herefd, stackblock(), len);
sstrnleft = len - 1;
return stackblock();
}
Index: parser.c
===================================================================
RCS file: /home/ncvs/src/bin/sh/parser.c,v
retrieving revision 1.23
diff -u -r1.23 parser.c
--- parser.c 1998/09/06 21:13:09 1.23
+++ parser.c 1998/09/13 04:57:09
@@ -619,7 +619,6 @@
if (quoteflag == 0)
n->type = NXHERE;
TRACE(("Here document %d\n", n->type));
- rmquotes0(wordtext);
if (here->striptabs) {
while (*wordtext == '\t')
wordtext++;
@@ -943,31 +942,39 @@
USTPUTC('\\', out);
if (SQSYNTAX[c] == CCTL)
USTPUTC(CTLESC, out);
- else
+ else if (eofmark == NULL)
USTPUTC(CTLQUOTEMARK, out);
USTPUTC(c, out);
quotef++;
}
break;
case CSQUOTE:
- USTPUTC(CTLQUOTEMARK, out);
+ if (eofmark == NULL)
+ USTPUTC(CTLQUOTEMARK, out);
syntax = SQSYNTAX;
break;
case CDQUOTE:
- USTPUTC(CTLQUOTEMARK, out);
+ if (eofmark == NULL)
+ USTPUTC(CTLQUOTEMARK, out);
syntax = DQSYNTAX;
dblquote = 1;
break;
case CENDQUOTE:
- if (eofmark) {
+ if (eofmark != NULL && arinest == 0 &&
+ varnest == 0) {
USTPUTC(c, out);
} else {
- if (arinest)
+ if (arinest) {
syntax = ARISYNTAX;
- else
+ dblquote = 0;
+ } else if (eofmark != NULL) {
+ syntax = DQSYNTAX;
+ dblquote = 1;
+ } else {
syntax = BASESYNTAX;
+ dblquote = 0;
+ }
quotef++;
- dblquote = 0;
}
break;
case CVAR: /* '$' */
@@ -977,6 +984,12 @@
if (varnest > 0) {
varnest--;
USTPUTC(CTLENDVAR, out);
+ if (eofmark != NULL &&
+ varnest == 0 &&
+ arinest == 0) {
+ syntax = DQSYNTAX;
+ dblquote = 1;
+ }
} else {
USTPUTC(c, out);
}
@@ -1445,6 +1458,8 @@
p = text;
while ((c = *p++) != '\0') {
+ if ( c == CTLQUOTEMARK)
+ continue;
if (c == CTLESC)
p++;
else if (BASESYNTAX[c] == CCTL)
- Tor Egge
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809130538.HAA29647>
