From owner-freebsd-current Sat Sep 12 22:39:21 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA23575 for freebsd-current-outgoing; Sat, 12 Sep 1998 22:39:21 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from midten.fast.no (midten.fast.no [195.139.251.11]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA23569 for ; Sat, 12 Sep 1998 22:39:16 -0700 (PDT) (envelope-from tegge@fast.no) Received: from fast.no (IDENT:tegge@midten.fast.no [195.139.251.11]) by midten.fast.no (8.9.1/8.9.1) with ESMTP id HAA29647; Sun, 13 Sep 1998 07:38:32 +0200 (CEST) Message-Id: <199809130538.HAA29647@midten.fast.no> To: seggers@semyam.dinoco.de Cc: eculp@webwizard.org.mx, cr@photox.jcmax.com, freebsd-current@FreeBSD.ORG Subject: Re: updatedb ? From: Tor.Egge@fast.no In-Reply-To: Your message of "Sat, 12 Sep 1998 23:12:38 +0200" References: <199809122112.XAA28964@semyam.dinoco.de> X-Mailer: Mew version 1.70 on Emacs 19.34.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sun, 13 Sep 1998 07:38:31 +0200 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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 <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