| 653 | } |
| 654 | |
| 655 | void* fxCharSetCombine(txPatternParser* parser, txCharSet* set1, txCharSet* set2, txInteger op) |
| 656 | { |
| 657 | txInteger flag = 0; |
| 658 | txInteger old = 0; |
| 659 | txInteger* current1 = set1->characters + 1; |
| 660 | txInteger* limit1 = current1 + set1->characters[0]; |
| 661 | txInteger* current2 = set2->characters + 1; |
| 662 | txInteger* limit2 = current2 + set2->characters[0]; |
| 663 | txCharSet* result = fxPatternParserCreateTerm(parser, sizeof(txCharSet) + ((set1->characters[0] + set2->characters[0]) * sizeof(txInteger)), fxCharSetMeasure); |
| 664 | txInteger count0 = 0; |
| 665 | txInteger* current0 = result->characters + 1; |
| 666 | while ((current1 < limit1) && (current2 < limit2)) { |
| 667 | txInteger test = *current1 - *current2; |
| 668 | txInteger character; |
| 669 | if (test <= 0) { |
| 670 | character = *current1; |
| 671 | flag ^= 1; |
| 672 | current1++; |
| 673 | } |
| 674 | if (test >= 0) { |
| 675 | character = *current2; |
| 676 | flag ^= 2; |
| 677 | current2++; |
| 678 | } |
| 679 | if ((flag == op) || (old == op)) { |
| 680 | count0++; |
| 681 | *current0++ = character; |
| 682 | } |
| 683 | old = flag; |
| 684 | } |
| 685 | if ((op & 2) == 0) { |
| 686 | while (current1 < limit1) { |
| 687 | count0++; |
| 688 | *current0++ = *current1++; |
| 689 | } |
| 690 | } |
| 691 | if ((op & 1) == 0) { |
| 692 | while (current2 < limit2) { |
| 693 | count0++; |
| 694 | *current0++ = *current2++; |
| 695 | } |
| 696 | } |
| 697 | result->stringCount = 0; |
| 698 | result->strings = C_NULL; |
| 699 | result->characters[0] = count0; |
| 700 | if (set1->strings && set2->strings) { |
| 701 | txInteger count1 = set1->stringCount; |
| 702 | txInteger count2 = set2->stringCount; |
| 703 | txInteger index1 = 0; |
| 704 | txInteger index2 = 0; |
| 705 | txInteger count = 0; |
| 706 | txString string1 = set1->strings[index1]; |
| 707 | txString string2 = set2->strings[index2]; |
| 708 | txInteger length1 = fxUnicodeLength(string1, C_NULL); |
| 709 | txInteger length2 = fxUnicodeLength(string2, C_NULL); |
| 710 | if (op == mxCharSetUnionOp) |
| 711 | count = count1 + count2; |
| 712 | else if (op == mxCharSetSubtractOp) |
no test coverage detected