Package org.jruby.util
Class RegexpSupport
java.lang.Object
org.jruby.util.RegexpSupport
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendOptions(ByteList to, RegexpOptions options) static voidappendRegexpString19(Ruby runtime, ByteList to, byte[] bytes, int start, int len, org.jcodings.Encoding enc, org.jcodings.Encoding resEnc) private static voidappendUtf8(Ruby runtime, ByteList to, int code, org.jcodings.Encoding[] enc, ByteList str, RegexpSupport.ErrorMode mode) Append the given utf8 characters to the buffer, if given, checking for errors along the way.private static voidcheckUnicodeRange(Ruby runtime, int code, ByteList str, RegexpSupport.ErrorMode mode) static ByteListpreprocess(Ruby runtime, ByteList str, org.jcodings.Encoding enc, org.jcodings.Encoding[] fixedEnc, RegexpSupport.ErrorMode mode) Preprocess the given string for use in regexp, raising errors for encoding incompatibilities that arise.static intraisePreprocessError(Ruby runtime, ByteList str, String err, RegexpSupport.ErrorMode mode) static voidraiseRegexpError19(Ruby runtime, ByteList bytes, org.jcodings.Encoding enc, RegexpOptions options, String err) static intreadEscapedByte(Ruby runtime, byte[] to, int toP, byte[] bytes, int p, int end, ByteList str, RegexpSupport.ErrorMode mode) private static ByteListregexpDescription19(Ruby runtime, byte[] s, int start, int len, RegexpOptions options, org.jcodings.Encoding enc) static ByteListregexpDescription19(Ruby runtime, ByteList bytes, RegexpOptions options, org.jcodings.Encoding enc) private static intunescapeEscapedNonAscii(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding enc, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape escaped non-ascii character at start position, appending all to the given bytelist if provided.static booleanunescapeNonAscii(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding enc, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape non-ascii elements in the given string, appending the results to the given bytelist if provided.private static intunescapeUnicodeBmp(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape unicode BMP char at given offset, appending to the specified buffer if non-null.private static intunescapeUnicodeList(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape unicode characters at given offset, appending to the given out buffer if provided.
-
Constructor Details
-
RegexpSupport
public RegexpSupport()
-
-
Method Details
-
preprocess
public static ByteList preprocess(Ruby runtime, ByteList str, org.jcodings.Encoding enc, org.jcodings.Encoding[] fixedEnc, RegexpSupport.ErrorMode mode) Preprocess the given string for use in regexp, raising errors for encoding incompatibilities that arise. This version produces a new unescaped version of the string based on fixes performed while walking.- Parameters:
runtime- current runtimestr- string to preprocessenc- string's encodingfixedEnc- new encoding after fixingmode- mode of errors- Returns:
- a new unescaped string
-
unescapeNonAscii
public static boolean unescapeNonAscii(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding enc, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape non-ascii elements in the given string, appending the results to the given bytelist if provided.- Parameters:
runtime- current runtimeto- output bytelist; if null, no appending will be donebytes- the bytes to unescapep- starting positionend- ending positionenc- bytes' encodingencp- out param for fixed encodingstr- original wrapper for the bytesmode- error mode- Returns:
- whether any propery elements were encountered while walking
-
raisePreprocessError
public static int raisePreprocessError(Ruby runtime, ByteList str, String err, RegexpSupport.ErrorMode mode) -
raiseRegexpError19
public static void raiseRegexpError19(Ruby runtime, ByteList bytes, org.jcodings.Encoding enc, RegexpOptions options, String err) -
regexpDescription19
public static ByteList regexpDescription19(Ruby runtime, ByteList bytes, RegexpOptions options, org.jcodings.Encoding enc) -
regexpDescription19
private static ByteList regexpDescription19(Ruby runtime, byte[] s, int start, int len, RegexpOptions options, org.jcodings.Encoding enc) -
appendRegexpString19
-
appendOptions
-
readEscapedByte
public static int readEscapedByte(Ruby runtime, byte[] to, int toP, byte[] bytes, int p, int end, ByteList str, RegexpSupport.ErrorMode mode) -
unescapeEscapedNonAscii
private static int unescapeEscapedNonAscii(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding enc, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape escaped non-ascii character at start position, appending all to the given bytelist if provided.- Parameters:
runtime- current runtimeto- output bytelist; if null, no appending will be donebytes- incoming bytesp- start positionend- end positionenc- bytes' encodingencp- out param for fixed encodingstr- original bytes wrappermode- error mode- Returns:
- new position after performing unescaping
-
unescapeUnicodeList
private static int unescapeUnicodeList(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape unicode characters at given offset, appending to the given out buffer if provided.- Parameters:
runtime- current runtimeto- output buffer; if null, no appending will be donebytes- input bytesp- start positionend- end positionencp- out param for fixed encodingstr- original bytes wrappermode- error mode- Returns:
- new position after unescaping
-
unescapeUnicodeBmp
private static int unescapeUnicodeBmp(Ruby runtime, ByteList to, byte[] bytes, int p, int end, org.jcodings.Encoding[] encp, ByteList str, RegexpSupport.ErrorMode mode) Unescape unicode BMP char at given offset, appending to the specified buffer if non-null.- Parameters:
runtime- current runtimeto- output buffer; if null, no appending will be donebytes- input bytesp- start positionend- end positionencp- out param for fixed encodingstr- original bytes wrappermode- error mode- Returns:
- new position after unescaping
-
appendUtf8
private static void appendUtf8(Ruby runtime, ByteList to, int code, org.jcodings.Encoding[] enc, ByteList str, RegexpSupport.ErrorMode mode) Append the given utf8 characters to the buffer, if given, checking for errors along the way.- Parameters:
runtime- current runtimeto- output buffer; if null, no appending will be donecode- utf8 character codeenc- output param for new encodingstr- original wrapper of source bytesmode- error mode
-
checkUnicodeRange
private static void checkUnicodeRange(Ruby runtime, int code, ByteList str, RegexpSupport.ErrorMode mode)
-