On 4/30/20 2:15 PM, Fabian Maurer wrote:
Hello Zebediah,
Could be, though I'd warn that attempts to reduce duplication (e.g. by introducing complicated macros) can often make code much less readable.
Sure, but in this case it should be very well worth it.
Okay, I'm not sure I'm reading this macro right, but this is all internal to diacritic weights, right? If I understand, final weights which are 1 or 0 get stripped from the end of the sortkey, right? I think you could easily handle that by stripping weights after adding all of the diacritics, e.g. to use my previous example code,
if (!(flags & NORM_IGNORENONSPACE)) { for (i = 0; i < srclen; ++i) used += get_diacritic_weights(src[i], dst + used, dstlen - used);
while (dst[used - 1] < 2) used--;
}
Generally, yes. But it not only affects diacritics. And one needs to keep in mind that the separator is also a 0 and must not be removed. But maybe here the duplication is worth it?
Sure, you'd need to guard a lower bound for "used" there in any case.
Regards, Fabian Maurer