Last change
on this file was
cfe8f7a,
checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/20 at 14:14:06
|
doxygen: Switch @brief and @ingroup
This order change fixes the Latex documentation build via Doxygen.
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[f5f2676] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup libmisc_conv_help Conversion Helpers |
---|
[cfe8f7a] | 5 | * |
---|
| 6 | * @brief Convert String to Float (with validation) |
---|
[f5f2676] | 7 | */ |
---|
| 8 | |
---|
[e8d59ca] | 9 | /* |
---|
| 10 | * COPYRIGHT (c) 2009. |
---|
| 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
[8b9a33e8] | 13 | * Copyright (c) 2011 Ralf Corsépius, Ulm, Germany. |
---|
| 14 | * |
---|
[e8d59ca] | 15 | * The license and distribution terms for this file may be |
---|
| 16 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 17 | * http://www.rtems.org/license/LICENSE. |
---|
[e8d59ca] | 18 | */ |
---|
| 19 | |
---|
[56f61c7d] | 20 | #ifdef HAVE_CONFIG_H |
---|
| 21 | #include "config.h" |
---|
| 22 | #endif |
---|
| 23 | |
---|
[8b9a33e8] | 24 | #include <errno.h> |
---|
| 25 | #include <stdlib.h> |
---|
| 26 | #include <math.h> |
---|
| 27 | |
---|
| 28 | #include <rtems/stringto.h> |
---|
| 29 | |
---|
[e8d59ca] | 30 | /* |
---|
| 31 | * Instantiate an error checking wrapper for strtof (float) |
---|
| 32 | */ |
---|
[8b9a33e8] | 33 | |
---|
| 34 | rtems_status_code rtems_string_to_float ( |
---|
| 35 | const char *s, |
---|
| 36 | float *n, |
---|
| 37 | char **endptr |
---|
| 38 | ) |
---|
| 39 | { |
---|
| 40 | float result; |
---|
| 41 | char *end; |
---|
| 42 | |
---|
| 43 | if ( !n ) |
---|
| 44 | return RTEMS_INVALID_ADDRESS; |
---|
| 45 | |
---|
| 46 | errno = 0; |
---|
| 47 | *n = 0; |
---|
| 48 | |
---|
| 49 | result = strtof( s, &end ); |
---|
| 50 | |
---|
| 51 | if ( endptr ) |
---|
| 52 | *endptr = end; |
---|
| 53 | |
---|
| 54 | if ( end == s ) |
---|
| 55 | return RTEMS_NOT_DEFINED; |
---|
| 56 | |
---|
[f5f2676] | 57 | if ( ( errno == ERANGE ) && |
---|
[a38457a] | 58 | (( result == 0 ) || ( result == HUGE_VALF ) || ( result == -HUGE_VALF ))) |
---|
[8b9a33e8] | 59 | return RTEMS_INVALID_NUMBER; |
---|
| 60 | |
---|
| 61 | *n = result; |
---|
| 62 | |
---|
| 63 | return RTEMS_SUCCESSFUL; |
---|
| 64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.