aboutsummaryrefslogtreecommitdiffstats
path: root/src/tparam.c
diff options
context:
space:
mode:
authorStefan Monnier2010-07-23 17:23:09 +0200
committerStefan Monnier2010-07-23 17:23:09 +0200
commit0ee81a0ce066375eac701c06cdfbdebefe594fdc (patch)
treef0dccd24163316cfe688f927681a3032a9b1fe2f /src/tparam.c
parent894e369ddf48e191638b8e66ce732f24ff9abe2a (diff)
parent94da839793affa2a270bc26cee9c4d95d4dc4708 (diff)
downloademacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.tar.gz
emacs-0ee81a0ce066375eac701c06cdfbdebefe594fdc.zip
Merge from trunk
Diffstat (limited to 'src/tparam.c')
-rw-r--r--src/tparam.c73
1 files changed, 5 insertions, 68 deletions
diff --git a/src/tparam.c b/src/tparam.c
index dcf79a3b617..d8a8f0260f0 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -18,66 +18,14 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18Boston, MA 02110-1301, USA. */ 18Boston, MA 02110-1301, USA. */
19 19
20/* Emacs config.h may rename various library functions such as malloc. */ 20/* Emacs config.h may rename various library functions such as malloc. */
21#ifdef HAVE_CONFIG_H
22#include <config.h> 21#include <config.h>
23#endif
24
25#ifdef emacs
26#include <setjmp.h> 22#include <setjmp.h>
27#include "lisp.h" /* for xmalloc */ 23#include "lisp.h" /* for xmalloc */
28#else
29
30#ifdef STDC_HEADERS
31#include <stdlib.h>
32#include <string.h>
33#else
34char *malloc ();
35char *realloc ();
36#endif
37
38/* Do this after the include, in case string.h prototypes bcopy. */
39#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
40#define bcopy(s, d, n) memcpy ((d), (s), (n))
41#endif
42
43#endif /* not emacs */
44 24
45#ifndef NULL 25#ifndef NULL
46#define NULL (char *) 0 26#define NULL (char *) 0
47#endif 27#endif
48 28
49#ifndef emacs
50static void
51memory_out ()
52{
53 write (2, "virtual memory exhausted\n", 25);
54 exit (1);
55}
56
57static char *
58xmalloc (size)
59 unsigned size;
60{
61 register char *tem = malloc (size);
62
63 if (!tem)
64 memory_out ();
65 return tem;
66}
67
68static char *
69xrealloc (ptr, size)
70 char *ptr;
71 unsigned size;
72{
73 register char *tem = realloc (ptr, size);
74
75 if (!tem)
76 memory_out ();
77 return tem;
78}
79#endif /* not emacs */
80
81/* Assuming STRING is the value of a termcap string entry 29/* Assuming STRING is the value of a termcap string entry
82 containing `%' constructs to expand parameters, 30 containing `%' constructs to expand parameters,
83 merge in parameter values and store result in block OUTSTRING points to. 31 merge in parameter values and store result in block OUTSTRING points to.
@@ -90,15 +38,11 @@ xrealloc (ptr, size)
90 38
91 The fourth and following args to tparam serve as the parameter values. */ 39 The fourth and following args to tparam serve as the parameter values. */
92 40
93static char *tparam1 (); 41static char *tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp);
94 42
95/* VARARGS 2 */ 43/* VARARGS 2 */
96char * 44char *
97tparam (string, outstring, len, arg0, arg1, arg2, arg3) 45tparam (char *string, char *outstring, int len, int arg0, int arg1, int arg2, int arg3)
98 char *string;
99 char *outstring;
100 int len;
101 int arg0, arg1, arg2, arg3;
102{ 46{
103 int arg[4]; 47 int arg[4];
104 48
@@ -115,9 +59,7 @@ char *UP;
115static char tgoto_buf[50]; 59static char tgoto_buf[50];
116 60
117char * 61char *
118tgoto (cm, hpos, vpos) 62tgoto (char *cm, int hpos, int vpos)
119 char *cm;
120 int hpos, vpos;
121{ 63{
122 int args[2]; 64 int args[2];
123 if (!cm) 65 if (!cm)
@@ -128,12 +70,7 @@ tgoto (cm, hpos, vpos)
128} 70}
129 71
130static char * 72static char *
131tparam1 (string, outstring, len, up, left, argp) 73tparam1 (char *string, char *outstring, int len, char *up, char *left, register int *argp)
132 char *string;
133 char *outstring;
134 int len;
135 char *up, *left;
136 register int *argp;
137{ 74{
138 register int c; 75 register int c;
139 register char *p = string; 76 register char *p = string;
@@ -162,7 +99,7 @@ tparam1 (string, outstring, len, up, left, argp)
162 { 99 {
163 outlen = len + 40; 100 outlen = len + 40;
164 new = (char *) xmalloc (outlen); 101 new = (char *) xmalloc (outlen);
165 bcopy (outstring, new, offset); 102 memcpy (new, outstring, offset);
166 } 103 }
167 else 104 else
168 { 105 {