Commit eda5c319 authored by joreland@mysql.com's avatar joreland@mysql.com

bug#5617

allow blank lines in Ndb.cfg files
parent ee75c45d
...@@ -229,10 +229,10 @@ LocalConfig::parseString(const char * connectString, char *line){ ...@@ -229,10 +229,10 @@ 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;
FILE * file = fopen(filename, "r"); FILE * file = fopen(filename, "r");
if(file == 0){ if(file == 0){
snprintf(line, 150, "Unable to open local config file: %s", filename); snprintf(line, 150, "Unable to open local config file: %s", filename);
...@@ -241,31 +241,33 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError) ...@@ -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; while(fgets(line, 1024, file)){
BaseString tmp(line);
fgets(theString, sz, file); tmp.trim(" \t\n\r");
while (fgets(line+1, 100, file)) { if(tmp.length() > 0 && tmp.c_str()[0] != '#'){
line[0] = ';'; theString.append(tmp);
while (strlen(theString) + strlen(line) >= sz) { break;
sz = sz*2;
char *newString = (char*)NdbMem_Allocate(sz);
strcpy(newString, theString);
free(theString);
theString = newString;
} }
strcat(theString, line);
} }
while (fgets(line, 1024, file)) {
bool return_value = parseString(theString, line); BaseString tmp(line);
tmp.trim(" \t\n\r");
if(tmp.length() > 0 && tmp.c_str()[0] != '#'){
theString.append(";");
theString.append(tmp);
}
}
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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment