Monday, March 28, 2005

view_cvs_addfile


#!/usr/bin/perl

#$cvs history -c| view_cvs_addfile
#のように使う

use Getopt::Std;
getopts("peh");#-p path, -e existance file only, -h help

if($opt_h){
print "type\n 'perldoc view_cvs_addfile'\n";
exit 8;
}

while(<>){
#read only output from $cvs histry -c
@words= split;
%files;
if($opt_p){
$fname= "$words[9]/$words[6]";

#expand ~/ to /home/usrname/
$fname =~ s{ ^ ~ ( [^/]* ) }
{ $1
? (getpwnam($1))[7]
: ( $ENV{HOME} || $ENV{LOGDIR}
|| (getpwuid($<))[7]
)
}ex;

}else{
$fname= $words[6];
}
if($words[0] eq "A" or $words[0] eq "M"){
$files{$fname}= 1;
}elsif($words[0] eq "R"){
$files{$fname}= 0;
}
}

foreach (sort keys %files){
if($opt_e){
if(-e $_ && -w $_){
print"$_\n" if $files{$_};
}
}else{
print"$_\n" if $files{$_};
}
}


=head1 NAME

view_cvs_addfile - view cvs add file from cvs histry

=head1 SYNOPSIS

example
$ cvs history -c |grep module_name|view_cvs_addfile

options
-p output with fullpath, -e existance file only, -h help

=head1 DESCRIPTION

cvs に登録しているファイルを抜き出す。

使用例
モジュール module_name に登録しているファイルの確認
$ cvs history -c |grep module_name|view_cvs_addfile

cvs に 登録しているテストファイル以外の行数の確認
$ cvs history -c |grep module_name|view_cvs_addfile

=cut






Sunday, March 27, 2005

Python で 固定長配列

Python で固定長配列を作る方法
http://www.python.jp/pipermail/python-ml-jp/2003-July/002386.html
より


0で初期化された固定長配列
array= [0] * 100

0で初期化された2次元の固定長配列 (10×10)
array= [[0] * 10] * 10


いままで for ループでappendしていた自分が恥ずかしい。

Friday, March 18, 2005

debian でgcc使ってX11ロードするときのライブラリ名

-lx11globalcomm
libx11globalcomm.so ってのが /usr/lib 以下にあるので
gcc hoge.c -lx11globalcomm
みたいな感じでコンパイル

Saturday, March 05, 2005

chmodの引数の数字の意味

chmod 755 とか 744 の意味って
-rwxr--r--
rwxにそれぞれ ビットを111 って立てたときの10進の値だったのだと今日気づいた。
r= 4 -> bit=100 w= 2 -> bit=010 x= 1 -> bit=001
みたいな感じで(足した値が7とか5になるー7ならrwx、5ならr-x)。

こんな当り前のことに今まで気づかなかったとは。

awklisp ってのを見つけた。


awklisp っていうawkで書かれたlispインタプリタを見つけた。
http://www.accesscom.com/~darius/
の awklisp のとこから。
インタラクティイブな起動は
$ mawk -f awklisp
で。