From b15ce1c23fc793842cc44727af0486e1f8c31cf5 Mon Sep 17 00:00:00 2001 From: Dennis Korpel Date: Tue, 15 Oct 2024 23:38:35 +0200 Subject: [PATCH] backend: Remove filespec.d --- compiler/src/build.d | 2 +- compiler/src/dmd/backend/dwarfdbginf.d | 34 +++++++++- compiler/src/dmd/backend/filespec.d | 94 -------------------------- 3 files changed, 34 insertions(+), 96 deletions(-) delete mode 100644 compiler/src/dmd/backend/filespec.d diff --git a/compiler/src/build.d b/compiler/src/build.d index e7aa0a02d1a2..236cb548447e 100755 --- a/compiler/src/build.d +++ b/compiler/src/build.d @@ -1622,7 +1622,7 @@ auto sourceFiles() "), backend: fileArray(env["C"], " bcomplex.d evalu8.d divcoeff.d dvec.d go.d gsroa.d glocal.d gdag.d gother.d gflow.d - dout.d inliner.d eh.d filespec.d aarray.d + dout.d inliner.d eh.d aarray.d gloop.d cgelem.d cgcs.d ee.d blockopt.d mem.d cg.d dtype.d debugprint.d fp.d symbol.d symtab.d elem.d dcode.d cgsched.d pdata.d util2.d var.d backconfig.d drtlsym.d ptrntab.d diff --git a/compiler/src/dmd/backend/dwarfdbginf.d b/compiler/src/dmd/backend/dwarfdbginf.d index b6a3b6aa8999..a4ce1a37d9c2 100644 --- a/compiler/src/dmd/backend/dwarfdbginf.d +++ b/compiler/src/dmd/backend/dwarfdbginf.d @@ -68,7 +68,6 @@ static if (1) import dmd.backend.dlist; import dmd.backend.el; import dmd.backend.elfobj : addSegmentToComdat; - import dmd.backend.filespec; import dmd.backend.machobj : getsegment2; import dmd.backend.global; import dmd.backend.obj; @@ -3234,3 +3233,36 @@ else void dwarf_CFA_offset(int reg, int offset) { } void dwarf_except_gentables(Funcsym *sfunc, uint startoffset, uint retoffset) { } } + +version (Windows) +{ + private enum DIRCHAR = '\\'; + + private bool ispathdelim(char c) nothrow { return c == DIRCHAR || c == ':' || c == '/'; } +} +else +{ + private enum DIRCHAR = '/'; + + private bool ispathdelim(char c) nothrow { return c == DIRCHAR; } +} + +/********************** + * Returns: string that is the filename plus dot and extension. + * The string returned is NOT mem_malloc'ed. + */ +@trusted +private char* filespecname(const(char)* filespec) nothrow +{ + const(char)* p; + + /* Start at end of string and back up till we find the beginning + * of the filename or a path + */ + for (p = filespec + strlen(filespec); + p != filespec && !ispathdelim(*(p - 1)); + p-- + ) + { } + return cast(char *)p; +} diff --git a/compiler/src/dmd/backend/filespec.d b/compiler/src/dmd/backend/filespec.d deleted file mode 100644 index 1f1a1a17b425..000000000000 --- a/compiler/src/dmd/backend/filespec.d +++ /dev/null @@ -1,94 +0,0 @@ -/*_ filespec.h Fri Jul 8 1988 Modified by: bright */ -/* Copyright (C) 1986-1987 by Northwest Software */ -/* All Rights Reserved */ -/* Written by Walter Bright */ -module dmd.backend.filespec; - -import core.stdc.ctype; -import core.stdc.stdio; -import core.stdc.stdlib; -import core.stdc.string; - -import dmd.backend.mem; - - -nothrow: -@safe: - -version (Windows) -{ - enum DIRCHAR = '\\'; - - bool ispathdelim(char c) { return c == DIRCHAR || c == ':' || c == '/'; } -} -else -{ - enum DIRCHAR = '/'; - - bool ispathdelim(char c) { return c == DIRCHAR; } -} - -/********************** - * Return string that is the dot and extension. - * The string returned is NOT mem_malloc'ed. - * Return pointer to the 0 at the end of filespec if dot isn't found. - * Return NULL if filespec is NULL. - */ -@trusted -char *filespecdotext(const(char)* filespec) -{ - auto p = filespec; - if (p) - { - const len = strlen(p); - p += len; - while (1) - { - if (*p == '.') - break; - if (p <= filespec || ispathdelim(*p)) - { p = filespec + len; - break; - } - p--; - } - } - return cast(char*)p; -} - -/*********************** - * Get root name of file name. - * That is, return a mem_strdup()'d version of the filename without - * the .ext. - */ - -char *filespecgetroot(const(char)* name) -{ - char* p = filespecdotext(name); - const c = *p; - *p = 0; - char* root = mem_strdup(name); - *p = c; - return root; -} - -/********************** - * Return string that is the filename plus dot and extension. - * The string returned is NOT mem_malloc'ed. - */ - -@trusted -char *filespecname(const(char)* filespec) -{ - const(char)* p; - - /* Start at end of string and back up till we find the beginning - * of the filename or a path - */ - for (p = filespec + strlen(filespec); - p != filespec && !ispathdelim(*(p - 1)); - p-- - ) - { } - return cast(char *)p; -}