diff --git a/modules/src/input/inp_pkg.body b/modules/src/input/inp_pkg.body index 6de4a5268..0bc80804d 100644 --- a/modules/src/input/inp_pkg.body +++ b/modules/src/input/inp_pkg.body @@ -340,6 +340,28 @@ InsertText(text, length) 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 which may be the end-of-buffer mark of the current input buffer. The '\0' could be genuine although not likely. diff --git a/modules/src/input/inp_pkg.spec b/modules/src/input/inp_pkg.spec index c349fa896..1b12a3f49 100644 --- a/modules/src/input/inp_pkg.spec +++ b/modules/src/input/inp_pkg.spec @@ -20,7 +20,7 @@ /* INPUT PRIMITIVES */ -#define LoadChar(dest) ((void)((dest = *_ipp++) || (dest = loadbuf()))) +#define LoadChar(dest) (dest = loadchar()) #define PushBack() (--_ipp) #define ChPushBack(ch) (*--_ipp = (ch)) @@ -31,6 +31,7 @@ extern char *_ipp; +_PROTOTYPE(int loadchar, (void)); _PROTOTYPE(int loadbuf, (void)); _PROTOTYPE(int AtEoIT, (void)); _PROTOTYPE(int AtEoIF, (void));