Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meson: handle backshash chars in strings and == operator correctly #4104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Units/parser-meson.r/escape-in-string.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--fields=+r
-G
6 changes: 6 additions & 0 deletions Units/parser-meson.r/escape-in-string.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
v input.meson /^ v = get_option(tuple[0])$/;" V roles:def
v input.meson /^ v = run_command($/;" V roles:def
v input.meson /^ v = tuple[2]$/;" V roles:def
v input.meson /^ v = v.to_int()$/;" V roles:def
dynamic_uid_min input.meson /^dynamic_uid_min = get_option('dynamic-uid-min')$/;" V roles:def
v_eof input.meson /^v_eof=$/;" V roles:def
31 changes: 31 additions & 0 deletions Units/parser-meson.r/escape-in-string.d/input.meson
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- Meson -*-
# Partially taken from meson.build in the source tree of systemd.
#
foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1], # Also see login.defs(5).
['system-uid-max', 'SYS_UID_MAX', 999],
['system-alloc-gid-min', 'SYS_GID_MIN', 1],
['system-gid-max', 'SYS_GID_MAX', 999]]
v = get_option(tuple[0])
if v <= 0
v = run_command(
awk,
'/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
'/etc/login.defs',
check : false).stdout().strip()
if v == ''
v = tuple[2]
else
v = v.to_int()
endif
endif
conf.set(tuple[0].underscorify().to_upper(), v)
endforeach
if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
error('Invalid uid allocation range')
endif
if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
error('Invalid gid allocation range')
endif

dynamic_uid_min = get_option('dynamic-uid-min')
v_eof=
11 changes: 7 additions & 4 deletions optlib/meson.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"^test[ \t\n]*\\([ \t\n]*'([^']*[^\\\\])'[ \t\n]*",
"\\1", "t", "{tenter=skipToArgEnd}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^([a-zA-Z_][a-zA-Z_0-9]*)[ \t\n]*=[ \t\n]*",
"\\1", "V", "", NULL);
"^([a-zA-Z_][a-zA-Z_0-9]*)[ \t\n]*=([^=]|$)",
"\\1", "V", "{_advanceTo=2start}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^.",
"", "", "", NULL);
Expand All @@ -74,14 +74,17 @@
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "string",
"^\\\\'",
"^[^\\\\']+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "string",
"^[^\\\\']+",
"^\\\\.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "string",
"^'",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "string",

Check warning on line 85 in optlib/meson.c

View check run for this annotation

Codecov / codecov/patch

optlib/meson.c#L85

Added line #L85 was not covered by tests
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "comment",
"^[^\n]+",
"", "", "", NULL);
Expand Down
5 changes: 3 additions & 2 deletions optlib/meson.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@
--_mtable-regex-Meson=comment/[^\n]+//
--_mtable-regex-Meson=comment/\n//{tleave}

--_mtable-regex-Meson=string/\\'//
--_mtable-regex-Meson=string/[^\\']+//
--_mtable-regex-Meson=string/\\.//
--_mtable-regex-Meson=string/'//{tleave}
--_mtable-regex-Meson=string/.//

--_mtable-regex-Meson=mline_string/'''//{tleave}
--_mtable-regex-Meson=mline_string/[^']+//
Expand All @@ -79,5 +80,5 @@
--_mtable-regex-Meson=main/project[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/P/{tenter=skipToArgEnd}
--_mtable-regex-Meson=main/subdir[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/S/{tenter=skipToArgEnd}
--_mtable-regex-Meson=main/test[ \t\n]*\([ \t\n]*'([^']*[^\\])'[ \t\n]*/\1/t/{tenter=skipToArgEnd}
--_mtable-regex-Meson=main/([a-zA-Z_][a-zA-Z_0-9]*)[ \t\n]*=[ \t\n]*/\1/V/
--_mtable-regex-Meson=main/([a-zA-Z_][a-zA-Z_0-9]*)[ \t\n]*=([^=]|$)/\1/V/{_advanceTo=2start}
--_mtable-regex-Meson=main/.//
Loading