Skip to content

Commit 9617720

Browse files
committed
Merge pull request #969 from wise0704/StringComparison_Ordinal
Ordinal String Comparison
2 parents 37ac293 + 07d925b commit 9617720

File tree

151 files changed

+832
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+832
-617
lines changed

External/Plugins/AS2Context/Context.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public override void ResolveTopLevelElement(string token, ASResult result)
372372
if (!result.IsNull()) return;
373373

374374
// special _levelN
375-
if (hasLevels && token.StartsWith("_") && re_level.IsMatch(token))
375+
if (hasLevels && token.StartsWith('_') && re_level.IsMatch(token))
376376
{
377377
result.Member = new MemberModel();
378378
result.Member.Name = token;
@@ -720,7 +720,7 @@ private ClassModel LookupClass(string package, string cname, string inPackage, b
720720
// in the same (or parent) package
721721
else if (testSamePackage)
722722
{
723-
if (inPackage == pkg || (matchParentPackage && pkg.Length < pLen && inPackage.StartsWith(pkg + ".")))
723+
if (inPackage == pkg || (matchParentPackage && pkg.Length < pLen && inPackage.StartsWithOrdinal(pkg + ".")))
724724
foreach (ClassModel aClass in aFile.Classes)
725725
if (aClass.Name == cname /*&& (aFile.Module == "" || aFile.Module == aClass.Name)*/)
726726
{
@@ -795,7 +795,7 @@ public override void CheckModel(bool onFileOpen)
795795
{
796796
string pathname = package.Replace('.', Path.DirectorySeparatorChar);
797797
string fullpath = Path.GetDirectoryName(cFile.FileName);
798-
if (!fullpath.EndsWith(pathname))
798+
if (!fullpath.EndsWithOrdinal(pathname))
799799
{
800800
if (settings.FixPackageAutomatically && CurSciControl != null)
801801
{
@@ -842,7 +842,7 @@ public override void CheckModel(bool onFileOpen)
842842
string correctPath = null;
843843
foreach (PathModel pm in classpaths)
844844
{
845-
if (fullpath.IndexOf(pm.Path) > -1 && fullpath.Length > pm.Path.Length)
845+
if (fullpath.IndexOfOrdinal(pm.Path) > -1 && fullpath.Length > pm.Path.Length)
846846
{
847847
correctPath = fullpath.Substring(pm.Path.Length + 1);
848848
}
@@ -882,7 +882,7 @@ public override void CheckModel(bool onFileOpen)
882882
{
883883
if (package.Length > 0) cname = package + "." + cname;
884884
string filename = cname.Replace('.', Path.DirectorySeparatorChar) + Path.GetExtension(cFile.FileName);
885-
if (!cFile.FileName.ToUpper().EndsWith(filename.ToUpper()))
885+
if (!cFile.FileName.ToUpper().EndsWithOrdinal(filename.ToUpper()))
886886
{
887887
string org = TextHelper.GetString("Info.TypeDontMatchFileName");
888888
string msg = String.Format(org, cname) + "\n" + cFile.FileName;
@@ -1025,7 +1025,7 @@ public override FileModel ResolvePackage(string name, bool lazyMode)
10251025
pModel.Members.Add(member.Clone() as MemberModel);
10261026
}
10271027
else if (package != prevPackage
1028-
&& (package.Length > name.Length && package.StartsWith(packagePrefix))) // imports
1028+
&& (package.Length > name.Length && package.StartsWithOrdinal(packagePrefix))) // imports
10291029
{
10301030
prevPackage = package;
10311031
if (nameLen > 1) package = package.Substring(nameLen);
@@ -1065,7 +1065,7 @@ private void PopulateClassesEntries(string package, string path, MemberList memb
10651065
foreach (string entry in fileEntries)
10661066
{
10671067
mname = GetLastStringToken(entry, dirSeparator);
1068-
mname = mname.Substring(0, mname.LastIndexOf("."));
1068+
mname = mname.Substring(0, mname.LastIndexOf('.'));
10691069
if (mname.Length > 0 && memberList.Search(mname, 0, 0) == null && re_token.IsMatch(mname))
10701070
{
10711071
type = mname;
@@ -1316,7 +1316,7 @@ public override void RunCMD(string append)
13161316
else mtascPath = Path.GetDirectoryName(mtascPath);
13171317

13181318
command += ";\"" + CurrentFile + "\"";
1319-
if (append == null || append.IndexOf("-swf-version") < 0)
1319+
if (append == null || append.IndexOfOrdinal("-swf-version") < 0)
13201320
command += " -version "+majorVersion;
13211321
// classpathes
13221322
foreach(PathModel aPath in classPath)

External/Plugins/AS3Context/AbcConverter.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Xml;
88
using ASCompletion.Context;
99
using ASCompletion.Model;
10+
using PluginCore;
1011
using SwfOp;
1112
using SwfOp.Data;
1213

@@ -53,7 +54,7 @@ private static void ParseDocumentation(ContentParser parser)
5354
if (parser.Docs.Count > 0)
5455
foreach (string docFile in parser.Docs.Keys)
5556
{
56-
if (docFile.EndsWith(".dita.xml"))
57+
if (docFile.EndsWithOrdinal(".dita.xml"))
5758
continue;
5859
try
5960
{
@@ -177,7 +178,7 @@ public static void Convert(ContentParser parser, PathModel path, IASContext cont
177178
type.Access = Visibility.Private;
178179
type.Namespace = "private";
179180
string genType = type.Name;
180-
if (type.Name.IndexOf("$") > 0)
181+
if (type.Name.IndexOf('$') > 0)
181182
{
182183
string[] itype = type.Name.Split('$');
183184
genType = itype[0];
@@ -192,7 +193,7 @@ public static void Convert(ContentParser parser, PathModel path, IASContext cont
192193
}
193194
else genericTypes[genType] = model;
194195
}
195-
else if (type.Name.StartsWith("_") && string.IsNullOrEmpty(model.Package))
196+
else if (type.Name.StartsWith('_') && string.IsNullOrEmpty(model.Package))
196197
{
197198
type.Access = Visibility.Private;
198199
type.Namespace = "private";
@@ -703,7 +704,7 @@ private void ReadDeclaration(string declType)
703704
int colon = id.IndexOf(':') + 1;
704705
if (colon > 0)
705706
{
706-
int dup = id.IndexOf(id.Substring(0, colon), colon);
707+
int dup = id.IndexOfOrdinal(id.Substring(0, colon), colon);
707708
if (dup > 0) id = id.Substring(dup);
708709
}
709710
doc.ApiType = id;
@@ -719,7 +720,7 @@ private void ReadDeclaration(string declType)
719720

720721
if (id != null)
721722
{
722-
if (doc.ApiType == "String" && doc.Value != null && !doc.Value.StartsWith("\""))
723+
if (doc.ApiType == "String" && doc.Value != null && !doc.Value.StartsWith('\"'))
723724
doc.Value = "\"" + doc.Value + "\"";
724725

725726
if (doc.LongDesc == null)

External/Plugins/AS3Context/Compiler/FlexShells.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
271271

272272
// cleanup tag
273273
string tag = mCmd.Groups["cmd"].Value;
274-
if (tag.IndexOf("-->") > 0) tag = tag.Substring(0, tag.IndexOf("-->"));
275-
if (tag.IndexOf("]]>") > 0) tag = tag.Substring(0, tag.IndexOf("]]>"));
274+
if (tag.IndexOfOrdinal("-->") > 0) tag = tag.Substring(0, tag.IndexOfOrdinal("-->"));
275+
if (tag.IndexOfOrdinal("]]>") > 0) tag = tag.Substring(0, tag.IndexOfOrdinal("]]>"));
276276
tag = " " + tag.Trim() + " --";
277277

278278
// split
@@ -299,7 +299,7 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
299299
{
300300
string concat = ";";
301301
arg = tag.Substring(start, end - start).Trim();
302-
if (arg.StartsWith("+=") || arg.StartsWith("="))
302+
if (arg.StartsWithOrdinal("+=") || arg.StartsWith('='))
303303
{
304304
concat = arg.Substring(0, arg.IndexOf('=') + 1);
305305
arg = arg.Substring(concat.Length);
@@ -309,7 +309,7 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
309309
{
310310
if (pswitch == op)
311311
{
312-
if (op.EndsWith("namespace"))
312+
if (op.EndsWithOrdinal("namespace"))
313313
{
314314
int sp = arg.IndexOf(' ');
315315
if (sp > 0)
@@ -320,10 +320,10 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
320320
}
321321
isPath = true;
322322
// remove quotes
323-
if (arg.StartsWith("\"") && arg.EndsWith("\""))
323+
if (arg.StartsWith('\"') && arg.EndsWith('\"'))
324324
arg = arg.Substring(1, arg.Length - 2);
325325

326-
if (!arg.StartsWith("\\") && !Path.IsPathRooted(arg))
326+
if (!arg.StartsWith('\\') && !Path.IsPathRooted(arg))
327327
arg = Path.Combine(buildPath, arg);
328328
}
329329
}
@@ -332,7 +332,7 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
332332
builtSWF = arg;
333333
hasOutput = true;
334334
}
335-
if (!isPath) arg = arg.Replace(" ", ";");
335+
if (!isPath) arg = arg.Replace(' ', ';');
336336
cmd += op + concat + arg + ";";
337337
}
338338
else cmd += op + ";";
@@ -347,7 +347,7 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
347347
else if (requireTag) return;
348348

349349
// Flex4 static linking
350-
if (isFlex4SDK && cmd.IndexOf("-static-link-runtime-shared-libraries") < 0)
350+
if (isFlex4SDK && cmd.IndexOfOrdinal("-static-link-runtime-shared-libraries") < 0)
351351
cmd += ";-static-link-runtime-shared-libraries=true";
352352

353353
// add current class sourcepath and global classpaths
@@ -382,7 +382,7 @@ private void CheckIsFlex4SDK(string flexPath)
382382
if (File.Exists(flexDesc))
383383
{
384384
string src = File.ReadAllText(flexDesc);
385-
isFlex4SDK = src.IndexOf("<version>4") > 0;
385+
isFlex4SDK = src.IndexOfOrdinal("<version>4") > 0;
386386
}
387387
else isFlex4SDK = false;
388388
}
@@ -473,7 +473,7 @@ private void StartMxmlcRunner(string flexPath)
473473

474474
private void ascRunner_Error(object sender, string line)
475475
{
476-
if (line.StartsWith("[Compiler] Error"))
476+
if (line.StartsWithOrdinal("[Compiler] Error"))
477477
{
478478
errorState = 1;
479479
errorDesc = line.Substring(10);
@@ -500,7 +500,7 @@ private void ascRunner_Error(object sender, string line)
500500
}
501501
else if (errorState > 0)
502502
{
503-
if (line.IndexOf("error found") > 0) errorState = 0;
503+
if (line.IndexOfOrdinal("error found") > 0) errorState = 0;
504504
}
505505
else if (line.Trim().Length > 0) ascRunner_OutputError(sender, line);
506506
}
@@ -510,7 +510,7 @@ private void ascRunner_OutputError(object sender, string line)
510510
if (line == null) return;
511511
PluginBase.RunAsync(delegate
512512
{
513-
if (line.StartsWith("Exception "))
513+
if (line.StartsWithOrdinal("Exception "))
514514
{
515515
TraceManager.AddAsync(line, -3);
516516
return;
@@ -534,9 +534,9 @@ private void ascRunner_OutputError(object sender, string line)
534534

535535
private void ascRunner_Output(object sender, string line)
536536
{
537-
if (line.StartsWith("(ash)"))
537+
if (line.StartsWithOrdinal("(ash)"))
538538
{
539-
if (line.IndexOf("Done") > 0)
539+
if (line.IndexOfOrdinal("Done") > 0)
540540
{
541541
running = false;
542542
if (!silentChecking && !notificationSent)
@@ -565,7 +565,7 @@ private void mxmlcRunner_Output(object sender, string line)
565565
{
566566
PluginBase.RunAsync(delegate
567567
{
568-
if (!notificationSent && line.StartsWith("Done("))
568+
if (!notificationSent && line.StartsWithOrdinal("Done("))
569569
{
570570
running = false;
571571
TraceManager.Add(line, -2);

External/Plugins/AS3Context/Context.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public override void BuildClassPath()
199199
List<string> addLibs = new List<string>();
200200
List<string> addLocales = new List<string>();
201201

202-
if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWith("$")) // fallback
202+
if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWith('$')) // fallback
203203
{
204204
sdkLibs = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "libs" + S + "player");
205205
}
@@ -225,7 +225,7 @@ public override void BuildClassPath()
225225
if (playerglobal != null)
226226
{
227227
// add missing SWC in new SDKs
228-
if (!swcPresent && sdkLibs.IndexOf(S + "flexlibs") < 0 && Directory.Exists(compiler))
228+
if (!swcPresent && sdkLibs.IndexOfOrdinal(S + "flexlibs") < 0 && Directory.Exists(compiler))
229229
{
230230
string swcDir = sdkLibs + S + "player" + S;
231231
if (!Directory.Exists(swcDir + "9") && !Directory.Exists(swcDir + "10"))

External/Plugins/AS3Context/MxmlComplete.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static bool GotoDeclaration()
5858
else return true;
5959
}
6060

61-
if (word != null && !ctag.Name.EndsWith(word))
61+
if (word != null && !ctag.Name.EndsWithOrdinal(word))
6262
{
6363
ASResult found = ResolveAttribute(model, word);
6464
ASComplete.OpenDocumentToDeclaration(sci, found);
@@ -207,15 +207,15 @@ static public bool HandleElementClose(object data)
207207
string type = ResolveType(mxmlContext, tagContext.Name);
208208
ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;
209209

210-
if (type.StartsWith("mx.builtin.") || type.StartsWith("fx.builtin.")) // special tags
210+
if (type.StartsWithOrdinal("mx.builtin.") || type.StartsWithOrdinal("fx.builtin.")) // special tags
211211
{
212-
if (type.EndsWith(".Script"))
212+
if (type.EndsWithOrdinal(".Script"))
213213
{
214214
string snip = "$(Boundary)\n\t<![CDATA[\n\t$(EntryPoint)\n\t]]>\n</" + tagContext.Name + ">";
215215
SnippetHelper.InsertSnippetText(sci, sci.CurrentPos, snip);
216216
return true;
217217
}
218-
if (type.EndsWith(".Style"))
218+
if (type.EndsWithOrdinal(".Style"))
219219
{
220220
string snip = "$(Boundary)";
221221
foreach (string ns in mxmlContext.namespaces.Keys)
@@ -695,7 +695,7 @@ private static FileModel ParseInclude(FileModel fileModel, ASMetaData meta)
695695
// parse & cache
696696
if (!File.Exists(fileName)) return null;
697697
string src = File.ReadAllText(fileName);
698-
if (src.IndexOf("package") < 0) src = "package {" + src + "}";
698+
if (src.IndexOfOrdinal("package") < 0) src = "package {" + src + "}";
699699
ASFileParser parser = new ASFileParser();
700700
FileModel model = new FileModel(path);
701701
parser.ParseSrc(model, src);
@@ -760,7 +760,7 @@ private static void GetAllTags()
760760
foreach (string key in nss.Keys)
761761
{
762762
string uri = nss[key];
763-
if (uri.EndsWith(".*"))
763+
if (uri.EndsWithOrdinal(".*"))
764764
packages[uri.Substring(0, uri.LastIndexOf('.') + 1)] = key;
765765
else if (uri == "*")
766766
packages["*"] = key;
@@ -810,7 +810,7 @@ public static string ResolveType(MxmlFilterContext ctx, string ns, string name)
810810
string uri = ctx.namespaces[ns];
811811
if (uri == "*")
812812
return name;
813-
if (uri.EndsWith(".*"))
813+
if (uri.EndsWithOrdinal(".*"))
814814
return uri.Substring(0, uri.Length - 1) + name;
815815

816816
if (uri == MxmlFilter.BETA_MX || uri == MxmlFilter.OLD_MX)
@@ -881,13 +881,13 @@ public int Compare(ICompletionListItem a, ICompletionListItem b)
881881
if (a is IHtmlCompletionListItem)
882882
{
883883
a1 = ((IHtmlCompletionListItem)a).Name;
884-
if (a.Value.StartsWith("mx:")) a1 += "z"; // push down mx: tags
884+
if (a.Value.StartsWithOrdinal("mx:")) a1 += "z"; // push down mx: tags
885885
}
886886
else a1 = a.Label;
887887
if (b is IHtmlCompletionListItem)
888888
{
889889
b1 = ((IHtmlCompletionListItem)b).Name;
890-
if (b.Value.StartsWith("mx:")) b1 += "z"; // push down mx: tags
890+
if (b.Value.StartsWithOrdinal("mx:")) b1 += "z"; // push down mx: tags
891891
}
892892
else b1 = b.Label;
893893
return string.Compare(a1, b1);

External/Plugins/AS3Context/MxmlFilter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static public void AddProjectManifests()
5353
foreach (string line in project.CompilerOptions.Additional)
5454
{
5555
string temp = line.Trim();
56-
if (temp.StartsWith("-compiler.namespaces.namespace") || temp.StartsWith("-namespace"))
56+
if (temp.StartsWithOrdinal("-compiler.namespaces.namespace") || temp.StartsWithOrdinal("-namespace"))
5757
{
5858
int p = temp.IndexOf(' ');
5959
if (p < 0) p = temp.IndexOf('=');
@@ -64,7 +64,7 @@ static public void AddProjectManifests()
6464
if (p < 0) continue;
6565
string uri = temp.Substring(0, p);
6666
string path = temp.Substring(p + 1).Trim();
67-
if (path.StartsWith("\"")) path = path.Substring(1, path.Length - 2);
67+
if (path.StartsWith('\"')) path = path.Substring(1, path.Length - 2);
6868
AddManifest(uri, PathHelper.ResolvePath(path, project.Directory));
6969
}
7070
}
@@ -297,7 +297,7 @@ private static void ReadNamespaces(MxmlFilterContext ctx, string src, int i)
297297
if (name == null) break;
298298
string value = GetAttributeValue(src, ref i);
299299
if (value == null) break;
300-
if (name.StartsWith("xmlns"))
300+
if (name.StartsWithOrdinal("xmlns"))
301301
{
302302
string[] qname = name.Split(':');
303303
if (qname.Length == 1) ctx.namespaces["*"] = value;

0 commit comments

Comments
 (0)