reindent 891 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. # reindent a libpng C source
  3. # COPYRIGHT: Written by Glenn Randers-Pehrson, 2016.
  4. # To the extent possible under law, the author has waived all copyright and
  5. # related or neighboring rights to this work. This work is published from:
  6. # United States.
  7. # Usage:
  8. # reindent inputtabsize outputtabsize inputcontinuestring outputcontinuestring
  9. #
  10. # Assumes that continued lines begin with indentation plus one space, and
  11. # that continued comments begin with indentation plus " *".
  12. #
  13. # eg, to change libpng coding style from 3-space indentation with 4-space
  14. # continuations to 4-space indentation with 2-space continuations:
  15. #
  16. # reindent 3 4 "\t " " " < example.c > example.c_4_2
  17. # and to restore the file back to libpng coding style
  18. # reindent 4 3 " " " " < example.c_4_2 > example.c_3_4
  19. unexpand --first-only --t $1 | \
  20. sed -e "/^ *$3[^\*]/{s/$3/$4/}" | \
  21. expand -t $2