Fix generation of snowball_create.sql on msvc builds.
authorMagnus Hagander <magnus@hagander.net>
Mon, 27 Aug 2007 10:29:49 +0000 (10:29 +0000)
committerMagnus Hagander <magnus@hagander.net>
Mon, 27 Aug 2007 10:29:49 +0000 (10:29 +0000)
src/backend/snowball/Makefile
src/tools/msvc/Install.pm

index ecdaa9b774e265a1788719e22115e1937d7f7d88..b77fefcb2caa73f06d48c7ca99b33c90a3e80a3e 100644 (file)
@@ -64,7 +64,7 @@ LANGUAGES=  \
        russian         english         \
        spanish         spanish         \
        swedish         swedish         \
-       turkish         turkish         \
+       turkish         turkish
 
 
 SQLSCRIPT= snowball_create.sql
index 37623f25014e17eb98f174e02826a57366237b66..51f2d6e607dd4092cdbd7b11876a27517ceef740 100644 (file)
@@ -64,6 +64,7 @@ sub Install
     );
     GenerateConversionScript($target);
     GenerateTimezoneFiles($target,$conf);
+    GenerateTsearchFiles($target);
     CopyContribFiles($config,$target);
     CopyIncludeFiles($target);
 
@@ -216,6 +217,45 @@ sub GenerateTimezoneFiles
     print "\n";
 }
 
+sub GenerateTsearchFiles
+{
+    my $target = shift;
+
+    print "Generating tsearch script...";
+    my $F;
+    my $tmpl = read_file('src/backend/snowball/snowball.sql.in');
+    my $mf = read_file('src/backend/snowball/Makefile');
+    $mf =~ s{\\\s*[\r\n]+}{}mg;
+    $mf =~ /^LANGUAGES\s*=\s*(.*)$/m
+      || die "Could not find LANGUAGES line in snowball Makefile\n";
+    my @pieces = split /\s+/,$1;
+    open($F,">$target/share/snowball_create.sql")
+      || die "Could not write snowball_create.sql";
+    print $F read_file('src/backend/snowball/snowball_func.sql.in');
+    while ($#pieces > 0)
+    {
+        my $lang = shift @pieces || last;
+        my $latlang = shift @pieces || last;
+        my $txt = $tmpl;
+        my $stop = '';
+
+        if (-s "src/backend/snowball/stopwords/$lang.stop") {
+            $stop = ", StopWords=$lang";
+        }
+
+        $txt =~ s#_LANGNAME_#${lang}#gs;
+        $txt =~ s#_DICTNAME_#${lang}_stem#gs;
+        $txt =~ s#_CFGNAME_#${lang}#gs;
+        $txt =~ s#_LATDICTNAME_#${latlang}_stem#gs;
+        $txt =~ s#_NONLATDICTNAME_#${lang}_stem#gs;
+        $txt =~ s#_STOPWORDS_#$stop#gs;
+        print $F $txt;
+        print ".";
+    }
+    close($F);
+    print "\n";
+}
+
 sub CopyContribFiles
 {
     my $config = shift;