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.
11 #define charntorune(pv, str, len) __go_get_rune(str, len, pv)
13 const String runtime_emptystring;
16 runtime_findnull(const byte *s)
20 return __builtin_strlen((const char*) s);
24 runtime_findnullw(const uint16 *s)
30 for(l=0; s[l]!=0; l++)
36 gostringsize(intgo l, byte** pmem)
43 return runtime_emptystring;
45 mem = runtime_mallocgc(l, 0, FlagNoScan|FlagNoZero);
53 runtime_gostring(const byte *str)
59 l = runtime_findnull(str);
60 s = gostringsize(l, &mem);
61 runtime_memmove(mem, str, l);
66 runtime_gostringnocopy(const byte *str)
71 s.len = runtime_findnull(str);
75 func cstringToGo(str *byte) (s String) {
76 s = runtime_gostringnocopy(str);
84 func stringiter(s String, k int) (retk int) {
88 // retk=0 is end of iteration
100 retk = k + charntorune(&l, s.str+k, s.len-k);
105 func stringiter2(s String, k int) (retk int, retv int32) {
107 // retk=0 is end of iteration
114 if(retv < Runeself) {
120 retk = k + charntorune(&retv, s.str+k, s.len-k);