On Friday 22 March 2002 03:10 am, stephan beal wrote:
> Project, Main, Recorder, RecorderEntry:
> -emacs command line parameter will apply to any Recorder which does not
> specify a preference for emacsmode. This was a pretty widely-spread change,
> but it's pretty low-impact.
>
> Project.toBoolean():
> If passed null, it now treats that as false. i hope that's not evil?

i know we don't all agree on the AbstractCvsTask changes, but any arguments 
against these? i need to change EMACS_MODE_FLAG from "emacsMode" to 
"ant.emacsmode", but i think they're usable. (Attached is a patch which 
includes that change to Project.)


----- stephan
Generic Universal Computer Guy
[EMAIL PROTECTED] - http://www.einsurance.de
Office: +49 (89) �552 92 862 Handy: �+49 (179) 211 97 67
Student: "Master, you must teach me the way of liberation!"
Master:  "Tell me who it is that binds you."
Student: "No one binds me!"
Master:  "Then why do you seek liberation?"
Index: src/main/org/apache/tools/ant/Project.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
retrieving revision 1.99
diff -u -r1.99 Project.java
--- src/main/org/apache/tools/ant/Project.java	5 Mar 2002 14:39:05 -0000	1.99
+++ src/main/org/apache/tools/ant/Project.java	22 Mar 2002 10:23:14 -0000
@@ -97,6 +97,15 @@
     /** Message priority of "debug". */
     public final static int MSG_DEBUG = 4;
 
+    /**
+     * Quick hack to enable emacsMode in RecorderEntry ([EMAIL PROTECTED])
+     * This is not in Main because Task doesn't need to know about Main, and i don't
+     * want to make it know about Main just to see this flag.
+     */
+    public final static String EMACS_MODE_FLAG = "ant.emacsmode";
+
+
+
     /** 
      * Constant for the "visiting" state, used when
      * traversing a DFS of target dependencies.
@@ -224,8 +233,7 @@
      * This involves setting the default task definitions and loading the
      * system properties.
      * 
-     * @exception BuildException if the default task list cannot be loaded
-     */
+     * @exception BuildException if the default task list cannot be loaded    */
     public void init() throws BuildException {
         setJavaVersionProperty();
         
@@ -321,6 +329,12 @@
      *                 Must not be <code>null</code>.
      */
     public void addBuildListener(BuildListener listener) {
+	if( listener instanceof org.apache.tools.ant.BuildLogger ) 
+	{
+	    BuildLogger bl = (BuildLogger)listener;
+	    bl.setEmacsMode( Project.toBoolean( getProperty( Project.EMACS_MODE_FLAG ) ) );
+	    //	    log( "Hey, Project["+getName()+"].addBuildListener() got a BuildLogger!", Project.MSG_DEBUG );
+	}
         listeners.addElement(listener);
     }
 
@@ -403,6 +417,7 @@
      *              Must not be <code>null</code>.
      */
     public void setProperty(String name, String value) {
+	// System.out.println( "Project["+getName()+"].setProperty( ["+name+"], ["+value+"] )" );
         // command line properties take precedence
         if (null != userProperties.get(name)) {
             log("Override ignored for user property " + name, MSG_VERBOSE);
@@ -1492,13 +1507,17 @@
      * or <code>"yes"</code> is found, ignoring case.
      * 
      * @param s The string to convert to a boolean value. 
-     *          Must not be <code>null</code>.
+     *          May be <code>null</code> (equals false).
      * 
      * @return <code>true</code> if the given string is <code>"on"</code>,
      *         <code>"true"</code> or <code>"yes"</code>, or
      *         <code>false</code> otherwise.
      */
     public static boolean toBoolean(String s) {
+	if( s == null ) { return false; } // added by [EMAIL PROTECTED] 
+	// It seems reasonable, but i don't know if it breaks anything. i can't imagine any 
+	// classes RELYING on a an NPE here.
+
         return (s.equalsIgnoreCase("on") ||
                 s.equalsIgnoreCase("true") ||
                 s.equalsIgnoreCase("yes"));
--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to