X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fxwt%2Futil%2FPreprocessor.java;h=00ae93eddf2435df7cb598e8e7e5857657043762;hb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;hp=5cff2d0b1b9e764e0fc50669a668e0957ee0d195;hpb=842cef088e3cf5d141677ce5d824c98a15c203e8;p=org.ibex.core.git diff --git a/src/org/xwt/util/Preprocessor.java b/src/org/xwt/util/Preprocessor.java index 5cff2d0..00ae93e 100644 --- a/src/org/xwt/util/Preprocessor.java +++ b/src/org/xwt/util/Preprocessor.java @@ -1,4 +1,10 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright (C) 2003 Adam Megacz all rights reserved. +// +// You may modify, copy, and redistribute this code under the terms of +// the GNU Library Public License version 2.1, with the exception of +// the portion of clause 6a after the semicolon (aka the "obnoxious +// relink clause") + package org.xwt.util; import java.util.*; @@ -122,7 +128,7 @@ PROCESS: while(trimmed.charAt(trimmed.length() - 1) == '\\') { String s2 = in.readLine().trim(); if (s2.startsWith("//")) s2 = s2.substring(2).trim(); - trimmed += s2; + trimmed = trimmed.substring(0, trimmed.length() - 1) + " " + s2; out.println(); // preserve line numbers } StringTokenizer st = new StringTokenizer(trimmed, " "); @@ -148,13 +154,13 @@ PROCESS: } else if (trimmed.startsWith("//#switch")) { int expStart = trimmed.indexOf('(') +1; if (expStart < 1) { err.add(new Error("expected ( in #switch")); continue PROCESS; } - int expEnd = trimmed.indexOf(')'); + int expEnd = trimmed.lastIndexOf(')'); if (expEnd == -1) { err.add(new Error("expected ) in #switch")); continue PROCESS; } if (expEnd - expStart <= 1) { err.add(new Error("badly formed #switch statement")); continue PROCESS; } String expr = trimmed.substring(expStart, expEnd); - out.println("final String ccSwitch"+enumSwitch+" = (String)("+expr+");"+ - "switch(ccSwitch"+enumSwitch+".length()) {"); + out.println("final String ccSwitch"+enumSwitch+" = (String)("+expr+");"); + out.println("SUCCESS:do { switch(ccSwitch"+enumSwitch+".length()) {"); Hashtable[] byLength = new Hashtable[255]; String key = null; @@ -196,8 +202,9 @@ PROCESS: buildTrie("", byLength[i]); out.println("}; break; }"); } - if (Default != null) out.println("default: { " + Default + " }"); out.println("} //switch"); + if (Default != null) out.println(Default); + out.println("} while(false); //OUTER"); enumSwitch++; } else { @@ -231,7 +238,7 @@ PROCESS: String code = (String)cases.get(keys.elementAt(i)); code = code.substring(0, code.length() - 1); String key = (String)keys.elementAt(i); - out.println("if (\""+key+"\".equals(ccSwitch"+enumSwitch+")) { " + code + " } break; "); + out.println("if (\""+key+"\".equals(ccSwitch"+enumSwitch+")) { if (true) do { " + code + " } while(false); break SUCCESS; } break; "); } } }