diff liboctave/oct-rl-edit.c @ 3933:f9ea3dcf58ee

[project @ 2002-05-15 03:21:00 by jwe]
author jwe
date Wed, 15 May 2002 03:21:01 +0000
parents 7ab0e1a1b943
children eab957395758
line wrap: on
line diff
--- a/liboctave/oct-rl-edit.c	Tue May 07 18:10:44 2002 +0000
+++ b/liboctave/oct-rl-edit.c	Wed May 15 03:21:01 2002 +0000
@@ -33,6 +33,19 @@
 
 #include "oct-rl-edit.h"
 
+#define OCTAVE_RL_SAVE_STRING(ss, s) \
+  static char *ss = 0; \
+ \
+  if (ss) \
+    { \
+      free (ss); \
+      ss = 0; \
+    } \
+ \
+  ss = malloc (strlen (s) + 1); \
+ \
+  strcpy (ss, s)
+
 int
 octave_rl_screen_height (void)
 {
@@ -123,17 +136,7 @@
 void
 octave_rl_set_name (const char *n)
 {
-  static char *nm = 0;
-
-  if (nm)
-    {
-      free (nm);
-      nm = 0;
-    }
-
-  nm = malloc (strlen (n + 1));
-
-  strcpy (nm, n);
+  OCTAVE_RL_SAVE_STRING (nm, n);
 
   rl_readline_name = nm;
 
@@ -184,19 +187,25 @@
 }
 
 void
+octave_rl_set_basic_word_break_characters (const char *s)
+{
+  OCTAVE_RL_SAVE_STRING (ss, s);
+
+  rl_basic_word_break_characters = ss;
+}
+
+void
+octave_rl_set_completer_word_break_characters (const char *s)
+{
+  OCTAVE_RL_SAVE_STRING (ss, s);
+
+  rl_completer_word_break_characters = ss;
+}
+
+void
 octave_rl_set_basic_quote_characters (const char *s)
 {
-  static char *ss = 0;
-
-  if (ss)
-    {
-      free (ss);
-      ss = 0;
-    }
-
-  ss = malloc (strlen (s) + 1);
-
-  strcpy (ss, s);
+  OCTAVE_RL_SAVE_STRING (ss, s);
 
   rl_basic_quote_characters = ss;
 }