August 1, 2025

Sun 3 bootrom souce - fixing tabs in the source files

For me, this means getting rid of them and turning them all into spaces.

I am using vim to edit the files, and my vim settings are set for a tab width of 4. This is clearly not how the sun programmers did things (8 was almost a standard back in 1987) and I see inconsistent and displeasing indentation.

There are a multitude of opinions about how to indent source code. I have no interest in negotiating any of that. I just want to be able to see the bootrom source just as the sun programmers saw it.

I also want to get rid of tabs entirely so that anyone else who looks at this code with whatever editor and whatever setting will see what they ought to see.

The "expand" program

What might work is this:
mv diag.s diag.ORIG
expand -t 8 diag.ORIG > diag.s
It turns out that 8 works and 8 is the default for expand, so it is as easy as this:
mv diag.s diag.ORIG
expand diag.ORIG > diag.s
This makes the files look nice rather than a chaotic jumble as they did with the wrong tab setting.

Automating this for a directory full of files

You can search on this and find various solutions that use a simple bash script, or even a one line command via "find". One thing for sure is that you are smart to make some kind of backup before running all your files through some automated file shredder of this sort. I was going to write the script in ruby, but I had misplaced my favorite ruby book, so I wrote it in python. It is named "detab" in the tools directory.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org