ReactOS 0.4.16-dev-311-g9382aa2
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 1569 of file lcformat.c.

◆ CF_CY_RIGHT

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

Definition at line 1570 of file lcformat.c.

◆ CF_CY_SPACE

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

Definition at line 1571 of file lcformat.c.

◆ CF_MINUS_BEFORE

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

Definition at line 1568 of file lcformat.c.

◆ CF_MINUS_LEFT

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

Definition at line 1566 of file lcformat.c.

◆ CF_MINUS_RIGHT

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

Definition at line 1567 of file lcformat.c.

◆ CF_PARENS

#define CF_PARENS   0x1 /* Parentheses */

Definition at line 1565 of file lcformat.c.

◆ DATE_DATEVARSONLY

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

Definition at line 80 of file lcformat.c.

◆ DATE_FORMAT_FLAGS

#define DATE_FORMAT_FLAGS   (DATE_DATEVARSONLY)

Definition at line 399 of file lcformat.c.

◆ GET_LOCALE_NUMBER

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

Definition at line 181 of file lcformat.c.

◆ GET_LOCALE_STRING

#define GET_LOCALE_STRING (   str,
  type 
)
Value:
TRACE( #type ": %s\n", debugstr_w(str))
#define debugstr_w
Definition: kernel32.h:32
static WCHAR * NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:167
const WCHAR * str

Definition at line 184 of file lcformat.c.

◆ GetAM

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

Definition at line 112 of file lcformat.c.

◆ GetGenitiveMonth

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

Definition at line 119 of file lcformat.c.

◆ GetLongDate

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

Definition at line 109 of file lcformat.c.

◆ GetLongDay

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

Definition at line 116 of file lcformat.c.

◆ GetLongMonth

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

Definition at line 118 of file lcformat.c.

◆ GetNegative

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

Definition at line 108 of file lcformat.c.

◆ GetPM

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

Definition at line 113 of file lcformat.c.

◆ GetShortDate

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

Definition at line 110 of file lcformat.c.

◆ GetShortDay

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

Definition at line 117 of file lcformat.c.

◆ GetShortMonth

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

Definition at line 120 of file lcformat.c.

◆ GetTime

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

Definition at line 111 of file lcformat.c.

◆ GetYearMonth

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

Definition at line 114 of file lcformat.c.

◆ IsDateFmtChar

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

Definition at line 392 of file lcformat.c.

◆ IsLiteralMarker

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

Definition at line 391 of file lcformat.c.

◆ IsTimeFmtChar

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

Definition at line 393 of file lcformat.c.

◆ NF_DIGITS

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

Definition at line 1196 of file lcformat.c.

◆ NF_DIGITS_OUT

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

Definition at line 1197 of file lcformat.c.

◆ NF_ISNEGATIVE

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

Definition at line 1194 of file lcformat.c.

◆ NF_ISREAL

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

Definition at line 1195 of file lcformat.c.

◆ NF_ROUND

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

Definition at line 1198 of file lcformat.c.

◆ NLS_NEG_LEFT

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

Definition at line 1202 of file lcformat.c.

◆ NLS_NEG_LEFT_SPACE

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

Definition at line 1203 of file lcformat.c.

◆ NLS_NEG_PARENS

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

Definition at line 1201 of file lcformat.c.

◆ NLS_NEG_RIGHT

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

Definition at line 1204 of file lcformat.c.

◆ NLS_NEG_RIGHT_SPACE

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

Definition at line 1205 of file lcformat.c.

◆ NLS_NUM_CACHED_STRINGS

#define NLS_NUM_CACHED_STRINGS   57

Definition at line 92 of file lcformat.c.

◆ TIME_FORMAT_FLAGS

#define TIME_FORMAT_FLAGS
Value:
#define TIME_TIMEVARSONLY
Definition: lcformat.c:81
#define TIME_NOTIMEMARKER
Definition: winnls.h:281
#define TIME_NOMINUTESORSECONDS
Definition: winnls.h:279
#define TIME_FORCE24HOURFORMAT
Definition: winnls.h:282
#define TIME_NOSECONDS
Definition: winnls.h:280

Definition at line 401 of file lcformat.c.

◆ TIME_TIMEVARSONLY

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

Definition at line 81 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 1884 of file lcformat.c.

1884 {
1888};
@ CALLBACK_ENUMPROCEX
Definition: lcformat.c:1886
@ CALLBACK_ENUMPROCEXEX
Definition: lcformat.c:1887
@ CALLBACK_ENUMPROC
Definition: lcformat.c:1885

Function Documentation

◆ EnumCalendarInfoA()

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

Definition at line 2341 of file lcformat.c.

2343{
2344 struct enumcalendar_context ctxt;
2345
2346 TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2347
2348 ctxt.type = CALLBACK_ENUMPROC;
2349 ctxt.u.callback = (CALINFO_ENUMPROCW)calinfoproc;
2350 ctxt.lcid = locale;
2351 ctxt.calendar = calendar;
2352 ctxt.caltype = caltype;
2353 ctxt.lParam = 0;
2354 ctxt.unicode = FALSE;
2355 return NLS_EnumCalendarInfo(&ctxt);
2356}
Definition: _locale.h:75
#define FALSE
Definition: types.h:117
static BOOL NLS_EnumCalendarInfo(const struct enumcalendar_context *ctxt)
Definition: lcformat.c:2223
#define TRACE(s)
Definition: solgame.cpp:4
BOOL(CALLBACK * CALINFO_ENUMPROCW)(LPWSTR)
Definition: winnls.h:530

◆ EnumCalendarInfoExA()

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

Definition at line 2381 of file lcformat.c.

2383{
2384 struct enumcalendar_context ctxt;
2385
2386 TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2387
2388 ctxt.type = CALLBACK_ENUMPROCEX;
2389 ctxt.u.callbackex = (CALINFO_ENUMPROCEXW)calinfoproc;
2390 ctxt.lcid = locale;
2391 ctxt.calendar = calendar;
2392 ctxt.caltype = caltype;
2393 ctxt.lParam = 0;
2394 ctxt.unicode = FALSE;
2395 return NLS_EnumCalendarInfo(&ctxt);
2396}
BOOL(CALLBACK * CALINFO_ENUMPROCEXW)(LPWSTR, CALID)
Definition: winnls.h:532

◆ EnumCalendarInfoExW()

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

Definition at line 2401 of file lcformat.c.

2403{
2404 struct enumcalendar_context ctxt;
2405
2406 TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2407
2408 ctxt.type = CALLBACK_ENUMPROCEX;
2409 ctxt.u.callbackex = calinfoproc;
2410 ctxt.lcid = locale;
2411 ctxt.calendar = calendar;
2412 ctxt.caltype = caltype;
2413 ctxt.lParam = 0;
2414 ctxt.unicode = TRUE;
2415 return NLS_EnumCalendarInfo(&ctxt);
2416}
#define TRUE
Definition: types.h:120

◆ EnumCalendarInfoW()

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

Definition at line 2361 of file lcformat.c.

2363{
2364 struct enumcalendar_context ctxt;
2365
2366 TRACE("(%p,0x%08x,0x%08x,0x%08x)\n", calinfoproc, locale, calendar, caltype);
2367
2368 ctxt.type = CALLBACK_ENUMPROC;
2369 ctxt.u.callback = calinfoproc;
2370 ctxt.lcid = locale;
2371 ctxt.calendar = calendar;
2372 ctxt.caltype = caltype;
2373 ctxt.lParam = 0;
2374 ctxt.unicode = TRUE;
2375 return NLS_EnumCalendarInfo(&ctxt);
2376}

◆ EnumDateFormatsA()

BOOL WINAPI EnumDateFormatsA ( DATEFMT_ENUMPROCA  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 = (DATEFMT_ENUMPROCW)proc;
2023 ctxt.lcid = lcid;
2024 ctxt.flags = flags;
2025 ctxt.unicode = FALSE;
2026
2027 return NLS_EnumDateFormats(&ctxt);
2028}
GLbitfield flags
Definition: glext.h:7161
static BOOL NLS_EnumDateFormats(const struct enumdateformats_context *ctxt)
Definition: lcformat.c:1914
static HANDLE proc()
Definition: pdb.c:34
enum enum_callback_type type
Definition: lcformat.c:1891
BOOL(CALLBACK * DATEFMT_ENUMPROCW)(LPWSTR)
Definition: winnls.h:545

Referenced by test_EnumDateFormatsA().

◆ EnumDateFormatsExA()

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

Definition at line 1982 of file lcformat.c.

1983{
1984 struct enumdateformats_context ctxt;
1985
1987 ctxt.u.callbackex = (DATEFMT_ENUMPROCEXW)proc;
1988 ctxt.lcid = lcid;
1989 ctxt.flags = flags;
1990 ctxt.unicode = FALSE;
1991
1992 return NLS_EnumDateFormats(&ctxt);
1993}
BOOL(CALLBACK * DATEFMT_ENUMPROCEXW)(LPWSTR, CALID)
Definition: winnls.h:547

◆ EnumDateFormatsExW()

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

Definition at line 1998 of file lcformat.c.

1999{
2000 struct enumdateformats_context ctxt;
2001
2003 ctxt.u.callbackex = proc;
2004 ctxt.lcid = lcid;
2005 ctxt.flags = flags;
2006 ctxt.unicode = TRUE;
2007
2008 return NLS_EnumDateFormats(&ctxt);
2009}

◆ EnumDateFormatsW()

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

Definition at line 2033 of file lcformat.c.

2034{
2035 struct enumdateformats_context ctxt;
2036
2037 ctxt.type = CALLBACK_ENUMPROC;
2038 ctxt.u.callback = proc;
2039 ctxt.lcid = lcid;
2040 ctxt.flags = flags;
2041 ctxt.unicode = TRUE;
2042
2043 return NLS_EnumDateFormats(&ctxt);
2044}

Referenced by InitLongDateCB(), and InitShortDateCB().

◆ EnumTimeFormatsA()

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

Definition at line 2134 of file lcformat.c.

2135{
2136 struct enumtimeformats_context ctxt;
2137
2138 /* EnumTimeFormatsA doesn't support flags, EnumTimeFormatsW does. */
2139 if (flags & ~LOCALE_USE_CP_ACP)
2140 {
2142 return FALSE;
2143 }
2144
2145 ctxt.type = CALLBACK_ENUMPROC;
2146 ctxt.u.callback = (TIMEFMT_ENUMPROCW)proc;
2147 ctxt.lcid = lcid;
2148 ctxt.flags = flags;
2149 ctxt.unicode = FALSE;
2150
2151 return NLS_EnumTimeFormats(&ctxt);
2152}
#define SetLastError(x)
Definition: compat.h:752
static BOOL NLS_EnumTimeFormats(struct enumtimeformats_context *ctxt)
Definition: lcformat.c:2077
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
BOOL(CALLBACK * TIMEFMT_ENUMPROCW)(LPWSTR)
Definition: winnls.h:549

Referenced by test_EnumTimeFormatsA(), and test_EnumTimeFormatsW().

◆ EnumTimeFormatsW()

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

Definition at line 2157 of file lcformat.c.

2158{
2159 struct enumtimeformats_context ctxt;
2160
2161 ctxt.type = CALLBACK_ENUMPROC;
2162 ctxt.u.callback = proc;
2163 ctxt.lcid = lcid;
2164 ctxt.flags = flags;
2165 ctxt.unicode = TRUE;
2166
2167 return NLS_EnumTimeFormats(&ctxt);
2168}
enum enum_callback_type type
Definition: lcformat.c:2066

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 2444 of file lcformat.c.

2446{
2447 int ret, cchDataW = cchData;
2448 LPWSTR lpCalDataW = NULL;
2449#ifdef __REACTOS__
2450 DWORD cp = CP_ACP;
2451 if (!(CalType & CAL_USE_CP_ACP))
2452 {
2453 DWORD dwFlags = ((CalType & CAL_NOUSEROVERRIDE) ? LOCALE_NOUSEROVERRIDE : 0);
2455 if (!node)
2456 {
2458 return 0;
2459 }
2460 cp = node->dwCodePage;
2461 }
2462 if ((CalType & 0xFFFF) == CAL_SABBREVERASTRING)
2463 {
2464 /* NOTE: CAL_SABBREVERASTRING is not supported in GetCalendarInfoA */
2466 return 0;
2467 }
2468#endif
2469
2470 if (NLS_IsUnicodeOnlyLcid(lcid))
2471 {
2473 return 0;
2474 }
2475
2476 if (!cchData && !(CalType & CAL_RETURN_NUMBER))
2477 cchDataW = GetCalendarInfoW(lcid, Calendar, CalType, NULL, 0, NULL);
2478 if (!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchDataW*sizeof(WCHAR))))
2479 return 0;
2480
2481 ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchDataW, lpValue);
2482 if(ret && lpCalDataW && lpCalData)
2483#ifdef __REACTOS__
2484 ret = WideCharToMultiByte(cp, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
2485#else
2486 ret = WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
2487#endif
2488 else if (CalType & CAL_RETURN_NUMBER)
2489 ret *= sizeof(WCHAR);
2490 HeapFree(GetProcessHeap(), 0, lpCalDataW);
2491
2492 return ret;
2493}
#define CAL_SABBREVERASTRING
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
Definition: lcformat.c:364
static const NLS_FORMAT_NODE * NLS_GetFormats(LCID lcid, DWORD dwFlags)
Definition: lcformat.c:192
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPWSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2499
POINT cp
Definition: magnifier.c:59
Definition: dlist.c:348
int ret
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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 2499 of file lcformat.c.

2501{
2502 static const LCTYPE caltype_lctype_map[] = {
2503 0, /* not used */
2504 0, /* CAL_ICALINTVALUE */
2505 0, /* CAL_SCALNAME */
2506 0, /* CAL_IYEAROFFSETRANGE */
2507 0, /* CAL_SERASTRING */
2550 LOCALE_SYEARMONTH,
2551 0, /* CAL_ITWODIGITYEARMAX */
2552#if (WINVER >= 0x0600) /* ReactOS */
2553 LOCALE_SSHORTESTDAYNAME1,
2554 LOCALE_SSHORTESTDAYNAME2,
2555 LOCALE_SSHORTESTDAYNAME3,
2556 LOCALE_SSHORTESTDAYNAME4,
2557 LOCALE_SSHORTESTDAYNAME5,
2558 LOCALE_SSHORTESTDAYNAME6,
2559 LOCALE_SSHORTESTDAYNAME7,
2560#endif
2562 0, /* CAL_SABBREVERASTRING */
2563 };
2564 DWORD localeflags = 0;
2565 CALTYPE calinfo;
2566
2567 if (CalType & CAL_NOUSEROVERRIDE)
2568 FIXME("flag CAL_NOUSEROVERRIDE used, not fully implemented\n");
2569 if (CalType & CAL_USE_CP_ACP)
2570 FIXME("flag CAL_USE_CP_ACP used, not fully implemented\n");
2571
2572 if (CalType & CAL_RETURN_NUMBER) {
2573 if (!lpValue)
2574 {
2576 return 0;
2577 }
2578 if (lpCalData != NULL)
2579 WARN("lpCalData not NULL (%p) when it should!\n", lpCalData);
2580 if (cchData != 0)
2581 WARN("cchData not 0 (%d) when it should!\n", cchData);
2582 } else {
2583 if (lpValue != NULL)
2584 WARN("lpValue not NULL (%p) when it should!\n", lpValue);
2585 }
2586
2587 /* FIXME: No verification is made yet wrt Locale
2588 * for the CALTYPES not requiring GetLocaleInfoA */
2589
2590 calinfo = CalType & 0xffff;
2591
2592#ifdef __REACTOS__
2593 if (CalType & LOCALE_RETURN_GENITIVE_NAMES)
2594#else
2595 if (CalType & CAL_RETURN_GENITIVE_NAMES)
2596#endif
2597 localeflags |= LOCALE_RETURN_GENITIVE_NAMES;
2598
2599 switch (calinfo) {
2600 case CAL_ICALINTVALUE:
2601#ifdef __REACTOS__
2602 if (IS_LCID_JAPANESE(Locale))
2603 {
2604 if (CalType & CAL_RETURN_NUMBER)
2605 {
2606 *lpValue = CAL_JAPAN;
2607 return sizeof(DWORD) / sizeof(WCHAR);
2608 }
2609 else
2610 {
2611 static const WCHAR fmtW[] = {'%','u',0};
2612 WCHAR buffer[10];
2613 int ret = snprintfW( buffer, 10, fmtW, CAL_JAPAN ) + 1;
2614 if (!lpCalData) return ret;
2615 if (ret <= cchData)
2616 {
2617 strcpyW( lpCalData, buffer );
2618 return ret;
2619 }
2621 return 0;
2622 }
2623 }
2624#endif
2625 if (CalType & CAL_RETURN_NUMBER)
2626 return GetLocaleInfoW(Locale, LOCALE_RETURN_NUMBER | LOCALE_ICALENDARTYPE,
2627 (LPWSTR)lpValue, 2);
2628 return GetLocaleInfoW(Locale, LOCALE_ICALENDARTYPE, lpCalData, cchData);
2629 case CAL_SCALNAME:
2630#ifdef __REACTOS__
2631 if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2632 {
2633 // Wareki
2634 lpCalData[0] = 0x548C;
2635 lpCalData[1] = 0x66A6;
2636 lpCalData[2] = 0;
2637 return 3;
2638 }
2639#endif
2640 FIXME("Unimplemented caltype %d\n", calinfo);
2641 if (lpCalData) *lpCalData = 0;
2642 return 1;
2644#ifdef __REACTOS__
2645 if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2646 {
2648 if (pEra)
2649 {
2650 if (CalType & CAL_RETURN_NUMBER)
2651 {
2652 *lpValue = pEra->wYear;
2653 return sizeof(DWORD) / sizeof(WCHAR);
2654 }
2655 else
2656 {
2657 static const WCHAR fmtW[] = {'%','u',0};
2658 WCHAR buffer[10];
2659 int ret = snprintfW( buffer, 10, fmtW, pEra->wYear ) + 1;
2660 if (!lpCalData) return ret;
2661 if (ret <= cchData)
2662 {
2663 strcpyW( lpCalData, buffer );
2664 return ret;
2665 }
2667 return 0;
2668 }
2669 }
2670 else
2671 {
2673 return 0;
2674 }
2675 }
2676#endif
2677 FIXME("Unimplemented caltype %d\n", calinfo);
2678 return 0;
2679 case CAL_SERASTRING:
2680#ifdef __REACTOS__
2681 if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2682 {
2684 if (pEra)
2685 {
2686 RtlStringCchCopyW(lpCalData, cchData, pEra->szEraName);
2687 return strlenW(lpCalData) + 1;
2688 }
2689 else
2690 {
2692 return 0;
2693 }
2694 }
2695#endif
2696 FIXME("Unimplemented caltype %d\n", calinfo);
2697 return 0;
2698 case CAL_SSHORTDATE:
2699 case CAL_SLONGDATE:
2700 case CAL_SDAYNAME1:
2701 case CAL_SDAYNAME2:
2702 case CAL_SDAYNAME3:
2703 case CAL_SDAYNAME4:
2704 case CAL_SDAYNAME5:
2705 case CAL_SDAYNAME6:
2706 case CAL_SDAYNAME7:
2714 case CAL_SMONTHNAME1:
2715 case CAL_SMONTHNAME2:
2716 case CAL_SMONTHNAME3:
2717 case CAL_SMONTHNAME4:
2718 case CAL_SMONTHNAME5:
2719 case CAL_SMONTHNAME6:
2720 case CAL_SMONTHNAME7:
2721 case CAL_SMONTHNAME8:
2722 case CAL_SMONTHNAME9:
2723 case CAL_SMONTHNAME10:
2724 case CAL_SMONTHNAME11:
2725 case CAL_SMONTHNAME12:
2726 case CAL_SMONTHNAME13:
2740 case CAL_SYEARMONTH:
2741 return GetLocaleInfoW(Locale, caltype_lctype_map[calinfo] | localeflags, lpCalData, cchData);
2742 case CAL_ITWODIGITYEARMAX:
2743#ifdef __REACTOS__
2744 if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2745 {
2746 if (CalType & CAL_RETURN_NUMBER)
2747 {
2748 *lpValue = JAPANESE_MAX_TWODIGITYEAR;
2749 return sizeof(DWORD) / sizeof(WCHAR);
2750 }
2751 else
2752 {
2753 static const WCHAR fmtW[] = {'%','u',0};
2754 WCHAR buffer[10];
2755 int ret = snprintfW( buffer, 10, fmtW, JAPANESE_MAX_TWODIGITYEAR ) + 1;
2756 if (!lpCalData) return ret;
2757 if (ret <= cchData)
2758 {
2759 strcpyW( lpCalData, buffer );
2760 return ret;
2761 }
2763 return 0;
2764 }
2765 }
2766#endif
2767 if (CalType & CAL_RETURN_NUMBER)
2768 {
2769 *lpValue = CALINFO_MAX_YEAR;
2770 return sizeof(DWORD) / sizeof(WCHAR);
2771 }
2772 else
2773 {
2774 static const WCHAR fmtW[] = {'%','u',0};
2775 WCHAR buffer[10];
2776 int ret = snprintfW( buffer, 10, fmtW, CALINFO_MAX_YEAR ) + 1;
2777 if (!lpCalData) return ret;
2778 if (ret <= cchData)
2779 {
2780 strcpyW( lpCalData, buffer );
2781 return ret;
2782 }
2784 return 0;
2785 }
2786 break;
2787#ifdef __REACTOS__
2789 if (IS_LCID_JAPANESE(Locale) && Calendar == CAL_JAPAN)
2790 {
2792 if (pEra)
2793 {
2794 RtlStringCchCopyW(lpCalData, cchData, pEra->szEraAbbrev);
2795 return strlenW(lpCalData) + 1;
2796 }
2797 }
2799 return 0;
2800#endif
2801 default:
2802 FIXME("Unknown caltype %d\n", calinfo);
2804 return 0;
2805 }
2806 return 0;
2807}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1666
GLuint buffer
Definition: glext.h:5915
PCJAPANESE_ERA JapaneseEra_Find(const SYSTEMTIME *pst OPTIONAL)
Definition: japanese.c:236
#define JAPANESE_MAX_TWODIGITYEAR
Definition: japanese.h:7
#define DWORD
Definition: nt_native.h:44
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
#define strlenW(s)
Definition: unicode.h:34
#define snprintfW
Definition: unicode.h:66
#define strcpyW(d, s)
Definition: unicode.h:35
WCHAR szEraAbbrev[5]
Definition: japanese.h:15
WORD wYear
Definition: japanese.h:11
WCHAR szEraName[16]
Definition: japanese.h:14
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:115
#define LOCALE_SMONTHNAME12
Definition: winnls.h:104
#define CAL_SMONTHNAME9
Definition: winnls.h:427
#define LOCALE_SMONTHNAME5
Definition: winnls.h:97
#define CAL_SDAYNAME5
Definition: winnls.h:409
#define CAL_SABBREVMONTHNAME8
Definition: winnls.h:439
#define LOCALE_SDAYNAME5
Definition: winnls.h:83
#define CAL_SABBREVMONTHNAME6
Definition: winnls.h:437
#define CAL_SABBREVMONTHNAME12
Definition: winnls.h:443
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:114
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:116
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:87
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:107
#define CAL_SMONTHNAME6
Definition: winnls.h:424
#define CAL_SCALNAME
Definition: winnls.h:400
#define LOCALE_SMONTHNAME13
Definition: winnls.h:105
#define CAL_SERASTRING
Definition: winnls.h:402
#define CAL_SABBREVMONTHNAME9
Definition: winnls.h:440
#define CAL_SABBREVMONTHNAME10
Definition: winnls.h:441
#define LOCALE_SMONTHNAME3
Definition: winnls.h:95
#define LOCALE_SMONTHNAME11
Definition: winnls.h:103
#define LOCALE_SMONTHNAME8
Definition: winnls.h:100
#define CAL_SABBREVMONTHNAME7
Definition: winnls.h:438
#define LOCALE_SMONTHNAME4
Definition: winnls.h:96
#define CAL_SABBREVDAYNAME7
Definition: winnls.h:418
#define LOCALE_SABBREVMONTHNAME13
Definition: winnls.h:118
#define CAL_SABBREVDAYNAME5
Definition: winnls.h:416
#define LOCALE_SDAYNAME1
Definition: winnls.h:79
#define CAL_SABBREVMONTHNAME11
Definition: winnls.h:442
#define CAL_SMONTHNAME4
Definition: winnls.h:422
#define LOCALE_SLONGDATE
Definition: winnls.h:63
#define CAL_SABBREVMONTHNAME1
Definition: winnls.h:432
#define LOCALE_SMONTHNAME7
Definition: winnls.h:99
#define CAL_SMONTHNAME8
Definition: winnls.h:426
#define CAL_ICALINTVALUE
Definition: winnls.h:399
DWORD CALTYPE
Definition: winnls.h:520
#define CAL_SDAYNAME3
Definition: winnls.h:407
#define CAL_SABBREVMONTHNAME3
Definition: winnls.h:434
#define LOCALE_SSHORTDATE
Definition: winnls.h:62
#define CAL_SMONTHNAME12
Definition: winnls.h:430
#define CAL_SDAYNAME4
Definition: winnls.h:408
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:109
#define CAL_SABBREVMONTHNAME5
Definition: winnls.h:436
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:89
#define CAL_JAPAN
Definition: winnls.h:447
#define CAL_SDAYNAME1
Definition: winnls.h:405
#define CAL_SMONTHNAME7
Definition: winnls.h:425
#define CAL_SSHORTDATE
Definition: winnls.h:403
#define LOCALE_SMONTHNAME1
Definition: winnls.h:93
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:108
#define CAL_SMONTHNAME11
Definition: winnls.h:429
#define CAL_SMONTHNAME2
Definition: winnls.h:420
#define LOCALE_SDAYNAME7
Definition: winnls.h:85
#define LOCALE_SDAYNAME2
Definition: winnls.h:80
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:106
#define CAL_SDAYNAME7
Definition: winnls.h:411
#define CAL_SABBREVDAYNAME6
Definition: winnls.h:417
#define CAL_SLONGDATE
Definition: winnls.h:404
#define CAL_SABBREVDAYNAME4
Definition: winnls.h:415
#define CAL_SMONTHNAME10
Definition: winnls.h:428
#define CAL_SDAYNAME6
Definition: winnls.h:410
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:91
#define LOCALE_SMONTHNAME2
Definition: winnls.h:94
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:86
#define LOCALE_SMONTHDAY
Definition: winnls.h:164
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:111
#define LOCALE_SMONTHNAME6
Definition: winnls.h:98
DWORD LCTYPE
Definition: winnls.h:519
#define LOCALE_SDAYNAME3
Definition: winnls.h:81
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:88
#define CAL_SMONTHNAME3
Definition: winnls.h:421
#define CAL_SMONTHNAME13
Definition: winnls.h:431
#define CAL_IYEAROFFSETRANGE
Definition: winnls.h:401
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:110
#define CAL_SABBREVMONTHNAME2
Definition: winnls.h:433
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:112
#define LOCALE_ICALENDARTYPE
Definition: winnls.h:75
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:113
#define CAL_SABBREVDAYNAME2
Definition: winnls.h:413
#define LOCALE_SDAYNAME4
Definition: winnls.h:82
#define LOCALE_SMONTHNAME10
Definition: winnls.h:102
#define LOCALE_SMONTHNAME9
Definition: winnls.h:101
#define CAL_SMONTHNAME1
Definition: winnls.h:419
#define CAL_SABBREVMONTHNAME13
Definition: winnls.h:444
#define CAL_SMONTHNAME5
Definition: winnls.h:423
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:117
#define LOCALE_SDAYNAME6
Definition: winnls.h:84
#define CAL_SABBREVMONTHNAME4
Definition: winnls.h:435
#define CAL_SABBREVDAYNAME3
Definition: winnls.h:414
#define CAL_SABBREVDAYNAME1
Definition: winnls.h:412
#define LOCALE_RETURN_GENITIVE_NAMES
Definition: winnls.h:24
#define CAL_SDAYNAME2
Definition: winnls.h:406
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:92

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 1496 of file lcformat.c.

1499{
1500 DWORD cp = CP_ACP;
1501 WCHAR szDec[8], szGrp[8], szCy[8], szIn[128], szOut[128];
1503 const CURRENCYFMTW *pfmt = NULL;
1504 INT iRet;
1505
1506 TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
1507 lpFormat, lpCurrencyStr, cchOut);
1508
1509 if (NLS_IsUnicodeOnlyLcid(lcid))
1510 {
1512 return 0;
1513 }
1514
1515 if (!(dwFlags & LOCALE_USE_CP_ACP))
1516 {
1518 if (!node)
1519 {
1521 return 0;
1522 }
1523
1524 cp = node->dwCodePage;
1525 }
1526
1527 if (lpFormat)
1528 {
1529 memcpy(&fmt, lpFormat, sizeof(fmt));
1530 pfmt = &fmt;
1531 if (lpFormat->lpDecimalSep)
1532 {
1533 MultiByteToWideChar(cp, 0, lpFormat->lpDecimalSep, -1, szDec, ARRAY_SIZE(szDec));
1534 fmt.lpDecimalSep = szDec;
1535 }
1536 if (lpFormat->lpThousandSep)
1537 {
1538 MultiByteToWideChar(cp, 0, lpFormat->lpThousandSep, -1, szGrp, ARRAY_SIZE(szGrp));
1539 fmt.lpThousandSep = szGrp;
1540 }
1541 if (lpFormat->lpCurrencySymbol)
1542 {
1543 MultiByteToWideChar(cp, 0, lpFormat->lpCurrencySymbol, -1, szCy, ARRAY_SIZE(szCy));
1544 fmt.lpCurrencySymbol = szCy;
1545 }
1546 }
1547
1548 if (lpszValue)
1549 MultiByteToWideChar(cp, 0, lpszValue, -1, szIn, ARRAY_SIZE(szIn));
1550
1551 if (cchOut > (int) ARRAY_SIZE(szOut))
1552 cchOut = ARRAY_SIZE(szOut);
1553
1554 szOut[0] = '\0';
1555
1556 iRet = GetCurrencyFormatW(lcid, dwFlags, lpszValue ? szIn : NULL, pfmt,
1557 lpCurrencyStr ? szOut : NULL, cchOut);
1558
1559 if (szOut[0] && lpCurrencyStr)
1560 WideCharToMultiByte(cp, 0, szOut, -1, lpCurrencyStr, cchOut, 0, 0);
1561 return iRet;
1562}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define MultiByteToWideChar
Definition: compat.h:110
#define debugstr_a
Definition: kernel32.h:31
INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
Definition: lcformat.c:1578
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: dsound.c:943
LPCWSTR lpFormat
Definition: trayclock.cpp:32
int32_t INT
Definition: typedefs.h:58

Referenced by test_GetCurrencyFormatA().

◆ GetCurrencyFormatW()

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

Definition at line 1578 of file lcformat.c.

1581{
1582 static const BYTE NLS_NegCyFormats[16] =
1583 {
1584 CF_PARENS|CF_CY_LEFT, /* ($1.1) */
1586 CF_MINUS_LEFT|CF_CY_LEFT, /* $-1.1 */
1587 CF_MINUS_RIGHT|CF_CY_LEFT, /* $1.1- */
1588 CF_PARENS|CF_CY_RIGHT, /* (1.1$) */
1589 CF_MINUS_LEFT|CF_CY_RIGHT, /* -1.1$ */
1591 CF_MINUS_RIGHT|CF_CY_RIGHT, /* 1.1$- */
1598 CF_PARENS|CF_CY_LEFT|CF_CY_SPACE, /* ($ 1.1) */
1599 CF_PARENS|CF_CY_RIGHT|CF_CY_SPACE, /* (1.1 $) */
1600 };
1601 static const BYTE NLS_PosCyFormats[4] =
1602 {
1603 CF_CY_LEFT, /* $1.1 */
1604 CF_CY_RIGHT, /* 1.1$ */
1605 CF_CY_LEFT|CF_CY_SPACE, /* $ 1.1 */
1606 CF_CY_RIGHT|CF_CY_SPACE, /* 1.1 $ */
1607 };
1608 WCHAR szBuff[128], *szOut = szBuff + ARRAY_SIZE(szBuff) - 1;
1609 WCHAR szNegBuff[8];
1610 const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc, *lpszCy, *lpszCyStart;
1611 DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0, dwFmt;
1612 INT iRet;
1613
1614 TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
1615 lpFormat, lpCurrencyStr, cchOut);
1616
1617 if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
1618 !IsValidLocale(lcid, 0) ||
1619 (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
1620 !lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
1621 lpFormat->PositiveOrder > 3)))
1622 {
1623 goto error;
1624 }
1625
1626 if (!lpFormat)
1627 {
1629
1630 if (!node)
1631 goto error;
1632
1633 lpFormat = &node->cyfmt;
1634 lpszNegStart = lpszNeg = GetNegative(node);
1635 }
1636 else
1637 {
1639 szNegBuff, ARRAY_SIZE(szNegBuff));
1640 lpszNegStart = lpszNeg = szNegBuff;
1641 }
1643
1644 lpszNeg = lpszNeg + strlenW(lpszNeg) - 1;
1645 lpszCyStart = lpFormat->lpCurrencySymbol;
1646 lpszCy = lpszCyStart + strlenW(lpszCyStart) - 1;
1647
1648 /* Format the currency backwards into a temporary buffer */
1649
1650 szSrc = lpszValue;
1651 *szOut-- = '\0';
1652
1653 /* Check the number for validity */
1654 while (*szSrc)
1655 {
1656 if (*szSrc >= '0' && *szSrc <= '9')
1657 {
1658 dwState |= NF_DIGITS;
1659 if (dwState & NF_ISREAL)
1660 dwDecimals++;
1661 }
1662 else if (*szSrc == '-')
1663 {
1664 if (dwState)
1665 goto error; /* '-' not first character */
1666 dwState |= NF_ISNEGATIVE;
1667 }
1668 else if (*szSrc == '.')
1669 {
1670 if (dwState & NF_ISREAL)
1671 goto error; /* More than one '.' */
1672 dwState |= NF_ISREAL;
1673 }
1674 else
1675 goto error; /* Invalid char */
1676 szSrc++;
1677 }
1678 szSrc--; /* Point to last character */
1679
1680 if (!(dwState & NF_DIGITS))
1681 goto error; /* No digits */
1682
1683 if (dwState & NF_ISNEGATIVE)
1684 dwFmt = NLS_NegCyFormats[lpFormat->NegativeOrder];
1685 else
1686 dwFmt = NLS_PosCyFormats[lpFormat->PositiveOrder];
1687
1688 /* Add any trailing negative or currency signs */
1689 if (dwFmt & CF_PARENS)
1690 *szOut-- = ')';
1691
1692 while (dwFmt & (CF_MINUS_RIGHT|CF_CY_RIGHT))
1693 {
1694 switch (dwFmt & (CF_MINUS_RIGHT|CF_MINUS_BEFORE|CF_CY_RIGHT))
1695 {
1696 case CF_MINUS_RIGHT:
1698 while (lpszNeg >= lpszNegStart)
1699 *szOut-- = *lpszNeg--;
1700 dwFmt &= ~CF_MINUS_RIGHT;
1701 break;
1702
1703 case CF_CY_RIGHT:
1706 while (lpszCy >= lpszCyStart)
1707 *szOut-- = *lpszCy--;
1708 if (dwFmt & CF_CY_SPACE)
1709 *szOut-- = ' ';
1710 dwFmt &= ~(CF_CY_RIGHT|CF_MINUS_BEFORE);
1711 break;
1712 }
1713 }
1714
1715 /* Copy all digits up to the decimal point */
1716 if (!lpFormat->NumDigits)
1717 {
1718 if (dwState & NF_ISREAL)
1719 {
1720 while (*szSrc != '.') /* Don't write any decimals or a separator */
1721 {
1722 if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1723 dwState |= NF_ROUND;
1724 else
1725 dwState &= ~NF_ROUND;
1726 szSrc--;
1727 }
1728 szSrc--;
1729 }
1730 }
1731 else
1732 {
1733 LPWSTR lpszDec = lpFormat->lpDecimalSep + strlenW(lpFormat->lpDecimalSep) - 1;
1734
1735 if (dwDecimals <= lpFormat->NumDigits)
1736 {
1737 dwDecimals = lpFormat->NumDigits - dwDecimals;
1738 while (dwDecimals--)
1739 *szOut-- = '0'; /* Pad to correct number of dp */
1740 }
1741 else
1742 {
1743 dwDecimals -= lpFormat->NumDigits;
1744 /* Skip excess decimals, and determine if we have to round the number */
1745 while (dwDecimals--)
1746 {
1747 if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1748 dwState |= NF_ROUND;
1749 else
1750 dwState &= ~NF_ROUND;
1751 szSrc--;
1752 }
1753 }
1754
1755 if (dwState & NF_ISREAL)
1756 {
1757 while (*szSrc != '.')
1758 {
1759 if (dwState & NF_ROUND)
1760 {
1761 if (*szSrc == '9')
1762 *szOut-- = '0'; /* continue rounding */
1763 else
1764 {
1765 dwState &= ~NF_ROUND;
1766 *szOut-- = (*szSrc)+1;
1767 }
1768 szSrc--;
1769 }
1770 else
1771 *szOut-- = *szSrc--; /* Write existing decimals */
1772 }
1773 szSrc--; /* Skip '.' */
1774 }
1775 while (lpszDec >= lpFormat->lpDecimalSep)
1776 *szOut-- = *lpszDec--; /* Write decimal separator */
1777 }
1778
1779 dwGroupCount = lpFormat->Grouping == 32 ? 3 : lpFormat->Grouping;
1780
1781 /* Write the remaining whole number digits, including grouping chars */
1782 while (szSrc >= lpszValue && *szSrc >= '0' && *szSrc <= '9')
1783 {
1784 if (dwState & NF_ROUND)
1785 {
1786 if (*szSrc == '9')
1787 *szOut-- = '0'; /* continue rounding */
1788 else
1789 {
1790 dwState &= ~NF_ROUND;
1791 *szOut-- = (*szSrc)+1;
1792 }
1793 szSrc--;
1794 }
1795 else
1796 *szOut-- = *szSrc--;
1797
1798 dwState |= NF_DIGITS_OUT;
1799 dwCurrentGroupCount++;
1800 if (szSrc >= lpszValue && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
1801 {
1802 LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
1803
1804 while (lpszGrp >= lpFormat->lpThousandSep)
1805 *szOut-- = *lpszGrp--; /* Write grouping char */
1806
1807 dwCurrentGroupCount = 0;
1808 if (lpFormat->Grouping == 32)
1809 dwGroupCount = 2; /* Indic grouping: 3 then 2 */
1810 }
1811 }
1812 if (dwState & NF_ROUND)
1813 *szOut-- = '1'; /* e.g. .6 > 1.0 */
1814 else if (!(dwState & NF_DIGITS_OUT) && lpFormat->LeadingZero)
1815 *szOut-- = '0'; /* Add leading 0 if we have no digits before the decimal point */
1816
1817 /* Add any leading negative or currency sign */
1818 while (dwFmt & (CF_MINUS_LEFT|CF_CY_LEFT))
1819 {
1820 switch (dwFmt & (CF_MINUS_LEFT|CF_MINUS_BEFORE|CF_CY_LEFT))
1821 {
1822 case CF_MINUS_LEFT:
1824 while (lpszNeg >= lpszNegStart)
1825 *szOut-- = *lpszNeg--;
1826 dwFmt &= ~CF_MINUS_LEFT;
1827 break;
1828
1829 case CF_CY_LEFT:
1832 if (dwFmt & CF_CY_SPACE)
1833 *szOut-- = ' ';
1834 while (lpszCy >= lpszCyStart)
1835 *szOut-- = *lpszCy--;
1836 dwFmt &= ~(CF_CY_LEFT|CF_MINUS_BEFORE);
1837 break;
1838 }
1839 }
1840 if (dwFmt & CF_PARENS)
1841 *szOut-- = '(';
1842 szOut++;
1843
1844 iRet = strlenW(szOut) + 1;
1845 if (cchOut)
1846 {
1847 if (iRet <= cchOut)
1848 memcpy(lpCurrencyStr, szOut, iRet * sizeof(WCHAR));
1849 else
1850 {
1851 memcpy(lpCurrencyStr, szOut, cchOut * sizeof(WCHAR));
1852 lpCurrencyStr[cchOut - 1] = '\0';
1854 iRet = 0;
1855 }
1856 }
1857 return iRet;
1858
1859error:
1861 return 0;
1862}
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
Definition: locale.c:2923
#define GetNegative(fmt)
Definition: lcformat.c:108
#define NF_DIGITS_OUT
Definition: lcformat.c:1197
#define CF_CY_SPACE
Definition: lcformat.c:1571
#define NF_ISNEGATIVE
Definition: lcformat.c:1194
#define CF_MINUS_BEFORE
Definition: lcformat.c:1568
#define CF_MINUS_LEFT
Definition: lcformat.c:1566
#define CF_MINUS_RIGHT
Definition: lcformat.c:1567
#define NF_DIGITS
Definition: lcformat.c:1196
#define CF_CY_RIGHT
Definition: lcformat.c:1570
#define NF_ROUND
Definition: lcformat.c:1198
#define NF_ISREAL
Definition: lcformat.c:1195
#define CF_CY_LEFT
Definition: lcformat.c:1569
#define CF_PARENS
Definition: lcformat.c:1565
#define error(str)
Definition: mkdosfs.c:1605
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:120
unsigned char BYTE
Definition: xxhash.c:193

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 936 of file lcformat.c.

938{
939 TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
940 debugstr_a(lpFormat), lpDateStr, cchOut);
941
942 return NLS_GetDateTimeFormatA(lcid, dwFlags | DATE_DATEVARSONLY, lpTime,
943 lpFormat, lpDateStr, cchOut);
944}
static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpStr, INT cchOut)
Definition: lcformat.c:843
#define DATE_DATEVARSONLY
Definition: lcformat.c:80

Referenced by _strdate(), ExtCabCallback(), filetime_to_str(), CFontExt::GetDetailsOf(), HTTPREQ_QueryOption(), START_TEST(), strftime_date(), test_cert_struct_string(), 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 
)

◆ GetNumberFormatA()

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

Definition at line 1130 of file lcformat.c.

1133{
1134 DWORD cp = CP_ACP;
1135 WCHAR szDec[8], szGrp[8], szIn[128], szOut[128];
1137 const NUMBERFMTW *pfmt = NULL;
1138 INT iRet;
1139
1140 TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_a(lpszValue),
1141 lpFormat, lpNumberStr, cchOut);
1142
1143 if (NLS_IsUnicodeOnlyLcid(lcid))
1144 {
1146 return 0;
1147 }
1148
1149 if (!(dwFlags & LOCALE_USE_CP_ACP))
1150 {
1152 if (!node)
1153 {
1155 return 0;
1156 }
1157
1158 cp = node->dwCodePage;
1159 }
1160
1161 if (lpFormat)
1162 {
1163 memcpy(&fmt, lpFormat, sizeof(fmt));
1164 pfmt = &fmt;
1165 if (lpFormat->lpDecimalSep)
1166 {
1167 MultiByteToWideChar(cp, 0, lpFormat->lpDecimalSep, -1, szDec, ARRAY_SIZE(szDec));
1168 fmt.lpDecimalSep = szDec;
1169 }
1170 if (lpFormat->lpThousandSep)
1171 {
1172 MultiByteToWideChar(cp, 0, lpFormat->lpThousandSep, -1, szGrp, ARRAY_SIZE(szGrp));
1173 fmt.lpThousandSep = szGrp;
1174 }
1175 }
1176
1177 if (lpszValue)
1178 MultiByteToWideChar(cp, 0, lpszValue, -1, szIn, ARRAY_SIZE(szIn));
1179
1180 if (cchOut > (int) ARRAY_SIZE(szOut))
1181 cchOut = ARRAY_SIZE(szOut);
1182
1183 szOut[0] = '\0';
1184
1185 iRet = GetNumberFormatW(lcid, dwFlags, lpszValue ? szIn : NULL, pfmt,
1186 lpNumberStr ? szOut : NULL, cchOut);
1187
1188 if (szOut[0] && lpNumberStr)
1189 WideCharToMultiByte(cp, 0, szOut, -1, lpNumberStr, cchOut, 0, 0);
1190 return iRet;
1191}
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212

Referenced by test_GetNumberFormatA().

◆ GetNumberFormatW()

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

Definition at line 1212 of file lcformat.c.

1215{
1216 WCHAR szBuff[128], *szOut = szBuff + ARRAY_SIZE(szBuff) - 1;
1217 WCHAR szNegBuff[8];
1218 const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc;
1219 DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0;
1220 INT iRet;
1221
1222 TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
1223 lpFormat, lpNumberStr, cchOut);
1224
1225 if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpNumberStr) ||
1226 !IsValidLocale(lcid, 0) ||
1227 (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep)))
1228 {
1229 goto error;
1230 }
1231
1232 if (!lpFormat)
1233 {
1235
1236 if (!node)
1237 goto error;
1238 lpFormat = &node->fmt;
1239 lpszNegStart = lpszNeg = GetNegative(node);
1240 }
1241 else
1242 {
1244 szNegBuff, ARRAY_SIZE(szNegBuff));
1245 lpszNegStart = lpszNeg = szNegBuff;
1246 }
1247 lpszNeg = lpszNeg + strlenW(lpszNeg) - 1;
1248
1250
1251 /* Format the number backwards into a temporary buffer */
1252
1253 szSrc = lpszValue;
1254 *szOut-- = '\0';
1255
1256 /* Check the number for validity */
1257 while (*szSrc)
1258 {
1259 if (*szSrc >= '0' && *szSrc <= '9')
1260 {
1261 dwState |= NF_DIGITS;
1262 if (dwState & NF_ISREAL)
1263 dwDecimals++;
1264 }
1265 else if (*szSrc == '-')
1266 {
1267 if (dwState)
1268 goto error; /* '-' not first character */
1269 dwState |= NF_ISNEGATIVE;
1270 }
1271 else if (*szSrc == '.')
1272 {
1273 if (dwState & NF_ISREAL)
1274 goto error; /* More than one '.' */
1275 dwState |= NF_ISREAL;
1276 }
1277 else
1278 goto error; /* Invalid char */
1279 szSrc++;
1280 }
1281 szSrc--; /* Point to last character */
1282
1283 if (!(dwState & NF_DIGITS))
1284 goto error; /* No digits */
1285
1286 /* Add any trailing negative sign */
1287 if (dwState & NF_ISNEGATIVE)
1288 {
1289 switch (lpFormat->NegativeOrder)
1290 {
1291 case NLS_NEG_PARENS:
1292 *szOut-- = ')';
1293 break;
1294 case NLS_NEG_RIGHT:
1296 while (lpszNeg >= lpszNegStart)
1297 *szOut-- = *lpszNeg--;
1298 if (lpFormat->NegativeOrder == NLS_NEG_RIGHT_SPACE)
1299 *szOut-- = ' ';
1300 break;
1301 }
1302 }
1303
1304 /* Copy all digits up to the decimal point */
1305 if (!lpFormat->NumDigits)
1306 {
1307 if (dwState & NF_ISREAL)
1308 {
1309 while (*szSrc != '.') /* Don't write any decimals or a separator */
1310 {
1311 if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1312 dwState |= NF_ROUND;
1313 else
1314 dwState &= ~NF_ROUND;
1315 szSrc--;
1316 }
1317 szSrc--;
1318 }
1319 }
1320 else
1321 {
1322 LPWSTR lpszDec = lpFormat->lpDecimalSep + strlenW(lpFormat->lpDecimalSep) - 1;
1323
1324 if (dwDecimals <= lpFormat->NumDigits)
1325 {
1326 dwDecimals = lpFormat->NumDigits - dwDecimals;
1327 while (dwDecimals--)
1328 *szOut-- = '0'; /* Pad to correct number of dp */
1329 }
1330 else
1331 {
1332 dwDecimals -= lpFormat->NumDigits;
1333 /* Skip excess decimals, and determine if we have to round the number */
1334 while (dwDecimals--)
1335 {
1336 if (*szSrc >= '5' || (*szSrc == '4' && (dwState & NF_ROUND)))
1337 dwState |= NF_ROUND;
1338 else
1339 dwState &= ~NF_ROUND;
1340 szSrc--;
1341 }
1342 }
1343
1344 if (dwState & NF_ISREAL)
1345 {
1346 while (*szSrc != '.')
1347 {
1348 if (dwState & NF_ROUND)
1349 {
1350 if (*szSrc == '9')
1351 *szOut-- = '0'; /* continue rounding */
1352 else
1353 {
1354 dwState &= ~NF_ROUND;
1355 *szOut-- = (*szSrc)+1;
1356 }
1357 szSrc--;
1358 }
1359 else
1360 *szOut-- = *szSrc--; /* Write existing decimals */
1361 }
1362 szSrc--; /* Skip '.' */
1363 }
1364
1365 while (lpszDec >= lpFormat->lpDecimalSep)
1366 *szOut-- = *lpszDec--; /* Write decimal separator */
1367 }
1368
1369 dwGroupCount = lpFormat->Grouping == 32 ? 3 : lpFormat->Grouping;
1370
1371 /* Write the remaining whole number digits, including grouping chars */
1372 while (szSrc >= lpszValue && *szSrc >= '0' && *szSrc <= '9')
1373 {
1374 if (dwState & NF_ROUND)
1375 {
1376 if (*szSrc == '9')
1377 *szOut-- = '0'; /* continue rounding */
1378 else
1379 {
1380 dwState &= ~NF_ROUND;
1381 *szOut-- = (*szSrc)+1;
1382 }
1383 szSrc--;
1384 }
1385 else
1386 *szOut-- = *szSrc--;
1387
1388 dwState |= NF_DIGITS_OUT;
1389 dwCurrentGroupCount++;
1390 if (szSrc >= lpszValue && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
1391 {
1392 LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
1393
1394 while (lpszGrp >= lpFormat->lpThousandSep)
1395 *szOut-- = *lpszGrp--; /* Write grouping char */
1396
1397 dwCurrentGroupCount = 0;
1398 if (lpFormat->Grouping == 32)
1399 dwGroupCount = 2; /* Indic grouping: 3 then 2 */
1400 }
1401 }
1402 if (dwState & NF_ROUND)
1403 {
1404 *szOut-- = '1'; /* e.g. .6 > 1.0 */
1405 }
1406 else if (!(dwState & NF_DIGITS_OUT) && lpFormat->LeadingZero)
1407 *szOut-- = '0'; /* Add leading 0 if we have no digits before the decimal point */
1408
1409 /* Add any leading negative sign */
1410 if (dwState & NF_ISNEGATIVE)
1411 {
1412 switch (lpFormat->NegativeOrder)
1413 {
1414 case NLS_NEG_PARENS:
1415 *szOut-- = '(';
1416 break;
1417 case NLS_NEG_LEFT_SPACE:
1418 *szOut-- = ' ';
1419 /* Fall through */
1420 case NLS_NEG_LEFT:
1421 while (lpszNeg >= lpszNegStart)
1422 *szOut-- = *lpszNeg--;
1423 break;
1424 }
1425 }
1426 szOut++;
1427
1428 iRet = strlenW(szOut) + 1;
1429 if (cchOut)
1430 {
1431 if (iRet <= cchOut)
1432 memcpy(lpNumberStr, szOut, iRet * sizeof(WCHAR));
1433 else
1434 {
1435 memcpy(lpNumberStr, szOut, cchOut * sizeof(WCHAR));
1436 lpNumberStr[cchOut - 1] = '\0';
1438 iRet = 0;
1439 }
1440 }
1441 return iRet;
1442
1443error:
1445 return 0;
1446}
#define NLS_NEG_RIGHT_SPACE
Definition: lcformat.c:1205
#define NLS_NEG_PARENS
Definition: lcformat.c:1201
#define NLS_NEG_RIGHT
Definition: lcformat.c:1204
#define NLS_NEG_LEFT
Definition: lcformat.c:1202
#define NLS_NEG_LEFT_SPACE
Definition: lcformat.c:1203

Referenced by AddCommasW(), format_size(), FormatBytes(), FormatDouble(), FormatInt(), FormatInteger(), GetNumberFormatA(), Int64ToString(), 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 1044 of file lcformat.c.

1046{
1047 TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
1048 debugstr_a(lpFormat), lpTimeStr, cchOut);
1049
1051 lpFormat, lpTimeStr, cchOut);
1052}

Referenced by _strtime(), ExtCabCallback(), CFontExt::GetDetailsOf(), HTTPREQ_QueryOption(), strftime_time(), test_cert_struct_string(), test_GetTimeFormatA(), and test_SHFormatDateTimeA().

◆ GetTimeFormatW()

◆ NLS_EnumCalendarInfo()

static BOOL NLS_EnumCalendarInfo ( const struct enumcalendar_context ctxt)
static

Definition at line 2223 of file lcformat.c.

2224{
2225 WCHAR *buf, *opt = NULL, *iter = NULL;
2226 CALID calendar = ctxt->calendar;
2227 BOOL ret = FALSE;
2228 int bufSz = 200; /* the size of the buffer */
2229
2230 if (ctxt->u.callback == NULL)
2231 {
2233 return FALSE;
2234 }
2235
2236 buf = HeapAlloc(GetProcessHeap(), 0, bufSz);
2237 if (buf == NULL)
2238 {
2240 return FALSE;
2241 }
2242
2243 if (calendar == ENUM_ALL_CALENDARS)
2244 {
2245 int optSz = GetLocaleInfoW(ctxt->lcid, LOCALE_IOPTIONALCALENDAR, NULL, 0);
2246 if (optSz > 1)
2247 {
2248 opt = HeapAlloc(GetProcessHeap(), 0, optSz * sizeof(WCHAR));
2249 if (opt == NULL)
2250 {
2252 goto cleanup;
2253 }
2254 if (GetLocaleInfoW(ctxt->lcid, LOCALE_IOPTIONALCALENDAR, opt, optSz))
2255 iter = opt;
2256 }
2258 }
2259
2260 while (TRUE) /* loop through calendars */
2261 {
2262 do /* loop until there's no error */
2263 {
2264 if (ctxt->caltype & CAL_RETURN_NUMBER)
2265 ret = GetCalendarInfoW(ctxt->lcid, calendar, ctxt->caltype, NULL, bufSz / sizeof(WCHAR), (LPDWORD)buf);
2266 else if (ctxt->unicode)
2267 ret = GetCalendarInfoW(ctxt->lcid, calendar, ctxt->caltype, buf, bufSz / sizeof(WCHAR), NULL);
2268 else ret = GetCalendarInfoA(ctxt->lcid, calendar, ctxt->caltype, (CHAR*)buf, bufSz / sizeof(CHAR), NULL);
2269
2270 if (!ret)
2271 {
2273 { /* so resize it */
2274 int newSz;
2275 if (ctxt->unicode)
2276 newSz = GetCalendarInfoW(ctxt->lcid, calendar, ctxt->caltype, NULL, 0, NULL) * sizeof(WCHAR);
2277 else newSz = GetCalendarInfoA(ctxt->lcid, calendar, ctxt->caltype, NULL, 0, NULL) * sizeof(CHAR);
2278 if (bufSz >= newSz)
2279 {
2280 ERR("Buffer resizing disorder: was %d, requested %d.\n", bufSz, newSz);
2281 goto cleanup;
2282 }
2283 bufSz = newSz;
2284 WARN("Buffer too small; resizing to %d bytes.\n", bufSz);
2285 buf = HeapReAlloc(GetProcessHeap(), 0, buf, bufSz);
2286 if (buf == NULL)
2287 goto cleanup;
2288 } else goto cleanup;
2289 }
2290 } while (!ret);
2291
2292 /* Here we are. We pass the buffer to the correct version of
2293 * the callback. Because it's not the same number of params,
2294 * we must check for Ex, but we don't care about Unicode
2295 * because the buffer is already in the correct format.
2296 */
2297 switch (ctxt->type)
2298 {
2299 case CALLBACK_ENUMPROC:
2300 ret = ctxt->u.callback(buf);
2301 break;
2303 ret = ctxt->u.callbackex(buf, calendar);
2304 break;
2306 ret = ctxt->u.callbackexex(buf, calendar, NULL, ctxt->lParam);
2307 break;
2308 default:
2309 ;
2310 }
2311
2312 if (!ret) { /* the callback told to stop */
2313 ret = TRUE;
2314 break;
2315 }
2316
2317 if ((iter == NULL) || (*iter == 0)) /* no more calendars */
2318 break;
2319
2320 calendar = 0;
2321 while ((*iter >= '0') && (*iter <= '9'))
2322 calendar = calendar * 10 + *iter++ - '0';
2323
2324 if (*iter++ != 0)
2325 {
2327 ret = FALSE;
2328 break;
2329 }
2330 }
2331
2332cleanup:
2333 HeapFree(GetProcessHeap(), 0, opt);
2335 return ret;
2336}
#define CHAR(Char)
#define ERR(fmt,...)
Definition: precomp.h:57
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define HeapReAlloc
Definition: compat.h:734
static void cleanup(void)
Definition: main.c:1335
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType, LPSTR lpCalData, int cchData, LPDWORD lpValue)
Definition: lcformat.c:2444
enum enum_callback_type type
Definition: lcformat.c:2190
CALINFO_ENUMPROCEXW callbackex
Definition: lcformat.c:2193
union enumcalendar_context::@463 u
CALINFO_ENUMPROCW callback
Definition: lcformat.c:2192
CALINFO_ENUMPROCEXEX callbackexex
Definition: lcformat.c:2194
uint32_t * LPDWORD
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_BADDB
Definition: winerror.h:588
DWORD CALID
Definition: winnls.h:521
#define LOCALE_IOPTIONALCALENDAR
Definition: winnls.h:76
#define ENUM_ALL_CALENDARS
Definition: winnls.h:197
char CHAR
Definition: xmlstorage.h:175

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

◆ NLS_EnumDateFormats()

static BOOL NLS_EnumDateFormats ( const struct enumdateformats_context ctxt)
static

Definition at line 1914 of file lcformat.c.

1915{
1916 WCHAR bufW[256];
1917 char bufA[256];
1918 LCTYPE lctype;
1919 CALID cal_id;
1920 INT ret;
1921
1922 if (!ctxt->u.callback)
1923 {
1925 return FALSE;
1926 }
1927
1928 if (!GetLocaleInfoW(ctxt->lcid, LOCALE_ICALENDARTYPE|LOCALE_RETURN_NUMBER, (LPWSTR)&cal_id, sizeof(cal_id)/sizeof(WCHAR)))
1929 return FALSE;
1930
1931 switch (ctxt->flags & ~LOCALE_USE_CP_ACP)
1932 {
1933 case 0:
1934 case DATE_SHORTDATE:
1935 lctype = LOCALE_SSHORTDATE;
1936 break;
1937 case DATE_LONGDATE:
1938 lctype = LOCALE_SLONGDATE;
1939 break;
1940 case DATE_YEARMONTH:
1941 lctype = LOCALE_SYEARMONTH;
1942 break;
1943 default:
1944 FIXME("Unknown date format (0x%08x)\n", ctxt->flags);
1946 return FALSE;
1947 }
1948
1949 lctype |= ctxt->flags & LOCALE_USE_CP_ACP;
1950 if (ctxt->unicode)
1951 ret = GetLocaleInfoW(ctxt->lcid, lctype, bufW, ARRAY_SIZE(bufW));
1952 else
1953 ret = GetLocaleInfoA(ctxt->lcid, lctype, bufA, ARRAY_SIZE(bufA));
1954
1955 if (ret)
1956 {
1957 switch (ctxt->type)
1958 {
1959 case CALLBACK_ENUMPROC:
1960 ctxt->u.callback(ctxt->unicode ? bufW : (WCHAR*)bufA);
1961 break;
1963 ctxt->u.callbackex(ctxt->unicode ? bufW : (WCHAR*)bufA, cal_id);
1964 break;
1966 ctxt->u.callbackexex(bufW, cal_id, ctxt->lParam);
1967 break;
1968 default:
1969 ;
1970 }
1971 }
1972
1973 return TRUE;
1974}
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: locale.c:1600
DATEFMT_ENUMPROCEXW callbackex
Definition: lcformat.c:1894
DATEFMT_ENUMPROCW callback
Definition: lcformat.c:1893
union enumdateformats_context::@461 u
DATEFMT_ENUMPROCEXEX callbackexex
Definition: lcformat.c:1895
#define DATE_LONGDATE
Definition: winnls.h:199
#define DATE_SHORTDATE
Definition: winnls.h:198

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

◆ NLS_EnumTimeFormats()

static BOOL NLS_EnumTimeFormats ( struct enumtimeformats_context ctxt)
static

Definition at line 2077 of file lcformat.c.

2078{
2079 WCHAR bufW[256];
2080 char bufA[256];
2081 LCTYPE lctype;
2082 INT ret;
2083
2084 if (!ctxt->u.callback)
2085 {
2087 return FALSE;
2088 }
2089
2090 switch (ctxt->flags & ~LOCALE_USE_CP_ACP)
2091 {
2092 case 0:
2093 lctype = LOCALE_STIMEFORMAT;
2094 break;
2095 case TIME_NOSECONDS:
2096 lctype = LOCALE_SSHORTTIME;
2097 break;
2098 default:
2099 FIXME("Unknown time format (%d)\n", ctxt->flags);
2101 return FALSE;
2102 }
2103
2104 lctype |= ctxt->flags & LOCALE_USE_CP_ACP;
2105 if (ctxt->unicode)
2106 ret = GetLocaleInfoW(ctxt->lcid, lctype, bufW, ARRAY_SIZE(bufW));
2107 else
2108 ret = GetLocaleInfoA(ctxt->lcid, lctype, bufA, ARRAY_SIZE(bufA));
2109
2110 if (ret)
2111 {
2112 switch (ctxt->type)
2113 {
2114 case CALLBACK_ENUMPROC:
2115 ctxt->u.callback(ctxt->unicode ? bufW : (WCHAR*)bufA);
2116 break;
2118 ctxt->u.callbackex(bufW, ctxt->lParam);
2119 break;
2120 default:
2121 ;
2122 }
2123 }
2124
2125 return TRUE;
2126}
TIMEFMT_ENUMPROCW callback
Definition: lcformat.c:2068
TIMEFMT_ENUMPROCEX callbackex
Definition: lcformat.c:2069
union enumtimeformats_context::@462 u
#define LOCALE_SSHORTTIME
Definition: winnls.h:165
#define LOCALE_STIMEFORMAT
Definition: winnls.h:64

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 843 of file lcformat.c.

846{
847 DWORD cp = CP_ACP;
848 WCHAR szFormat[128], szOut[128];
849 INT iRet;
850
851 TRACE("(0x%04x,0x%08x,%p,%s,%p,%d)\n", lcid, dwFlags, lpTime,
852 debugstr_a(lpFormat), lpStr, cchOut);
853
854 if (NLS_IsUnicodeOnlyLcid(lcid))
855 {
857 return 0;
858 }
859
860 if (!(dwFlags & LOCALE_USE_CP_ACP))
861 {
863 if (!node)
864 {
866 return 0;
867 }
868
869 cp = node->dwCodePage;
870 }
871
872 if (lpFormat)
873 MultiByteToWideChar(cp, 0, lpFormat, -1, szFormat, ARRAY_SIZE(szFormat));
874
875 if (cchOut > (int) ARRAY_SIZE(szOut))
876 cchOut = ARRAY_SIZE(szOut);
877
878 szOut[0] = '\0';
879
880 iRet = NLS_GetDateTimeFormatW(lcid, dwFlags, lpTime, lpFormat ? szFormat : NULL,
881 lpStr ? szOut : NULL, cchOut);
882
883 if (lpStr)
884 {
885 if (szOut[0])
886 WideCharToMultiByte(cp, 0, szOut, iRet ? -1 : cchOut, lpStr, cchOut, 0, 0);
887 else if (cchOut && iRet)
888 *lpStr = '\0';
889 }
890 return iRet;
891}

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 414 of file lcformat.c.

417{
418 const NLS_FORMAT_NODE *node;
419 SYSTEMTIME st;
420 INT cchWritten = 0;
421 INT lastFormatPos = 0;
422 BOOL bSkipping = FALSE; /* Skipping text around marker? */
423 BOOL d_dd_formatted = FALSE; /* previous formatted part was for d or dd */
424
425 /* Verify our arguments */
426 if ((cchOut && !lpStr) || !(node = NLS_GetFormats(lcid, dwFlags)))
427 goto invalid_parameter;
428
430 {
431 if (lpFormat &&
434 {
435 goto invalid_flags;
436 }
437
439 {
440 if ((dwFlags & (DATE_LTRREADING|DATE_RTLREADING)) == (DATE_LTRREADING|DATE_RTLREADING))
441 goto invalid_flags;
442 else if (dwFlags & (DATE_LTRREADING|DATE_RTLREADING))
443 FIXME("Unsupported flags: DATE_LTRREADING/DATE_RTLREADING\n");
444
445 switch (dwFlags & (DATE_SHORTDATE|DATE_LONGDATE|DATE_YEARMONTH))
446 {
447 case 0:
448 break;
449 case DATE_SHORTDATE:
450 case DATE_LONGDATE:
451 case DATE_YEARMONTH:
452 if (lpFormat)
453 goto invalid_flags;
454 break;
455 default:
456 goto invalid_flags;
457 }
458 }
459 }
460
461 if (!lpFormat)
462 {
463 /* Use the appropriate default format */
465 {
466 if (dwFlags & DATE_YEARMONTH)
468 else if (dwFlags & DATE_LONGDATE)
470 else
472 }
473 else
475 }
476
477 if (!lpTime)
478 {
479 GetLocalTime(&st); /* Default to current time */
480 lpTime = &st;
481 }
482 else
483 {
485 {
486 FILETIME ftTmp;
487
488 /* Verify the date and correct the D.O.W. if needed */
489 memset(&st, 0, sizeof(st));
490 st.wYear = lpTime->wYear;
491 st.wMonth = lpTime->wMonth;
492 st.wDay = lpTime->wDay;
493
494 if (st.wDay > 31 || st.wMonth > 12 || !SystemTimeToFileTime(&st, &ftTmp))
495 goto invalid_parameter;
496
497 FileTimeToSystemTime(&ftTmp, &st);
498 lpTime = &st;
499 }
500
502 {
503 /* Verify the time */
504 if (lpTime->wHour > 24 || lpTime->wMinute > 59 || lpTime->wSecond > 59)
505 goto invalid_parameter;
506 }
507 }
508
509 /* Format the output */
510 while (*lpFormat)
511 {
513 {
514 /* Start of a literal string */
515 lpFormat++;
516
517 /* Loop until the end of the literal marker or end of the string */
518 while (*lpFormat)
519 {
521 {
522 lpFormat++;
524 break; /* Terminating literal marker */
525 }
526
527 if (!cchOut)
528 cchWritten++; /* Count size only */
529 else if (cchWritten >= cchOut)
530 goto overrun;
531 else if (!bSkipping)
532 {
533 lpStr[cchWritten] = *lpFormat;
534 cchWritten++;
535 }
536 lpFormat++;
537 }
538 }
541 {
542 WCHAR buff[32], fmtChar;
543 LPCWSTR szAdd = NULL;
544 DWORD dwVal = 0;
545 int count = 0, dwLen;
546
547 bSkipping = FALSE;
548
549 fmtChar = *lpFormat;
550 while (*lpFormat == fmtChar)
551 {
552 count++;
553 lpFormat++;
554 }
555 buff[0] = '\0';
556
557 if (fmtChar != 'M') d_dd_formatted = FALSE;
558 switch(fmtChar)
559 {
560 case 'd':
561 if (count >= 4)
562 szAdd = GetLongDay(node, (lpTime->wDayOfWeek + 6) % 7);
563 else if (count == 3)
564 szAdd = GetShortDay(node, (lpTime->wDayOfWeek + 6) % 7);
565 else
566 {
567 dwVal = lpTime->wDay;
568 szAdd = buff;
569 d_dd_formatted = TRUE;
570 }
571 break;
572
573 case 'M':
574 if (count >= 4)
575 {
576 LPCWSTR genitive = GetGenitiveMonth(node, lpTime->wMonth - 1);
577 if (genitive)
578 {
579 if (d_dd_formatted)
580 {
581 szAdd = genitive;
582 break;
583 }
584 else
585 {
587 /* Look forward now, if next format pattern is for day genitive
588 name should be used */
589 while (*format)
590 {
591 /* Skip parts within markers */
593 {
594 ++format;
595 while (*format)
596 {
598 {
599 ++format;
600 if (!IsLiteralMarker(*format)) break;
601 }
602 }
603 }
604 if (*format != ' ') break;
605 ++format;
606 }
607 /* Only numeric day form matters */
608 if (*format == 'd')
609 {
610 INT dcount = 1;
611 while (*++format == 'd') dcount++;
612 if (dcount < 3)
613 {
614 szAdd = genitive;
615 break;
616 }
617 }
618 }
619 }
620 szAdd = GetLongMonth(node, lpTime->wMonth - 1);
621 }
622 else if (count == 3)
623 szAdd = GetShortMonth(node, lpTime->wMonth - 1);
624 else
625 {
626 dwVal = lpTime->wMonth;
627 szAdd = buff;
628 }
629 break;
630
631 case 'y':
632#ifdef __REACTOS__
633 if (IS_LCID_JAPANESE(lcid) && (dwFlags & DATE_USE_ALT_CALENDAR))
634 {
635 PCJAPANESE_ERA pEra = JapaneseEra_Find(lpTime);
636 if (pEra)
637 {
638 if (count >= 2)
639 {
640 count = 2;
641 }
642
643 dwVal = lpTime->wYear - pEra->wYear + 1;
644
645 if (dwVal == 1 && JapaneseEra_IsFirstYearGannen())
646 {
647 // Gan of 'Gannen'
648 buff[0] = 0x5143;
649 buff[1] = 0;
650 }
651 szAdd = buff;
652 break;
653 }
655 return 0;
656 }
657#endif
658 if (count >= 4)
659 {
660 count = 4;
661 dwVal = lpTime->wYear;
662 }
663 else
664 {
665 count = count > 2 ? 2 : count;
666 dwVal = lpTime->wYear % 100;
667 }
668 szAdd = buff;
669 break;
670
671 case 'g':
672#ifdef __REACTOS__
673 if (IS_LCID_JAPANESE(lcid))
674 {
676 {
677 PCJAPANESE_ERA pEra = JapaneseEra_Find(lpTime);
678 if (pEra)
679 {
680 RtlStringCbCopyW(buff, sizeof(buff), pEra->szEraName);
681 szAdd = buff;
682 break;
683 }
685 return 0;
686 }
687 else
688 {
689 /* Seireki */
690 buff[0] = 0x897F;
691 buff[1] = 0x66A6;
692 buff[2] = 0;
693 szAdd = buff;
694 break;
695 }
696 }
697#endif
698 if (count == 2)
699 {
700 /* FIXME: Our GetCalendarInfo() does not yet support CAL_SERASTRING.
701 * When it is fixed, this string should be cached in 'node'.
702 */
703 FIXME("Should be using GetCalendarInfo(CAL_SERASTRING), defaulting to 'AD'\n");
704 buff[0] = 'A'; buff[1] = 'D'; buff[2] = '\0';
705 }
706 else
707 {
708 buff[0] = 'g'; buff[1] = '\0'; /* Add a literal 'g' */
709 }
710 szAdd = buff;
711 break;
712
713 case 'h':
715 {
716 count = count > 2 ? 2 : count;
717 dwVal = lpTime->wHour == 0 ? 12 : (lpTime->wHour - 1) % 12 + 1;
718 szAdd = buff;
719 break;
720 }
721 /* .. fall through if we are forced to output in 24 hour format */
722
723 case 'H':
724 count = count > 2 ? 2 : count;
725 dwVal = lpTime->wHour;
726 szAdd = buff;
727 break;
728
729 case 'm':
731 {
732 cchWritten = lastFormatPos; /* Skip */
733 bSkipping = TRUE;
734 }
735 else
736 {
737 count = count > 2 ? 2 : count;
738 dwVal = lpTime->wMinute;
739 szAdd = buff;
740 }
741 break;
742
743 case 's':
745 {
746 cchWritten = lastFormatPos; /* Skip */
747 bSkipping = TRUE;
748 }
749 else
750 {
751 count = count > 2 ? 2 : count;
752 dwVal = lpTime->wSecond;
753 szAdd = buff;
754 }
755 break;
756
757 case 't':
759 {
760 cchWritten = lastFormatPos; /* Skip */
761 bSkipping = TRUE;
762 }
763 else
764 {
765 if (count == 1)
766 szAdd = lpTime->wHour < 12 ? node->szShortAM : node->szShortPM;
767 else
768 szAdd = lpTime->wHour < 12 ? GetAM(node) : GetPM(node);
769 }
770 break;
771 }
772
773 if (szAdd == buff && buff[0] == '\0')
774 {
775 static const WCHAR fmtW[] = {'%','.','*','d',0};
776 /* We have a numeric value to add */
777 snprintfW(buff, ARRAY_SIZE(buff), fmtW, count, dwVal);
778 }
779
780 dwLen = szAdd ? strlenW(szAdd) : 0;
781
782 if (cchOut && dwLen)
783 {
784 if (cchWritten + dwLen < cchOut)
785 memcpy(lpStr + cchWritten, szAdd, dwLen * sizeof(WCHAR));
786 else
787 {
788 memcpy(lpStr + cchWritten, szAdd, (cchOut - cchWritten) * sizeof(WCHAR));
789 goto overrun;
790 }
791 }
792 cchWritten += dwLen;
793 lastFormatPos = cchWritten; /* Save position of last output format text */
794 }
795 else
796 {
797 /* Literal character */
798 if (!cchOut)
799 cchWritten++; /* Count size only */
800 else if (cchWritten >= cchOut)
801 goto overrun;
802 else if (!bSkipping || *lpFormat == ' ')
803 {
804 lpStr[cchWritten] = *lpFormat;
805 cchWritten++;
806 }
807 lpFormat++;
808 }
809 }
810
811 /* Final string terminator and sanity check */
812 if (cchOut)
813 {
814 if (cchWritten >= cchOut)
815 goto overrun;
816 else
817 lpStr[cchWritten] = '\0';
818 }
819 cchWritten++; /* Include terminating NUL */
820
821 TRACE("returning length=%d, output=%s\n", cchWritten, debugstr_w(lpStr));
822 return cchWritten;
823
824overrun:
825 TRACE("returning 0, (ERROR_INSUFFICIENT_BUFFER)\n");
827 return 0;
828
829invalid_parameter:
831 return 0;
832
833invalid_flags:
835 return 0;
836}
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
static unsigned char buff[32768]
Definition: fatten.c:17
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL JapaneseEra_IsFirstYearGannen(void)
Definition: japanese.c:63
#define TIME_FORMAT_FLAGS
Definition: lcformat.c:401
#define GetLongMonth(fmt, mth)
Definition: lcformat.c:118
#define GetShortMonth(fmt, mth)
Definition: lcformat.c:120
#define IsDateFmtChar(p)
Definition: lcformat.c:392
#define GetLongDate(fmt)
Definition: lcformat.c:109
#define GetYearMonth(fmt)
Definition: lcformat.c:114
#define GetTime(fmt)
Definition: lcformat.c:111
#define GetPM(fmt)
Definition: lcformat.c:113
#define GetShortDay(fmt, day)
Definition: lcformat.c:117
#define GetAM(fmt)
Definition: lcformat.c:112
#define DATE_FORMAT_FLAGS
Definition: lcformat.c:399
#define IsTimeFmtChar(p)
Definition: lcformat.c:393
#define GetLongDay(fmt, day)
Definition: lcformat.c:116
#define IsLiteralMarker(p)
Definition: lcformat.c:391
#define GetGenitiveMonth(fmt, mth)
Definition: lcformat.c:119
#define GetShortDate(fmt)
Definition: lcformat.c:110
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
#define memset(x, y, z)
Definition: compat.h:39
WORD wYear
Definition: winbase.h:930
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
WORD wDay
Definition: winbase.h:933
WORD wDayOfWeek
Definition: winbase.h:932
Definition: format.c:58
#define DATE_USE_ALT_CALENDAR
Definition: winnls.h:200
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

◆ NLS_GetFormats()

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

Definition at line 192 of file lcformat.c.

193{
194 /* GetLocaleInfo() identifiers for cached formatting strings */
195 static const LCTYPE NLS_LocaleIndices[] = {
225 LOCALE_SYEARMONTH
226 };
227 static NLS_FORMAT_NODE *NLS_CachedFormats = NULL;
228 NLS_FORMAT_NODE *node = NLS_CachedFormats;
229
231
232 TRACE("(0x%04x,0x%08x)\n", lcid, dwFlags);
233
234 /* See if we have already cached the locales number format */
235 while (node && (node->lcid != lcid || node->dwFlags != dwFlags) && node->next)
236 node = node->next;
237
238 if (!node || node->lcid != lcid || node->dwFlags != dwFlags)
239 {
240 NLS_FORMAT_NODE *new_node;
241 DWORD i;
242
243 TRACE("Creating new cache entry\n");
244
245 if (!(new_node = HeapAlloc(GetProcessHeap(), 0, sizeof(NLS_FORMAT_NODE))))
246 return NULL;
247
249
250 /* Number Format */
251 new_node->lcid = lcid;
252 new_node->dwFlags = dwFlags;
253 new_node->next = NULL;
254
258
260 if (new_node->fmt.Grouping > 9 && new_node->fmt.Grouping != 32)
261 {
262 WARN("LOCALE_SGROUPING (%d) unhandled, please report!\n",
263 new_node->fmt.Grouping);
264 new_node->fmt.Grouping = 0;
265 }
266
269
270 /* Currency Format */
271 new_node->cyfmt.NumDigits = new_node->fmt.NumDigits;
272 new_node->cyfmt.LeadingZero = new_node->fmt.LeadingZero;
273
275
276 if (new_node->cyfmt.Grouping > 9)
277 {
278 WARN("LOCALE_SMONGROUPING (%d) unhandled, please report!\n",
279 new_node->cyfmt.Grouping);
280 new_node->cyfmt.Grouping = 0;
281 }
282
284 if (new_node->cyfmt.NegativeOrder > 15)
285 {
286 WARN("LOCALE_INEGCURR (%d) unhandled, please report!\n",
287 new_node->cyfmt.NegativeOrder);
288 new_node->cyfmt.NegativeOrder = 0;
289 }
291 if (new_node->cyfmt.PositiveOrder > 3)
292 {
293 WARN("LOCALE_IPOSCURR (%d) unhandled,please report!\n",
294 new_node->cyfmt.PositiveOrder);
295 new_node->cyfmt.PositiveOrder = 0;
296 }
300
301 /* Date/Time Format info, negative character, etc */
302 for (i = 0; i < ARRAY_SIZE(NLS_LocaleIndices); i++)
303 {
304 GET_LOCALE_STRING(new_node->lppszStrings[i], NLS_LocaleIndices[i]);
305 }
306 /* Save some memory if month genitive name is the same or not present */
307 for (i = 0; i < 12; i++)
308 {
309 if (strcmpW(GetLongMonth(new_node, i), GetGenitiveMonth(new_node, i)) == 0)
310 {
311 HeapFree(GetProcessHeap(), 0, GetGenitiveMonth(new_node, i));
312 GetGenitiveMonth(new_node, i) = NULL;
313 }
314 }
315
316 new_node->szShortAM[0] = GetAM(new_node)[0]; new_node->szShortAM[1] = '\0';
317 new_node->szShortPM[0] = GetPM(new_node)[0]; new_node->szShortPM[1] = '\0';
318
319 /* Now add the computed format to the cache */
321
322 /* Search again: We may have raced to add the node */
323 node = NLS_CachedFormats;
324 while (node && (node->lcid != lcid || node->dwFlags != dwFlags) && node->next)
325 node = node->next;
326
327 if (!node)
328 {
329 node = NLS_CachedFormats = new_node; /* Empty list */
330 new_node = NULL;
331 }
332 else if (node->lcid != lcid || node->dwFlags != dwFlags)
333 {
334 node->next = new_node; /* Not in the list, add to end */
335 node = new_node;
336 new_node = NULL;
337 }
338
340
341 if (new_node)
342 {
343 /* We raced and lost: The node was already added by another thread.
344 * node points to the currently cached node, so free new_node.
345 */
346 for (i = 0; i < ARRAY_SIZE(NLS_LocaleIndices); i++)
347 HeapFree(GetProcessHeap(), 0, new_node->lppszStrings[i]);
348 HeapFree(GetProcessHeap(), 0, new_node->fmt.lpDecimalSep);
349 HeapFree(GetProcessHeap(), 0, new_node->fmt.lpThousandSep);
350 HeapFree(GetProcessHeap(), 0, new_node->cyfmt.lpDecimalSep);
353 HeapFree(GetProcessHeap(), 0, new_node);
354 }
355 }
356 return node;
357}
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 GET_LOCALE_NUMBER(num, type)
Definition: lcformat.c:181
#define GET_LOCALE_STRING(str, type)
Definition: lcformat.c:184
static CRITICAL_SECTION NLS_FormatsCS
Definition: lcformat.c:123
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define strcmpW(s1, s2)
Definition: unicode.h:44
DWORD dwCodePage
Definition: lcformat.c:98
struct _NLS_FORMAT_NODE * next
Definition: lcformat.c:104
CURRENCYFMTW cyfmt
Definition: lcformat.c:100
WCHAR szShortAM[2]
Definition: lcformat.c:102
NUMBERFMTW fmt
Definition: lcformat.c:99
LPWSTR lppszStrings[NLS_NUM_CACHED_STRINGS]
Definition: lcformat.c:101
WCHAR szShortPM[2]
Definition: lcformat.c:103
UINT LeadingZero
Definition: winnls.h:615
LPWSTR lpDecimalSep
Definition: winnls.h:617
UINT NumDigits
Definition: winnls.h:614
LPWSTR lpCurrencySymbol
Definition: winnls.h:621
UINT PositiveOrder
Definition: winnls.h:620
UINT Grouping
Definition: winnls.h:616
UINT NegativeOrder
Definition: winnls.h:619
LPWSTR lpThousandSep
Definition: winnls.h:618
UINT NumDigits
Definition: winnls.h:644
LPWSTR lpDecimalSep
Definition: winnls.h:647
UINT Grouping
Definition: winnls.h:646
UINT NegativeOrder
Definition: winnls.h:649
LPWSTR lpThousandSep
Definition: winnls.h:648
UINT LeadingZero
Definition: winnls.h:645
void * next
Definition: dlist.c:360
#define LOCALE_SGROUPING
Definition: winnls.h:46
#define LOCALE_SDECIMAL
Definition: winnls.h:44
#define LOCALE_S1159
Definition: winnls.h:73
#define LOCALE_SMONDECIMALSEP
Definition: winnls.h:53
#define LOCALE_ICURRENCY
Definition: winnls.h:58
#define LOCALE_SMONTHOUSANDSEP
Definition: winnls.h:54
#define LOCALE_IDIGITS
Definition: winnls.h:47
#define LOCALE_STHOUSAND
Definition: winnls.h:45
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:40
#define LOCALE_INEGNUMBER
Definition: winnls.h:49
#define LOCALE_S2359
Definition: winnls.h:74
#define LOCALE_ILZERO
Definition: winnls.h:48
#define LOCALE_SCURRENCY
Definition: winnls.h:51
#define LOCALE_INEGCURR
Definition: winnls.h:59

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 142 of file lcformat.c.

143{
144 WCHAR szBuff[80];
145 DWORD dwVal = 0;
146
147 szBuff[0] = '\0';
148 GetLocaleInfoW(lcid, dwFlags, szBuff, ARRAY_SIZE(szBuff));
149
150 if (szBuff[0] && szBuff[1] == ';' && szBuff[2] != '0')
151 dwVal = (szBuff[0] - '0') * 10 + (szBuff[2] - '0');
152 else
153 {
154 const WCHAR* iter = szBuff;
155 dwVal = 0;
156 while(*iter >= '0' && *iter <= '9')
157 dwVal = dwVal * 10 + (*iter++ - '0');
158 }
159 return dwVal;
160}

Referenced by NLS_EnumCalendarInfo().

◆ NLS_GetLocaleString()

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

Definition at line 167 of file lcformat.c.

168{
169 WCHAR szBuff[80], *str;
170 DWORD dwLen;
171
172 szBuff[0] = '\0';
173 GetLocaleInfoW(lcid, dwFlags, szBuff, ARRAY_SIZE(szBuff));
174 dwLen = strlenW(szBuff) + 1;
175 str = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
176 if (str)
177 memcpy(str, szBuff, dwLen * sizeof(WCHAR));
178 return str;
179}

◆ NLS_IsUnicodeOnlyLcid()

BOOL NLS_IsUnicodeOnlyLcid ( LCID  lcid)

Definition at line 364 of file lcformat.c.

365{
366 lcid = ConvertDefaultLocale(lcid);
367
368 switch (PRIMARYLANGID(lcid))
369 {
370 case LANG_ARMENIAN:
371 case LANG_DIVEHI:
372 case LANG_GEORGIAN:
373 case LANG_GUJARATI:
374 case LANG_HINDI:
375 case LANG_KANNADA:
376 case LANG_KONKANI:
377 case LANG_MARATHI:
378 case LANG_PUNJABI:
379 case LANG_SANSKRIT:
380 TRACE("lcid 0x%08x: langid 0x%4x is Unicode Only\n", lcid, PRIMARYLANGID(lcid));
381 return TRUE;
382 default:
383 return FALSE;
384 }
385}
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: locale.c:2877
#define LANG_KONKANI
Definition: nls.h:83
#define LANG_HINDI
Definition: nls.h:68
#define LANG_SANSKRIT
Definition: nls.h:115
#define LANG_KANNADA
Definition: nls.h:77
#define LANG_GEORGIAN
Definition: nls.h:61
#define LANG_PUNJABI
Definition: nls.h:109
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_DIVEHI
Definition: nls.h:50
#define LANG_GUJARATI
Definition: nls.h:65
#define LANG_MARATHI
Definition: nls.h:98
#define LANG_ARMENIAN
Definition: nls.h:30

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

◆ SetCalendarInfoA()

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

Definition at line 2830 of file lcformat.c.

2831{
2832 FIXME("(%08x,%08x,%08x,%s): stub\n",
2833 Locale, Calendar, CalType, debugstr_a(lpCalData));
2834 return 0;
2835}

◆ SetCalendarInfoW()

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

Definition at line 2842 of file lcformat.c.

2843{
2844 FIXME("(%08x,%08x,%08x,%s): stub\n",
2845 Locale, Calendar, CalType, debugstr_w(lpCalData));
2846 return 0;
2847}

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 123 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") }
}
static CRITICAL_SECTION_DEBUG NLS_FormatsCS_debug
Definition: lcformat.c:124
LIST_ENTRY ProcessLocksList
Definition: winbase.h:908
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 124 of file lcformat.c.