"func runtime.catstring (? string, ? string) (? string)\n"
"func runtime.cmpstring (? string, ? string) (? int)\n"
"func runtime.slicestring (? string, ? int, ? int) (? string)\n"
+ "func runtime.slicestring1 (? string, ? int) (? string)\n"
"func runtime.indexstring (? string, ? int) (? uint8)\n"
"func runtime.intstring (? int64) (? string)\n"
"func runtime.slicebytetostring (? []uint8) (? string)\n"
void
convlit(Node **np, Type *t)
{
- return convlit1(np, t, 0);
+ convlit1(np, t, 0);
}
/*
func catstring(string, string) string
func cmpstring(string, string) int
func slicestring(string, int, int) string
+func slicestring1(string, int) string
func indexstring(string, int) byte
func intstring(int64) string
func slicebytetostring([]byte) string
case OSLICESTR:
// sys_slicestring(s, lb, hb)
- n = mkcall("slicestring", n->type, init,
- conv(n->left, types[TSTRING]),
- conv(n->right->left, types[TINT]),
- conv(n->right->right, types[TINT]));
+ if(n->right->right) {
+ n = mkcall("slicestring", n->type, init,
+ conv(n->left, types[TSTRING]),
+ conv(n->right->left, types[TINT]),
+ conv(n->right->right, types[TINT]));
+ } else {
+ n = mkcall("slicestring1", n->type, init,
+ conv(n->left, types[TSTRING]),
+ conv(n->right->left, types[TINT]));
+ }
goto ret;
case OINDEXSTR:
// mcpy(so.str, si.str+lindex, l);
}
+func slicestring1(si String, lindex int32) (so String) {
+ int32 l;
+
+ if(lindex < 0 || lindex > si.len) {
+ runtime·printpc(&si);
+ prints(" ");
+ prbounds("slice", lindex, si.len, si.len);
+ }
+
+ l = si.len-lindex;
+ so.str = si.str + lindex;
+ so.len = l;
+
+// alternate to create a new string
+// so = gostringsize(l);
+// mcpy(so.str, si.str+lindex, l);
+}
+
func indexstring(s String, i int32) (b byte) {
if(i < 0 || i >= s.len) {
runtime·printpc(&s);
}
/* slice strings */
- print(c[0:3], c[3:6]);
+ print(c[0:3], c[3:]);
print("\n");