<commit_before>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "sizes.h"
#include "cc1.h"

#define NR_TYPE_HASH 16

Type
	*voidtype = &(Type) {
		.op = VOID,
		.letter = 'W'
	},
	*pvoidtype = &(Type) {
		.op = PTR,
		.letter = 'R'
	},
	*booltype = &(Type) {
		.op = INT,
		.letter = 'B',
		.defined = 1,
		.u.rank = RANK_BOOL
	},
	*uchartype = &(Type) {
		.op = INT,
		.letter = 'M',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_UCHAR
	},
	*chartype = &(Type) {
		.op = INT,
		.letter = 'C',
		.defined = 1,
		.u.rank = RANK_SCHAR
	},
	*ushortype = &(Type) {
		.op = INT,
		.letter = 'E',
		.defined = 1,
		.u.rank = RANK_USHORT
	},
	*shortype = &(Type) {
		.op = INT,
		.letter = 'K',
		.defined = 1,
		.u.rank = RANK_SHORT
	},
	*uinttype = &(Type) {
		.op = INT,
		.letter = 'U',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_UINT
	},
	*inttype = &(Type) {
		.op = INT,
		.letter = 'I',
		.defined = 1,
		.u.rank = RANK_INT
	},
	*longtype = &(Type) {
		.op = INT,
		.letter = 'L',
		.defined = 1,
		.u.rank = RANK_LONG
	},
	*ulongtype = &(Type) {
		.op = INT,
		.letter = 'Z',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_ULONG
	},
	*ullongtype = &(Type) {
		.op = INT,
		.letter = 'O',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_ULLONG
	},
	*llongtype = &(Type) {
		.op = INT,
		.letter = 'J',
		.defined = 1,
		.u.rank = RANK_LLONG
	},
	*floattype = &(Type) {
		.op = FLOAT,
		.letter = 'F',
		.defined = 1,
		.u.rank = RANK_FLOAT
	},
	*doubletype = &(Type) {
		.op = FLOAT,
		.letter = 'D',
		.defined = 1,
		.u.rank = RANK_DOUBLE
	},
	*ldoubletype = &(Type) {
		.op = FLOAT,
		.letter = 'H',
		.defined = 1,
		.u.rank = RANK_LDOUBLE
	};

Type *
ctype(int8_t type, int8_t sign, int8_t size)
{
	if (type == CHAR && !sign)
		sign = options.charsign;
	if (sign == SIGNED)
		sign = 0;
	if (type == DOUBLE)
		type = FLOAT, size += LONG;

	switch (type) {
	case VOID:                      return voidtype;
	case BOOL:                      return booltype;
	case CHAR:                      return (sign) ? uchartype  : chartype;
	case INT: switch (size) {
		case 0:                 return (sign) ? uinttype   : inttype;
		case SHORT:             return (sign) ? ushortype  : shortype;
		case LONG:              return (sign) ? ulongtype   : longtype;
		case LONG+LONG:         return (sign) ? ullongtype : llongtype;
		}
	case FLOAT: switch (size) {
		case 0:                 return floattype;
		case LONG:              return doubletype;
		case LONG+LONG:         return ldoubletype;
		}
	}
}

Type *
mktype(Type *tp, uint8_t op,
       Symbol *sym, uint16_t nelem)
{
	static Type *typetab[NR_TYPE_HASH], **tbl;
	static uint8_t t;
	register Type *bp;
	char letter;

	if (op == PTR && tp == voidtype)
		return pvoidtype;
	t = (op  ^  (uint8_t) ((unsigned short) tp >> 3))
	         & NR_TYPE_HASH-1;
	tbl = &typetab[t];
	if (op != FTN || op != STRUCT || op != UNION || op != ENUM) {
		for (bp = *tbl; bp; bp = bp->next) {
			if (bp->type == tp && bp->op == op &&
			    bp->sym == sym && bp->u.nelem == nelem) {<commit_msg>Separate char and signed/unsigned char<commit_after>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include "sizes.h"
#include "cc1.h"

#define NR_TYPE_HASH 16

Type
	*voidtype = &(Type) {
		.op = VOID,
		.letter = 'W'
	},
	*pvoidtype = &(Type) {
		.op = PTR,
		.letter = 'R'
	},
	*booltype = &(Type) {
		.op = INT,
		.letter = 'B',
		.defined = 1,
		.u.rank = RANK_BOOL
	},
	*schartype = &(Type) {
		.op = INT,
		.letter = 'C',
		.defined = 1,
		.u.rank = RANK_SCHAR
	},
	*uchartype = &(Type) {
		.op = INT,
		.letter = 'M',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_UCHAR
	},
	*chartype = &(Type) {
		.op = INT,
		.letter = 'M',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_UCHAR
	},
	*ushortype = &(Type) {
		.op = INT,
		.letter = 'E',
		.defined = 1,
		.u.rank = RANK_USHORT
	},
	*shortype = &(Type) {
		.op = INT,
		.letter = 'K',
		.defined = 1,
		.u.rank = RANK_SHORT
	},
	*uinttype = &(Type) {
		.op = INT,
		.letter = 'U',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_UINT
	},
	*inttype = &(Type) {
		.op = INT,
		.letter = 'I',
		.defined = 1,
		.u.rank = RANK_INT
	},
	*longtype = &(Type) {
		.op = INT,
		.letter = 'L',
		.defined = 1,
		.u.rank = RANK_LONG
	},
	*ulongtype = &(Type) {
		.op = INT,
		.letter = 'Z',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_ULONG
	},
	*ullongtype = &(Type) {
		.op = INT,
		.letter = 'O',
		.sign = 1,
		.defined = 1,
		.u.rank = RANK_ULLONG
	},
	*llongtype = &(Type) {
		.op = INT,
		.letter = 'J',
		.defined = 1,
		.u.rank = RANK_LLONG
	},
	*floattype = &(Type) {
		.op = FLOAT,
		.letter = 'F',
		.defined = 1,
		.u.rank = RANK_FLOAT
	},
	*doubletype = &(Type) {
		.op = FLOAT,
		.letter = 'D',
		.defined = 1,
		.u.rank = RANK_DOUBLE
	},
	*ldoubletype = &(Type) {
		.op = FLOAT,
		.letter = 'H',
		.defined = 1,
		.u.rank = RANK_LDOUBLE
	};

Type *
ctype(int8_t type, int8_t sign, int8_t size)
{
	if (type == DOUBLE)
		type = FLOAT, size += LONG;

	switch (type) {
	case CHAR: if (sign == 0)
					return chartype;
				return (sign == UNSIGNED) ?  uchartype : schartype;
	case VOID:            return voidtype;
	case BOOL:            return booltype;
	case INT: switch (size) {
		case 0:          return (sign == UNSIGNED) ? uinttype   : inttype;
		case SHORT:      return (sign == UNSIGNED) ? ushortype  : shortype;
		case LONG:       return (sign == UNSIGNED) ? ulongtype  : longtype;
		case LONG+LONG:  return (sign == UNSIGNED) ? ullongtype : llongtype;
		}
	case FLOAT: switch (size) {
		case 0:          return floattype;
		case LONG:       return doubletype;
		case LONG+LONG:  return ldoubletype;
		}
	}
}

Type *
mktype(Type *tp, uint8_t op,
       Symbol *sym, uint16_t nelem)
{
	static Type *typetab[NR_TYPE_HASH], **tbl;
	static uint8_t t;
	register Type *bp;
	char letter;

	if (op == PTR && tp == voidtype)
		return pvoidtype;
	t = (op  ^  (uint8_t) ((unsigned short) tp >> 3))
	         & NR_TYPE_HASH-1;
	tbl = &typetab[t];
	if (op != FTN || op != STRUCT || op != UNION || op != ENUM) {
		for (bp = *tbl; bp; bp = bp->next) {
			if (bp->type == tp && bp->op == op &&
			    bp->sym == sym && bp->u.nelem == nelem) {
{'fraction_non_alphanumeric': 0.1872969460688759, 'fraction_numerical': 0.011371020142949967, 'mean_word_length': 2.225248821372446, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '577312', 'n_tokens_mistral': 2993, 'n_tokens_neox': 2725, 'n_words': 659}