(Fset_char_table_parent): Doc fix.
[bpt/emacs.git] / src / termcap.c
index 472005f..b1e0a87 100644 (file)
@@ -1,5 +1,6 @@
 /* Work-alike for termcap, plus extra features.
-   Copyright (C) 1985, 86, 93, 94, 95 Free Software Foundation, Inc.
+   Copyright (C) 1985, 86, 93, 94, 95, 2000, 2001
+   Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -52,7 +53,7 @@ char *realloc ();
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifdef _POSIX_VERSION
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 
@@ -143,6 +144,9 @@ find_capability (bp, cap)
   return NULL;
 }
 
+/* These are already defined in the System framework in Mac OS X and
+   cause prebinding to fail.  */
+#ifndef MAC_OSX
 int
 tgetnum (cap)
      char *cap;
@@ -176,6 +180,7 @@ tgetstr (cap, area)
     return NULL;
   return tgetst1 (ptr, area);
 }
+#endif /* MAC_OSX */
 
 #ifdef IS_EBCDIC_HOST
 /* Table, indexed by a character in range 0200 to 0300 with 0200 subtracted,
@@ -288,11 +293,19 @@ tgetst1 (ptr, area)
 \f
 /* Outputting a string with padding.  */
 
+#ifndef emacs
 short ospeed;
 /* If OSPEED is 0, we use this as the actual baud rate.  */
 int tputs_baud_rate;
+#endif
+
+/* Already defined in the System framework in Mac OS X and causes
+   prebinding to fail.  */
+#ifndef MAC_OSX
 char PC;
+#endif  /* MAC_OSX */
 
+#ifndef emacs
 /* Actual baud rate if positive;
    - baud rate / 100 if negative.  */
 
@@ -307,6 +320,11 @@ static int speeds[] =
 #endif /* not VMS */
   };
 
+#endif /* not emacs */
+
+/* Already defined in the System framework in Mac OS X and causes
+   prebinding to fail.  */
+#ifndef MAC_OSX
 void
 tputs (str, nlines, outfun)
      register char *str;
@@ -317,7 +335,7 @@ tputs (str, nlines, outfun)
   register int speed;
 
 #ifdef emacs
-  extern int baud_rate;
+  extern EMACS_INT baud_rate;
   speed = baud_rate;
   /* For quite high speeds, convert to the smaller
      units to avoid overflow.  */
@@ -326,10 +344,8 @@ tputs (str, nlines, outfun)
 #else
   if (ospeed == 0)
     speed = tputs_baud_rate;
-  else if (ospeed > 0 && ospeed < (sizeof speeds / sizeof speeds[0]))
-    speed = speeds[ospeed];
   else
-    speed = 0;
+    speed = speeds[ospeed];
 #endif
 
   if (!str)
@@ -371,6 +387,7 @@ tputs (str, nlines, outfun)
   while (padcount-- > 0)
     (*outfun) (PC);
 }
+#endif /* MAC_OSX */
 \f
 /* Finding the termcap entry in the termcap data base.  */
 
@@ -441,6 +458,9 @@ valid_filename_p (fn)
    0 if the data base is accessible but the type NAME is not defined
    in it, and some other value otherwise.  */
 
+/* Already defined in the System framework in Mac OS X and causes
+   prebinding to fail.  */
+#ifndef MAC_OSX
 int
 tgetent (bp, name)
      char *bp, *name;
@@ -453,7 +473,7 @@ tgetent (bp, name)
   char *term;
   int malloc_size = 0;
   register int c;
-  char *tcenv;                 /* TERMCAP value, if it contains :tc=.  */
+  char *tcenv = NULL;          /* TERMCAP value, if it contains :tc=.  */
   char *indirect = NULL;       /* Terminal type in :tc= in TERMCAP value.  */
   int filep;
 
@@ -565,11 +585,11 @@ tgetent (bp, name)
       /* If BP is malloc'd by us, make sure it is big enough.  */
       if (malloc_size)
        {
-         malloc_size = bp1 - bp + buf.size;
-         termcap_name = (char *) xrealloc (bp, malloc_size);
-         bp1 += termcap_name - bp;
-         tc_search_point += termcap_name - bp;
-         bp = termcap_name;
+         int offset1 = bp1 - bp, offset2 = tc_search_point - bp;
+         malloc_size = offset1 + buf.size;
+         bp = termcap_name = (char *) xrealloc (bp, malloc_size);
+         bp1 = termcap_name + offset1;
+         tc_search_point = termcap_name + offset2;
        }
 
       /* Copy the line of the entry from buf into bp.  */
@@ -599,6 +619,7 @@ tgetent (bp, name)
   term_entry = bp;
   return 1;
 }
+#endif /* MAC_OSX */
 
 /* Given file open on FD and buffer BUFP,
    scan the file from the beginning until a line is found
@@ -807,3 +828,6 @@ tprint (cap)
 }
 
 #endif /* TEST */
+
+/* arch-tag: c2e8d427-2271-4fac-95fe-411857238b80
+   (do not change this comment) */