GNOME Bugzilla – Bug 596429
GScanner ignores skip_comment_multi if "/" is allowed in identifiers.
Last modified: 2018-05-24 11:58:56 UTC
The code in http://git.debian.org/?p=users/jak/apt2.git includes a GScanner based parser for APT configuration files. I set the option skip_comment_multi to true and set cset_identifier_nth and cset_identifier_first to a_2_z + A_2_Z + DIGITS + "/-:._+". If I now parse a file, with a comment like /* alpha */, '/' would be treated as an identifier and '*' as a character; although it should completely ignore the comment.
Could you attach a small sample to reproduce this problem? This makes it much easier to fix
Created attachment 144176 [details] Test case This attachment contains a test code written in Vala which reproduces the bug. Unsetting the identifier settings would cause no errors, with identifiers set it causes an error.
Any update here? The solution would be to read a second character if a '/' was read and if the second character is a '*', treat is as a comment.
The cause of all this is: /* this is *evil*, but needed ;( * we first check for identifier first character, because it * might interfere with other key chars like slashes or numbers */ if (config->scan_identifier && ch && strchr (config->cset_identifier_first, ch)) The following check checks whether the character actually starts a comment: if (config->scan_identifier && ch && strchr (config->cset_identifier_first, ch)) if (!(config->scan_comment_multi && ch = '/' && g_scanner_peek_next_char (scanner) == '*')) Adding this should fix the bug.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/242.