2
*******************************************************************************
4
* Copyright (C) 1998-2001, International Business Machines
5
* Corporation and others. All Rights Reserved.
7
*******************************************************************************
11
* Modification History:
13
* Date Name Description
14
* 12/02/98 stephen Creation.
15
* 03/13/99 stephen Modified for new C API.
16
*******************************************************************************
22
/* flag characters for u_scanf */
23
#define FLAG_ASTERISK 0x002A
24
#define FLAG_PAREN 0x0028
26
#define ISFLAG(s) (s) == FLAG_ASTERISK || \
29
/* special characters for u_scanf */
30
#define SPEC_DOLLARSIGN 0x0024
33
#define DIGIT_ZERO 0x0030
34
#define DIGIT_ONE 0x0031
35
#define DIGIT_TWO 0x0032
36
#define DIGIT_THREE 0x0033
37
#define DIGIT_FOUR 0x0034
38
#define DIGIT_FIVE 0x0035
39
#define DIGIT_SIX 0x0036
40
#define DIGIT_SEVEN 0x0037
41
#define DIGIT_EIGHT 0x0038
42
#define DIGIT_NINE 0x0039
44
#define ISDIGIT(s) (s) == DIGIT_ZERO || \
47
(s) == DIGIT_THREE || \
48
(s) == DIGIT_FOUR || \
49
(s) == DIGIT_FIVE || \
51
(s) == DIGIT_SEVEN || \
52
(s) == DIGIT_EIGHT || \
55
/* u_scanf modifiers */
57
#define MOD_LOWERL 0x006C
60
#define ISMOD(s) (s) == MOD_H || \
61
(s) == MOD_LOWERL || \
64
/* We parse the argument list in Unicode */
66
u_scanf_parse_spec (const UChar *fmt,
71
u_scanf_spec_info *info = &(spec->fInfo);
73
/* initialize spec to default values */
75
spec->fSkipArg = FALSE;
79
info->fPadChar = 0x0020;
80
info->fIsLongDouble = FALSE;
81
info->fIsShort = FALSE;
82
info->fIsLong = FALSE;
83
info->fIsLongLong = FALSE;
86
/* skip over the initial '%' */
89
/* Check for positional argument */
92
/* Save the current position */
95
/* handle positional parameters */
97
spec->fArgPos = (int) (*s++ - DIGIT_ZERO);
101
spec->fArgPos += (int) (*s++ - DIGIT_ZERO);
105
/* if there is no '$', don't read anything */
106
if(*s != SPEC_DOLLARSIGN) {
115
/* Get any format flags */
121
spec->fSkipArg = TRUE;
124
/* pad character specified */
127
/* first four characters are hex values for pad char */
128
info->fPadChar = (UChar)ufmt_digitvalue(*s++);
129
info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
130
info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
131
info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
133
/* final character is ignored */
142
info->fWidth = (int) (*s++ - DIGIT_ZERO);
146
info->fWidth += (int) (*s++ - DIGIT_ZERO);
150
/* Get any modifiers */
156
info->fIsShort = TRUE;
159
/* long or long long */
161
if(*s == MOD_LOWERL) {
162
info->fIsLongLong = TRUE;
163
/* skip over the next 'l' */
167
info->fIsLong = TRUE;
172
info->fIsLongDouble = TRUE;
177
/* finally, get the specifier letter */
180
/* return # of characters in this specifier */