From: <cr...@us...> - 2008-07-26 05:52:20
|
Revision: 4359 http://jnode.svn.sourceforge.net/jnode/?rev=4359&view=rev Author: crawley Date: 2008-07-26 05:52:17 +0000 (Sat, 26 Jul 2008) Log Message: ----------- More bug fixes + debug mode. Modified Paths: -------------- trunk/builder/src/configure/org/jnode/configure/Configure.java trunk/builder/src/configure/org/jnode/configure/Screen.java trunk/builder/src/configure/org/jnode/configure/ScriptParser.java trunk/builder/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java Modified: trunk/builder/src/configure/org/jnode/configure/Configure.java =================================================================== --- trunk/builder/src/configure/org/jnode/configure/Configure.java 2008-07-25 21:09:31 UTC (rev 4358) +++ trunk/builder/src/configure/org/jnode/configure/Configure.java 2008-07-26 05:52:17 UTC (rev 4359) @@ -57,7 +57,7 @@ private void run(String[] args) { try { parseArguments(args); - ConfigureScript script = new ScriptParser().loadScript(scriptFile); + ConfigureScript script = new ScriptParser(this).loadScript(scriptFile); for (PropertySet propFile : script.getPropsFiles()) { propFile.load(this); } @@ -123,6 +123,12 @@ format(err, message, DISPLAY_NORMAL); } + public void debug(String message) { + if (debug) { + format(err, message, DISPLAY_NORMAL); + } + } + private void format(PrintStream stream, String text, int displayAttributes) { switch (displayAttributes) { case DISPLAY_PROMPT: Modified: trunk/builder/src/configure/org/jnode/configure/Screen.java =================================================================== --- trunk/builder/src/configure/org/jnode/configure/Screen.java 2008-07-25 21:09:31 UTC (rev 4358) +++ trunk/builder/src/configure/org/jnode/configure/Screen.java 2008-07-26 05:52:17 UTC (rev 4359) @@ -137,12 +137,11 @@ } value = prop.getType().fromInput(input); if (value == null && input.length() == 0 && prop.hasDefaultValue()) { + configure.debug("Trying default"); value = prop.getDefaultValue(); } } while (value == null); - if (value != null) { - prop.setValue(value); - } + prop.setValue(value); } } } Modified: trunk/builder/src/configure/org/jnode/configure/ScriptParser.java =================================================================== --- trunk/builder/src/configure/org/jnode/configure/ScriptParser.java 2008-07-25 21:09:31 UTC (rev 4358) +++ trunk/builder/src/configure/org/jnode/configure/ScriptParser.java 2008-07-26 05:52:17 UTC (rev 4359) @@ -121,7 +121,12 @@ } } - private LinkedList<ParseContext> stack = new LinkedList<ParseContext>(); + private final LinkedList<ParseContext> stack = new LinkedList<ParseContext>(); + private final Configure configure; + + public ScriptParser(Configure configure) { + this.configure = configure; + } public ConfigureScript loadScript(String fileName) throws ConfigureException { final File file = new File(fileName); @@ -338,6 +343,8 @@ error("Use of undeclared type '" + typeName + "'", child); } Value defaultValue = (defaultText == null) ? null : type.fromValue(defaultText); + configure.debug("Default value for " + name + " is " + + (defaultValue == null ? "null" : defaultValue.toString())); try { propSet.addProperty(name, type, description, defaultValue, child, stack.getLast() .getFile()); Modified: trunk/builder/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java =================================================================== --- trunk/builder/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java 2008-07-25 21:09:31 UTC (rev 4358) +++ trunk/builder/src/configure/org/jnode/configure/adapter/BasePropertyFileAdapter.java 2008-07-26 05:52:17 UTC (rev 4359) @@ -98,7 +98,7 @@ try { if (!file.exists() && defaultFile != null) { if (defaultFile.exists()) { - configure.output("Taking initial values for the '" + file + + configure.debug("Taking initial values for the '" + file + "' properties from '" + defaultFile + "'."); file = defaultFile; } @@ -107,7 +107,7 @@ loadFromFile(properties, in); } catch (FileNotFoundException ex) { // Fall back to the builtin default property values - configure.output("Taking initial values for the '" + file + + configure.debug("Taking initial values for the '" + file + "' properties from the builtin defaults."); } catch (IOException ex) { throw new ConfigureException("Problem loading properties from '" + file + "'.", ex); @@ -125,20 +125,29 @@ String value = (String) properties.get(key); Property prop = propSet.getProperty((String) key); if (prop != null) { - PropertyType type = prop.getType(); - prop.setDefaultValue(type.fromValue(value)); + PropertySet.Value defaultValue = prop.getType().fromValue(value); + configure.debug("Setting default value for " + key + " to " + + (defaultValue == null ? "null" : defaultValue.toString())); + prop.setDefaultValue(defaultValue); } } } public void save(PropertySet propSet, Configure configure) throws ConfigureException { - // Harvest the properties to be written into a Properties Object + // Harvest the properties to be written into a temporary Properties Object Properties properties = new Properties(); for (Map.Entry<String, Property> entry : propSet.getProperties().entrySet()) { PropertySet.Value propValue = entry.getValue().getValue(); + if (propValue == null) { + configure.debug("Using default for unset property " + entry.getKey()); + propValue = entry.getValue().getDefaultValue(); + } String text = (propValue == null) ? "" : propValue.getText(); + configure.debug("Property " + entry.getKey() + " is \"" + text + "\""); properties.setProperty(entry.getKey(), text); } + // Output properties, either using the child class'es saveToFile method + // or by using the template expansion mechanism. OutputStream os = null; InputStream is = null; File toFile = propSet.getFile(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |