A backslash typed into a Text field with MULTILINE flag was not being escaped when saved back to State.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3082 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
eccles 2003-11-01 00:17:19 +00:00
parent c84dcdb8a2
commit 764bdc8f87
2 changed files with 30 additions and 26 deletions

View file

@ -18,7 +18,7 @@
#include "../exdll/exdll.h" #include "../exdll/exdll.h"
#undef popstring #undef popstring
static int popstring(char *str) static int WINAPI popstring(char *str)
{ {
stack_t *th; stack_t *th;
if (!g_stacktop || !*g_stacktop) return 1; if (!g_stacktop || !*g_stacktop) return 1;
@ -46,10 +46,10 @@ typedef struct {
#define stricmp(x,y) lstrcmpi(x,y) #define stricmp(x,y) lstrcmpi(x,y)
//#define abs(x) ((x) < 0 ? -(x) : (x)) //#define abs(x) ((x) < 0 ? -(x) : (x))
void *MALLOC(int len) { return (void*)GlobalAlloc(GPTR,len); } void *WINAPI MALLOC(int len) { return (void*)GlobalAlloc(GPTR,len); }
void FREE(void *d) { if (d) GlobalFree((HGLOBAL)d); } void WINAPI FREE(void *d) { if (d) GlobalFree((HGLOBAL)d); }
char *STRDUP(const char *c) char *WINAPI STRDUP(const char *c)
{ {
char *t=(char*)MALLOC(lstrlen(c)+1); char *t=(char*)MALLOC(lstrlen(c)+1);
return lstrcpy(t,c); return lstrcpy(t,c);
@ -120,10 +120,10 @@ struct TableEntry {
int nValue; int nValue;
}; };
int LookupToken(TableEntry*, char*); int WINAPI LookupToken(TableEntry*, char*);
int LookupTokens(TableEntry*, char*); int WINAPI LookupTokens(TableEntry*, char*);
void ConvertNewLines(char *str); void WINAPI ConvertNewLines(char *str);
struct FieldType { struct FieldType {
char *pszText; char *pszText;
@ -185,7 +185,7 @@ int nRectId = 0;
int nNumFields = 0; int nNumFields = 0;
int g_done; int g_done;
int FindControlIdx(UINT id) int WINAPI FindControlIdx(UINT id)
{ {
for (int nIdx = 0; nIdx < nNumFields; nIdx++) for (int nIdx = 0; nIdx < nNumFields; nIdx++)
if (id == pFields[nIdx].nControlID) if (id == pFields[nIdx].nControlID)
@ -195,7 +195,7 @@ int FindControlIdx(UINT id)
// array of HWNDs and window styles used to make the main NSIS controls invisible while this program runs. // array of HWNDs and window styles used to make the main NSIS controls invisible while this program runs.
bool BrowseForFile(int nControlIdx) { bool WINAPI BrowseForFile(int nControlIdx) {
OPENFILENAME ofn={0,}; OPENFILENAME ofn={0,};
HWND hControl; HWND hControl;
BOOL bResult; BOOL bResult;
@ -260,7 +260,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
} }
bool BrowseForFolder(int nControlIdx) { bool WINAPI BrowseForFolder(int nControlIdx) {
BROWSEINFO bi; BROWSEINFO bi;
bi.hwndOwner = hConfigWindow; bi.hwndOwner = hConfigWindow;
@ -311,7 +311,7 @@ bool BrowseForFolder(int nControlIdx) {
return true; return true;
} }
bool ValidateFields() { bool WINAPI ValidateFields() {
int nIdx; int nIdx;
int nLength; int nLength;
@ -337,7 +337,7 @@ bool ValidateFields() {
return true; return true;
} }
bool SaveSettings(void) { bool WINAPI SaveSettings(void) {
static char szField[25]; static char szField[25];
int nIdx; int nIdx;
HWND hwnd; HWND hwnd;
@ -414,20 +414,24 @@ bool SaveSettings(void) {
char *pszBuf2 = (char*)MALLOC(nBufLen*2); // double the size, consider the worst case, all chars are \r\n char *pszBuf2 = (char*)MALLOC(nBufLen*2); // double the size, consider the worst case, all chars are \r\n
char *p1, *p2; char *p1, *p2;
for (p1=pszBuffer,p2=pszBuf2; *p1; p1++, p2++) { for (p1=pszBuffer,p2=pszBuf2; *p1; p1++, p2++) {
if (*p1 == '\r') { switch (*p1) {
case '\r':
*p2++ = '\\'; *p2++ = '\\';
*p2 = 'r'; *p2 = 'r';
} break;
else if (*p1 == '\n') { case '\n':
*p2++ = '\\'; *p2++ = '\\';
*p2 = 'n'; *p2 = 'n';
} break;
else if (*p1 == '\t') { case '\t':
*p2++ = '\\'; *p2++ = '\\';
*p2 = 't'; *p2 = 't';
} break;
else case '\\':
*p2++ = '\\';
default:
*p2=*p1; *p2=*p1;
}
} }
*p2 = 0; *p2 = 0;
nBufLen = nBufLen*2; nBufLen = nBufLen*2;
@ -472,7 +476,7 @@ UINT WINAPI myGetProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault)
return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault, pszFilename); return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault, pszFilename);
} }
int ReadSettings(void) { int WINAPI ReadSettings(void) {
static char szField[25]; static char szField[25];
int nIdx, nCtrlIdx; int nIdx, nCtrlIdx;
@ -667,7 +671,7 @@ int ReadSettings(void) {
} }
LRESULT WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) { LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
switch (codeNotify) { switch (codeNotify) {
case BN_CLICKED: case BN_CLICKED:
{ {
@ -837,7 +841,7 @@ int WINAPI StaticLINKWindowProc(HWND hWin, UINT uMsg, LPARAM wParam, WPARAM lPar
int old_cancel_visible; int old_cancel_visible;
int createCfgDlg() int WINAPI createCfgDlg()
{ {
UINT nAddMsg, nFindMsg, nSetSelMsg; UINT nAddMsg, nFindMsg, nSetSelMsg;
@ -1228,7 +1232,7 @@ int createCfgDlg()
return 0; return 0;
} }
void showCfgDlg() void WINAPI showCfgDlg()
{ {
lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc); lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc);
@ -1344,7 +1348,7 @@ extern "C" BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call
} }
int LookupToken(TableEntry* psTable_, char* pszToken_) int WINAPI LookupToken(TableEntry* psTable_, char* pszToken_)
{ {
for (int i = 0; psTable_[i].pszName; i++) for (int i = 0; psTable_[i].pszName; i++)
if (!stricmp(pszToken_, psTable_[i].pszName)) if (!stricmp(pszToken_, psTable_[i].pszName))
@ -1352,7 +1356,7 @@ int LookupToken(TableEntry* psTable_, char* pszToken_)
return 0; return 0;
} }
int LookupTokens(TableEntry* psTable_, char* pszTokens_) int WINAPI LookupTokens(TableEntry* psTable_, char* pszTokens_)
{ {
int n = 0; int n = 0;
char *pszStart = pszTokens_; char *pszStart = pszTokens_;
@ -1373,7 +1377,7 @@ int LookupTokens(TableEntry* psTable_, char* pszTokens_)
return n; return n;
} }
void ConvertNewLines(char *str) { void WINAPI ConvertNewLines(char *str) {
char *p1, *p2; char *p1, *p2;
if (!str) return; if (!str) return;
for (p1=p2=str; *p1; p1++, p2++) { for (p1=p2=str; *p1; p1++, p2++) {

Binary file not shown.