aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2025-03-25 19:37:34 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2025-03-26 19:32:02 +0100
commit7c4f409524dabf23cb59b2663dc6cfa819a4287a (patch)
tree75ea74fe4f9056119df9c9204db3cf7b6d28b3f9 /gcc/d
parent101f302363e8773958887e00750098b760a5b6bd (diff)
downloadgcc-7c4f409524dabf23cb59b2663dc6cfa819a4287a.zip
gcc-7c4f409524dabf23cb59b2663dc6cfa819a4287a.tar.gz
gcc-7c4f409524dabf23cb59b2663dc6cfa819a4287a.tar.bz2
d: import __stdin causes compilation to pause while reading from stdin
Moves the special handling of reading from stdin out of the language semantic routines. All references to `__stdin.d` have also been removed from the front-end implementation. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 02a64d2e13.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/dmodule.d8
-rw-r--r--gcc/d/dmd/file_manager.d55
-rw-r--r--gcc/d/dmd/globals.d1
-rw-r--r--gcc/d/dmd/globals.h1
5 files changed, 8 insertions, 59 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 1160749..08b4e78 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-032e24446b3d8c6cfe3043d62534d5ce6d004c34
+02a64d2e1359119b91d2b932e61ed712f272507a
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/dmodule.d b/gcc/d/dmd/dmodule.d
index 6c74168..1d14c08 100644
--- a/gcc/d/dmd/dmodule.d
+++ b/gcc/d/dmd/dmodule.d
@@ -58,12 +58,10 @@ import dmd.visitor;
version (Windows)
{
- import core.sys.windows.winbase : getpid = GetCurrentProcessId;
enum PathSeparator = '\\';
}
else version (Posix)
{
- import core.sys.posix.unistd : getpid;
enum PathSeparator = '/';
}
else
@@ -577,12 +575,6 @@ extern (C++) final class Module : Package
else
{
const(char)[] argdoc;
- OutBuffer buf;
- if (arg == "__stdin.d")
- {
- buf.printf("__stdin_%d.d", getpid());
- arg = buf[];
- }
if (global.params.preservePaths)
argdoc = arg;
else
diff --git a/gcc/d/dmd/file_manager.d b/gcc/d/dmd/file_manager.d
index fc7824f..8a6ec99 100644
--- a/gcc/d/dmd/file_manager.d
+++ b/gcc/d/dmd/file_manager.d
@@ -16,7 +16,6 @@ import dmd.root.stringtable : StringTable;
import dmd.root.file : File, Buffer;
import dmd.root.filename : FileName, isDirSeparator;
import dmd.root.string : toDString;
-import dmd.errors;
import dmd.globals;
import dmd.identifier;
import dmd.location;
@@ -184,9 +183,6 @@ nothrow:
scope(exit) FileName.free(sdi.ptr);
const sd = FileName.forceExt(filename, mars_ext);
- // Special file name representing `stdin`, always assume its presence
- if (sd == "__stdin.d")
- return sd;
if (checkLocal && FileName.exists(sd) == 1)
return sd;
scope(exit) FileName.free(sd.ptr);
@@ -312,20 +308,12 @@ nothrow:
if (auto val = files.lookup(name)) // if `name` is cached
return val.value; // return its contents
- OutBuffer buf;
- if (name == "__stdin.d") // special name for reading from stdin
- {
- if (readFromStdin(buf))
- fatal();
- }
- else
- {
- if (FileName.exists(name) != 1) // if not an ordinary file
- return null;
+ if (FileName.exists(name) != 1) // if not an ordinary file
+ return null;
- if (File.read(name, buf))
- return null; // failed
- }
+ OutBuffer buf;
+ if (File.read(name, buf))
+ return null; // failed
buf.write32(0); // terminating dchar 0
@@ -351,36 +339,3 @@ nothrow:
return val == null ? null : val.value;
}
}
-
-private bool readFromStdin(ref OutBuffer sink) nothrow
-{
- import core.stdc.stdio;
- import dmd.errors;
-
- enum BufIncrement = 128 * 1024;
-
- for (size_t j; 1; ++j)
- {
- char[] buffer = sink.allocate(BufIncrement);
-
- // Fill up buffer
- size_t filled = 0;
- do
- {
- filled += fread(buffer.ptr + filled, 1, buffer.length - filled, stdin);
- if (ferror(stdin))
- {
- import core.stdc.errno;
- error(Loc.initial, "cannot read from stdin, errno = %d", errno);
- return true;
- }
- if (feof(stdin)) // successful completion
- {
- sink.setsize(j * BufIncrement + filled);
- return false;
- }
- } while (filled < BufIncrement);
- }
-
- assert(0);
-}
diff --git a/gcc/d/dmd/globals.d b/gcc/d/dmd/globals.d
index 900c554..132683e 100644
--- a/gcc/d/dmd/globals.d
+++ b/gcc/d/dmd/globals.d
@@ -160,6 +160,7 @@ extern (C++) struct ImportPathInfo {
extern (C++) struct Param
{
bool obj = true; // write object file
+ bool readStdin; // saw "-" on command line, read source file from stdin
bool multiobj; // break one object file into multiple ones
bool trace; // insert profiling hooks
bool tracegc; // instrument calls to 'new'
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index 69fe709..59952a2 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -168,6 +168,7 @@ struct ImportPathInfo
struct Param
{
d_bool obj; // write object file
+ d_bool readStdin; // read source file from stdin
d_bool multiobj; // break one object file into multiple ones
d_bool trace; // insert profiling hooks
d_bool tracegc; // instrument calls to 'new'