summaryrefslogtreecommitdiff
path: root/app/xterm/ptydata.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2008-03-19 21:15:47 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2008-03-19 21:15:47 +0000
commitdf8be2bf52dea73cda8e929f68e8636dc11e58f0 (patch)
tree0291a0d12c96b5d7bb91a4d2b0ee8efc700dad59 /app/xterm/ptydata.c
parent7b26eaf1c64d74443c5155fd127b7c16a7b5d1c8 (diff)
update to xterm 234. tested by merdely@, 'looks ok' deraadt@.
Diffstat (limited to 'app/xterm/ptydata.c')
-rw-r--r--app/xterm/ptydata.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/app/xterm/ptydata.c b/app/xterm/ptydata.c
index 641f0a4f0..055e51c82 100644
--- a/app/xterm/ptydata.c
+++ b/app/xterm/ptydata.c
@@ -1,4 +1,4 @@
-/* $XTermId: ptydata.c,v 1.74 2006/07/11 21:53:15 tom Exp $ */
+/* $XTermId: ptydata.c,v 1.79 2008/02/21 22:19:03 tom Exp $ */
/*
* $XFree86: xc/programs/xterm/ptydata.c,v 1.25 2006/02/13 01:14:59 dickey Exp $
@@ -6,7 +6,7 @@
/************************************************************
-Copyright 1999-2005,2006 by Thomas E. Dickey
+Copyright 1999-2006,2007 by Thomas E. Dickey
All Rights Reserved
@@ -62,7 +62,7 @@ authorization.
* Convert the 8-bit codes in data->buffer[] into Unicode in data->utf_data.
* The number of bytes converted will be nonzero iff there is data.
*/
-static Bool
+Bool
decodeUtf8(PtyData * data)
{
int i;
@@ -110,22 +110,21 @@ decodeUtf8(PtyData * data)
if (!utf_char && !((c & 0x7f) >> (7 - utf_count))) {
utf_char = UCS_REPL;
}
- /* characters outside UCS-2 become UCS_REPL */
- if (utf_char > 0x03ff) {
- /* value would be >0xffff */
- utf_char = UCS_REPL;
- } else {
- utf_char <<= 6;
- utf_char |= (c & 0x3f);
- }
+ utf_char <<= 6;
+ utf_char |= (c & 0x3f);
if ((utf_char >= 0xd800 &&
utf_char <= 0xdfff) ||
(utf_char == 0xfffe) ||
- (utf_char == 0xffff)) {
+ (utf_char == HIDDEN_CHAR)) {
utf_char = UCS_REPL;
}
utf_count--;
if (utf_count == 0) {
+ /* characters outside UCS-2 become UCS_REPL */
+ if (utf_char > 0xffff) {
+ TRACE(("using replacement for %#x\n", utf_char));
+ utf_char = UCS_REPL;
+ }
data->utf_data = utf_char;
data->utf_size = (i + 1);
break;
@@ -249,7 +248,7 @@ readPtyData(TScreen * screen, PtySelect * select_mask, PtyData * data)
*/
#if OPT_WIDE_CHARS
Bool
-morePtyData(TScreen * screen GCC_UNUSED, PtyData * data)
+morePtyData(TScreen * screen, PtyData * data)
{
Bool result = (data->last > data->next);
if (result && screen->utf8_inparse) {
@@ -272,9 +271,7 @@ nextPtyData(TScreen * screen, PtyData * data)
{
IChar result;
if (screen->utf8_inparse) {
- result = data->utf_data;
- data->next += data->utf_size;
- data->utf_size = 0;
+ result = skipPtyData(data);
} else {
result = *((data)->next++);
if (!screen->output_eight_bits)
@@ -283,6 +280,20 @@ nextPtyData(TScreen * screen, PtyData * data)
TRACE2(("nextPtyData returns %#x\n", result));
return result;
}
+
+/*
+ * Simply return the data and skip past it.
+ */
+IChar
+skipPtyData(PtyData * data)
+{
+ IChar result = data->utf_data;
+
+ data->next += data->utf_size;
+ data->utf_size = 0;
+
+ return result;
+}
#endif
#if OPT_WIDE_CHARS
@@ -302,6 +313,9 @@ switchPtyData(TScreen * screen, int flag)
}
#endif
+/*
+ * Allocate a buffer.
+ */
void
initPtyData(PtyData ** result)
{
@@ -329,6 +343,23 @@ initPtyData(PtyData ** result)
}
/*
+ * Initialize a buffer for the caller, using its data in 'source'.
+ */
+#if OPT_WIDE_CHARS
+PtyData *
+fakePtyData(PtyData * result, Char * next, Char * last)
+{
+ PtyData *data = result;
+
+ memset(data, 0, sizeof(*data));
+ data->next = next;
+ data->last = last;
+
+ return data;
+}
+#endif
+
+/*
* Remove used data by shifting the buffer down, to make room for more data,
* e.g., a continuation-read.
*/