From 155d247ef93ee483bc64936601f8cc2313867858 Mon Sep 17 00:00:00 2001 From: nishi Date: Tue, 23 Apr 2024 02:16:06 +0000 Subject: [PATCH] replace git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@4 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- HEADER | 1 + Makefile | 12 ++++++++++- Tool/configgen.c | 30 ++++++++++++++++++++++++++ replace.pl | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 HEADER create mode 100755 replace.pl diff --git a/HEADER b/HEADER new file mode 100644 index 0000000..9d91f81 --- /dev/null +++ b/HEADER @@ -0,0 +1 @@ +Lisp Dialect diff --git a/Makefile b/Makefile index 3e02d44..3f0f096 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SUFFIX = .include "platform.mk" -.PHONY: all ./Serenade +.PHONY: all ./Serenade ./Tool replace all: ./Tool ./Serenade @@ -21,3 +21,13 @@ all: ./Tool ./Serenade clean: $(MAKE) -C ./Tool clean $(MAKE) -C ./Serenade clean + +FILES = `find . -name "*.c" -or -name "*.h"` + +replace: + for i in $(FILES); do \ + echo -n "$$i ... "; \ + perl replace.pl < $$i > $$i.new; \ + mv $$i.new $$i; \ + echo "done"; \ + done diff --git a/Tool/configgen.c b/Tool/configgen.c index d582ac4..4c67be6 100644 --- a/Tool/configgen.c +++ b/Tool/configgen.c @@ -1,3 +1,33 @@ +/* $Id$ */ +/* --- START LICENSE --- */ +/* -------------------------------------------------------------------------- */ +/* Lisp Dialect */ +/* -------------------------------------------------------------------------- */ +/* 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 --- */ + #include int main(){} diff --git a/replace.pl b/replace.pl new file mode 100755 index 0000000..6060d5e --- /dev/null +++ b/replace.pl @@ -0,0 +1,55 @@ +#!/usr/bin/env perl +# $Id: replace.pl 269 2024-03-29 02:14:50Z nishi $ +# 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