From: "Peter A. Castro" <doctor@fruitbat.org>
To: zsh-workers@sunsite.dk
Subject: Re: zsh and line breaks
Date: Mon, 5 Apr 2004 15:08:33 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.53.0404051424500.11532@gremlin.fruitbat.org> (raw)
In-Reply-To: <29767.1081186817@csr.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1100 bytes --]
On Mon, 5 Apr 2004, Peter Stephenson wrote:
> "Peter A. Castro" wrote:
> > Excellent! Ok, that's decided. So, how/where do I submit code changes?
>
> Submit the context diffs or unidiffs to the list. If you're going to be
> doing this a lot and would like access to the CVS archive at
> Sourceforge, mail me with your Sourceforge user name.
Ok, see attached diff of the following files. These are primarily Cygwin
specific fixes, but some could be considdered generic:
Doc/Makefile.in - A little correction to the texi2html command
args and a fix to the install.html target to use sdir.
Src/builtin.c - Prevent from constructing "//path".
Src/exec.c - change read to use actual length instead of stat'd length.
Src/main.c - added Cygwin premain hook to deal with Text related I/O.
Src/system.h - add #include of <sys/cygwin.h>.
configure - change DLLD & DLLDFLAGS to not use dllwrap
configure.ac - change DLLD & DLLDFLAGS to not use dllwrap
--
Peter A. Castro <doctor@fruitbat.org> or <Peter.Castro@oracle.com>
"Cats are just autistic Dogs" -- Dr. Tony Attwood
[-- Attachment #2: zsh420cygwin.patch --]
[-- Type: TEXT/PLAIN, Size: 7281 bytes --]
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/Doc/Makefile.in zsh-4.2.0/Doc/Makefile.in
--- zsh-4.2.0-orig/Doc/Makefile.in 2003-10-25 10:38:19.000000000 -0700
+++ zsh-4.2.0/Doc/Makefile.in 2004-04-05 12:17:29.724238400 -0700
@@ -40,7 +40,7 @@
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
DVIPS = dvips
-TEXI2HTML = texi2html -expand info -split chapter
+TEXI2HTML = texi2html -expandinfo -split_chapter
.SUFFIXES: .yo .1
@@ -303,7 +303,7 @@
# install HTML manual
install.html: html
${SHELL} $(sdir_top)/mkinstalldirs $(DESTDIR)$(htmldir)
- for file in zsh*.html; do \
+ for file in ${sdir}/zsh*.html; do \
$(INSTALL_DATA) $$file $(DESTDIR)$(htmldir) || exit 1; \
done
.PHONY: install.html
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/Src/builtin.c zsh-4.2.0/Src/builtin.c
--- zsh-4.2.0-orig/Src/builtin.c 2004-03-18 03:31:40.000000000 -0800
+++ zsh-4.2.0/Src/builtin.c 2004-04-05 12:17:30.014656000 -0700
@@ -927,7 +927,9 @@
* DOS style names with drives in them
*/
static char buf[PATH_MAX];
+#ifndef _SYS_CYGWIN_H
void cygwin_conv_to_posix_path(const char *, char *);
+#endif
cygwin_conv_to_posix_path(dest, buf);
dest = buf;
@@ -1031,7 +1033,15 @@
/* handle directory prefix */
if (pfix && *pfix) {
if (*pfix == '/')
+#ifdef __CYGWIN__
+/* 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 *
+ * handling CDPATH correctly. */
+ buf = tricat(pfix, ( pfix[1] == '\0' ? "" : "/" ), dest);
+#else
buf = tricat(pfix, "/", dest);
+#endif
else {
int pfl = strlen(pfix);
dlen = strlen(pwd);
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/Src/exec.c zsh-4.2.0/Src/exec.c
--- zsh-4.2.0-orig/Src/exec.c 2004-03-18 03:48:42.000000000 -0800
+++ zsh-4.2.0/Src/exec.c 2004-04-05 12:17:30.204929600 -0700
@@ -3662,6 +3662,7 @@
{
char **pp, buf[PATH_MAX];
off_t len;
+ off_t rlen;
char *d;
Eprog r;
int fd;
@@ -3681,12 +3682,12 @@
if ((len = lseek(fd, 0, 2)) != -1) {
d = (char *) zalloc(len + 1);
lseek(fd, 0, 0);
- if (read(fd, d, len) == len) {
+ if ((rlen = read(fd, d, len)) >= 0) {
char *oldscriptname = scriptname;
close(fd);
- d[len] = '\0';
- d = metafy(d, len, META_REALLOC);
+ d[rlen] = '\0';
+ d = metafy(d, rlen, META_REALLOC);
scriptname = dupstring(s);
r = parse_string(d);
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/Src/main.c zsh-4.2.0/Src/main.c
--- zsh-4.2.0-orig/Src/main.c 2000-08-02 11:01:51.000000000 -0700
+++ zsh-4.2.0/Src/main.c 2004-04-05 12:17:30.445275200 -0700
@@ -30,6 +30,62 @@
#include "zsh.mdh"
#include "main.pro"
+/*
+ * Support for Cygwin binary/text mode filesystems.
+ * Peter A. Castro <doctor@fruitbat.org>
+ *
+ * This deserves some explaination, because it uses Cygwin specific
+ * runtime functions.
+ *
+ * Cygwin supports the notion of binary or text mode access to files
+ * based on the mount attributes of the filesystem. If a file is on
+ * a binary mounted filesystem, you get exactly what's in the file, CRLF's
+ * and all. If it's on a text mounted filesystem, Cygwin will strip out
+ * the CRs. This presents a problem because zsh code doesn't allow for
+ * CRLF's as line terminators. So, we must force all open files to be
+ * in text mode reguardless of the underlying filesystem attributes.
+ * However, we only want to do this for reading, not writing as we still
+ * want to write files in the mode of the filesystem. To do this,
+ * we have two options: augment all {f}open() calls to have O_TEXT added to
+ * the list of file mode options, or have the Cygwin runtime do it for us.
+ * I choose the latter. :)
+ *
+ * Cygwin's runtime provides pre-execution hooks which allow you to set
+ * various attributes for the process which effect how the process functions.
+ * One of these attributes controls how files are opened. I've set
+ * it up so that all files opened RDONLY will have the O_TEXT option set,
+ * thus forcing line termination manipulation. This seems to solve the
+ * problem (at least the Test suite runs clean :).
+ *
+ * Note: this may not work in later implementations. This will override
+ * all mode options passed into open(). Cygwin (really Windows) doesn't
+ * support all that much in options, so for now this is OK, but later on
+ * it may not, in which case O_TEXT will have to be added to all opens calls
+ * appropriately.
+ *
+ * This function is actually a hook in the Cygwin runtime which
+ * is called before the main of a program. Because it's part of the program
+ * pre-startup, it must be located in the program main and not in a DLL.
+ * It must also be made an export so the linker resolves this function to
+ * our code instead of the default Cygwin stub routine.
+ */
+
+/**/
+#ifdef __CYGWIN__
+/**/
+mod_export void
+cygwin_premain0 (int argc, char **argv, void *myself)
+{
+ static struct __cygwin_perfile pf[] =
+ {
+ {"", O_RDONLY | O_TEXT},
+ {NULL, 0}
+ };
+ cygwin_internal (CW_PERFILE, pf);
+}
+/**/
+#endif /* __CYGWIN__ */
+
/**/
int
main(int argc, char **argv)
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/Src/system.h zsh-4.2.0/Src/system.h
--- zsh-4.2.0-orig/Src/system.h 2004-02-24 05:02:12.000000000 -0800
+++ zsh-4.2.0/Src/system.h 2004-04-05 12:17:30.655577600 -0700
@@ -675,6 +675,7 @@
#endif
#ifdef __CYGWIN__
+# include <sys/cygwin.h>
# define IS_DIRSEP(c) ((c) == '/' || (c) == '\\')
#else
# define IS_DIRSEP(c) ((c) == '/')
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/configure zsh-4.2.0/configure
--- zsh-4.2.0-orig/configure 2004-03-15 11:10:03.000000000 -0800
+++ zsh-4.2.0/configure 2004-04-05 12:17:31.016096000 -0700
@@ -13547,8 +13547,10 @@
zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}"
elif test "$host_os" = cygwin; then
DL_EXT="${DL_EXT=dll}"
- DLLD="${DLLD=dllwrap}"
- DLLDFLAGS="${DLLDFLAGS=--export-all-symbols}"
+##DLLD="${DLLD=dllwrap}"
+ DLLD="${DLLD=$CC}"
+##DLLDFLAGS="${DLLDFLAGS=--export-all-symbols}"
+ DLLDFLAGS=${DLLDFLAGS=-shared -Wl,--export-all-symbols}
zsh_cv_func_dlsym_needs_underscore=no
DLLDFLAGS=${DLLDFLAGS=}
EXTRA_LDFLAGS=${EXTRA_LDFLAGS=}
diff -urN -x .build -x .inst -x .sinst zsh-4.2.0-orig/configure.ac zsh-4.2.0/configure.ac
--- zsh-4.2.0-orig/configure.ac 2004-03-15 11:08:25.000000000 -0800
+++ zsh-4.2.0/configure.ac 2004-04-05 12:17:31.226398400 -0700
@@ -1934,8 +1934,10 @@
zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}"
elif test "$host_os" = cygwin; then
DL_EXT="${DL_EXT=dll}"
- DLLD="${DLLD=dllwrap}"
- DLLDFLAGS="${DLLDFLAGS=--export-all-symbols}"
+##DLLD="${DLLD=dllwrap}"
+ DLLD="${DLLD=$CC}"
+##DLLDFLAGS="${DLLDFLAGS=--export-all-symbols}"
+ DLLDFLAGS=${DLLDFLAGS=-shared -Wl,--export-all-symbols}
zsh_cv_func_dlsym_needs_underscore=no
DLLDFLAGS=${DLLDFLAGS=}
EXTRA_LDFLAGS=${EXTRA_LDFLAGS=}
next prev parent reply other threads:[~2004-04-05 22:10 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <s38u10erwrz.fsf@ackusativ.ling.uu.se>
[not found] ` <1vvf60l9i7n4nlobcroik2le5ofe6v2rn4@4ax.com>
[not found] ` <Pine.LNX.4.53.0403291441160.5939@gremlin.fruitbat.org>
2004-03-30 9:32 ` Oliver Kiddle
2004-03-30 18:54 ` Peter A. Castro
2004-03-31 12:45 ` Oliver Kiddle
2004-03-31 17:53 ` Peter A. Castro
2004-04-01 9:09 ` Oliver Kiddle
2004-04-01 21:20 ` Peter A. Castro
2004-04-02 9:49 ` Dave Korn
2004-04-02 16:59 ` Peter A. Castro
2004-04-03 1:23 ` Peter A. Castro
2004-04-03 20:35 ` Bart Schaefer
2004-04-04 19:29 ` Peter Stephenson
2004-04-05 16:19 ` Peter A. Castro
2004-04-05 17:40 ` Peter Stephenson
2004-04-05 22:08 ` Peter A. Castro [this message]
2004-04-05 23:08 ` Clint Adams
2004-04-05 23:25 ` Peter A. Castro
2004-04-07 21:10 ` Clint Adams
2004-04-08 1:16 ` Peter A. Castro
2004-04-09 5:00 ` Felix Rosencrantz
2004-04-09 16:26 ` Peter A. Castro
2004-04-06 9:43 ` Peter Stephenson
2004-04-06 22:25 ` Peter A. Castro
2004-04-15 5:03 ` Clint Adams
2004-04-15 6:43 ` Peter A. Castro
2004-04-15 10:35 ` Clint Adams
2004-04-15 16:57 ` Peter A. Castro
2004-04-15 18:14 ` Clint Adams
2005-01-31 5:07 ` Patch for 4.2.3 building on Cygwin Peter A. Castro
2005-01-31 11:37 ` Peter Stephenson
2005-01-31 20:48 ` Peter A. Castro
2005-02-01 10:53 ` Peter Stephenson
2005-02-01 16:03 ` Bart Schaefer
2005-02-01 18:04 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.53.0404051424500.11532@gremlin.fruitbat.org \
--to=doctor@fruitbat.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).