From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from math.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by werple.net.au (8.7/8.7.1) with SMTP id XAA01050 for ; Tue, 14 Nov 1995 23:58:48 +1100 (EST) Received: by math.gatech.edu (5.x/SMI-SVR4) id AA10300; Tue, 14 Nov 1995 07:33:18 -0500 Resent-Date: Tue, 14 Nov 1995 13:32:49 +0100 Old-Return-Path: Message-Id: <9511141232.AA11316@sgi.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Colon qualifiers with ^...^...^ Date: Tue, 14 Nov 1995 13:32:49 +0100 From: Peter William Stephenson Resent-Message-Id: <"N5rfn2.0.oW2.Do8gm"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/608 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Someone pointed out that history substitution in the ^...^...^ form doesn't allow extra qualifiers at the end any more... this was only because I didn't know it worked before. Fixing it turns out to be trivial. This patch (despite its length) does nothing more than reposition the closing brace after the test for the ^ form, so there's no overhead in fixing it at all. All the other changes are indentation. % print foo foo % ^print^echo^:s/foo/bar/ echo bar bar I assume this is what is meant: I don't think allowing word selections from the just-substituted line is on at this point. I don't think this depends on my long history fix. *** Src/hist.c~ Wed Nov 8 09:25:47 1995 --- Src/hist.c Tue Nov 14 13:20:05 1995 *************** *** 322,412 **** if (!(sline = getargs(ehist, farg, larg))) return -1; ! /* do the modifiers */ ! for (;;) { ! c = (cflag) ? ':' : ingetc(); ! cflag = 0; ! if (c == ':') { ! int gbal = 0; ! if ((c = ingetc()) == 'g') { ! gbal = 1; ! c = ingetc(); } ! switch (c) { ! case 'p': ! histdone = HISTFLAG_DONE | HISTFLAG_NOEXEC; ! break; ! case 'h': ! if (!remtpath(&sline)) { ! inerrflush(); ! zerr("modifier failed: h", NULL, 0); ! return -1; ! } ! break; ! case 'e': ! if (!rembutext(&sline)) { ! inerrflush(); ! zerr("modifier failed: e", NULL, 0); ! return -1; ! } ! break; ! case 'r': ! if (!remtext(&sline)) { ! inerrflush(); ! zerr("modifier failed: r", NULL, 0); ! return -1; ! } ! break; ! case 't': ! if (!remlpaths(&sline)) { ! inerrflush(); ! zerr("modifier failed: t", NULL, 0); ! return -1; ! } ! break; ! case 's': ! if (getsubsargs(sline)) ! return -1; /* fall through */ ! case '&': ! if (hsubl && hsubr) ! subst(&sline, hsubl, hsubr, gbal); ! else { ! inerrflush(); ! zerr("no previous substitution with &", NULL, 0); ! return -1; ! } ! break; ! case 'q': ! quote(&sline); ! break; ! case 'x': ! quotebreak(&sline); ! break; ! case 'l': ! downcase(&sline); ! break; ! case 'u': ! upcase(&sline); ! break; ! default: inerrflush(); ! zerr("illegal modifier: %c", NULL, c); return -1; } ! } else { ! if (c != '}' || !bflag) ! inungetc(c); ! if (c != '}' && bflag) { ! zerr("'}' expected", NULL, 0); return -1; } break; } } - } /* * Push the expanded value onto the input stack, * marking this as a history word for purposes of the alias stack. --- 322,412 ---- if (!(sline = getargs(ehist, farg, larg))) return -1; ! } ! /* do the modifiers */ ! for (;;) { ! c = (cflag) ? ':' : ingetc(); ! cflag = 0; ! if (c == ':') { ! int gbal = 0; ! if ((c = ingetc()) == 'g') { ! gbal = 1; ! c = ingetc(); ! } ! switch (c) { ! case 'p': ! histdone = HISTFLAG_DONE | HISTFLAG_NOEXEC; ! break; ! case 'h': ! if (!remtpath(&sline)) { ! inerrflush(); ! zerr("modifier failed: h", NULL, 0); ! return -1; ! } ! break; ! case 'e': ! if (!rembutext(&sline)) { ! inerrflush(); ! zerr("modifier failed: e", NULL, 0); ! return -1; ! } ! break; ! case 'r': ! if (!remtext(&sline)) { ! inerrflush(); ! zerr("modifier failed: r", NULL, 0); ! return -1; } ! break; ! case 't': ! if (!remlpaths(&sline)) { inerrflush(); ! zerr("modifier failed: t", NULL, 0); return -1; } ! break; ! case 's': ! if (getsubsargs(sline)) ! return -1; /* fall through */ ! case '&': ! if (hsubl && hsubr) ! subst(&sline, hsubl, hsubr, gbal); ! else { ! inerrflush(); ! zerr("no previous substitution with &", NULL, 0); return -1; } break; + case 'q': + quote(&sline); + break; + case 'x': + quotebreak(&sline); + break; + case 'l': + downcase(&sline); + break; + case 'u': + upcase(&sline); + break; + default: + inerrflush(); + zerr("illegal modifier: %c", NULL, c); + return -1; + } + } else { + if (c != '}' || !bflag) + inungetc(c); + if (c != '}' && bflag) { + zerr("'}' expected", NULL, 0); + return -1; } + break; } } + /* * Push the expanded value onto the input stack, * marking this as a history word for purposes of the alias stack. -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.