Remove inline comment support in multilingual INI parser
This commit is contained in:
parent
664c25bdac
commit
ae4368a3ca
|
@ -490,7 +490,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
||||||
Data.currentFile = file;
|
Data.currentFile = file;
|
||||||
|
|
||||||
unsigned int line, col;
|
unsigned int line, col;
|
||||||
bool result = textparsers->ParseFile_INI(file, static_cast<ITextListener_INI*>(this), &line, &col);
|
bool result = textparsers->ParseFile_INI(file, static_cast<ITextListener_INI*>(this), &line, &col, false);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
|
|
@ -778,7 +778,7 @@ failed:
|
||||||
* INI parser
|
* INI parser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listener, unsigned int *line, unsigned int *col)
|
bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listener, unsigned int *line, unsigned int *col, bool inline_comment)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(file, "rt");
|
FILE *fp = fopen(file, "rt");
|
||||||
unsigned int curline = 0;
|
unsigned int curline = 0;
|
||||||
|
@ -842,47 +842,50 @@ bool TextParsers::ParseFile_INI(const char *file, ITextListener_INI *ini_listene
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now search for comment characters */
|
if (inline_comment)
|
||||||
in_quote = false;
|
|
||||||
save_ptr = ptr;
|
|
||||||
for (size_t i = 0; i<len; i++, ptr++)
|
|
||||||
{
|
{
|
||||||
if (!in_quote)
|
/* Now search for comment characters */
|
||||||
|
in_quote = false;
|
||||||
|
save_ptr = ptr;
|
||||||
|
for (size_t i = 0; i<len; i++, ptr++)
|
||||||
{
|
{
|
||||||
switch (*ptr)
|
if (!in_quote)
|
||||||
{
|
{
|
||||||
case '"':
|
switch (*ptr)
|
||||||
{
|
{
|
||||||
in_quote = true;
|
case '"':
|
||||||
break;
|
{
|
||||||
}
|
in_quote = true;
|
||||||
case ';':
|
break;
|
||||||
{
|
}
|
||||||
/* Stop the loop */
|
case ';':
|
||||||
len = i;
|
{
|
||||||
|
/* Stop the loop */
|
||||||
|
len = i;
|
||||||
|
|
||||||
/* Terminate the string here */
|
/* Terminate the string here */
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (*ptr == '"')
|
||||||
|
{
|
||||||
|
in_quote = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!len)
|
||||||
{
|
{
|
||||||
if (*ptr == '"')
|
continue;
|
||||||
{
|
|
||||||
in_quote = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!len)
|
ptr = save_ptr;
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = save_ptr;
|
|
||||||
|
|
||||||
/* Lastly, strip ending whitespace off */
|
/* Lastly, strip ending whitespace off */
|
||||||
for (size_t i = len - 1; i<len; i--)
|
for (size_t i = len - 1; i<len; i--)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,8 @@ public:
|
||||||
bool ParseFile_INI(const char *file,
|
bool ParseFile_INI(const char *file,
|
||||||
ITextListener_INI *ini_listener,
|
ITextListener_INI *ini_listener,
|
||||||
unsigned int *line,
|
unsigned int *line,
|
||||||
unsigned int *col);
|
unsigned int *col,
|
||||||
|
bool inline_comment);
|
||||||
|
|
||||||
SMCError ParseFile_SMC(const char *file,
|
SMCError ParseFile_SMC(const char *file,
|
||||||
ITextListener_SMC *smc_listener,
|
ITextListener_SMC *smc_listener,
|
||||||
|
|
|
@ -351,12 +351,14 @@
|
||||||
* @param ini_listener Event handler for reading file.
|
* @param ini_listener Event handler for reading file.
|
||||||
* @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
|
* @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
|
||||||
* @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
|
* @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
|
||||||
|
* @param inline_comment Whether inline comment is allowed.
|
||||||
* @return True if parsing succeeded, false if file couldn't be opened or there was a syntax error.
|
* @return True if parsing succeeded, false if file couldn't be opened or there was a syntax error.
|
||||||
*/
|
*/
|
||||||
virtual bool ParseFile_INI(const char *file,
|
virtual bool ParseFile_INI(const char *file,
|
||||||
ITextListener_INI *ini_listener,
|
ITextListener_INI *ini_listener,
|
||||||
unsigned int *line,
|
unsigned int *line,
|
||||||
unsigned int *col) =0;
|
unsigned int *col,
|
||||||
|
bool inline_comment = true) =0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses an SMC-format text file.
|
* @brief Parses an SMC-format text file.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user