/* 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
#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>
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
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;
args[1] = hpos;
return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
}
+#endif
static char *
tparam1 (string, outstring, len, up, left, argp)
int outlen = 0;
register int tem;
- int *old_argp = argp;
+ int *old_argp = argp; /* can move */
+ int *fixed_argp = argp; /* never moves */
+ int explicit_param_p = 0; /* set by %p */
int doleft = 0;
int doup = 0;
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++;
if (c == '%')
{
c = *p++;
- tem = *argp;
+ if (explicit_param_p)
+ explicit_param_p = 0;
+ else
+ tem = *argp;
switch (c)
{
case 'd': /* %d means output in decimal. */
*op++ = tem % 10 + '0';
argp++;
break;
-
+ case 'p': /* %pN means use param N for next subst. */
+ tem = fixed_argp[(*p++) - '1'];
+ explicit_param_p = 1;
+ break;
case 'C':
/* For c-100: print quotient of value by 96, if nonzero,
then do like %+. */
case 'D': /* %D means weird Delta Data transformation. */
argp[0] -= 2 * (tem % 16);
break;
+
+ default:
+ abort ();
}
}
else
}
#endif /* DEBUG */
+
+/* arch-tag: 83f7b5ac-a808-4f75-b87a-123de009b402
+ (do not change this comment) */