[cp-patches] FYI: [generics] Fix for System.getenv bug

2006-06-04 Thread Andrew John Hughes
I'm committing the patch which fixes a bug in System.getenv()
when an environment variable has an empty value.

Changelog:

2006-06-04  Andrew John Hughes  [EMAIL PROTECTED]

* java/lang/System.java:
(getenv()): Handle cases where split only
returns an array of size 1.

-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

If you use Microsoft Office, support movement towards the end of vendor lock-in:
http://opendocumentfellowship.org/petition/

Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn. 
-- Richard Stallman

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: java/lang/System.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/System.java,v
retrieving revision 1.38.2.19
diff -u -3 -p -u -r1.38.2.19 System.java
--- java/lang/System.java   3 Jun 2006 16:02:08 -   1.38.2.19
+++ java/lang/System.java   4 Jun 2006 15:35:55 -
@@ -549,7 +549,10 @@ public final class System
for (String pair : environ)
  {
String[] parts = pair.split(=);
-   variables.put(parts[0], parts[1]);
+   if (parts.length == 2)
+ variables.put(parts[0], parts[1]);
+   else
+ variables.put(parts[0], );
  }
environmentMap = Collections.unmodifiableMap(variables);
   }


signature.asc
Description: Digital signature


Re: [cp-patches] FYI: [generics] Fix for System.getenv bug

2006-06-04 Thread Archie Cobbs

Andrew John Hughes wrote:

I'm committing the patch which fixes a bug in System.getenv()
when an environment variable has an empty value.


Not part of your patch (code was there before) but:


String[] parts = pair.split(=);


Shouldn't this be pair.split(=, 1) instead? E.g. what if I have
a variable like FOO=2+2=4.

Actually, even that is not right. E.g., consider FOO==BAR. The
value is =BAR not empty string.

Instead, I think using pair.indexOf('=') is required here...

-Archie

__
Archie Cobbs  *CTO, Awarix*  http://www.awarix.com