Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pablo Winant
preprocessor
Commits
e13e5a32
Verified
Commit
e13e5a32
authored
5 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
macro processor: simplify handling of `@#define`
(cherry picked from commit
148aa9d9
)
parent
e137b2df
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/macro/Driver.cc
+1
-24
1 addition, 24 deletions
src/macro/Driver.cc
with
1 addition
and
24 deletions
src/macro/Driver.cc
+
1
−
24
View file @
e13e5a32
...
@@ -34,30 +34,7 @@ Driver::parse(const string &file_arg, const string &basename_arg, istream &modfi
...
@@ -34,30 +34,7 @@ Driver::parse(const string &file_arg, const string &basename_arg, istream &modfi
{
{
stringstream
command_line_defines_with_endl
;
stringstream
command_line_defines_with_endl
;
for
(
const
auto
&
[
var
,
val
]
:
defines
)
for
(
const
auto
&
[
var
,
val
]
:
defines
)
try
command_line_defines_with_endl
<<
"@#define "
<<
var
<<
" = "
<<
val
<<
endl
;
{
string
::
size_type
pos
;
stod
(
val
,
&
pos
);
if
(
pos
==
val
.
size
())
command_line_defines_with_endl
<<
"@#define "
<<
var
<<
" = "
<<
val
<<
endl
;
else
{
// The following regex matches the range syntax: double:double(:double)?
regex
colon_separated_doubles
(
R"(((((\d*\.\d+)|(\d+\.))([ed][-+]?\d+)?)|(\d+([ed][-+]?\d+)?)):((((\d*\.\d+)|(\d+\.))([ed][-+]?\d+)?)|(\d+([ed][-+]?\d+)?))(:((((\d*\.\d+)|(\d+\.))([ed][-+]?\d+)?)|(\d+([ed][-+]?\d+)?)))?)"
);
if
(
regex_match
(
val
,
colon_separated_doubles
))
command_line_defines_with_endl
<<
"@#define "
<<
var
<<
" = "
<<
val
<<
endl
;
else
command_line_defines_with_endl
<<
"@#define "
<<
var
<<
R"( = ")"
<<
val
<<
R"(")"
<<
endl
;
}
}
catch
(
const
invalid_argument
&
)
{
if
(
!
val
.
empty
()
&&
val
.
at
(
0
)
==
'['
&&
val
.
at
(
val
.
length
()
-
1
)
==
']'
)
// If the input is an array. Issue #1578
command_line_defines_with_endl
<<
"@#define "
<<
var
<<
" = "
<<
val
<<
endl
;
else
command_line_defines_with_endl
<<
"@#define "
<<
var
<<
R"( = ")"
<<
val
<<
R"(")"
<<
endl
;
}
Driver
m
(
env
,
true
);
Driver
m
(
env
,
true
);
istream
is
(
command_line_defines_with_endl
.
rdbuf
());
istream
is
(
command_line_defines_with_endl
.
rdbuf
());
m
.
parse
(
"command_line_defines"
,
"command_line_defines"
,
is
,
output
,
debug
,
vector
<
pair
<
string
,
string
>>
{},
paths
);
m
.
parse
(
"command_line_defines"
,
"command_line_defines"
,
is
,
output
,
debug
,
vector
<
pair
<
string
,
string
>>
{},
paths
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment