Bläddra i källkod

cleanup stdio fiddling patch

Ralf S. Engelschall 21 år sedan
förälder
incheckning
1d59841891
2 ändrade filer med 41 tillägg och 42 borttagningar
  1. 38 35
      flex/flex.patch
  2. 3 7
      flex/flex.spec

+ 38 - 35
flex/flex.patch

@@ -1,38 +1,3 @@
-Index: filter.c
---- filter.c.orig	2003-03-25 17:39:08.000000000 +0100
-+++ filter.c	2004-03-19 14:43:31.317172000 +0100
-@@ -158,10 +158,13 @@
- 			int     r;
- 
- 			/* setup streams again */
-+#ifdef NOTOUCHSTDIO
--			if ((stdin = fdopen (0, "r")) == NULL)
--				flexfatal (_("fdopen(0) failed"));
--			if ((stdout = fdopen (1, "w")) == NULL)
--				flexfatal (_("fdopen(1) failed"));
-+#else
-+			if ((freopen ("/dev/stdin", "r", stdin)) == NULL)
-+				flexfatal (_("freopen(stdin) failed"));
-+			if ((freopen ("/dev/stdout", "w", stdout)) == NULL)
-+				flexfatal (_("freopen(stdout) failed"));
-+#endif
- 
- 			if ((r = chain->filter_func (chain)) == -1)
- 				flexfatal (_("filter_func failed"));
-@@ -181,8 +188,11 @@
- 	if (dup2 (pipes[1], 1) == -1)
- 		flexfatal (_("dup2(pipes[1],1)"));
- 	close (pipes[1]);
-+#ifdef NOTOUCHSTDIO
--	if ((stdout = fdopen (1, "w")) == NULL)
--		flexfatal (_("fdopen(1) failed"));
-+#else
-+	if ((freopen ("/dev/stdout", "w", stdout)) == NULL)
-+		flexfatal (_("freopen(stdout) failed"));
-+#endif
- 
- 	return true;
- }
 Index: flex.skl
 --- flex.skl.orig	2003-04-01 03:51:38.000000000 +0200
 +++ flex.skl	2004-02-07 13:21:59.000000000 +0100
@@ -360,3 +325,41 @@ Index: scan.c
  case YY_STATE_EOF(INITIAL):
  case YY_STATE_EOF(SECT2):
  case YY_STATE_EOF(CODEBLOCK):
+Index: filter.c
+--- filter.c.orig	2003-03-25 17:39:08.000000000 +0100
++++ filter.c	2004-03-31 16:55:21.000000000 +0200
+@@ -158,10 +158,21 @@
+ 			int     r;
+ 
+ 			/* setup streams again */
++#if 0
+ 			if ((stdin = fdopen (0, "r")) == NULL)
+ 				flexfatal (_("fdopen(0) failed"));
+ 			if ((stdout = fdopen (1, "w")) == NULL)
+ 				flexfatal (_("fdopen(1) failed"));
++#else
++			/* the above is theoretically correct, but on some
++			   platforms (FreeBSD, Solaris, etc) not possible because
++			   stdin/stdout/stderr are read-only. Unfortunately there is no
++			   standardized alternative except the cheating solution: in most
++			   Unix stdio(3) implementations a FILE is nothing more than a C
++			   structure referencing a Unix filedescriptor. Hence one can just
++			   do nothing as long as the underlying filedescriptor was already
++			   changed. */
++#endif
+ 
+ 			if ((r = chain->filter_func (chain)) == -1)
+ 				flexfatal (_("filter_func failed"));
+@@ -181,8 +192,12 @@
+ 	if (dup2 (pipes[1], 1) == -1)
+ 		flexfatal (_("dup2(pipes[1],1)"));
+ 	close (pipes[1]);
++#if 0
+ 	if ((stdout = fdopen (1, "w")) == NULL)
+ 		flexfatal (_("fdopen(1) failed"));
++#else
++	/* do just nothing (reason: see above) */
++#endif
+ 
+ 	return true;
+ }

+ 3 - 7
flex/flex.spec

@@ -39,7 +39,7 @@ Class:        CORE
 Group:        Language
 License:      BSD
 Version:      %{V_release}
-Release:      20040319
+Release:      20040331
 
 #   package options
 %option       with_beta  yes
@@ -88,14 +88,10 @@ AutoReqProv:  no
 %endif
 
 %build
-    CFLAGS="%{l_cflags -O}"
-    case "%{l_platform -t}" in
-       *-sunos*    ) CFLAGS="$CFLAGS -DNOTOUCHSTDIO" ;;
-    esac
     #   configure and build Flex (stable version)
     ( cd flex-%{V_release_maj}
       CC="%{l_cc}" \
-      CFLAGS="$CFLAGS" \
+      CFLAGS="%{l_cflags -O}" \
       ./configure \
           --prefix=$RPM_BUILD_ROOT%{l_prefix}
       %{l_make} %{l_mflags}
@@ -105,7 +101,7 @@ AutoReqProv:  no
 %if "%{with_beta}" == "yes"
     ( cd flex-%{V_beta}
       CC="%{l_cc}" \
-      CFLAGS="$CFLAGS" \
+      CFLAGS="%{l_cflags -O}" \
       HELP2MAN=`type -P true` \
       ./configure \
           --prefix=%{l_prefix} \