Mercurial > emacs
annotate src/doprnt.c @ 13889:1c65a1e5f099
(command-line-x-option-alist): New variable.
(command-line-1): Ignore X options when not using X.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 29 Dec 1995 20:00:39 +0000 |
parents | 626f0886b434 |
children | ee40177f6c68 |
rev | line source |
---|---|
49 | 1 /* Output like sprintf to a buffer of specified size. |
2 Also takes args differently: pass one pointer to an array of strings | |
3 in addition to the format string which is separate. | |
4 Copyright (C) 1985 Free Software Foundation, Inc. | |
5 | |
6 This file is part of GNU Emacs. | |
7 | |
8 GNU Emacs is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
12244 | 10 the Free Software Foundation; either version 2, or (at your option) |
49 | 11 any later version. |
12 | |
13 GNU Emacs is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with GNU Emacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
21 | |
22 | |
5036 | 23 #include <config.h> |
49 | 24 #include <stdio.h> |
25 #include <ctype.h> | |
13449 | 26 #include "lisp.h" |
49 | 27 |
11320
aaf81f284f83
(xmalloc, xrealloc): Declare them here.
Richard M. Stallman <rms@gnu.org>
parents:
8141
diff
changeset
|
28 extern long *xmalloc (), *xrealloc (); |
aaf81f284f83
(xmalloc, xrealloc): Declare them here.
Richard M. Stallman <rms@gnu.org>
parents:
8141
diff
changeset
|
29 |
13449 | 30 static int doprnt1 (); |
31 | |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
32 /* Generate output from a format-spec FORMAT, |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
33 terminated at position FORMAT_END. |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
34 Output goes in BUFFER, which has room for BUFSIZE chars. |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
35 If the output does not fit, truncate it to fit. |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
36 Returns the number of characters stored into BUFFER. |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
37 ARGS points to the vector of arguments, and NARGS says how many. |
13449 | 38 A double counts as two arguments. |
39 String arguments are passed as C strings. | |
40 Integers are passed as C integers. */ | |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
41 |
49 | 42 doprnt (buffer, bufsize, format, format_end, nargs, args) |
43 char *buffer; | |
44 register int bufsize; | |
45 char *format; | |
46 char *format_end; | |
47 int nargs; | |
48 char **args; | |
49 { | |
13449 | 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 | |
56 doprnt_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 | |
67 static int | |
68 doprnt1 (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 { | |
49 | 77 int cnt = 0; /* Number of arg to gobble next */ |
78 register char *fmt = format; /* Pointer into format string */ | |
79 register char *bufptr = buffer; /* Pointer into output buffer.. */ | |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
80 |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
81 /* Use this for sprintf unless we need something really big. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
82 char tembuf[100]; |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
83 |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
84 /* Size of sprintf_buffer. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
85 int size_allocated = 100; |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
86 |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
87 /* Buffer to use for sprintf. Either tembuf or same as BIG_BUFFER. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
88 char *sprintf_buffer = tembuf; |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
89 |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
90 /* Buffer we have got with malloc. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
91 char *big_buffer = 0; |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
92 |
49 | 93 register int tem; |
94 char *string; | |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
95 char fixed_buffer[20]; /* Default buffer for small formatting. */ |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
96 char *fmtcpy; |
49 | 97 int minlen; |
98 int size; /* Field width factor; e.g., %90d */ | |
8141
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
99 char charbuf[2]; /* Used for %c. */ |
49 | 100 |
101 if (format_end == 0) | |
102 format_end = format + strlen (format); | |
103 | |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
104 if ((format_end - format + 1) < sizeof (fixed_buffer)) |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
105 fmtcpy = fixed_buffer; |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
106 else |
5053
b98e742f0b05
(doprnt): Cast the value alloca returns.
Richard M. Stallman <rms@gnu.org>
parents:
5036
diff
changeset
|
107 fmtcpy = (char *) alloca (format_end - format + 1); |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
108 |
49 | 109 bufsize--; |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
110 |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
111 /* Loop until end of format string or buffer full. */ |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
112 while (fmt != format_end && bufsize > 0) |
49 | 113 { |
114 if (*fmt == '%') /* Check for a '%' character */ | |
115 { | |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
116 int size_bound; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
117 |
49 | 118 fmt++; |
484 | 119 /* Copy this one %-spec into fmtcpy. */ |
49 | 120 string = fmtcpy; |
121 *string++ = '%'; | |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
122 while (1) |
49 | 123 { |
124 *string++ = *fmt; | |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
125 if (! (*fmt >= '0' && *fmt <= '9') |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
126 && *fmt != '-' && *fmt != ' '&& *fmt != '.') |
49 | 127 break; |
128 fmt++; | |
129 } | |
130 *string = 0; | |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
131 /* Get an idea of how much space we might need. */ |
6236
d9f096200099
(doprnt): Do the right thing for negative size spec.
Karl Heuer <kwzh@gnu.org>
parents:
5053
diff
changeset
|
132 size_bound = atoi (&fmtcpy[1]); |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
133 |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
134 /* Avoid pitfall of negative "size" parameter ("%-200d"). */ |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
135 if (size_bound < 0) |
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
136 size_bound = -size_bound; |
6236
d9f096200099
(doprnt): Do the right thing for negative size spec.
Karl Heuer <kwzh@gnu.org>
parents:
5053
diff
changeset
|
137 size_bound += 50; |
4774
8e36034f65e2
(doprnt): Use a fixed buffer to store the format
Brian Fox <bfox@gnu.org>
parents:
2439
diff
changeset
|
138 |
13363
941c37982f37
(BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Karl Heuer <kwzh@gnu.org>
parents:
12959
diff
changeset
|
139 if (size_bound > (unsigned) (1 << (BITS_PER_INT - 1))) |
12959
f83031b644ac
(doprnt): Fix typo in error message.
Richard M. Stallman <rms@gnu.org>
parents:
12830
diff
changeset
|
140 error ("Format padding too large"); |
12797
f0724d9d625e
(doprnt): Don't let size_bound be gigantic. Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
141 |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
142 /* Make sure we have that much. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
143 if (size_bound > size_allocated) |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
144 { |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
145 if (big_buffer) |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
146 big_buffer = (char *) xrealloc (big_buffer, size_bound); |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
147 else |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
148 big_buffer = (char *) xmalloc (size_bound); |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
149 sprintf_buffer = big_buffer; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
150 size_allocated = size_bound; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
151 } |
49 | 152 minlen = 0; |
153 switch (*fmt++) | |
154 { | |
155 default: | |
156 error ("Invalid format operation %%%c", fmt[-1]); | |
157 | |
158 /* case 'b': */ | |
159 case 'd': | |
160 case 'o': | |
161 case 'x': | |
162 if (cnt == nargs) | |
12797
f0724d9d625e
(doprnt): Don't let size_bound be gigantic. Fix error message.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
163 error ("Not enough arguments for format string"); |
11700
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
164 if (sizeof (int) == sizeof (EMACS_INT)) |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
165 ; |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
166 else if (sizeof (long) == sizeof (EMACS_INT)) |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
167 /* Insert an `l' the right place. */ |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
168 string[1] = string[0], |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
169 string[0] = string[-1], |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
170 string[-1] = 'l', |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
171 string++; |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
172 else |
79358a3240fe
(doprnt): Handle long EMACS_INT in sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11320
diff
changeset
|
173 abort (); |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
174 sprintf (sprintf_buffer, fmtcpy, args[cnt++]); |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
175 /* Now copy into final output, truncating as nec. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
176 string = sprintf_buffer; |
49 | 177 goto doit; |
178 | |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
179 case 'f': |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
180 case 'e': |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
181 case 'g': |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
182 { |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
183 union { double d; char *half[2]; } u; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
184 if (cnt + 1 == nargs) |
6715
3864d274a56c
(doprnt): Reword confusing error message.
Karl Heuer <kwzh@gnu.org>
parents:
6236
diff
changeset
|
185 error ("not enough arguments for format string"); |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
186 u.half[0] = args[cnt++]; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
187 u.half[1] = args[cnt++]; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
188 sprintf (sprintf_buffer, fmtcpy, u.d); |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
189 /* Now copy into final output, truncating as nec. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
190 string = sprintf_buffer; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
191 goto doit; |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
192 } |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
193 |
49 | 194 case 'S': |
195 string[-1] = 's'; | |
196 case 's': | |
197 if (cnt == nargs) | |
6715
3864d274a56c
(doprnt): Reword confusing error message.
Karl Heuer <kwzh@gnu.org>
parents:
6236
diff
changeset
|
198 error ("not enough arguments for format string"); |
49 | 199 if (fmtcpy[1] != 's') |
200 minlen = atoi (&fmtcpy[1]); | |
13449 | 201 if (lispstrings) |
202 { | |
13554 | 203 string = (char *) XSTRING (((Lisp_Object *) args)[cnt])->data; |
13449 | 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 | |
49 | 214 /* Copy string into final output, truncating if no room. */ |
215 doit: | |
216 tem = strlen (string); | |
8141
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
217 doit1: |
49 | 218 if (minlen > 0) |
219 { | |
220 while (minlen > tem && bufsize > 0) | |
221 { | |
222 *bufptr++ = ' '; | |
223 bufsize--; | |
224 minlen--; | |
225 } | |
226 minlen = 0; | |
227 } | |
228 if (tem > bufsize) | |
229 tem = bufsize; | |
13449 | 230 bcopy (string, bufptr, tem); |
49 | 231 bufptr += tem; |
232 bufsize -= tem; | |
233 if (minlen < 0) | |
234 { | |
235 while (minlen < - tem && bufsize > 0) | |
236 { | |
237 *bufptr++ = ' '; | |
238 bufsize--; | |
239 minlen++; | |
240 } | |
241 minlen = 0; | |
242 } | |
243 continue; | |
244 | |
245 case 'c': | |
246 if (cnt == nargs) | |
6715
3864d274a56c
(doprnt): Reword confusing error message.
Karl Heuer <kwzh@gnu.org>
parents:
6236
diff
changeset
|
247 error ("not enough arguments for format string"); |
11320
aaf81f284f83
(xmalloc, xrealloc): Declare them here.
Richard M. Stallman <rms@gnu.org>
parents:
8141
diff
changeset
|
248 *charbuf = (EMACS_INT) args[cnt++]; |
8141
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
249 string = charbuf; |
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
250 tem = 1; |
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
251 if (fmtcpy[1] != 'c') |
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
252 minlen = atoi (&fmtcpy[1]); |
e3859c43c6f4
(doprnt): Handle padding on %c.
Richard M. Stallman <rms@gnu.org>
parents:
6715
diff
changeset
|
253 goto doit1; |
49 | 254 |
255 case '%': | |
256 fmt--; /* Drop thru and this % will be treated as normal */ | |
257 } | |
258 } | |
259 *bufptr++ = *fmt++; /* Just some characters; Copy 'em */ | |
260 bufsize--; | |
261 }; | |
262 | |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
263 /* If we had to malloc something, free it. */ |
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
264 if (big_buffer) |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
265 xfree (big_buffer); |
147
0f50f1badd75
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
116
diff
changeset
|
266 |
49 | 267 *bufptr = 0; /* Make sure our string end with a '\0' */ |
268 return bufptr - buffer; | |
269 } |