bug#5617
allow blank lines in Ndb.cfg files
This commit is contained in:
parent
ee75c45d9d
commit
eda5c31970
@ -229,7 +229,7 @@ LocalConfig::parseString(const char * connectString, char *line){
|
|||||||
|
|
||||||
bool LocalConfig::readFile(const char * filename, bool &fopenError)
|
bool LocalConfig::readFile(const char * filename, bool &fopenError)
|
||||||
{
|
{
|
||||||
char line[150], line2[150];
|
char line[1024];
|
||||||
|
|
||||||
fopenError = false;
|
fopenError = false;
|
||||||
|
|
||||||
@ -241,31 +241,33 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int sz = 1024;
|
BaseString theString;
|
||||||
char* theString = (char*)NdbMem_Allocate(sz);
|
|
||||||
theString[0] = 0;
|
|
||||||
|
|
||||||
fgets(theString, sz, file);
|
while(fgets(line, 1024, file)){
|
||||||
while (fgets(line+1, 100, file)) {
|
BaseString tmp(line);
|
||||||
line[0] = ';';
|
tmp.trim(" \t\n\r");
|
||||||
while (strlen(theString) + strlen(line) >= sz) {
|
if(tmp.length() > 0 && tmp.c_str()[0] != '#'){
|
||||||
sz = sz*2;
|
theString.append(tmp);
|
||||||
char *newString = (char*)NdbMem_Allocate(sz);
|
break;
|
||||||
strcpy(newString, theString);
|
}
|
||||||
free(theString);
|
}
|
||||||
theString = newString;
|
while (fgets(line, 1024, file)) {
|
||||||
|
BaseString tmp(line);
|
||||||
|
tmp.trim(" \t\n\r");
|
||||||
|
if(tmp.length() > 0 && tmp.c_str()[0] != '#'){
|
||||||
|
theString.append(";");
|
||||||
|
theString.append(tmp);
|
||||||
}
|
}
|
||||||
strcat(theString, line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool return_value = parseString(theString, line);
|
bool return_value = parseString(theString.c_str(), line);
|
||||||
|
|
||||||
if (!return_value) {
|
if (!return_value) {
|
||||||
snprintf(line2, 150, "Reading %s: %s", filename, line);
|
BaseString tmp;
|
||||||
setError(0,line2);
|
tmp.assfmt("Reading %s: %s", filename, line);
|
||||||
|
setError(0, tmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
free(theString);
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user