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/03/98 stephen Creation.
15
* 03/13/99 stephen Modified for new C API.
16
******************************************************************************
23
u_scanf_scanset_add(u_scanf_scanset *scanset,
26
if(scanset->single_count == U_SCANF_MAX_SCANSET_SIZE - 1)
29
scanset->singles[ scanset->single_count ] = c;
30
(scanset->single_count)++;
36
u_scanf_scanset_addrange(u_scanf_scanset *scanset,
40
if(scanset->pair_count == U_SCANF_MAX_SCANSET_SIZE - 1)
43
scanset->pairs[ scanset->pair_count ].start = start;
44
scanset->pairs[ scanset->pair_count ].end = end;
46
(scanset->pair_count)++;
52
u_scanf_scanset_init(u_scanf_scanset *scanset,
62
/* set up parameters */
66
/* initialize to defaults */
67
scanset->single_count = 0;
68
scanset->pair_count = 0;
69
scanset->is_inclusive = TRUE;
71
/* check to see if this is an inclusive or exclusive scanset */
72
if(*s == 0x005E) { /* '^' */
73
scanset->is_inclusive = FALSE;
75
/* increment s and count */
80
/* if ']' is the first character, add it */
81
else if(*s == 0x005D) {
82
result = u_scanf_scanset_add(scanset, *s++);
88
/* if the first character is '^' and the second is ']', add ']' */
89
if( ! scanset->is_inclusive && *s == 0x005D) {
90
result = u_scanf_scanset_add(scanset, *s++);
96
/* add characters until a ']' is seen, adding ranges as necessary */
99
/* grab the current character */
102
/* if it's a ']', we're done */
106
/* check if this is a range */
107
if(*s == 0x002D && *(s+1) != 0x005D) {
108
result = u_scanf_scanset_addrange(scanset, c, *(s+1));
110
/* increment count and s */
115
/* otherwise, just add the character */
117
result = u_scanf_scanset_add(scanset, c);
120
/* increment count */
124
/* update length to reflect # of characters consumed */
130
u_scanf_scanset_in(u_scanf_scanset *scanset,
135
/* if this is an inclusive scanset, make sure c is in it */
136
if(scanset->is_inclusive) {
138
/* check the single chars first*/
139
for(i = 0; i < scanset->single_count; ++i) {
140
if(c == scanset->singles[i])
144
/* check the pairs */
145
for(i = 0; i < scanset->pair_count; ++i) {
146
if(c >= scanset->pairs[i].start && c <= scanset->pairs[i].end)
150
/* didn't find it, so c isn't in set */
154
/* otherwise, make sure c isn't in it */
157
/* check the single chars first*/
158
for(i = 0; i < scanset->single_count; ++i) {
159
if(c == scanset->singles[i])
163
/* check the pairs */
164
for(i = 0; i < scanset->pair_count; ++i) {
165
if(c >= scanset->pairs[i].start && c <= scanset->pairs[i].end)
169
/* didn't find it, so c is in set */