Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (22c266d86d58a8967c0aac4c6c2fc99d05d44d44)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (22c266d86d58a8967c0aac4c6c2fc99d05d44d44)
  • Date: Wed, 7 Apr 2010 10:27:17 -0500

GIT changes to master cauldron by Justin Boffemmyer <flux AT sourcemage.org>:

HACKING | 84 +++++++++++++-
delint/cauldron_sources | 47 --------
delint/enchantment_sources | 50 --------
delint/functions | 84 --------------
delint/global_variables | 83 --------------
delint/libdelint | 264
---------------------------------------------
delint/release-test | 53 ---------
delint/test-configvars | 106 ------------------
delint/test-errorcodes | 114 -------------------
delint/test-functions | 102 -----------------
ward/cauldron_sources | 47 ++++++++
ward/enchantment_sources | 50 ++++++++
ward/functions | 84 ++++++++++++++
ward/global_variables | 83 ++++++++++++++
ward/libward | 264
+++++++++++++++++++++++++++++++++++++++++++++
ward/ward-all | 53 +++++++++
ward/ward-configvars | 106 ++++++++++++++++++
ward/ward-errorcodes | 114 +++++++++++++++++++
ward/ward-functions | 102 +++++++++++++++++
ward/ward-localvars | 0
20 files changed, 983 insertions(+), 907 deletions(-)

New commits:
commit 22c266d86d58a8967c0aac4c6c2fc99d05d44d44
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

HACKING: update for delint -> ward rename

Updated the HACKING file to reflect the rename of delint to ward. Also
added documentation of the different ward files, as only
global_variables was there before.

commit 1e7bd7489deb8056f4d7e304173689db19e2ffc7
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

ward: update function/variable names

Now that delint is renamed to ward, update the function and variable
prefixes accordingly.

commit a096150e69012f8a475210d6db38f0723b24531f
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

rename delint to ward

In keeping with the magical tradition of Source Mage, delinters are now
known as wards.

diff --git a/HACKING b/HACKING
index f6b0089..0b1ed74 100644
--- a/HACKING
+++ b/HACKING
@@ -283,17 +283,93 @@ overrides what is in etc/cauldron/config.


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-delint/
+ward/

A collection of scripts for performing quality assurance on the
Cauldron codebase.

-***************************
-* delint/global_variables *
-***************************
+*************************
+* ward/cauldron_sources *
+*************************
+ Defines an array which lists all the cauldron sources to scan using
the
+wards.
+
+****************************
+* ward/enchantment_sources *
+****************************
+ Defines an array which lists all the enchantment sources to scan using
+the wards.
+
+
+****************
+* ward/libward *
+****************
+ Defines the various functions that are used to perform each ward's
+checks.
+
+
+******************
+* ward/functions *
+******************
+ Performs a static analysis of function calls in files passed on the
+command line, testing if they are defined first in the file being checked and
+then in the different libraries in the respective component, checking from
+outer prefix to inner.
+
+*************************
+* ward/global_variables *
+*************************
Performs a static analysis of global variables (the uppercased ones)
in
files passed on the command line against a "definition" file (typically this
would either be one of the etc/config files, or one of the errorcodes files).

+************************
+* ward/local_variables *
+************************
+ Performs a static analysis of local variables (the lowercased ones
+defined with the "local" keyword) in files passed on the command line against
+the file being checked to ensure that the variable is properly defined within
+the scope it is being used in, and before the variable is used.
+
+
+*****************
+* ward/ward-all *
+*****************
+ Runs all wards on the cauldron and enchantment sources. This should be
+used for any "release" which is done to ensure both that the code is
compliant
+with the API and that there is higher quality of the code (bug prevention is
+better than bug fixing).
+
+************************
+* ward/ward-configvars *
+************************
+ Tests the use of all configuration variables (global variables which
+aren't error codes) in all cauldron and enchantment sources (as defined in
+cauldron_sources and enchantment_sources above) to ensure that they are
+properly defined in the respective configuration files.
+
+************************
+* ward/ward-errorcodes *
+************************
+ Tests both the internal consistency of the cauldron and enchantment
+errorcodes files (makes sure that the number of codes matches the number of
+messages and that every code has a corresponding message and vice versa), and
+the use of all error codes in all cauldron and enchantment sources (as
defined
+in cauldron_sources and enchantment_sources above) to ensure that they are
+properly defined in the respective errorcodes files.
+
+***********************
+* ward/ward-functions *
+***********************
+ Tests all function calls in all cauldron and enchantment sources (as
+defined in cauldron_sources and enchantment_sources above) to ensure that
they
+are properly defined.
+
+***********************
+* ward/ward-localvars *
+***********************
+ Tests all local variables in all cauldron and enchantment sources (as
+defined in cauldron_sources and enchantment_sources above) to ensure that
they
+are properly defined.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

diff --git a/delint/cauldron_sources b/delint/cauldron_sources
deleted file mode 100644
index feae9ae..0000000
--- a/delint/cauldron_sources
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## This goes through all the known sources for both cauldron and
enchantment,
-## scans their uses of error codes, and ensures that they are defined in the
-## relevant errorcodes files.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-cauldron_srcs=(
- "$cauldron/cauldron"
- "$cauldron/libcauldron"
- "$cauldron/lib.chroot"
- "$cauldron/lib.hostcache"
- "$cauldron/lib.init"
- "$cauldron/lib.sorcerous"
- )
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/enchantment_sources b/delint/enchantment_sources
deleted file mode 100644
index e24fc73..0000000
--- a/delint/enchantment_sources
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## This goes through all the known sources for both cauldron and
enchantment,
-## scans their uses of error codes, and ensures that they are defined in the
-## relevant errorcodes files.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-enchantment_srcs=(
- "$enchantment/libenchantment"
- "$enchantment/lib.chroot"
- "$enchantment/lib.i18n"
- "$enchantment/lib.install"
- "$enchantment/lib.potion"
- "$enchantment/shell/bashrc"
- "$enchantment/shell/functions"
- "$enchantment/shell/bin/enchantment"
- "$enchantment/modules/*/{enter,exit,potion}/*"
- )
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/functions b/delint/functions
deleted file mode 100755
index 5cbb8af..0000000
--- a/delint/functions
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## Function delinter - tests all functions (as defined in the API
-## specification) for whether they are defined in a given file.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-DELINT_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-if ! . "$DELINT_PATH/libdelint"
-then
- echo "error: could not load $DELINT_PATH/libdelint"
- exit 1
-fi
-
-function delint_print_usage() {
- cat << EndUsage
-Usage: $(basename $0) [-n] FILE_PATH FILE_TO_CHECK1 [FILE_TO_CHECK2 ...]
-
-Checks whether functions called in FILE_TO_CHECK1 [FILE_TO_CHECK2 ...] were
-defined in either the file being checked itself or a library in FILE_PATH
which
-matches the function prefix(es) (as defined in the API). For any functions
not
-so defined, they are printed on stdout along with the file in which they were
-used. If passed -n, color output is disabled.
-EndUsage
-}
-
-function delint_usage() {
- delint_print_usage
- exit $ERR_FATAL
-}
-
-# check if color should be disabled
-if [[ "$1" == "-n" ]]
-then
- if [[ "$#" -gt 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- delint_usage
- fi
-fi
-
-# we need a minimum of 2 arguments at this point:
-# the defines file + at least one file to check
-if [[ $# -lt 2 ]]
-then
- echo "$(delint_print_usage)"
- liberror_die $ERR_FATAL
-fi
-
-delint_functions "$@"
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/global_variables b/delint/global_variables
deleted file mode 100755
index 747abc5..0000000
--- a/delint/global_variables
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## Global variable delinter - tests all global variables (as defined in the
-## API specification) for whether they are defined in a given definitions
file.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-DELINT_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-if ! . "$DELINT_PATH/libdelint"
-then
- echo "error: could not load $DELINT_PATH/libdelint"
- exit 1
-fi
-
-function delint_print_usage() {
- cat << EndUsage
-Usage: $(basename $0) [-n] DEFINITION_FILE FILE_TO_CHECK1 [FILE_TO_CHECK2
...]
-
-Checks whether global variables in FILE_TO_CHECK1 [FILE_TO_CHECK2 ...] were
-defined in DEFINITION_FILE. For any global variables not so defined, they are
-printed on stdout along with the file in which they were used. If passed -n,
-color output is disabled.
-EndUsage
-}
-
-function delint_usage() {
- delint_print_usage
- exit $ERR_FATAL
-}
-
-# check if color should be disabled
-if [[ "$1" == "-n" ]]
-then
- if [[ "$#" -gt 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- delint_usage
- fi
-fi
-
-# we need a minimum of 2 arguments at this point:
-# the defines file + at least one file to check
-if [[ $# -lt 2 ]]
-then
- echo "$(delint_print_usage)"
- liberror_die $ERR_FATAL
-fi
-
-delint_global_variables "$@"
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/libdelint b/delint/libdelint
deleted file mode 100644
index ec9ae65..0000000
--- a/delint/libdelint
+++ /dev/null
@@ -1,264 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## Function and variable definitions for the delinters.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-# set LC_COLLATE to C so we don't get affected by the user's locale
-# when grepping, sorting, etc.
-export LC_COLLATE="C"
-
-# ensure that DELINT_PATH has a value
-DELINT_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-# load liberror (this is not optional)
-if ! . "$DELINT_PATH/../lib/liberror"
-then
- echo "error: could not load $DELINT_PATH/../lib/liberror"
- exit 1
-fi
-
-# load libcolor (there should be an option for this later)
-if ! . "$DELINT_PATH/../lib/libcolor"
-then
- echo "error: could not load $DELINT_PATH/../lib/libcolor"
- exit 1
-fi
-
-#-------------------------------------------------------------------------------
-## @param definition file
-## @param source1 [source2 source3...]
-##
-## Tests whether any variables used in source1 (source2, source3, etc.) are
-## defined in the definition file. Any variables that are used but not
defined
-## in the definition file are output via libcolor_warn, preceded by the file
-## they were found in via libcolor_file.
-##
-#-------------------------------------------------------------------------------
-function delint_global_variables() {
- local defines=""
- local file=""
-
- # get the defines file, then drop it from the argument list
- defines="$1"
- shift
-
- # make sure the defines file exists, otherwise we can't check anything
- if [[ ! -f "$defines" ]]
- then
- echo "error: definition file not found"
- liberror_die $ERR_FATAL
- fi
-
- while [[ $# -gt 0 ]]
- do
- file="$1"
- shift
-
- [[ -f "$file" ]] || continue
-
- # as per the API specification, all global variables are required to be
- # uppercase, and must begin with a letter, containing only letters,
- # underscores, and trailing numbers
- for search in $(grep -o '${\?[A-Z][A-Z_]*[0-9]*' "$file" | sed
's/^\${\?//' | sort -u)
- do
- if ! grep -q "$search=" "$defines"
- then
- echo "$(libcolor_file $file): $(libcolor_warn $search)"
- fi
- done
- done
-}
-
-#-------------------------------------------------------------------------------
-## @param error code file
-##
-## Ensures that the error code file itself is properly defined, making sure
that
-## for every error code there is a matching error message, and for every
error
-## message there is a matching error code.
-##
-#-------------------------------------------------------------------------------
-function delint_error_codes() {
- local errorcodes="$1"
- local leader=" "
- local codes=()
- local msgcode=""
- local count=""
-
- # make sure the defines file exists, otherwise we can't check anything
- if [[ ! -f "$errorcodes" ]]
- then
- libcolor_error "error: error code file "
- libcolor_file "$errorcodes"
- libcolor_error " not found"
- echo ""
- liberror_die $ERR_FATAL
- fi
-
- if ! source "$errorcodes" 2 > /dev/null
- then
- libcolor_error "error: could not source error code file "
- libcolor_file "$errorcodes"
- echo ""
- fi
-
- # get the list of defined error codes
- codes=( $(grep -o '^ERR_[A-Z_]\+[0-9]*' "$errorcodes" | grep -v
'ERR_MSGS') )
-
- # test if the number of messages matches the number of error codes
- if [[ "${#codes[@]}" -ne "${#ERR_MSGS[@]}" ]]
- then
- libcolor_error "error: "
- libcolor_error "number of error codes not equal to number of messages"
- echo ""
- libcolor_error "${leader}codes: ${#codes[@]}"
- echo ""
- libcolor_error "${leader}messages: ${#ERR_MSGS[@]}"
- echo ""
- fi
-
- # for every error code defined, make sure there is a corresponding message
- for ((count=0; "$count" < "${#codes[@]}"; count++))
- do
- if ! grep -q "${codes[count]}\$" "$errorcodes"
- then
- libcolor_error "error: ${codes[count]}: "
- libcolor_error "DEFINED but has no corresponding message"
- echo ""
- fi
- done
-
- # for every error message defined, make sure there is a corresponding code
- for ((count=0; "$count" < "${#ERR_MSGS[@]}"; count++))
- do
- msgcode=$(grep "${ERR_MSGS[count]}.*# " "$errorcodes" | sed 's/.*# //')
-
- if ! grep -q "^${msgcode}=" "$errorcodes"
- then
- libcolor_error "error: $msgcode: "
- libcolor_error "NOT DEFINED but message is"
- echo ""
- fi
- done
-}
-
-#-------------------------------------------------------------------------------
-## @param directory where function definition files are stored
-## @param source1 [source2 source3...]
-##
-## Tests whether any functions used in source1 (source2, source3, etc.) are
-## defined. Any functions that are used but not defined in the corresponding
-## definition file are output via libcolor_warn, preceded by the file they
were
-## found in via libcolor_file.
-##
-#-------------------------------------------------------------------------------
-function delint_functions() {
- local path=""
- local file=""
- local prefix=""
- local list=""
- local matched=""
-
- # make sure we have a minimum number of arguments
- if [[ $# -lt 2 ]]
- then
- echo "error: improper number of arguments"
- liberror_die $ERR_FATAL
- fi
-
- # get the defines file, then drop it from the argument list
- path="$1"
- shift
-
- # make sure we got a good path component
- if [[ ! -d "$DELINT_PATH/../$path" ]]
- then
- echo "error: library search path not recognized"
- liberror_die $ERR_FATAL
- else
- path="$DELINT_PATH/../$path"
- fi
-
- while [[ $# -gt 0 ]]
- do
- file="$1"
- shift
-
- [[ -f "$file" ]] || continue
-
- list=($(grep -o "^[ ]*[a-z]\+_[a-z_]\+" "$file" | sed 's/^ *//' | sort
-u))
- # for each called function, check prefix by prefix
- for function in "${list[@]}"
- do
- # check if the function is defined somewhere in the file it came from
- grep -q "^function $function() {" "$file" && continue
-
- # seed the defines variable for the loop below
- local mangle="$function"
-
- # check against the prefixes, one at a time
- while $(echo $mangle | grep -q '^[a-z]\+_[a-z_]\+')
- do
- prefix="${mangle%%_*}"
- [[ "$prefix" == "enchant" ]] && prefix="enchantment"
-
- # check for the function in a library file matching the prefix
- if [[ -f "$path/lib$prefix" ]]
- then
- if grep -q "^function $function() {" "$path/lib$prefix"
- then
- matched="yes"
- break
- fi
- elif [[ -f "$path/lib.$prefix" ]]
- then
- if grep -q "^function $function() {" "$path/lib.$prefix"
- then
- matched="yes"
- break
- fi
- fi
-
- # no match yet, strip the prefix and repeat
- mangle="${mangle#*_}"
- done
-
- # if the function isn't defined in the corresponding file, warn the
user
- if [[ -z "$matched" ]]
- then
- echo "$(libcolor_file $file): $(libcolor_warn $function)"
- fi
- done
- done
-}
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/local_variables b/delint/local_variables
deleted file mode 100755
index e69de29..0000000
diff --git a/delint/release-test b/delint/release-test
deleted file mode 100755
index 00390b8..0000000
--- a/delint/release-test
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## Runs all the necessary tests against the Cauldron codebase to ensure
-## quality releases.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-DELINT_PATH="$(dirname $0)"
-PATH="$DELINT_PATH:$PATH"
-
-TESTERS=(
- "test-configvars"
- "test-errorcodes"
- "test-functions"
- )
-
-for tester in "${TESTERS[@]}"
-do
- echo ""
- echo "RUNNING: $tester"
- $tester
-done | $PAGER
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/return_values b/delint/return_values
deleted file mode 100755
index e69de29..0000000
diff --git a/delint/test-configvars b/delint/test-configvars
deleted file mode 100755
index 0ad5034..0000000
--- a/delint/test-configvars
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## This goes through all the known sources for both cauldron and
enchantment,
-## scans their uses of global configurable variables (those listed in the
-## etc/config files), and ensures that they are defined in the relevant
-## config files.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-
-DELINT_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-cauldron="$DELINT_PATH/../cauldron"
-c_conf="$cauldron/etc/config"
-
-enchantment="$DELINT_PATH/../enchantment"
-e_conf="$enchantment/etc/config"
-
-if ! . "$DELINT_PATH/libdelint"
-then
- echo "error: could not load $DELINT_PATH/libdelint"
- exit 1
-fi
-
-# source the list of cauldron source files to examine
-if ! . "$DELINT_PATH/cauldron_sources"
-then
- echo "error: could not load cauldron_sources"
- exit $ERR_FATAL
-fi
-# source the list of enchantment source files to examine
-if ! . "$DELINT_PATH/enchantment_sources"
-then
- echo "error: could not load enchantment_sources"
- exit $ERR_FATAL
-fi
-
-function delint_print_usage() {
- cat << EndUsage
-Usage: $(basename $0) [-n]
-
-Calls the global_variables delinter to check whether there are error codes
used
-in the known cauldron and enchantment source files that aren't defined in the
-respective errorcodes files. If passed -n, color output is disabled.
-EndUsage
-}
-
-function delint_usage() {
- delint_print_usage
- exit $ERR_FATAL
-}
-
-# check if color should be disabled
-if [[ "$1" == "-n" ]]
-then
- if [[ "$#" -eq 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- delint_usage
- fi
-fi
-
-# check cauldron files
-libcolor_notice "Checking cauldron config variables"
-echo ""
-delint_global_variables "$c_conf" "${cauldron_srcs[@]}" | \
- grep -v '[^A-Z_]ERR_[A-Z_]*'
-
-# check enchantment files
-libcolor_notice "Checking enchantment config variables"
-echo ""
-delint_global_variables "$e_conf" "${enchantment_srcs[@]}" | \
- grep -v '[^A-Z_]ERR_[A-Z_]*'
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/test-errorcodes b/delint/test-errorcodes
deleted file mode 100755
index 5e42663..0000000
--- a/delint/test-errorcodes
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## This goes through all the known sources for both cauldron and
enchantment,
-## scans their uses of error codes, and ensures that they are defined in the
-## relevant errorcodes files.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-DELINT_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-cauldron="$DELINT_PATH/../cauldron"
-c_codes="$cauldron/errorcodes"
-
-enchantment="$DELINT_PATH/../enchantment"
-e_codes="$enchantment/errorcodes"
-
-if ! . "$DELINT_PATH/libdelint"
-then
- echo "error: could not load $DELINT_PATH/libdelint"
- exit 1
-fi
-
-# source the list of cauldron source files to examine
-if ! . "$DELINT_PATH/cauldron_sources"
-then
- echo "error: could not load cauldron_sources"
- exit $ERR_FATAL
-fi
-# source the list of enchantment source files to examine
-if ! . "$DELINT_PATH/enchantment_sources"
-then
- echo "error: could not load enchantment_sources"
- exit $ERR_FATAL
-fi
-
-function delint_print_usage() {
- cat << EndUsage
-Usage: $(basename $0) [-n]
-
-Calls the global_variables delinter to check whether there are error codes
used
-in the known cauldron and enchantment source files that aren't defined in the
-respective errorcodes files. If passed -n, color output is disabled.
-EndUsage
-}
-
-function delint_usage() {
- delint_print_usage
- exit $ERR_FATAL
-}
-
-# check if color should be disabled
-if [[ "$1" == "-n" ]]
-then
- if [[ "$#" -eq 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- delint_usage
- fi
-fi
-
-# check cauldron error codes/messages files for internal consistency
-libcolor_notice "Checking cauldron errorcodes for internal consistency"
-echo ""
-delint_error_codes "$c_codes"
-
-# check cauldron files
-libcolor_notice "Checking cauldron sources for undefined error codes"
-echo ""
-delint_global_variables "$c_codes" "${cauldron_srcs[@]}" | \
- grep '[^A-Z_]ERR_[A-Z_]*'
-
-# check enchantment error codes/messages files for internal consistency
-libcolor_notice "Checking enchantment errorcodes for internal consistency"
-echo ""
-delint_error_codes "$e_codes"
-
-# check enchantment files
-libcolor_notice "Checking enchantment sources for undefined error codes"
-echo ""
-delint_global_variables "$e_codes" "${enchantment_srcs[@]}" | \
- grep '[^A-Z_]ERR_[A-Z_]*'
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/test-functions b/delint/test-functions
deleted file mode 100755
index db3e178..0000000
--- a/delint/test-functions
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/bash
-#-------------------------------------------------------------------------------
-##
-##=head1 SYNOPSIS
-##
-## This goes through all the known sources for both cauldron and
enchantment,
-## scans their uses of global configurable variables (those listed in the
-## etc/config files), and ensures that they are defined in the relevant
-## config files.
-##
-##=head1 COPYRIGHT
-##
-## Copyright 2010 by the Cauldron Team
-##
-##=head1 FUNCTIONS
-##
-##=over 4
-##
-#-------------------------------------------------------------------------------
-
-
-DELINT_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-cauldron="$DELINT_PATH/../cauldron"
-
-enchantment="$DELINT_PATH/../enchantment"
-
-if ! . "$DELINT_PATH/libdelint"
-then
- echo "error: could not load $DELINT_PATH/libdelint"
- exit 1
-fi
-
-# source the list of cauldron source files to examine
-if ! . "$DELINT_PATH/cauldron_sources"
-then
- echo "error: could not load cauldron_sources"
- exit $ERR_FATAL
-fi
-# source the list of enchantment source files to examine
-if ! . "$DELINT_PATH/enchantment_sources"
-then
- echo "error: could not load enchantment_sources"
- exit $ERR_FATAL
-fi
-
-function delint_print_usage() {
- cat << EndUsage
-Usage: $(basename $0) [-n]
-
-Calls the functions delinter to check whether there are functions called in
the
-known cauldron and enchantment source files that aren't defined in the
-respective library files. If passed -n, color output is disabled.
-EndUsage
-}
-
-function delint_usage() {
- delint_print_usage
- exit $ERR_FATAL
-}
-
-# check if color should be disabled
-if [[ "$1" == "-n" ]]
-then
- if [[ "$#" -eq 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- delint_usage
- fi
-fi
-
-# check cauldron files
-libcolor_notice "Checking cauldron functions"
-echo ""
-delint_functions "cauldron" "${cauldron_srcs[@]}"
-
-# check enchantment files
-libcolor_notice "Checking enchantment functions"
-echo ""
-delint_functions "enchantment" "${enchantment_srcs[@]}"
-
-#-------------------------------------------------------------------------------
-##
-## This software 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.
-##
-## This software is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this software; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-#-------------------------------------------------------------------------------
-
-# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/test-localvars b/delint/test-localvars
deleted file mode 100755
index e69de29..0000000
diff --git a/ward/cauldron_sources b/ward/cauldron_sources
new file mode 100644
index 0000000..feae9ae
--- /dev/null
+++ b/ward/cauldron_sources
@@ -0,0 +1,47 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of error codes, and ensures that they are defined in the
+## relevant errorcodes files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+cauldron_srcs=(
+ "$cauldron/cauldron"
+ "$cauldron/libcauldron"
+ "$cauldron/lib.chroot"
+ "$cauldron/lib.hostcache"
+ "$cauldron/lib.init"
+ "$cauldron/lib.sorcerous"
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/enchantment_sources b/ward/enchantment_sources
new file mode 100644
index 0000000..e24fc73
--- /dev/null
+++ b/ward/enchantment_sources
@@ -0,0 +1,50 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of error codes, and ensures that they are defined in the
+## relevant errorcodes files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+enchantment_srcs=(
+ "$enchantment/libenchantment"
+ "$enchantment/lib.chroot"
+ "$enchantment/lib.i18n"
+ "$enchantment/lib.install"
+ "$enchantment/lib.potion"
+ "$enchantment/shell/bashrc"
+ "$enchantment/shell/functions"
+ "$enchantment/shell/bin/enchantment"
+ "$enchantment/modules/*/{enter,exit,potion}/*"
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/functions b/ward/functions
new file mode 100755
index 0000000..3038f0c
--- /dev/null
+++ b/ward/functions
@@ -0,0 +1,84 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Function ward - tests all functions (as defined in the API specification)
+## for whether they are defined in a given file.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
+
+if ! . "$WARD_PATH/libdelint"
+then
+ echo "error: could not load $WARD_PATH/libdelint"
+ exit 1
+fi
+
+function ward_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n] FILE_PATH FILE_TO_CHECK1 [FILE_TO_CHECK2 ...]
+
+Checks whether functions called in FILE_TO_CHECK1 [FILE_TO_CHECK2 ...] were
+defined in either the file being checked itself or a library in FILE_PATH
which
+matches the function prefix(es) (as defined in the API). For any functions
not
+so defined, they are printed on stdout along with the file in which they were
+used. If passed -n, color output is disabled.
+EndUsage
+}
+
+function ward_usage() {
+ ward_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -gt 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ ward_usage
+ fi
+fi
+
+# we need a minimum of 2 arguments at this point:
+# the defines file + at least one file to check
+if [[ $# -lt 2 ]]
+then
+ echo "$(ward_print_usage)"
+ liberror_die $ERR_FATAL
+fi
+
+ward_functions "$@"
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/global_variables b/ward/global_variables
new file mode 100755
index 0000000..6a3e116
--- /dev/null
+++ b/ward/global_variables
@@ -0,0 +1,83 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Global variable ward - tests all global variables (as defined in the API
+## specification) for whether they are defined in a given definitions file.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
+
+if ! . "$WARD_PATH/libdelint"
+then
+ echo "error: could not load $WARD_PATH/libdelint"
+ exit 1
+fi
+
+function ward_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n] DEFINITION_FILE FILE_TO_CHECK1 [FILE_TO_CHECK2
...]
+
+Checks whether global variables in FILE_TO_CHECK1 [FILE_TO_CHECK2 ...] were
+defined in DEFINITION_FILE. For any global variables not so defined, they are
+printed on stdout along with the file in which they were used. If passed -n,
+color output is disabled.
+EndUsage
+}
+
+function ward_usage() {
+ ward_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -gt 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ ward_usage
+ fi
+fi
+
+# we need a minimum of 2 arguments at this point:
+# the defines file + at least one file to check
+if [[ $# -lt 2 ]]
+then
+ echo "$(ward_print_usage)"
+ liberror_die $ERR_FATAL
+fi
+
+ward_global_variables "$@"
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/libward b/ward/libward
new file mode 100644
index 0000000..db60d46
--- /dev/null
+++ b/ward/libward
@@ -0,0 +1,264 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Function and variable definitions for the wards.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+# set LC_COLLATE to C so we don't get affected by the user's locale
+# when grepping, sorting, etc.
+export LC_COLLATE="C"
+
+# ensure that WARD_PATH has a value
+WARD_PATH="${WARD_PATH:-$(dirname $0)}"
+
+# load liberror (this is not optional)
+if ! . "$WARD_PATH/../lib/liberror"
+then
+ echo "error: could not load $WARD_PATH/../lib/liberror"
+ exit 1
+fi
+
+# load libcolor (there should be an option for this later)
+if ! . "$WARD_PATH/../lib/libcolor"
+then
+ echo "error: could not load $WARD_PATH/../lib/libcolor"
+ exit 1
+fi
+
+#-------------------------------------------------------------------------------
+## @param definition file
+## @param source1 [source2 source3...]
+##
+## Tests whether any variables used in source1 (source2, source3, etc.) are
+## defined in the definition file. Any variables that are used but not
defined
+## in the definition file are output via libcolor_warn, preceded by the file
+## they were found in via libcolor_file.
+##
+#-------------------------------------------------------------------------------
+function ward_global_variables() {
+ local defines=""
+ local file=""
+
+ # get the defines file, then drop it from the argument list
+ defines="$1"
+ shift
+
+ # make sure the defines file exists, otherwise we can't check anything
+ if [[ ! -f "$defines" ]]
+ then
+ echo "error: definition file not found"
+ liberror_die $ERR_FATAL
+ fi
+
+ while [[ $# -gt 0 ]]
+ do
+ file="$1"
+ shift
+
+ [[ -f "$file" ]] || continue
+
+ # as per the API specification, all global variables are required to be
+ # uppercase, and must begin with a letter, containing only letters,
+ # underscores, and trailing numbers
+ for search in $(grep -o '${\?[A-Z][A-Z_]*[0-9]*' "$file" | sed
's/^\${\?//' | sort -u)
+ do
+ if ! grep -q "$search=" "$defines"
+ then
+ echo "$(libcolor_file $file): $(libcolor_warn $search)"
+ fi
+ done
+ done
+}
+
+#-------------------------------------------------------------------------------
+## @param error code file
+##
+## Ensures that the error code file itself is properly defined, making sure
that
+## for every error code there is a matching error message, and for every
error
+## message there is a matching error code.
+##
+#-------------------------------------------------------------------------------
+function ward_error_codes() {
+ local errorcodes="$1"
+ local leader=" "
+ local codes=()
+ local msgcode=""
+ local count=""
+
+ # make sure the defines file exists, otherwise we can't check anything
+ if [[ ! -f "$errorcodes" ]]
+ then
+ libcolor_error "error: error code file "
+ libcolor_file "$errorcodes"
+ libcolor_error " not found"
+ echo ""
+ liberror_die $ERR_FATAL
+ fi
+
+ if ! source "$errorcodes" 2 > /dev/null
+ then
+ libcolor_error "error: could not source error code file "
+ libcolor_file "$errorcodes"
+ echo ""
+ fi
+
+ # get the list of defined error codes
+ codes=( $(grep -o '^ERR_[A-Z_]\+[0-9]*' "$errorcodes" | grep -v
'ERR_MSGS') )
+
+ # test if the number of messages matches the number of error codes
+ if [[ "${#codes[@]}" -ne "${#ERR_MSGS[@]}" ]]
+ then
+ libcolor_error "error: "
+ libcolor_error "number of error codes not equal to number of messages"
+ echo ""
+ libcolor_error "${leader}codes: ${#codes[@]}"
+ echo ""
+ libcolor_error "${leader}messages: ${#ERR_MSGS[@]}"
+ echo ""
+ fi
+
+ # for every error code defined, make sure there is a corresponding message
+ for ((count=0; "$count" < "${#codes[@]}"; count++))
+ do
+ if ! grep -q "${codes[count]}\$" "$errorcodes"
+ then
+ libcolor_error "error: ${codes[count]}: "
+ libcolor_error "DEFINED but has no corresponding message"
+ echo ""
+ fi
+ done
+
+ # for every error message defined, make sure there is a corresponding code
+ for ((count=0; "$count" < "${#ERR_MSGS[@]}"; count++))
+ do
+ msgcode=$(grep "${ERR_MSGS[count]}.*# " "$errorcodes" | sed 's/.*# //')
+
+ if ! grep -q "^${msgcode}=" "$errorcodes"
+ then
+ libcolor_error "error: $msgcode: "
+ libcolor_error "NOT DEFINED but message is"
+ echo ""
+ fi
+ done
+}
+
+#-------------------------------------------------------------------------------
+## @param directory where function definition files are stored
+## @param source1 [source2 source3...]
+##
+## Tests whether any functions used in source1 (source2, source3, etc.) are
+## defined. Any functions that are used but not defined in the corresponding
+## definition file are output via libcolor_warn, preceded by the file they
were
+## found in via libcolor_file.
+##
+#-------------------------------------------------------------------------------
+function ward_functions() {
+ local path=""
+ local file=""
+ local prefix=""
+ local list=""
+ local matched=""
+
+ # make sure we have a minimum number of arguments
+ if [[ $# -lt 2 ]]
+ then
+ echo "error: improper number of arguments"
+ liberror_die $ERR_FATAL
+ fi
+
+ # get the defines file, then drop it from the argument list
+ path="$1"
+ shift
+
+ # make sure we got a good path component
+ if [[ ! -d "$WARD_PATH/../$path" ]]
+ then
+ echo "error: library search path not recognized"
+ liberror_die $ERR_FATAL
+ else
+ path="$WARD_PATH/../$path"
+ fi
+
+ while [[ $# -gt 0 ]]
+ do
+ file="$1"
+ shift
+
+ [[ -f "$file" ]] || continue
+
+ list=($(grep -o "^[ ]*[a-z]\+_[a-z_]\+" "$file" | sed 's/^ *//' | sort
-u))
+ # for each called function, check prefix by prefix
+ for function in "${list[@]}"
+ do
+ # check if the function is defined somewhere in the file it came from
+ grep -q "^function $function() {" "$file" && continue
+
+ # seed the defines variable for the loop below
+ local mangle="$function"
+
+ # check against the prefixes, one at a time
+ while $(echo $mangle | grep -q '^[a-z]\+_[a-z_]\+')
+ do
+ prefix="${mangle%%_*}"
+ [[ "$prefix" == "enchant" ]] && prefix="enchantment"
+
+ # check for the function in a library file matching the prefix
+ if [[ -f "$path/lib$prefix" ]]
+ then
+ if grep -q "^function $function() {" "$path/lib$prefix"
+ then
+ matched="yes"
+ break
+ fi
+ elif [[ -f "$path/lib.$prefix" ]]
+ then
+ if grep -q "^function $function() {" "$path/lib.$prefix"
+ then
+ matched="yes"
+ break
+ fi
+ fi
+
+ # no match yet, strip the prefix and repeat
+ mangle="${mangle#*_}"
+ done
+
+ # if the function isn't defined in the corresponding file, warn the
user
+ if [[ -z "$matched" ]]
+ then
+ echo "$(libcolor_file $file): $(libcolor_warn $function)"
+ fi
+ done
+ done
+}
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/local_variables b/ward/local_variables
new file mode 100755
index 0000000..e69de29
diff --git a/ward/return_values b/ward/return_values
new file mode 100755
index 0000000..e69de29
diff --git a/ward/ward-all b/ward/ward-all
new file mode 100755
index 0000000..eb67406
--- /dev/null
+++ b/ward/ward-all
@@ -0,0 +1,53 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Runs all the necessary tests against the Cauldron codebase to ensure
+## quality releases.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+WARD_PATH="$(dirname $0)"
+PATH="$WARD_PATH:$PATH"
+
+TESTERS=(
+ "test-configvars"
+ "test-errorcodes"
+ "test-functions"
+ )
+
+for tester in "${TESTERS[@]}"
+do
+ echo ""
+ echo "RUNNING: $tester"
+ $tester
+done | $PAGER
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/ward-configvars b/ward/ward-configvars
new file mode 100755
index 0000000..131d759
--- /dev/null
+++ b/ward/ward-configvars
@@ -0,0 +1,106 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of global configurable variables (those listed in the
+## etc/config files), and ensures that they are defined in the relevant
+## config files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+
+WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
+
+cauldron="$WARD_PATH/../cauldron"
+c_conf="$cauldron/etc/config"
+
+enchantment="$WARD_PATH/../enchantment"
+e_conf="$enchantment/etc/config"
+
+if ! . "$WARD_PATH/libdelint"
+then
+ echo "error: could not load $WARD_PATH/libdelint"
+ exit 1
+fi
+
+# source the list of cauldron source files to examine
+if ! . "$WARD_PATH/cauldron_sources"
+then
+ echo "error: could not load cauldron_sources"
+ exit $ERR_FATAL
+fi
+# source the list of enchantment source files to examine
+if ! . "$WARD_PATH/enchantment_sources"
+then
+ echo "error: could not load enchantment_sources"
+ exit $ERR_FATAL
+fi
+
+function ward_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n]
+
+Calls the global_variables delinter to check whether there are error codes
used
+in the known cauldron and enchantment source files that aren't defined in the
+respective errorcodes files. If passed -n, color output is disabled.
+EndUsage
+}
+
+function ward_usage() {
+ ward_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -eq 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ ward_usage
+ fi
+fi
+
+# check cauldron files
+libcolor_notice "Checking cauldron config variables"
+echo ""
+ward_global_variables "$c_conf" "${cauldron_srcs[@]}" | \
+ grep -v '[^A-Z_]ERR_[A-Z_]*'
+
+# check enchantment files
+libcolor_notice "Checking enchantment config variables"
+echo ""
+ward_global_variables "$e_conf" "${enchantment_srcs[@]}" | \
+ grep -v '[^A-Z_]ERR_[A-Z_]*'
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/ward-errorcodes b/ward/ward-errorcodes
new file mode 100755
index 0000000..98b73cc
--- /dev/null
+++ b/ward/ward-errorcodes
@@ -0,0 +1,114 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of error codes, and ensures that they are defined in the
+## relevant errorcodes files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
+
+cauldron="$WARD_PATH/../cauldron"
+c_codes="$cauldron/errorcodes"
+
+enchantment="$WARD_PATH/../enchantment"
+e_codes="$enchantment/errorcodes"
+
+if ! . "$WARD_PATH/libdelint"
+then
+ echo "error: could not load $WARD_PATH/libdelint"
+ exit 1
+fi
+
+# source the list of cauldron source files to examine
+if ! . "$WARD_PATH/cauldron_sources"
+then
+ echo "error: could not load cauldron_sources"
+ exit $ERR_FATAL
+fi
+# source the list of enchantment source files to examine
+if ! . "$WARD_PATH/enchantment_sources"
+then
+ echo "error: could not load enchantment_sources"
+ exit $ERR_FATAL
+fi
+
+function ward_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n]
+
+Calls the global_variables delinter to check whether there are error codes
used
+in the known cauldron and enchantment source files that aren't defined in the
+respective errorcodes files. If passed -n, color output is disabled.
+EndUsage
+}
+
+function ward_usage() {
+ ward_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -eq 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ ward_usage
+ fi
+fi
+
+# check cauldron error codes/messages files for internal consistency
+libcolor_notice "Checking cauldron errorcodes for internal consistency"
+echo ""
+ward_error_codes "$c_codes"
+
+# check cauldron files
+libcolor_notice "Checking cauldron sources for undefined error codes"
+echo ""
+ward_global_variables "$c_codes" "${cauldron_srcs[@]}" | \
+ grep '[^A-Z_]ERR_[A-Z_]*'
+
+# check enchantment error codes/messages files for internal consistency
+libcolor_notice "Checking enchantment errorcodes for internal consistency"
+echo ""
+ward_error_codes "$e_codes"
+
+# check enchantment files
+libcolor_notice "Checking enchantment sources for undefined error codes"
+echo ""
+ward_global_variables "$e_codes" "${enchantment_srcs[@]}" | \
+ grep '[^A-Z_]ERR_[A-Z_]*'
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/ward-functions b/ward/ward-functions
new file mode 100755
index 0000000..1c443b9
--- /dev/null
+++ b/ward/ward-functions
@@ -0,0 +1,102 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of global configurable variables (those listed in the
+## etc/config files), and ensures that they are defined in the relevant
+## config files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+
+WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
+
+cauldron="$WARD_PATH/../cauldron"
+
+enchantment="$WARD_PATH/../enchantment"
+
+if ! . "$WARD_PATH/libdelint"
+then
+ echo "error: could not load $WARD_PATH/libdelint"
+ exit 1
+fi
+
+# source the list of cauldron source files to examine
+if ! . "$WARD_PATH/cauldron_sources"
+then
+ echo "error: could not load cauldron_sources"
+ exit $ERR_FATAL
+fi
+# source the list of enchantment source files to examine
+if ! . "$WARD_PATH/enchantment_sources"
+then
+ echo "error: could not load enchantment_sources"
+ exit $ERR_FATAL
+fi
+
+function ward_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n]
+
+Calls the functions delinter to check whether there are functions called in
the
+known cauldron and enchantment source files that aren't defined in the
+respective library files. If passed -n, color output is disabled.
+EndUsage
+}
+
+function ward_usage() {
+ ward_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -eq 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ ward_usage
+ fi
+fi
+
+# check cauldron files
+libcolor_notice "Checking cauldron functions"
+echo ""
+ward_functions "cauldron" "${cauldron_srcs[@]}"
+
+# check enchantment files
+libcolor_notice "Checking enchantment functions"
+echo ""
+ward_functions "enchantment" "${enchantment_srcs[@]}"
+
+#-------------------------------------------------------------------------------
+##
+## This software 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.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/ward/ward-localvars b/ward/ward-localvars
new file mode 100755
index 0000000..e69de29




Archive powered by MHonArc 2.6.24.

Top of Page