Index: /trunk/src/emx/src/lib/app/stdio.c
===================================================================
--- /trunk/src/emx/src/lib/app/stdio.c	(revision 1369)
+++ /trunk/src/emx/src/lib/app/stdio.c	(revision 1370)
@@ -3,9 +3,9 @@
 
 #include "libc-alias.h"
-#include <stdio.h>
-#include <stdlib.h>
 #include <sys/builtin.h>        /* For <sys/fmutex.h> */
 #include <sys/fmutex.h>         /* For <sys/rmutex.h> */
 #include <sys/rmutex.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <emx/io.h>
 #include <emx/startup.h>
@@ -22,8 +22,5 @@
 
 /** Vector entry for preallocated streams. */
-static struct streamvec     gPreStreamVec = {&gaPreFiles[0], NULL, _NFILES};
-
-/** More structures for preallocated streams. */
-static struct _file2        gaPreFile2s[_NFILES];
+static struct streamvec     gPreStreamVec = {_NFILES, NULL, &gaPreFiles[0], NULL, _NFILES};
 
 /** The buffer for stdin. */
@@ -38,6 +35,8 @@
  */
 
-/** Head of the stream vector. */
+/** Head of the stream vector list. */
 struct streamvec           *_streamvec_head = NULL;
+/** Tail of the stream vector list. */
+struct streamvec           *_streamvec_tail = NULL;
 
 /** Standard input stream pointer. */
@@ -58,5 +57,4 @@
     LIBCLOG_ENTER("\n");
     struct _FILE       *pFile;
-    struct _file2      *pFile2;
     int                 i;
     static char         fInited = 0;
@@ -74,10 +72,6 @@
      */
     pFile   = &gaPreFiles[0];
-    pFile2  = &gaPreFile2s[0];
-    for (i = 0; i < _NFILES; i++, pFile++, pFile2++)
-    {
-        pFile2->owner = pFile; /* obsolete? */
-        pFile->_more = pFile2;
-    }
+    for (i = 0; i < _NFILES; i++, pFile++)
+        pFile->__pSV = &gPreStreamVec;
 
     /*
@@ -85,6 +79,6 @@
      * ASSUME: we're ALONE at this point.
      */
-    gPreStreamVec.next  = _streamvec_head;
     _streamvec_head     = &gPreStreamVec;
+    _streamvec_tail     = &gPreStreamVec;
     _rmutex_checked_create(&_streamv_rmutex, 0);
 
@@ -102,8 +96,9 @@
              * Common init - recall everything is ZERO.
              */
-            gaPreFiles[i]._flags    |= _IOOPEN;
+            gPreStreamVec.cFree--;
+            gaPreFiles[i]._flags    |= _IOOPEN | _IONOCLOSEALL;
             gaPreFiles[i]._handle    = i;
             gaPreFiles[i]._flush     = _flushstream;
-            if (_setmore(&gaPreFiles[i], 0))
+            if (_rmutex_create (&gaPreFiles[i].__u.__rsem, 0) != 0)
             {
                 LIBC_ASSERTM_FAILED("_setmore failed for i=%d\n", i);
Index: /trunk/src/emx/src/lib/io/_fopen.c
===================================================================
--- /trunk/src/emx/src/lib/io/_fopen.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/_fopen.c	(revision 1370)
@@ -2,8 +2,11 @@
 
 #include "libc-alias.h"
-#include <stdio.h>
 #include <io.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <emx/io.h>
 
@@ -75,15 +78,11 @@
       if (ok) ++mode;
     }
-  dst->_ptr = NULL;
-  dst->_buffer = NULL;
-  dst->_buf_size = 0;
-  dst->_rcount = 0;
-  dst->_wcount = 0;
-  dst->_tmpidx = 0;
-  dst->_ungetc_count = 0;
   dst->_flags |= _IOOPEN | _IOBUFNONE;
   dst->_flush = _flushstream;
-  if (_setmore (dst, lock) != 0)
-    return NULL;
+  if (_rmutex_create (&dst->__u.__rsem, 0) != 0)
+    {
+      _closestream (dst);
+      return NULL;
+    }
   dst->_handle = sopen (fname, omode, shflag, 0644);
   if (dst->_handle < 0)
Index: /trunk/src/emx/src/lib/io/_mfopen.c
===================================================================
--- /trunk/src/emx/src/lib/io/_mfopen.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/_mfopen.c	(revision 1370)
@@ -2,7 +2,10 @@
 
 #include "libc-alias.h"
-#include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <emx/io.h>
 
@@ -86,5 +89,5 @@
   stream->_tmpidx = inc;
   stream->_ungetc_count = 0;
-  if (_setmore (stream, 1) != 0)
+  if (_rmutex_create (&stream->__u.__rsem, 0) != 0)
     {
       if (abuf != NULL) free (abuf);
Index: /trunk/src/emx/src/lib/io/_newstre.c
===================================================================
--- /trunk/src/emx/src/lib/io/_newstre.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/_newstre.c	(revision 1370)
@@ -3,13 +3,13 @@
 
 #include "libc-alias.h"
-#include <stdio.h>
 #include <stdlib.h>
 #include <sys/builtin.h>        /* For <sys/fmutex.h> */
 #include <sys/fmutex.h>         /* For <sys/rmutex.h> */
 #include <sys/rmutex.h>
+#include <stdio.h>
+#include <emx/io.h>
 #include <emx/umalloc.h>
-#include <emx/io.h>
 
-#define INC     32
+#define INC     64
 #define ALIGN(p, a) (((unsigned long)(p) + (a) - 1) & ~((a) - 1))
 
@@ -18,19 +18,29 @@
     int                 i;
     struct streamvec   *pSV;
-    struct streamvec   *pSVNew;
 
     /*
      * Search thru the list of streams.
+     * Backwards as we're more likely to find free itmes at the end.
      */
     STREAMV_LOCK;
-    for (pSV = _streamvec_head; pSV != NULL; pSV = pSV->next)
+    for (pSV = _streamvec_tail; pSV != NULL; pSV = pSV->pPrev)
     {
-        for (i = 0; i < pSV->n; ++i)
+        if (pSV->cFree > 0)
         {
-            if (!(pSV->vec[i]._flags & (_IOOPEN|_IONEW)))
+            for (i = 0; i < pSV->cFiles; ++i)
             {
-                pSV->vec[i]._flags = _IONEW;
-                STREAMV_UNLOCK;
-                return &pSV->vec[i];
+                if (!(pSV->aFiles[i]._flags & (_IOOPEN|_IONEW)))
+                {
+                    pSV->aFiles[i]._flags = _IONEW;
+                    pSV->cFree--;
+                    STREAMV_UNLOCK;
+
+                    /*
+                     * We zero all members up till the __pSV member
+                     * before returning the handle to the caller.
+                     */
+                    memset(&pSV->aFiles[i], 0, offsetof(FILE, __pSV));
+                    return &pSV->aFiles[i];
+                }
             }
         }
@@ -42,12 +52,11 @@
      * (As the entries must not move, we add another segment.)
      */
-    pSVNew = _hcalloc(1, sizeof(*pSV) + 15
-                      + INC * sizeof(struct _FILE)
-                      + 15
-                      + INC * sizeof(struct _file2));
-    if (pSVNew)
+    pSV = _hcalloc(1, sizeof(*pSV) + 15
+                   + INC * sizeof(struct _FILE)
+                   + 15
+                   );
+    if (pSV)
     {
         struct _FILE       *pFile;
-        struct _file2      *pFile2;
 
         /*
@@ -55,18 +64,15 @@
          * Remember everything is ZEROed by calloc()!
          */
-        pSVNew->vec = pFile = (struct _FILE  *)ALIGN(pSVNew + 1, 16);
-        pFile2              = (struct _file2 *)ALIGN(&pFile[INC], 16);
-        pSVNew->vec         = pFile;
-        pSVNew->n           = INC;
-        for (i = 0; i < INC; i++, pFile++, pFile2++)
-        {
-            pFile2->owner = pFile; /* obsolete? */
-            pFile->_more = pFile2;
-        }
+        pSV->aFiles = pFile = (struct _FILE  *)ALIGN(pSV + 1, 16);
+        pSV->aFiles         = pFile;
+        pSV->cFiles         = INC;
+        pSV->cFree          = INC - 1;
+        for (i = 0; i < INC; i++, pFile++)
+            pFile->__pSV = pSV;
 
         /*
          * Allocate the first one.
          */
-        pFile = &pSVNew->vec[0];
+        pFile = &pSV->aFiles[0];
         pFile->_flags = _IONEW;
 
@@ -75,16 +81,11 @@
          */
         STREAMV_LOCK;
-        if (_streamvec_head)
-        {
-            for (pSV = _streamvec_head; pSV; pSV = pSV->next)
-                if (!pSV->next)
-                {
-                    pSV->next = pSVNew;
-                    break;
-                }
-        }
+        pSV->pPrev = _streamvec_tail;
+        /* pNext is NULLed by calloc(). */
+        if (_streamvec_tail)
+            _streamvec_tail = _streamvec_tail->pNext = pSV;
         else
             /* Someone fopen'ed something before streams were initated. */
-            _streamvec_head = pSVNew;
+            _streamvec_head = _streamvec_tail = pSV;
         STREAMV_UNLOCK;
         return pFile;
@@ -92,45 +93,4 @@
 
     return NULL;
-}
-
-/**
- * This used to set the _more member, but now it only create the mutex and
- * init _mbstate.
- *
- * @returns 0 on success.
- * @returns -1 on failure
- * @param   stream  Stream to init.
- * @param   lock    Ignored.
- */
-int _setmore(FILE *stream, int lock)
-{
-    /*
-     * Now this isn't so much work any longer, the streams are
-     * allocated with a more buffer by default now.
-     * All we gotta do is init _mbstate and create the mutex.
-     */
-    stream->_mbstate = 0;
-    if (_rmutex_create(&stream->_more->rsem, 0) != 0)
-    {
-        /* free the stream */
-        stream->_flags = 0;
-        lock = lock;
-        return -1;
-    }
-    return 0;
-}
-
-/**
- * This is used when creating a special stream for instance in vsprintf().
- *
- * @param   stream  Special stream.
- * @param   more    Dummy more block
- */
-void _setdummymore (FILE *stream, struct _file2 *more)
-{
-    stream->_mbstate = 0;
-    stream->_more = more;
-    more->owner = stream;
-    _rmutex_dummy(&more->rsem);
 }
 
@@ -143,7 +103,14 @@
 void _closestream(FILE *stream)
 {
-    if (    stream->_more != NULL
-        &&  stream->_more->owner == stream) /* paranoia */
-        _rmutex_close(&stream->_more->rsem);
     stream->_flags = 0;
+    /* Assumption hare made about how the dummy stuff is made. */
+    if (stream->__u.__rsem.fm.hev)
+        _rmutex_close(&stream->__u.__rsem);
+
+    if (stream->__pSV)
+    {
+        STREAMV_LOCK;
+        ((struct streamvec *)stream->__pSV)->cFree++;
+        STREAMV_UNLOCK;
+    }
 }
Index: /trunk/src/emx/src/lib/io/_rmtmp.c
===================================================================
--- /trunk/src/emx/src/lib/io/_rmtmp.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/_rmtmp.c	(revision 1370)
@@ -17,9 +17,9 @@
 
   n = 0;
-  for (sv = _streamvec_head; sv != NULL; sv = sv->next)
-    for (i = 0; i < sv->n; ++i)
-      if ((sv->vec[i]._flags & _IOOPEN) && (sv->vec[i]._flags & _IOTMP)
-          && STREAM_UNLOCKED (&sv->vec[i])
-          && fclose (&sv->vec[i]) == 0)
+  for (sv = _streamvec_head; sv != NULL; sv = sv->pNext)
+    for (i = 0; i < sv->cFiles; ++i)
+      if ((sv->aFiles[i]._flags & _IOOPEN) && (sv->aFiles[i]._flags & _IOTMP)
+          && STREAM_UNLOCKED (&sv->aFiles[i])
+          && fclose (&sv->aFiles[i]) == 0)
         ++n;
   return n;
Index: unk/src/emx/src/lib/io/fassign.c
===================================================================
--- /trunk/src/emx/src/lib/io/fassign.c	(revision 1369)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/* fassign.c (emx+gcc) -- Copyright (c) 1996 by Eberhard Mattes */
-
-#include "libc-alias.h"
-#include <stdio.h>
-#include <errno.h>
-#include <sys/builtin.h>        /* For <sys/fmutex.h> */
-#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
-#include <sys/rmutex.h>
-#include <emx/io.h>
-
-FILE *_fassign (FILE *target, FILE *source)
-{
-  /* Prevent other threads from reusing TARGET's slot while TARGET is
-     closed. */
-
-  STREAMV_LOCK;
-
-  if (!(source->_flags & _IOOPEN))
-    {
-      STREAMV_UNLOCK;
-      errno = EINVAL;
-      return NULL;
-    }
-
-  /* Do nothing if TARGET and SOURCE are the same stream. */
-
-  if (source == target)
-    {
-      STREAMV_UNLOCK;
-      return target;
-    }
-
-  /* Close TARGET, ignoring errors. */
-
-  fclose (target);
-
-  /* Assign the stream. */
-
-  *target = *source;
-  if (target->_more != NULL)
-    target->_more->owner = target;
-  source->_flags = 0;
-  STREAMV_UNLOCK;
-  return target;
-}
Index: /trunk/src/emx/src/lib/io/fcloseal.c
===================================================================
--- /trunk/src/emx/src/lib/io/fcloseal.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/fcloseal.c	(revision 1370)
@@ -12,12 +12,10 @@
 
   n = 0; ok = 1;
-  for (sv = _streamvec_head; sv != NULL; sv = sv->next)
+  for (sv = _streamvec_head; sv != NULL; sv = sv->pNext)
     {
-      for (i = sv->vec == stdin ? 3 : 0; /* Keep stdin, stdout, stderr */
-           i < sv->n;
-           ++i)
-        if (sv->vec[i]._flags & _IOOPEN)
+      for (i = 0; i < sv->cFiles; ++i)
+        if ((sv->aFiles[i]._flags & (_IOOPEN | _IONOCLOSEALL)) == _IOOPEN)
           {
-            if (fclose (&sv->vec[i]) == 0)
+            if (fclose (&sv->aFiles[i]) == 0)
               ++n;
             else
Index: /trunk/src/emx/src/lib/io/fdopen.c
===================================================================
--- /trunk/src/emx/src/lib/io/fdopen.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/fdopen.c	(revision 1370)
@@ -2,8 +2,12 @@
 
 #include "libc-alias.h"
-#include <stdio.h>
 #include <io.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
+#include <stdio.h>
 #include <emx/io.h>
 
@@ -25,4 +29,11 @@
     }
   dst = _newstream ();
+  if (!dst)
+    return NULL;
+  if (_rmutex_create (&dst->__u.__rsem, 0) != 0)
+    {
+      _closestream (dst);
+      return NULL;
+    }
   switch (*mode)
     {
@@ -80,14 +91,6 @@
     setmode (handle, omode);
   dst->_handle = handle;
-  dst->_ptr = NULL;
-  dst->_buffer = NULL;
-  dst->_buf_size = 0;
-  dst->_rcount = 0;
-  dst->_wcount = 0;
   dst->_flags |= _IOOPEN | _IOBUFNONE;
   dst->_flush = _flushstream;
-  dst->_ungetc_count = 0;
-  if (_setmore (dst, 1) != 0)
-    return NULL;
   return dst;
 }
Index: /trunk/src/emx/src/lib/io/fflush.c
===================================================================
--- /trunk/src/emx/src/lib/io/fflush.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/fflush.c	(revision 1370)
@@ -73,8 +73,8 @@
   if (stream == NULL)
     {
-      for (sv = _streamvec_head; sv != NULL; sv = sv->next)
-        for (n = 0; n < sv->n; ++n)
-          if ((sv->vec[n]._flags & (_IOOPEN|_IOWRT)) == (_IOOPEN|_IOWRT))
-            if (fflush (&sv->vec[n]) != 0)
+      for (sv = _streamvec_head; sv != NULL; sv = sv->pNext)
+        for (n = 0; n < sv->cFiles; ++n)
+          if ((sv->aFiles[n]._flags & (_IOOPEN|_IOWRT)) == (_IOOPEN|_IOWRT))
+            if (fflush (&sv->aFiles[n]) != 0)
               result = EOF;
       return result;
Index: /trunk/src/emx/src/lib/io/flushall.c
===================================================================
--- /trunk/src/emx/src/lib/io/flushall.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/flushall.c	(revision 1370)
@@ -18,11 +18,11 @@
 
   n = 0;
-  for (sv = _streamvec_head; sv != NULL; sv = sv->next)
-    for (i = 0; i < sv->n; ++i)
-      if ((sv->vec[i]._flags & _IOOPEN) && STREAM_LOCK_NOWAIT (&sv->vec[i]))
+  for (sv = _streamvec_head; sv != NULL; sv = sv->pNext)
+    for (i = 0; i < sv->cFiles; ++i)
+      if ((sv->aFiles[i]._flags & _IOOPEN) && STREAM_LOCK_NOWAIT (&sv->aFiles[i]))
         {
           ++n;
-          _fflush_nolock (&sv->vec[i]);
-          STREAM_UNLOCK (&sv->vec[i]);
+          _fflush_nolock (&sv->aFiles[i]);
+          STREAM_UNLOCK (&sv->aFiles[i]);
         }
   return n;
Index: /trunk/src/emx/src/lib/io/snprintf.c
===================================================================
--- /trunk/src/emx/src/lib/io/snprintf.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/snprintf.c	(revision 1370)
@@ -2,4 +2,8 @@
 
 #include "libc-alias.h"
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -11,5 +15,4 @@
   va_list arg_ptr;
   FILE trick;
-  struct _file2 trick2;
   int result;
 
@@ -26,5 +29,6 @@
   trick._flush = NULL;
   trick._ungetc_count = 0;
-  _setdummymore (&trick, &trick2);
+  trick._mbstate = 0;
+  _rmutex_dummy(&trick.__u.__rsem);
   result = _output (&trick, format, arg_ptr);
   if (n != 0)
Index: /trunk/src/emx/src/lib/io/sprintf.c
===================================================================
--- /trunk/src/emx/src/lib/io/sprintf.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/sprintf.c	(revision 1370)
@@ -2,4 +2,8 @@
 
 #include "libc-alias.h"
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -11,5 +15,4 @@
   va_list arg_ptr;
   FILE trick;
-  struct _file2 trick2;
   int result;
 
@@ -24,5 +27,6 @@
   trick._flush = NULL;
   trick._ungetc_count = 0;
-  _setdummymore (&trick, &trick2);
+  trick._mbstate = 0;
+  _rmutex_dummy(&trick.__u.__rsem);
   result = _output (&trick, format, arg_ptr);
   putc (0, &trick);
Index: /trunk/src/emx/src/lib/io/sscanf.c
===================================================================
--- /trunk/src/emx/src/lib/io/sscanf.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/sscanf.c	(revision 1370)
@@ -2,4 +2,8 @@
 
 #include "libc-alias.h"
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -12,5 +16,4 @@
   va_list arg_ptr;
   FILE trick;
-  struct _file2 trick2;
   int result;
 
@@ -25,5 +28,6 @@
   trick._flush = NULL;
   trick._ungetc_count = 0;
-  _setdummymore (&trick, &trick2);
+  trick._mbstate = 0;
+  _rmutex_dummy(&trick.__u.__rsem);
   result = _input (&trick, format, arg_ptr);
   va_end (arg_ptr);
Index: /trunk/src/emx/src/lib/io/vsnprint.c
===================================================================
--- /trunk/src/emx/src/lib/io/vsnprint.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/vsnprint.c	(revision 1370)
@@ -2,4 +2,8 @@
 
 #include "libc-alias.h"
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <stdio.h>
 #include <limits.h>
@@ -9,5 +13,4 @@
 {
   FILE trick;
-  struct _file2 trick2;
   int result;
 
@@ -23,5 +26,6 @@
   trick._flush = NULL;
   trick._ungetc_count = 0;
-  _setdummymore (&trick, &trick2);
+  trick._mbstate = 0;
+  _rmutex_dummy(&trick.__u.__rsem);
   result = _output (&trick, format, arg_ptr);
   if (n != 0)
Index: /trunk/src/emx/src/lib/io/vsprintf.c
===================================================================
--- /trunk/src/emx/src/lib/io/vsprintf.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/vsprintf.c	(revision 1370)
@@ -2,4 +2,8 @@
 
 #include "libc-alias.h"
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <stdio.h>
 #include <limits.h>
@@ -9,5 +13,4 @@
 {
   FILE trick;
-  struct _file2 trick2;
   int result;
 
@@ -21,5 +24,6 @@
   trick._flush = NULL;
   trick._ungetc_count = 0;
-  _setdummymore (&trick, &trick2);
+  trick._mbstate = 0;
+  _rmutex_dummy(&trick.__u.__rsem);
   result = _output (&trick, format, arg_ptr);
   putc (0, &trick);
Index: /trunk/src/emx/src/lib/io/vsscanf.c
===================================================================
--- /trunk/src/emx/src/lib/io/vsscanf.c	(revision 1369)
+++ /trunk/src/emx/src/lib/io/vsscanf.c	(revision 1370)
@@ -2,4 +2,8 @@
 
 #include "libc-alias.h"
+#include <sys/builtin.h>        /* For <sys/fmutex.h> */
+#include <sys/fmutex.h>         /* For <sys/rmutex.h> */
+#include <sys/rmutex.h>
+#include <stdio.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -11,5 +15,4 @@
 {
   FILE trick;
-  struct _file2 trick2;
   int result;
 
@@ -23,5 +26,6 @@
   trick._flush = NULL;
   trick._ungetc_count = 0;
-  _setdummymore (&trick, &trick2);
+  trick._mbstate = 0;
+  _rmutex_dummy(&trick.__u.__rsem);
   result = _input (&trick, format, arg_ptr);
   return result;
