On 04/10/2013 12:41:35 PM, Felix Janda wrote:
The toy also does not follow the whitespace conventions in toybox.
But I
think that someone has scripts lying around to fix that.
That would be me. :)
My blog entry from when I did the reindent has some basic sed
invocations to do a conversion:
http://landley.net/notes-2012.html#02-11-2012
But the attached python file is another thing I used. It takes an input
file and converts leading whitespace to a series of T and S characters
for tab and space respectively. Then if you pipe the output to sort -u
you can get an idea of what kind of indentation the file is currently
using. In the case of find:
$ stuff/whippet.py toys/pending/find.c | sort -u
toys/pending/find.c:S
toys/pending/find.c:SSSSSSSSSS
toys/pending/find.c:T
toys/pending/find.c:TSS
toys/pending/find.c:TT
toys/pending/find.c:TTT
toys/pending/find.c:TTTT
toys/pending/find.c:TTTTT
I.E. mostly tabs but the occasional mix of tabs and spaces, and a
couple lines indented with a lot of spaces. (In this case the lots of
spaces line is the last line of the help text.
Another quick little gotcha:
sed -i 's/^ *$//' toys/pending/find.c
Find lines with nothing but whitespace and blank them. (Some people's
editors auto-indent lines and then it gets kept even though they left
the line blank. I should just do a generic find and remove trailing
whitespace thing...)
I'm checking in the whitespace change as its own commit because mixing
whitespace and code changes is seldom a good idea. :)
Rob
#!/usr/bin/python
# Tab to space conversions
import os, sys
for i in sys.argv[1:]:
lines=open(i,"r").read().split('\n')
for j in lines:
if not len(j): continue
out=""
for k in xrange(len(j)):
if not j[k].isspace(): break
if j[k]=='\t': out=out+"T"
elif j[k]==' ': out=out+"S"
else: dieawholelot
if not k: continue
sys.stdout.write("%s:%s\n" % (i,out))
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net