(Fset_char_table_parent): Doc fix.
[bpt/emacs.git] / src / tparam.c
index a5ee362..7306e0d 100644 (file)
@@ -1,5 +1,5 @@
 /* Merge parameters into a termcap entry string.
-   Copyright (C) 1985, 87, 93, 95 Free Software Foundation, Inc.
+   Copyright (C) 1985, 87, 93, 95, 2000 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
@@ -13,17 +13,17 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 /* Emacs config.h may rename various library functions such as malloc.  */
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#ifndef emacs
-#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
+#ifdef emacs
+#include "lisp.h"              /* for xmalloc */
+#else
 
 #ifdef STDC_HEADERS
 #include <stdlib.h>
@@ -33,6 +33,11 @@ char *malloc ();
 char *realloc ();
 #endif
 
+/* Do this after the include, in case string.h prototypes bcopy.  */
+#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
+#define bcopy(s, d, n) memcpy ((d), (s), (n))
+#endif
+
 #endif /* not emacs */
 
 #ifndef NULL
@@ -102,6 +107,9 @@ tparam (string, outstring, len, arg0, arg1, arg2, arg3)
   return tparam1 (string, outstring, len, NULL, NULL, arg);
 }
 
+/* These are already defined in the System framework in Mac OS X and
+   cause prebinding to fail.  */
+#ifndef MAC_OSX
 char *BC;
 char *UP;
 
@@ -119,6 +127,7 @@ tgoto (cm, hpos, vpos)
   args[1] = hpos;
   return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
 }
+#endif
 
 static char *
 tparam1 (string, outstring, len, up, left, argp)
@@ -147,21 +156,22 @@ tparam1 (string, outstring, len, up, left, argp)
       if (op + 5 >= outend)
        {
          register char *new;
+         int offset = op - outstring;
+
          if (outlen == 0)
            {
              outlen = len + 40;
              new = (char *) xmalloc (outlen);
-             outend += 40;
-             bcopy (outstring, new, op - outstring);
+             bcopy (outstring, new, offset);
            }
          else
            {
-             outend += outlen;
              outlen *= 2;
              new = (char *) xrealloc (outstring, outlen);
            }
-         op += new - outstring;
-         outend += new - outstring;
+
+         op = new + offset;
+         outend = new + outlen;
          outstring = new;
        }
       c = *p++;
@@ -289,6 +299,9 @@ tparam1 (string, outstring, len, up, left, argp)
            case 'D':           /* %D means weird Delta Data transformation.  */
              argp[0] -= 2 * (tem % 16);
              break;
+
+           default:
+             abort ();
            }
        }
       else
@@ -321,3 +334,6 @@ main (argc, argv)
 }
 
 #endif /* DEBUG */
+
+/* arch-tag: 83f7b5ac-a808-4f75-b87a-123de009b402
+   (do not change this comment) */