OSDN Git Service

mn10300: Add attribute enabled.
[pf3gnuchains/gcc-fork.git] / libgo / runtime / string.goc
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.
4
5 package runtime
6 #include "runtime.h"
7 #define charntorune(pv, str, len) __go_get_rune(str, len, pv)
8
9 enum
10 {
11         Runeself        = 0x80,
12 };
13
14 func stringiter(s String, k int32) (retk int32) {
15         int32 l, n;
16
17         if(k >= s.__length) {
18                 // retk=0 is end of iteration
19                 retk = 0;
20                 goto out;
21         }
22
23         l = s.__data[k];
24         if(l < Runeself) {
25                 retk = k+1;
26                 goto out;
27         }
28
29         // multi-char rune
30         n = charntorune(&l, s.__data+k, s.__length-k);
31         retk = k + (n ? n : 1);
32
33 out:
34 }
35
36 func stringiter2(s String, k int32) (retk int32, retv int32) {
37         int32 n;
38
39         if(k >= s.__length) {
40                 // retk=0 is end of iteration
41                 retk = 0;
42                 retv = 0;
43                 goto out;
44         }
45
46         retv = s.__data[k];
47         if(retv < Runeself) {
48                 retk = k+1;
49                 goto out;
50         }
51
52         // multi-char rune
53         n = charntorune(&retv, s.__data+k, s.__length-k);
54         retk = k + (n ? n : 1);
55
56 out:
57 }