yxml.c (a788b16c9db13afe868b3d4716de6e2eab37c7fd) | yxml.c (c1ab6cc1beb14b16b46e74a3723644016d8c3cc7) |
---|---|
1/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT! */ 2 3/* Copyright (c) 2013-2014 Yoran Heling 4 5 Permission is hereby granted, free of charge, to any person obtaining 6 a copy of this software and associated documentation files (the 7 "Software"), to deal in the Software without restriction, including 8 without limitation the rights to use, copy, modify, merge, publish, --- 174 unchanged lines hidden (view full) --- 183 yxml_setchar(x->data+2, ch); 184 x->data[3] = 0; 185 return YXML_CONTENT; 186} 187 188 189static inline yxml_ret_t yxml_dataattr(yxml_t *x, unsigned ch) { 190 /* Normalize attribute values according to the XML spec section 3.3.3. */ | 1/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT! */ 2 3/* Copyright (c) 2013-2014 Yoran Heling 4 5 Permission is hereby granted, free of charge, to any person obtaining 6 a copy of this software and associated documentation files (the 7 "Software"), to deal in the Software without restriction, including 8 without limitation the rights to use, copy, modify, merge, publish, --- 174 unchanged lines hidden (view full) --- 183 yxml_setchar(x->data+2, ch); 184 x->data[3] = 0; 185 return YXML_CONTENT; 186} 187 188 189static inline yxml_ret_t yxml_dataattr(yxml_t *x, unsigned ch) { 190 /* Normalize attribute values according to the XML spec section 3.3.3. */ |
191 yxml_setchar(x->data, ch == 0x9 || ch == 0xa ? 0x20 : ch); | 191 yxml_setchar(x->data, (ch == 0x9) || (ch == 0xa) ? 0x20 : ch); |
192 x->data[1] = 0; 193 return YXML_ATTRVAL; 194} 195 196 197static yxml_ret_t yxml_pushstack(yxml_t *x, char **res, unsigned ch) { | 192 x->data[1] = 0; 193 return YXML_ATTRVAL; 194} 195 196 197static yxml_ret_t yxml_pushstack(yxml_t *x, char **res, unsigned ch) { |
198 if(x->stacklen+2 >= x->stacksize) | 198 if((x->stacklen+2) >= x->stacksize) |
199 return YXML_ESTACK; 200 x->stacklen++; 201 *res = (char *)x->stack+x->stacklen; 202 x->stack[x->stacklen] = ch; 203 x->stacklen++; 204 x->stack[x->stacklen] = 0; 205 return YXML_OK; 206} 207 208 209static yxml_ret_t yxml_pushstackc(yxml_t *x, unsigned ch) { | 199 return YXML_ESTACK; 200 x->stacklen++; 201 *res = (char *)x->stack+x->stacklen; 202 x->stack[x->stacklen] = ch; 203 x->stacklen++; 204 x->stack[x->stacklen] = 0; 205 return YXML_OK; 206} 207 208 209static yxml_ret_t yxml_pushstackc(yxml_t *x, unsigned ch) { |
210 if(x->stacklen+1 >= x->stacksize) | 210 if((x->stacklen+1) >= x->stacksize) |
211 return YXML_ESTACK; 212 x->stack[x->stacklen] = ch; 213 x->stacklen++; 214 x->stack[x->stacklen] = 0; 215 return YXML_OK; 216} 217 218 --- 46 unchanged lines hidden (view full) --- 265static inline yxml_ret_t yxml_attrnameend(yxml_t *x, unsigned ch) { (void) x; (void) ch; return YXML_ATTRSTART; } 266static inline yxml_ret_t yxml_attrvalend (yxml_t *x, unsigned ch) { (void) ch; yxml_popstack(x); return YXML_ATTREND; } 267 268 269static inline yxml_ret_t yxml_pistart (yxml_t *x, unsigned ch) { return yxml_pushstack(x, &x->pi, ch); } 270static inline yxml_ret_t yxml_piname (yxml_t *x, unsigned ch) { return yxml_pushstackc(x, ch); } 271static inline yxml_ret_t yxml_piabort (yxml_t *x, unsigned ch) { (void) x; (void) ch; yxml_popstack(x); return YXML_OK; } 272static inline yxml_ret_t yxml_pinameend(yxml_t *x, unsigned ch) { (void) ch; | 211 return YXML_ESTACK; 212 x->stack[x->stacklen] = ch; 213 x->stacklen++; 214 x->stack[x->stacklen] = 0; 215 return YXML_OK; 216} 217 218 --- 46 unchanged lines hidden (view full) --- 265static inline yxml_ret_t yxml_attrnameend(yxml_t *x, unsigned ch) { (void) x; (void) ch; return YXML_ATTRSTART; } 266static inline yxml_ret_t yxml_attrvalend (yxml_t *x, unsigned ch) { (void) ch; yxml_popstack(x); return YXML_ATTREND; } 267 268 269static inline yxml_ret_t yxml_pistart (yxml_t *x, unsigned ch) { return yxml_pushstack(x, &x->pi, ch); } 270static inline yxml_ret_t yxml_piname (yxml_t *x, unsigned ch) { return yxml_pushstackc(x, ch); } 271static inline yxml_ret_t yxml_piabort (yxml_t *x, unsigned ch) { (void) x; (void) ch; yxml_popstack(x); return YXML_OK; } 272static inline yxml_ret_t yxml_pinameend(yxml_t *x, unsigned ch) { (void) ch; |
273 return (x->pi[0]|32) == 'x' && (x->pi[1]|32) == 'm' && (x->pi[2]|32) == 'l' && !x->pi[3] ? YXML_ESYN : YXML_PISTART; | 273 return ((x->pi[0]|32) == 'x') && ((x->pi[1]|32) == 'm') && ((x->pi[2]|32) == 'l') && !x->pi[3] ? YXML_ESYN : YXML_PISTART; |
274} 275static inline yxml_ret_t yxml_pivalend (yxml_t *x, unsigned ch) { (void) ch; yxml_popstack(x); x->pi = (char *)x->stack; return YXML_PIEND; } 276 277 278static inline yxml_ret_t yxml_refstart(yxml_t *x, unsigned ch) { 279 (void) ch; 280 memset(x->data, 0, sizeof(x->data)); 281 x->reflen = 0; --- 11 unchanged lines hidden (view full) --- 293 294 295static yxml_ret_t yxml_refend(yxml_t *x, yxml_ret_t ret) { 296 unsigned char *r = (unsigned char *)x->data; 297 unsigned ch = 0; 298 if(*r == '#') { 299 if(r[1] == 'x') 300 for(r += 2; yxml_isHex((unsigned)*r); r++) | 274} 275static inline yxml_ret_t yxml_pivalend (yxml_t *x, unsigned ch) { (void) ch; yxml_popstack(x); x->pi = (char *)x->stack; return YXML_PIEND; } 276 277 278static inline yxml_ret_t yxml_refstart(yxml_t *x, unsigned ch) { 279 (void) ch; 280 memset(x->data, 0, sizeof(x->data)); 281 x->reflen = 0; --- 11 unchanged lines hidden (view full) --- 293 294 295static yxml_ret_t yxml_refend(yxml_t *x, yxml_ret_t ret) { 296 unsigned char *r = (unsigned char *)x->data; 297 unsigned ch = 0; 298 if(*r == '#') { 299 if(r[1] == 'x') 300 for(r += 2; yxml_isHex((unsigned)*r); r++) |
301 ch = (ch<<4) + (*r <= '9' ? *r-'0' : (*r|32)-'a' + 10); | 301 ch = (ch<<4) + ((*r <= '9') ? (*r-'0') : ((*r|32)-'a' + 10)); |
302 else 303 for(r++; yxml_isNum((unsigned)*r); r++) 304 ch = (ch*10) + (*r-'0'); 305 if(*r) 306 ch = 0; 307 } else { 308 uint64_t i = INTFROM5CHARS(r[0], r[1], r[2], r[3], r[4]); 309 ch = --- 39 unchanged lines hidden (view full) --- 349 * normalized to a single '\n' as per XML 1.0 section 2.11. XML 1.1 adds 350 * some non-ASCII character sequences to this list, but we can only handle 351 * ASCII here without making assumptions about the input encoding. */ 352 if(x->ignore == ch) { 353 x->ignore = 0; 354 return YXML_OK; 355 } 356 x->ignore = (ch == 0xd) * 0xa; | 302 else 303 for(r++; yxml_isNum((unsigned)*r); r++) 304 ch = (ch*10) + (*r-'0'); 305 if(*r) 306 ch = 0; 307 } else { 308 uint64_t i = INTFROM5CHARS(r[0], r[1], r[2], r[3], r[4]); 309 ch = --- 39 unchanged lines hidden (view full) --- 349 * normalized to a single '\n' as per XML 1.0 section 2.11. XML 1.1 adds 350 * some non-ASCII character sequences to this list, but we can only handle 351 * ASCII here without making assumptions about the input encoding. */ 352 if(x->ignore == ch) { 353 x->ignore = 0; 354 return YXML_OK; 355 } 356 x->ignore = (ch == 0xd) * 0xa; |
357 if(ch == 0xa || ch == 0xd) { | 357 if((ch == 0xa) || (ch == 0xd)) { |
358 ch = 0xa; 359 x->line++; 360 x->byte = 0; 361 } 362 x->byte++; 363 364 switch((yxml_state_t)x->state) { 365 case YXMLS_string: --- 700 unchanged lines hidden --- | 358 ch = 0xa; 359 x->line++; 360 x->byte = 0; 361 } 362 x->byte++; 363 364 switch((yxml_state_t)x->state) { 365 case YXMLS_string: --- 700 unchanged lines hidden --- |