Convert CRLF into LF on read; this should avoid problems with parsing CRLF files.
Fixes #117.
This commit is contained in:
parent
788f439a48
commit
fa1ba55ad2
|
@ -340,6 +340,28 @@ InsertText(text, length)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RAWLOAD(dest) \
|
||||||
|
((void)((dest = *_ipp++) || (dest = loadbuf())))
|
||||||
|
|
||||||
|
/* Reads the next character, converting CRLF into LF. */
|
||||||
|
int
|
||||||
|
loadchar(void)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
RAWLOAD(ch);
|
||||||
|
if (ch == '\r')
|
||||||
|
{
|
||||||
|
RAWLOAD(ch);
|
||||||
|
if (ch != '\n')
|
||||||
|
{
|
||||||
|
/* Oops, this isn't a CRLF; put back the char we just read. */
|
||||||
|
ChPushBack(ch);
|
||||||
|
}
|
||||||
|
ch = '\n';
|
||||||
|
}
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
/* loadbuf() is called if LoadChar meets a '\0' character
|
/* loadbuf() is called if LoadChar meets a '\0' character
|
||||||
which may be the end-of-buffer mark of the current input
|
which may be the end-of-buffer mark of the current input
|
||||||
buffer. The '\0' could be genuine although not likely.
|
buffer. The '\0' could be genuine although not likely.
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
/* INPUT PRIMITIVES */
|
/* INPUT PRIMITIVES */
|
||||||
|
|
||||||
#define LoadChar(dest) ((void)((dest = *_ipp++) || (dest = loadbuf())))
|
#define LoadChar(dest) (dest = loadchar())
|
||||||
#define PushBack() (--_ipp)
|
#define PushBack() (--_ipp)
|
||||||
#define ChPushBack(ch) (*--_ipp = (ch))
|
#define ChPushBack(ch) (*--_ipp = (ch))
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
extern char *_ipp;
|
extern char *_ipp;
|
||||||
|
|
||||||
|
_PROTOTYPE(int loadchar, (void));
|
||||||
_PROTOTYPE(int loadbuf, (void));
|
_PROTOTYPE(int loadbuf, (void));
|
||||||
_PROTOTYPE(int AtEoIT, (void));
|
_PROTOTYPE(int AtEoIT, (void));
|
||||||
_PROTOTYPE(int AtEoIF, (void));
|
_PROTOTYPE(int AtEoIF, (void));
|
||||||
|
|
Loading…
Reference in a new issue