version 1.24, 2004/06/01 19:57:18
|
version 1.25, 2005/12/01 20:05:22
|
Line 2454 check_input_usymb(u_symb)char *u_symb;
|
Line 2454 check_input_usymb(u_symb)char *u_symb;
|
/* num_p : the numerical part in string */ |
/* num_p : the numerical part in string */ |
/* unit_p : the unit string */ |
/* unit_p : the unit string */ |
/* num_p is used to calculate sig figs */ |
/* num_p is used to calculate sig figs */ |
/* return : 0 empty string */ |
/* return : -1 invalid string */ |
|
/* 0 empty string */ |
/* 1 number without units */ |
/* 1 number without units */ |
/* 2 empty number with units */ |
/* 2 empty number with units */ |
/* 3 number with units */ |
/* 3 number with units */ |
Line 2505 char *buf;double *num; char *num_p; char
|
Line 2506 char *buf;double *num; char *num_p; char
|
|
|
e_part = 1.0; /* default power */ |
e_part = 1.0; /* default power */ |
base_str[b_idx] = 0; /* initialize base_str[] */ |
base_str[b_idx] = 0; /* initialize base_str[] */ |
while( isdigit(buf[idx]) || buf[idx] == '.' ) { /* should start with a digit or . */ |
if( buf[idx] == '1' && buf[idx+1] == '0') { |
base_str[b_idx++] = buf[idx++]; |
base_str[b_idx++] = buf[idx++]; |
|
base_str[b_idx++] = buf[idx++]; |
|
} else { |
|
return (-1); |
} |
} |
base_str[b_idx] = 0; /* terminate base_str[] */ |
base_str[b_idx] = 0; /* terminate base_str[] */ |
while( isspace(buf[idx]) ) { idx++; } /* skip over white spaces */ |
while( isspace(buf[idx]) ) { idx++; } /* skip over white spaces */ |
Line 2520 char *buf;double *num; char *num_p; char
|
Line 2524 char *buf;double *num; char *num_p; char
|
while( isspace(buf[idx]) ) { idx++; } |
while( isspace(buf[idx]) ) { idx++; } |
if( isdigit(buf[idx]) || buf[idx] == '+' || buf[idx] == '-' ) { |
if( isdigit(buf[idx]) || buf[idx] == '+' || buf[idx] == '-' ) { |
exp_str[e_idx] = 0; /* initialize exp_str[], again */ |
exp_str[e_idx] = 0; /* initialize exp_str[], again */ |
while( isdigit(buf[idx]) || buf[idx] == '.' || buf[idx] == '+' || buf[idx] == '-' ) { |
while( isdigit(buf[idx]) /*|| buf[idx] == '.'*/ || buf[idx] == '+' || buf[idx] == '-' ) { |
exp_str[e_idx++] = buf[idx++]; |
exp_str[e_idx++] = buf[idx++]; |
} |
} |
exp_str[e_idx] = 0; /* terminate exp_str[] */ |
exp_str[e_idx] = 0; /* terminate exp_str[] */ |
Line 2554 char *buf;double *num; char *num_p; char
|
Line 2558 char *buf;double *num; char *num_p; char
|
while( isspace(buf[idx]) ) { idx++; } |
while( isspace(buf[idx]) ) { idx++; } |
if( isdigit(buf[idx]) || buf[idx] == '+' || buf[idx] == '-' ) { |
if( isdigit(buf[idx]) || buf[idx] == '+' || buf[idx] == '-' ) { |
exp_str[e_idx] = 0; |
exp_str[e_idx] = 0; |
while( isdigit(buf[idx]) || buf[idx] == '.' || buf[idx] == '+' || buf[idx] == '-' ) { |
while( isdigit(buf[idx]) /*|| buf[idx] == '.'*/ || buf[idx] == '+' || buf[idx] == '-' ) { |
exp_str[e_idx++] = buf[idx++]; |
exp_str[e_idx++] = buf[idx++]; |
} |
} |
exp_str[e_idx] = 0; |
exp_str[e_idx] = 0; |
Line 2565 char *buf;double *num; char *num_p; char
|
Line 2569 char *buf;double *num; char *num_p; char
|
} |
} |
sscanf(exp_str, "%lg", &e_part); |
sscanf(exp_str, "%lg", &e_part); |
sscanf(num_str, "%lg", &n_part); |
sscanf(num_str, "%lg", &n_part); |
|
if( n_part != 10 ) { |
|
return (-1); |
|
} |
result = pow(n_part,e_part); |
result = pow(n_part,e_part); |
errcode = errcode | 1; |
errcode = errcode | 1; |
} else { /* number unit */ |
} else { /* number unit */ |
Line 2953 capa_check_ans(ai,ans, error) AnswerInfo
|
Line 2960 capa_check_ans(ai,ans, error) AnswerInfo
|
all_alphabet = 0; |
all_alphabet = 0; |
} |
} |
} |
} |
if( !all_alphabet ) { /* answer string is not all alphabets */ |
if( !all_alphabet ) { |
outcome = split_num_unit(ans,&n_part,num_str,unit_str); |
outcome = split_num_unit(ans,&n_part,num_str,unit_str); |
|
} |
|
if( outcome > 0 ) { |
if( outcome > 1 ) { /* with both num and unit parts or only unit part */ |
if( outcome > 1 ) { /* with both num and unit parts or only unit part */ |
if( u_p != NULL ) { |
if( u_p != NULL ) { |
result = check_correct_unit(unit_str,u_p,&scale); |
result = check_correct_unit(unit_str,u_p,&scale); |
Line 3122 capa_check_answer(p, answer, error) Prob
|
Line 3131 capa_check_answer(p, answer, error) Prob
|
} |
} |
if( !all_alphabet ) { |
if( !all_alphabet ) { |
outcome = split_num_unit(answer,&n_part,input,unit_str); |
outcome = split_num_unit(answer,&n_part,input,unit_str); |
|
} |
|
if( outcome > 0 ) { |
if( outcome > 1 ) { /* with both num and unit parts or only unit part */ |
if( outcome > 1 ) { /* with both num and unit parts or only unit part */ |
if( p->ans_unit != NULL ) { |
if( p->ans_unit != NULL ) { |
result = check_correct_unit(unit_str,p->ans_unit,&scale); |
result = check_correct_unit(unit_str,p->ans_unit,&scale); |