annotate ezBAMQC/src/htslib/cram/vlen.c @ 20:9de3bbec2479 draft default tip

Uploaded
author youngkim
date Thu, 31 Mar 2016 10:10:37 -0400
parents dfa3745e5fd8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
1 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
2 Author: James Bonfield (jkb@sanger.ac.uk)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
3
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
4 Copyright (c) 1995-1996 MEDICAL RESEARCH COUNCIL
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
5 All rights reserved
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
6
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
7 Redistribution and use in source and binary forms, with or without
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
8 modification, are permitted provided that the following conditions are met:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
9
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
10 1 Redistributions of source code must retain the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
11 this list of conditions and the following disclaimer.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
12
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
13 2 Redistributions in binary form must reproduce the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
14 this list of conditions and the following disclaimer in the documentation
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
15 and/or other materials provided with the distribution.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
16
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
17 3 Neither the name of the MEDICAL RESEARCH COUNCIL, THE LABORATORY OF
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
18 MOLECULAR BIOLOGY nor the names of its contributors may be used to endorse or
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
19 promote products derived from this software without specific prior written
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
20 permission.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
21
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
32 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
33
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
34 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
35 Copyright (c) 2004, 2009, 2011-2012 Genome Research Ltd.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
36
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
37 Author: James Bonfield <jkb@sanger.ac.uk>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
38
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
39 Redistribution and use in source and binary forms, with or without
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
40 modification, are permitted provided that the following conditions are met:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
41
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
42 1. Redistributions of source code must retain the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
43 this list of conditions and the following disclaimer.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
44
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
45 2. Redistributions in binary form must reproduce the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
46 this list of conditions and the following disclaimer in the documentation
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
47 and/or other materials provided with the distribution.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
48
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
49 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
50 Institute nor the names of its contributors may be used to endorse or promote
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
51 products derived from this software without specific prior written permission.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
52
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
53 THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
54 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
55 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
56 DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
57 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
58 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
59 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
60 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
61 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
62 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
63 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
64
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
65 #ifdef HAVE_CONFIG_H
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
66 #include "io_lib_config.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
67 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
68
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
69 #include <stdio.h>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
70 #include <stdlib.h>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
71 #include <stdarg.h>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
72 #include <sys/types.h>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
73 #include <string.h>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
74
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
75 #include "cram/vlen.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
76 #include "cram/os.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
77
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
78 #ifndef MAX
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
79 #define MAX(a,b) ((a)>(b)?(a):(b))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
80 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
81
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
82 #ifndef ABS
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
83 #define ABS(a) ((a)>0?(a):-(a))
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
84 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
85
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
86 /* #define DEBUG_printf(a,n) printf(a,n) */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
87 #define DEBUG_printf(a,n)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
88
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
89 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
90 * vlen: 27/10/95 written by James Bonfield, jkb@mrc-lmb.cam.ac.uk
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
91 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
92 * Given sprintf style of arguments this routine returns the maximum
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
93 * size of buffer needed to allocate to use with sprintf. It errs on
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
94 * the side of caution by being simplistic in its approach: we assume
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
95 * all numbers are of maximum length.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
96 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
97 * Handles the usual type conversions (%[%diuaxXcfeEgGpns]), but not
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
98 * the 'wide' character conversions (%C and %S).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
99 * Precision is handled in the correct formats, including %*.*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
100 * notations.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
101 * Additionally, some of the more dubious (but probably illegal) cases
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
102 * are supported (eg "%10%" will expand to " %" on many
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
103 * systems).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
104 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
105 * We also assume that the largest integer and larger pointer are 64
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
106 * bits, which at least covers the machines we'll need it for.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
107 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
108 int flen(char *fmt, ...)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
109 {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
110 va_list args;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
111
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
112 va_start(args, fmt);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
113 return vflen(fmt, args);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
114 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
115
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
116 int vflen(char *fmt, va_list ap)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
117 {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
118 int len = 0;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
119 char *cp, c;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
120 long long l;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
121 int i;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
122 double d;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
123
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
124 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
125 * This code modifies 'ap', but we do not know if va_list is a structure
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
126 * or a pointer to an array so we do not know if it is a local variable
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
127 * or not.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
128 * C99 gets around this by defining va_copy() to make copies of ap, but
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
129 * this does not exist on all systems.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
130 * For now, I just assume that when va_list is a pointer the system also
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
131 * provides a va_copy macro to work around this problem. The only system
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
132 * I have seen needing this so far was Linux on AMD64.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
133 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
134 #if defined(HAVE_VA_COPY)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
135 va_list ap_local;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
136 va_copy(ap_local, ap);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
137 # define ap ap_local
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
138 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
139
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
140 for(cp = fmt; *cp; cp++) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
141 switch(*cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
142
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
143 /* A format specifier */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
144 case '%': {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
145 char *endp;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
146 long conv_len1=0, conv_len2=0, conv_len=0;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
147 signed int arg_size;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
148
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
149 /* Firstly, strip the modifier flags (+-#0 and [space]) */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
150 for(; (c=*++cp);) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
151 if ('#' == c)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
152 len+=2; /* Worst case of "0x" */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
153 else if ('-' == c || '+' == c || ' ' == c)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
154 len++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
155 else
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
156 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
157 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
158
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
159 /* Width specifier */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
160 l = strtol(cp, &endp, 10);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
161 if (endp != cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
162 cp = endp;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
163 conv_len = conv_len1 = l;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
164 } else if (*cp == '*') {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
165 conv_len = conv_len1 = (int)va_arg(ap, int);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
166 cp++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
167 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
168
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
169 /* Precision specifier */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
170 if ('.' == *cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
171 cp++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
172 conv_len2 = strtol(cp, &endp, 10);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
173 if (endp != cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
174 cp = endp;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
175 } else if (*cp == '*') {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
176 conv_len2 = (int)va_arg(ap, int);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
177 cp++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
178 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
179 conv_len = MAX(conv_len1, conv_len2);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
180 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
181
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
182 /* Short/long identifier */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
183 if ('h' == *cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
184 arg_size = -1; /* short */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
185 cp++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
186 } else if ('l' == *cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
187 arg_size = 1; /* long */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
188 cp++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
189 if ('l' == *cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
190 arg_size = 2; /* long long */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
191 cp++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
192 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
193 } else {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
194 arg_size = 0; /* int */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
195 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
196
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
197 /* The actual type */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
198 switch (*cp) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
199 case '%':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
200 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
201 * Not real ANSI I suspect, but we'll allow for the
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
202 * completely daft "%10%" example.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
203 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
204 len += MAX(conv_len1, 1);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
205 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
206
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
207 case 'd':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
208 case 'i':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
209 case 'u':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
210 case 'a':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
211 case 'x':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
212 case 'X':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
213 /* Remember: char and short are sent as int on the stack */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
214 if (arg_size == -1)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
215 l = (long)va_arg(ap, int);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
216 else if (arg_size == 1)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
217 l = va_arg(ap, long);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
218 else if (arg_size == 2)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
219 l = va_arg(ap, long long);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
220 else
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
221 l = (long)va_arg(ap, int);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
222
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
223 DEBUG_printf("%d", l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
224
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
225 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
226 * No number can be more than 24 characters so we'll take
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
227 * the max of conv_len and 24 (23 is len(2^64) in octal).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
228 * All that work above and we then go and estimate ;-),
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
229 * but it's needed incase someone does %500d.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
230 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
231 len += MAX(conv_len, 23);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
232 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
233
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
234 case 'c':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
235 i = va_arg(ap, int);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
236 DEBUG_printf("%c", i);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
237 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
238 * Note that %10c and %.10c act differently.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
239 * Besides, I think precision is not really allowed for %c.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
240 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
241 len += MAX(conv_len1, i>=0x80 ?MB_CUR_MAX :1);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
242 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
243
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
244 case 'f':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
245 d = va_arg(ap, double);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
246 DEBUG_printf("%f", d);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
247 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
248 * Maybe "Inf" or "NaN", but we'll not worry about that.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
249 * Again, err on side of caution and take max of conv_len
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
250 * and max length of a double. The worst case I can
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
251 * think of is 317 characters (-1[308 zeros].000000)
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
252 * without using precision codes. That's horrid. I
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
253 * cheat and either use 317 or 15 depending on how
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
254 * large the number is as I reckon 99% of floats
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
255 * aren't that long.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
256 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
257 l = (ABS(d) > 1000000) ? 317 : 15;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
258 l = MAX(l, conv_len1 + 2);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
259 if (conv_len2) l += conv_len2 - 6;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
260 len += l;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
261 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
262
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
263 case 'e':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
264 case 'E':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
265 case 'g':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
266 case 'G':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
267 d = va_arg(ap, double);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
268 DEBUG_printf("%g", d);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
269 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
270 * Maybe "Inf" or "NaN", but we'll not worry about that
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
271 * Again, err on side of caution and take max of conv_len
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
272 * and max length of a double (which defaults to only
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
273 * '-' + 6 + '.' + 'E[+-]xxx' == 13.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
274 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
275 len += MAX(conv_len, 13);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
276 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
277
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
278 case 'p':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
279 l = (long)va_arg(ap, void *);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
280 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
281 * Max pointer is 64bits == 16 chars (on alpha),
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
282 * == 20 with + "0x".
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
283 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
284 DEBUG_printf("%p", (void *)l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
285 len += MAX(conv_len, 20);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
286 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
287
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
288 case 'n':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
289 /* produces no output */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
290 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
291
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
292 case 's': {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
293 char *s = (char *)va_arg(ap, char *);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
294 DEBUG_printf("%s", s);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
295
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
296 if (!conv_len2) {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
297 len += MAX(conv_len, (int)strlen(s));
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
298 } else {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
299 len += conv_len;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
300 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
301 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
302 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
303
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
304 default:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
305 /* wchar_t types of 'C' and 'S' aren't supported */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
306 DEBUG_printf("Arg is %c\n", *cp);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
307 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
308
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
309 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
310
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
311 case '\0':
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
312 break;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
313
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
314 default:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
315 DEBUG_printf("%c", *cp);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
316 len++;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
317 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
318 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
319
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
320 va_end(ap);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
321
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
322 return len+1; /* one for the null character */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
323 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
324
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
325 #if 0
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
326 int main() {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
327 int l;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
328 char buf[10000];
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
329
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
330 sprintf(buf, "d: %d\n", 500);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
331 l = flen("d: %d\n", 500);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
332 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
333
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
334 sprintf(buf, "");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
335 l = flen("");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
336 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
337
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
338 sprintf(buf, "%s\n","test");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
339 l = flen("%s\n", "test");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
340 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
341
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
342 sprintf(buf, "%c\n", 'a');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
343 l = flen("%c\n", 'a');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
344 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
345
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
346 sprintf(buf, "%31.30f\n", -9999.99);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
347 l = flen("%31.30f\n", -9999.99);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
348 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
349
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
350 sprintf(buf, "%f\n", -1e308);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
351 l = flen("%f\n", -1e308);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
352 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
353
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
354 sprintf(buf, "%.9f\n", -1e308);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
355 l = flen("%.9f\n", -1e308);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
356 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
357
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
358 sprintf(buf, "%10.20f\n", -1.999222333);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
359 l = flen("%10.20f\n", -1.999222333);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
360 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
361
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
362 sprintf(buf, "%#g\n", -3.14159265358e-222);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
363 l = flen("%#g\n", -3.1415927e-222);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
364 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
365
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
366 sprintf(buf, "%e\n", -123456789123456789.1);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
367 l = flen("%e\n", -123456789123456789.1);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
368 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
369
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
370 sprintf(buf, "%c %f %d %s %c %g %ld %s\n", 'a', 3.1, 9, "one", 'b', 4.2, 9, "two");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
371 l = flen("%c %f %d %s %c %g %ld %s\n", 'a', 3.1, 9, "one", 'b', 4.2, 9, "two");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
372 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
373
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
374 sprintf(buf, "%*.*e %*c\n", 10, 5, 9.0, 20, 'x');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
375 l = flen("%*.*e %*c\n", 10, 5, 9.0, 20, 'x');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
376 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
377
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
378 sprintf(buf, "%10c\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
379 l = flen("%10c\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
380 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
381
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
382 sprintf(buf, "%.10c\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
383 l = flen("%.10c\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
384 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
385
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
386 sprintf(buf, "%10d\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
387 l = flen("%10d\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
388 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
389
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
390 sprintf(buf, "%.10d\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
391 l = flen("%.10d\n", 'z');
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
392 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
393
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
394 sprintf(buf, "%10%\n");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
395 l = flen("%10%\n");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
396 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
397
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
398 sprintf(buf, "%.10%\n");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
399 l = flen("%.10%\n");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
400 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
401
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
402 sprintf(buf, "%s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
403 l = flen("%s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
404 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
405
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
406 sprintf(buf, "%5s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
407 l = flen("%5s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
408 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
409
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
410 sprintf(buf, "%50s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
411 l = flen("%50s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
412 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
413
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
414 sprintf(buf, "%.5s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
415 l = flen("%.5s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
416 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
417
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
418 sprintf(buf, "%.50s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
419 l = flen("%.50s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
420 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
421
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
422 sprintf(buf, "%5.50s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
423 l = flen("%5.50s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
424 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
425
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
426 sprintf(buf, "%50.5s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
427 l = flen("%50.5s\n", "0123456789");
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
428 printf("%d %d\n\n", strlen(buf), l);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
429
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
430 return 0;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
431 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
432 #endif