mirror of
https://github.com/python/cpython.git
synced 2025-11-15 16:09:29 +00:00
(Jack:) On the Mac, give syntax error on \r.
This commit is contained in:
parent
3648884490
commit
2d45be1366
1 changed files with 11 additions and 0 deletions
|
|
@ -303,13 +303,16 @@ tok_nextc(tok)
|
||||||
done = tok->inp[-1] == '\n';
|
done = tok->inp[-1] == '\n';
|
||||||
}
|
}
|
||||||
tok->cur = tok->buf + cur;
|
tok->cur = tok->buf + cur;
|
||||||
|
#ifndef macintosh
|
||||||
/* replace "\r\n" with "\n" */
|
/* replace "\r\n" with "\n" */
|
||||||
|
/* For Mac we leave the \r, giving a syntax error */
|
||||||
pt = tok->inp - 2;
|
pt = tok->inp - 2;
|
||||||
if (pt >= tok->buf && *pt == '\r') {
|
if (pt >= tok->buf && *pt == '\r') {
|
||||||
*pt++ = '\n';
|
*pt++ = '\n';
|
||||||
*pt = '\0';
|
*pt = '\0';
|
||||||
tok->inp = pt;
|
tok->inp = pt;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (tok->done != E_OK) {
|
if (tok->done != E_OK) {
|
||||||
if (tok->prompt != NULL)
|
if (tok->prompt != NULL)
|
||||||
|
|
@ -560,6 +563,14 @@ tok_get(tok, p_start, p_end)
|
||||||
return NEWLINE;
|
return NEWLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef macintosh
|
||||||
|
if (c == '\r') {
|
||||||
|
fprintf(stderr, "File contains \\r characters (incorrect line endings?)\n");
|
||||||
|
tok->done = E_TOKEN;
|
||||||
|
tok->cur = tok->inp;
|
||||||
|
return ERRORTOKEN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* Period or number starting with period? */
|
/* Period or number starting with period? */
|
||||||
if (c == '.') {
|
if (c == '.') {
|
||||||
c = tok_nextc(tok);
|
c = tok_nextc(tok);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue