| … | |
… | |
| 431 | + size_t mblength = 1; |
431 | + size_t mblength = 1; |
| 432 | + mbstate_t state, state_bak; |
432 | + mbstate_t state, state_bak; |
| 433 | + |
433 | + |
| 434 | + memset (&state, 0, sizeof (mbstate_t)); |
434 | + memset (&state, 0, sizeof (mbstate_t)); |
| 435 | + |
435 | + |
| 436 | + if (ptr == lim) |
436 | + if (ptr >= lim) |
| 437 | + return; |
437 | + return; |
| 438 | + |
438 | + |
| 439 | + if (tab != NULL) |
439 | + if (tab != NULL) |
| 440 | + { |
440 | + { |
| 441 | + unsigned char t = tab[0]; |
441 | + unsigned char t = tab[0]; |
| … | |
… | |
| 462 | + sep += mblength; |
462 | + sep += mblength; |
| 463 | + continue; |
463 | + continue; |
| 464 | + } |
464 | + } |
| 465 | + } |
465 | + } |
| 466 | + |
466 | + |
| 467 | + if (sep == lim) |
467 | + if (sep >= lim) |
| 468 | + break; |
468 | + break; |
| 469 | + |
469 | + |
| 470 | + extract_field (line, ptr, sep - ptr); |
470 | + extract_field (line, ptr, sep - ptr); |
| 471 | + } |
471 | + } |
| 472 | + } |
472 | + } |
| … | |
… | |
| 503 | + break; |
503 | + break; |
| 504 | + } |
504 | + } |
| 505 | + mblength = (mblength < 1) ? 1 : mblength; |
505 | + mblength = (mblength < 1) ? 1 : mblength; |
| 506 | + |
506 | + |
| 507 | + sep = ptr + mblength; |
507 | + sep = ptr + mblength; |
| 508 | + while (sep != lim) |
508 | + while (sep < lim) |
| 509 | + { |
509 | + { |
| 510 | + state_bak = state; |
510 | + state_bak = state; |
| 511 | + mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); |
511 | + mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); |
| 512 | + if (mblength == (size_t)-1 || mblength == (size_t)-2) |
512 | + if (mblength == (size_t)-1 || mblength == (size_t)-2) |
| 513 | + { |
513 | + { |
| … | |
… | |
| 522 | + |
522 | + |
| 523 | + sep += mblength; |
523 | + sep += mblength; |
| 524 | + } |
524 | + } |
| 525 | + |
525 | + |
| 526 | + extract_field (line, ptr, sep - ptr); |
526 | + extract_field (line, ptr, sep - ptr); |
| 527 | + if (sep == lim) |
527 | + if (sep >= lim) |
| 528 | + return; |
528 | + return; |
| 529 | + |
529 | + |
| 530 | + state_bak = state; |
530 | + state_bak = state; |
| 531 | + mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); |
531 | + mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); |
| 532 | + if (mblength == (size_t)-1 || mblength == (size_t)-2) |
532 | + if (mblength == (size_t)-1 || mblength == (size_t)-2) |
| … | |
… | |
| 536 | + break; |
536 | + break; |
| 537 | + } |
537 | + } |
| 538 | + mblength = (mblength < 1) ? 1 : mblength; |
538 | + mblength = (mblength < 1) ? 1 : mblength; |
| 539 | + |
539 | + |
| 540 | + ptr = sep + mblength; |
540 | + ptr = sep + mblength; |
| 541 | + while (ptr != lim) |
541 | + while (ptr < lim) |
| 542 | + { |
542 | + { |
| 543 | + state_bak = state; |
543 | + state_bak = state; |
| 544 | + mblength = mbrtowc (&wc, ptr, lim - ptr + 1, &state); |
544 | + mblength = mbrtowc (&wc, ptr, lim - ptr + 1, &state); |
| 545 | + if (mblength == (size_t)-1 || mblength == (size_t)-2) |
545 | + if (mblength == (size_t)-1 || mblength == (size_t)-2) |
| 546 | + { |
546 | + { |
| … | |
… | |
| 554 | + break; |
554 | + break; |
| 555 | + |
555 | + |
| 556 | + ptr += mblength; |
556 | + ptr += mblength; |
| 557 | + } |
557 | + } |
| 558 | + } |
558 | + } |
| 559 | + while (ptr != lim); |
559 | + while (ptr < lim); |
| 560 | + } |
560 | + } |
| 561 | + |
561 | + |
| 562 | + extract_field (line, ptr, lim - ptr); |
562 | + extract_field (line, ptr, lim - ptr); |
| 563 | +} |
563 | +} |
| 564 | +#endif |
564 | +#endif |