summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2013-02-14 13:22:47 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2013-02-14 13:22:47 +0000
commitb67a0345014079ca4d6d2ffc95d55086abc5b96b (patch)
treed4cc57ded9a6b19796bd32974f3731414ffb014c
parent25359ca57da5cc1dd5d6e34ca7b5bd65353f092a (diff)
minor cleanup and typos (by Basil)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3600 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Variables/res/Variables.rc32
-rw-r--r--plugins/Variables/src/contact.cpp33
-rw-r--r--plugins/Variables/src/help.cpp35
-rw-r--r--plugins/Variables/src/parse_alias.cpp2
-rw-r--r--plugins/Variables/src/parse_inet.cpp2
-rw-r--r--plugins/Variables/src/parse_miranda.cpp3
-rw-r--r--plugins/Variables/src/parse_str.cpp16
-rw-r--r--plugins/Variables/src/parse_system.cpp160
-rw-r--r--plugins/Variables/src/parse_xml.cpp10
-rw-r--r--plugins/Variables/src/variables.cpp11
10 files changed, 111 insertions, 193 deletions
diff --git a/plugins/Variables/res/Variables.rc b/plugins/Variables/res/Variables.rc
index 604367cf88..49851366a6 100644
--- a/plugins/Variables/res/Variables.rc
+++ b/plugins/Variables/res/Variables.rc
@@ -31,32 +31,32 @@ STYLE DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg"
BEGIN
- EDITTEXT IDC_FORMATTEXT,31,101,250,52,ES_MULTILINE |
- ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
- WS_VSCROLL | WS_HSCROLL
- PUSHBUTTON "Parse",IDC_PARSE,231,157,50,14
- CONTROL "Auto parse",IDC_AUTOPARSE,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,31,161,161,10
- EDITTEXT IDC_RESULT,31,172,250,52,ES_MULTILINE | ES_AUTOVSCROLL |
- ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN |
- WS_VSCROLL | WS_HSCROLL
- CONTROL "Parse the following string at startup",
- IDC_PARSEATSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 31,90,161,10
+ GROUPBOX "Parse options",IDC_STATIC,23,7,272,51
CONTROL "Automatically strip ""end of line"" characters",
IDC_STRIPCRLF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,31,
20,253,10
CONTROL "Automatically strip white space",IDC_STRIPWS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,31,32,253,10
- GROUPBOX "Test area",IDC_STATIC,23,62,272,168
- LTEXT "Click on the help button to get more information",
- IDC_STATIC,31,73,249,8
- GROUPBOX "Parse options",IDC_STATIC,23,7,272,51
CONTROL "Automatically strip all non-parsing characters",
IDC_STRIPALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,31,44,
253,10
+ GROUPBOX "Test area",IDC_STATIC,23,62,272,168
+ LTEXT "Click on the help button to get more information",
+ IDC_STATIC,31,73,249,8
CONTROL "",IDC_SHOWHELP,"MButtonClass",WS_TABSTOP,265,87,16,14,
0x18000000L
+ CONTROL "Parse the following string at startup",
+ IDC_PARSEATSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+ 31,90,161,10
+ EDITTEXT IDC_FORMATTEXT,31,101,250,52,ES_MULTILINE |
+ ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN |
+ WS_VSCROLL | WS_HSCROLL
+ CONTROL "Auto parse",IDC_AUTOPARSE,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,31,161,161,10
+ PUSHBUTTON "Parse",IDC_PARSE,231,157,50,14
+ EDITTEXT IDC_RESULT,31,172,250,52,ES_MULTILINE | ES_AUTOVSCROLL |
+ ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN |
+ WS_VSCROLL | WS_HSCROLL
END
IDD_TRG_STRINGCHANGE DIALOGEX 0, 0, 314, 240
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index bfe4da507e..d392cb78ff 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -427,22 +427,18 @@ int getContactFromString( CONTACTSINFO* ci )
/* keep cache consistent */
static int contactSettingChanged(WPARAM wParam, LPARAM lParam)
{
- int i;
- DBCONTACTWRITESETTING *dbw;
- char *szProto, *uid;
-
- uid = NULL;
+ DBCONTACTWRITESETTING *dbw = (DBCONTACTWRITESETTING*)lParam;
+ HANDLE hContact = (HANDLE) wParam;
EnterCriticalSection(&csContactCache);
- for (i=0;i<cacheSize;i++) {
- if ((HANDLE)wParam != cce[i].hContact && (cce[i].flags & CI_CNFINFO) == 0 )
+ for (int i=0;i<cacheSize;i++) {
+ if (hContact != cce[i].hContact && (cce[i].flags & CI_CNFINFO) == 0 )
continue;
- dbw = (DBCONTACTWRITESETTING*)lParam;
- szProto = GetContactProto((HANDLE)wParam);
+ char *szProto = GetContactProto(hContact);
if (szProto == NULL)
continue;
- uid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
+ char *uid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
if (((!strcmp(dbw->szSetting, "Nick")) && (cce[i].flags&CI_NICK)) ||
((!strcmp(dbw->szSetting, "FirstName")) && (cce[i].flags&CI_FIRSTNAME)) ||
((!strcmp(dbw->szSetting, "LastName")) && (cce[i].flags&CI_LASTNAME)) ||
@@ -495,21 +491,19 @@ int deinitContactModule()
// result must be freed
TCHAR *encodeContactToString(HANDLE hContact)
{
- char *szProto;
- TCHAR *tszUniqueId, *tszResult, *tszProto;
DBVARIANT dbv;
ZeroMemory(&dbv, sizeof(DBVARIANT));
- szProto = GetContactProto(hContact);
- tszUniqueId = getContactInfoT(CNF_UNIQUEID, hContact);
+ char *szProto = GetContactProto(hContact);
+ TCHAR *tszUniqueId = getContactInfoT(CNF_UNIQUEID, hContact);
if (szProto == NULL || tszUniqueId == NULL)
return NULL;
- tszResult = (TCHAR*)mir_calloc((_tcslen(tszUniqueId) + strlen(szProto) + 4) * sizeof(TCHAR));
+ TCHAR *tszResult = (TCHAR*)mir_calloc((_tcslen(tszUniqueId) + strlen(szProto) + 4) * sizeof(TCHAR));
if (tszResult == NULL)
return NULL;
- tszProto = mir_a2t(szProto);
+ TCHAR *tszProto = mir_a2t(szProto);
if (tszProto == NULL)
return NULL;
@@ -525,16 +519,13 @@ TCHAR *encodeContactToString(HANDLE hContact)
// returns INVALID_HANDLE_VALUE in case of an error.
HANDLE *decodeContactFromString(TCHAR *tszContact)
{
- int count;
- HANDLE hContact;
+ HANDLE hContact = INVALID_HANDLE_VALUE;
CONTACTSINFO ci;
-
- hContact = INVALID_HANDLE_VALUE;
ZeroMemory(&ci, sizeof(CONTACTSINFO));
ci.cbSize = sizeof(CONTACTSINFO);
ci.tszContact = tszContact;
ci.flags = CI_PROTOID|CI_TCHAR;
- count = getContactFromString( &ci );
+ int count = getContactFromString( &ci );
if (count != 1) {
if (ci.hContacts != NULL)
mir_free(ci.hContacts);
diff --git a/plugins/Variables/src/help.cpp b/plugins/Variables/src/help.cpp
index 3abf3117cd..cff8e60871 100644
--- a/plugins/Variables/src/help.cpp
+++ b/plugins/Variables/src/help.cpp
@@ -306,23 +306,21 @@ static TCHAR *getHelpDescription(TOKENREGISTEREX *tr)
static TCHAR *getTokenDescription(TOKENREGISTEREX *tr)
{
- int len;
- char *args, *helpText, *cur, *first, *second;
- TCHAR *desc, *tArgs;
+ char *args, *first, *second;
if (tr == NULL)
return NULL;
args = NULL;
- tArgs = NULL;
+ TCHAR *tArgs = NULL;
if (tr->szHelpText == NULL)
return mir_tstrdup(tr->tszTokenString);
- helpText = mir_strdup(tr->szHelpText);
+ char *helpText = mir_strdup(tr->szHelpText);
if (helpText == NULL)
return NULL;
- cur = helpText;
+ char *cur = helpText;
first = second = NULL;
while (*cur != _T('\0')) {
if (*cur == _T('\t')) {
@@ -340,8 +338,8 @@ static TCHAR *getTokenDescription(TOKENREGISTEREX *tr)
}
else args = NULL;
- len = _tcslen(tr->tszTokenString) + (args!=NULL?strlen(args):0) + 3;
- desc = (TCHAR*)mir_calloc(len * sizeof(TCHAR));
+ size_t len = _tcslen(tr->tszTokenString) + (args!=NULL?strlen(args):0) + 3;
+ TCHAR *desc = (TCHAR*)mir_calloc(len * sizeof(TCHAR));
if (desc == NULL)
return NULL;
@@ -349,7 +347,6 @@ static TCHAR *getTokenDescription(TOKENREGISTEREX *tr)
mir_sntprintf(desc, len, _T("%c%s%c"), _T(FIELD_CHAR), tr->szTokenString, _T(FIELD_CHAR));
else {
if (args != NULL)
-
tArgs = mir_a2t(args);
mir_sntprintf(desc, len, _T("%c%s%s"), _T(FUNC_CHAR), tr->tszTokenString, (tArgs!=NULL?tArgs:_T("")));
@@ -521,18 +518,14 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam
case WM_NOTIFY:
if ((((NMHDR*)lParam)->idFrom == IDC_TOKENLIST) && (((NMHDR*)lParam)->code == NM_DBLCLK)) {
- HWND hList, hwndInputDlg;
- LVITEM lvItem;
- int len, item;
- TCHAR *tokenString;
- TOKENREGISTER *tr;
-
- hwndInputDlg = (HWND)SendMessage(GetParent(hwndDlg), VARM_GETDIALOG, (WPARAM)VHF_INPUT, 0);
+ HWND hwndInputDlg = (HWND)SendMessage(GetParent(hwndDlg), VARM_GETDIALOG, (WPARAM)VHF_INPUT, 0);
if (hwndInputDlg == NULL) {
break;
}
- hList = GetDlgItem(hwndDlg, IDC_TOKENLIST);
- item = ListView_GetNextItem(hList, -1, LVNI_SELECTED|LVNI_FOCUSED);
+ HWND hList = GetDlgItem(hwndDlg, IDC_TOKENLIST);
+ int item = ListView_GetNextItem(hList, -1, LVNI_SELECTED|LVNI_FOCUSED);
+
+ LVITEM lvItem;
ZeroMemory(&lvItem, sizeof(lvItem));
lvItem.mask = LVIF_PARAM;
lvItem.iSubItem = 0;
@@ -540,15 +533,15 @@ static BOOL CALLBACK processTokenListMessage(HWND hwndDlg,UINT msg,WPARAM wParam
if (ListView_GetItem(hList, &lvItem) == FALSE) {
break;
}
- tr = (TOKENREGISTER *)lvItem.lParam;
+ TOKENREGISTER *tr = (TOKENREGISTER *)lvItem.lParam;
if (tr == NULL) {
break;
}
- len = _tcslen(tr->tszTokenString) + 2;
+ size_t len = _tcslen(tr->tszTokenString) + 2;
if (len < 0) {
break;
}
- tokenString = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
+ TCHAR *tokenString = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
if (tokenString == NULL) {
break;
}
diff --git a/plugins/Variables/src/parse_alias.cpp b/plugins/Variables/src/parse_alias.cpp
index e5f033cc38..4c859df110 100644
--- a/plugins/Variables/src/parse_alias.cpp
+++ b/plugins/Variables/src/parse_alias.cpp
@@ -194,7 +194,7 @@ static TCHAR *parseAddAlias(ARGUMENTSINFO *ai) {
szHelp = ( char* )mir_alloc(32 + strlen(szArgsA));
memset(szHelp, '\0', 32 + strlen(szArgsA));
- sprintf(szHelp, LPGEN("Alias\t(%s)\tuser defined"), szArgsA);
+ sprintf(szHelp, LPGEN("Alias")"\t(%s)\t"LPGEN("user defined"), szArgsA);
res = registerIntToken(alias, parseTranslateAlias, TRF_FUNCTION|TRF_UNPARSEDARGS, szHelp);
mir_free(szArgsA);
}
diff --git a/plugins/Variables/src/parse_inet.cpp b/plugins/Variables/src/parse_inet.cpp
index 95c94aba7d..0fe84a7ae5 100644
--- a/plugins/Variables/src/parse_inet.cpp
+++ b/plugins/Variables/src/parse_inet.cpp
@@ -32,7 +32,7 @@ static TCHAR *parseUrlEnc(ARGUMENTSINFO *ai) {
if (res == NULL) {
return NULL;
}
- unsigned int cur = 0;
+ size_t cur = 0;
while (cur < strlen(res)) {
if (( (*(res+cur) >= '0') && (*(res+cur) <= '9')) || ( (*(res+cur) >= 'a') && (*(res+cur) <= 'z')) || ( (*(res+cur) >= 'A') && (*(res+cur) <= 'Z')) ) {
cur++;
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp
index 549a3f5ac5..85c1c7e238 100644
--- a/plugins/Variables/src/parse_miranda.cpp
+++ b/plugins/Variables/src/parse_miranda.cpp
@@ -474,7 +474,6 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
return NULL;
ai->flags |= AIF_DONTPARSE;
- TCHAR *res = NULL;
TCHAR *szUniqueID = NULL;
char *szProto = GetContactProto(ai->fi->hContact);
if (szProto != NULL)
@@ -488,7 +487,7 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
return NULL;
}
- res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
+ TCHAR *res = (TCHAR*)mir_alloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
if (res == NULL) {
mir_free(szUniqueID);
return NULL;
diff --git a/plugins/Variables/src/parse_str.cpp b/plugins/Variables/src/parse_str.cpp
index 3eb6314183..8b0740654d 100644
--- a/plugins/Variables/src/parse_str.cpp
+++ b/plugins/Variables/src/parse_str.cpp
@@ -133,7 +133,7 @@ static TCHAR *parseFixeol2(ARGUMENTSINFO *ai)
}
TCHAR *res = mir_tstrdup(ai->targv[1]);
- for (unsigned int pos=0; pos < _tcslen(res); pos++ ) {
+ for (size_t pos=0; pos < _tcslen(res); pos++ ) {
TCHAR *cur = res+pos;
TCHAR *szEol = NULL;
if (!_tcsncmp(cur, _T("\r\n"), _tcslen(_T("\r\n"))))
@@ -393,16 +393,14 @@ static TCHAR *parseRepeat(ARGUMENTSINFO *ai)
}
static TCHAR *parseReplace(ARGUMENTSINFO *ai) {
-
- TCHAR *res, *cur;
- unsigned int i, pos;
-
if ((ai->argc < 4) || (ai->argc%2 != 0)) {
return NULL;
}
- pos = 0;
- res = mir_tstrdup(ai->targv[1]);
- for (i=2;i<ai->argc;i+=2) {
+ TCHAR *cur;
+
+ size_t pos = 0;
+ TCHAR *res = mir_tstrdup(ai->targv[1]);
+ for (size_t i=2;i<ai->argc;i+=2) {
if ( _tcslen(ai->targv[i]) == 0) {
continue;
}
@@ -861,7 +859,7 @@ int registerStrTokens() {
registerIntToken(_T(PAD), parsePad, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y,z)\t"LPGEN("pads x to length y prepending character z (z is optional)"));
registerIntToken(_T(PADRIGHT), parsePadright, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y,z)\t"LPGEN("pads x to length y appending character z (z is optional)"));
registerIntToken(_T(PADCUT), parsePadcut, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y,z)\t"LPGEN("pads x to length y prepending character z, or cut if x is longer (z is optional)"));
- registerIntToken(_T(PADCUTRIGHT), parsePadcutright, TRF_FUNCTION, LPGEN("String Functions")"\t"LPGEN("(x,y,z)\tpads x to length y appending character z, or cut if x is longer (z is optional)"));
+ registerIntToken(_T(PADCUTRIGHT), parsePadcutright, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y,z)\t"LPGEN("pads x to length y appending character z, or cut if x is longer (z is optional)"));
registerIntToken(_T(REPEAT), parseRepeat, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y)\t"LPGEN("repeats x y times"));
registerIntToken(_T(REPLACE), parseReplace, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y,z,...)\t"LPGEN("replace all occurrences of y in x with z, multiple y and z arguments allowed"));
registerIntToken(_T(RIGHT), parseRight, TRF_FUNCTION, LPGEN("String Functions")"\t(x,y)\t"LPGEN("trims x to length y, keeping last y characters"));
diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp
index cd0d530c23..e702ca9ea1 100644
--- a/plugins/Variables/src/parse_system.cpp
+++ b/plugins/Variables/src/parse_system.cpp
@@ -27,23 +27,17 @@
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x400
-#endif
-
-#ifndef WINE
-#include "enumprocs.h"
+#else
+ #include "enumprocs.h"
#endif
static TCHAR *parseComputerName(ARGUMENTSINFO *ai) {
-
- DWORD len;
- TCHAR *res;
-
if (ai->argc != 1)
return NULL;
ai->flags |= AIF_DONTPARSE;
- len = MAX_COMPUTERNAME_LENGTH;
- res = (TCHAR*)mir_calloc((len + 1) * sizeof(TCHAR));
+ DWORD len = MAX_COMPUTERNAME_LENGTH;
+ TCHAR *res = (TCHAR*)mir_calloc((len + 1) * sizeof(TCHAR));
if (res == NULL)
return NULL;
@@ -61,7 +55,6 @@ static TCHAR *parseComputerName(ARGUMENTSINFO *ai) {
static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
HQUERY hQuery;
- PDH_STATUS pdhStatus;
PDH_FMT_COUNTERVALUE cValue;
HCOUNTER hCounter;
TCHAR *szCounter, szVal[32];
@@ -78,7 +71,7 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
wsprintf(szCounter, _T("\\Process(%s)\\%% Processor Time"), ai->targv[1]);
}
- pdhStatus = PdhValidatePath(szCounter);
+ PDH_STATUS pdhStatus = PdhValidatePath(szCounter);
if (pdhStatus != ERROR_SUCCESS) {
mir_free(szCounter);
return NULL;
@@ -132,17 +125,14 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
#endif
static TCHAR *parseCurrentDate(ARGUMENTSINFO *ai) {
-
- int len;
- TCHAR *szFormat, *res;
-
+ TCHAR *szFormat;
if (ai->argc == 1 || (ai->argc > 1 && _tcslen(ai->targv[1]) == 0 ))
szFormat = NULL;
else
szFormat = ai->targv[1];
- len = GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, NULL, 0);
- res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
+ int len = GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, NULL, 0);
+ TCHAR *res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
@@ -155,17 +145,14 @@ static TCHAR *parseCurrentDate(ARGUMENTSINFO *ai) {
}
static TCHAR *parseCurrentTime(ARGUMENTSINFO *ai) {
-
- int len;
- TCHAR *szFormat, *res;
-
+ TCHAR *szFormat;
if (ai->argc == 1 || (ai->argc > 1) && (_tcslen(ai->targv[1]) == 0))
szFormat = NULL;
else
szFormat = ai->targv[1];
- len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, NULL, 0);
- res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
+ int len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, NULL, 0);
+ TCHAR *res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
@@ -248,11 +235,8 @@ static TCHAR *parseDirectory2(ARGUMENTSINFO *ai)
}
static int getTime(TCHAR *szTime, struct tm *date) {
-
- TCHAR *cur;
-
// do some extra checks here
- cur = szTime;
+ TCHAR *cur = szTime;
if (cur >= szTime+_tcslen(szTime))
return -1;
@@ -320,13 +304,10 @@ static TCHAR *parseDiffTime(ARGUMENTSINFO *ai) {
}
static TCHAR *parseDirExists(ARGUMENTSINFO *ai) {
-
- HANDLE hFile;
-
if (ai->argc != 2) {
return NULL;
}
- hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ HANDLE hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
ai->flags |= AIF_FALSE;
}
@@ -338,18 +319,14 @@ static TCHAR *parseDirExists(ARGUMENTSINFO *ai) {
}
static TCHAR *parseEnvironmentVariable(ARGUMENTSINFO *ai) {
-
- DWORD len;
- TCHAR *res;
-
if (ai->argc != 2) {
return NULL;
}
- len = ExpandEnvironmentStrings(ai->targv[1], NULL, 0);
+ DWORD len = ExpandEnvironmentStrings(ai->targv[1], NULL, 0);
if (len <= 0) {
return NULL;
}
- res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
+ TCHAR *res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
@@ -362,13 +339,10 @@ static TCHAR *parseEnvironmentVariable(ARGUMENTSINFO *ai) {
}
static TCHAR *parseFileExists(ARGUMENTSINFO *ai) {
-
- HANDLE hFile;
-
if (ai->argc != 2)
return NULL;
- hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
ai->flags |= AIF_FALSE;
else
@@ -378,21 +352,16 @@ static TCHAR *parseFileExists(ARGUMENTSINFO *ai) {
}
static TCHAR *parseFindWindow(ARGUMENTSINFO *ai) {
-
- HWND hWin;
- TCHAR *res;
- int len;
-
if (ai->argc != 2)
return NULL;
- hWin = FindWindow(ai->targv[1], NULL);
+ HWND hWin = FindWindow(ai->targv[1], NULL);
if (hWin == NULL)
return NULL;
- len = SendMessage(hWin, WM_GETTEXTLENGTH, 0, 0);
+ int len = SendMessage(hWin, WM_GETTEXTLENGTH, 0, 0);
if (len >= 0) {
- res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
+ TCHAR *res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
ZeroMemory(res, (len+1)*sizeof(TCHAR));
GetWindowText(hWin, res, len+1);
return res;
@@ -405,8 +374,6 @@ static TCHAR *parseFindWindow(ARGUMENTSINFO *ai) {
// 3 = sperator
// 4 = [f]iles, [d]irs
static TCHAR *parseListDir(ARGUMENTSINFO *ai) {
-
- HANDLE hFind;
BOOL bFiles, bDirs;
WIN32_FIND_DATA ffd;
TCHAR tszFirst[MAX_PATH], *tszRes, *tszSeperator, *tszFilter;
@@ -443,7 +410,7 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai) {
_tcsncat(tszFirst, _T("\\"), SIZEOF(tszFirst) - _tcslen(tszFirst) - 1);
_tcsncat(tszFirst, tszFilter, SIZEOF(tszFirst) - _tcslen(tszFirst) - 1);
}
- hFind = FindFirstFile(tszFirst, &ffd);
+ HANDLE hFind = FindFirstFile(tszFirst, &ffd);
if (hFind == INVALID_HANDLE_VALUE) {
return NULL;
}
@@ -472,9 +439,7 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai) {
#ifndef WINE
static BOOL CALLBACK MyProcessEnumerator(DWORD dwPID, WORD wTask, char *szProcess, LPARAM lParam) {
- char **szProc;
-
- szProc = (char **)lParam;
+ char **szProc = (char **)lParam;
if ((*szProc != NULL) && (!_stricmp(*szProc, szProcess))) {
*szProc = NULL;
}
@@ -483,13 +448,11 @@ static BOOL CALLBACK MyProcessEnumerator(DWORD dwPID, WORD wTask, char *szProces
}
static TCHAR *parseProcessRunning(ARGUMENTSINFO *ai) {
-
- char *szProc, *ref;
-
if (ai->argc != 2) {
return NULL;
}
+ char *szProc, *ref;
szProc = ref = mir_u2a(ai->targv[1]);
EnumProcs((PROCENUMPROC) MyProcessEnumerator, (LPARAM)&szProc);
@@ -502,20 +465,20 @@ static TCHAR *parseProcessRunning(ARGUMENTSINFO *ai) {
#endif
static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) {
+ if (ai->argc != 3) {
+ return NULL;
+ }
HKEY hKey;
- TCHAR *key, *subKey, *cur, *res;
+ TCHAR *subKey, *res;
DWORD len, type;
int err;
- if (ai->argc != 3) {
- return NULL;
- }
- key = subKey = mir_tstrdup(ai->targv[1]);
+ TCHAR *key = subKey = mir_tstrdup(ai->targv[1]);
if (subKey == NULL) {
return NULL;
}
- cur = _tcschr(subKey, _T('\\'));
+ TCHAR *cur = _tcschr(subKey, _T('\\'));
if (cur == NULL) {
return NULL;
}
@@ -560,10 +523,7 @@ static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) {
}
static int TsToSystemTime(SYSTEMTIME *sysTime, time_t timestamp) {
-
- struct tm *pTime;
-
- pTime = localtime(&timestamp);
+ struct tm *pTime = localtime(&timestamp);
if (pTime == NULL) {
return -1;
}
@@ -580,16 +540,13 @@ static int TsToSystemTime(SYSTEMTIME *sysTime, time_t timestamp) {
}
static TCHAR *parseTimestamp2Date(ARGUMENTSINFO *ai) {
-
- int len;
- time_t timestamp;
- SYSTEMTIME sysTime;
- TCHAR *szFormat, *res;
-
if (ai->argc <= 1) {
return NULL;
}
- timestamp = ttoi(ai->targv[1]);
+
+ SYSTEMTIME sysTime;
+ TCHAR *szFormat;
+ time_t timestamp = ttoi(ai->targv[1]);
if (timestamp == 0) {
return NULL;
}
@@ -602,8 +559,8 @@ static TCHAR *parseTimestamp2Date(ARGUMENTSINFO *ai) {
if (TsToSystemTime(&sysTime, timestamp) != 0) {
return NULL;
}
- len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, NULL, 0);
- res = (TCHAR*)mir_calloc((len+1) * sizeof(TCHAR));
+ int len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, NULL, 0);
+ TCHAR *res = (TCHAR*)mir_calloc((len+1) * sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
@@ -616,19 +573,16 @@ static TCHAR *parseTimestamp2Date(ARGUMENTSINFO *ai) {
}
static TCHAR *parseTimestamp2Time(ARGUMENTSINFO *ai) {
-
- int len;
- time_t timestamp;
- SYSTEMTIME sysTime;
- TCHAR *szFormat, *res;
-
if (ai->argc <= 1) {
return NULL;
}
- timestamp = ttoi(ai->targv[1]);
+
+ SYSTEMTIME sysTime;
+ time_t timestamp = ttoi(ai->targv[1]);
if (timestamp == 0) {
return NULL;
}
+ TCHAR *szFormat;
if ((ai->argc == 2) || ((ai->argc > 2) && (_tcslen(ai->targv[2]) == 0))) {
szFormat = NULL;
}
@@ -638,8 +592,8 @@ static TCHAR *parseTimestamp2Time(ARGUMENTSINFO *ai) {
if (TsToSystemTime(&sysTime, timestamp) != 0) {
return NULL;
}
- len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, NULL, 0);
- res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
+ int len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, NULL, 0);
+ TCHAR *res = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
@@ -655,7 +609,6 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
int lineNo, lineCount, csz;
unsigned int icur, bufSz;
- HANDLE hFile;
DWORD fileSz, readSz, totalReadSz;
unsigned long linePos;
TCHAR tUC, *res;
@@ -665,7 +618,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
return NULL;
}
lineNo = ttoi(ai->targv[2]);
- hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ HANDLE hFile = CreateFile(ai->targv[1], GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
return NULL;
}
@@ -868,7 +821,6 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
static TCHAR *parseUpTime(ARGUMENTSINFO *ai) {
HQUERY hQuery;
- PDH_STATUS pdhStatus;
PDH_FMT_COUNTERVALUE cValue;
HCOUNTER hCounter;
TCHAR szVal[32];
@@ -877,7 +829,7 @@ static TCHAR *parseUpTime(ARGUMENTSINFO *ai) {
return NULL;
}
- pdhStatus = PdhOpenQuery (NULL, 0, &hQuery);
+ PDH_STATUS pdhStatus = PdhOpenQuery (NULL, 0, &hQuery);
if (pdhStatus != ERROR_SUCCESS) {
return NULL;
}
@@ -907,16 +859,12 @@ static TCHAR *parseUpTime(ARGUMENTSINFO *ai) {
#endif
static TCHAR *parseUserName(ARGUMENTSINFO *ai) {
-
- DWORD len;
- TCHAR *res;
-
if (ai->argc != 1) {
return NULL;
}
ai->flags |= AIF_DONTPARSE;
- len = UNLEN;
- res = (TCHAR*)mir_alloc(len + 1);
+ DWORD len = UNLEN;
+ TCHAR *res = (TCHAR*)mir_alloc(len + 1);
if (res == NULL) {
return NULL;
}
@@ -930,27 +878,19 @@ static TCHAR *parseUserName(ARGUMENTSINFO *ai) {
// clipboard support
static TCHAR *parseClipboard(ARGUMENTSINFO *ai) {
-
- TCHAR *res;
-
if (ai->argc != 1)
return NULL;
ai->flags |= AIF_DONTPARSE;
- res = NULL;
+ TCHAR *res = NULL;
if (IsClipboardFormatAvailable(CF_TEXT)) {
if (OpenClipboard(NULL)) {
- HANDLE hData = NULL;
- TCHAR* tszText = NULL;
- int len = 0;
-
- hData = GetClipboardData(CF_UNICODETEXT);
-
+ HANDLE hData = GetClipboardData(CF_UNICODETEXT);
if (hData != NULL) {
- tszText = (TCHAR*)GlobalLock(hData);
- len = _tcslen(tszText);
+ TCHAR *tszText = (TCHAR*)GlobalLock(hData);
+ size_t len = _tcslen(tszText);
res = (TCHAR*)mir_alloc((len + 1) * sizeof(TCHAR));
_tcscpy(res, tszText);
res[len] = _T('\0');
@@ -996,7 +936,7 @@ int registerSystemTokens() {
srand((unsigned int)GetTickCount());
- registerIntToken(_T(CLIPBOARD), parseClipboard, TRF_FIELD, LPGEN("System Functions\ttext from clipboard"));
+ registerIntToken(_T(CLIPBOARD), parseClipboard, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("text from clipboard"));
return 0;
}
diff --git a/plugins/Variables/src/parse_xml.cpp b/plugins/Variables/src/parse_xml.cpp
index 954252d1d4..2a4a8a0a7b 100644
--- a/plugins/Variables/src/parse_xml.cpp
+++ b/plugins/Variables/src/parse_xml.cpp
@@ -52,8 +52,7 @@ void (*pXsltCleanupGlobals)(void);
pattern, subject
*/
static TCHAR *parseXslts(ARGUMENTSINFO *ai) {
- TCHAR *tszRes;
- xmlDocPtr doc, res, sdoc;
+ xmlDocPtr res;
xmlChar *xmlChRes = NULL;
int resLen;
@@ -66,9 +65,8 @@ static TCHAR *parseXslts(ARGUMENTSINFO *ai) {
log_debugA("calling xsltParseMemory");
- sdoc = pXmlParseMemory(szStyleSheet, strlen(szStyleSheet));
+ xmlDocPtr sdoc = pXmlParseMemory(szStyleSheet, strlen(szStyleSheet));
if (sdoc == NULL) {
-
return NULL;
}
@@ -82,7 +80,7 @@ static TCHAR *parseXslts(ARGUMENTSINFO *ai) {
}
log_debugA("calling xsltParseMemory");
- doc = pXmlParseMemory(szDoc, strlen(szDoc));
+ xmlDocPtr doc = pXmlParseMemory(szDoc, strlen(szDoc));
if (doc == NULL) {
log_debugA("calling xsltFreeDoc");
pXmlFreeDoc(sdoc);
@@ -118,7 +116,7 @@ static TCHAR *parseXslts(ARGUMENTSINFO *ai) {
log_debugA("calling mir_free");
mir_free(szDoc);
- tszRes = mir_a2t((char *)xmlChRes);
+ TCHAR *tszRes = mir_a2t((char *)xmlChRes);
log_debugA("calling xmlFree");
pXmlFree(xmlChRes);
diff --git a/plugins/Variables/src/variables.cpp b/plugins/Variables/src/variables.cpp
index 8bce78de58..dcdc3c48c0 100644
--- a/plugins/Variables/src/variables.cpp
+++ b/plugins/Variables/src/variables.cpp
@@ -161,8 +161,8 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
**argv, // arguments (dyn alloc)
**pargv, // dyn alloc
*token; // variable name (pnt only)
- int argc, i, parsedTokenLen, initStrLen, tokenLen, scurPos, curPos, tmpVarPos;
- unsigned int pos;
+ int argc = 0, i, tokenLen = 0, scurPos, curPos, tmpVarPos;
+ size_t pos;
FORMATINFO afi;
TOKENREGISTEREX *tr;
ARGUMENTSINFO ai = { 0 };
@@ -171,7 +171,6 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
if (string == NULL)
return NULL;
- argc = parsedTokenLen = initStrLen = tokenLen = 0;
cur = tcur = scur = token = parsedToken = NULL;
pargv = argv = NULL;
//fi->pCount = 0;
@@ -190,7 +189,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
if (argv != NULL)
mir_free(argv);
- argc = parsedTokenLen = initStrLen = tokenLen = 0;
+ argc = tokenLen = 0;
tcur = scur = token = parsedToken = NULL;
pargv = argv = NULL;
// new round
@@ -359,8 +358,8 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
}
}*/
- parsedTokenLen = _tcslen(parsedToken);
- initStrLen = _tcslen(string);
+ size_t parsedTokenLen = _tcslen(parsedToken);
+ size_t initStrLen = _tcslen(string);
tokenLen = cur-scur;
scurPos = scur-string;
curPos = cur-string;