-void *fc_val_from_str(const char *str, unsigned int len, char exp_size, char mant_size, void *result) {
-#if 0
- enum {
- START,
- LEFT_OF_DOT,
- RIGHT_OF_DOT,
- EXP_START,
- EXPONENT,
- END
- };
-
- char exp_sign;
- int exp_int, hsb, state;
-
- const char *old_str;
-
- int pos;
- char *mant_str, *exp_val, *power_val;
-
- (void) len;
- if (result == NULL) result = calc_buffer;
-
- exp_val = alloca(value_size);
- power_val = alloca(calc_buffer_size);
- mant_str = alloca((len)?(len):(strlen(str)));
-
- result->desc.exponent_size = exp_size;
- result->desc.mantissa_size = mant_size;
- result->desc.clss = NORMAL;
-
- old_str = str;
- pos = 0;
- exp_int = 0;
- state = START;
-
- while (len == 0 || str-old_str < len) {
- switch (state) {
- case START:
- switch (*str) {
- case '+':
- result->sign = 0;
- state = LEFT_OF_DOT;
- str++;
- break;
-
- case '-':
- result->sign = 1;
- state = LEFT_OF_DOT;
- str++;
- break;
-
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- result->sign = 0;
- state = LEFT_OF_DOT;
- break;
-
- case '.':
- result->sign = 0;
- state = RIGHT_OF_DOT;
- str++;
- break;
-
- case 'n':
- case 'N':
- case 'i':
- case 'I':
- break;
-
- default:
- fail_char(old_str, len, str - old_str);
- }
- break;
-
- case LEFT_OF_DOT:
- switch (*str) {
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- mant_str[pos++] = *(str++);
- break;
-
- case '.':
- state = RIGHT_OF_DOT;
- str++;
- break;
-
- case 'e':
- case 'E':
- state = EXP_START;
- str++;
- break;
-
- case '\0':
- mant_str[pos] = '\0';
- goto done;
-
- default:
- fail_char(old_str, len, str - old_str);
- }
- break;
-
- case RIGHT_OF_DOT:
- switch (*str) {
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- mant_str[pos++] = *(str++);
- exp_int++;
- break;
-
- case 'e':
- case 'E':
- state = EXP_START;
- str++;
- break;
-
- case '\0':
- mant_str[pos] = '\0';
- goto done;
-
- default:
- fail_char(old_str, len, str - old_str);
- }
- break;
-
- case EXP_START:
- switch (*str) {
- case '-':
- exp_sign = 1;
- /* fall through */
- case '+':
- if (*(str-1) != 'e' && *(str-1) != 'E') fail_char(old_str, len, str - old_str);
- str++;
- break;
-
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- mant_str[pos] = '\0';
- pos = 1;
- str++;
- state = EXPONENT;
- break;
-
- default:
- fail_char(old_str, len, str - old_str);
- }
- break;
-
- case EXPONENT:
- switch (*str) {
- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- pos++;
- str++;
- break;
-
- case '\0': goto done;
-
- default:
- fail_char(old_str, len, str - old_str);
- }
- }
- } /* switch(state) */
-
-done:
- sc_val_from_str(mant_str, strlen(mant_str), _mant(result));
-
- /* shift to put value left of radix point */
- sc_val_from_ulong(mant_size + ROUNDING_BITS, exp_val);
-
- _shift_left(_mant(result), exp_val, _mant(result));