/****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insch.c,v 1.24 2005/02/26 19:27:28 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.27 2009/04/18 23:53:33 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
NCURSES_CH_T wch;
int count;
NCURSES_CONST char *s;
-
+#if NCURSES_SP_FUNCS || USE_REENTRANT
+ SCREEN *sp = _nc_screen_of(win);
+#endif
+ int tabsize =
+#if USE_REENTRANT
+ sp->_TABSIZE
+#else
+ TABSIZE
+#endif
+ ;
switch (ch) {
case '\t':
- for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--) {
+ for (count = (tabsize - (win->_curx % tabsize)); count > 0; count--) {
if ((code = _nc_insert_ch(win, ' ')) != OK)
break;
}
win->_curx++;
}
} else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
- s = unctrl(ChCharOf(ch));
+ s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch));
while (*s != '\0') {
- if ((code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s))) != OK)
+ code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
+ if (code != OK)
break;
++s;
}
*/
SetChar2(wch, ch);
wch = _nc_render(win, wch);
- if (_nc_build_wch(win, &wch) >= 0)
+ count = _nc_build_wch(win, &wch);
+ if (count > 0) {
code = wins_wch(win, &wch);
+ } else if (count == -1) {
+ /* handle EILSEQ */
+ if (is8bits(ch)) {
+ s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx ChCharOf(ch));
+ while (*s != '\0') {
+ code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s));
+ if (code != OK)
+ break;
+ ++s;
+ }
+ } else {
+ code = ERR;
+ }
+ }
}
#endif
break;