changeset 7528:26d8a92644de

try to avoid ctype macro problems
author John W. Eaton <jwe@octave.org>
date Mon, 25 Feb 2008 15:57:49 -0500
parents d219e712c20e
children 7e1b042c5418
files src/ChangeLog src/mappers.cc src/ov-base.cc src/ov-base.h src/ov-str-mat.cc src/ov-str-mat.h src/ov.h src/strfns.cc
diffstat 8 files changed, 188 insertions(+), 498 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/ChangeLog	Mon Feb 25 15:57:49 2008 -0500
@@ -1,5 +1,17 @@
 2008-02-25  John W. Eaton  <jwe@octave.org>
 
+	* ov-base.cc (UNDEFINED_MAPPER, STRING_MAPPER): New macros.  Use
+	them to define mapper functions.
+
+	* mappers.cc (Fisalnum, Fisalpha, Fisascii, Fiscntrl, Fisdigit,
+	Fisgraph, Fislower, Fisprint, Fispunct, Fisspace, Fisupper,
+	Fisxdigit, Ftoascii, Ftolower, Ftoupper):
+	Use DEFUNX to define ctype mapper functions.
+	Use new function names.
+
+	* ov-base.h, ov-base.cc, ov-str-mat.h, ov-str-mat.cc:
+	Prepend x to ctype mapper function names.
+
 	* graphics.h.in (row_vector_property::row_vector_property):
 	Set default constraints here.
 	(row_vector_property::add_constraint): New function.
--- a/src/mappers.cc	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/mappers.cc	Mon Feb 25 15:57:49 2008 -0500
@@ -468,7 +468,7 @@
   return retval;
 }
 
-DEFUN (isalnum, args, ,
+DEFUNX ("isalnum", Fisalnum, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isalnum (@var{s})\n\
 Return 1 for characters that are letters or digits (@code{isalpha\n\
@@ -477,14 +477,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isalnum ();
+    retval = args(0).xisalnum ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (isalpha, args, ,
+DEFUNX ("isalpha", Fisalpha, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isalpha (@var{s})\n\
 @deftypefnx {Mapping Function} {} isletter (@var{s})\n\
@@ -494,18 +494,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isalpha ();
+    retval = args(0).xisalpha ();
   else
     print_usage ();
 
   return retval;
 }
 
-#ifdef isascii
-#undef isascii
-#endif
-
-DEFUN (isascii, args, ,
+DEFUNX ("isascii", Fisascii, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isascii (@var{s})\n\
 Return 1 for characters that are ASCII (in the range 0 to 127 decimal).\n\
@@ -513,14 +509,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isascii ();
+    retval = args(0).xisascii ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (iscntrl, args, ,
+DEFUNX ("iscntrl", Fiscntrl, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} iscntrl (@var{s})\n\
 Return 1 for control characters.\n\
@@ -528,14 +524,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).iscntrl ();
+    retval = args(0).xiscntrl ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (isdigit, args, ,
+DEFUNX ("isdigit", Fisdigit, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isdigit (@var{s})\n\
 Return 1 for characters that are decimal digits.\n\
@@ -543,7 +539,7 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isdigit ();
+    retval = args(0).xisdigit ();
   else
     print_usage ();
 
@@ -573,7 +569,7 @@
   return retval;
 }
 
-DEFUN (isgraph, args, ,
+DEFUNX ("isgraph", Fisgraph, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isgraph (@var{s})\n\
 Return 1 for printable characters (but not the space character).\n\
@@ -581,14 +577,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isgraph ();
+    retval = args(0).xisgraph ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (islower, args, ,
+DEFUNX ("islower", Fislower, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} islower (@var{s})\n\
 Return 1 for characters that are lower case letters.\n\
@@ -596,7 +592,7 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).islower ();
+    retval = args(0).xislower ();
   else
     print_usage ();
 
@@ -649,7 +645,7 @@
   return retval;
 }
 
-DEFUN (isprint, args, ,
+DEFUNX ("isprint", Fisprint, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isprint (@var{s})\n\
 Return 1 for printable characters (including the space character).\n\
@@ -657,14 +653,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isprint ();
+    retval = args(0).xisprint ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (ispunct, args, ,
+DEFUNX ("ispunct", Fispunct, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} ispunct (@var{s})\n\
 Return 1 for punctuation characters.\n\
@@ -672,14 +668,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).ispunct ();
+    retval = args(0).xispunct ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (isspace, args, ,
+DEFUNX ("isspace", Fisspace, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isspace (@var{s})\n\
 Return 1 for whitespace characters (space, formfeed, newline,\n\
@@ -688,14 +684,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isspace ();
+    retval = args(0).xisspace ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (isupper, args, ,
+DEFUNX ("isupper", Fisupper, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isupper (@var{s})\n\
 Return 1 for upper case letters.\n\
@@ -703,14 +699,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isupper ();
+    retval = args(0).xisupper ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (isxdigit, args, ,
+DEFUNX ("isxdigit", Fisxdigit, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} isxdigit (@var{s})\n\
 Return 1 for characters that are hexadecimal digits.\n\
@@ -718,7 +714,7 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).isxdigit ();
+    retval = args(0).xisxdigit ();
   else
     print_usage ();
 
@@ -918,11 +914,7 @@
   return retval;
 }
 
-#ifdef toascii
-#undef toascii
-#endif
-
-DEFUN (toascii, args, ,
+DEFUNX ("toascii", Ftoascii, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} toascii (@var{s})\n\
 Return ASCII representation of @var{s} in a matrix.  For example,\n\
@@ -938,14 +930,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).toascii ();
+    retval = args(0).xtoascii ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (tolower, args, ,
+DEFUNX ("tolower", Ftolower, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} tolower (@var{s})\n\
 Return a copy of the string @var{s}, with each upper-case character\n\
@@ -960,14 +952,14 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).tolower ();
+    retval = args(0).xtolower ();
   else
     print_usage ();
 
   return retval;
 }
 
-DEFUN (toupper, args, ,
+DEFUNX ("toupper", Ftoupper, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} toupper (@var{s})\n\
 Return a copy of the string @var{s}, with each  lower-case character\n\
@@ -984,7 +976,7 @@
 {
   octave_value retval;
   if (args.length () == 1)
-    retval = args(0).toupper ();
+    retval = args(0).xtoupper ();
   else
     print_usage ();
 
--- a/src/ov-base.cc	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/ov-base.cc	Mon Feb 25 15:57:49 2008 -0500
@@ -895,401 +895,75 @@
   return octave_value();
 }
 
-octave_value
-octave_base_value::abs (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::abs ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::acos (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::acos ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::acosh (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::acosh ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::angle (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::angle ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::arg (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::arg ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::asin (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::asin ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::asinh (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::asinh ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::atan (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::atan ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::atanh (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::atanh ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::ceil (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::ceil ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::conj (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::conj ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::cos (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::cos ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::cosh (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::cosh ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::erf (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::erf ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::erfc (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::erfc ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::exp (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::exp ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::finite (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::finite ()", type_name ());
-  return octave_value ();
-}
+#define UNDEFINED_MAPPER(F) \
+  octave_value \
+  octave_base_value::F (void) const \
+  { \
+    gripe_wrong_type_arg ("octave_base_value::" #F " ()", type_name ()); \
+    return octave_value (); \
+  }
 
-octave_value
-octave_base_value::fix (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::fix ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::floor (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::floor ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::gamma (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::gamma ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::imag (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::imag ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::isinf (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::isinf ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::isna (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::isna ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::isnan (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::isnan ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::lgamma (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::lgamma ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::log (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::log ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::log10 (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::log10 ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::real (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::real ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::round (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::round ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::signum (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::signum ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::sin (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::sin ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::sinh (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::sinh ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::sqrt (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::sqrt ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::tan (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::tan ()", type_name ());
-  return octave_value ();
-}
-
-octave_value
-octave_base_value::tanh (void) const
-{
-  gripe_wrong_type_arg ("octave_base_value::tanh ()", type_name ());
-  return octave_value ();
-}
+UNDEFINED_MAPPER (abs)
+UNDEFINED_MAPPER (acos)
+UNDEFINED_MAPPER (acosh)
+UNDEFINED_MAPPER (angle)
+UNDEFINED_MAPPER (arg)
+UNDEFINED_MAPPER (asin)
+UNDEFINED_MAPPER (asinh)
+UNDEFINED_MAPPER (atan)
+UNDEFINED_MAPPER (atanh)
+UNDEFINED_MAPPER (ceil)
+UNDEFINED_MAPPER (conj)
+UNDEFINED_MAPPER (cos)
+UNDEFINED_MAPPER (cosh)
+UNDEFINED_MAPPER (erf)
+UNDEFINED_MAPPER (erfc)
+UNDEFINED_MAPPER (exp)
+UNDEFINED_MAPPER (finite)
+UNDEFINED_MAPPER (fix)
+UNDEFINED_MAPPER (floor)
+UNDEFINED_MAPPER (gamma)
+UNDEFINED_MAPPER (imag)
+UNDEFINED_MAPPER (isinf)
+UNDEFINED_MAPPER (isna)
+UNDEFINED_MAPPER (isnan)
+UNDEFINED_MAPPER (lgamma)
+UNDEFINED_MAPPER (log)
+UNDEFINED_MAPPER (log10)
+UNDEFINED_MAPPER (real)
+UNDEFINED_MAPPER (round)
+UNDEFINED_MAPPER (signum)
+UNDEFINED_MAPPER (sin)
+UNDEFINED_MAPPER (sinh)
+UNDEFINED_MAPPER (sqrt)
+UNDEFINED_MAPPER (tan)
+UNDEFINED_MAPPER (tanh)
 
 // String mapper functions, convert to a string
-octave_value
-octave_base_value::isalnum (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isalnum ();
-  else
-    return octave_value ();
-}
 
-octave_value
-octave_base_value::isalpha (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isalpha ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::isascii (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isascii ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::iscntrl (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.iscntrl ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::isdigit (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isdigit ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::isgraph (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isgraph ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::islower (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.islower ();
-  else
-    return octave_value ();
-}
+#define STRING_MAPPER(F) \
+  octave_value \
+  octave_base_value::F (void) const \
+  { \
+    octave_value tmp = octave_value (char_array_value (true), true); \
+    return error_state ? octave_value () : octave_value (tmp.F ()); \
+  }
 
-octave_value
-octave_base_value::isprint (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isprint ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::ispunct (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.ispunct ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::isspace (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isspace ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::isupper (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isupper ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::isxdigit (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.isxdigit ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::toascii (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.toascii ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::tolower (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.tolower ();
-  else
-    return octave_value ();
-}
-
-octave_value
-octave_base_value::toupper (void) const
-{
-  octave_value tmp = octave_value (char_array_value (true), true);
-  if (! error_state)
-    return tmp.toupper ();
-  else
-    return octave_value ();
-}
+STRING_MAPPER (xisalnum)
+STRING_MAPPER (xisalpha)
+STRING_MAPPER (xisascii)
+STRING_MAPPER (xiscntrl)
+STRING_MAPPER (xisdigit)
+STRING_MAPPER (xisgraph)
+STRING_MAPPER (xislower)
+STRING_MAPPER (xisprint)
+STRING_MAPPER (xispunct)
+STRING_MAPPER (xisspace)
+STRING_MAPPER (xisupper)
+STRING_MAPPER (xisxdigit)
+STRING_MAPPER (xtoascii)
+STRING_MAPPER (xtolower)
+STRING_MAPPER (xtoupper)
 
 void
 octave_base_value::lock (void)
--- a/src/ov-base.h	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/ov-base.h	Mon Feb 25 15:57:49 2008 -0500
@@ -503,21 +503,25 @@
   virtual octave_value sqrt (void) const;
   virtual octave_value tan (void) const;
   virtual octave_value tanh (void) const;
-  virtual octave_value isalnum (void) const;
-  virtual octave_value isalpha (void) const;
-  virtual octave_value isascii (void) const;
-  virtual octave_value iscntrl (void) const;
-  virtual octave_value isdigit (void) const;
-  virtual octave_value isgraph (void) const;
-  virtual octave_value islower (void) const;
-  virtual octave_value isprint (void) const;
-  virtual octave_value ispunct (void) const;
-  virtual octave_value isspace (void) const;
-  virtual octave_value isupper (void) const;
-  virtual octave_value isxdigit (void) const;
-  virtual octave_value toascii (void) const;
-  virtual octave_value tolower (void) const;
-  virtual octave_value toupper (void) const;
+
+  // These functions are prefixed with X to avoid potential macro
+  // conflicts.
+
+  virtual octave_value xisalnum (void) const;
+  virtual octave_value xisalpha (void) const;
+  virtual octave_value xisascii (void) const;
+  virtual octave_value xiscntrl (void) const;
+  virtual octave_value xisdigit (void) const;
+  virtual octave_value xisgraph (void) const;
+  virtual octave_value xislower (void) const;
+  virtual octave_value xisprint (void) const;
+  virtual octave_value xispunct (void) const;
+  virtual octave_value xisspace (void) const;
+  virtual octave_value xisupper (void) const;
+  virtual octave_value xisxdigit (void) const;
+  virtual octave_value xtoascii (void) const;
+  virtual octave_value xtolower (void) const;
+  virtual octave_value xtoupper (void) const;
 
 protected:
 
--- a/src/ov-str-mat.cc	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/ov-str-mat.cc	Mon Feb 25 15:57:49 2008 -0500
@@ -25,6 +25,8 @@
 #include <config.h>
 #endif
 
+#include <cctype>
+
 #include <iostream>
 #include <vector>
 
@@ -772,44 +774,45 @@
 
 #endif
 
-#define MACRO_WRAPPER(FCN) \
-  static int x ## FCN (int c) { return FCN (c); }
+#define MACRO_WRAPPER(FCN, CTYPE_FCN) \
+  static int x ## FCN (int c) { return CTYPE_FCN (c); }
 
-#define STRING_MAPPER(MAP, AMAP, FCN) \
-  MACRO_WRAPPER (FCN) \
+#define STRING_MAPPER(FCN, AMAP, CTYPE_FCN) \
+  MACRO_WRAPPER (FCN, CTYPE_FCN) \
+ \
   octave_value \
-  octave_char_matrix_str::MAP (void) const \
+  octave_char_matrix_str::FCN (void) const \
   { \
     static charNDArray::mapper smap = x ## FCN; \
     return matrix.AMAP (smap);  \
   }
 
-#define TOSTRING_MAPPER(MAP, AMAP, FCN) \
-  MACRO_WRAPPER (FCN) \
+#define TOSTRING_MAPPER(FCN, AMAP, CTYPE_FCN) \
+  MACRO_WRAPPER (FCN, CTYPE_FCN) \
  \
   octave_value \
-  octave_char_matrix_str::MAP (void) const \
+  octave_char_matrix_str::FCN (void) const \
   { \
     static charNDArray::mapper smap = x ## FCN; \
-    return (is_sq_string () ? octave_value (matrix.AMAP (smap), true, '\'') : \
-	    octave_value (matrix.AMAP (smap), true)); \
+    return octave_value (matrix.AMAP (smap), true, \
+			 is_sq_string () ? '\'' : '"'); \
   }
 
-STRING_MAPPER (isalnum, bmap, isalnum)
-STRING_MAPPER (isalpha, bmap, isalpha)
-STRING_MAPPER (isascii, bmap, isascii)
-STRING_MAPPER (iscntrl, bmap, iscntrl)
-STRING_MAPPER (isdigit, bmap, isdigit)
-STRING_MAPPER (isgraph, bmap, isgraph)
-STRING_MAPPER (islower, bmap, islower)
-STRING_MAPPER (isprint, bmap, isprint)
-STRING_MAPPER (ispunct, bmap, ispunct)
-STRING_MAPPER (isspace, bmap, isspace)
-STRING_MAPPER (isupper, bmap, isupper)
-STRING_MAPPER (isxdigit, bmap, isxdigit)
-STRING_MAPPER (toascii, dmap, toascii)
-TOSTRING_MAPPER (tolower, smap, tolower)
-TOSTRING_MAPPER (toupper, smap, toupper)
+STRING_MAPPER (xisalnum, bmap, isalnum)
+STRING_MAPPER (xisalpha, bmap, isalpha)
+STRING_MAPPER (xisascii, bmap, isascii)
+STRING_MAPPER (xiscntrl, bmap, iscntrl)
+STRING_MAPPER (xisdigit, bmap, isdigit)
+STRING_MAPPER (xisgraph, bmap, isgraph)
+STRING_MAPPER (xislower, bmap, islower)
+STRING_MAPPER (xisprint, bmap, isprint)
+STRING_MAPPER (xispunct, bmap, ispunct)
+STRING_MAPPER (xisspace, bmap, isspace)
+STRING_MAPPER (xisupper, bmap, isupper)
+STRING_MAPPER (xisxdigit, bmap, isxdigit)
+STRING_MAPPER (xtoascii, dmap, toascii)
+TOSTRING_MAPPER (xtolower, smap, tolower)
+TOSTRING_MAPPER (xtoupper, smap, toupper)
 
 /*
 ;;; Local Variables: ***
--- a/src/ov-str-mat.h	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/ov-str-mat.h	Mon Feb 25 15:57:49 2008 -0500
@@ -158,21 +158,21 @@
 	     oct_mach_info::float_format flt_fmt) const
     { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
 
-  octave_value isalnum (void) const;
-  octave_value isalpha (void) const;
-  octave_value isascii (void) const;
-  octave_value iscntrl (void) const;
-  octave_value isdigit (void) const;
-  octave_value isgraph (void) const;
-  octave_value islower (void) const;
-  octave_value isprint (void) const;
-  octave_value ispunct (void) const;
-  octave_value isspace (void) const;
-  octave_value isupper (void) const;
-  octave_value isxdigit (void) const;
-  octave_value toascii (void) const;
-  octave_value tolower (void) const;
-  octave_value toupper (void) const;
+  octave_value xisalnum (void) const;
+  octave_value xisalpha (void) const;
+  octave_value xisascii (void) const;
+  octave_value xiscntrl (void) const;
+  octave_value xisdigit (void) const;
+  octave_value xisgraph (void) const;
+  octave_value xislower (void) const;
+  octave_value xisprint (void) const;
+  octave_value xispunct (void) const;
+  octave_value xisspace (void) const;
+  octave_value xisupper (void) const;
+  octave_value xisxdigit (void) const;
+  octave_value xtoascii (void) const;
+  octave_value xtolower (void) const;
+  octave_value xtoupper (void) const;
 
 #define MAT_MAPPER(MAP) \
   octave_value MAP (void) const \
--- a/src/ov.h	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/ov.h	Mon Feb 25 15:57:49 2008 -0500
@@ -915,21 +915,25 @@
   MAPPER_FORWARD (sqrt)
   MAPPER_FORWARD (tan)
   MAPPER_FORWARD (tanh)
-  MAPPER_FORWARD (isalnum)
-  MAPPER_FORWARD (isalpha)
-  MAPPER_FORWARD (isascii)
-  MAPPER_FORWARD (iscntrl)
-  MAPPER_FORWARD (isdigit)
-  MAPPER_FORWARD (isgraph)
-  MAPPER_FORWARD (islower)
-  MAPPER_FORWARD (isprint)
-  MAPPER_FORWARD (ispunct)
-  MAPPER_FORWARD (isspace)
-  MAPPER_FORWARD (isupper)
-  MAPPER_FORWARD (isxdigit)
-  MAPPER_FORWARD (toascii)
-  MAPPER_FORWARD (tolower)
-  MAPPER_FORWARD (toupper)
+
+  // These functions are prefixed with X to avoid potential macro
+  // conflicts.
+
+  MAPPER_FORWARD (xisalnum)
+  MAPPER_FORWARD (xisalpha)
+  MAPPER_FORWARD (xisascii)
+  MAPPER_FORWARD (xiscntrl)
+  MAPPER_FORWARD (xisdigit)
+  MAPPER_FORWARD (xisgraph)
+  MAPPER_FORWARD (xislower)
+  MAPPER_FORWARD (xisprint)
+  MAPPER_FORWARD (xispunct)
+  MAPPER_FORWARD (xisspace)
+  MAPPER_FORWARD (xisupper)
+  MAPPER_FORWARD (xisxdigit)
+  MAPPER_FORWARD (xtoascii)
+  MAPPER_FORWARD (xtolower)
+  MAPPER_FORWARD (xtoupper)
 
 #undef MAPPER_FORWARD
 
--- a/src/strfns.cc	Mon Feb 25 04:59:17 2008 -0500
+++ b/src/strfns.cc	Mon Feb 25 15:57:49 2008 -0500
@@ -26,6 +26,7 @@
 #endif
 
 #include <cctype>
+
 #include <sstream>
 
 #include "dMatrix.h"