Changeset 73 for pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c
- Timestamp:
- Nov 21, 2005 5:06:21 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c
r65 r73 22 22 #include <pj/os.h> 23 23 #include <pj/errno.h> 24 #include <pj/assert.h> 24 25 25 26 #define PJ_SCAN_IS_SPACE(c) ((c)==' ' || (c)=='\t') … … 28 29 29 30 31 #if defined(PJ_SCANNER_USE_BITWISE) && PJ_SCANNER_USE_BITWISE != 0 32 # include "scanner_cis_bitwise.c" 33 #else 34 # include "scanner_cis_uint.c" 35 #endif 36 37 30 38 static void pj_scan_syntax_err(pj_scanner *scanner) 31 39 { … … 33 41 } 34 42 35 PJ_DEF(void) pj_cis_buf_init( pj_cis_buf_t *cis_buf)36 {37 pj_memset(cis_buf->cis_buf, 0, sizeof(cis_buf->cis_buf));38 cis_buf->use_mask = 0;39 }40 41 PJ_DEF(pj_status_t) pj_cis_init(pj_cis_buf_t *cis_buf, pj_cis_t *cis)42 {43 unsigned i;44 45 cis->cis_buf = cis_buf->cis_buf;46 47 for (i=0; i<PJ_CIS_MAX_INDEX; ++i) {48 if ((cis_buf->use_mask & (1 << i)) == 0) {49 cis->cis_id = i;50 cis_buf->use_mask |= (1 << i);51 return PJ_SUCCESS;52 }53 }54 55 cis->cis_id = PJ_CIS_MAX_INDEX;56 return PJ_ETOOMANY;57 }58 59 PJ_DEF(pj_status_t) pj_cis_dup( pj_cis_t *new_cis, pj_cis_t *existing)60 {61 pj_status_t status;62 unsigned i;63 64 /* Warning: typecasting here! */65 status = pj_cis_init((pj_cis_buf_t*)existing->cis_buf, new_cis);66 if (status != PJ_SUCCESS)67 return status;68 69 for (i=0; i<256; ++i) {70 if (PJ_CIS_ISSET(existing, i))71 PJ_CIS_SET(new_cis, i);72 else73 PJ_CIS_CLR(new_cis, i);74 }75 76 return PJ_SUCCESS;77 }78 43 79 44 PJ_DEF(void) pj_cis_add_range(pj_cis_t *cis, int cstart, int cend) 80 45 { 46 /* Can not set zero. This is the requirement of the parser. */ 47 pj_assert(cstart > 0); 48 81 49 while (cstart != cend) { 82 50 PJ_CIS_SET(cis, cstart); … … 123 91 { 124 92 unsigned i; 125 for (i=0; i<256; ++i) { 93 /* Can not set zero. This is the requirement of the parser. */ 94 for (i=1; i<256; ++i) { 126 95 if (PJ_CIS_ISSET(cis,i)) 127 96 PJ_CIS_CLR(cis,i); … … 285 254 PJ_CHECK_STACK(); 286 255 256 pj_assert(pj_cis_match(spec,0)==0); 257 287 258 if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) { 288 259 pj_scan_syntax_err(scanner); … … 292 263 do { 293 264 ++s; 294 } while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s)); 265 } while (pj_cis_match(spec, *s)); 266 /* No need to check EOF here (PJ_SCAN_CHECK_EOF(s)) because 267 * buffer is NULL terminated and pj_cis_match(spec,0) should be 268 * false. 269 */ 295 270 296 271 pj_strset3(out, scanner->curptr, s);
Note: See TracChangeset
for help on using the changeset viewer.