diff options
author | dmg <dmg@uvic.ca> | 2014-04-06 21:36:32 -0700 |
---|---|---|
committer | dmg <dmg@uvic.ca> | 2014-04-06 21:38:00 -0700 |
commit | 5d23990da5e2b4ee9a2830aba47bae6c8674f6c5 (patch) | |
tree | 222f3d3f054ff48f182e1f15c1b583bfff0554f9 | |
parent | b689e53e4d55994661a3ce810b3e9b40afc6b56c (diff) | |
download | ninka-5d23990da5e2b4ee9a2830aba47bae6c8674f6c5.tar.gz |
escaped aposthrophes
-rwxr-xr-x | extComments/extComments.pl | 35 | ||||
-rwxr-xr-x | matcher/matcher.pl | 11 | ||||
-rw-r--r-- | matcher/rules.dict | 31 | ||||
-rwxr-xr-x | ninka.pl | 24 |
4 files changed, 58 insertions, 43 deletions
diff --git a/extComments/extComments.pl b/extComments/extComments.pl index a270b5a..4fdf9bb 100755 --- a/extComments/extComments.pl +++ b/extComments/extComments.pl @@ -42,6 +42,14 @@ print STDERR "Usage $0 -v my $f = $ARGV[0]; +my $original = $f; + +$f =~ s/'/\\'/g; +$f =~ s/\$/\\\$/g; +$f =~ s/;/\\;/g; +$f =~ s/ /\\ /g; + + #die "illegal file [$f]" if $f =~ m@/\.@; my $numberComments = 1; @@ -49,20 +57,22 @@ $numberComments = $opts{c} if exists $opts{c}; my $verbose = 1; $verbose = exists $opts{v}; - - -if (get_size($f) == 0) { +if (get_size($original) == 0) { print STDERR "Empty file, just exit\n" if $verbose; exit 0; # nothing to report, just end } + + + + my $commentsCmd = Determine_Comments_Extractor($f); execute("$commentsCmd"); if ($commentsCmd =~ /^comments/ and get_size("${f}.comments") == 0){ - `cat '$f' | head -700 > ${f}.comments`; + `cat $f | head -700 > ${f}.comments`; } exit 0; @@ -71,6 +81,7 @@ exit 0; sub Determine_Comments_Extractor { my ($f) = @_; + if ($f =~ /\.([^\.]+)$/) { my $ext= $1; @@ -79,26 +90,26 @@ sub Determine_Comments_Extractor ######################## # for the time being, let us just extract the top 400 lines - return "cat '$f' | head -400 > '${f}.comments'"; -# return "$path/hashComments.pl -p '#' '$f'"; + return "cat $f | head -400 > ${f}.comments"; +# return "$path/hashComments.pl -p '#' $f"; } elsif ($ext eq "jl" or $ext eq "el" ) { - return "cat '$f' | head -400 > '${f}.comments'"; -# return "$path/hashComments.pl -p ';' '$f'";; + return "cat $f | head -400 > ${f}.comments"; +# return "$path/hashComments.pl -p ';' $f";; } elsif ($ext =~ /^(java|c|cpp|h|cxx|c\+\+|cc)$/ ) { my $comm = `which comments`; if ($comm ne "") { - return "comments -c1 '$f' 2> /dev/null"; + return "comments -c1 $f 2> /dev/null"; } else { - return "cat '$f' | head -400 > '${f}.comments'"; + return "cat $f | head -400 > ${f}.comments"; } } else { - return "cat '$f' | head -700 > '${f}.comments'"; + return "cat $f | head -700 > ${f}.comments"; } } else { print "\n>>>>>>>>>>>>>>>>>>>>>\n"; - return "cat '$f' | head -700 > '${f}.comments'"; + return "cat $f | head -700 > ${f}.comments"; } } diff --git a/matcher/matcher.pl b/matcher/matcher.pl index c1a46ae..49cd567 100755 --- a/matcher/matcher.pl +++ b/matcher/matcher.pl @@ -64,6 +64,9 @@ $NonCriticalRules{"LesserGPLv2.1"} = [@gplNonCritical]; $NonCriticalRules{"LGPLv2orv3"}= [@gplNonCritical]; $NonCriticalRules{"LesserGPLv2"} = [@gplNonCritical]; $NonCriticalRules{"LesserGPLv2+"} = [@gplNonCritical]; +$NonCriticalRules{"GPLVer2.1or3KDE+"} = [@gplNonCritical]; +$NonCriticalRules{"LGPLVer2.1or3KDE+"} = [@gplNonCritical]; + $NonCriticalRules{"GPLv2+"} = [@gplNonCritical]; $NonCriticalRules{"GPLv2"} = [@gplNonCritical]; @@ -75,8 +78,8 @@ $NonCriticalRules{"AGPLv3"} = [@gplNonCritical, 'AGPLreceivedVer0','AGPLseeVer0' $NonCriticalRules{"AGPLv3+"} = [@gplNonCritical, 'AGPLreceivedVer0','AGPLseeVer0']; $NonCriticalRules{"GPLnoVersion"} = [@gplNonCritical]; -$NonCriticalRules{"Apachev1.1"} = ['ApacheLic1_1']; -$NonCriticalRules{"Apachev2"} = ['ApachePre','ApacheSee']; +$NonCriticalRules{"Apache-1.1"} = ['ApacheLic1_1']; +$NonCriticalRules{"Apache-2"} = ['ApachePre','ApacheSee']; $NonCriticalRules{"LibGCJLic"} = ['LibGCJSee']; $NonCriticalRules{"CDDLicV1"} = ['Compliance','CDDLicWhere','ApachesPermLim','CDDLicIncludeFile','UseSubjectToTerm', 'useOnlyInCompliance']; @@ -106,9 +109,7 @@ $NonCriticalRules{"MPLv1_1"} = ['licenseBlockBegin','MPLsee','Copyright','licens $NonCriticalRules{"MPL1_1andLGPLv2_1"} = ["MPLoptionIfNotDelete2licsVer0",'MPL_LGPLseeVer0']; $NonCriticalRules{"FreeType"} = ["FreeTypeNotice"]; - -$NonCriticalRules{"GPLVer2.1or3KDE+"} = [@gplNonCritical]; -$NonCriticalRules{"LGPLVer2.1or3KDE+"} = [@gplNonCritical]; +$NonCriticalRules{"boostV1"} = ["boostSeev1", "SeeFile"]; # initialize diff --git a/matcher/rules.dict b/matcher/rules.dict index 1055eca..28d274a 100644 --- a/matcher/rules.dict +++ b/matcher/rules.dict @@ -19,8 +19,6 @@ GPL2orBSD3:BSDpre,BSDcondSourceExtrict,BSDcondBinaryExtrict,BSDcondEndorse,Altern,GPLGenVer2,BSDasIsExtrict,BSDWarrExtrict - - GPLv2:GPLv2 GPLv2+:GPLv2\+ GPLv3+:GPLv3\+ @@ -134,24 +132,25 @@ openSSL:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdv,OpenSSLendorse,OpenSSLwrit openSSLvar1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart1,BSDcondAdvPart2,SSLeayWindows,BSDcondAdvPart2,BSDasIs,BSDWarr,NoLicenseChangeAllowed openSSLvar3:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart1,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,BSDasIs,BSDWarr -Apachev1.0:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart1,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,OpenSSLAckPart1,BSDcondAdvPart2,BSDasIs,BSDWarr -Apachev1.1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdv,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,OpenSSLAck,BSDasIs,BSDWarr -Apachev1.1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart1,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,BSDasIs,BSDWarr -Apachev1.1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,BSDasIs,BSDWarr -Apachev1.1:BSDpre,BSDcondSourceExtrict,BSDcondBinary,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,BSDasIs,BSDWarr +Apache-1.0:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart1,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,OpenSSLAckPart1,BSDcondAdvPart2,BSDasIs,BSDWarr +Apache-1.1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdv,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,OpenSSLAck,BSDasIs,BSDWarr +Apache-1.1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart1,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,BSDasIs,BSDWarr +Apache-1.1:BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,BSDasIs,BSDWarr +Apache-1.1:BSDpre,BSDcondSourceExtrict,BSDcondBinary,BSDcondAdvPart2,OpenSSLendorse,OpenSSLwritCond,OpenSSLName,BSDasIs,BSDWarr # this is dangerous. The v2 applies to apache (ninka-ism) -ApacheV2orLGPLgeneric:apacheAndLGPLgenVer2.0 +Apache-2orLGPLgeneric:apacheAndLGPLgenVer2.0 SleepyCat:BSDpre,BSDcondSource,BSDcondBinary,SleepyCatObtain,SleepyCatSourceIncluded,SleepyCatSourceComplete,SleepyCatDoesNotInclude,SleepyCatAsIs,BSDWarr -boost:boostPermission,boostPreserve,boostAsIs,boostWarr -boostV1:boostRefv1 -boostV1Ref:boostSeev1 +boost-1:boostPermission,boostPreserve,boostAsIs,boostWarr +boost-1:boostRefv1 +boost-1ref:boostSeev1 + SSLeay:SSLCopy,SSLeayAttrib,SSLeayAdType,BSDpre,BSDcondSource,BSDcondBinary,BSDcondAdvRULE,SSLeayCrypto,SSLeayWindows,BSDasIs,BSDWarr,SSLeayCantChangeLic # qt -Qt:qtCommercialuseVer0 +QPLt:qtCommercialuseVer0 orLGPLVer2.1:qtLGPLVer2.1 orLGPLVer2:qtLGPLv2 orGPLv3:qtGPLVer3.0 @@ -171,7 +170,7 @@ Cecill:CecillEn1,CecillEn2,CecillEn3,CecillEn4,CecillEn5,CecillEn6,CecillEn7,Cec SimpleOnlyKeepCopyright:SimpleOnlyKeepCopyright #------------ -QTv1:QTv1 +QPLv1:QTv1 CDDLv1orGPLv2:CDDLorGPLv2ifYouWish,CDDLorGPLv2IfYouAdd CDDLorGPLv2:CDDLorGPLVer2 @@ -233,8 +232,8 @@ EPLv1:EPLv1 CDDLic:CDDLic CDDLicV1:CDDLicV1Only #---------------------------------------------------------------------- -Apachev2:Apachev2,ApacheLicWherePart1,ApacheLicWherePart2v2,ApachesAsIs,ApachesPermLim -Apachev2:Apachev2,ApacheLicWherePart1,ApacheLicWherePart2v2 +Apache-2:Apachev2,ApacheLicWherePart1,ApacheLicWherePart2v2,ApachesAsIs,ApachesPermLim +Apache-2:Apachev2,ApacheLicWherePart1,ApacheLicWherePart2v2 # publid comain publicDomain:publicDomain @@ -312,7 +311,7 @@ SameAsPerl:SameAsPerl ArtisticLicensev1:ArtisticLicensev1 # QT triple license, outdated :) -QtGPLv2or3:qtGPLv2or3 +QplGPLv2or3:qtGPLv2or3 FreeType:FreeType ## @@ -74,9 +74,13 @@ my $forceLicense = exists $opts{L}; my $f = $ARGV[0]; -my $original = $f; +my $original = $f; +$f =~ s/'/\\'/g; +$f =~ s/\$/\\\$/g; +$f =~ s/;/\\;/g; +$f =~ s/ /\\ /g; print "Starting: $original;\n" if ($verbose); @@ -87,38 +91,38 @@ my $sentencesFile = "${f}.sentences"; my $goodsentFile = "${f}.goodsent"; my $sentokFile = "${f}.senttok"; -if (not (-f "$f")) { - print "ERROR;[${f}] is not a file\n" ; +if (not (-f $original)) { + print "ERROR;[${original}] is not a file\n" ; exit 0; } Do_File_Process($original, $commentsFile, ($force or $forceComments), - "$path/extComments/extComments.pl -c1 '${original}'", + "$path/extComments/extComments.pl -c1 ${f}", "Creating comments file", exists $opts{c}); Do_File_Process($commentsFile, $sentencesFile, ($force or $forceSentences), - "$path/splitter/splitter.pl '${commentsFile}'", + "$path/splitter/splitter.pl ${commentsFile}", "Splitting sentences", exists $opts{s} ); Do_File_Process( $sentencesFile, $goodsentFile, ($force or $forceGood), - "$path/filter/filter.pl '${sentencesFile}'", + "$path/filter/filter.pl ${sentencesFile}", "Filtering good sentences", exists $opts{s} ); Do_File_Process($goodsentFile, $sentokFile, ($force or $forceSentok), - "$path/senttok/senttok.pl '${goodsentFile}' > '${sentokFile}'", + "$path/senttok/senttok.pl ${goodsentFile} > ${sentokFile}", "Matching sentences against rules", exists $opts{t} ); print "Matching ${f}.senttok against rules" if ($verbose); -execute("$path/matcher/matcher.pl '${f}.senttok' > '${f}.license'"); +execute("$path/matcher/matcher.pl ${f}.senttok > ${f}.license"); -print `cat '${f}.license'`; +print `cat ${f}.license`; unlink("${f}.code"); @@ -126,7 +130,7 @@ if ($delete) { unlink("${f}.badsent"); unlink("${f}.comments"); unlink("${f}.goodsent"); -# unlink("${f}.sentences"); + unlink("${f}.sentences"); unlink("${f}.senttok"); } |