[jruby-joni] 89/223: Fix escape for 8 and 9.
Hideki Yamane
henrich at moszumanska.debian.org
Mon Nov 16 11:21:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository jruby-joni.
commit 7485ec4646e939f7656d95cf915e1f63ed905bb2
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Fri Feb 17 23:51:06 2012 +0100
Fix escape for 8 and 9.
---
src/org/joni/Lexer.java | 13 +++++--------
src/org/joni/ScannerSupport.java | 6 ++++++
src/org/joni/ast/StringNode.java | 5 +++--
test/org/joni/test/TestA.java | 5 ++++-
4 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/org/joni/Lexer.java b/src/org/joni/Lexer.java
index 9ba85b7..e26e6ba 100644
--- a/src/org/joni/Lexer.java
+++ b/src/org/joni/Lexer.java
@@ -483,7 +483,6 @@ class Lexer extends ScannerSupport {
boolean inEsc = false;
int i=0;
-
while(p < to) {
if (inEsc) {
inEsc = false;
@@ -805,8 +804,7 @@ class Lexer extends ScannerSupport {
unfetch();
int last = p;
int num = scanUnsignedNumber();
- if (num < 0 || num > Config.MAX_BACKREF_NUM) {
- // goto skip_backref
+ if (num < 0 || num > Config.MAX_BACKREF_NUM) { // goto skip_backref
} else if (syntax.opDecimalBackref() && (num <= env.numMem || num <= 9)) { /* This spec. from GNU regex */
if (syntax.strictCheckBackref()) {
if (num > env.numMem || env.memNodes == null || env.memNodes[num] == null) newValueException(ERR_INVALID_BACKREF);
@@ -818,16 +816,15 @@ class Lexer extends ScannerSupport {
if (Config.USE_BACKREF_WITH_LEVEL) token.setBackrefExistLevel(false);
return;
}
- // skip_backref:
- if (c == '8' || c == '9') {
- /* normal char */
+
+ if (c == '8' || c == '9') { /* normal char */ // skip_backref:
p = last;
inc();
return;
}
p = last;
- /* fall through */
- fetchTokenFor_zero();
+
+ fetchTokenFor_zero(); /* fall through */
}
private void fetchTokenFor_zero() {
diff --git a/src/org/joni/ScannerSupport.java b/src/org/joni/ScannerSupport.java
index a2ced01..8598fc6 100644
--- a/src/org/joni/ScannerSupport.java
+++ b/src/org/joni/ScannerSupport.java
@@ -60,6 +60,7 @@ abstract class ScannerSupport extends IntHolder implements ErrorMessages {
private final int INT_SIGN_BIT = 1 << 31;
protected final int scanUnsignedNumber() {
+ int last = c;
int num = 0; // long ???
while(left()) {
fetch();
@@ -72,10 +73,12 @@ abstract class ScannerSupport extends IntHolder implements ErrorMessages {
break;
}
}
+ c = last;
return num;
}
protected final int scanUnsignedHexadecimalNumber(int maxLength) {
+ int last = c;
int num = 0;
while(left() && maxLength-- != 0) {
fetch();
@@ -89,10 +92,12 @@ abstract class ScannerSupport extends IntHolder implements ErrorMessages {
break;
}
}
+ c = last;
return num;
}
protected final int scanUnsignedOctalNumber(int maxLength) {
+ int last = c;
int num = 0;
while(left() && maxLength-- != 0) {
fetch();
@@ -106,6 +111,7 @@ abstract class ScannerSupport extends IntHolder implements ErrorMessages {
break;
}
}
+ c = last;
return num;
}
diff --git a/src/org/joni/ast/StringNode.java b/src/org/joni/ast/StringNode.java
index 4429d20..57e33c5 100644
--- a/src/org/joni/ast/StringNode.java
+++ b/src/org/joni/ast/StringNode.java
@@ -94,14 +94,15 @@ public final class StringNode extends Node implements StringType {
@Override
public String toString(int level) {
StringBuilder value = new StringBuilder();
- value.append("\n bytes: ");
+ value.append("\n bytes: \'");
for (int i=p; i<end; i++) {
if ((bytes[i] & 0xff) >= 0x20 && (bytes[i] & 0xff) < 0x7f) {
value.append((char)bytes[i]);
} else {
- value.append(String.format(" 0x%02x", bytes[i]));
+ value.append(String.format("0x%02x", bytes[i]));
}
}
+ value.append("'");
return value.toString();
}
diff --git a/test/org/joni/test/TestA.java b/test/org/joni/test/TestA.java
index 427c1d9..ed2d035 100644
--- a/test/org/joni/test/TestA.java
+++ b/test/org/joni/test/TestA.java
@@ -479,7 +479,10 @@ public class TestA extends Test {
x2s("\\g", "g", 0, 1);
x2s("\\gx", "gx", 0, 2);
x2s("\\k\\g", "kg", 0, 2);
-
+ ns("\\00", "00");
+ ns("\\70", "70");
+ x2s("\\80", "80", 0, 2);
+ x2s("\\90", "90", 0, 2);
}
public static void main(String[] args) throws Throwable{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git
More information about the pkg-java-commits
mailing list