static void
cpstripped(char **start, char *end, char *str)
{
+#ifdef MULTIBYTE_SUPPORT
+ int char_len; /* bytes in current character */
+ int nbytes;
+ wchar_t wide_char;
+#else
int c;
+#endif
char *s = str;
if (!s)
return;
/* skip any initial control characters or spaces */
+#ifdef MULTIBYTE_SUPPORT
+ nbytes = end - *start + 1;
+ mbtowc(NULL, NULL, 0); /* reset shift state */
+ while ((char_len = mbtowc(&wide_char, s, nbytes)) > 0 && (iswcntrl(wide_char) || iswspace(wide_char))) {
+ s += char_len;
+ nbytes -= char_len;
+ }
+#else
while ((c = (unsigned char) *s) && (iscntrl(c) || isspace(c)))
s++;
+#endif
/* compact repeated control characters and spaces into a single space */
+#ifdef MULTIBYTE_SUPPORT
+ while ((char_len = mbtowc(&wide_char, s, nbytes)) > 0 && *start < end) {
+ if (!iswcntrl(wide_char) && !iswspace(wide_char)) {
+ strncpy(*start, s, char_len);
+ s += char_len;
+ *start += char_len;
+ nbytes -= char_len;
+ } else {
+ while ((char_len = mbtowc(&wide_char, s, nbytes)) > 0 && (iswcntrl(wide_char) || iswspace(wide_char))) {
+ s += char_len;
+ nbytes -= char_len;
+ }
+ *(*start)++ = ' ';
+ }
+ }
+#else
while((c = (unsigned char) *s++) && *start < end)
if (!iscntrl(c) && !isspace(c))
*(*start)++ = c;
s++;
*(*start)++ = ' ';
}
+#endif
}
static char *lmonth[] = {