--- cppfiles.c~ 2004-07-16 17:16:42.000000000 +0000 +++ cppfiles.c 2004-09-07 19:12:36.000000000 +0000 @@ -40,6 +40,7 @@ #endif #ifdef __DJGPP__ +#include /* For DJGPP redirected input is opened in text mode. */ # define set_stdin_to_binary_mode() \ if (! isatty (0)) setmode (0, O_BINARY) @@ -231,6 +232,19 @@ } else if (errno == ENOTDIR) errno = ENOENT; +#if defined(__DJGPP__) + /* DJGPP v2.03 library open returns errno=EACCES on + attempt to open directory. Therefore test on EACCES + whether it's an directory */ + else if (errno==EACCES) + { + struct stat st; + if (stat(file->path,&st)==0 && S_ISDIR(st.st_mode)) + errno = ENOENT; + else + errno = EACCES; + } +#endif /* __DJGPP__ */ file->err_no = errno; @@ -509,6 +523,14 @@ cpp_error (pfile, CPP_DL_WARNING, "%s is shorter than expected", file->path); +#ifdef __DJGPP__ + /* For DOS we should handle DOS EOF character (0x1A, ^Z) */ + do { + uchar * dos_eof = memchr (buf, 0x1A, total); + if (dos_eof) total = dos_eof - buf; + } while (0); +#endif + file->buffer = _cpp_convert_input (pfile, CPP_OPTION (pfile, input_charset), buf, size, total, &file->st.st_size); file->buffer_valid = true;