Index: trunk/src/emx/ChangeLog.LIBC
===================================================================
--- trunk/src/emx/ChangeLog.LIBC	(revision 2118)
+++ trunk/src/emx/ChangeLog.LIBC	(revision 2119)
@@ -8,4 +8,5 @@
         o Added ieeefp.h and functions from FreeBSD - this is
           the SysV/386 FP control interface. (inline only)
+        o Added fgets_unlocked and gets_unlocked.
 
 2005-06-28: knut st. osmundsen <bird-gccos2-spam@anduin.net>
Index: trunk/src/emx/include/stdio.h
===================================================================
--- trunk/src/emx/include/stdio.h	(revision 2118)
+++ trunk/src/emx/include/stdio.h	(revision 2119)
@@ -374,5 +374,7 @@
 int     fputc_unlocked(int, FILE *);
 int     fputs_unlocked(const char * __restrict, FILE * __restrict);
+char	*fgets_unlocked(char * __restrict, int, FILE * __restrict);
 int     puts_unlocked(const char *);
+char	*gets_unlocked(char *);
 #endif
 
Index: trunk/src/emx/src/lib/io/fgets.c
===================================================================
--- trunk/src/emx/src/lib/io/fgets.c	(revision 2118)
+++ trunk/src/emx/src/lib/io/fgets.c	(revision 2119)
@@ -9,41 +9,45 @@
 #include "getputc.h"
 
-char *_STD(fgets) (char *buffer, int n, FILE *stream)
+char *_STD(fgets)(char *buffer, int n, FILE *stream)
 {
-  int c;
-  char *dst;
+    STREAM_LOCK(stream);
+    char *psz = fgets_unlocked(buffer, n, stream);
+    STREAM_UNLOCK(stream);
+    return psz;
+}
 
-  if (n <= 0)
-    return NULL;
-  dst = buffer;
 
-  STREAM_LOCK (stream);
-  while (n > 1)
+char *_STD(fgets_unlocked)(char *buffer, int n, FILE *stream)
+{
+    int c;
+    char *dst;
+
+    if (n <= 0)
+        return NULL;
+    dst = buffer;
+
+    while (n > 1)
     {
-      c = _getc_inline (stream);
-      if (c == EOF)
+        c = _getc_inline(stream);
+        if (c == EOF)
         {
-          /* ISO/IEC 9899:1990, 7.9.7.2: "If end-of-file is
-             encountered and no characters have been read into the
-             array, the contents of the array remain unchanged and a
-             null pointer is returned.  If a read error occurs during
-             the operation, the array contents are indeterminate and a
-             null pointer is returned." */
+            /* ISO/IEC 9899:1990, 7.9.7.2: "If end-of-file is
+               encountered and no characters have been read into the
+               array, the contents of the array remain unchanged and a
+               null pointer is returned.  If a read error occurs during
+               the operation, the array contents are indeterminate and a
+               null pointer is returned." */
 
-          if (dst == buffer || ferror (stream))
-            {
-              STREAM_UNLOCK (stream);
-              return NULL;
-            }
-          else
+            if (dst == buffer || ferror(stream))
+                return NULL;
             break;              /* EOF after reading at least one char */
         }
-      *dst++ = (char)c;
-      if (c == '\n')
-        break;
-      --n;
+        *dst++ = (char)c;
+        if (c == '\n')
+            break;
+        --n;
     }
-  STREAM_UNLOCK (stream);
-  *dst = 0;
-  return buffer;
+    *dst = '\0';
+    return buffer;
 }
+
Index: trunk/src/emx/src/lib/io/gets.c
===================================================================
--- trunk/src/emx/src/lib/io/gets.c	(revision 2118)
+++ trunk/src/emx/src/lib/io/gets.c	(revision 2119)
@@ -9,31 +9,38 @@
 #include "getputc.h"
 
-char *_STD(gets) (char *buffer)
+char *_STD(gets_unlocked)(char *buffer)
 {
-  int c;
-  char *dst;
+    int c;
+    char *dst;
 
-  dst = buffer;
-  STREAM_LOCK (stdin);
-  for (;;)
+    dst = buffer;
+    for (;;)
     {
-      c = _getc_inline (stdin);
-      if (c == EOF)
+        c = _getc_inline(stdin);
+        if (c == EOF)
         {
-          if (dst == buffer)
+            if (dst == buffer)
             {
-              *dst = 0;
-              STREAM_UNLOCK (stdin);
-              return NULL;
+                *dst = '\0';
+                return NULL;
             }
-          else
             break;
         }
-      if (c == '\n')
-        break;
-      *dst++ = (char)c;
+        if (c == '\n')
+            break;
+        *dst++ = (char)c;
     }
-  STREAM_UNLOCK (stdin);
-  *dst = 0;
-  return buffer;
+    *dst = 0;
+    return buffer;
 }
+
+char *_STD(gets)(char *buffer)
+{
+    STREAM_LOCK(stdin);
+    char *psz = gets_unlocked(buffer);
+    STREAM_UNLOCK(stdin);
+    return psz;
+}
+
+
+
Index: trunk/src/emx/src/lib/libc.def
===================================================================
--- trunk/src/emx/src/lib/libc.def	(revision 2118)
+++ trunk/src/emx/src/lib/libc.def	(revision 2119)
@@ -1744,2 +1744,4 @@
     "__std_rawmemchr" @1745
     "__std_strchrnul" @1746
+    "__std_fgets_unlocked" @1747
+    "__std_gets_unlocked" @1748
