@@ -1974,7 +1974,8 @@ bool createModules(ref Strings files, ref Strings libmodules, ref Param params,
19741974
19751975 // Set the source file contents of the module
19761976 OutBuffer buf;
1977- buf.readFromStdin();
1977+ if (buf.readFromStdin(eSink))
1978+ return true ; // propagate error
19781979 m.src = cast (ubyte [])buf.extractSlice();
19791980
19801981 // Give unique outfile name
@@ -2007,10 +2008,17 @@ Module moduleWithEmptyMain()
20072008 return result;
20082009}
20092010
2010- private void readFromStdin (ref OutBuffer sink) nothrow
2011+ /* *******************************
2012+ * Read from stdin, append results to sink.
2013+ * Params:
2014+ * sink = output range to append stdin to
2015+ * eSink = send error messages to this
2016+ * Returns:
2017+ * true on error
2018+ */
2019+ private bool readFromStdin (ref OutBuffer sink, ErrorSink eSink) nothrow
20112020{
20122021 import core.stdc.stdio ;
2013- import dmd.errors;
20142022
20152023 enum BufIncrement = 128 * 1024 ;
20162024
@@ -2026,14 +2034,14 @@ private void readFromStdin(ref OutBuffer sink) nothrow
20262034 if (ferror(stdin))
20272035 {
20282036 import core.stdc.errno ;
2029- error(Loc.initial, " cannot read from stdin, errno = %d" , errno);
2030- fatal() ;
2037+ eSink. error(Loc.initial, " cannot read from stdin, errno = %d" , errno);
2038+ return true ;
20312039 }
20322040 if (feof(stdin)) // successful completion
20332041 {
20342042 memset(buffer.ptr + filled, ' \0 ' , 16 );
20352043 sink.setsize(j * BufIncrement + filled);
2036- return ;
2044+ return false ;
20372045 }
20382046 } while (filled < BufIncrement);
20392047 }
0 commit comments