- dbassert(! results[ct_Digit].match );
- if (results[ct_Word].match) return ct_Word;
- if (results[ct_Lower].rx > results[ct_Upper].rx) return ct_Lower;
- if (results[ct_Upper].rx > results[ct_Lower].rx) return ct_Upper;
+ 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;
+ }
+
+ /* oh well */