Split format recipe into format and license.

Format formats only C source code. License applies the license file to
C source code *and* header files.
This commit is contained in:
Jordan Bancino 2023-04-27 18:03:32 +00:00
parent 24a03ba126
commit 9880aac674
4 changed files with 43 additions and 12 deletions

View file

@ -1,3 +1,26 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <HeaderParser.h> #include <HeaderParser.h>
#include <Memory.h> #include <Memory.h>

View file

@ -1,4 +1,4 @@
/** /*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net> * Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person

View file

@ -182,20 +182,28 @@ recipe_clean() {
rm -r build rm -r build
} }
# Format the source code by updating the copyright headers and # Update copyright comments in sources and header files.
# then running indent(1) on each source code file. recipe_license() {
recipe_format() { find . -name '*.[ch]' | while IFS= read -r src; do
find . -name '*.c' -or -name '*.h' | while IFS= read -r src; do
if [ -t 1 ]; then if [ -t 1 ]; then
printf "FMT %s%*c\r" $(basename "$src") "16" " " printf "LICENSE %s%*c\r" $(basename "$src") "16" " "
fi fi
# Update the headers
srcHeader=$(grep -n -m 1 '^ \*/' "$src" | cut -d ':' -f 1) srcHeader=$(grep -n -m 1 '^ \*/' "$src" | cut -d ':' -f 1)
head "-n$srcHeader" "$src" | head "-n$srcHeader" "$src" |
diff -u -p - LICENSE.txt | diff -u -p - LICENSE.txt |
patch "$src" | grep -v "^Hmm" patch "$src" | grep -v "^Hmm"
done
if [ -t 1 ]; then
printf "%*c\n" "50" " "
fi
}
# Format the source code # Format source code files by running indent(1) on them.
recipe_format() {
find . -name '*.c' | while IFS= read -r src; do
if [ -t 1 ]; then
printf "FMT %s%*c\r" $(basename "$src") "16" " "
fi
if indent "$src"; then if indent "$src"; then
rm $(basename "$src").BAK rm $(basename "$src").BAK
fi fi