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 gostringsize(intgo l, byte** pmem)
32 return runtime_emptystring;
34 // leave room for NUL for C runtime (e.g., callers of getenv)
35 mem = runtime_mallocgc(l+1, FlagNoPointers, 1, 0);
44 runtime_gostring(const byte *str)
50 l = runtime_findnull(str);
51 s = gostringsize(l, &mem);
52 runtime_memmove(mem, str, l);
57 runtime_gostringnocopy(const byte *str)
62 s.len = runtime_findnull(str);
71 func stringiter(s String, k int) (retk int) {
75 // retk=0 is end of iteration
87 retk = k + charntorune(&l, s.str+k, s.len-k);
92 func stringiter2(s String, k int) (retk int, retv int32) {
94 // retk=0 is end of iteration
101 if(retv < Runeself) {
107 retk = k + charntorune(&retv, s.str+k, s.len-k);