<commit_before>/*----------------------------------------------------------------------------*/
/*  xresource.c                                                               */
/*----------------------------------------------------------------------------*/
/*  copyright         : (C) 2002 by <NAME>                               */
/*                      VISC Software & Security Consultant Company           */
/*                      Hall 3, Quang Trung Software City                     */
/*                      Tan Chanh Hiep Ward, District 12,                     */
/*                      Ho Chi Minh city, VIETNAM                             */
/*  website           : http://www.visc-network.com                           */
/*  email             : <EMAIL>                                  */
/*  last modify       : Thu, 18 Apr 2002 22:00:33 +0700                       */
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*   This program is free software; you can redistribute it and/or modify     */
/*   it under the terms of the GNU General Public License as published by     */
/*   the Free Software Foundation; either version 2 of the License, or        */
/*   (at your option) any later version.                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/
#include "data.h"
#include <locale.h>
/*----------------------------------------------------------------------------*/
char *sys_lang = NULL;
/*----------------------------------------------------------------------------*/
void VKLocaleInit()
{
	char *lang = sys_lang = getenv("LANG");
	lang = lang ? strdup(lang) : strdup("en_US");
	if( !strstr(lang, ".UTF-8") ) {
		char env[256];
		char *p = strchr(lang, '.');
		if( p ) *p = 0;
		if( !strcmp(lang, "C") )
			p = strdup("vi_VN.UTF-8");
		else {
			p = (char *)malloc(strlen(lang)+8);
			sprintf(p, "%s%s", lang, ".UTF-8");
		}
		snprintf(env, sizeof(env), "LANG=%s", p);
		putenv(env);
		free(lang);
		lang = p;
	}
	if( !setlocale(LC_ALL, "") ) {
#ifndef USE_XFT
		error("Error: Cannot set locale %s!\n", lang);
#endif
	}
	free(lang);
}
/*----------------------------------------------------------------------------*/
#ifndef USE_XFT
char *VKXftFont2XFont(char *name)
{
	static char fn[128], *sep = ":";

	char s[128], *p, *face, *style = 0;
	int bold = 0, mode = 'r';

	strcpy(s, name);
	face = strtok(s, sep);
	p = strtok(NULL, sep);
	while( p ) {
		if( !strncasecmp(p, "style=", 6) )
			style = p+6;
		p = strtok(NULL, sep);
	}
	if( style ) {
		p = strtok(style, " ");
		while( p ) {
			if( !strcasecmp(p, "bold") )
				bold = 1;
			else
			if( !strcasecmp(p, "italic") ||
				!strcasecmp(p, "oblique") )<commit_msg>Display error message instead of exit<commit_after>/*----------------------------------------------------------------------------*/
/*  xresource.c                                                               */
/*----------------------------------------------------------------------------*/
/*  copyright         : (C) 2002 by <NAME>                               */
/*                      VISC Software & Security Consultant Company           */
/*                      Hall 3, Quang Trung Software City                     */
/*                      Tan Chanh Hiep Ward, District 12,                     */
/*                      Ho Chi Minh city, VIETNAM                             */
/*  website           : http://www.visc-network.com                           */
/*  email             : <EMAIL>                                  */
/*  last modify       : Thu, 18 Apr 2002 22:00:33 +0700                       */
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*   This program is free software; you can redistribute it and/or modify     */
/*   it under the terms of the GNU General Public License as published by     */
/*   the Free Software Foundation; either version 2 of the License, or        */
/*   (at your option) any later version.                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/
#include "data.h"
#include <locale.h>
/*----------------------------------------------------------------------------*/
int sys_utf8 = 1;
char *sys_lang = NULL;
/*----------------------------------------------------------------------------*/
void VKLocaleInit()
{
	char *lang = sys_lang = getenv("LANG");
	lang = lang ? strdup(lang) : strdup("en_US");
	if( !strstr(lang, ".UTF-8") ) {
		char env[256];
		char *p = strchr(lang, '.');
		if( p ) *p = 0;
		if( !strcmp(lang, "C") )
			p = strdup("vi_VN.UTF-8");
		else {
			p = (char *)malloc(strlen(lang)+8);
			sprintf(p, "%s%s", lang, ".UTF-8");
		}
		snprintf(env, sizeof(env), "LANG=%s", p);
		putenv(env);
		free(lang);
		lang = p;
	}
	if( !setlocale(LC_ALL, "") ) {
#ifndef USE_XFT
		// Cannot use XmbDrawingString in this case
		// to draw UTF-8 string => force back to English
		vk_interface = 0;
		sys_utf8 = 0;
#endif
	}
	free(lang);
}
/*----------------------------------------------------------------------------*/
#ifndef USE_XFT
char *VKXftFont2XFont(char *name)
{
	static char fn[128], *sep = ":";

	char s[128], *p, *face, *style = 0;
	int bold = 0, mode = 'r';

	strcpy(s, name);
	face = strtok(s, sep);
	p = strtok(NULL, sep);
	while( p ) {
		if( !strncasecmp(p, "style=", 6) )
			style = p+6;
		p = strtok(NULL, sep);
	}
	if( style ) {
		p = strtok(style, " ");
		while( p ) {
			if( !strcasecmp(p, "bold") )
				bold = 1;
			else
			if( !strcasecmp(p, "italic") ||
				!strcasecmp(p, "oblique") )
{'fraction_non_alphanumeric': 0.30713564456411985, 'fraction_numerical': 0.015819589363850556, 'mean_word_length': 0.8981156180134142, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1242401', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1551, 'n_words': 422}