Exemplo n.º 1
0
void
runtime·stringtoslicerune(String s, Slice b)
{
#line 296 "/home/pi/go_build/go/src/pkg/runtime/string.goc"

	intgo n;
	int32 dum, *r;
	uint8 *p, *ep;

	// two passes.
	// unlike slicerunetostring, no race because strings are immutable.
	p = s.str;
	ep = s.str+s.len;
	n = 0;
	while(p < ep) {
		p += runtime·charntorune(&dum, p, ep-p);
		n++;
	}

	b.array = runtime·mallocgc(n*sizeof(r[0]), 0, FlagNoScan|FlagNoZero);
	b.len = n;
	b.cap = n;
	p = s.str;
	r = (int32*)b.array;
	while(p < ep)
		p += runtime·charntorune(r++, p, ep-p);
	FLUSH(&b);
}
Exemplo n.º 2
0
void
runtime·stringtoslicerune(String s, Slice b)
{
#line 3622 "C:\Go\src\pkg\runtime\string.goc"

	int32 n;
	int32 dum, *r;
	uint8 *p, *ep;

	// two passes.
	// unlike slicerunetostring, no race because strings are immutable.
	p = s.str;
	ep = s.str+s.len;
	n = 0;
	while(p < ep) {
		p += runtime·charntorune(&dum, p, ep-p);
		n++;
	}

	b.array = runtime·mallocgc(n*sizeof(r[0]), FlagNoPointers, 1, 0);
	b.len = n;
	b.cap = n;
	p = s.str;
	r = (int32*)b.array;
	while(p < ep)
		p += runtime·charntorune(r++, p, ep-p);
	FLUSH(&b);
}
Exemplo n.º 3
0
void
runtime·stringiter2(String s, intgo k, intgo retk, int32 retv)
{
	retk = 0;
	FLUSH(&retk);
	retv = 0;
	FLUSH(&retv);
#line 393 "/home/14/ren/source/golang/go/src/pkg/runtime/string.goc"

	if(k >= s.len) {
		// retk=0 is end of iteration
		retk = 0;
		retv = 0;
		goto out;
	}

	retv = s.str[k];
	if(retv < Runeself) {
		retk = k+1;
		goto out;
	}

	// multi-char rune
	retk = k + runtime·charntorune(&retv, s.str+k, s.len-k);

out:
	FLUSH(&retk);
	FLUSH(&retv);
}
Exemplo n.º 4
0
void
runtime·stringiter2(String s, int32 k, int32 retk, int32 retv)
{
#line 3672 "C:\Go\src\pkg\runtime\string.goc"

	if(k >= s.len) {
		// retk=0 is end of iteration
		retk = 0;
		retv = 0;
		goto out;
	}

	retv = s.str[k];
	if(retv < Runeself) {
		retk = k+1;
		goto out;
	}

	// multi-char rune
	retk = k + runtime·charntorune(&retv, s.str+k, s.len-k);

out:
	FLUSH(&retk);
	FLUSH(&retv);
}
Exemplo n.º 5
0
void
runtime·stringiter(String s, int32 k, int32 retk)
{
#line 3651 "C:\Go\src\pkg\runtime\string.goc"

	int32 l;

	if(k >= s.len) {
		// retk=0 is end of iteration
		retk = 0;
		goto out;
	}

	l = s.str[k];
	if(l < Runeself) {
		retk = k+1;
		goto out;
	}

	// multi-char rune
	retk = k + runtime·charntorune(&l, s.str+k, s.len-k);

out:
	FLUSH(&retk);
}
Exemplo n.º 6
0
void
runtime·stringiter(String s, intgo k, intgo retk)
{
#line 325 "/home/pi/go_build/go/src/pkg/runtime/string.goc"

	int32 l;

	if(k >= s.len) {
		// retk=0 is end of iteration
		retk = 0;
		goto out;
	}

	l = s.str[k];
	if(l < Runeself) {
		retk = k+1;
		goto out;
	}

	// multi-char rune
	retk = k + runtime·charntorune(&l, s.str+k, s.len-k);

out:
	FLUSH(&retk);
}
Exemplo n.º 7
0
int
fullrune(const char *s, size_t len)
{
	Rune r;

	return charntorune(&r, s, len) > 0;
}
Exemplo n.º 8
0
size_t
utfnlen(const char *s, size_t len)
{
	const char *p = s;
	size_t i;
	Rune r;
	int n;

	for(i = 0; (n = charntorune(&r, p, len-(p-s))) && r != '\0'; i++)
		p += n;
	return i;
}
Exemplo n.º 9
0
void
runtime·stringtoslicerune(String s, Slice b)
{
	b.array = 0;
	b.len = 0;
	b.cap = 0;
	FLUSH(&b);
#line 337 "/home/14/ren/source/golang/go/src/pkg/runtime/string.goc"

	intgo n;
	int32 dum, *r;
	uint8 *p, *ep;
	uintptr mem;

	// two passes.
	// unlike slicerunetostring, no race because strings are immutable.
	p = s.str;
	ep = s.str+s.len;
	n = 0;
	while(p < ep) {
		p += runtime·charntorune(&dum, p, ep-p);
		n++;
	}

	if(n > MaxMem/sizeof(r[0]))
		runtime·throw("out of memory");
	mem = runtime·roundupsize(n*sizeof(r[0]));
	b.array = runtime·mallocgc(mem, 0, FlagNoScan|FlagNoZero);
	b.len = n;
	b.cap = mem/sizeof(r[0]);
	p = s.str;
	r = (int32*)b.array;
	while(p < ep)
		p += runtime·charntorune(r++, p, ep-p);
	if(b.cap > b.len)
		runtime·memclr(b.array+b.len*sizeof(r[0]), (b.cap-b.len)*sizeof(r[0]));
	FLUSH(&b);
}
Exemplo n.º 10
0
char *
utfecpy(char *to, char *end, const char *from)
{
	Rune r = Runeerror;
	size_t i, n;

	/* seek through to find final full rune */
	for(i = 0; r != '\0' && (n = charntorune(&r, &from[i], end - &to[i])); i += n)
		;
	memcpy(to, from, i); /* copy over bytes up to this rune */

	if(i > 0 && r != '\0')
		to[i] = '\0'; /* terminate if unterminated */
	return &to[i];
}
Exemplo n.º 11
0
int SpanInterchangeValid(const char* begin, int byte_length) {
  char32 rune;
  const char* p = begin;
  const char* end = begin + byte_length;
  while (p < end) {
    int bytes_consumed = charntorune(&rune, p, end - p);
    // We want to accept Runeerror == U+FFFD as a valid char, but it is used
    // by chartorune to indicate error. Luckily, the real codepoint is size 3
    // while errors return bytes_consumed == 1.
    if ((rune == Runeerror && bytes_consumed == 1) ||
        !IsInterchangeValidCodepoint(rune)) {
      break;  // Found
    }
    p += bytes_consumed;
  }
  return p - begin;
}
Exemplo n.º 12
0
int
chartorune(Rune *p, const char *s)
{
	return charntorune(p, s, UTFmax);
}