[INTL]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 30 Apr 2017 15:39:41 +0000 (15:39 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 30 Apr 2017 15:39:41 +0000 (15:39 +0000)
- 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.

svn path=/trunk/; revision=74434

reactos/dll/cpl/intl/advanced.c
reactos/dll/cpl/intl/currency.c
reactos/dll/cpl/intl/date.c
reactos/dll/cpl/intl/generalp.c
reactos/dll/cpl/intl/intl.c
reactos/dll/cpl/intl/intl.h
reactos/dll/cpl/intl/misc.c
reactos/dll/cpl/intl/numbers.c
reactos/dll/cpl/intl/setupreg.c [deleted file]
reactos/dll/cpl/intl/sort.c
reactos/dll/cpl/intl/time.c

index bd956cd..059687a 100644 (file)
@@ -188,15 +188,15 @@ LocalesEnumProc(PWSTR lpLocale)
 
     if (bNoShow == FALSE)
     {
 
     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;
     }
 
     return TRUE;
@@ -245,7 +245,10 @@ GetCurrentDPI(LPTSTR szDPI)
             return;
         }
     }
             return;
         }
     }
-    else wsprintf(szDPI, L"%d", dwDPI);
+    else
+    {
+        wsprintf(szDPI, L"%d", dwDPI);
+    }
 
     RegCloseKey(hKey);
 }
 
     RegCloseKey(hKey);
 }
@@ -266,7 +269,6 @@ SaveFontSubstitutionSettings(
     wsprintf(szSection, L"Font.CP%s.%s", szDefCP, szDPI);
 
     hFontInf = SetupOpenInfFileW(L"font.inf", NULL, INF_STYLE_WIN4, NULL);
     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;
 
     if (hFontInf == INVALID_HANDLE_VALUE)
         return;
 
@@ -277,12 +279,15 @@ SaveFontSubstitutionSettings(
     }
 
     Count = (UINT) SetupGetLineCount(hFontInf, szSection);
     }
 
     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))
 
     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);
         MessageBoxW(hwnd, L"Unable to install a new language for programs don't support unicode!",
                    NULL, MB_ICONERROR | MB_OK);
+    }
 
     SetupCloseInfFile(hFontInf);
 }
 
     SetupCloseInfFile(hFontInf);
 }
@@ -421,10 +426,7 @@ AdvancedPageProc(HWND hwndDlg,
             break;
 
         case WM_NOTIFY:
             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);
 
             {
                 PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
 
@@ -432,8 +434,7 @@ AdvancedPageProc(HWND hwndDlg,
                 SaveFontSubstitutionSettings(hwndDlg, pGlobalData);
                 SaveFontLinkingSettings(hwndDlg, pGlobalData);
             }
                 SaveFontSubstitutionSettings(hwndDlg, pGlobalData);
                 SaveFontLinkingSettings(hwndDlg, pGlobalData);
             }
-        }
-        break;
+            break;
     }
 
     return FALSE;
     }
 
     return FALSE;
index 696df95..9af9f25 100644 (file)
@@ -439,7 +439,7 @@ CurrencyPageProc(HWND hwndDlg,
                 if (!SetCurrencyFieldSep(hwndDlg, pGlobalData))
                     break;
 
                 if (!SetCurrencyFieldSep(hwndDlg, pGlobalData))
                     break;
 
-                pGlobalData->fUserLocaleChanged = TRUE;
+                pGlobalData->bUserLocaleChanged = TRUE;
 
                 UpdateExamples(hwndDlg, pGlobalData);
             }
 
                 UpdateExamples(hwndDlg, pGlobalData);
             }
index c694c3d..728c7ad 100644 (file)
@@ -55,9 +55,8 @@ FindDateSep(const WCHAR *szSourceStr)
     UINT nDateCompCount=0;
     UINT nDateSepCount=0;
 
     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);
         return NULL;
 
     wcscpy(pszFoundSep,STD_DATE_SEP);
@@ -171,15 +170,19 @@ SetShortDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData)
     }
 
     pszFoundSep = FindDateSep(szShortDateFmt);
     }
 
     pszFoundSep = FindDateSep(szShortDateFmt);
+    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);
+        }
 
 
-    /* Substring replacement of separator */
-    wcscpy(szFoundDateSep, pszFoundSep);
-    pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
-    wcscpy(szShortDateFmt, pszResultStr);
-    free(pszResultStr);
-
-    if (pszFoundSep)
-        free(pszFoundSep);
+        HeapFree(GetProcessHeap(), 0, pszFoundSep);
+    }
 
     /* Save short date format */
     wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
 
     /* Save short date format */
     wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
@@ -393,19 +396,19 @@ SetMaxDate(HWND hwndDlg, LCID lcid)
     hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
 
     /* Get spin value */
     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,
 
     /* 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 */
 }
 
 /* Get max date value from registry set */
@@ -457,13 +460,13 @@ InitMinMaxDateSpin(HWND hwndDlg, PGLOBALDATA pGlobalData)
 
     /* Limit text lengths */
     SendDlgItemMessageW(hwndDlg, IDC_FIRSTYEAR_EDIT,
 
     /* 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,
     SendDlgItemMessageW(hwndDlg, IDC_SECONDYEAR_EDIT,
-                EM_LIMITTEXT,
-                MAX_YEAR_EDIT,
-                0);
+                        EM_LIMITTEXT,
+                        MAX_YEAR_EDIT,
+                        0);
 
     hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
 
 
     hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
 
@@ -584,7 +587,7 @@ DatePageProc(HWND hwndDlg,
                 if (!SetShortDateSep(hwndDlg, pGlobalData))
                     break;
 
                 if (!SetShortDateSep(hwndDlg, pGlobalData))
                     break;
 
-                pGlobalData->fUserLocaleChanged = TRUE;
+                pGlobalData->bUserLocaleChanged = TRUE;
 
                 SetMaxDate(hwndDlg, pGlobalData->UserLCID);
                 InitShortDateCB(hwndDlg, pGlobalData);
 
                 SetMaxDate(hwndDlg, pGlobalData->UserLCID);
                 InitShortDateCB(hwndDlg, pGlobalData);
index 8e97ac8..c8fc16f 100644 (file)
@@ -1429,7 +1429,7 @@ GeneralPageProc(HWND hwndDlg,
 
                         SetNewLocale(pGlobalData, NewLcid);
                         UpdateLocaleSample(hwndDlg, pGlobalData);
 
                         SetNewLocale(pGlobalData, NewLcid);
                         UpdateLocaleSample(hwndDlg, pGlobalData);
-                        pGlobalData->fUserLocaleChanged = TRUE;
+                        pGlobalData->bUserLocaleChanged = TRUE;
 
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
 
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
@@ -1456,7 +1456,7 @@ GeneralPageProc(HWND hwndDlg,
                             break;
 
                         pGlobalData->geoid = NewGeoID;
                             break;
 
                         pGlobalData->geoid = NewGeoID;
-                        pGlobalData->fGeoIdChanged = TRUE;
+                        pGlobalData->bGeoIdChanged = TRUE;
 
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
 
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
@@ -1466,7 +1466,7 @@ GeneralPageProc(HWND hwndDlg,
                     if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData) > 0)
                     {
                         UpdateLocaleSample(hwndDlg, pGlobalData);
                     if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData) > 0)
                     {
                         UpdateLocaleSample(hwndDlg, pGlobalData);
-                        pGlobalData->fUserLocaleChanged = TRUE;
+                        pGlobalData->bUserLocaleChanged = TRUE;
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
                     break;
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                     }
                     break;
@@ -1474,30 +1474,26 @@ GeneralPageProc(HWND hwndDlg,
             break;
 
         case WM_NOTIFY:
             break;
 
         case WM_NOTIFY:
+            if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
             {
             {
-                LPNMHDR lpnm = (LPNMHDR)lParam;
+                /* Apply changes */
+                PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
 
 
-                if (lpnm->code == (UINT)PSN_APPLY)
+                /* 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;
-                    }
+                    SaveCurrentLocale(pGlobalData);
+                    pGlobalData->bUserLocaleChanged = FALSE;
+                }
 
 
-                    AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
+                /* Set new GEO ID */
+                if (pGlobalData->bGeoIdChanged == TRUE)
+                {
+                    SaveGeoID(pGlobalData);
+                    pGlobalData->bGeoIdChanged = FALSE;
                 }
                 }
+
+                AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
             }
             break;
     }
             }
             break;
     }
index d390375..6bf35ed 100644 (file)
@@ -51,16 +51,16 @@ APPLET Applets[NUM_APPLETS] =
 VOID
 PrintErrorMsgBox(UINT msg)
 {
 VOID
 PrintErrorMsgBox(UINT msg)
 {
-    TCHAR szErrorText[BUFFERSIZE];
-    TCHAR szErrorCaption[BUFFERSIZE];
+    WCHAR szErrorText[BUFFERSIZE];
+    WCHAR szErrorCaption[BUFFERSIZE];
 
 
-    LoadString(hApplet, msg, szErrorText, sizeof(szErrorText)/sizeof(TCHAR));
-    LoadString(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption)/sizeof(TCHAR));
+    LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
+    LoadStringW(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
 
 
-    MessageBox(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
+    MessageBoxW(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
 }
 
 }
 
-VOID
+INT
 ResourceMessageBox(
     HWND hwnd,
     UINT uType,
 ResourceMessageBox(
     HWND hwnd,
     UINT uType,
@@ -73,7 +73,7 @@ ResourceMessageBox(
     LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
     LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
 
     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
 }
 
 static VOID
index b252c4a..1a039f8 100644 (file)
@@ -12,7 +12,6 @@
 #include <winuser.h>
 #include <cpl.h>
 #include <setupapi.h>
 #include <winuser.h>
 #include <cpl.h>
 #include <setupapi.h>
-#include <malloc.h>
 #include <ndk/exfuncs.h>
 
 #include "resource.h"
 #include <ndk/exfuncs.h>
 
 #include "resource.h"
@@ -110,11 +109,11 @@ typedef struct _GLOBALDATA
 
     LCID UserLCID;
     LCID SystemLCID;
 
     LCID UserLCID;
     LCID SystemLCID;
-    BOOL fUserLocaleChanged;
+    BOOL bUserLocaleChanged;
     BOOL bApplyToDefaultUser;
 
     GEOID geoid;
     BOOL bApplyToDefaultUser;
 
     GEOID geoid;
-    BOOL fGeoIdChanged;
+    BOOL bGeoIdChanged;
 
     /* Misc */
     BOOL bIsUserAdmin;
 
     /* Misc */
     BOOL bIsUserAdmin;
@@ -134,7 +133,7 @@ extern GROUPINGDATA GroupingFormats[MAX_GROUPINGFORMATS];
 /* intl.c */
 VOID PrintErrorMsgBox(UINT msg);
 
 /* intl.c */
 VOID PrintErrorMsgBox(UINT msg);
 
-VOID
+INT
 ResourceMessageBox(
     HWND hwnd,
     UINT uType,
 ResourceMessageBox(
     HWND hwnd,
     UINT uType,
index 451536c..e05d75c 100644 (file)
@@ -9,7 +9,9 @@ InsSpacePos(PCWSTR szInsStr, const int nPos)
     INT nStrCnt;
     INT nStrSize;
 
     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);
 
 
     wcscpy(pszDestStr, szInsStr);
 
@@ -45,7 +47,9 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
     INT nSpaceOffset = 0;
     BOOL wasNul=FALSE;
 
     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);
 
 
     wcscpy(pszDestStr, szSourceStr);
 
@@ -80,7 +84,7 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
             /* Insert space to finded position plus all pos before */
             pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
             wcscpy(pszDestStr,pszTempStr);
             /* 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)
 
             /* Num of spaces total increment */
             if (!wasNul)
@@ -102,7 +106,7 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
         {
             pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
             wcscpy(pszDestStr, pszTempStr);
         {
             pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
             wcscpy(pszDestStr, pszTempStr);
-            free(pszTempStr);
+            HeapFree(GetProcessHeap(), 0, pszTempStr);
         }
     }
 
         }
     }
 
@@ -121,7 +125,9 @@ ReplaceSubStr(PCWSTR szSourceStr,
     UINT nDestStrCnt;
     UINT nFirstCharCnt;
 
     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;
 
     nDestStrCnt = 0;
     nFirstCharCnt = 0;
index 3b9e887..25d4d55 100644 (file)
@@ -198,11 +198,14 @@ InitFieldDigNumCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
     for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
     {
         pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
     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,
     }
 
     SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
@@ -280,18 +283,24 @@ InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
         pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
                                      pGlobalData->szNumDecimalSep,
                                      L",");
         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"-");
 
         /* 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 */
     }
 
     /* Set current item to value from registry */
@@ -320,11 +329,14 @@ InitLeadingZeroesCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
         pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
                                      pGlobalData->szNumDecimalSep,
                                      L",");
         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 */
     }
 
     /* Set current item to value from registry */
@@ -692,7 +704,7 @@ NumbersPageProc(HWND hwndDlg,
                 if (!SetNumUnitsSys(hwndDlg, pGlobalData))
                     break;
 
                 if (!SetNumUnitsSys(hwndDlg, pGlobalData))
                     break;
 
-                pGlobalData->fUserLocaleChanged = TRUE;
+                pGlobalData->bUserLocaleChanged = TRUE;
 
                 UpdateNumSamples(hwndDlg, pGlobalData);
             }
 
                 UpdateNumSamples(hwndDlg, pGlobalData);
             }
diff --git a/reactos/dll/cpl/intl/setupreg.c b/reactos/dll/cpl/intl/setupreg.c
deleted file mode 100644 (file)
index 2452391..0000000
+++ /dev/null
@@ -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@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 */
index d833376..0409b4c 100644 (file)
@@ -198,7 +198,7 @@ SortPageProc(HWND hwndDlg,
 
                 /* Save the new LCID */
                 pGlobalData->UserLCID = NewLcid;
 
                 /* Save the new LCID */
                 pGlobalData->UserLCID = NewLcid;
-                pGlobalData->fUserLocaleChanged = TRUE;
+                pGlobalData->bUserLocaleChanged = TRUE;
             }
             break;
     }
             }
             break;
     }
index d0d38e4..511400d 100644 (file)
@@ -53,30 +53,40 @@ UpdateTimeSample(HWND hWnd, PGLOBALDATA pGlobalData)
 static VOID
 GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
 {
 static VOID
 GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
 {
-    int nIndex;
     HWND hChildWnd;
     HWND hChildWnd;
+    PWSTR tmp;
+    INT nIndex;
+    UINT uReqSize;
 
     /* Get handle to time format control */
     hChildWnd = GetDlgItem(hwndDlg, dwIdc);
 
     /* 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)
     /* 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);
         /* 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;
         /* 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 */
         /* 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 @@ TimePageProc(HWND hwndDlg,
             {
                 /* Get selected/typed time format text */
                 GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT,
             {
                 /* Get selected/typed time format text */
                 GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT,
-                                      pGlobalData->szTimeFormat, 
+                                      pGlobalData->szTimeFormat,
                                       MAX_TIMEFORMAT);
 
                 /* Get selected/typed time separator text */
                                       MAX_TIMEFORMAT);
 
                 /* Get selected/typed time separator text */
@@ -257,7 +267,7 @@ TimePageProc(HWND hwndDlg,
                                       pGlobalData->szTimePM,
                                       MAX_TIMEPMSYMBOL);
 
                                       pGlobalData->szTimePM,
                                       MAX_TIMEPMSYMBOL);
 
-                pGlobalData->fUserLocaleChanged = TRUE;
+                pGlobalData->bUserLocaleChanged = TRUE;
 
                 /* Update the time format sample */
                 UpdateTimeSample(hwndDlg, pGlobalData);
 
                 /* Update the time format sample */
                 UpdateTimeSample(hwndDlg, pGlobalData);