1 // Copyright 2009, 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 #define charntorune(pv, str, len) __go_get_rune(str, len, pv)
14 const String runtime_emptystring;
17 runtime_findnull(const byte *s)
21 return __builtin_strlen((const char*) s);
25 runtime_findnullw(const uint16 *s)
31 for(l=0; s[l]!=0; l++)
37 gostringsize(intgo l, byte** pmem)
44 return runtime_emptystring;
46 mem = runtime_mallocgc(l, 0, FlagNoScan|FlagNoZero);
54 runtime_gostring(const byte *str)
60 l = runtime_findnull(str);
61 s = gostringsize(l, &mem);
62 runtime_memmove(mem, str, l);
67 runtime_gostringnocopy(const byte *str)
72 s.len = runtime_findnull(str);
76 func cstringToGo(str *byte) (s String) {
77 s = runtime_gostringnocopy(str);
85 func stringiter(s String, k int) (retk int) {
89 // retk=0 is end of iteration
101 retk = k + charntorune(&l, s.str+k, s.len-k);
106 func stringiter2(s String, k int) (retk int, retv int32) {
108 // retk=0 is end of iteration
115 if(retv < Runeself) {
121 retk = k + charntorune(&retv, s.str+k, s.len-k);