- /* strip leading spaces */
- while ((len > 0) && (*str == ' ')) { len--; str++; }
-
- /* if the first two characters are 0x or 0X -> hex
- * if the first is a 0 -> oct
- * else dec, strip leading -/+ and remember sign
- *
- * only a + or - sign is no number resulting in an error */
- if (len >= 2) {
- switch (str[0]) {
- case '0':
- if (str[1] == 'x' || str[1] == 'X') { /* hex */
- str += 2;
- len -= 2;
- base[1] = SC_1; base[0] = SC_0;
- } else { /* oct */
- str += 1;
- len -= 1;
- base[1] = SC_0; base[0] = SC_8;
- }
- break;
-
- case '+':
- str += 1;
- len -= 1;
- base[1] = SC_0; base[0] = SC_A;
- break;
-
- case '-':
- str += 1;
- len -= 1;
- sign = 1;
- base[1] = SC_0; base[0] = SC_A;
- break;
-
- default: /* dec, else would have begun with 0x or 0 */
- base[1] = SC_0; base[0] = SC_A;
- }
- } else { /* dec, else would have begun with 0x or 0 */
- base[1] = SC_0; base[0] = SC_A;
- }
-