Update, rename and clean up various scripts

Rename contrib/tools/chkfmt to contrib/tools/chkfmt.sh; refactor:
 * Increase the max line length for contrib/**/*.[ch] from 96 to 100.
 * Set the max line length for ci_*.sh to 100.
 * Use `basename $0` instead of the hard-coded script name.
 * Update comments.

Remove contrib/tools/reindent. For automated code formatting, including
indentation, we need a robust solution.

Add an empty line after the hashbang line in all scripts.

Remove the "last changed" version info from comment headers.
(The version control system maintains this information automatically.)
This commit is contained in:
Cosmin Truta 2022-11-20 20:21:41 +02:00
parent 689e06516b
commit f6036c0aeb
7 changed files with 46 additions and 63 deletions

View File

@ -1,12 +1,10 @@
#!/bin/sh
#
# Make a set of test PNG files, MAKEPNG is the name of the makepng executable
# built from contrib/libtests/makepng.c
# Copyright (c) 2015 John Cunningham Bowler
# Last changed in libpng 1.6.20 [December 3, 2015]
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h

View File

@ -1,21 +1,28 @@
#!/bin/sh
# chkfmt
# chkfmt.sh
#
# COPYRIGHT: Written by John Cunningham Bowler, 2010.
# COPYRIGHT:
# Written by John Cunningham Bowler, 2010.
# Revised by Cosmin Truta, 2022.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
# related or neighboring rights to this work. The author published this work
# from the United States.
#
# Check the format of the source files in the current directory - checks for a
# line length of 80 characters max and no tab characters.
# Check the format of the source files in the current directory:
#
# * The lines should not exceed a predefined maximum length.
# * Tab characters should appear only where necessary (e.g. in makefiles).
#
# Optionally arguments are files or directories to check.
#
# -v: output the long lines (makes fixing them easier)
# -e: spawn an editor for each file that needs a change ($EDITOR must be
# defined). When using -e the script MUST be run from an interactive
# command line.
# -v: output the long lines (makes fixing them easier)
# -e: spawn an editor for each file that needs a change ($EDITOR must be
# defined). When using -e the script MUST be run from an interactive
# command line.
script_name=`basename "$0"`
verbose=
edit=
vers=
@ -32,14 +39,14 @@ test "$1" = "-e" && {
# Copy the standard streams for the editor
exec 3>&0 4>&1 5>&2
else
echo "chkfmt -e: EDITOR must be defined" >&2
echo "$script_name -e: EDITOR must be defined" >&2
exit 1
fi
}
# Function to edit a single file - if the file isn't changed ask the user
# whether or not to continue. This stuff only works if the script is run from
# the command line (otherwise, don't specify -e or you will be sorry).
# whether or not to continue. This stuff only works if the script is run
# from the command line (otherwise, don't specify -e or you will be sorry).
doed(){
cp "$file" "$file".orig
"$EDITOR" "$file" 0>&3 1>&4 2>&5 3>&- 4>&- 5>&- || exit 1
@ -53,19 +60,22 @@ doed(){
return 0
}
# In beta versions the version string which appears in files can be a little
# long and cause spuriously overlong lines. To avoid this substitute the version
# string with a 'standard' version a.b.cc before checking for long lines.
# In beta versions, the version string which appears in files can be a little
# long and cause spuriously overlong lines. To avoid this, substitute the
# version string with a placeholder string "a.b.cc" before checking for long
# lines.
# (Starting from libpng version 1.6.36, we switched to a conventional Git
# workflow, and we are no longer publishing beta versions.)
if test -r png.h
then
vers="`sed -n -e \
's/^#define PNG_LIBPNG_VER_STRING .\([0-9]\.[0-9]\.[0-9][0-9a-z]*\).$/\1/p' \
png.h`"
echo "chkfmt: checking version $vers"
echo "$script_name: checking version $vers"
fi
if test -z "$vers"
then
echo "chkfmt: png.h not found, ignoring version number" >&2
echo "$script_name: png.h not found, ignoring version number" >&2
fi
test -n "$1" || set -- .
@ -89,13 +99,16 @@ find "$@" \( -type d \( -name '.git' -o -name '.libs' -o -name 'projects' \) \
check_tabs=
line_length=100;;
*.awk)
# Includes literal tabs
# Allow literal tabs.
check_tabs=
# The following is arbitrary
# Mainframe line printer, anyone?
line_length=132;;
*/ci_*.sh)
check_tabs=yes
line_length=100;;
*contrib/*/*.[ch])
check_tabs=yes
line_length=96;;
line_length=100;;
*)
check_tabs=yes
line_length=80;;

View File

@ -1,13 +1,11 @@
#!/bin/sh
#
# intgamma.sh
#
# Last changed in libpng 1.6.0 [February 14, 2013]
#
# COPYRIGHT: Written by John Cunningham Bowler, 2013.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
# related or neighboring rights to this work. The author published this work
# from the United States.
#
# Shell script to generate png.c 8-bit and 16-bit log tables (see the code in
# png.c for details).
@ -17,10 +15,10 @@
# (0..255) value and a similar table for the exponent calculation.
#
# "bc" must be on the path when the script is executed, and the math library
# (-lm) must be available
#
# function to print out a list of numbers as integers; the function truncates
# the integers which must be one-per-line
# (-lm) must be available.
# Function to print out a list of numbers as integers; the function truncates
# the integers which must be one-per-line.
function print(){
awk 'BEGIN{
str = ""

View File

@ -1,25 +0,0 @@
#!/bin/sh
# reindent a libpng C source
# COPYRIGHT: Written by Glenn Randers-Pehrson, 2016.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
# Usage:
# reindent inputtabsize outputtabsize inputcontinuestring outputcontinuestring
#
# Assumes that continued lines begin with indentation plus one space, and
# that continued comments begin with indentation plus " *".
#
# eg, to change libpng coding style from 3-space indentation with 4-space
# continuations to 4-space indentation with 2-space continuations:
#
# reindent 3 4 "\t " " " < example.c > example.c_4_2
# and to restore the file back to libpng coding style
# reindent 4 3 " " " " < example.c_4_2 > example.c_3_4
unexpand --first-only --t $1 | \
sed -e "/^ *$3[^\*]/{s/$3/$4/}" | \
expand -t $2

View File

@ -1,4 +1,5 @@
#!/bin/awk -f
# Check a list of symbols against the master definition
# (official) list. Arguments:
#

View File

@ -1,8 +1,7 @@
#!/bin/awk -f
# scripts/dfn.awk - process a .dfn file
#
# last changed in libpng version 1.5.19 - August 21, 2014
#
# Copyright (c) 2013-2014 Glenn Randers-Pehrson
#
# This code is released under the libpng license.

View File

@ -1,8 +1,7 @@
#!/bin/awk -f
# scripts/options.awk - library build configuration control
#
# last changed in libpng version 1.6.11 - June 5, 2014
#
# Copyright (c) 1998-2014 Glenn Randers-Pehrson
#
# This code is released under the libpng license.