zsh-workers
 help / color / mirror / code / Atom feed
From: Peter William Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Colon qualifiers with ^...^...^
Date: Tue, 14 Nov 1995 13:32:49 +0100	[thread overview]
Message-ID: <9511141232.AA11316@sgi.ifh.de> (raw)

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 <pws@ifh.de>       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.


                 reply	other threads:[~1995-11-14 12:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9511141232.AA11316@sgi.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).