From 9e124c49a130a702959a55999b1a6c3a3a559997 Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 9 Feb 2004 23:30:47 +0000 Subject: [PATCH] fixed bug 362: preprocessor not preserving line numbers darcs-hash:20040209233047-5007d-6b568c5a81f30f969b7df191906361bb8e105e08.gz --- src/org/ibex/Template.java | 1 - src/org/ibex/util/Preprocessor.java | 12 ++++++------ src/org/ibex/util/XML.java | 14 +++++++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/org/ibex/Template.java b/src/org/ibex/Template.java index aa190b3..41c23aa 100644 --- a/src/org/ibex/Template.java +++ b/src/org/ibex/Template.java @@ -191,7 +191,6 @@ public class Template { // GROSS hack try { t.prev = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999); - if (t.prev == null) throw new JSExn("template " + tagname + " not found"); } catch (Exception e) { Log.error(Template.class, e); } diff --git a/src/org/ibex/util/Preprocessor.java b/src/org/ibex/util/Preprocessor.java index 54c2b1c..875416d 100644 --- a/src/org/ibex/util/Preprocessor.java +++ b/src/org/ibex/util/Preprocessor.java @@ -191,7 +191,7 @@ PROCESS: if (key != null) { Hashtable hash = byLength[key.length()]; - hash.put(key, (String)hash.get(key) + processLine(trimmed, false).replaceAll("//[^\"]*$", "")); + hash.put(key, (String)hash.get(key) + processLine(trimmed, false).replaceAll("//[^\"]*$", "").trim() + "\n"); } else { out.print(processLine(trimmed, false)); } @@ -199,13 +199,13 @@ PROCESS: for(int i=0; i<255; i++) { if (byLength[i] == null) continue; - out.print("case " + i + ": { switch(ccSwitch"+enumSwitch+".charAt(0)) {\n"); + out.print("case " + i + ": { switch(ccSwitch"+enumSwitch+".charAt(0)) { "); buildTrie("", byLength[i]); - out.print("}; break; }\n"); + out.print("}; break; } "); } out.print("} /* switch */ "); - if (Default != null) out.print("\n" + Default); - out.print(" } while(false); //OUTER\n"); + if (Default != null) out.print(" " + Default); + out.print(" } while(false); /* OUTER */\n"); enumSwitch++; } else { @@ -237,7 +237,7 @@ PROCESS: } else { out.print("case \'" + prefixPlusOne.charAt(prefixPlusOne.length() - 1) + "\': "); String code = (String)cases.get(keys.elementAt(i)); - code = code.substring(0, code.length() - 1); + code = code.substring(0, code.length()); String key = (String)keys.elementAt(i); out.print("if (\""+key+"\".equals(ccSwitch"+enumSwitch+")) { if (true) do { " + code + " } while(false); break SUCCESS; } break; "); } diff --git a/src/org/ibex/util/XML.java b/src/org/ibex/util/XML.java index db55a66..d3ed118 100644 --- a/src/org/ibex/util/XML.java +++ b/src/org/ibex/util/XML.java @@ -787,7 +787,19 @@ public abstract class XML /** Prefix of current element. Substring of qName. XML Namespace Spec 14-Jan-1999 [7] */ public String getPrefix() { return prefix; } - public Hash getUriMap() { return urimap; } // HACK + // HACK + public Hash getUriMap() { + Hash map = new Hash(); + for (Element e = this; e != null; e = e.getParent()) { + java.util.Enumeration en = e.urimap.keys(); + while(en.hasMoreElements()) { + String key = (String)en.nextElement(); + String val = getUri(key); + map.put(key, val); + } + } + return map; + } /** URI of current tag. XML Namespace Spec 14-Jan-1999 section 1 */ public String getUri() { return getUri(prefix); } -- 1.7.10.4