OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package runtime | 5 package runtime |
6 #include "runtime.h" | 6 #include "runtime.h" |
7 #include "malloc.h" | 7 #include "malloc.h" |
8 | 8 |
9 String runtime·emptystring; | 9 String runtime·emptystring; |
10 | 10 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 c2 = s2[i]; | 186 c2 = s2[i]; |
187 if(c1 < c2) | 187 if(c1 < c2) |
188 return -1; | 188 return -1; |
189 if(c1 > c2) | 189 if(c1 > c2) |
190 return +1; | 190 return +1; |
191 if(c1 == 0) | 191 if(c1 == 0) |
192 return 0; | 192 return 0; |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
| 196 byte* |
| 197 runtime·strstr(byte *s1, byte *s2) |
| 198 { |
| 199 byte *sp1, *sp2; |
| 200 |
| 201 if(*s2 == 0) |
| 202 return s1; |
| 203 for(; *s1; s1++) { |
| 204 if(*s1 != *s2) |
| 205 continue; |
| 206 sp1 = s1; |
| 207 sp2 = s2; |
| 208 for(;;) { |
| 209 if(*sp2 == 0) |
| 210 return s1; |
| 211 if(*sp1++ != *sp2++) |
| 212 break; |
| 213 } |
| 214 } |
| 215 return nil; |
| 216 } |
| 217 |
196 func slicestring(si String, lindex int32, hindex int32) (so String) { | 218 func slicestring(si String, lindex int32, hindex int32) (so String) { |
197 int32 l; | 219 int32 l; |
198 | 220 |
199 if(lindex < 0 || lindex > si.len || | 221 if(lindex < 0 || lindex > si.len || |
200 hindex < lindex || hindex > si.len) { | 222 hindex < lindex || hindex > si.len) { |
201 runtime·panicslice(); | 223 runtime·panicslice(); |
202 } | 224 } |
203 | 225 |
204 l = hindex-lindex; | 226 l = hindex-lindex; |
205 so.str = si.str + lindex; | 227 so.str = si.str + lindex; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if(retv < Runeself) { | 341 if(retv < Runeself) { |
320 retk = k+1; | 342 retk = k+1; |
321 goto out; | 343 goto out; |
322 } | 344 } |
323 | 345 |
324 // multi-char rune | 346 // multi-char rune |
325 retk = k + runtime·charntorune(&retv, s.str+k, s.len-k); | 347 retk = k + runtime·charntorune(&retv, s.str+k, s.len-k); |
326 | 348 |
327 out: | 349 out: |
328 } | 350 } |
OLD | NEW |