-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HELP WANTED] Maybe(?) fixes(?) regex #1793
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
english
@@ -20,14 +20,15 @@ | |||
src.flags = flags | |||
|
|||
proc/Find(haystack, start = 1, end = 0) | |||
return findtext(text, src, start, end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime replaces this proc with the native proc found in DreamProcNativeRegex.cs
so this doesn't do anything.
proc/Replace(haystack, replacement, start = 1, end = 0) | ||
return replacetext(text, src, replacement, start, end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this proc
|
||
proc/Replace_char(haystack, replacement, start = 1, end = 0) | ||
set opendream_unimplemented = TRUE | ||
return haystack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this removed?
state.GetArgument(1, "start").TryGetValueAsInteger(out int start); | ||
state.GetArgument(2, "end").TryGetValueAsInteger(out int end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be verified that these are both treated as 0
for non-integer values.
return await RegexFind(state, state.Src, haystack, start, end); | ||
} | ||
|
||
public static async Task<DreamValue> RegexFind(AsyncNativeProc.State state, DreamObject regexInstance, DreamValue haystack, int start, int end) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why async? I don't see anything in here that is asynchronous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied this from RegexReplace, not gonna lie!
int start = bundle.GetArgument(2, "Start").MustGetValueAsInteger(); //1-indexed | ||
int end = bundle.GetArgument(3, "End").MustGetValueAsInteger(); //1-indexed | ||
if(!needleArg.TryGetValueAsString(out var needle)) | ||
return DreamValue.True; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BYOND returns different values for different combinations of invalid arguments. Are those still replicated?
This pr is basically a shot in the dark. I believe that
regex.Find()
was broken when it was a global regex. Also impliments proper regex functionality forfindtext()
andreplacetext()