From 4b99b5b4abad1cf12ac5c7bbb8788899ba6a48ab Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 9 Jul 2018 13:03:28 +0300 Subject: massive Variables-related code cleaning (removed TCHAR, manually created unions replaced with MAllString etc) --- plugins/Variables/src/parse_str.cpp | 219 ++++++++++++++++++------------------ 1 file changed, 108 insertions(+), 111 deletions(-) (limited to 'plugins/Variables/src/parse_str.cpp') diff --git a/plugins/Variables/src/parse_str.cpp b/plugins/Variables/src/parse_str.cpp index f13b4a0252..e335a36d69 100644 --- a/plugins/Variables/src/parse_str.cpp +++ b/plugins/Variables/src/parse_str.cpp @@ -24,7 +24,7 @@ static wchar_t *parseCaps(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); wchar_t *cur = res; CharLower(res); *cur = (wchar_t)CharUpper((LPTSTR)*cur); @@ -49,7 +49,7 @@ static wchar_t *parseCaps2(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); wchar_t *cur = res; *cur = (wchar_t)CharUpper((LPTSTR)*cur); cur++; @@ -75,7 +75,7 @@ static wchar_t *parseEolToCrlf(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); wchar_t *cur = res; do { cur = wcschr(cur, '\n'); @@ -101,24 +101,24 @@ static wchar_t *parseFixeol(ARGUMENTSINFO *ai) if (ai->argc == 2) szReplacement = L"(...)"; else if (ai->argc == 3) - szReplacement = ai->targv[2]; + szReplacement = ai->argv.w[2]; else return nullptr; - wchar_t *cur = ai->targv[1]; + wchar_t *cur = ai->argv.w[1]; while (mir_wstrcmp(cur, L"\r\n") && *cur != '\n' && *cur != 0) cur++; if (*cur == '\0') - return mir_wstrdup(ai->targv[1]); + return mir_wstrdup(ai->argv.w[1]); cur--; - wchar_t *res = (wchar_t*)mir_alloc((cur - ai->targv[1] + mir_wstrlen(szReplacement) + 1)*sizeof(wchar_t)); + wchar_t *res = (wchar_t*)mir_alloc((cur - ai->argv.w[1] + mir_wstrlen(szReplacement) + 1)*sizeof(wchar_t)); if (res == nullptr) return res; - memset(res, 0, (((cur - ai->targv[1]) + 1) * sizeof(wchar_t))); - wcsncpy(res, ai->targv[1], cur - ai->targv[1]); + memset(res, 0, (((cur - ai->argv.w[1]) + 1) * sizeof(wchar_t))); + wcsncpy(res, ai->argv.w[1], cur - ai->argv.w[1]); mir_wstrcat(res, szReplacement); return res; } @@ -128,11 +128,11 @@ static wchar_t *parseFixeol2(ARGUMENTSINFO *ai) wchar_t *szReplacement; switch (ai->argc) { case 2: szReplacement = L" "; break; - case 3: szReplacement = ai->targv[2]; break; + case 3: szReplacement = ai->argv.w[2]; break; default: return nullptr; } - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); for (size_t pos = 0; pos < mir_wstrlen(res); pos++) { wchar_t *cur = res + pos; wchar_t *szEol = nullptr; @@ -160,18 +160,18 @@ static wchar_t *parseInsert(ARGUMENTSINFO *ai) if (ai->argc != 4) return nullptr; - unsigned int pos = ttoi(ai->targv[3]); - if (pos > mir_wstrlen(ai->targv[1])) + unsigned int pos = ttoi(ai->argv.w[3]); + if (pos > mir_wstrlen(ai->argv.w[1])) return nullptr; - wchar_t *res = (wchar_t*)mir_alloc((mir_wstrlen(ai->targv[1]) + mir_wstrlen(ai->targv[2]) + 1)*sizeof(wchar_t)); + wchar_t *res = (wchar_t*)mir_alloc((mir_wstrlen(ai->argv.w[1]) + mir_wstrlen(ai->argv.w[2]) + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; - memset(res, 0, ((mir_wstrlen(ai->targv[1]) + mir_wstrlen(ai->targv[2]) + 1) * sizeof(wchar_t))); - wcsncpy(res, ai->targv[1], pos); - mir_wstrcpy(res + pos, ai->targv[2]); - mir_wstrcpy(res + pos + mir_wstrlen(ai->targv[2]), ai->targv[1] + pos); + memset(res, 0, ((mir_wstrlen(ai->argv.w[1]) + mir_wstrlen(ai->argv.w[2]) + 1) * sizeof(wchar_t))); + wcsncpy(res, ai->argv.w[1], pos); + mir_wstrcpy(res + pos, ai->argv.w[2]); + mir_wstrcpy(res + pos + mir_wstrlen(ai->argv.w[2]), ai->argv.w[1] + pos); return res; } @@ -180,17 +180,17 @@ static wchar_t *parseLeft(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - int len = ttoi(ai->targv[2]); + int len = ttoi(ai->argv.w[2]); if (len < 0) return nullptr; - len = min(len, (signed int)mir_wstrlen(ai->targv[1])); + len = min(len, (signed int)mir_wstrlen(ai->argv.w[1])); wchar_t *res = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; memset(res, 0, ((len + 1) * sizeof(wchar_t))); - wcsncpy(res, ai->targv[1], len); + wcsncpy(res, ai->argv.w[1], len); return res; } @@ -199,7 +199,7 @@ static wchar_t *parseLen(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - return itot((int)mir_wstrlen(ai->targv[1])); + return itot((int)mir_wstrlen(ai->argv.w[1])); } static wchar_t *parseLineCount(ARGUMENTSINFO *ai) @@ -208,8 +208,8 @@ static wchar_t *parseLineCount(ARGUMENTSINFO *ai) return nullptr; int count = 1; - wchar_t *cur = ai->targv[1]; - while (cur < (ai->targv[1] + mir_wstrlen(ai->targv[1]))) { + wchar_t *cur = ai->argv.w[1]; + while (cur < (ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]))) { if (!wcsncmp(cur, L"\r\n", 2)) { count++; cur++; @@ -228,7 +228,7 @@ static wchar_t *parseLower(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); if (res == nullptr) return nullptr; @@ -242,10 +242,10 @@ static wchar_t *parseLongest(ARGUMENTSINFO *ai) unsigned int iLong = 1; for (unsigned int i = 2; i < ai->argc; i++) - if (mir_wstrlen(ai->targv[i]) > mir_wstrlen(ai->targv[iLong])) + if (mir_wstrlen(ai->argv.w[i]) > mir_wstrlen(ai->argv.w[iLong])) iLong = i; - return mir_wstrdup(ai->targv[iLong]); + return mir_wstrdup(ai->argv.w[iLong]); } static wchar_t *parseNoOp(ARGUMENTSINFO *ai) @@ -253,7 +253,7 @@ static wchar_t *parseNoOp(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - return mir_wstrdup(ai->targv[1]); + return mir_wstrdup(ai->argv.w[1]); } static wchar_t *parsePad(ARGUMENTSINFO *ai) @@ -261,25 +261,25 @@ static wchar_t *parsePad(ARGUMENTSINFO *ai) wchar_t padchar; switch (ai->argc) { case 3: padchar = ' '; break; - case 4: padchar = *ai->targv[3]; break; + case 4: padchar = *ai->argv.w[3]; break; default: return nullptr; } - int padding = ttoi(ai->targv[2]); + int padding = ttoi(ai->argv.w[2]); if (padding < 0) return nullptr; - unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0); - wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t)); + unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0); + wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; - memset(res, 0, ((addcount + mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t))); + memset(res, 0, ((addcount + mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t))); wchar_t *cur = res; for (unsigned int i = 0; i < addcount; i++) *cur++ = padchar; - mir_wstrcat(res, ai->targv[1]); + mir_wstrcat(res, ai->argv.w[1]); return res; } @@ -288,22 +288,22 @@ static wchar_t *parsePadright(ARGUMENTSINFO *ai) wchar_t padchar; switch (ai->argc) { case 3: padchar = ' '; break; - case 4: padchar = *ai->targv[3]; break; + case 4: padchar = *ai->argv.w[3]; break; default: return nullptr; } - int padding = ttoi(ai->targv[2]); + int padding = ttoi(ai->argv.w[2]); if (padding < 0) return nullptr; - unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0); - wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t)); + unsigned int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0); + wchar_t *res = (wchar_t*)mir_alloc((addcount + mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; - memset(res, 0, ((addcount + mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t))); - mir_wstrcpy(res, ai->targv[1]); - wchar_t *cur = res + mir_wstrlen(ai->targv[1]); + memset(res, 0, ((addcount + mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t))); + mir_wstrcpy(res, ai->argv.w[1]); + wchar_t *cur = res + mir_wstrlen(ai->argv.w[1]); for (unsigned int i = 0; i < addcount; i++) *cur++ = padchar; @@ -315,15 +315,15 @@ static wchar_t *parsePadcut(ARGUMENTSINFO *ai) wchar_t padchar; switch (ai->argc) { case 3: padchar = ' '; break; - case 4: padchar = *ai->targv[3]; break; + case 4: padchar = *ai->argv.w[3]; break; default: return nullptr; } - int padding = ttoi(ai->targv[2]); + int padding = ttoi(ai->argv.w[2]); if (padding < 0) return nullptr; - int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0); + int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0); wchar_t *res = (wchar_t*)mir_alloc((padding + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; @@ -334,7 +334,7 @@ static wchar_t *parsePadcut(ARGUMENTSINFO *ai) *cur++ = padchar; if (padding > addcount) - wcsncpy(res + addcount, ai->targv[1], padding - addcount); + wcsncpy(res + addcount, ai->argv.w[1], padding - addcount); return res; } @@ -344,15 +344,15 @@ static wchar_t *parsePadcutright(ARGUMENTSINFO *ai) wchar_t padchar; switch (ai->argc) { case 3: padchar = ' '; break; - case 4: padchar = *ai->targv[3]; break; + case 4: padchar = *ai->argv.w[3]; break; default: return nullptr; } - int padding = ttoi(ai->targv[2]); + int padding = ttoi(ai->argv.w[2]); if (padding < 0) return nullptr; - int addcount = max(padding - (signed int)mir_wstrlen(ai->targv[1]), 0); + int addcount = max(padding - (signed int)mir_wstrlen(ai->argv.w[1]), 0); wchar_t *res = (wchar_t*)mir_alloc((padding + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; @@ -363,7 +363,7 @@ static wchar_t *parsePadcutright(ARGUMENTSINFO *ai) *cur++ = padchar; if (padding > addcount) - wcsncpy(res, ai->targv[1], padding - addcount); + wcsncpy(res, ai->argv.w[1], padding - addcount); return res; } @@ -373,17 +373,17 @@ static wchar_t *parseRepeat(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - int count = ttoi(ai->targv[2]); + int count = ttoi(ai->argv.w[2]); if (count < 0) return nullptr; - wchar_t *res = (wchar_t*)mir_alloc((count * mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t)); + wchar_t *res = (wchar_t*)mir_alloc((count * mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; - memset(res, 0, ((count * mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t))); + memset(res, 0, ((count * mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t))); for (int i = 0; i < count; i++) - mir_wstrcat(res, ai->targv[1]); + mir_wstrcat(res, ai->argv.w[1]); return res; } @@ -396,21 +396,21 @@ static wchar_t *parseReplace(ARGUMENTSINFO *ai) wchar_t *cur; size_t pos = 0; - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); for (size_t i = 2; i < ai->argc; i += 2) { - if (mir_wstrlen(ai->targv[i]) == 0) + if (mir_wstrlen(ai->argv.w[i]) == 0) continue; for (pos = 0; postargv[i], mir_wstrlen(ai->targv[i]))) { - if (mir_wstrlen(ai->targv[i + 1]) > mir_wstrlen(ai->targv[i])) { - res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + mir_wstrlen(ai->targv[i + 1]) - mir_wstrlen(ai->targv[i]) + 1)*sizeof(wchar_t)); + if (!wcsncmp(cur, ai->argv.w[i], mir_wstrlen(ai->argv.w[i]))) { + if (mir_wstrlen(ai->argv.w[i + 1]) > mir_wstrlen(ai->argv.w[i])) { + res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + mir_wstrlen(ai->argv.w[i + 1]) - mir_wstrlen(ai->argv.w[i]) + 1)*sizeof(wchar_t)); cur = res + pos; } - memmove(cur + mir_wstrlen(ai->targv[i + 1]), cur + mir_wstrlen(ai->targv[i]), (mir_wstrlen(cur + mir_wstrlen(ai->targv[i])) + 1)*sizeof(wchar_t)); - memcpy(cur, ai->targv[i + 1], mir_wstrlen(ai->targv[i + 1])*sizeof(wchar_t)); - pos += mir_wstrlen(ai->targv[i + 1]) - 1; + memmove(cur + mir_wstrlen(ai->argv.w[i + 1]), cur + mir_wstrlen(ai->argv.w[i]), (mir_wstrlen(cur + mir_wstrlen(ai->argv.w[i])) + 1)*sizeof(wchar_t)); + memcpy(cur, ai->argv.w[i + 1], mir_wstrlen(ai->argv.w[i + 1])*sizeof(wchar_t)); + pos += mir_wstrlen(ai->argv.w[i + 1]) - 1; } } res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + 1)*sizeof(wchar_t)); @@ -424,17 +424,17 @@ static wchar_t *parseRight(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - int len = ttoi(ai->targv[2]); + int len = ttoi(ai->argv.w[2]); if (len < 0) return nullptr; - len = min(len, (signed int)mir_wstrlen(ai->targv[1])); + len = min(len, (signed int)mir_wstrlen(ai->argv.w[1])); wchar_t *res = (wchar_t*)mir_alloc((len + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; memset(res, 0, ((len + 1)*sizeof(wchar_t))); - wcsncpy(res, ai->targv[1] + mir_wstrlen(ai->targv[1]) - len, len); + wcsncpy(res, ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]) - len, len); return res; } @@ -446,21 +446,21 @@ static wchar_t *parseScroll(ARGUMENTSINFO *ai) if (ai->argc != 4) return nullptr; - if (mir_wstrlen(ai->targv[1]) == 0) - return mir_wstrdup(ai->targv[1]); + if (mir_wstrlen(ai->argv.w[1]) == 0) + return mir_wstrdup(ai->argv.w[1]); - size_t move = ttoi(ai->targv[3]) % mir_wstrlen(ai->targv[1]); - size_t display = ttoi(ai->targv[2]); - if (display > mir_wstrlen(ai->targv[1])) - display = (unsigned)mir_wstrlen(ai->targv[1]); + size_t move = ttoi(ai->argv.w[3]) % mir_wstrlen(ai->argv.w[1]); + size_t display = ttoi(ai->argv.w[2]); + if (display > mir_wstrlen(ai->argv.w[1])) + display = (unsigned)mir_wstrlen(ai->argv.w[1]); - wchar_t *res = (wchar_t*)mir_alloc((2 * mir_wstrlen(ai->targv[1]) + 1)*sizeof(wchar_t)); + wchar_t *res = (wchar_t*)mir_alloc((2 * mir_wstrlen(ai->argv.w[1]) + 1)*sizeof(wchar_t)); if (res == nullptr) return nullptr; - memset(res, 0, ((2 * mir_wstrlen(ai->targv[1]) + 1) * sizeof(wchar_t))); - mir_wstrcpy(res, ai->targv[1]); - mir_wstrcat(res, ai->targv[1]); + memset(res, 0, ((2 * mir_wstrlen(ai->argv.w[1]) + 1) * sizeof(wchar_t))); + mir_wstrcpy(res, ai->argv.w[1]); + mir_wstrcat(res, ai->argv.w[1]); memmove(res, res + move, (mir_wstrlen(res + move) + 1)*sizeof(wchar_t)); *(res + display) = 0; res = (wchar_t*)mir_realloc(res, (mir_wstrlen(res) + 1)*sizeof(wchar_t)); @@ -475,10 +475,10 @@ static wchar_t *parseShortest(ARGUMENTSINFO *ai) int iShort = 1; for (unsigned i = 2; i < ai->argc; i++) - if (mir_wstrlen(ai->targv[i]) < mir_wstrlen(ai->targv[iShort])) + if (mir_wstrlen(ai->argv.w[i]) < mir_wstrlen(ai->argv.w[iShort])) iShort = i; - return mir_wstrdup(ai->targv[iShort]); + return mir_wstrdup(ai->argv.w[iShort]); } static wchar_t *parseStrchr(ARGUMENTSINFO *ai) @@ -486,11 +486,11 @@ static wchar_t *parseStrchr(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - wchar_t *c = wcschr(ai->targv[1], *ai->targv[2]); + wchar_t *c = wcschr(ai->argv.w[1], *ai->argv.w[2]); if (c == nullptr || *c == 0) return mir_wstrdup(L"0"); - return itot(c - ai->targv[1] + 1); + return itot(c - ai->argv.w[1] + 1); } static wchar_t *parseStrcmp(ARGUMENTSINFO *ai) @@ -498,7 +498,7 @@ static wchar_t *parseStrcmp(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - if (mir_wstrcmp(ai->targv[1], ai->targv[2])) + if (mir_wstrcmp(ai->argv.w[1], ai->argv.w[2])) ai->flags |= AIF_FALSE; return mir_wstrdup(L""); @@ -511,7 +511,7 @@ static wchar_t *parseStrmcmp(ARGUMENTSINFO *ai) ai->flags |= AIF_FALSE; for (unsigned i = 2; i < ai->argc; i++) { - if (!mir_wstrcmp(ai->targv[1], ai->targv[i])) { + if (!mir_wstrcmp(ai->argv.w[1], ai->argv.w[i])) { ai->flags &= ~AIF_FALSE; break; } @@ -525,11 +525,11 @@ static wchar_t *parseStrncmp(ARGUMENTSINFO *ai) if (ai->argc != 4) return nullptr; - int n = ttoi(ai->targv[3]); + int n = ttoi(ai->argv.w[3]); if (n <= 0) return nullptr; - if (wcsncmp(ai->targv[1], ai->targv[2], n)) + if (wcsncmp(ai->argv.w[1], ai->argv.w[2], n)) ai->flags |= AIF_FALSE; return mir_wstrdup(L""); @@ -540,7 +540,7 @@ static wchar_t *parseStricmp(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - if (mir_wstrcmpi(ai->targv[1], ai->targv[2])) + if (mir_wstrcmpi(ai->argv.w[1], ai->argv.w[2])) ai->flags |= AIF_FALSE; return mir_wstrdup(L""); @@ -551,11 +551,11 @@ static wchar_t *parseStrnicmp(ARGUMENTSINFO *ai) if (ai->argc != 4) return nullptr; - int n = ttoi(ai->targv[3]); + int n = ttoi(ai->argv.w[3]); if (n <= 0) return nullptr; - if (wcsnicmp(ai->targv[1], ai->targv[2], n)) + if (wcsnicmp(ai->argv.w[1], ai->argv.w[2], n)) ai->flags |= AIF_FALSE; return mir_wstrdup(L""); @@ -566,11 +566,11 @@ static wchar_t *parseStrrchr(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - wchar_t *c = wcsrchr(ai->targv[1], *ai->targv[2]); + wchar_t *c = wcsrchr(ai->argv.w[1], *ai->argv.w[2]); if ((c == nullptr) || (*c == 0)) return mir_wstrdup(L"0"); - return itot(c - ai->targv[1] + 1); + return itot(c - ai->argv.w[1] + 1); } static wchar_t *parseStrstr(ARGUMENTSINFO *ai) @@ -578,11 +578,11 @@ static wchar_t *parseStrstr(ARGUMENTSINFO *ai) if (ai->argc != 3) return nullptr; - wchar_t *c = wcsstr(ai->targv[1], ai->targv[2]); + wchar_t *c = wcsstr(ai->argv.w[1], ai->argv.w[2]); if ((c == nullptr) || (*c == 0)) return mir_wstrdup(L"0"); - return itot(c - ai->targv[1] + 1); + return itot(c - ai->argv.w[1] + 1); } static wchar_t *parseSubstr(ARGUMENTSINFO *ai) @@ -590,18 +590,18 @@ static wchar_t *parseSubstr(ARGUMENTSINFO *ai) if (ai->argc < 3) return nullptr; - int to, from = max(ttoi(ai->targv[2]) - 1, 0); + int to, from = max(ttoi(ai->argv.w[2]) - 1, 0); if (ai->argc > 3) - to = min(ttoi(ai->targv[3]), (int)mir_wstrlen(ai->targv[1])); + to = min(ttoi(ai->argv.w[3]), (int)mir_wstrlen(ai->argv.w[1])); else - to = (int)mir_wstrlen(ai->targv[1]); + to = (int)mir_wstrlen(ai->argv.w[1]); if (to < from) return nullptr; wchar_t *res = (wchar_t*)mir_alloc((to - from + 1)*sizeof(wchar_t)); memset(res, 0, ((to - from + 1) * sizeof(wchar_t))); - wcsncpy(res, ai->targv[1] + from, to - from); + wcsncpy(res, ai->argv.w[1] + from, to - from); return res; } @@ -610,11 +610,11 @@ static wchar_t *parseSelect(ARGUMENTSINFO *ai) if (ai->argc <= 1) return nullptr; - int n = ttoi(ai->targv[1]); + int n = ttoi(ai->argv.w[1]); if ((n > (signed int)ai->argc - 2) || n <= 0) return nullptr; - return mir_wstrdup(ai->targv[n + 1]); + return mir_wstrdup(ai->argv.w[n + 1]); } static wchar_t *parseSwitch(ARGUMENTSINFO *ai) @@ -623,8 +623,8 @@ static wchar_t *parseSwitch(ARGUMENTSINFO *ai) return nullptr; for (unsigned i = 2; i < ai->argc; i += 2) - if (!mir_wstrcmp(ai->targv[1], ai->targv[i])) - return mir_wstrdup(ai->targv[i + 1]); + if (!mir_wstrcmp(ai->argv.w[1], ai->argv.w[i])) + return mir_wstrdup(ai->argv.w[i + 1]); return nullptr; } @@ -634,12 +634,12 @@ static wchar_t *parseTrim(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - wchar_t *scur = ai->targv[1]; + wchar_t *scur = ai->argv.w[1]; while (*scur == ' ') scur++; - wchar_t *ecur = ai->targv[1] + mir_wstrlen(ai->targv[1]) - 1; - while ((*ecur == ' ') && (ecur > ai->targv[1])) + wchar_t *ecur = ai->argv.w[1] + mir_wstrlen(ai->argv.w[1]) - 1; + while ((*ecur == ' ') && (ecur > ai->argv.w[1])) ecur--; if (scur >= ecur) @@ -658,8 +658,8 @@ static wchar_t *parseTrim(ARGUMENTSINFO *ai) static wchar_t *parseTab(ARGUMENTSINFO *ai) { int count = 1; - if ((ai->argc == 2) && (mir_wstrlen(ai->targv[1]) > 0)) - count = ttoi(ai->targv[1]); + if ((ai->argc == 2) && (mir_wstrlen(ai->argv.w[1]) > 0)) + count = ttoi(ai->argv.w[1]); if (count < 0) return nullptr; @@ -681,7 +681,7 @@ static wchar_t *parseUpper(ARGUMENTSINFO *ai) if (ai->argc != 2) return nullptr; - wchar_t *res = mir_wstrdup(ai->targv[1]); + wchar_t *res = mir_wstrdup(ai->argv.w[1]); if (res == nullptr) return nullptr; @@ -731,10 +731,10 @@ static wchar_t *parseWord(ARGUMENTSINFO *ai) return nullptr; wchar_t *res = nullptr; - int to, from = ttoi(ai->targv[2]); + int to, from = ttoi(ai->argv.w[2]); if (ai->argc == 4) { - if (mir_wstrlen(ai->targv[3]) > 0) - to = ttoi(ai->targv[3]); + if (mir_wstrlen(ai->argv.w[3]) > 0) + to = ttoi(ai->argv.w[3]); else to = 100000; // rework } @@ -744,7 +744,7 @@ static wchar_t *parseWord(ARGUMENTSINFO *ai) return nullptr; for (int i = from; i <= to; i++) { - wchar_t *szWord = getNthWord(ai->targv[1], i); + wchar_t *szWord = getNthWord(ai->argv.w[1], i); if (szWord == nullptr) return res; @@ -769,10 +769,7 @@ static wchar_t *parseExtratext(ARGUMENTSINFO *ai) return nullptr; ai->flags |= AIF_DONTPARSE; - if (ai->fi->szExtraText != nullptr) - return mir_wstrdup(ai->fi->tszExtraText); - - return nullptr; + return mir_wstrdup(ai->fi->szExtraText.w); } void registerStrTokens() -- cgit v1.2.3