Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Problem with history special parameter



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@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author