changeset 15215:9020dddc925a

use std::numeric_limits for integer max and min values * strfind.cc, gl-render.cc, jit-typeinfo.cc, oct-stream.cc, sparse-xpow.cc, xpow.cc, debug.cc, file-io.cc, ls-oct-ascii.cc, oct-hist.cc, pr-output.cc, utils.cc, variables.h, ov-base-int.cc, ov-base.cc, ov-bool-sparse.cc, ov-cx-sparse.cc, ov-float.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-struct.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, Array.cc, Sparse.cc, chNDArray.cc, dNDArray.cc, data-conv.cc, data-conv.h, fNDArray.cc, kpse.cc, oct-inttypes.h, oct-time.cc: Use std::numeric_limits for max and min integer values. Include <limits>, not <climits>.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Aug 2012 17:36:54 -0400
parents ae6b7ee0a733
children dd7c37ceb800
files libinterp/corefcn/strfind.cc libinterp/interp-core/gl-render.cc libinterp/interp-core/jit-typeinfo.cc libinterp/interp-core/oct-stream.cc libinterp/interp-core/sparse-xpow.cc libinterp/interp-core/xpow.cc libinterp/interpfcn/debug.cc libinterp/interpfcn/file-io.cc libinterp/interpfcn/ls-oct-ascii.cc libinterp/interpfcn/oct-hist.cc libinterp/interpfcn/pr-output.cc libinterp/interpfcn/utils.cc libinterp/interpfcn/variables.h libinterp/octave-value/ov-base-int.cc libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-bool-sparse.cc libinterp/octave-value/ov-cx-sparse.cc libinterp/octave-value/ov-float.cc libinterp/octave-value/ov-flt-re-mat.cc libinterp/octave-value/ov-int16.cc libinterp/octave-value/ov-int32.cc libinterp/octave-value/ov-int64.cc libinterp/octave-value/ov-int8.cc libinterp/octave-value/ov-re-mat.cc libinterp/octave-value/ov-re-sparse.cc libinterp/octave-value/ov-scalar.cc libinterp/octave-value/ov-struct.cc libinterp/octave-value/ov-uint16.cc libinterp/octave-value/ov-uint32.cc libinterp/octave-value/ov-uint64.cc libinterp/octave-value/ov-uint8.cc liboctave/Array.cc liboctave/Sparse.cc liboctave/chNDArray.cc liboctave/dNDArray.cc liboctave/data-conv.cc liboctave/data-conv.h liboctave/fNDArray.cc liboctave/kpse.cc liboctave/oct-inttypes.h liboctave/oct-time.cc
diffstat 41 files changed, 105 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/strfind.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/corefcn/strfind.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,10 +25,10 @@
 #include <config.h>
 #endif
 
-#include <string>
-#include <climits>
 #include <algorithm>
 #include <deque>
+#include <limits>
+#include <string>
 
 #include "Cell.h"
 #include "ov.h"
@@ -39,13 +39,13 @@
 
 // This allows safe indexing with char. In C++, char may be (and often is) signed!
 #define ORD(ch) static_cast<unsigned char>(ch)
-#define TABSIZE (UCHAR_MAX + 1)
+#define TABSIZE (std::numeric_limits<unsigned char>::max () + 1)
 
 // This is the quick search algorithm, as described at
 // http://www-igm.univ-mlv.fr/~lecroq/string/node19.html
 static void
 qs_preprocess (const Array<char>& needle,
-               octave_idx_type table[TABSIZE])
+               octave_idx_type *table)
 {
   const char *x = needle.data ();
   octave_idx_type m = needle.numel ();
@@ -60,7 +60,7 @@
 static Array<octave_idx_type>
 qs_search (const Array<char>& needle,
            const Array<char>& haystack,
-           const octave_idx_type table[TABSIZE],
+           const octave_idx_type *table,
            bool overlaps = true)
 {
   const char *x = needle.data ();
@@ -261,7 +261,7 @@
 static Array<char>
 qs_replace (const Array<char>& str, const Array<char>& pat,
             const Array<char>& rep,
-            const octave_idx_type table[TABSIZE],
+            const octave_idx_type *table,
             bool overlaps = true)
 {
   Array<char> ret = str;
--- a/libinterp/interp-core/gl-render.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interp-core/gl-render.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -135,7 +135,7 @@
 {
   int m = 1;
 
-  while (m < n && m < INT_MAX)
+  while (m < n && m < std::numeric_limits<int>::max ())
     m <<= 1;
 
   return m;
@@ -1425,7 +1425,7 @@
   Matrix z = xform.zscale (props.get_zdata ().matrix_value ());
 
   bool has_z = (z.numel () > 0);
-  int n = static_cast<int> (::xmin (::xmin (x.numel (), y.numel ()), (has_z ? z.numel () : INT_MAX)));
+  int n = static_cast<int> (::xmin (::xmin (x.numel (), y.numel ()), (has_z ? z.numel () : std::numeric_limits<int>::max ())));
   octave_uint8 clip_mask = (props.is_clipping () ? 0x7F : 0x40), clip_ok (0x40);
 
   std::vector<octave_uint8> clip (n);
--- a/libinterp/interp-core/jit-typeinfo.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interp-core/jit-typeinfo.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -381,8 +381,8 @@
 xisint (double x)
 {
   return (D_NINT (x) == x
-          && ((x >= 0 && x < INT_MAX)
-              || (x <= 0 && x > INT_MIN)));
+          && ((x >= 0 && x < std::numeric_limits<int>::max ())
+              || (x <= 0 && x > std::numermic_limits<int>::min ())));
 }
 
 extern "C" Complex
--- a/libinterp/interp-core/oct-stream.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interp-core/oct-stream.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -1445,7 +1445,7 @@
   do \
     { \
       if (! width) \
-        width = INT_MAX; \
+        width = std::numeric_limits<int>::max (); \
  \
       std::ostringstream buf; \
  \
@@ -1468,7 +1468,7 @@
             buf << static_cast<char> (c); \
         } \
  \
-      if (width == INT_MAX && c != EOF) \
+      if (width == std::numeric_limits<int>::max () && c != EOF) \
         is.putback (c); \
  \
       tmp = buf.str (); \
--- a/libinterp/interp-core/sparse-xpow.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interp-core/sparse-xpow.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -26,7 +26,8 @@
 #endif
 
 #include <cassert>
-#include <climits>
+
+#include <limits>
 
 #include "Array-util.h"
 #include "oct-cmplx.h"
@@ -46,8 +47,8 @@
 xisint (double x)
 {
   return (D_NINT (x) == x
-          && ((x >= 0 && x < INT_MAX)
-              || (x <= 0 && x > INT_MIN)));
+          && ((x >= 0 && x < std::numeric_limits<int>::max ())
+              || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
 
 
--- a/libinterp/interp-core/xpow.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interp-core/xpow.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -26,7 +26,8 @@
 #endif
 
 #include <cassert>
-#include <climits>
+
+#include <limits>
 
 #include "Array-util.h"
 #include "CColVector.h"
@@ -59,8 +60,8 @@
 xisint (double x)
 {
   return (D_NINT (x) == x
-          && ((x >= 0 && x < INT_MAX)
-              || (x <= 0 && x > INT_MIN)));
+          && ((x >= 0 && x < std::numeric_limits<int>::max ())
+              || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
 
 // Safer pow functions.
@@ -1508,8 +1509,8 @@
 xisint (float x)
 {
   return (D_NINT (x) == x
-          && ((x >= 0 && x < INT_MAX)
-              || (x <= 0 && x > INT_MIN)));
+          && ((x >= 0 && x < std::numeric_limits<int>::max ())
+              || (x <= 0 && x > std::numeric_limits<int>::min ())));
 }
 
 // Safer pow functions.
--- a/libinterp/interpfcn/debug.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/debug.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -825,7 +825,8 @@
           dbg_fcn = get_user_code ();
 
           if (dbg_fcn)
-            do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX);
+            do_dbtype (octave_stdout, dbg_fcn->name (), 0,
+                       std::numeric_limits<int>::max ());
           else
             error ("dbtype: must be inside a user function to give no arguments to dbtype\n");
           break;
@@ -848,7 +849,7 @@
                     int start, end;
                     start = atoi (start_str.c_str ());
                     if (end_str == "end")
-                      end = INT_MAX;
+                      end = std::numeric_limits<int>::max ();
                     else
                       end = atoi (end_str.c_str ());
 
@@ -866,7 +867,8 @@
                 dbg_fcn = get_user_code (arg);
 
                 if (dbg_fcn)
-                  do_dbtype (octave_stdout, dbg_fcn->name (), 0, INT_MAX);
+                  do_dbtype (octave_stdout, dbg_fcn->name (), 0,
+                             std::numeric_limits<int>::max ());
                 else
                   error ("dbtype: function <%s> not found\n", arg.c_str ());
               }
@@ -889,7 +891,7 @@
 
                   start = atoi (start_str.c_str ());
                   if (end_str == "end")
-                    end = INT_MAX;
+                    end = std::numeric_limits<int>::max ();
                   else
                     end = atoi (end_str.c_str ());
                 }
--- a/libinterp/interpfcn/file-io.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/file-io.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -39,10 +39,10 @@
 #endif
 
 #include <cerrno>
-#include <climits>
 #include <cstdio>
 
 #include <iostream>
+#include <limits>
 #include <locale>
 #include <stack>
 #include <stdexcept>
--- a/libinterp/interpfcn/ls-oct-ascii.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/ls-oct-ascii.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -428,5 +428,6 @@
 variable value is restored when exiting the function.\n\
 @end deftypefn")
 {
-  return SET_INTERNAL_VARIABLE_WITH_LIMITS (save_precision, -1, INT_MAX);
+  return SET_INTERNAL_VARIABLE_WITH_LIMITS (save_precision, -1,
+                                            std::numeric_limits<int>::max ());
 }
--- a/libinterp/interpfcn/oct-hist.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/oct-hist.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -698,7 +698,8 @@
   int tmp = old_history_size;
 
   octave_value retval = set_internal_variable (tmp, args, nargout,
-                                               "history_size", -1, INT_MAX);
+                                               "history_size", -1,
+                                               std::numeric_limits<int>::max ());
 
   if (tmp != old_history_size)
     command_history::set_size (tmp);
--- a/libinterp/interpfcn/pr-output.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/pr-output.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -356,7 +356,9 @@
     s = "1/0";
   else if (xisnan (val))
     s = "0/0";
-  else if (val < INT_MIN || val > INT_MAX || D_NINT (val) == val)
+  else if (val < std::numeric_limits<int>::min ()
+           || val > std::numeric_limits<int>::max ()
+           || D_NINT (val) == val)
     {
       std::ostringstream buf;
       buf.flags (std::ios::fixed);
@@ -385,7 +387,7 @@
           double nextd = d;
 
           // Have we converged to 1/intmax ?
-          if (m > 100 || fabs (frac) < 1 / static_cast<double>(INT_MAX))
+          if (m > 100 || fabs (frac) < 1 / static_cast<double> (std::numeric_limits<int>::max ()))
             {
               lastn = n;
               lastd = d;
@@ -4068,7 +4070,8 @@
 @seealso{format, fixed_point_format, output_precision}\n\
 @end deftypefn")
 {
-  return SET_INTERNAL_VARIABLE_WITH_LIMITS (output_max_field_width, 0, INT_MAX);
+  return SET_INTERNAL_VARIABLE_WITH_LIMITS (output_max_field_width, 0,
+                                            std::numeric_limits<int>::max ());
 }
 
 DEFUN (output_precision, args, nargout,
@@ -4085,5 +4088,6 @@
 @seealso{format, fixed_point_format, output_max_field_width}\n\
 @end deftypefn")
 {
-  return SET_INTERNAL_VARIABLE_WITH_LIMITS (output_precision, -1, INT_MAX);
+  return SET_INTERNAL_VARIABLE_WITH_LIMITS (output_precision, -1,
+                                            std::numeric_limits<int>::max ());
 }
--- a/libinterp/interpfcn/utils.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/utils.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -26,11 +26,11 @@
 #endif
 
 #include <cerrno>
-#include <climits>
 #include <cstring>
 
 #include <fstream>
 #include <iostream>
+#include <limits>
 #include <string>
 
 #include <sys/types.h>
@@ -1266,7 +1266,9 @@
         = static_cast<unsigned int> (modf (seconds, &t) * 1000000);
 
       unsigned int sec
-        = (t > UINT_MAX) ? UINT_MAX : static_cast<unsigned int> (t);
+        = ((t > std::numeric_limits<unsigned int>::max ())
+           ? std::numeric_limits<unsigned int>::max ()
+           : static_cast<unsigned int> (t));
 
       // Versions of these functions that accept unsigned int args are
       // defined in cutils.c.
--- a/libinterp/interpfcn/variables.h	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/interpfcn/variables.h	Wed Aug 22 17:36:54 2012 -0400
@@ -32,11 +32,13 @@
 class octave_builtin;
 class string_vector;
 
-#include <climits>
 #include <cfloat>
 
+#include <limits>
 #include <string>
 
+#include "lo-ieee.h"
+
 #include "ov.h"
 #include "ov-builtin.h"
 #include "symtab.h"
@@ -97,7 +99,8 @@
 extern OCTINTERP_API octave_value
 set_internal_variable (int& var, const octave_value_list& args,
                        int nargout, const char *nm,
-                       int minval = INT_MIN, int maxval = INT_MAX);
+                       int minval = std::numeric_limits<int>::min (),
+                       int maxval = std::numeric_limits<int>::max ());
 
 extern OCTINTERP_API octave_value
 set_internal_variable (double& var, const octave_value_list& args,
--- a/libinterp/octave-value/ov-base-int.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-base-int.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 #include <vector>
 
 #include "lo-ieee.h"
@@ -65,7 +64,10 @@
 struct octave_base_int_helper
 {
   static bool
-  char_value_out_of_range (T val) { return val < 0 || val > UCHAR_MAX; }
+  char_value_out_of_range (T val)
+  {
+    return val < 0 || val > std::numeric_limits<unsigned char>::max ();
+  }
 };
 
 template <class T>
@@ -77,7 +79,10 @@
 template <class T>
 struct octave_base_int_helper<T, false, true>
 {
-  static bool char_value_out_of_range (T val) { return val > UCHAR_MAX; }
+  static bool char_value_out_of_range (T val)
+  {
+    return val > std::numeric_limits<unsigned char>::max ();
+  }
 };
 
 template <class T>
--- a/libinterp/octave-value/ov-base.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-base.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-mappers.h"
@@ -450,7 +449,7 @@
   os << "no info for type: " << type_name () << "\n";
 }
 
-#define INT_CONV_METHOD(T, F, MIN_LIMIT, MAX_LIMIT) \
+#define INT_CONV_METHOD(T, F) \
   T \
   octave_base_value::F ## _value (bool require_int, bool frc_str_conv) const \
   { \
@@ -462,10 +461,10 @@
       { \
         if (require_int && D_NINT (d) != d) \
           error_with_cfn ("conversion of %g to " #T " value failed", d); \
-        else if (d < MIN_LIMIT) \
-          retval = MIN_LIMIT; \
-        else if (d > MAX_LIMIT) \
-          retval = MAX_LIMIT; \
+        else if (d < std::numeric_limits<T>::min ()) \
+          retval = std::numeric_limits<T>::min (); \
+        else if (d > std::numeric_limits<T>::max ()) \
+          retval = std::numeric_limits<T>::max (); \
         else \
           retval = static_cast<T> (::fix (d));  \
       } \
@@ -476,14 +475,14 @@
     return retval; \
   }
 
-INT_CONV_METHOD (short int, short, SHRT_MIN, SHRT_MAX)
-INT_CONV_METHOD (unsigned short int, ushort, 0, USHRT_MAX)
+INT_CONV_METHOD (short int, short)
+INT_CONV_METHOD (unsigned short int, ushort)
 
-INT_CONV_METHOD (int, int, INT_MIN, INT_MAX)
-INT_CONV_METHOD (unsigned int, uint, 0, UINT_MAX)
+INT_CONV_METHOD (int, int)
+INT_CONV_METHOD (unsigned int, uint)
 
-INT_CONV_METHOD (long int, long, LONG_MIN, LONG_MAX)
-INT_CONV_METHOD (unsigned long int, ulong, 0, ULONG_MAX)
+INT_CONV_METHOD (long int, long)
+INT_CONV_METHOD (unsigned long int, ulong)
 
 int
 octave_base_value::nint_value (bool frc_str_conv) const
--- a/libinterp/octave-value/ov-bool-sparse.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-bool-sparse.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 #include <vector>
 
 #include "dim-vector.h"
--- a/libinterp/octave-value/ov-cx-sparse.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 #include <vector>
 
 #include "lo-specfun.h"
--- a/libinterp/octave-value/ov-float.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-float.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -115,7 +115,7 @@
     {
       int ival = NINT (scalar);
 
-      if (ival < 0 || ival > UCHAR_MAX)
+      if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         {
           // FIXME -- is there something better we could do?
 
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 #include <vector>
 
 #include "data-conv.h"
@@ -69,10 +68,6 @@
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
-#if ! defined (UCHAR_MAX)
-#define UCHAR_MAX 255
-#endif
-
 template class octave_base_matrix<FloatNDArray>;
 
 DEFINE_OCTAVE_ALLOCATOR (octave_float_matrix);
@@ -308,7 +303,7 @@
         {
           int ival = NINT (d);
 
-          if (ival < 0 || ival > UCHAR_MAX)
+          if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
             {
               // FIXME -- is there something
               // better we could do?
--- a/libinterp/octave-value/ov-int16.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-int16.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-int32.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-int32.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-int64.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-int64.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-int8.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-int8.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-re-mat.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-re-mat.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 #include <vector>
 
 #include "data-conv.h"
@@ -69,10 +68,6 @@
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
-#if ! defined (UCHAR_MAX)
-#define UCHAR_MAX 255
-#endif
-
 template class octave_base_matrix<NDArray>;
 
 DEFINE_OCTAVE_ALLOCATOR (octave_matrix);
@@ -410,7 +405,7 @@
         {
           int ival = NINT (d);
 
-          if (ival < 0 || ival > UCHAR_MAX)
+          if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
             {
               // FIXME -- is there something
               // better we could do?
--- a/libinterp/octave-value/ov-re-sparse.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-re-sparse.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,9 +25,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 #include <vector>
 
 #include "lo-specfun.h"
@@ -233,7 +232,7 @@
                 {
                   int ival = NINT (d);
 
-                  if (ival < 0 || ival > UCHAR_MAX)
+                  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
                     {
                       // FIXME -- is there something
                       // better we could do?
--- a/libinterp/octave-value/ov-scalar.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-scalar.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -130,7 +130,7 @@
     {
       int ival = NINT (scalar);
 
-      if (ival < 0 || ival > UCHAR_MAX)
+      if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
         {
           // FIXME -- is there something better we could do?
 
--- a/libinterp/octave-value/ov-struct.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-struct.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -2212,8 +2212,8 @@
 variable value is restored when exiting the function.\n\
 @end deftypefn")
 {
-  return SET_INTERNAL_VARIABLE_WITH_LIMITS (struct_levels_to_print,
-                                            -1, INT_MAX);
+  return SET_INTERNAL_VARIABLE_WITH_LIMITS (struct_levels_to_print, -1,
+                                            std::numeric_limits<int>::max ());
 }
 
 DEFUN (print_struct_array_contents, args, nargout,
--- a/libinterp/octave-value/ov-uint16.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-uint16.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-uint32.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-uint32.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-uint64.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-uint64.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/libinterp/octave-value/ov-uint8.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/libinterp/octave-value/ov-uint8.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,9 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
-
 #include <iostream>
+#include <limits>
 
 #include "lo-ieee.h"
 #include "lo-utils.h"
--- a/liboctave/Array.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/Array.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -28,7 +28,6 @@
 #endif
 
 #include <cassert>
-#include <climits>
 
 #include <iostream>
 #include <sstream>
--- a/liboctave/Sparse.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/Sparse.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -28,10 +28,10 @@
 #endif
 
 #include <cassert>
-#include <climits>
 
 #include <algorithm>
 #include <iostream>
+#include <limits>
 #include <sstream>
 #include <vector>
 
--- a/liboctave/chNDArray.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/chNDArray.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -79,7 +79,7 @@
         {
           octave_idx_type ival = NINTbig (d);
 
-          if (ival < 0 || ival > UCHAR_MAX)
+          if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
             // FIXME -- is there something
             // better we could do? Should we warn the user?
             ival = 0;
--- a/liboctave/dNDArray.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/dNDArray.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -776,7 +776,7 @@
         {
           octave_idx_type ival = NINTbig (d);
 
-          if (ival < 0 || ival > UCHAR_MAX)
+          if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
             // FIXME -- is there something
             // better we could do? Should we warn the user?
             ival = 0;
--- a/liboctave/data-conv.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/data-conv.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -25,6 +25,7 @@
 #endif
 
 #include <cctype>
+#include <climits>
 #include <cstdlib>
 
 #include <iostream>
--- a/liboctave/data-conv.h	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/data-conv.h	Wed Aug 22 17:36:54 2012 -0400
@@ -23,7 +23,7 @@
 #if !defined (octave_data_conv_h)
 #define octave_data_conv_h 1
 
-#include <climits>
+#include <limits>
 
 #include "mach-info.h"
 
--- a/liboctave/fNDArray.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/fNDArray.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -736,7 +736,7 @@
         {
           octave_idx_type ival = NINTbig (d);
 
-          if (ival < 0 || ival > UCHAR_MAX)
+          if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
             // FIXME -- is there something
             // better we could do? Should we warn the user?
             ival = 0;
--- a/liboctave/kpse.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/kpse.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -129,7 +129,6 @@
 #include <cstdio>
 #include <cstdarg>
 #include <cstdlib>
-#include <climits>
 #include <cerrno>
 #include <cassert>
 
--- a/liboctave/oct-inttypes.h	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/oct-inttypes.h	Wed Aug 22 17:36:54 2012 -0400
@@ -24,7 +24,6 @@
 #if !defined (octave_inttypes_h)
 #define octave_inttypes_h 1
 
-#include <climits>
 #include <cstdlib>
 
 #include <limits>
--- a/liboctave/oct-time.cc	Wed Aug 22 13:46:29 2012 -0700
+++ b/liboctave/oct-time.cc	Wed Aug 22 17:36:54 2012 -0400
@@ -24,7 +24,8 @@
 #include <config.h>
 #endif
 
-#include <climits>
+#include <limits>
+
 #include <ctime>
 
 #include <sys/time.h>
@@ -121,7 +122,8 @@
 DEFINE_SET_INT_FIELD_FCN (hour, 0, 23)
 DEFINE_SET_INT_FIELD_FCN (mday, 1, 31)
 DEFINE_SET_INT_FIELD_FCN (mon, 0, 11)
-DEFINE_SET_INT_FIELD_FCN (year, INT_MIN, INT_MAX)
+DEFINE_SET_INT_FIELD_FCN (year, std::numeric_limits<int>::min (),
+                          std::numeric_limitd<int>::max ())
 DEFINE_SET_INT_FIELD_FCN (wday, 0, 6)
 DEFINE_SET_INT_FIELD_FCN (yday, 0, 365)
 DEFINE_SET_INT_FIELD_FCN (isdst, 0, 1)
@@ -256,7 +258,7 @@
   t.tm_hour = 0;
   t.tm_mday = 0;
   t.tm_mon = -1;
-  t.tm_year = INT_MIN;
+  t.tm_year = std::numeric_limits<int>::min ();
   t.tm_wday = 0;
   t.tm_yday = 0;
   t.tm_isdst = 0;
@@ -276,7 +278,8 @@
 
   // Fill in wday and yday, but only if mday is valid and the mon and year
   // are filled in, avoiding issues with mktime and invalid dates.
-  if (t.tm_mday != 0 && t.tm_mon >= 0 && t.tm_year != INT_MIN)
+  if (t.tm_mday != 0 && t.tm_mon >= 0
+      && t.tm_year != std::numeric_limits<int>::min ())
     {
       t.tm_isdst = -1;
       gnulib::mktime (&t);
@@ -285,7 +288,7 @@
   if (t.tm_mon < 0)
     t.tm_mon = 0;
 
-  if (t.tm_year == INT_MIN)
+  if (t.tm_year == std::numeric_limits<int>::min ())
     t.tm_year = 0;
 
   if (q)