zsh-workers
 help / color / mirror / code / Atom feed
* Re: Problem with history special parameter
@ 2000-01-19 16:36 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 2000-01-19 16:36 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> The first time I print out the keys to the history associative array (print
> ${(k)history}) I get:
> 
> %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK
> 
> for all elements.  The second time I just get a blank.
> 
> This is with zsh/parameter loaded, obviously.

Oops. Keys were not built. This also change the funcs for the job
parameters to avoid building the keys if we are only counting the
entries.


Bye
 Sven

diff -ru ../z.old/Src/Modules/parameter.c Src/Modules/parameter.c
--- ../z.old/Src/Modules/parameter.c	Wed Jan 19 17:16:57 2000
+++ Src/Modules/parameter.c	Wed Jan 19 17:33:09 2000
@@ -1086,12 +1086,12 @@
     pm.level = 0;
 
     while (he) {
-	if (func != scancountparams &&
-	    ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
-	     !(flags & SCANPM_WANTKEYS))) {
+	if (func != scancountparams) {
 	    sprintf(buf, "%d", he->histnum);
 	    pm.nam = dupstring(buf);
-	    pm.u.str = dupstring(he->text);
+	    if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
+		!(flags & SCANPM_WANTKEYS))
+		pm.u.str = dupstring(he->text);
 	}
 	func((HashNode) &pm, flags);
 
@@ -1209,12 +1209,13 @@
     for (job = 1; job < MAXJOB; job++) {
 	if (jobtab[job].stat && jobtab[job].procs &&
 	    !(jobtab[job].stat & STAT_NOPRINT)) {
-	    sprintf(buf, "%d", job);
-	    pm.nam = dupstring(buf);
-	    if (func != scancountparams &&
-		((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
-		 !(flags & SCANPM_WANTKEYS)))
-		pm.u.str = pmjobtext(job);
+	    if (func != scancountparams) {
+		sprintf(buf, "%d", job);
+		pm.nam = dupstring(buf);
+		if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
+		    !(flags & SCANPM_WANTKEYS))
+		    pm.u.str = pmjobtext(job);
+	    }
 	    func((HashNode) &pm, flags);
 	}
     }
@@ -1314,12 +1315,13 @@
     for (job = 1; job < MAXJOB; job++) {
 	if (jobtab[job].stat && jobtab[job].procs &&
 	    !(jobtab[job].stat & STAT_NOPRINT)) {
-	    sprintf(buf, "%d", job);
-	    pm.nam = dupstring(buf);
-	    if (func != scancountparams &&
-		((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
-		 !(flags & SCANPM_WANTKEYS)))
-		pm.u.str = pmjobstate(job);
+	    if (func != scancountparams) {
+		sprintf(buf, "%d", job);
+		pm.nam = dupstring(buf);
+		if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
+		    !(flags & SCANPM_WANTKEYS))
+		    pm.u.str = pmjobstate(job);
+	    }
 	    func((HashNode) &pm, flags);
 	}
     }
@@ -1391,12 +1393,13 @@
     for (job = 1; job < MAXJOB; job++) {
        if (jobtab[job].stat && jobtab[job].procs &&
            !(jobtab[job].stat & STAT_NOPRINT)) {
-           sprintf(buf, "%d", job);
-           pm.nam = dupstring(buf);
-           if (func != scancountparams &&
-               ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
-                !(flags & SCANPM_WANTKEYS)))
-               pm.u.str = pmjobdir(job);
+           if (func != scancountparams) {
+	       sprintf(buf, "%d", job);
+	       pm.nam = dupstring(buf);
+               if ((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
+		   !(flags & SCANPM_WANTKEYS))
+		   pm.u.str = pmjobdir(job);
+	   }
            func((HashNode) &pm, flags);
        }
     }

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Problem with history special parameter
@ 2000-01-19 12:48 Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2000-01-19 12:48 UTC (permalink / raw)
  To: Zsh hackers list

The first time I print out the keys to the history associative array (print
${(k)history}) I get:

%s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK %s.LOCK

for all elements.  The second time I just get a blank.

This is with zsh/parameter loaded, obviously.
-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-01-19 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-19 16:36 Problem with history special parameter Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-01-19 12:48 Peter Stephenson

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).