From f54c98a771e3735cac14045da2f46b3219f93cc7 Mon Sep 17 00:00:00 2001 From: nishi Date: Fri, 12 Apr 2024 15:07:04 +0000 Subject: [PATCH] yeah git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@2 f982e544-4a7d-3444-ad1a-fde59a2a69f1 --- .clang-format | 12 ++++++++++ DevForge/Makefile | 18 +++++++++++++++ DevForge/devforge.h | 36 +++++++++++++++++++++++++++++ DevForge/main.c | 31 +++++++++++++++++++++++++ HEADER | 1 + LICENSE | 9 ++++++++ Makefile | 12 +++++++++- replace.pl | 55 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 .clang-format create mode 100644 DevForge/Makefile create mode 100644 DevForge/devforge.h create mode 100644 DevForge/main.c create mode 100644 HEADER create mode 100644 LICENSE create mode 100755 replace.pl diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..26f3286 --- /dev/null +++ b/.clang-format @@ -0,0 +1,12 @@ +--- +# $Id: .clang-format 71 2024-01-26 02:05:40Z nishi $ +Language: Cpp +UseTab: Always +TabWidth: 8 +IndentWidth: 8 +PointerAlignment: Left +ColumnLimit: 1024 +AllowShortIfStatementsOnASingleLine: Always +AllowShortBlocksOnASingleLine: Never +AllowShortLoopsOnASingleLine: true +SpaceBeforeParens: Never diff --git a/DevForge/Makefile b/DevForge/Makefile new file mode 100644 index 0000000..72085cc --- /dev/null +++ b/DevForge/Makefile @@ -0,0 +1,18 @@ +# $Id$ + +.PHONY: all clean + +ifeq ($(shell uname -s),Linux) +LIBS += -ldl +endif + +all: ./devforge + +./devforge: ./main.o + $(CC) $(LDFLAGS) -o $@ $< $(LIBS) + +./main.o: ./main.c ./devforge.h + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + rm -f ./devforge ./*.o diff --git a/DevForge/devforge.h b/DevForge/devforge.h new file mode 100644 index 0000000..52a8dbc --- /dev/null +++ b/DevForge/devforge.h @@ -0,0 +1,36 @@ +/* $Id$ */ +/* --- START LICENSE --- */ +/* -------------------------------------------------------------------------- */ +/* DevForge - Build Automation */ +/* -------------------------------------------------------------------------- */ +/* Copyright (c) 2024 Nishi. */ +/* Redistribution and use in source and binary forms, with or without modific */ +/* ation, are permitted provided that the following conditions are met: */ +/* 1. Redistributions of source code must retain the above copyright noti */ +/* ce, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright n */ +/* otice, this list of conditions and the following disclaimer in the documen */ +/* tation and/or other materials provided with the distribution. */ +/* 3. Neither the name of the copyright holder nor the names of its contr */ +/* ibutors may be used to endorse or promote products derived from this softw */ +/* are without specific prior written permission. */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */ +/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */ +/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */ +/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */ +/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */ +/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */ +/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */ +/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */ +/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */ +/* OF SUCH DAMAGE. */ +/* -------------------------------------------------------------------------- */ +/* --- END LICENSE --- */ + +#ifndef __DEVFORGE_DEVFORGE_H__ +#define __DEVFORGE_DEVFORGE_H__ + +#define DEVFORGE_VERSION "0.0" + +#endif diff --git a/DevForge/main.c b/DevForge/main.c new file mode 100644 index 0000000..0eeea44 --- /dev/null +++ b/DevForge/main.c @@ -0,0 +1,31 @@ +/* $Id$ */ +/* --- START LICENSE --- */ +/* -------------------------------------------------------------------------- */ +/* DevForge - Build Automation */ +/* -------------------------------------------------------------------------- */ +/* Copyright (c) 2024 Nishi. */ +/* Redistribution and use in source and binary forms, with or without modific */ +/* ation, are permitted provided that the following conditions are met: */ +/* 1. Redistributions of source code must retain the above copyright noti */ +/* ce, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright n */ +/* otice, this list of conditions and the following disclaimer in the documen */ +/* tation and/or other materials provided with the distribution. */ +/* 3. Neither the name of the copyright holder nor the names of its contr */ +/* ibutors may be used to endorse or promote products derived from this softw */ +/* are without specific prior written permission. */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */ +/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */ +/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */ +/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */ +/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */ +/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */ +/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */ +/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */ +/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */ +/* OF SUCH DAMAGE. */ +/* -------------------------------------------------------------------------- */ +/* --- END LICENSE --- */ + +int main() {} diff --git a/HEADER b/HEADER new file mode 100644 index 0000000..54b866c --- /dev/null +++ b/HEADER @@ -0,0 +1 @@ +DevForge - Build Automation diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0e2472 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +Copyright (c) 2024 Nishi. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile index 2ade6b6..7614be3 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CFLAGS := -g -std=c99 LDFLAGS := LIBS := -.PHONY: all clean ./DevForge ./Module +.PHONY: all clean format replace ./DevForge ./Module all: ./DevForge ./Module @@ -14,6 +14,16 @@ all: ./DevForge ./Module ./Module:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" + +format: + clang-format -i $(wildcard Module/*.c Module/*.h DevForge/*.c DevForge/*.h) + +replace: + for i in $(wildcard Module/*.c Module/*.h DevForge/*.c DevForge/*.h); do \ + cat $$i | perl replace.pl > $$i.new; \ + mv $$i.new $$i; \ + done + clean: $(MAKE) -C ./DevForge $(MAKE) -C ./Module diff --git a/replace.pl b/replace.pl new file mode 100755 index 0000000..98f6aab --- /dev/null +++ b/replace.pl @@ -0,0 +1,55 @@ +#!/usr/bin/env perl +# $Id$ +# To put LICENSE into the source code + +use IO::Handle; + +my $str = ""; +while(){ + $str = $str . $_; +} + +my $rep = 74; + +my $repl = "/* " . ("-" x $rep) . " */\n"; + +my $io = IO::Handle->new(); + +if(open $io, '<', "HEADER"){ + my $len = 0; + while(<$io>){ + my @list = $_ =~ /.{1,$rep}/g; + for my $s (@list){ + if(length($s) > $len){ + $len = length($s); + } + } + } + $io->close; + open $io, '<', "HEADER"; + while(<$io>){ + my @list = $_ =~ /.{1,$rep}/g; + for my $s (@list){ + $repl = $repl . "/* " . (" " x ($rep - $len - 1)) . "$s" . (" " x ($len - length($s) + 1)) . " */\n"; + } + } + $repl = $repl . "/* " . ("-" x $rep) . " */\n"; +} + +$io = IO::Handle->new(); + +open $io, '<', "LICENSE" or die "$!"; + +while(<$io>){ + my @list = $_ =~ /.{1,$rep}/g; + for my $s (@list){ + $repl = $repl . "/* $s" . (" " x ($rep - length($s))) . " */\n"; + } +} + +$io->close; + +$repl = $repl . "/* " . ("-" x $rep) . " */\n"; + +$str =~ s/\/\* --- START LICENSE --- \*\/\n(.+\n)?\/\* --- END LICENSE --- \*\//\/\* --- START LICENSE --- \*\/\n$repl\/\* --- END LICENSE --- \*\//gs; +print $str; -- 2.43.0