2000-03-27 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
[deliverable/binutils-gdb.git] / readline / input.c
index 7e3c0feb5ce8b0a7f6a4d053794e058d3cdd661a..a8ba23c3c43717fb0ddf1933a93b3ef0487b7986 100644 (file)
@@ -96,7 +96,7 @@ extern Keymap _rl_keymap;
 
 extern int _rl_convert_meta_chars_to_ascii;
 
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (HAVE_SELECT)
 #  include <pc.h>
 #endif /* __GO32__ */
 
@@ -124,38 +124,13 @@ _rl_any_typein ()
   return any_typein;
 }
 
-/* Add KEY to the buffer of characters to be read. */
-int
-rl_stuff_char (key)
-     int key;
-{
-  if (key == EOF)
-    {
-      key = NEWLINE;
-      rl_pending_input = EOF;
-    }
-  ibuffer[push_index++] = key;
-  if (push_index >= ibuffer_len)
-    push_index = 0;
-  return push_index;
-}
-
-/* Make C be the next command to be executed. */
-int
-rl_execute_next (c)
-     int c;
-{
-  rl_pending_input = c;
-  return 0;
-}
-
-/* Return the amount of space available in the
-   buffer for stuffing characters. */
+/* Return the amount of space available in the buffer for stuffing
+   characters. */
 static int
 ibuffer_space ()
 {
   if (pop_index > push_index)
-    return (pop_index - push_index);
+    return (pop_index - push_index - 1);
   else
     return (ibuffer_len - (push_index - pop_index));
 }
@@ -201,7 +176,7 @@ rl_unget_char (key)
 static void
 rl_gather_tyi ()
 {
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (HAVE_SELECT)
   char input;
 
   if (isatty (0) && kbhit () && ibuffer_space ())
@@ -341,6 +316,36 @@ _rl_insert_typein (c)
   free (string);
 }
 
+/* Add KEY to the buffer of characters to be read.  Returns 1 if the
+   character was stuffed correctly; 0 otherwise. */
+int
+rl_stuff_char (key)
+     int key;
+{
+  if (ibuffer_space () == 0)
+    return 0;
+
+  if (key == EOF)
+    {
+      key = NEWLINE;
+      rl_pending_input = EOF;
+    }
+  ibuffer[push_index++] = key;
+  if (push_index >= ibuffer_len)
+    push_index = 0;
+
+  return 1;
+}
+
+/* Make C be the next command to be executed. */
+int
+rl_execute_next (c)
+     int c;
+{
+  rl_pending_input = c;
+  return 0;
+}
+
 /* **************************************************************** */
 /*                                                                 */
 /*                          Character Input                        */
@@ -392,7 +397,7 @@ rl_getc (stream)
   int result, flags;
   unsigned char c;
 
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (HAVE_TERMIOS_H)
   if (isatty (0))
     return (getkey () & 0x7F);
 #endif /* __GO32__ */
@@ -409,6 +414,11 @@ rl_getc (stream)
       if (result == 0)
        return (EOF);
 
+#if defined (__BEOS__)
+      if (errno == EINTR)
+       continue;
+#endif
+
 #if defined (EWOULDBLOCK)
       if (errno == EWOULDBLOCK)
        {
@@ -438,7 +448,7 @@ rl_getc (stream)
        }
 #endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
 
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
       /* If the error that we received was SIGINT, then try again,
         this is simply an interrupted system call to read ().
         Otherwise, some error ocurred, also signifying EOF. */
This page took 0.023993 seconds and 4 git commands to generate.