← all packages

utf8

native: 162 functions analysed · 138 typed · 2 untypeable · 9 timed out · 7 entry points (4 typed) · R: 32 definitions, 16 typed strict, 22 gradual, prelude debt 8 · fuzzing: 18 definitions, 0 unsound, 9 accept calls outside their domain · tyr dc7f1a7 · Rsem 7bcb45f · NativeSem 770a1eb · rstt 2b2696f unpinned

Native functions

C functions reachable from an entry point
162 / 162 (100.0%)
typed
138 / 162 (85.2%)
13 more bound at their declared C signature after inference failed.

Native → R

entry points
7 / 7 (100.0%)
defined in src/
7 / 7 (100.0%)
typed
4 / 7 (57.1%)
bound in R
4 / 7 (57.1%)

R definitions

named top-level definitions
32 / 32 (100.0%)
not blocked by an unbound native symbol
32 / 32 (100.0%)
typed, gradual
22 / 32 (68.8%)
typed, strict
16 / 32 (50.0%)
8 of the strict failures are a name missing from the prelude.
side
mode
195 / 195

Native functions 162

append_location typed

[c_null, c_int_na] -> ()
timing: 0.031 s
source
void append_location(struct utf8lite_message *msg, size_t offset)
{
	utf8lite_message_append(msg, " at position %"PRIu64,
				(uint64_t)(offset + 1));
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textassign.c:192

ascii_width typed

([c(127), c_int_na] -> c(-1) | c(6))&([c_int_na \ c(127), c_int_na] -> c_true | c(-1) | c(6))
timing: 0.077 s
source
int ascii_width(int32_t ch, int flags)
{
	// handle control characters
	if (ch <= 0x1F || ch == 0x7F) {
		if (!(flags & UTF8LITE_ESCAPE_CONTROL)) {
			return -1;
		}

		switch (ch) {
		case '\a':
		case '\v':
			// \u0007, \u000b (JSON) : \a, \b (C)
			return (flags & UTF8LITE_ENCODE_JSON) ? 6 : 2;
		case '\b':
		case '\f':
		case '\n':
		case '\r':
		case '\t':
			return 2;
		default:
			return 6; // \uXXXX
		}
	}

	// handle printable characters
	switch (ch) {
	case '\"':
		return (flags & UTF8LITE_ESCAPE_DQUOTE) ? 2 : 1;
	case '\'':
		return (flags & UTF8LITE_ESCAPE_SQUOTE) ? 2 : 1;
	case '\\':
		if (flags & (UTF8LITE_ESCAPE_CONTROL
				| UTF8LITE_ESCAPE_DQUOTE
				| UTF8LITE_ESCAPE_SQUOTE
				| UTF8LITE_ESCAPE_EXTENDED
				| UTF8LITE_ESCAPE_UTF8)) {
			return 2;
		} else {
			return 1;
		}
	default:
		return 1;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graph.c:98

assign_esc_unsafe typed

([*struct utf8lite_text, c_null, c_int_na] -> ())&([c_null, c_null, c_int_na] -> empty)
timing: 8.66 s
source
void assign_esc_unsafe(struct utf8lite_text *text, const uint8_t *ptr,
		       size_t size)
{
	const uint8_t *end = ptr + size;
	size_t attr = 0;
	int32_t code;
	uint_fast8_t ch;

	text->ptr = (uint8_t *)ptr;

	while (ptr != end) {
		ch = *ptr++;
		if (ch == '\\') {
			attr |= UTF8LITE_TEXT_ESC_BIT;
			ch = *ptr++;

			switch (ch) {
			case 'u':
				utf8lite_decode_uescape(&ptr, &code);
				break;
			default:
				break;
			}
		} else if (ch & 0x80) {
			ptr += UTF8LITE_UTF8_TAIL_LEN(ch);
		}
	}

	attr |= size;
	text->attr = attr;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textassign.c:159

assign_raw_unsafe typed

([*struct utf8lite_text, *c_int_na, c_int_na] -> ())&([c_null, *c_int_na, c_int_na] -> empty)
timing: 8.44 s
source
void assign_raw_unsafe(struct utf8lite_text *text, const uint8_t *ptr,
		       size_t size)
{
	const uint8_t *end = ptr + size;
	uint_fast8_t ch;

	text->ptr = (uint8_t *)ptr;

	while (ptr != end) {
		ch = *ptr++;
		if (ch & 0x80) {
			ptr += UTF8LITE_UTF8_TAIL_LEN(ch);
		}
	}

	text->attr = size;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textassign.c:139

at_escape typed

[*c_int_na, *c_int_na] -> c_int
timing: 0.259 s
source
static int at_escape(const uint8_t *begin, const uint8_t *ptr)
{
	int at = 0;
	uint_fast8_t prev;

	while (begin < ptr) {
		prev = *(--ptr);

		if (prev != '\\') {
			goto out;
		}

		at = !at;
	}

out:
	return at;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:157

byte_width typed

[c_int_na \ c(..127), c_int_na] -> c(-1) | c(4)
timing: 0.046 s
source
int byte_width(uint8_t byte, int flags)
{
	if (byte < 0x80) {
		switch (byte) {
		case '\a':
		case '\b':
		case '\f':
		case '\n':
		case '\r':
		case '\t':
		case '\v':
			return (flags & UTF8LITE_ESCAPE_CONTROL) ? 2 : -1;
		case '\\':
			return (flags & (UTF8LITE_ESCAPE_CONTROL
						| UTF8LITE_ESCAPE_DQUOTE)
					? 2 : 1);
		case '"':
			return (flags & UTF8LITE_ESCAPE_DQUOTE) ? 2 : 1;
		default:
			if (isprint((int)byte)) {
				return 1;
			}
			break;
		}
	}

	// \xXX non-ASCII or non-printable byte
	return (flags & UTF8LITE_ESCAPE_CONTROL) ? 4 : -1;
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:331

bytes_init typed

([*struct rutf8_bytes, p(CHR)] -> ())&([c_null, p(CHR)] -> empty)
timing: 0.363 s
source
void bytes_init(struct rutf8_bytes *bytes, SEXP charsxp)
{
	assert(charsxp != NA_STRING);
	bytes->ptr = (const uint8_t *)CHAR(charsxp);
	bytes->size = (size_t)XLENGTH(charsxp);
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:37

casefold typed

[*struct utf8lite_text] -> *struct utf8lite_text
timing: 0.006 s
source
static void casefold(int type, int32_t code, int32_t **bufp)
{
	const int32_t block_size = CASEFOLD_BLOCK_SIZE;
	unsigned i = casefold_stage1[code / block_size];
	struct casefold c = casefold_stage2[i][code % block_size];
	unsigned length = c.length;
	const int32_t *src;
	int32_t *dst;

	if (length == 0) {
		dst = *bufp;
		*dst++ = code;
		*bufp = dst;
	} else if (length == 1) {
		utf8lite_map(type, (int32_t)c.data, bufp);
	} else {
		src = &casefold_mapping[c.data];
		while (length-- > 0) {
			utf8lite_map(type, *src, bufp);
			src++;
		}
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:89

charsxp_width typed

[p(CHR), c_int_na] -> c_int_na
timing: 0.040 s
source
static int charsxp_width(SEXP sx, int flags)
{
	struct rutf8_string text;
	int quotes = (flags & UTF8LITE_ESCAPE_DQUOTE) ? 2 : 0;
	rutf8_string_init(&text, sx);
	return rutf8_string_width(&text, flags) + quotes;
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:86

charwidth typed

[c_int] -> c_int_na
timing: 0.021 s
source
static int charwidth(int32_t code)
{
	const int32_t block_size = 128;
	uint8_t i = charwidth_stage1[code / block_size];
	return charwidth_stage2[i][code % block_size];
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/private/charwidth.h:3221

CHECK_ERROR typed any: arg 1

tuple1 -> any
timing: 0.003 s
(definition not located in src/)

CHECK_ERROR_FORMAT_SEP typed

any --> any
timing: 0.000 s
(definition not located in src/)

CHECK_INTERRUPT typed

[c_int_na] -> ()
timing: 0.266 s
(definition not located in src/)

code_cmp typed

[c_ptr, c_ptr] -> c(-1..1)
timing: 0.019 s
source
static int code_cmp(const void *x1, const void *x2)
{
	int32_t y1 = *(const int32_t *)x1;
	int32_t y2 = *(const int32_t *)x2;

	if (y1 < y2) {
		return -1;
	} else if (y1 > y2) {
		return +1;
	} else {
		return 0;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:238

combiner_find typed

([c_int_na, c_false, c_int_na] -> c(-1))&([c_int_na, c_true, c_int_na] -> c(-1..0))
timing: 0.207 s
source
static int combiner_find(int offset, int length, int32_t code)
{
	const int32_t *base = composition_combiner + offset;
	const int32_t *ptr;

	// handle empty and singleton case
	if (length == 0) {
		return -1;
	} else if (length == 1) {
		return (*base == code) ? 0 : -1;
	}

	// handle general case
	ptr = bsearch(&code, base, (size_t)length, sizeof(*base), code_cmp);

	if (ptr == NULL) {
		return -1;
	} else {
		return (int)(ptr - base);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:253

combining_class typed

[c_int] -> c_int_na
timing: 0.019 s
source
static uint8_t combining_class(int32_t code)
{
	const int32_t block_size = 128;
	uint8_t i = combining_class_stage1[code / block_size];
	return combining_class_stage2[i][code % block_size];
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/private/combining.h:1564

context_destroy typed

([c_null] -> empty)&([(*(~(c_string | struct context)) | c_string) \ c_null] | [*struct context \ c_null] -> ())
timing: 0.203 s
source
static void context_destroy(void *obj)
{
	struct context *ctx = obj;

	if (ctx->has_map) {
		utf8lite_textmap_destroy(&ctx->map);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_normalize.c:59

encoding_name typed

([c_int_na] -> c("latin1"))&([~c_int_na] -> c("unknown"))
timing: 0.031 s
source
static const char *encoding_name(cetype_t ce)
{
	switch (ce) {
	case CE_LATIN1:
		return "latin1";
	case CE_UTF8:
		return "UTF-8";
	case CE_SYMBOL:
		return "symbol";
	case CE_BYTES:
		return "bytes";
	case CE_ANY:
	case CE_NATIVE:
	default:
		return "unknown";
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/as_utf8.c:27

flags_get typed

([*struct flags, c(2)] | [*struct flags, c(3)] | [*struct flags, c_false] | [*struct flags, c_true] -> c_int_na)&([c_null, c(2)] | [c_null, c(3)] | [c_null, c_false] | [c_null, c_true] -> empty)
timing: 0.325 s
source
static int flags_get(const struct flags *f, enum cell_type t)
{
	switch (t) {
	case CELL_ENTRY:
		return f->entry;
	case CELL_NA:
		return f->na;
	case CELL_NAME:
		return f->name;
	case CELL_ROWNAME:
		return f->rowname;
	default:
		return -1;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:51

follows_extended_pictographic typed

([c_null] -> empty)&([*struct utf8lite_text_iter] \ [c_null] -> c_int_na)
timing: 0.046 s
source
static int follows_extended_pictographic(const struct utf8lite_text_iter *prev)
{
	struct utf8lite_text_iter it = *prev;
	int prop;

	while (utf8lite_text_iter_retreat(&it)) {
		prop = graph_break(it.current);
		switch (prop) {
		case GRAPH_BREAK_EXTENDED_PICTOGRAPHIC:
			return 1;
		case GRAPH_BREAK_EXTEND:
			break;
		default:
			return 0;
		}
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:263

graph_break typed

[c_int] -> c_int_na
timing: 0.019 s
source
static int graph_break(int32_t code)
{
	const int32_t block_size = 128;
	uint8_t i = graph_break_stage1[code / block_size];
	return graph_break_stage2[i][code % block_size];
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/private/graphbreak.h:2231

hangul_compose_lv typed

([c_int, c_int] -> c_int)&([c_int_na, c_int_na] -> c_int_na)
timing: 0.169 s
source
static int32_t hangul_compose_lv(int32_t lpart, int32_t vpart)
{
	int32_t lindex = lpart - HANGUL_LBASE;
	int32_t vindex = vpart - HANGUL_VBASE;
	int32_t lvindex = lindex * HANGUL_NCOUNT + vindex * HANGUL_TCOUNT;
	int32_t s = HANGUL_SBASE + lvindex;
	return s;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:71

hangul_compose_lvt typed

([c_int, c_int] -> c_int)&([c_int_na, c_int_na] -> c_int_na)
timing: 0.045 s
source
static int32_t hangul_compose_lvt(int32_t lvpart, int32_t tpart)
{
	int32_t tindex = tpart - HANGUL_TBASE;
	int32_t s = lvpart + tindex;
	return s;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:81

hangul_decompose typed

([c_int, *(*c_int_na \ c_null)] -> ())&([c_int, *c_null] | [c_int_na, c_null] -> empty)
timing: 0.613 s
source
static void hangul_decompose(int32_t code, int32_t **bufp)
{
	int32_t *dst = *bufp;
	int32_t sindex = code - HANGUL_SBASE;
	int32_t lindex = sindex / HANGUL_NCOUNT;
	int32_t vindex = (sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT;
	int32_t tindex = sindex % HANGUL_TCOUNT;
	int32_t lpart = HANGUL_LBASE + lindex;
	int32_t vpart = HANGUL_VBASE + vindex;
	int32_t tpart = HANGUL_TBASE + tindex;

	*dst++ = lpart;
	*dst++ = vpart;
	if (tindex > 0) {
		*dst++ = tpart;
	}

	*bufp = dst;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:36

has_combiner typed

[c_int_na, c_int_na, c_bool, c_int_na, *c_int_na] -> c_bool
timing: 0.763 s
source
static int has_combiner(int32_t left, int offset, int length, int32_t code,
		        int32_t *primaryptr)
{
	int i;

	if (offset < COMPOSITION_HANGUL_LPART) {
		i = combiner_find(offset, length, code);
		if (i >= 0) {
			*primaryptr = composition_primary[offset + i];
			return 1;
		}
	} else if (offset == COMPOSITION_HANGUL_LPART) {
		if (is_hangul_vpart(code)) {
			*primaryptr = hangul_compose_lv(left, code);
			return 1;
		}
	} else if (offset == COMPOSITION_HANGUL_LVPART) {
		if (is_hangul_tpart(code)) {
			*primaryptr = hangul_compose_lvt(left, code);
			return 1;
		}
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:276

has_compose typed

[c_int, *c_int_na, *c_int_na] -> c_bool
timing: 0.059 s
source
static int has_compose(int32_t code, int *offsetptr, int *lengthptr)
{
	const int32_t block_size = COMPOSITION_BLOCK_SIZE;
	unsigned i = composition_stage1[code / block_size];
	struct composition c = composition_stage2[i][code % block_size];
	int offset = (int)c.offset;
	int length = (int)c.length;

	*offsetptr = offset;
	*lengthptr = length;

	return (length > 0 ? 1 : 0);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:223

has_prev typed

() -> c_int_na
timing: 0.006 s
source
static int has_prev()
{
	struct utf8lite_text_iter it = text_iter;
	return utf8lite_text_iter_retreat(&it);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/tests/check_text.c:353

hextoi typed

[c_int_na] -> any
timing: 0.029 s
(definition not located in src/)

is_hangul_tpart typed

[c_int_na] -> c_bool
timing: 0.023 s
source
static int is_hangul_tpart(int32_t code)
{
	// strict less-than on lower bound
	return (HANGUL_TBASE < code && code < HANGUL_TBASE + HANGUL_TCOUNT);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:64

is_hangul_vpart typed

[c_int_na] -> c_bool
timing: 0.022 s
source
static int is_hangul_vpart(int32_t code)
{
	return (HANGUL_VBASE <= code && code < HANGUL_VBASE + HANGUL_VCOUNT);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:57

iter_retreat_escaped typed empty return

[c_null, *c_int_na] -> empty
timing: 15.16 s
source
void iter_retreat_escaped(struct utf8lite_text_iter *it, const uint8_t *begin)
{
	const uint8_t *ptr = it->ptr;
	int32_t code, unesc, hi;
	int i;

	code = *(--ptr);

	// check for 2-byte escape
	switch (code) {
	case '"':
	case '\\':
	case '/':
		unesc = code;
		break;

	case 'b':
		unesc = '\b';
		break;

	case 'f':
		unesc = '\f';
		break;
	case 'n':
		unesc = '\n';
		break;

	case 'r':
		unesc = '\r';
		break;

	case 't':
		unesc = '\t';
		break;

	default:
		unesc = 0;
		break;
	}

	if (unesc) {
	       if (at_escape(begin, ptr)) {
		       ptr--;
		       code = unesc;
	       }
	       goto out;
	}

	// check for 6-byte escape
	if (isxdigit((int)code)) {
		if (!(begin + 4 < ptr && ptr[-4] == 'u'
				&& at_escape(begin, ptr - 4))) {
			goto out;
		}

		code = 0;
		for (i = 0; i < 4; i++) {
			code = (code << 4) + hextoi(ptr[i - 3]);
		}
		ptr -= 5;

		if (UTF8LITE_IS_UTF16_LOW(code)) {
			hi = 0;
			for (i = 0; i < 4; i++) {
				hi = (hi << 4) + hextoi(ptr[i - 4]);
			}

			code = UTF8LITE_DECODE_UTF16_PAIR(hi, code);
			ptr -= 6;
		}

		goto out;
	}

	// check for ascii
	if (code < 0x80) {
		goto out;
	}

	// if we got here, then code is a continuation byte

	// skip over preceding continuation bytes
	do {
		ptr--;
	} while (*ptr < 0xC0);

	// decode the utf-8 value
	it->ptr = (uint8_t *)ptr;
	utf8lite_decode_utf8(&ptr, &it->current);
	return;

out:
	it->ptr = (uint8_t *)ptr;
	it->current = code;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:177

iter_retreat_raw typed

([*struct utf8lite_text_iter] -> ())&([c_null] -> empty)
timing: 3.46 s
source
void iter_retreat_raw(struct utf8lite_text_iter *it)
{
	const uint8_t *ptr = it->ptr;
	int32_t code;

	code = *(--ptr);

	if (code < 0x80) {
		it->ptr = (uint8_t *)ptr;
		it->current = code;
	} else {
		// skip over continuation bytes
		do {
			ptr--;
		} while (*ptr < 0xC0);

		it->ptr = (uint8_t *)ptr;

		utf8lite_decode_utf8(&ptr, &it->current);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:131

maybe_indent typed

([*struct utf8lite_render] -> c_int_na)&([c_null] -> empty)
timing: 2.27 s
source
static int maybe_indent(struct utf8lite_render *r)
{
	int ntab = r->indent;
	char *end;
	int i;

	if (!r->needs_indent) {
		return 0;
	}

	for (i = 0; i < ntab; i++) {
		utf8lite_render_grow(r, r->tab_length);
		CHECK_ERROR(r);

		end = r->string + r->length;
		memcpy(end, r->tab, r->tab_length + 1); // include '\0'
		r->length += r->tab_length;
	}

	r->needs_indent = 0;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:245

prev typed

() -> c_int_na
timing: 0.007 s
source
const struct utf8lite_text *prev(void)
{
	struct utf8lite_text *graph;
	if (!utf8lite_graphscan_retreat(&scan)) {
		return NULL;
	}
	graph = alloc(sizeof(*graph));
	*graph = scan.current.text;
	return graph;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/tests/check_graphscan.c:57

regional_indicator_odd typed

([c_null] -> empty)&([*struct utf8lite_text_iter] \ [c_null] -> c_int_na)
timing: 0.047 s
source
static int regional_indicator_odd(const struct utf8lite_text_iter *prev)
{
	struct utf8lite_text_iter it = *prev;
	int odd = 1, prop;

	while (utf8lite_text_iter_retreat(&it)) {
		prop = graph_break(it.current);
		if (prop == GRAPH_BREAK_REGIONAL_INDICATOR) {
			odd = odd ? 0 : 1;
		} else {
			return odd;
		}
	}

	return odd;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:245

render_byte typed

[c_null, c_int_na] -> ()
timing: 0.166 s
source
void render_byte(struct utf8lite_render *r, uint8_t byte)
{
	char ch, buf[5];
	int err = 0;

	if (byte <= 0x1f || byte >= 0x7f) {
		if (r->flags & UTF8LITE_ESCAPE_CONTROL) {
			switch (byte) {
			case '\a':
				TRY(utf8lite_render_raw(r, "\\a", 2));
				break;
			case '\b':
				TRY(utf8lite_render_raw(r, "\\b", 2));
				break;
			case '\f':
				TRY(utf8lite_render_raw(r, "\\f", 2));
				break;
			case '\n':
				TRY(utf8lite_render_raw(r, "\\n", 2));
				break;
			case '\r':
				TRY(utf8lite_render_raw(r, "\\r", 2));
				break;
			case '\t':
				TRY(utf8lite_render_raw(r, "\\t", 2));
				break;
			case '\v':
				TRY(utf8lite_render_raw(r, "\\v", 2));
				break;
			default:
				snprintf(buf, sizeof(buf), "\\x%02x", (unsigned)byte);
				TRY(utf8lite_render_raw(r, buf, 4));
				break;
			}
		} else {
			ch = (char)byte;
			TRY(utf8lite_render_raw(r, &ch, 1));
		}
	} else {
		buf[0] = (char)byte;
		buf[1] = '\0';
		TRY(utf8lite_render_string(r, buf));
	}
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:362

render_cell typed empty return

[c_null, *struct style, c(0..3), any_sexp, c_int_na] -> empty
timing: 12.98 s
source
static void render_cell(struct utf8lite_render *r, const struct style *s,
			enum cell_type t, SEXP sx, int width)
{
	struct rutf8_string str;
	const char *sgr;
	int err = 0, w, pad, right, quote, old, nsgr;

	old = r->flags;
	TRY(utf8lite_render_set_flags(r, flags_get(&s->flags, t)));
	quote = r->flags & UTF8LITE_ESCAPE_DQUOTE;
	right = (t == CELL_ROWNAME) ? 0 : s->right;
	sgr = sgr_get(s, t, &nsgr);

	w = charsxp_width(sx, r->flags);
	pad = width - w;

	if (sgr) {
		TRY(utf8lite_render_raw(r, sgr, nsgr));
	}

	if (right) {
		TRY(utf8lite_render_chars(r, ' ', pad));
	}

	if (t == CELL_ENTRY) {
		TRY(utf8lite_render_set_style(r, s->esc_open, s->esc_close));
	}

	rutf8_string_init(&str, sx);
	rutf8_string_render(r, &str, 0, quote, RUTF8_JUSTIFY_NONE);

	if (t == CELL_ENTRY) {
		TRY(utf8lite_render_set_style(r, NULL, NULL));
	}

	if (!right) {
		TRY(utf8lite_render_chars(r, ' ', pad));
	}

	if (sgr) {
		TRY(utf8lite_render_raw(r, RUTF8_STYLE_CLOSE,
					RUTF8_STYLE_CLOSE_SIZE));
	}
	TRY(utf8lite_render_set_flags(r, old));
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:95

render_entry typed empty return

[c_null, *struct style, any_sexp, c_int_na] -> empty
timing: 0.016 s
source
static void render_entry(struct utf8lite_render *r, const struct style *s,
			 SEXP sx, int width)
{
	render_cell(r, s, CELL_ENTRY, sx, width);
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:144

render_na typed empty return

[c_null, *struct style, any_sexp, c_int_na] -> empty
timing: 0.016 s
source
static void render_na(struct utf8lite_render *r, const struct style *s,
		      SEXP sx, int width)
{
	render_cell(r, s, CELL_NA, sx, width);
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:151

render_name typed empty return

[c_null, *struct style, any_sexp, c_int_na] -> empty
timing: 0.015 s
source
static void render_name(struct utf8lite_render *r, const struct style *s,
			SEXP sx, int width)
{
	render_cell(r, s, CELL_NAME, sx, width);
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:158

render_rowname typed empty return

[c_null, *struct style, any_sexp, c_int_na] -> empty
timing: 0.016 s
source
static void render_rowname(struct utf8lite_render *r, const struct style *s,
			   SEXP sx, int width)
{
	render_cell(r, s, CELL_ROWNAME, sx, width);
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:165

rutf8_as_context typed

([(~externalptr)<...> | null | p(CHR) | sym] -> empty)&([any_sexp] \ [(~externalptr)<...> | null | p(CHR) | sym] -> c_ptr)
timing: 0.033 s
source
void *rutf8_as_context(SEXP x)
{
	struct context *ctx;

	if (!rutf8_is_context(x)) {
		error("invalid context object");
	}

	ctx = R_ExternalPtrAddr(x);
	return ctx->data;
}
/__w/r-typing/r-typing/work/sources/utf8/src/context.c:80

rutf8_as_justify typed

[CHR] -> c(0..3)
timing: 0.058 s
source
int rutf8_as_justify(SEXP justify)
{
	const char *str;

	str = CHAR(STRING_ELT(justify, 0));
	if (strcmp(str, "left") == 0) {
		return RUTF8_JUSTIFY_LEFT;
	} else if (strcmp(str, "right") == 0) {
		return RUTF8_JUSTIFY_RIGHT;
	} else if (strcmp(str, "centre") == 0) {
		return RUTF8_JUSTIFY_CENTRE;
	} else {
		return RUTF8_JUSTIFY_NONE;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/util.c:23

rutf8_as_render typed

([(~externalptr)<...> | null | p(CHR) | sym] -> empty)&([any_sexp] \ [(~externalptr)<...> | null | p(CHR) | sym] -> *struct utf8lite_render)
timing: 0.043 s
source
struct utf8lite_render *rutf8_as_render(SEXP x)
{
	struct rutf8_render *obj;

	if (!rutf8_is_render(x)) {
		error("invalid render object");
	}

	obj = R_ExternalPtrAddr(x);
	return (obj->has_render) ? &obj->render : NULL;
}
/__w/r-typing/r-typing/work/sources/utf8/src/render.c:70

rutf8_as_style typed

([CHR] -> c_string)&([null] -> c_null)
timing: 0.202 s
source
const char *rutf8_as_style(SEXP style)
{
	SEXP elt;
	char *ans;
	int n;

	if (style == R_NilValue) {
		return NULL;
	}

	PROTECT(elt = STRING_ELT(style, 0));

	n = LENGTH(elt);
	ans = R_alloc(2 + n + 2, 1);

	ans[0] = '\033';
	ans[1] = '[';
	memcpy(ans + 2, CHAR(elt), n);
	ans[2 + n] = 'm';
	ans[3 + n] = '\0';

	UNPROTECT(1);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/util.c:40

rutf8_as_utf8 typed entry .Call accepts outside

([null] -> null)&([(~CHR)<...> | p(CHR) | sym] -> empty)
timing: 0.157 s
fuzzing: 3 inside (3 ok) · 5 outside (4 rejected, 1 accepted)
type drawn from: ((x1: null) -> null) & ((x1: p(CHR) | (~CHR)<...> | sym) -> empty)

Accepted outside the domain x1: 1

parameterchangecallreturned
x1kind:chrrutf8_as_utf8("fuzz")"fuzz"<> with { }
source
SEXP rutf8_as_utf8(SEXP sx)
{
	SEXP ans, sstr;
	PROTECT_INDEX ipx;
	struct utf8lite_message msg;
	struct utf8lite_text text;
	const uint8_t *str;
	cetype_t ce;
	size_t size;
	R_xlen_t i, n;
	int nprot = 0, duped = 0, raw;

	if (sx == R_NilValue) {
		return R_NilValue;
	}
	if (!isString(sx)) {
		error("argument is not a character object");
	}

	// reserve a protection slot for ans in case we need to duplicate
	PROTECT_WITH_INDEX(ans = sx, &ipx); nprot++;

	n = XLENGTH(sx);
	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(sstr = STRING_ELT(sx, i)); nprot++;
		if (sstr == NA_STRING) {
			UNPROTECT(1); nprot--;
			continue;
		}

		ce = getCharCE(sstr);
		raw = rutf8_encodes_utf8(ce) || ce == CE_BYTES;

		if (raw) {
			str = (const uint8_t *)CHAR(sstr);
			size = (size_t)XLENGTH(sstr);
		} else {
			str = (const uint8_t *)rutf8_translate_utf8(sstr);
			size = strlen((const char *)str);
		}

		if (utf8lite_text_assign(&text, str, size, 0, &msg)) {
			if (ce == CE_BYTES) {
				Rf_error("entry %"PRIu64
					 " cannot be converted from \"bytes\""
					 " Encoding to \"UTF-8\"; %s",
					 (uint64_t)i + 1, msg.string);
			} else if (raw) {
				Rf_error("entry %"PRIu64
					 " has wrong Encoding;"
					 " marked as \"UTF-8\""
					 " but %s",
					 (uint64_t)i + 1,
					 msg.string);
			} else {
				Rf_error("entry %"PRIu64
					 " cannot be converted"
					 " from \"%s\" Encoding to \"UTF-8\";"
					 " %s in converted string",
					 (uint64_t)i + 1,
					 encoding_name(ce),
					 msg.string);
			}
		}

		if (!raw || ce == CE_BYTES || ce == CE_NATIVE) {
			if (!duped) {
				REPROTECT(ans = duplicate(ans), ipx);
				duped = 1;
			}
			SET_STRING_ELT(ans, i,
				       mkCharLenCE((const char *)str,
					           (int)size, CE_UTF8));
		}

		UNPROTECT(1); nprot--;
	}

	UNPROTECT(nprot);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/as_utf8.c:46

rutf8_bytes_format typed

([*struct utf8lite_render, c_null, c_int_na, c_int_na, c(3), c_int_na, c_int_na, c_int_na] -> empty)&([*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c(2), c_int_na, c_int_na, c_int_na] | [*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c(3), c_int_na, c_int_na, c_int_na] | [*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c_bool, c_int_na, c_int_na, c_int_na] -> any_sexp)
timing: 0.105 s
source
SEXP rutf8_bytes_format(struct utf8lite_render *r,
			const struct rutf8_bytes *bytes,
			int trim, int chars, enum rutf8_justify_type justify,
			int quote, int flags, int width_max)
{
	int centre;

	if (justify == RUTF8_JUSTIFY_RIGHT) {
		return rutf8_bytes_rformat(r, bytes, trim, chars, quote,
					   flags, width_max);
	} else {
		centre = (justify == RUTF8_JUSTIFY_CENTRE);
		return rutf8_bytes_lformat(r, bytes, trim, chars, quote,
					   flags, width_max, centre);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:313

rutf8_bytes_lwidth typed

([c_null, c_int_na, c_int_na] -> empty)&([*struct rutf8_bytes, c_int_na, c_int_na] \ [c_null, c_int_na, c_int_na] -> c_int_na)
timing: 2.36 s
source
int rutf8_bytes_lwidth(const struct rutf8_bytes *bytes, int flags, int limit)
{
	const uint8_t *ptr = bytes->ptr;
	const uint8_t *end = ptr + bytes->size;
	uint8_t byte;
	int width, w, ellipsis = 3;

	width = 0;
	while (ptr != end) {
		byte = *ptr++;
		w = byte_width(byte, flags);
		assert(w >= 0);
		if (width > limit - w) {
			return width + ellipsis;
		}
		width += w;
	}

	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:51

rutf8_bytes_render typed

[*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c(2)] | [*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c(3)] | [*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c_bool] -> ()
timing: 0.049 s
source
void rutf8_bytes_render(struct utf8lite_render *r,
		       const struct rutf8_bytes *bytes,
		       int width, int quote, enum rutf8_justify_type justify)
{
	int centre;
	if (justify == RUTF8_JUSTIFY_RIGHT) {
		rutf8_bytes_rrender(r, bytes, width, quote);
	} else {
		centre = (justify == RUTF8_JUSTIFY_CENTRE);
		rutf8_bytes_lrender(r, bytes, width, quote, centre);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:195

rutf8_bytes_rformat typed

([*struct utf8lite_render, c_null, c_int_na, c_int_na, c_false, c_int_na, c_int_na] | [*struct utf8lite_render, c_null, c_int_na, c_int_na, c_int_na \ c_false, c_int_na, c_int_na] -> empty)&([*struct utf8lite_render, *struct rutf8_bytes, c_int_na, c_int_na, c_int_na, c_int_na, c_int_na] & ~[*struct utf8lite_render, c_null, c_int_na, c_int_na, c_false, c_int_na, c_int_na] & ~[*struct utf8lite_render, c_null, c_int_na, c_int_na, c_int_na \ c_false, c_int_na, c_int_na] -> any_sexp)
timing: 4.01 s
source
static SEXP rutf8_bytes_rformat(struct utf8lite_render *r,
				const struct rutf8_bytes *bytes,
				int trim, int chars, int quote,
				int flags, int width_max)
{
	SEXP ans = R_NilValue;
	const uint8_t *ptr, *end;
	uint8_t byte;
	int err = 0, w, width, quotes, trunc;

	quotes = quote ? 2 : 0;

	end = bytes->ptr + bytes->size;
	ptr = end;
	width = 0;
	trunc = 0;

	while (!trunc && ptr > bytes->ptr) {
		byte = *--ptr;
		w = byte_width(byte, flags);

		if (width > chars - w) {
			w = 3; // ...
			trunc = 1;
		}

		width += w;
	}

	if (!trim) {
		TRY(utf8lite_render_chars(r, ' ', width_max - width - quotes));
	}

	if (trunc) {
		TRY(utf8lite_render_raw(r, "...", 3));
	}

	while (ptr < end) {
		byte = *ptr++;
		render_byte(r, byte);
	}

	ans = mkCharLenCE((char *)r->string, r->length, CE_BYTES);
	utf8lite_render_clear(r);
exit:
	CHECK_ERROR(err);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:263

rutf8_bytes_rwidth typed

([c_null, c_int_na, c_int_na] -> empty)&([*struct rutf8_bytes, c_int_na, c_int_na] \ [c_null, c_int_na, c_int_na] -> c_int_na)
timing: 2.38 s
source
int rutf8_bytes_rwidth(const struct rutf8_bytes *bytes, int flags, int limit)
{
	const uint8_t *ptr = bytes->ptr;
	const uint8_t *end = ptr + bytes->size;
	uint8_t byte;
	int width, w, ellipsis = 3;

	width = 0;
	while (ptr != end) {
		byte = *ptr++;
		w = byte_width(byte, flags);
		assert(w >= 0);
		if (width > limit - w) {
			return width + ellipsis;
		}
		width += w;
	}

	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:73

rutf8_bytes_width typed

([c_null, c_int_na] -> empty)&([*struct rutf8_bytes, c_int_na] \ [c_null, c_int_na] -> c_int_na)
timing: 2.12 s
source
int rutf8_bytes_width(const struct rutf8_bytes *bytes, int flags)
{
	const uint8_t *ptr = bytes->ptr;
	const uint8_t *end = ptr + bytes->size;
	uint8_t byte;
	int width, w;

	width = 0;
	while (ptr != end) {
		byte = *ptr++;
		w = byte_width(byte, flags);
		if (w < 0) {
			return -1;
		}
		if (width > INT_MAX - w) {
			Rf_error("width exceeds maximum (%d)", INT_MAX);
		}
		width += w;
	}

	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:27

rutf8_encodes_utf8 typed

([c_int_na] -> c_true)&([~c_int_na] -> c_false)
timing: 0.009 s
source
int rutf8_encodes_utf8(cetype_t ce)
{
	switch (ce) {
	case CE_ANY:
	case CE_UTF8:
#if (!defined(_WIN32) && !defined(_WIN64))
	case CE_NATIVE: // assume that 'native' is UTF-8 on non-Windows
#endif
		return 1;
	default:
		return 0;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/util.c:66

rutf8_free_context typed

[externalptr(empty)] -> ()
timing: 0.304 s
source
void rutf8_free_context(SEXP x)
{
        struct context *ctx = R_ExternalPtrAddr(x);
        R_SetExternalPtrAddr(x, NULL);
	if (ctx) {
		if (ctx->destroy_func) {
			(ctx->destroy_func)(ctx->data);
		}
		free(ctx->data);
		free(ctx);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/context.c:32

rutf8_free_render typed

[externalptr(empty)] | [externalptr(struct rutf8_render) \ externalptr(empty)] | [externalptr(~struct rutf8_render) \ externalptr(empty)] -> ()
timing: 0.256 s
source
void rutf8_free_render(SEXP x)
{
        struct rutf8_render *obj = R_ExternalPtrAddr(x);
        R_SetExternalPtrAddr(x, NULL);
	if (obj) {
		if (obj->has_render) {
			utf8lite_render_destroy(&obj->render);
		}
		free(obj);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/render.c:29

rutf8_is_context typed

[(~externalptr)<...> | null | p(CHR) | sym] -> c_false
timing: 0.095 s
source
int rutf8_is_context(SEXP x)
{
	return ((TYPEOF(x) == EXTPTRSXP)
                && (R_ExternalPtrTag(x) == CONTEXT_TAG));
}
/__w/r-typing/r-typing/work/sources/utf8/src/context.c:73

rutf8_is_render typed

[(~externalptr)<...> | null | p(CHR) | sym] -> c_false
timing: 0.102 s
source
int rutf8_is_render(SEXP x)
{
	return ((TYPEOF(x) == EXTPTRSXP)
                && (R_ExternalPtrTag(x) == RENDER_TAG));
}
/__w/r-typing/r-typing/work/sources/utf8/src/render.c:63

rutf8_string_format typed

([*struct utf8lite_render, c_null, c_int_na, c_int_na, c(0..3), c_int_na, c_string, c_int_na, c_int_na, c_int_na, c_int_na] -> empty)&([*struct utf8lite_render, *struct rutf8_string, c_int_na, c_int_na, c(0..3), c_int_na, c_string, c_int_na, c_int_na, c_int_na, c_int_na] \ [*struct utf8lite_render, c_null, c_int_na, c_int_na, c(0..3), c_int_na, c_string, c_int_na, c_int_na, c_int_na, c_int_na] -> any_sexp)
timing: 0.195 s
source
SEXP rutf8_string_format(struct utf8lite_render *r,
			 const struct rutf8_string *str,
			 int trim, int chars, enum rutf8_justify_type justify,
			 int quote, const char *ellipsis, size_t nellipsis,
			 int wellipsis, int flags, int width_max)
{
	switch (str->type) {
	case RUTF8_STRING_TEXT:
		return rutf8_text_format(r, &str->value.text, trim, chars,
					 justify, quote, ellipsis, nellipsis,
					 wellipsis, flags, width_max);

	case RUTF8_STRING_BYTES:
		// always use ASCII for byte formatting; UTF-8 isn't allowed
		return rutf8_bytes_format(r, &str->value.bytes, trim, chars,
					  justify, quote, flags, width_max);
	default:
		return NA_STRING;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:132

rutf8_string_init typed

([*struct rutf8_string, p(CHR)] -> ())&([c_null, <...> | null | sym] -> empty)
timing: 0.451 s
source
void rutf8_string_init(struct rutf8_string *str, SEXP charsxp)
{
	if (charsxp == NA_STRING) {
		str->type = RUTF8_STRING_NONE;
	} else if (!text_init(&str->value.text, charsxp)) {
		str->type = RUTF8_STRING_TEXT;
	} else {
		bytes_init(&str->value.bytes, charsxp);
		str->type = RUTF8_STRING_BYTES;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:24

rutf8_string_lwidth typed

([c_null, c_int_na, c_int_na, c_int_na] -> empty)&([*struct rutf8_string, c_int_na, c_int_na, c_int_na] \ [c_null, c_int_na, c_int_na, c_int_na] -> c_int_na)
timing: 0.136 s
source
int rutf8_string_lwidth(const struct rutf8_string *str, int flags,
			int limit, int ellipsis)
{
	switch (str->type) {
	case RUTF8_STRING_TEXT:
		return rutf8_text_lwidth(&str->value.text, flags, limit,
					 ellipsis);
	case RUTF8_STRING_BYTES:
		return rutf8_bytes_lwidth(&str->value.bytes, flags, limit);
	default:
		return -1;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:85

rutf8_string_render typed

([*struct utf8lite_render, c_null, c_int_na, c_int_na, c(0..3)] -> empty)&([c_null, *struct rutf8_string, c(1..), c_int_na, c(2..3)] | [c_null, *struct rutf8_string, c_int_na, c_int_na \ c_false, c(0..3)] -> ())
timing: 0.528 s
source
void rutf8_string_render(struct utf8lite_render *r,
			 const struct rutf8_string *str,
			 int width, int quote, enum rutf8_justify_type justify)
{
	switch (str->type) {
	case RUTF8_STRING_TEXT:
		rutf8_text_render(r, &str->value.text, width, quote, justify);
		break;
	case RUTF8_STRING_BYTES:
		rutf8_bytes_render(r, &str->value.bytes, width, quote, justify);
		break;
	default:
		break;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:115

rutf8_string_rwidth typed

([c_null, c_int_na, c_int_na, c_int_na] -> empty)&([*struct rutf8_string, c_int_na, c_int_na, c_int_na] \ [c_null, c_int_na, c_int_na, c_int_na] -> c_int_na)
timing: 0.130 s
source
int rutf8_string_rwidth(const struct rutf8_string *str, int flags,
			int limit, int ellipsis)
{
	switch (str->type) {
	case RUTF8_STRING_TEXT:
		return rutf8_text_rwidth(&str->value.text, flags,
					 limit, ellipsis);
	case RUTF8_STRING_BYTES:
		return rutf8_bytes_rwidth(&str->value.bytes, flags, limit);
	default:
		return -1;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:100

rutf8_string_width typed

([c_null, c_int_na] -> empty)&([*struct rutf8_string, c_int_na] \ [c_null, c_int_na] -> c_int_na)
timing: 0.133 s
source
int rutf8_string_width(const struct rutf8_string *str, int flags)
{
	switch (str->type) {
	case RUTF8_STRING_TEXT:
		return rutf8_text_width(&str->value.text, flags);
	case RUTF8_STRING_BYTES:
		return rutf8_bytes_width(&str->value.bytes, flags);
	default:
		return -1;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:72

rutf8_text_format typed

[*struct utf8lite_render, c_null, c_int_na, c_int_na, c(3), c_int_na, c_string, c_int_na, c_int_na, c_int_na, c_int_na] | [*struct utf8lite_render, c_null, c_int_na, c_int_na, c_bool, c_int_na, c_string, c_int_na, c_int_na, c_int_na, c_int_na] | [*struct utf8lite_render, c_null, c_int_na \ c_false, c_int_na, c(2), c_int_na, c_string, c_int_na, c_int_na, c_int_na, c_int_na] -> any_sexp
timing: 0.157 s
source
SEXP rutf8_text_format(struct utf8lite_render *r,
		       const struct utf8lite_text *text,
		       int trim, int chars, enum rutf8_justify_type justify,
		       int quote, const char *ellipsis, size_t nellipsis,
		       int wellipsis, int flags, int width_max)
{
	int centre;

	if (justify == RUTF8_JUSTIFY_RIGHT) {
		return rutf8_text_rformat(r, text, trim, chars, quote,
					  ellipsis, nellipsis, wellipsis,
					  flags, width_max);
	} else {
		centre = (justify == RUTF8_JUSTIFY_CENTRE);
		return rutf8_text_lformat(r, text, trim, chars, quote,
					  ellipsis, nellipsis, wellipsis,
					  flags, width_max, centre);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:296

rutf8_text_lformat typed

[*struct utf8lite_render, c_null, c_int_na, c_int_na, c_false, c_string, c_int_na, c_int_na, c_int_na, c_int_na, c_false] | [*struct utf8lite_render, c_null, c_int_na, c_int_na, c_int_na \ c_false, c_string, c_int_na, c_int_na, c_int_na, c_int_na, c_false] | [*struct utf8lite_render, c_null, c_int_na \ c_false, c_int_na, c_false, c_string, c_int_na, c_int_na, c_int_na, c_int_na, c_int_na \ c_false] | [*struct utf8lite_render, c_null, c_int_na \ c_false, c_int_na, c_int_na \ c_false, c_string, c_int_na, c_int_na, c_int_na, c_int_na, c_int_na \ c_false] -> any_sexp
timing: 0.693 s
source
static SEXP rutf8_text_lformat(struct utf8lite_render *r,
			       const struct utf8lite_text *text,
			       int trim, int chars, int quote,
			       const char *ellipsis, size_t nellipsis,
			       int wellipsis, int flags, int width_max,
			       int centre)
{
	SEXP ans = R_NilValue;
	struct utf8lite_graphscan scan;
	int err = 0, w, trunc, bfill, efill, fullwidth, width, quotes;

	quotes = quote ? 2 : 0;

	bfill = 0;
	if (centre && !trim) {
		fullwidth = (rutf8_text_lwidth(text, flags, chars, wellipsis)
			     + quotes);
		if (fullwidth < width_max) {
			bfill = (width_max - fullwidth) / 2;
			TRY(utf8lite_render_chars(r, ' ', bfill));
		}
	}

	width = 0;
	trunc = 0;
	utf8lite_graphscan_make(&scan, text);

	while (!trunc && utf8lite_graphscan_advance(&scan)) {
		TRY(utf8lite_graph_measure(&scan.current, flags, &w));

		if (width > chars - w) {
			w = wellipsis;
			TRY(utf8lite_render_raw(r, ellipsis, nellipsis));
			trunc = 1;
		} else {
			TRY(utf8lite_render_graph(r, &scan.current));
		}

		width += w;
	}

	if (!trim) {
		efill = width_max - width - quotes - bfill;
		TRY(utf8lite_render_chars(r, ' ', efill));
	}

	ans = mkCharLenCE((char *)r->string, r->length, CE_UTF8);
	utf8lite_render_clear(r);
exit:
	CHECK_ERROR(err);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:194

rutf8_text_lrender typed

[*struct utf8lite_render, c_null, c_int_na, c_false, c_false] | [*struct utf8lite_render, c_null, c_int_na, c_int_na \ c_false, c_false] | [*struct utf8lite_render, c_null, c_int_na \ c(1..), c_false, c_int_na \ c_false] | [*struct utf8lite_render, c_null, c_int_na \ c(1..), c_int_na \ c_false, c_int_na \ c_false] | [c_null, *struct utf8lite_text, c(1..), c_false, c_int_na \ c_false] | [c_null, *struct utf8lite_text, c(1..), c_int_na \ c_false, c_int_na \ c_false] | [c_null, *struct utf8lite_text, c_int_na, c_int_na \ c_false, c_false] | [c_null, *struct utf8lite_text, c_int_na \ c(1..), c_int_na \ c_false, c_int_na \ c_false] -> ()
timing: 0.720 s
source
static void rutf8_text_lrender(struct utf8lite_render *r,
			       const struct utf8lite_text *text,
			       int width_min, int quote, int centre)
{
	struct utf8lite_graphscan scan;
	int err = 0, w, fullwidth, width, quotes;

	assert(width_min >= 0);

	quotes = quote ? 2 : 0;
	width = 0;

	if (centre && width_min > 0) {
		fullwidth = rutf8_text_width(text, r->flags);
		// ensure fullwidth + quotes doesn't overflow
		if (fullwidth <= width_min - quotes) {
			width = (width_min - fullwidth - quotes) / 2;
			TRY(utf8lite_render_chars(r, ' ', width));
		}
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
		assert(width < INT_MAX); // width <= width_min / 2
		width++;
	}

	utf8lite_graphscan_make(&scan, text);
	while (utf8lite_graphscan_advance(&scan)) {
		TRY(utf8lite_graph_measure(&scan.current, r->flags, &w));
		TRY(utf8lite_render_graph(r, &scan.current));

		assert(w >= 0);
		if (width <= width_min - w) {
			width += w;
		} else {
			width = width_min; // truncate to avoid overflow
		}
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
		if (width < width_min) { // avoid overflow
			width++;
		}
	}

	TRY(utf8lite_render_chars(r, ' ', width_min - width));
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:92

rutf8_text_lwidth typed

[c_null, c_int_na, c_int_na, c_int_na] -> c_int_na
timing: 0.044 s
source
int rutf8_text_lwidth(const struct utf8lite_text *text, int flags,
		      int limit, int ellipsis)
{
	struct utf8lite_graphscan scan;
	int err = 0, width, w;

	utf8lite_graphscan_make(&scan, text);
	width = 0;
	while (utf8lite_graphscan_advance(&scan)) {
		TRY(utf8lite_graph_measure(&scan.current, flags, &w));
		if (w < 0) {
			return -1;
		}
		if (width > limit - w) {
			return width + ellipsis;
		}
		width += w;
	}
exit:
	CHECK_ERROR(err);
	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:44

rutf8_text_render typed

[*struct utf8lite_render, c_null, c_int_na, c_int_na, c_bool] | [*struct utf8lite_render, c_null, c_int_na \ c(1..), c_int_na, c(2)] | [*struct utf8lite_render, c_null, c_int_na \ c(1..), c_int_na, c(3)] | [c_null, *struct utf8lite_text, c(1..), c_int_na, c(2)] | [c_null, *struct utf8lite_text, c(1..), c_int_na, c(3)] | [c_null, *struct utf8lite_text, c_int_na, c_int_na \ c_false, c(2)] | [c_null, *struct utf8lite_text, c_int_na, c_int_na \ c_false, c(3)] | [c_null, *struct utf8lite_text, c_int_na, c_int_na \ c_false, c_bool] -> ()
timing: 0.167 s
source
void rutf8_text_render(struct utf8lite_render *r,
		       const struct utf8lite_text *text,
		       int width, int quote, enum rutf8_justify_type justify)
{
	int centre;
	if (justify == RUTF8_JUSTIFY_RIGHT) {
		rutf8_text_rrender(r, text, width, quote);
	} else {
		centre = (justify == RUTF8_JUSTIFY_CENTRE);
		rutf8_text_lrender(r, text, width, quote, centre);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:181

rutf8_text_rformat typed

[*struct utf8lite_render, c_null, c_int_na, c_int_na, c_false, c_string, c_int_na, c_int_na, c_int_na, c_int_na] | [*struct utf8lite_render, c_null, c_int_na, c_int_na, c_int_na \ c_false, c_string, c_int_na, c_int_na, c_int_na, c_int_na] -> any_sexp
timing: 0.152 s
source
static SEXP rutf8_text_rformat(struct utf8lite_render *r,
			       const struct utf8lite_text *text,
			       int trim, int chars, int quote,
			       const char *ellipsis, size_t nellipsis,
			       int wellipsis, int flags, int width_max)
{
	SEXP ans = R_NilValue;
	struct utf8lite_graphscan scan;
	int err = 0, w, width, quotes, trunc;

	quotes = quote ? 2 : 0;

	utf8lite_graphscan_make(&scan, text);
	utf8lite_graphscan_skip(&scan);
	width = 0;
	trunc = 0;

	while (!trunc && utf8lite_graphscan_retreat(&scan)) {
		TRY(utf8lite_graph_measure(&scan.current, flags, &w));

		if (width > chars - w) {
			w = wellipsis;
			trunc = 1;
		}

		width += w;
	}

	if (!trim) {
		TRY(utf8lite_render_chars(r, ' ', width_max - width - quotes));
	}

	if (trunc) {
		TRY(utf8lite_render_raw(r, ellipsis, nellipsis));
	}

	while (utf8lite_graphscan_advance(&scan)) {
		TRY(utf8lite_render_graph(r, &scan.current));
	}

	ans = mkCharLenCE((char *)r->string, r->length, CE_UTF8);
	utf8lite_render_clear(r);
exit:
	CHECK_ERROR(err);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:248

rutf8_text_rrender typed

[*struct utf8lite_render, c_null, c_int_na \ c(1..), c_false] | [*struct utf8lite_render, c_null, c_int_na \ c(1..), c_int_na \ c_false] | [c_null, *struct utf8lite_text, c(1..), c_false] | [c_null, *struct utf8lite_text, c(1..), c_int_na \ c_false] | [c_null, *struct utf8lite_text, c_int_na \ c(1..), c_int_na \ c_false] -> ()
timing: 0.446 s
source
static void rutf8_text_rrender(struct utf8lite_render *r,
			       const struct utf8lite_text *text,
			       int width_min, int quote)
{
	struct utf8lite_graphscan scan;
	int err = 0, fullwidth, quotes;

	quotes = quote ? 2 : 0;

	if (width_min > 0) {
		fullwidth = rutf8_text_width(text, r->flags);
		// ensure fullwidth + quotes doesn't overflow
		if (fullwidth <= width_min - quotes) {
			fullwidth += quotes;
			TRY(utf8lite_render_chars(r, ' ',
						  width_min - fullwidth));
		}
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
	}

	utf8lite_graphscan_make(&scan, text);
	while (utf8lite_graphscan_advance(&scan)) {
		TRY(utf8lite_render_graph(r, &scan.current));
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
	}
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:145

rutf8_text_rwidth typed

[c_null, c_int_na, c_int_na, c_int_na] -> c_int_na
timing: 0.034 s
source
int rutf8_text_rwidth(const struct utf8lite_text *text, int flags,
		      int limit, int ellipsis)
{
	struct utf8lite_graphscan scan;
	int err = 0, width, w;

	utf8lite_graphscan_make(&scan, text);
	utf8lite_graphscan_skip(&scan);
	width = 0;
	while (utf8lite_graphscan_retreat(&scan)) {
		TRY(utf8lite_graph_measure(&scan.current, flags, &w));
		if (w < 0) {
			return -1;
		}
		if (width > limit - w) {
			return width + ellipsis;
		}
		width += w;
	}
exit:
	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:68

rutf8_text_width typed

[c_null, c_int_na] -> c_int_na
timing: 0.038 s
source
int rutf8_text_width(const struct utf8lite_text *text, int flags)
{
	struct utf8lite_graphscan scan;
	int err = 0, width, w;

	utf8lite_graphscan_make(&scan, text);
	width = 0;
	while (utf8lite_graphscan_advance(&scan)) {
		TRY(utf8lite_graph_measure(&scan.current, flags, &w));
		if (w < 0) {
			return -1;
		}
		if (width > INT_MAX - w) {
			Rf_error("width exceeds maximum (%d)", INT_MAX);
		}
		width += w;
	}
exit:
	CHECK_ERROR(err);
	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/text.c:21

rutf8_translate_utf8 typed

[p(CHR)] -> c_string
timing: 0.006 s
source
const char *rutf8_translate_utf8(SEXP x)
{
	return translateCharUTF8(x);
}
/__w/r-typing/r-typing/work/sources/utf8/src/util.c:137

rutf8_utf8_format typed entry .Call fuzz ok

([null, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp] -> null)&([(~CHR)<...> | p(CHR) | sym, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp, any_sexp] -> empty)
timing: 0.617 s
fuzzing: 8 inside (8 ok) · 8 outside (8 rejected)
type drawn from: ((x1: null, x2: any_sexp, x3: any_sexp, x4: any_sexp, x5: any_sexp, x6: any_sexp, x7: any_sexp, x8: any_sexp, x9: any_sexp, x10: any_sexp, x11: any_sexp) -> null) & ((x1: p(CHR) | (~CHR)<...> | sym, x2: any_sexp, x3: any_sexp, x4: any_sexp, x5: any_sexp, x6: any_sexp, x7: any_sexp, x8: any_sexp, x9: any_sexp, x10: any_sexp, x11: any_sexp) -> empty)
source
SEXP rutf8_utf8_format(SEXP sx, SEXP strim, SEXP schars, SEXP sjustify,
		       SEXP swidth, SEXP sna_encode, SEXP squote,
		       SEXP sna_print, SEXP sellipsis, SEXP swellipsis,
		       SEXP sutf8)
{
	SEXP ans, selt, srender, na_print, ans_i = NA_STRING;
	struct utf8lite_render *render;
	enum rutf8_justify_type justify;
	struct rutf8_string elt, na;
	const char *ellipsis;
	size_t nellipsis;
	R_xlen_t i, n;
	int chars, chars_i, wellipsis, width, width_max, trim, na_encode,
	    quote, quote_i, quotes, na_width, utf8, nprot, flags;

	nprot = 0;

	if (sx == R_NilValue) {
		return R_NilValue;
	}

	if (!isString(sx)) {
		error("argument is not a character vector");
	}
	PROTECT(ans = duplicate(sx)); nprot++;
	n = XLENGTH(ans);

	PROTECT(strim = coerceVector(strim, LGLSXP)); nprot++;
	trim = (LOGICAL(strim)[0] == TRUE);

	PROTECT(squote = coerceVector(squote, LGLSXP)); nprot++;
	quote = (LOGICAL(squote)[0] == TRUE);
	quotes = quote ? 2 : 0;

	PROTECT(sellipsis = STRING_ELT(sellipsis, 0)); nprot++;
	ellipsis = CHAR(sellipsis);
	nellipsis = strlen(ellipsis);

	PROTECT(swellipsis = coerceVector(swellipsis, INTSXP)); nprot++;
	wellipsis = INTEGER(swellipsis)[0];

	PROTECT(sutf8 = coerceVector(sutf8, LGLSXP)); nprot++;
	utf8 = (LOGICAL(sutf8)[0] == TRUE);

	if (schars == R_NilValue) {
		chars = NA_INTEGER;
	} else {
		PROTECT(schars = coerceVector(schars, INTSXP)); nprot++;
		chars = INTEGER(schars)[0];
	}

	if (chars == NA_INTEGER || chars > INT_MAX - wellipsis - quotes) {
		chars = INT_MAX - wellipsis - quotes;
	} else if (chars < 0) {
		chars = 0;
	}

	justify = rutf8_as_justify(sjustify);
	if (justify == RUTF8_JUSTIFY_NONE) {
		trim = 1;
	}

	if (swidth == R_NilValue) {
		width_max = 0;
	} else {
		PROTECT(swidth = coerceVector(swidth, INTSXP)); nprot++;
		width_max = INTEGER(swidth)[0];
		if (width_max == NA_INTEGER || width_max < 0) {
			width_max = 0;
		}
	}

	PROTECT(sna_encode = coerceVector(sna_encode, LGLSXP)); nprot++;
	na_encode = (LOGICAL(sna_encode)[0] == TRUE);

	if (sna_print == R_NilValue) {
		PROTECT(na_print = mkChar(quote ? "NA" : "<NA>")); nprot++;
	} else {
		PROTECT(na_print = STRING_ELT(sna_print, 0)); nprot++;
	}

	flags = (UTF8LITE_ESCAPE_CONTROL | UTF8LITE_ENCODE_C);
	if (quote) {
		flags |= UTF8LITE_ESCAPE_DQUOTE;
	}
	if (!utf8) {
		flags |= UTF8LITE_ESCAPE_UTF8;
	}
#if defined(_WIN32) || defined(_WIN64)
	flags |= UTF8LITE_ESCAPE_EXTENDED;
#endif

	rutf8_string_init(&na, na_print);
	na_width = rutf8_string_width(&na, flags);

        PROTECT(srender = rutf8_alloc_render(0)); nprot++;
	render = rutf8_as_render(srender);

	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(selt = STRING_ELT(sx, i)); nprot++;
		rutf8_string_init(&elt, selt);

		if (elt.type == RUTF8_STRING_NONE) {
			width = na_encode ? na_width : 0;
		} else if (justify == RUTF8_JUSTIFY_RIGHT) {
			width = (rutf8_string_rwidth(&elt, flags, chars,
						     wellipsis)
				 + quotes);
		} else {
			width = (rutf8_string_lwidth(&elt, flags, chars,
						     wellipsis)
				 + quotes);
		}

		if (width > width_max) {
			width_max = width;
		}

		if (width >= chars + wellipsis + quotes) {
			break;
		}

		UNPROTECT(1); nprot--;
	}

	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(selt = STRING_ELT(sx, i)); nprot++;
		rutf8_string_init(&elt, selt);

		if (elt.type == RUTF8_STRING_NONE) {
			if (na_encode) {
				elt = na;
				chars_i = na_width;
				quote_i = 0;
			} else {
				UNPROTECT(1); nprot--;
				SET_STRING_ELT(ans, i, NA_STRING);
				continue;
			}
		} else {
			chars_i = chars;
			quote_i = quote;
		}

		ans_i = rutf8_string_format(render, &elt, trim, chars_i,
					    justify, quote_i, ellipsis,
					    nellipsis, wellipsis, flags,
					    width_max);
		UNPROTECT(1); nprot--;
		SET_STRING_ELT(ans, i, ans_i);
	}

	rutf8_free_render(srender);
	UNPROTECT(nprot);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_format.c:26

rutf8_utf8_valid typed entry .Call accepts outside

([null] -> null)&([(~CHR)<...> | p(CHR) | sym] -> empty)
timing: 0.806 s
fuzzing: 4 inside (4 ok) · 5 outside (4 rejected, 1 accepted)
type drawn from: ((x1: null) -> null) & ((x1: p(CHR) | (~CHR)<...> | sym) -> empty)

Accepted outside the domain x1: 1

parameterchangecallreturned
x1kind:chrrutf8_utf8_valid("fuzz")tt<> with { }
source
SEXP rutf8_utf8_valid(SEXP sx)
{
	SEXP ans, sstr;
	const uint8_t *str;
	struct utf8lite_text text;
	cetype_t ce;
	size_t size;
	R_xlen_t i, n;
	int raw, val;

	if (sx == R_NilValue) {
		return R_NilValue;
	}
	if (!isString(sx)) {
		error("argument is not a character object");
	}

	n = XLENGTH(sx);
	PROTECT(ans = allocVector(LGLSXP, n));
	setAttrib(ans, R_NamesSymbol, getAttrib(sx, R_NamesSymbol));
	setAttrib(ans, R_DimSymbol, getAttrib(sx, R_DimSymbol));
	setAttrib(ans, R_DimNamesSymbol, getAttrib(sx, R_DimNamesSymbol));

	n = XLENGTH(sx);
	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(sstr = STRING_ELT(sx, i));
		if (sstr == NA_STRING) {
			LOGICAL(ans)[i] = NA_LOGICAL;
			UNPROTECT(1);
			continue;
		}

		ce = getCharCE(sstr);
		raw = rutf8_encodes_utf8(ce) || ce == CE_BYTES;

		if (raw) {
			str = (const uint8_t *)CHAR(sstr);
			size = (size_t)XLENGTH(sstr);
		} else {
			str = (const uint8_t *)rutf8_translate_utf8(sstr);
			size = strlen((const char *)str);
		}

		if (utf8lite_text_assign(&text, str, size, 0, NULL)) {
			val = FALSE;
		} else {
			val = TRUE;
		}
		LOGICAL(ans)[i] = val;
		UNPROTECT(1);
	}

	UNPROTECT(1);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_valid.c:22

rutf8_utf8_width typed entry .Call fuzz ok

([null, any_sexp, any_sexp, any_sexp] -> null)&([(~CHR)<...> | p(CHR) | sym, any_sexp, any_sexp, any_sexp] -> empty)
timing: 9.01 s
fuzzing: 8 inside (8 ok) · 8 outside (8 rejected)
type drawn from: ((x1: null, x2: any_sexp, x3: any_sexp, x4: any_sexp) -> null) & ((x1: p(CHR) | (~CHR)<...> | sym, x2: any_sexp, x3: any_sexp, x4: any_sexp) -> empty)
source
SEXP rutf8_utf8_width(SEXP sx, SEXP sencode, SEXP squote, SEXP sutf8)
{
	SEXP ans, selt;
	struct rutf8_string elt;
	R_xlen_t i, n;
	int flags, encode, quote, quotes, utf8, w;

	if (sx == R_NilValue) {
		return R_NilValue;
	}
	if (!isString(sx)) {
		error("argument is not a character object");
	}
	n = XLENGTH(sx);
	encode = LOGICAL(sencode)[0] == TRUE;
	quote = LOGICAL(squote)[0] == TRUE;
	utf8 = LOGICAL(sutf8)[0] == TRUE;

	flags = UTF8LITE_ENCODE_C;
	if (encode) {
		flags |= UTF8LITE_ESCAPE_CONTROL;
		if (!utf8) {
			flags |= UTF8LITE_ESCAPE_UTF8;
		}
#if defined(_WIN32) || defined(_WIN64)
		flags |= UTF8LITE_ESCAPE_EXTENDED;
#endif
	}
	if (quote) {
		flags |= UTF8LITE_ESCAPE_DQUOTE;
	}
	quotes = quote ? 2 : 0;

	PROTECT(ans = allocVector(INTSXP, n));
	setAttrib(ans, R_NamesSymbol, getAttrib(sx, R_NamesSymbol));
	setAttrib(ans, R_DimSymbol, getAttrib(sx, R_DimSymbol));
	setAttrib(ans, R_DimNamesSymbol, getAttrib(sx, R_DimNamesSymbol));

	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(selt = STRING_ELT(sx, i));
		rutf8_string_init(&elt, selt);
		
		if (elt.type == RUTF8_STRING_NONE) {
			w = NA_INTEGER;
		} else if (elt.type == RUTF8_STRING_TEXT && !encode && !utf8
				&& !utf8lite_text_isascii(&elt.value.text)) {
			w = NA_INTEGER;
		} else {
			w = rutf8_string_width(&elt, flags);
			if (w < 0) {
				w = NA_INTEGER;
			} else if (w > INT_MAX - quotes) {
				Rf_error("width exceeds maximum (%d)",
					 INT_MAX);
			} else {
				w += quotes;
			}
		}
		INTEGER(ans)[i] = w;
		UNPROTECT(1);
	}

	UNPROTECT(1);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_width.c:21

sgr_get typed

([*struct style, c_bool, *c_int_na] -> c_null)&([*struct style, c(2), *c_int_na] | [*struct style, c(3), *c_int_na] -> c_string)&([c_null, c(2), *c_int_na] | [c_null, c(3), *c_int_na] -> empty)
timing: 0.330 s
source
static const char *sgr_get(const struct style *s, enum cell_type t, int *lenptr)
{
	switch (t) {
	case CELL_NAME:
		*lenptr = s->names_len;
		return s->names;

	case CELL_ROWNAME:
		*lenptr = s->rownames_len;
		return s->rownames;

	default:
		*lenptr = 0;
		return NULL;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:68

style_close typed

([*struct utf8lite_render] -> c_int_na)&([c_null] -> empty)
timing: 0.156 s
source
static int style_close(struct utf8lite_render *r)
{
	if (!r->style_close_length) {
		return 0;
	}

	return utf8lite_render_raw(r, r->style_close, r->style_close_length);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:84

style_open typed

([*struct utf8lite_render] -> c_int_na)&([c_null] -> empty)
timing: 0.161 s
source
static int style_open(struct utf8lite_render *r)
{
	if (!r->style_open_length) {
		return 0;
	}

	return utf8lite_render_raw(r, r->style_open, r->style_open_length);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:74

text_init typed

[*struct utf8lite_text, p(CHR)] -> c_int_na
timing: 0.089 s
source
int text_init(struct utf8lite_text *text, SEXP charsxp)
{
	const uint8_t *ptr;
	size_t size;
	cetype_t ce;
	int err = 0;

	assert(charsxp != NA_STRING);

	ce = getCharCE(charsxp);
	if (rutf8_encodes_utf8(ce)) {
		ptr = (const uint8_t *)CHAR(charsxp);
		size = (size_t)XLENGTH(charsxp);
	} else if (ce == CE_LATIN1 || ce == CE_NATIVE) {
		ptr = (const uint8_t *)rutf8_translate_utf8(charsxp);
		size = strlen((const char *)ptr);
	} else {
		err = UTF8LITE_ERROR_INVAL; // bytes or other encoding
		goto exit;
	}

	TRY(utf8lite_text_assign(text, ptr, size, 0, NULL));
exit:
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/string.c:45

utf8_escape_width typed

[c_int_na, c_int_na] -> c(6) | c(10) | c(12)
timing: 0.010 s
source
int utf8_escape_width(int32_t ch, int flags)
{
	if (ch <= 0xFFFF) {
		return 6;
	} else if (flags & UTF8LITE_ENCODE_JSON) {
		return 12;
	} else {
		return 10;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graph.c:180

utf8_width typed

[c_int_na, c_int_na, c_int_na] -> c(-1..2) | c(6) | c(10) | c(12)
timing: 0.109 s
source
int utf8_width(int32_t ch, int cw, int flags)
{
	int w = -1;

	switch ((enum utf8lite_charwidth_type)cw) {
	case UTF8LITE_CHARWIDTH_NONE:
		if (flags & UTF8LITE_ESCAPE_CONTROL) {
			w = utf8_escape_width(ch, flags);
		} else {
			w = -1;
		}
		break;

	case UTF8LITE_CHARWIDTH_IGNORABLE:
	case UTF8LITE_CHARWIDTH_MARK:
		w = 0;
		break;

	case UTF8LITE_CHARWIDTH_NARROW:
		w = 1;
		break;

	case UTF8LITE_CHARWIDTH_AMBIGUOUS:
		w = (flags & UTF8LITE_ENCODE_AMBIGWIDE) ? 2 : 1;
		break;

	case UTF8LITE_CHARWIDTH_WIDE:
	case UTF8LITE_CHARWIDTH_EMOJI:
		w = 2;
		break;
	}

	return w;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graph.c:144

utf8lite_array_grow typed

([*c_ptr, *c_int_na, c_false, c_int_na, c_int_na] -> c_false | c(2))&([*c_ptr, c_null, c_int_na, c_int_na, c_int_na] | [c_null, *c_int_na, c_false, c_int_na, c_int_na] -> empty)
timing: 0.471 s
source
int utf8lite_array_grow(void **baseptr, int *sizeptr, size_t width, int count,
		      int nadd)
{
	void *base = *baseptr;
	int size = *sizeptr;
	int err;

	assert(0 <= count);
	assert(count <= size);
	assert(width > 0);

	if (nadd <= size - count) {
		return 0;
	}

	if ((err = utf8lite_array_size_add(&size, width, count, nadd))) {
		return err;
	}

	if (!(base = realloc(base, ((size_t)size) * width))) {
		err = UTF8LITE_ERROR_NOMEM;
		return err;
	}

	*baseptr = base;
	*sizeptr = size;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/array.c:122

utf8lite_array_size_add typed

([*c_int_na, c_false, c_int_na, c_int_na] -> c_false)&([c_null, c_int_na, c_int_na, c_int_na] -> empty)
timing: 0.103 s
source
int utf8lite_array_size_add(int *sizeptr, size_t width, int count, int nadd)
{
	size_t size, size_min, size_max;
	int err;

	assert(*sizeptr >= 0);
	assert(count >= 0);
	assert(nadd >= 0);

	if (width == 0) {
		return 0;
	}

	size = (size_t)*sizeptr;
	if ((err = utf8lite_bigarray_size_add(&size, width, (size_t)count,
					    (size_t)nadd))) {
		return err;
	}
	size_max = (size_t)INT_MAX / width;
	if (size > size_max) {
		size = size_max;
		size_min = (size_t)count + (size_t)nadd;
		if (size < size_min) {
			err = UTF8LITE_ERROR_OVERFLOW;
			//utf8lite_log(err, "array size (%"PRIu64
			//	   " elements of %"PRIu64" bytes each)"
			//	   " exceeds maximum (%"PRIu64" elements)",
			//	   (uint64_t)size_min, (uint64_t)width,
			//	   (uint64_t)size_max);
			return err;
		}
	}

	*sizeptr = (int)size;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/array.c:84

utf8lite_bigarray_size_add typed

[*c_int_na, c_false, c_int_na, c_int_na] -> c_false
timing: 0.050 s
source
int utf8lite_bigarray_size_add(size_t *sizeptr, size_t width, size_t count,
			       size_t nadd)
{
	size_t size = *sizeptr;
	size_t size_min;
	int err;
	double n1;

	if (width == 0) {
		return 0;
	}

	if (count > (SIZE_MAX - nadd) / width) {
		err = UTF8LITE_ERROR_OVERFLOW;
		//utf8lite_log(err, "array size (%"PRIu64" + %"PRIu64
		//	     " elements of %"PRIu64" bytes each)"
		//	     " exceeds maximum (%"PRIu64" elements)",
		//	     (uint64_t)count, (uint64_t)nadd,
		//	     (uint64_t)width, (uint64_t)SIZE_MAX);
		return err;
	}

	size_min = count + nadd;
	if (size >= size_min) {
		return 0;
	}

	assert(UTF8LITE_ARRAY_SIZE_INIT > 0);
	assert(UTF8LITE_ARRAY_GROW > 1);

	if (size < UTF8LITE_ARRAY_SIZE_INIT && size_min > 0) {
		size = UTF8LITE_ARRAY_SIZE_INIT;
	}

	while (size < size_min) {
		n1 = UTF8LITE_ARRAY_GROW * size;
		if (n1 > SIZE_MAX / width) {
			size = SIZE_MAX / width;
		} else {
			size = (size_t)n1;
		}
	}

	*sizeptr = size;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/array.c:36

utf8lite_charwidth typed

[c_int] -> c_int_na
timing: 0.077 s
source
int utf8lite_charwidth(int32_t code)
{
	int prop = charwidth(code);
	switch(prop) {
	case CHARWIDTH_NONE:
		return UTF8LITE_CHARWIDTH_NONE;
	case CHARWIDTH_IGNORABLE:
		return UTF8LITE_CHARWIDTH_IGNORABLE;
	case CHARWIDTH_MARK:
		return UTF8LITE_CHARWIDTH_MARK;
	case CHARWIDTH_NARROW:
		return UTF8LITE_CHARWIDTH_NARROW;
	case CHARWIDTH_AMBIGUOUS:
		return UTF8LITE_CHARWIDTH_AMBIGUOUS;
	case CHARWIDTH_WIDE:
		return UTF8LITE_CHARWIDTH_WIDE;
	case CHARWIDTH_EMOJI:
		return UTF8LITE_CHARWIDTH_EMOJI;
	default:
		assert(0 && "internal error: unrecognized charwidth property");
		return prop;
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/char.c:23

utf8lite_compose typed

([*c_int_na, c_null] -> empty)&([c_null, *c_int_na] -> ())
timing: 4.81 s
source
void utf8lite_compose(int32_t *ptr, size_t *lenptr)
{
	size_t len = *lenptr;
	int32_t *begin = ptr;
	int32_t *end = begin + len;
	int32_t *leftptr, *dst;
	int32_t left = 0, code, prim;
	uint8_t code_ccc, prev_ccc = 0;
	int moff = 0, mlen = 0;
	int blocked, has_prev, did_del;

	did_del = 0;

	// find the first combining starter (the left code point, L)
	leftptr = begin;
	while (leftptr != end) {
		left = *leftptr;
		if (has_compose(left, &moff, &mlen)) {
			break;
		}
		leftptr++;
	}

	if (leftptr == end) {
		goto out;
	}

	ptr = leftptr + 1;
	has_prev = 0;
	while (ptr != end) {
		code = *ptr;
		code_ccc = combining_class(code);

		// determine whether the code is blocked
		if (has_prev && prev_ccc >= code_ccc) {
			blocked = 1;
		} else {
			blocked = 0;
		}

		if (!blocked && has_combiner(left, moff, mlen, code, &prim)) {
			// replace L by P
			*leftptr = prim;
			left = prim;
			has_compose(left, &moff, &mlen);

			// delete C
			*ptr = UTF8LITE_CODE_NONE;
			did_del = 1;
		} else if (code_ccc == 0) {
			// new leftmost combining starter, L
			leftptr = ptr;
			left = code;
			has_compose(left, &moff, &mlen);
			has_prev = 0;
		} else {
			prev_ccc = code_ccc;
			has_prev = 1;
		}
		ptr++;
	}

	// remove the deleted entries
	if (did_del) {
		ptr = begin;
		dst = begin;
		while (ptr != end) {
			code = *ptr++;
			if (code != UTF8LITE_CODE_NONE) {
				*dst++ = code;
			}
		}
		len = (size_t)(dst - begin);
	}

out:
	*lenptr = len;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:303

utf8lite_decode_escape typed

([*(*c_int_na \ c_null), *c_int_na] -> ())&([*c_null, *c_int_na] -> empty)
timing: 0.528 s
source
void utf8lite_decode_escape(const uint8_t **inputptr, int32_t *codeptr)
{
	const uint8_t *ptr = *inputptr;
	int32_t code;

	code = *ptr++;

	switch (code) {
	case 'b':
		code = '\b';
		break;
	case 'f':
		code = '\f';
		break;
	case 'n':
		code = '\n';
		break;
	case 'r':
		code = '\r';
		break;
	case 't':
		code = '\t';
		break;
	case 'u':
		*inputptr = ptr;
		utf8lite_decode_uescape(inputptr, codeptr);
		return;
	default:
		break;
	}

	*inputptr = ptr;
	*codeptr = code;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/escape.c:195

UTF8LITE_DECODE_UTF16_PAIR typed

[c_int_na, c_int_na] -> c_int
timing: 0.021 s
(definition not located in src/)

utf8lite_decode_utf8 typed

([*(*c_int_na \ c_null), *c_int_na] -> ())&([*c_null, *c_int_na] -> empty)
timing: 3.48 s
source
void utf8lite_decode_utf8(const uint8_t **bufptr, int32_t *codeptr)
{
	const uint8_t *ptr = *bufptr;
	int32_t code;
	uint_fast8_t ch;
	unsigned nc;

	ch = *ptr++;
	if (!(ch & 0x80)) {
		code = ch;
		nc = 0;
	} else if (!(ch & 0x20)) {
		code = ch & 0x1F;
		nc = 1;
	} else if (!(ch & 0x10)) {
		code = ch & 0x0F;
		nc = 2;
	} else {
		code = ch & 0x07;
		nc = 3;
	}

	while (nc-- > 0) {
		ch = *ptr++;
		code = (code << 6) + (ch & 0x3F);
	}

	*bufptr = ptr;
	*codeptr = code;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/encode.c:208

utf8lite_encode_utf8 typed

([c_int_na, *(*c_int_na \ c_null)] -> ())&([c_int_na, *c_null] -> empty)
timing: 1.52 s
source
void utf8lite_encode_utf8(int32_t code, uint8_t **bufptr)
{
	uint8_t *ptr = *bufptr;
	int32_t x = code;

	if (x <= 0x7F) {
		*ptr++ = (uint8_t)x;
	} else if (x <= 0x07FF) {
		*ptr++ = (uint8_t)(0xC0 | (x >> 6));
		*ptr++ = (uint8_t)(0x80 | (x & 0x3F));
	} else if (x <= 0xFFFF) {
		*ptr++ = (uint8_t)(0xE0 | (x >> 12));
		*ptr++ = (uint8_t)(0x80 | ((x >> 6) & 0x3F));
		*ptr++ = (uint8_t)(0x80 | (x & 0x3F));
	} else {
		*ptr++ = (uint8_t)(0xF0 | (x >> 18));
		*ptr++ = (uint8_t)(0x80 | ((x >> 12) & 0x3F));
		*ptr++ = (uint8_t)(0x80 | ((x >> 6) & 0x3F));
		*ptr++ = (uint8_t)(0x80 | (x & 0x3F));
	}

	*bufptr = ptr;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/encode.c:241

utf8lite_escape_ascii typed

([c_null, c_int_na] -> empty)&([*struct utf8lite_render, c(127)] | [*struct utf8lite_render, c_int_na \ c(127)] -> c_int_na)
timing: 15.56 s
source
static int utf8lite_escape_ascii(struct utf8lite_render *r, int32_t ch)
{
	style_open(r);
	CHECK_ERROR(r);

	// character expansion for a special escape: \uXXXX or \X
	utf8lite_render_grow(r, 6);
	CHECK_ERROR(r);

	if (ch <= 0x1F || ch == 0x7F) {
		switch (ch) {
		case '\a':
			if (r->flags & UTF8LITE_ENCODE_JSON) {
				r->length += snprintf(&r->string[r->length], r->length_max - r->length + 1,
						     "\\u%04x", (unsigned)ch);
			} else {
				r->string[r->length++] = '\\';
				r->string[r->length++] = 'a';
				r->string[r->length] = '\0';
			}
			break;
		case '\b':
			r->string[r->length++] = '\\';
			r->string[r->length++] = 'b';
			r->string[r->length] = '\0';
			break;
		case '\f':
			r->string[r->length++] = '\\';
			r->string[r->length++] = 'f';
			r->string[r->length] = '\0';
			break;
		case '\n':
			r->string[r->length++] = '\\';
			r->string[r->length++] = 'n';
			r->string[r->length] = '\0';
			break;
		case '\r':
			r->string[r->length++] = '\\';
			r->string[r->length++] = 'r';
			r->string[r->length] = '\0';
			break;
		case '\t':
			r->string[r->length++] = '\\';
			r->string[r->length++] = 't';
			r->string[r->length] = '\0';
			break;
		case '\v':
			if (r->flags & UTF8LITE_ENCODE_JSON) {
				r->length += snprintf(&r->string[r->length], r->length_max - r->length + 1,
						     "\\u%04x", (unsigned)ch);
			} else {
				r->string[r->length++] = '\\';
				r->string[r->length++] = 'v';
				r->string[r->length] = '\0';
			}
			break;
		default:
			r->length += snprintf(&r->string[r->length], r->length_max - r->length + 1,
					     "\\u%04x", (unsigned)ch);
			break;
		}

		style_close(r);
		CHECK_ERROR(r);
	} else {
		r->string[r->length++] = '\\';
		r->string[r->length] = '\0';
		style_close(r);
		CHECK_ERROR(r);

		utf8lite_render_grow(r, 1);
		CHECK_ERROR(r);
		r->string[r->length++] = (char)ch;
		r->string[r->length] = '\0';
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:311

utf8lite_escape_utf8 typed

([*struct utf8lite_render, c_int_na] -> c_int_na)&([c_null, c_int_na] -> empty)
timing: 4.87 s
source
static int utf8lite_escape_utf8(struct utf8lite_render *r, int32_t ch)
{
	unsigned hi, lo;
	int len;

	style_open(r);
	CHECK_ERROR(r);

	if (ch <= 0xFFFF) {
		// \uXXXX
		len = 6;
	} else if (r->flags & UTF8LITE_ENCODE_JSON) {
		// \uXXXX\uYYYY
		len = 12;
	} else {
		// \UXXXXYYYY
		len = 10;
	}

	utf8lite_render_grow(r, len);
	CHECK_ERROR(r);

	if (ch <= 0xFFFF) {
		r->length += snprintf(&r->string[r->length], r->length_max - r->length + 1,
				     "\\u%04x", (unsigned)ch);
	} else if (r->flags & UTF8LITE_ENCODE_JSON) {
		hi = UTF8LITE_UTF16_HIGH(ch);
		lo = UTF8LITE_UTF16_LOW(ch);
		r->length += snprintf(&r->string[r->length], r->length_max - r->length + 1,
				     "\\u%04x\\u%04x", hi, lo);
	} else {
		r->length += snprintf(&r->string[r->length],  r->length_max - r->length + 1,
				     "\\U%08"PRIx32, (uint32_t)ch);
	}

	style_close(r);
	CHECK_ERROR(r);

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:269

utf8lite_graph_measure typed

[c_null, c_int_na, *c_int_na \ c_null] | [c_null, c_int_na, c_null] -> c_int_na
timing: 0.304 s
source
int utf8lite_graph_measure(const struct utf8lite_graph *g,
			   int flags, int *widthptr)
{
	struct utf8lite_text_iter it;
	int32_t ch;
	int err = 0, cw, w, width;

	width = 0;
	utf8lite_text_iter_make(&it, &g->text);

	while (utf8lite_text_iter_advance(&it)) {
		ch = it.current;

		if (ch <= 0x7F) {
			w = ascii_width(ch, flags);
		} else if (flags & UTF8LITE_ESCAPE_UTF8) {
			w = utf8_escape_width(ch, flags);
		} else if ((flags & UTF8LITE_ESCAPE_EXTENDED)
				&& (ch > 0xFFFF)) {
			w = utf8_escape_width(ch, flags);
		} else {
			cw = utf8lite_charwidth(ch);
			if (cw == UTF8LITE_CHARWIDTH_EMOJI) {
				width = 2;
				goto exit;
			}
			w = utf8_width(ch, cw, flags);
		}

		if (w < 0) {
			width = w;
			goto exit;
		} else if (w > INT_MAX - width) {
			width = -1;
			err = UTF8LITE_ERROR_OVERFLOW;
			goto exit;
		} else {
			width += w;
		}
	}

exit:
	if (widthptr) {
		*widthptr = width;
	}
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graph.c:49

utf8lite_graphscan_advance typed

([c_null] -> empty)&([*struct utf8lite_graphscan] \ [c_null] -> c_int_na)
timing: 4.70 s
source
int utf8lite_graphscan_advance(struct utf8lite_graphscan *scan)
{
	scan->current.text.ptr = (uint8_t *)scan->ptr;
	scan->current.text.attr = (scan->iter.text_attr
				   & ~UTF8LITE_TEXT_SIZE_MASK);
Start:
	// GB2: Break at the end of text
	if (scan->prop < 0) {
		goto Break;
	}

	switch ((enum graph_break_prop)scan->prop) {
	case GRAPH_BREAK_CR:
		NEXT();
		goto CR;

	case GRAPH_BREAK_CONTROL:
	case GRAPH_BREAK_LF:
		// Break after controls
		// GB4: (Newline | LF) +
		NEXT();
		goto Break;

	case GRAPH_BREAK_L:
		NEXT();
		goto L;

	case GRAPH_BREAK_LV:
	case GRAPH_BREAK_V:
		NEXT();
		goto V;

	case GRAPH_BREAK_LVT:
	case GRAPH_BREAK_T:
		NEXT();
		goto T;

	case GRAPH_BREAK_PREPEND:
		NEXT();
		goto Prepend;

	case GRAPH_BREAK_EXTENDED_PICTOGRAPHIC:
		NEXT();
		goto Extended_Pictographic;

	case GRAPH_BREAK_REGIONAL_INDICATOR:
		NEXT();
		goto Regional_Indicator;

	case GRAPH_BREAK_EXTEND:
	case GRAPH_BREAK_SPACINGMARK:
	case GRAPH_BREAK_ZWJ:
	case GRAPH_BREAK_OTHER:
		NEXT();
		goto MaybeBreak;
	}

	assert(0 && "unhandled grapheme break property");

CR:
	// GB3: Do not break within CRLF
	// GB4: Otherwise break after controls
	if (scan->prop == GRAPH_BREAK_LF) {
		NEXT();
	}
	goto Break;

L:
	// GB6: Do not break Hangul syllable sequences.
	switch (scan->prop) {
	case GRAPH_BREAK_L:
		NEXT();
		goto L;

	case GRAPH_BREAK_V:
	case GRAPH_BREAK_LV:
		NEXT();
		goto V;

	case GRAPH_BREAK_LVT:
		NEXT();
		goto T;

	default:
		goto MaybeBreak;
	}

V:
	// GB7: Do not break Hangul syllable sequences.
	switch (scan->prop) {
	case GRAPH_BREAK_V:
		NEXT();
		goto V;

	case GRAPH_BREAK_T:
		NEXT();
		goto T;

	default:
		goto MaybeBreak;
	}

T:
	// GB8: Do not break Hangul syllable sequences.
	switch (scan->prop) {
	case GRAPH_BREAK_T:
		NEXT();
		goto T;

	default:
		goto MaybeBreak;
	}

Prepend:
	switch (scan->prop) {
	case GRAPH_BREAK_CONTROL:
	case GRAPH_BREAK_CR:
	case GRAPH_BREAK_LF:
		// GB5: break before controls
		goto Break;

	default:
		// GB9b: do not break after Prepend characters.
		goto Start;
	}

Extended_Pictographic:
	// GB9:  Do not break before extending characters
	while (scan->prop == GRAPH_BREAK_EXTEND) {
		NEXT();
	}
    // GB9: Do not break before ZWJ
    if (scan->prop == GRAPH_BREAK_ZWJ) {
        NEXT();
        // GB11: Do not break within emoji modifier sequences
        // or emoji zwj sequences.
        if (scan->prop == GRAPH_BREAK_EXTENDED_PICTOGRAPHIC) {
            NEXT();
            goto Extended_Pictographic;
        }
    }
	goto MaybeBreak;

Regional_Indicator:
	// Do not break within emoji flag sequences. That is, do not break
	// between regional indicator (RI) symbols if there is an odd number
	// of RI characters before the break point
	if (scan->prop == GRAPH_BREAK_REGIONAL_INDICATOR) {
		// GB12/13: [^RI] RI * RI
		NEXT();
	}
	goto MaybeBreak;

MaybeBreak:
	// GB9: Do not break before extending characters or ZWJ.
	// GB9a: Do not break before SpacingMark [extended grapheme clusters]
	// GB999: Otherwise, break everywhere
	switch (scan->prop) {
	case GRAPH_BREAK_EXTEND:
	case GRAPH_BREAK_SPACINGMARK:
	case GRAPH_BREAK_ZWJ:
		NEXT();
		goto MaybeBreak;

	default:
		goto Break;
	}

Break:
	scan->current.text.attr |= (size_t)(scan->ptr - scan->current.text.ptr);
	return (scan->ptr == scan->current.text.ptr) ? 0 : 1;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:62

utf8lite_graphscan_make typed empty return

[*struct utf8lite_graphscan, c_null] | [c_null, *struct utf8lite_text] -> empty
timing: 0.053 s
source
void utf8lite_graphscan_make(struct utf8lite_graphscan *scan,
			     const struct utf8lite_text *text)
{
	utf8lite_text_iter_make(&scan->iter, text);
	utf8lite_graphscan_reset(scan);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:34

utf8lite_graphscan_reset typed empty return

[c_null] -> empty
timing: 4.73 s
source
void utf8lite_graphscan_reset(struct utf8lite_graphscan *scan)
{
	utf8lite_text_iter_reset(&scan->iter);
	scan->current.text.ptr = (uint8_t *)scan->iter.ptr;
	scan->current.text.attr = (scan->iter.text_attr
				   & ~UTF8LITE_TEXT_SIZE_MASK);
	NEXT();
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:42

utf8lite_graphscan_retreat typed

([c_null] -> empty)&([*struct utf8lite_graphscan] \ [c_null] -> c_int_na)
timing: 0.237 s
source
int utf8lite_graphscan_retreat(struct utf8lite_graphscan *scan)
{
	struct utf8lite_text_iter prev;
	int prop;

	// see if there is a previous character
	prev = scan->iter;
	if (!utf8lite_text_iter_retreat(&prev)) {
		// already at the start
		return 0;
	}

	// if so, start of current grapheme becomes end of previous
	scan->current.text.attr = (scan->iter.text_attr
				   & ~UTF8LITE_TEXT_SIZE_MASK);
	scan->ptr = scan->current.text.ptr;

	// position iter after the last character, prev before
	while (prev.ptr != scan->ptr) {
		scan->iter = prev;
		utf8lite_text_iter_retreat(&prev);
	}

	// update iterator property
	if (scan->iter.current < 0) {
		scan->prop = -1;
	} else {
		scan->prop = graph_break(scan->iter.current);
	}

	if (prev.current < 0) {
		prop = -1;
	} else {
		prop = graph_break(prev.current);
	}

Start:
	// at the start of the text
	if (prop < 0) {
		goto Break;
	}

	switch ((enum graph_break_prop)prop) {
	case GRAPH_BREAK_CONTROL:
	case GRAPH_BREAK_CR:
		// GB4: Break after controls
		PREV();
		goto Break;

	case GRAPH_BREAK_LF:
		PREV();
		goto LF;

	case GRAPH_BREAK_L:
	case GRAPH_BREAK_LV:
	case GRAPH_BREAK_LVT:
		PREV();
		goto L;

	case GRAPH_BREAK_V:
		PREV();
		goto V;

	case GRAPH_BREAK_T:
		PREV();
		goto T;

	case GRAPH_BREAK_EXTEND:
	case GRAPH_BREAK_SPACINGMARK:
	case GRAPH_BREAK_ZWJ:
		PREV();
		goto Extend;

	case GRAPH_BREAK_EXTENDED_PICTOGRAPHIC:
		PREV();
		goto Extended_Pictographic;

	case GRAPH_BREAK_REGIONAL_INDICATOR:
		PREV();
		goto Regional_Indicator;

	case GRAPH_BREAK_PREPEND:
	case GRAPH_BREAK_OTHER:
		PREV();
		goto MaybeBreak;
	}
	assert(0 && "unhandled graph break property");

LF:
	// GB3: Do not break between a CR and LF
	// GB4: Otherwise, break after controls.
	if (prop == GRAPH_BREAK_CR) {
		PREV();
	}
	goto Break;

L:
	// GB6: Do not break Hangul syllable sequences
	switch (prop) {
	case GRAPH_BREAK_L:
		PREV();
		goto L;

	default:
		goto MaybeBreak;
	}

V:
	// GB6, GB7: Do not break Hangul syllable sequences
	switch (prop) {
	case GRAPH_BREAK_V:
		PREV();
		goto V;

	case GRAPH_BREAK_L:
	case GRAPH_BREAK_LV:
		PREV();
		goto L;

	default:
		goto MaybeBreak;
	}

T:
	// GB6, GB7, GB8: Do not break Hangul syllable sequences
	switch (prop) {
	case GRAPH_BREAK_LV:
	case GRAPH_BREAK_LVT:
		PREV();
		goto L;

	case GRAPH_BREAK_V:
		PREV();
		goto V;

	case GRAPH_BREAK_T:
		PREV();
		goto T;

	default:
		goto MaybeBreak;
	}

Extend:
	switch (prop) {
	// GB4: Break after controls
	case GRAPH_BREAK_CONTROL:
	case GRAPH_BREAK_CR:
	case GRAPH_BREAK_LF:
		goto Break;

	// GB9: Do not break before extending characters or ZWJ.
	// GB9a: Do not break before SpacingMarks
	default:
		goto Start;
	}

Extended_Pictographic:
    // GB11: Do not break within emoji modifier sequences or
    // emoji zwj sequences.
	if (prop == GRAPH_BREAK_ZWJ && follows_extended_pictographic(&prev)) {
        PREV(); // ZWJ
		while (prop == GRAPH_BREAK_EXTEND) { // Extend*
			PREV();
		}

        PREV();
        goto Extended_Pictographic;
	}
    goto MaybeBreak;

Regional_Indicator:
	// GB12, GB13: Do not break within emoji flag sequences
	if (prop == GRAPH_BREAK_REGIONAL_INDICATOR) {
		if (regional_indicator_odd(&prev)) {
			PREV();
		}
	}
	goto MaybeBreak;

MaybeBreak:
	switch (prop) {
	// GB9b: Do not break after Prepend characters
	case GRAPH_BREAK_PREPEND:
		PREV();
		goto MaybeBreak;

	default:
		goto Break;
	}

Break:
	scan->current.text.ptr = (uint8_t *)prev.ptr;
	scan->current.text.attr |= (size_t)(scan->ptr - scan->current.text.ptr);
	return (scan->ptr == scan->current.text.ptr) ? 0 : 1;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:284

utf8lite_graphscan_skip typed empty return

[c_null] -> empty
timing: 4.64 s
source
void utf8lite_graphscan_skip(struct utf8lite_graphscan *scan)
{
	utf8lite_text_iter_skip(&scan->iter);
	scan->current.text.ptr = (uint8_t *)scan->iter.ptr;
	scan->current.text.attr = (scan->iter.text_attr
				   & ~UTF8LITE_TEXT_SIZE_MASK);
	scan->prop = -1;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/graphscan.c:52

UTF8LITE_IS_ASCII typed any: arg 1

tuple1 -> c_bool
timing: 0.003 s
(definition not located in src/)

UTF8LITE_IS_UTF16_HIGH typed

[c_int_na] -> c_bool
timing: 0.005 s
(definition not located in src/)

UTF8LITE_IS_UTF16_LOW typed

[c_int_na] -> c_bool
timing: 0.004 s
(definition not located in src/)

utf8lite_isignorable typed

[c_int] -> c_bool
timing: 0.006 s
source
int utf8lite_isignorable(int32_t code)
{
    int prop = utf8lite_charwidth(code);
    return (prop == UTF8LITE_CHARWIDTH_IGNORABLE);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/char.c:81

utf8lite_message_append typed

[c_null, c_string] -> ()
timing: 0.153 s
source
void utf8lite_message_append(struct utf8lite_message *msg,
			     const char *fmt, ...)
{
	size_t n, nmax;
	va_list ap;
	       
	if (msg) {
		nmax = sizeof(msg->string);
		n = strlen(msg->string);
		assert(n <= nmax);

		va_start(ap, fmt);
		vsnprintf(msg->string + n, nmax - n, fmt, ap);
		va_end(ap);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/error.c:45

utf8lite_message_set typed

[c_null, c_string] -> ()
timing: 0.020 s
source
void utf8lite_message_set(struct utf8lite_message *msg,
			  const char *fmt, ...)
{
	va_list ap;

	if (msg) {
		va_start(ap, fmt);
		vsnprintf(msg->string, sizeof(msg->string), fmt, ap);
		va_end(ap);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/error.c:32

utf8lite_order typed

[*c_int, c_int_na] -> ()
timing: 7.15 s
source
void utf8lite_order(int32_t *ptr, size_t len)
{
	int32_t *end = ptr + len;
	int32_t *c_begin, *c_end, *c_tail, *c_ptr;
	int32_t code, code_prev;
	int32_t cl, cl_prev;

	while (ptr != end) {
		c_begin = ptr;
		code = *ptr++;
		cl = combining_class(code);

		// skip to the next combining mark
		if (cl == 0) {
			continue;
		}

		// It takes 21 bits to encode a codepoint and 8 bits
		// to encode c combining class.
		// Mark the start of the combining mark sequence (c_begin)
		// encode the combining class in bits 22-29.
		*c_begin = code | (cl << UTF8LITE_CODE_BITS);

		// the combining mark sequence ends at the first starter
		// (c_end)
		c_end = ptr;
		while (c_end != end) {
			// until we hit a non-starter, encode the combining
			// class in the high 8 bits of the code
			code = *ptr++;
			cl = combining_class(code);
			if (cl == 0) {
				break;
			}

			*c_end = code | (cl << UTF8LITE_CODE_BITS);
			c_end++;
		}

		// sort the combining marks, using insertion sort (stable)
		for (c_tail = c_begin + 1; c_tail != c_end; c_tail++) {
			c_ptr = c_tail;
			code = *c_ptr;
			cl = code & (0xFF << UTF8LITE_CODE_BITS);

			while (c_ptr != c_begin) {
				code_prev = c_ptr[-1];
				cl_prev = (code_prev
					   & (0xFF << UTF8LITE_CODE_BITS));

				if (cl_prev <= cl) {
					break;
				}

				// swap with previous item
				c_ptr[0] = code_prev;

				// move down
				c_ptr--;
			}

			// complete the final swap
			*c_ptr = code;
		}

		// remove the combining mark annotations
		while (c_begin != c_end) {
			code = *c_begin;
			*c_begin = code & (~(0xFF << UTF8LITE_CODE_BITS));
			c_begin++;
		}
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:146

utf8lite_render_ascii typed

([*struct utf8lite_render, c(127)] | [*struct utf8lite_render, c_int_na \ c(127)] -> c_int_na)&([c_null, c(127)] | [c_null, c_int_na \ c(127)] -> empty)
timing: 1.81 s
source
static int utf8lite_render_ascii(struct utf8lite_render *r, int32_t ch)
{
	if ((ch <= 0x1F || ch == 0x7F)
			&& (r->flags & UTF8LITE_ESCAPE_CONTROL)) {
		return utf8lite_escape_ascii(r, ch);
	}

	switch (ch) {
	case '\"':
		if (r->flags & UTF8LITE_ESCAPE_DQUOTE) {
			return utf8lite_escape_ascii(r, ch);
		}
		break;
	case '\'':
		if (r->flags & UTF8LITE_ESCAPE_SQUOTE) {
			return utf8lite_escape_ascii(r, ch);
		}
		break;
	case '\\':
		if (r->flags & (UTF8LITE_ESCAPE_CONTROL
					| UTF8LITE_ESCAPE_DQUOTE
					| UTF8LITE_ESCAPE_SQUOTE
					| UTF8LITE_ESCAPE_EXTENDED
					| UTF8LITE_ESCAPE_UTF8)) {
			return utf8lite_escape_ascii(r, ch);
		}
		break;
	default:
		break;
	}

	utf8lite_render_grow(r, 1);
	CHECK_ERROR(r);

	r->string[r->length++] = (char)ch;
	r->string[r->length] = '\0';
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:391

utf8lite_render_char typed

([*struct utf8lite_render, c_int_na] -> c_int_na)&([c_null, c_int_na] -> empty)
timing: 0.051 s
source
int utf8lite_render_char(struct utf8lite_render *r, int32_t ch)
{
	uint8_t buf[5];
	uint8_t *ptr = buf;

	// decode to string, then render. 'render_string' handles
	// escaping, removing default ignorables, etc. if necessary
	utf8lite_encode_utf8(ch, &ptr);
	*ptr = '\0';
	return utf8lite_render_string(r, (const char *)buf);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:493

utf8lite_render_chars typed

([*struct utf8lite_render, c_int_na, c_int_na] -> c_int_na)&([c_null, c_int_na, c_int_na] -> empty)
timing: 0.299 s
source
int utf8lite_render_chars(struct utf8lite_render *r, int32_t ch, int nchar)
{
	CHECK_ERROR(r);

	while (nchar-- > 0) {
		utf8lite_render_char(r, ch);
		CHECK_ERROR(r);
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:506

utf8lite_render_clear typed

([*struct utf8lite_render] -> ())&([c_null] -> empty)
timing: 0.273 s
source
void utf8lite_render_clear(struct utf8lite_render *r)
{
	r->string[0] = '\0';
	r->length = 0;
	r->indent = 0;
	r->needs_indent = 1;
	r->error = 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:131

utf8lite_render_code typed

([c_null, c_int_na, *c_int_na] -> empty)&([*struct utf8lite_render, c(..65535), *c_int_na] | [*struct utf8lite_render, c(65536..), *c_int_na] | [*struct utf8lite_render, c_int_na \ c(65536..), c_null] -> c_int_na)
timing: 8.27 s
source
int utf8lite_render_code(struct utf8lite_render *r, int32_t ch, int *attrptr)
{
	char *end;
	uint8_t *uend;
	int type;

	CHECK_ERROR(r);

	maybe_indent(r);
	CHECK_ERROR(r);

	// maximum character expansion: \uXXXX\uXXXX
	utf8lite_render_grow(r, 12);
	CHECK_ERROR(r);

	end = r->string + r->length;
	if (UTF8LITE_IS_ASCII(ch)) {
		return utf8lite_render_ascii(r, ch);
	} else if (r->flags & UTF8LITE_ESCAPE_UTF8) {
		return utf8lite_escape_utf8(r, ch);
	}

	if (ch > 0xFFFF) {
		if (r->flags & UTF8LITE_ESCAPE_EXTENDED) {
			return utf8lite_escape_utf8(r, ch);
		} else {
			*attrptr |= CODE_EXTENDED;
		}
	}
	*attrptr |= CODE_UTF8;

	type = utf8lite_charwidth(ch);
	switch (type) {
	case UTF8LITE_CHARWIDTH_NONE:
		if (r->flags & UTF8LITE_ESCAPE_CONTROL) {
			return utf8lite_escape_utf8(r, ch);
		}
		break;

	case UTF8LITE_CHARWIDTH_IGNORABLE:
		if ((r->flags & UTF8LITE_ENCODE_RMDI)
				&& (!(*attrptr & CODE_EMOJI))) {
			return 0;
		}
		break;

	case UTF8LITE_CHARWIDTH_EMOJI:
		*attrptr |= CODE_EMOJI;
		break;

	default:
		break;
	}

	uend = (uint8_t *)end;
	utf8lite_encode_utf8(ch, &uend);
	*uend = '\0';
	r->length += UTF8LITE_UTF8_ENCODE_LEN(ch);
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:431

utf8lite_render_destroy typed

([*struct utf8lite_render] -> ())&([c_null] -> empty)
timing: 0.030 s
source
void utf8lite_render_destroy(struct utf8lite_render *r)
{
	free(r->string);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:125

utf8lite_render_graph typed

([*struct utf8lite_render, c_null] -> c_int_na)&([c_null, *struct utf8lite_graph] -> empty)
timing: 0.214 s
source
int utf8lite_render_graph(struct utf8lite_render *r,
			 const struct utf8lite_graph *g)
{
	struct utf8lite_text_iter it;
	int attr = CODE_ASCII;

	CHECK_ERROR(r);

	utf8lite_text_iter_make(&it, &g->text);
	while (utf8lite_text_iter_advance(&it)) {
		utf8lite_render_code(r, it.current, &attr);
		CHECK_ERROR(r);
	}

	if (attr & CODE_EMOJI && (r->flags & UTF8LITE_ENCODE_EMOJIZWSP)) {
		utf8lite_render_raw(r, "\xE2\x80\x8B", 3); // U+200B, ZWSP
		CHECK_ERROR(r);
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:587

utf8lite_render_grow typed

([c_null, c_int_na] -> empty)&([*struct utf8lite_render, c_int_na] \ [c_null, c_int_na] -> c_int_na)
timing: 1.27 s
source
static int utf8lite_render_grow(struct utf8lite_render *r, int nadd)
{
	void *base = r->string;
	int size = r->length_max + 1;
	int err;

	if (nadd <= 0 || r->length_max - nadd > r->length) {
		return 0;
	}

	if ((err = utf8lite_array_grow(&base, &size, sizeof(*r->string),
				       r->length + 1, nadd))) {
		r->error = err;
		return r->error;
	}

	r->string = base;
	r->length_max = size - 1;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:52

utf8lite_render_init typed

([*struct utf8lite_render, c_int_na] -> c_false)&([c_null, c_int_na] -> empty)
timing: 1.08 s
source
int utf8lite_render_init(struct utf8lite_render *r, int flags)
{
	int err;

	r->string = malloc(1);
	if (!r->string) {
		err = UTF8LITE_ERROR_NOMEM;
		return err;
	}

	r->length = 0;
	r->length_max = 0;
	r->flags = flags;

	r->tab = "\t";
	r->tab_length = (int)strlen(r->tab);

	r->newline = "\n";
	r->newline_length = (int)strlen(r->newline);

	r->style_open = NULL;
	r->style_open_length = 0;
	r->style_close = NULL;
	r->style_close_length = 0;

	utf8lite_render_clear(r);

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:94

utf8lite_render_newlines typed

([*struct utf8lite_render, c_int_na] -> c_int_na)&([c_null, c_int_na] -> empty)
timing: 2.01 s
source
int utf8lite_render_newlines(struct utf8lite_render *r, int nline)
{
	char *end;
	int i;

	CHECK_ERROR(r);

	for (i = 0; i < nline; i++) {
		utf8lite_render_grow(r, r->newline_length);
		CHECK_ERROR(r);

		end = r->string + r->length;
		memcpy(end, r->newline, r->newline_length + 1); // include '\0'
		r->length += r->newline_length;
		r->needs_indent = 1;
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:224

utf8lite_render_raw typed

([*struct utf8lite_render, c_string, c_int_na] -> c_int_na)&([c_null, c_string, c_int_na] -> empty)
timing: 1.08 s
source
int utf8lite_render_raw(struct utf8lite_render *r, const char *bytes,
			size_t size)
{
	if (size > INT_MAX) {
		r->error = UTF8LITE_ERROR_OVERFLOW;
		return r->error;
	}
	utf8lite_render_grow(r, (int)size);
	CHECK_ERROR(r);

	memcpy(r->string + r->length, bytes, size);
	r->length += (int)size;
	r->string[r->length] = '\0';
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:610

utf8lite_render_set_flags typed

[*struct utf8lite_render, c_int_na] -> c_false
timing: 0.025 s
source
int utf8lite_render_set_flags(struct utf8lite_render *r, int flags)
{
	r->flags = flags;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:141

utf8lite_render_set_style typed

([*struct utf8lite_render, c_string, c_string] -> c_int_na)&([c_null, c_string, c_string] -> empty)
timing: 0.524 s
source
int utf8lite_render_set_style(struct utf8lite_render *r,
			      const char *open, const char *close)
{
	size_t open_len = 0, close_len = 0;

	CHECK_ERROR(r);
	if (open) {
		if ((open_len = strlen(open)) >= INT_MAX) {
			r->error = UTF8LITE_ERROR_OVERFLOW;
			return r->error;
		}
	}
	if (close) {
		if ((close_len = strlen(close)) >= INT_MAX) {
			r->error = UTF8LITE_ERROR_OVERFLOW;
			return r->error;
		}
	}
	r->style_open = open;
	r->style_close = close;
	r->style_open_length = (int)open_len;
	r->style_close_length = (int)close_len;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:182

utf8lite_render_string typed

([c_null, c_string] -> empty)&([*struct utf8lite_render, c_string] \ [c_null, c_string] -> c_int_na)
timing: 0.209 s
source
int utf8lite_render_string(struct utf8lite_render *r, const char *str)
{
	struct utf8lite_text text;
	const uint8_t *ptr;
	size_t len;

	CHECK_ERROR(r);

	ptr = (const uint8_t *)str;
	len = strlen(str);
	r->error = utf8lite_text_assign(&text, ptr, len, 0, NULL);
	CHECK_ERROR(r);

	return utf8lite_render_text(r, &text);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:519

utf8lite_render_text typed

([*struct utf8lite_render, c_null] -> c_int_na)&([c_null, *struct utf8lite_text] -> empty)
timing: 0.116 s
source
int utf8lite_render_text(struct utf8lite_render *r,
			 const struct utf8lite_text *text)
{
	struct utf8lite_graphscan scan;

	CHECK_ERROR(r);

	utf8lite_graphscan_make(&scan, text);
	while (utf8lite_graphscan_advance(&scan)) {
		utf8lite_render_graph(r, &scan.current);
		CHECK_ERROR(r);
	}

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/render.c:570

utf8lite_scan_escape typed

([c_null, *c_int_na, *struct utf8lite_message] -> empty)&([*(*c_int_na \ c_null), *c_int_na, c_null] | [*c_null, *c_int_na, c_null] -> c_int_na)
timing: 0.505 s
source
int utf8lite_scan_escape(const uint8_t **bufptr, const uint8_t *end,
			 struct utf8lite_message *msg)
{
	const uint8_t *input = *bufptr;
	const uint8_t *ptr = input;
	uint_fast8_t ch;
	int err;
	
	if (ptr == end) {
		goto error_incomplete;
	}

	ch = *ptr++;

	switch (ch) {
	case '"':
	case '\\':
	case '/':
	case 'b':
	case 'f':
	case 'n':
	case 'r':
	case 't':
		break;
	case 'u':
		if ((err = utf8lite_scan_uescape(&ptr, end, msg))) {
			goto out;
		}
		break;
	default:
		goto error_inval;
	}

	err = 0;
	goto out;

error_incomplete:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "incomplete escape code (\\)");
	goto out;

error_inval:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "invalid escape code (\\%c)", ch);
	goto out;

out:
	*bufptr = ptr;
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/escape.c:23

utf8lite_scan_uescape typed

([*c_null, *c_int_na, c_null] -> c_int_na)&([c_null, *c_int_na, c_null] -> empty)
timing: 2.48 s
source
int utf8lite_scan_uescape(const uint8_t **bufptr, const uint8_t *end,
			  struct utf8lite_message *msg)
{
	const uint8_t *input = *bufptr;
	const uint8_t *ptr = input;
	int32_t code, low;
	uint_fast8_t ch;
	unsigned i;
	int err;

	if (ptr + 4 > end) {
		goto error_inval_incomplete;
	}

	code = 0;
	for (i = 0; i < 4; i++) {
		ch = *ptr++;
		if (!isxdigit(ch)) {
			goto error_inval_hex;
		}
		code = (code << 4) + hextoi(ch);
	}

	if (UTF8LITE_IS_UTF16_HIGH(code)) {
		if (ptr + 6 > end || ptr[0] != '\\' || ptr[1] != 'u') {
			goto error_inval_nolow;
		}
		ptr += 2;
		input = ptr;

		low = 0;
		for (i = 0; i < 4; i++) {
			ch = *ptr++;
			if (!isxdigit(ch)) {
				goto error_inval_hex;
			}
			low = (low << 4) + hextoi(ch);
		}
		if (!UTF8LITE_IS_UTF16_LOW(low)) {
			ptr -= 6;
			goto error_inval_low;
		}
	} else if (UTF8LITE_IS_UTF16_LOW(code)) {
		goto error_inval_nohigh;
	}

	err = 0;
	goto out;

error_inval_incomplete:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "incomplete escape code (\\u%.*s)",
			     (int)(end - input), input);
	goto out;

error_inval_hex:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "invalid hex value in escape code (\\u%.*s)",
			     4, input);
	goto out;

error_inval_nolow:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "missing UTF-16 low surrogate"
			     " after high surrogate escape code (\\u%.*s)",
			     4, input);
	goto out;

error_inval_low:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "invalid UTF-16 low surrogate (\\u%.*s)"
			     " after high surrogate escape code (\\u%.*s)",
			     4, input, 4, input - 6);
	goto out;

error_inval_nohigh:
	err = UTF8LITE_ERROR_INVAL;
	utf8lite_message_set(msg, "missing UTF-16 high surrogate"
			     " before low surrogate escape code (\\u%.*s)",
			     4, input);
	goto out;

out:
	*bufptr = ptr;
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/escape.c:75

utf8lite_text_isascii typed

([*struct utf8lite_text] -> c_bool)&([c_null] -> empty)
timing: 0.059 s
source
int utf8lite_text_isascii(const struct utf8lite_text *text)
{
	struct utf8lite_text_iter it;

	utf8lite_text_iter_make(&it, text);
	while (utf8lite_text_iter_advance(&it)) {
		if (!UTF8LITE_IS_ASCII(it.current)) {
			return 0;
		}
	}
	return 1;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/text.c:51

utf8lite_text_iter_advance typed

([c_null] -> empty)&([*struct utf8lite_text_iter] \ [c_null] -> c_int_na)
timing: 1.17 s
source
int utf8lite_text_iter_advance(struct utf8lite_text_iter *it)
{
	const uint8_t *ptr = it->ptr;
	size_t text_attr = it->text_attr;
	int32_t code;

	if (it->ptr == it->end) {
		goto at_end;
	}

	code = *ptr++;

	if (code == '\\' && (text_attr & UTF8LITE_TEXT_ESC_BIT)) {
		utf8lite_decode_escape(&ptr, &code);
	} else if (code >= 0x80) {
		ptr--;
		utf8lite_decode_utf8(&ptr, &code);
	}

	it->ptr = ptr;
	it->current = code;
	return 1;

at_end:
	it->current = UTF8LITE_CODE_NONE;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:37

utf8lite_text_iter_make typed

([*struct utf8lite_text_iter, *struct utf8lite_text] -> ())&([*struct utf8lite_text_iter, c_null] | [c_null, *struct utf8lite_text] -> empty)
timing: 3.33 s
source
void utf8lite_text_iter_make(struct utf8lite_text_iter *it,
			   const struct utf8lite_text *text)
{
	it->ptr = text->ptr;
	it->end = it->ptr + UTF8LITE_TEXT_SIZE(text);
	it->text_attr = text->attr;
	it->current = UTF8LITE_CODE_NONE;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:27

utf8lite_text_iter_skip typed

([*struct utf8lite_text_iter] -> ())&([c_null] -> empty)
timing: 0.652 s
source
void utf8lite_text_iter_skip(struct utf8lite_text_iter *it)
{
	it->ptr = it->end;
	it->current = UTF8LITE_CODE_NONE;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:66

utf8lite_textmap_clear_type typed

([*struct utf8lite_textmap] -> ())&([c_null] -> empty)
timing: 0.312 s
source
void utf8lite_textmap_clear_type(struct utf8lite_textmap *map)
{
	uint_fast8_t ch;

	map->charmap_type = UTF8LITE_DECOMP_NORMAL | UTF8LITE_CASEFOLD_NONE;

	for (ch = 0; ch < 0x80; ch++) {
		map->ascii_map[ch] = (int8_t)ch;
	}

	map->type = 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:59

utf8lite_textmap_destroy typed

([*struct utf8lite_textmap] -> ())&([c_null] -> empty)
timing: 0.084 s
source
void utf8lite_textmap_destroy(struct utf8lite_textmap *map)
{
	free(map->codes);
	free(map->text.ptr);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:52

utf8lite_textmap_init typed

([*struct utf8lite_textmap, c_int_na] -> c_int_na)&([c_null, c_int_na] -> empty)
timing: 1.92 s
source
int utf8lite_textmap_init(struct utf8lite_textmap *map, int type)
{
	int err;

	map->text.ptr = NULL;
	map->text.attr = 0;
	map->codes = NULL;
	map->size_max = 0;

	utf8lite_textmap_clear_type(map);
	err = utf8lite_textmap_set_type(map, type);
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:37

utf8lite_textmap_reserve typed

([c_null, c_int_na] -> empty)&([*struct utf8lite_textmap, c_int_na] \ [c_null, c_int_na] -> c_int_na)
timing: 1.76 s
source
int utf8lite_textmap_reserve(struct utf8lite_textmap *map, size_t size)
{
	uint8_t *ptr = map->text.ptr;
	int32_t *codes = map->codes;

	if (map->size_max >= size) {
		return 0;
	}

	if (!(ptr = realloc(ptr, size))) {
		return UTF8LITE_ERROR_NOMEM;
	}
	map->text.ptr = ptr;

	if (size > SIZE_MAX / UTF8LITE_UNICODE_DECOMP_MAX) {
		return UTF8LITE_ERROR_OVERFLOW;
	}

	if (!(codes = realloc(codes, size * UTF8LITE_UNICODE_DECOMP_MAX))) {
		return UTF8LITE_ERROR_NOMEM;
	}
	map->codes = codes;

	map->size_max = size;
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:101

utf8lite_textmap_set typed

([*struct utf8lite_textmap, c_null] -> empty)&([*struct utf8lite_textmap, *struct utf8lite_text] \ [*struct utf8lite_textmap, c_null] -> c_int_na)
timing: 0.080 s
source
int utf8lite_textmap_set(struct utf8lite_textmap *map,
		       const struct utf8lite_text *text)
{
	struct utf8lite_text_iter it;
	size_t size = UTF8LITE_TEXT_SIZE(text);
	int32_t *dst;
	int err;

	if (utf8lite_text_isascii(text)) {
		return utf8lite_textmap_set_ascii(map, text);
	}

	// For most inputs, mapping to type reduces or preserves the size.
	// However, for U+0390 and U+03B0, case folding triples the size.
	// (You can verify this with util/compute-typelen.py)
	//
	// Add one for a trailing NUL.
	if (size > ((SIZE_MAX - 1) / 3)) {
		err = UTF8LITE_ERROR_OVERFLOW;
		goto out;
	}

	if ((err = utf8lite_textmap_reserve(map, 3 * size + 1))) {
		goto out;
	}

	dst = map->codes;
	utf8lite_text_iter_make(&it, text);
	while (utf8lite_text_iter_advance(&it)) {
		utf8lite_map(map->charmap_type, it.current, &dst);
	}

	size = (size_t)(dst - map->codes);
	utf8lite_order(map->codes, size);
	utf8lite_compose(map->codes, &size);

	if ((err = utf8lite_textmap_set_utf32(map, map->codes,
					      map->codes + size))) {
		goto out;
	}

out:
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:129

utf8lite_textmap_set_type typed

([c_null, c_int_na] -> empty)&([*struct utf8lite_textmap, c_int_na] \ [c_null, c_int_na] -> c_int_na)
timing: 0.163 s
source
int utf8lite_textmap_set_type(struct utf8lite_textmap *map, int type)
{
	int_fast8_t ch;

	if (map->type == type) {
		return 0;
	}

	utf8lite_textmap_clear_type(map);

	if (type & UTF8LITE_TEXTMAP_CASE) {
		for (ch = 'A'; ch <= 'Z'; ch++) {
			map->ascii_map[ch] = ch + ('a' - 'A');
		}

		map->charmap_type |= UTF8LITE_CASEFOLD_ALL;
	}

	if (type & UTF8LITE_TEXTMAP_COMPAT) {
		map->charmap_type = UTF8LITE_DECOMP_ALL;
	}

	map->type = type;

	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:73

UTF8LITE_UTF16_HIGH typed any: arg 1

tuple1 -> c_int
timing: 0.008 s
(definition not located in src/)

UTF8LITE_UTF16_LOW typed any: arg 1

tuple1 -> c_int
timing: 0.007 s
(definition not located in src/)

UTF8LITE_UTF8_ENCODE_LEN typed any: arg 1

tuple1 -> c(1..4)
timing: 0.008 s
(definition not located in src/)

UTF8LITE_UTF8_TAIL_LEN typed

[c_int_na] -> c(0..3)
timing: 0.010 s
(definition not located in src/)

width typed

([c_null] -> empty)&([*struct utf8lite_text] \ [c_null] -> c_int_na)
timing: 0.023 s
source
static int width(const struct utf8lite_text *text)
{
	struct utf8lite_graphscan scan;
	int width, w;

	width = 0;
	utf8lite_graphscan_make(&scan, text);
	while (utf8lite_graphscan_advance(&scan)) {
		ck_assert(!utf8lite_graph_measure(&scan.current,
						  render.flags, &w));
		if (w == -1) {
			return w;
		}
		ck_assert(w >= 0);
		ck_assert(width <= INT_MAX - w);
		width += w;
	}

	return width;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/tests/check_render.c:84

alloc C signature

[c_int_na] --> c_ptr
untypeable coercion
error detail
expected: *c_ptr
given: c_ptr
timing: 0.027 s
source
void *alloc(size_t size)
{
	void *ptr;

	allocs = realloc(allocs, (size_t)(nalloc + 1) * sizeof(*allocs));
	ck_assert(allocs != NULL);

	ptr = malloc(size);
	ck_assert(ptr != NULL || size == 0);

	allocs[nalloc] = ptr;
	nalloc++;

	return ptr;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/tests/testutil.c:47

context_init C signature

[*struct context, any_sexp, any_sexp, any_sexp, any_sexp] --> c_void
untypeable application
error detail
function: ([*('I43763 \ c_string)] --> 'I43763) & ([c_null] --> empty) & ([c_string] --> c_char)
argument: [c_int_na | 'I43685]
timing: 4.20 s
source
static void context_init(struct context *ctx, SEXP map_case, SEXP map_compat,
			 SEXP map_quote, SEXP remove_ignorable)
{
	int err = 0, type;

	type = UTF8LITE_TEXTMAP_NORMAL;

	if (LOGICAL(map_case)[0] == TRUE) {
		type |= UTF8LITE_TEXTMAP_CASE;
	}

	if (LOGICAL(map_compat)[0] == TRUE) {
		type |= UTF8LITE_TEXTMAP_COMPAT;
	}

	if (LOGICAL(map_quote)[0] == TRUE) {
		type |= UTF8LITE_TEXTMAP_QUOTE;
	}

	if (LOGICAL(remove_ignorable)[0] == TRUE) {
		type |= UTF8LITE_TEXTMAP_RMDI;
	}

	TRY(utf8lite_textmap_init(&ctx->map, type));
	ctx->has_map = 1;
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_normalize.c:29

get_map C signature

[*struct utf8lite_text, c_int_na] --> *struct utf8lite_text
unbound variable
error detail
name: ck_assert
timing: 0.019 s
source
struct utf8lite_text *get_map(const struct utf8lite_text *text, int flags)
{
	struct utf8lite_text *val;
	struct utf8lite_textmap map;
	size_t size;

	ck_assert(!utf8lite_textmap_init(&map, flags));
	ck_assert(!utf8lite_textmap_set(&map, text));

	size = UTF8LITE_TEXT_SIZE(&map.text);
	val = alloc(sizeof(*val));

	val->ptr = alloc(size + 1);
	memcpy(val->ptr, map.text.ptr, size);
	val->ptr[size] = '\0';
	val->attr = map.text.attr;

	utf8lite_textmap_destroy(&map);
	return val;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/tests/check_textmap.c:30

NEXT C signature

() --> any
unbound variable
error detail
name: scan
timing: 0.016 s
(definition not located in src/)

render_range C signature

[*struct utf8lite_render, *struct style, any_sexp, any_sexp, c_int_na, c_int_na, c_int_na, c_int_na, c_int_na, *c_int_na] --> c_int_na
untypeable application
error detail
function: [{ 'I47987 }, c_int] --> 'I47987
argument: [list | null, c_false]
timing: 0.207 s
source
static int render_range(struct utf8lite_render *r, const struct style *s,
			SEXP sx, SEXP na_print, int begin, int end,
			int print_gap, int max, int namewidth,
			const int *colwidths)
{
	SEXP elt, name, dim_names, row_names, col_names;
	R_xlen_t ix;
	int i, j, nrow, nprint, width;
	int err = 0, nprot = 0;

	PROTECT(dim_names = getAttrib(sx, R_DimNamesSymbol)); nprot++;
	row_names = VECTOR_ELT(dim_names, 0);
	col_names = VECTOR_ELT(dim_names, 1);
	nrow = nrows(sx);
	nprint = 0;

	if (col_names != R_NilValue) {
		TRY(utf8lite_render_chars(r, ' ', namewidth));

		for (j = begin; j < end; j++) {
			PROTECT(name = STRING_ELT(col_names, j)); nprot++;
			assert(name != NA_STRING);

			if (j > begin || row_names != R_NilValue) {
				TRY(utf8lite_render_chars(r, ' ', print_gap));
			}
			render_name(r, s, name, colwidths[j]);
			UNPROTECT(1); nprot--;
		}
		TRY(utf8lite_render_newlines(r, 1));
	}

	for (i = 0; i < nrow; i++) {
		CHECK_INTERRUPT(i);

		if (nprint == max) {
			goto exit;
		}

		if (row_names != R_NilValue) {
			PROTECT(name = STRING_ELT(row_names, i)); nprot++;
			assert(name != NA_STRING);
			render_rowname(r, s, name, namewidth);
			UNPROTECT(1); nprot--;
		}

		for (j = begin; j < end; j++) {
			if (nprint == max) {
				TRY(utf8lite_render_newlines(r, 1));
				goto exit;
			}
			nprint++;

			if (j > begin || row_names != R_NilValue) {
				TRY(utf8lite_render_chars(r, ' ', print_gap));
			}

			width = colwidths[j];
			ix = (R_xlen_t)i + (R_xlen_t)j * (R_xlen_t)nrow;
			PROTECT(elt = STRING_ELT(sx, ix)); nprot++;
			if (elt == NA_STRING) {
				render_na(r, s, na_print, width);
			} else {
				render_entry(r, s, elt, width);
			}
			UNPROTECT(1); nprot--;
		}

		TRY(utf8lite_render_newlines(r, 1));
	}
exit:
	UNPROTECT(nprot);
	CHECK_ERROR(err);
	return nprint;
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:172

rutf8_alloc_context C signature

[c_int_na, [c_ptr] --> c_void] --> any_sexp
unbound variable
error detail
name: CONTEXT_TAG
timing: 0.028 s
source
SEXP rutf8_alloc_context(size_t size, void (*destroy_func)(void *))
{
	SEXP ans;
	struct context *ctx = NULL;
	void *obj = NULL;
	int err = 0;

	PROTECT(ans = R_MakeExternalPtr(NULL, CONTEXT_TAG, R_NilValue));
        R_RegisterCFinalizerEx(ans, rutf8_free_context, TRUE);

	TRY_ALLOC(obj = calloc(1, size == 0 ? 1 : size));
	TRY_ALLOC(ctx = calloc(1, sizeof(*ctx)));

	ctx->data = obj;
	ctx->destroy_func = destroy_func;
        R_SetExternalPtrAddr(ans, ctx);
	ctx = NULL;
	obj = NULL;
exit:
	free(ctx);
	free(obj);
	CHECK_ERROR(err);
	UNPROTECT(1);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/context.c:46

rutf8_alloc_render C signature

[c_int_na] --> any_sexp
unbound variable
error detail
name: RENDER_TAG
timing: 0.022 s
source
SEXP rutf8_alloc_render(int flags)
{
	SEXP ans;
	struct rutf8_render *obj;
	int err = 0;

	PROTECT(ans = R_MakeExternalPtr(NULL, RENDER_TAG, R_NilValue));
        R_RegisterCFinalizerEx(ans, rutf8_free_render, TRUE);

	TRY_ALLOC(obj = calloc(1, sizeof(*obj)));
        R_SetExternalPtrAddr(ans, obj);

	TRY(utf8lite_render_init(&obj->render, flags));
	obj->has_render = 1;
exit:
	CHECK_ERROR(err);
	UNPROTECT(1);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/render.c:42

utf8lite_map C signature

[c_int_na, c_int_na, *(*c_int_na)] --> c_void
untypeable application
error detail
function: [*struct utf8lite_text] --> *struct utf8lite_text
argument: [c_int_na & 'I42670, c_int & 'I42671, *(*c_int_na) & 'I42672]
timing: 0.170 s
source
void utf8lite_map(int type, int32_t code, int32_t **bufptr)
{
	const int32_t block_size = DECOMPOSITION_BLOCK_SIZE;
	unsigned i = decomposition_stage1[code / block_size];
	struct decomposition d = decomposition_stage2[i][code % block_size];
	unsigned length = d.length;
	const int32_t *src;
	int32_t *dst;

	if (length == 0 || (d.type > 0 && !(type & (1 << (d.type - 1))))) {
		if (type & UTF8LITE_CASEFOLD_ALL) {
			casefold(type, code, bufptr);
		} else {
			dst = *bufptr;
			*dst++ = code;
			*bufptr = dst;
		}
	} else if (length == 1) {
		utf8lite_map(type, d.data, bufptr);
	} else if (d.type >= 0) {
		src = &decomposition_mapping[d.data];
		while (length-- > 0) {
			utf8lite_map(type, *src, bufptr);
			src++;
		}
	} else {
		hangul_decompose(code, bufptr);
	}
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/normalize.c:115

utf8lite_text_assign C signature

[*struct utf8lite_text, *c_int_na, c_int_na, c_int_na, *struct utf8lite_message] --> c_int_na
unbound variable
error detail
name: UTF8LITE_TEXT_SIZE_MASK
timing: 0.017 s
source
int utf8lite_text_assign(struct utf8lite_text *text, const uint8_t *ptr,
			 size_t size, int flags, struct utf8lite_message *msg)
{
	int err = 0;

	if (size > UTF8LITE_TEXT_SIZE_MAX) {
		err = UTF8LITE_ERROR_OVERFLOW;
		utf8lite_message_set(msg, "text size (%"PRIu64" bytes)"
				     " exceeds maximum (%"PRIu64" bytes)",
				     (uint64_t)size,
				     (uint64_t)UTF8LITE_TEXT_SIZE_MAX);
	} else if (flags & UTF8LITE_TEXT_UNESCAPE) {
		if (flags & UTF8LITE_TEXT_VALID) {
			assign_esc_unsafe(text, ptr, size);
		} else {
			err = assign_esc(text, ptr, size, msg);
		}
	} else {
		if (flags & UTF8LITE_TEXT_VALID) {
			assign_raw_unsafe(text, ptr, size);
		} else {
			err = assign_raw(text, ptr, size, msg);
		}
	}

	if (err) {
		text->ptr = NULL;
		text->attr = 0;
	}

	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textassign.c:37

utf8lite_text_iter_reset C signature

[*struct utf8lite_text_iter] --> c_void
unbound variable
error detail
name: UTF8LITE_TEXT_SIZE_MASK
timing: 0.078 s
source
void utf8lite_text_iter_reset(struct utf8lite_text_iter *it)
{
	const size_t size = (it->text_attr & UTF8LITE_TEXT_SIZE_MASK);
	const uint8_t *begin = it->end - size;

	it->ptr = begin;
	it->current = UTF8LITE_CODE_NONE;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:121

utf8lite_text_iter_retreat C signature

[*struct utf8lite_text_iter] --> c_int_na
unbound variable
error detail
name: UTF8LITE_TEXT_SIZE_MASK
timing: 0.182 s
source
int utf8lite_text_iter_retreat(struct utf8lite_text_iter *it)
{
	const size_t size = (it->text_attr & UTF8LITE_TEXT_SIZE_MASK);
	const uint8_t *begin = it->end - size;
	const uint8_t *ptr = it->ptr;
	const uint8_t *end = it->end;
	int32_t code = it->current;

	if (ptr == begin) {
		return 0;
	}

	if (it->text_attr & UTF8LITE_TEXT_ESC_BIT) {
		iter_retreat_escaped(it, begin);
	} else {
		iter_retreat_raw(it);
	}

	// we were at the end of the text
	if (code == UTF8LITE_CODE_NONE) {
		it->ptr = end;
		return 1;
	}

	// at this point, it->code == code, and it->ptr is the code start
	ptr = it->ptr;

	if (ptr == begin) {
		it->current = UTF8LITE_CODE_NONE;
		return 0;
	}

	// read the previous code
	if (it->text_attr & UTF8LITE_TEXT_ESC_BIT) {
		iter_retreat_escaped(it, begin);
	} else {
		iter_retreat_raw(it);
	}

	// now, it->code is the previous code, and it->ptr is the start
	// of the previous code

	// set the pointer to the end of the previous code
	it->ptr = ptr;
	return 1;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textiter.c:73

UTF8LITE_TEXT_SIZE C signature

tuple1 --> any
unbound variable
error detail
name: UTF8LITE_TEXT_SIZE_MASK
timing: 0.014 s
(definition not located in src/)

utf8lite_textmap_set_ascii C signature

[*struct utf8lite_textmap, *struct utf8lite_text] --> c_int_na
unbound variable
error detail
name: SIZE_MAX
timing: 0.087 s
source
int utf8lite_textmap_set_ascii(struct utf8lite_textmap *map,
			       const struct utf8lite_text *text)
{
	struct utf8lite_text_iter it;
	size_t size = UTF8LITE_TEXT_SIZE(text);
	int8_t ch;
	uint8_t *dst;
	int err;

	assert(size < SIZE_MAX);

	if ((err = utf8lite_textmap_reserve(map, size + 1))) {
		goto error;
	}

	dst = map->text.ptr;

	utf8lite_text_iter_make(&it, text);
	while (utf8lite_text_iter_advance(&it)) {
		ch = map->ascii_map[it.current];
		if (ch >= 0) {
			*dst++ = (uint8_t)ch;
		}
	}

	*dst = '\0'; // not necessary, but helps with debugging
	map->text.attr = (UTF8LITE_TEXT_SIZE_MASK
			  & ((size_t)(dst - map->text.ptr)));
	return 0;

error:
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:222

rutf8_render_table untypeable entry .Call

untypeable application
error detail
function: [{ 'I48174 }, c_int] --> 'I48174
argument: [list | null, c_false]
timing: 0.185 s
source
SEXP rutf8_render_table(SEXP sx, SEXP swidth, SEXP squote, SEXP sna_print,
			SEXP sprint_gap, SEXP sright, SEXP smax,
			SEXP snames, SEXP srownames, SEXP sescapes,
			SEXP sdisplay, SEXP sstyle, SEXP sutf8,
			SEXP slinewidth)
{
	SEXP ans, na_print, str, srender, elt, dim_names, row_names, col_names;
	struct utf8lite_render *render;
	struct style s;
	R_xlen_t ix, nx;
	int i, j, nrow, ncol;
	int width, quote, print_gap, max, display, style, linewidth, utf8;
	int begin, end, w, nprint, lw, namewidth, *colwidths;
	int nprot = 0;

	memset(&s, 0, sizeof(s));

	PROTECT(dim_names = getAttrib(sx, R_DimNamesSymbol)); nprot++;
	row_names = VECTOR_ELT(dim_names, 0);
	col_names = VECTOR_ELT(dim_names, 1);
	nrow = nrows(sx);
	ncol = ncols(sx);
	nx = XLENGTH(sx);

	width = INTEGER(swidth)[0];
        quote = LOGICAL(squote)[0] == TRUE;
	PROTECT(na_print = STRING_ELT(sna_print, 0)); nprot++;
	print_gap = INTEGER(sprint_gap)[0];
	s.right = LOGICAL(sright)[0] == TRUE;
	max = INTEGER(smax)[0];
	display = LOGICAL(sdisplay)[0] == TRUE;
	style = LOGICAL(sstyle)[0] == TRUE;
	utf8 = LOGICAL(sutf8)[0] == TRUE;
	linewidth = INTEGER(slinewidth)[0];

	s.flags.entry = (UTF8LITE_ESCAPE_CONTROL | UTF8LITE_ENCODE_C);
	if (quote) {
		s.flags.entry |= UTF8LITE_ESCAPE_DQUOTE;
	}
        if (display) {
                s.flags.entry |= UTF8LITE_ENCODE_RMDI;
                s.flags.entry |= UTF8LITE_ENCODE_EMOJIZWSP;
        }
	if (style) {
		if ((s.names = rutf8_as_style(snames))) {
			s.names_len = (int)strlen(s.names);
		}
		if ((s.rownames = rutf8_as_style(srownames))) {
			s.rownames_len = (int)strlen(s.rownames);
		}
	}
        if (!utf8) {
                s.flags.entry |= UTF8LITE_ESCAPE_UTF8;
        }
#if defined(_WIN32) || defined(_WIN64)
        s.flags.entry |= UTF8LITE_ESCAPE_EXTENDED;
#endif
	s.flags.na = s.flags.entry & ~UTF8LITE_ESCAPE_DQUOTE;
	s.flags.name = s.flags.na;
	s.flags.rowname = s.flags.name;

	PROTECT(srender = rutf8_alloc_render(0)); nprot++;
	render = rutf8_as_render(srender);

	if (style) {
		if ((s.esc_open = rutf8_as_style(sescapes))) {
			s.esc_close = RUTF8_STYLE_CLOSE;
		}
	}

	namewidth = 0;
	if (row_names == R_NilValue) {
		namewidth = 0;
	} else {
		for (i = 0; i < nrow; i++) {
			CHECK_INTERRUPT(i);

			PROTECT(elt = STRING_ELT(row_names, i)); nprot++;
			assert(elt != NA_STRING);

			w = charsxp_width(elt, s.flags.rowname);
			if (w > namewidth) {
				namewidth = w;
			}

			UNPROTECT(1); nprot--;
		}
	}

	if (ncol == 0) {
		nprint = render_range(render, &s, sx, na_print, 0, 0,
				      print_gap, max, namewidth, NULL);
		goto exit;
	}

	colwidths = (void *)R_alloc(ncol, sizeof(*colwidths));
	for (j = 0; j < ncol; j++) {
		colwidths[j] = width;
	}
	if (col_names != R_NilValue) {
		for (j = 0; j < ncol; j++) {
			PROTECT(elt = STRING_ELT(col_names, j)); nprot++;
			assert(elt != NA_STRING);
			w = charsxp_width(elt, s.flags.name);
			if (w > colwidths[j]) {
				colwidths[j] = w;
			}
			UNPROTECT(1); nprot--;
		}
	}

	j = 0;
	for (ix = 0; ix < nx; ix++) {
		PROTECT(elt = STRING_ELT(sx, ix)); nprot++;

		if (elt == NA_STRING) {
			w = charsxp_width(na_print, s.flags.na);
		} else {
			w = charsxp_width(elt, s.flags.entry);
		}

		if (w > colwidths[j]) {
			colwidths[j] = w;
		}

		if ((ix + 1) % nrow == 0) {
			j++;
		}

		UNPROTECT(1); nprot--;
	}

	nprint = 0;
	begin = 0;
	while (begin != ncol) {
		lw = namewidth;
		end = begin;

		while (end != ncol) {
			// break if including the column puts us over the
			// width; we do the calculations like this to
			// avoid integer overflow

			if (end > begin || row_names != R_NilValue) {
				if (lw > linewidth - print_gap) {
					break;
				}
				lw += print_gap;
			}

			if (lw > linewidth - colwidths[end]) {
				break;
			}
			lw += colwidths[end];

			end++;
		}

		if (begin == end) {
			// include at least one column, even if it
			// puts us over the line width
			end++;
		}

		nprint += render_range(render, &s, sx, na_print, begin,
				       end, print_gap, max - nprint,
				       namewidth, colwidths);
		begin = end;
	}

exit:
	PROTECT(str = mkCharLenCE(render->string, render->length, CE_UTF8));
	nprot++;
	PROTECT(ans = ScalarString(str)); nprot++;

	rutf8_free_render(srender);
	UNPROTECT(nprot);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/render_table.c:249

rutf8_utf8_normalize untypeable entry .Call

untypeable application
error detail
function: [c_int_na, [c_ptr] --> c_void] --> any_sexp
argument: [c_int, ([c_null] -> empty) & ([(*(~(c_string | struct context)) | c_string) \ c_null] | [*struct context \ c_null] -> ())]
timing: 0.219 s
source
SEXP rutf8_utf8_normalize(SEXP x, SEXP map_case, SEXP map_compat,
			  SEXP map_quote, SEXP remove_ignorable)
{
	SEXP ans, sctx, elt;
	struct context *ctx;
	struct utf8lite_text text;
	const uint8_t *ptr;
	size_t size;
	R_xlen_t i, n;
	int err = 0, nprot = 0;

	if (x == R_NilValue) {
		return R_NilValue;
	}

	PROTECT(sctx = rutf8_alloc_context(sizeof(*ctx), context_destroy));
	nprot++;
        ctx = rutf8_as_context(sctx);
	context_init(ctx, map_case, map_compat, map_quote, remove_ignorable);

	PROTECT(ans = duplicate(x)); nprot++;
	n = XLENGTH(ans);

	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(elt = STRING_ELT(ans, i)); nprot++;
		if (elt == NA_STRING) {
			UNPROTECT(1); nprot--;
			continue;
		}

		ptr = (const uint8_t *)rutf8_translate_utf8(elt);
		size = strlen((const char *)ptr);
		TRY(utf8lite_text_assign(&text, ptr, size, 0, NULL));
		TRY(utf8lite_textmap_set(&ctx->map, &text));

		ptr = ctx->map.text.ptr;
		size = UTF8LITE_TEXT_SIZE(&ctx->map.text);
		TRY(size > INT_MAX ? UTF8LITE_ERROR_OVERFLOW : 0);

		elt = mkCharLenCE((const char *)ptr, (int)size, CE_UTF8);
		SET_STRING_ELT(ans, i, elt);
		UNPROTECT(1); nprot--;
	}

exit:
	CHECK_ERROR(err);
	rutf8_free_context(sctx);
	UNPROTECT(nprot);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_normalize.c:69

assign_esc timeout

timing: 20.00 s
source
int assign_esc(struct utf8lite_text *text, const uint8_t *ptr, size_t size,
	       struct utf8lite_message *msg)
{
	const uint8_t *input = ptr;
	const uint8_t *end = ptr + size;
	size_t attr = 0;
	uint_fast8_t ch;
	int err;

	text->ptr = (uint8_t *)ptr;

	while (ptr != end) {
		ch = *ptr++;
		if (ch == '\\') {
			attr |= UTF8LITE_TEXT_ESC_BIT;

			if ((err = utf8lite_scan_escape(&ptr, end, msg))) {
				goto error;
			}
		} else if (ch & 0x80) {
			ptr--;
			if ((err = utf8lite_scan_utf8(&ptr, end, msg))) {
				goto error;
			}
		}
	}

	attr |= size;
	text->attr = attr;
	return 0;

error:
	append_location(msg, (size_t)(ptr - input));
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textassign.c:102

assign_raw timeout

timing: 20.00 s
source
int assign_raw(struct utf8lite_text *text, const uint8_t *ptr, size_t size,
	       struct utf8lite_message *msg)
{
	const uint8_t *input = ptr;
	const uint8_t *end = ptr + size;
	uint_fast8_t ch;
	int err;

	text->ptr = (uint8_t *)ptr;

	while (ptr != end) {
		ch = *ptr++;
		if (ch & 0x80) {
			ptr--;
			if ((err = utf8lite_scan_utf8(&ptr, end, msg))) {
				goto error;
			}
		}
	}

	text->attr = size;
	return 0;

error:
	append_location(msg, (size_t)(ptr - input));
	text->ptr = NULL;
	text->attr = 0;
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textassign.c:71

rutf8_bytes_lformat timeout

timing: 20.00 s
source
static SEXP rutf8_bytes_lformat(struct utf8lite_render *r,
				const struct rutf8_bytes *bytes,
				int trim, int chars, int quote,
				int flags, int width_max, int centre)
{
	SEXP ans = R_NilValue;
	const uint8_t *ptr, *end;
	uint8_t byte;
	int err = 0, w, trunc, bfill, efill, fullwidth, width, quotes;

	quotes = quote ? 2 : 0;

	bfill = 0;
	if (centre && !trim) {
		fullwidth = (rutf8_bytes_lwidth(bytes, flags, chars) + quotes);
		if (fullwidth < width_max) {
			bfill = (width_max - fullwidth) / 2;
			TRY(utf8lite_render_chars(r, ' ', bfill));
		}
	}

	width = 0;
	trunc = 0;
	ptr = bytes->ptr;
	end = bytes->ptr + bytes->size;

	while (!trunc && ptr < end) {
		byte = *ptr++;
		w = byte_width(byte, flags);

		if (width > chars - w) {
			w = 3;
			TRY(utf8lite_render_raw(r, "...", 3));
			trunc = 1;
		} else {
			render_byte(r, byte);
		}

		width += w;
	}

	if (!trim) {
		efill = width_max - width - quotes - bfill;
		TRY(utf8lite_render_chars(r, ' ', efill));
	}

	ans = mkCharLenCE((char *)r->string, r->length, CE_BYTES);
	utf8lite_render_clear(r);
exit:
	CHECK_ERROR(err);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:209

rutf8_bytes_lrender timeout

timing: 20.00 s
source
static void rutf8_bytes_lrender(struct utf8lite_render *r,
				const struct rutf8_bytes *bytes,
				int width_min, int quote, int centre)
{
	const uint8_t *ptr, *end;
	uint8_t byte;
	int err = 0, w, fullwidth, width, quotes;

	assert(width_min >= 0);

	quotes = quote ? 2 : 0;
	width = 0;

	if (centre && width_min > 0) {
		fullwidth = rutf8_bytes_width(bytes, r->flags);
		if (fullwidth <= width_min - quotes) {
			width = (width_min - fullwidth - quotes) / 2;
			TRY(utf8lite_render_chars(r, ' ', width));
		}
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
		assert(width < INT_MAX);
		width++;
	}

	ptr = bytes->ptr;
	end = bytes->ptr + bytes->size;

	while (ptr < end) {
		byte = *ptr++;
		w = byte_width(byte, r->flags);
		render_byte(r, byte);

		assert(w >= 0);
		if (width <= width_min - w) {
			width += w;
		} else {
			width = width_min; // truncate to avoid overflow
		}
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
		if (width < width_min) { // avoid overflow
			width++;
		}
	}

	if (width < width_min) {
		TRY(utf8lite_render_chars(r, ' ', width_min - width));
	}
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:95

rutf8_bytes_rrender timeout

timing: 20.00 s
source
static void rutf8_bytes_rrender(struct utf8lite_render *r,
				const struct rutf8_bytes *bytes,
				int width_min, int quote)
{
	const uint8_t *ptr, *end;
	uint8_t byte;
	int err = 0, fullwidth, quotes;

	assert(width_min >= 0);

	quotes = quote ? 2 : 0;

	if (width_min > 0) {
		fullwidth = rutf8_bytes_width(bytes, r->flags);
		// ensure fullwidth + quotes doesn't overflow
		if (fullwidth <= width_min - quotes) {
			fullwidth += quotes;
			TRY(utf8lite_render_chars(r, ' ',
						  width_min - fullwidth));
		}
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
	}

	ptr = bytes->ptr;
	end = bytes->ptr + bytes->size;

	while (ptr < end) {
		byte = *ptr++;
		render_byte(r, byte);
	}

	if (quote) {
		TRY(utf8lite_render_raw(r, "\"", 1));
	}
exit:
	CHECK_ERROR(err);
}
/__w/r-typing/r-typing/work/sources/utf8/src/bytes.c:153

rutf8_utf8_encode timeout entry .Call

timing: 20.00 s
source
SEXP rutf8_utf8_encode(SEXP sx, SEXP swidth, SEXP squote, SEXP sjustify,
		       SEXP sescapes, SEXP sdisplay, SEXP sutf8)
{
	SEXP ans, selt, ans_i = NA_STRING, srender;
	struct rutf8_string elt;
	struct utf8lite_render *render;
	enum rutf8_justify_type justify;
	const char *escapes;
	R_xlen_t i, n;
	int width, quote, display, utf8;
	int err = 0, nprot = 0, w, quotes, flags;

	if (sx == R_NilValue) {
		return R_NilValue;
	}

	if (!isString(sx)) {
		Rf_error("argument is not a character object");
	}
	n = XLENGTH(sx);

	if (swidth == R_NilValue || INTEGER(swidth)[0] == NA_INTEGER) {
		width = -1;
	} else {
		width = INTEGER(swidth)[0];
	}

	quote = LOGICAL(squote)[0] == TRUE;
	justify = rutf8_as_justify(sjustify);
	escapes = rutf8_as_style(sescapes);
	display = LOGICAL(sdisplay)[0] == TRUE;
	utf8 = LOGICAL(sutf8)[0] == TRUE;

	flags = (UTF8LITE_ESCAPE_CONTROL | UTF8LITE_ENCODE_C);
	if (quote) {
		flags |= UTF8LITE_ESCAPE_DQUOTE;
	}
	if (display) {
		flags |= UTF8LITE_ENCODE_RMDI;
		flags |= UTF8LITE_ENCODE_EMOJIZWSP;
	}
	if (!utf8) {
		flags |= UTF8LITE_ESCAPE_UTF8;
	}
#if defined(_WIN32) || defined(_WIN64)
	flags |= UTF8LITE_ESCAPE_EXTENDED;
#endif
	quotes = quote ? 2 : 0;

	if (justify == RUTF8_JUSTIFY_NONE) {
		width = 0;
	}

	if (width < 0) {
		width = 0;
		for (i = 0; i < n; i++) {
			CHECK_INTERRUPT(i);

			PROTECT(selt = STRING_ELT(sx, i)); nprot++;
			rutf8_string_init(&elt, selt);

			if (elt.type == RUTF8_STRING_NONE) {
				UNPROTECT(1); nprot--;
				continue;
			}

			w = rutf8_string_width(&elt, flags);
			if (w > INT_MAX - quotes) {
				Rf_error("width exceeds maximum (%d)",
					 INT_MAX);
			}
			w += quotes;

			if (w > width) {
				width = w;
			}
			UNPROTECT(1); nprot--;
		}
	}

        PROTECT(srender = rutf8_alloc_render(flags)); nprot++;
	render = rutf8_as_render(srender);
	if (escapes) {
		TRY(utf8lite_render_set_style(render, escapes,
					      RUTF8_STYLE_CLOSE));
	}

	PROTECT(ans = duplicate(sx)); nprot++;

	for (i = 0; i < n; i++) {
		CHECK_INTERRUPT(i);

		PROTECT(selt = STRING_ELT(sx, i)); nprot++;
		rutf8_string_init(&elt, selt);
		if (elt.type == RUTF8_STRING_NONE) {
			ans_i = NA_STRING;
		} else {
			rutf8_string_render(render, &elt, width, quote,
					    justify);
			ans_i = mkCharLenCE(render->string, render->length,
					    CE_UTF8);
			utf8lite_render_clear(render);
		}

		UNPROTECT(1); nprot--;
		SET_STRING_ELT(ans, i, ans_i);
	}

exit:
	UNPROTECT(nprot);
	CHECK_ERROR(err);
	return ans;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8_encode.c:21

utf8lite_decode_uescape timeout

timing: 20.00 s
source
void utf8lite_decode_uescape(const uint8_t **inputptr, int32_t *codeptr)
{
	const uint8_t *ptr = *inputptr;
	int32_t code;
	uint_fast16_t low;
	uint_fast8_t ch;
	unsigned i;

	code = 0;
	for (i = 0; i < 4; i++) {
		ch = *ptr++;
		code = (code << 4) + hextoi(ch);
	}

	if (UTF8LITE_IS_UTF16_HIGH(code)) {
		// skip over \u
		ptr += 2;

		low = 0;
		for (i = 0; i < 4; i++) {
			ch = *ptr++;
			low = (uint_fast16_t)(low << 4) + hextoi(ch);
		}

		code = UTF8LITE_DECODE_UTF16_PAIR(code, low);
	}

	*codeptr = code;
	*inputptr = ptr;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/escape.c:163

utf8lite_scan_utf8 timeout

timing: 20.00 s
source
int utf8lite_scan_utf8(const uint8_t **bufptr, const uint8_t *end,
		       struct utf8lite_message *msg)
{
	const uint8_t *ptr = *bufptr;
	uint_fast8_t ch, ch1;
	unsigned nc;
	int err;

	assert(ptr < end);

	/* First byte
	 * ----------
	 *
	 * 1-byte sequence:
	 * 00: 0000 0000
	 * 7F: 0111 1111
	 * (ch1 & 0x80 == 0)
	 *
	 * Invalid:
	 * 80: 1000 0000
	 * BF: 1011 1111
	 * C0: 1100 0000
	 * C1: 1100 0001
	 * (ch & 0xF0 == 0x80 || ch == 0xC0 || ch == 0xC1)
	 *
	 * 2-byte sequence:
	 * C2: 1100 0010
	 * DF: 1101 1111
	 * (ch & 0xE0 == 0xC0 && ch > 0xC1)
	 *
	 * 3-byte sequence
	 * E0: 1110 0000
	 * EF: 1110 1111
	 * (ch & 0xF0 == E0)
	 *
	 * 4-byte sequence:
	 * F0: 1111 0000
	 * F4: 1111 0100
	 * (ch & 0xFC == 0xF0 || ch == 0xF4)
	 */

	ch1 = *ptr++;

	if ((ch1 & 0x80) == 0) {
		goto success;
	} else if ((ch1 & 0xC0) == 0x80) {
		goto inval_lead;
	} else if ((ch1 & 0xE0) == 0xC0) {
		if (ch1 == 0xC0 || ch1 == 0xC1) {
			goto inval_lead;
		}
		nc = 1;
	} else if ((ch1 & 0xF0) == 0xE0) {
		nc = 2;
	} else if ((ch1 & 0xFC) == 0xF0 || ch1 == 0xF4) {
		nc = 3;
	} else {
		// expecting bytes in the following ranges: 00..7F C2..F4
		goto inval_lead;
	}

	// ensure string is long enough
	if (ptr + nc > end) {
		// expecting another continuation byte
		goto inval_incomplete;
	}

	/* First Continuation byte
	 * -----------
	 * X  + 80..BF:
	 * 80: 1000 0000
	 * BF: 1011 1111
	 * (ch & 0xC0 == 0x80)
	 *
	 * E0 + A0..BF:
	 * A0: 1010 0000
	 * BF: 1011 1111
	 * (ch & 0xE0 == 0xA0)
	 *
	 * ED + 80..9F:
	 * 80: 1000 0000
	 * 9F: 1001 1111
	 * (ch & 0xE0 == 0x80)
	 *
	 * F0 + 90..BF:
	 * 90: 1001 0000
	 * BF: 1011 1111
	 * (ch & 0xF0 == 0x90 || ch & 0xE0 == A0)
	 *
	 */

	// validate the first continuation byte
	ch = *ptr++;
	switch (ch1) {
	case 0xE0:
		if ((ch & 0xE0) != 0xA0) {
			// expecting a byte between A0 and BF
			goto inval_cont;
		}
		break;
	case 0xED:
		if ((ch & 0xE0) != 0x80) {
			// expecting a byte between A0 and 9F
			goto inval_cont;
		}
		break;
	case 0xF0:
		if ((ch & 0xE0) != 0xA0 && (ch & 0xF0) != 0x90) {
			// expecting a byte between 90 and BF
			goto inval_cont;
		}
		break;
	case 0xF4:
		if ((ch & 0xF0) != 0x80) {
			// expecting a byte between 80 and 8F
			goto inval_cont;
		}
	default:
		if ((ch & 0xC0) != 0x80) {
			// expecting a byte between 80 and BF
			goto inval_cont;
		}
		break;
	}
	nc--;

	// validate the trailing continuation bytes
	while (nc-- > 0) {
		ch = *ptr++;
		if ((ch & 0xC0) != 0x80) {
			// expecting a byte between 80 and BF
			goto inval_cont;
		}
	}

success:
	err = 0;
	goto out;

inval_incomplete:
	utf8lite_message_set(msg, "not enough continuation bytes"
			     " after leading byte (0x%02X)",
			     (unsigned)ch1);
	goto error;

inval_lead:
	utf8lite_message_set(msg, "invalid leading byte (0x%02X)",
			     (unsigned)ch1);
	goto error;

inval_cont:
	utf8lite_message_set(msg, "leading byte 0x%02X followed by"
			     " invalid continuation byte (0x%02X)",
			     (unsigned)ch1, (unsigned)ch);
	goto error;

error:
	ptr--;
	err = UTF8LITE_ERROR_INVAL;
out:
	*bufptr = ptr;
	return err;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/encode.c:43

utf8lite_textmap_set_utf32 timeout

timing: 20.03 s
source
int utf8lite_textmap_set_utf32(struct utf8lite_textmap *map, const int32_t *ptr,
			     const int32_t *end)
{
	int map_quote = map->type & UTF8LITE_TEXTMAP_QUOTE;
	int rm_di = map->type & UTF8LITE_TEXTMAP_RMDI;
	uint8_t *dst = map->text.ptr;
	int32_t code;
	int8_t ch;

	while (ptr != end) {
		code = *ptr++;

		if (code <= 0x7F) {
			ch = map->ascii_map[code];
			if (ch >= 0) {
				*dst++ = (uint8_t)ch;
			}
			continue;
		} else {
			switch (code) {
			case 0x055A: // ARMENIAN APOSTROPHE
			case 0x2018: // LEFT SINGLE QUOTATION MARK
			case 0x2019: // RIGHT SINGLE QUOTATION MARK
			case 0x201B: // SINGLE HIGH-REVERSED-9 QUOTATION MARK
			case 0xFF07: // FULLWIDTH APOSTROPHE
				if (map_quote) {
					code = '\'';
				}
				break;

			default:
				if (rm_di && utf8lite_isignorable(code)) {
					continue;
				}
				break;
			}
		}
		utf8lite_encode_utf8(code, &dst);
	}

	*dst = '\0'; // not necessary, but helps with debugging
	map->text.attr = (UTF8LITE_TEXT_SIZE_MASK
			  & ((size_t)(dst - map->text.ptr)));
	return 0;
}
/__w/r-typing/r-typing/work/sources/utf8/src/utf8lite/src/textmap.c:175

R definitions 33

R/output.R

output_ansi untypeabletyped

unbound variable (line 19)
unbound: isatty — a name the prelude does not declare
error detail
name: isatty
gradual mode: typed
(() -> ff<> | tt<>)<>
timing: 0.014 s
source
output_ansi <- function() {
  # tty?
  if (isatty(stdout())) {
    # and not Windows GUI?
    return(.Platform$GUI != "Rgui")
  }

  # RStudio 1.1 or later with color enabled?
  if (!is.na(as.numeric(Sys.getenv("RSTUDIO_CONSOLE_COLOR")))) {
    # and output is stdout?
    return(stdout() == 1)
  }

  FALSE
}
R/output.R:17

output_utf8 untypeable

untypeable application of base::$ (line 107)
error detail
argument: @(list<>, "UTF-8"<>)
failing call: base::$(list(), "UTF-8")
timing: 0.056 s
source
output_utf8 <- function() {
  # ASCII-only character locale?
  if (Sys.getlocale("LC_CTYPE") == "C") {
    return(FALSE)
  }

  # UTF-8 locale?
  if (l10n_info()$`UTF-8`) {
    return(TRUE)
  }

  # Windows?
  if (.Platform$OS.type == "windows") {
    # This isn't really the case, but there's no way to set the
    # locale to UTF-8 on Windows. In RGui and RStudio, UTF-8 is
    # always supported on stdout(); output through connections
    # gets translated through the native locale.
    return(TRUE)
  }

  FALSE
}
R/output.R:100
R/util.R

with_rethrow skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
with_rethrow <- function(expr) {
  parentcall <- sys.call(-1)
  eval(
    envir = parent.frame(),
    withCallingHandlers(
      expr,
      error = function(e, call = parentcall) {
        e$call <- call
        stop(e)
      },
      warning = function(w, call = parentcall) {
        w$call <- call
        warning(w)
        invokeRestart("muffleWarning")
      },
      message = function(m, call = parentcall) {
        m$call <- call
      }
    )
  )
}
R/util.R:15
R/utf8.R

utf8_normalize untypeabletyped

unbound variable (line 168)
unbound: ...length — a name the prelude does not declare
error detail
name: ...length
gradual mode: typed
((x: any, ...: any, map_case: any?, map_compat: any?, map_quote: any?, remove_ignorable: any?) -> any)<>
timing: 0.046 s
source
utf8_normalize <- function(
  x,
  ...,
  map_case = FALSE,
  map_compat = FALSE,
  map_quote = FALSE,
  remove_ignorable = FALSE
) {
  stopifnot(...length() == 0)

  with_rethrow({
    x <- as_utf8(x, normalize = FALSE)
    map_case <- as_option("map_case", map_case)
    map_compat <- as_option("map_compat", map_compat)
    map_quote <- as_option("map_quote", map_quote)
    remove_ignorable <- as_option("remove_ignorable", remove_ignorable)
  })

  .Call(
    rutf8_utf8_normalize,
    x,
    map_case,
    map_compat,
    map_quote,
    remove_ignorable
  )
}
R/utf8.R:160

as_utf8 typed any: normalize accepts outside

(((x: p(CHR) | (~CHR)<...> | sym, normalize: any?) -> empty)&((x: p(CHR) | (~CHR)<...> | sym | null, normalize: ff?) -> null))<>
gradual mode: typed
(((x: p(CHR) | (~CHR)<...> | sym, normalize: any?) -> empty)&((x: p(CHR) | (~CHR)<...> | sym | null, normalize: any?) -> any)&((x: p(CHR) | (~CHR)<...> | sym | null, normalize: ff?) -> null))<>
timing: 0.070 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain x: 1

parameterchangecallreturned
xretype:int>chras_utf8(c(NA_character_, "NA"), "normalize" = FALSE)(CHR & ~vec1)<> with { }
source
as_utf8 <- function(x, normalize = FALSE) {
  ans <- .Call(rutf8_as_utf8, x)
  if (normalize) {
    ans <- utf8_normalize(ans)
  }
  ans
}
R/utf8.R:57

utf8_valid typed fuzz ok

(((x: p(CHR) | (~CHR)<...> | sym) -> empty)&((x: p(CHR) | (~CHR)<...> | sym | null) -> null))<>
timing: 0.025 s
fuzzing: 7 inside (7 ok) · 8 outside (8 rejected)
source
utf8_valid <- function(x) {
  .Call(rutf8_utf8_valid, x)
}
R/utf8.R:68

utf8_width untypeable

unbound variable (line 117)
unbound: ...length — a name the prelude does not declare
error detail
name: ...length
timing: 0.022 s
source
utf8_width <- function(
  x,
  ...,
  encode = TRUE,
  quote = FALSE,
  utf8 = NULL
) {
  stopifnot(...length() == 0)

  with_rethrow({
    encode <- as_option("encode", encode)
    quote <- as_option("quote", quote)
    utf8 <- as_output_utf8("utf8", utf8)
  })

  .Call(rutf8_utf8_width, x, encode, quote, utf8)
}
R/utf8.R:110
R/coerce.R

as_character_vector typed any: name, utf8 accepts outside

((name: any, value: null, utf8: any?) -> null)<>
timing: 0.984 s
fuzzing: 8 inside (8 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain name: 1

parameterchangecallreturned
namedropas_character_vector("value" = NULL)null
source
as_character_vector <- function(name, value, utf8 = TRUE) {
  if (
    !(is.null(value) ||
      is.character(value) ||
      is.factor(value) ||
      all(is.na(value)))
  ) {
    stop(sprintf("'%s' must be text, a character vector, or NULL", name))
  }
  if (is.null(value)) {
    return(NULL)
  }
  value <- as.character(value)
  if (utf8) {
    value <- as_utf8(value)
  }
  value
}
R/coerce.R:27

as_character_scalar typed any: name, utf8 fuzz ok

((name: any, value: null, utf8: any?) -> null)<>
timing: 0.081 s
fuzzing: 8 inside (8 ok) · 8 outside (8 rejected)
source
as_character_scalar <- function(name, value, utf8 = TRUE) {
  if (is.null(value)) {
    return(NULL)
  }
  value <- as_character_vector(name, value, utf8)
  if (length(value) != 1) {
    stop(sprintf("'%s' must be a scalar character string", name))
  }
  value
}
R/coerce.R:15

as_enum typed empty return any: name, choices

((name: any, value: ~CHR, choices: any) -> empty)<>
gradual mode: typed
(((name: any, value: CHR, choices: any) -> any)&((name: any, value: ~CHR, choices: any) -> empty))<>
timing: 0.345 s
source
as_enum <- function(name, value, choices) {
  if (!(is.character(value) && length(value) == 1 && !is.na(value))) {
    stop(sprintf("'%s' must be a character string", name))
  }

  i <- pmatch(value, choices, nomatch = 0)
  if (all(i == 0)) {
    stop(
      sprintf("'%s' must be one of the following: ", name),
      paste(dQuote(choices), collapse = ", ")
    )
  }
  i <- i[i > 0]
  choices[[i]]
}
R/coerce.R:47

as_integer_vector typed any: name, nonnegative accepts outside

(((name: any, value: CHR | CLX | LGL | RAW, nonnegative: any?) | (name: any, value: DBL | INT, nonnegative: any?) -> INT<>)&((name: any, value: CHR1 | CLX1 | LGL1 | RAW1, nonnegative: any?) | (name: any, value: DBL1 | INT1, nonnegative: any?) -> INT1<>)&((name: any, value: null, nonnegative: any?) -> null))<>
timing: 3.42 s
fuzzing: 8 inside (2 ok, 1 error pkg, 5 error type) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain value: 1

parameterchangecallreturned
valuekind:listas_integer_vector(as.name("x"), "value" = list())(INT & ~vec1)<> with { }

Other calls inside the domain

callverdicterror
as_integer_vector("name" = function(...) local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "value" = as.raw(c(255, 0, 255, 0, 0)), "nonnegative" = NULL)error_typebase::as.character: cannot coerce type 'closure' to vector of type 'character'
as_integer_vector(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), as.raw(c(255)), "nonnegative" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_typebase::as.character: cannot coerce type 'externalptr' to vector of type 'character'
as_integer_vector(as.name("x"), 2147483647L, list())error_typebase::&&: invalid 'x' type in 'x && y'
as_integer_vector(NULL, complex(real = 0, imaginary = 0), "nonnegative" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_pkgutf8::as_integer_vector:
as_integer_vector(as.name("x"), raw(0), "nonnegative" = NULL)error_typebase::&&: invalid 'x' type in 'x && y'
as_integer_vector(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "value" = NA_complex_, "nonnegative" = quote(f(x)))error_typebase::&&: invalid 'x' type in 'x && y'
source
as_integer_vector <- function(name, value, nonnegative = FALSE) {
  if (is.null(value)) {
    return(NULL)
  }

  if (!(is.numeric(value) || all(is.na(value)))) {
    stop(sprintf("'%s' must be integer-valued", name))
  }

  value <- as.integer(value)
  if (nonnegative && any(!is.na(value) & value < 0)) {
    stop(sprintf("'%s' must be non-negative", name))
  }

  value
}
R/coerce.R:76

as_integer_scalar typed any: name, nonnegative fuzz ok

(((name: any, value: null, nonnegative: any?) -> null)&((name: any, value: vec, nonnegative: any?) -> INT<>)&((name: any, value: vec1, nonnegative: any?) -> INT1<>))<>
timing: 0.320 s
fuzzing: 8 inside (4 ok, 1 error pkg, 3 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
as_integer_scalar(as.name("x"), 2L, c(2147483647, -1))error_typebase::&&: 'length = 2' in coercion to 'logical(1)'
as_integer_scalar(function(...) new.env(), "value" = as.raw(c(0)), "nonnegative" = quote(f(x)))error_typebase::as.character: cannot coerce type 'closure' to vector of type 'character'
as_integer_scalar(list(NULL, NA_complex_), c(42L, 2147483647L, -2147483647L, 0L, -2147483647L))error_pkgutf8::as_integer_scalar: 'NULL' must have length 1'NA' must have length 1
as_integer_scalar(function(...) quote(f(x)), "value" = as.raw(c(255)), "nonnegative" = quote(f(x)))error_typebase::as.character: cannot coerce type 'closure' to vector of type 'character'
source
as_integer_scalar <- function(name, value, nonnegative = FALSE) {
  if (is.null(value)) {
    return(NULL)
  }
  value <- as_integer_vector(name, value, nonnegative)
  if (length(value) != 1) {
    stop(sprintf("'%s' must have length 1", name))
  }
  value
}
R/coerce.R:64

as_na_print typed any: name accepts outside

((name: any, value: null) -> null)<>
timing: 0.048 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain name: 1

parameterchangecallreturned
namedropas_na_print("value" = NULL)null
source
as_na_print <- function(name, value) {
  if (is.null(value)) {
    return(NULL)
  }
  value <- as_character_scalar(name, value)
  if (is.na(value)) {
    stop(sprintf("'%s' cannot be NA", name))
  }
  value
}
R/coerce.R:94

as_nonnegative typed any: name fuzz ok

(((name: any, value: null) -> null)&((name: any, value: vec) -> INT<>)&((name: any, value: vec1) -> INT1<>))<>
timing: 0.185 s
fuzzing: 8 inside (4 ok, 3 error pkg, 1 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
as_nonnegative(NULL, "value" = c(complex(real = 1, imaginary = -2), complex(real = 1, imaginary = -2), NA_complex_, complex(real = 1, imaginary = -2), NA_complex_))error_pkgutf8::as_integer_vector:
as_nonnegative("name" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "value" = as.raw(c(0)))error_typebase::as.character: cannot coerce type 'externalptr' to vector of type 'character'
as_nonnegative("name" = new.env(), "value" = c(2L, NA_integer_))error_pkgutf8::as_integer_scalar:
as_nonnegative(new.env(), c(complex(real = 1, imaginary = -2), complex(real = 1, imaginary = -2), complex(real = 1, imaginary = -2), complex(real = 1, imaginary = -2), complex(real = 0, imaginary = 0)))error_pkgutf8::as_integer_vector:
source
as_nonnegative <- function(name, value) {
  if (is.null(value)) {
    return(NULL)
  }
  value <- as_integer_scalar(name, value, nonnegative = TRUE)
  if (is.na(value)) {
    stop(sprintf("'%s' cannot be NA", name))
  }
  value
}
R/coerce.R:106

as_option typed any: name accepts outside

(((name: any, value: LGL) -> LGL<>)&((name: any, value: LGL1) -> LGL1<>)&((name: any, value: null) -> ff<>)&((name: any, value: ~(LGL | null)) -> empty))<>
timing: 0.506 s
fuzzing: 8 inside (6 ok, 1 error pkg, 1 error type) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain name: 1

parameterchangecallreturned
namedropas_option("value" = NULL)ff<> with { }

Other calls inside the domain

callverdicterror
as_option(new.env(), NA)error_pkgutf8::as_option:
as_option(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), NA)error_typebase::as.character: cannot coerce type 'externalptr' to vector of type 'character'
source
as_option <- function(name, value) {
  if (is.null(value)) {
    return(FALSE)
  }

  if (!(length(value) == 1 && is.logical(value) && !is.na(value))) {
    stop(sprintf("'%s' must be TRUE or FALSE", name))
  }
  as.logical(value)
}
R/coerce.R:118

as_chars typed any: name fuzz ok

(((name: any, value: null) -> null)&((name: any, value: vec) -> INT<>)&((name: any, value: vec1) -> INT1<>))<>
timing: 0.023 s
fuzzing: 8 inside (4 ok, 1 error pkg, 3 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
as_chars(function(...) local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), c(FALSE, NA, FALSE, TRUE, FALSE))error_typebase::as.character: cannot coerce type 'closure' to vector of type 'character'
as_chars("name" = NULL, "value" = -Inf)error_pkgutf8::as_chars:
as_chars("name" = as.name("x"), "value" = complex(real = 1, imaginary = -2))error_typebase::sprintf: invalid type of argument[1]: 'symbol'
as_chars("name" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "value" = logical(0))error_typebase::as.character: cannot coerce type 'externalptr' to vector of type 'character'
source
as_chars <- as_nonnegative
R/coerce.R:129

as_justify typed empty return any: name

((name: any, value: ~CHR) -> empty)<>
gradual mode: typed
(((name: any, value: any) -> any)&((name: any, value: ~CHR) -> empty))<>
timing: 0.046 s
source
as_justify <- function(name, value) {
  as_enum(name, value, c("left", "right", "centre", "none"))
}
R/coerce.R:131

as_max_print typed any: name fuzz ok

(((name: any, value: null) -> null)&((name: any, value: vec) -> INT<>)&((name: any, value: vec1) -> INT1<>))<>
timing: 0.024 s
fuzzing: 8 inside (5 ok, 2 error pkg, 1 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
as_max_print(new.env(), c(complex(real = 1, imaginary = -2), complex(real = 0, imaginary = 0)))error_pkgutf8::as_integer_vector:
as_max_print(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "value" = -1L)error_typebase::as.character: cannot coerce type 'externalptr' to vector of type 'character'
as_max_print(list(list(NULL, c("a", "", NA_character_, "x y", "NA"))), "value" = c(NA, TRUE))error_pkgutf8::as_integer_vector: 'list(NULL, c("a", "", NA, "x y", "NA"))' must be integer-valued
source
as_max_print <- as_nonnegative
R/coerce.R:135

as_print_gap typed any: name accepts outside

(((name: any, value: null) -> null)&((name: any, value: vec) -> INT<>)&((name: any, value: vec1) -> INT1<>))<>
timing: 0.224 s
fuzzing: 8 inside (3 ok, 2 error pkg, 3 error type) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain name: 1

parameterchangecallreturned
namedropas_print_gap("value" = NULL)null

Other calls inside the domain

callverdicterror
as_print_gap("name" = function(...) list(as.name("x")), "value" = as.raw(c(0)))error_typebase::as.character: cannot coerce type 'closure' to vector of type 'character'
as_print_gap(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "é")error_typebase::as.character: cannot coerce type 'externalptr' to vector of type 'character'
as_print_gap("name" = as.raw(c(0, 0, 255, 255, 255)), "value" = Inf)error_pkgutf8::as_nonnegative: '00' cannot be NA'00' cannot be NA'ff' cannot be NA'ff' cannot be NA'ff' cannot be NA
as_print_gap(function(...) new.env(), "value" = FALSE)error_typebase::as.character: cannot coerce type 'closure' to vector of type 'character'
as_print_gap(c("NA", "x y", "NA", NA_character_, NA_character_), "value" = as.raw(c(255, 0, 255, 0, 255)))error_pkgutf8::as_integer_vector: 'NA' must be integer-valued'x y' must be integer-valued'NA' must be integer-valued'NA' must be integer-valued'NA' must be integer-valued
source
as_print_gap <- function(name, value) {
  value <- as_nonnegative(name, value)
  if (!is.null(value) && value > 1024) {
    stop(sprintf("'%s' must be less than or equal to 1024", name))
  }
  value
}
R/coerce.R:137

as_style typed any: name accepts outside

((name: any, value: null) -> null)<>
timing: 0.099 s
fuzzing: 8 inside (8 ok) · 6 outside (5 rejected, 1 accepted)

Accepted outside the domain name: 1

parameterchangecallreturned
namedropas_style("value" = NULL)null
source
as_style <- function(name, value) {
  value <- as_character_scalar(name, value)
  if (is.null(value) || is.na(value)) {
    return(NULL)
  }
  if (!grepl("^[0-9;]*$", value)) {
    stop(sprintf("'%s' must be a valid ANSI SGR parameter string", name))
  }
  if (nchar(value) >= 128) {
    stop(sprintf("'%s' must have length below 128 characters", name))
  }
  value
}
R/coerce.R:145

as_output_utf8 typed any: name fuzz ok

(((name: any, value: ~(LGL & ~LGL1 | null)) -> LGL1<>)&((name: any, value: ~(LGL | null)) -> empty)&((name: any, value: ~null) -> LGL<>))<>
gradual mode: typed
(((name: any, value: null) -> any)&((name: any, value: ~(LGL & ~LGL1 | null)) -> LGL1<>)&((name: any, value: ~(LGL | null)) -> empty)&((name: any, value: ~null) -> LGL<>))<>
timing: 0.120 s
fuzzing: 8 inside (8 ok) · 8 outside (8 rejected)
source
as_output_utf8 <- function(name, value) {
  if (is.null(value)) {
    return(output_utf8())
  }
  as_option(name, value)
}
R/coerce.R:159
R/utf8-package.R

<statement> typed

timing: 0.002 s
source
"_PACKAGE"
R/utf8-package.R:34
R/utf8_encode.R

utf8_encode untypeabletyped

unbound variable (line 69)
unbound: ...length — a name the prelude does not declare
error detail
name: ...length
gradual mode: typed
(((x: CHR, ...: any, width: vec?, quote: any?, justify: any?, escapes: null?, display: any?, utf8: any?) | (x: CHR, ...: any, width: (vec1 | null)?, quote: any?, justify: any?, escapes: null?, display: any?, utf8: any?) -> any)&((x: null, ...: any, width: any?, quote: any?, justify: any?, escapes: any?, display: any?, utf8: any?) -> null)&((x: ~(CHR | null), ...: any, width: any?, quote: any?, justify: any?, escapes: any?, display: any?, utf8: any?) -> empty))<>
timing: 0.047 s
source
utf8_encode <- function(
  x,
  ...,
  width = 0L,
  quote = FALSE,
  justify = "left",
  escapes = NULL,
  display = FALSE,
  utf8 = NULL
) {
  stopifnot(...length() == 0)

  if (is.null(x)) {
    return(NULL)
  }

  if (!is.character(x)) {
    stop("argument is not a character object")
  }

  with_rethrow({
    width <- as_integer_scalar("width", width)
    quote <- as_option("quote", quote)
    justify <- as_justify("justify", justify)
    escapes <- as_style("escapes", escapes)
    display <- as_option("display", display)
    utf8 <- as_output_utf8("utf8", utf8)
  })

  .Call(rutf8_utf8_encode, x, width, quote, justify, escapes, display, utf8)
}
R/utf8_encode.R:59
R/utf8_format.R

utf8_format untypeabletimeout

unbound variable (line 78)
unbound: ...length — a name the prelude does not declare
error detail
name: ...length
gradual mode: timeout
timing: 1.31 s
source
utf8_format <- function(
  x,
  ...,
  trim = FALSE,
  chars = NULL,
  justify = "left",
  width = NULL,
  na.encode = TRUE,
  quote = FALSE,
  na.print = NULL,
  print.gap = NULL,
  utf8 = NULL
) {
  stopifnot(...length() == 0)

  if (is.null(x)) {
    return(NULL)
  }

  if (!is.character(x)) {
    stop("argument is not a character object")
  }

  with_rethrow({
    trim <- as_option("trim", trim)
    chars <- as_chars("chars", chars)
    justify <- as_justify("justify", justify)
    width <- as_integer_scalar("width", width)
    na.encode <- as_option("na.encode", na.encode)
    quote <- as_option("quote", quote)
    na.print <- as_na_print("na.print", na.print)
    print.gap <- as_print_gap("print_gap", print.gap)
    utf8 <- as_output_utf8("utf8", utf8)
  })

  ellipsis <- "\u2026"
  iellipsis <- iconv(ellipsis, "UTF-8", "")
  if (is.na(iellipsis) || identical(iellipsis, "...")) {
    ellipsis <- "..."
    wellipsis <- 3L
  } else {
    wellipsis <- 1L
  }

  if (is.null(chars) && length(x) > 0) {
    linewidth <- getOption("width")
    quotes <- if (quote) 2 else 0
    gap <- if (is.null(print.gap)) 1 else NULL

    dim <- dim(x)
    dimnames <- dimnames(x)
    names <- if (is.null(dimnames)) names(x) else dimnames[[1]]

    if (is.null(names)) {
      comma <- length(dim) > 1
      namewidth <- floor(log10(length(x)) + 1) + 2 + comma
    } else if (length(dim) > 1) {
      namewidth <- max(0, utf8_width(names, utf8 = utf8))
    } else {
      namewidth <- 0
    }

    chars <- (linewidth - wellipsis - quotes - gap - namewidth)
    chars <- max(chars, 12)
  }

  .Call(
    rutf8_utf8_format,
    x,
    trim,
    chars,
    justify,
    width,
    na.encode,
    quote,
    na.print,
    ellipsis,
    wellipsis,
    utf8
  )
}
R/utf8_format.R:65
R/utf8_print.R

print_table timeout

timing: 20.00 s
source
print_table <- function(
  x,
  width,
  quote,
  na.print,
  print.gap,
  right,
  max,
  names,
  rownames,
  escapes,
  display,
  style,
  utf8
) {
  width <- as.integer(width)
  if (is.null(na.print)) {
    na.print <- if (quote) "NA" else "<NA>"
    na.name.print <- "<NA>"
  } else {
    na.name.print <- na.print
  }
  print.gap <- as.integer(print.gap)
  max <- as.integer(max)

  if (!is.null(rownames(x))) {
    rownames(x)[is.na(rownames(x))] <- na.name.print
  }
  if (!is.null(colnames(x))) {
    colnames(x)[is.na(colnames(x))] <- na.name.print
  }

  linewidth <- getOption("width")
  str <- .Call(
    rutf8_render_table,
    x,
    width,
    quote,
    na.print,
    print.gap,
    right,
    max,
    names,
    rownames,
    escapes,
    display,
    style,
    utf8,
    linewidth
  )
  cat(str)

  nprint <- min(max, length(x))
  nprint
}
R/utf8_print.R:551

set_dimnames untypeabletyped

unbound variable (line 610)
unbound: dimnames — a name the prelude does not declare
error detail
name: dimnames
gradual mode: typed
((x: any with { dim: { }<~@"[[", ...>, any }) -> any)<>
timing: 1.53 s
source
set_dimnames <- function(x) {
  dim <- dim(x)
  dimnames <- dimnames(x)

  if (is.null(dimnames)) {
    dimnames <- vector("list", length(dim))
  }

  for (i in seq_along(dim)) {
    d <- dim[[i]]
    ix <- seq_len(d)
    if (is.null(dimnames[[i]]) && d > 0) {
      if (i == 1) {
        dimnames[[i]] <- format(paste0("[", ix, ",]"), justify = "right")
      } else if (i == 2) {
        dimnames[[i]] <- paste0("[,", ix, "]")
      } else {
        dimnames[[i]] <- as.character(ix)
      }
    }
  }

  dimnames(x) <- dimnames

  x
}
R/utf8_print.R:608

print_array untypeable

unbound variable (line 497)
unbound: set_dimnames — one of the package’s own names, itself untyped
error detail
name: set_dimnames
timing: 3.62 s
source
print_array <- function(
  x,
  quote,
  na.print,
  print.gap,
  right,
  max,
  names,
  rownames,
  escapes,
  display,
  style,
  utf8
) {
  n <- length(x)
  dim <- dim(x)
  if (any(dim == 0)) {
    cat(sprintf("<%s array>\n", paste(dim, collapse = " x ")))
    return(0L)
  }

  x <- set_dimnames(x)
  dimnames <- dimnames(x)

  nrow <- dim[1]
  ncol <- dim[2]

  base <- c(NA, NA, rep(1, length(dim) - 2))
  label <- vector("character", length(dim))
  for (r in 3:length(dim)) {
    label[[r]] <- dimnames[[r]][[1]]
  }

  nprint <- 0L
  off <- 0L
  while (off + nrow * ncol <= n && nprint < max) {
    cat(paste(label, collapse = ", "), "\n\n", sep = "")

    ix <- off + seq_len(nrow * ncol)
    mat <- matrix(x[ix], nrow, ncol, dimnames = dimnames[1:2])
    np <- print_table(
      mat,
      width = 0L,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max - nprint,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
    nprint <- nprint + np
    off <- off + (nrow * ncol)

    r <- 3L
    while (r < length(dim) && base[r] == dim[r]) {
      base[r] <- 1L
      label[r] <- dimnames[[r]][[1L]]
      r <- r + 1L
    }
    if (base[r] < dim[r]) {
      base[r] <- base[r] + 1L
      label[r] <- dimnames[[r]][[base[r]]]
    }
    cat("\n")
  }

  nprint
}
R/utf8_print.R:476

print_matrix untypeabletyped

unbound variable (line 457)
unbound: set_dimnames — one of the package’s own names, itself untyped
error detail
name: set_dimnames
gradual mode: typed
((x: any with { dim: { }<~@"[[", ...>, any }, quote: any, na.print: any, print.gap: any, right: any, max: any, names: any, rownames: any, escapes: any, display: any, style: any, utf8: any) -> any)<>
timing: 2.05 s
source
print_matrix <- function(
  x,
  quote,
  na.print,
  print.gap,
  right,
  max,
  names,
  rownames,
  escapes,
  display,
  style,
  utf8
) {
  if (all(dim(x) == 0)) {
    cat("<0 x 0 matrix>\n")
    return(0L)
  }
  x <- set_dimnames(x)
  print_table(
    x,
    width = 0L,
    quote = quote,
    na.print = na.print,
    print.gap = print.gap,
    right = right,
    max = max,
    names = names,
    rownames = rownames,
    escapes = escapes,
    display = display,
    style = style,
    utf8 = utf8
  )
}
R/utf8_print.R:439

element_width untypeabletyped

unbound variable (line 426)
unbound: utf8_width — one of the package’s own names, itself untyped
error detail
name: utf8_width
gradual mode: typed
((x: any, quote: any, na.print: ~null, utf8: any) -> any)<>
timing: 0.023 s
source
element_width <- function(x, quote, na.print, utf8) {
  width <- max(
    0L,
    utf8_width(x, encode = TRUE, quote = quote, utf8 = utf8),
    na.rm = TRUE
  )
  if (anyNA(x)) {
    if (is.null(na.print)) {
      na.print <- if (quote) "NA" else "<NA>"
    }
    width <- max(width, utf8_width(na.print, utf8 = utf8))
  }
  width
}
R/utf8_print.R:423

print_vector_named untypeable

unbound variable (line 287)
unbound: utf8_width — one of the package’s own names, itself untyped
error detail
name: utf8_width
timing: 1.36 s
source
print_vector_named <- function(
  x,
  quote,
  na.print,
  print.gap,
  right,
  max,
  names,
  rownames,
  escapes,
  display,
  style,
  utf8
) {
  n <- length(x)
  nm <- names(x)
  namewidth <- max(0L, utf8_width(nm, utf8 = utf8))
  eltwidth <- element_width(x, quote = quote, na.print = na.print, utf8 = utf8)
  width <- max(eltwidth, namewidth)

  linewidth <- getOption("width")
  ncol <- max(1L, linewidth %/% (width + print.gap))
  extra <- n %% ncol

  nprint <- 0L
  off <- 0L
  while (off + ncol <= n && nprint < max) {
    ix <- (off + 1L):(off + ncol)
    mat <- matrix(
      x[ix],
      ncol = ncol,
      byrow = TRUE,
      dimnames = list(NULL, nm[ix])
    )
    np <- print_table(
      mat,
      width = width,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max - nprint,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
    nprint <- nprint + np
    off <- off + ncol
  }

  if (extra > 0L && nprint < max) {
    ix <- n - extra + seq_len(extra)
    last <- rbind(as.vector(x[ix]))
    rownames(last) <- NULL
    colnames(last) <- nm[ix]

    np <- print_table(
      last,
      width = width,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max - nprint,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
    nprint <- nprint + np
  }

  nprint
}
R/utf8_print.R:271

print_vector_unnamed untypeable

unbound variable
unbound: escapes — a name the prelude does not declare
error detail
name: escapes
timing: 0.309 s
source
print_vector_unnamed <- function(
  x,
  quote,
  na.print,
  print.gap,
  right,
  max,
  names,
  rownames,
  escapes = escapes,
  display,
  style,
  utf8
) {
  n <- length(x)
  nm <- utf8_format(
    paste0("[", seq_len(n), "]"),
    justify = "right",
    utf8 = utf8
  )
  namewidth <- max(0L, utf8_width(nm, utf8 = utf8))
  width <- element_width(x, quote = quote, na.print = na.print, utf8 = utf8)

  linewidth <- getOption("width")
  ncol <- max(1L, (linewidth - namewidth) %/% (width + print.gap))
  extra <- n %% ncol

  mat <- matrix(x[seq_len(n - extra)], ncol = ncol, byrow = TRUE)
  rownames(mat) <- nm[seq(from = 1L, by = ncol, length.out = nrow(mat))]

  nprint <- print_table(
    mat,
    width = width,
    quote = quote,
    na.print = na.print,
    print.gap = print.gap,
    right = right,
    max = max,
    names = names,
    rownames = rownames,
    escapes = escapes,
    display = display,
    style = style,
    utf8 = utf8
  )

  if (extra > 0L && nprint < max) {
    last <- rbind(as.vector(x[n - extra + seq_len(extra)]))
    rownames(last) <- nm[n - extra + 1]
    np <- print_table(
      last,
      width = width,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max - nprint,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
    nprint <- nprint + np
  }

  nprint
}
R/utf8_print.R:352

print_vector timeout

timing: 20.00 s
source
print_vector <- function(
  x,
  quote,
  na.print,
  print.gap,
  right,
  max,
  names,
  rownames,
  escapes,
  display,
  style,
  utf8
) {
  if (length(x) == 0) {
    cat("character(0)\n")
    return(0L)
  }

  # drop dim, convert dimnames to names
  if (!is.null(dim(x))) {
    x <- c(x)
  }

  if (!is.null(names(x))) {
    nprint <- print_vector_named(
      x,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
  } else {
    nprint <- print_vector_unnamed(
      x,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
  }

  nprint
}
R/utf8_print.R:211

utf8_print untypeabletimeout

unbound variable (line 99)
unbound: ...length — a name the prelude does not declare
error detail
name: ...length
gradual mode: timeout
timing: 0.194 s
source
utf8_print <- function(
  x,
  ...,
  chars = NULL,
  quote = TRUE,
  na.print = NULL,
  print.gap = NULL,
  right = FALSE,
  max = NULL,
  names = NULL,
  rownames = NULL,
  escapes = NULL,
  display = TRUE,
  style = TRUE,
  utf8 = NULL
) {
  stopifnot(...length() == 0)

  if (is.null(x)) {
    return(invisible(NULL))
  }

  if (!is.character(x)) {
    stop("argument is not a character object")
  }

  with_rethrow({
    chars <- as_chars("chars", chars)
    quote <- as_option("quote", quote)
    na.print <- as_na_print("na.print", na.print)
    print.gap <- as_print_gap("print_gap", print.gap)
    right <- as_option("right", right)
    max <- as_max_print("max", max)
    names <- as_style("names", names)
    rownames <- as_style("rownames", rownames)
    escapes <- as_style("escapes", escapes)
    display <- as_option("display", display)
    style <- as_option("style", style)
    utf8 <- as_output_utf8("utf8", utf8)
  })

  if (is.null(print.gap)) {
    print.gap <- 1L
  }
  if (is.null(max)) {
    max <- getOption("max.print")
  }

  if (!output_ansi()) {
    style <- FALSE
  }

  if (!output_utf8()) {
    utf8 <- FALSE
  }

  # truncate character objects
  justify <- if (right) "right" else "left"
  fmt <- utf8_format(
    x,
    trim = TRUE,
    chars = chars,
    justify = justify,
    na.encode = FALSE,
    quote = quote,
    utf8 = utf8
  )

  dim <- dim(x)
  if (is.null(dim) || length(dim) == 1) {
    nprint <- print_vector(
      fmt,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
  } else if (length(dim) == 2) {
    nprint <- print_matrix(
      fmt,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
  } else {
    nprint <- print_array(
      fmt,
      quote = quote,
      na.print = na.print,
      print.gap = print.gap,
      right = right,
      max = max,
      names = names,
      rownames = rownames,
      escapes = escapes,
      display = display,
      style = style,
      utf8 = utf8
    )
  }

  n <- length(x)
  if (nprint < n) {
    cat(sprintf(
      " [ reached getOption(\"max.print\") -- omitted %d entries ]\n",
      n - nprint
    ))
  }

  invisible(x)
}
R/utf8_print.R:83