ReactOS  0.4.15-dev-321-g2d9b385
strxfrm.c
Go to the documentation of this file.
1 #include <precomp.h>
2 
3 #include <locale.h>
4 #include <internal/wine/msvcrt.h>
5 
6 size_t CDECL _strxfrm_l( char *dest, const char *src,
7  size_t len, _locale_t locale )
8 {
10  int ret;
11 
12  if(!MSVCRT_CHECK_PMT(src)) return INT_MAX;
13  if(!MSVCRT_CHECK_PMT(dest || !len)) return INT_MAX;
14 
15  if(len > INT_MAX) {
16  FIXME("len > INT_MAX not supported\n");
17  len = INT_MAX;
18  }
19 
20  if(!locale)
21  locinfo = get_locinfo();
22  else
23  locinfo = ((MSVCRT__locale_t)locale)->locinfo;
24 
25  if(!locinfo->lc_handle[MSVCRT_LC_COLLATE]) {
26  strncpy(dest, src, len);
27  return strlen(src);
28  }
29 
31  LCMAP_SORTKEY, src, -1, NULL, 0);
32  if(!ret) {
33  if(len) dest[0] = 0;
34  *_errno() = EILSEQ;
35  return INT_MAX;
36  }
37  if(!len) return ret-1;
38 
39  if(ret > len) {
40  dest[0] = 0;
41  *_errno() = ERANGE;
42  return ret-1;
43  }
44 
45  return LCMapStringA(locinfo->lc_handle[MSVCRT_LC_COLLATE],
46  LCMAP_SORTKEY, src, -1, dest, len) - 1;
47 }
48 
49 /*********************************************************************
50  * strxfrm (MSVCRT.@)
51  */
52 size_t CDECL strxfrm( char *dest, const char *src, size_t len )
53 {
54  return _strxfrm_l(dest, src, len, NULL);
55 }
#define EILSEQ
Definition: errno.h:97
size_t CDECL strxfrm(char *dest, const char *src, size_t len)
Definition: strxfrm.c:52
struct MSVCRT_localeinfo_struct * MSVCRT__locale_t
#define INT_MAX
Definition: limits.h:40
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
Definition: _locale.h:75
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define get_locinfo()
Definition: winesup.h:25
size_t CDECL _strxfrm_l(char *dest, const char *src, size_t len, _locale_t locale)
Definition: strxfrm.c:6
#define LCMAP_SORTKEY
Definition: winnls.h:183
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19
#define ERANGE
Definition: acclib.h:92
int ret
else locinfo
Definition: scanf.h:159
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
#define CDECL
Definition: compat.h:21
static char * dest
Definition: rtl.c:135
#define MSVCRT_LC_COLLATE
Definition: msvcrt.h:651
INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen, LPSTR dst, INT dstlen)
Definition: lang.c:2047