style: Convert leading spaces to tabs in GeneralsMD Libraries and Tools#2564
style: Convert leading spaces to tabs in GeneralsMD Libraries and Tools#2564bobtista wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| scripts/cpp/convert_leading_spaces_to_tabs.py | New reference script using tree-sitter-cpp for AST-guided space→tab conversion; included for transparency, not intended to be permanently merged per PR description. No GPL/copyright header consistent with other scripts in the directory. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp | Largest single-file change (96 lines): whitespace-only corrections throughout this display implementation. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | Whitespace-only: mixed space+tab indentation corrected to pure tabs in inline member functions and struct body. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Whitespace-only changes across this large DX8 rendering implementation file. |
| GeneralsMD/Code/Main/WinMain.cpp | Whitespace-only: leading spaces on WNDCLASS initialization and CreateWindow call corrected to tabs; multi-line continuation alignment preserved. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/shader.h | Whitespace-only: leading spaces before enum declarations corrected to tabs. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.h | Whitespace-only: stray leading spaces on comment dividers and virtual method declarations corrected to tabs. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read .cpp/.h file\ncp1252 encoding] --> B[Preprocess macros\nfor tree-sitter]
B --> C[Parse with\ntree-sitter-cpp]
C --> D{Too many\nparse errors?}
D -- yes --> E[Skip file]
D -- no --> F[For each line]
F --> G{Inside block\ncomment?}
G -- yes --> H[Keep as-is]
G -- no --> I{Blank / preprocessor\n/ already tabs?}
I -- yes --> H
I -- no --> J[Find AST node\nat first non-WS char]
J --> K{ERROR ancestor\nor continuation?}
K -- yes --> H
K -- no --> L[get_indent_depth\nbased on AST]
L --> M{depth==0 &\nspaces >= 4?}
M -- yes --> H
M -- no --> N[Replace leading WS\nwith N tabs]
N --> O[Write converted file]
Reviews (2): Last reviewed commit: "fix: Handle braceless control-flow body ..." | Re-trigger Greptile
Skyaero42
left a comment
There was a problem hiding this comment.
Picked out a few things that don't look right. They may appear multiple times in this PR.
|
|
||
| void checkForChangedTextData(); /**< called when we need to update our | ||
| render sentence and update extents */ | ||
| render sentence and update extents */ |
There was a problem hiding this comment.
I checked this on main, and I like it this way more. The goal is to remove leading spaces (convert to semantically the same indentation in tabs) only in this PR - I think aligning multiline things to previous line spots like open parens will be another PR.
|
|
||
| void setRenderObject( RenderObjClass *robj) {assert(m_robj==nullptr); m_robj=robj;} | ||
| void setRenderObjExtent ( Real extent) { m_robjExtent = extent; } | ||
| void setRenderObjExtent ( Real extent) { m_robjExtent = extent; } |
| if ( flagSpikes ) | ||
| { | ||
| if ( Debug_Statistics::Get_Draw_Calls()>2000 ) | ||
| fprintf( m_fp, " DRAWS OUT OF TOLERANCE(2000)\n" ); |
There was a problem hiding this comment.
What do you mean? It's preserving that weird string ...DRAWS OUT OF TOLERANCE(2000)\n" ); if you look at main, it's the same there. If we want to remove the leading spaces maybe do it in another PR?
There was a problem hiding this comment.
Shouldn't fprintf not have another indent because of the if-statement above it?
There was a problem hiding this comment.
Oh you mean the conditional without braces - can fix
| if ( ! isVisible ) | ||
| continue; | ||
| if ( ! isVisible ) | ||
| continue; |
There was a problem hiding this comment.
Yeah, I had to fix these conditionals without braces in another branch too, I'll do that now
| if ( ! TheInGameUI ) | ||
| return; | ||
| if ( ! TheInGameUI ) | ||
| return; |
Summary
git diff -wis empty)Access specifiers (
public:/private:/protected:) are placed at the classbrace level, matching the existing codebase convention.
Script
The formatting script is included in the PR for reference but is not intended
to be merged — it shows how the changes were generated.
See
scripts/cpp/convert_leading_spaces_to_tabs.pyfor details.Part 4 of 4 — GeneralsMD/Code/Libraries/ and GeneralsMD/Code/Tools/ (161 files).
See also: #2561, #2562, #2563.