Added support for long lines in config file

Single line key-value pair can now exceed 255 characters
Long path names and additional command line parameters (macOS only) are no longer cut off
This commit is contained in:
alexey.lysiuk 2016-12-28 12:03:17 +02:00 committed by Christoph Oelckers
parent 203653b9a1
commit c03cb2c97a
1 changed files with 38 additions and 7 deletions

View File

@ -643,15 +643,21 @@ bool FConfigFile::ReadConfig (void *file)
{ {
continue; continue;
} }
// Do not process tail of long line
const bool longline = 255 == strlen(readbuf) && '\n' != readbuf[254];
if (!longline)
{
// Remove white space at end of line // Remove white space at end of line
endpt = start + strlen (start) - 1; endpt = start + strlen (start) - 1;
while (endpt > start && *endpt <= ' ') while (endpt > start && *endpt <= ' ')
{ {
endpt--; endpt--;
} }
// Remove line feed '\n' character
endpt[1] = 0; endpt[1] = 0;
if (endpt <= start) if (endpt <= start)
continue; // Nothing here continue; // Nothing here
}
if (*start == '[') if (*start == '[')
{ // Section header { // Section header
@ -687,6 +693,31 @@ bool FConfigFile::ReadConfig (void *file)
{ {
ReadMultiLineValue (file, section, start, whiteprobe + 3); ReadMultiLineValue (file, section, start, whiteprobe + 3);
} }
else if (longline)
{
const FString key = start;
FString value = whiteprobe;
while (ReadLine (readbuf, READBUFFERSIZE, file) != NULL)
{
const size_t endpos = (0 == readbuf[0]) ? 0 : (strlen(readbuf) - 1);
const bool endofline = '\n' == readbuf[endpos];
if (endofline)
{
readbuf[endpos] = 0;
}
value += readbuf;
if (endofline)
{
break;
}
}
NewConfigEntry (section, key.GetChars(), value.GetChars());
}
else else
{ {
NewConfigEntry (section, start, whiteprobe); NewConfigEntry (section, start, whiteprobe);