width = 1;
if (!width)
width = (term->cjk_ambig_wide ?
- mk_wcwidth_cjk((wchar_t) c) :
- mk_wcwidth((wchar_t) c));
+ mk_wcwidth_cjk((unsigned int) c) :
+ mk_wcwidth((unsigned int) c));
if (term->wrapnext && term->wrap && width > 0) {
cline->lattr |= LATTR_WRAPPED;
}
term->wcFrom[it].origwc = term->wcFrom[it].wc =
- (wchar_t)uc;
+ (unsigned int)uc;
term->wcFrom[it].index = it;
}
dirty_run = TRUE;
}
- if (ccount >= chlen) {
+ if (ccount+2 > chlen) {
chlen = ccount + 256;
ch = sresize(ch, chlen, wchar_t);
}
+
+#ifdef PLATFORM_IS_UTF16
+ if (tchar > 0x10000 && tchar < 0x110000) {
+ ch[ccount++] = (wchar_t) HIGH_SURROGATE_OF(tchar);
+ ch[ccount++] = (wchar_t) LOW_SURROGATE_OF(tchar);
+ } else
+#endif /* PLATFORM_IS_UTF16 */
ch[ccount++] = (wchar_t) tchar;
if (d->cc_next) {
break;
}
- if (ccount >= chlen) {
+ if (ccount+2 > chlen) {
chlen = ccount + 256;
ch = sresize(ch, chlen, wchar_t);
}
+
+#ifdef PLATFORM_IS_UTF16
+ if (schar > 0x10000 && schar < 0x110000) {
+ ch[ccount++] = (wchar_t) HIGH_SURROGATE_OF(schar);
+ ch[ccount++] = (wchar_t) LOW_SURROGATE_OF(schar);
+ } else
+#endif /* PLATFORM_IS_UTF16 */
ch[ccount++] = (wchar_t) schar;
}
{
int i;
for (i = 0; i < (int)p->n_prompts; i++)
- memset(p->prompts[i]->result, 0, p->prompts[i]->result_len);
+ prompt_set_result(p->prompts[i], "");
}
}
case 10:
case 13:
term_data(term, 0, "\r\n", 2);
+ prompt_ensure_result_size(pr, s->pos + 1);
pr->result[s->pos] = '\0';
- pr->result[pr->result_len - 1] = '\0';
/* go to next prompt, if any */
s->curr_prompt++;
s->done_prompt = 0;
* when we're doing password input, because some people
* have control characters in their passwords.
*/
- if ((!pr->echo ||
- (c >= ' ' && c <= '~') ||
- ((unsigned char) c >= 160))
- && s->pos < pr->result_len - 1) {
+ if (!pr->echo || (c >= ' ' && c <= '~') ||
+ ((unsigned char) c >= 160)) {
+ prompt_ensure_result_size(pr, s->pos + 1);
pr->result[s->pos++] = c;
if (pr->echo)
term_data(term, 0, &c, 1);