diff --git a/ChangeLog b/ChangeLog index b4c8944d6..7c284407b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-09-04 Bart Schaefer + + * 16613 (modified): acconfig.h, zshconfig.ac, Src/init.c: detect + variant tgetent() return value and test for it correctly. + 2002-08-22 Clint Adams * 17571: Src/Modules/terminfo.c: backport of terminfo segfault diff --git a/Src/init.c b/Src/init.c index ffe873e4f..645897982 100644 --- a/Src/init.c +++ b/Src/init.c @@ -535,11 +535,11 @@ init_term(void) #ifdef TGETENT_ACCEPTS_NULL /* If possible, we let tgetent allocate its own termcap buffer */ - if (tgetent(NULL, term) != 1) { + if (tgetent(NULL, term) != TGETENT_SUCCESS) #else - if (tgetent(termbuf, term) != 1) { + if (tgetent(termbuf, term) != TGETENT_SUCCESS) #endif - + { if (isset(INTERACTIVE)) zerr("can't find terminal definition for %s", term, 0); errflag = 0; diff --git a/acconfig.h b/acconfig.h index 1026f2b7b..80663a65b 100644 --- a/acconfig.h +++ b/acconfig.h @@ -187,6 +187,9 @@ /* Define to 1 if tgetent() accepts NULL as a buffer */ #undef TGETENT_ACCEPTS_NULL +/* Define to what tgetent() returns on success (0 on HP-UX X/Open curses) */ +#define TGETENT_SUCCESS 1 + /* Define to 1 if you use POSIX style signal handling */ #undef POSIX_SIGNALS diff --git a/zshconfig.ac b/zshconfig.ac index b47b21307..5db30aede 100644 --- a/zshconfig.ac +++ b/zshconfig.ac @@ -957,14 +957,16 @@ zsh_cv_func_tgetent_accepts_null, [AC_TRY_RUN([ main() { - int i = tgetent((char*)0,"vt100"); - if (i > 0) { - char tbuf[1024], *u; - u = tbuf; + char buf[4096]; + int r1 = tgetent(buf, "vt100"); + int r2 = tgetent((char*)0,"vt100"); + if (r1 >= 0 && r1 == r2) { + char tbuf[1024], *u; + u = tbuf; tgetstr("cl", &u); creat("conftest.tgetent", 0640); } - exit(!i || i == -1); + exit((r1 != r2) || r2 == -1); } ], if test -f conftest.tgetent; then @@ -977,6 +979,35 @@ main() if test $zsh_cv_func_tgetent_accepts_null = yes; then AC_DEFINE(TGETENT_ACCEPTS_NULL) fi +AC_CACHE_CHECK(if tgetent returns 0 on success, +zsh_cv_func_tgetent_zero_success, +[AC_TRY_RUN([ +main() +{ + char buf[4096]; + int r1 = tgetent(buf, "!@#$%^&*"); + int r2 = tgetent(buf, "vt100"); + if (r1 < 0 && r2 == 0) { + char tbuf[1024], *u; + u = tbuf; + tgetstr("cl", &u); + creat("conftest.tgetent0", 0640); + } + exit(r1 == r2); +} +], + if test -f conftest.tgetent0; then + zsh_cv_func_tgetent_zero_success=yes + else + zsh_cv_func_tgetent_zero_success=no + fi, + zsh_cv_func_tgetent_zero_success=no, + zsh_cv_func_tgetent_zero_success=no)]) +if test $zsh_cv_func_tgetent_zero_success = yes; then + AC_DEFINE(TGETENT_SUCCESS, 0) +else + AC_DEFINE(TGETENT_SUCCESS, 1) +fi AC_FUNC_MMAP if test x$ac_cv_func_mmap_fixed_mapped = xyes; then