Changeset 4250 for lang/perl/Text-MeCab

Show
Ignore:
Timestamp:
01/09/08 08:29:33 (5 years ago)
Author:
daisuke
Message:

lang/perl/Text-MeCab?; use prompt() instead of STDIN and such. Pointed out by David Cantrell

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Text-MeCab/trunk/tools/probe_mecab.pl

    r4157 r4250  
    77use strict; 
    88use File::Spec; 
     9use ExtUtils::MakeMaker; 
    910 
    10 my $interactive = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; 
    1111my($version, $cflags, $libs); 
    1212 
     
    1515# Save the poor puppies that run on Windows 
    1616if ($^O eq 'MSWin32') { 
    17     print <<EOM; 
    18 You seem to be running on an environment that may not have mecab-config 
    19 available. This script uses mecab-config to auto-probe  
    20   1. The version string of libmecab that you are building Text::MeCab 
    21      against. (e.g. 0.90) 
    22   2. Additional compiler flags that you may have built libmecab with, and 
    23   3. Additional linker flags that you may have build libmecab with. 
    24  
    25 Since we can't auto-probe, you should specify the above three to proceed 
    26 with compilation: 
    27 EOM 
    28  
    29     print "Version of libmecab that you are compiling against (e.g. 0.90)? (REQUIRED) [] "; 
    30     $version = <STDIN>; 
    31     chomp($version); 
     17    $version = prompt( 
     18        join( 
     19            "\n", 
     20            "", 
     21            "You seem to be running on an environment that may not have mecab-config", 
     22            "available. This script uses mecab-config to auto-probe", 
     23            "  1. The version string of libmecab that you are building Text::MeCab", 
     24            "     against. (e.g. 0.90)", 
     25            "  2. Additional compiler flags that you may have built libmecab with, and", 
     26            "  3. Additional linker flags that you may have build libmecab with.", 
     27            "", 
     28            "Since we can't auto-probe, you should specify the above three to proceed", 
     29            "with compilation:", 
     30            "", 
     31            "Version of libmecab that you are compiling against (e.g. 0.90)? (REQUIRED) []" 
     32        ) 
     33    ); 
     34    chomp $version; 
    3235    die "no version specified! cowardly refusing to proceed." unless $version; 
    3336 
    34     print "Additional compiler flags (e.g. -DWIN32 -Ic:\\path\\to\\mecab\\sdk)? [] "; 
    35     if ($interactive) { 
    36         $cflags = <STDIN>; 
    37         chomp($cflags); 
    38     } 
     37    $cflags = prompt("Additional compiler flags (e.g. -DWIN32 -Ic:\\path\\to\\mecab\\sdk)? []"); 
    3938 
    40     print "Additional linker flags (e.g. -lc:\\path\\to\\mecab\\sdk\\libmecab.lib? [] "; 
    41     if ($interactive) { 
    42         $libs = <STDIN>; 
    43         chomp($libs); 
    44     } 
     39    $libs = prompt("Additional linker flags (e.g. -lc:\\path\\to\\mecab\\sdk\\libmecab.lib? [] "); 
    4540} else { 
    4641    # try probing in places where we expect it to be 
    4742    my $mecab_config; 
     43    my $default_config; 
    4844    foreach my $path qw(/usr/bin /usr/local/bin) { 
    4945        my $tmp = File::Spec->catfile($path, 'mecab-config'); 
    5046        if (-f $tmp && -x _) { 
    51             $mecab_config = $tmp; 
     47            $default_config = $tmp; 
    5248            last; 
    5349        } 
    5450    } 
    55      
    56     print "Path to mecab config? [$mecab_config] "; 
    57     if ($interactive) { 
    58         my $tmp = <STDIN>; 
    59         chomp $tmp; 
    60         if ($tmp) { 
    61             $mecab_config = $tmp; 
    62         } 
    63     } 
    64      
     51 
     52    $mecab_config = prompt( "Path to mecab config?", $default_config ); 
     53 
    6554    if (!-f $mecab_config || ! -x _) { 
    6655        print STDERR "Can't proceed without mecab-config. Aborting...\n"; 
     
    10392} 
    10493 
    105 my $encoding = 'utf-8'; 
    106 print  
    107     "Text::MeCab needs to know what encoding you built your dictionary with\n", 
    108     "to properly execute tests.\n", 
    109     "\n", 
    110     "Encoding of your mecab dictionary? (shift_jis, euc-jp, utf-8) [$encoding] " 
    111 ; 
    112  
    113 if ($interactive) { 
    114     my $input = <STDIN>; 
    115     chomp $input; 
    116     if ($input) { 
    117         $encoding = $input; 
    118     } 
    119 } 
     94my $default_encoding = 'utf-8'; 
     95my $encoding = prompt( 
     96    join( 
     97        "\n", 
     98        "", 
     99        "Text::MeCab needs to know what encoding you built your dictionary with", 
     100        "to properly execute tests.", 
     101        "", 
     102        "Encoding of your mecab dictionary? (shift_jis, euc-jp, utf-8)", 
     103    ), 
     104    $default_encoding 
     105); 
    120106 
    121107print "Using $encoding as your dictionary encoding\n";