Commit 41025d56 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

comctl32: datetime: Support literals in apostrophes.

parent a871830d
......@@ -133,8 +133,8 @@ extern int MONTHCAL_MonthLength(int month, int year);
static BOOL DATETIME_SendSimpleNotify (const DATETIME_INFO *infoPtr, UINT code);
static BOOL DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO *infoPtr);
extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to);
static const WCHAR allowedformatchars[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', '\'', 0};
static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1};
static const WCHAR allowedformatchars[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', 0};
static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1};
static DWORD
......@@ -205,6 +205,7 @@ DATETIME_UseFormat (DATETIME_INFO *infoPtr, LPCWSTR formattxt)
{
unsigned int i;
int j, k, len;
BOOL inside_literal = FALSE; /* inside '...' */
int *nrFields = &infoPtr->nrFields;
*nrFields = 0;
......@@ -214,27 +215,37 @@ DATETIME_UseFormat (DATETIME_INFO *infoPtr, LPCWSTR formattxt)
for (i = 0; formattxt[i]; i++) {
TRACE ("\n%d %c:", i, formattxt[i]);
for (j = 0; j < len; j++) {
if (allowedformatchars[j]==formattxt[i]) {
TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]);
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
break;
}
if (infoPtr->fieldspec[*nrFields] >> 4 != j) {
(*nrFields)++;
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
break;
}
if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) {
(*nrFields)++;
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
break;
}
infoPtr->fieldspec[*nrFields]++;
break;
} /* if allowedformatchar */
} /* for j */
if (!inside_literal) {
for (j = 0; j < len; j++) {
if (allowedformatchars[j]==formattxt[i]) {
TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]);
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
break;
}
if (infoPtr->fieldspec[*nrFields] >> 4 != j) {
(*nrFields)++;
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
break;
}
if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) {
(*nrFields)++;
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
break;
}
infoPtr->fieldspec[*nrFields]++;
break;
} /* if allowedformatchar */
} /* for j */
}
else
j = len;
if (formattxt[i] == '\'')
{
inside_literal = !inside_literal;
continue;
}
/* char is not a specifier: handle char like a string */
if (j == len) {
......
......@@ -193,6 +193,8 @@ static HWND create_datetime_control(DWORD style, DWORD exstyle)
static void test_dtm_set_format(HWND hWndDateTime)
{
CHAR txt[256];
SYSTEMTIME systime;
LRESULT r;
r = SendMessage(hWndDateTime, DTM_SETFORMAT, 0, (LPARAM)NULL);
......@@ -203,6 +205,17 @@ static void test_dtm_set_format(HWND hWndDateTime)
expect(1, r);
ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_format_seq, "test_dtm_set_format", FALSE);
r = SendMessage(hWndDateTime, DTM_SETFORMAT, 0,
(LPARAM)"'hh' hh");
expect(1, r);
ZeroMemory(&systime, sizeof(systime));
systime.wYear = 2000;
systime.wMonth = systime.wDay = 1;
r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, 0, (LPARAM)&systime);
expect(1, r);
GetWindowText(hWndDateTime, txt, 256);
todo_wine ok(strcmp(txt, "hh 12") == 0, "String mismatch (\"%s\" vs \"hh 12\")\n", txt);
flush_sequences(sequences, NUM_MSG_SEQUENCES);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment