zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Compilation fix for AIX (missing consts)
@ 2011-04-26 13:33 Jérémie Roquet
  2011-04-26 19:16 ` Wayne Davison
  2011-05-03 10:23 ` Peter Stephenson
  0 siblings, 2 replies; 10+ messages in thread
From: Jérémie Roquet @ 2011-04-26 13:33 UTC (permalink / raw)
  To: zsh-workers

Hello,

I've had to fix the source to compile zsh on AIX. It looks like the
protos were wrong anyway, but gcc doesn't complain on Linux…
I'm not sure it doesn't break some other platform, but at least these
are the right protos for AIX, Linux and FreeBSD.

Any thoughts on this?

Best regards,

---
diff --git a/Src/prototypes.h b/Src/prototypes.h
index 07fe2d0..401dccf 100644
--- a/Src/prototypes.h
+++ b/Src/prototypes.h
@@ -34,12 +34,12 @@ char *calloc _((size_t, size_t));
 #endif

 #if !(defined(USES_TERMCAP_H) || defined(USES_TERM_H))
-extern int tgetent _((char *bp, char *name));
+extern int tgetent _((char *bp, const char *name));
 extern int tgetnum _((char *id));
 extern int tgetflag _((char *id));
 extern char *tgetstr _((char *id, char **area));
-extern char *tgoto _((char *cm, int destcol, int destline));
-extern int tputs _((char *cp, int affcnt, int (*outc) (int)));
+extern char *tgoto _((const char *cm, int destcol, int destline));
+extern int tputs _((const char *cp, int affcnt, int (*outc) (int)));
 #endif

 /* MISSING PROTOTYPES FOR VARIOUS OPERATING SYSTEMS */

-- 
Jérémie


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-04-26 13:33 [PATCH] Compilation fix for AIX (missing consts) Jérémie Roquet
@ 2011-04-26 19:16 ` Wayne Davison
  2011-04-27 15:49   ` Jérémie Roquet
  2011-05-03 10:23 ` Peter Stephenson
  1 sibling, 1 reply; 10+ messages in thread
From: Wayne Davison @ 2011-04-26 19:16 UTC (permalink / raw)
  To: Jérémie Roquet; +Cc: zsh-workers

2011/4/26 Jérémie Roquet <arkanosis@gmail.com>:
> I've had to fix the source to compile zsh on AIX. It looks like the
> protos were wrong anyway, but gcc doesn't complain on Linux…

Yeah, that section doesn't get included on Linux, since it has the
prototypes available in the public term.h and termcap.h.  I
(temporarily) commented out the #if/#endif lines and made all the
changes necessary to get it to compile without error, which also
required adding a "const" to the 3 "char *id" args that you didn't
change.  Since that section of the file is only supposed to be used
when the public prototypes aren't available, that should be better
than what we had before.

Does AIX have a conflicting header file?  Or just the calls weren't
matching the prototypes?  If the former, you may want to look into why
the Src/Modules/termcap.c code isn't setting either USES_TERMCAP_H or
USES_TERM_H for AIX.

..wayne..


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-04-26 19:16 ` Wayne Davison
@ 2011-04-27 15:49   ` Jérémie Roquet
  2011-04-27 18:54     ` Wayne Davison
  0 siblings, 1 reply; 10+ messages in thread
From: Jérémie Roquet @ 2011-04-27 15:49 UTC (permalink / raw)
  To: zsh-workers; +Cc: Wayne Davison

2011/4/26 Wayne Davison <wayned@users.sourceforge.net>:
> 2011/4/26 Jérémie Roquet <arkanosis@gmail.com>:
>> I've had to fix the source to compile zsh on AIX. It looks like the
>> protos were wrong anyway, but gcc doesn't complain on Linux…
>
> Yeah, that section doesn't get included on Linux, since it has the
> prototypes available in the public term.h and termcap.h.

Of course… stupid me :-)

> I (temporarily) commented out the #if/#endif lines and made all the
> changes necessary to get it to compile without error, which also
> required adding a "const" to the 3 "char *id" args that you didn't
> change.

Well, I didn't change them because it doesn't match the protos which
are (copy-paste) :

  int tgetent(char *bp, const char *name);
  int tgetflag(char *id);
  int tgetnum(char *id);
  char *tgetstr(char *id, char **area);
  char *tgoto(const char *cap, int col, int row);
  int tputs(const char *str, int affcnt, int (*putc)(int));

That's from the man for Linux and FreeBSD and from the source for AIX.

> Since that section of the file is only supposed to be used
> when the public prototypes aren't available, that should be better
> than what we had before.

Thanks!

> Does AIX have a conflicting header file?  Or just the calls weren't
> matching the prototypes?  If the former, you may want to look into why
> the Src/Modules/termcap.c code isn't setting either USES_TERMCAP_H or
> USES_TERM_H for AIX.

Yes, it's conflicting with the available header.

I haven't spent much time checking who includes who, but it seems that
prototypes.h is included by zsh,mdh which also includes config.h
beforehand but neither defines USES_TERMCAP_H nor USES_TERM_H (which
is done, as expected, by termcap.c).

Best regards,

-- 
Jérémie


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-04-27 15:49   ` Jérémie Roquet
@ 2011-04-27 18:54     ` Wayne Davison
  2011-05-03 12:23       ` Jérémie Roquet
  0 siblings, 1 reply; 10+ messages in thread
From: Wayne Davison @ 2011-04-27 18:54 UTC (permalink / raw)
  To: Jérémie Roquet; +Cc: zsh-workers

2011/4/27 Jérémie Roquet <arkanosis@gmail.com>:
> That's from the man for Linux and FreeBSD and from the source for AIX.

In Linux they now have the extra "const"s in the include files, though
not in the man pages.

> Yes, it's conflicting with the available header.

So, where are those defined in your /usr/include files?  The best fix
is to avoid manual prototypes on systems that have them already
defined.  So we should work out a rule that avoids including that
section on AIX.  What do the various TERM vars get defined as in
config.h?

..wayne..


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-04-26 13:33 [PATCH] Compilation fix for AIX (missing consts) Jérémie Roquet
  2011-04-26 19:16 ` Wayne Davison
@ 2011-05-03 10:23 ` Peter Stephenson
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2011-05-03 10:23 UTC (permalink / raw)
  To: zsh-workers

On Tue, 26 Apr 2011 15:33:52 +0200
Jérémie Roquet <arkanosis@gmail.com> wrote:
> I've had to fix the source to compile zsh on AIX. It looks like the
> protos were wrong anyway, but gcc doesn't complain on Linux…
> I'm not sure it doesn't break some other platform, but at least these
> are the right protos for AIX, Linux and FreeBSD.
> 
> Any thoughts on this?

As Wayne says, we really need to find the headers, but until then the
following should at least be safe... although this code hasn't change
for a very long time, and it used to compile on AIX, so it's possible
there's a version issue (the other possibility is it's a
local configuration issue).

Index: Src/prototypes.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prototypes.h,v
retrieving revision 1.5
diff -p -u -r1.5 prototypes.h
--- Src/prototypes.h	20 Dec 2010 10:28:43 -0000	1.5
+++ Src/prototypes.h	3 May 2011 10:20:43 -0000
@@ -34,12 +34,24 @@ char *calloc _((size_t, size_t));
 #endif
 
 #if !(defined(USES_TERMCAP_H) || defined(USES_TERM_H))
-extern int tgetent _((char *bp, char *name));
+/*
+ * These prototypes are only used where we don't have the
+ * headers.  In some cases they need tweaking.
+ * TBD: we'd much prefer to get hold of the header where
+ * these are defined.
+ */
+#ifdef _AIX
+#define TC_CONST const
+#else
+#define TC_CONST
+#endif
+extern int tgetent _((char *bp, TC_CONST char *name));
 extern int tgetnum _((char *id));
 extern int tgetflag _((char *id));
 extern char *tgetstr _((char *id, char **area));
-extern char *tgoto _((char *cm, int destcol, int destline));
-extern int tputs _((char *cp, int affcnt, int (*outc) (int)));
+extern char *tgoto _((TC_CONST char *cm, int destcol, int destline));
+extern int tputs _((TC_CONST char *cp, int affcnt, int (*outc) (int)));
+#undef TC_CONST
 #endif
 
 /* MISSING PROTOTYPES FOR VARIOUS OPERATING SYSTEMS */

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-04-27 18:54     ` Wayne Davison
@ 2011-05-03 12:23       ` Jérémie Roquet
  2011-05-06 13:51         ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Jérémie Roquet @ 2011-05-03 12:23 UTC (permalink / raw)
  To: zsh-workers; +Cc: Wayne Davison

Hello,

Sorry, I've been away from AIX for a few days…

2011/4/27 Wayne Davison <wayned@users.sourceforge.net>:
> 2011/4/27 Jérémie Roquet <arkanosis@gmail.com>:
>> That's from the man for Linux and FreeBSD and from the source for AIX.
>
> In Linux they now have the extra "const"s in the include files, though
> not in the man pages.
>
>> Yes, it's conflicting with the available header.
>
> So, where are those defined in your /usr/include files?  The best fix
> is to avoid manual prototypes on systems that have them already
> defined.  So we should work out a rule that avoids including that
> section on AIX.  What do the various TERM vars get defined as in
> config.h?

So… I have /usr/include/term.h and :

$ grep TERM config.h
/* #undef HAVE_NCURSESW_TERM_H */
/* #undef HAVE_NCURSES_TERM_H */
#define HAVE_SETUPTERM 1
/* #undef HAVE_TERMCAP_H */
#define HAVE_TERMIOS_H 1
#define HAVE_TERMIO_H 1
#define HAVE_TERM_H 1
#define ZSH_HAVE_TERM_H 1

$ grep CURSES config.h
#define HAVE_CURSES_H 1
#define HAVE_NCURSESW_NCURSES_H 1
#define HAVE_NCURSESW_TERM_H 1
#define HAVE_NCURSES_H 1
/* #undef HAVE_NCURSES_NCURSES_H */
/* #undef HAVE_NCURSES_TERM_H */
#define ZSH_HAVE_CURSES_H 1

$ grep TGETENT config.h
#define HAVE_TGETENT 1
#define TGETENT_ACCEPTS_NULL 1
#define TGETENT_SUCCESS 1

Which I think is fine.

But prototypes.h declares the prototypes whenever it is included if
!(defined(USES_TERMCAP_H) || defined(USES_TERM_H)); which means the
files that include it (ie. the files that include zsh.mdh, since it's
the only file to directly include prototypes.h) have to define one of
these macros before the inclusion.

That's what termcap.c does:

#include "../../config.h"

#ifdef HAVE_TGETENT
# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H)
#  define USES_TERM_H 1
# else
#  ifdef HAVE_TERMCAP_H
#   define USES_TERMCAP_H 1
#  endif
# endif
#endif

#include "termcap.mdh"

… but termcap.c is the only one to do that (along wtih terminfo.c
which always define the macro, regardless of the values in config.h).

Every other single file that include zsh.mdh (and prototypes.h) does
not set USES_*.
For example, loop.c, prompt.c, sort.c… (there are about ~30 of them)
include zsh.mdh (and prototypes.h) without defining USES_* so they
declare the prototypes even when the HAVE_* macros are defined.

I may have missed something, but I think it's the whole problem.

Best regards,

-- 
Jérémie


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-05-03 12:23       ` Jérémie Roquet
@ 2011-05-06 13:51         ` Peter Stephenson
  2011-05-06 14:16           ` Peter Stephenson
  2011-05-09  9:54           ` Peter Stephenson
  0 siblings, 2 replies; 10+ messages in thread
From: Peter Stephenson @ 2011-05-06 13:51 UTC (permalink / raw)
  To: zsh-workers

On Tue, 3 May 2011 14:23:04 +0200
Jérémie Roquet <arkanosis@gmail.com> wrote:
> But prototypes.h declares the prototypes whenever it is included if
> !(defined(USES_TERMCAP_H) || defined(USES_TERM_H)); which means the
> files that include it (ie. the files that include zsh.mdh, since it's
> the only file to directly include prototypes.h) have to define one of
> these macros before the inclusion.
> 
> That's what termcap.c does:
>...
> … but termcap.c is the only one to do that (along wtih terminfo.c
> which always define the macro, regardless of the values in config.h).
> 
> Every other single file that include zsh.mdh (and prototypes.h) does
> not set USES_*.

Hmm.

The problem is the following.

We can't currently #include <term.h> in the main shell as there are
clashes, so we #include <termcap.h> there (well, in principle at lest)
and only #include <term.h> in those files that need them.

However, so far as I know the same difficulties will turn up with term.h
on AIX as with the Fedora system where this happened.  So to fix it for
AIX (an, indeed, to have any remote hope of keeping the AIX version in
sync with the rest) we need to allow term.h to be included in the main
shell.

The issues I can see are with the names columns, lines, move, newline
and tab (ick!).  After fixing these, this now compiles and runs
correctly on my machine.  I can't entirely exclude the possibility it
has subtly redefined some other word.

Unfortunately, it means we're at the mercy of term.h everywhere it
exists.  Given that this only happens in the case we are trying to use
it in at least one part of the shell, it's probably the right thing to
do to use it everywhere.  However, this could do with some major
testing.  I'll upload a new test version soon.

The only remotely interesting bits in the patch are in system.h and
termcap.c.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.250
diff -p -u -r1.250 builtin.c
--- Src/builtin.c	11 Apr 2011 16:34:21 -0000	1.250
+++ Src/builtin.c	6 May 2011 13:45:50 -0000
@@ -3903,7 +3903,7 @@ bin_print(char *name, char **args, Optio
 	     * nc: number of columns (at least one)
 	     */
 	    sc = l + 2;
-	    nc = (columns + 1) / sc;
+	    nc = (zterm_columns + 1) / sc;
 	    if (!nc)
 		nc = 1;
 	    nr = (n + nc - 1) / nc;
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.193
diff -p -u -r1.193 exec.c
--- Src/exec.c	2 May 2011 12:32:43 -0000	1.193
+++ Src/exec.c	6 May 2011 13:45:50 -0000
@@ -4398,7 +4398,7 @@ loadautofn(Shfunc shf, int fksh, int aut
 mod_export int
 doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
 {
-    char **tab, **x, *oargv0;
+    char **pptab, **x, *oargv0;
     int oldzoptind, oldlastval, oldoptcind, oldnumpipestats, ret;
     int *oldpipestats = NULL;
     char saveopts[OPT_SIZE], *oldscriptname = scriptname;
@@ -4432,7 +4432,7 @@ doshfunc(Shfunc shfunc, LinkList dosharg
 
     starttrapscope();
 
-    tab = pparams;
+    pptab = pparams;
     if (!(flags & PM_UNDEFINED))
 	scriptname = dupstring(name);
     oldzoptind = zoptind;
@@ -4548,7 +4548,7 @@ doshfunc(Shfunc shfunc, LinkList dosharg
 	zsfree(argzero);
 	argzero = oargv0;
     }
-    pparams = tab;
+    pparams = pptab;
     optcind = oldoptcind;
     zoptind = oldzoptind;
     scriptname = oldscriptname;
Index: Src/glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.75
diff -p -u -r1.75 glob.c
--- Src/glob.c	10 Jan 2011 18:24:17 -0000	1.75
+++ Src/glob.c	6 May 2011 13:45:50 -0000
@@ -2000,7 +2000,7 @@ hasbraces(char *str)
 
 /**/
 int
-xpandredir(struct redir *fn, LinkList tab)
+xpandredir(struct redir *fn, LinkList redirtab)
 {
     char *nam;
     struct redir *ff;
@@ -2048,7 +2048,7 @@ xpandredir(struct redir *fn, LinkList ta
 	    ff = (struct redir *) zhalloc(sizeof *ff);
 	    *ff = *fn;
 	    ff->name = nam;
-	    addlinknode(tab, ff);
+	    addlinknode(redirtab, ff);
 	    ret = 1;
 	}
     }
Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.32
diff -p -u -r1.32 hashtable.c
--- Src/hashtable.c	21 Sep 2009 09:22:23 -0000	1.32
+++ Src/hashtable.c	6 May 2011 13:45:50 -0000
@@ -59,7 +59,7 @@ struct scanstatus {
     int sorted;
     union {
 	struct {
-	    HashNode *tab;
+	    HashNode *hashtab;
 	    int ct;
 	} s;
 	HashNode u;
@@ -187,11 +187,11 @@ addhashnode2(HashTable ht, char *nam, vo
 	hn->next = hp->next;
 	if(ht->scan) {
 	    if(ht->scan->sorted) {
-		HashNode *tab = ht->scan->u.s.tab;
+		HashNode *hashtab = ht->scan->u.s.hashtab;
 		int i;
 		for(i = ht->scan->u.s.ct; i--; )
-		    if(tab[i] == hp)
-			tab[i] = hn;
+		    if(hashtab[i] == hp)
+			hashtab[i] = hn;
 	    } else if(ht->scan->u.u == hp)
 		ht->scan->u.u = hn;
 	}
@@ -286,11 +286,11 @@ removehashnode(HashTable ht, const char 
 	ht->ct--;
 	if(ht->scan) {
 	    if(ht->scan->sorted) {
-		HashNode *tab = ht->scan->u.s.tab;
+		HashNode *hashtab = ht->scan->u.s.hashtab;
 		int i;
 		for(i = ht->scan->u.s.ct; i--; )
-		    if(tab[i] == hp)
-			tab[i] = NULL;
+		    if(hashtab[i] == hp)
+			hashtab[i] = NULL;
 	    } else if(ht->scan->u.u == hp)
 		ht->scan->u.u = hp->next;
 	}
@@ -397,7 +397,7 @@ scanmatchtable(HashTable ht, Patprog ppr
 	qsort((void *)hnsorttab, ct, sizeof(HashNode), hnamcmp);
 
 	st.sorted = 1;
-	st.u.s.tab = hnsorttab;
+	st.u.s.hashtab = hnsorttab;
 	st.u.s.ct = ct;
 	ht->scan = &st;
 
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.119
diff -p -u -r1.119 init.c
--- Src/init.c	18 Apr 2011 20:36:31 -0000	1.119
+++ Src/init.c	6 May 2011 13:45:50 -0000
@@ -908,8 +908,8 @@ setupvals(void)
     /* columns and lines are normally zero, unless something different *
      * was inhereted from the environment.  If either of them are zero *
      * the setiparam calls below set them to the defaults from termcap */
-    setiparam("COLUMNS", columns);
-    setiparam("LINES", lines);
+    setiparam("COLUMNS", zterm_columns);
+    setiparam("LINES", zterm_lines);
 #endif
 
 #ifdef HAVE_GETRLIMIT
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.80
diff -p -u -r1.80 jobs.c
--- Src/jobs.c	1 Apr 2011 11:02:16 -0000	1.80
+++ Src/jobs.c	6 May 2011 13:45:50 -0000
@@ -893,7 +893,7 @@ printjob(Job jn, int lng, int synch)
 {
     Process pn;
     int job, len = 9, sig, sflag = 0, llen;
-    int conted = 0, lineleng = columns, skip = 0, doputnl = 0;
+    int conted = 0, lineleng = zterm_columns, skip = 0, doputnl = 0;
     int doneprint = 0, skip_print = 0;
     FILE *fout = (synch == 2 || !shout) ? stdout : shout;
 
Index: Src/loop.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/loop.c,v
retrieving revision 1.25
diff -p -u -r1.25 loop.c
--- Src/loop.c	31 Jul 2008 08:44:21 -0000	1.25
+++ Src/loop.c	6 May 2011 13:45:50 -0000
@@ -324,13 +324,13 @@ selectlist(LinkList l, size_t start)
     while (t0)
 	t0 /= 10, longest++;
     /* to compensate for added ')' */
-    fct = (columns - 1) / (longest + 3);
+    fct = (zterm_columns - 1) / (longest + 3);
     if (fct == 0)
 	fct = 1;
     else
-	fw = (columns - 1) / fct;
+	fw = (zterm_columns - 1) / fct;
     colsz = (ct + fct - 1) / fct;
-    for (t1 = start; t1 != colsz && t1 - start < lines - 2; t1++) {
+    for (t1 = start; t1 != colsz && t1 - start < zterm_lines - 2; t1++) {
 	ap = arr + t1;
 	do {
 	    size_t t2 = strlen(*ap) + 2;
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.169
diff -p -u -r1.169 params.c
--- Src/params.c	16 Jan 2011 20:35:31 -0000	1.169
+++ Src/params.c	6 May 2011 13:45:51 -0000
@@ -94,8 +94,8 @@ mod_export
 zlong lastval,		/* $?           */
      mypid,		/* $$           */
      lastpid,		/* $!           */
-     columns,		/* $COLUMNS     */
-     lines,		/* $LINES       */
+     zterm_columns,	/* $COLUMNS     */
+     zterm_lines,	/* $LINES       */
      ppid,		/* $PPID        */
      zsh_subshell;	/* $ZSH_SUBSHELL */
 /**/
@@ -312,8 +312,8 @@ IPDEF4("PPID", &ppid),
 IPDEF4("ZSH_SUBSHELL", &zsh_subshell),
 
 #define IPDEF5(A,B,F) {{NULL,A,PM_INTEGER|PM_SPECIAL},BR((void *)B),GSU(varinteger_gsu),10,0,NULL,NULL,NULL,0}
-IPDEF5("COLUMNS", &columns, zlevar_gsu),
-IPDEF5("LINES", &lines, zlevar_gsu),
+IPDEF5("COLUMNS", &zterm_columns, zlevar_gsu),
+IPDEF5("LINES", &zterm_lines, zlevar_gsu),
 IPDEF5("OPTIND", &zoptind, varinteger_gsu),
 IPDEF5("SHLVL", &shlvl, varinteger_gsu),
 IPDEF5("TRY_BLOCK_ERROR", &try_errflag, varinteger_gsu),
@@ -3269,8 +3269,8 @@ zlevarsetfn(Param pm, zlong x)
     zlong *p = pm->u.valptr;
 
     *p = x;
-    if (p == &lines || p == &columns)
-	adjustwinsize(2 + (p == &columns));
+    if (p == &zterm_lines || p == &zterm_columns)
+	adjustwinsize(2 + (p == &zterm_columns));
 }
 
 /* Function to set value of generic special scalar    *
Index: Src/prompt.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v
retrieving revision 1.61
diff -p -u -r1.61 prompt.c
--- Src/prompt.c	4 Mar 2011 13:25:26 -0000	1.61
+++ Src/prompt.c	6 May 2011 13:45:51 -0000
@@ -1008,7 +1008,7 @@ countprompt(char *str, int *wp, int *hp,
 #endif
 
     for (; *str; str++) {
-	if (w >= columns && overf >= 0) {
+	if (w >= zterm_columns && overf >= 0) {
 	    w = 0;
 	    h++;
 	}
@@ -1092,8 +1092,8 @@ countprompt(char *str, int *wp, int *hp,
      * This isn't easy to handle generally; just assume there's no
      * output.
      */
-    if(w >= columns && overf >= 0) {
-	if (!overf || w > columns) {
+    if(w >= zterm_columns && overf >= 0) {
+	if (!overf || w > zterm_columns) {
 	    w = 0;
 	    h++;
 	}
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.58
diff -p -u -r1.58 system.h
--- Src/system.h	14 Apr 2011 09:11:03 -0000	1.58
+++ Src/system.h	6 May 2011 13:45:51 -0000
@@ -850,3 +850,27 @@ extern short ospeed;
 #elif HAVE_STRUCT_STAT_ST_CTIMENSEC
 # define GET_ST_CTIME_NSEC(st) (st).st_ctimensec
 #endif
+
+#ifdef HAVE_TGETENT
+# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H)
+#  define USES_TERM_H 1
+# else
+#  ifdef HAVE_TERMCAP_H
+#   define USES_TERMCAP_H 1
+#  endif
+# endif
+
+# ifdef USES_TERM_H
+#  ifdef HAVE_TERMIO_H
+#   include <termio.h>
+#  endif
+#  ifdef ZSH_HAVE_CURSES_H
+#   include "zshcurses.h"
+#  endif
+#  include "zshterm.h"
+# else
+#  ifdef USES_TERMCAP_H
+#   include <termcap.h>
+#  endif
+# endif
+#endif
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.257
diff -p -u -r1.257 utils.c
--- Src/utils.c	6 Apr 2011 00:04:06 -0000	1.257
+++ Src/utils.c	6 May 2011 13:45:51 -0000
@@ -1296,7 +1296,8 @@ preprompt(void)
 	countprompt(str, &w, 0, -1);
 	opts[PROMPTPERCENT] = percents;
 	zputs(str, shout);
-	fprintf(shout, "%*s\r%*s\r", (int)columns - w - !hasxn, "", w, "");
+	fprintf(shout, "%*s\r%*s\r", (int)zterm_columns - w - !hasxn,
+		"", w, "");
 	fflush(shout);
 	free(str);
     }
@@ -1558,49 +1559,49 @@ mod_export int winchanged;
 static int
 adjustlines(int signalled)
 {
-    int oldlines = lines;
+    int oldlines = zterm_lines;
 
 #ifdef TIOCGWINSZ
-    if (signalled || lines <= 0)
-	lines = shttyinfo.winsize.ws_row;
+    if (signalled || zterm_lines <= 0)
+	zterm_lines = shttyinfo.winsize.ws_row;
     else
-	shttyinfo.winsize.ws_row = lines;
+	shttyinfo.winsize.ws_row = zterm_lines;
 #endif /* TIOCGWINSZ */
-    if (lines <= 0) {
+    if (zterm_lines <= 0) {
 	DPUTS(signalled, "BUG: Impossible TIOCGWINSZ rows");
-	lines = tclines > 0 ? tclines : 24;
+	zterm_lines = tclines > 0 ? tclines : 24;
     }
 
-    if (lines > 2)
+    if (zterm_lines > 2)
 	termflags &= ~TERM_SHORT;
     else
 	termflags |= TERM_SHORT;
 
-    return (lines != oldlines);
+    return (zterm_lines != oldlines);
 }
 
 static int
 adjustcolumns(int signalled)
 {
-    int oldcolumns = columns;
+    int oldcolumns = zterm_columns;
 
 #ifdef TIOCGWINSZ
-    if (signalled || columns <= 0)
-	columns = shttyinfo.winsize.ws_col;
+    if (signalled || zterm_columns <= 0)
+	zterm_columns = shttyinfo.winsize.ws_col;
     else
-	shttyinfo.winsize.ws_col = columns;
+	shttyinfo.winsize.ws_col = zterm_columns;
 #endif /* TIOCGWINSZ */
-    if (columns <= 0) {
+    if (zterm_columns <= 0) {
 	DPUTS(signalled, "BUG: Impossible TIOCGWINSZ cols");
-	columns = tccolumns > 0 ? tccolumns : 80;
+	zterm_columns = tccolumns > 0 ? tccolumns : 80;
     }
 
-    if (columns > 2)
+    if (zterm_columns > 2)
 	termflags &= ~TERM_NARROW;
     else
 	termflags |= TERM_NARROW;
 
-    return (columns != oldcolumns);
+    return (zterm_columns != oldcolumns);
 }
 
 /* check the size of the window and adjust if necessary. *
@@ -1634,8 +1635,8 @@ adjustwinsize(int from)
 	    ttycols = shttyinfo.winsize.ws_col;
 	} else {
 	    /* Set to value from environment on failure */
-	    shttyinfo.winsize.ws_row = lines;
-	    shttyinfo.winsize.ws_col = columns;
+	    shttyinfo.winsize.ws_row = zterm_lines;
+	    shttyinfo.winsize.ws_col = zterm_columns;
 	    resetzle = (from == 1);
 	}
 #else
@@ -1655,9 +1656,9 @@ adjustwinsize(int from)
 	 * but I'm concerned about what happens on race conditions; e.g., *
 	 * suppose the user resizes his xterm during `eval $(resize)'?    */
 	if (adjustlines(from) && zgetenv("LINES"))
-	    setiparam("LINES", lines);
+	    setiparam("LINES", zterm_lines);
 	if (adjustcolumns(from) && zgetenv("COLUMNS"))
-	    setiparam("COLUMNS", columns);
+	    setiparam("COLUMNS", zterm_columns);
 	getwinsz = 1;
 	break;
     case 2:
Index: Src/Modules/files.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/files.c,v
retrieving revision 1.21
diff -p -u -r1.21 files.c
--- Src/Modules/files.c	24 Mar 2009 12:52:08 -0000	1.21
+++ Src/Modules/files.c	6 May 2011 13:45:51 -0000
@@ -195,7 +195,7 @@ bin_rmdir(char *nam, char **args, UNUSED
 static int
 bin_ln(char *nam, char **args, Options ops, int func)
 {
-    MoveFunc move;
+    MoveFunc movefn;
     int flags, have_dir, err = 0;
     char **a, *ptr, *rp, *buf;
     struct stat st;
@@ -203,7 +203,7 @@ bin_ln(char *nam, char **args, Options o
 
 
     if(func == BIN_MV) {
-	move = (MoveFunc) rename;
+	movefn = (MoveFunc) rename;
 	flags = OPT_ISSET(ops,'f') ? 0 : MV_ASKNW;
 	flags |= MV_ATOMIC;
     } else {
@@ -212,11 +212,11 @@ bin_ln(char *nam, char **args, Options o
 	if(OPT_ISSET(ops,'h') || OPT_ISSET(ops,'n'))
 	    flags |= MV_NOCHASETARGET;
 	if(OPT_ISSET(ops,'s'))
-	    move = (MoveFunc) symlink;
+	    movefn = (MoveFunc) symlink;
 	else
 #endif
 	{
-	    move = (MoveFunc) link;
+	    movefn = (MoveFunc) link;
 	    if(!OPT_ISSET(ops,'d'))
 		flags |= MV_NODIRS;
 	}
@@ -267,7 +267,7 @@ bin_ln(char *nam, char **args, Options o
 	else
 	    args[1] = args[0];
     }
-    return domove(nam, move, args[0], args[1], flags);
+    return domove(nam, movefn, args[0], args[1], flags);
  havedir:
     buf = ztrdup(*a);
     *a = NULL;
@@ -283,7 +283,7 @@ bin_ln(char *nam, char **args, Options o
 
 	buf[blen] = 0;
 	buf = appstr(buf, ptr);
-	err |= domove(nam, move, *args, buf, flags);
+	err |= domove(nam, movefn, *args, buf, flags);
     }
     zsfree(buf);
     return err;
@@ -291,7 +291,7 @@ bin_ln(char *nam, char **args, Options o
 
 /**/
 static int
-domove(char *nam, MoveFunc move, char *p, char *q, int flags)
+domove(char *nam, MoveFunc movefn, char *p, char *q, int flags)
 {
     struct stat st;
     char *pbuf, *qbuf;
@@ -341,7 +341,7 @@ domove(char *nam, MoveFunc move, char *p
 	if(doit && !(flags & MV_ATOMIC))
 	    unlink(qbuf);
     }
-    if(move(pbuf, qbuf)) {
+    if(movefn(pbuf, qbuf)) {
 	zwarnnam(nam, "%s: %e", p, errno);
 	zsfree(pbuf);
 	return 1;
Index: Src/Modules/termcap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.c,v
retrieving revision 1.28
diff -p -u -r1.28 termcap.c
--- Src/Modules/termcap.c	2 Jun 2010 13:13:43 -0000	1.28
+++ Src/Modules/termcap.c	6 May 2011 13:45:51 -0000
@@ -35,34 +35,11 @@
  */
 #include "../../config.h"
 
-#ifdef HAVE_TGETENT
-# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H)
-#  define USES_TERM_H 1
-# else
-#  ifdef HAVE_TERMCAP_H
-#   define USES_TERMCAP_H 1
-#  endif
-# endif
-#endif
-
 #include "termcap.mdh"
 #include "termcap.pro"
 
 /**/
 #ifdef HAVE_TGETENT
-# ifdef USES_TERM_H
-#  ifdef HAVE_TERMIO_H
-#   include <termio.h>
-#  endif
-#  ifdef ZSH_HAVE_CURSES_H
-#   include "../zshcurses.h"
-#  endif
-#  include "../zshterm.h"
-# else
-#  ifdef USES_TERMCAP_H
-#   include <termcap.h>
-#  endif
-# endif
 
 #ifndef HAVE_BOOLCODES
 static char *boolcodes[] = {
Index: Src/Modules/zpty.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zpty.c,v
retrieving revision 1.44
diff -p -u -r1.44 zpty.c
--- Src/Modules/zpty.c	12 May 2010 10:07:02 -0000	1.44
+++ Src/Modules/zpty.c	6 May 2011 13:45:51 -0000
@@ -351,8 +351,8 @@ newptycmd(char *nam, char *pname, char *
 	    struct ttyinfo info;
 
 	    if (ioctl(slave, TIOCGWINSZ, (char *) &info.winsize) == 0) {
-		info.winsize.ws_row = lines;
-		info.winsize.ws_col = columns;
+		info.winsize.ws_row = zterm_lines;
+		info.winsize.ws_col = zterm_columns;
 		ioctl(slave, TIOCSWINSZ, (char *) &info.winsize);
 	    }
 	}
Index: Src/Zle/comp.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/comp.h,v
retrieving revision 1.19
diff -p -u -r1.19 comp.h
--- Src/Zle/comp.h	15 Nov 2008 21:27:46 -0000	1.19
+++ Src/Zle/comp.h	6 May 2011 13:45:51 -0000
@@ -323,8 +323,8 @@ struct cadata {
 typedef struct cldata *Cldata;
 
 struct cldata {
-    int columns;		/* screen width */
-    int lines;			/* screen height */
+    int zterm_columns;		/* screen width */
+    int zterm_lines;		/* screen height */
     int menuacc;		/* value of global menuacc */
     int valid;			/* no need to calculate anew */
     int nlist;			/* number of matches to list */
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.124
diff -p -u -r1.124 complist.c
--- Src/Zle/complist.c	24 Apr 2011 19:10:20 -0000	1.124
+++ Src/Zle/complist.c	6 May 2011 13:45:51 -0000
@@ -656,7 +656,7 @@ clprintfmt(char *p, int ml)
 		tcout(TCCLEAREOL);
 	    cc = 0;
 	}
-	if (ml == mlend - 1 && (cc % columns) == columns - 1)
+	if (ml == mlend - 1 && (cc % zterm_columns) == zterm_columns - 1)
 	    return 0;
 
 	if (*p == Meta) {
@@ -664,9 +664,9 @@ clprintfmt(char *p, int ml)
 	    putc(*p ^ 32, shout);
 	} else
 	    putc(*p, shout);
-	if ((beg = !(cc % columns)))
+	if ((beg = !(cc % zterm_columns)))
 	    ml++;
-	if (mscroll && !(cc % columns) &&
+	if (mscroll && !(cc % zterm_columns) &&
 	    !--mrestlines && (ask = asklistscroll(ml)))
 	    return ask;
     }
@@ -765,7 +765,7 @@ clnicezputs(int do_colors, char *s, int 
 	    /* Input is metafied... */
 	    int nc = (*t == Meta) ? STOUC(*++t ^ 32) : STOUC(*t);
 	    /* Is the screen full? */
-	    if (ml == mlend - 1 && col == columns - 1) {
+	    if (ml == mlend - 1 && col == zterm_columns - 1) {
 		mlprinted = ml - oml;
 		return 0;
 	    }
@@ -787,13 +787,13 @@ clnicezputs(int do_colors, char *s, int 
 	     * There might be problems with characters of printing width
 	     * greater than one here.
 	     */
-	    if (col > columns) {
+	    if (col > zterm_columns) {
 		ml++;
 		if (mscroll && !--mrestlines && (ask = asklistscroll(ml))) {
 		    mlprinted = ml - oml;
 		    return ask;
 		}
-		col -= columns;
+		col -= zterm_columns;
 		if (do_colors)
 		    fputs(" \010", shout);
 	    }
@@ -820,12 +820,12 @@ clnicezputs(int do_colors, char *s, int 
 
 	for (t = nicechar(cc); *t; t++) {
 	    int nc = (*t == Meta) ? STOUC(*++t ^ 32) : STOUC(*t);
-	    if (ml == mlend - 1 && col == columns - 1) {
+	    if (ml == mlend - 1 && col == zterm_columns - 1) {
 		mlprinted = ml - oml;
 		return 0;
 	    }
 	    putc(nc, shout);
-	    if (++col > columns) {
+	    if (++col > zterm_columns) {
 		ml++;
 		if (mscroll && !--mrestlines && (ask = asklistscroll(ml))) {
 		    mlprinted = ml - oml;
@@ -991,7 +991,7 @@ asklistscroll(int ml)
 		   !strcmp(cmd->nam, "expand-or-complete-prefix") ||
 		   !strcmp(cmd->nam, "menu-complete") ||
 	     !strcmp(cmd->nam, "menu-expand-or-complete"))
-	mrestlines = lines - 1;
+	mrestlines = zterm_lines - 1;
     else if (cmd == Th(z_acceptsearch))
 	ret = 1;
     else {
@@ -1001,7 +1001,7 @@ asklistscroll(int ml)
     selectlocalmap(NULL);
     settyinfo(&shttyinfo);
     putc('\r', shout);
-    for (i = columns - 1; i-- > 0; )
+    for (i = zterm_columns - 1; i-- > 0; )
 	putc(' ', shout);
     putc('\r', shout);
 
@@ -1213,8 +1213,8 @@ compprintfmt(char *fmt, int n, int dopr,
 		    /* nc only contains ASCII text */
 		    int l = strlen(nc);
 
-		    if (l + cc > columns - 2)
-			nc[l -= l + cc - (columns - 2)] = '\0';
+		    if (l + cc > zterm_columns - 2)
+			nc[l -= l + cc - (zterm_columns - 2)] = '\0';
 		    fputs(nc, shout);
 		    cc += l;
 		} else if (dopr && m == 1) {
@@ -1230,16 +1230,17 @@ compprintfmt(char *fmt, int n, int dopr,
 	} else {
 	    cc += width;
 
-	    if ((cc >= columns - 2 || cchar == ZWC('\n')) && stat)
+	    if ((cc >= zterm_columns - 2 || cchar == ZWC('\n')) && stat)
 		dopr = 2;
 	    if (cchar == ZWC('\n')) {
 		if (dopr == 1 && mlbeg >= 0 && tccan(TCCLEAREOL))
 		    tcout(TCCLEAREOL);
-		l += 1 + ((cc - 1) / columns);
+		l += 1 + ((cc - 1) / zterm_columns);
 		cc = 0;
 	    }
 	    if (dopr == 1) {
-		if (ml == mlend - 1 && (cc % columns) == columns - 1) {
+		if (ml == mlend - 1 && (cc % zterm_columns) ==
+		    zterm_columns - 1) {
 		    dopr = 0;
 		    p += len;
 		    continue;
@@ -1256,7 +1257,7 @@ compprintfmt(char *fmt, int n, int dopr,
 		 * TODO: the following doesn't allow for
 		 * character widths greater than 1.
 		 */
-		if ((beg = !(cc % columns)) && !stat) {
+		if ((beg = !(cc % zterm_columns)) && !stat) {
 		    ml++;
                     fputs(" \010", shout);
                 }
@@ -1264,7 +1265,7 @@ compprintfmt(char *fmt, int n, int dopr,
 		    *stop = 1;
 		    if (stat && n)
 			mfirstl = -1;
-		    mlprinted = l + (cc ? ((cc-1) / columns) : 0);
+		    mlprinted = l + (cc ? ((cc-1) / zterm_columns) : 0);
 		    return mlprinted;
 		}
 	    }
@@ -1273,7 +1274,7 @@ compprintfmt(char *fmt, int n, int dopr,
 	}
     }
     if (dopr) {
-        if (!(cc % columns))
+        if (!(cc % zterm_columns))
             fputs(" \010", shout);
         if (mlbeg >= 0 && tccan(TCCLEAREOL))
             tcout(TCCLEAREOL);
@@ -1285,7 +1286,7 @@ compprintfmt(char *fmt, int n, int dopr,
      * *Not* subtracting 1 from cc at this point appears to be
      * correct.  C.f. printfmt in zle_tricky.c.
      */
-    mlprinted = l + (cc / columns);
+    mlprinted = l + (cc / zterm_columns);
     return mlprinted;
 }
 
@@ -1309,7 +1310,7 @@ compzputs(char const *s, int ml)
 	putc(c, shout);
 	if (c == '\n' && mlbeg >= 0 && tccan(TCCLEAREOL))
 	    tcout(TCCLEAREOL);
-	if (mscroll && (++col == columns || c == '\n')) {
+	if (mscroll && (++col == zterm_columns || c == '\n')) {
 	    ml++;
 	    if (!--mrestlines && (ask = asklistscroll(ml)))
 		return ask;
@@ -1344,10 +1345,11 @@ compprintlist(int showall)
 	lastml = 0;
 	lastnlnct = -1;
     }
-    cl = (listdat.nlines > lines - nlnct - mhasstat ?
-	  lines - nlnct - mhasstat : listdat.nlines) - (lastnlnct > nlnct);
+    cl = (listdat.nlines > zterm_lines - nlnct - mhasstat ?
+	  zterm_lines - nlnct - mhasstat :
+	  listdat.nlines) - (lastnlnct > nlnct);
     lastnlnct = nlnct;
-    mrestlines = lines - 1;
+    mrestlines = zterm_lines - 1;
     lastinvcount = invcount;
 
     if (cl < 2) {
@@ -1643,20 +1645,20 @@ compprintlist(int showall)
 	/* Move the cursor up to the prompt, if always_last_prompt *
 	 * is set and all that...                                  */
 	if (mlbeg >= 0) {
-	    if ((nl = listdat.nlines + nlnct) >= lines) {
+	    if ((nl = listdat.nlines + nlnct) >= zterm_lines) {
 		if (mhasstat) {
 		    putc('\n', shout);
 		    compprintfmt(NULL, 0, 1, 1, mline, NULL);
                     mstatprinted = 1;
 		}
-		nl = lines - 1;
+		nl = zterm_lines - 1;
 	    } else
 		nl--;
 	    tcmultout(TCUP, TCMULTUP, nl);
 	    showinglist = -1;
 
 	    lastlistlen = listdat.nlines;
-	} else if ((nl = listdat.nlines + nlnct - 1) < lines) {
+	} else if ((nl = listdat.nlines + nlnct - 1) < zterm_lines) {
 	    if (mlbeg >= 0 && tccan(TCCLEAREOL))
 		tcout(TCCLEAREOL);
 	    tcmultout(TCUP, TCMULTUP, nl);
@@ -1666,12 +1668,12 @@ compprintlist(int showall)
 	} else {
 	    clearflag = 0;
 	    if (!asked) {
-		mrestlines = (ml + nlnct > lines);
+		mrestlines = (ml + nlnct > zterm_lines);
 		compprintnl(ml);
 	    }
 	}
     } else if (!asked) {
-	mrestlines = (ml + nlnct > lines);
+	mrestlines = (ml + nlnct > zterm_lines);
 	compprintnl(ml);
     }
     listshown = (clearflag ? 1 : -1);
@@ -1789,7 +1791,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, 
 	if (!dolist(ml)) {
 	    int nc = ZMB_nicewidth(m->disp ? m->disp : m->str);
 	    if (nc)
-		mlprinted = (nc-1) / columns;
+		mlprinted = (nc-1) / zterm_columns;
 	    else
 		mlprinted = 0;
 	    return 0;
@@ -1831,7 +1833,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, 
 	    return 1;
 	}
 	len = ZMB_nicewidth(m->disp ? m->disp : m->str);
-	mlprinted = len ? (len-1) / columns : 0;
+	mlprinted = len ? (len-1) / zterm_columns : 0;
 
 	modec = (mcolors.flags & LC_FOLLOW_SYMLINKS) ? m->fmodec : m->modec;
 	if ((g->flags & CGF_FILES) && modec) {
@@ -1864,9 +1866,11 @@ static int
 singlecalc(int *cp, int l, int *lcp)
 {
     int c = *cp, n, j, first = 1;
-    Cmatch **p, *op, *mp = mtab[l * columns + c];
+    Cmatch **p, *op, *mp = mtab[l * zterm_columns + c];
 
-    for (n = 0, j = c, p = mtab + l * columns + c, op = NULL; j >= 0; j--, p--) {
+    for (n = 0, j = c, p = mtab + l * zterm_columns + c, op = NULL;
+	 j >= 0;
+	 j--, p--) {
         if (*p == mp)
             c = j;
         if (!first && *p != op)
@@ -1876,7 +1880,7 @@ singlecalc(int *cp, int l, int *lcp)
     }
     *cp = c;
     *lcp = 1;
-    for (p = mtab + l * columns + c; c < columns; c++, p++)
+    for (p = mtab + l * zterm_columns + c; c < zterm_columns; c++, p++)
         if (*p && mp != *p)
             *lcp = 0;
 
@@ -1906,9 +1910,9 @@ singledraw()
         tc_downcurs(md1);
     if (mc1)
         tcmultout(TCRIGHT, TCMULTRIGHT, mc1);
-    DPUTS(ml1 * columns + mc1 >= mgtabsize, "BUG: invalid position");
-    g = mgtab[ml1 * columns + mc1];
-    clprintm(g, mtab[ml1 * columns + mc1], mcc1, ml1, lc1,
+    DPUTS(ml1 * zterm_columns + mc1 >= mgtabsize, "BUG: invalid position");
+    g = mgtab[ml1 * zterm_columns + mc1];
+    clprintm(g, mtab[ml1 * zterm_columns + mc1], mcc1, ml1, lc1,
              (g->widths ? g->widths[mcc1] : g->width));
     if (mlprinted)
 	(void) tcmultout(TCUP, TCMULTUP, mlprinted);
@@ -1918,20 +1922,20 @@ singledraw()
         tc_downcurs(md2 - md1);
     if (mc2)
         tcmultout(TCRIGHT, TCMULTRIGHT, mc2);
-    DPUTS(ml2 * columns + mc2 >= mgtabsize, "BUG: invalid position");
-    g = mgtab[ml2 * columns + mc2];
-    clprintm(g, mtab[ml2 * columns + mc2], mcc2, ml2, lc2,
+    DPUTS(ml2 * zterm_columns + mc2 >= mgtabsize, "BUG: invalid position");
+    g = mgtab[ml2 * zterm_columns + mc2];
+    clprintm(g, mtab[ml2 * zterm_columns + mc2], mcc2, ml2, lc2,
              (g->widths ? g->widths[mcc2] : g->width));
     if (mlprinted)
 	(void) tcmultout(TCUP, TCMULTUP, mlprinted);
     putc('\r', shout);
 
     if (mstatprinted) {
-        int i = lines - md2 - nlnct;
+        int i = zterm_lines - md2 - nlnct;
 
         tc_downcurs(i - 1);
         compprintfmt(NULL, 0, 1, 1, mline, NULL);
-        tcmultout(TCUP, TCMULTUP, lines - 1);
+        tcmultout(TCUP, TCMULTUP, zterm_lines - 1);
     } else
         tcmultout(TCUP, TCMULTUP, md2 + nlnct);
 
@@ -1951,7 +1955,7 @@ complistmatches(UNUSED(Hookdef dummy), C
 
     noselect = 0;
 
-    if ((minfo.asked == 2 && mselect < 0) || nlnct >= lines) {
+    if ((minfo.asked == 2 && mselect < 0) || nlnct >= zterm_lines) {
 	showinglist = 0;
 	amatches = oamatches;
 	return (noselect = 1);
@@ -1971,7 +1975,7 @@ complistmatches(UNUSED(Hookdef dummy), C
 
     getcols();
 
-    mnew = ((calclist(mselect >= 0) || mlastcols != columns ||
+    mnew = ((calclist(mselect >= 0) || mlastcols != zterm_columns ||
 	     mlastlines != listdat.nlines) && mselect >= 0);
 
     if (!listdat.nlines || (mselect >= 0 &&
@@ -2006,7 +2010,7 @@ complistmatches(UNUSED(Hookdef dummy), C
 	    mscroll = 1;
 	} else {
 	    clearflag = 1;
-	    minfo.asked = (listdat.nlines + nlnct <= lines);
+	    minfo.asked = (listdat.nlines + nlnct <= zterm_lines);
 	}
     } else {
 	unqueue_signals();
@@ -2019,7 +2023,7 @@ complistmatches(UNUSED(Hookdef dummy), C
 	}
     }
     if (mlbeg >= 0) {
-	mlend = mlbeg + lines - nlnct - mhasstat;
+	mlend = mlbeg + zterm_lines - nlnct - mhasstat;
 	while (mline >= mlend)
 	    mlbeg++, mlend++;
     } else
@@ -2030,7 +2034,7 @@ complistmatches(UNUSED(Hookdef dummy), C
 
     	mtab_been_reallocated = 1;
 
-	i = columns * listdat.nlines;
+	i = zterm_columns * listdat.nlines;
 	free(mtab);
 	mtab = (Cmatch **) zalloc(i * sizeof(Cmatch **));
 	memset(mtab, 0, i * sizeof(Cmatch **));
@@ -2040,7 +2044,7 @@ complistmatches(UNUSED(Hookdef dummy), C
 	mgtabsize = i;
 #endif
 	memset(mgtab, 0, i * sizeof(Cmgroup));
-	mlastcols = mcols = columns;
+	mlastcols = mcols = zterm_columns;
 	mlastlines = mlines = listdat.nlines;
     }
     last_cap = (char *) zhalloc(max_caplen + 1);
@@ -2067,13 +2071,13 @@ complistmatches(UNUSED(Hookdef dummy), C
 static int
 adjust_mcol(int wish, Cmatch ***tabp, Cmgroup **grp)
 {
-    Cmatch **tab = *tabp;
+    Cmatch **matchtab = *tabp;
     int p, n, c;
 
-    tab -= mcol;
+    matchtab -= mcol;
 
-    for (p = wish; p >= 0 && (!tab[p] || mmarked(tab[p])); p--);
-    for (n = wish; n < mcols && (!tab[n] || mmarked(tab[n])); n++);
+    for (p = wish; p >= 0 && (!matchtab[p] || mmarked(matchtab[p])); p--);
+    for (n = wish; n < mcols && (!matchtab[n] || mmarked(matchtab[n])); n++);
     if (n == mcols)
 	n = -1;
 
@@ -2086,7 +2090,7 @@ adjust_mcol(int wish, Cmatch ***tabp, Cm
     else
 	c = ((mcol - p) < (n - mcol) ? p : n);
 
-    *tabp = tab + c;
+    *tabp = matchtab + c;
     if (grp)
 	*grp = *grp + c - mcol;
 
@@ -2177,7 +2181,7 @@ setmstatus(char *status, char *sline, in
     }
     pl = strlen(p);
     sl = strlen(s);
-    max = (columns < MAX_STATUS ? columns : MAX_STATUS) - 14;
+    max = (zterm_columns < MAX_STATUS ? zterm_columns : MAX_STATUS) - 14;
 
     if (max > 12) {
         int h = (max - 2) >> 1;
@@ -2394,9 +2398,9 @@ domenuselect(Hookdef dummy, Chdata dat)
     
     if ((s = getsparam("MENUSCROLL"))) {
 	if (!(step = mathevali(s)))
-	    step = (lines - nlnct) >> 1;
+	    step = (zterm_lines - nlnct) >> 1;
 	else if (step < 0)
-	    if ((step += lines - nlnct) < 0)
+	    if ((step += zterm_lines - nlnct) < 0)
 		step = 1;
     }
     if ((s = getsparam("MENUMODE"))) {
@@ -2473,34 +2477,34 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    }
 
 	if (mlbeg && lbeg != mlbeg) {
-	    Cmatch **p = mtab + ((mlbeg - 1) * columns), **q;
+	    Cmatch **p = mtab + ((mlbeg - 1) * zterm_columns), **q;
 	    int c;
 
 	    while (mlbeg) {
-		for (q = p, c = columns; c > 0; q++, c--)
+		for (q = p, c = zterm_columns; c > 0; q++, c--)
 		    if (*q && !mmarked(*q))
 			break;
 		if (c)
 		    break;
-		p -= columns;
+		p -= zterm_columns;
 		mlbeg--;
 	    }
 	}
-	if ((space = lines - pl - mhasstat))
+	if ((space = zterm_lines - pl - mhasstat))
 	    while (mline >= mlbeg + space)
 		if ((mlbeg += step) + space > mlines)
 		    mlbeg = mlines - space;
 	if (lbeg != mlbeg) {
-	    Cmatch **p = mtab + (mlbeg * columns), **q;
+	    Cmatch **p = mtab + (mlbeg * zterm_columns), **q;
 	    int c;
 
 	    while (mlbeg < mlines) {
-		for (q = p, c = columns; c > 0; q++, c--)
+		for (q = p, c = zterm_columns; c > 0; q++, c--)
 		    if (*q)
 			break;
 		if (c)
 		    break;
-		p += columns;
+		p += zterm_columns;
 		mlbeg++;
 	    }
 	}
@@ -2955,7 +2959,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 		   cmd == Th(z_viforwardword) ||
 		   cmd == Th(z_viforwardwordend) ||
 		   cmd == Th(z_forwardword)) {
-	    int i = lines - pl - 1, oi = i, ll = 0;
+	    int i = zterm_lines - pl - 1, oi = i, ll = 0;
 	    Cmatch **lp = NULL;
 
             mode = 0;
@@ -2983,7 +2987,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 	} else if (cmd == Th(z_emacsbackwardword) ||
 		   cmd == Th(z_vibackwardword) ||
 		   cmd == Th(z_backwardword)) {
-	    int i = lines - pl - 1, oi = i, ll = 0;
+	    int i = zterm_lines - pl - 1, oi = i, ll = 0;
 	    Cmatch **lp = NULL;
 
             mode = 0;
Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.64
diff -p -u -r1.64 compmatch.c
--- Src/Zle/compmatch.c	29 Jan 2009 11:08:04 -0000	1.64
+++ Src/Zle/compmatch.c	6 May 2011 13:45:51 -0000
@@ -1268,7 +1268,7 @@ pattern_match_equivalence(Cpattern lp, c
 /**/
 static int
 pattern_match_restrict(Cpattern p, Cpattern wp, convchar_t *wsc, int wsclen,  
-		       Cpattern prestrict, ZLE_STRING_T newline)
+		       Cpattern prestrict, ZLE_STRING_T new_line)
 {
     convchar_t c;
     convchar_t ind, wind;
@@ -1356,7 +1356,7 @@ pattern_match_restrict(Cpattern p, Cpatt
 	}
 
 	/* We need to assemble the line */
-	*newline++ = (ZLE_CHAR_T)c;
+	*new_line++ = (ZLE_CHAR_T)c;
 	prestrict = prestrict->next;
 	wsc++;
 	wsclen--;
@@ -1393,7 +1393,7 @@ pattern_match_restrict(Cpattern p, Cpatt
 	if (!pattern_match1(p, c, &mt))
 	    return 0;
 	p = p->next;
-	*newline++ = (ZLE_CHAR_T)c;
+	*new_line++ = (ZLE_CHAR_T)c;
 	prestrict = prestrict->next;
     }
 
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.80
diff -p -u -r1.80 compresult.c
--- Src/Zle/compresult.c	18 Feb 2011 22:08:46 -0000	1.80
+++ Src/Zle/compresult.c	6 May 2011 13:45:51 -0000
@@ -1473,13 +1473,14 @@ calclist(int showall)
     if (lastinvcount == invcount &&
 	listdat.valid && onlyexpl == listdat.onlyexpl &&
 	menuacc == listdat.menuacc && showall == listdat.showall &&
-	lines == listdat.lines && columns == listdat.columns)
+	zterm_lines == listdat.zterm_lines &&
+	zterm_columns == listdat.zterm_columns)
 	return 0;
     lastinvcount = invcount;
 
     for (g = amatches; g; g = g->next) {
 	char **pp = g->ylist;
-	int nl = 0, l, glong = 1, gshort = columns, ndisp = 0, totl = 0;
+	int nl = 0, l, glong = 1, gshort = zterm_columns, ndisp = 0, totl = 0;
         int hasf = 0;
 
 	g->flags |= CGF_PACKED | CGF_ROWS;
@@ -1495,7 +1496,7 @@ calclist(int showall)
 	    /* We have an ylist, lets see, if it contains newlines. */
 	    hidden = 1;
 	    while (!nl && *pp) {
-                if (MB_METASTRWIDTH(*pp) >= columns)
+                if (MB_METASTRWIDTH(*pp) >= zterm_columns)
                     nl = 1;
                 else
                     nl = !!strchr(*pp++, '\n');
@@ -1511,11 +1512,12 @@ calclist(int showall)
 		    while (*sptr) {
 			if ((nlptr = strchr(sptr, '\n'))) {
 			    *nlptr = '\0';
-			    nlines += 1 + (MB_METASTRWIDTH(sptr)-1) / columns;
+			    nlines += 1 + (MB_METASTRWIDTH(sptr)-1) /
+				zterm_columns;
 			    *nlptr = '\n';
 			    sptr = nlptr + 1;
 			} else {
-			    nlines += (MB_METASTRWIDTH(sptr)-1) / columns;
+			    nlines += (MB_METASTRWIDTH(sptr)-1) / zterm_columns;
 			    break;
 			}
 		    }
@@ -1607,7 +1609,7 @@ calclist(int showall)
 	g->dcount = ndisp;
 	g->width = glong + CM_SPACE;
 	g->shortest = gshort + CM_SPACE;
-	if ((g->cols = columns / g->width) > g->dcount)
+	if ((g->cols = zterm_columns / g->width) > g->dcount)
 	    g->cols = g->dcount;
 	if (g->cols) {
 	    i = g->cols * g->width - CM_SPACE;
@@ -1636,9 +1638,10 @@ calclist(int showall)
 		    } else {
 			g->cols = 1;
 			g->width = 1;
-			
+
 			while (*pp)
-			    glines += 1 + (MB_METASTRWIDTH(*pp++) / columns);
+			    glines += 1 + (MB_METASTRWIDTH(*pp++) /
+					   zterm_columns);
 		    }
 		}
 	    } else {
@@ -1650,15 +1653,17 @@ calclist(int showall)
 		} else if (!(g->flags & CGF_LINES)) {
 		    g->cols = 1;
 		    g->width = 0;
-		    
+
 		    for (p = g->matches; (m = *p); p++)
 			if (!(m->flags & CMF_HIDE)) {
 			    if (m->disp) {
 				if (!(m->flags & CMF_DISPLINE))
-				    glines += 1 + ((mlens[m->gnum] - 1) / columns);
+				    glines += 1 + ((mlens[m->gnum] - 1) /
+						   zterm_columns);
 			    } else if (showall ||
 				       !(m->flags & (CMF_NOLIST | CMF_MULT)))
-				glines += 1 + (((mlens[m->gnum]) - 1) / columns);
+				glines += 1 + (((mlens[m->gnum]) - 1) /
+					       zterm_columns);
 			}
 		}
 	    }
@@ -1669,8 +1674,8 @@ calclist(int showall)
 	    if (!(g->flags & CGF_PACKED))
 		continue;
 
-	    ws = g->widths = (int *) zalloc(columns * sizeof(int));
-	    memset(ws, 0, columns * sizeof(int));
+	    ws = g->widths = (int *) zalloc(zterm_columns * sizeof(int));
+	    memset(ws, 0, zterm_columns * sizeof(int));
 	    tlines = g->lins;
 	    tcols = g->cols;
 	    width = 0;
@@ -1686,14 +1691,14 @@ calclist(int showall)
 		    if (g->flags & CGF_ROWS) {
                         int nth, tcol, len;
 
-                        for (tcols = columns / (g->shortest + CM_SPACE);
+                        for (tcols = zterm_columns / (g->shortest + CM_SPACE);
                              tcols > g->cols;
                              tcols--) {
 
                             memset(ws, 0, tcols * sizeof(int));
 
                             for (width = nth = tcol = 0, tlines = 1;
-                                 width < columns && nth < g->dcount;
+                                 width < zterm_columns && nth < g->dcount;
                                  nth++, tcol++) {
 
                                 m = *p;
@@ -1709,13 +1714,13 @@ calclist(int showall)
                                     ws[tcol] = len;
                                 }
                             }
-                            if (width < columns)
+                            if (width < zterm_columns)
                                 break;
                         }
 		    } else {
                         int nth, tcol, tline, len;
 
-                        for (tcols = columns / (g->shortest + CM_SPACE);
+                        for (tcols = zterm_columns / (g->shortest + CM_SPACE);
                              tcols > g->cols;
                              tcols--) {
 
@@ -1725,7 +1730,7 @@ calclist(int showall)
                             memset(ws, 0, tcols * sizeof(int));
 
                             for (width = nth = tcol = tline = 0;
-                                 width < columns && nth < g->dcount;
+                                 width < zterm_columns && nth < g->dcount;
                                  nth++, tline++) {
 
                                 m = *p;
@@ -1745,7 +1750,7 @@ calclist(int showall)
                                     ws[tcol] = len;
                                 }
                             }
-                            if (width < columns)
+                            if (width < zterm_columns)
                                 break;
                         }
 		    }
@@ -1754,7 +1759,7 @@ calclist(int showall)
 		if (g->flags & CGF_ROWS) {
                     int nth, tcol, len;
 
-                    for (tcols = columns / (g->shortest + CM_SPACE);
+                    for (tcols = zterm_columns / (g->shortest + CM_SPACE);
                          tcols > g->cols;
                          tcols--) {
 
@@ -1762,7 +1767,7 @@ calclist(int showall)
 
                         for (width = nth = tcol = 0, tlines = 1,
                              p = skipnolist(g->matches, showall);
-                             *p && width < columns && nth < g->dcount;
+                             *p && width < zterm_columns && nth < g->dcount;
                              nth++, p = skipnolist(p + 1, showall), tcol++) {
 
                             m = *p;
@@ -1779,13 +1784,13 @@ calclist(int showall)
                                 ws[tcol] = len;
                             }
                         }
-                        if (width < columns)
+                        if (width < zterm_columns)
                             break;
                     }
 		} else {
                     int nth, tcol, tline, len;
 
-                    for (tcols = columns / (g->shortest + CM_SPACE);
+                    for (tcols = zterm_columns / (g->shortest + CM_SPACE);
                          tcols > g->cols;
                          tcols--) {
 
@@ -1796,7 +1801,7 @@ calclist(int showall)
 
                         for (width = nth = tcol = tline = 0,
                              p = skipnolist(g->matches, showall);
-                             *p && width < columns && nth < g->dcount;
+                             *p && width < zterm_columns && nth < g->dcount;
                              nth++, p = skipnolist(p + 1, showall), tline++) {
 
                             m = *p;
@@ -1817,7 +1822,7 @@ calclist(int showall)
                                 ws[tcol] = len;
                             }
                         }
-                        if (width < columns) {
+                        if (width < zterm_columns) {
                             if (++tcol < tcols)
                                 tcols = tcol;
                             break;
@@ -1828,7 +1833,7 @@ calclist(int showall)
             if (tcols <= g->cols)
                 tlines = g->lins;
 	    if (tlines == g->lins) {
-		zfree(ws, columns * sizeof(int));
+		zfree(ws, zterm_columns * sizeof(int));
 		g->widths = NULL;
 	    } else {
 		nlines += tlines - g->lins;
@@ -1862,8 +1867,8 @@ calclist(int showall)
     listdat.nlines = nlines;
     listdat.menuacc = menuacc;
     listdat.onlyexpl = onlyexpl;
-    listdat.columns = columns;
-    listdat.lines = lines;
+    listdat.zterm_columns = zterm_columns;
+    listdat.zterm_lines = zterm_lines;
     listdat.showall = showall;
 
     return 1;
@@ -1884,7 +1889,7 @@ asklist(void)
     if ((!minfo.cur || !minfo.asked) &&
 	((complistmax > 0 && listdat.nlist >= complistmax) ||
 	 (complistmax < 0 && listdat.nlines <= -complistmax) ||
-	 (!complistmax && listdat.nlines >= lines))) {
+	 (!complistmax && listdat.nlines >= zterm_lines))) {
 	int qup, l;
 
 	zsetterm();
@@ -1893,7 +1898,7 @@ asklist(void)
 		     listdat.nlist, listdat.nlines) :
 	     fprintf(shout, "zsh: do you wish to see all %d lines? ",
 		     listdat.nlines));
-	qup = ((l + columns - 1) / columns) - 1;
+	qup = ((l + zterm_columns - 1) / zterm_columns) - 1;
 	fflush(shout);
 	if (!getzlequery()) {
 	    if (clearflag) {
@@ -1987,7 +1992,7 @@ printlist(int over, CLPrintFunc printm, 
 		while ((p = *pp++)) {
 		    zputs(p, shout);
 		    if (*pp) {
-                        if (MB_METASTRWIDTH(p) % columns)
+                        if (MB_METASTRWIDTH(p) % zterm_columns)
                             putc('\n', shout);
                         else
                             fputs(" \010", shout);
@@ -2113,7 +2118,7 @@ printlist(int over, CLPrintFunc printm, 
     if (clearflag) {
 	/* Move the cursor up to the prompt, if always_last_prompt *
 	 * is set and all that...                                  */
-	if ((ml = listdat.nlines + nlnct - 1) < lines) {
+	if ((ml = listdat.nlines + nlnct - 1) < zterm_lines) {
 	    tcmultout(TCUP, TCMULTUP, ml);
 	    showinglist = -1;
 
@@ -2134,8 +2139,8 @@ bld_all_str(Cmatch all)
 {
     Cmgroup g;
     Cmatch *mp, m;
-    int len = columns - 5, t, add = 0;
-    VARARR(char, buf, columns + 1);
+    int len = zterm_columns - 5, t, add = 0;
+    VARARR(char, buf, zterm_columns + 1);
 
     buf[0] = '\0';
 
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.120
diff -p -u -r1.120 computil.c
--- Src/Zle/computil.c	15 Apr 2011 14:56:53 -0000	1.120
+++ Src/Zle/computil.c	6 May 2011 13:45:52 -0000
@@ -226,8 +226,8 @@ cd_prep()
     runp = &(cd_state.runs);
 
     if (cd_state.groups) {
-        int lines = cd_state.groups + cd_state.descs;
-        VARARR(Cdstr, grps, lines);
+        int preplines = cd_state.groups + cd_state.descs;
+        VARARR(Cdstr, grps, preplines);
         VARARR(int, wids, cd_state.maxg);
         Cdstr gs, gp, gn, *gpp;
         int i, j, d;
@@ -275,7 +275,7 @@ cd_prep()
         if (cd_state.gprew > cd_state.maxmlen && cd_state.maxglen > 1)
             return 1;
 
-	for (i = 0; i < lines; i++) {
+	for (i = 0; i < preplines; i++) {
 	    Cdstr s = grps[i];
 	    int dummy;
 
@@ -283,9 +283,9 @@ cd_prep()
 	    unmetafy(s->sortstr, &dummy);
 	}
 
-        qsort(grps, lines, sizeof(Cdstr), cd_sort);
+        qsort(grps, preplines, sizeof(Cdstr), cd_sort);
 
-        for (i = lines, strp = grps; i > 1; i--, strp++) {
+        for (i = preplines, strp = grps; i > 1; i--, strp++) {
             strp2 = strp + 1;
             if (!strcmp((*strp)->desc, (*strp2)->desc))
                 continue;
@@ -303,9 +303,9 @@ cd_prep()
         expl =  (Cdrun) zalloc(sizeof(*run));
         expl->type = CRT_EXPL;
         expl->strs = grps[0];
-        expl->count = lines;
+        expl->count = preplines;
 
-        for (i = lines, strp = grps, strp2 = NULL; i; i--, strp++) {
+        for (i = preplines, strp = grps, strp2 = NULL; i; i--, strp++) {
             str = *strp;
             *strp = str->other;
             if (strp2)
@@ -321,7 +321,7 @@ cd_prep()
         *strp2 = NULL;
 
         for (i = cd_state.maxg - 1; i; i--) {
-            for (d = 0, j = lines, strp = grps; j; j--, strp++) {
+            for (d = 0, j = preplines, strp = grps; j; j--, strp++) {
                 if ((str = *strp)) {
                     if (d) {
                         *runp = run = (Cdrun) zalloc(sizeof(*run));
@@ -465,7 +465,7 @@ cd_init(char *nam, char *hide, char *mle
     cd_state.showd = disp;
     cd_state.maxg = cd_state.groups = cd_state.descs = 0;
     cd_state.maxmlen = atoi(mlen);
-    itmp = columns - cd_state.swidth - 4;
+    itmp = zterm_columns - cd_state.swidth - 4;
     if (cd_state.maxmlen > itmp)
         cd_state.maxmlen = itmp;
     if (cd_state.maxmlen < 4)
@@ -545,7 +545,7 @@ cd_init(char *nam, char *hide, char *mle
 	    args++;
     }
     if (disp && grp) {
-        int mg = columns;
+        int mg = zterm_columns;
 
         do {
             cd_group(mg);
@@ -651,7 +651,8 @@ cd_get(char **params)
 		     * is available. Leave 1 character at the end of screen
 		     * as safety margin
 		     */
-		    remw = columns - cd_state.premaxw - cd_state.swidth - 3;
+		    remw = zterm_columns - cd_state.premaxw -
+			cd_state.swidth - 3;
 		    d = str->desc;
 		    w = MB_METASTRWIDTH(d);
 		    if (w <= remw)
@@ -727,7 +728,8 @@ cd_get(char **params)
         case CRT_EXPL:
             {
 		/* add columns as safety margin */
-                VARARR(char, dbuf, cd_state.suf + cd_state.slen + columns);
+                VARARR(char, dbuf, cd_state.suf + cd_state.slen +
+		       zterm_columns);
                 char buf[20], *p, *pp, *d;
                 int i = run->count, remw, w, l;
 
@@ -743,7 +745,8 @@ cd_get(char **params)
                     }
 
                     strcpy(dbuf, cd_state.sep);
-		    remw = columns - cd_state.gprew - cd_state.swidth - CM_SPACE;
+		    remw = zterm_columns - cd_state.gprew -
+			cd_state.swidth - CM_SPACE;
 		    p = pp = dbuf + cd_state.slen;
 		    d = str->desc;
 		    w = MB_METASTRWIDTH(d);
Index: Src/Zle/zle_refresh.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_refresh.c,v
retrieving revision 1.85
diff -p -u -r1.85 zle_refresh.c
--- Src/Zle/zle_refresh.c	18 Feb 2011 22:08:46 -0000	1.85
+++ Src/Zle/zle_refresh.c	6 May 2011 13:45:52 -0000
@@ -688,12 +688,12 @@ resetvideo(void)
 {
     int ln;
  
-    winw = columns;  /* terminal width */
+    winw = zterm_columns;  /* terminal width */
     if (termflags & TERM_SHORT)
 	winh = 1;
     else
-	winh = (lines < 2) ? 24 : lines;
-    rwinh = lines;		/* keep the real number of lines */
+	winh = (zterm_lines < 2) ? 24 : zterm_lines;
+    rwinh = zterm_lines;		/* keep the real number of lines */
     vln = vmaxln = winprompt = 0;
     winpos = -1;
     if (winw_alloc != winw || winh_alloc != winh) {
@@ -1082,7 +1082,7 @@ zrefresh(void)
 
     cleareol = 0;		/* unset */
     more_start = more_end = 0;	/* unset */
-    if (isset(SINGLELINEZLE) || lines < 3
+    if (isset(SINGLELINEZLE) || zterm_lines < 3
 	|| (termflags & (TERM_NOUP | TERM_BAD | TERM_UNKNOWN)))
 	termflags |= TERM_SHORT;
     else
@@ -1138,7 +1138,7 @@ zrefresh(void)
 	}
 	fflush(shout);
 	clearf = clearflag;
-    } else if (winw != columns || rwinh != lines)
+    } else if (winw != zterm_columns || rwinh != zterm_lines)
 	resetvideo();
 
 /* now winw equals columns and winh equals lines 
@@ -2004,7 +2004,7 @@ refreshline(int ln)
 		 * last line lest undesired scrolling occurs due to `illegal'
 		 * characters on screen
 		 */ 
-		if (tccan(TCINS) && (vln != lines - 1)) {
+		if (tccan(TCINS) && (vln != zterm_lines - 1)) {
 		    /* not on last line */
 		    for (i = 1; nl[i].chr; i++) {
 			if (tcinscost(i) < wpfxlen(ol, nl + i)) {
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.107
diff -p -u -r1.107 zle_tricky.c
--- Src/Zle/zle_tricky.c	29 Apr 2011 15:23:34 -0000	1.107
+++ Src/Zle/zle_tricky.c	6 May 2011 13:45:52 -0000
@@ -2419,13 +2419,13 @@ printfmt(char *fmt, int n, int dopr, int
 		    if (tccan(TCCLEAREOL))
 			tcout(TCCLEAREOL);
 		    else {
-			int s = columns - 1 - (cc % columns);
+			int s = zterm_columns - 1 - (cc % zterm_columns);
 
 			while (s-- > 0)
 			    putc(' ', shout);
 		    }
 		}
-		l += 1 + ((cc - 1) / columns);
+		l += 1 + ((cc - 1) / zterm_columns);
 		cc = 0;
 		if (dopr)
 		    putc('\n', shout);
@@ -2445,18 +2445,18 @@ printfmt(char *fmt, int n, int dopr, int
 		} else
 		    p += clen;
 		cc += WCWIDTH_WINT(cchar);
-		if (dopr && !(cc % columns))
+		if (dopr && !(cc % zterm_columns))
 			fputs(" \010", shout);
 	    }
 	}
     }
     if (dopr) {
-        if (!(cc % columns))
+        if (!(cc % zterm_columns))
             fputs(" \010", shout);
 	if (tccan(TCCLEAREOL))
 	    tcout(TCCLEAREOL);
 	else {
-	    int s = columns - 1 - (cc % columns);
+	    int s = zterm_columns - 1 - (cc % zterm_columns);
 
 	    while (s-- > 0)
 		putc(' ', shout);
@@ -2467,7 +2467,7 @@ printfmt(char *fmt, int n, int dopr, int
      * cc is correct, i.e. if just misses wrapping we still add 1.
      * (Why?)
      */
-    return l + (cc / columns);
+    return l + (cc / zterm_columns);
 }
 
 /* This is used to print expansions. */
@@ -2481,8 +2481,8 @@ listlist(LinkList l)
     LinkNode node;
     char **p;
     VARARR(int, lens, num);
-    VARARR(int, widths, columns);
-    int longest = 0, shortest = columns, totl = 0;
+    VARARR(int, widths, zterm_columns);
+    int longest = 0, shortest = zterm_columns, totl = 0;
     int len, ncols, nlines, tolast, col, i, max, pack = 0, *lenp;
 
     for (node = firstnode(l), p = data; node; incnode(node), p++)
@@ -2500,7 +2500,7 @@ listlist(LinkList l)
 	    shortest = len;
 	totl += len;
     }
-    if ((ncols = ((columns + 2) / longest))) {
+    if ((ncols = ((zterm_columns + 2) / longest))) {
 	int tlines = 0, tline, tcols = 0, maxlen, nth, width;
 
 	nlines = (num + ncols - 1) / ncols;
@@ -2509,7 +2509,7 @@ listlist(LinkList l)
 	    if (isset(LISTROWSFIRST)) {
 		int count, tcol, first, maxlines = 0, llines;
 
-		for (tcols = columns / shortest; tcols > ncols;
+		for (tcols = zterm_columns / shortest; tcols > ncols;
 		     tcols--) {
 		    for (nth = first = maxlen = width = maxlines =
 			     llines = tcol = 0,
@@ -2522,7 +2522,7 @@ listlist(LinkList l)
 			nth += tcols;
 			tlines++;
 			if (nth >= num) {
-			    if ((width += maxlen) >= columns)
+			    if ((width += maxlen) >= zterm_columns)
 				break;
 			    widths[tcol++] = maxlen;
 			    maxlen = 0;
@@ -2536,13 +2536,13 @@ listlist(LinkList l)
 			widths[tcol++] = maxlen;
 			width += maxlen;
 		    }
-		    if (!count && width < columns)
+		    if (!count && width < zterm_columns)
 			break;
 		}
 		if (tcols > ncols)
 		    tlines = maxlines;
 	    } else {
-		for (tlines = ((totl + columns) / columns);
+		for (tlines = ((totl + zterm_columns) / zterm_columns);
 		     tlines < nlines; tlines++) {
 		    for (p = data, nth = tline = width =
 			     maxlen = tcols = 0;
@@ -2550,7 +2550,7 @@ listlist(LinkList l)
 			if (lens[nth] > maxlen)
 			    maxlen = lens[nth];
 			if (++tline == tlines) {
-			    if ((width += maxlen) >= columns)
+			    if ((width += maxlen) >= zterm_columns)
 				break;
 			    widths[tcols++] = maxlen;
 			    maxlen = tline = 0;
@@ -2560,7 +2560,7 @@ listlist(LinkList l)
 			widths[tcols++] = maxlen;
 			width += maxlen;
 		    }
-		    if (nth == num && width < columns)
+		    if (nth == num && width < zterm_columns)
 			break;
 		}
 	    }
@@ -2572,7 +2572,7 @@ listlist(LinkList l)
     } else {
 	nlines = 0;
 	for (p = data; *p; p++)
-	    nlines += 1 + (strlen(*p) / columns);
+	    nlines += 1 + (strlen(*p) / zterm_columns);
     }
     /* Set the cursor below the prompt. */
     trashzle();
@@ -2581,7 +2581,7 @@ listlist(LinkList l)
     clearflag = (isset(USEZLE) && !termflags && tolast);
 
     max = getiparam("LISTMAX");
-    if ((max && num > max) || (!max && nlines > lines)) {
+    if ((max && num > max) || (!max && nlines > zterm_lines)) {
 	int qup, l;
 
 	zsetterm();
@@ -2589,7 +2589,7 @@ listlist(LinkList l)
 	     fprintf(shout, "zsh: do you wish to see all %d possibilities (%d lines)? ",
 		     num, nlines) :
 	     fprintf(shout, "zsh: do you wish to see all %d lines? ", nlines));
-	qup = ((l + columns - 1) / columns) - 1;
+	qup = ((l + zterm_columns - 1) / zterm_columns) - 1;
 	fflush(shout);
 	if (!getzlequery()) {
 	    if (clearflag) {
@@ -2656,7 +2656,7 @@ listlist(LinkList l)
 	}
     }
     if (clearflag) {
-	if ((nlines += nlnct - 1) < lines) {
+	if ((nlines += nlnct - 1) < zterm_lines) {
 	    tcmultout(TCUP, TCMULTUP, nlines);
 	    showinglist = -1;
 	} else
Index: Src/Zle/zle_utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v
retrieving revision 1.60
diff -p -u -r1.60 zle_utils.c
--- Src/Zle/zle_utils.c	11 Mar 2011 10:33:34 -0000	1.60
+++ Src/Zle/zle_utils.c	6 May 2011 13:45:52 -0000
@@ -1257,7 +1257,7 @@ showmsg(char const *msg)
 	    p++;
 
 	    putc('\n', shout);
-	    up += 1 + cc / columns;
+	    up += 1 + cc / zterm_columns;
 	    cc = 0;
 	} else {
 	    /*
@@ -1308,7 +1308,7 @@ showmsg(char const *msg)
 	    c = *++p ^ 32;
 	if(c == '\n') {
 	    putc('\n', shout);
-	    up += 1 + cc / columns;
+	    up += 1 + cc / zterm_columns;
 	    cc = 0;
 	} else {
 	    char const *n = nicechar(c);
@@ -1317,7 +1317,7 @@ showmsg(char const *msg)
 	}
     }
 #endif
-    up += cc / columns;
+    up += cc / zterm_columns;
 
     if (clearflag) {
 	putc('\r', shout);

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-05-06 13:51         ` Peter Stephenson
@ 2011-05-06 14:16           ` Peter Stephenson
  2011-05-09  9:54           ` Peter Stephenson
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2011-05-06 14:16 UTC (permalink / raw)
  To: zsh-workers

On Fri, 6 May 2011 14:51:42 +0100
Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> The issues I can see are with the names columns, lines, move, newline
> and tab (ick!).  After fixing these, this now compiles and runs
> correctly on my machine.  I can't entirely exclude the possibility it
> has subtly redefined some other word.

To try to help, I ran

egrep -w "("${(j.|.)$(perl -ne '/\#define\s+([[:alnum:]_]+)/ &&
print "$1\n"' /usr/include/ncursesw/term.h | uniq)}")" **/*.[ch]

and looked for definitions we were using in the shell.  It's a bit hard
to be sure --- there are lots of matches with words like "TTY" and
"lines" in comments, parameter names etc. --- but I didn't see anything
that looked suspicious.

Grepping the source after comment removal would be a better check but I
don't have the energy.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-05-06 13:51         ` Peter Stephenson
  2011-05-06 14:16           ` Peter Stephenson
@ 2011-05-09  9:54           ` Peter Stephenson
  2011-05-09 10:33             ` Peter Stephenson
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2011-05-09  9:54 UTC (permalink / raw)
  To: zsh-workers

On Fri, 6 May 2011 14:51:42 +0100
Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> So to
> fix it for AIX (an, indeed, to have any remote hope of keeping the
> AIX version in sync with the rest) we need to allow term.h to be
> included in the main shell.
> 
> The issues I can see are with the names columns, lines, move, newline
> and tab (ick!).  After fixing these, this now compiles and runs
> correctly on my machine.  I can't entirely exclude the possibility it
> has subtly redefined some other word.
> 
> Unfortunately, it means we're at the mercy of term.h everywhere it
> exists.  Given that this only happens in the case we are trying to use
> it in at least one part of the shell, it's probably the right thing to
> do to use it everywhere.  However, this could do with some major
> testing.  I'll upload a new test version soon.

I've committed this.  I'll upload a test version when a bit more dust
has settled elsewhere, but it could do with some testing.  I suspect
there are some interesting versions of term.h around.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

* Re: [PATCH] Compilation fix for AIX (missing consts)
  2011-05-09  9:54           ` Peter Stephenson
@ 2011-05-09 10:33             ` Peter Stephenson
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2011-05-09 10:33 UTC (permalink / raw)
  To: zsh-workers

On Mon, 9 May 2011 10:54:41 +0100
Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> I suspect there are some interesting versions of term.h around.

Next problem.

Solaris 8 has clashing definitions of "bool" in curses.h and an RPC
header.  Luckily we only use the RPC header in one place, so moving that
into a file that doesn't need terminal definitions seems to work.

Index: Src/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/.distfiles,v
retrieving revision 1.6
diff -p -u -r1.6 .distfiles
--- Src/.distfiles	16 Apr 2007 13:21:26 -0000	1.6
+++ Src/.distfiles	9 May 2011 10:31:12 -0000
@@ -1,13 +1,53 @@
 DISTFILES_SRC='
-    .cvsignore .distfiles .exrc .indent.pro
-    Makefile.in Makemod.in.in
-    signames1.awk signames2.awk
-    modentry.c
-    builtin.c compat.c cond.c exec.c glob.c hashtable.c hashtable.h
-    hist.c init.c input.c jobs.c lex.c linklist.c loop.c main.c makepro.awk
-    math.c mem.c mkbltnmlst.sh mkmakemod.sh
-    module.c options.c params.c parse.c pattern.c prompt.c prototypes.h
-    signals.c signals.h sort.c string.c subst.c system.h text.c utils.c
-    watch.c zsh.h zsh.mdd ztype.h
-    zsh.rc zsh.ico
+.cvsignore
+.distfiles
+.exrc
+.indent.pro
+Makefile.in
+Makemod.in.in
+signames1.awk
+signames2.awk
+modentry.c
+builtin.c
+compat.c
+cond.c
+exec.c
+glob.c
+hashtable.c
+hashtable.h
+hashnameddir.c
+hist.c
+init.c
+input.c
+jobs.c
+lex.c
+linklist.c
+loop.c
+main.c
+makepro.awk
+math.c
+mem.c
+mkbltnmlst.sh
+mkmakemod.sh
+module.c
+options.c
+params.c
+parse.c
+pattern.c
+prompt.c
+prototypes.h
+signals.c
+signals.h
+sort.c
+string.c
+subst.c
+system.h
+text.c
+utils.c
+watch.c
+zsh.h
+zsh.mdd
+ztype.h
+zsh.rc
+zsh.ico
 '
Index: Src/hashnameddir.c
===================================================================
RCS file: Src/hashnameddir.c
diff -N Src/hashnameddir.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Src/hashnameddir.c	9 May 2011 10:31:12 -0000
@@ -0,0 +1,307 @@
+/*
+ * hashtable.c - hash tables
+ *
+ * This file is part of zsh, the Z shell.
+ *
+ * Copyright (c) 1992-1997 Paul Falstad
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and to distribute modified versions of this software for any
+ * purpose, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ *
+ * In no event shall Paul Falstad or the Zsh Development Group be liable
+ * to any party for direct, indirect, special, incidental, or consequential
+ * damages arising out of the use of this software and its documentation,
+ * even if Paul Falstad and the Zsh Development Group have been advised of
+ * the possibility of such damage.
+ *
+ * Paul Falstad and the Zsh Development Group specifically disclaim any
+ * warranties, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose.  The software
+ * provided hereunder is on an "as is" basis, and Paul Falstad and the
+ * Zsh Development Group have no obligation to provide maintenance,
+ * support, updates, enhancements, or modifications.
+ *
+ */
+
+#include "../config.h"
+
+/*
+ * On Solaris 8 there's a clash between "bool" in curses and RPC.
+ * We don't need curses here, so ensure it doesn't get included.
+ */
+#define ZSH_NO_TERM_HANDLING
+
+#include "zsh.mdh"
+#include "hashnameddir.pro"
+
+/****************************************/
+/* Named Directory Hash Table Functions */
+/****************************************/
+
+#ifdef HAVE_NIS_PLUS
+# include <rpcsvc/nis.h>
+#else
+# ifdef HAVE_NIS
+#  include	<rpc/types.h>
+#  include	<rpc/rpc.h>
+#  include	<rpcsvc/ypclnt.h>
+#  include	<rpcsvc/yp_prot.h>
+# endif
+#endif
+
+/* hash table containing named directories */
+
+/**/
+mod_export HashTable nameddirtab;
+
+/* != 0 if all the usernames have already been *
+ * added to the named directory hash table.    */
+
+static int allusersadded;
+
+/* Create new hash table for named directories */
+
+/**/
+void
+createnameddirtable(void)
+{
+    nameddirtab = newhashtable(201, "nameddirtab", NULL);
+
+    nameddirtab->hash        = hasher;
+    nameddirtab->emptytable  = emptynameddirtable;
+    nameddirtab->filltable   = fillnameddirtable;
+    nameddirtab->cmpnodes    = strcmp;
+    nameddirtab->addnode     = addnameddirnode;
+    nameddirtab->getnode     = gethashnode;
+    nameddirtab->getnode2    = gethashnode2;
+    nameddirtab->removenode  = removenameddirnode;
+    nameddirtab->disablenode = NULL;
+    nameddirtab->enablenode  = NULL;
+    nameddirtab->freenode    = freenameddirnode;
+    nameddirtab->printnode   = printnameddirnode;
+
+    allusersadded = 0;
+    finddir(NULL);		/* clear the finddir cache */
+}
+
+/* Empty the named directories table */
+
+/**/
+static void
+emptynameddirtable(HashTable ht)
+{
+    emptyhashtable(ht);
+    allusersadded = 0;
+    finddir(NULL);		/* clear the finddir cache */
+}
+
+/* Add all the usernames in the password file/database *
+ * to the named directories table.                     */
+
+#ifdef HAVE_NIS_PLUS
+static int
+add_userdir(nis_name table, nis_object *object, void *userdata)
+{
+    if (object->zo_data.objdata_u.en_data.en_cols.en_cols_len >= 6) {
+	static char name[40], dir[PATH_MAX + 1];
+	register entry_col *ec =
+	    object->zo_data.objdata_u.en_data.en_cols.en_cols_val;
+	register int nl = minimum(ec[0].ec_value.ec_value_len, 39);
+	register int dl = minimum(ec[5].ec_value.ec_value_len, PATH_MAX);
+
+	memcpy(name, ec[0].ec_value.ec_value_val, nl);
+	name[nl] = '\0';
+	memcpy(dir, ec[5].ec_value.ec_value_val, dl);
+	dir[dl] = '\0';
+
+	adduserdir(name, dir, ND_USERNAME, 1);
+    }
+    return 0;
+}
+#else
+# ifdef HAVE_NIS
+static int
+add_userdir(int status, char *key, int keylen, char *val, int vallen, char *dummy)
+{
+    char *p, *d, *de;
+
+    if (status != YP_TRUE)
+	return 1;
+
+    if (vallen > keylen && *(p = val + keylen) == ':') {
+	*p++ = '\0';
+	for (de = val + vallen - 1; *de != ':' && de > val; de--);
+	if (de > val) {
+	    *de = '\0';
+	    if ((d = strrchr(p, ':'))) {
+		if (*++d && val[0])
+		    adduserdir(val, d, ND_USERNAME, 1);
+	    }
+	}
+    }
+    return 0;
+}
+# endif /* HAVE_NIS */
+#endif  /* HAVE_NIS_PLUS */
+
+/**/
+static void
+fillnameddirtable(UNUSED(HashTable ht))
+{
+    if (!allusersadded) {
+#if defined(HAVE_NIS) || defined(HAVE_NIS_PLUS)
+	FILE *pwf;
+	char buf[BUFSIZ], *p, *d, *de;
+	int skipping, oldct = nameddirtab->ct, usepwf = 1;
+
+# ifndef HAVE_NIS_PLUS
+	char domain[YPMAXDOMAIN];
+	struct ypall_callback cb;
+
+	/* Get potential matches from NIS and cull those without local accounts */
+	if (getdomainname(domain, YPMAXDOMAIN) == 0) {
+	    cb.foreach = (int (*)()) add_userdir;
+	    cb.data = NULL;
+	    yp_all(domain, PASSWD_MAP, &cb);
+    }
+# else  /* HAVE_NIS_PLUS */
+	/* Maybe we should turn this string into a #define'd constant...? */
+
+	nis_list("passwd.org_dir", EXPAND_NAME|ALL_RESULTS|FOLLOW_LINKS|FOLLOW_PATH,
+		 add_userdir, 0);
+# endif
+	if (nameddirtab->ct == oldct) {
+	    /* Using NIS or NIS+ didn't add any user directories. This seems
+	     * fishy, so we fall back to using getpwent(). If we don't have
+	     * that, we only use the passwd file. */
+#ifdef HAVE_GETPWENT
+	    struct passwd *pw;
+
+	    setpwent();
+
+	    /* loop through the password file/database *
+	     * and add all entries returned.           */
+	    while ((pw = getpwent()) && !errflag)
+		adduserdir(pw->pw_name, pw->pw_dir, ND_USERNAME, 1);
+
+	    endpwent();
+	    usepwf = 0;
+#endif /* HAVE_GETPWENT */
+	}
+	if (usepwf) {
+	    /* Don't forget the non-NIS matches from the flat passwd file */
+	    if ((pwf = fopen(PASSWD_FILE, "r")) != NULL) {
+		skipping = 0;
+		while (fgets(buf, BUFSIZ, pwf) != NULL) {
+		    if (strchr(buf, '\n') != NULL) {
+			if (!skipping) {
+			    if ((p = strchr(buf, ':')) != NULL) {
+				*p++ = '\0';
+				if ((de = strrchr(p, ':'))) {
+				    *de = '\0';
+				    if ((d = strrchr(p, ':'))) {
+					if (*++d && buf[0])
+					    adduserdir(buf, d, ND_USERNAME, 1);
+				    }
+				}
+			    }
+			} else
+			    skipping = 0;
+		    } else
+			skipping = 1;
+		}
+		fclose(pwf);
+	    }
+	}
+#else  /* no NIS or NIS_PLUS */
+#ifdef USE_GETPWENT
+	struct passwd *pw;
+
+	setpwent();
+
+	/* loop through the password file/database *
+	 * and add all entries returned.           */
+	while ((pw = getpwent()) && !errflag)
+	    adduserdir(pw->pw_name, pw->pw_dir, ND_USERNAME, 1);
+
+	endpwent();
+#endif /* HAVE_GETPWENT */
+#endif
+	allusersadded = 1;
+    }
+}
+
+/* Add an entry to the named directory hash *
+ * table, clearing the finddir() cache and  *
+ * initialising the `diff' member.          */
+
+/**/
+static void
+addnameddirnode(HashTable ht, char *nam, void *nodeptr)
+{
+    Nameddir nd = (Nameddir) nodeptr;
+
+    nd->diff = strlen(nd->dir) - strlen(nam);
+    finddir(NULL);		/* clear the finddir cache */
+    addhashnode(ht, nam, nodeptr);
+}
+
+/* Remove an entry from the named directory  *
+ * hash table, clearing the finddir() cache. */
+
+/**/
+static HashNode
+removenameddirnode(HashTable ht, const char *nam)
+{
+    HashNode hn = removehashnode(ht, nam);
+
+    if(hn)
+	finddir(NULL);		/* clear the finddir cache */
+    return hn;
+}
+
+/* Free up the memory used by a named directory hash node. */
+
+/**/
+static void
+freenameddirnode(HashNode hn)
+{
+    Nameddir nd = (Nameddir) hn;
+
+    zsfree(nd->node.nam);
+    zsfree(nd->dir);
+    zfree(nd, sizeof(struct nameddir));
+}
+
+/* Print a named directory */
+
+/**/
+static void
+printnameddirnode(HashNode hn, int printflags)
+{
+    Nameddir nd = (Nameddir) hn;
+
+    if (printflags & PRINT_NAMEONLY) {
+	zputs(nd->node.nam, stdout);
+	putchar('\n');
+	return;
+    }
+
+    if (printflags & PRINT_LIST) {
+      printf("hash -d ");
+
+      if(nd->node.nam[0] == '-')
+	    printf("-- ");
+    }
+
+    quotedzputs(nd->node.nam, stdout);
+    putchar('=');
+    quotedzputs(nd->dir, stdout);
+    putchar('\n');
+}
+
+#include "../config.h"
Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.33
diff -p -u -r1.33 hashtable.c
--- Src/hashtable.c	9 May 2011 09:49:09 -0000	1.33
+++ Src/hashtable.c	9 May 2011 10:31:12 -0000
@@ -1196,272 +1196,6 @@ printaliasnode(HashNode hn, int printfla
     putchar('\n');
 }
 
-/****************************************/
-/* Named Directory Hash Table Functions */
-/****************************************/
-
-#ifdef HAVE_NIS_PLUS
-# include <rpcsvc/nis.h>
-#else
-# ifdef HAVE_NIS
-#  include	<rpc/types.h>
-#  include	<rpc/rpc.h>
-#  include	<rpcsvc/ypclnt.h>
-#  include	<rpcsvc/yp_prot.h>
-# endif
-#endif
-
-/* hash table containing named directories */
-
-/**/
-mod_export HashTable nameddirtab;
- 
-/* != 0 if all the usernames have already been *
- * added to the named directory hash table.    */
-
-static int allusersadded;
-
-/* Create new hash table for named directories */
-
-/**/
-void
-createnameddirtable(void)
-{
-    nameddirtab = newhashtable(201, "nameddirtab", NULL);
-
-    nameddirtab->hash        = hasher;
-    nameddirtab->emptytable  = emptynameddirtable;
-    nameddirtab->filltable   = fillnameddirtable;
-    nameddirtab->cmpnodes    = strcmp;
-    nameddirtab->addnode     = addnameddirnode;
-    nameddirtab->getnode     = gethashnode;
-    nameddirtab->getnode2    = gethashnode2;
-    nameddirtab->removenode  = removenameddirnode;
-    nameddirtab->disablenode = NULL;
-    nameddirtab->enablenode  = NULL;
-    nameddirtab->freenode    = freenameddirnode;
-    nameddirtab->printnode   = printnameddirnode;
-
-    allusersadded = 0;
-    finddir(NULL);		/* clear the finddir cache */
-}
-
-/* Empty the named directories table */
-
-/**/
-static void
-emptynameddirtable(HashTable ht)
-{
-    emptyhashtable(ht);
-    allusersadded = 0;
-    finddir(NULL);		/* clear the finddir cache */
-}
-
-/* Add all the usernames in the password file/database *
- * to the named directories table.                     */
-
-#ifdef HAVE_NIS_PLUS
-static int
-add_userdir(nis_name table, nis_object *object, void *userdata)
-{
-    if (object->zo_data.objdata_u.en_data.en_cols.en_cols_len >= 6) {
-	static char name[40], dir[PATH_MAX + 1];
-	register entry_col *ec =
-	    object->zo_data.objdata_u.en_data.en_cols.en_cols_val;
-	register int nl = minimum(ec[0].ec_value.ec_value_len, 39);
-	register int dl = minimum(ec[5].ec_value.ec_value_len, PATH_MAX);
-
-	memcpy(name, ec[0].ec_value.ec_value_val, nl);
-	name[nl] = '\0';
-	memcpy(dir, ec[5].ec_value.ec_value_val, dl);
-	dir[dl] = '\0';
-
-	adduserdir(name, dir, ND_USERNAME, 1);
-    }
-    return 0;
-}
-#else
-# ifdef HAVE_NIS
-static int
-add_userdir(int status, char *key, int keylen, char *val, int vallen, char *dummy)
-{
-    char *p, *d, *de;
-
-    if (status != YP_TRUE)
-	return 1;
-
-    if (vallen > keylen && *(p = val + keylen) == ':') {
-	*p++ = '\0';
-	for (de = val + vallen - 1; *de != ':' && de > val; de--);
-	if (de > val) {
-	    *de = '\0';
-	    if ((d = strrchr(p, ':'))) {
-		if (*++d && val[0])
-		    adduserdir(val, d, ND_USERNAME, 1);
-	    }
-	}
-    }
-    return 0;
-}
-# endif /* HAVE_NIS */
-#endif  /* HAVE_NIS_PLUS */
-
-/**/
-static void
-fillnameddirtable(UNUSED(HashTable ht))
-{
-    if (!allusersadded) {
-#if defined(HAVE_NIS) || defined(HAVE_NIS_PLUS)
-	FILE *pwf;
-	char buf[BUFSIZ], *p, *d, *de;
-	int skipping, oldct = nameddirtab->ct, usepwf = 1;
-
-# ifndef HAVE_NIS_PLUS
-	char domain[YPMAXDOMAIN];
-	struct ypall_callback cb;
-
-	/* Get potential matches from NIS and cull those without local accounts */
-	if (getdomainname(domain, YPMAXDOMAIN) == 0) {
-	    cb.foreach = (int (*)()) add_userdir;
-	    cb.data = NULL;
-	    yp_all(domain, PASSWD_MAP, &cb);
-    }
-# else  /* HAVE_NIS_PLUS */
-	/* Maybe we should turn this string into a #define'd constant...? */
-
-	nis_list("passwd.org_dir", EXPAND_NAME|ALL_RESULTS|FOLLOW_LINKS|FOLLOW_PATH,
-		 add_userdir, 0);
-# endif
-	if (nameddirtab->ct == oldct) {
-	    /* Using NIS or NIS+ didn't add any user directories. This seems
-	     * fishy, so we fall back to using getpwent(). If we don't have
-	     * that, we only use the passwd file. */
-#ifdef HAVE_GETPWENT
-	    struct passwd *pw;
- 
-	    setpwent();
- 
-	    /* loop through the password file/database *
-	     * and add all entries returned.           */
-	    while ((pw = getpwent()) && !errflag)
-		adduserdir(pw->pw_name, pw->pw_dir, ND_USERNAME, 1);
- 
-	    endpwent();
-	    usepwf = 0;
-#endif /* HAVE_GETPWENT */
-	}
-	if (usepwf) {
-	    /* Don't forget the non-NIS matches from the flat passwd file */
-	    if ((pwf = fopen(PASSWD_FILE, "r")) != NULL) {
-		skipping = 0;
-		while (fgets(buf, BUFSIZ, pwf) != NULL) {
-		    if (strchr(buf, '\n') != NULL) {
-			if (!skipping) {
-			    if ((p = strchr(buf, ':')) != NULL) {
-				*p++ = '\0';
-				if ((de = strrchr(p, ':'))) {
-				    *de = '\0';
-				    if ((d = strrchr(p, ':'))) {
-					if (*++d && buf[0])
-					    adduserdir(buf, d, ND_USERNAME, 1);
-				    }
-				}
-			    }
-			} else
-			    skipping = 0;
-		    } else
-			skipping = 1;
-		}
-		fclose(pwf);
-	    }
-	}
-#else  /* no NIS or NIS_PLUS */
-#ifdef USE_GETPWENT
-	struct passwd *pw;
- 
-	setpwent();
- 
-	/* loop through the password file/database *
-	 * and add all entries returned.           */
-	while ((pw = getpwent()) && !errflag)
-	    adduserdir(pw->pw_name, pw->pw_dir, ND_USERNAME, 1);
- 
-	endpwent();
-#endif /* HAVE_GETPWENT */
-#endif
-	allusersadded = 1;
-    }
-}
-
-/* Add an entry to the named directory hash *
- * table, clearing the finddir() cache and  *
- * initialising the `diff' member.          */
-
-/**/
-static void
-addnameddirnode(HashTable ht, char *nam, void *nodeptr)
-{
-    Nameddir nd = (Nameddir) nodeptr;
-
-    nd->diff = strlen(nd->dir) - strlen(nam);
-    finddir(NULL);		/* clear the finddir cache */
-    addhashnode(ht, nam, nodeptr);
-}
-
-/* Remove an entry from the named directory  *
- * hash table, clearing the finddir() cache. */
-
-/**/
-static HashNode
-removenameddirnode(HashTable ht, const char *nam)
-{
-    HashNode hn = removehashnode(ht, nam);
-
-    if(hn)
-	finddir(NULL);		/* clear the finddir cache */
-    return hn;
-}
-
-/* Free up the memory used by a named directory hash node. */
-
-/**/
-static void
-freenameddirnode(HashNode hn)
-{
-    Nameddir nd = (Nameddir) hn;
- 
-    zsfree(nd->node.nam);
-    zsfree(nd->dir);
-    zfree(nd, sizeof(struct nameddir));
-}
-
-/* Print a named directory */
-
-/**/
-static void
-printnameddirnode(HashNode hn, int printflags)
-{
-    Nameddir nd = (Nameddir) hn;
-
-    if (printflags & PRINT_NAMEONLY) {
-	zputs(nd->node.nam, stdout);
-	putchar('\n');
-	return;
-    }
-    
-    if (printflags & PRINT_LIST) {
-      printf("hash -d ");
-
-      if(nd->node.nam[0] == '-')
-	    printf("-- ");
-    }
-
-    quotedzputs(nd->node.nam, stdout);
-    putchar('=');
-    quotedzputs(nd->dir, stdout);
-    putchar('\n');
-}
-
 /*************************************/
 /* History Line Hash Table Functions */
 /*************************************/
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.59
diff -p -u -r1.59 system.h
--- Src/system.h	9 May 2011 09:49:09 -0000	1.59
+++ Src/system.h	9 May 2011 10:31:12 -0000
@@ -851,7 +851,7 @@ extern short ospeed;
 # define GET_ST_CTIME_NSEC(st) (st).st_ctimensec
 #endif
 
-#ifdef HAVE_TGETENT
+#if defined(HAVE_TGETENT) && !defined(ZSH_NO_TERM_HANDLING)
 # if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H)
 #  define USES_TERM_H 1
 # else
Index: Src/zsh.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.mdd,v
retrieving revision 1.23
diff -p -u -r1.23 zsh.mdd
--- Src/zsh.mdd	18 Apr 2011 20:36:31 -0000	1.23
+++ Src/zsh.mdd	9 May 2011 10:31:12 -0000
@@ -9,7 +9,7 @@ alwayslink=1
 
 # autobins not specified because of alwayslink
 
-objects="builtin.o compat.o cond.o exec.o glob.o hashtable.o \
+objects="builtin.o compat.o cond.o exec.o glob.o hashtable.o hashnameddir.o \
 hist.o init.o input.o jobs.o lex.o linklist.o loop.o math.o \
 mem.o module.o options.o params.o parse.o pattern.o prompt.o signals.o \
 signames.o sort.o string.o subst.o text.o utils.o watch.o"



-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

end of thread, other threads:[~2011-05-09 10:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-26 13:33 [PATCH] Compilation fix for AIX (missing consts) Jérémie Roquet
2011-04-26 19:16 ` Wayne Davison
2011-04-27 15:49   ` Jérémie Roquet
2011-04-27 18:54     ` Wayne Davison
2011-05-03 12:23       ` Jérémie Roquet
2011-05-06 13:51         ` Peter Stephenson
2011-05-06 14:16           ` Peter Stephenson
2011-05-09  9:54           ` Peter Stephenson
2011-05-09 10:33             ` Peter Stephenson
2011-05-03 10:23 ` 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).