<commit_before>/*
 * konoha2_inlinelibs.h
 *
 *  Created on: Mar 15, 2012
 *      Author: kimio
 */

#ifndef KONOHA2_INLINELIBS_H_
#define KONOHA2_INLINELIBS_H_

static inline uintptr_t strhash(const char *name, size_t len)
{
	uintptr_t i, hcode = 0;
	for(i = 0; i < len; i++) {
		hcode = name[i] + (31 * hcode);
	}
	return hcode;
}

static inline uintptr_t casehash(const char *name, size_t len)
{
	uintptr_t i, hcode = 0;
	for(i = 0; i < len; i++) {
		hcode = tolower(name[i]) + (31 * hcode);
	}
	return hcode;
}

// --------------------------------------------------------------------------

#define S_cid(X)  S_cid_(_ctx, X)
#define T_cid(X)  S_text(S_cid(X))

static inline kString* S_cid_(CTX, ktype_t ty)
{
	return CT_(ty)->name;
}

#define S_ty(X)  S_ty_(_ctx, X)
#define T_ty(X)  S_text(S_ty(X))

static inline kString* S_ty_(CTX, ktype_t ty)
{
	if(ty < _ctx->share->ca.max) {
		return CT_(ty)->name;
	}
	DBG_P("undefined type sym=%d", ty);
	return TS_EMPTY;
}

#define S_fn(fn)   S_fn_(_ctx, fn)
#define T_fn(fn)   S_text(S_fn_(_ctx, fn))
static inline kString* S_fn_(CTX, ksymbol_t sym)
{
	size_t index = (size_t) MN_UNMASK(sym);
	if(index < kArray_size(_ctx->share->symbolList)) {
		return _ctx->share->symbolList->strings[index];
	}
	DBG_P("undefined symbol sym=%d", sym);
	return TS_EMPTY;
}

static inline const char* filename(const char *str)
{
	char *p = strrchr(str, '/');
	return (p == NULL) ? str : (const char*)p+1;
}

#define S_uri(I)  Suri(_ctx, I)
static inline kString* Suri(CTX, kline_t uri)
{
	kline_t n = (uri >> (sizeof(kshort_t) * 8));<commit_msg>fix build error at g++<commit_after>/*
 * konoha2_inlinelibs.h
 *
 *  Created on: Mar 15, 2012
 *      Author: kimio
 */

#ifndef KONOHA2_INLINELIBS_H_
#define KONOHA2_INLINELIBS_H_

static inline uintptr_t strhash(const char *name, size_t len)
{
	uintptr_t i, hcode = 0;
	for(i = 0; i < len; i++) {
		hcode = name[i] + (31 * hcode);
	}
	return hcode;
}

static inline uintptr_t casehash(const char *name, size_t len)
{
	uintptr_t i, hcode = 0;
	for(i = 0; i < len; i++) {
		hcode = tolower(name[i]) + (31 * hcode);
	}
	return hcode;
}

// --------------------------------------------------------------------------

#define S_cid(X)  S_cid_(_ctx, X)
#define T_cid(X)  S_text(S_cid(X))

static inline kString* S_cid_(CTX, ktype_t ty)
{
	return CT_(ty)->name;
}

#define S_ty(X)  S_ty_(_ctx, X)
#define T_ty(X)  S_text(S_ty(X))

static inline kString* S_ty_(CTX, ktype_t ty)
{
	if(ty < _ctx->share->ca.max) {
		return CT_(ty)->name;
	}
	DBG_P("undefined type sym=%d", ty);
	return TS_EMPTY;
}

#define S_fn(fn)   S_fn_(_ctx, fn)
#define T_fn(fn)   S_text(S_fn_(_ctx, fn))
static inline kString* S_fn_(CTX, ksymbol_t sym)
{
	size_t index = (size_t) MN_UNMASK(sym);
	if(index < kArray_size(_ctx->share->symbolList)) {
		return _ctx->share->symbolList->strings[index];
	}
	DBG_P("undefined symbol sym=%d", sym);
	return TS_EMPTY;
}

static inline const char* filename(const char *str)
{
	/*XXX g++ 4.4.5 need char* cast to compile it. */
	char *p = (char *) strrchr(str, '/');
	return (p == NULL) ? str : (const char*)p+1;
}

#define S_uri(I)  Suri(_ctx, I)
static inline kString* Suri(CTX, kline_t uri)
{
	kline_t n = (uri >> (sizeof(kshort_t) * 8));
{'fraction_non_alphanumeric': 0.20384734719205708, 'fraction_numerical': 0.012721067328575862, 'mean_word_length': 3.386394557823129, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '3269670', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1396, 'n_words': 325}