summaryrefslogtreecommitdiffstats
path: root/src/jake2/util
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-01-09 23:41:53 +0000
committerCarsten Weisse <[email protected]>2005-01-09 23:41:53 +0000
commit16127433f99df634d924cf8d0ddff2e526fcdda1 (patch)
tree986fb91e326cdb5f259f50736a002e52c8386146 /src/jake2/util
parent2fb37c78fb3ef89482b20b0521e6f1c63bba36c3 (diff)
replacement for String.trim()
Diffstat (limited to 'src/jake2/util')
-rw-r--r--src/jake2/util/Lib.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java
index 709dfc7..4f709d4 100644
--- a/src/jake2/util/Lib.java
+++ b/src/jake2/util/Lib.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Lib.java,v 1.11 2004-12-16 19:46:49 cawe Exp $
+// $Id: Lib.java,v 1.12 2005-01-09 23:41:53 cawe Exp $
package jake2.util;
@@ -210,7 +210,7 @@ public class Lib {
byte buffer[] = new byte[len];
FS.Read(buffer, len, f);
- return new String(buffer).trim();
+ return Lib.CtoJava(buffer);
}
public static String rightFrom(String in, char c) {
int pos = in.lastIndexOf(c);
@@ -266,8 +266,13 @@ public class Lib {
return (index > 0) ? old.substring(0, index) : old;
}
+ public static String CtoJava(byte[] old) {
+ return CtoJava(old, 0, old.length);
+ }
+
public static String CtoJava(byte[] old, int offset, int maxLenght) {
- int i;
+ if (old.length == 0 || old[0] == 0) return "";
+ int i;
for (i = offset; old[i] != 0 && (i - offset) < maxLenght; i++);
return new String(old, offset, i - offset);
}