Revert "(glslang) Cleanups"

This reverts commit bdff6a146baacf6a21088c16909d334b08dd6036.
This commit is contained in:
libretroadmin 2024-06-15 06:20:19 +02:00
parent 66ed1bd095
commit 7a9679c7fd
3 changed files with 17 additions and 5 deletions

View File

@ -1173,7 +1173,7 @@ int TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, bool newLineOka
case PpAtomLineMacro:
ppToken->ival = _parseContext.getCurrentLoc().line;
snprintf(ppToken->name, sizeof(ppToken->name), "%d", ppToken->ival);
pushInput(new tUngotTokenInput(this, PpAtomConstInt, ppToken));
UngetToken(PpAtomConstInt, ppToken);
return 1;
case PpAtomFileMacro: {
@ -1181,14 +1181,14 @@ int TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, bool newLineOka
_parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based __FILE__");
ppToken->ival = _parseContext.getCurrentLoc().string;
strlcpy(ppToken->name, ppToken->loc.getStringNameOrNum().c_str(), sizeof(ppToken->name));
pushInput(new tUngotTokenInput(this, PpAtomConstInt, ppToken));
UngetToken(PpAtomConstInt, ppToken);
return 1;
}
case PpAtomVersionMacro:
ppToken->ival = _parseContext.version;
snprintf(ppToken->name, sizeof(ppToken->name), "%d", ppToken->ival);
pushInput(new tUngotTokenInput(this, PpAtomConstInt, ppToken));
UngetToken(PpAtomConstInt, ppToken);
return 1;
default:
@ -1223,7 +1223,7 @@ int TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, bool newLineOka
token = scanToken(ppToken);
}
if (token != '(') {
pushInput(new tUngotTokenInput(this, token, ppToken));
UngetToken(token, ppToken);
delete in;
return 0;
}

View File

@ -406,6 +406,7 @@ protected:
// From PpTokens.cpp
//
void pushTokenStreamInput(TokenStream&, bool pasting = false);
void UngetToken(int token, TPpToken*);
class tTokenInput : public tInput {
public:

View File

@ -83,6 +83,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
#ifndef snprintf
#define snprintf sprintf_s
#endif
#endif
#include <cstdlib>
#include <cstring>
@ -158,7 +163,8 @@ int TPpContext::TokenStream::getSubtoken()
{
if (current < data.size())
return data[current++];
return EndOfInput;
else
return EndOfInput;
}
// back up one position in the stream
@ -341,4 +347,9 @@ int TPpContext::tUngotTokenInput::scan(TPpToken* ppToken)
return ret;
}
void TPpContext::UngetToken(int token, TPpToken* ppToken)
{
pushInput(new tUngotTokenInput(this, token, ppToken));
}
} // end namespace glslang