mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 13:28:41 +00:00
Revert "Fixed Broken String Comparison Functions"
This reverts commit 64440ba3c1.
This commit is contained in:
parent
0437fdb55e
commit
f8fabfd49e
2 changed files with 4 additions and 105 deletions
|
|
@ -12,14 +12,10 @@
|
|||
<AssemblyName>Cosmos.System.Plugs</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>Cosmos.snk</AssemblyOriginatorKeyFile>
|
||||
<TargetFrameworkProfile />
|
||||
|
|
@ -86,7 +82,6 @@
|
|||
<Compile Include="System\IO\PathImpl.cs" />
|
||||
<Compile Include="System\IO\StreamReaderImpl.cs" />
|
||||
<Compile Include="System\RandomImpl.cs" />
|
||||
<Compile Include="System\StringImpl.cs" />
|
||||
<Compile Include="System\Text\DecoderFallbackImpl.cs" />
|
||||
<Compile Include="System\Text\EncoderFallbackImpl.cs" />
|
||||
<Compile Include="System\Text\ASCIIEncodingImpl.cs" />
|
||||
|
|
|
|||
|
|
@ -1,96 +0,0 @@
|
|||
using Cosmos.IL2CPU.Plugs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Plug = Cosmos.IL2CPU.Plugs.PlugAttribute;
|
||||
|
||||
namespace Cosmos.System.Plugs.System
|
||||
{
|
||||
[@Plug(Target = typeof(string))]
|
||||
public static class StringImpl
|
||||
{
|
||||
public static bool StartsWith(this string str, string value)
|
||||
{
|
||||
Char[] di = str.ToCharArray();
|
||||
Char[] ci = value.ToCharArray();
|
||||
if (value.Length > str.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < ci.Length; i++)
|
||||
{
|
||||
if (di[i] != ci[i])
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Contains(this string str, string comp)
|
||||
{
|
||||
Char[] di = str.ToCharArray();
|
||||
Char[] ci = comp.ToCharArray();
|
||||
if (comp.Length == str.Length)
|
||||
{
|
||||
if (comp == str)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!(comp.Length > str.Length) && (comp.Length != str.Length))
|
||||
{
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (di[i] == ci[0])
|
||||
{
|
||||
for (int j = 1; j < comp.Length; j++)
|
||||
{
|
||||
if (di[i + j] != ci[j])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool EndsWith(this string str, string comp)
|
||||
{
|
||||
Char[] di = str.ToCharArray();
|
||||
Char[] ci = comp.ToCharArray();
|
||||
if(str.Length == comp.Length)
|
||||
{
|
||||
if(str == comp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if(comp.Length > str.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = str.Length - comp.Length; i < str.Length; i++)
|
||||
{
|
||||
if (di[str.Length - comp.Length + i] != ci[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue