mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Changed calc_errno a global int variable so that is may be directly accessed by libcalc users. Further improve help files for help/errno, help/error, help/newerror, help/stoponerror and help/strerror by adding to documentation of the calc error code system as well as libcalc interface where applicable. Changed #define E_USERDEF to #define E__USERDEF. Removed use of E_USERDEF, E__BASE, E__COUNT, and E__HIGHEST from custom/c_sysinfo because the c_sysinfo is just a demo and this will simplify the custom/Makefile. The include file calcerr.h is now the errsym.h include file. The calcerr.tbl has been replaced by errtbl.c and errtbl.h. The calcerr_c.awk, calcerr_c.sed, calcerr_h.awk, and calcerr_h.sed files are now obsolete and have been removed. The calcerr.c and calcerr.h now obsolete and are no longer built. The calc computation error codes, symbols and messages are now in a error_table[] array of struct errtbl. An E_STRING is a string corresponds to an error code #define. For example, the E_STRING for the calc error E_STRCAT, is the string "E_STRING". An E_STRING must now match the regular expression: "^E_[A-Z0-9_]+$". The old array error_table[] of error message strings has been replaced by a new error_table[] array of struct errtbl. The struct errtbl array holds calc errnum error codes, the related E_STRING symbol as a string, and the original related error message. To add new computation error codes, add them near the bottom of the error_table[] array, just before the NULL entry. The ./errcode utility, when run, will verify the consistency of the error_table[] array. The Makefile uses ./errcode -e to generate the contents of help/errorcodes file. The help errorcodes now prints information from the new cstruct errtbl error_table[] array. The help/errorcodes.hdr and help/errorcodes.sed files are now obsolete and have been removed. The Makefile uses ./errcode -d to generate the contents of the errsym.h include file. Updated .gitignore and trailblank to support the above changes.
196 lines
7.1 KiB
Bash
Executable File
196 lines
7.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# trailblank - find trailing blanks and other file format picky issues
|
|
#
|
|
# This tools is used by "make prep".
|
|
#
|
|
# If all is well, this tool prints nothing and does an exit 0.
|
|
# If a problem is found, this tool prints messages and does a non-0 exit.
|
|
#
|
|
# Copyright (C) 2017,2018,2021-2023 Landon Curt Noll
|
|
#
|
|
# Calc is open software; you can redistribute it and/or modify it under
|
|
# the terms of version 2.1 of the GNU Lesser General Public License
|
|
# as published by the Free Software Foundation.
|
|
#
|
|
# Calc 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 Lesser General
|
|
# Public License for more details.
|
|
#
|
|
# A copy of version 2.1 of the GNU Lesser General Public License is
|
|
# distributed with calc under the filename COPYING-LGPL. You should have
|
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
#
|
|
# Under source code control: 2017/05/22 03:28:20
|
|
# File existed as early as: 2017
|
|
#
|
|
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
|
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
|
|
|
# exit code
|
|
#
|
|
export EXIT_CODE=0
|
|
|
|
# Look for leading whiitespace before a tab
|
|
#
|
|
# We exclude binary files, RCS source code history, intermediate
|
|
# compiled files, patch droppings and compiled binary libraries.
|
|
#
|
|
# Last, we have two files that have long lines that, for now,
|
|
# we cannot be as picky about without significant work.
|
|
#
|
|
LEADING_SPACES_BEFORE_TAB=$(
|
|
find . \( -path './NOTES' -o -path './calc' -o -path './ver_calc' -o \
|
|
-name '*.o' -o -name '*.a' -o -name '*ptch*' -o -name 'core*' -o \
|
|
-name '*.orig' -o -name '*.rej' -o -name '*.bak' -o \
|
|
-name '*.ptch' -o -name 'core.*' -o \
|
|
-name '*.so*' -o -name 'calc-static' -o -name 'libcalc.*' -o \
|
|
-name 'sample_many' -o -name 'sample_rand' -o -name 'errcode' -o \
|
|
-path './help/funclist' -o -path './have_stdvs' -o \
|
|
-path './endian' -o -path './no_implicit' -o -name 'chk_c' -o \
|
|
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
|
|
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
|
|
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
|
|
-name 'codeql-analysis.yml' -o -name tags -o -name debug.out \
|
|
\) -prune -o -type f -print0 | \
|
|
xargs -0 egrep -l '^ * * '
|
|
)
|
|
if [[ -n $LEADING_SPACES_BEFORE_TAB ]]; then
|
|
echo
|
|
echo '# files with leading spaces before a tab'
|
|
echo "$LEADING_SPACES_BEFORE_TAB" | sed -e 's/^\.\///'
|
|
EXIT_CODE=1
|
|
fi
|
|
|
|
# Look for trailing whitespace
|
|
#
|
|
# We exclude binary files, RCS source code history, intermediate
|
|
# compiled files, patch droppings and compiled binary libraries.
|
|
#
|
|
# Last, we have two files that have long lines that, for now,
|
|
# we cannot be as picky about without significant work.
|
|
#
|
|
TRAILING_WHITESPACE=$(
|
|
find . \( -path './NOTES' -o -path './calc' -o -path './ver_calc' -o \
|
|
-name '*.o' -o -name '*.a' -o -name '*ptch*' -o -name 'core*' -o \
|
|
-name '*.orig' -o -name '*.rej' -o -name '*.bak' -o \
|
|
-name '*.ptch' -o -name 'core.*' -o \
|
|
-name '*.so*' -o -name 'calc-static' -o -name 'libcalc.*' -o \
|
|
-name 'sample_many' -o -name 'sample_rand' -o -name 'errcode' -o \
|
|
-path './help/funclist' -o -path './have_stdvs' -o \
|
|
-path './endian' -o -path './no_implicit' -o -name 'chk_c' -o \
|
|
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
|
|
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
|
|
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
|
|
-name 'codeql-analysis.yml' -o -name tags -o -name debug.out \
|
|
\) -prune -o -type f -print0 | \
|
|
xargs -0 egrep -l '[ ]$'
|
|
)
|
|
if [[ -n $TRAILING_WHITESPACE ]]; then
|
|
echo
|
|
echo '# files with trailing whitespace'
|
|
echo "$TRAILING_WHITESPACE" | sed -e 's/^\.\///'
|
|
EXIT_CODE=2
|
|
fi
|
|
|
|
# Perform special picky tool phase 0 processing
|
|
#
|
|
# Some of these files must have long lines. Some of these files may not exist.
|
|
#
|
|
if [[ -x /usr/local/bin/picky ]]; then
|
|
PICKY_PHASE_0A=$(/usr/local/bin/picky -w -s -v ./cal/set8700.line \
|
|
.gitignore README.md .lldbinit 2>&1)
|
|
status="$?"
|
|
if [[ $status -ne 0 ]]; then
|
|
echo
|
|
echo '# picky failed on one of the files with long lines'
|
|
echo "$PICKY_PHASE_0A" | sed -e 's/\.\///'
|
|
EXIT_CODE=3
|
|
fi
|
|
if [[ -e conf.h ]]; then
|
|
PICKY_PHASE_0B=$(/usr/local/bin/picky -w -s -v conf.h 2>&1)
|
|
status="$?"
|
|
if [[ $status -ne 0 ]]; then
|
|
echo
|
|
echo '# picky failed on conf.h'
|
|
echo "$PICKY_PHASE_0B" | sed -e 's/\.\///'
|
|
EXIT_CODE=4
|
|
fi
|
|
fi
|
|
if [[ -e errsym.h ]]; then
|
|
PICKY_PHASE_0C=$(/usr/local/bin/picky -w -s -v errsym.h 2>&1)
|
|
status="$?"
|
|
if [[ $status -ne 0 ]]; then
|
|
echo
|
|
echo '# picky failed on errsym.h'
|
|
echo "$PICKY_PHASE_0C" | sed -e 's/\.\///'
|
|
EXIT_CODE=5
|
|
fi
|
|
fi
|
|
else
|
|
echo "# $0: WARNING: /usr/local/bin/picky not found: skipping picky phase 0 checks!" 1>&2
|
|
echo "#" 1>&2
|
|
fi
|
|
|
|
# Picky tool processing phase 1
|
|
#
|
|
# We exclude binary files, source code history, intermediate
|
|
# compiled files, patch droppings and compiled binary libraries.
|
|
#
|
|
# Last, we have files that have long lines that, for now,
|
|
# we cannot be as picky about without significant work.
|
|
#
|
|
PICKY_PHASE_1=$(
|
|
find . \( -path './NOTES' -o -path './calc' -o -path './ver_calc' -o \
|
|
-name '*.o' -o -name '*.a' -o -name '*ptch*' -o -name 'core*' -o \
|
|
-name '*.orig' -o -name '*.rej' -o -name '*.bak' -o \
|
|
-name '*.ptch' -o -name 'core.*' -o \
|
|
-name '*.so*' -o -name 'calc-static' -o -name 'libcalc.*' -o \
|
|
-name 'sample_many' -o -name 'sample_rand' -o -name 'errcode' -o \
|
|
-path './help/funclist' -o -path './have_stdvs' -o \
|
|
-path './endian' -o -path './no_implicit' -o -name 'chk_c' -o \
|
|
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
|
|
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
|
|
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
|
|
-name 'codeql-analysis.yml' -o -name tags -o -name debug.out -o \
|
|
-name '.gitignore' -o -name 'README.md' -o -name '.lldbinit' \
|
|
\) -prune -o -type f -print0 | \
|
|
if [[ -x /usr/local/bin/picky ]]; then
|
|
xargs -0 /usr/local/bin/picky -s -v -w132
|
|
else
|
|
echo "# $0: WARNING: /usr/local/bin/picky not found: skipping picky phase 1 check!" 1>&2
|
|
echo "#" 1>&2
|
|
echo "# $0: NOTICE: The picky tool used is from the following GitHub repo:" 1>&2
|
|
echo "#" 1>&2
|
|
echo "# https://github.com/lcn2/picky for the picky tool GitHub repo." 1>&2
|
|
echo "#" 1>&2
|
|
fi
|
|
)
|
|
if [[ -n $PICKY_PHASE_1 ]]; then
|
|
echo
|
|
echo '# files flagged by picky'
|
|
echo "$PICKY_PHASE_1" | sed -e 's/^picky: \.\///' -e 's/ / - /'
|
|
EXIT_CODE=6
|
|
fi
|
|
|
|
# look for backup Makefiles
|
|
#
|
|
BACKUP_MAKEILES=$(
|
|
find . -name Makefile.bak -print
|
|
)
|
|
if [[ -n $BACKUP_MAKEILES ]]; then
|
|
echo
|
|
echo "# You need execute the following to remove backup Makefiles:"
|
|
echo
|
|
echo "$BACKUP_MAKEILES" | while read file; do
|
|
echo "rm -f $file"
|
|
done
|
|
EXIT_CODE=7
|
|
fi
|
|
|
|
# All Done!!! -- Jessica Noll, Age 2
|
|
#
|
|
exit "$EXIT_CODE"
|