File: beautify-source

package info (click to toggle)
kwave 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,272 kB
  • sloc: cpp: 56,173; xml: 817; perl: 688; sh: 57; makefile: 11
file content (64 lines) | stat: -rwxr-xr-x 2,127 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
############################################################################
#        beautify-source  -  adjust coding style to the one of Kwave
#                            -------------------
#   begin                : Fri May 05 2000
#   copyright            : (C) 2000 by Thomas Eschenbacher
#   email                : Thomas.Eschenbacher@gmx.de
############################################################################
#
############################################################################
#                                                                          #
#    This program is free software; you can redistribute it and/or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
############################################################################
#
# Beautifies all C/C++ header and source files according to my
# personally favorite coding style. It makes use of the "Artistic Style"
# package available at "http://astyle.sourceforge.net/"
# or as rpm named "astyle"
#
# Thanks to Tal Davidson, Israel (E-mail: davidsont@bigfoot.com)
# for writing it :-)
#

function Format_File() {
    echo indenting $1
    cat $1 | expand | astyle \
        --style=kr \
        --mode=c \
        --brackets=attach \
        --pad=oper \
        --indent-switches \
        --indent-cases \
        --min-conditional=0 \
        --max-instatement-indent=4 \
        --indent=spaces=4  \
        > /tmp/indent 2>/dev/null
    cat /tmp/indent | unexpand > $1


};

#
# uncomment the 7 lines below if your source comes from
# a DOS / Windooze environment...
#
# for file in `find -type f | grep -E .S$\|.s$\|.cpp$\|.c$\|.h$\|?akefile\|.orig$`; do
# {
#     echo converting $file
#     /usr/bin/recode --silent ibmpc:lat1 $file
# };
# done

for file in `find . -name \*.cpp -o -name \*.h`; do
{
    Format_File $file
};
done

exit 0