在github中clone了nanomsghttps://github.com/davidmpc/nanomsg.git的源代碼,發現代碼是google風格,即for、if后大括號沒有另起一行,十分不習慣,因此需要改變代碼格式。
參考http://blog.csdn.net/i_am_tom/article/details/54375266,在sourceforgehttps://sourceforge.net/projects/astyle/?source=typ_redirect中下載了macos的Astyle的代碼,進入build文件夾。
davidma@mac:~/software/astyle$ls
LICENSE.md README.md build doc file src
直接make,在bin中有Astyle的可執行文件。
執行如下命令,既可以讓大括號另起一行、switch中case前有一個tab、對文件夾下所有的.c迭代格式化。
davidma@mac:~/software/astyle/build/mac/bin$./AStyle --style=allman --indent-switches --recursive ../../../../../Documents/code/nanomsg/nanomsg/src/*.c