zsh-workers
 help / color / mirror / code / Atom feed
* Native Windows port, introduction.
@ 2012-03-15 18:26 Fabio Fabbri
  2012-03-16  7:43 ` Marc Chantreux
  2012-03-16 20:06 ` Peter Stephenson
  0 siblings, 2 replies; 3+ messages in thread
From: Fabio Fabbri @ 2012-03-15 18:26 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]

Hi all,

A quality native port of many useful u*x tools is available from
http://gnuwin32.sourceforge.net/ but the lack of a native u*x shell
in a Windows console is really annoying, because for scripting CMD.EXE
is poor and has a horrible syntax.

So I started the effort of porting zsh version 4.3.17 to native Windows
(i.e. using libc and Win32 calls).

- Are you interested in this effort ?

The port is based on two older projects: the very old port of zsh 3.0.5
to Windows by Amol Deshpande, and the Windows native port of tcsh
(version 6.17 as a base). I made _a lot_ of modifications to the sources,
and got a working port of zsh 3.0.8 that I called 3.0.8.1.

The sources of the library needed for the port (the fork() emulation
and many C libray missing pieces) are contained in the Src/win32
directory.

zsh 3.0.8.1, needed to bootstrap version 4.3.17 currenly has no home,
but I can easyly provide a tarball and an executable.

As a first step, to review the source code modifications, the port for
zsh 4.3.17 links a dummy forklib.a, where fork() returns an error.
This first step in many places adds _WIN32 conditionals to already
preset __CYGWIN__ sections.

The attached patch file has the minimal modifications to compile a NON YET
WORKING zsh. The compiled executable is able to execute only simple
builtin commands like echo or setopt.

The configure modifications SHOULD not be applied. They fix three
problems I was not able to workaround:
- at line 3306:
  # The possible output files:
  ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.o"
  deleting conftest.* deletes the source file to be compiled !
- at line 14099
  $SHELL $CONFIG_STATUS -d $ac_config_status_args || ac_cs_success=false
  the -d prevents config.status from failing as it is not able to
  delete the temporary directory that is used by a sub-shell
- the same applies to mkmakemod,sh at line 467
  ${CONFIG_SHELL-/bin/sh} ./config.status -d\

How should I go on from this ?

Best Regards

Fabio

[-- Attachment #2: patch-s1 --]
[-- Type: application/octet-stream, Size: 43715 bytes --]

diff -rupN zsh-4.3.17-orig/0-mingw-conf zsh-4.3.17-s1/0-mingw-conf
--- zsh-4.3.17-orig/0-mingw-conf	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/0-mingw-conf	2012-03-15 19:13:13.852576400 +0100
@@ -0,0 +1,43 @@
+# 0-mingw-conf
+# setup some variables and call configure 
+# BUGS:
+#       1 - the config.site hack is because configure does not set
+#           ac_executable_extensions=.exe. Why ?
+#           -- somehow fixed with the config.site hack
+#       2 - not always run to completion. 
+#       3 - the debugview log has many errors like
+#           [PID1] !!! close(11): invalid fd handle 0xFFFFFFFF
+#       4 - the debugview log has some errors like
+#           [PID2] !!! iodupfd(6, 10): invalid fd
+#       5 - the debugview log has some errors like
+#           [PID3] !!! close(-1): invalid fd handle 0x00000000
+#       6 - mingw-config.log has
+#           ....
+#           checking for wcrtomb... yes
+#           checking for wcwidth... no   <= WHY ? missing from mingw RT
+#           checking for wmemchr... yes
+#           ...
+#           configure: missing functions, multibyte support disabled
+#       7 - After configure exits there are errors with rlimits.awk, but
+#           they could be ignored, there are no rlimits on Windows
+
+
+IPATH="$PWD/Src/win32"
+export CFLAGS="-I$IPATH"
+export CPPFLAGS="-I$IPATH"
+# export LDFLAGS=  # LDFLAGS are inserted BEFORE other args
+# add the dummy fork lib, for configure tests
+export LIBS="-L$IPATH/lib -lfork"
+export MAKE=mingw32-make
+# needed to add "ac_executable_extensions=.exe"
+export CONFIG_SITE=Src/win32/config.site
+
+# where to log the ./configure output 
+cfgout=mingw-conf.log
+
+if [ ! -f $IPATH/unistd.h ]; then
+	echo "cannot find $IPATH/unistd.h"
+	exit 1
+fi	
+
+./configure --prefix=/bin --enable-zsh-debug --disable-dynamic --disable-restricted-r --disable-maildir-support --disable-pcre --disable-gdbm --disable-locale --disable-dynamic-nss > "$cfgout" 2>&1
diff -rupN zsh-4.3.17-orig/configure zsh-4.3.17-s1/configure
--- zsh-4.3.17-orig/configure	2011-08-11 20:09:05.000000000 +0200
+++ zsh-4.3.17-s1/configure	2012-03-13 16:57:28.087342300 +0100
@@ -3304,7 +3304,7 @@ $as_echo_n "checking whether the C compi
 ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 
 # The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.o"
 
 ac_rmfiles=
 for ac_file in $ac_files
@@ -14095,7 +14095,7 @@ if test "$no_create" != yes; then
   test "$silent" = yes &&
     ac_config_status_args="$ac_config_status_args --quiet"
   exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  $SHELL $CONFIG_STATUS -d $ac_config_status_args || ac_cs_success=false
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
diff -rupN zsh-4.3.17-orig/Src/builtin.c zsh-4.3.17-s1/Src/builtin.c
--- zsh-4.3.17-orig/Src/builtin.c	2012-02-05 20:25:50.000000000 +0100
+++ zsh-4.3.17-s1/Src/builtin.c	2012-03-12 17:35:41.077572000 +0100
@@ -1072,7 +1072,7 @@ cd_try_chdir(char *pfix, char *dest, int
     /* handle directory prefix */
     if (pfix && *pfix) {
 	if (*pfix == '/') {
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined(_WIN32)
 /* NB: Don't turn "/"+"bin" into "//"+"bin" by mistake!  "//bin" may *
  * not be what user really wants (probably wants "/bin"), but        *
  * "//bin" could be valid too (see fixdir())!  This is primarily for *
@@ -1223,7 +1223,7 @@ int
 fixdir(char *src)
 {
     char *dest = src, *d0 = dest;
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined(_WIN32)
     char *s0 = src;
 #endif
     int ret = 0;
@@ -1243,7 +1243,7 @@ fixdir(char *src)
     for (;;) {
 	/* compress multiple /es into single */
 	if (*src == '/') {
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) || defined(_WIN32)
 	    /* allow leading // under cygwin, but /// still becomes / */
 	    if (src == s0 && src[1] == '/' && src[2] != '/')
 		*dest++ = *src++;
@@ -5163,6 +5163,7 @@ bin_read(char *name, char **args, Option
     } else
 	readfd = izle = 0;
 
+#if !defined(_WIN32)
     if (OPT_ISSET(ops,'s') && SHTTY != -1) {
 	struct ttyinfo ti;
 	gettyinfo(&ti);
@@ -5175,6 +5176,7 @@ bin_read(char *name, char **args, Option
 #endif
 	settyinfo(&ti);
     }
+#endif
 
     /* handle prompt */
     if (firstarg) {
@@ -5208,6 +5210,7 @@ bin_read(char *name, char **args, Option
 #else
         delim = (delimstr[0] == Meta) ? delimstr[1] ^ 32 : delimstr[0];
 #endif
+#if !defined(_WIN32)
 	if (SHTTY != -1) {
 	    struct ttyinfo ti;
 	    gettyinfo(&ti);
@@ -5224,6 +5227,7 @@ bin_read(char *name, char **args, Option
 #endif
 	    settyinfo(&ti);
 	}
+#endif
     }
     if (OPT_ISSET(ops,'t')) {
 	zlong timeout = 0;
diff -rupN zsh-4.3.17-orig/Src/compat.c zsh-4.3.17-s1/Src/compat.c
--- zsh-4.3.17-orig/Src/compat.c	2010-06-14 20:30:00.000000000 +0200
+++ zsh-4.3.17-s1/Src/compat.c	2012-03-12 17:38:18.561722100 +0100
@@ -262,7 +262,7 @@ zgetdir(struct dirsav *d)
     struct stat sbuf;
     ino_t pino;
     dev_t pdev;
-#if !defined(__CYGWIN__) && !defined(USE_GETCWD)
+#if !defined(__CYGWIN__) && !defined(USE_GETCWD) && !defined(_WIN32)
     struct dirent *de;
     DIR *dir;
     dev_t dev;
@@ -283,7 +283,7 @@ zgetdir(struct dirsav *d)
     pdev = sbuf.st_dev;
     if (d)
 	d->ino = pino, d->dev = pdev;
-#if !defined(__CYGWIN__) && !defined(USE_GETCWD)
+#if !defined(__CYGWIN__) && !defined(USE_GETCWD) && !defined(_WIN32)
 #ifdef HAVE_FCHDIR
     else
 #endif
diff -rupN zsh-4.3.17-orig/Src/exec.c zsh-4.3.17-s1/Src/exec.c
--- zsh-4.3.17-orig/Src/exec.c	2012-02-12 21:18:42.000000000 +0100
+++ zsh-4.3.17-s1/Src/exec.c	2012-03-13 15:50:48.281250000 +0100
@@ -800,11 +800,17 @@ findcmd(char *arg0, int docopy)
 int
 iscom(char *s)
 {
-    struct stat statbuf;
     char *us = unmeta(s);
 
+#if defined(_WIN32)
+    /* our access() is always false for directories */
+    return (access(us, X_OK) == 0);
+#else
+    struct stat statbuf;
+
     return (access(us, X_OK) == 0 && stat(us, &statbuf) >= 0 &&
 	    S_ISREG(statbuf.st_mode));
+#endif
 }
 
 /**/
@@ -3633,7 +3639,11 @@ getherestr(struct redir *fn)
 	return -1;
     write_loop(fd, t, len);
     close(fd);
+#if defined(_WIN32)
+    fd = open(s, O_RDONLY | O_NOCTTY | O_TEMPORARY);
+#else
     fd = open(s, O_RDONLY | O_NOCTTY);
+#endif
     unlink(s);
     return fd;
 }
diff -rupN zsh-4.3.17-orig/Src/hist.c zsh-4.3.17-s1/Src/hist.c
--- zsh-4.3.17-orig/Src/hist.c	2012-02-09 22:55:19.000000000 +0100
+++ zsh-4.3.17-s1/Src/hist.c	2012-03-12 18:12:26.298616500 +0100
@@ -2390,8 +2390,8 @@ readhistfile(char *fn, int err, int read
     unlockhistfile(fn);
 }
 
-#ifdef HAVE_FCNTL_H
 static int flock_fd = -1;
+#if defined(HAVE_FCNTL_H) && !defined(_WIN32)
 
 /*
  * Lock file using fcntl().  Return 0 on success, 1 on failure of
@@ -2635,7 +2635,7 @@ lockhistfile(char *fn, int keep_trying)
     if (!fn && !(fn = getsparam("HISTFILE")))
 	return 1;
 
-#ifdef HAVE_FCNTL_H
+#if defined(HAVE_FCNTL_H) && !defined(_WIN32)
     if (isset(HISTFCNTLLOCK) && flock_fd < 0) {
 	ret = flockhistfile(fn, keep_trying);
 	if (ret)
diff -rupN zsh-4.3.17-orig/Src/init.c zsh-4.3.17-s1/Src/init.c
--- zsh-4.3.17-orig/Src/init.c	2012-02-05 20:24:30.000000000 +0100
+++ zsh-4.3.17-s1/Src/init.c	2012-03-14 18:22:22.831432600 +0100
@@ -427,6 +427,19 @@ init_io(void)
     /* Send xtrace output to stderr -- see execcmd() */
     xtrerr = stderr;
 
+#if defined(_WIN32)
+    {
+	int fd;
+	SHTTY = movefd(open("CONIN$", O_RDONLY));
+	fd = open("CONOUT$", O_WRONLY);
+	if (interact && SHTTY != -1) {
+	    shout = fdopen(fd,"w");
+	    if(!shout)
+		opts[USEZLE] = 0;
+	} else
+	    opts[USEZLE] = 0;
+    }
+#else
     /* Make sure the tty is opened read/write. */
     if (isatty(0)) {
 	zsfree(ttystrname);
@@ -499,6 +512,7 @@ init_io(void)
 	    opts[USEZLE] = 0;
     } else
 	opts[USEZLE] = 0;
+#endif /* _WIN32 */
 
 #ifdef JOB_CONTROL
     /* If interactive, make sure the shell is in the foreground and is the
@@ -918,11 +932,16 @@ setupvals(void)
 #ifdef TIOCGWINSZ
     adjustwinsize(0);
 #else
+# if defined(_WIN32)
+    zterm_lines = nt_getlines();
+    zterm_columns = nt_getcolumns();
+# else
     /* 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", zterm_columns);
     setiparam("LINES", zterm_lines);
+# endif
 #endif
 
 #ifdef HAVE_GETRLIMIT
diff -rupN zsh-4.3.17-orig/Src/mkmakemod.sh zsh-4.3.17-s1/Src/mkmakemod.sh
--- zsh-4.3.17-orig/Src/mkmakemod.sh	2011-05-13 20:07:35.000000000 +0200
+++ zsh-4.3.17-s1/Src/mkmakemod.sh	2012-03-15 16:01:50.148632300 +0100
@@ -464,7 +464,7 @@ fi
 if $second_stage ; then
     trap "rm -f $the_subdir/${the_makefile}; exit 1" 1 2 15
 
-    ${CONFIG_SHELL-/bin/sh} ./config.status \
+    ${CONFIG_SHELL-/bin/sh} ./config.status -d\
 	--file=$the_subdir/${the_makefile}:$the_subdir/${the_makefile}.in ||
     exit 1
 fi
diff -rupN zsh-4.3.17-orig/Src/utils.c zsh-4.3.17-s1/Src/utils.c
--- zsh-4.3.17-orig/Src/utils.c	2011-12-11 20:29:26.000000000 +0100
+++ zsh-4.3.17-s1/Src/utils.c	2012-03-13 16:33:10.180691600 +0100
@@ -1508,10 +1508,12 @@ gettyinfo(struct ttyinfo *ti)
 # ifdef HAVE_TERMIO_H
 	ioctl(SHTTY, TCGETA, &ti->tio);
 # else
+#  if !defined(_WIN32)
 	ioctl(SHTTY, TIOCGETP, &ti->sgttyb);
 	ioctl(SHTTY, TIOCLGET, &ti->lmodes);
 	ioctl(SHTTY, TIOCGETC, &ti->tchars);
 	ioctl(SHTTY, TIOCGLTC, &ti->ltchars);
+#  endif
 # endif
 #endif
     }
@@ -1538,10 +1540,12 @@ settyinfo(struct ttyinfo *ti)
 # ifdef HAVE_TERMIO_H
 	ioctl(SHTTY, TCSETA, &ti->tio);
 # else
+#  if !defined(_WIN32)
 	ioctl(SHTTY, TIOCSETN, &ti->sgttyb);
 	ioctl(SHTTY, TIOCLSET, &ti->lmodes);
 	ioctl(SHTTY, TIOCSETC, &ti->tchars);
 	ioctl(SHTTY, TIOCSLTC, &ti->ltchars);
+#  endif
 # endif
 #endif
     }
@@ -1624,7 +1628,7 @@ void
 adjustwinsize(int from)
 {
     static int getwinsz = 1;
-#ifdef TIOCGWINSZ
+#if defined(TIOCGWINSZ) && !defined(_WIN32)
     int ttyrows = shttyinfo.winsize.ws_row;
     int ttycols = shttyinfo.winsize.ws_col;
 #endif
@@ -2378,6 +2382,7 @@ getquery(char *valid_chars, int purge)
     attachtty(mypgrp);
 
     gettyinfo(&ti);
+#if !defined(_WIN32)
 #ifdef HAS_TIO
     ti.tio.c_lflag &= ~ECHO;
     if (!isem) {
@@ -2390,6 +2395,7 @@ getquery(char *valid_chars, int purge)
     if (!isem)
 	ti.sgttyb.sg_flags |= CBREAK;
 #endif
+#endif
     settyinfo(&ti);
 
     if (noquery(purge)) {
@@ -3850,6 +3856,7 @@ spdist(char *s, char *t, int thresh)
 void
 setcbreak(void)
 {
+#if !defined(_WIN32)
     struct ttyinfo ti;
 
     ti = shttyinfo;
@@ -3861,6 +3868,7 @@ setcbreak(void)
     ti.sgttyb.sg_flags |= CBREAK;
 #endif
     settyinfo(&ti);
+#endif
 }
 
 /* give the tty to some process */
@@ -3869,6 +3877,7 @@ setcbreak(void)
 mod_export void
 attachtty(pid_t pgrp)
 {
+#if !defined(_WIN32)
     static int ep = 0;
 
     if (jobbing && interact) {
@@ -3897,6 +3906,7 @@ attachtty(pid_t pgrp)
 	    }
 	}
     }
+#endif
 }
 
 /* get the process group associated with the tty */
@@ -3905,6 +3915,9 @@ attachtty(pid_t pgrp)
 pid_t
 gettygrp(void)
 {
+#if defined(_WIN32)
+    return 0;
+#else
     pid_t arg;
 
     if (SHTTY == -1)
@@ -3917,6 +3930,7 @@ gettygrp(void)
 #endif
 
     return arg;
+#endif
 }
 
 
diff -rupN zsh-4.3.17-orig/Src/win32/config.site zsh-4.3.17-s1/Src/win32/config.site
--- zsh-4.3.17-orig/Src/win32/config.site	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/config.site	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1 @@
+ac_executable_extensions=.exe
diff -rupN zsh-4.3.17-orig/Src/win32/doc/BUILD.txt zsh-4.3.17-s1/Src/win32/doc/BUILD.txt
--- zsh-4.3.17-orig/Src/win32/doc/BUILD.txt	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/doc/BUILD.txt	2012-03-15 19:21:50.664162900 +0100
@@ -0,0 +1,16 @@
+
+BUILD
+-----
+
+How to build the prototype:
+
+Get the mingw compiler (www.mingw.org) and install it. Add the mingw
+compiler and tools to PATH.
+Put sed, awk, grep and coreutil packages from gnuwin32 in /bin.
+Put zsh 3.0.8.1 in /bin and create a hardlink from /bin/zsh.exe to
+/bin/sh.exe. Add /bin to PATH.
+Copy and adapt the zsh 3.0.8.1 startup files.
+
+Open a zsh 3.0.8.1 command window and execute
+./0-mingw-conf
+mingw32-make
\ No newline at end of file
diff -rupN zsh-4.3.17-orig/Src/win32/grp.h zsh-4.3.17-s1/Src/win32/grp.h
--- zsh-4.3.17-orig/Src/win32/grp.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/grp.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)grp.h	8.2 (Berkeley) 1/21/94
+ */
+/* from
+ * $OpenBSD: grp.h,v 1.8 2005/12/13 00:35:22 millert Exp $
+ * oldfaber@gmail.com: simplified
+ */
+
+#ifndef	_GRP_H_
+#define	_GRP_H_	1
+
+#include "uni_types.h"
+
+
+struct group
+{
+	char	*gr_name;		/* group name */
+	char	*gr_passwd;		/* group password */
+	gid_t	gr_gid;			/* group id */
+	char	**gr_mem;		/* group members */
+};
+
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+struct group *getgrnam(const char *name);
+struct group *getgrgid(gid_t gid);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* !_GRP_H_ */
diff -rupN zsh-4.3.17-orig/Src/win32/lib/dummy.c zsh-4.3.17-s1/Src/win32/lib/dummy.c
--- zsh-4.3.17-orig/Src/win32/lib/dummy.c	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/lib/dummy.c	2012-03-15 13:26:54.577176800 +0100
@@ -0,0 +1,327 @@
+/*-
+ * Copyright (c) 2011, ...
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the following disclaimer in
+ *    the documentation and/or other materials provided with the distribution.
+ * 3. The names of the contributors may not be used to endorse or promote
+ *    products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * f/f:
+ *      dummy body for library functions
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "../uni_types.h"
+#include "sys/times.h"
+
+/* hack for configure */
+static int forcefork;
+
+uid_t getuid(void)
+{
+	return 0;
+}
+
+gid_t getgid(void)
+{
+	return 0;
+}
+
+uid_t geteuid(void)
+{
+	return 0;
+}
+
+gid_t getegid(void)
+{
+	return 0;
+}
+
+pid_t getppid(void)
+{
+	return 0;
+}
+
+unsigned int sleep(unsigned int seconds)
+{
+        return (0);
+}
+
+static void init_passwd(void)
+{
+}
+
+struct passwd *getpwnam(const char *name)
+{
+       	return NULL;
+}
+
+struct passwd *getpwuid(uid_t uid)
+{
+	return NULL;
+}
+
+struct group * getgrnam(const char *name)
+{
+	return NULL;
+}
+
+pid_t getpgrp(void)
+{
+        return (0);
+}
+
+int setpgid(pid_t pid, pid_t pgid)
+{
+        /* always succeed */
+        return (0);
+}
+
+char *getlogin(void)
+{
+	return NULL;
+}
+
+struct passwd * getpwent(void)
+{
+        return (NULL);
+}
+
+void endpwent()
+{
+        return;
+}
+
+void setpwent()
+{
+        return;
+}
+
+int getgroups(int gidsetsize, gid_t grouplist[])
+{
+	/* 0 groups */
+	return (0);
+}
+
+struct group *getgrgid(gid_t gid)
+{
+	return (NULL);
+}
+
+int gethostname(char *buf, int len)
+{
+        return (-1);
+}
+
+char *ttyname(int fd)
+{
+        return NULL;
+}
+
+int readlink(const char *path, char *buf, size_t len)
+{
+	/* always fail */
+        return (-1);
+}
+
+int link(const char *oldname, const char *newname)
+{
+	/* always fail */
+        return (-1);
+}
+
+int chown (const char *filename, uid_t owner, gid_t group)
+{
+	/* always succeed */
+        return (0);
+}
+
+clock_t times(struct tms *ignore)
+{
+	return (clock_t)(-1);
+}
+
+int fork(void)
+{
+	if (forcefork) {
+		forcefork = 0;
+                return (0);
+	}
+        errno = ENOMEM;
+        return (-1);
+}
+
+void *sbrk(ptrdiff_t delta)
+{
+        return NULL;
+}
+
+int waitpid(pid_t pid, int *statloc, int options)
+{
+        return (-1);
+}
+
+int kill(int pid, int sig)
+{
+        return (-1);
+}
+
+int nice(int niceness)
+{
+        return (-1);
+}
+
+unsigned int alarm(unsigned int seconds)
+{
+        return 0;
+}
+
+int fcntl(int fd, int command, ...)
+{
+        return 0;
+}
+
+int nt_execve(const char *prog, char **argv, char **env)
+{
+        return 0;
+}
+
+int nt_isatty(int fd)
+{
+        return 0;
+}
+
+int nt_fstat(int fd, struct stat *fs)
+{
+        return fstat(fd, fs);
+}
+
+int nt_stat(const char *fn, struct stat *fs)
+{
+        return stat(fn, fs);
+}
+
+int pipe(int pipefd[2])
+{
+        return (-1);
+}
+
+/* signal handling */
+void _nt_signal(void)
+{
+}
+
+int sigaction(int signo, void *act, void *oact)
+{
+	if (signo == 15)
+                forcefork++;
+        return 0;
+}
+
+int sigaddset(void *set, int signo)
+{
+        return 0;
+}
+
+int sigprocmask(int how, void *set, void *oset)
+{
+        return 0;
+}
+
+int sigsuspend(void *mask)
+{
+        /* return success ! */
+	errno = EINTR;
+	return (-1);
+}
+
+
+#if !(defined(__MINGW32__)||defined(__MINGW64__))
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+	return 0;
+}
+#endif
+
+
+/* win32 library NEEDED functions */
+
+
+void nt_init(char ***argv)
+{
+}
+
+int nt_getlines(void)
+{
+	return 25;
+}
+
+int nt_getcolumns(void)
+{
+	return 80;
+}
+
+void nt_setcursor(int mode)
+{
+}
+
+char *get_os_dir(const char *sysdir)
+{
+        static char c = 0;
+        return &c;
+}
+
+void *fmalloc(size_t sz)
+{
+        return malloc(sz);
+}
+
+void *frealloc(void *p, size_t sz)
+{
+        return realloc(p, sz);
+}
+
+/* fcalloc not used in zsh */
+void *fcalloc(size_t count, size_t elsize)
+{
+        return calloc(count, elsize);
+}
+
+void ffree(void *p)
+{
+        free(p);
+}
+
+int setenv(const char *name, const char *value, int replace)
+{
+        return 0;
+}
+
+int unsetenv(const char *name)
+{
+        return 0;
+}
+
Files zsh-4.3.17-orig/Src/win32/lib/libfork.a and zsh-4.3.17-s1/Src/win32/lib/libfork.a differ
diff -rupN zsh-4.3.17-orig/Src/win32/lib/Makefile zsh-4.3.17-s1/Src/win32/lib/Makefile
--- zsh-4.3.17-orig/Src/win32/lib/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/lib/Makefile	2012-03-15 14:00:51.701312200 +0100
@@ -0,0 +1,9 @@
+# makefile for libfork
+
+SHELL = /bin/sh
+CC = gcc -I..
+
+libfork.a:	dummy.o
+	ar rcs libfork.a $<
+	rm dummy.o
+	
\ No newline at end of file
diff -rupN zsh-4.3.17-orig/Src/win32/pwd.h zsh-4.3.17-s1/Src/win32/pwd.h
--- zsh-4.3.17-orig/Src/win32/pwd.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/pwd.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ * Portions Copyright(C) 1995, 1996, Jason Downs.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
+ */
+/* from
+ * $OpenBSD: pwd.h,v 1.20 2008/06/25 14:51:27 millert Exp $
+ * oldfaber@gmail.com: simplified
+ */
+
+#ifndef	_PWD_H_
+#define	_PWD_H_	1
+
+#include "uni_types.h"
+
+
+struct passwd {
+	char	*pw_name;		/* user name */
+	char	*pw_passwd;		/* encrypted password */
+	uid_t	pw_uid;			/* user uid */
+	gid_t	pw_gid;			/* user gid */
+	time_t	pw_change;		/* password change time */
+	char	*pw_class;		/* user access class */
+	char	*pw_gecos;		/* Honeywell login info */
+	char	*pw_dir;		/* home directory */
+	char	*pw_shell;		/* default shell */
+	time_t	pw_expire;		/* account expiration */
+};
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+struct passwd *getpwuid (uid_t);
+struct passwd *getpwnam (const char *);
+struct passwd	*getpwent (void);
+void		 setpwent (void);
+void		 endpwent (void);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* !_PWD_H_ */
diff -rupN zsh-4.3.17-orig/Src/win32/sgtty.h zsh-4.3.17-s1/Src/win32/sgtty.h
--- zsh-4.3.17-orig/Src/win32/sgtty.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/sgtty.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)ioctl_compat.h	8.4 (Berkeley) 1/21/94
+ */
+/* oldfaber@gmail.com: simplified, used only for compiling */
+
+struct tchars
+{
+	char t_intrc;		/* interrupt */
+	char t_quitc;		/* quit */
+	char t_startc;		/* start output */
+	char t_stopc;		/* stop output */
+	char t_eofc;		/* end-of-file */
+	char t_brkc;		/* input delimiter (like nl) */
+};
+
+struct ltchars
+{
+	char t_suspc;		/* stop process signal */
+	char t_dsuspc;		/* delayed stop process signal */
+	char t_rprntc;		/* reprint line */
+	char t_flushc;		/* flush output (toggles) */
+	char t_werasc;		/* word erase */
+	char t_lnextc;		/* literal next character */
+};
+
+/*
+ * Structure for TIOCGETP and TIOCSETP ioctls.
+ */
+#ifndef _SGTTYB_
+#define	_SGTTYB_
+struct sgttyb
+{
+	char sg_ispeed;		/* input speed */
+	char sg_ospeed;		/* output speed */
+	char sg_erase;		/* erase character */
+	char sg_kill;		/* kill character */
+	short int sg_flags;	/* mode flags */
+};
+#endif
diff -rupN zsh-4.3.17-orig/Src/win32/signal.h zsh-4.3.17-s1/Src/win32/signal.h
--- zsh-4.3.17-orig/Src/win32/signal.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/signal.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 1997-2002, 2010, Amol Deshpande and contributors
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * signal.h
+ * signal emulation things
+ * -amol
+ */
+
+
+#ifndef SIGNAL_H
+#define SIGNAL_H
+
+#include "uni_types.h"
+
+#define NSIG 23     
+
+#if !defined(_SIG_ATOMIC_T_DEFINED)
+typedef int sig_atomic_t;
+#define _SIG_ATOMIC_T_DEFINED
+#endif
+
+/* ctr_handler() maps CTRL_xxx_EVENT to the following: (see wincon.h) */
+#define SIGINT		1 
+#define SIGBREAK 	2
+#define SIGHUP		3  /* CTRL_CLOSE_EVENT */
+/* 3 and 4 are reserved. hence we can't use 4 and 5 */
+#define	SIGTERM		6 /* ctrl_logoff */
+#define SIGKILL		7 /* ctrl_shutdown */
+
+#define SIGILL		8 
+#define SIGFPE		9	
+#define SIGALRM		10
+#define SIGWINCH	11
+#define SIGSEGV 	12	
+#define SIGSTOP 	13
+#define SIGPIPE 	14
+#define SIGCHLD 	15
+#define SIGCONT		16 
+#define SIGTSTP 	18
+#define SIGTTOU 	19
+#define SIGTTIN 	20
+#define SIGABRT 	22	
+
+#define SIGQUIT SIGBREAK
+
+/* signal action codes */
+
+#define SIG_DFL (void (*)(int))0	   /* default signal action */
+#define SIG_IGN (void (*)(int))1	   /* ignore signal */
+#define SIG_SGE (void (*)(int))3	   /* signal gets error */
+#define SIG_ACK (void (*)(int))4	   /* acknowledge */
+
+
+/* signal error value (returned by signal call on error) */
+
+#define SIG_ERR (void (*)(int))-1	   /* signal error value */
+
+
+#define SIG_BLOCK 0
+#define SIG_UNBLOCK 1
+#define SIG_SETMASK 2
+
+#if defined(signal)
+# undef signal
+#endif
+#define signal(a,b) _nt_signal((a), (b))
+
+/* only defined for __MINGW32__ */
+#if defined(__MINGW64__) || defined(_MSC_VER)
+typedef unsigned long sigset_t;
+#endif
+typedef void Sigfunc (int);
+
+struct sigaction {
+	Sigfunc *sa_handler;
+	sigset_t sa_mask;
+	int sa_flags;
+};
+
+
+#define sigemptyset(ptr) (*(ptr) = 0)
+#define sigfillset(ptr)  ( *(ptr) = ~(sigset_t)0,0)
+
+/* Function prototypes */
+
+void (* _nt_signal(int, void (*)(int)))(int);
+
+int sigaddset(sigset_t*, int);
+int sigdelset(sigset_t*,int);
+unsigned int alarm(unsigned int);
+
+int sigismember(const sigset_t *set, int);
+int sigprocmask(int, const sigset_t *, sigset_t *);
+int sigaction(int, const struct sigaction *, struct sigaction *);
+int sigsuspend(const sigset_t *sigmask);
+
+int kill(pid_t pid, int sig);
+  
+#endif /* SIGNAL_H */
diff -rupN zsh-4.3.17-orig/Src/win32/uni_types.h zsh-4.3.17-s1/Src/win32/uni_types.h
--- zsh-4.3.17-orig/Src/win32/uni_types.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/uni_types.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,91 @@
+/* 
+ * uni_types.h
+ */
+
+/*
+ * Missing types from sys/types.h
+ */
+
+
+#ifndef	_UNI_TYPES_H
+#define	_UNI_TYPES_H	1
+
+#include <time.h>
+#include <sys/types.h>
+
+/* Microsoft includes unconditionally define this struct */
+#if !(defined(_TIMEVAL_DEFINED)||defined(_WINSOCKAPI_))
+#define _TIMEVAL_DEFINED
+struct timeval{
+	long tv_sec;
+	long tv_usec;
+};
+#endif
+
+/* some defines not available in win32 headers */
+#ifdef S_IFMT
+# if !defined(S_IFBLK)
+#  define	S_IFBLK		0x3000	/* never used under win32 */
+# endif
+# if !defined(S_IFIFO)
+#  define	S_IFIFO		0x1000	/* FIFO */
+# endif
+# if !defined(S_IFLNK)
+#  define	S_IFLNK		0xA000	/* symlink */
+# endif
+# if !defined(S_ISDIR) && defined(S_IFDIR)
+#  define S_ISDIR(a)	(((a) & S_IFMT) == S_IFDIR)
+# endif	/* ! S_ISDIR && S_IFDIR */
+# if !defined(S_ISCHR) && defined(S_IFCHR)
+#  define S_ISCHR(a)	(((a) & S_IFMT) == S_IFCHR)
+# endif /* ! S_ISCHR && S_IFCHR */
+# if !defined(S_ISBLK) && defined(S_IFBLK)
+#  define S_ISBLK(a)	(((a) & S_IFMT) == S_IFBLK)
+# endif	/* ! S_ISBLK && S_IFBLK */
+# if !defined(S_ISREG) && defined(S_IFREG)
+#  define S_ISREG(a)	(((a) & S_IFMT) == S_IFREG)
+# endif	/* ! S_ISREG && S_IFREG */
+# if !defined(S_ISFIFO) && defined(S_IFIFO)
+#  define S_ISFIFO(a)	(((a) & S_IFMT) == S_IFIFO)
+# endif	/* ! S_ISFIFO && S_IFIFO */
+# if !defined(S_ISNAM) && defined(S_IFNAM)
+#  define S_ISNAM(a)	(((a) & S_IFMT) == S_IFNAM)
+# endif	/* ! S_ISNAM && S_IFNAM */
+# if !defined(S_ISLNK) && defined(S_IFLNK)
+#  define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
+# endif	/* ! S_ISLNK && S_IFLNK */
+# if !defined(S_ISSOCK) && defined(S_IFSOCK)
+#  define S_ISSOCK(a)	(((a) & S_IFMT) == S_IFSOCK)
+# endif	/* ! S_ISSOCK && S_IFSOCK */
+#endif /* S_IFMT */
+
+#if !defined(UID_T_DEFINED)
+# define UID_T_DEFINED
+typedef int uid_t;
+#endif
+#if !defined(GID_T_DEFINED)
+# define GID_T_DEFINED
+typedef int gid_t;
+#endif
+#if defined(_MSC_VER)
+typedef int mode_t;
+# if !defined(_PID_T_DEFINED)
+#  define _PID_T_DEFINED
+typedef int pid_t;
+# endif
+typedef int int32_t;
+#endif
+
+#if !defined(HAVE_RLIM_T)
+# define HAVE_RLIM_T 1
+typedef unsigned long rlim_t;
+#endif
+
+#if !(defined(__MINGW32__)||defined(__MINGW64__))
+struct timezone {
+	int tz_minuteswest;
+	int dsttime;
+};
+#endif
+
+#endif
diff -rupN zsh-4.3.17-orig/Src/win32/unistd.h zsh-4.3.17-s1/Src/win32/unistd.h
--- zsh-4.3.17-orig/Src/win32/unistd.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/unistd.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,95 @@
+/* unistd.h for *nix challenged environments */
+
+#ifndef	_UNISTD_H
+#define	_UNISTD_H	1
+
+/* functions missing from this file may be found in */
+#include <process.h>
+#include <stddef.h>
+#include <io.h>
+
+#include "uni_types.h"
+
+#if defined(__MINGW32__)||defined(__MINGW64__)
+# include <stdint.h>
+# include <sys/time.h>
+#endif
+#if defined(__GNUC__)
+# include_next <unistd.h>
+#endif
+
+#if defined(_MSC_VER)
+/* NOTE: Microsoft CRT gives a runtime parameter error for access(s, X_OK) */
+/* file test macros:
+   00  Existence only           01  Executable
+   02  Write permission         04  Read permission
+   06  Read and write permission
+*/
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
+#endif
+
+/* these are command values for fcntl(), not found in windows fcntl.h */
+#define	F_DUPFD	0      	/* duplicate file descriptor */
+#define	F_GETFD	1      	/* get file descriptor flags */
+#define	F_SETFD	2      	/* set file descriptor flags */
+#define	F_GETFL	3      	/* get file status flags */
+#define	F_SETFL	4      	/* set file status flags */
+/* requests, not found in windows fcntl.h */
+#define	FD_CLOEXEC 1	
+/* get/set non blocking mode, not found in windows fcntl.h */
+#define	O_NONBLOCK	0x0004
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/* windows declaration in winsock.h differs ... */
+#if !(defined(_MSC_VER) && defined(_WINSOCKAPI_))
+int gethostname(char *buf, int len);
+#endif
+
+int readlink(const char *__path, char *__buf, size_t __len);
+char *getlogin(void);
+char *ttyname(int fd);
+int nice(int increment);
+/* MSVC runtime only has _pipe() */
+int pipe(int hpipe[2]);
+int fork(void);
+#if !defined(__MINGW32__)
+/* defined in sys/time.h with a different prototype */
+int gettimeofday(struct timeval *tv, struct timezone *tz);
+#endif
+uid_t getuid(void);
+uid_t geteuid(void);
+gid_t getgid(void);
+gid_t getegid(void);
+pid_t getppid(void);
+pid_t getpgrp (void);
+int setuid(uid_t newuid);
+int setgid(gid_t newgid);
+int seteuid(uid_t neweuid);
+int setegid(gid_t newegid);
+int setpgid(pid_t pid, pid_t pgid);
+int getgroups(int gidsetsize, gid_t grouplist[]);
+unsigned int sleep(unsigned int seconds);
+int chown(const char *filename, uid_t owner, gid_t group);
+int link(const char *oldname, const char *newname);
+/* usually declared in stdlib.h */
+int setenv(const char *name, const char *value, int replace);
+int unsetenv(const char *name);
+
+/* this function is available in the fork library */
+void *sbrk(ptrdiff_t delta);
+
+/* this function should be in fcntl.h, but windows compiler already have
+   a sys/fcntl.h file, lacking this function */
+int fcntl(int, int, ...);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* unistd.h  */
diff -rupN zsh-4.3.17-orig/Src/win32/utmp.h zsh-4.3.17-s1/Src/win32/utmp.h
--- zsh-4.3.17-orig/Src/win32/utmp.h	1970-01-01 01:00:00.000000000 +0100
+++ zsh-4.3.17-s1/Src/win32/utmp.h	2012-03-15 18:55:07.231099400 +0100
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)utmp.h	8.2 (Berkeley) 1/21/94
+ */
+/* from
+ * $OpenBSD: utmp.h,v 1.5 2003/06/02 19:34:12 millert Exp $
+ * oldfaber@gmail.com: simplified, there is no utmp in Windows
+ */
+
+#ifndef	_UTMP_H_
+#define	_UTMP_H_	1
+
+#define	UT_NAMESIZE	32
+#define	UT_LINESIZE	8
+#define	UT_HOSTSIZE	256
+
+struct utmp {
+	char	ut_line[UT_LINESIZE];
+	char	ut_name[UT_NAMESIZE];
+	char	ut_host[UT_HOSTSIZE];
+	time_t	ut_time;
+};
+
+#endif /* !_UTMP_H_ */
diff -rupN zsh-4.3.17-orig/Src/Zle/zle_main.c zsh-4.3.17-s1/Src/Zle/zle_main.c
--- zsh-4.3.17-orig/Src/Zle/zle_main.c	2012-02-05 20:24:35.000000000 +0100
+++ zsh-4.3.17-s1/Src/Zle/zle_main.c	2012-03-13 17:27:55.618217500 +0100
@@ -208,6 +208,7 @@ char **watch_funcs;	/* The corresponding
 mod_export void
 zsetterm(void)
 {
+#if !defined(_WIN32)
     struct ttyinfo ti;
 #if defined(FIONREAD)
     int val;
@@ -357,6 +358,7 @@ zsetterm(void)
 #endif
 
     settyinfo(&ti);
+#endif /* _WIN32, i.e. this function is void */
 }
 
 static char *kungetbuf;
@@ -876,8 +878,10 @@ getbyte(long do_keytmout, int *timeout)
 		breaks = obreaks;
 		errno = old_errno;
 		return lastchar = EOF;
+#if !defined(_WIN32)
 	    } else if (errno == EWOULDBLOCK) {
 		fcntl(0, F_SETFL, 0);
+#endif
 	    } else if (errno == EIO && !die) {
 		ret = opts[MONITOR];
 		opts[MONITOR] = 1;
diff -rupN zsh-4.3.17-orig/Src/Zle/zle_misc.c zsh-4.3.17-s1/Src/Zle/zle_misc.c
--- zsh-4.3.17-orig/Src/Zle/zle_misc.c	2010-12-09 20:47:19.000000000 +0100
+++ zsh-4.3.17-s1/Src/Zle/zle_misc.c	2012-03-13 17:30:04.274467500 +0100
@@ -627,11 +627,13 @@ int
 quotedinsert(char **args)
 {
 #ifndef HAS_TIO
+# if !defined(_WIN32)
     struct sgttyb sob;
 
     sob = shttyinfo.sgttyb;
     sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
     ioctl(SHTTY, TIOCSETN, &sob);
+# endif
 #endif
     getfullchar(0);
 #ifndef HAS_TIO
diff -rupN zsh-4.3.17-orig/Src/Zle/zle_vi.c zsh-4.3.17-s1/Src/Zle/zle_vi.c
--- zsh-4.3.17-orig/Src/Zle/zle_vi.c	2008-04-30 23:21:40.000000000 +0200
+++ zsh-4.3.17-s1/Src/Zle/zle_vi.c	2012-03-13 17:30:54.696342500 +0100
@@ -959,9 +959,11 @@ viquotedinsert(char **args)
     zleline[zlecs] = '^';
     zrefresh();
 #ifndef HAS_TIO
+# if !defined(_WIN32)
     sob = shttyinfo.sgttyb;
     sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
     ioctl(SHTTY, TIOCSETN, &sob);
+# endif
 #endif
     getfullchar(0);
 #ifndef HAS_TIO
diff -rupN zsh-4.3.17-orig/Src/zsh_system.h zsh-4.3.17-s1/Src/zsh_system.h
--- zsh-4.3.17-orig/Src/zsh_system.h	2011-05-10 18:44:39.000000000 +0200
+++ zsh-4.3.17-s1/Src/zsh_system.h	2012-03-14 18:24:56.674198000 +0100
@@ -766,8 +766,10 @@ extern short ospeed;
 #define mailstat(X,Y) stat(X,Y)
 #endif
 
-#ifdef __CYGWIN__
-# include <sys/cygwin.h>
+#if defined(__CYGWIN__) || defined(_WIN32)
+# if defined(__CYGWIN__)
+#  include <sys/cygwin.h>
+# endif
 # define IS_DIRSEP(c) ((c) == '/' || (c) == '\\')
 #else
 # define IS_DIRSEP(c) ((c) == '/')

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

* Re: Native Windows port, introduction.
  2012-03-15 18:26 Native Windows port, introduction Fabio Fabbri
@ 2012-03-16  7:43 ` Marc Chantreux
  2012-03-16 20:06 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Chantreux @ 2012-03-16  7:43 UTC (permalink / raw)
  To: Fabio Fabbri; +Cc: zsh-workers

hello,

On Thu, Mar 15, 2012 at 07:26:52PM +0100, Fabio Fabbri wrote:
> Hi all,
> 
> A quality native port of many useful u*x tools is available from
> http://gnuwin32.sourceforge.net/ but the lack of a native u*x shell
> in a Windows console is really annoying, because for scripting CMD.EXE
> is poor and has a horrible syntax.

* I used amol's zsh with the gnuwin32 tools years ago and it was much,
  much slower than cygwin was. is there some news about that ? 
* Don't you think powershell is now the defacto shell for windows ? 
  - pro: accces to all the .net framework 
  - pro: powerfull syntax piping object and having anonymous functions
    for filter and apply 
  - pro: default standard
  - cons: lack of vi binding

regards 
marc 


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

* Re: Native Windows port, introduction.
  2012-03-15 18:26 Native Windows port, introduction Fabio Fabbri
  2012-03-16  7:43 ` Marc Chantreux
@ 2012-03-16 20:06 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2012-03-16 20:06 UTC (permalink / raw)
  To: zsh-workers

On Thu, 15 Mar 2012 19:26:52 +0100
Fabio Fabbri <oldfaber@gmail.com> wrote:
> So I started the effort of porting zsh version 4.3.17 to native Windows
> (i.e. using libc and Win32 calls).
> 
> - Are you interested in this effort ?

Thanks, most of the differences don't look they're a problem to
incorporate.  You probably don't need the config.status -d changes,
though, they should only be useful for debugging.
 
> The port is based on two older projects: the very old port of zsh 3.0.5
> to Windows by Amol Deshpande, and the Windows native port of tcsh
> (version 6.17 as a base). I made _a lot_ of modifications to the sources,
> and got a working port of zsh 3.0.8 that I called 3.0.8.1.

We'll need to be careful about the licences of anything we include.  I
presume the 3.0.5 changes are under the normal zsh licence, but tcsh is
probably different.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

end of thread, other threads:[~2012-03-16 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-15 18:26 Native Windows port, introduction Fabio Fabbri
2012-03-16  7:43 ` Marc Chantreux
2012-03-16 20:06 ` 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).