mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
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:
parent
203653b9a1
commit
c03cb2c97a
1 changed files with 38 additions and 7 deletions
|
@ -643,15 +643,21 @@ bool FConfigFile::ReadConfig (void *file)
|
|||
{
|
||||
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
|
||||
endpt = start + strlen (start) - 1;
|
||||
while (endpt > start && *endpt <= ' ')
|
||||
{
|
||||
endpt--;
|
||||
}
|
||||
// Remove line feed '\n' character
|
||||
endpt[1] = 0;
|
||||
if (endpt <= start)
|
||||
continue; // Nothing here
|
||||
}
|
||||
|
||||
if (*start == '[')
|
||||
{ // Section header
|
||||
|
@ -687,6 +693,31 @@ bool FConfigFile::ReadConfig (void *file)
|
|||
{
|
||||
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
|
||||
{
|
||||
NewConfigEntry (section, start, whiteprobe);
|
||||
|
|
Loading…
Reference in a new issue