cbits/field.c
numeric_field warden_field_numeric(const char *buf, size_t n) {
	size_t i = 0;
	int preradix_digits = 0; /* digits before the radix point */
	int exponent_digits = 0; /* digits in the exponent (scientific notation) */

	if (n < 1) {
		return non_numeric_field;
	}
	if (buf[i] == '+' || buf[i] == '-') {
		i++;
	}
	while (is_digit(buf[i]) && i < n) {
		i++;
		preradix_digits++;
	}

	/* "+" or "-" on its own */
	if (preradix_digits == 0) {
		return non_numeric_field;
	}

	/* got the whole int, we're done */
	if (i == n) {
		return integral_field;
	}

	/* optional postradix part */
	if (buf[i] == '.') {
		i++;
		while (i < n && is_digit(buf[i])) {
			i++;
		}
		/* one of "n." or "n.m", counts as real either way */
		if (i == n) {
			return real_field;
		}
	}

	/* scientific notation, or just cruft on the end? */
	if (buf[i] != 'e') {
		/* cruft */
		return non_numeric_field;
	}

	/* scientific notation */

	i++;

	if (i < n && (buf[i] == '+' || buf[i] == '-')) {
		i++;
	}

	while (i < n && is_digit(buf[i])) {
		i++;
		exponent_digits++;
	}

	/* need at least one exponent digit, "1.2e-" doesn't make sense on its
	   own */
	if (i == n && exponent_digits) {
		return real_field;
	}

	/* just cruft on the end after all */
	return non_numeric_field;
}
/* Returns integral_field for a (possibly signed) decimal integer.

   Returns real_field for a (possibly signed) decimal number, possibly
   in scientific notation.

   Otherwise returns non_numeric_field. */
Returns integral_field for a (possibly signed) decimal integer.
Returns real_field for a (possibly signed) decimal number, possibly
in scientific notation.


Returns integral_field for a ( possibly signed ) decimal integer . Returns real_field for a ( possibly signed ) decimal number possibly in scientific notation .
numeric_field warden_field_numeric(const char *buf, size_t n) {
	size_t i = 0;
	int preradix_digits = 0; 
	int exponent_digits = 0; 
	if (n < 1) {
		return non_numeric_field;
	}
	if (buf[i] == '+' || buf[i] == '-') {
		i++;
	}
	while (is_digit(buf[i]) && i < n) {
		i++;
		preradix_digits++;
	}
	if (preradix_digits == 0) {
		return non_numeric_field;
	}
	if (i == n) {
		return integral_field;
	}
	if (buf[i] == '.') {
		i++;
		while (i < n && is_digit(buf[i])) {
			i++;
		}
		if (i == n) {
			return real_field;
		}
	}
	if (buf[i] != 'e') {
		return non_numeric_field;
	}
	i++;
	if (i < n && (buf[i] == '+' || buf[i] == '-')) {
		i++;
	}
	while (i < n && is_digit(buf[i])) {
		i++;
		exponent_digits++;
	}
	if (i == n && exponent_digits) {
		return real_field;
	}
	return non_numeric_field;
}
numeric_field warden_field_numeric ( const char * buf , size_t n ) { size_t i = 0 ; int preradix_digits = 0 ; int exponent_digits = 0 ; if ( n < 1 ) { return non_numeric_field ; } if ( buf [ i ] == ' ' || buf [ i ] == ' ' ) { i ++ ; } while ( is_digit ( buf [ i ] ) && i < n ) { i ++ ; preradix_digits ++ ; } if ( preradix_digits == 0 ) { return non_numeric_field ; } if ( i == n ) { return integral_field ; } if ( buf [ i ] == ' ' ) { i ++ ; while ( i < n && is_digit ( buf [ i ] ) ) { i ++ ; } if ( i == n ) { return real_field ; } } if ( buf [ i ] != ' ' ) { return non_numeric_field ; } i ++ ; if ( i < n && ( buf [ i ] == ' ' || buf [ i ] == ' ' ) ) { i ++ ; } while ( i < n && is_digit ( buf [ i ] ) ) { i ++ ; exponent_digits ++ ; } if ( i == n && exponent_digits ) { return real_field ; } return non_numeric_field ; }
Returns integral_field for a (possibly signed) decimal integer.
Returns integral_field for a ( possibly signed ) decimal integer .
/* digits before the radix point */ /* digits in the exponent (scientific notation) */ /* "+" or "-" on its own */ /* got the whole int, we're done */ /* optional postradix part */ /* one of "n." or "n.m", counts as real either way */ /* scientific notation, or just cruft on the end? */ /* cruft */ /* scientific notation */ /* need at least one exponent digit, "1.2e-" doesn't make sense on its
	   own */ /* just cruft on the end after all */