<commit_before>/**
 * plat_path.c
 *
 * Copyright (c) 2012
 *	libchewing Core Team. See ChangeLog for details.
 *
 * See the file "COPYING" for information on usage and redistribution
 * of this file.
 */

#ifdef HAVE_CONFIG_H
  #include <config.h>
#endif
#include "plat_path.h"

#if !HAVE_ASPRINTF
#include <stdarg.h>
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "plat_types.h"

#ifdef UNDER_POSIX
#define SEARCH_PATH_SEP ":"
int get_search_path( char * path, size_t path_len )
{
	char *chewing_path;
	char *home;

	chewing_path = getenv( "CHEWING_PATH" );
	if ( chewing_path ) {
		strncpy( path, chewing_path, path_len );
	} else {
		home = getenv( "HOME" );
		if ( home ) {
			snprintf( path, path_len, "%s/.chewing" SEARCH_PATH_SEP
				LIBDIR "/chewing", home );
		} else {
			// No HOME ?
			strncpy( path, SEARCH_PATH_SEP LIBDIR "/chewing", path_len );
		}
	}

	return 0;
}

#elif defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
#define SEARCH_PATH_SEP ";"
int get_search_path( char * path, size_t path_len )
{
	char *chewing_path;
	char *appdata;

	chewing_path = getenv( "CHEWING_PATH" );
	if ( chewing_path ) {
		strncpy( path, chewing_path, path_len );
	} else {
		appdata = getenv( "APPDATA" );
		if ( appdata ) {
			snprintf( path, path_len, "%s", appdata );
		} else {
			return -1;
		}
	}

	return 0;
}
#else
#error please implement get_search_path
#endif<commit_msg>Fix default search path<commit_after>/**
 * plat_path.c
 *
 * Copyright (c) 2012
 *	libchewing Core Team. See ChangeLog for details.
 *
 * See the file "COPYING" for information on usage and redistribution
 * of this file.
 */

#ifdef HAVE_CONFIG_H
  #include <config.h>
#endif
#include "plat_path.h"

#if !HAVE_ASPRINTF
#include <stdarg.h>
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "plat_types.h"

#ifdef UNDER_POSIX
#define SEARCH_PATH_SEP ":"
int get_search_path( char * path, size_t path_len )
{
	char *chewing_path;
	char *home;

	chewing_path = getenv( "CHEWING_PATH" );
	if ( chewing_path ) {
		strncpy( path, chewing_path, path_len );
	} else {
		home = getenv( "HOME" );
		if ( home ) {
			snprintf( path, path_len, "%s/.chewing" SEARCH_PATH_SEP
				LIBDIR "/libchewing", home );
		} else {
			// No HOME ?
			strncpy( path, SEARCH_PATH_SEP LIBDIR "/libchewing", path_len );
		}
	}

	return 0;
}

#elif defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
#define SEARCH_PATH_SEP ";"
int get_search_path( char * path, size_t path_len )
{
	char *chewing_path;
	char *appdata;

	chewing_path = getenv( "CHEWING_PATH" );
	if ( chewing_path ) {
		strncpy( path, chewing_path, path_len );
	} else {
		appdata = getenv( "APPDATA" );
		if ( appdata ) {
			snprintf( path, path_len, "%s", appdata );
		} else {
			return -1;
		}
	}

	return 0;
}
#else
#error please implement get_search_path
#endif
{'fraction_non_alphanumeric': 0.13724137931034483, 'fraction_numerical': 0.00896551724137931, 'mean_word_length': 3.9169491525423727, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, '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': '799774', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1143, 'n_words': 286}