Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
3dd32293
Commit
3dd32293
authored
Jan 06, 2017
by
John Kessenich
Committed by
GitHub
Jan 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #661 from KhronosGroup/fix-include-error-paths
PP: #include: simplify the different paths out of #include.
parents
28d31335
1b1defd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
23 deletions
+28
-23
Pp.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
+28
-23
No files found.
glslang/MachineIndependent/preprocessor/Pp.cpp
View file @
3dd32293
...
...
@@ -593,37 +593,42 @@ int TPpContext::CPPinclude(TPpToken* ppToken)
// Make a copy of the name because it will be overwritten by the next token scan.
const
std
::
string
filename
=
ppToken
->
name
;
// See if the directive was well formed
token
=
scanToken
(
ppToken
);
if
(
token
!=
'\n'
)
{
if
(
token
==
EndOfInput
)
parseContext
.
ppError
(
ppToken
->
loc
,
"expected newline after header name:"
,
"#include"
,
"%s"
,
filename
.
c_str
());
else
parseContext
.
ppError
(
ppToken
->
loc
,
"extra content after header name:"
,
"#include"
,
"%s"
,
filename
.
c_str
());
}
else
{
TShader
::
Includer
::
IncludeResult
*
res
=
includer
.
include
(
filename
.
c_str
(),
includeType
,
currentSourceFile
.
c_str
(),
includeStack
.
size
()
+
1
);
if
(
res
&&
!
res
->
file_name
.
empty
())
{
if
(
res
->
file_data
&&
res
->
file_length
)
{
const
bool
forNextLine
=
parseContext
.
lineDirectiveShouldSetNextLine
();
std
::
ostringstream
prologue
;
std
::
ostringstream
epilogue
;
prologue
<<
"#line "
<<
forNextLine
<<
" "
<<
"
\"
"
<<
res
->
file_name
<<
"
\"\n
"
;
epilogue
<<
(
res
->
file_data
[
res
->
file_length
-
1
]
==
'\n'
?
""
:
"
\n
"
)
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
<<
directiveLoc
.
getStringNameOrNum
()
<<
"
\n
"
;
pushInput
(
new
TokenizableIncludeFile
(
directiveLoc
,
prologue
.
str
(),
res
,
epilogue
.
str
(),
this
));
}
// At EOF, there's no "current" location anymore.
if
(
token
!=
EndOfInput
)
parseContext
.
setCurrentColumn
(
0
);
// Don't accidentally return EndOfInput, which will end all preprocessing.
return
'\n'
;
return
token
;
}
// Process well-formed directive
TShader
::
Includer
::
IncludeResult
*
res
=
includer
.
include
(
filename
.
c_str
(),
includeType
,
currentSourceFile
.
c_str
(),
includeStack
.
size
()
+
1
);
if
(
res
&&
!
res
->
file_name
.
empty
())
{
if
(
res
->
file_data
&&
res
->
file_length
)
{
// path for processing one or more tokens from an included header, hand off 'res'
const
bool
forNextLine
=
parseContext
.
lineDirectiveShouldSetNextLine
();
std
::
ostringstream
prologue
;
std
::
ostringstream
epilogue
;
prologue
<<
"#line "
<<
forNextLine
<<
" "
<<
"
\"
"
<<
res
->
file_name
<<
"
\"\n
"
;
epilogue
<<
(
res
->
file_data
[
res
->
file_length
-
1
]
==
'\n'
?
""
:
"
\n
"
)
<<
"#line "
<<
directiveLoc
.
line
+
forNextLine
<<
" "
<<
directiveLoc
.
getStringNameOrNum
()
<<
"
\n
"
;
pushInput
(
new
TokenizableIncludeFile
(
directiveLoc
,
prologue
.
str
(),
res
,
epilogue
.
str
(),
this
));
parseContext
.
setCurrentColumn
(
0
);
}
else
{
std
::
string
message
=
res
?
std
::
string
(
res
->
file_data
,
res
->
file_length
)
:
std
::
string
(
"Could not process include directive"
);
parseContext
.
ppError
(
directiveLoc
,
message
.
c_str
(),
"#include"
,
"for header name: %s"
,
filename
.
c_str
());
if
(
res
)
{
includer
.
releaseInclude
(
res
);
}
// things are okay, but there is nothing to process
includer
.
releaseInclude
(
res
);
}
}
else
{
// error path, clean up
std
::
string
message
=
res
?
std
::
string
(
res
->
file_data
,
res
->
file_length
)
:
std
::
string
(
"Could not process include directive"
);
parseContext
.
ppError
(
directiveLoc
,
message
.
c_str
(),
"#include"
,
"for header name: %s"
,
filename
.
c_str
());
includer
.
releaseInclude
(
res
);
}
return
token
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment