From octave-sources-request at bevo dot che dot wisc dot edu Sat Feb 13 00:19:12 1999 Subject: Patch for uint16/uint32 types From: James Macnicol To: octave-sources at bevo dot che dot wisc dot edu Date: Sat, 13 Feb 99 17:19:05 EST In porting a Matlab script to Octave I've come across the lack of a uint32 type when doing fread. The following patches correct this. -- James Macnicol jamesm at ee dot adfa dot oz dot au This is a patch for src/file-io.cc --------------------------- cut here ------------------------------------ --- file-io.cc.orig Sat Feb 13 17:09:24 1999 +++ file-io.cc Sat Feb 13 16:58:58 1999 at @ -935,7 +935,9 @@ float, float32, real*4 -- single precision float\n\ double, float64, real*8 -- double precision float\n\ int16, integer*2 -- two byte integer\n\ + uint16 -- two byte unsigned integer\n\ int32, integer*4 -- four byte integer\n\ + uint32 -- four byte unsigned integer\n\ \n\ SKIP : number of bytes to skip after each element is read\n\ (default is 0)\n\ at @ -1067,7 +1069,9 @@ float, float32, real*4 -- single precision float\n\ double, float64, real*8 -- double precision float\n\ int16, integer*2 -- two byte integer\n\ + uint16 -- two byte unsigned integer\n\ int32, integer*4 -- four byte integer\n\ + uint32 -- four byte unsigned integer\n\ \n\ SKIP : number of bytes to skip before each element is written\n\ (the default is 0)\n\ --------------------------- cut here ------------------------------------ And this is for liboctave/data-conv.cc --------------------------- cut here ------------------------------------ --- data-conv.cc.orig Sat Feb 13 16:47:05 1999 +++ data-conv.cc Sat Feb 13 16:56:43 1999 at @ -95,6 +95,26 @@ (*current_liboctave_error_handler) ("unable to find matching native data type for %s", s.c_str ()); } + else if (s == "uint16") + { + if (sizeof (unsigned short) == 2) + retval = dt_ushort; + else if (sizeof (unsigned int) == 2) + retval = dt_uint; + else + (*current_liboctave_error_handler) + ("unable to find matching native data type for %s", s.c_str ()); + } + else if (s == "uint32") + { + if (sizeof (unsigned int) == 4) + retval = dt_uint; + else if (sizeof (unsigned long) == 4) + retval = dt_ulong; + else + (*current_liboctave_error_handler) + ("unable to find matching native data type for %s", s.c_str ()); + } else (*current_liboctave_error_handler) ("invalid data type specified"); --------------------------- cut here ------------------------------------