ReactOS  0.4.13-dev-79-gcd489d8
lcformat.c File Reference
#include "config.h"
#include "wine/port.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "winternl.h"
#include "kernel_private.h"
Include dependency graph for lcformat.c:

Go to the source code of this file.

Classes

struct  _NLS_FORMAT_NODE
 
struct  enumdateformats_context
 
struct  enumtimeformats_context
 
struct  enumcalendar_context
 

Macros

#define DATE_DATEVARSONLY   0x0100 /* only date stuff: yMdg */
 
#define TIME_TIMEVARSONLY   0x0200 /* only time stuff: hHmst */
 
#define NLS_NUM_CACHED_STRINGS   57
 
#define GetNegative(fmt)   fmt->lppszStrings[0]
 
#define GetLongDate(fmt)   fmt->lppszStrings[1]
 
#define GetShortDate(fmt)   fmt->lppszStrings[2]
 
#define GetTime(fmt)   fmt->lppszStrings[3]
 
#define GetAM(fmt)   fmt->lppszStrings[54]
 
#define GetPM(fmt)   fmt->lppszStrings[55]
 
#define GetYearMonth(fmt)   fmt->lppszStrings[56]
 
#define GetLongDay(fmt, day)   fmt->lppszStrings[4 + day]
 
#define GetShortDay(fmt, day)   fmt->lppszStrings[11 + day]
 
#define GetLongMonth(fmt, mth)   fmt->lppszStrings[18 + mth]
 
#define GetGenitiveMonth(fmt, mth)   fmt->lppszStrings[30 + mth]
 
#define GetShortMonth(fmt, mth)   fmt->lppszStrings[42 + mth]
 
#define GET_LOCALE_NUMBER(num, type)
 
#define GET_LOCALE_STRING(str, type)
 
#define IsLiteralMarker(p)   (p == '\'')
 
#define IsDateFmtChar(p)   (p == 'd'||p == 'M'||p == 'y'||p == 'g')
 
#define IsTimeFmtChar(p)   (p == 'H'||p == 'h'||p == 'm'||p == 's'||p == 't')
 
#define DATE_FORMAT_FLAGS   (DATE_DATEVARSONLY)
 
#define TIME_FORMAT_FLAGS
 
#define NF_ISNEGATIVE   0x1 /* '-' found */
 
#define NF_ISREAL   0x2 /* '.' found */
 
#define NF_DIGITS   0x4 /* '0'-'9' found */
 
#define NF_DIGITS_OUT   0x8 /* Digits before the '.' found */
 
#define NF_ROUND   0x10 /* Number needs to be rounded */
 
#define NLS_NEG_PARENS   0 /* "(1.1)" */
 
#define NLS_NEG_LEFT   1 /* "-1.1" */
 
#define NLS_NEG_LEFT_SPACE   2 /* "- 1.1" */
 
#define NLS_NEG_RIGHT   3 /* "1.1-" */
 
#define NLS_NEG_RIGHT_SPACE   4 /* "1.1 -" */
 
#define CF_PARENS   0x1 /* Parentheses */
 
#define CF_MINUS_LEFT   0x2 /* '-' to the left */
 
#define CF_MINUS_RIGHT   0x4 /* '-' to the right */
 
#define CF_MINUS_BEFORE   0x8 /* '-' before '$' */
 
#define CF_CY_LEFT   0x10 /* '$' to the left */
 
#define CF_CY_RIGHT   0x20 /* '$' to the right */
 
#define CF_CY_SPACE   0x40 /* ' ' by '$' */
 

Typedefs

typedef struct _NLS_FORMAT_NODE NLS_FORMAT_NODE
 

Enumerations

enum  enum_callback_type { CALLBACK_ENUMPROC, CALLBACK_ENUMPROCEX, CALLBACK_ENUMPROCEXEX }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (nls)
 
static DWORD NLS_GetLocaleNumber (LCID lcid, DWORD dwFlags)
 
static WCHARNLS_GetLocaleString (LCID lcid, DWORD dwFlags)
 
static const NLS_FORMAT_NODENLS_GetFormats (LCID lcid, DWORD dwFlags)
 
BOOL NLS_IsUnicodeOnlyLcid (LCID lcid)
 
static INT NLS_GetDateTimeFormatW (LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpStr, INT cchOut)
 
static INT NLS_GetDateTimeFormatA (LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpStr, INT cchOut)
 
INT WINAPI GetDateFormatA (LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
 
INT WINAPI GetDateFormatW (LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
 
INT WINAPI GetTimeFormatA (LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpTimeStr, INT cchOut)
 
INT WINAPI GetTimeFormatW (LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
 
INT WINAPI GetNumberFormatA (LCID lcid, DWORD dwFlags, LPCSTR lpszValue, const NUMBERFMTA *lpFormat, LPSTR lpNumberStr, int cchOut)
 
INT WINAPI GetNumberFormatW (LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
 
INT WINAPI GetCurrencyFormatA (LCID lcid, DWORD dwFlags, LPCSTR lpszValue, const CURRENCYFMTA *lpFormat, LPSTR lpCurrencyStr, int cchOut)
 
INT WINAPI GetCurrencyFormatW (LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
 
static BOOL NLS_EnumDateFormats (const struct enumdateformats_context *ctxt)
 
BOOL WINAPI EnumDateFormatsExA (DATEFMT_ENUMPROCEXA proc, LCID lcid, DWORD flags)
 
BOOL WINAPI EnumDateFormatsExW (DATEFMT_ENUMPROCEXW proc, LCID lcid, DWORD flags)
 
BOOL WINAPI EnumDateFormatsA (DATEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
 
BOOL WINAPI EnumDateFormatsW (DATEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
 
static BOOL NLS_EnumTimeFormats (struct enumtimeformats_context *ctxt)
 
BOOL WINAPI EnumTimeFormatsA (TIMEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
 
BOOL WINAPI EnumTimeFormatsW (TIMEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
 
static BOOL NLS_EnumCalendarInfo (const struct enumcalendar_context *ctxt)
 
BOOL WINAPI EnumCalendarInfoA (CALINFO_ENUMPROCA calinfoproc, LCID locale, CALID calendar, CALTYPE caltype)
 
BOOL WINAPI EnumCalendarInfoW (CALINFO_ENUMPROCW calinfoproc, LCID locale, CALID calendar, CALTYPE caltype)
 
BOOL WINAPI EnumCalendarInfoExA (CALINFO_ENUMPROCEXA calinfoproc, LCID locale, CALID calendar, CALTYPE caltype)
 
BOOL WINAPI EnumCalendarInfoExW (CALINFO_ENUMPROCEXW calinfoproc, LCID locale, CALID calendar, CALTYPE caltype)
 
int WINAPI GetCalendarInfoA (LCID lcid, CALID Calendar, CALTYPE CalType, LPSTR lpCalData, int cchData, LPDWORD lpValue)
 
int WINAPI GetCalendarInfoW (LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue)
 
int WINAPI SetCalendarInfoA (LCID Locale, CALID Calendar, CALTYPE CalType, LPCSTR lpCalData)
 
int WINAPI SetCalendarInfoW (LCID Locale, CALID Calendar, CALTYPE CalType, LPCWSTR lpCalData)
 

Variables

static CRITICAL_SECTION NLS_FormatsCS = { &NLS_FormatsCS_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG NLS_FormatsCS_debug
 

Macro Definition Documentation

◆ CF_CY_LEFT

#define CF_CY_LEFT   0x10 /* '$' to the left */

Definition at line 1555 of file lcformat.c.

◆ CF_CY_RIGHT

#define CF_CY_RIGHT   0x20 /* '$' to the right */

Definition at line 1556 of file lcformat.c.

◆ CF_CY_SPACE

#define CF_CY_SPACE   0x40 /* ' ' by '$' */

Definition at line 1557 of file lcformat.c.

◆ CF_MINUS_BEFORE

#define CF_MINUS_BEFORE   0x8 /* '-' before '$' */

Definition at line 1554 of file lcformat.c.

◆ CF_MINUS_LEFT

#define CF_MINUS_LEFT   0x2 /* '-' to the left */

Definition at line 1552 of file lcformat.c.

◆ CF_MINUS_RIGHT

#define CF_MINUS_RIGHT   0x4 /* '-' to the right */

Definition at line 1553 of file lcformat.c.

◆ CF_PARENS

#define CF_PARENS   0x1 /* Parentheses */

Definition at line 1551 of file lcformat.c.

◆ DATE_DATEVARSONLY

#define DATE_DATEVARSONLY   0x0100 /* only date stuff: yMdg */

Definition at line 66 of file lcformat.c.

◆ DATE_FORMAT_FLAGS

#define DATE_FORMAT_FLAGS   (DATE_DATEVARSONLY)

Definition at line 385 of file lcformat.c.

◆ GET_LOCALE_NUMBER

#define GET_LOCALE_NUMBER (   num,
  type 
)
Value:
TRACE( #type ": %d (%08x)\n", (DWORD)num, (DWORD)num)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
static DWORD NLS_GetLocaleNumber(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:128
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Definition at line 167 of file lcformat.c.

◆ GET_LOCALE_STRING

#define GET_LOCALE_STRING (   str,
  type 
)
Value:
TRACE( #type ": %s\n", debugstr_w(str))
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static WCHAR * NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:153

Definition at line 170 of file lcformat.c.

◆ GetAM

#define GetAM (   fmt)    fmt->lppszStrings[54]

Definition at line 98 of file lcformat.c.

◆ GetGenitiveMonth

#define GetGenitiveMonth (   fmt,
  mth 
)    fmt->lppszStrings[30 + mth]

Definition at line 105 of file lcformat.c.

◆ GetLongDate

#define GetLongDate (   fmt)    fmt->lppszStrings[1]

Definition at line 95 of file lcformat.c.

◆ GetLongDay

#define GetLongDay (   fmt,
  day 
)    fmt->lppszStrings[4 + day]

Definition at line 102 of file lcformat.c.

◆ GetLongMonth

#define GetLongMonth (   fmt,
  mth 
)    fmt->lppszStrings[18 + mth]

Definition at line 104 of file lcformat.c.

◆ GetNegative

#define GetNegative (   fmt)    fmt->lppszStrings[0]

Definition at line 94 of file lcformat.c.

◆ GetPM

#define GetPM (   fmt)    fmt->lppszStrings[55]

Definition at line 99 of file lcformat.c.

◆ GetShortDate

#define GetShortDate (   fmt)    fmt->lppszStrings[2]

Definition at line 96 of file lcformat.c.

◆ GetShortDay

#define GetShortDay (   fmt,
  day 
)    fmt->lppszStrings[11 + day]

Definition at line 103 of file lcformat.c.

◆ GetShortMonth

#define GetShortMonth (   fmt,
  mth 
)    fmt->lppszStrings[42 + mth]

Definition at line 106 of file lcformat.c.

◆ GetTime

#define GetTime (   fmt)    fmt->lppszStrings[3]

Definition at line 97 of file lcformat.c.

◆ GetYearMonth

#define GetYearMonth (   fmt)    fmt->lppszStrings[56]

Definition at line 100 of file lcformat.c.

◆ IsDateFmtChar

#define IsDateFmtChar (   p)    (p == 'd'||p == 'M'||p == 'y'||p == 'g')

Definition at line 378 of file lcformat.c.

◆ IsLiteralMarker

#define IsLiteralMarker (   p)    (p == '\'')

Definition at line 377 of file lcformat.c.

◆ IsTimeFmtChar

#define IsTimeFmtChar (   p)    (p == 'H'||p == 'h'||p == 'm'||p == 's'||p == 't')

Definition at line 379 of file lcformat.c.

◆ NF_DIGITS

#define NF_DIGITS   0x4 /* '0'-'9' found */

Definition at line 1182 of file lcformat.c.

◆ NF_DIGITS_OUT

#define NF_DIGITS_OUT   0x8 /* Digits before the '.' found */

Definition at line 1183 of file lcformat.c.

◆ NF_ISNEGATIVE

#define NF_ISNEGATIVE   0x1 /* '-' found */

Definition at line 1180 of file lcformat.c.

◆ NF_ISREAL

#define NF_ISREAL   0x2 /* '.' found */

Definition at line 1181 of file lcformat.c.

◆ NF_ROUND

#define NF_ROUND   0x10 /* Number needs to be rounded */

Definition at line 1184 of file lcformat.c.

◆ NLS_NEG_LEFT

#define NLS_NEG_LEFT   1 /* "-1.1" */

Definition at line 1188 of file lcformat.c.

◆ NLS_NEG_LEFT_SPACE

#define NLS_NEG_LEFT_SPACE   2 /* "- 1.1" */

Definition at line 1189 of file lcformat.c.

◆ NLS_NEG_PARENS

#define NLS_NEG_PARENS   0 /* "(1.1)" */

Definition at line 1187 of file lcformat.c.

◆ NLS_NEG_RIGHT

#define NLS_NEG_RIGHT   3 /* "1.1-" */

Definition at line 1190 of file lcformat.c.

◆ NLS_NEG_RIGHT_SPACE

#define NLS_NEG_RIGHT_SPACE   4 /* "1.1 -" */

Definition at line 1191 of file lcformat.c.

◆ NLS_NUM_CACHED_STRINGS

#define NLS_NUM_CACHED_STRINGS   57

Definition at line 78 of file lcformat.c.

◆ TIME_FORMAT_FLAGS

#define TIME_FORMAT_FLAGS
Value:
TIME_NOMINUTESORSECONDS|TIME_NOSECONDS| \
TIME_NOTIMEMARKER)
#define TIME_TIMEVARSONLY
Definition: lcformat.c:67
#define TIME_FORCE24HOURFORMAT
Definition: winnls.h:277
#define TIME_NOSECONDS
Definition: winnls.h:275

Definition at line 387 of file lcformat.c.

◆ TIME_TIMEVARSONLY

#define TIME_TIMEVARSONLY   0x0200 /* only time stuff: hHmst */

Definition at line 67 of file lcformat.c.

Typedef Documentation

◆ NLS_FORMAT_NODE

Enumeration Type Documentation

◆ enum_callback_type

Enumerator
CALLBACK_ENUMPROC 
CALLBACK_ENUMPROCEX 
CALLBACK_ENUMPROCEXEX 

Definition at line 1868 of file lcformat.c.

Function Documentation

◆ EnumCalendarInfoA()

BOOL WINAPI EnumCalendarInfoA ( CALINFO_ENUMPROCA  calinfoproc,
LCID  locale,
CALID  calendar,
CALTYPE  caltype 
)

Definition at line 2325 of file lcformat.c.

2327 {
2328  struct enumcalendar_context ctxt;
2329 
2330  TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2331 
2332  ctxt.type = CALLBACK_ENUMPROC;
2333  ctxt.u.callback = (CALINFO_ENUMPROCW)calinfoproc;
2334  ctxt.lcid = locale;
2335  ctxt.calendar = calendar;
2336  ctxt.caltype = caltype;
2337  ctxt.lParam = 0;
2338  ctxt.unicode = FALSE;
2339  return NLS_EnumCalendarInfo(&ctxt);
2340 }
Definition: _locale.h:75
BOOL(CALLBACK * CALINFO_ENUMPROCW)(LPWSTR)
Definition: winnls.h:525
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL NLS_EnumCalendarInfo(const struct enumcalendar_context *ctxt)
Definition: lcformat.c:2207
static const wchar_t void * locale
Definition: printf.c:73

◆ EnumCalendarInfoExA()

BOOL WINAPI EnumCalendarInfoExA ( CALINFO_ENUMPROCEXA  calinfoproc,
LCID  locale,
CALID  calendar,
CALTYPE  caltype 
)

Definition at line 2365 of file lcformat.c.

2367 {
2368  struct enumcalendar_context ctxt;
2369 
2370  TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2371 
2372  ctxt.type = CALLBACK_ENUMPROCEX;
2373  ctxt.u.callbackex = (CALINFO_ENUMPROCEXW)calinfoproc;
2374  ctxt.lcid = locale;
2375  ctxt.calendar = calendar;
2376  ctxt.caltype = caltype;
2377  ctxt.lParam = 0;
2378  ctxt.unicode = FALSE;
2379  return NLS_EnumCalendarInfo(&ctxt);
2380 }
Definition: _locale.h:75
#define TRACE(s)
Definition: solgame.cpp:4
BOOL(CALLBACK * CALINFO_ENUMPROCEXW)(LPWSTR, CALID)
Definition: winnls.h:527
static BOOL NLS_EnumCalendarInfo(const struct enumcalendar_context *ctxt)
Definition: lcformat.c:2207
static const wchar_t void * locale
Definition: printf.c:73

◆ EnumCalendarInfoExW()

BOOL WINAPI EnumCalendarInfoExW ( CALINFO_ENUMPROCEXW  calinfoproc,
LCID  locale,
CALID  calendar,
CALTYPE  caltype 
)

Definition at line 2385 of file lcformat.c.

2387 {
2388  struct enumcalendar_context ctxt;
2389 
2390  TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2391 
2392  ctxt.type = CALLBACK_ENUMPROCEX;
2393  ctxt.u.callbackex = calinfoproc;
2394  ctxt.lcid = locale;
2395  ctxt.calendar = calendar;
2396  ctxt.caltype = caltype;
2397  ctxt.lParam = 0;
2398  ctxt.unicode = TRUE;
2399  return NLS_EnumCalendarInfo(&ctxt);
2400 }
#define TRUE
Definition: types.h:120
Definition: _locale.h:75
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL NLS_EnumCalendarInfo(const struct enumcalendar_context *ctxt)
Definition: lcformat.c:2207
static const wchar_t void * locale
Definition: printf.c:73

◆ EnumCalendarInfoW()

BOOL WINAPI EnumCalendarInfoW ( CALINFO_ENUMPROCW  calinfoproc,
LCID  locale,
CALID  calendar,
CALTYPE  caltype 
)

Definition at line 2345 of file lcformat.c.

2347 {
2348  struct enumcalendar_context ctxt;
2349 
2350  TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2351 
2352  ctxt.type = CALLBACK_ENUMPROC;
2353  ctxt.u.callback = calinfoproc;
2354  ctxt.lcid = locale;
2355  ctxt.calendar = calendar;
2356  ctxt.caltype = caltype;
2357  ctxt.lParam = 0;
2358  ctxt.unicode = TRUE;
2359  return NLS_EnumCalendarInfo(&ctxt);
2360 }
#define TRUE
Definition: types.h:120
Definition: _locale.h:75
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL NLS_EnumCalendarInfo(const struct enumcalendar_context *ctxt)
Definition: lcformat.c:2207
static const wchar_t void * locale
Definition: printf.c:73

◆ EnumDateFormatsA()

BOOL WINAPI EnumDateFormatsA ( DATEFMT_ENUMPROCA  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 2001 of file lcformat.c.

2002 {
2003  struct enumdateformats_context ctxt;
2004 
2005  ctxt.type = CALLBACK_ENUMPROC;
2006  ctxt.u.callback = (DATEFMT_ENUMPROCW)proc;
2007  ctxt.lcid = lcid;
2008  ctxt.flags = flags;
2009  ctxt.unicode = FALSE;
2010 
2011  return NLS_EnumDateFormats(&ctxt);
2012 }
static HANDLE proc()
Definition: pdb.c:32
enum enum_callback_type type
Definition: lcformat.c:1875
static BOOL NLS_EnumDateFormats(const struct enumdateformats_context *ctxt)
Definition: lcformat.c:1898
GLbitfield flags
Definition: glext.h:7161
BOOL(CALLBACK * DATEFMT_ENUMPROCW)(LPWSTR)
Definition: winnls.h:540

Referenced by test_EnumDateFormatsA().

◆ EnumDateFormatsExA()

BOOL WINAPI EnumDateFormatsExA ( DATEFMT_ENUMPROCEXA  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 1966 of file lcformat.c.

1967 {
1968  struct enumdateformats_context ctxt;
1969 
1970  ctxt.type = CALLBACK_ENUMPROCEX;
1971  ctxt.u.callbackex = (DATEFMT_ENUMPROCEXW)proc;
1972  ctxt.lcid = lcid;
1973  ctxt.flags = flags;
1974  ctxt.unicode = FALSE;
1975 
1976  return NLS_EnumDateFormats(&ctxt);
1977 }
static HANDLE proc()
Definition: pdb.c:32
enum enum_callback_type type
Definition: lcformat.c:1875
static BOOL NLS_EnumDateFormats(const struct enumdateformats_context *ctxt)
Definition: lcformat.c:1898
BOOL(CALLBACK * DATEFMT_ENUMPROCEXW)(LPWSTR, CALID)
Definition: winnls.h:542
GLbitfield flags
Definition: glext.h:7161

◆ EnumDateFormatsExW()

BOOL WINAPI EnumDateFormatsExW ( DATEFMT_ENUMPROCEXW  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 1982 of file lcformat.c.

1983 {
1984  struct enumdateformats_context ctxt;
1985 
1986  ctxt.type = CALLBACK_ENUMPROCEX;
1987  ctxt.u.callbackex = proc;
1988  ctxt.lcid = lcid;
1989  ctxt.flags = flags;
1990  ctxt.unicode = TRUE;
1991 
1992  return NLS_EnumDateFormats(&ctxt);
1993 }
#define TRUE
Definition: types.h:120
static HANDLE proc()
Definition: pdb.c:32
enum enum_callback_type type
Definition: lcformat.c:1875
static BOOL NLS_EnumDateFormats(const struct enumdateformats_context *ctxt)
Definition: lcformat.c:1898
GLbitfield flags
Definition: glext.h:7161

◆ EnumDateFormatsW()

BOOL WINAPI EnumDateFormatsW ( DATEFMT_ENUMPROCW  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 2017 of file lcformat.c.

2018 {
2019  struct enumdateformats_context ctxt;
2020 
2021  ctxt.type = CALLBACK_ENUMPROC;
2022  ctxt.u.callback = proc;
2023  ctxt.lcid = lcid;
2024  ctxt.flags = flags;
2025  ctxt.unicode = TRUE;
2026 
2027  return NLS_EnumDateFormats(&ctxt);
2028 }
#define TRUE
Definition: types.h:120
static HANDLE proc()
Definition: pdb.c:32
enum enum_callback_type type
Definition: lcformat.c:1875
static BOOL NLS_EnumDateFormats(const struct enumdateformats_context *ctxt)
Definition: lcformat.c:1898
GLbitfield flags
Definition: glext.h:7161

Referenced by InitLongDateCB(), and InitShortDateCB().

◆ EnumTimeFormatsA()

BOOL WINAPI EnumTimeFormatsA ( TIMEFMT_ENUMPROCA  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 2118 of file lcformat.c.

2119 {
2120  struct enumtimeformats_context ctxt;
2121 
2122  /* EnumTimeFormatsA doesn't support flags, EnumTimeFormatsW does. */
2123  if (flags & ~LOCALE_USE_CP_ACP)
2124  {
2126  return FALSE;
2127  }
2128 
2129  ctxt.type = CALLBACK_ENUMPROC;
2130  ctxt.u.callback = (TIMEFMT_ENUMPROCW)proc;
2131  ctxt.lcid = lcid;
2132  ctxt.flags = flags;
2133  ctxt.unicode = FALSE;
2134 
2135  return NLS_EnumTimeFormats(&ctxt);
2136 }
static HANDLE proc()
Definition: pdb.c:32
#define SetLastError(x)
Definition: compat.h:409
GLbitfield flags
Definition: glext.h:7161
static BOOL NLS_EnumTimeFormats(struct enumtimeformats_context *ctxt)
Definition: lcformat.c:2061
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
BOOL(CALLBACK * TIMEFMT_ENUMPROCW)(LPWSTR)
Definition: winnls.h:544
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583

Referenced by test_EnumTimeFormatsA(), and test_EnumTimeFormatsW().

◆ EnumTimeFormatsW()

BOOL WINAPI EnumTimeFormatsW ( TIMEFMT_ENUMPROCW  proc,
LCID  lcid,
DWORD  flags 
)

Definition at line 2141 of file lcformat.c.

2142 {
2143  struct enumtimeformats_context ctxt;
2144 
2145  ctxt.type = CALLBACK_ENUMPROC;
2146  ctxt.u.callback = proc;
2147  ctxt.lcid = lcid;
2148  ctxt.flags = flags;
2149  ctxt.unicode = TRUE;
2150 
2151  return NLS_EnumTimeFormats(&ctxt);
2152 }
#define TRUE
Definition: types.h:120
static HANDLE proc()
Definition: pdb.c:32
GLbitfield flags
Definition: glext.h:7161
static BOOL NLS_EnumTimeFormats(struct enumtimeformats_context *ctxt)
Definition: lcformat.c:2061
enum enum_callback_type type
Definition: lcformat.c:2050

Referenced by InitTimeFormatCB(), and test_EnumTimeFormatsW().

◆ GetCalendarInfoA()

int WINAPI GetCalendarInfoA ( LCID  lcid,
CALID  Calendar,
CALTYPE  CalType,
LPSTR  lpCalData,
int  cchData,
LPDWORD  lpValue 
)

Definition at line 2428 of file lcformat.c.

2430 {
2431  int ret, cchDataW = cchData;
2432  LPWSTR lpCalDataW = NULL;
2433 #ifdef __REACTOS__
2434  DWORD cp = CP_ACP;
2435  if (!(CalType & CAL_USE_CP_ACP))
2436  {
2437  DWORD dwFlags = ((CalType & CAL_NOUSEROVERRIDE) ? LOCALE_NOUSEROVERRIDE : 0);
2439  if (!node)
2440  {
2442  return 0;
2443  }
2444  cp = node->dwCodePage;
2445  }
2446  if ((CalType & 0xFFFF) == CAL_SABBREVERASTRING)
2447  {
2448  /* NOTE: CAL_SABBREVERASTRING is not supported in GetCalendarInfoA */
2450  return 0;
2451  }
2452 #endif
2453 
2455  {
2457  return 0;
2458  }
2459 
2460  if (!cchData && !(CalType & CAL_RETURN_NUMBER))
2461  cchDataW = GetCalendarInfoW(lcid, Calendar, CalType, NULL, 0, NULL);
2462  if (!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchDataW*sizeof(WCHAR))))
2463  return 0;
2464 
2465  ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchDataW, lpValue);
2466  if(ret && lpCalDataW && lpCalData)
2467 #ifdef __REACTOS__
2468  ret = WideCharToMultiByte(cp, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
2469 #else
2470  ret = WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
2471 #endif
2472  else if (CalType & CAL_RETURN_NUMBER)
2473  ret *= sizeof(WCHAR);
2474  HeapFree(GetProcessHeap(), 0, lpCalDataW);
2475 
2476  return ret;
2477 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
Definition: lcformat.c:350
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
POINT cp
Definition: magnifier.c:60
#define CAL_SABBREVERASTRING
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2483
Definition: dlist.c:348

Referenced by NLS_EnumCalendarInfo(), and START_TEST().

◆ GetCalendarInfoW()

int WINAPI GetCalendarInfoW ( LCID  Locale,
CALID  Calendar,
CALTYPE  CalType,
LPWSTR  lpCalData,
int  cchData,
LPDWORD  lpValue 
)

Definition at line 2483 of file lcformat.c.

2485 {
2486  static const LCTYPE caltype_lctype_map[] = {
2487  0, /* not used */
2488  0, /* CAL_ICALINTVALUE */
2489  0, /* CAL_SCALNAME */
2490  0, /* CAL_IYEAROFFSETRANGE */
2491  0, /* CAL_SERASTRING */
2534  LOCALE_SYEARMONTH,
2535  0, /* CAL_ITWODIGITYEARMAX */
2536 #if (WINVER >= 0x0600) /* ReactOS */
2537  LOCALE_SSHORTESTDAYNAME1,
2538  LOCALE_SSHORTESTDAYNAME2,
2539  LOCALE_SSHORTESTDAYNAME3,
2540  LOCALE_SSHORTESTDAYNAME4,
2541  LOCALE_SSHORTESTDAYNAME5,
2542  LOCALE_SSHORTESTDAYNAME6,
2543  LOCALE_SSHORTESTDAYNAME7,
2544 #endif
2546  0, /* CAL_SABBREVERASTRING */
2547  };
2548  DWORD localeflags = 0;
2549  CALTYPE calinfo;
2550 
2551  if (CalType & CAL_NOUSEROVERRIDE)
2552  FIXME("flag CAL_NOUSEROVERRIDE used, not fully implemented\n");
2553  if (CalType & CAL_USE_CP_ACP)
2554  FIXME("flag CAL_USE_CP_ACP used, not fully implemented\n");
2555 
2556  if (CalType & CAL_RETURN_NUMBER) {
2557  if (!lpValue)
2558  {
2560  return 0;
2561  }
2562  if (lpCalData != NULL)
2563  WARN("lpCalData not NULL (%p) when it should!\n", lpCalData);
2564  if (cchData != 0)
2565  WARN("cchData not 0 (%d) when it should!\n", cchData);
2566  } else {
2567  if (lpValue != NULL)
2568  WARN("lpValue not NULL (%p) when it should!\n", lpValue);
2569  }
2570 
2571  /* FIXME: No verification is made yet wrt Locale
2572  * for the CALTYPES not requiring GetLocaleInfoA */
2573 
2574  calinfo = CalType & 0xffff;
2575 
2576 #ifdef __REACTOS__
2577  if (CalType & LOCALE_RETURN_GENITIVE_NAMES)
2578 #else
2579  if (CalType & CAL_RETURN_GENITIVE_NAMES)
2580 #endif
2581  localeflags |= LOCALE_RETURN_GENITIVE_NAMES;
2582 
2583  switch (calinfo) {
2584  case CAL_ICALINTVALUE:
2585 #ifdef __REACTOS__
2586  if (IS_LCID_JAPANESE(Locale))
2587  {
2588  if (CalType & CAL_RETURN_NUMBER)
2589  {
2590  *lpValue = CAL_JAPAN;
2591  return sizeof(DWORD) / sizeof(WCHAR);
2592  }
2593  else
2594  {
2595  static const WCHAR fmtW[] = {'%','u',0};
2596  WCHAR buffer[10];
2597  int ret = snprintfW( buffer, 10, fmtW, CAL_JAPAN ) + 1;
2598  if (!lpCalData) return ret;
2599  if (ret <= cchData)
2600  {
2601  strcpyW( lpCalData, buffer );
2602  return ret;
2603  }
2605  return 0;
2606  }
2607  }
2608 #endif
2609  if (CalType & CAL_RETURN_NUMBER)
2610  return GetLocaleInfoW(Locale, LOCALE_RETURN_NUMBER | LOCALE_ICALENDARTYPE,
2611  (LPWSTR)lpValue, 2);
2612  return GetLocaleInfoW(Locale, LOCALE_ICALENDARTYPE, lpCalData, cchData);
2613  case CAL_SCALNAME:
2614 #ifdef __REACTOS__
2615  if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2616  {
2617  // Wareki
2618  lpCalData[0] = 0x548C;
2619  lpCalData[1] = 0x66A6;
2620  lpCalData[2] = 0;
2621  return 3;
2622  }
2623 #endif
2624  FIXME("Unimplemented caltype %d\n", calinfo);
2625  if (lpCalData) *lpCalData = 0;
2626  return 1;
2627  case CAL_IYEAROFFSETRANGE:
2628 #ifdef __REACTOS__
2629  if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2630  {
2632  if (pEra)
2633  {
2634  if (CalType & CAL_RETURN_NUMBER)
2635  {
2636  *lpValue = pEra->wYear;
2637  return sizeof(DWORD) / sizeof(WCHAR);
2638  }
2639  else
2640  {
2641  static const WCHAR fmtW[] = {'%','u',0};
2642  WCHAR buffer[10];
2643  int ret = snprintfW( buffer, 10, fmtW, pEra->wYear ) + 1;
2644  if (!lpCalData) return ret;
2645  if (ret <= cchData)
2646  {
2647  strcpyW( lpCalData, buffer );
2648  return ret;
2649  }
2651  return 0;
2652  }
2653  }
2654  else
2655  {
2657  return 0;
2658  }
2659  }
2660 #endif
2661  FIXME("Unimplemented caltype %d\n", calinfo);
2662  return 0;
2663  case CAL_SERASTRING:
2664 #ifdef __REACTOS__
2665  if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2666  {
2668  if (pEra)
2669  {
2670  RtlStringCchCopyW(lpCalData, cchData, pEra->szEraName);
2671  return strlenW(lpCalData) + 1;
2672  }
2673  else
2674  {
2676  return 0;
2677  }
2678  }
2679 #endif
2680  FIXME("Unimplemented caltype %d\n", calinfo);
2681  return 0;
2682  case CAL_SSHORTDATE:
2683  case CAL_SLONGDATE:
2684  case CAL_SDAYNAME1:
2685  case CAL_SDAYNAME2:
2686  case CAL_SDAYNAME3:
2687  case CAL_SDAYNAME4:
2688  case CAL_SDAYNAME5:
2689  case CAL_SDAYNAME6:
2690  case CAL_SDAYNAME7:
2691  case CAL_SABBREVDAYNAME1:
2692  case CAL_SABBREVDAYNAME2:
2693  case CAL_SABBREVDAYNAME3:
2694  case CAL_SABBREVDAYNAME4:
2695  case CAL_SABBREVDAYNAME5:
2696  case CAL_SABBREVDAYNAME6:
2697  case CAL_SABBREVDAYNAME7:
2698  case CAL_SMONTHNAME1:
2699  case CAL_SMONTHNAME2:
2700  case CAL_SMONTHNAME3:
2701  case CAL_SMONTHNAME4:
2702  case CAL_SMONTHNAME5:
2703  case CAL_SMONTHNAME6:
2704  case CAL_SMONTHNAME7:
2705  case CAL_SMONTHNAME8:
2706  case CAL_SMONTHNAME9:
2707  case CAL_SMONTHNAME10:
2708  case CAL_SMONTHNAME11:
2709  case CAL_SMONTHNAME12:
2710  case CAL_SMONTHNAME13:
2711  case CAL_SABBREVMONTHNAME1:
2712  case CAL_SABBREVMONTHNAME2:
2713  case CAL_SABBREVMONTHNAME3:
2714  case CAL_SABBREVMONTHNAME4:
2715  case CAL_SABBREVMONTHNAME5:
2716  case CAL_SABBREVMONTHNAME6:
2717  case CAL_SABBREVMONTHNAME7:
2718  case CAL_SABBREVMONTHNAME8:
2719  case CAL_SABBREVMONTHNAME9:
2724  case CAL_SYEARMONTH:
2725  return GetLocaleInfoW(Locale, caltype_lctype_map[calinfo] | localeflags, lpCalData, cchData);
2726  case CAL_ITWODIGITYEARMAX:
2727 #ifdef __REACTOS__
2728  if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2729  {
2730  if (CalType & CAL_RETURN_NUMBER)
2731  {
2732  *lpValue = JAPANESE_MAX_TWODIGITYEAR;
2733  return sizeof(DWORD) / sizeof(WCHAR);
2734  }
2735  else
2736  {
2737  static const WCHAR fmtW[] = {'%','u',0};
2738  WCHAR buffer[10];
2739  int ret = snprintfW( buffer, 10, fmtW, JAPANESE_MAX_TWODIGITYEAR ) + 1;
2740  if (!lpCalData) return ret;
2741  if (ret <= cchData)
2742  {
2743  strcpyW( lpCalData, buffer );
2744  return ret;
2745  }
2747  return 0;
2748  }
2749  }
2750 #endif
2751  if (CalType & CAL_RETURN_NUMBER)
2752  {
2753  *lpValue = CALINFO_MAX_YEAR;
2754  return sizeof(DWORD) / sizeof(WCHAR);
2755  }
2756  else
2757  {
2758  static const WCHAR fmtW[] = {'%','u',0};
2759  WCHAR buffer[10];
2760  int ret = snprintfW( buffer, 10, fmtW, CALINFO_MAX_YEAR ) + 1;
2761  if (!lpCalData) return ret;
2762  if (ret <= cchData)
2763  {
2764  strcpyW( lpCalData, buffer );
2765  return ret;
2766  }
2768  return 0;
2769  }
2770  break;
2771 #ifdef __REACTOS__
2772  case CAL_SABBREVERASTRING:
2773  if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2774  {
2776  if (pEra)
2777  {
2778  RtlStringCchCopyW(lpCalData, cchData, pEra->szEraAbbrev);
2779  return strlenW(lpCalData) + 1;
2780  }
2781  }
2783  return 0;
2784 #endif
2785  default:
2786  FIXME("Unknown caltype %d\n", calinfo);
2788  return 0;
2789  }
2790  return 0;
2791 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CAL_SDAYNAME6
Definition: winnls.h:405
#define CAL_SCALNAME
Definition: winnls.h:395
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define CAL_SABBREVMONTHNAME12
Definition: winnls.h:438
#define snprintfW
Definition: unicode.h:60
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define WARN(fmt,...)
Definition: debug.h:111
#define CAL_SMONTHNAME1
Definition: winnls.h:414
#define LOCALE_SMONTHNAME13
Definition: winnls.h:103
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_ICALENDARTYPE
Definition: winnls.h:73
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
GLuint buffer
Definition: glext.h:5915
#define CAL_SERASTRING
Definition: winnls.h:397
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define DWORD
Definition: nt_native.h:44
#define CAL_SMONTHNAME4
Definition: winnls.h:417
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define CAL_SDAYNAME3
Definition: winnls.h:402
#define LOCALE_RETURN_GENITIVE_NAMES
Definition: winnls.h:24
#define CAL_SABBREVMONTHNAME7
Definition: winnls.h:433
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
#define CAL_SABBREVDAYNAME2
Definition: winnls.h:408
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define CAL_SDAYNAME7
Definition: winnls.h:406
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
DWORD LCTYPE
Definition: winnls.h:514
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define CAL_SABBREVDAYNAME3
Definition: winnls.h:409
#define CAL_SABBREVMONTHNAME10
Definition: winnls.h:436
#define CAL_SABBREVMONTHNAME4
Definition: winnls.h:430
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define FIXME(fmt,...)
Definition: debug.h:110
#define CAL_SSHORTDATE
Definition: winnls.h:398
#define CAL_SABBREVMONTHNAME3
Definition: winnls.h:429
#define CAL_JAPAN
Definition: winnls.h:442
#define CAL_SMONTHNAME13
Definition: winnls.h:426
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
smooth NULL
Definition: ftsmooth.c:416
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SABBREVMONTHNAME13
Definition: winnls.h:116
#define CAL_SABBREVDAYNAME1
Definition: winnls.h:407
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define CAL_SMONTHNAME7
Definition: winnls.h:420
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CAL_ICALINTVALUE
Definition: winnls.h:394
#define CAL_SDAYNAME2
Definition: winnls.h:401
WCHAR szEraName[16]
Definition: japanese.h:14
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
PCJAPANESE_ERA JapaneseEra_Find(const SYSTEMTIME *pst OPTIONAL)
Definition: japanese.c:236
#define CAL_SMONTHNAME6
Definition: winnls.h:419
#define CAL_SLONGDATE
Definition: winnls.h:399
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define CAL_IYEAROFFSETRANGE
Definition: winnls.h:396
#define JAPANESE_MAX_TWODIGITYEAR
Definition: japanese.h:7
DWORD CALTYPE
Definition: winnls.h:515
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
int ret
#define CAL_SMONTHNAME12
Definition: winnls.h:425
#define CAL_SMONTHNAME11
Definition: winnls.h:424
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define CAL_SABBREVDAYNAME4
Definition: winnls.h:410
#define CAL_SABBREVMONTHNAME1
Definition: winnls.h:427
#define CAL_SABBREVMONTHNAME13
Definition: winnls.h:439
#define CAL_SMONTHNAME5
Definition: winnls.h:418
#define CAL_SMONTHNAME2
Definition: winnls.h:415
#define CAL_SABBREVMONTHNAME11
Definition: winnls.h:437
#define CAL_SMONTHNAME10
Definition: winnls.h:423
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:135
#define CAL_SABBREVMONTHNAME6
Definition: winnls.h:432
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define CAL_SDAYNAME1
Definition: winnls.h:400
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define CAL_SABBREVDAYNAME6
Definition: winnls.h:412
#define LOCALE_SMONTHDAY
Definition: winnls.h:159
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
#define CAL_SABBREVERASTRING
#define CAL_SABBREVMONTHNAME5
Definition: winnls.h:431
#define CAL_SMONTHNAME3
Definition: winnls.h:416
WCHAR szEraAbbrev[5]
Definition: japanese.h:15
#define CAL_SMONTHNAME8
Definition: winnls.h:421
#define CAL_SABBREVDAYNAME5
Definition: winnls.h:411
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define CAL_SABBREVMONTHNAME9
Definition: winnls.h:435
#define CAL_SABBREVDAYNAME7
Definition: winnls.h:413
#define CAL_SABBREVMONTHNAME2
Definition: winnls.h:428
#define CAL_SDAYNAME5
Definition: winnls.h:404
WORD wYear
Definition: japanese.h:11
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define CAL_SMONTHNAME9
Definition: winnls.h:422
#define CAL_SABBREVMONTHNAME8
Definition: winnls.h:434
#define CAL_SDAYNAME4
Definition: winnls.h:403
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetCalendarInfoA(), GetMaxDate(), NLS_EnumCalendarInfo(), and START_TEST().

◆ GetCurrencyFormatA()

INT WINAPI GetCurrencyFormatA ( LCID  lcid,
DWORD  dwFlags,
LPCSTR  lpszValue,
const CURRENCYFMTA lpFormat,
LPSTR  lpCurrencyStr,
int  cchOut 
)

Definition at line 1482 of file lcformat.c.

1485 {
1486  DWORD cp = CP_ACP;
1487  WCHAR szDec[8], szGrp[8], szCy[8], szIn[128], szOut[128];
1488  CURRENCYFMTW fmt;
1489  const CURRENCYFMTW *pfmt = NULL;
1490  INT iRet;
1491 
1492  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
1493  lpFormat, lpCurrencyStr, cchOut);
1494 
1496  {
1498  return 0;
1499  }
1500 
1501  if (!(dwFlags & LOCALE_USE_CP_ACP))
1502  {
1504  if (!node)
1505  {
1507  return 0;
1508  }
1509 
1510  cp = node->dwCodePage;
1511  }
1512 
1513  if (lpFormat)
1514  {
1515  memcpy(&fmt, lpFormat, sizeof(fmt));
1516  pfmt = &fmt;
1517  if (lpFormat->lpDecimalSep)
1518  {
1519  MultiByteToWideChar(cp, 0, lpFormat->lpDecimalSep, -1, szDec, ARRAY_SIZE(szDec));
1520  fmt.lpDecimalSep = szDec;
1521  }
1522  if (lpFormat->lpThousandSep)
1523  {
1524  MultiByteToWideChar(cp, 0, lpFormat->lpThousandSep, -1, szGrp, ARRAY_SIZE(szGrp));
1525  fmt.lpThousandSep = szGrp;
1526  }
1527  if (lpFormat->lpCurrencySymbol)
1528  {
1529  MultiByteToWideChar(cp, 0, lpFormat->lpCurrencySymbol, -1, szCy, ARRAY_SIZE(szCy));
1530  fmt.lpCurrencySymbol = szCy;
1531  }
1532  }
1533 
1534  if (lpszValue)
1535  MultiByteToWideChar(cp, 0, lpszValue, -1, szIn, ARRAY_SIZE(szIn));
1536 
1537  if (cchOut > (int) ARRAY_SIZE(szOut))
1538  cchOut = ARRAY_SIZE(szOut);
1539 
1540  szOut[0] = '\0';
1541 
1542  iRet = GetCurrencyFormatW(lcid, dwFlags, lpszValue ? szIn : NULL, pfmt,
1543  lpCurrencyStr ? szOut : NULL, cchOut);
1544 
1545  if (szOut[0] && lpCurrencyStr)
1546  WideCharToMultiByte(cp, 0, szOut, -1, lpCurrencyStr, cchOut, 0, 0);
1547  return iRet;
1548 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
Definition: lcformat.c:1564
const char * fmt
Definition: wsprintf.c:30
int32_t INT
Definition: typedefs.h:56
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
Definition: lcformat.c:350
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:100
POINT cp
Definition: magnifier.c:60
Definition: dsound.c:943
Definition: dlist.c:348

Referenced by test_GetCurrencyFormatA().

◆ GetCurrencyFormatW()

INT WINAPI GetCurrencyFormatW ( LCID  lcid,
DWORD  dwFlags,
LPCWSTR  lpszValue,
const CURRENCYFMTW lpFormat,
LPWSTR  lpCurrencyStr,
int  cchOut 
)

Definition at line 1564 of file lcformat.c.

1567 {
1568  static const BYTE NLS_NegCyFormats[16] =
1569  {
1570  CF_PARENS|CF_CY_LEFT, /* ($1.1) */
1572  CF_MINUS_LEFT|CF_CY_LEFT, /* $-1.1 */
1573  CF_MINUS_RIGHT|CF_CY_LEFT, /* $1.1- */
1574  CF_PARENS|CF_CY_RIGHT, /* (1.1$) */
1575  CF_MINUS_LEFT|CF_CY_RIGHT, /* -1.1$ */
1577  CF_MINUS_RIGHT|CF_CY_RIGHT, /* 1.1$- */
1578  CF_MINUS_LEFT|CF_CY_RIGHT|CF_CY_SPACE, /* -1.1 $ */
1580  CF_MINUS_RIGHT|CF_CY_RIGHT|CF_CY_SPACE, /* 1.1 $- */
1581  CF_MINUS_RIGHT|CF_CY_LEFT|CF_CY_SPACE, /* $ 1.1- */
1582  CF_MINUS_LEFT|CF_CY_LEFT|CF_CY_SPACE, /* $ -1.1 */
1584  CF_PARENS|CF_CY_LEFT|CF_CY_SPACE, /* ($ 1.1) */
1585  CF_PARENS|CF_CY_RIGHT|CF_CY_SPACE, /* (1.1 $) */
1586  };
1587  static const BYTE NLS_PosCyFormats[4] =
1588  {
1589  CF_CY_LEFT, /* $1.1 */
1590  CF_CY_RIGHT, /* 1.1$ */
1591  CF_CY_LEFT|CF_CY_SPACE, /* $ 1.1 */
1592  CF_CY_RIGHT|CF_CY_SPACE, /* 1.1 $ */
1593  };
1594  WCHAR szBuff[128], *szOut = szBuff + ARRAY_SIZE(szBuff) - 1;
1595  WCHAR szNegBuff[8];
1596  const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc, *lpszCy, *lpszCyStart;
1597  DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0, dwFmt;
1598  INT iRet;
1599 
1600  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
1601  lpFormat, lpCurrencyStr, cchOut);
1602 
1603  if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
1604  !IsValidLocale(lcid, 0) ||
1605  (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
1606  !lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
1607  lpFormat->PositiveOrder > 3)))
1608  {
1609  goto error;
1610  }
1611 
1612  if (!lpFormat)
1613  {
1615 
1616  if (!node)
1617  goto error;
1618 
1619  lpFormat = &node->cyfmt;
1620  lpszNegStart = lpszNeg = GetNegative(node);
1621  }
1622  else
1623  {
1625  szNegBuff, ARRAY_SIZE(szNegBuff));
1626  lpszNegStart = lpszNeg = szNegBuff;
1627  }
1629 
1630  lpszNeg = lpszNeg + strlenW(lpszNeg) - 1;
1631  lpszCyStart = lpFormat->lpCurrencySymbol;
1632  lpszCy = lpszCyStart + strlenW(lpszCyStart) - 1;
1633 
1634  /* Format the currency backwards into a temporary buffer */
1635 
1636  szSrc = lpszValue;
1637  *szOut-- = '\0';
1638 
1639  /* Check the number for validity */
1640  while (*szSrc)
1641  {
1642  if (*szSrc >= '0' && *szSrc <= '9')
1643  {
1644  dwState |= NF_DIGITS;
1645  if (dwState & NF_ISREAL)
1646  dwDecimals++;
1647  }
1648  else if (*szSrc == '-')
1649  {
1650  if (dwState)
1651  goto error; /* '-' not first character */
1652  dwState |= NF_ISNEGATIVE;
1653  }
1654  else if (*szSrc == '.')
1655  {
1656  if (dwState & NF_ISREAL)
1657  goto error; /* More than one '.' */
1658  dwState |= NF_ISREAL;
1659  }
1660  else
1661  goto error; /* Invalid char */
1662  szSrc++;
1663  }
1664  szSrc--; /* Point to last character */
1665 
1666  if (!(dwState & NF_DIGITS))
1667  goto error; /* No digits */
1668 
1669  if (dwState & NF_ISNEGATIVE)
1670  dwFmt = NLS_NegCyFormats[lpFormat->NegativeOrder];
1671  else
1672  dwFmt = NLS_PosCyFormats[lpFormat->PositiveOrder];
1673 
1674  /* Add any trailing negative or currency signs */
1675  if (dwFmt & CF_PARENS)
1676  *szOut-- = ')';
1677 
1678  while (dwFmt & (CF_MINUS_RIGHT|CF_CY_RIGHT))
1679  {
1680  switch (dwFmt & (CF_MINUS_RIGHT|CF_MINUS_BEFORE|CF_CY_RIGHT))
1681  {
1682  case CF_MINUS_RIGHT:
1684  while (lpszNeg >= lpszNegStart)
1685  *szOut-- = *lpszNeg--;
1686  dwFmt &= ~CF_MINUS_RIGHT;
1687  break;
1688 
1689  case CF_CY_RIGHT:
1692  while (lpszCy >= lpszCyStart)
1693  *szOut-- = *lpszCy--;
1694  if (dwFmt & CF_CY_SPACE)
1695  *szOut-- = ' ';
1696  dwFmt &= ~(CF_CY_RIGHT|CF_MINUS_BEFORE);
1697  break;
1698  }
1699  }
1700 
1701  /* Copy all digits up to the decimal point */
1702  if (!lpFormat->NumDigits)
1703  {
1704  if (dwState & NF_ISREAL)
1705  {
1706  while (*szSrc != '.') /* Don't write any decimals or a separator */
1707  {
1708  if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1709  dwState |= NF_ROUND;
1710  else
1711  dwState &= ~NF_ROUND;
1712  szSrc--;
1713  }
1714  szSrc--;
1715  }
1716  }
1717  else
1718  {
1719  LPWSTR lpszDec = lpFormat->lpDecimalSep + strlenW(lpFormat->lpDecimalSep) - 1;
1720 
1721  if (dwDecimals <= lpFormat->NumDigits)
1722  {
1723  dwDecimals = lpFormat->NumDigits - dwDecimals;
1724  while (dwDecimals--)
1725  *szOut-- = '0'; /* Pad to correct number of dp */
1726  }
1727  else
1728  {
1729  dwDecimals -= lpFormat->NumDigits;
1730  /* Skip excess decimals, and determine if we have to round the number */
1731  while (dwDecimals--)
1732  {
1733  if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1734  dwState |= NF_ROUND;
1735  else
1736  dwState &= ~NF_ROUND;
1737  szSrc--;
1738  }
1739  }
1740 
1741  if (dwState & NF_ISREAL)
1742  {
1743  while (*szSrc != '.')
1744  {
1745  if (dwState & NF_ROUND)
1746  {
1747  if (*szSrc == '9')
1748  *szOut-- = '0'; /* continue rounding */
1749  else
1750  {
1751  dwState &= ~NF_ROUND;
1752  *szOut-- = (*szSrc)+1;
1753  }
1754  szSrc--;
1755  }
1756  else
1757  *szOut-- = *szSrc--; /* Write existing decimals */
1758  }
1759  szSrc--; /* Skip '.' */
1760  }
1761  while (lpszDec >= lpFormat->lpDecimalSep)
1762  *szOut-- = *lpszDec--; /* Write decimal separator */
1763  }
1764 
1765  dwGroupCount = lpFormat->Grouping;
1766 
1767  /* Write the remaining whole number digits, including grouping chars */
1768  while (szSrc >= lpszValue && *szSrc >= '0' && *szSrc <= '9')
1769  {
1770  if (dwState & NF_ROUND)
1771  {
1772  if (*szSrc == '9')
1773  *szOut-- = '0'; /* continue rounding */
1774  else
1775  {
1776  dwState &= ~NF_ROUND;
1777  *szOut-- = (*szSrc)+1;
1778  }
1779  szSrc--;
1780  }
1781  else
1782  *szOut-- = *szSrc--;
1783 
1784  dwState |= NF_DIGITS_OUT;
1785  dwCurrentGroupCount++;
1786  if (szSrc >= lpszValue && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
1787  {
1788  LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
1789 
1790  while (lpszGrp >= lpFormat->lpThousandSep)
1791  *szOut-- = *lpszGrp--; /* Write grouping char */
1792 
1793  dwCurrentGroupCount = 0;
1794  }
1795  }
1796  if (dwState & NF_ROUND)
1797  *szOut-- = '1'; /* e.g. .6 > 1.0 */
1798  else if (!(dwState & NF_DIGITS_OUT) && lpFormat->LeadingZero)
1799  *szOut-- = '0'; /* Add leading 0 if we have no digits before the decimal point */
1800 
1801  /* Add any leading negative or currency sign */
1802  while (dwFmt & (CF_MINUS_LEFT|CF_CY_LEFT))
1803  {
1804  switch (dwFmt & (CF_MINUS_LEFT|CF_MINUS_BEFORE|CF_CY_LEFT))
1805  {
1806  case CF_MINUS_LEFT:
1808  while (lpszNeg >= lpszNegStart)
1809  *szOut-- = *lpszNeg--;
1810  dwFmt &= ~CF_MINUS_LEFT;
1811  break;
1812 
1813  case CF_CY_LEFT:
1816  if (dwFmt & CF_CY_SPACE)
1817  *szOut-- = ' ';
1818  while (lpszCy >= lpszCyStart)
1819  *szOut-- = *lpszCy--;
1820  dwFmt &= ~(CF_CY_LEFT|CF_MINUS_BEFORE);
1821  break;
1822  }
1823  }
1824  if (dwFmt & CF_PARENS)
1825  *szOut-- = '(';
1826  szOut++;
1827 
1828  iRet = strlenW(szOut) + 1;
1829  if (cchOut)
1830  {
1831  if (iRet <= cchOut)
1832  memcpy(lpCurrencyStr, szOut, iRet * sizeof(WCHAR));
1833  else
1834  {
1835  memcpy(lpCurrencyStr, szOut, cchOut * sizeof(WCHAR));
1836  lpCurrencyStr[cchOut - 1] = '\0';
1838  iRet = 0;
1839  }
1840  }
1841  return iRet;
1842 
1843 error:
1845  return 0;
1846 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define GetNegative(fmt)
Definition: lcformat.c:94
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define NF_ROUND
Definition: lcformat.c:1184
#define error(str)
Definition: mkdosfs.c:1605
#define CF_CY_RIGHT
Definition: lcformat.c:1556
#define CF_MINUS_BEFORE
Definition: lcformat.c:1554
int32_t INT
Definition: typedefs.h:56
#define CF_MINUS_LEFT
Definition: lcformat.c:1552
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define debugstr_w
Definition: kernel32.h:32
#define CF_MINUS_RIGHT
Definition: lcformat.c:1553
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define NF_ISREAL
Definition: lcformat.c:1181
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define CF_CY_LEFT
Definition: lcformat.c:1555
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
Definition: lang.c:1548
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define NF_ISNEGATIVE
Definition: lcformat.c:1180
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define ARRAY_SIZE(a)
Definition: main.h:24
#define CF_CY_SPACE
Definition: lcformat.c:1557
#define NF_DIGITS
Definition: lcformat.c:1182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define NF_DIGITS_OUT
Definition: lcformat.c:1183
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define CF_PARENS
Definition: lcformat.c:1551
Definition: dlist.c:348
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetCurrencyFormatA(), InitCurrencyNegativeFormats(), InitCurrencyPositiveFormats(), InitDigitGroupCB(), UpdateExamples(), UpdateLocaleSample(), VarBstrFromCy(), and VarFormatCurrency().

◆ GetDateFormatA()

INT WINAPI GetDateFormatA ( LCID  lcid,
DWORD  dwFlags,
const SYSTEMTIME lpTime,
LPCSTR  lpFormat,
LPSTR  lpDateStr,
INT  cchOut 
)

Definition at line 922 of file lcformat.c.

924 {
925  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
926  debugstr_a(lpFormat), lpDateStr, cchOut);
927 
929  lpFormat, lpDateStr, cchOut);
930 }
#define DATE_DATEVARSONLY
Definition: lcformat.c:66
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR lpFormat
Definition: trayclock.cpp:32
static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpStr, INT cchOut)
Definition: lcformat.c:829

Referenced by _ILGetFileDate(), _strdate(), ExtCabCallback(), filetime_to_str(), START_TEST(), strftime_date(), test_GetDateFormatA(), test_SHFormatDateTimeA(), and test_wm_set_get_text().

◆ GetDateFormatW()

INT WINAPI GetDateFormatW ( LCID  lcid,
DWORD  dwFlags,
const SYSTEMTIME lpTime,
LPCWSTR  lpFormat,
LPWSTR  lpDateStr,
INT  cchOut 
)

Definition at line 979 of file lcformat.c.

981 {
982  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n", lcid, dwFlags, lpTime,
983  debugstr_w(lpFormat), lpDateStr, cchOut);
984 
986  lpFormat, lpDateStr, cchOut);
987 }
#define DATE_DATEVARSONLY
Definition: lcformat.c:66
#define debugstr_w
Definition: kernel32.h:32
static INT NLS_GetDateTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpStr, INT cchOut)
Definition: lcformat.c:400
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR lpFormat
Definition: trayclock.cpp:32

Referenced by CZipFolder::_GetFileTimeString(), _wstrdate(), add_cert_to_list(), add_cert_to_view(), add_date_string_to_control(), Date_toLocaleDateString(), Date_toLocaleString(), datetime_proc(), EnumEventsThread(), fill_datetime_information(), format_date(), format_long_date(), FormatDateTime(), GetFileModifyTime(), CFileDefExt::GetFileTimeString(), GetFileTimeString(), CShellLink::Load(), MONTHCAL_PaintTitle(), MONTHCAL_PaintTodayTitle(), msi_get_property_row(), OnInitSecurityDlg(), PrintDateTime(), set_print_template(), SHFormatDateTimeW(), START_TEST(), test_GetDateFormatW(), test_SHFormatDateTimeW(), UpdateDateLocaleSamples(), UpdateLocaleSample(), BtrfsScrub::UpdateTextBox(), and XCOPY_ParseCommandLine().

◆ GetNumberFormatA()

INT WINAPI GetNumberFormatA ( LCID  lcid,
DWORD  dwFlags,
LPCSTR  lpszValue,
const NUMBERFMTA lpFormat,
LPSTR  lpNumberStr,
int  cchOut 
)

Definition at line 1116 of file lcformat.c.

1119 {
1120  DWORD cp = CP_ACP;
1121  WCHAR szDec[8], szGrp[8], szIn[128], szOut[128];
1122  NUMBERFMTW fmt;
1123  const NUMBERFMTW *pfmt = NULL;
1124  INT iRet;
1125 
1126  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
1127  lpFormat, lpNumberStr, cchOut);
1128 
1130  {
1132  return 0;
1133  }
1134 
1135  if (!(dwFlags & LOCALE_USE_CP_ACP))
1136  {
1138  if (!node)
1139  {
1141  return 0;
1142  }
1143 
1144  cp = node->dwCodePage;
1145  }
1146 
1147  if (lpFormat)
1148  {
1149  memcpy(&fmt, lpFormat, sizeof(fmt));
1150  pfmt = &fmt;
1151  if (lpFormat->lpDecimalSep)
1152  {
1153  MultiByteToWideChar(cp, 0, lpFormat->lpDecimalSep, -1, szDec, ARRAY_SIZE(szDec));
1154  fmt.lpDecimalSep = szDec;
1155  }
1156  if (lpFormat->lpThousandSep)
1157  {
1158  MultiByteToWideChar(cp, 0, lpFormat->lpThousandSep, -1, szGrp, ARRAY_SIZE(szGrp));
1159  fmt.lpThousandSep = szGrp;
1160  }
1161  }
1162 
1163  if (lpszValue)
1164  MultiByteToWideChar(cp, 0, lpszValue, -1, szIn, ARRAY_SIZE(szIn));
1165 
1166  if (cchOut > (int) ARRAY_SIZE(szOut))
1167  cchOut = ARRAY_SIZE(szOut);
1168 
1169  szOut[0] = '\0';
1170 
1171  iRet = GetNumberFormatW(lcid, dwFlags, lpszValue ? szIn : NULL, pfmt,
1172  lpNumberStr ? szOut : NULL, cchOut);
1173 
1174  if (szOut[0] && lpNumberStr)
1175  WideCharToMultiByte(cp, 0, szOut, -1, lpNumberStr, cchOut, 0, 0);
1176  return iRet;
1177 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
const char * fmt
Definition: wsprintf.c:30
int32_t INT
Definition: typedefs.h:56
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
Definition: lcformat.c:350
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:100
POINT cp
Definition: magnifier.c:60
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1198
Definition: dsound.c:943
Definition: dlist.c:348

Referenced by test_GetNumberFormatA().

◆ GetNumberFormatW()

INT WINAPI GetNumberFormatW ( LCID  lcid,
DWORD  dwFlags,
LPCWSTR  lpszValue,
const NUMBERFMTW lpFormat,
LPWSTR  lpNumberStr,
int  cchOut 
)

Definition at line 1198 of file lcformat.c.

1201 {
1202  WCHAR szBuff[128], *szOut = szBuff + ARRAY_SIZE(szBuff) - 1;
1203  WCHAR szNegBuff[8];
1204  const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc;
1205  DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0;
1206  INT iRet;
1207 
1208  TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
1209  lpFormat, lpNumberStr, cchOut);
1210 
1211  if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpNumberStr) ||
1212  !IsValidLocale(lcid, 0) ||
1213  (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep)))
1214  {
1215  goto error;
1216  }
1217 
1218  if (!lpFormat)
1219  {
1221 
1222  if (!node)
1223  goto error;
1224  lpFormat = &node->fmt;
1225  lpszNegStart = lpszNeg = GetNegative(node);
1226  }
1227  else
1228  {
1230  szNegBuff, ARRAY_SIZE(szNegBuff));
1231  lpszNegStart = lpszNeg = szNegBuff;
1232  }
1233  lpszNeg = lpszNeg + strlenW(lpszNeg) - 1;
1234 
1236 
1237  /* Format the number backwards into a temporary buffer */
1238 
1239  szSrc = lpszValue;
1240  *szOut-- = '\0';
1241 
1242  /* Check the number for validity */
1243  while (*szSrc)
1244  {
1245  if (*szSrc >= '0' && *szSrc <= '9')
1246  {
1247  dwState |= NF_DIGITS;
1248  if (dwState & NF_ISREAL)
1249  dwDecimals++;
1250  }
1251  else if (*szSrc == '-')
1252  {
1253  if (dwState)
1254  goto error; /* '-' not first character */
1255  dwState |= NF_ISNEGATIVE;
1256  }
1257  else if (*szSrc == '.')
1258  {
1259  if (dwState & NF_ISREAL)
1260  goto error; /* More than one '.' */
1261  dwState |= NF_ISREAL;
1262  }
1263  else
1264  goto error; /* Invalid char */
1265  szSrc++;
1266  }
1267  szSrc--; /* Point to last character */
1268 
1269  if (!(dwState & NF_DIGITS))
1270  goto error; /* No digits */
1271 
1272  /* Add any trailing negative sign */
1273  if (dwState & NF_ISNEGATIVE)
1274  {
1275  switch (lpFormat->NegativeOrder)
1276  {
1277  case NLS_NEG_PARENS:
1278  *szOut-- = ')';
1279  break;
1280  case NLS_NEG_RIGHT:
1281  case NLS_NEG_RIGHT_SPACE:
1282  while (lpszNeg >= lpszNegStart)
1283  *szOut-- = *lpszNeg--;
1284  if (lpFormat->NegativeOrder == NLS_NEG_RIGHT_SPACE)
1285  *szOut-- = ' ';
1286  break;
1287  }
1288  }
1289 
1290  /* Copy all digits up to the decimal point */
1291  if (!lpFormat->NumDigits)
1292  {
1293  if (dwState & NF_ISREAL)
1294  {
1295  while (*szSrc != '.') /* Don't write any decimals or a separator */
1296  {
1297  if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1298  dwState |= NF_ROUND;
1299  else
1300  dwState &= ~NF_ROUND;
1301  szSrc--;
1302  }
1303  szSrc--;
1304  }
1305  }
1306  else
1307  {
1308  LPWSTR lpszDec = lpFormat->lpDecimalSep + strlenW(lpFormat->lpDecimalSep) - 1;
1309 
1310  if (dwDecimals <= lpFormat->NumDigits)
1311  {
1312  dwDecimals = lpFormat->NumDigits - dwDecimals;
1313  while (dwDecimals--)
1314  *szOut-- = '0'; /* Pad to correct number of dp */
1315  }
1316  else
1317  {
1318  dwDecimals -= lpFormat->NumDigits;
1319  /* Skip excess decimals, and determine if we have to round the number */
1320  while (dwDecimals--)
1321  {
1322  if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1323  dwState |= NF_ROUND;
1324  else
1325  dwState &= ~NF_ROUND;
1326  szSrc--;
1327  }
1328  }
1329 
1330  if (dwState & NF_ISREAL)
1331  {
1332  while (*szSrc != '.')
1333  {
1334  if (dwState & NF_ROUND)
1335  {
1336  if (*szSrc == '9')
1337  *szOut-- = '0'; /* continue rounding */
1338  else
1339  {
1340  dwState &= ~NF_ROUND;
1341  *szOut-- = (*szSrc)+1;
1342  }
1343  szSrc--;
1344  }
1345  else
1346  *szOut-- = *szSrc--; /* Write existing decimals */
1347  }
1348  szSrc--; /* Skip '.' */
1349  }
1350 
1351  while (lpszDec >= lpFormat->lpDecimalSep)
1352  *szOut-- = *lpszDec--; /* Write decimal separator */
1353  }
1354 
1355  dwGroupCount = lpFormat->Grouping == 32 ? 3 : lpFormat->Grouping;
1356 
1357  /* Write the remaining whole number digits, including grouping chars */
1358  while (szSrc >= lpszValue && *szSrc >= '0' && *szSrc <= '9')
1359  {
1360  if (dwState & NF_ROUND)
1361  {
1362  if (*szSrc == '9')
1363  *szOut-- = '0'; /* continue rounding */
1364  else
1365  {
1366  dwState &= ~NF_ROUND;
1367  *szOut-- = (*szSrc)+1;
1368  }
1369  szSrc--;
1370  }
1371  else
1372  *szOut-- = *szSrc--;
1373 
1374  dwState |= NF_DIGITS_OUT;
1375  dwCurrentGroupCount++;
1376  if (szSrc >= lpszValue && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
1377  {
1378  LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
1379 
1380  while (lpszGrp >= lpFormat->lpThousandSep)
1381  *szOut-- = *lpszGrp--; /* Write grouping char */
1382 
1383  dwCurrentGroupCount = 0;
1384  if (lpFormat->Grouping == 32)
1385  dwGroupCount = 2; /* Indic grouping: 3 then 2 */
1386  }
1387  }
1388  if (dwState & NF_ROUND)
1389  {
1390  *szOut-- = '1'; /* e.g. .6 > 1.0 */
1391  }
1392  else if (!(dwState & NF_DIGITS_OUT) && lpFormat->LeadingZero)
1393  *szOut-- = '0'; /* Add leading 0 if we have no digits before the decimal point */
1394 
1395  /* Add any leading negative sign */
1396  if (dwState & NF_ISNEGATIVE)
1397  {
1398  switch (lpFormat->NegativeOrder)
1399  {
1400  case NLS_NEG_PARENS:
1401  *szOut-- = '(';
1402  break;
1403  case NLS_NEG_LEFT_SPACE:
1404  *szOut-- = ' ';
1405  /* Fall through */
1406  case NLS_NEG_LEFT:
1407  while (lpszNeg >= lpszNegStart)
1408  *szOut-- = *lpszNeg--;
1409  break;
1410  }
1411  }
1412  szOut++;
1413 
1414  iRet = strlenW(szOut) + 1;
1415  if (cchOut)
1416  {
1417  if (iRet <= cchOut)
1418  memcpy(lpNumberStr, szOut, iRet * sizeof(WCHAR));
1419  else
1420  {
1421  memcpy(lpNumberStr, szOut, cchOut * sizeof(WCHAR));
1422  lpNumberStr[cchOut - 1] = '\0';
1424  iRet = 0;
1425  }
1426  }
1427  return iRet;
1428 
1429 error:
1431  return 0;
1432 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define GetNegative(fmt)
Definition: lcformat.c:94
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define NF_ROUND
Definition: lcformat.c:1184
#define error(str)
Definition: mkdosfs.c:1605
#define NLS_NEG_RIGHT_SPACE
Definition: lcformat.c:1191
int32_t INT
Definition: typedefs.h:56
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define NLS_NEG_LEFT_SPACE
Definition: lcformat.c:1189
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define NLS_NEG_RIGHT
Definition: lcformat.c:1190
#define TRACE(s)
Definition: solgame.cpp:4
#define NF_ISREAL
Definition: lcformat.c:1181
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
Definition: lang.c:1548
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define NF_ISNEGATIVE
Definition: lcformat.c:1180
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define NLS_NEG_LEFT
Definition: lcformat.c:1188
#define NLS_NEG_PARENS
Definition: lcformat.c:1187
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NF_DIGITS
Definition: lcformat.c:1182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define NF_DIGITS_OUT
Definition: lcformat.c:1183
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
Definition: dlist.c:348
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AddCommasW(), format_size(), FormatBytes(), FormatDouble(), FormatInt(), FormatInteger(), GetNumberFormatA(), init_output(), SH_FormatInteger(), UpdateLocaleSample(), UpdateNumSamples(), VarBstrFromDec(), VarFormatNumber(), VARIANT_BstrFromReal(), VARIANT_BstrReplaceDecimal(), and VARIANT_MakeBstr().

◆ GetTimeFormatA()

INT WINAPI GetTimeFormatA ( LCID  lcid,
DWORD  dwFlags,
const SYSTEMTIME lpTime,
LPCSTR  lpFormat,
LPSTR  lpTimeStr,
INT  cchOut 
)

Definition at line 1030 of file lcformat.c.

1032 {
1033  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
1034  debugstr_a(lpFormat), lpTimeStr, cchOut);
1035 
1037  lpFormat, lpTimeStr, cchOut);
1038 }
#define TIME_TIMEVARSONLY
Definition: lcformat.c:67
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR lpFormat
Definition: trayclock.cpp:32
static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpStr, INT cchOut)
Definition: lcformat.c:829

Referenced by _ILGetFileDate(), _strtime(), ExtCabCallback(), strftime_time(), test_GetTimeFormatA(), and test_SHFormatDateTimeA().

◆ GetTimeFormatW()

INT WINAPI GetTimeFormatW ( LCID  lcid,
DWORD  dwFlags,
const SYSTEMTIME lpTime,
LPCWSTR  lpFormat,
LPWSTR  lpTimeStr,
INT  cchOut 
)

Definition at line 1079 of file lcformat.c.

1081 {
1082  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
1083  debugstr_w(lpFormat), lpTimeStr, cchOut);
1084 
1086  lpFormat, lpTimeStr, cchOut);
1087 }
#define TIME_TIMEVARSONLY
Definition: lcformat.c:67
#define debugstr_w
Definition: kernel32.h:32
static INT NLS_GetDateTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpStr, INT cchOut)
Definition: lcformat.c:400
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR lpFormat
Definition: trayclock.cpp:32

Referenced by CZipFolder::_GetFileTimeString(), _wstrtime(), Date_toLocaleString(), Date_toLocaleTimeString(), datetime_proc(), EnumEventsThread(), fill_datetime_information(), format_date(), FormatDateTime(), GetFileModifyTime(), CFileDefExt::GetFileTimeString(), GetFileTimeString(), InitializeSystemPage(), msi_get_property_row(), OnInitSecurityDlg(), PrintDateTime(), SHFormatDateTimeW(), test_SHFormatDateTimeW(), UpdateLanStatusUiDlg(), UpdateLocaleSample(), BtrfsScrub::UpdateTextBox(), UpdateTimeSample(), VarBstrFromDate(), and XCOPY_ParseCommandLine().

◆ NLS_EnumCalendarInfo()

static BOOL NLS_EnumCalendarInfo ( const struct enumcalendar_context ctxt)
static

Definition at line 2207 of file lcformat.c.

2208 {
2209  WCHAR *buf, *opt = NULL, *iter = NULL;
2210  CALID calendar = ctxt->calendar;
2211  BOOL ret = FALSE;
2212  int bufSz = 200; /* the size of the buffer */
2213 
2214  if (ctxt->u.callback == NULL)
2215  {
2217  return FALSE;
2218  }
2219 
2220  buf = HeapAlloc(GetProcessHeap(), 0, bufSz);
2221  if (buf == NULL)
2222  {
2224  return FALSE;
2225  }
2226 
2227  if (calendar == ENUM_ALL_CALENDARS)
2228  {
2229  int optSz = GetLocaleInfoW(ctxt->lcid, LOCALE_IOPTIONALCALENDAR, NULL, 0);
2230  if (optSz > 1)
2231  {
2232  opt = HeapAlloc(GetProcessHeap(), 0, optSz * sizeof(WCHAR));
2233  if (opt == NULL)
2234  {
2236  goto cleanup;
2237  }
2238  if (GetLocaleInfoW(ctxt->lcid, LOCALE_IOPTIONALCALENDAR, opt, optSz))
2239  iter = opt;
2240  }
2241  calendar = NLS_GetLocaleNumber(ctxt->lcid, LOCALE_ICALENDARTYPE);
2242  }
2243 
2244  while (TRUE) /* loop through calendars */
2245  {
2246  do /* loop until there's no error */
2247  {
2248  if (ctxt->caltype & CAL_RETURN_NUMBER)
2249  ret = GetCalendarInfoW(ctxt->lcid, calendar, ctxt->caltype, NULL, bufSz / sizeof(WCHAR), (LPDWORD)buf);
2250  else if (ctxt->unicode)
2251  ret = GetCalendarInfoW(ctxt->lcid, calendar, ctxt->caltype, buf, bufSz / sizeof(WCHAR), NULL);
2252  else ret = GetCalendarInfoA(ctxt->lcid, calendar, ctxt->caltype, (CHAR*)buf, bufSz / sizeof(CHAR), NULL);
2253 
2254  if (!ret)
2255  {
2257  { /* so resize it */
2258  int newSz;
2259  if (ctxt->unicode)
2260  newSz = GetCalendarInfoW(ctxt->lcid, calendar, ctxt->caltype, NULL, 0, NULL) * sizeof(WCHAR);
2261  else newSz = GetCalendarInfoA(ctxt->lcid, calendar, ctxt->caltype, NULL, 0, NULL) * sizeof(CHAR);
2262  if (bufSz >= newSz)
2263  {
2264  ERR("Buffer resizing disorder: was %d, requested %d.\n", bufSz, newSz);
2265  goto cleanup;
2266  }
2267  bufSz = newSz;
2268  WARN("Buffer too small; resizing to %d bytes.\n", bufSz);
2269  buf = HeapReAlloc(GetProcessHeap(), 0, buf, bufSz);
2270  if (buf == NULL)
2271  goto cleanup;
2272  } else goto cleanup;
2273  }
2274  } while (!ret);
2275 
2276  /* Here we are. We pass the buffer to the correct version of
2277  * the callback. Because it's not the same number of params,
2278  * we must check for Ex, but we don't care about Unicode
2279  * because the buffer is already in the correct format.
2280  */
2281  switch (ctxt->type)
2282  {
2283  case CALLBACK_ENUMPROC:
2284  ret = ctxt->u.callback(buf);
2285  break;
2286  case CALLBACK_ENUMPROCEX:
2287  ret = ctxt->u.callbackex(buf, calendar);
2288  break;
2289  case CALLBACK_ENUMPROCEXEX:
2290  ret = ctxt->u.callbackexex(buf, calendar, NULL, ctxt->lParam);
2291  break;
2292  default:
2293  ;
2294  }
2295 
2296  if (!ret) { /* the callback told to stop */
2297  ret = TRUE;
2298  break;
2299  }
2300 
2301  if ((iter == NULL) || (*iter == 0)) /* no more calendars */
2302  break;
2303 
2304  calendar = 0;
2305  while ((*iter >= '0') && (*iter <= '9'))
2306  calendar = calendar * 10 + *iter++ - '0';
2307 
2308  if (*iter++ != 0)
2309  {
2311  ret = FALSE;
2312  break;
2313  }
2314  }
2315 
2316 cleanup:
2317  HeapFree(GetProcessHeap(), 0, opt);
2318  HeapFree(GetProcessHeap(), 0, buf);
2319  return ret;
2320 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
CALINFO_ENUMPROCEXEX callbackexex
Definition: lcformat.c:2178
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:111
#define LOCALE_ICALENDARTYPE
Definition: winnls.h:73
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
union enumcalendar_context::@441 u
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType, LPSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2428
CALINFO_ENUMPROCW callback
Definition: lcformat.c:2176
smooth NULL
Definition: ftsmooth.c:416
enum enum_callback_type type
Definition: lcformat.c:2174
#define ENUM_ALL_CALENDARS
Definition: winnls.h:192
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
DWORD CALID
Definition: winnls.h:516
static DWORD NLS_GetLocaleNumber(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:128
int ret
#define ERR(fmt,...)
Definition: debug.h:109
#define HeapReAlloc
Definition: compat.h:393
CALINFO_ENUMPROCEXW callbackex
Definition: lcformat.c:2177
uint32_t * LPDWORD
Definition: typedefs.h:57
char * cleanup(char *str)
Definition: wpickclick.c:99
#define CHAR(Char)
#define LOCALE_IOPTIONALCALENDAR
Definition: winnls.h:74
#define HeapFree(x, y, z)
Definition: compat.h:394
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2483
#define ERROR_BADDB
Definition: winerror.h:588
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by EnumCalendarInfoA(), EnumCalendarInfoExA(), EnumCalendarInfoExW(), and EnumCalendarInfoW().

◆ NLS_EnumDateFormats()

static BOOL NLS_EnumDateFormats ( const struct enumdateformats_context ctxt)
static

Definition at line 1898 of file lcformat.c.

1899 {
1900  WCHAR bufW[256];
1901  char bufA[256];
1902  LCTYPE lctype;
1903  CALID cal_id;
1904  INT ret;
1905 
1906  if (!ctxt->u.callback)
1907  {
1909  return FALSE;
1910  }
1911 
1912  if (!GetLocaleInfoW(ctxt->lcid, LOCALE_ICALENDARTYPE|LOCALE_RETURN_NUMBER, (LPWSTR)&cal_id, sizeof(cal_id)/sizeof(WCHAR)))
1913  return FALSE;
1914 
1915  switch (ctxt->flags & ~LOCALE_USE_CP_ACP)
1916  {
1917  case 0:
1918  case DATE_SHORTDATE:
1919  lctype = LOCALE_SSHORTDATE;
1920  break;
1921  case DATE_LONGDATE:
1922  lctype = LOCALE_SLONGDATE;
1923  break;
1924  case DATE_YEARMONTH:
1925  lctype = LOCALE_SYEARMONTH;
1926  break;
1927  default:
1928  FIXME("Unknown date format (0x%08x)\n", ctxt->flags);
1930  return FALSE;
1931  }
1932 
1933  lctype |= ctxt->flags & LOCALE_USE_CP_ACP;
1934  if (ctxt->unicode)
1935  ret = GetLocaleInfoW(ctxt->lcid, lctype, bufW, ARRAY_SIZE(bufW));
1936  else
1937  ret = GetLocaleInfoA(ctxt->lcid, lctype, bufA, ARRAY_SIZE(bufA));
1938 
1939  if (ret)
1940  {
1941  switch (ctxt->type)
1942  {
1943  case CALLBACK_ENUMPROC:
1944  ctxt->u.callback(ctxt->unicode ? bufW : (WCHAR*)bufA);
1945  break;
1946  case CALLBACK_ENUMPROCEX:
1947  ctxt->u.callbackex(ctxt->unicode ? bufW : (WCHAR*)bufA, cal_id);
1948  break;
1949  case CALLBACK_ENUMPROCEXEX:
1950  ctxt->u.callbackexex(bufW, cal_id, ctxt->lParam);
1951  break;
1952  default:
1953  ;
1954  }
1955  }
1956 
1957  return TRUE;
1958 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: lang.c:1018
#define DATE_SHORTDATE
Definition: winnls.h:193
#define LOCALE_ICALENDARTYPE
Definition: winnls.h:73
int32_t INT
Definition: typedefs.h:56
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
enum enum_callback_type type
Definition: lcformat.c:1875
DWORD LCTYPE
Definition: winnls.h:514
DATEFMT_ENUMPROCEXW callbackex
Definition: lcformat.c:1878
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define FIXME(fmt,...)
Definition: debug.h:110
__wchar_t WCHAR
Definition: xmlstorage.h:180
DATEFMT_ENUMPROCW callback
Definition: lcformat.c:1877
#define SetLastError(x)
Definition: compat.h:409
DWORD CALID
Definition: winnls.h:516
int ret
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define ARRAY_SIZE(a)
Definition: main.h:24
#define DATE_LONGDATE
Definition: winnls.h:194
DATEFMT_ENUMPROCEXEX callbackexex
Definition: lcformat.c:1879
union enumdateformats_context::@439 u
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by EnumDateFormatsA(), EnumDateFormatsExA(), EnumDateFormatsExW(), and EnumDateFormatsW().

◆ NLS_EnumTimeFormats()

static BOOL NLS_EnumTimeFormats ( struct enumtimeformats_context ctxt)
static

Definition at line 2061 of file lcformat.c.

2062 {
2063  WCHAR bufW[256];
2064  char bufA[256];
2065  LCTYPE lctype;
2066  INT ret;
2067 
2068  if (!ctxt->u.callback)
2069  {
2071  return FALSE;
2072  }
2073 
2074  switch (ctxt->flags & ~LOCALE_USE_CP_ACP)
2075  {
2076  case 0:
2077  lctype = LOCALE_STIMEFORMAT;
2078  break;
2079  case TIME_NOSECONDS:
2080  lctype = LOCALE_SSHORTTIME;
2081  break;
2082  default:
2083  FIXME("Unknown time format (%d)\n", ctxt->flags);
2085  return FALSE;
2086  }
2087 
2088  lctype |= ctxt->flags & LOCALE_USE_CP_ACP;
2089  if (ctxt->unicode)
2090  ret = GetLocaleInfoW(ctxt->lcid, lctype, bufW, ARRAY_SIZE(bufW));
2091  else
2092  ret = GetLocaleInfoA(ctxt->lcid, lctype, bufA, ARRAY_SIZE(bufA));
2093 
2094  if (ret)
2095  {
2096  switch (ctxt->type)
2097  {
2098  case CALLBACK_ENUMPROC:
2099  ctxt->u.callback(ctxt->unicode ? bufW : (WCHAR*)bufA);
2100  break;
2101  case CALLBACK_ENUMPROCEX:
2102  ctxt->u.callbackex(bufW, ctxt->lParam);
2103  break;
2104  default:
2105  ;
2106  }
2107  }
2108 
2109  return TRUE;
2110 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: lang.c:1018
int32_t INT
Definition: typedefs.h:56
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
DWORD LCTYPE
Definition: winnls.h:514
union enumtimeformats_context::@440 u
#define FIXME(fmt,...)
Definition: debug.h:110
#define LOCALE_SSHORTTIME
Definition: winnls.h:160
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
TIMEFMT_ENUMPROCEX callbackex
Definition: lcformat.c:2053
int ret
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define ARRAY_SIZE(a)
Definition: main.h:24
#define TIME_NOSECONDS
Definition: winnls.h:275
TIMEFMT_ENUMPROCW callback
Definition: lcformat.c:2052
#define LOCALE_STIMEFORMAT
Definition: winnls.h:62
enum enum_callback_type type
Definition: lcformat.c:2050

Referenced by EnumTimeFormatsA(), and EnumTimeFormatsW().

◆ NLS_GetDateTimeFormatA()

static INT NLS_GetDateTimeFormatA ( LCID  lcid,
DWORD  dwFlags,
const SYSTEMTIME lpTime,
LPCSTR  lpFormat,
LPSTR  lpStr,
INT  cchOut 
)
static

Definition at line 829 of file lcformat.c.

832 {
833  DWORD cp = CP_ACP;
834  WCHAR szFormat[128], szOut[128];
835  INT iRet;
836 
837  TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n", lcid, dwFlags, lpTime,
838  debugstr_a(lpFormat), lpStr, cchOut);
839 
841  {
843  return 0;
844  }
845 
846  if (!(dwFlags & LOCALE_USE_CP_ACP))
847  {
849  if (!node)
850  {
852  return 0;
853  }
854 
855  cp = node->dwCodePage;
856  }
857 
858  if (lpFormat)
859  MultiByteToWideChar(cp, 0, lpFormat, -1, szFormat, ARRAY_SIZE(szFormat));
860 
861  if (cchOut > (int) ARRAY_SIZE(szOut))
862  cchOut = ARRAY_SIZE(szOut);
863 
864  szOut[0] = '\0';
865 
866  iRet = NLS_GetDateTimeFormatW(lcid, dwFlags, lpTime, lpFormat ? szFormat : NULL,
867  lpStr ? szOut : NULL, cchOut);
868 
869  if (lpStr)
870  {
871  if (szOut[0])
872  WideCharToMultiByte(cp, 0, szOut, iRet ? -1 : cchOut, lpStr, cchOut, 0, 0);
873  else if (cchOut && iRet)
874  *lpStr = '\0';
875  }
876  return iRet;
877 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
int32_t INT
Definition: typedefs.h:56
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
smooth NULL
Definition: ftsmooth.c:416
static INT NLS_GetDateTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpStr, INT cchOut)
Definition: lcformat.c:400
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
Definition: lcformat.c:350
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:100
POINT cp
Definition: magnifier.c:60
Definition: dlist.c:348

Referenced by GetDateFormatA(), and GetTimeFormatA().

◆ NLS_GetDateTimeFormatW()

static INT NLS_GetDateTimeFormatW ( LCID  lcid,
DWORD  dwFlags,
const SYSTEMTIME lpTime,
LPCWSTR  lpFormat,
LPWSTR  lpStr,
INT  cchOut 
)
static

Definition at line 400 of file lcformat.c.

403 {
404  const NLS_FORMAT_NODE *node;
405  SYSTEMTIME st;
406  INT cchWritten = 0;
407  INT lastFormatPos = 0;
408  BOOL bSkipping = FALSE; /* Skipping text around marker? */
409  BOOL d_dd_formatted = FALSE; /* previous formatted part was for d or dd */
410 
411  /* Verify our arguments */
412  if ((cchOut && !lpStr) || !(node = NLS_GetFormats(lcid, dwFlags)))
413  goto invalid_parameter;
414 
416  {
417  if (lpFormat &&
420  {
421  goto invalid_flags;
422  }
423 
425  {
426  if ((dwFlags & (DATE_LTRREADING|DATE_RTLREADING)) == (DATE_LTRREADING|DATE_RTLREADING))
427  goto invalid_flags;
428  else if (dwFlags & (DATE_LTRREADING|DATE_RTLREADING))
429  FIXME("Unsupported flags: DATE_LTRREADING/DATE_RTLREADING\n");
430 
431  switch (dwFlags & (DATE_SHORTDATE|DATE_LONGDATE|DATE_YEARMONTH))
432  {
433  case 0:
434  break;
435  case DATE_SHORTDATE:
436  case DATE_LONGDATE:
437  case DATE_YEARMONTH:
438  if (lpFormat)
439  goto invalid_flags;
440  break;
441  default:
442  goto invalid_flags;
443  }
444  }
445  }
446 
447  if (!lpFormat)
448  {
449  /* Use the appropriate default format */
451  {
452  if (dwFlags & DATE_YEARMONTH)
454  else if (dwFlags & DATE_LONGDATE)
456  else
458  }
459  else
460  lpFormat = GetTime(node);
461  }
462 
463  if (!lpTime)
464  {
465  GetLocalTime(&st); /* Default to current time */
466  lpTime = &st;
467  }
468  else
469  {
471  {
472  FILETIME ftTmp;
473 
474  /* Verify the date and correct the D.O.W. if needed */
475  memset(&st, 0, sizeof(st));
476  st.wYear = lpTime->wYear;
477  st.wMonth = lpTime->wMonth;
478  st.wDay = lpTime->wDay;
479 
480  if (st.wDay > 31 || st.wMonth > 12 || !SystemTimeToFileTime(&st, &ftTmp))
481  goto invalid_parameter;
482 
483  FileTimeToSystemTime(&ftTmp, &st);
484  lpTime = &st;
485  }
486 
488  {
489  /* Verify the time */
490  if (lpTime->wHour > 24 || lpTime->wMinute > 59 || lpTime->wSecond > 59)
491  goto invalid_parameter;
492  }
493  }
494 
495  /* Format the output */
496  while (*lpFormat)
497  {
499  {
500  /* Start of a literal string */
501  lpFormat++;
502 
503  /* Loop until the end of the literal marker or end of the string */
504  while (*lpFormat)
505  {
507  {
508  lpFormat++;
509  if (!IsLiteralMarker(*lpFormat))
510  break; /* Terminating literal marker */
511  }
512 
513  if (!cchOut)
514  cchWritten++; /* Count size only */
515  else if (cchWritten >= cchOut)
516  goto overrun;
517  else if (!bSkipping)
518  {
519  lpStr[cchWritten] = *lpFormat;
520  cchWritten++;
521  }
522  lpFormat++;
523  }
524  }
525  else if ((dwFlags & DATE_DATEVARSONLY && IsDateFmtChar(*lpFormat)) ||
527  {
528  WCHAR buff[32], fmtChar;
529  LPCWSTR szAdd = NULL;
530  DWORD dwVal = 0;
531  int count = 0, dwLen;
532 
533  bSkipping = FALSE;
534 
535  fmtChar = *lpFormat;
536  while (*lpFormat == fmtChar)
537  {
538  count++;
539  lpFormat++;
540  }
541  buff[0] = '\0';
542 
543  if (fmtChar != 'M') d_dd_formatted = FALSE;
544  switch(fmtChar)
545  {
546  case 'd':
547  if (count >= 4)
548  szAdd = GetLongDay(node, (lpTime->wDayOfWeek + 6) % 7);
549  else if (count == 3)
550  szAdd = GetShortDay(node, (lpTime->wDayOfWeek + 6) % 7);
551  else
552  {
553  dwVal = lpTime->wDay;
554  szAdd = buff;
555  d_dd_formatted = TRUE;
556  }
557  break;
558 
559  case 'M':
560  if (count >= 4)
561  {
562  LPCWSTR genitive = GetGenitiveMonth(node, lpTime->wMonth - 1);
563  if (genitive)
564  {
565  if (d_dd_formatted)
566  {
567  szAdd = genitive;
568  break;
569  }
570  else
571  {
573  /* Look forward now, if next format pattern is for day genitive
574  name should be used */
575  while (*format)
576  {
577  /* Skip parts within markers */
578  if (IsLiteralMarker(*format))
579  {
580  ++format;
581  while (*format)
582  {
583  if (IsLiteralMarker(*format))
584  {
585  ++format;
586  if (!IsLiteralMarker(*format)) break;
587  }
588  }
589  }
590  if (*format != ' ') break;
591  ++format;
592  }
593  /* Only numeric day form matters */
594  if (*format == 'd')
595  {
596  INT dcount = 1;
597  while (*++format == 'd') dcount++;
598  if (dcount < 3)
599  {
600  szAdd = genitive;
601  break;
602  }
603  }
604  }
605  }
606  szAdd = GetLongMonth(node, lpTime->wMonth - 1);
607  }
608  else if (count == 3)
609  szAdd = GetShortMonth(node, lpTime->wMonth - 1);
610  else
611  {
612  dwVal = lpTime->wMonth;
613  szAdd = buff;
614  }
615  break;
616 
617  case 'y':
618 #ifdef __REACTOS__
619  if (IS_LCID_JAPANESE(lcid) && (dwFlags & DATE_USE_ALT_CALENDAR))
620  {
621  PCJAPANESE_ERA pEra = JapaneseEra_Find(lpTime);
622  if (pEra)
623  {
624  if (count >= 2)
625  {
626  count = 2;
627  }
628 
629  dwVal = lpTime->wYear - pEra->wYear + 1;
630 
631  if (dwVal == 1 && JapaneseEra_IsFirstYearGannen())
632  {
633  // Gan of 'Gannen'
634  buff[0] = 0x5143;
635  buff[1] = 0;
636  }
637  szAdd = buff;
638  break;
639  }
641  return 0;
642  }
643 #endif
644  if (count >= 4)
645  {
646  count = 4;
647  dwVal = lpTime->wYear;
648  }
649  else
650  {
651  count = count > 2 ? 2 : count;
652  dwVal = lpTime->wYear % 100;
653  }
654  szAdd = buff;
655  break;
656 
657  case 'g':
658 #ifdef __REACTOS__
659  if (IS_LCID_JAPANESE(lcid))
660  {
662  {
663  PCJAPANESE_ERA pEra = JapaneseEra_Find(lpTime);
664  if (pEra)
665  {
666  RtlStringCbCopyW(buff, sizeof(buff), pEra->szEraName);
667  szAdd = buff;
668  break;
669  }
671  return 0;
672  }
673  else
674  {
675  /* Seireki */
676  buff[0] = 0x897F;
677  buff[1] = 0x66A6;
678  buff[2] = 0;
679  szAdd = buff;
680  break;
681  }
682  }
683 #endif
684  if (count == 2)
685  {
686  /* FIXME: Our GetCalendarInfo() does not yet support CAL_SERASTRING.
687  * When it is fixed, this string should be cached in 'node'.
688  */
689  FIXME("Should be using GetCalendarInfo(CAL_SERASTRING), defaulting to 'AD'\n");
690  buff[0] = 'A'; buff[1] = 'D'; buff[2] = '\0';
691  }
692  else
693  {
694  buff[0] = 'g'; buff[1] = '\0'; /* Add a literal 'g' */
695  }
696  szAdd = buff;
697  break;
698 
699  case 'h':
701  {
702  count = count > 2 ? 2 : count;
703  dwVal = lpTime->wHour == 0 ? 12 : (lpTime->wHour - 1) % 12 + 1;
704  szAdd = buff;
705  break;
706  }
707  /* .. fall through if we are forced to output in 24 hour format */
708 
709  case 'H':
710  count = count > 2 ? 2 : count;
711  dwVal = lpTime->wHour;
712  szAdd = buff;
713  break;
714 
715  case 'm':
717  {
718  cchWritten = lastFormatPos; /* Skip */
719  bSkipping = TRUE;
720  }
721  else
722  {
723  count = count > 2 ? 2 : count;
724  dwVal = lpTime->wMinute;
725  szAdd = buff;
726  }
727  break;
728 
729  case 's':
731  {
732  cchWritten = lastFormatPos; /* Skip */
733  bSkipping = TRUE;
734  }
735  else
736  {
737  count = count > 2 ? 2 : count;
738  dwVal = lpTime->wSecond;
739  szAdd = buff;
740  }
741  break;
742 
743  case 't':
745  {
746  cchWritten = lastFormatPos; /* Skip */
747  bSkipping = TRUE;
748  }
749  else
750  {
751  if (count == 1)
752  szAdd = lpTime->wHour < 12 ? node->szShortAM : node->szShortPM;
753  else
754  szAdd = lpTime->wHour < 12 ? GetAM(node) : GetPM(node);
755  }
756  break;
757  }
758 
759  if (szAdd == buff && buff[0] == '\0')
760  {
761  static const WCHAR fmtW[] = {'%','.','*','d',0};
762  /* We have a numeric value to add */
763  snprintfW(buff, ARRAY_SIZE(buff), fmtW, count, dwVal);
764  }
765 
766  dwLen = szAdd ? strlenW(szAdd) : 0;
767 
768  if (cchOut && dwLen)
769  {
770  if (cchWritten + dwLen < cchOut)
771  memcpy(lpStr + cchWritten, szAdd, dwLen * sizeof(WCHAR));
772  else
773  {
774  memcpy(lpStr + cchWritten, szAdd, (cchOut - cchWritten) * sizeof(WCHAR));
775  goto overrun;
776  }
777  }
778  cchWritten += dwLen;
779  lastFormatPos = cchWritten; /* Save position of last output format text */
780  }
781  else
782  {
783  /* Literal character */
784  if (!cchOut)
785  cchWritten++; /* Count size only */
786  else if (cchWritten >= cchOut)
787  goto overrun;
788  else if (!bSkipping || *lpFormat == ' ')
789  {
790  lpStr[cchWritten] = *lpFormat;
791  cchWritten++;
792  }
793  lpFormat++;
794  }
795  }
796 
797  /* Final string terminator and sanity check */
798  if (cchOut)
799  {
800  if (cchWritten >= cchOut)
801  goto overrun;
802  else
803  lpStr[cchWritten] = '\0';
804  }
805  cchWritten++; /* Include terminating NUL */
806 
807  TRACE("returning length=%d, output=%s\n", cchWritten, debugstr_w(lpStr));
808  return cchWritten;
809 
810 overrun:
811  TRACE("returning 0, (ERROR_INSUFFICIENT_BUFFER)\n");
813  return 0;
814 
815 invalid_parameter:
817  return 0;
818 
819 invalid_flags:
821  return 0;
822 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:179
#define GetShortDate(fmt)
Definition: lcformat.c:96
#define TRUE
Definition: types.h:120
#define snprintfW
Definition: unicode.h:60
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
BOOL JapaneseEra_IsFirstYearGannen(void)
Definition: japanese.c:63
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WORD wMonth
Definition: winbase.h:871
GLuint GLuint GLsizei count
Definition: gl.h:1545
WORD wDayOfWeek
Definition: winbase.h:872
#define DATE_SHORTDATE
Definition: winnls.h:193
#define TIME_TIMEVARSONLY
Definition: lcformat.c:67
#define GetGenitiveMonth(fmt, mth)
Definition: lcformat.c:105
#define GetAM(fmt)
Definition: lcformat.c:98
#define IsLiteralMarker(p)
Definition: lcformat.c:377
#define DATE_DATEVARSONLY
Definition: lcformat.c:66
int32_t INT
Definition: typedefs.h:56
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:178
struct node node
WORD wYear
Definition: winbase.h:870
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define GetPM(fmt)
Definition: lcformat.c:99
#define FIXME(fmt,...)
Definition: debug.h:110
WORD wMinute
Definition: winbase.h:875
smooth NULL
Definition: ftsmooth.c:416
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
#define GetLongDate(fmt)
Definition: lcformat.c:95
#define IsTimeFmtChar(p)
Definition: lcformat.c:379
#define GetLongMonth(fmt, mth)
Definition: lcformat.c:104
#define GetShortDay(fmt, day)
Definition: lcformat.c:103
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR szEraName[16]
Definition: japanese.h:14
#define GetLongDay(fmt, day)
Definition: lcformat.c:102
PCJAPANESE_ERA JapaneseEra_Find(const SYSTEMTIME *pst OPTIONAL)
Definition: japanese.c:236
#define TIME_NOMINUTESORSECONDS
Definition: winnls.h:274
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
WORD wSecond
Definition: winbase.h:876
#define DATE_FORMAT_FLAGS
Definition: lcformat.c:385
#define DATE_USE_ALT_CALENDAR
Definition: winnls.h:195
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GetYearMonth(fmt)
Definition: lcformat.c:100
LPCWSTR lpFormat
Definition: trayclock.cpp:32
WORD wDay
Definition: winbase.h:873
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
#define TIME_FORCE24HOURFORMAT
Definition: winnls.h:277
#define IsDateFmtChar(p)
Definition: lcformat.c:378
#define ARRAY_SIZE(a)
Definition: main.h:24
#define DATE_LONGDATE
Definition: winnls.h:194
WORD wHour
Definition: winbase.h:874
#define GetShortMonth(fmt, mth)
Definition: lcformat.c:106
#define GetTime(fmt)
Definition: lcformat.c:97
#define TIME_NOSECONDS
Definition: winnls.h:275
#define memset(x, y, z)
Definition: compat.h:39
static unsigned char buff[32768]
Definition: fatten.c:17
WORD wYear
Definition: japanese.h:11
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define TIME_NOTIMEMARKER
Definition: winnls.h:276
Definition: dlist.c:348
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TIME_FORMAT_FLAGS
Definition: lcformat.c:387

Referenced by GetDateFormatW(), GetTimeFormatW(), and NLS_GetDateTimeFormatA().

◆ NLS_GetFormats()

static const NLS_FORMAT_NODE* NLS_GetFormats ( LCID  lcid,
DWORD  dwFlags 
)
static

Definition at line 178 of file lcformat.c.

179 {
180  /* GetLocaleInfo() identifiers for cached formatting strings */
181  static const LCTYPE NLS_LocaleIndices[] = {
211  LOCALE_SYEARMONTH
212  };
213  static NLS_FORMAT_NODE *NLS_CachedFormats = NULL;
214  NLS_FORMAT_NODE *node = NLS_CachedFormats;
215 
217 
218  TRACE("(0x%04x,0x%08x)\n", lcid, dwFlags);
219 
220  /* See if we have already cached the locales number format */
221  while (node && (node->lcid != lcid || node->dwFlags != dwFlags) && node->next)
222  node = node->next;
223 
224  if (!node || node->lcid != lcid || node->dwFlags != dwFlags)
225  {
226  NLS_FORMAT_NODE *new_node;
227  DWORD i;
228 
229  TRACE("Creating new cache entry\n");
230 
231  if (!(new_node = HeapAlloc(GetProcessHeap(), 0, sizeof(NLS_FORMAT_NODE))))
232  return NULL;
233 
235 
236  /* Number Format */
237  new_node->lcid = lcid;
238  new_node->dwFlags = dwFlags;
239  new_node->next = NULL;
240 
244 
246  if (new_node->fmt.Grouping > 9 && new_node->fmt.Grouping != 32)
247  {
248  WARN("LOCALE_SGROUPING (%d) unhandled, please report!\n",
249  new_node->fmt.Grouping);
250  new_node->fmt.Grouping = 0;
251  }
252 
255 
256  /* Currency Format */
257  new_node->cyfmt.NumDigits = new_node->fmt.NumDigits;
258  new_node->cyfmt.LeadingZero = new_node->fmt.LeadingZero;
259 
261 
262  if (new_node->cyfmt.Grouping > 9)
263  {
264  WARN("LOCALE_SMONGROUPING (%d) unhandled, please report!\n",
265  new_node->cyfmt.Grouping);
266  new_node->cyfmt.Grouping = 0;
267  }
268 
270  if (new_node->cyfmt.NegativeOrder > 15)
271  {
272  WARN("LOCALE_INEGCURR (%d) unhandled, please report!\n",
273  new_node->cyfmt.NegativeOrder);
274  new_node->cyfmt.NegativeOrder = 0;
275  }
277  if (new_node->cyfmt.PositiveOrder > 3)
278  {
279  WARN("LOCALE_IPOSCURR (%d) unhandled,please report!\n",
280  new_node->cyfmt.PositiveOrder);
281  new_node->cyfmt.PositiveOrder = 0;
282  }
286 
287  /* Date/Time Format info, negative character, etc */
288  for (i = 0; i < ARRAY_SIZE(NLS_LocaleIndices); i++)
289  {
290  GET_LOCALE_STRING(new_node->lppszStrings[i], NLS_LocaleIndices[i]);
291  }
292  /* Save some memory if month genitive name is the same or not present */
293  for (i = 0; i < 12; i++)
294  {
295  if (strcmpW(GetLongMonth(new_node, i), GetGenitiveMonth(new_node, i)) == 0)
296  {
297  HeapFree(GetProcessHeap(), 0, GetGenitiveMonth(new_node, i));
298  GetGenitiveMonth(new_node, i) = NULL;
299  }
300  }
301 
302  new_node->szShortAM[0] = GetAM(new_node)[0]; new_node->szShortAM[1] = '\0';
303  new_node->szShortPM[0] = GetPM(new_node)[0]; new_node->szShortPM[1] = '\0';
304 
305  /* Now add the computed format to the cache */
307 
308  /* Search again: We may have raced to add the node */
309  node = NLS_CachedFormats;
310  while (node && (node->lcid != lcid || node->dwFlags != dwFlags) && node->next)
311  node = node->next;
312 
313  if (!node)
314  {
315  node = NLS_CachedFormats = new_node; /* Empty list */
316  new_node = NULL;
317  }
318  else if (node->lcid != lcid || node->dwFlags != dwFlags)
319  {
320  node->next = new_node; /* Not in the list, add to end */
321  node = new_node;
322  new_node = NULL;
323  }
324 
326 
327  if (new_node)
328  {
329  /* We raced and lost: The node was already added by another thread.
330  * node points to the currently cached node, so free new_node.
331  */
332  for (i = 0; i < ARRAY_SIZE(NLS_LocaleIndices); i++)
333  HeapFree(GetProcessHeap(), 0, new_node->lppszStrings[i]);
334  HeapFree(GetProcessHeap(), 0, new_node->fmt.lpDecimalSep);
335  HeapFree(GetProcessHeap(), 0, new_node->fmt.lpThousandSep);
336  HeapFree(GetProcessHeap(), 0, new_node->cyfmt.lpDecimalSep);
337  HeapFree(GetProcessHeap(), 0, new_node->cyfmt.lpThousandSep);
339  HeapFree(GetProcessHeap(), 0, new_node);
340  }
341  }
342  return node;
343 }
LPWSTR lpThousandSep
Definition: winnls.h:643
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
CURRENCYFMTW cyfmt
Definition: lcformat.c:86
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
LPWSTR lpDecimalSep
Definition: winnls.h:642
UINT PositiveOrder
Definition: winnls.h:615
UINT Grouping
Definition: winnls.h:611
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
UINT NegativeOrder
Definition: winnls.h:614
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
UINT LeadingZero
Definition: winnls.h:610
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define WARN(fmt,...)
Definition: debug.h:111
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_ILZERO
Definition: winnls.h:46
void * next
Definition: dlist.c:360
UINT Grouping
Definition: winnls.h:641
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define GetGenitiveMonth(fmt, mth)
Definition: lcformat.c:105
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define GetAM(fmt)
Definition: lcformat.c:98
LPWSTR lpThousandSep
Definition: winnls.h:613
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define LOCALE_RETURN_GENITIVE_NAMES
Definition: winnls.h:24
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SCURRENCY
Definition: winnls.h:49
UINT NegativeOrder
Definition: winnls.h:644
#define LOCALE_INEGNUMBER
Definition: winnls.h:47
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
struct node node
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
DWORD LCTYPE
Definition: winnls.h:514
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define GetPM(fmt)
Definition: lcformat.c:99
UINT NumDigits
Definition: winnls.h:639
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define GET_LOCALE_NUMBER(num, type)
Definition: lcformat.c:167
#define LOCALE_INEGCURR
Definition: winnls.h:57
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
smooth NULL
Definition: ftsmooth.c:416
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SDECIMAL
Definition: winnls.h:42
struct _NLS_FORMAT_NODE * next
Definition: lcformat.c:90
#define GetLongMonth(fmt, mth)
Definition: lcformat.c:104
WCHAR szShortAM[2]
Definition: lcformat.c:88
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_ICURRENCY
Definition: winnls.h:56
#define LOCALE_SMONDECIMALSEP
Definition: winnls.h:51
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SMONTHOUSANDSEP
Definition: winnls.h:52
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
#define LOCALE_S1159
Definition: winnls.h:71
LPWSTR lpDecimalSep
Definition: winnls.h:612
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define LOCALE_IDIGITS
Definition: winnls.h:45
#define GET_LOCALE_STRING(str, type)
Definition: lcformat.c:170
NUMBERFMTW fmt
Definition: lcformat.c:85
LPWSTR lpCurrencySymbol
Definition: winnls.h:616
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define ARRAY_SIZE(a)
Definition: main.h:24
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
WCHAR szShortPM[2]
Definition: lcformat.c:89
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
UINT NumDigits
Definition: winnls.h:609
DWORD dwCodePage
Definition: lcformat.c:84
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
UINT LeadingZero
Definition: winnls.h:640
static CRITICAL_SECTION NLS_FormatsCS
Definition: lcformat.c:109
LPWSTR lppszStrings[NLS_NUM_CACHED_STRINGS]
Definition: lcformat.c:87
#define LOCALE_S2359
Definition: winnls.h:72
#define LOCALE_STIMEFORMAT
Definition: winnls.h:62
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: dlist.c:348

Referenced by GetCalendarInfoA(), GetCurrencyFormatA(), GetCurrencyFormatW(), GetNumberFormatA(), GetNumberFormatW(), NLS_GetDateTimeFormatA(), and NLS_GetDateTimeFormatW().

◆ NLS_GetLocaleNumber()

static DWORD NLS_GetLocaleNumber ( LCID  lcid,
DWORD  dwFlags 
)
static

Definition at line 128 of file lcformat.c.

129 {
130  WCHAR szBuff[80];
131  DWORD dwVal = 0;
132 
133  szBuff[0] = '\0';
134  GetLocaleInfoW(lcid, dwFlags, szBuff, ARRAY_SIZE(szBuff));
135 
136  if (szBuff[0] && szBuff[1] == ';' && szBuff[2] != '0')
137  dwVal = (szBuff[0] - '0') * 10 + (szBuff[2] - '0');
138  else
139  {
140  const WCHAR* iter = szBuff;
141  dwVal = 0;
142  while(*iter >= '0' && *iter <= '9')
143  dwVal = dwVal * 10 + (*iter++ - '0');
144  }
145  return dwVal;
146 }
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by NLS_EnumCalendarInfo().

◆ NLS_GetLocaleString()

static WCHAR* NLS_GetLocaleString ( LCID  lcid,
DWORD  dwFlags 
)
static

Definition at line 153 of file lcformat.c.

154 {
155  WCHAR szBuff[80], *str;
156  DWORD dwLen;
157 
158  szBuff[0] = '\0';
159  GetLocaleInfoW(lcid, dwFlags, szBuff, ARRAY_SIZE(szBuff));
160  dwLen = strlenW(szBuff) + 1;
161  str = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
162  if (str)
163  memcpy(str, szBuff, dwLen * sizeof(WCHAR));
164  return str;
165 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
const WCHAR * str
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ARRAY_SIZE(a)
Definition: main.h:24

◆ NLS_IsUnicodeOnlyLcid()

BOOL NLS_IsUnicodeOnlyLcid ( LCID  lcid)

Definition at line 350 of file lcformat.c.

351 {
353 
354  switch (PRIMARYLANGID(lcid))
355  {
356  case LANG_ARMENIAN:
357  case LANG_DIVEHI:
358  case LANG_GEORGIAN:
359  case LANG_GUJARATI:
360  case LANG_HINDI:
361  case LANG_KANNADA:
362  case LANG_KONKANI:
363  case LANG_MARATHI:
364  case LANG_PUNJABI:
365  case LANG_SANSKRIT:
366  TRACE("lcid 0x%08x: langid 0x%4x is Unicode Only\n", lcid, PRIMARYLANGID(lcid));
367  return TRUE;
368  default:
369  return FALSE;
370  }
371 }
#define TRUE
Definition: types.h:120
#define LANG_HINDI
Definition: nls.h:68
#define LANG_DIVEHI
Definition: nls.h:50
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: lang.c:1502
#define LANG_KONKANI
Definition: nls.h:83
#define TRACE(s)
Definition: solgame.cpp:4
#define LANG_SANSKRIT
Definition: nls.h:115
#define LANG_KANNADA
Definition: nls.h:77
#define LANG_MARATHI
Definition: nls.h:98
#define LANG_PUNJABI
Definition: nls.h:109
#define LANG_ARMENIAN
Definition: nls.h:30
#define LANG_GEORGIAN
Definition: nls.h:61
#define LANG_GUJARATI
Definition: nls.h:65
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by GetCalendarInfoA(), GetCurrencyFormatA(), GetNumberFormatA(), and NLS_GetDateTimeFormatA().

◆ SetCalendarInfoA()

int WINAPI SetCalendarInfoA ( LCID  Locale,
CALID  Calendar,
CALTYPE  CalType,
LPCSTR  lpCalData 
)

Definition at line 2814 of file lcformat.c.

2815 {
2816  FIXME("(%08x,%08x,%08x,%s): stub\n",
2817  Locale, Calendar, CalType, debugstr_a(lpCalData));
2818  return 0;
2819 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_a
Definition: kernel32.h:31

◆ SetCalendarInfoW()

int WINAPI SetCalendarInfoW ( LCID  Locale,
CALID  Calendar,
CALTYPE  CalType,
LPCWSTR  lpCalData 
)

Definition at line 2826 of file lcformat.c.

2827 {
2828  FIXME("(%08x,%08x,%08x,%s): stub\n",
2829  Locale, Calendar, CalType, debugstr_w(lpCalData));
2830  return 0;
2831 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by SetMaxDate().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( nls  )

Variable Documentation

◆ NLS_FormatsCS

static CRITICAL_SECTION NLS_FormatsCS = { &NLS_FormatsCS_debug, -1, 0, 0, 0, 0 }
static

Definition at line 109 of file lcformat.c.

Referenced by NLS_GetFormats().

◆ NLS_FormatsCS_debug

CRITICAL_SECTION_DEBUG NLS_FormatsCS_debug
static
Initial value:
=
{
0, 0, &NLS_FormatsCS,
0, 0, { (DWORD_PTR)(__FILE__ ": NLS_Formats") }
}
#define DWORD_PTR
Definition: treelist.c:76
static CRITICAL_SECTION_DEBUG NLS_FormatsCS_debug
Definition: lcformat.c:110
LIST_ENTRY ProcessLocksList
Definition: winbase.h:848
static CRITICAL_SECTION NLS_FormatsCS
Definition: lcformat.c:109

Definition at line 110 of file lcformat.c.