forked from lda/telodendria
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:
parent
24a03ba126
commit
9880aac674
4 changed files with 43 additions and 12 deletions
|
@ -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 <Memory.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
|
22
tools/bin/td
22
tools/bin/td
|
@ -182,20 +182,28 @@ recipe_clean() {
|
|||
rm -r build
|
||||
}
|
||||
|
||||
# Format the source code by updating the copyright headers and
|
||||
# then running indent(1) on each source code file.
|
||||
recipe_format() {
|
||||
find . -name '*.c' -or -name '*.h' | while IFS= read -r src; do
|
||||
# Update copyright comments in sources and header files.
|
||||
recipe_license() {
|
||||
find . -name '*.[ch]' | while IFS= read -r src; do
|
||||
if [ -t 1 ]; then
|
||||
printf "FMT %s%*c\r" $(basename "$src") "16" " "
|
||||
printf "LICENSE %s%*c\r" $(basename "$src") "16" " "
|
||||
fi
|
||||
# Update the headers
|
||||
srcHeader=$(grep -n -m 1 '^ \*/' "$src" | cut -d ':' -f 1)
|
||||
head "-n$srcHeader" "$src" |
|
||||
diff -u -p - LICENSE.txt |
|
||||
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
|
||||
rm $(basename "$src").BAK
|
||||
fi
|
||||
|
|
|
@ -108,7 +108,7 @@ main(int argc, char **argv)
|
|||
char comment[HEADER_EXPR_MAX];
|
||||
int isDocumented = 0;
|
||||
|
||||
Stream *in = NULL;
|
||||
Stream *in = NULL;
|
||||
Stream *out = NULL;
|
||||
|
||||
int opt;
|
||||
|
@ -135,7 +135,7 @@ main(int argc, char **argv)
|
|||
if (!in)
|
||||
{
|
||||
StreamPrintf(StreamStderr(), "Error: %s:%s",
|
||||
optarg, strerror(errno));
|
||||
optarg, strerror(errno));
|
||||
exit = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ main(int argc, char **argv)
|
|||
if (!out)
|
||||
{
|
||||
StreamPrintf(StreamStderr(), "Error: %s:%s",
|
||||
optarg, strerror(errno));
|
||||
optarg, strerror(errno));
|
||||
exit = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ main(int argc, char **argv)
|
|||
if (!*val || *val != '=')
|
||||
{
|
||||
StreamPrintf(StreamStderr(), "Bad register definition: %s",
|
||||
optarg);
|
||||
optarg);
|
||||
exit = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue