- if (str_byte >= orig_str + 1)
- prev_c = (unsigned char)*(str_byte - 1);
- next_c = (unsigned char)*str_byte;
- pos = str_byte - orig_str;
- if (len < 0 || pos < len)
- str_byte++;
+ if (!found_high_bit)
+ {
+ if (str_byte >= orig_str + 1)
+ prev_c = (unsigned char)*(str_byte - 1);
+ next_c = (unsigned char)*str_byte;
+ pos = str_byte - orig_str;
+ if (len < 0 || pos < len)
+ str_byte++;
+ }
+ else
+ {
+ if (str_byte == orig_str)
+ goto no_first_optimization;
+ /*
+ * Back up one character, fix up the position, then call
+ * GET_NEXT_WCHAR() to process the multibyte character.
+ */
+ /* no need to set prev_c, since GET_NEXT_WCHAR will overwrite */
+ next_c = (unsigned char)*(str_byte - 1);
+ pos = (str_byte - 1) - orig_str;
+ GET_NEXT_WCHAR();
+ }