aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-int-array-to-string.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-11-01 03:02:13 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-11-01 03:02:13 +0000
commit776f27a67f26c795ba8c27a4e69525382b9379c3 (patch)
tree0285cca6b375a23d93c20efec03cb9adec30f0e0 /libgo/runtime/go-int-array-to-string.c
parent79e0221796bf5897204e8077afc20e34f88dab3b (diff)
downloadgcc-776f27a67f26c795ba8c27a4e69525382b9379c3.zip
gcc-776f27a67f26c795ba8c27a4e69525382b9379c3.tar.gz
gcc-776f27a67f26c795ba8c27a4e69525382b9379c3.tar.bz2
compiler, runtime: More steps toward separating int and intgo.
From-SVN: r193059
Diffstat (limited to 'libgo/runtime/go-int-array-to-string.c')
-rw-r--r--libgo/runtime/go-int-array-to-string.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/libgo/runtime/go-int-array-to-string.c b/libgo/runtime/go-int-array-to-string.c
index 1a37879..6cae2fd 100644
--- a/libgo/runtime/go-int-array-to-string.c
+++ b/libgo/runtime/go-int-array-to-string.c
@@ -5,31 +5,30 @@
license that can be found in the LICENSE file. */
#include "go-assert.h"
-#include "go-string.h"
#include "runtime.h"
#include "arch.h"
#include "malloc.h"
-struct __go_string
-__go_int_array_to_string (const void* p, int len)
+String
+__go_int_array_to_string (const void* p, intgo len)
{
- const int *ints;
- int slen;
- int i;
+ const int32 *ints;
+ intgo slen;
+ intgo i;
unsigned char *retdata;
- struct __go_string ret;
+ String ret;
unsigned char *s;
- ints = (const int *) p;
+ ints = (const int32 *) p;
slen = 0;
for (i = 0; i < len; ++i)
{
- int v;
+ int32 v;
v = ints[i];
- if (v > 0x10ffff)
+ if (v < 0 || v > 0x10ffff)
v = 0xfffd;
if (v <= 0x7f)
@@ -42,20 +41,20 @@ __go_int_array_to_string (const void* p, int len)
slen += 4;
}
- retdata = runtime_mallocgc (slen, FlagNoPointers, 1, 0);
- ret.__data = retdata;
- ret.__length = slen;
+ retdata = runtime_mallocgc ((uintptr) slen, FlagNoPointers, 1, 0);
+ ret.str = retdata;
+ ret.len = slen;
s = retdata;
for (i = 0; i < len; ++i)
{
- int v;
+ int32 v;
v = ints[i];
/* If V is out of range for UTF-8, substitute the replacement
character. */
- if (v > 0x10ffff)
+ if (v < 0 || v > 0x10ffff)
v = 0xfffd;
if (v <= 0x7f)