mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 06:46:24 +02:00
misc: chore: Move all GeneratedRegex methods into one static class with static instance accessors.
This commit is contained in:
parent
9f94aa1c79
commit
38ef65aae0
9 changed files with 139 additions and 76 deletions
|
@ -5,6 +5,7 @@ using LibHac.FsSystem;
|
|||
using LibHac.Ncm;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Common.Helper;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
|
@ -30,9 +31,6 @@ namespace Ryujinx.HLE.HOS.Applets.Error
|
|||
|
||||
public event EventHandler AppletStateChanged;
|
||||
|
||||
[GeneratedRegex(@"[^\u0000\u0009\u000A\u000D\u0020-\uFFFF]..")]
|
||||
private static partial Regex CleanTextRegex();
|
||||
|
||||
public ErrorApplet(Horizon horizon)
|
||||
{
|
||||
_horizon = horizon;
|
||||
|
@ -107,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
|
|||
|
||||
private static string CleanText(string value)
|
||||
{
|
||||
return CleanTextRegex().Replace(value, string.Empty).Replace("\0", string.Empty);
|
||||
return Patterns.CleanText.Replace(value, string.Empty).Replace("\0", string.Empty);
|
||||
}
|
||||
|
||||
private string GetMessageText(uint module, uint description, string key)
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using Ryujinx.Common.Helper;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
{
|
||||
public static partial class CJKCharacterValidation
|
||||
public static class CJKCharacterValidation
|
||||
{
|
||||
public static bool IsCJK(char value)
|
||||
{
|
||||
Regex regex = CJKRegex();
|
||||
|
||||
return regex.IsMatch(value.ToString());
|
||||
}
|
||||
|
||||
[GeneratedRegex("\\p{IsHangulJamo}|\\p{IsCJKRadicalsSupplement}|\\p{IsCJKSymbolsandPunctuation}|\\p{IsEnclosedCJKLettersandMonths}|\\p{IsCJKCompatibility}|\\p{IsCJKUnifiedIdeographsExtensionA}|\\p{IsCJKUnifiedIdeographs}|\\p{IsHangulSyllables}|\\p{IsCJKCompatibilityForms}")]
|
||||
private static partial Regex CJKRegex();
|
||||
public static bool IsCJK(char value) => Patterns.CJK.IsMatch(value.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using Ryujinx.Common.Helper;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
{
|
||||
public static partial class NumericCharacterValidation
|
||||
public static class NumericCharacterValidation
|
||||
{
|
||||
public static bool IsNumeric(char value)
|
||||
{
|
||||
Regex regex = NumericRegex();
|
||||
|
||||
return regex.IsMatch(value.ToString());
|
||||
}
|
||||
|
||||
[GeneratedRegex("[0-9]|.")]
|
||||
private static partial Regex NumericRegex();
|
||||
public static bool IsNumeric(char value) => Patterns.Numeric.IsMatch(value.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,13 @@
|
|||
using Ryujinx.Common.Helper;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
|
||||
{
|
||||
static partial class DnsBlacklist
|
||||
static class DnsBlacklist
|
||||
{
|
||||
const RegexOptions RegexOpts = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture;
|
||||
|
||||
[GeneratedRegex(@"^(.*)\-lp1\.(n|s)\.n\.srv\.nintendo\.net$", RegexOpts)]
|
||||
private static partial Regex BlockedHost1();
|
||||
[GeneratedRegex(@"^(.*)\-lp1\.lp1\.t\.npln\.srv\.nintendo\.net$", RegexOpts)]
|
||||
private static partial Regex BlockedHost2();
|
||||
[GeneratedRegex(@"^(.*)\-lp1\.(znc|p)\.srv\.nintendo\.net$", RegexOpts)]
|
||||
private static partial Regex BlockedHost3();
|
||||
[GeneratedRegex(@"^(.*)\-sb\-api\.accounts\.nintendo\.com$", RegexOpts)]
|
||||
private static partial Regex BlockedHost4();
|
||||
[GeneratedRegex(@"^(.*)\-sb\.accounts\.nintendo\.com$", RegexOpts)]
|
||||
private static partial Regex BlockedHost5();
|
||||
[GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)]
|
||||
private static partial Regex BlockedHost6();
|
||||
|
||||
private static readonly Regex[] _blockedHosts =
|
||||
[
|
||||
BlockedHost1(),
|
||||
BlockedHost2(),
|
||||
BlockedHost3(),
|
||||
BlockedHost4(),
|
||||
BlockedHost5(),
|
||||
BlockedHost6()
|
||||
];
|
||||
|
||||
public static bool IsHostBlocked(string host)
|
||||
{
|
||||
foreach (Regex regex in _blockedHosts)
|
||||
foreach (Regex regex in Patterns.BlockedHosts)
|
||||
{
|
||||
if (regex.IsMatch(host))
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@ using LibHac.Common.FixedArrays;
|
|||
using LibHac.Fs;
|
||||
using LibHac.Loader;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Common.Helper;
|
||||
using Ryujinx.Common.Logging;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
@ -29,13 +30,6 @@ namespace Ryujinx.HLE.Loaders.Executables
|
|||
public string Name;
|
||||
public Array32<byte> BuildId;
|
||||
|
||||
[GeneratedRegex(@"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
|
||||
private static partial Regex ModuleRegex();
|
||||
[GeneratedRegex(@"sdk_version: ([0-9.]*)")]
|
||||
private static partial Regex FsSdkRegex();
|
||||
[GeneratedRegex(@"SDK MW[ -~]*")]
|
||||
private static partial Regex SdkMwRegex();
|
||||
|
||||
public NsoExecutable(IStorage inStorage, string name = null)
|
||||
{
|
||||
NsoReader reader = new();
|
||||
|
@ -90,7 +84,7 @@ namespace Ryujinx.HLE.Loaders.Executables
|
|||
|
||||
if (string.IsNullOrEmpty(modulePath))
|
||||
{
|
||||
Match moduleMatch = ModuleRegex().Match(rawTextBuffer);
|
||||
Match moduleMatch = Patterns.Module.Match(rawTextBuffer);
|
||||
if (moduleMatch.Success)
|
||||
{
|
||||
modulePath = moduleMatch.Value;
|
||||
|
@ -99,13 +93,13 @@ namespace Ryujinx.HLE.Loaders.Executables
|
|||
|
||||
stringBuilder.AppendLine($" Module: {modulePath}");
|
||||
|
||||
Match fsSdkMatch = FsSdkRegex().Match(rawTextBuffer);
|
||||
Match fsSdkMatch = Patterns.FsSdk.Match(rawTextBuffer);
|
||||
if (fsSdkMatch.Success)
|
||||
{
|
||||
stringBuilder.AppendLine($" FS SDK Version: {fsSdkMatch.Value.Replace("sdk_version: ", string.Empty)}");
|
||||
}
|
||||
|
||||
MatchCollection sdkMwMatches = SdkMwRegex().Matches(rawTextBuffer);
|
||||
MatchCollection sdkMwMatches = Patterns.SdkMw.Matches(rawTextBuffer);
|
||||
if (sdkMwMatches.Count != 0)
|
||||
{
|
||||
string libHeader = " SDK Libraries: ";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue