Commit 5d0a2b1a authored by Klemens Nanni's avatar Klemens Nanni Committed by Gargaj
Browse files

Fix C++ NULL shenanigans

The type definition of `sptr_t' depends on the compiler and C++ standard
being used, see external/scintilla/include/Scintilla.h and Scintilla's
upstream commit "Change definition of uptr_t and sptr_t to use
standardised types and headers"[0].

On OpenBSD 6.5/amd64, Clang 7.0.1 defaults to C++14,  thus `NULL' is
defined as `nullptr' so assigning it to `sptr_t' aka. `long' will fail.

Fix all callers (to the legacy Scintilla code) by using zero:

	/WndProc(/s,NULL,0,
	/glBindBuffer(/s,NULL,0,
	/glUseProgram(/s,NULL,0,

0: https://github.com/mirror/scintilla/commit/91bbc3c933d663b3bc9f4572cf1ed02d77922fde

Signed-off-by: default avatarGargaj <gargaj@conspiracy.hu>
parent 976346ae
......@@ -92,15 +92,15 @@ void ShaderEditor::Initialise()
lexState = new Scintilla::LexState( pdoc );
WndProc( SCI_SETBUFFEREDDRAW, NULL, NULL );
WndProc( SCI_SETCODEPAGE, SC_CP_UTF8, NULL );
WndProc( SCI_SETBUFFEREDDRAW, 0, 0 );
WndProc( SCI_SETCODEPAGE, SC_CP_UTF8, 0 );
WndProc( SCI_SETWRAPMODE, SC_WRAP_WORD, NULL );
WndProc( SCI_SETWRAPMODE, SC_WRAP_WORD, 0 );
//WndProc( SCI_SETLEXERLANGUAGE, SCLEX_CPP, NULL );
//WndProc( SCI_SETLEXERLANGUAGE, SCLEX_CPP, 0 );
SetAStyle( STYLE_DEFAULT, 0xFFFFFFFF, BACKGROUND( 0x000000 ), nFontSize, sFontFile.c_str() );
WndProc( SCI_STYLECLEARALL, NULL, NULL );
WndProc( SCI_STYLECLEARALL, 0, 0 );
SetAStyle( STYLE_LINENUMBER, 0xFFC0C0C0, BACKGROUND( 0x000000 ), nFontSize, sFontFile.c_str() );
SetAStyle( STYLE_BRACELIGHT, 0xFF00FF00, BACKGROUND( 0x000000 ), nFontSize, sFontFile.c_str() );
SetAStyle( STYLE_BRACEBAD, 0xFF0000FF, BACKGROUND( 0x000000 ), nFontSize, sFontFile.c_str() );
......@@ -118,16 +118,16 @@ void ShaderEditor::Initialise()
WndProc(SCI_MARKERSETBACK, markersArray[FOLDER_TYPE][i], 0xFF6A6A6A);
WndProc(SCI_MARKERSETFORE, markersArray[FOLDER_TYPE][i], 0xFF333333);
}
WndProc(SCI_SETUSETABS, bUseSpacesForTabs ? 0 : 1, NULL);
WndProc(SCI_SETTABWIDTH, nTabSize, NULL);
WndProc(SCI_SETINDENT, nTabSize, NULL);
WndProc(SCI_SETINDENTATIONGUIDES, SC_IV_REAL, NULL);
WndProc(SCI_SETUSETABS, bUseSpacesForTabs ? 0 : 1, 0);
WndProc(SCI_SETTABWIDTH, nTabSize, 0);
WndProc(SCI_SETINDENT, nTabSize, 0);
WndProc(SCI_SETINDENTATIONGUIDES, SC_IV_REAL, 0);
if (bVisibleWhitespace)
{
WndProc(SCI_SETVIEWWS, SCWS_VISIBLEALWAYS, NULL);
WndProc(SCI_SETVIEWWS, SCWS_VISIBLEALWAYS, 0);
WndProc(SCI_SETWHITESPACEFORE, 1, 0x30FFFFFF);
WndProc(SCI_SETWHITESPACESIZE, 2, NULL );
WndProc(SCI_SETWHITESPACESIZE, 2, 0 );
}
lexState->SetLexer( SCLEX_CPP );
......@@ -147,7 +147,7 @@ void ShaderEditor::Initialise()
lexState->Colourise( 0, -1 );
//WndProc( SCI_COLOURISE, NULL, NULL );
//WndProc( SCI_COLOURISE, 0, 0 );
vs.Refresh( *surfaceWindow, 4 );
}
......@@ -255,13 +255,13 @@ void ShaderEditor::Paint()
void ShaderEditor::SetText( const char * buf )
{
WndProc( SCI_SETREADONLY, false, NULL );
WndProc( SCI_CLEARALL, false, NULL );
WndProc( SCI_SETUNDOCOLLECTION, 0, NULL);
WndProc( SCI_SETREADONLY, false, 0 );
WndProc( SCI_CLEARALL, false, 0 );
WndProc( SCI_SETUNDOCOLLECTION, 0, 0);
WndProc( SCI_ADDTEXT, strlen(buf), (sptr_t)buf );
WndProc( SCI_SETUNDOCOLLECTION, 1, NULL);
WndProc( SCI_SETREADONLY, bReadOnly, NULL );
WndProc( SCI_GOTOPOS, 0, NULL );
WndProc( SCI_SETUNDOCOLLECTION, 1, 0);
WndProc( SCI_SETREADONLY, bReadOnly, 0 );
WndProc( SCI_GOTOPOS, 0, 0 );
if (!bReadOnly)
SetFocusState( true );
}
......@@ -290,7 +290,7 @@ void ShaderEditor::GetText( char * buf, int len )
{
memset( buf, 0, len );
int lengthDoc = (int)WndProc( SCI_GETLENGTH, NULL, NULL );
int lengthDoc = (int)WndProc( SCI_GETLENGTH, 0, 0 );
Scintilla::TextRange tr;
tr.chrg.cpMin = 0;
......@@ -315,13 +315,13 @@ void ShaderEditor::NotifyStyleToNeeded(int endStyleNeeded) {
void ShaderEditor::SetReadOnly( bool b )
{
bReadOnly = b;
WndProc( SCI_SETREADONLY, bReadOnly, NULL );
WndProc( SCI_SETREADONLY, bReadOnly, 0 );
if (bReadOnly)
{
WndProc(SCI_SETVIEWWS, SCWS_INVISIBLE, NULL);
WndProc(SCI_SETVIEWWS, SCWS_INVISIBLE, 0);
WndProc(SCI_SETMARGINWIDTHN, 0, 0);
WndProc(SCI_SETMARGINWIDTHN, 1, 0);
WndProc( SCI_SETCARETLINEVISIBLE, 0, NULL);
WndProc( SCI_SETCARETLINEVISIBLE, 0, 0);
WndProc( SCI_SETCARETFORE, 0, 0);
}
else
......@@ -331,9 +331,9 @@ void ShaderEditor::SetReadOnly( bool b )
WndProc(SCI_SETMARGINMASKN, 1, SC_MASK_FOLDERS);//Calculate correct width
WndProc( SCI_SETCARETFORE, 0xFFFFFFFF, 0);
WndProc( SCI_SETCARETLINEVISIBLE, 1, NULL);
WndProc( SCI_SETCARETLINEBACK, 0xFFFFFFFF, NULL);
WndProc( SCI_SETCARETLINEBACKALPHA, 0x20, NULL);
WndProc( SCI_SETCARETLINEVISIBLE, 1, 0);
WndProc( SCI_SETCARETLINEBACK, 0xFFFFFFFF, 0);
WndProc( SCI_SETCARETLINEBACKALPHA, 0x20, 0);
}
}
......@@ -391,26 +391,26 @@ void ShaderEditor::FineTickerCancel( TickReason )
// Indentation handling
int ShaderEditor::GetLineLength(int line) {
return WndProc(SCI_GETLINEENDPOSITION, line, NULL) - WndProc(SCI_POSITIONFROMLINE, line, NULL);
return WndProc(SCI_GETLINEENDPOSITION, line, 0) - WndProc(SCI_POSITIONFROMLINE, line, 0);
}
int ShaderEditor::GetCurrentLineNumber() {
return WndProc(SCI_LINEFROMPOSITION, WndProc(SCI_GETCURRENTPOS, NULL, NULL), NULL);
return WndProc(SCI_LINEFROMPOSITION, WndProc(SCI_GETCURRENTPOS, 0, 0), 0);
}
Sci_CharacterRange ShaderEditor::GetSelection() {
Sci_CharacterRange chrange;
chrange.cpMin = WndProc(SCI_GETSELECTIONSTART, NULL, NULL);
chrange.cpMax = WndProc(SCI_GETSELECTIONEND, NULL, NULL);
chrange.cpMin = WndProc(SCI_GETSELECTIONSTART, 0, 0);
chrange.cpMax = WndProc(SCI_GETSELECTIONEND, 0, 0);
return chrange;
}
int ShaderEditor::GetLineIndentation(int line) {
return WndProc(SCI_GETLINEINDENTATION, line, NULL);
return WndProc(SCI_GETLINEINDENTATION, line, 0);
}
int ShaderEditor::GetLineIndentPosition(int line) {
return WndProc(SCI_GETLINEINDENTPOSITION, line, NULL);
return WndProc(SCI_GETLINEINDENTPOSITION, line, 0);
}
void ShaderEditor::SetLineIndentation(int line, int indent) {
......@@ -450,7 +450,7 @@ void ShaderEditor::SetLineIndentation(int line, int indent) {
}
void ShaderEditor::PreserveIndentation(char ch) {
int eolMode = WndProc(SCI_GETEOLMODE, NULL, NULL);
int eolMode = WndProc(SCI_GETEOLMODE, 0, 0);
int curLine = GetCurrentLineNumber();
int lastLine = curLine - 1;
......@@ -471,11 +471,11 @@ void ShaderEditor::PreserveIndentation(char ch) {
std::vector<std::string> ShaderEditor::GetLinePartsInStyle(int line, int style) {
std::vector<std::string> out;
std::string s;
int thisLineStart = WndProc(SCI_POSITIONFROMLINE, line, NULL);
int nextLineStart = WndProc(SCI_POSITIONFROMLINE, line + 1, NULL);
int thisLineStart = WndProc(SCI_POSITIONFROMLINE, line, 0);
int nextLineStart = WndProc(SCI_POSITIONFROMLINE, line + 1, 0);
for (int pos = thisLineStart; pos < nextLineStart; pos++) {
if (static_cast<char>(WndProc(SCI_GETSTYLEAT, pos, 0)) == style) {
char c = WndProc(SCI_GETCHARAT, pos, NULL);
char c = WndProc(SCI_GETCHARAT, pos, 0);
// special handling for statements and blocks characters as they should be dissociated to other strings
if (c == statementEnd || c == blockStart || c == blockEnd) {
out.push_back(std::string(1, c));
......@@ -542,7 +542,7 @@ ShaderEditor::IndentationStatus ShaderEditor::GetIndentState(int line) {
int ShaderEditor::IndentOfBlock(int line) {
if (line < 0)
return 0;
int indentSize = WndProc(SCI_GETINDENT, NULL, NULL);
int indentSize = WndProc(SCI_GETINDENT, 0, 0);
int indentBlock = GetLineIndentation(line);
int backLine = line;
IndentationStatus indentState = isNone;
......@@ -572,7 +572,7 @@ int ShaderEditor::IndentOfBlock(int line) {
bool ShaderEditor::RangeIsAllWhitespace(int start, int end) {
for (int i = start; i < end; i++) {
if ((WndProc(SCI_GETCHARAT, i, NULL) != ' ') && (WndProc(SCI_GETCHARAT, i, NULL) != '\t'))
if ((WndProc(SCI_GETCHARAT, i, 0) != ' ') && (WndProc(SCI_GETCHARAT, i, 0) != '\t'))
return false;
}
return true;
......@@ -582,8 +582,8 @@ void ShaderEditor::AutomaticIndentation(char ch) {
Sci_CharacterRange crange = GetSelection();
int selStart = static_cast<int>(crange.cpMin);
int curLine = GetCurrentLineNumber();
int thisLineStart = WndProc(SCI_POSITIONFROMLINE, curLine, NULL);
int indentSize = WndProc(SCI_GETINDENT, NULL, NULL);
int thisLineStart = WndProc(SCI_POSITIONFROMLINE, curLine, 0);
int indentSize = WndProc(SCI_GETINDENT, 0, 0);
int indentBlock = IndentOfBlock(curLine - 1);
if (ch == blockEnd) {
......
......@@ -314,7 +314,7 @@ namespace Renderer
glGenBuffers( 1, &glhFullscreenQuadVB );
glBindBuffer( GL_ARRAY_BUFFER, glhFullscreenQuadVB );
glBufferData( GL_ARRAY_BUFFER, sizeof(float) * 5 * 4, pFullscreenQuadVertices, GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, NULL );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glGenVertexArrays(1, &glhFullscreenQuadVA);
......@@ -430,7 +430,7 @@ namespace Renderer
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo[1]);
glBufferData(GL_PIXEL_PACK_BUFFER, nWidth * nHeight * sizeof(unsigned int), NULL, GL_STREAM_READ);
//unbind buffers for now
glBindBuffer(GL_PIXEL_PACK_BUFFER, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glViewport(0, 0, nWidth, nHeight);
......@@ -620,7 +620,7 @@ namespace Renderer
if (position >= 0)
glDisableVertexAttribArray( position );
glUseProgram(NULL);
glUseProgram(0);
}
bool ReloadShader( const char * szShaderCode, int nShaderCodeSize, char * szErrorBuffer, int nErrorBufferSize )
......@@ -959,7 +959,7 @@ namespace Renderer
glDisableVertexAttribArray( color );
glDisableVertexAttribArray( position );
glUseProgram(NULL);
glUseProgram(0);
glDisable(GL_BLEND);
glDisable(GL_SCISSOR_TEST);
......@@ -988,7 +988,7 @@ namespace Renderer
}
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment