19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <wchar.h>
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "asprintf.h"
#define MAX_SUBFMT_LEN 64
struct context {
const char *fmt;
size_t fmt_len;
char subfmt[MAX_SUBFMT_LEN + 1];
|
>
>
>
>
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <wchar.h>
#include <sys/types.h>
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "asprintf.h"
#import "macros.h"
#define MAX_SUBFMT_LEN 64
struct context {
const char *fmt;
size_t fmt_len;
char subfmt[MAX_SUBFMT_LEN + 1];
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
ctx->len_mod = LENGTH_MODIFIER_H;
}
break;
case 'l': /* and also ll */
if (ctx->fmt_len > ctx->i + 1 && ctx->fmt[ctx->i + 1] == 'l') {
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 2))
return false;
ctx->i++;
ctx->len_mod = LENGTH_MODIFIER_LL;
} else {
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
ctx->len_mod = LENGTH_MODIFIER_L;
}
break;
case 'j':
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
ctx->len_mod = LENGTH_MODIFIER_J;
break;
case 'z':
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
|
>
>
>
>
>
>
>
>
>
>
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
ctx->len_mod = LENGTH_MODIFIER_H;
}
break;
case 'l': /* and also ll */
if (ctx->fmt_len > ctx->i + 1 && ctx->fmt[ctx->i + 1] == 'l') {
#ifndef _WIN32
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 2))
return false;
#else
if (!append_subfmt(ctx, "I64", 3))
return false;
#endif
ctx->i++;
ctx->len_mod = LENGTH_MODIFIER_LL;
} else {
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
ctx->len_mod = LENGTH_MODIFIER_L;
}
break;
case 'j':
#ifndef _WIN32
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
#else
if (!append_subfmt(ctx, "I64", 3))
return false;
#endif
ctx->len_mod = LENGTH_MODIFIER_J;
break;
case 'z':
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
case 'L':
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
ctx->len_mod = LENGTH_MODIFIER_CAPITAL_L;
break;
default:
ctx->i--;
break;
}
ctx->state = STATE_FORMAT_CONVERSION_SPECIFIER;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
case 'L':
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
ctx->len_mod = LENGTH_MODIFIER_CAPITAL_L;
break;
#ifdef _WIN32
case 'I': /* win32 strangeness (I64 instead of ll or j) */
if (ctx->fmt_len > ctx->i + 2 && ctx->fmt[ctx->i + 1] == '6' &&
ctx->fmt[ctx->i + 2] == '4') {
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 3))
return false;
ctx->i += 2;
ctx->len_mod = LENGTH_MODIFIER_LL;
} else
ctx->i--;
break;
#endif
#ifdef OF_IOS
case 'q': /* iOS uses this for PRI?64 */
if (!append_subfmt(ctx, ctx->fmt + ctx->i, 1))
return false;
ctx->len_mod = LENGTH_MODIFIER_LL;
break;
#endif
default:
ctx->i--;
break;
}
ctx->state = STATE_FORMAT_CONVERSION_SPECIFIER;
|