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 gostringsize(intgo l, byte** pmem)
31 return runtime_emptystring;
33 // leave room for NUL for C runtime (e.g., callers of getenv)
34 mem = runtime_mallocgc(l+1, FlagNoPointers, 1, 0);
43 runtime_gostring(const byte *str)
49 l = runtime_findnull(str);
50 s = gostringsize(l, &mem);
51 runtime_memmove(mem, str, l);
56 runtime_gostringnocopy(const byte *str)
61 s.len = runtime_findnull(str);
70 func stringiter(s String, k int) (retk int) {
74 // retk=0 is end of iteration
86 retk = k + charntorune(&l, s.str+k, s.len-k);
91 func stringiter2(s String, k int) (retk int, retv int32) {
93 // retk=0 is end of iteration
100 if(retv < Runeself) {
106 retk = k + charntorune(&retv, s.str+k, s.len-k);