diff options
Diffstat (limited to 'plugins/Variables/src')
-rw-r--r-- | plugins/Variables/src/parse_regexp.cpp | 4 | ||||
-rw-r--r-- | plugins/Variables/src/parse_str.cpp | 12 | ||||
-rw-r--r-- | plugins/Variables/src/variables.cpp | 50 | ||||
-rw-r--r-- | plugins/Variables/src/variables.h | 3 |
4 files changed, 24 insertions, 45 deletions
diff --git a/plugins/Variables/src/parse_regexp.cpp b/plugins/Variables/src/parse_regexp.cpp index 774b64275a..87b3925e2d 100644 --- a/plugins/Variables/src/parse_regexp.cpp +++ b/plugins/Variables/src/parse_regexp.cpp @@ -46,7 +46,7 @@ static TCHAR *parseRegExpCheck(ARGUMENTSINFO *ai) { return NULL;
}
pcre_extra *extra = pcre_study(ppat, 0, &err);
- int nmat = pcre_exec(ppat, extra, arg2, strlen(arg2), 0, 0, offsets, 99);
+ int nmat = pcre_exec(ppat, extra, arg2, (int)strlen(arg2), 0, 0, offsets, 99);
mir_free(arg1);
mir_free(arg2);
if (nmat > 0) {
@@ -96,7 +96,7 @@ static TCHAR *parseRegExpSubstr(ARGUMENTSINFO *ai) { return NULL;
}
pcre_extra *extra = pcre_study(ppat, 0, &err);
- int nmat = pcre_exec(ppat, extra, arg2, strlen(arg2), 0, 0, offsets, 99);
+ int nmat = pcre_exec(ppat, extra, arg2, (int)strlen(arg2), 0, 0, offsets, 99);
if (nmat >= 0) {
ai->flags &= ~AIF_FALSE;
}
diff --git a/plugins/Variables/src/parse_str.cpp b/plugins/Variables/src/parse_str.cpp index 8b0740654d..df9eef63c4 100644 --- a/plugins/Variables/src/parse_str.cpp +++ b/plugins/Variables/src/parse_str.cpp @@ -199,7 +199,7 @@ static TCHAR *parseLen(ARGUMENTSINFO *ai) if (ai->argc != 2)
return NULL;
- return itot( _tcslen( ai->targv[1] ));
+ return itot((int)_tcslen( ai->targv[1] ));
}
static TCHAR *parseLineCount(ARGUMENTSINFO *ai)
@@ -462,13 +462,13 @@ static TCHAR *parseScroll(ARGUMENTSINFO *ai) { }
move = ttoi(ai->targv[3])%_tcslen(ai->targv[1]);
display = ttoi(ai->targv[2]);
- if (display > _tcslen(ai->targv[1])) {
- display = _tcslen(ai->targv[1]);
- }
+ if (display > _tcslen(ai->targv[1]))
+ display = (unsigned)_tcslen(ai->targv[1]);
+
res = (TCHAR*)mir_alloc((2*_tcslen(ai->targv[1])+1)*sizeof(TCHAR));
- if (res == NULL) {
+ if (res == NULL)
return NULL;
- }
+
ZeroMemory(res, (2*_tcslen(ai->targv[1])+1)*sizeof(TCHAR));
_tcscpy(res, ai->targv[1]);
_tcscat(res, ai->targv[1]);
diff --git a/plugins/Variables/src/variables.cpp b/plugins/Variables/src/variables.cpp index dcdc3c48c0..86c8efe983 100644 --- a/plugins/Variables/src/variables.cpp +++ b/plugins/Variables/src/variables.cpp @@ -24,7 +24,6 @@ static BOOL bWarningShown = FALSE; // unicode on ansi warning /* some handles */
static HANDLE
hFormatStringService,
- hFreeMemoryService,
hRegisterVariableService,
hGetMMIService,
hShowHelpService,
@@ -492,51 +491,30 @@ static INT_PTR formatStringService(WPARAM wParam, LPARAM lParam) { return res;
}
-TCHAR *formatString(FORMATINFO *fi) {
-
+TCHAR *formatString(FORMATINFO *fi)
+{
/* the service to format a given string */
- TCHAR *string, *formattedString;
-
if (fi->eCount + fi->pCount > 5000) {
fi->eCount += 1;
fi->pCount += 1;
log_debugA("Variables: Overflow protection; %d parses", fi->eCount + fi->pCount);
return NULL;
}
- if ((fi == NULL) || (fi->tszFormat == NULL)) {
- return NULL;
- }
- string = mir_tstrdup(fi->tszFormat);
- if (string == NULL) {
- return NULL;
- }
- formattedString = replaceDynVars(string, fi);
- mir_free(string);
- if (formattedString == NULL) {
+ if ((fi == NULL) || (fi->tszFormat == NULL))
return NULL;
- }
-
- return formattedString;
-}
-/*
- MS_VARS_FREEMEMORY
-*/
-static INT_PTR freeMemory(WPARAM wParam, LPARAM lParam) {
-
- if ((void*)wParam == NULL) {
- return -1;
- }
- mir_free((void*)wParam);
+ mir_ptr<TCHAR> string( mir_tstrdup(fi->tszFormat));
+ if (string == NULL)
+ return NULL;
- return 0;
+ return replaceDynVars(string, fi);
}
-int setParseOptions(struct ParseOptions *po) {
-
- if (po == NULL) {
+int setParseOptions(struct ParseOptions *po)
+{
+ if (po == NULL)
po = &gParseOpts;
- }
+
ZeroMemory(po, sizeof(struct ParseOptions));
if (!db_get_b(NULL, MODULENAME, SETTING_STRIPALL, 0)) {
po->bStripEOL = db_get_b(NULL, MODULENAME, SETTING_STRIPCRLF, 0);
@@ -558,7 +536,6 @@ int LoadVarModule() setParseOptions(NULL);
hFormatStringService = CreateServiceFunction(MS_VARS_FORMATSTRING, formatStringService);
- hFreeMemoryService = CreateServiceFunction(MS_VARS_FREEMEMORY, freeMemory);
hRegisterVariableService = CreateServiceFunction(MS_VARS_REGISTERTOKEN, registerToken);
// help dialog
hCurSplitNS = LoadCursor(NULL, IDC_SIZENS);
@@ -573,7 +550,7 @@ int LoadVarModule() hShowHelpExService = CreateServiceFunction(MS_VARS_SHOWHELPEX, showHelpExService);
Icon_Register(hInst, LPGEN("Variables"), &icon, 1);
-
+
hIconsChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED, iconsChanged);
hGetIconService = CreateServiceFunction(MS_VARS_GETSKINITEM, getSkinItemService);
@@ -600,7 +577,7 @@ int LoadVarModule() fi.cbSize = sizeof(fi);
fi.tszFormat = db_get_tsa(NULL, MODULENAME, SETTING_STARTUPTEXT);
if (fi.tszFormat != NULL) {
- freeMemory((WPARAM)formatString(&fi), 0);
+ mir_free(formatString(&fi));
mir_free(fi.tszFormat);
}
}
@@ -616,7 +593,6 @@ int UnloadVarModule() { UnhookEvent(hIconsChangedHook);
DestroyServiceFunction(hRegisterVariableService);
- DestroyServiceFunction(hFreeMemoryService);
DestroyServiceFunction(hFormatStringService);
DestroyServiceFunction(hGetMMIService);
DestroyServiceFunction(hShowHelpService);
diff --git a/plugins/Variables/src/variables.h b/plugins/Variables/src/variables.h index 2029c5d848..3030b41f2e 100644 --- a/plugins/Variables/src/variables.h +++ b/plugins/Variables/src/variables.h @@ -17,6 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define _CRT_NON_CONFORMING_SWPRINTFS
+#define _CRT_SECURE_NO_WARNINGS
+
#include <tchar.h>
#include <malloc.h>
|