Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 25a76ab8 in mainline for kernel/generic/src/lib/func.c


Ignore:
Timestamp:
2010-05-08T07:53:23Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
051bc69a
Parents:
6c39a907 (diff), 1317380 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/lib/func.c

    r6c39a907 r25a76ab8  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3333/**
    3434 * @file
    35  * @brief       Miscellaneous functions.
     35 * @brief Miscellaneous functions.
    3636 */
    3737
     
    7979}
    8080
    81 /** Convert ascii representation to unative_t
    82  *
    83  * Supports 0x for hexa & 0 for octal notation.
    84  * Does not check for overflows, does not support negative numbers
    85  *
    86  * @param text Textual representation of number
    87  * @return Converted number or 0 if no valid number ofund
    88  */
    89 unative_t atoi(const char *text)
    90 {
    91         int base = 10;
    92         unative_t result = 0;
    93 
    94         if (text[0] == '0' && text[1] == 'x') {
    95                 base = 16;
    96                 text += 2;
    97         } else if (text[0] == '0')
    98                 base = 8;
    99 
    100         while (*text) {
    101                 if (base != 16 && \
    102                     ((*text >= 'A' && *text <= 'F' )
    103                      || (*text >='a' && *text <='f')))
    104                         break;
    105                 if (base == 8 && *text >='8')
    106                         break;
    107 
    108                 if (*text >= '0' && *text <= '9') {
    109                         result *= base;
    110                         result += *text - '0';
    111                 } else if (*text >= 'A' && *text <= 'F') {
    112                         result *= base;
    113                         result += *text - 'A' + 10;
    114                 } else if (*text >= 'a' && *text <= 'f') {
    115                         result *= base;
    116                         result += *text - 'a' + 10;
    117                 } else
    118                         break;
    119                 text++;
    120         }
    121 
    122         return result;
    123 }
    124 
    12581/** @}
    12682 */
Note: See TracChangeset for help on using the changeset viewer.