Char-GB18030

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.31  2009-01-29 00:00:00
  - create test data file on execute test.pl
  - require run-time module version
  - rewrite all about "split" logic
  - created by INABA Hitoshi

0.30  2009-01-04 00:00:00
  - support context when calling lc(), lc, uc(), uc
  - support chr(0x5C) ended path on MSWin32
    - file test operators
    - functions lstat(), opendir(), stat(), and unlink()
    - glob() and <WILDCARD>
  - remove pl2ebat.bat, jperl55.bat, jperl58.bat, and jperl510.bat
  - merge esjis.pl into Sjis.pm
  - matched variables $1,$2,$3,... after s/// came to function as it was a description
  - support function of chr, ord, and reverse again
  - add test filetest, pathdir, pathfile, and perlmemo
  - created at kanmi-kissa Hahaso in Chichibu

0.29  2008-11-20 00:00:00
  - remove \G from $your_gap

lib/Egb18030.pm  view on Meta::CPAN

sub Egb18030::u_();
sub Egb18030::g_();
sub Egb18030::k_();
sub Egb18030::T_();
sub Egb18030::B_();
sub Egb18030::M_();
sub Egb18030::A_();
sub Egb18030::C_();
sub Egb18030::glob($);
sub Egb18030::glob_();
sub Egb18030::lstat(*);
sub Egb18030::lstat_();
sub Egb18030::opendir(*$);
sub Egb18030::stat(*);
sub Egb18030::stat_();
sub Egb18030::unlink(@);
sub Egb18030::chdir(;$);
sub Egb18030::do($);
sub Egb18030::require(;$);
sub Egb18030::telldir(*);

sub GB18030::ord(;$);
sub GB18030::ord_();
sub GB18030::reverse(@);

lib/Egb18030.pm  view on Meta::CPAN

    # For example, "nobody"-like users might use /nonexistant
    if (defined $home and ! Egb18030::d($home)) {
        $home = undef;
    }
    return $home;
}

#
# GB18030 file lstat (with parameter)
#
sub Egb18030::lstat(*) {

    local $_ = shift if @_;

    if (-e $_) {
        return CORE::lstat _;
    }
    elsif (_MSWin32_5Cended_path($_)) {

        # Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Egb18030::lstat()
        # on Windows opens the file for the path which has 5c at end.
        # (and so on)

        local *MUST_BE_BAREWORD_AT_HERE;
        if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
            if (wantarray) {
                my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat
                close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
                return @stat;
            }

lib/Egb18030.pm  view on Meta::CPAN

        if (CORE::opendir $dh, "$_[1]/.") {
            return 1;
        }
    }
    return undef;
}

#
# GB18030 file stat (with parameter)
#
sub Egb18030::stat(*) {

    local $_ = shift if @_;

    my $fh = qualify_to_ref $_;
    if (defined fileno $fh) {
        return CORE::stat $fh;
    }
    elsif (-e $_) {
        return CORE::stat _;
    }
    elsif (_MSWin32_5Cended_path($_)) {

        # Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Egb18030::stat()
        # on Windows opens the file for the path which has 5c at end.
        # (and so on)

        local *MUST_BE_BAREWORD_AT_HERE;
        if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) {
            if (wantarray) {
                my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE;
                close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!";
                return @stat;
            }

lib/Egb18030.pm  view on Meta::CPAN

            }
            else {
                $realfilename = "$prefix/$filename";
            }

            if (Egb18030::f($realfilename)) {

                my $script = '';

                if (Egb18030::e("$realfilename.e")) {
                    my $e_mtime      = (Egb18030::stat("$realfilename.e"))[9];
                    my $mtime        = (Egb18030::stat($realfilename))[9];
                    my $module_mtime = (Egb18030::stat(__FILE__))[9];
                    if (($e_mtime < $mtime) or ($mtime < $module_mtime)) {
                        Egb18030::unlink "$realfilename.e";
                    }
                }

                if (Egb18030::e("$realfilename.e")) {
                    my $fh = gensym();
                    if (_open_r($fh, "$realfilename.e")) {
                        if ($^O eq 'MacOS') {
                            CORE::eval q{

lib/Egb18030.pm  view on Meta::CPAN

            else {
                $realfilename = "$prefix/$_";
            }

            if (Egb18030::f($realfilename)) {
                $INC{$_} = $realfilename;

                my $script = '';

                if (Egb18030::e("$realfilename.e")) {
                    my $e_mtime      = (Egb18030::stat("$realfilename.e"))[9];
                    my $mtime        = (Egb18030::stat($realfilename))[9];
                    my $module_mtime = (Egb18030::stat(__FILE__))[9];
                    if (($e_mtime < $mtime) or ($mtime < $module_mtime)) {
                        Egb18030::unlink "$realfilename.e";
                    }
                }

                if (Egb18030::e("$realfilename.e")) {
                    my $fh = gensym();
                    _open_r($fh, "$realfilename.e") or croak "Can't open file: $realfilename.e";
                    if ($^O eq 'MacOS') {
                        CORE::eval q{

lib/Egb18030.pm  view on Meta::CPAN

    Egb18030::fc(...);
    Egb18030::fc_;
    Egb18030::ignorecase(...);
    Egb18030::capture(...);
    Egb18030::chr(...);
    Egb18030::chr_;
    Egb18030::X ...;
    Egb18030::X_;
    Egb18030::glob(...);
    Egb18030::glob_;
    Egb18030::lstat(...);
    Egb18030::lstat_;
    Egb18030::opendir(...);
    Egb18030::stat(...);
    Egb18030::stat_;
    Egb18030::unlink(...);
    Egb18030::chdir(...);
    Egb18030::do(...);
    Egb18030::require(...);
    Egb18030::telldir(...);

  # "no Egb18030;" not supported

=head1 ABSTRACT

lib/Egb18030.pm  view on Meta::CPAN


  # absolute path
  @abspath_file = split(/\n/,`dir /s /b wildcard\\here*.txt 2>NUL`);

  # on COMMAND.COM
  @relpath_file = split(/\n/,`dir /b wildcard\\here*.txt`);
  @abspath_file = split(/\n/,`dir /s /b wildcard\\here*.txt`);

=item * Statistics about link

  @lstat = Egb18030::lstat($file);
  @lstat = Egb18030::lstat_;

  Like Egb18030::stat, returns information on file, except that if file is a symbolic
  link, Egb18030::lstat returns information about the link; Egb18030::stat returns
  information about the file pointed to by the link. If symbolic links are
  unimplemented on your system, a normal Egb18030::stat is done instead. If file is
  omitted, returns information on file given in $_. Returns values (especially
  device and inode) may be bogus.
  This subroutine function when the filename ends with chr(0x5C) on MSWin32.

lib/Egb18030.pm  view on Meta::CPAN


  $rc = Egb18030::opendir(DIR,$dir);

  This subroutine opens a directory named $dir for processing by readdir, telldir,
  seekdir, rewinddir, and closedir. The subroutine returns true if successful.
  Directory handles have their own namespace from filehandles.
  This subroutine function when the directory name ends with chr(0x5C) on MSWin32.

=item * Statistics about file

  $stat = Egb18030::stat(FILEHANDLE);
  $stat = Egb18030::stat(DIRHANDLE);
  $stat = Egb18030::stat($expr);
  $stat = Egb18030::stat_;
  @stat = Egb18030::stat(FILEHANDLE);
  @stat = Egb18030::stat(DIRHANDLE);
  @stat = Egb18030::stat($expr);
  @stat = Egb18030::stat_;

  In scalar context, this subroutine returns a Boolean value that indicates whether
  the call succeeded. In list context, it returns a 13-element list giving the
  statistics for a file, either the file opened via FILEHANDLE or DIRHANDLE, or
  named by $expr. It's typically used as followes:

  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
      $atime,$mtime,$ctime,$blksize,$blocks) = Egb18030::stat($expr);

  Not all fields are supported on all filesystem types; unsupported fields return
  0. Here are the meanings of the fields:

  -------------------------------------------------------------------------
  Index  Field      Meaning
  -------------------------------------------------------------------------
    0    $dev       Device number of filesystem
                    drive number for MSWin32
                    vRefnum for MacOS

lib/Egb18030.pm  view on Meta::CPAN

                    int(($size + $blksize-1) / $blksize) for MacOS
  -------------------------------------------------------------------------

  $dev and $ino, token together, uniquely identify a file on the same system.
  The $blksize and $blocks are likely defined only on BSD-derived filesystems.
  The $blocks field (if defined) is reported in 512-byte blocks. The value of
  $blocks * 512 can differ greatly from $size for files containing unallocated
  blocks, or "hole", which aren't counted in $blocks.

  If Egb18030::stat is passed the special filehandle consisting of an underline, no
  actual stat(2) is done, but the current contents of the stat structure from
  the last Egb18030::stat, Egb18030::lstat, or Egb18030::stat-based file test subroutine
  (such as Egb18030::r, Egb18030::w, and Egb18030::x) are returned.

  Because the mode contains both the file type and its permissions, you should
  mask off the file type portion and printf or sprintf using a "%o" if you want
  to see the real permissions:

  $mode = (Egb18030::stat($expr))[2];
  printf "Permissions are %04o\n", $mode & 07777;

  If $expr is omitted, returns information on file given in $_.
  This subroutine function when the filename ends with chr(0x5C) on MSWin32.

=item * Deletes a list of files.

  $unlink = Egb18030::unlink(@list);
  $unlink = Egb18030::unlink($file);
  $unlink = Egb18030::unlink;

lib/GB18030.pm  view on Meta::CPAN

            #
            # Filter >
            # Source >>>
            # Escape >>>>> executable without re-escape
            #
            # Filter >>>
            # Source >
            # Escape >>>>> executable without re-escape
            #----------------------------------------------------

            my $mtime_filter = (Egb18030::stat(__FILE__     ))[9];
            my $mtime_source = (Egb18030::stat($filename    ))[9];
            my $mtime_escape = (Egb18030::stat("$filename.e"))[9];
            if (($mtime_escape < $mtime_source) or ($mtime_escape < $mtime_filter)) {
                Egb18030::unlink "$filename.e";
            }
        }
    }

    if (not Egb18030::e("$filename.e")) {
        my $fh = gensym();
        Egb18030::_open_a($fh, "$filename.e") or die __FILE__, ": Can't write open file: $filename.e\n";

lib/GB18030.pm  view on Meta::CPAN

        else {
            CORE::eval q{ flock($fh, LOCK_EX) };
        }

        CORE::eval q{ truncate($fh, 0) };
        seek($fh, 0, 0) or die __FILE__, ": Can't seek file: $filename.e\n";

        my $e_script = GB18030::escape_script($filename);
        print {$fh} $e_script;

        my $mode = (Egb18030::stat($filename))[2] & 0777;
        chmod $mode, "$filename.e";

        close($fh) or die "Can't close file: $filename.e: $!";
    }

    my $fh = gensym();
    Egb18030::_open_r($fh, "$filename.e") or die __FILE__, ": Can't read open file: $filename.e\n";

    if (0) {
    }

lib/GB18030.pm  view on Meta::CPAN


=item * Unicode Properties (aka Character Properties) of Regular Expression

Unicode properties (aka character properties) of regexp are not available.
Also (?[]) in regexp of Perl 5.18 is not available. There is no plans to currently
support these.

=item * ${^WIN32_SLOPPY_STAT} is ignored

Even if ${^WIN32_SLOPPY_STAT} is set to a true value, file test functions Egb18030::*(),
Egb18030::lstat(), and Egb18030::stat() on Microsoft Windows open the file for the path
which has chr(0x5c) at end.

=item * Delimiter of String and Regexp

qq//, q//, qw//, qx//, qr//, m//, s///, tr///, and y/// can't use a wide character
as the delimiter.

=item * \b{...} Boundaries in Regular Expressions

Following \b{...} available starting in v5.22 are not supported.

t/GB18030/207_stat.t  view on Meta::CPAN

close(FILE);
open(FILE,'>D‹@”\/c.txt') || die "Can't open file: D‹@”\/c.txt\n";
print FILE "1\n";
close(FILE);
open(FILE,'>D‹@”\/F‹@”\') || die "Can't open file: D‹@”\/F‹@”\\n";
print FILE "1\n";
close(FILE);
mkdir('D‹@”\/D‹@”\', 0777);

$_ = 'F‹@”\';
if (@_ = stat($_)) {
    print "ok - 1 $^X $__FILE__\n";
}
else{
    print "not ok - 1 $^X $__FILE__\n";
}

$_ = 'D‹@”\';
if (@_ = stat($_)) {
    print "not ok - 2 $^X $__FILE__\n";
}
else{
    print "ok - 2 $^X $__FILE__\n";
}

unlink('F‹@”\');
rmdir('D‹@”\/D‹@”\');
unlink('D‹@”\/a.txt');
unlink('D‹@”\/b.txt');
unlink('D‹@”\/c.txt');
unlink('D‹@”\/F‹@”\');
rmdir('D‹@”\');

__END__

Perlƒƒ‚/Windows‚ł̃tƒ@ƒCƒ‹ƒpƒX
http://digit.que.ne.jp/work/wiki.cgi?Perl%E3%83%A1%E3%83%A2%2FWindows%E3%81%A7%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%83%91%E3%82%B9

ƒtƒ@ƒCƒ‹ŠÖ˜AƒRƒ}ƒ“ƒh‚Ì“®ìŠm”F
u‹@”\v‚Æ‚¢‚¤•¶Žš—ñ‚ð•ϐ”$_‚É“ü‚êAstat($_)‚Æ‚µ‚Ä‚à•Ô‚è’l‚ª‚È‚¢ 

t/GB18030/215_lstat.t  view on Meta::CPAN

if ($chcp !~ /932|936/oxms) {
    print "ok - 1 # SKIP $^X $0\n";
    exit;
}

open(FILE,'>F‹@”\') || die "Can't open file: F‹@”\\n";
print FILE "1\n";
close(FILE);

# lstat
if (lstat('F‹@”\')) {
    print "ok - 1 lstat $^X $__FILE__\n";
}
else {
    print "not ok - 1 lstat: $! $^X $__FILE__\n";
}

unlink('F‹@”\');

__END__

t/GB18030/220_stat.t  view on Meta::CPAN

if ($chcp !~ /932|936/oxms) {
    print "ok - 1 # SKIP $^X $0\n";
    exit;
}

open(FILE,'>F‹@”\') || die "Can't open file: F‹@”\\n";
print FILE "1\n";
close(FILE);

# stat
if (stat('F‹@”\')) {
    print "ok - 1 stat $^X $__FILE__\n";
}
else {
    print "not ok - 1 stat: $! $^X $__FILE__\n";
}

unlink('F‹@”\');

__END__



( run in 1.500 second using v1.01-cache-2.11-cpan-49f99fa48dc )