diff options
author | Cosmin Truta <ctruta@gmail.com> | 2022-11-20 20:21:41 +0200 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2022-11-20 20:21:41 +0200 |
commit | f6036c0aeb01ca800bdf41ec5f07ded2ce89d26c (patch) | |
tree | 12b353cbb44cb8c42cf36117d0ec9e1f890e6a2c | |
parent | 689e06516bce26ba0113a70ec15bd80c2e535ccd (diff) | |
download | libpng-f6036c0aeb01ca800bdf41ec5f07ded2ce89d26c.tar.gz |
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.)
-rwxr-xr-x | contrib/testpngs/makepngs.sh | 4 | ||||
-rwxr-xr-x | contrib/tools/chkfmt.sh (renamed from contrib/tools/chkfmt) | 55 | ||||
-rwxr-xr-x | contrib/tools/intgamma.sh | 16 | ||||
-rwxr-xr-x | contrib/tools/reindent | 25 | ||||
-rwxr-xr-x | scripts/checksym.awk | 1 | ||||
-rwxr-xr-x | scripts/dfn.awk | 3 | ||||
-rwxr-xr-x | scripts/options.awk | 5 |
7 files changed, 46 insertions, 63 deletions
diff --git a/contrib/testpngs/makepngs.sh b/contrib/testpngs/makepngs.sh index eb1c15fc9..270f0630a 100755 --- a/contrib/testpngs/makepngs.sh +++ b/contrib/testpngs/makepngs.sh @@ -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 diff --git a/contrib/tools/chkfmt b/contrib/tools/chkfmt.sh index 95181fde2..8810aa7b5 100755 --- a/contrib/tools/chkfmt +++ b/contrib/tools/chkfmt.sh @@ -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;; diff --git a/contrib/tools/intgamma.sh b/contrib/tools/intgamma.sh index 41c5d6dd2..3198cb241 100755 --- a/contrib/tools/intgamma.sh +++ b/contrib/tools/intgamma.sh @@ -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 = "" diff --git a/contrib/tools/reindent b/contrib/tools/reindent deleted file mode 100755 index f4df309b6..000000000 --- a/contrib/tools/reindent +++ /dev/null @@ -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 diff --git a/scripts/checksym.awk b/scripts/checksym.awk index fe3af55e0..48e55e60e 100755 --- a/scripts/checksym.awk +++ b/scripts/checksym.awk @@ -1,4 +1,5 @@ #!/bin/awk -f + # Check a list of symbols against the master definition # (official) list. Arguments: # diff --git a/scripts/dfn.awk b/scripts/dfn.awk index 0dc99df0f..0b25c8a37 100755 --- a/scripts/dfn.awk +++ b/scripts/dfn.awk @@ -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. diff --git a/scripts/options.awk b/scripts/options.awk index fef5dfd78..284811967 100755 --- a/scripts/options.awk +++ b/scripts/options.awk @@ -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. @@ -243,7 +242,7 @@ $1 == "file" && NF >= 2{ # option NAME ( (requires|enables|if) NAME* | on | off | disabled | # sets SETTING VALUE+ )* -# +# # Declares an option 'NAME' and describes its default setting (disabled) # and its relationship to other options. The option is disabled # unless *all* the options listed after 'requires' are set and at |