Mantis Bug Tracker

View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000434FirmwareStructure / Stylepublic2011-11-26 15:312012-06-30 09:29
Assigned ToFred 
PlatformOSOS Version
Product Version0.2.0-SNAPSHOT 
Target Version0.2.0Fixed in Version0.2.0 
Summary0000434: Clean Up All White Space
DescriptionIndenting with tabs, always. Tabs only to be used for indenting, no where else.

Comments should only span blocks with the same indentation and should be indented from the code with spaces.

Macro blocks back filled with whitespace should not use tabs at all.

line count between various things should be standardised more. It's not bad, but could be better.
TagsNo tags attached.
Issue TypeTask
Risk of Breakagevery low
Attached Files? file icon tabsnotatbol [^] (82 bytes) 2012-06-27 10:43 [Show Content]
? file icon [^] (273 bytes) 2012-06-27 10:43

- Relationships
related to 0000601assignedFred Remove All Commented Out Code 

-  Notes
User avatar (0001420)
Fred (administrator)
2012-04-10 11:08

Came up with a grep command to find tabs used post tokens and not as indentation, only 80 offending lines in src/*.c. More in other files (400 total) but didn't check those, they could be false positives on ASM and linker scripts etc. Will get that into a commit soon.
User avatar (0001502)
Fred (administrator)
2012-05-03 22:34

find . -name "*.c" -or -name "*.h" | xargs grep -rn "[:space:].*[ ]"|wc

where the space between the last [] pair is a real tab entered by hitting ctrl v and then the tab.
User avatar (0001503)
Fred (administrator)
2012-05-03 22:39

The above only works on the Mac OS X grep/bash, apparently. Fails on Linux.
User avatar (0001621)
Fred (administrator)
2012-06-26 16:23

Mac has 2.5.1 and Deb currently has 2.8 - this is a clue.
User avatar (0001622)
Fred (administrator)
2012-06-26 23:45

find . -name "*.c" -or -name "*.h" | xargs cat | perl -ne 'chomp;print "$_\n" if /[^^\s]\t+/'

Courtesy of AncientGeek! Thanks! :-)

Just needs line numbers and file names and it's good to go.
User avatar (0001623)
Fred (administrator)
2012-06-27 10:43

find . -name "*.c" -or -name "*.h" | xargs ./tabsnotatbol

To be run in src/ with the two files that I am about to attach placed in src/ too.

Supplied by AncientGeek and tweaked only slightly by me and work well enough.

Thank you AncientGeek!
User avatar (0001624)
Fred (administrator)
2012-06-27 11:57

In vim you can run :%s/\v([^\t]+)\t+/\4 /g to turn each tab that isn't leading into 4 spaces. Thanks to masterkorp for that. It changes stuff it shouldn't, but using a difftool it's easy to revert that.
User avatar (0001625)
Fred (administrator)
2012-06-27 16:30

Fixed in 7945946638ac06ab9cb529cca753ad2711ae9cc1 creating a new issue to remove all commented out code.
User avatar (0001629)
Fred (administrator)
2012-06-30 09:29

New issue is 0000601 for reference.

Another option:

Karsten: I'd use perl for this, like this:

perl -lpe 's/(^)?(\t+)/defined($1)?$2:" "/eg'

That will replace any non-leading group of tabs with a single space, and replace leading tabs with themselves, i.e. leave them untouched.

Fred: I guess that's a good idea, provided that it's in source control, and everything is committed. Then I can just git diff it afterward to find the issues and git reset if I don't want to fix them.

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker