Changeset 73 for pjproject/trunk
- Timestamp:
- Nov 21, 2005 5:06:21 PM (19 years ago)
- Location:
- pjproject/trunk/pjlib-util
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/build/pjlib_util.dsp
r65 r73 42 42 # PROP Target_Dir "" 43 43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 # ADD CPP /nologo /MD /W3 /GX / O2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c44 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /Ob2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c 45 45 # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 46 # ADD RSC /l 0x409 /d "NDEBUG" … … 94 94 # Begin Source File 95 95 96 SOURCE="..\src\pjlib-util\scanner_cis_bitwise.c" 97 # PROP Exclude_From_Build 1 98 # End Source File 99 # Begin Source File 100 101 SOURCE="..\src\pjlib-util\scanner_cis_uint.c" 102 # PROP Exclude_From_Build 1 103 # End Source File 104 # Begin Source File 105 96 106 SOURCE="..\src\pjlib-util\string.c" 97 107 # End Source File … … 130 140 # Begin Source File 131 141 142 SOURCE="..\include\pjlib-util\scanner_cis_bitwise.h" 143 # End Source File 144 # Begin Source File 145 146 SOURCE="..\include\pjlib-util\scanner_cis_uint.h" 147 # End Source File 148 # Begin Source File 149 132 150 SOURCE="..\include\pjlib-util\string.h" 133 151 # End Source File -
pjproject/trunk/pjlib-util/include/pjlib-util/scanner.h
r65 r73 27 27 #include <pj/types.h> 28 28 29 /** 30 * Macro PJ_SCANNER_USE_BITWISE is defined and non-zero (by default yes) 31 * will enable the use of bitwise for character input specification (cis). 32 * This would save several kilobytes of .bss memory in the SIP parser. 33 */ 34 #ifndef PJ_SCANNER_USE_BITWISE 35 # define PJ_SCANNER_USE_BITWISE 1 36 #endif 37 38 29 39 PJ_BEGIN_DECL 30 40 … … 37 47 * @{ 38 48 */ 39 40 /** 41 * This describes the type of individual character specification in 42 * #pj_cis_buf_t. Basicly the number of bits here 43 */ 44 #ifndef PJ_CIS_ELEM_TYPE 45 # define PJ_CIS_ELEM_TYPE pj_uint32_t 49 #if defined(PJ_SCANNER_USE_BITWISE) && PJ_SCANNER_USE_BITWISE != 0 50 # include <pjlib-util/scanner_cis_bitwise.h> 51 #else 52 # include <pjlib-util/scanner_cis_uint.h> 46 53 #endif 47 48 /**49 * This describes the type of individual character specification in50 * #pj_cis_buf_t.51 */52 typedef PJ_CIS_ELEM_TYPE pj_cis_elem_t;53 54 /**55 * Maximum number of input specification in a buffer.56 * Effectively this means the number of bits in pj_cis_elem_t.57 */58 #define PJ_CIS_MAX_INDEX (sizeof(pj_cis_elem_t) << 3)59 60 /**61 * The scanner input specification buffer.62 */63 typedef struct pj_cis_buf_t64 {65 pj_cis_elem_t cis_buf[256]; /**< Must be 256 (not 128)! */66 pj_cis_elem_t use_mask; /**< To keep used indexes. */67 } pj_cis_buf_t;68 69 /**70 * Character input specification.71 */72 typedef struct pj_cis_t73 {74 pj_cis_elem_t *cis_buf; /**< Pointer to buffer. */75 int cis_id; /**< Id. */76 } pj_cis_t;77 54 78 55 /** … … 107 84 */ 108 85 PJ_DECL(pj_status_t) pj_cis_dup(pj_cis_t *new_cis, pj_cis_t *existing); 109 110 /**111 * Set the membership of the specified character.112 * Note that this is a macro, and arguments may be evaluated more than once.113 *114 * @param cis Pointer to character input specification.115 * @param c The character.116 */117 #define PJ_CIS_SET(cis,c) ((cis)->cis_buf[(c)] |= (1 << (cis)->cis_id))118 119 /**120 * Remove the membership of the specified character.121 * Note that this is a macro, and arguments may be evaluated more than once.122 *123 * @param cis Pointer to character input specification.124 * @param c The character to be removed from the membership.125 */126 #define PJ_CIS_CLR(cis,c) ((cis)->cis_buf[c] &= ~(1 << (cis)->cis_id))127 128 /**129 * Check the membership of the specified character.130 * Note that this is a macro, and arguments may be evaluated more than once.131 *132 * @param cis Pointer to character input specification.133 * @param c The character.134 */135 #define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[c] & (1 << (cis)->cis_id))136 86 137 87 /** -
pjproject/trunk/pjlib-util/src/pjlib-util-test/test.c
r65 r73 75 75 return test_inner(); 76 76 } 77 PJ_ DEFAULT{77 PJ_CATCH_ANY { 78 78 int id = PJ_GET_EXCEPTION(); 79 79 PJ_LOG(3,("test", "FATAL: unhandled exception id %d (%s)", -
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); -
pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
r65 r73 172 172 node = xml_parse_node(pool, &scanner); 173 173 } 174 PJ_ DEFAULT{174 PJ_CATCH_ANY { 175 175 PJ_LOG(4,(THIS_FILE, "Syntax error parsing XML in line %d column %d", 176 176 scanner.line, scanner.col));
Note: See TracChangeset
for help on using the changeset viewer.