Skip to content

Commit

Permalink
[KERNELBASE] locale.c
Browse files Browse the repository at this point in the history
  • Loading branch information
tkreuzer authored and DarkFire01 committed Nov 1, 2024
1 parent e102b88 commit 74de034
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
3 changes: 2 additions & 1 deletion dll/win32/KernelBase/wine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
list(APPEND SOURCE_STATIC
#console.c #looks like ReactOS console.c is nothing like wine.
loader.c
locale.c
version.c
volume.c)

add_library(kernelbase_static ${SOURCE_STATIC})
target_link_libraries(kernelbase_static ${PSEH_LIB})
add_dependencies(kernelbase_static psdk)
add_dependencies(kernelbase_static psdk)
51 changes: 47 additions & 4 deletions dll/win32/KernelBase/wine/locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(nls);

#define CALINFO_MAX_YEAR 2029

#ifdef __REACTOS__
//#define RtlEnterCriticalSection EnterCriticalSection
//#define RtlLeaveCriticalSection LeaveCriticalSection
#define CRITICAL_SECTION RTL_CRITICAL_SECTION
#define CRITICAL_SECTION_DEBUG RTL_CRITICAL_SECTION_DEBUG
#define swprintf snwprintf
#endif

static HMODULE kernelbase_handle;

struct registry_entry
Expand Down Expand Up @@ -433,7 +441,7 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
};
static CRITICAL_SECTION locale_section = { &critsect_debug, -1, 0, 0, 0, 0 };


#ifndef __REACTOS__
static void load_locale_nls(void)
{
struct
Expand Down Expand Up @@ -526,6 +534,7 @@ static void load_sortdefault_nls(void)
}


#endif
static const struct sortguid *find_sortguid( const GUID *guid )
{
int pos, ret, min = 0, max = sort.guid_count - 1;
Expand All @@ -548,6 +557,7 @@ static const NLS_LOCALE_DATA *get_locale_data( UINT idx )
ULONG offset = locale_table->locales_offset + idx * locale_table->locale_size;
return (const NLS_LOCALE_DATA *)((const char *)locale_table + offset);
}
#ifndef __REACTOS__


static const struct calendar *get_calendar_data( const NLS_LOCALE_DATA *locale, UINT id )
Expand All @@ -561,6 +571,7 @@ static const struct calendar *get_calendar_data( const NLS_LOCALE_DATA *locale,
}


#endif
static int compare_locale_names( const WCHAR *n1, const WCHAR *n2 )
{
for (;;)
Expand Down Expand Up @@ -606,6 +617,7 @@ static const NLS_LOCALE_LCID_INDEX *find_lcid_entry( LCID lcid )
}
return NULL;
}
#ifndef __REACTOS__


static const struct geo_id *find_geo_id_entry( GEOID id )
Expand Down Expand Up @@ -639,6 +651,7 @@ static const struct geo_id *find_geo_name_entry( const WCHAR *name )
}


#endif
static const NLS_LOCALE_DATA *get_locale_by_name( const WCHAR *name, LCID *lcid )
{
const NLS_LOCALE_LCNAME_INDEX *entry;
Expand Down Expand Up @@ -713,6 +726,7 @@ static const struct sortguid *get_language_sort( const WCHAR *name )
locale_sorts[entry - lcnames_index] = ret;
return ret;
}
#ifndef __REACTOS__


/******************************************************************************
Expand Down Expand Up @@ -2081,13 +2095,15 @@ static int casemap_string( const USHORT *table, const WCHAR *src, int srclen, WC
}


#endif
static union char_weights get_char_weights( WCHAR c, UINT except )
{
union char_weights ret;

ret.val = except ? sort.keys[sort.keys[except + (c >> 8)] + (c & 0xff)] : sort.keys[c];
return ret;
}
#ifndef __REACTOS__


static BYTE rol( BYTE val, BYTE count )
Expand Down Expand Up @@ -3268,6 +3284,7 @@ static int wcstombs_codepage( const CPTABLEINFO *info, DWORD flags, const WCHAR
}


#endif
struct sortkey
{
BYTE *buf;
Expand Down Expand Up @@ -3565,6 +3582,7 @@ static int append_hangul_weights( struct sortkey *key, const WCHAR *src, int src
append_sortkey( key, trailing_idx != -1 ? sort.jamo[trailing_idx].weight : 2 );
return pos - 1;
}
#ifndef __REACTOS__

/* put one of the elements of a sortkey into the dst buffer */
static int put_sortkey( BYTE *dst, int dstlen, int pos, const struct sortkey *key, BYTE terminator )
Expand All @@ -3578,6 +3596,7 @@ static int put_sortkey( BYTE *dst, int dstlen, int pos, const struct sortkey *ke
}


#endif
struct sortkey_state
{
struct sortkey key_primary;
Expand Down Expand Up @@ -3771,6 +3790,7 @@ static int append_weights( const struct sortguid *sortid, DWORD flags,

return ret;
}
#ifndef __REACTOS__

/* implementation of LCMAP_SORTKEY */
static int get_sortkey( const struct sortguid *sortid, DWORD flags,
Expand Down Expand Up @@ -3893,6 +3913,7 @@ static int compare_string( const struct sortguid *sortid, DWORD flags,
}


#endif
/* implementation of FindNLSStringEx */
static int find_substring( const struct sortguid *sortid, DWORD flags, const WCHAR *src, int srclen,
const WCHAR *value, int valuelen, int *reslen )
Expand Down Expand Up @@ -3981,6 +4002,7 @@ static int find_substring( const struct sortguid *sortid, DWORD flags, const WCH
free_sortkey_state( &val );
return found;
}
#ifndef __REACTOS__


/* map buffer to full-width katakana */
Expand Down Expand Up @@ -4221,6 +4243,7 @@ static int lcmap_string( const struct sortguid *sortid, DWORD flags,
}


#endif
static int compare_tzdate( const TIME_FIELDS *tf, const SYSTEMTIME *compare )
{
static const int month_lengths[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
Expand Down Expand Up @@ -4304,6 +4327,7 @@ static DWORD get_timezone_id( const TIME_ZONE_INFORMATION *info, LARGE_INTEGER t
}
return TIME_ZONE_ID_STANDARD;
}
#ifndef __REACTOS__


/* Note: the Internal_ functions are not documented. The number of parameters
Expand Down Expand Up @@ -4879,7 +4903,7 @@ INT WINAPI DECLSPEC_HOTPATCH CompareStringW( LCID lcid, DWORD flags, const WCHAR
return CompareStringEx( locale, flags, str1, len1, str2, len2, NULL, NULL, 0 );
}


#endif
/******************************************************************************
* CompareStringOrdinal (kernelbase.@)
*/
Expand All @@ -4901,6 +4925,7 @@ INT WINAPI DECLSPEC_HOTPATCH CompareStringOrdinal( const WCHAR *str1, INT len1,
if (ret > 0) return CSTR_GREATER_THAN;
return CSTR_EQUAL;
}
#ifndef __REACTOS__


/******************************************************************************
Expand Down Expand Up @@ -5182,7 +5207,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumTimeFormatsEx( TIMEFMT_ENUMPROCEX proc, const
flags, TRUE, TRUE, lparam );
}


#endif
/**************************************************************************
* FindNLSString (kernelbase.@)
*/
Expand Down Expand Up @@ -5246,6 +5271,7 @@ INT WINAPI DECLSPEC_HOTPATCH FindNLSStringEx( const WCHAR *locale, DWORD flags,

return find_substring( sortid, flags, src, srclen, value, valuelen, found );
}
#ifndef __REACTOS__


/******************************************************************************
Expand Down Expand Up @@ -5644,6 +5670,7 @@ INT WINAPI DECLSPEC_HOTPATCH GetCalendarInfoEx( const WCHAR *name, CALID calenda
}


#endif
static CRITICAL_SECTION tzname_section;
static CRITICAL_SECTION_DEBUG tzname_section_debug =
{
Expand All @@ -5666,6 +5693,10 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetDynamicTimeZoneInformation( DYNAMIC_TIME_ZONE_
{
HKEY key;
LARGE_INTEGER now;
#ifdef __REACTOS__
WCHAR system_dir[MAX_PATH];
GetSystemDirectoryW(system_dir, MAX_PATH);
#endif

if (!set_ntstatus( RtlQueryDynamicTimeZoneInformation( (RTL_DYNAMIC_TIME_ZONE_INFORMATION *)info )))
return TIME_ZONE_ID_INVALID;
Expand Down Expand Up @@ -5702,6 +5733,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetDynamicTimeZoneInformation( DYNAMIC_TIME_ZONE_
NtQuerySystemTime( &now );
return get_timezone_id( (TIME_ZONE_INFORMATION *)info, now, FALSE );
}
#ifndef __REACTOS__


/******************************************************************************
Expand Down Expand Up @@ -6249,13 +6281,15 @@ LANGID WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLangID(void)
}


//#endif
/***********************************************************************
* GetSystemDefaultLocaleName (kernelbase.@)
*/
INT WINAPI DECLSPEC_HOTPATCH GetSystemDefaultLocaleName( LPWSTR name, INT count )
{
return get_locale_info( system_locale, system_lcid, LOCALE_SNAME, name, count );
}
//#ifndef __REACTOS__


/***********************************************************************
Expand Down Expand Up @@ -6302,6 +6336,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetTimeZoneInformation( TIME_ZONE_INFORMATION *in
}


// here
/***********************************************************************
* GetTimeZoneInformationForYear (kernelbase.@)
*/
Expand Down Expand Up @@ -6376,6 +6411,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetTimeZoneInformationForYear( USHORT year,
if (ret) SetLastError( ret );
return !ret;
}
// end


/***********************************************************************
Expand Down Expand Up @@ -6457,6 +6493,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetUserPreferredUILanguages( DWORD flags, ULONG *c
}


// this
/******************************************************************************
* IdnToAscii (kernelbase.@)
*/
Expand Down Expand Up @@ -6491,7 +6528,7 @@ INT WINAPI DECLSPEC_HOTPATCH IdnToUnicode( DWORD flags, const WCHAR *src, INT sr
if (!set_ntstatus( status )) return 0;
return dstlen;
}

// end

/******************************************************************************
* IsCharAlphaA (kernelbase.@)
Expand Down Expand Up @@ -6662,6 +6699,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsDBCSLeadByteEx( UINT codepage, BYTE testchar )
}


// here
/******************************************************************************
* IsNormalizedString (kernelbase.@)
*/
Expand All @@ -6671,6 +6709,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsNormalizedString( NORM_FORM form, const WCHAR *s
if (!set_ntstatus( RtlIsNormalizedString( form, str, len, &res ))) res = FALSE;
return res;
}
// endif


/******************************************************************************
Expand Down Expand Up @@ -7055,6 +7094,7 @@ INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, co
}


// here
/******************************************************************************
* NormalizeString (kernelbase.@)
*/
Expand All @@ -7076,6 +7116,7 @@ INT WINAPI DECLSPEC_HOTPATCH NormalizeString(NORM_FORM form, const WCHAR *src, I
SetLastError( RtlNtStatusToDosError( status ));
return dst_len;
}
// end


/******************************************************************************
Expand Down Expand Up @@ -8374,3 +8415,5 @@ int WINAPI GetTimeFormatEx( const WCHAR *name, DWORD flags, const SYSTEMTIME *sy
TRACE( "(%s,%lx,%p,%s,%p,%d)\n", debugstr_w(name), flags, systime, debugstr_w(format), buffer, len );
return get_time_format( locale, flags, systime, format, buffer, len );
}

#endif // !__REACTOS__

0 comments on commit 74de034

Please sign in to comment.