Ignore:
Timestamp:
Jul 23, 2009, 2:32:34 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 5, master
Children:
7611ed8e
Parents:
73dfaf8
Message:

2009-07-23 Joel Sherrill <joel.sherrill@…>

  • libmisc/Makefile.am, libmisc/shell/main_chmod.c, libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c, libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c, libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c, libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c, libmisc/shell/shell_script.c, libmisc/stringto/stringto.h, libmisc/stringto/stringto_template.h: Convert return type from bool to rtems_status_code and add rtems_string_to_pointer. Perform associated clean up and changes for return type change.
  • libmisc/stringto/stringtopointer.c: New file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/stringto/stringto_template.h

    r73dfaf8 r48751ab  
    1010 */
    1111
     12#include <rtems/stringto.h>
     13
    1214#include <errno.h>
    1315#include <stdlib.h>
     
    1517#include <stdbool.h>
    1618
    17 #include <math.h>
     19/*
     20 *  If we are doing floating point conversion, then we need math.h
     21 */
     22#if defined(STRING_TO_FLOAT)
     23  #include <math.h>
     24#endif
     25
     26#include <rtems.h>
    1827
    1928/*
     
    2130 * it and should NOT be protected against multiple inclusions.
    2231 */
     32
     33#if defined(STRING_TO_POINTER)
     34  #define STRING_TO_INTEGER
     35#endif
    2336
    2437#if !defined(STRING_TO_FLOAT) && !defined(STRING_TO_INTEGER)
     
    5366#endif
    5467
    55 bool STRING_TO_NAME (
     68#if !defined(STRING_TO_INPUT_TYPE)
     69  #define STRING_TO_INPUT_TYPE STRING_TO_TYPE
     70#endif
     71
     72rtems_status_code STRING_TO_NAME (
    5673  const char      *s,
    5774  STRING_TO_TYPE  *n,
    5875  char           **endptr
    59   #if defined(STRING_TO_INTEGER)
     76  #if defined(STRING_TO_INTEGER) && !defined(STRING_TO_POINTER)
    6077    ,
    6178    int              base
     
    6380)
    6481{
    65   STRING_TO_TYPE  result;
    66   char           *end;
     82  STRING_TO_INPUT_TYPE  result;
     83  char                 *end;
    6784
    6885  if ( !n )
    69     return false;
     86    return RTEMS_INVALID_ADDRESS;
    7087
    7188  errno = 0;
     
    7491  #ifdef STRING_TO_FLOAT
    7592    result = STRING_TO_METHOD( s, &end );
     93  #elif defined(STRING_TO_POINTER)
     94    result = STRING_TO_METHOD( s, &end, 16 );
    7695  #elif defined(STRING_TO_INTEGER)
    7796    result = STRING_TO_METHOD( s, &end, base );
     
    84103  /* nothing was converted */
    85104  if ( end == s )
    86     return false;
     105    return RTEMS_NOT_DEFINED;
    87106
    88107  /* there was a conversion error */
    89108  if ( (result == ZERO) && errno )
    90     return false;
     109    return RTEMS_INVALID_NUMBER;
    91110
    92111  #ifdef STRING_TO_MAX
    93112    /* there was an overflow */
    94113    if ( (result == STRING_TO_MAX) && (errno == ERANGE))
    95       return false;
     114      return RTEMS_INVALID_NUMBER;
    96115  #endif
    97116
     
    99118    /* there was an underflow */
    100119    if ( (result == STRING_TO_MIN) && (errno == ERANGE))
    101       return false;
     120      return RTEMS_INVALID_NUMBER;
    102121  #endif
    103122
    104123  *n = (STRING_TO_TYPE) result;
    105   return true;
     124  return RTEMS_SUCCESSFUL;
    106125}
    107126
Note: See TracChangeset for help on using the changeset viewer.