Description: Replace BSD-specific funopen with GNU-specific fopencookie
Forwarded: not-needed
Author: Matej Vela <vela@debian.org>
Last-Update: 2011-05-13

--- a/csh.c
+++ b/csh.c
@@ -154,10 +154,11 @@
 
 extern char **environ;
 
-static int	readf(void *, char *, int);
+static ssize_t	readf(void *, char *, size_t);
 static off_t	seekf(void *, off_t, int);
-static int	writef(void *, const char *, int);
+static ssize_t	writef(void *, const char *, size_t);
 static int	closef(void *);
+static cookie_io_functions_t cookief = {readf, writef, seekf, closef};
 static int	srccat(Char *, Char *);
 static int	srcfile(char *, bool, bool);
 static void	phup(int);
@@ -250,14 +251,11 @@
      *	    Fortunately this is not needed under the current implementation
      *	    of stdio.
      */
-    (void) fclose(cshin);
-    (void) fclose(cshout);
-    (void) fclose(csherr);
-    if (!(cshin  = funopen((void *) &SHIN,  readf, writef, seekf, closef)))
+    if (!(cshin  = fopencookie((void *) &SHIN,  "r", cookief)))
 	exit(1);
-    if (!(cshout = funopen((void *) &SHOUT, readf, writef, seekf, closef)))
+    if (!(cshout = fopencookie((void *) &SHOUT, "w", cookief)))
 	exit(1);
-    if (!(csherr = funopen((void *) &SHERR, readf, writef, seekf, closef)))
+    if (!(csherr = fopencookie((void *) &SHERR, "w", cookief)))
 	exit(1);
     (void) setvbuf(cshin,  NULL, _IOLBF, 0);
     (void) setvbuf(cshout, NULL, _IOLBF, 0);
@@ -1258,15 +1256,15 @@
  */
 #define DESC(a) (*((int *) (a)) - (didfds && *((int *) a) >= FSHIN ? FSHIN : 0))
 
-static int
-readf(void *oreo, char *buf, int siz)
+static ssize_t
+readf(void *oreo, char *buf, size_t siz)
 {
     return read(DESC(oreo), buf, siz);
 }
 
 
-static int
-writef(void *oreo, const char *buf, int siz)
+static ssize_t
+writef(void *oreo, const char *buf, size_t siz)
 {
     return write(DESC(oreo), buf, siz);
 }
