+ fix: bug while reading String to Vector

This commit is contained in:
Rainer Kottenhoff 2018-04-29 21:30:24 +02:00
parent 1b7d055218
commit 520ea555bb
4 changed files with 11 additions and 7 deletions

View File

@ -2861,6 +2861,7 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, i
for (int i = 0; i < len; ++i) {
if (wchTmpBuff[i] == L',') { wchTmpBuff[i] = L'\0'; }
}
wchTmpBuff[len + 1] = L'\0'; // double zero at the end
// fill default
for (int i = 0; i < iCount; ++i) { StringCchCopyW(sMatrix[i], (size_t)iLen, sDefault); }
// insert values
@ -2881,7 +2882,7 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, i
// ReadVectorFromString()
//
//
int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, int iMax, int iDefault)
int ReadVectorFromString(LPCWSTR wchStrg, int iVector[], int iCount, int iMin, int iMax, int iDefault)
{
static WCHAR wchTmpBuff[SMALL_BUFFER];
@ -2898,6 +2899,8 @@ int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, in
for (int i = 0; i < len; ++i) {
if (wchTmpBuff[i] == L' ') { wchTmpBuff[i] = L'\0'; }
}
wchTmpBuff[len + 1] = L'\0'; // double zero at the end
// fill default
for (int i = 0; i < iCount; ++i) { iVector[i] = iDefault; }
// insert values

View File

@ -388,7 +388,7 @@ __forceinline int GetHexDigit(char ch) {
void UrlUnescapeEx(LPWSTR, LPWSTR, DWORD*);
int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, int const iLen, LPCWSTR sDefault);
int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, int iMax, int iDefault);
int ReadVectorFromString(LPCWSTR wchStrg, int iVector[], int iCount, int iMin, int iMax, int iDefault);
// --------------------------------------------------------------------------------------------------------------------------------

View File

@ -143,12 +143,12 @@ static WCHAR g_tchStatusbarPrefixes[MIDSZ_BUFFER] = { L'\0' };
static prefix_t g_mxStatusBarPrefix[STATUS_SECTOR_COUNT];
static WCHAR g_tchStatusbarSections[SMALL_BUFFER] = { L'\0' };
static int g_iStatusbarSections[STATUS_SECTOR_COUNT];
static bool g_iStatusbarVisible[STATUS_SECTOR_COUNT];
static int g_vSBSOrder[STATUS_SECTOR_COUNT];
static int g_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS;
static bool g_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO;
static int g_vSBSOrder[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS;
static WCHAR g_tchStatusbarWidthSpec[SMALL_BUFFER] = { L'\0' };
static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT];
static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO;
static WCHAR g_tchToolbarBitmap[MAX_PATH] = { L'\0' };
@ -7776,7 +7776,7 @@ void UpdateStatusbar()
_CalculateStatusbarSections(g_vStatusbarSectionWidth, tchStatusBar);
int aStatusbarSections[STATUS_SECTOR_COUNT];
int aStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO;
int cnt = 0;
int totalWidth = 0;
for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {

View File

@ -91,6 +91,7 @@ typedef enum {
#define SBS_INIT_ZERO { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
#define SBS_INIT_MINUS { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }
#define SBS_INIT_ORDER { 0, 1, 2, 3, 4, 5, 6, 7. 8. 9, 10, 11 }
#define STATUSBAR_EXTION_PREFIXES L"Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,"
#define STATUSBAR_DEFAULT_IDS L"0 1 2 4 5 6 7 8 9 10 11"