implemented RFE #1564986 - block unsupported language

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5080 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2007-04-14 23:03:40 +00:00
parent acaecfdade
commit f1c873ba36
3 changed files with 39 additions and 11 deletions

View file

@ -20,12 +20,14 @@ HWND g_hwndParent;
char temp[1024];
char g_wndtitle[1024], g_wndtext[1024];
int dofont;
int docp;
int langs_num;
struct lang {
char *name;
char *id;
UINT cp;
} *langs;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@ -37,7 +39,12 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
// add languages
for (i = langs_num - 1; i >= 0; i--) {
int cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
int cbi;
if (langs[i].cp != 0 && langs[i].cp != GetACP())
continue;
cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
// remember selected language
@ -123,6 +130,18 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
// get flags
if (popstring(temp)) return;
// parse flags
{
char *p=temp;
while (*p)
{
if (*p == 'F') dofont=1; // parse font flag
if (*p == 'C') docp=1; // parse codepage flag
p++;
}
}
if (*temp == 'A') {
// automatic language count
stack_t *th;
@ -133,19 +152,18 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
th = th->next;
}
if (!th) return;
langs_num /= 2;
if (dofont)
langs_num -= 2;
if (docp)
langs_num /= 3;
else
langs_num /= 2;
pop_empty_string = TRUE;
} else {
// use counts languages
langs_num = myatoi(temp);
}
{
// parse font flag
char *p=temp;
while (*p) if (*p++ == 'F') dofont=1;
}
// zero languages?
if (!langs_num) return;
@ -164,6 +182,12 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
if (!langs[i].id) return;
lstrcpy(langs[i].id, temp);
if (docp)
{
if (popstring(temp)) return;
langs[i].cp = myatoi(temp);
}
}
// pop the empty string to keep the stack clean