OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [contrib/] [check_GNU_style.sh] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 723 jeremybenn
#!/bin/sh
2
 
3
# Checks some of the GNU style formatting rules in a set of patches.
4
# Copyright (C) 2010  Free Software Foundation, Inc.
5
# Contributed by Sebastian Pop <sebastian.pop@amd.com>
6
 
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
 
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
 
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 
21
usage() {
22
    cat <<EOF
23
check_GNU_style.sh [patch]...
24
 
25
    Checks the patches for some of the GNU style formatting problems.
26
    Please note that these checks are not always accurate, and
27
    complete.  The reference documentation of the GNU Coding Standards
28
    can be found here: http://www.gnu.org/prep/standards_toc.html
29
    and there are also some additional coding conventions for GCC:
30
    http://gcc.gnu.org/codingconventions.html
31
 
32
EOF
33
    exit 1
34
}
35
 
36
test $# -eq 0 && usage
37
 
38
tmp=check_GNU_style.tmp
39
 
40
# Grep
41
g (){
42
    msg="$1"
43
    arg="$2"
44
    shift 2
45
    grep -nH '^+' $* \
46
        | grep -v ':+++' \
47
        | egrep --color=always -- "$arg" \
48
        > $tmp && printf "\n$msg\n"
49
    cat $tmp
50
}
51
 
52
# And Grep
53
ag (){
54
    msg="$1"
55
    arg1="$2"
56
    arg2="$3"
57
    shift 3
58
    grep -nH '^+' $* \
59
        | grep -v ':+++' \
60
        | egrep --color=always -- "$arg1" \
61
        | egrep --color=always -- "$arg2" \
62
        > $tmp && printf "\n$msg\n"
63
    cat $tmp
64
}
65
 
66
# reVerse Grep
67
vg (){
68
    msg="$1"
69
    varg="$2"
70
    arg="$3"
71
    shift 3
72
    grep -nH '^+' $* \
73
        | grep -v ':+++' \
74
        | egrep -v -- "$varg" \
75
        | egrep --color=always -- "$arg" \
76
        > $tmp && printf "\n$msg\n"
77
    cat $tmp
78
}
79
 
80
col (){
81
    msg="$1"
82
    shift 1
83
    grep -nH '^+' $* \
84
        | grep -v ':+++' \
85
        | cut -f 2 -d '+' \
86
        | awk '{ if (length ($0) > 80) print $0 }' \
87
        > $tmp
88
    if [ -s $tmp ]; then
89
        printf "\n$msg\n"
90
        cat $tmp
91
    fi
92
}
93
 
94
col 'Lines should not exceed 80 characters.' $*
95
 
96
g 'Trailing whitespace.' \
97
    '[[:space:]]$' $*
98
 
99
g 'Space before dot.' \
100
    '[[:alnum:]][[:blank:]]+\.' $*
101
 
102
g 'Dot, space, space, new sentence.' \
103
    '[[:alnum:]]\.([[:blank:]]|[[:blank:]]{3,})[[:alnum:]]' $*
104
 
105
g 'Dot, space, space, end of comment.' \
106
    '[[:alnum:]]\.([[:blank:]]{0,1}|[[:blank:]]{3,})\*/' $*
107
 
108
g 'Sentences should end with a dot.  Dot, space, space, end of the comment.' \
109
    '[[:alnum:]][[:blank:]]*\*/' $*
110
 
111
vg 'There should be exactly one space between function name and parentheses.' \
112
    '\#define' '[[:alnum:]]([^[:blank:]]|[[:blank:]]{2,})\(' $*
113
 
114
g 'There should be no space before closing parentheses.' \
115
    '[[:graph:]][[:blank:]]+\)' $*
116
 
117
ag 'Braces should be on a separate line.' \
118
    '\{' 'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\(' $*
119
 
120
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.