fixed bug #604575
[fw/sdcc] / support / cpp2 / cppfiles.c
index 137882b340c231159a673df5144fbc796069dc97..6c9a69fe1b7e820de55417cf8c35cac9d819485d 100644 (file)
@@ -378,11 +378,15 @@ read_include_file (pfile, inc)
         SSIZE_MAX to be much smaller than the actual range of the
         type.  Use INTTYPE_MAXIMUM unconditionally to ensure this
         does not bite us.  */
+#ifndef __BORLANDC__
       if (inc->st.st_size > INTTYPE_MAXIMUM (ssize_t))
        {
-         cpp_error (pfile, "%s is too large", inc->name);
+         cpp_error (pfile, "%s is too large (%lu > %lu)", inc->name, 
+                    (unsigned long)inc->st.st_size,
+                    INTTYPE_MAXIMUM(ssize_t));
          goto fail;
        }
+#endif 
       size = inc->st.st_size;
 
       inc->mapped = 0;
@@ -409,7 +413,18 @@ read_include_file (pfile, inc)
                goto perror_fail;
              if (count == 0)
                {
-                 cpp_warning (pfile, "%s is shorter than expected", inc->name);
+#ifndef __BORLANDC__               
+                 /* For some reason, even though we opened with O_BINARY, 
+                  * Borland C++ seems to insist on doing CR/LF -> LF 
+                  * translations for us, which results in the file appearing
+                  * shorter than stat told us it should be.
+                  * 
+                  * This sucks, but don't bother throwing a warning.
+                  */
+                 cpp_warning (pfile, "%s is shorter than expected (expected %u, got %u)", 
+                              inc->name, inc->st.st_size, offset);
+#endif             
+                 inc->st.st_size = offset;
                  break;
                }
              offset += count;