<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2011-02-01)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
 <font color='#bb2222'><strong>ralf</strong></font>
 <font color='#225522'><em>(on branch rtems-4-10-branch)</em></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>Backport from CVS-HEAD.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2346.2.75&r2=text&tr2=1.2346.2.76&diff_format=h">M</a></td><td width='1%'>1.2346.2.76</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/Makefile.am.diff?r1=text&tr1=1.85&r2=text&tr2=1.85.2.1&diff_format=h">M</a></td><td width='1%'>1.85.2.1</td><td width='100%'>cpukit/libmisc/Makefile.am</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringto.h.diff?r1=text&tr1=1.3&r2=text&tr2=1.3.2.1&diff_format=h">M</a></td><td width='1%'>1.3.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringto.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringto_template.h?rev=1.7&content-type=text/vnd.viewcvs-markup">R</a></td><td width='1%'><font color="#880000">1.7</font></td><td width='100%'><font color="#880000">cpukit/libmisc/stringto/stringto_template.h</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtodouble.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtodouble.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtofloat.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtofloat.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtoint.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtoint.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtolong.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtolong.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtolonglong.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtolonglong.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtopointer.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtopointer.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtounsignedchar.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtounsignedchar.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtounsignedint.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtounsignedint.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtounsignedlong.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtounsignedlong.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/stringto/stringtounsignedlonglong.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libmisc/stringto/stringtounsignedlonglong.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2346.2.75 rtems/cpukit/ChangeLog:1.2346.2.76
--- rtems/cpukit/ChangeLog:1.2346.2.75  Fri Jan 21 13:40:27 2011
+++ rtems/cpukit/ChangeLog      Tue Feb  1 20:30:08 2011
</font><font color='#997700'>@@ -1,3 +1,39 @@
</font><font color='#000088'>+2011-02-01    Ralf Corsepius <ralf.corsepius@rtems.org>
+
+       * libmisc/stringto/stringtounsignedchar.c,<span style="background-color: #FF0000"> </span>
+       libmisc/stringto/stringtounsignedint.c: Reformat range check.
+       * libmisc/Makefile.am: Add stringto/stringtolongdouble.c.
+       * libmisc/stringto/stringtolongdouble.c: New.
+       * libmisc/stringto/stringto.h: Rename header-guard.
+       Add rtems_string_to_long_double.
+       * libmisc/stringto/stringtoint.c: Reformat range check.
+       Add check for result==0.
+       * libmisc/stringto/stringtofloat.c: Reformat range check.
+       Add check for result = -HUGE_VALF.
+       * libmisc/stringto/stringtodouble.c: Reformat range check.
+       Add check for result = -HUGE_VAL.
+       * libmisc/stringto/stringtolonglong.c: Reformat range check.
+       c99 portability improvements. Add check for result==0.
+       * libmisc/stringto/stringtounsignedlonglong.c: Reformat range check.
+       c99 portability improvements.
+       * libmisc/stringto/stringtounsignedlong.c: Reformat range check.
+       * libmisc/stringto/stringtolong.c:  Reformat range check.
+       Add check for result==0.
+
+2011-02-01     Ralf Corsepius <ralf.corsepius@rtems.org>
+<span style="background-color: #FF0000">       </span>
+       * libmisc/Makefile.am: Remove stringto/stringto_template.h.
+       * libmisc/stringto/stringto_template.h: Remove.
+
+       * libmisc/stringto/stringtodouble.c,
+       libmisc/stringto/stringtofloat.c: Rework.
+
+       * libmisc/stringto/stringtolong.c,
+       libmisc/stringto/stringtolonglong.c,
+       libmisc/stringto/stringtounsignedlong.c,
+       libmisc/stringto/stringtounsignedlonglong.c:
+       Rework.
+
</font> 2011-01-21        Eric Norum <wenorum@lbl.gov>
 
        * libmisc/capture/capture.c: Avoid using TCB of task just deleted.

<font color='#006600'>diff -u rtems/cpukit/libmisc/Makefile.am:1.85 rtems/cpukit/libmisc/Makefile.am:1.85.2.1
--- rtems/cpukit/libmisc/Makefile.am:1.85       Mon May 31 08:56:37 2010
+++ rtems/cpukit/libmisc/Makefile.am    Tue Feb  1 20:30:09 2011
</font><font color='#997700'>@@ -135,10 +135,11 @@
</font> noinst_LIBRARIES += libstringto.a
 libstringto_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/stringto
 libstringto_a_SOURCES = stringto/stringtodouble.c stringto/stringtofloat.c \
<font color='#000088'>+    stringto/stringtolongdouble.c \
</font>     stringto/stringtoint.c stringto/stringtolong.c stringto/stringtolonglong.c \
     stringto/stringtopointer.c stringto/stringtounsignedint.c \
     stringto/stringtounsignedchar.c stringto/stringtounsignedlong.c \
<font color='#880000'>-    stringto/stringtounsignedlonglong.c stringto/stringto_template.h
</font><font color='#000088'>+    stringto/stringtounsignedlonglong.c
</font> 
 ## fsmount
 noinst_LIBRARIES += libfsmount.a

<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringto.h:1.3 rtems/cpukit/libmisc/stringto/stringto.h:1.3.2.1
--- rtems/cpukit/libmisc/stringto/stringto.h:1.3        Tue Dec  1 16:16:10 2009
+++ rtems/cpukit/libmisc/stringto/stringto.h    Tue Feb  1 20:30:09 2011
</font><font color='#997700'>@@ -9,8 +9,8 @@
</font>  *  $Id$
  */
 
<font color='#880000'>-#ifndef __STRING_TO_A_TYPE_h__
-#define __STRING_TO_A_TYPE_h__
</font><font color='#000088'>+#ifndef _RTEMS_STRINGTO_H
+#define _RTEMS_STRINGTO_H
</font> 
 #include <rtems.h>
 
<font color='#997700'>@@ -224,4 +224,23 @@
</font>   char        **endptr
 );
 
<font color='#000088'>+/**
+ *  @brief Convert String to long double (with validation)
+ *
+ *  This method converts a string to a long double with range validation.
+ *
+ *  @param[in] s is the string to convert
+ *  @param[in] n points to the variable to place the converted output in
+ *  @param[in] endptr is used to keep track of the position in the string
+ *
+ *  @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ *          and *n is filled in.  Otherwise, the status indicates the
+ *          source of the error.
+ */
+rtems_status_code rtems_string_to_long_double(
+  const char   *s,
+  long double  *n,
+  char        **endptr
+);
+
</font> #endif

<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtodouble.c:1.2 rtems/cpukit/libmisc/stringto/stringtodouble.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtodouble.c:1.2  Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtodouble.c      Tue Feb  1 20:30:09 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,13 +15,44 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <rtems/stringto.h>
+
</font> /*
  *  Instantiate an error checking wrapper for strtod (double)
  */
<font color='#880000'>-#define STRING_TO_FLOAT
-#define STRING_TO_TYPE double
-#define STRING_TO_NAME rtems_string_to_double
-#define STRING_TO_METHOD strtod
-#define STRING_TO_MAX HUGE_VAL
-#include "stringto_template.h"
</font> 
<font color='#000088'>+rtems_status_code rtems_string_to_double (
+  const char *s,
+  double *n,
+  char **endptr
+)
+{
+  double result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtod( s, &end );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == HUGE_VAL ) || ( result == -HUGE_VAL )))
+      return RTEMS_INVALID_NUMBER;
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtofloat.c:1.2 rtems/cpukit/libmisc/stringto/stringtofloat.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtofloat.c:1.2   Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtofloat.c       Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,12 +15,44 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <rtems/stringto.h>
+
</font> /*
  *  Instantiate an error checking wrapper for strtof (float)
  */
<font color='#880000'>-#define STRING_TO_FLOAT
-#define STRING_TO_TYPE float
-#define STRING_TO_NAME rtems_string_to_float
-#define STRING_TO_METHOD strtof
-#define STRING_TO_MAX HUGE_VALF
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_float (
+  const char *s,
+  float *n,
+  char **endptr
+)
+{
+  float result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtof( s, &end );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == HUGE_VALF ) || ( result == -HUGE_VALF )))
+      return RTEMS_INVALID_NUMBER;
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtoint.c:1.2 rtems/cpukit/libmisc/stringto/stringtoint.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtoint.c:1.2     Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtoint.c Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,12 +15,59 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
</font> /*
  *  Instantiate an error checking wrapper for strtol (int)
  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE int
-#define STRING_TO_NAME rtems_string_to_int
-#define STRING_TO_METHOD strtol
-#define STRING_TO_MAX LONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_int (
+  const char *s,
+  int *n,
+  char **endptr,
+  int base
+)
+{
+  long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtol( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == LONG_MAX ) || ( result == LONG_MIN )))
+      return RTEMS_INVALID_NUMBER;
+
+#if (INT_MAX < LONG_MAX)
+  if ( result > INT_MAX ) {
+    errno = ERANGE;
+    return RTEMS_INVALID_NUMBER;
+  }
+#endif
+
+#if (INT_MIN < LONG_MIN)
+  if ( result < INT_MIN ) {
+    errno = ERANGE;
+    return RTEMS_INVALID_NUMBER;
+  }
+#endif
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtolong.c:1.2 rtems/cpukit/libmisc/stringto/stringtolong.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtolong.c:1.2    Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtolong.c        Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,13 +15,45 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
</font> /*
  *  Instantiate an error checking wrapper for strtol (long)
  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE long int
-#define STRING_TO_NAME rtems_string_to_long
-#define STRING_TO_METHOD strtol
-#define STRING_TO_MIN LONG_MIN
-#define STRING_TO_MAX LONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_long (
+  const char *s,
+  long *n,
+  char **endptr,
+  int base
+)
+{
+  long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtol( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == LONG_MAX ) || ( result == LONG_MIN )))
+      return RTEMS_INVALID_NUMBER;
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtolonglong.c:1.2 rtems/cpukit/libmisc/stringto/stringtolonglong.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtolonglong.c:1.2        Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtolonglong.c    Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,13 +15,54 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
+/* c99 has LLONG_MAX instead of LONG_LONG_MAX */
+#ifndef LONG_LONG_MAX
+#define LONG_LONG_MAX  LLONG_MAX
+#endif
+/* c99 has LLONG_MIN instead of LONG_LONG_MIN */
+#ifndef LONG_LONG_MIN
+#define LONG_LONG_MIN  LLONG_MIN
+#endif
+
</font> /*
  *  Instantiate an error checking wrapper for strtoll (long long)
  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE long long
-#define STRING_TO_NAME rtems_string_to_long_long
-#define STRING_TO_METHOD strtoll
-#define STRING_TO_MIN LONG_LONG_MIN
-#define STRING_TO_MAX LONG_LONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_long_long (
+  const char *s,
+  long long *n,
+  char **endptr,
+  int base
+)
+{
+  long long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtoll( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == LONG_LONG_MAX ) || ( result == LONG_LONG_MIN )))
+      return RTEMS_INVALID_NUMBER;
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtopointer.c:1.2 rtems/cpukit/libmisc/stringto/stringtopointer.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtopointer.c:1.2 Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtopointer.c     Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,17 +15,33 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdint.h>
+
+#include <rtems/stringto.h>
+
</font> /*
<font color='#880000'>- *  Instantiate an error checking wrapper for strtoul which is
- *  used to input a (void *)
- *
- *  NOTE: This is only an appropriate implementation when unsigned long
- *        can represent a void *
</font><font color='#000088'>+ *  Instantiate an error checking wrapper for strtoul/strtoull (void *)
</font>  */
<font color='#880000'>-#define STRING_TO_POINTER
-#define STRING_TO_TYPE void *
-#define STRING_TO_INPUT_TYPE unsigned long
-#define STRING_TO_NAME rtems_string_to_pointer
-#define STRING_TO_METHOD strtoul
-#define STRING_TO_MAX ULONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+#if (UINTPTR_MAX == ULONG_MAX)
+#define STRTOFUNC(a,b,c)       rtems_string_to_unsigned_long(a, (unsigned long*) b, c, 0)
+#elif (UINTPTR_MAX == ULONG_LONG_MAX)
+#define STRTOFUNC(a,b,c)       rtems_string_to_unsigned_long_long(a, (unsigned long long*) b, c, 0)
+#elif (UINTPTR_MAX == UINT_MAX)
+#define STRTOFUNC(a,b,c)       rtems_string_to_unsigned_int(a, (unsigned int*) b, c, 0)
+#else
+/* Fallback to unsigned long */
+#define STRTOFUNC(a,b,c)       rtems_string_to_unsigned_long(a, (unsigned long*) b, c, 0)
+#endif
+
+rtems_status_code rtems_string_to_pointer (
+  const char *s,
+  void **n,
+  char **endptr
+)
+{
+  return STRTOFUNC( s, n, endptr );
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtounsignedchar.c:1.2 rtems/cpukit/libmisc/stringto/stringtounsignedchar.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtounsignedchar.c:1.2    Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtounsignedchar.c        Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,12 +15,52 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
</font> /*
<font color='#880000'>- *  Instantiate an error checking wrapper for strtol (unsigned char)
</font><font color='#000088'>+ *  Instantiate an error checking wrapper for strtoul (unsigned char)
</font>  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE unsigned char
-#define STRING_TO_NAME rtems_string_to_unsigned_char
-#define STRING_TO_METHOD strtoul
-#define STRING_TO_MAX ULONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_unsigned_char (
+  const char *s,
+  unsigned char *n,
+  char **endptr,
+  int base
+)
+{
+  unsigned long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtoul( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == ULONG_MAX )))
+      return RTEMS_INVALID_NUMBER;
+
+#if (UCHAR_MAX < ULONG_MAX)
+  if ( result > UCHAR_MAX ) {
+    errno = ERANGE;
+    return RTEMS_INVALID_NUMBER;
+  }
+#endif
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtounsignedint.c:1.2 rtems/cpukit/libmisc/stringto/stringtounsignedint.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtounsignedint.c:1.2     Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtounsignedint.c Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,12 +15,52 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
</font> /*
  *  Instantiate an error checking wrapper for strtoul (unsigned int)
  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE unsigned int
-#define STRING_TO_NAME rtems_string_to_unsigned_int
-#define STRING_TO_METHOD strtoul
-#define STRING_TO_MAX ULONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_unsigned_int (
+  const char *s,
+  unsigned int *n,
+  char **endptr,
+  int base
+)
+{
+  unsigned long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtoul( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == ULONG_MAX )))
+      return RTEMS_INVALID_NUMBER;
+
+#if (UINT_MAX < ULONG_MAX)
+  if ( result > UINT_MAX ) {
+    errno = ERANGE;
+    return RTEMS_INVALID_NUMBER;
+  }
+#endif
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtounsignedlong.c:1.2 rtems/cpukit/libmisc/stringto/stringtounsignedlong.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtounsignedlong.c:1.2    Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtounsignedlong.c        Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,12 +15,45 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
</font> /*
  *  Instantiate an error checking wrapper for strtoul (unsigned long)
  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE unsigned long int
-#define STRING_TO_NAME rtems_string_to_unsigned_long
-#define STRING_TO_METHOD strtoul
-#define STRING_TO_MAX ULONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_unsigned_long (
+  const char *s,
+  unsigned long *n,
+  char **endptr,
+  int base
+)
+{
+  unsigned long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtoul( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == ULONG_MAX )))
+      return RTEMS_INVALID_NUMBER;
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/stringto/stringtounsignedlonglong.c:1.2 rtems/cpukit/libmisc/stringto/stringtounsignedlonglong.c:1.2.2.1
--- rtems/cpukit/libmisc/stringto/stringtounsignedlonglong.c:1.2        Sun Mar 28 10:20:32 2010
+++ rtems/cpukit/libmisc/stringto/stringtounsignedlonglong.c    Tue Feb  1 20:30:10 2011
</font><font color='#997700'>@@ -2,6 +2,8 @@
</font>  *  COPYRIGHT (c) 2009.
  *  On-Line Applications Research Corporation (OAR).
  *
<font color='#000088'>+ *  Copyright (c) 2011  Ralf Corsépius, Ulm, Germany.
+ *
</font>  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
  *  http://www.rtems.com/license/LICENSE.
<font color='#997700'>@@ -13,12 +15,50 @@
</font> #include "config.h"
 #endif
 
<font color='#000088'>+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+#include <rtems/stringto.h>
+
+/* c99 has ULLONG_MAX instead of ULONG_LONG_MAX */
+#ifndef ULONG_LONG_MAX
+#define ULONG_LONG_MAX ULLONG_MAX
+#endif
+
</font> /*
  *  Instantiate an error checking wrapper for strtoull (unsigned long long)
  */
<font color='#880000'>-#define STRING_TO_INTEGER
-#define STRING_TO_TYPE unsigned long long
-#define STRING_TO_NAME rtems_string_to_unsigned_long_long
-#define STRING_TO_METHOD strtoull
-#define STRING_TO_MAX ULONG_LONG_MAX
-#include "stringto_template.h"
</font><font color='#000088'>+
+rtems_status_code rtems_string_to_unsigned_long_long (
+  const char *s,
+  unsigned long long *n,
+  char **endptr,
+  int base
+)
+{
+  unsigned long long result;
+  char *end;
+
+  if ( !n )
+    return RTEMS_INVALID_ADDRESS;
+
+  errno = 0;
+  *n = 0;
+
+  result = strtoull( s, &end, base );
+
+  if ( endptr )
+    *endptr = end;
+
+  if ( end == s )
+    return RTEMS_NOT_DEFINED;
+
+  if ( ( errno == ERANGE ) &&<span style="background-color: #FF0000"> </span>
+    (( result == 0 ) || ( result == ULONG_LONG_MAX )))
+      return RTEMS_INVALID_NUMBER;
+
+  *n = result;
+
+  return RTEMS_SUCCESSFUL;
+}
</font></pre>
<p> </p>

<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>