2016-07-13 17:38:01 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-07-14 18:38:35 -04:00
|
|
|
# reindent a libpng C source
|
|
|
|
|
|
|
|
# COPYRIGHT: Written by Glenn Randers-Pehrson, 2016.
|
|
|
|
# To the extent possible under law, the author has waived all copyright and
|
|
|
|
# related or neighboring rights to this work. This work is published from:
|
|
|
|
# United States.
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
# reindent inputtabsize outputtabsize inputcontinuestring outputcontinuestring
|
2016-07-13 17:38:01 -04:00
|
|
|
#
|
|
|
|
# Assumes that continued lines begin with indentation plus one space, and
|
|
|
|
# that continued comments begin with indentation plus " *".
|
2016-07-14 18:38:35 -04:00
|
|
|
#
|
|
|
|
# eg, to change libpng coding style from 3-space indentation to 4-space
|
|
|
|
#
|
|
|
|
# reindent 3 4 " " " " < example.c > example.c_reindented
|
2016-07-13 17:38:01 -04:00
|
|
|
|
2016-07-14 18:38:35 -04:00
|
|
|
unexpand --first-only --t $1 | \
|
2016-07-13 17:38:01 -04:00
|
|
|
sed -e "/^ $3[^\*]/{s/ $3/ $4/}" | \
|
|
|
|
expand -t $2
|