[ARM] Fix typo in comment in arm_expand_prologue
[official-gcc.git] / libgo / runtime / go-strslice.c
blob0e897812be624f656a91c37f43d2fc970f595f37
1 /* go-strslice.c -- the go string slice function.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 #include "runtime.h"
9 String
10 __go_string_slice (String s, intgo start, intgo end)
12 intgo len;
13 String ret;
15 len = s.len;
16 if (end == -1)
17 end = len;
18 if (start > len || end < start || end > len)
19 runtime_panicstring ("string index out of bounds");
20 ret.len = end - start;
21 // If the length of the new string is zero, don't adjust the str
22 // field. This ensures that we don't create a pointer to the next
23 // memory block, and thus keep it live unnecessarily.
24 if (ret.len > 0)
25 ret.str = s.str + start;
26 return ret;