d: Revert "Come up with startswith function."
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 18 May 2021 17:05:20 +0000 (19:05 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 18 May 2021 21:01:30 +0000 (23:01 +0200)
This reverts changes to the DMD front-end in commit
6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b.

Changes were incorrectly committed directly to the GCC repo instead of
the master repository.

gcc/d/ChangeLog:

* dmd/dinterpret.c (evaluateIfBuiltin): Revert last change.
* dmd/dmangle.c: Likewise.
* dmd/hdrgen.c: Likewise.
* dmd/identifier.c (Identifier::toHChars2): Likewise.

gcc/d/dmd/dinterpret.c
gcc/d/dmd/dmangle.c
gcc/d/dmd/hdrgen.c
gcc/d/dmd/identifier.c

index 9e74a0d..5e71f3b 100644 (file)
@@ -6881,7 +6881,7 @@ Expression *evaluateIfBuiltin(UnionExp *pue, InterState *istate, Loc loc,
         const char *id = fd->ident->toChars();
         size_t idlen = strlen(id);
         if (nargs == 2 && (idlen == 10 || idlen == 11) &&
-            startswith (id, "_aApply"))
+            !strncmp(id, "_aApply", 7))
         {
             // Functions from aApply.d and aApplyR.d in the runtime
             bool rvs = (idlen == 11);   // true if foreach_reverse
index f112243..83f4c18 100644 (file)
@@ -673,7 +673,7 @@ public:
                 cd == ClassDeclaration::object ||
                 cd == Type::typeinfoclass ||
                 cd == Module::moduleinfo ||
-                startswith (cd->ident->toChars(), "TypeInfo_"))
+                strncmp(cd->ident->toChars(), "TypeInfo_", 9) == 0)
             {
                 // Don't mangle parent
                 ad->parent = NULL;
index e72273b..9397b1e 100644 (file)
@@ -3212,7 +3212,7 @@ public:
         }
         else if (p->type->ty == Tident &&
                  strlen(((TypeIdentifier *)p->type)->ident->toChars()) > 3 &&
-                 startswith (((TypeIdentifier *)p->type)->ident->toChars(), "__T"))
+                 strncmp(((TypeIdentifier *)p->type)->ident->toChars(), "__T", 3) == 0)
         {
             // print parameter name, instead of undetermined type parameter
             buf->writestring(p->ident->toChars());
index dd2c58f..197d288 100644 (file)
@@ -73,11 +73,11 @@ const char *Identifier::toHChars2()
     {   p = toChars();
         if (*p == '_')
         {
-            if (startswith(p, "_staticCtor"))
+            if (strncmp(p, "_staticCtor", 11) == 0)
                 p = "static this";
-            else if (startswith(p, "_staticDtor"))
+            else if (strncmp(p, "_staticDtor", 11) == 0)
                 p = "static ~this";
-            else if (startswith(p, "__invariant"))
+            else if (strncmp(p, "__invariant", 11) == 0)
                 p = "invariant";
         }
     }