[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isascii/toascii with MSVC
From: |
John W. Eaton |
Subject: |
Re: isascii/toascii with MSVC |
Date: |
Mon, 25 Feb 2008 16:02:29 -0500 |
On 25-Feb-2008, Michael Goffioul wrote:
| On Mon, Feb 25, 2008 at 11:05 AM, John W. Eaton <address@hidden> wrote:
| > I think I'd prefer to have the octave_value function names be the same
| > as they are in the scripting language,
|
| I agree, it's better.
|
| > so what about
| >
| > #include <cctype>
| >
| > inline int xisascii (int c) { return isascii (c); }
| > inline int xtoascii (int c) { return toascii (c); }
| >
| > #undef isascii
| > #undef toascii
|
| This should be fine: put this into some lo-cctype.h header and
| include it in ov-base.h should be enough to make MSVC happy
| (I'll merge my repo with yours and try to recompile once you
| commit the change).
OK, after looking at this some more I noticed that there could be some
trouble if we use the method I outlined above. So I made the
following change instead. I didn't really want to have to rename the
octave_value mapper methods (to xisascii, etc.) but I really don't see
any other solution that will work reliably if some vendor converts
other functions declared in ctype.h to be macros.
Does this change work for you?
jwe
# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1203973069 18000
# Node ID 26d8a92644de6c84f6052e4766bf662cf553c97b
# Parent d219e712c20e97cf1d426dfdfb89075abf3581c1
try to avoid ctype macro problems
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,16 @@ 2008-02-25 John W. Eaton <address@hidden
2008-02-25 John W. Eaton <address@hidden>
+
+ * 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.
diff --git a/src/mappers.cc b/src/mappers.cc
--- a/src/mappers.cc
+++ b/src/mappers.cc
@@ -468,7 +468,7 @@ Return the imaginary part of @var{z} as
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 @@ Return 1 for characters that are letters
{
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 @@ or @code{islower (@var{s})} is true).\n\
{
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 @@ Return 1 for characters that are ASCII (
{
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 @@ Return 1 for control characters.\n\
{
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 @@ Return 1 for characters that are decimal
{
octave_value retval;
if (args.length () == 1)
- retval = args(0).isdigit ();
+ retval = args(0).xisdigit ();
else
print_usage ();
@@ -573,7 +569,7 @@ isinf ([13, Inf, NA, NaN])\n\
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 @@ Return 1 for printable characters (but n
{
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 @@ Return 1 for characters that are lower c
{
octave_value retval;
if (args.length () == 1)
- retval = args(0).islower ();
+ retval = args(0).xislower ();
else
print_usage ();
@@ -649,7 +645,7 @@ isnan ([13, Inf, NA, NaN])\n\
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 @@ Return 1 for printable characters (inclu
{
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 @@ Return 1 for punctuation characters.\n\
{
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 @@ carriage return, tab, and vertical tab).
{
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 @@ Return 1 for upper case letters.\n\
{
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 @@ Return 1 for characters that are hexadec
{
octave_value retval;
if (args.length () == 1)
- retval = args(0).isxdigit ();
+ retval = args(0).xisxdigit ();
else
print_usage ();
@@ -918,11 +914,7 @@ Compute hyperbolic tangent of each eleme
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 @@ toascii (\"ASCII\")\n\
{
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 @@ tolower (\"MiXeD cAsE 123\")\n\
{
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 @@ toupper (\"MiXeD cAsE 123\")\n\
{
octave_value retval;
if (args.length () == 1)
- retval = args(0).toupper ();
+ retval = args(0).xtoupper ();
else
print_usage ();
diff --git a/src/ov-base.cc b/src/ov-base.cc
--- a/src/ov-base.cc
+++ b/src/ov-base.cc
@@ -895,401 +895,75 @@ octave_base_value::sort (Array<octave_id
return octave_value();
}
-octave_value
-octave_base_value::abs (void) const
-{
- gripe_wrong_type_arg ("octave_base_value::abs ()", 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::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 ();
-}
-
-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 ();
-}
+#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::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 ();
-}
-
-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)
diff --git a/src/ov-base.h b/src/ov-base.h
--- a/src/ov-base.h
+++ b/src/ov-base.h
@@ -503,21 +503,25 @@ public:
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:
diff --git a/src/ov-str-mat.cc b/src/ov-str-mat.cc
--- a/src/ov-str-mat.cc
+++ b/src/ov-str-mat.cc
@@ -24,6 +24,8 @@ along with Octave; see the file COPYING.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
+#include <cctype>
#include <iostream>
#include <vector>
@@ -772,44 +774,45 @@ octave_char_matrix_str::load_hdf5 (hid_t
#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: ***
diff --git a/src/ov-str-mat.h b/src/ov-str-mat.h
--- a/src/ov-str-mat.h
+++ b/src/ov-str-mat.h
@@ -158,21 +158,21 @@ public:
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 \
diff --git a/src/ov.h b/src/ov.h
--- a/src/ov.h
+++ b/src/ov.h
@@ -915,21 +915,25 @@ public:
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
diff --git a/src/strfns.cc b/src/strfns.cc
--- a/src/strfns.cc
+++ b/src/strfns.cc
@@ -26,6 +26,7 @@ along with Octave; see the file COPYING.
#endif
#include <cctype>
+
#include <sstream>
#include "dMatrix.h"
- isascii/toascii with MSVC, Michael Goffioul, 2008/02/24
- Re: isascii/toascii with MSVC, Michael Goffioul, 2008/02/25
- Re: isascii/toascii with MSVC, John W. Eaton, 2008/02/25
- Re: isascii/toascii with MSVC, Michael Goffioul, 2008/02/25
- Re: isascii/toascii with MSVC, John W. Eaton, 2008/02/25
- Re: isascii/toascii with MSVC, Michael Goffioul, 2008/02/25
- Re: isascii/toascii with MSVC, John W. Eaton, 2008/02/25
- Re: isascii/toascii with MSVC, Michael Goffioul, 2008/02/25
- Re: isascii/toascii with MSVC,
John W. Eaton <=
- Re: isascii/toascii with MSVC, Michael Goffioul, 2008/02/25
- Re: isascii/toascii with MSVC, John W. Eaton, 2008/02/25
- Re: isascii/toascii with MSVC, Michael Goffioul, 2008/02/26
- Re: isascii/toascii with MSVC, Daniel J Sebald, 2008/02/25