javar/jdk8-analysis/src/launcher/version_comp.c
/*
 *      Validate a string as parsable as a "Java int". If so parsable,
 *      return true (non-zero) and store the numeric value at the address
 *      passed in as "value"; otherwise return false (zero).
 *
 *      Note that the maximum allowable value is 2147483647 as defined by
 *      the "Java Language Specification" which precludes the use of native
 *      conversion routines which may have other limits.
 *
 *      Also note that we don't have to worry about the alternate maximum
 *      allowable value of 2147483648 because it is only allowed after
 *      the unary negation operator and this grammar doesn't have one
 *      of those.
 *
 *      Finally, note that a value which exceeds the maximum jint value will
 *      return false (zero). This results in the otherwise purely numeric
 *      string being compared as a string of characters (as per the spec.)
 */
Validate a string as parsable as a "Java int". If so parsable,
return true (non-zero) and store the numeric value at the address
passed in as "value"; otherwise return false (zero).

Note that the maximum allowable value is 2147483647 as defined by
the "Java Language Specification" which precludes the use of native
conversion routines which may have other limits.

Also note that we don't have to worry about the alternate maximum
allowable value of 2147483648 because it is only allowed after
the unary negation operator and this grammar doesn't have one
of those.

Finally, note that a value which exceeds the maximum jint value will
return false (zero). This results in the otherwise purely numeric
string being compared as a string of characters (as per the spec.)
Validate a string as parsable as a " Java int " . If so parsable return true ( non - zero ) and store the numeric value at the address passed in as " value " ; otherwise return false ( zero ) . Note that the maximum allowable value is 2147483647 as defined by the " Java Language Specification " which precludes the use of native conversion routines which may have other limits . Also note that we don ' t have to worry about the alternate maximum allowable value of 2147483648 because it is only allowed after the unary negation operator and this grammar doesn ' t have one of those . Finally note that a value which exceeds the maximum jint value will return false ( zero ) . This results in the otherwise purely numeric string being compared as a string of characters ( as per the spec . )
static int
isjavaint(const char *s, jint *value)
{
    jlong sum = 0;
    jint digit;
    while (*s != '\0')
        if (isdigit(*s)) {
            digit = (jint)((int)(*s++) - (int)('0'));
            sum = (sum * 10) + digit;
            if (sum > 2147483647)
                return (0);     
        } else
            return (0);
    *value = (jint)sum;
    return (1);
}
static int isjavaint ( const char * s , jint * value ) { jlong sum = 0 ; jint digit ; while ( * s != ' \0 ' ) if ( isdigit ( * s ) ) { digit = ( jint ) ( ( int ) ( * s ++ ) - ( int ) ( ' ' ) ) ; sum = ( sum * 10 ) + digit ; if ( sum > 2147483647 ) return ( 0 ) ; } else return ( 0 ) ; * value = ( jint ) sum ; return ( 1 ) ; }
Validate a string as parsable as a "Java int".
Validate a string as parsable as a " Java int " .
/* Overflows jint (but not jlong) */