MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / actualMerge

Method actualMerge

src/jrd/Collation.cpp:870–973  ·  view source on GitHub ↗

Merge the matching pattern and control strings to give a cannonical matching pattern. Return the length of the combined string. What this routine does is to take the language template, strip off the prefix and put it in the output string, then parse the definitions into an array of character pointers. The index array is the defined character. The routine then takes the actual match pattern an

Source from the content-addressed store, hash-verified

868 // highest character defined (also max_op). Believe it or not, that part
869 // is not a bug.
870 static ULONG actualMerge(/*MemoryPool& pool,*/ Jrd::TextType* obj,
871 const CharType* match, SLONG match_bytes,
872 const CharType* control, SLONG control_bytes,
873 CharType* combined) //, SLONG combined_bytes)
874 {
875 fb_assert(match != NULL);
876 fb_assert(control != NULL);
877 fb_assert(combined != NULL);
878
879 fb_assert((match_bytes % sizeof(CharType)) == 0);
880 fb_assert((control_bytes % sizeof(CharType)) == 0);
881 fb_assert(obj->getCanonicalWidth() == sizeof(CharType));
882
883 const CharType* const end_match = match + (match_bytes / sizeof(CharType));
884 const CharType* const end_control = control + (control_bytes / sizeof(CharType));
885
886 CharType max_op = 0;
887 CharType* comb = combined;
888 CharType* vector[256];
889 CharType** v = vector;
890 CharType temp[256];
891 CharType* t = temp;
892
893 // Parse control string into substitution strings and initializing string
894
895 while (control < end_control)
896 {
897 CharType c = *control++;
898 if (*control == *(CharType*) obj->getCanonicalChar(CHAR_GDML_SUBSTITUTE))
899 {
900 // Note: don't allow substitution characters larger than vector
901 CharType** const end_vector = vector + (((int) c < FB_NELEM(vector)) ? c : 0);
902 while (v <= end_vector)
903 *v++ = 0;
904 *end_vector = t;
905 ++control;
906 while (control < end_control)
907 {
908 c = *control++;
909 if ((t > temp && t[-1] == *(CharType*) obj->getCanonicalChar(CHAR_GDML_QUOTE)) ||
910 ((c != *(CharType*) obj->getCanonicalChar(CHAR_GDML_COMMA)) &&
911 (c != *(CharType*) obj->getCanonicalChar(CHAR_GDML_RPAREN))))
912 {
913 *t++ = c;
914 }
915 else
916 break;
917 }
918 *t++ = 0;
919 }
920 else if (c == *(CharType*) obj->getCanonicalChar(CHAR_GDML_QUOTE) && control < end_control)
921 *comb++ = *control++;
922 else if (c == *(CharType*) obj->getCanonicalChar(CHAR_GDML_RPAREN))
923 break;
924 else if (c != *(CharType*) obj->getCanonicalChar(CHAR_GDML_LPAREN))
925 *comb++ = c;
926 }
927

Callers

nothing calls this directly

Calls 2

getCanonicalWidthMethod · 0.80
getCanonicalCharMethod · 0.80

Tested by

no test coverage detected