Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r45570:9c3e9ffb771c
Date: 2011-07-13 20:18 +0000
http://bitbucket.org/pypy/pypy/changeset/9c3e9ffb771c/
Log: Fix the string startswith and endswith stuff for the JVM and CLR.
diff --git a/pypy/translator/cli/src/pypylib.cs
b/pypy/translator/cli/src/pypylib.cs
--- a/pypy/translator/cli/src/pypylib.cs
+++ b/pypy/translator/cli/src/pypylib.cs
@@ -615,10 +615,28 @@
return s1.StartsWith(s2);
}
+ public static bool ll_startswith_char(string s, char c)
+ {
+ if (s.Length == 0)
+ {
+ return false;
+ }
+ return s[0] == c;
+ }
+
public static bool ll_endswith(string s1, string s2)
{
return s1.EndsWith(s2);
}
+
+ public static bool ll_endswith_char(string s, char c)
+ {
+ if (s.Length == 0)
+ {
+ return false;
+ }
+ return s[s.Length - 1] == c;
+ }
public static int ll_find(string s1, string s2, int start, int stop)
{
diff --git a/pypy/translator/jvm/src/pypy/PyPy.java
b/pypy/translator/jvm/src/pypy/PyPy.java
--- a/pypy/translator/jvm/src/pypy/PyPy.java
+++ b/pypy/translator/jvm/src/pypy/PyPy.java
@@ -791,6 +791,20 @@
return str.substring(start,start+cnt);
}
+ public static boolean ll_startswith_char(String str, char c) {
+ if (str.length() == 0) {
+ return false;
+ }
+ return str.charAt(0) == c;
+ }
+
+ public static boolean ll_endswith_char(String str, char c) {
+ if (str.length() == 0) {
+ return false;
+ }
+ return str.charAt(str.length() - 1) == c;
+ }
+
// ----------------------------------------------------------------------
// StringBuffer
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit