/[cvs]/eggdev-docs/tools/eggcheck
ViewVC logotype

Contents of /eggdev-docs/tools/eggcheck

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Nov 15 05:14:27 2005 UTC (13 years, 2 months ago) by wcc
Branch: MAIN
CVS Tags: HEAD
* A bit of modification to the directory structure.
* Added my little 'eggcheck' script to tools/. This is by no means anything
  complete, but it does find a few common errors that keep happening. Maybe
  something that we could improve and run from cron or at least before
  releases.

1 #! /bin/bash
2 #
3 # eggcheck - checks for common errors in the tree.
4 #
5 # Copyright (C) 2004 - 2005 Eggheads Development Team
6 #
7 # This file is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 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, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #
21 # As a special exception to the GNU General Public License, if you
22 # distribute this file as part of a program that contains a
23 # configuration script generated by Autoconf, you may include it under
24 # the same distribution terms that you use for the rest of that program.
25 #
26 # $Id: $
27
28 show_usage() {
29 echo "Usage: `basename $0` [-h|-c]"
30 echo " -h - Print this help and exit."
31 echo " -d - Check docs only."
32 echo " -c - Colorize output."
33 echo ""
34 }
35
36 if ! test -f src/patch.h; then
37 echo "You must be in the Eggdrop root directory to run this script." >&2
38 exit 1
39 fi
40
41 do_color=0
42 doc_only=0
43 RED=""
44 NOCOLOR=""
45 GREEN=""
46 BLUE=""
47
48 while getopts cdh opt; do
49 case $opt in
50 c)
51 do_color=1
52 RED=$'\e[31;01m'
53 GREEN=$'\e[32;01m'
54 BLUE=$'\e[34;01m'
55 NOCOLOR=$'\e[0;0m'
56 ;;
57 d)
58 doc_only=1
59 ;;
60 h)
61 show_usage
62 exit 0
63 ;;
64 *)
65 show_usage
66 exit 1
67 ;;
68 esac
69 done
70
71 errorpipe () {
72 sed "s/^/${RED}Error: ${NOCOLOR}/"
73 }
74
75 greppipe () {
76 if test $do_color -eq 1; then
77 xargs grep --color=always $@
78 else
79 xargs grep $@
80 fi
81 }
82
83 find_bad_function() {
84 if test "x${2}" = "x"; then
85 echo -e "${GREEN}Checking for ${1}() usage...${NOCOLOR}"
86 else
87 echo -e "${GREEN}Checking for ${1}() usage instead of ${2}()...${NOCOLOR}"
88 fi
89 find src/ -name '*.[ch]' -print | grep -v 'src/compat' | greppipe -n '[^A-Za-z_]'${1}'(' | errorpipe
90 }
91
92 # Docs
93 echo -e "\n${BLUE}Checking for common doc errors...${NOCOLOR}"
94 echo -e "${GREEN}Checking for ' instead of ' in HTML docs...${NOCOLOR}"
95 find doc/html/ -name '*.html' -print | greppipe -n \' | errorpipe
96 echo -e "${GREEN}Checking for <b> instead of <strong> in HTML docs...${NOCOLOR}"
97 find doc/html/ -name '*.html' -print | greppipe -n '<[bB]>' | errorpipe
98 echo -e "${GREEN}Checking for <i> instead of <em> in HTML docs...${NOCOLOR}"
99 find doc/html/ -name '*.html' -print | greppipe -n '<[iI]>' | errorpipe
100 echo -e "${GREEN}Checking for use of '©' instead of (C) or &copy;...${NOCOLOR}"
101 if test $do_color -eq 1; then
102 grep --color=auto -HIrn '©' * | errorpipe
103 else
104 grep -HIrn '©' * | errorpipe
105 fi
106
107 if test $doc_only = 1; then
108 echo -e "\n${BLUE}Done.${NOCOLOR}\n"
109 exit 0
110 fi
111
112 # Portability
113 echo -e "\n${BLUE}Checking for common portability problems...${NOCOLOR}"
114 find_bad_function snprintf egg_snprintf
115 find_bad_function memcpy egg_memcpy
116 find_bad_function memset egg_memset
117 find_bad_function bzero egg_bzero
118 find_bad_function strftime egg_strftime
119 find_bad_function inet_aton egg_inet_aton
120 find_bad_function strncasecmp egg_strncasecmp
121 find_bad_function strcasecmp egg_strcasecmp
122
123 # Autotools
124 echo -e "\n${BLUE}Checking for common autotools problems...${NOCOLOR}"
125 echo -e "${GREEN}Checking if configure and configure.ac revisions match...${NOCOLOR}"
126 CONFVERSION_AC="x`cat configure.ac | grep AC_REVISION | awk '{print $2}'`"
127 CONFVERSION="x`cat configure | grep 'configure.ac Revision:' | awk '{print $5}'`"
128 if ! test "${CONFVERSION_AC}" = "${CONFVERSION}"; then
129 echo "${RED}Error: configure is from configure.ac revision ${CONFVERSION} instead of ${CONFVERSION_AC}.${NOCOLOR}"
130 fi
131
132 echo -e "\n${BLUE}Done.${NOCOLOR}\n"

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23