my own uncrustify run

This commit is contained in:
Rudolf Polzer
2012-03-27 12:03:21 +02:00
parent 203343b01a
commit e4287c28bb
1056 changed files with 194610 additions and 205971 deletions

View File

@@ -1,73 +1,73 @@
/*
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
BobToolz plugin for GtkRadiant
Copyright (C) 2001 Gordon Biggans
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ScriptParser.h"
#include <string.h>
CScriptParser::CScriptParser(void):
m_pScript(NULL),
m_pScriptSection(NULL),
m_pLastScriptSection(NULL),
m_pToken(NULL) {
CScriptParser::CScriptParser( void ) :
m_pScript( NULL ),
m_pScriptSection( NULL ),
m_pLastScriptSection( NULL ),
m_pToken( NULL ) {
ClearBuffer();
}
CScriptParser::~CScriptParser(void) {
CScriptParser::~CScriptParser( void ) {
ClearBuffer();
}
void CScriptParser::ClearBuffer(void) {
if(m_pScript) {
void CScriptParser::ClearBuffer( void ) {
if ( m_pScript ) {
delete[] m_pScript;
m_pScript = NULL;
}
if(m_pToken) {
if ( m_pToken ) {
delete[] m_pToken;
m_pToken = NULL;
}
m_pScriptSection = NULL;
m_pLastScriptSection = NULL;
memset(m_breakChars, 0, sizeof(m_breakChars));
memset( m_breakChars, 0, sizeof( m_breakChars ) );
}
const char* CScriptParser::MakeToken(const char* pToken) {
if(m_pToken) {
const char* CScriptParser::MakeToken( const char* pToken ) {
if ( m_pToken ) {
delete[] m_pToken;
m_pToken = NULL;
}
if(!pToken) {
if ( !pToken ) {
pToken = "";
}
int len = static_cast<int>(strlen(pToken));
int len = static_cast<int>( strlen( pToken ) );
m_pToken = new char[len + 1];
m_pToken[len] = '\0';
strcpy(m_pToken, pToken);
strcpy( m_pToken, pToken );
return m_pToken;
}
#define MAX_TOKEN_STRING 1024
// Should NEVER return NULL
const char* CScriptParser::GetToken(bool bAllowLinebreaks) {
const char* CScriptParser::GetToken( bool bAllowLinebreaks ) {
int c = 0, len;
char token[MAX_TOKEN_STRING];
bool bNewLines = false;
@@ -77,27 +77,28 @@ const char* CScriptParser::GetToken(bool bAllowLinebreaks) {
len = 0;
*token = '\0';
if(!m_pScript || !m_pScriptSection) {
return MakeToken(token);
if ( !m_pScript || !m_pScriptSection ) {
return MakeToken( token );
}
while ( true ) {
SkipWhitespace( &bNewLines );
if ( !*m_pScriptSection ) {
return MakeToken(token);
return MakeToken( token );
}
if ( bNewLines && !bAllowLinebreaks ) {
return MakeToken(token);
return MakeToken( token );
}
c = *m_pScriptSection;
if ( c == '/' && m_pScriptSection[1] == '/' ) { // C style comments
m_pScriptSection += 2;
while (*m_pScriptSection && *m_pScriptSection != '\n') {
while ( *m_pScriptSection && *m_pScriptSection != '\n' ) {
m_pScriptSection++;
}
} else if ( c=='/' && m_pScriptSection[1] == '*' ) { // C++ style comments
}
else if ( c == '/' && m_pScriptSection[1] == '*' ) { // C++ style comments
m_pScriptSection += 2;
while ( *m_pScriptSection && ( *m_pScriptSection != '*' || m_pScriptSection[1] != '/' ) ) {
m_pScriptSection++;
@@ -105,20 +106,21 @@ const char* CScriptParser::GetToken(bool bAllowLinebreaks) {
if ( *m_pScriptSection ) {
m_pScriptSection += 2;
}
} else {
}
else {
break;
}
}
if (c == '\"') {
if ( c == '\"' ) {
m_pScriptSection++;
while ( true ) {
c = *m_pScriptSection++;
if (c=='\"' || !c) {
if ( c == '\"' || !c ) {
token[len] = 0;
return MakeToken(token);
return MakeToken( token );
}
if (len < MAX_TOKEN_STRING) {
if ( len < MAX_TOKEN_STRING ) {
token[len] = c;
len++;
}
@@ -126,72 +128,73 @@ const char* CScriptParser::GetToken(bool bAllowLinebreaks) {
}
do {
if(len > 0 && IsBreakChar(*m_pScriptSection)) {
if ( len > 0 && IsBreakChar( *m_pScriptSection ) ) {
break;
}
if (len < MAX_TOKEN_STRING) {
if ( len < MAX_TOKEN_STRING ) {
token[len] = c;
len++;
}
m_pScriptSection++;
if(IsBreakChar(c)) {
if ( IsBreakChar( c ) ) {
break;
}
c = *m_pScriptSection;
} while (c > 32);
} while ( c > 32 );
if (len == MAX_TOKEN_STRING) {
if ( len == MAX_TOKEN_STRING ) {
len = 0;
}
token[len] = 0;
return MakeToken(token);
return MakeToken( token );
}
void CScriptParser::SkipWhitespace(bool* pbNewLines) {
void CScriptParser::SkipWhitespace( bool* pbNewLines ) {
int c;
if(!m_pScript || !m_pScriptSection) {
if ( !m_pScript || !m_pScriptSection ) {
return;
}
while( (c = *m_pScriptSection) <= ' ') {
if( !c ) {
while ( ( c = *m_pScriptSection ) <= ' ' ) {
if ( !c ) {
return;
}
if( c == '\n' ) {
if ( c == '\n' ) {
*pbNewLines = true;
}
m_pScriptSection++;
}
}
void CScriptParser::SkipBracedSection(void) {
const char *token;
int depth;
void CScriptParser::SkipBracedSection( void ) {
const char *token;
int depth;
depth = 0;
do {
token = GetToken( true );
if( token[1] == 0 ) {
if( *token == '{' ) {
if ( token[1] == 0 ) {
if ( *token == '{' ) {
depth++;
} else if( *token == '}' ) {
}
else if ( *token == '}' ) {
depth--;
}
}
} while( depth && *m_pScriptSection );
} while ( depth && *m_pScriptSection );
}
void CScriptParser::SkipRestOfLine(void) {
char *p;
int c;
void CScriptParser::SkipRestOfLine( void ) {
char *p;
int c;
p = m_pScriptSection;
while ( (c = *p++) != 0 ) {
while ( ( c = *p++ ) != 0 ) {
if ( c == '\n' ) {
break;
}
@@ -199,16 +202,16 @@ void CScriptParser::SkipRestOfLine(void) {
m_pScriptSection = p;
}
void CScriptParser::UndoGetToken(void) {
if(!m_pLastScriptSection) {
void CScriptParser::UndoGetToken( void ) {
if ( !m_pLastScriptSection ) {
return;
}
m_pScriptSection = m_pLastScriptSection;
m_pLastScriptSection = NULL;
}
void CScriptParser::ResetParseSession(void) {
if(!m_pScript) {
void CScriptParser::ResetParseSession( void ) {
if ( !m_pScript ) {
return;
}
@@ -216,43 +219,43 @@ void CScriptParser::ResetParseSession(void) {
m_pLastScriptSection = NULL;
}
char* CScriptParser::GetBufferCopy(void) {
if(!m_pScript) {
char* CScriptParser::GetBufferCopy( void ) {
if ( !m_pScript ) {
return NULL;
}
int len = static_cast<int>(strlen(m_pScript));
int len = static_cast<int>( strlen( m_pScript ) );
char* pBuffer = new char[len + 1];
strcpy(pBuffer, m_pScript);
strcpy( pBuffer, m_pScript );
return pBuffer;
}
int CScriptParser::GetTokenOffset(void) {
if(!m_pScript || !m_pScriptSection) {
int CScriptParser::GetTokenOffset( void ) {
if ( !m_pScript || !m_pScriptSection ) {
return 0;
}
return static_cast<int>(m_pScriptSection - m_pScript);
return static_cast<int>( m_pScriptSection - m_pScript );
}
void CScriptParser::LoadScript(const char* pScript) {
void CScriptParser::LoadScript( const char* pScript ) {
ClearBuffer();
int len = static_cast<int>(strlen(pScript));
if(len <= 0) {
int len = static_cast<int>( strlen( pScript ) );
if ( len <= 0 ) {
return;
}
m_pScript = new char[len + 1];
m_pScript[len] = '\0';
strcpy(m_pScript, pScript);
strcpy( m_pScript, pScript );
m_pScriptSection = m_pScript;
}
void CScriptParser::AddBreakChar(char c) {
for(int i = 0; i < SP_MAX_BREAKCHARS; i++) {
if(!m_breakChars[i]) {
void CScriptParser::AddBreakChar( char c ) {
for ( int i = 0; i < SP_MAX_BREAKCHARS; i++ ) {
if ( !m_breakChars[i] ) {
m_breakChars[i] = c;
return;
}
@@ -261,23 +264,23 @@ void CScriptParser::AddBreakChar(char c) {
// TODO: Error: max break chars hit
}
bool CScriptParser::IsBreakChar(char c) {
for(int i = 0; i < SP_MAX_BREAKCHARS; i++) {
if(!m_breakChars[i]) {
bool CScriptParser::IsBreakChar( char c ) {
for ( int i = 0; i < SP_MAX_BREAKCHARS; i++ ) {
if ( !m_breakChars[i] ) {
return false;
}
if(m_breakChars[i] == c) {
if ( m_breakChars[i] == c ) {
return true;
}
}
return false;
}
void CScriptParser::SetScript(char* pScript) {
void CScriptParser::SetScript( char* pScript ) {
ClearBuffer();
int len = static_cast<int>(strlen(pScript));
if(len <= 0) {
int len = static_cast<int>( strlen( pScript ) );
if ( len <= 0 ) {
return;
}