Reformat the code, using:

find -type f |  # list all regular files
  grep -E '\.(h|cpp|mm)$' |  # filter for source files
  grep -v '/mt_' |  # filter out generated files
  grep -v '/vendor/' | # and vendored GL
  grep -v '/test/image_loader_test.cpp' |  # and this file (has giant literals arrays)
  xargs -n 1 -P $(nproc) clang-format -i  # reformat everything

Co-authored-by: numzero <numzer0@yandex.ru>
This commit is contained in:
Desour
2024-03-20 19:35:52 +01:00
committed by sfan5
parent 9814510b1b
commit f5c6d3e945
292 changed files with 37376 additions and 42421 deletions

View File

@ -19,62 +19,61 @@ namespace core
// ----------- some basic quite often used string functions -----------------
//! search if a filename has a proper extension
inline s32 isFileExtension (const io::path& filename, const io::path& ext0,
const io::path& ext1, const io::path& ext2)
inline s32 isFileExtension(const io::path &filename, const io::path &ext0,
const io::path &ext1, const io::path &ext2)
{
s32 extPos = filename.findLast ( '.' );
if ( extPos < 0 )
s32 extPos = filename.findLast('.');
if (extPos < 0)
return 0;
extPos += 1;
if ( filename.equals_substring_ignore_case ( ext0, extPos ) )
if (filename.equals_substring_ignore_case(ext0, extPos))
return 1;
if ( filename.equals_substring_ignore_case ( ext1, extPos ) )
if (filename.equals_substring_ignore_case(ext1, extPos))
return 2;
if ( filename.equals_substring_ignore_case ( ext2, extPos ) )
if (filename.equals_substring_ignore_case(ext2, extPos))
return 3;
return 0;
}
//! search if a filename has a proper extension
inline bool hasFileExtension(const io::path& filename, const io::path& ext0,
const io::path& ext1 = "", const io::path& ext2 = "")
inline bool hasFileExtension(const io::path &filename, const io::path &ext0,
const io::path &ext1 = "", const io::path &ext2 = "")
{
return isFileExtension ( filename, ext0, ext1, ext2 ) > 0;
return isFileExtension(filename, ext0, ext1, ext2) > 0;
}
//! cut the filename extension from a source file path and store it in a dest file path
inline io::path& cutFilenameExtension ( io::path &dest, const io::path &source )
inline io::path &cutFilenameExtension(io::path &dest, const io::path &source)
{
s32 endPos = source.findLast ( '.' );
dest = source.subString ( 0, endPos < 0 ? source.size () : endPos );
s32 endPos = source.findLast('.');
dest = source.subString(0, endPos < 0 ? source.size() : endPos);
return dest;
}
//! get the filename extension from a file path
inline io::path& getFileNameExtension ( io::path &dest, const io::path &source )
inline io::path &getFileNameExtension(io::path &dest, const io::path &source)
{
s32 endPos = source.findLast ( '.' );
if ( endPos < 0 )
s32 endPos = source.findLast('.');
if (endPos < 0)
dest = "";
else
dest = source.subString ( endPos, source.size () );
dest = source.subString(endPos, source.size());
return dest;
}
//! delete path from filename
inline io::path& deletePathFromFilename(io::path& filename)
inline io::path &deletePathFromFilename(io::path &filename)
{
// delete path from filename
const fschar_t* s = filename.c_str();
const fschar_t* p = s + filename.size();
const fschar_t *s = filename.c_str();
const fschar_t *p = s + filename.size();
// search for path separator or beginning
while ( *p != '/' && *p != '\\' && p != s )
while (*p != '/' && *p != '\\' && p != s)
p--;
if ( p != s )
{
if (p != s) {
++p;
filename = p;
}
@ -82,51 +81,45 @@ inline io::path& deletePathFromFilename(io::path& filename)
}
//! trim paths
inline io::path& deletePathFromPath(io::path& filename, s32 pathCount)
inline io::path &deletePathFromPath(io::path &filename, s32 pathCount)
{
// delete path from filename
s32 i = filename.size();
// search for path separator or beginning
while ( i>=0 )
{
if ( filename[i] == '/' || filename[i] == '\\' )
{
if ( --pathCount <= 0 )
while (i >= 0) {
if (filename[i] == '/' || filename[i] == '\\') {
if (--pathCount <= 0)
break;
}
--i;
}
if ( i>0 )
{
filename [ i + 1 ] = 0;
if (i > 0) {
filename[i + 1] = 0;
filename.validate();
}
else
filename="";
} else
filename = "";
return filename;
}
//! looks if file is in the same directory of path. returns offset of directory.
//! 0 means in same directory. 1 means file is direct child of path
inline s32 isInSameDirectory ( const io::path& path, const io::path& file )
inline s32 isInSameDirectory(const io::path &path, const io::path &file)
{
if ( path.size() && !path.equalsn ( file, path.size() ) )
if (path.size() && !path.equalsn(file, path.size()))
return -1;
s32 subA = 0;
s32 subB = 0;
s32 pos = 0;
while ( (pos = path.findNext ( '/', pos )) >= 0 )
{
while ((pos = path.findNext('/', pos)) >= 0) {
subA += 1;
pos += 1;
}
pos = 0;
while ( (pos = file.findNext ( '/', pos )) >= 0 )
{
while ((pos = file.findNext('/', pos)) >= 0) {
subB += 1;
pos += 1;
}
@ -135,55 +128,47 @@ inline s32 isInSameDirectory ( const io::path& path, const io::path& file )
}
//! splits a path into components
static inline void splitFilename(const io::path &name, io::path* path=0,
io::path* filename=0, io::path* extension=0, bool make_lower=false)
static inline void splitFilename(const io::path &name, io::path *path = 0,
io::path *filename = 0, io::path *extension = 0, bool make_lower = false)
{
s32 i = name.size();
s32 extpos = i;
// search for path separator or beginning
while ( i >= 0 )
{
if ( name[i] == '.' )
{
while (i >= 0) {
if (name[i] == '.') {
extpos = i;
if ( extension )
*extension = name.subString ( extpos + 1, name.size() - (extpos + 1), make_lower );
}
else
if ( name[i] == '/' || name[i] == '\\' )
{
if ( filename )
*filename = name.subString ( i + 1, extpos - (i + 1), make_lower );
if ( path )
{
*path = name.subString ( 0, i + 1, make_lower );
path->replace ( '\\', '/' );
if (extension)
*extension = name.subString(extpos + 1, name.size() - (extpos + 1), make_lower);
} else if (name[i] == '/' || name[i] == '\\') {
if (filename)
*filename = name.subString(i + 1, extpos - (i + 1), make_lower);
if (path) {
*path = name.subString(0, i + 1, make_lower);
path->replace('\\', '/');
}
return;
}
i -= 1;
}
if ( filename )
*filename = name.subString ( 0, extpos, make_lower );
if (filename)
*filename = name.subString(0, extpos, make_lower);
}
//! create a filename from components
static inline io::path mergeFilename(const io::path& path, const io::path& filename, const io::path& extension = "")
static inline io::path mergeFilename(const io::path &path, const io::path &filename, const io::path &extension = "")
{
io::path result(path);
if ( !result.empty() )
{
if (!result.empty()) {
fschar_t last = result.lastChar();
if ( last != _IRR_TEXT('/') && last != _IRR_TEXT('\\') )
if (last != _IRR_TEXT('/') && last != _IRR_TEXT('\\'))
result += _IRR_TEXT('/');
}
if ( !filename.empty() )
if (!filename.empty())
result += filename;
if ( !extension.empty() )
{
if ( !result.empty() && extension[0] != _IRR_TEXT('.') )
if (!extension.empty()) {
if (!result.empty() && extension[0] != _IRR_TEXT('.'))
result += _IRR_TEXT('.');
result += extension;
}
@ -191,13 +176,19 @@ static inline io::path mergeFilename(const io::path& path, const io::path& filen
return result;
}
//! some standard function ( to remove dependencies )
inline bool isdigit(s32 c) { return c >= '0' && c <= '9'; }
inline bool isspace(s32 c) { return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; }
inline bool isupper(s32 c) { return c >= 'A' && c <= 'Z'; }
inline bool isdigit(s32 c)
{
return c >= '0' && c <= '9';
}
inline bool isspace(s32 c)
{
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
}
inline bool isupper(s32 c)
{
return c >= 'A' && c <= 'Z';
}
} // end namespace core
} // end namespace irr