From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id DAA11902 for ; Fri, 27 Sep 1996 03:05:37 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id MAA10472; Thu, 26 Sep 1996 12:54:15 -0400 (EDT) Resent-Date: Thu, 26 Sep 1996 12:54:15 -0400 (EDT) From: "Bart Schaefer" Message-Id: <960926095644.ZM13281@candle.brasslantern.com> Date: Thu, 26 Sep 1996 09:56:43 -0700 In-Reply-To: Zoltan Hidvegi "Re: emacs configure broken when invoked as /bin/sh" (Sep 24, 1:40am) References: <199609232340.BAA03127@bolyai.cs.elte.hu> Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: Zoltan Hidvegi Subject: 3.0.1-test2 - sanity for COLUMNS, LINES, FIGNORE, MAILPATH, and PSVAR Cc: zsh-workers@math.gatech.edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"9mMHO1.0.YZ2.oKhIo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2173 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I posted this a while back, but it didn't show up in 3.0.1-test2 so here it is again just in case. This imposes sanity on zle's internal reflection of the LINES and COLUMNS environment variables, so that resizing xterm to a ridiculously small size or otherwise playing with bogus settings of the variables will not result in strange behavior and crashes. As a side effect, it backs out the COLUMNS macro introduced a while back and returns to using the columns global. Also buried in here, and worth having even if you don't like the rest of the patch, is a fix for the FIGNORE, MAILPATH, and PSVAR variables so that they don't develop the value "." (dot) when assigned "" (empty). Index: Src/builtin.c *** zsh-3.0.0/Src/builtin.c Wed Aug 14 08:06:54 1996 --- zsh-3.0.0-build/Src/builtin.c Thu Aug 22 22:57:18 1996 *************** *** 4314,4320 **** l = t; sc = l + 2; ! nc = (COLUMNS + 1) / sc; if (!nc) nc = 1; nr = (n + nc - 1) / nc; --- 4314,4320 ---- l = t; sc = l + 2; ! nc = (columns + 1) / sc; if (!nc) nc = 1; nr = (n + nc - 1) / nc; Index: Src/hashtable.h *** zsh-3.0.0/Src/hashtable.h Tue Aug 13 18:13:18 1996 --- zsh-3.0.0-build/Src/hashtable.h Thu Aug 22 23:08:23 1996 *************** *** 134,144 **** IPDEF4("LINENO", &lineno), IPDEF4("PPID", &ppid), ! #define IPDEF5(A,B) {NULL,A,PM_INTEGER|PM_SPECIAL,NULL,IFN(intvarsetfn),IFN(intvargetfn),10,(void *)B,NULL,NULL,NULL,0} ! IPDEF5("COLUMNS", &columns), ! IPDEF5("LINES", &lines), ! IPDEF5("OPTIND", &zoptind), ! IPDEF5("SHLVL", &shlvl), #define IPDEF6(A,B) {NULL,A,PM_SCALAR|PM_READONLY|PM_SPECIAL,NULL,IFN(nullsetfn),IFN(strvargetfn),0,(void *)B,NULL,NULL,NULL,0} IPDEF6("PWD", &pwd), --- 134,144 ---- IPDEF4("LINENO", &lineno), IPDEF4("PPID", &ppid), ! #define IPDEF5(A,B,F) {NULL,A,PM_INTEGER|PM_SPECIAL,NULL,IFN(F),IFN(intvargetfn),10,(void *)B,NULL,NULL,NULL,0} ! IPDEF5("COLUMNS", &columns, zlevarsetfn), ! IPDEF5("LINES", &lines, zlevarsetfn), ! IPDEF5("OPTIND", &zoptind, intvarsetfn), ! IPDEF5("SHLVL", &shlvl, intvarsetfn), #define IPDEF6(A,B) {NULL,A,PM_SCALAR|PM_READONLY|PM_SPECIAL,NULL,IFN(nullsetfn),IFN(strvargetfn),0,(void *)B,NULL,NULL,NULL,0} IPDEF6("PWD", &pwd), *************** *** 158,170 **** IPDEF7("SPROMPT", &sprompt), IPDEF7("0", &argzero), ! #define IPDEF8(A,B,C) {NULL,A,PM_SCALAR|PM_SPECIAL,NULL,IFN(colonarrsetfn),IFN(colonarrgetfn),0,(void *)B,NULL,C,NULL,0} ! IPDEF8("CDPATH", &cdpath, "cdpath"), ! IPDEF8("FIGNORE", &fignore, "fignore"), ! IPDEF8("FPATH", &fpath, "fpath"), ! IPDEF8("MAILPATH", &mailpath, "mailpath"), ! IPDEF8("WATCH", &watch, "watch"), ! IPDEF8("PSVAR", &psvar, "psvar"), {NULL, "PATH", PM_SPECIAL,NULL, IFN(colonpathsetfn), IFN(colonpathgetfn), 0, (void *) NULL, NULL, "path", NULL, 0}, --- 158,170 ---- IPDEF7("SPROMPT", &sprompt), IPDEF7("0", &argzero), ! #define IPDEF8(A,B,C,F) {NULL,A,PM_SCALAR|PM_SPECIAL,NULL,IFN(F),IFN(colonarrgetfn),0,(void *)B,NULL,C,NULL,0} ! IPDEF8("CDPATH", &cdpath, "cdpath", colonarrsetfn), ! IPDEF8("FIGNORE", &fignore, "fignore", colonarr2setfn), ! IPDEF8("FPATH", &fpath, "fpath", colonarrsetfn), ! IPDEF8("MAILPATH", &mailpath, "mailpath", colonarr2setfn), ! IPDEF8("WATCH", &watch, "watch", colonarrsetfn), ! IPDEF8("PSVAR", &psvar, "psvar", colonarr2setfn), {NULL, "PATH", PM_SPECIAL,NULL, IFN(colonpathsetfn), IFN(colonpathgetfn), 0, (void *) NULL, NULL, "path", NULL, 0}, *************** *** 183,189 **** IPDEF7("PROMPT2", &prompt2), IPDEF7("PROMPT3", &prompt3), IPDEF7("PROMPT4", &prompt4), ! IPDEF8("MANPATH", &manpath, "manpath"), IPDEF9("argv", 0, &pparams, NULL), IPDEF9("fignore", 0, &fignore, "FIGNORE"), IPDEF9("cdpath", 0, &cdpath, "CDPATH"), --- 183,189 ---- IPDEF7("PROMPT2", &prompt2), IPDEF7("PROMPT3", &prompt3), IPDEF7("PROMPT4", &prompt4), ! IPDEF8("MANPATH", &manpath, "manpath", colonarrsetfn), IPDEF9("argv", 0, &pparams, NULL), IPDEF9("fignore", 0, &fignore, "FIGNORE"), IPDEF9("cdpath", 0, &cdpath, "CDPATH"), Index: Src/init.c *** zsh-3.0.0/Src/init.c Thu Aug 15 09:42:16 1996 --- zsh-3.0.0-build/Src/init.c Thu Aug 22 22:28:59 1996 *************** *** 535,542 **** --- 535,546 ---- #ifdef TIOCGWINSZ if (!(columns = shttyinfo.winsize.ws_col)) columns = 80; + if (columns < 2) + opts[USEZLE] = 0; if (!(lines = shttyinfo.winsize.ws_row)) lines = 24; + if (lines < 2) + opts[SINGLELINEZLE] = 1; #else columns = 80; lines = 24; Index: Src/jobs.c *** zsh-3.0.0/Src/jobs.c Wed Jul 31 11:13:17 1996 --- zsh-3.0.0-build/Src/jobs.c Thu Aug 22 22:59:42 1996 *************** *** 221,227 **** { Process pn; int job = jn - jobtab, len = 9, sig, sflag = 0, llen; ! int conted = 0, lineleng = COLUMNS, skip = 0, doputnl = 0; FILE *fout = (synch == 2) ? stdout : shout; if (jn->stat & STAT_NOPRINT) --- 221,227 ---- { Process pn; int job = jn - jobtab, len = 9, sig, sflag = 0, llen; ! int conted = 0, lineleng = columns, skip = 0, doputnl = 0; FILE *fout = (synch == 2) ? stdout : shout; if (jn->stat & STAT_NOPRINT) Index: Src/params.c *** zsh-3.0.0/Src/params.c Sun Aug 4 05:52:33 1996 --- zsh-3.0.0-build/Src/params.c Thu Aug 22 23:13:08 1996 *************** *** 1223,1228 **** --- 1223,1253 ---- *((long *)pm->data) = x; } + /* Function to set value of any ZLE-related integer * + * parameter. data is pointer to global variable * + * where the value is to be stored. */ + + /**/ + void + zlevarsetfn(Param pm, long x) + { + if (x < 2) { + if ((long *)pm->data == & columns) { + if (x <= 0) + x = 80; /* Arbitary, but same as init.c */ + else + x = 2; + opts[USEZLE] = 0; + } else if ((long *)pm->data == & lines) { + if (x <= 0) + x = 24; /* Arbitrary, but same as init.c */ + else + opts[SINGLELINEZLE] = 1; + } + } + *((long *)pm->data) = x; + } + /* Function to set value of generic special scalar * * parameter. data is pointer to a character pointer * * representing the scalar (string). */ *************** *** 1317,1327 **** char ***dptr = (char ***)pm->data; freearray(*dptr); ! if (pm->data == (void *) & mailpath && x && !*x) { zsfree(x); *dptr = mkarray(NULL); } else ! *dptr = x ? colonfix(x, pm->ename ? pm->nam : NULL, pm->flags & PM_UNIQUE) : mkarray(NULL); } /* Function to get the value of special (scalar) * --- 1342,1362 ---- char ***dptr = (char ***)pm->data; freearray(*dptr); ! *dptr = x ? colonfix(x, pm->ename ? pm->nam : NULL, pm->flags & PM_UNIQUE) : mkarray(NULL); ! } ! ! /**/ ! void ! colonarr2setfn(Param pm, char *x) ! { ! char ***dptr = (char ***)pm->data; ! ! if (x && !*x) { ! freearray(*dptr); zsfree(x); *dptr = mkarray(NULL); } else ! colonarrsetfn(pm, x); } /* Function to get the value of special (scalar) * Index: Src/utils.c *** zsh-3.0.0/Src/utils.c Wed Aug 14 09:18:34 1996 --- zsh-3.0.0-build/Src/utils.c Sat Aug 24 14:15:53 1996 *************** *** 844,849 **** --- 844,853 ---- if (shttyinfo.winsize.ws_row) lines = shttyinfo.winsize.ws_row; if (oldcols != columns) { + if (columns < 2) + opts[USEZLE] = 0; + if (lines < 2) + opts[SINGLELINEZLE] = 1; if (zleactive) { resetneeded = winchanged = 1; refresh(); Index: Src/zle_misc.c *** zsh-3.0.0/Src/zle_misc.c Tue Aug 13 13:24:14 1996 --- zsh-3.0.0-build/Src/zle_misc.c Thu Aug 22 22:59:51 1996 *************** *** 835,842 **** if (wp) { *wp = bp - bl0 - lensb; if (pmpt != rpmpt) { ! *wp %= COLUMNS; ! if (*wp == COLUMNS - 1) { addbufspc(1); *wp = 0; *bp++ = ' '; --- 835,842 ---- if (wp) { *wp = bp - bl0 - lensb; if (pmpt != rpmpt) { ! *wp %= columns; ! if (*wp == columns - 1) { addbufspc(1); *wp = 0; *bp++ = ' '; Index: Src/zle_refresh.c *** zsh-3.0.0/Src/zle_refresh.c Sun Aug 11 18:39:05 1996 --- zsh-3.0.0-build/Src/zle_refresh.c Fri Aug 30 23:18:27 1996 *************** *** 66,72 **** int ln; static int lwinw = -1, lwinh = -1; /* last window width & height */ ! winw = COLUMNS; /* terminal width */ if (isset(SINGLELINEZLE) || termok != TERM_OK) winh = 1; else --- 66,72 ---- int ln; static int lwinw = -1, lwinh = -1; /* last window width & height */ ! winw = columns; /* terminal width */ if (isset(SINGLELINEZLE) || termok != TERM_OK) winh = 1; else *************** *** 247,253 **** moveto(0, pptw); } clearf = clearflag; ! } else if (winw != COLUMNS) resetvideo(); /* now winw equals columns; now all width comparisons can be made to winw */ --- 249,255 ---- moveto(0, pptw); } clearf = clearflag; ! } else if (winw != columns) resetvideo(); /* now winw equals columns; now all width comparisons can be made to winw */ Index: Src/zle_tricky.c *** zsh-3.0.0/Src/zle_tricky.c Sun Aug 11 12:15:35 1996 --- zsh-3.0.0-build/Src/zle_tricky.c Sun Aug 25 17:50:38 1996 *************** *** 3469,3475 **** } else { cc++; if (*p == '\n') { ! l += 1 + (cc / COLUMNS); cc = 0; } if (dopr) --- 3470,3476 ---- } else { cc++; if (*p == '\n') { ! l += 1 + (cc / columns); cc = 0; } if (dopr) *************** *** 3477,3483 **** } } ! return l + (cc / COLUMNS); } /* List the matches. Note that the list entries are metafied. */ --- 3478,3484 ---- } } ! return l + (cc / columns); } /* List the matches. Note that the list entries are metafied. */ *************** *** 3551,3557 **** longest++; fw = longest + 2; ! fct = (COLUMNS + 1) / fw; if (fct == 0) { fct = 1; colsz = ct; --- 3552,3558 ---- longest++; fw = longest + 2; ! fct = (columns + 1) / fw; if (fct == 0) { fct = 1; colsz = ct; *************** *** 3559,3565 **** for (ap = arr; *ap; ap++) up += (niceztrlen(*ap + off) - nboff + of + (ispattern ? 0 : ! (!(haswhat & HAS_MISC) ? nfpl + nfsl : nlpl + nlsl))) / COLUMNS; } else { colsz = (ct + fct - 1) / fct; up = colsz + nlnct - clearflag; --- 3560,3566 ---- for (ap = arr; *ap; ap++) up += (niceztrlen(*ap + off) - nboff + of + (ispattern ? 0 : ! (!(haswhat & HAS_MISC) ? nfpl + nfsl : nlpl + nlsl))) / columns; } else { colsz = (ct + fct - 1) / fct; up = colsz + nlnct - clearflag; *************** *** 3739,3749 **** while (t0) t0 /= 10, longest++; /* to compensate for added ')' */ ! fct = (COLUMNS - 1) / (longest + 3); if (fct == 0) fct = 1; else ! fw = (COLUMNS - 1) / fct; colsz = (ct + fct - 1) / fct; for (t1 = 0; t1 != colsz; t1++) { ap = arr + t1; --- 3740,3750 ---- while (t0) t0 /= 10, longest++; /* to compensate for added ')' */ ! fct = (columns - 1) / (longest + 3); if (fct == 0) fct = 1; else ! fw = (columns - 1) / fct; colsz = (ct + fct - 1) / fct; for (t1 = 0; t1 != colsz; t1++) { ap = arr + t1; Index: Src/zsh.h *** zsh-3.0.0/Src/zsh.h Mon Aug 12 10:57:32 1996 --- zsh-3.0.0-build/Src/zsh.h Thu Aug 22 22:56:55 1996 *************** *** 1246,1253 **** #define txtchangeisset(X) (txtchange & (X)) #define txtchangeset(X, Y) (txtchange |= (X), txtchange &= ~(Y)) - #define COLUMNS (columns < 1 ? 80 : columns) - /****************************************/ /* Definitions for the %_ prompt escape */ /****************************************/ --- 1246,1251 ---- -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"