Skip to content

style: Convert leading spaces to tabs in GeneralsMD Libraries and Tools#2564

Open
bobtista wants to merge 6 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/feat/access-spec-indent-generalsmd-rest
Open

style: Convert leading spaces to tabs in GeneralsMD Libraries and Tools#2564
bobtista wants to merge 6 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/feat/access-spec-indent-generalsmd-rest

Conversation

@bobtista
Copy link
Copy Markdown

@bobtista bobtista commented Apr 9, 2026

Summary

  • Convert leading spaces/mixed whitespace to tabs, including access specifier indentation
  • All changes are whitespace-only (git diff -w is empty)
  • Uses tree-sitter-cpp for accurate C++ parsing with macro preprocessing

Access specifiers (public:/private:/protected:) are placed at the class
brace 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.py for details.

Part 4 of 4 — GeneralsMD/Code/Libraries/ and GeneralsMD/Code/Tools/ (161 files).
See also: #2561, #2562, #2563.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR (Part 4 of 4) converts leading spaces to pure tab indentation in 161 C++ source files under GeneralsMD/Code/Libraries/ and GeneralsMD/Code/Tools/, plus adds a reference Python conversion script using tree-sitter-cpp. Verified whitespace-only: git diff -w shows only the new Python script differs, confirming no logic changes are buried in the diff.

Confidence Score: 5/5

Safe to merge — all C++ changes are whitespace-only, verified by git diff -w.

161 C++ files with confirmed whitespace-only changes (git diff -w shows only the new Python script). The conversion is consistent with the codebase convention established in parts 1–3 of this series. The reference Python script is logically sound and its output has been validated by the diff itself.

No files require special attention.

Vulnerabilities

No security concerns identified. All C++ changes are purely whitespace (confirmed by git diff -w). The Python script processes only local files, uses no network I/O, and does not execute any shell commands.

Important Files Changed

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]
Loading

Reviews (2): Last reviewed commit: "fix: Handle braceless control-flow body ..." | Re-trigger Greptile

Copy link
Copy Markdown

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right

if ( flagSpikes )
{
if ( Debug_Statistics::Get_Draw_Calls()>2000 )
fprintf( m_fp, " DRAWS OUT OF TOLERANCE(2000)\n" );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't fprintf not have another indent because of the if-statement above it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you mean the conditional without braces - can fix

if ( ! isVisible )
continue;
if ( ! isVisible )
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had to fix these conditionals without braces in another branch too, I'll do that now

if ( ! TheInGameUI )
return;
if ( ! TheInGameUI )
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants