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

PATCH: ptmx part 2



Peter Stephenson wrote:
> One course of action:
> 
> - Define _GNU_SOURCE for Linux only --- we've got enough testers to make
> it fairly painless to find out if this causes compilation problems.
> (Defining _XOPEN_SOURCE directly is harder since you've got to work
> out the version number.)
> - Check for the function definitions, particularly ptsname(), to make
> sure.
> - Only let the streams stuff cause havoc on Solaris.

This works on RedHat 9 and Solaris 8.

The check for the ptsname() prototype is a bit of a hack, since I don't
know how to do this properly.  I declare it as int ptsname(), i.e. the
same as the implicit definition, and if that causes an error I assume it
was properly prototyped.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.7
diff -u -r1.7 configure.ac
--- configure.ac	18 Feb 2004 13:33:08 -0000	1.7
+++ configure.ac	20 Feb 2004 14:47:48 -0000
@@ -1802,8 +1802,6 @@
 dnl We need to open it read/write, so make sure it is writeable.
 dnl Yet another test which won't work when cross-compiling.
 dnl ---------------
-AH_TEMPLATE([HAVE_DEV_PTMX],
-[Define to 1 if your system can use /dev/ptmx for creating ptys.])
 AC_CACHE_CHECK(if your system has /dev/ptmx,
 ac_cv_have_dev_ptmx,
 [if test -w /dev/ptmx; then
@@ -1811,10 +1809,38 @@
 else
   ac_cv_have_dev_ptmx=no
 fi])
-if test $ac_cv_have_dev_ptmx = yes; then
-  AC_DEFINE(HAVE_DEV_PTMX)
+
+dnl --------
+dnl Check if the ptmx functions are usable.
+dnl We need to be able to find the prototypes, which may
+dnl require non-POSIX source definitions.  So test to see
+dnl if ptsname is correctly recognised as returning a char *.
+dnl We do this by making sure a program where ptsname() is declared
+dnl as returning int does *not* compile.
+dnl On Linux we need the XOPEN extensions.  The easiest way to get
+dnl these is by defining _GNU_SOURCE.
+dnl -------
+AH_TEMPLATE([USE_DEV_PTMX],
+[Define to 1 if all the kit for using /dev/ptmx for ptys is available.])
+if test $ac_cv_have_dev_ptmx = yes && \
+   test $ac_cv_func_grantpt = yes && \
+   test $ac_cv_func_unlockpt = yes && \
+   test $ac_cv_func_ptsname = yes; then
+   AC_CACHE_CHECK([if /dev/ptmx is usable],
+   ac_cv_use_dev_ptmx,
+   [AC_TRY_COMPILE([#ifdef __linux
+#define _GNU_SOURCE 1
+#endif
+#include <stdlib.h>
+int ptsname();], ,
+   ac_cv_use_dev_ptmx=no,
+   ac_cv_use_dev_ptmx=yes)])
+   if test $ac_cv_use_dev_ptmx = yes; then
+     AC_DEFINE(USE_DEV_PTMX)
+   fi
 fi
 
+
 dnl ---------------
 dnl dynamic loading
 dnl ---------------
Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.17
diff -u -r1.17 system.h
--- Src/system.h	25 Jun 2003 14:48:38 -0000	1.17
+++ Src/system.h	20 Feb 2004 14:47:49 -0000
@@ -37,6 +37,14 @@
 #endif
 #endif
 
+#ifdef __linux
+/*
+ * Turn on numerous extensions.
+ * This is in order to get the functions for manipulating /dev/ptmx.
+ */
+#define _GNU_SOURCE 1
+#endif
+
 /* NeXT has half-implemented POSIX support *
  * which currently fools configure         */
 #ifdef __NeXT__
Index: Src/Modules/zpty.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zpty.c,v
retrieving revision 1.28
diff -u -r1.28 zpty.c
--- Src/Modules/zpty.c	17 Feb 2004 13:53:40 -0000	1.28
+++ Src/Modules/zpty.c	20 Feb 2004 14:47:49 -0000
@@ -154,8 +154,7 @@
     return NULL;
 }
 
-#if defined(HAVE_DEV_PTMX) && defined(HAVE_GRANTPT) && \
-    defined(HAVE_PTSNAME) && defined(HAVE_UNLOCKPT)
+#ifdef USE_DEV_PTMX
 
 #ifdef HAVE_SYS_STROPTS_H
 #include <sys/stropts.h>
@@ -190,7 +189,7 @@
 	close(mfd);
 	return 1;
     }
-#if defined(I_FIND) && defined(I_PUSH)
+#if defined(I_FIND) && defined(I_PUSH) && defined(__SVR4)
     /*
      * Use if STREAMS is available.  The test is probably OK,
      * but we could use e.g. the sys/stropts.h test.
Index: Src/Zle/iwidgets.list
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v
retrieving revision 1.4
diff -u -r1.4 iwidgets.list
--- Src/Zle/iwidgets.list	1 Jul 2002 09:54:48 -0000	1.4
+++ Src/Zle/iwidgets.list	20 Feb 2004 14:47:49 -0000
@@ -56,7 +56,7 @@
 "expand-word", expandword, 0
 "forward-char", forwardchar, 0
 "forward-word", forwardword, 0
-"get-line", getline, 0
+"get-line", zgetline, 0
 "gosmacs-transpose-chars", gosmacstransposechars, 0
 "history-beginning-search-backward", historybeginningsearchbackward, 0
 "history-beginning-search-forward", historybeginningsearchforward, 0
Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.9
diff -u -r1.9 zle_hist.c
--- Src/Zle/zle_hist.c	6 Dec 2002 23:24:07 -0000	1.9
+++ Src/Zle/zle_hist.c	20 Feb 2004 14:47:49 -0000
@@ -660,9 +660,10 @@
     return ret;
 }
 
+/* Renamed to avoid clash with library function */
 /**/
 int
-getline(char **args)
+zgetline(char **args)
 {
     char *s = (char *)getlinknode(bufstack);
 

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



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