+
+ dbassert(! results[ct_Digit].match ); /* digits are supposedly unambiguous */
+
+ switch (fca->ctxmap) {
+
+#define RETURN_IF_LONGER(this,that) do{ \
+ if (results[ct_##this].rx > results[ct_##that].rx) \
+ return ct_##this; \
+ }while(0)
+
+ case ctf_Digit | ctf_Upper | ctf_Lower | ctf_Word:
+ /* Start of word. Prefer Word match; failing that, take the longest */
+ if (results[ct_Word].match) return ct_Word;
+ RETURN_IF_LONGER(Lower,Upper);
+ RETURN_IF_LONGER(Upper,Lower);
+ break;
+
+ case ctf_Digit | ctf_Upper | ctf_Lower:
+ /* Mid-word. Prefer longer match; failing that, match lower. */
+ RETURN_IF_LONGER(Upper,Lower);
+ return ct_Lower;
+ }