about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Src/init.c6
-rw-r--r--acconfig.h3
-rw-r--r--zshconfig.ac41
3 files changed, 42 insertions, 8 deletions
diff --git a/Src/init.c b/Src/init.c
index f343f3025..1a5728870 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 fb99d7c42..1f143717c 100644
--- a/zshconfig.ac
+++ b/zshconfig.ac
@@ -964,14 +964,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
@@ -984,6 +986,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