[PATCH-YAP 3/4] ISO: Restrict binary, octal, hexadecimal integer constant indicators

and exponent char to minuscules.  (6.4.4)
from Ulrich Neumerkel
This commit is contained in:
Vitor Santos Costa 2010-11-21 21:55:58 +00:00
parent 86d0a251b5
commit c4913849c6

View File

@ -547,7 +547,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
ch = Nxtch(inp_stream); ch = Nxtch(inp_stream);
} }
} }
} else if ((ch == 'x' || ch == 'X') && base == 0) { } else if (ch == 'x' && base == 0) {
might_be_float = FALSE; might_be_float = FALSE;
if (--max_size == 0) { if (--max_size == 0) {
Yap_ErrorMessage = "Number Too Long"; Yap_ErrorMessage = "Number Too Long";
@ -571,11 +571,11 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
} }
*chp = ch; *chp = ch;
} }
else if ((ch == 'o' || ch == 'O') && base == 0) { else if (ch == 'o' && base == 0) {
might_be_float = FALSE; might_be_float = FALSE;
base = 8; base = 8;
ch = Nxtch(inp_stream); ch = Nxtch(inp_stream);
} else if ((ch == 'b' || ch == 'B') && base == 0) { } else if (ch == 'b' && base == 0) {
might_be_float = FALSE; might_be_float = FALSE;
base = 2; base = 2;
ch = Nxtch(inp_stream); ch = Nxtch(inp_stream);
@ -602,7 +602,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
has_overflow = TRUE; has_overflow = TRUE;
ch = Nxtch(inp_stream); ch = Nxtch(inp_stream);
} }
if (might_be_float && (ch == '.' || ch == 'e' || ch == 'E')) { if (might_be_float && (ch == '.' || ch == 'e' )) {
if (ch == '.') { if (ch == '.') {
if (--max_size == 0) { if (--max_size == 0) {
Yap_ErrorMessage = "Number Too Long"; Yap_ErrorMessage = "Number Too Long";
@ -628,7 +628,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
} }
while (chtype(ch = Nxtch(inp_stream)) == NU); while (chtype(ch = Nxtch(inp_stream)) == NU);
} }
if (ch == 'e' || ch == 'E') { if (ch == 'e') {
char *sp0 = sp; char *sp0 = sp;
char cbuff = ch; char cbuff = ch;
@ -654,15 +654,7 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
/* error */ /* error */
char *sp; char *sp;
*chp = ch; *chp = ch;
if (*sp0 == 'E') { *chbuffp = cbuff;
/* code the fact that we have E and not e */
if (cbuff == '+')
*chbuffp = '=';
else
*chbuffp = '_';
} else {
*chbuffp = cbuff;
}
*sp0 = '\0'; *sp0 = '\0';
for (sp = s; sp < sp0; sp++) { for (sp = s; sp < sp0; sp++) {
if (*sp == '.') if (*sp == '.')
@ -685,11 +677,11 @@ get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*Quoted
*sp = '\0'; *sp = '\0';
/* skip base */ /* skip base */
*chp = ch; *chp = ch;
if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) if (s[0] == '0' && s[1] == 'x')
return read_int_overflow(s+2,16,val,sign); return read_int_overflow(s+2,16,val,sign);
else if (s[0] == '0' && (s[1] == 'o' || s[1] == 'O')) else if (s[0] == '0' && s[1] == 'o')
return read_int_overflow(s+2,8,val,sign); return read_int_overflow(s+2,8,val,sign);
else if (s[0] == '0' && (s[1] == 'b' || s[1] == 'B')) else if (s[0] == '0' && s[1] == 'b')
return read_int_overflow(s+2,2,val,sign); return read_int_overflow(s+2,2,val,sign);
if (s[1] == '\'') if (s[1] == '\'')
return read_int_overflow(s+2,base,val,sign); return read_int_overflow(s+2,base,val,sign);