zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: SECONDS can be floating point
Date: Tue, 29 Oct 2002 10:40:25 +0000	[thread overview]
Message-ID: <23260.1035888025@csr.com> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Mon, 28 Oct 2002 18:55:52 GMT." <22634.1035831352@csr.com>

Peter Stephenson wrote:
> This allows typeset to switch the SECONDS special parameter between
> integer and floating point.

Committed, but the following extra patch is necessary for checking that
typesets that create a local copy have a suitable type.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.88
diff -u -r1.88 builtin.c
--- Src/builtin.c	29 Oct 2002 10:31:16 -0000	1.88
+++ Src/builtin.c	29 Oct 2002 10:39:27 -0000
@@ -1732,11 +1732,30 @@
 	    int err = 1;
 	    if (!readonly && !strcmp(pname, "SECONDS"))
 	    {
+		/*
+		 * We allow SECONDS to change type between integer
+		 * and floating point.  If we are creating a new
+		 * local copy we check the type here and allow
+		 * a new special to be created with that type.
+		 * We then need to make sure the correct type
+		 * for the special is restored at the end of the scope.
+		 * If we are changing the type of an existing
+		 * parameter, we do the whole thing here.
+		 */
 		if (newspecial != NS_NONE)
 		{
-		    newspecial = NS_SECONDS;
-		    err = 0;	/* and continue */
-		    tc = 0;	/* but don't do a normal conversion */
+		    /*
+		     * The first test allows `typeset' to copy the
+		     * existing type.  This is the usual behaviour
+		     * for making special parameters local.
+		     */
+		    if (PM_TYPE(on) == 0 || PM_TYPE(on) == PM_INTEGER ||
+			PM_TYPE(on) == PM_FFLOAT || PM_TYPE(on) == PM_EFLOAT)
+		    {
+			newspecial = NS_SECONDS;
+			err = 0;	/* and continue */
+			tc = 0;	/* but don't do a normal conversion */
+		    }
 		} else if (!setsecondstype(pm, on, off)) {
 		    if (value && !setsparam(pname, ztrdup(value)))
 			return NULL;


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


  reply	other threads:[~2002-10-29 10:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-28 18:55 Peter Stephenson
2002-10-29 10:40 ` Peter Stephenson [this message]
2002-10-29 11:23   ` Peter Stephenson
2002-10-29 17:52     ` Wayne Davison
2002-10-29 18:08     ` Wayne Davison
2002-10-29 18:13       ` Peter Stephenson
2002-10-30 21:17 ` PATCH: my "SECONDS can be floating point" tweaks Wayne Davison
2002-10-31  5:09   ` Bart Schaefer
2002-10-31 18:53     ` Wayne Davison
2002-10-31 10:34   ` Peter Stephenson
2002-10-31 18:53     ` Wayne Davison

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=23260.1035888025@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /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).