aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-11-10 06:40:06 +0000
committerRichard M. Stallman1995-11-10 06:40:06 +0000
commit1513af9e91d145bbd1cf46db2e7afdfe3359bebb (patch)
tree424fe48cdda6d5b9ac952e75f5b00ac6815c50eb /src
parented8740116938029a00b222399fdf6d4279e993cf (diff)
downloademacs-1513af9e91d145bbd1cf46db2e7afdfe3359bebb.tar.gz
emacs-1513af9e91d145bbd1cf46db2e7afdfe3359bebb.zip
Include lisp.h.
(doprnt1): Renamed from doprnt. New arg LISPSTRINGS. This is now a static subroutine. (doprnt): New definition calls doprnt1. (doprnt_lisp): New function.
Diffstat (limited to 'src')
-rw-r--r--src/doprnt.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/doprnt.c b/src/doprnt.c
index 5639a7eff3a..ab3627768ba 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -23,16 +23,21 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23#include <config.h> 23#include <config.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <ctype.h> 25#include <ctype.h>
26#include "lisp.h"
26 27
27extern long *xmalloc (), *xrealloc (); 28extern long *xmalloc (), *xrealloc ();
28 29
30static int doprnt1 ();
31
29/* Generate output from a format-spec FORMAT, 32/* Generate output from a format-spec FORMAT,
30 terminated at position FORMAT_END. 33 terminated at position FORMAT_END.
31 Output goes in BUFFER, which has room for BUFSIZE chars. 34 Output goes in BUFFER, which has room for BUFSIZE chars.
32 If the output does not fit, truncate it to fit. 35 If the output does not fit, truncate it to fit.
33 Returns the number of characters stored into BUFFER. 36 Returns the number of characters stored into BUFFER.
34 ARGS points to the vector of arguments, and NARGS says how many. 37 ARGS points to the vector of arguments, and NARGS says how many.
35 A double counts as two arguments. */ 38 A double counts as two arguments.
39 String arguments are passed as C strings.
40 Integers are passed as C integers. */
36 41
37doprnt (buffer, bufsize, format, format_end, nargs, args) 42doprnt (buffer, bufsize, format, format_end, nargs, args)
38 char *buffer; 43 char *buffer;
@@ -42,6 +47,33 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
42 int nargs; 47 int nargs;
43 char **args; 48 char **args;
44{ 49{
50 return doprnt1 (0, buffer, bufsize, format, format_end, nargs, args);
51}
52
53/* Like doprnt except that strings in ARGS are passed
54 as Lisp_Object. */
55
56doprnt_lisp (buffer, bufsize, format, format_end, nargs, args)
57 char *buffer;
58 register int bufsize;
59 char *format;
60 char *format_end;
61 int nargs;
62 char **args;
63{
64 return doprnt1 (1, buffer, bufsize, format, format_end, nargs, args);
65}
66
67static int
68doprnt1 (lispstrings, buffer, bufsize, format, format_end, nargs, args)
69 int lispstrings;
70 char *buffer;
71 register int bufsize;
72 char *format;
73 char *format_end;
74 int nargs;
75 char **args;
76{
45 int cnt = 0; /* Number of arg to gobble next */ 77 int cnt = 0; /* Number of arg to gobble next */
46 register char *fmt = format; /* Pointer into format string */ 78 register char *fmt = format; /* Pointer into format string */
47 register char *bufptr = buffer; /* Pointer into output buffer.. */ 79 register char *bufptr = buffer; /* Pointer into output buffer.. */
@@ -164,9 +196,21 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
164 case 's': 196 case 's':
165 if (cnt == nargs) 197 if (cnt == nargs)
166 error ("not enough arguments for format string"); 198 error ("not enough arguments for format string");
167 string = args[cnt++];
168 if (fmtcpy[1] != 's') 199 if (fmtcpy[1] != 's')
169 minlen = atoi (&fmtcpy[1]); 200 minlen = atoi (&fmtcpy[1]);
201 if (lispstrings)
202 {
203 string = XSTRING (((Lisp_Object *) args)[cnt])->data;
204 tem = XSTRING (((Lisp_Object *) args)[cnt])->size;
205 cnt++;
206 }
207 else
208 {
209 string = args[cnt++];
210 tem = strlen (string);
211 }
212 goto doit1;
213
170 /* Copy string into final output, truncating if no room. */ 214 /* Copy string into final output, truncating if no room. */
171 doit: 215 doit:
172 tem = strlen (string); 216 tem = strlen (string);
@@ -183,7 +227,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
183 } 227 }
184 if (tem > bufsize) 228 if (tem > bufsize)
185 tem = bufsize; 229 tem = bufsize;
186 strncpy (bufptr, string, tem); 230 bcopy (string, bufptr, tem);
187 bufptr += tem; 231 bufptr += tem;
188 bufsize -= tem; 232 bufsize -= tem;
189 if (minlen < 0) 233 if (minlen < 0)