+ fix: bug in calculating position for thousand separator

This commit is contained in:
Rainer Kottenhoff 2018-02-09 10:22:42 +01:00
parent 03f5508343
commit be2d57580d
2 changed files with 28 additions and 24 deletions

View File

@ -1671,32 +1671,33 @@ DWORD_PTR SHGetFileInfo2(LPCWSTR pszPath,DWORD dwFileAttributes,
//
int FormatNumberStr(LPWSTR lpNumberStr)
{
WCHAR *c;
WCHAR szSep[8];
int i = 0;
static WCHAR szSep[8] = { L'\0' };
const int iPlace = 3;
if (!lstrlen(lpNumberStr))
return(0);
if (!lstrlen(lpNumberStr)) { return 0; }
if (!GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_STHOUSAND,
szSep,
COUNTOF(szSep)))
szSep[0] = L'\'';
StrTrim(lpNumberStr, L" \t");
c = StrEnd(lpNumberStr);
if (lstrlen(lpNumberStr) > iPlace) {
while ((c = CharPrev(lpNumberStr,c)) != lpNumberStr)
{
if (++i == 3)
{
i = 0;
MoveMemory(c+1,c,sizeof(WCHAR)*(lstrlen(c)+1));
*c = szSep[0];
if (szSep[0] == L'\0') {
if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND,
szSep, COUNTOF(szSep))) {
szSep[0] = L'\'';
}
}
WCHAR* ch = StrEnd(lpNumberStr);
int i = 0;
while ((ch = CharPrev(lpNumberStr, ch)) != lpNumberStr) {
if (((++i) % iPlace) == 0) {
MoveMemory(ch + 1, ch, sizeof(WCHAR)*(lstrlen(ch) + 1));
*ch = szSep[0];
}
}
}
return(lstrlen(lpNumberStr));
return lstrlen(lpNumberStr);
}

View File

@ -6972,6 +6972,8 @@ void UpdateStatusbar()
static WCHAR tch2ndDef[32] = { L'\0' };
static WCHAR tchLexerName[128] = { L'\0' };
static WCHAR tchLinesSelected[32] = { L'\0' };
static WCHAR tchTmp[32] = { L'\0' };
if (!bShowStatusbar) { return; }
@ -7005,7 +7007,6 @@ void UpdateStatusbar()
const int iSel = (int)SendMessage(g_hwndEdit, SCI_COUNTCHARACTERS, iSelStart, iSelEnd);
StringCchPrintf(tchSel, COUNTOF(tchSel), L"%i", iSel);
FormatNumberStr(tchSel);
StrFormatByteSize((iSelEnd - iSelStart), tchSelB, COUNTOF(tchSelB));
}
else {
@ -7018,15 +7019,17 @@ void UpdateStatusbar()
{
if ((iMarkOccurrencesMaxCount < 0) || (iMarkOccurrencesCount < iMarkOccurrencesMaxCount))
{
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i ", iMarkOccurrencesCount);
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i", iMarkOccurrencesCount);
FormatNumberStr(tchOcc);
}
else {
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L">= %i ", iMarkOccurrencesMaxCount);
StringCchPrintf(tchTmp, COUNTOF(tchTmp), L"%i", iMarkOccurrencesCount);
FormatNumberStr(tchTmp);
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L">= %s", tchTmp);
}
}
else {
StringCchCopy(tchOcc, COUNTOF(tchOcc), L"-- ");
StringCchCopy(tchOcc, COUNTOF(tchOcc), L"--");
}
// Print number of selected lines in statusbar