Skip to content

Commit

Permalink
Fix typo in basic.yml that stopped those tests from running on MRI, a…
Browse files Browse the repository at this point in the history
…nd fix all the rest of the failures on JRuby
  • Loading branch information
olabini committed Oct 23, 2008
1 parent 1c34721 commit 11e3005
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 55 deletions.
1 change: 0 additions & 1 deletion ext/redcloth_scan/redcloth_attributes.java.rl
Expand Up @@ -75,7 +75,6 @@ public class RedclothAttributes extends RedclothScanService.Base {
private IRubyObject buf;

public RedclothAttributes(int machine, IRubyObject self, byte[] data, int p, int pe) {
System.err.println("RedclothAttributes(data.len: " + data.length + ", p: " + p + ", pe: " + pe + ")");
this.runtime = self.getRuntime();
this.self = self;

Expand Down
10 changes: 5 additions & 5 deletions ext/redcloth_scan/redcloth_common.java.rl
Expand Up @@ -2,10 +2,10 @@

machine redcloth_common;

action A { System.err.println("action A{reg=" + p + "}");reg = p; }
action B { System.err.println("action B");bck = p; }
action T { System.err.println("action T");STORE("text"); }
action X { System.err.println("action X");CLEAR_REGS(); reg = -1; }
action A { reg = p; }
action B { bck = p; }
action T { STORE("text"); }
action X { CLEAR_REGS(); reg = -1; }
action cat { CAT(block); }
action esc { strCatEscaped(self, block, data, ts, te); }
action esc_pre { strCatEscapedForPreformatted(self, block, data, ts, te); }
Expand Down Expand Up @@ -115,7 +115,7 @@
p == orig_p || data[(p-1)] == '\r' || data[(p-1)] == '\n' || data[(p-1)] == '\f'
}
action starts_phrase {
print("starts_phrase: " + (p == orig_p || data[(p-1)] == '\r' || data[(p-1)] == '\n' || data[(p-1)] == '\f' || data[(p-1)] == ' ')) && (p == orig_p || data[(p-1)] == '\r' || data[(p-1)] == '\n' || data[(p-1)] == '\f' || data[(p-1)] == ' ')
p == orig_p || data[(p-1)] == '\r' || data[(p-1)] == '\n' || data[(p-1)] == '\f' || data[(p-1)] == ' '
}

}%%;
9 changes: 2 additions & 7 deletions ext/redcloth_scan/redcloth_inline.java.rl
Expand Up @@ -152,7 +152,7 @@ public class RedclothInline extends RedclothScanService.Base {
emdash { INLINE(block, "emdash"); };
endash { INLINE(block, "endash"); };
arrow { INLINE(block, "arrow"); };
caps { System.err.println("MATCHED caps"); INLINE(block, "caps"); };
caps { INLINE(block, "caps"); };
acronym { INLINE(block, "acronym"); };
dim { INLINE(block, "dim"); };
trademark { INLINE(block, "trademark"); };
Expand Down Expand Up @@ -204,25 +204,21 @@ public class RedclothInline extends RedclothScanService.Base {
}

public void PASS_CODE(IRubyObject H, String A, String T, int O) {
System.err.println("PASS_CODE");
((RubyString)H).append(red_pass_code(self, regs, runtime.newSymbol(A), T));
}

public void PARSE_ATTR(String A) {
System.err.println("PARSE_ATTR");
red_parse_attr(self, regs, runtime.newSymbol(A));
}

public void PARSE_LINK_ATTR(String A) {
System.err.println("PARSE_LINK_ATTR");
red_parse_link_attr(self, regs, runtime.newSymbol(A));
}

private int opts;
private IRubyObject buf;

public RedclothInline(IRubyObject self, byte[] data, int p, int pe, IRubyObject refs) {
System.err.println("RedclothInline(data.len: " + data.length + ", p: " + p + ", pe: " + pe + ")");
this.runtime = self.getRuntime();
this.self = self;

Expand All @@ -247,8 +243,7 @@ public class RedclothInline extends RedclothScanService.Base {
public IRubyObject inline() {
%% write init;
%% write exec;
System.err.println("gah: p: " + p + " pe: " + pe + " regs: " + regs + " refs: " + refs);
System.err.println(" reg: " + reg);

return block;
}

Expand Down
45 changes: 5 additions & 40 deletions ext/redcloth_scan/redcloth_scan.java.rl
Expand Up @@ -26,10 +26,6 @@ import org.jruby.util.ByteList;
public class RedclothScanService implements BasicLibraryService {

public static class Base {
public boolean print(String str) {
System.err.println(str);
return true;
}
public void LIST_ITEM() {
int aint = 0;
IRubyObject aval = ((RubyArray)list_index).entry(nest-1);
Expand Down Expand Up @@ -111,9 +107,11 @@ public class RedclothScanService implements BasicLibraryService {
}
te = p;
}

STORE(T);

if(!refs.isNil() && refs.callMethod(runtime.getCurrentContext(), "has_key?", ((RubyHash)regs).aref(runtime.newSymbol(T))).isTrue()) {
((RubyHash)regs).aset(runtime.newSymbol(T), ((RubyHash)refs).aref(((RubyHash)refs).aref(runtime.newSymbol(T))));
((RubyHash)regs).aset(runtime.newSymbol(T), ((RubyHash)refs).aref(((RubyHash)regs).aref(runtime.newSymbol(T))));
}
}

Expand Down Expand Up @@ -143,26 +141,21 @@ public class RedclothScanService implements BasicLibraryService {
IRubyObject sym_text = runtime.newSymbol("text");
IRubyObject btype = ((RubyHash)regs).aref(runtime.newSymbol("type"));
block = block.callMethod(runtime.getCurrentContext(), "strip");
System.err.println(":red_block: \"" + block + "\"");

if(!block.isNil() && !btype.isNil()) {
method = btype.convertToString().intern();

if(method == runtime.newSymbol("notextile")) {
System.err.println("-NOTEXTILE");
((RubyHash)regs).aset(sym_text, block);
} else {
System.err.println("-INLINE2");
((RubyHash)regs).aset(sym_text, inline2(self, block, refs));
}
System.err.println("METHOD: " + method);

if(self.respondsTo(method.asJavaString())) {
System.err.println("-method: " + method);
block = self.callMethod(runtime.getCurrentContext(), method.asJavaString(), regs);
} else {
System.err.println("-fallback");
IRubyObject fallback = ((RubyHash)regs).aref(runtime.newSymbol("fallback"));
if(!fallback.isNil()) {
System.err.println(" fallback is: " + fallback);
((RubyString)fallback).append(((RubyHash)regs).aref(sym_text));
regs = RubyHash.newHash(runtime);
((RubyHash)regs).aset(sym_text, fallback);
Expand All @@ -175,22 +168,18 @@ public class RedclothScanService implements BasicLibraryService {
}

public void strCatEscaped(IRubyObject self, IRubyObject str, byte[] data, int ts, int te) {
System.err.println("strCatEscaped(str="+str+", ts="+ts+", te="+te+")");
IRubyObject sourceStr = RubyString.newString(self.getRuntime(), data, ts, te-ts);
System.err.println(" -- result: " + sourceStr);
IRubyObject escapedStr = self.callMethod(self.getRuntime().getCurrentContext(), "escape", sourceStr);
((RubyString)str).concat(escapedStr);
}

public void strCatEscapedForPreformatted(IRubyObject self, IRubyObject str, byte[] data, int ts, int te) {
System.err.println("strCatEscapedForPreformatted");
IRubyObject sourceStr = RubyString.newString(self.getRuntime(), data, ts, te-ts);
IRubyObject escapedStr = self.callMethod(self.getRuntime().getCurrentContext(), "escape_pre", sourceStr);
((RubyString)str).concat(escapedStr);
}

public void CLEAR(IRubyObject obj) {
// System.err.println("CLEAR");
if(block == obj) {
block = RubyString.newEmptyString(runtime);
} else if(html == obj) {
Expand All @@ -201,73 +190,60 @@ public class RedclothScanService implements BasicLibraryService {
}

public void ADD_BLOCK() {
// System.err.println("ADD_BLOCK: [before] html=|" + html + "| block=|" + block + "| table=|" + table + "|");
((RubyString)html).append(red_block(self, regs, block, refs));
// System.err.println(" [after] html=|" + html + "| block=|" + block + "| table=|" + table + "|");
extend = runtime.getNil();
CLEAR(block);
CLEAR_REGS();
}

public void CLEAR_REGS() {
// System.err.println("CLEAR_REGS");
regs = RubyHash.newHash(runtime);
}

public void CAT(IRubyObject H) {
// System.err.println("CAT: (ts="+ts+", te="+te+") \"" + new String(data, ts, te-ts) + "\"");
((RubyString)H).cat(data, ts, te-ts);
}

public void INLINE(IRubyObject H, String T) {
// System.err.println("INLINE: \"" + H + "\" for: " + T);
((RubyString)H).append(self.callMethod(runtime.getCurrentContext(), T, regs));
}

public void DONE(IRubyObject H) {
// System.err.println("DONE");
((RubyString)html).append(H);
CLEAR(H);
CLEAR_REGS();
}

public void ADD_EXTENDED_BLOCK() {
// System.err.println("ADD_EXTENDED_BLOCK");
((RubyString)html).append(red_block(self, regs, block, refs));
CLEAR(block);
}

public void ADD_BLOCKCODE() {
// System.err.println("ADD_BLOCKCODE");
((RubyString)html).append(red_blockcode(self, regs, block));
CLEAR(block);
CLEAR_REGS();
}

public void ADD_EXTENDED_BLOCKCODE() {
// System.err.println("ADD_EXTENDED_BLOCKCODE");
((RubyString)html).append(red_blockcode(self, regs, block));
CLEAR(block);
}

public void AINC(String T) {
// System.err.println("AINC");
red_inc(regs, runtime.newSymbol(T));
}

public void END_EXTENDED() {
// System.err.println("END_EXTENDED");
extend = runtime.getNil();
CLEAR_REGS();
}

public void ASET(String T, String V) {
// System.err.println("ASET");
((RubyHash)regs).aset(runtime.newSymbol(T), runtime.newString(V));
}

public void STORE(String T) {
// System.err.println("STORE: " + T + " p: " + p + " reg: " + reg + "(\""+new String(data, reg, p-reg)+"\")");
if(p > reg && reg >= ts) {

IRubyObject str = RubyString.newString(runtime, data, reg, p-reg);
Expand All @@ -278,7 +254,6 @@ public class RedclothScanService implements BasicLibraryService {
}

public void STORE_B(String T) {
// System.err.println("STORE_B: " + T + " p: " + p + " bck: " + bck);
if(p > bck && bck >= ts) {
IRubyObject str = RubyString.newString(runtime, data, bck, p-bck);
((RubyHash)regs).aset(runtime.newSymbol(T), str);
Expand Down Expand Up @@ -642,7 +617,6 @@ public class RedclothScanService implements BasicLibraryService {
%% write data nofinal;

public Transformer(IRubyObject self, byte[] data, int p, int pe, IRubyObject refs) {
System.err.println("Transformer(data.len: " + data.length + ", p: " + p + ", pe: " + pe + ")");
if(p+pe > data.length) {
throw new RuntimeException("BLAHAHA");
}
Expand Down Expand Up @@ -680,14 +654,9 @@ public class RedclothScanService implements BasicLibraryService {

%% write exec;

// System.err.println("gah: p: " + p + " pe: " + pe);
if(((RubyString)block).getByteList().realSize > 0) {
ADD_BLOCK();
}
// System.err.println("gah2: p: " + p + " pe: " + pe);
// System.err.println(" html: " + html);
// System.err.println(" table: " + table);
// System.err.println(" block: " + block);

if(refs.isNil() && !refs_found.callMethod(runtime.getCurrentContext(), "empty?").isTrue()) {
return RedclothScanService.transform(self, data, orig_p, orig_pe, refs_found);
Expand Down Expand Up @@ -737,18 +706,15 @@ public class RedclothScanService implements BasicLibraryService {
level = args[1];
}
str = args[0];
//System.err.println("html_esc called: " + self + ",,, args: " +str + ", " + level);

IRubyObject new_str = RubyString.newEmptyString(runtime);
if(str.isNil()) {
// System.err.println("isnil1");
return new_str;
}

ByteList bl = str.convertToString().getByteList();

if(bl.realSize == 0) {
// System.err.println("isnil2");
return new_str;
}

Expand Down Expand Up @@ -798,7 +764,6 @@ public class RedclothScanService implements BasicLibraryService {
((RubyString)new_str).cat(bytes, t, t2-t);
}

// System.err.println(" returning: " + new_str);
return new_str;
}

Expand Down
4 changes: 2 additions & 2 deletions test/basic.yml
Expand Up @@ -76,7 +76,7 @@ html: |-
<pre>I saw a ship. It ate my elephant.</pre>
<pre>When the elephant comes to take a p. you&#8230;</pre>
---
---
name: html tags
desc: You can certainly use HTML tags inside your Textile documents. HTML will only be escaped if it&#8217;s found in a <code>pre</code> or <code>code</code> block.
in: |-
Expand Down Expand Up @@ -868,4 +868,4 @@ in: |-
[Papers "blah blah."]
html: |-
<p>citation [&#8220;(Berk.) Hilton&#8221;], see<br />
[Papers &#8220;blah blah.&#8221;]</p>
[Papers &#8220;blah blah.&#8221;]</p>

0 comments on commit 11e3005

Please sign in to comment.