fixed bug 362: preprocessor not preserving line numbers
authoradam <adam@megacz.com>
Mon, 9 Feb 2004 23:30:47 +0000 (23:30 +0000)
committeradam <adam@megacz.com>
Mon, 9 Feb 2004 23:30:47 +0000 (23:30 +0000)
darcs-hash:20040209233047-5007d-6b568c5a81f30f969b7df191906361bb8e105e08.gz

src/org/ibex/Template.java
src/org/ibex/util/Preprocessor.java
src/org/ibex/util/XML.java

index aa190b3..41c23aa 100644 (file)
@@ -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);
                 }
index 54c2b1c..875416d 100644 (file)
@@ -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;  ");
             }
index db55a66..d3ed118 100644 (file)
@@ -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); }