[xiph-cvs] cvs commit: vorbis-tools/ogg123 ogg123.c
Monty
xiphmont at xiph.org
Fri Nov 3 22:23:22 PST 2000
xiphmont 00/11/03 22:23:22
Modified: ogg123 ogg123.c
Added: . file-replace.pl
Log:
Add my batch regexp substitution tool :-)
Update comment on ogg123 to fix typo
Revision Changes Path
1.1 vorbis-tools/file-replace.pl
Index: file-replace.pl
===================================================================
#!/usr/bin/perl
# parse the arguments:
# file-replace [options] [--] filename[s]|dir[s]
# --in-pattern="search for"
# --out-pattern="replace with"
# --in-pattern-file="file"
# --out-pattern-file="file"
# --no-recurse
# --no-directories
my $search;
my $replace;
my $argflag;
my @infiles;
my $norecurse;
my $nodirs;
my$pwd=`pwd`;
chomp($pwd);
foreach $arg (@ARGV){
if($arg eq "--"){
$argflag=1;
next;
}
if(!$argflag && $arg=~/--([^=]*)=(.*)/){
my$key=$1;
my$val=$2;
if($key eq "in-pattern"){
$search=$val;
next;
}
if($key eq "out-pattern"){
$replace=$val;
next;
}
if($key eq "in-pattern-file"){
die "Could not open file $val: $!" unless open(F,"$val");
undef $/;
$search=<F>;
$/="\n";
close(F);
next;
}
if($key eq "out-pattern-file"){
die "Could not open file $val: $!" unless open(F,"$val");
undef $/;
$replace=<F>;
$/="\n";
close(F);
next;
}
print "Unknown option --$key\n";
exit(1);
}
if(!$argflag && $arg=~/--(.*)/){
if($key eq "no-recurse"){
$norecurse;
next;
}
if($key eq "no-directories"){
$nodirs=1;
next;
}
print "Unknown option --$key\n";
exit(1);
}
push @infiles, ($arg);
}
&recursive_doit($pwd, at infiles);
ub recursive_doit{
my($pwd, at globlist)=@_;
my @dirs;
my @files;
# seperate files from directories
foreach $file (@globlist){
if(-d $file){
push @dirs,($file);
next;
}
if(-f $file){
push @files,($file);
next;
}
print "$pwd/$file is not a plain file or directory.\n";
}
# Are we called on a directory? recurse?
if(!$nodirs){
# fork into each dir with all but the original path ar
foreach $dir (@dirs){
if(fork){
wait; # don't hose the box ;-)
}else{
die "Could not chdir to $pwd/$dir: $!\n" unless chdir $dir;
$pwd.="/$dir";
# open and read the dir
die "Could not read directory $pwd: $!\n" unless
opendir (D,".");
#ignore dotfiles
@globlist=grep { /^[^\.]/ && !(-l "$_") } readdir(D);
closedir(D);
$nodirs=$norecurse;
recursive_doit($pwd, at globlist);
exit(0);
}
}
}
foreach $file (@files){
if (open(F,$file)){
undef $/;
my$body=<F>;
$/="\n";
close(F);
# do the regexp
if($body=~s{$search}{$replace}g){
print "Performed substitution on $pwd/$file\n";
# replace with modified file
my$tempfile="file-replace-tmp_$$";
die $! unless open(F,">$tempfile");
syswrite F,$body;
close(F);
die "Unable to replace modified file $file: $!\n" unless
rename($tempfile,$file);
unlink $tempfile;
}
}else{
print "Could not open $pwd/$file: $!\n";
}
}
exit(0);
}
1.10 +5 -5 vorbis-tools/ogg123/ogg123.c
Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ogg123.c 2000/11/01 00:58:31 1.9
+++ ogg123.c 2000/11/04 06:23:21 1.10
@@ -3,18 +3,18 @@
/********************************************************************
* *
- * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
* THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
- * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
- * by Monty <monty at xiph.org> and The XIPHOPHORUS Company *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty at xiph.org> and the XIPHOPHORUS Company *
* http://www.xiph.org/ *
* *
********************************************************************
- last mod: $Id: ogg123.c,v 1.9 2000/11/01 00:58:31 jack Exp $
+ last mod: $Id: ogg123.c,v 1.10 2000/11/04 06:23:21 xiphmont Exp $
********************************************************************/
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list