summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwrog <wrog>2006-12-06 23:57:51 (GMT)
committerwrog <wrog>2006-12-06 23:57:51 (GMT)
commite6816f605d09158be5d5c904c71580688f0591ae (patch)
tree9eeac8cdb10f87ae3dfabd108b61ff9cc66ba8b2
parent0d13527d1f076fb37e7fbaa556c8d07a03fa0036 (diff)
downloadmoo-cvs-e6816f605d09158be5d5c904c71580688f0591ae.zip
moo-cvs-e6816f605d09158be5d5c904c71580688f0591ae.tar.gz
moo-cvs-e6816f605d09158be5d5c904c71580688f0591ae.tar.bz2
moo-cvs-e6816f605d09158be5d5c904c71580688f0591ae.tar.xz
New INPUT_APPLY_BACKSPACE option to process backspace/delete characters on nonbinary connections (patch 1571939)constants.updater.1
-rw-r--r--net_multi.c7
-rw-r--r--net_single.c7
-rw-r--r--options.h12
-rw-r--r--streams.c10
-rw-r--r--streams.h4
5 files changed, 40 insertions, 0 deletions
diff --git a/net_multi.c b/net_multi.c
index 9e54c71..a506a09 100644
--- a/net_multi.c
+++ b/net_multi.c
@@ -274,6 +274,10 @@ pull_input(nhandle * h)
if (isgraph(c) || c == ' ' || c == '\t')
stream_add_char(s, c);
+#ifdef INPUT_APPLY_BACKSPACE
+ else if (c == 0x08 || c == 0x7F)
+ stream_delete_char(s);
+#endif
else if (c == '\r' || (c == '\n' && !h->last_input_was_CR))
server_receive_line(h->shandle, reset_stream(s));
@@ -700,6 +704,9 @@ char rcsid_net_multi[] = "$Id$";
/*
* $Log$
+ * Revision 1.6 2006/12/06 23:57:51 wrog
+ * New INPUT_APPLY_BACKSPACE option to process backspace/delete characters on nonbinary connections (patch 1571939)
+ *
* Revision 1.5 2005/09/29 18:46:17 bjj
* Add third argument to open_network_connection() that associates a specific listener object with the new connection. This simplifies a lot of outbound connection management.
*
diff --git a/net_single.c b/net_single.c
index 366870c..34265ce 100644
--- a/net_single.c
+++ b/net_single.c
@@ -204,6 +204,10 @@ network_process_io(int timeout)
if (isgraph(c) || c == ' ' || c == '\t')
stream_add_char(s, c);
+#ifdef INPUT_APPLY_BACKSPACE
+ else if (c == 0x08 || c == 0x7F)
+ stream_delete_char(s);
+#endif
else if (c == '\n')
server_receive_line(sh, reset_stream(s));
}
@@ -225,6 +229,9 @@ char rcsid_net_single[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2006/12/06 23:57:51 wrog
+ * New INPUT_APPLY_BACKSPACE option to process backspace/delete characters on nonbinary connections (patch 1571939)
+ *
* Revision 1.3 2004/05/22 01:25:44 wrog
* merging in WROGUE changes (W_SRCIP, W_STARTUP, W_OOB)
*
diff --git a/options.h b/options.h
index 310e65b..02a23fc 100644
--- a/options.h
+++ b/options.h
@@ -207,6 +207,15 @@
#define DEFAULT_CONNECT_TIMEOUT 300
/******************************************************************************
+ * On connections that have not been set to binary mode, the server normally
+ * discards incoming characters that are not printable ASCII, including
+ * backspace (8) and delete(127). If INPUT_APPLY_BACKSPACE is defined,
+ * backspace and delete cause the preceding character (if any) to be removed
+ * from the input stream. (Comment this out to restore pre-1.8.3 behavior)
+ */
+#define INPUT_APPLY_BACKSPACE
+
+/******************************************************************************
* The server maintains a cache of the most recently used patterns from calls
* to the match() and rmatch() built-in functions. PATTERN_CACHE_SIZE controls
* how many past patterns are remembered by the server. Do not set it to a
@@ -391,6 +400,9 @@
/*
* $Log$
+ * Revision 1.11 2006/12/06 23:57:51 wrog
+ * New INPUT_APPLY_BACKSPACE option to process backspace/delete characters on nonbinary connections (patch 1571939)
+ *
* Revision 1.10 2006/09/07 00:55:02 bjj
* Add new MEMO_STRLEN option which uses the refcounting mechanism to
* store strlen with strings. This is basically free, since most string
diff --git a/streams.c b/streams.c
index ca318e3..a3b8ef0 100644
--- a/streams.c
+++ b/streams.c
@@ -59,6 +59,13 @@ stream_add_char(Stream * s, char c)
}
void
+stream_delete_char(Stream * s)
+{
+ if (s->current > 0)
+ s->current--;
+}
+
+void
stream_add_string(Stream * s, const char *string)
{
int len = strlen(string);
@@ -231,6 +238,9 @@ char rcsid_streams[] = "$Id$";
/*
* $Log$
+ * Revision 1.4 2006/12/06 23:57:51 wrog
+ * New INPUT_APPLY_BACKSPACE option to process backspace/delete characters on nonbinary connections (patch 1571939)
+ *
* Revision 1.3 1998/12/14 13:19:01 nop
* Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
*
diff --git a/streams.h b/streams.h
index c2d6a9b..699885f 100644
--- a/streams.h
+++ b/streams.h
@@ -28,6 +28,7 @@ typedef struct {
extern Stream *new_stream(int size);
extern void stream_add_char(Stream *, char);
+extern void stream_delete_char(Stream *);
extern void stream_add_string(Stream *, const char *);
extern void stream_printf(Stream *, const char *,...);
extern void free_stream(Stream *);
@@ -39,6 +40,9 @@ extern int stream_length(Stream *);
/*
* $Log$
+ * Revision 1.4 2006/12/06 23:57:51 wrog
+ * New INPUT_APPLY_BACKSPACE option to process backspace/delete characters on nonbinary connections (patch 1571939)
+ *
* Revision 1.3 1998/12/14 13:19:02 nop
* Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
*