Return-Path: X-Original-To: apmail-incubator-jena-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-jena-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AE7A84DF8 for ; Wed, 29 Jun 2011 20:36:14 +0000 (UTC) Received: (qmail 35258 invoked by uid 500); 29 Jun 2011 20:36:14 -0000 Delivered-To: apmail-incubator-jena-commits-archive@incubator.apache.org Received: (qmail 35236 invoked by uid 500); 29 Jun 2011 20:36:14 -0000 Mailing-List: contact jena-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-dev@incubator.apache.org Delivered-To: mailing list jena-commits@incubator.apache.org Received: (qmail 35229 invoked by uid 99); 29 Jun 2011 20:36:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jun 2011 20:36:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jun 2011 20:36:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8B4E22388980; Wed, 29 Jun 2011 20:35:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1141234 - /incubator/jena/Jena2/ARQ/trunk/apacheize Date: Wed, 29 Jun 2011 20:35:52 -0000 To: jena-commits@incubator.apache.org From: andy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110629203552.8B4E22388980@eris.apache.org> Author: andy Date: Wed Jun 29 20:35:52 2011 New Revision: 1141234 URL: http://svn.apache.org/viewvc?rev=1141234&view=rev Log: (empty) Modified: incubator/jena/Jena2/ARQ/trunk/apacheize Modified: incubator/jena/Jena2/ARQ/trunk/apacheize URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/apacheize?rev=1141234&r1=1141233&r2=1141234&view=diff ============================================================================== --- incubator/jena/Jena2/ARQ/trunk/apacheize (original) +++ incubator/jena/Jena2/ARQ/trunk/apacheize Wed Jun 29 20:35:52 2011 @@ -1,46 +1,45 @@ #!/usr/bin/perl # Remove old head/tail /*...*/ comments and add apache boilerplate. -# find DIRS -name \*.java -o -name .svn -prune | xargs perl perl-script -# TODO Remove only last /*..*/ comment, not all the ones after last } +# find DIRS -name \*.java -o -name .svn -prune | xargs -n 1 perl -i.bak perl-script +# find src* -name \*.java -print -o -name .svn -prune | xargs -n 1 perl -i.bak ../ARQ/apacheize -&setExclude ; -undef $/ ; +# TODO +## Comments /** with ending **/ confuse this script. -$HTEXT="HEADER" ; -$TTEXT="TRAILER" ; +$HTEXT= <<'END'; +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +END -while(defined($file = shift @ARGV)) -{ - # Excludes - next if ( defined($exclude{$file}) ) ; - &process($file) ; -} +$TTEXT="" ; -sub process -{ - my $file = @_[0] ; - open(FILE, "<$file") || die ; - binmode FILE ; - $_ = ; - my $t = &clean($_) ; - print $HTEXT,"\n" ; - print $t ; - print "\n" unless ( $t =~ /\n$/s ) ; - print $TTEXT,"\n" ; -} -## head and tail -sub clean -{ - my $text = @_[0] ; - ## These remove multipl adjacent comments - # remove first comment +undef $/ ; +$text = <> ; +# Protect // /* and " /* +$text =~ s!//(.*)/\*!//$1/-XYXY-!g ; +$text =~ s!//(.*)"\*!//$1"-XYXY-!g ; -## $text =~ s!^\s*/\*[^{}/]*\*/\s*!!s ; -## $text =~ s!\s*/\*[^{}]*\*/\s*$!!s ; +## These remove multiple adjacent comments +# remove first comment - $text =~ s!^ ## Start of file. +$text =~ s!^ ## Start of file. \s* ## Whitespace /\* ## Start of comment [^*]*\*+ ## Any non-* then 1-or-more * @@ -49,8 +48,8 @@ sub clean \s* ## Whitespace !!sx ; - # Blocks *(not/)-starting text - $text =~ s! +# Blocks *(not/)-starting text +$text =~ s! \s* ## Whitespace /\* ## Start of comment [^*]*\*+ ## Any non-* then 1-or-more * @@ -58,25 +57,20 @@ sub clean / ## Close / for the comment \s*$ ## Whitespace, end of file !!sx ; - return $text ; -} -## # Head -## if ( m!^\s*/\*[^{}]*\*/!s ) -## { -## ##print "HEAD\n" ; -## $head = $& ; -## ##print $head,"\n" ; -## ##print "HEAD\n" ; -## } -## if ( m!/\*[^{}]*\*/\s*$!s ) -## { -## ##print "TAIL\n" ; -## $tail = $& ; -## ##print $tail,"\n" ; -## ##print "TAIL\n" ; -## } +$text = trim($text) ; +$text =~ s!-XYXY-!\*!g ; + +print $HTEXT,"\n" ; +print $text ; +print "\n" unless ( $text =~ /\n$/s ) ; +print $TTEXT,"\n" if ( $TTEXT ne "" ) ; -sub setExclude +# Perl trim function to remove whitespace from the start and end of the string +sub trim($) { + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + return $string; }