Author: ekohl
Date: Sun Apr 30 15:39:41 2017
New Revision: 74434
URL:
http://svn.reactos.org/svn/reactos?rev=74434&view=rev
Log:
[INTL]
- Get rid of alloca, malloc and free.
- Always check the return values of HeapAlloc.
- Rename fUserLocaleChanged to bUserLocaleChanged and fGeoIdChanged to bGeoIdChanged.
- Use WCHAR instead of TCHAR.
- Fix indentation and coding style.
- Remove setupreg.c because it is an unused copy of misc.c.
Removed:
trunk/reactos/dll/cpl/intl/setupreg.c
Modified:
trunk/reactos/dll/cpl/intl/advanced.c
trunk/reactos/dll/cpl/intl/currency.c
trunk/reactos/dll/cpl/intl/date.c
trunk/reactos/dll/cpl/intl/generalp.c
trunk/reactos/dll/cpl/intl/intl.c
trunk/reactos/dll/cpl/intl/intl.h
trunk/reactos/dll/cpl/intl/misc.c
trunk/reactos/dll/cpl/intl/numbers.c
trunk/reactos/dll/cpl/intl/sort.c
trunk/reactos/dll/cpl/intl/time.c
Modified: trunk/reactos/dll/cpl/intl/advanced.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/advanced.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/advanced.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/advanced.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -188,15 +188,15 @@
if (bNoShow == FALSE)
{
- index = SendMessageW(hLangList,
- CB_ADDSTRING,
- 0,
- (LPARAM)lang);
-
- SendMessageW(hLangList,
- CB_SETITEMDATA,
- index,
- (LPARAM)lcid);
+ index = SendMessageW(hLangList,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)lang);
+
+ SendMessageW(hLangList,
+ CB_SETITEMDATA,
+ index,
+ (LPARAM)lcid);
}
return TRUE;
@@ -245,7 +245,10 @@
return;
}
}
- else wsprintf(szDPI, L"%d", dwDPI);
+ else
+ {
+ wsprintf(szDPI, L"%d", dwDPI);
+ }
RegCloseKey(hKey);
}
@@ -266,7 +269,6 @@
wsprintf(szSection, L"Font.CP%s.%s", szDefCP, szDPI);
hFontInf = SetupOpenInfFileW(L"font.inf", NULL, INF_STYLE_WIN4, NULL);
-
if (hFontInf == INVALID_HANDLE_VALUE)
return;
@@ -277,12 +279,15 @@
}
Count = (UINT) SetupGetLineCount(hFontInf, szSection);
- if (Count <= 0) return;
+ if (Count <= 0)
+ return;
if (!SetupInstallFromInfSectionW(hwnd, hFontInf, szSection, SPINST_REGISTRY &
~SPINST_FILES,
NULL, NULL, 0, NULL, NULL, NULL, NULL))
+ {
MessageBoxW(hwnd, L"Unable to install a new language for programs don't
support unicode!",
NULL, MB_ICONERROR | MB_OK);
+ }
SetupCloseInfFile(hFontInf);
}
@@ -421,10 +426,7 @@
break;
case WM_NOTIFY:
- {
- LPNMHDR lpnm = (LPNMHDR)lParam;
-
- if (lpnm->code == (UINT)PSN_APPLY)
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
{
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
@@ -432,8 +434,7 @@
SaveFontSubstitutionSettings(hwndDlg, pGlobalData);
SaveFontLinkingSettings(hwndDlg, pGlobalData);
}
- }
- break;
+ break;
}
return FALSE;
Modified: trunk/reactos/dll/cpl/intl/currency.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/currency.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/currency.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/currency.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -439,7 +439,7 @@
if (!SetCurrencyFieldSep(hwndDlg, pGlobalData))
break;
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
UpdateExamples(hwndDlg, pGlobalData);
}
Modified: trunk/reactos/dll/cpl/intl/date.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/date.c?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/intl/date.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/date.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -55,9 +55,8 @@
UINT nDateCompCount=0;
UINT nDateSepCount=0;
- pszFoundSep = (LPWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
-
- if(!pszFoundSep)
+ pszFoundSep = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE *
sizeof(WCHAR));
+ if (pszFoundSep == NULL)
return NULL;
wcscpy(pszFoundSep,STD_DATE_SEP);
@@ -171,15 +170,19 @@
}
pszFoundSep = FindDateSep(szShortDateFmt);
-
- /* Substring replacement of separator */
- wcscpy(szFoundDateSep, pszFoundSep);
- pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
- wcscpy(szShortDateFmt, pszResultStr);
- free(pszResultStr);
-
- if (pszFoundSep)
- free(pszFoundSep);
+ if (pszFoundSep != NULL)
+ {
+ /* Substring replacement of separator */
+ wcscpy(szFoundDateSep, pszFoundSep);
+ pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
+ if (pszResultStr != NULL)
+ {
+ wcscpy(szShortDateFmt, pszResultStr);
+ HeapFree(GetProcessHeap(), 0, pszResultStr);
+ }
+
+ HeapFree(GetProcessHeap(), 0, pszFoundSep);
+ }
/* Save short date format */
wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
@@ -393,19 +396,19 @@
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
/* Get spin value */
- nSpinVal=LOWORD(SendMessageW(hWndYearSpin,
- UDM_GETPOS,
- 0,
- 0));
+ nSpinVal = LOWORD(SendMessageW(hWndYearSpin,
+ UDM_GETPOS,
+ 0,
+ 0));
/* convert to wide char */
_itow(nSpinVal, szMaxDateVal, DECIMAL_RADIX);
/* Save max date value */
SetCalendarInfoW(lcid,
- CAL_GREGORIAN,
- 48 , /* CAL_ITWODIGITYEARMAX */
- (PCWSTR)szMaxDateVal);
+ CAL_GREGORIAN,
+ 48 , /* CAL_ITWODIGITYEARMAX */
+ (PCWSTR)szMaxDateVal);
}
/* Get max date value from registry set */
@@ -457,13 +460,13 @@
/* Limit text lengths */
SendDlgItemMessageW(hwndDlg, IDC_FIRSTYEAR_EDIT,
- EM_LIMITTEXT,
- MAX_YEAR_EDIT,
- 0);
+ EM_LIMITTEXT,
+ MAX_YEAR_EDIT,
+ 0);
SendDlgItemMessageW(hwndDlg, IDC_SECONDYEAR_EDIT,
- EM_LIMITTEXT,
- MAX_YEAR_EDIT,
- 0);
+ EM_LIMITTEXT,
+ MAX_YEAR_EDIT,
+ 0);
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
@@ -584,7 +587,7 @@
if (!SetShortDateSep(hwndDlg, pGlobalData))
break;
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
SetMaxDate(hwndDlg, pGlobalData->UserLCID);
InitShortDateCB(hwndDlg, pGlobalData);
Modified: trunk/reactos/dll/cpl/intl/generalp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/generalp.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/generalp.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/generalp.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -1429,7 +1429,7 @@
SetNewLocale(pGlobalData, NewLcid);
UpdateLocaleSample(hwndDlg, pGlobalData);
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
@@ -1456,7 +1456,7 @@
break;
pGlobalData->geoid = NewGeoID;
- pGlobalData->fGeoIdChanged = TRUE;
+ pGlobalData->bGeoIdChanged = TRUE;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
@@ -1466,7 +1466,7 @@
if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData)
> 0)
{
UpdateLocaleSample(hwndDlg, pGlobalData);
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
break;
@@ -1474,30 +1474,26 @@
break;
case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
{
- LPNMHDR lpnm = (LPNMHDR)lParam;
-
- if (lpnm->code == (UINT)PSN_APPLY)
+ /* Apply changes */
+ PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
+
+ /* Set new locale */
+ if (pGlobalData->bUserLocaleChanged == TRUE)
{
- /* Apply changes */
- PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
-
- /* Set new locale */
- if (pGlobalData->fUserLocaleChanged == TRUE)
- {
- SaveCurrentLocale(pGlobalData);
- pGlobalData->fUserLocaleChanged = FALSE;
- }
-
- /* Set new GEO ID */
- if (pGlobalData->fGeoIdChanged == TRUE)
- {
- SaveGeoID(pGlobalData);
- pGlobalData->fGeoIdChanged = FALSE;
- }
-
- AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
+ SaveCurrentLocale(pGlobalData);
+ pGlobalData->bUserLocaleChanged = FALSE;
}
+
+ /* Set new GEO ID */
+ if (pGlobalData->bGeoIdChanged == TRUE)
+ {
+ SaveGeoID(pGlobalData);
+ pGlobalData->bGeoIdChanged = FALSE;
+ }
+
+ AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
}
break;
}
Modified: trunk/reactos/dll/cpl/intl/intl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/intl.c?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/intl/intl.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/intl.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -51,16 +51,16 @@
VOID
PrintErrorMsgBox(UINT msg)
{
- TCHAR szErrorText[BUFFERSIZE];
- TCHAR szErrorCaption[BUFFERSIZE];
-
- LoadString(hApplet, msg, szErrorText, sizeof(szErrorText)/sizeof(TCHAR));
- LoadString(hApplet, IDS_ERROR, szErrorCaption,
sizeof(szErrorCaption)/sizeof(TCHAR));
-
- MessageBox(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
-}
-
-VOID
+ WCHAR szErrorText[BUFFERSIZE];
+ WCHAR szErrorCaption[BUFFERSIZE];
+
+ LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
+ LoadStringW(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption) /
sizeof(WCHAR));
+
+ MessageBoxW(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
+}
+
+INT
ResourceMessageBox(
HWND hwnd,
UINT uType,
@@ -73,7 +73,7 @@
LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) /
sizeof(WCHAR));
- MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
+ return MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
}
static VOID
Modified: trunk/reactos/dll/cpl/intl/intl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/intl.h?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/intl/intl.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/intl.h [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -12,7 +12,6 @@
#include <winuser.h>
#include <cpl.h>
#include <setupapi.h>
-#include <malloc.h>
#include <ndk/exfuncs.h>
#include "resource.h"
@@ -110,11 +109,11 @@
LCID UserLCID;
LCID SystemLCID;
- BOOL fUserLocaleChanged;
+ BOOL bUserLocaleChanged;
BOOL bApplyToDefaultUser;
GEOID geoid;
- BOOL fGeoIdChanged;
+ BOOL bGeoIdChanged;
/* Misc */
BOOL bIsUserAdmin;
@@ -134,7 +133,7 @@
/* intl.c */
VOID PrintErrorMsgBox(UINT msg);
-VOID
+INT
ResourceMessageBox(
HWND hwnd,
UINT uType,
Modified: trunk/reactos/dll/cpl/intl/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/misc.c?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/intl/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/misc.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -9,7 +9,9 @@
INT nStrCnt;
INT nStrSize;
- pszDestStr = (PWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
+ pszDestStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE *
sizeof(WCHAR));
+ if (pszDestStr == NULL)
+ return NULL;
wcscpy(pszDestStr, szInsStr);
@@ -45,7 +47,9 @@
INT nSpaceOffset = 0;
BOOL wasNul=FALSE;
- pszDestStr = (PWSTR)malloc(255 * sizeof(WCHAR));
+ pszDestStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, 255 * sizeof(WCHAR));
+ if (pszDestStr == NULL)
+ return NULL;
wcscpy(pszDestStr, szSourceStr);
@@ -80,7 +84,7 @@
/* Insert space to finded position plus all pos before */
pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
wcscpy(pszDestStr,pszTempStr);
- free(pszTempStr);
+ HeapFree(GetProcessHeap(), 0, pszTempStr);
/* Num of spaces total increment */
if (!wasNul)
@@ -102,7 +106,7 @@
{
pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
wcscpy(pszDestStr, pszTempStr);
- free(pszTempStr);
+ HeapFree(GetProcessHeap(), 0, pszTempStr);
}
}
@@ -121,7 +125,9 @@
UINT nDestStrCnt;
UINT nFirstCharCnt;
- szDestStr = (PWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
+ szDestStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE *
sizeof(WCHAR));
+ if (szDestStr == NULL)
+ return NULL;
nDestStrCnt = 0;
nFirstCharCnt = 0;
Modified: trunk/reactos/dll/cpl/intl/numbers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/numbers.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/intl/numbers.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/numbers.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -198,11 +198,14 @@
for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
{
pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER,
lpFieldDigNumSamples[nCBIndex]);
- SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
- CB_ADDSTRING,
- 0,
- (LPARAM)pszFieldDigNumSmpl);
- free(pszFieldDigNumSmpl);
+ if (pszFieldDigNumSmpl != NULL)
+ {
+ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)pszFieldDigNumSmpl);
+ HeapFree(GetProcessHeap(), 0, pszFieldDigNumSmpl);
+ }
}
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
@@ -280,18 +283,24 @@
pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
pGlobalData->szNumDecimalSep,
L",");
- wcscpy(szNewSample, pszResultStr);
- free(pszResultStr);
+ if (pszResultStr != NULL)
+ {
+ wcscpy(szNewSample, pszResultStr);
+ HeapFree(GetProcessHeap(), 0, pszResultStr);
+ }
/* Replace standard negative sign to setted */
pszResultStr = ReplaceSubStr(szNewSample,
pGlobalData->szNumNegativeSign,
L"-");
- SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
- CB_ADDSTRING,
- 0,
- (LPARAM)pszResultStr);
- free(pszResultStr);
+ if (pszResultStr != NULL)
+ {
+ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)pszResultStr);
+ HeapFree(GetProcessHeap(), 0, pszResultStr);
+ }
}
/* Set current item to value from registry */
@@ -320,11 +329,14 @@
pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
pGlobalData->szNumDecimalSep,
L",");
- SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
- CB_ADDSTRING,
- 0,
- (LPARAM)pszResultStr);
- free(pszResultStr);
+ if (pszResultStr != NULL)
+ {
+ SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)pszResultStr);
+ HeapFree(GetProcessHeap(), 0, pszResultStr);
+ }
}
/* Set current item to value from registry */
@@ -692,7 +704,7 @@
if (!SetNumUnitsSys(hwndDlg, pGlobalData))
break;
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
UpdateNumSamples(hwndDlg, pGlobalData);
}
Removed: trunk/reactos/dll/cpl/intl/setupreg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/setupreg.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/intl/setupreg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/setupreg.c (removed)
@@ -1,231 +0,0 @@
-/*
- * PROJECT: ReactOS International Control Panel
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: dll/cpl/intl/setupreg.c
- * PURPOSE: ReactOS International Control Panel
- * PROGRAMMERS: Alexey Zavyalov (gen_x(a)mail.ru)
-*/
-
-/* INCLUDES *****************************************************************/
-
-#include "intl.h"
-
-/* GLOBALS ******************************************************************/
-
-#define NUM_SHEETS 4
-
-/* FUNCTIONS ****************************************************************/
-
-/* Insert the space */
-TCHAR*
-InsSpacePos(const TCHAR *szInsStr, const int nPos)
-{
- LPTSTR pszDestStr;
- int nDestStrCnt=0;
- int nStrCnt;
- int nStrSize;
-
- pszDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR));
-
- _tcscpy(pszDestStr, szInsStr);
-
- nStrSize = _tcslen(szInsStr);
-
- for (nStrCnt = 0; nStrCnt < nStrSize; nStrCnt++)
- {
- if (nStrCnt == nStrSize - nPos)
- {
- pszDestStr[nDestStrCnt] = _T(' ');
- nDestStrCnt++;
- }
-
- pszDestStr[nDestStrCnt] = szInsStr[nStrCnt];
- nDestStrCnt++;
- }
-
- pszDestStr[nDestStrCnt] = _T('\0');
-
- return pszDestStr;
-}
-
-/* Insert the spaces by format string separated by ';' */
-LPTSTR
-InsSpacesFmt(const TCHAR *szSourceStr, const TCHAR *szFmtStr)
-{
- LPTSTR pszDestStr;
- LPTSTR pszTempStr;
- TCHAR szFmtVal[255];
- int nFmtCount=0;
- int nValCount=0;
- int nLastVal=0;
- int nSpaceOffset=0;
- BOOL wasNul=FALSE;
-
- pszDestStr = (LPTSTR) malloc(255 * sizeof(TCHAR));
-
- _tcscpy(pszDestStr, szSourceStr);
-
- /* If format is clean return source string */
- if (!*szFmtStr)
- return pszDestStr;
-
- /* Search for all format values */
- for (nFmtCount = 0; nFmtCount <= (int)_tcslen(szFmtStr); nFmtCount++)
- {
- if (szFmtStr[nFmtCount] == _T(';') || szFmtStr[nFmtCount] ==
_T('\0'))
- {
- if (_ttoi(szFmtVal) == 0 && !wasNul)
- {
- wasNul = TRUE;
- break;
- }
-
- /* If was 0, repeat spaces */
- if (wasNul)
- {
- nSpaceOffset += nLastVal;
- }
- else
- {
- nSpaceOffset += _ttoi(szFmtVal);
- }
-
- szFmtVal[nValCount] = _T('\0');
- nValCount=0;
-
- /* Insert space to finded position plus all pos before */
- pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
- _tcscpy(pszDestStr, pszTempStr);
- free(pszTempStr);
-
- /* Num of spaces total increment */
- if (!wasNul)
- {
- nSpaceOffset++;
- nLastVal = _ttoi(szFmtVal);
- }
- }
- else
- {
- szFmtVal[nValCount++] = szFmtStr[nFmtCount];
- }
- }
-
- /* Create spaces for rest part of string */
- if (wasNul && nLastVal!=0)
- {
- for (nFmtCount = nSpaceOffset + nLastVal; nFmtCount < _tcslen(pszDestStr);
nFmtCount += nLastVal + 1)
- {
- pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
- _tcscpy(pszDestStr,pszTempStr);
- free(pszTempStr);
- }
- }
-
- return pszDestStr;
-}
-
-/* Replace given template in source string with string to replace and return received
string */
-TCHAR*
-ReplaceSubStr(const TCHAR *szSourceStr,
- const TCHAR *szStrToReplace,
- const TCHAR *szTempl)
-{
- int nCharCnt;
- int nSubStrCnt;
- int nDestStrCnt;
- int nFirstCharCnt;
- LPTSTR szDestStr;
-
- szDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR));
- nDestStrCnt = 0;
- nFirstCharCnt = 0;
-
- _tcscpy(szDestStr, _T(L""));
-
- while (nFirstCharCnt < (int)_tcslen(szSourceStr))
- {
- if (szSourceStr[nFirstCharCnt] == szTempl[0])
- {
- nSubStrCnt=0;
- for (nCharCnt = nFirstCharCnt; nCharCnt < nFirstCharCnt +
(int)_tcslen(szTempl); nCharCnt++)
- {
- if (szSourceStr[nCharCnt] == szTempl[nSubStrCnt])
- {
- nSubStrCnt++;
- }
- else
- {
- break;
- }
-
- if ((int)_tcslen(szTempl) == nSubStrCnt)
- {
- _tcscat(szDestStr, szStrToReplace);
- nDestStrCnt = (int)_tcslen(szDestStr);
- nFirstCharCnt += (int)_tcslen(szTempl) - 1;
- break;
- }
- }
- }
- else
- {
- szDestStr[nDestStrCnt++] = wszSourceStr[nFirstCharCnt];
- szDestStr[nDestStrCnt] = _T('\0');
- }
-
- nFirstCharCnt++;
- }
-
- return szDestStr;
-}
-
-static
-VOID
-InitPropSheetPage(PROPSHEETPAGE *PsPage, WORD IdDlg, DLGPROC DlgProc)
-{
- ZeroMemory(PsPage, sizeof(PROPSHEETPAGE));
- PsPage->dwSize = sizeof(PROPSHEETPAGE);
- PsPage->dwFlags = PSP_DEFAULT;
- PsPage->hInstance = hApplet;
- PsPage->pszTemplate = MAKEINTRESOURCE(IdDlg);
- PsPage->pfnDlgProc = DlgProc;
-}
-
-/* Create applets */
-LONG
-APIENTRY
-SetupApplet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
-{
-
- PROPSHEETPAGE PsPage[NUM_SHEETS];
- PROPSHEETHEADER psh;
- TCHAR Caption[MAX_STR_SIZE];
-
- UNREFERENCED_PARAMETER(lParam);
- UNREFERENCED_PARAMETER(wParam);
- UNREFERENCED_PARAMETER(uMsg);
- UNREFERENCED_PARAMETER(hwnd);
-
- LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
-
- ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
- psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
- psh.hwndParent = NULL;
- psh.hInstance = hApplet;
- psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
- psh.pszCaption = Caption;
- psh.nPages = sizeof(PsPage) / sizeof(PROPSHEETPAGE);
- psh.nStartPage = 0;
- psh.ppsp = PsPage;
-
- InitPropSheetPage(&PsPage[0], IDD_NUMSOPTSSETUP, NumsOptsSetProc);
- InitPropSheetPage(&PsPage[1], IDD_CURRENCYOPTSSETUP, CurrencyOptsSetProc);
- InitPropSheetPage(&PsPage[2], IDD_TIMEOPTSSETUP, TimeOptsSetProc);
- InitPropSheetPage(&PsPage[3], IDD_DATEOPTSSETUP, DateOptsSetProc);
-
- return (LONG)(PropertySheet(&psh) != -1);
-}
-
-/* EOF */
Modified: trunk/reactos/dll/cpl/intl/sort.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/sort.c?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/intl/sort.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/sort.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -198,7 +198,7 @@
/* Save the new LCID */
pGlobalData->UserLCID = NewLcid;
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
}
break;
}
Modified: trunk/reactos/dll/cpl/intl/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/intl/time.c?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/intl/time.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/intl/time.c [iso-8859-1] Sun Apr 30 15:39:41 2017
@@ -53,30 +53,40 @@
static VOID
GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
{
- int nIndex;
HWND hChildWnd;
+ PWSTR tmp;
+ INT nIndex;
+ UINT uReqSize;
/* Get handle to time format control */
hChildWnd = GetDlgItem(hwndDlg, dwIdc);
+
/* Get index to selected time format */
nIndex = SendMessageW(hChildWnd, CB_GETCURSEL, 0, 0);
if (nIndex == CB_ERR)
+ {
/* No selection? Get content of the edit control */
SendMessageW(hChildWnd, WM_GETTEXT, uSize, (LPARAM)Buffer);
- else {
- PWSTR tmp;
- UINT uReqSize;
-
+ }
+ else
+ {
/* Get requested size, including the null terminator;
* it shouldn't be required because the previous CB_LIMITTEXT,
* but it would be better to check it anyways */
uReqSize = SendMessageW(hChildWnd, CB_GETLBTEXTLEN, (WPARAM)nIndex, 0) + 1;
+
/* Allocate enough space to be more safe */
- tmp = (PWSTR)_alloca(uReqSize*sizeof(WCHAR));
- /* Get selected time format text */
- SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
- /* Finally, copy the result into the output */
- wcsncpy(Buffer, tmp, uSize);
+ tmp = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uReqSize *
sizeof(WCHAR));
+ if (tmp != NULL)
+ {
+ /* Get selected time format text */
+ SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
+
+ /* Finally, copy the result into the output */
+ wcsncpy(Buffer, tmp, uSize);
+
+ HeapFree(GetProcessHeap(), 0, tmp);
+ }
}
}
@@ -239,7 +249,7 @@
{
/* Get selected/typed time format text */
GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT,
- pGlobalData->szTimeFormat,
+ pGlobalData->szTimeFormat,
MAX_TIMEFORMAT);
/* Get selected/typed time separator text */
@@ -257,7 +267,7 @@
pGlobalData->szTimePM,
MAX_TIMEPMSYMBOL);
- pGlobalData->fUserLocaleChanged = TRUE;
+ pGlobalData->bUserLocaleChanged = TRUE;
/* Update the time format sample */
UpdateTimeSample(hwndDlg, pGlobalData);