Re: [cp-patches] FYI: System.getenv

2008-09-19 Thread Mario Torre
Il giorno gio, 18/09/2008 alle 01.00 +0100, Andrew John Hughes ha
scritto:

 Please be more careful when applying such fixes.  This patch
 alters code which is nothing to do with the bug:
 
  -   ListString environ = (ListString)VMSystem.environ();
  -   MapString,String variables = new EnvironmentMap();
  +MapString, String _map = new HashMap();
  +ListString environ = (ListString)VMSystem.environ();

Sorry, this one was a cut and paste typo, thanks for spotting it.

Cheers,
Mario
-- 
Mario Torre, Software Developer, http://www.jroller.com/neugens/
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-53
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/




Re: [cp-patches] FYI: System.getenv

2008-09-17 Thread Andrew John Hughes
On 21:42 Tue 16 Sep , Mario Torre wrote:
 Hi all!
 
 I just submitted this patch that fixes a problem in our System.getenv()
 method.
 
 It's possible to have variable in the form of:
 
 key=value=value=value
 
 like (from my env list):
 
 XDM_MANAGED=method=classic
 
 cheers,
 Mario
 
 2008-09-16  Mario Torre  [EMAIL PROTECTED]
 
 * java/lang/System.java (getenv): Fix env entries of the form
 key=value=value=value not parsed correctly. 
 
 -- 
 Mario Torre, Software Developer, http://www.jroller.com/neugens/
 aicas Allerton Interworks Computer Automated Systems GmbH
 Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
 http://www.aicas.com   * Tel: +49-721-663 968-53
 pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
 Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF
 
 USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
 Geschäftsführer: Dr. James J. Hunt
 
 Please, support open standards:
 http://opendocumentfellowship.org/petition/
 http://www.nosoftwarepatents.com/

 ### Eclipse Workspace Patch 1.0
 #P classpath
 Index: java/lang/System.java
 ===
 RCS file: /sources/classpath/classpath/java/lang/System.java,v
 retrieving revision 1.62
 diff -u -r1.62 System.java
 --- java/lang/System.java 7 Jan 2008 21:11:24 -   1.62
 +++ java/lang/System.java 16 Sep 2008 19:26:17 -
 @@ -546,20 +546,28 @@
  SecurityManager sm = SecurityManager.current; // Be thread-safe.
  if (sm != null)
sm.checkPermission(new RuntimePermission(getenv.*));
 +
  if (environmentMap == null)
{
 - ListString environ = (ListString)VMSystem.environ();
 - MapString,String variables = new EnvironmentMap();
 - for (String pair : environ)
 -   {
 - String[] parts = pair.split(=);
 - if (parts.length == 2)
 -   variables.put(parts[0], parts[1]);
 - else
 -   variables.put(parts[0], );
 -   }
 - environmentMap = Collections.unmodifiableMap(variables);
 +MapString, String _map = new HashMap();
 +ListString environ = (ListString)VMSystem.environ();
 +for (String envEntry : environ)
 +  {
 +// avoid broken and null entries
 +if (envEntry != null  !envEntry.endsWith(=))
 +  {
 +// it's perfectly legal that some entries may be in the form
 +// key=value=value=value
 +int equalSignIndex = envEntry.indexOf('=');
 +String key = envEntry.substring(0, equalSignIndex);
 +String value = envEntry.substring(equalSignIndex + 1);
 +_map.put(key, value);
 +  }
 +  }
 +
 +environmentMap = Collections.unmodifiableMap(_map);
}
 +
  return environmentMap;
}
  

Please be more careful when applying such fixes.  This patch
alters code which is nothing to do with the bug:

 - ListString environ = (ListString)VMSystem.environ();
 - MapString,String variables = new EnvironmentMap();
 +MapString, String _map = new HashMap();
 +ListString environ = (ListString)VMSystem.environ();

and thus breaks the implementation by replacing the EnvironmentMap
(necessary to ensure the contract of the returned collection)
with a raw HashMap.

Fixed in CVS with this patch:

2008-09-16  Andrew John Hughes  [EMAIL PROTECTED]

* java/lang/System.java (getenv): Reinstate
use of EnvironmentMap as opposed to raw
HashMap.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: java/lang/System.java
===
RCS file: /sources/classpath/classpath/java/lang/System.java,v
retrieving revision 1.63
diff -u -u -r1.63 System.java
--- java/lang/System.java   16 Sep 2008 19:41:44 -  1.63
+++ java/lang/System.java   16 Sep 2008 20:52:01 -
@@ -549,7 +549,7 @@
 
 if (environmentMap == null)
   {
-MapString, String _map = new HashMap();
+   MapString,String variables = new EnvironmentMap();
 ListString environ = (ListString)VMSystem.environ();
 for (String envEntry : environ)
   {
@@ -561,11 +561,11 @@
 int equalSignIndex = envEntry.indexOf('=');
 String key = envEntry.substring(0, equalSignIndex);
 String value = envEntry.substring(equalSignIndex + 1);
-_map.put(key, value);
+variables.put(key, value);
   }
   }
 
-environmentMap = Collections.unmodifiableMap(_map);
+environmentMap = Collections.unmodifiableMap(variables);
   }
 
 return environmentMap;


[cp-patches] FYI: System.getenv

2008-09-16 Thread Mario Torre
Hi all!

I just submitted this patch that fixes a problem in our System.getenv()
method.

It's possible to have variable in the form of:

key=value=value=value

like (from my env list):

XDM_MANAGED=method=classic

cheers,
Mario

2008-09-16  Mario Torre  [EMAIL PROTECTED]

* java/lang/System.java (getenv): Fix env entries of the form
key=value=value=value not parsed correctly. 

-- 
Mario Torre, Software Developer, http://www.jroller.com/neugens/
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-53
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P classpath
Index: java/lang/System.java
===
RCS file: /sources/classpath/classpath/java/lang/System.java,v
retrieving revision 1.62
diff -u -r1.62 System.java
--- java/lang/System.java	7 Jan 2008 21:11:24 -	1.62
+++ java/lang/System.java	16 Sep 2008 19:26:17 -
@@ -546,20 +546,28 @@
 SecurityManager sm = SecurityManager.current; // Be thread-safe.
 if (sm != null)
   sm.checkPermission(new RuntimePermission(getenv.*));
+
 if (environmentMap == null)
   {
-	ListString environ = (ListString)VMSystem.environ();
-	MapString,String variables = new EnvironmentMap();
-	for (String pair : environ)
-	  {
-	String[] parts = pair.split(=);
-	if (parts.length == 2)
-	  variables.put(parts[0], parts[1]);
-	else
-	  variables.put(parts[0], );
-	  }
-	environmentMap = Collections.unmodifiableMap(variables);
+MapString, String _map = new HashMap();
+ListString environ = (ListString)VMSystem.environ();
+for (String envEntry : environ)
+  {
+// avoid broken and null entries
+if (envEntry != null  !envEntry.endsWith(=))
+  {
+// it's perfectly legal that some entries may be in the form
+// key=value=value=value
+int equalSignIndex = envEntry.indexOf('=');
+String key = envEntry.substring(0, equalSignIndex);
+String value = envEntry.substring(equalSignIndex + 1);
+_map.put(key, value);
+  }
+  }
+
+environmentMap = Collections.unmodifiableMap(_map);
   }
+
 return environmentMap;
   }