head     1.1;
branch   1.1.1;
access   ;
symbols  gfxboot25:1.1.1.1 morphix:1.1.1;
locks    ; strict;
comment  @# @;


1.1
date     2005.10.17.17.11.57;  author tcheun;  state Exp;
branches 1.1.1.1;
next     ;

1.1.1.1
date     2005.10.17.17.11.57;  author tcheun;  state Exp;
branches ;
next     ;


desc
@@



1.1
log
@Initial revision
@
text
@#! /usr/bin/perl

# remove a text from *.po files

sub drop;

die "usage: rm_text id\n" if @@ARGV != 1;

$id = shift;
$id = "TXT_$id" unless $id =~ /^TXT_/;

mkdir old, 0755;

for $f ("linuxrc.pot", <*.po>) {
  if(open F, $f) {
    @@f = <F>;
    close F;

    ( $new, $old ) = drop @@f;
    if(open F, ">>old/$f") {
      print F @@$old;
      close F;

      open F, ">$f";
      print F @@$new;
      close F;
    }
  }
}


sub drop
{
  local $_;
  my (@@f, @@g, $drop_it, @@d);

  for (@@_) {
    push @@g, $_;
    $drop_it = 1 if /^#\.\s*${id}\s*$/;
    if(/^\s*$/) {
      if($drop_it) {
        push @@d, @@g;
      }
      else {
        push @@f, @@g;
      }
      undef $drop_it;
      undef @@g;
    }
  }

  if(@@g) {
    if($drop_it) {
      push @@d, @@g;
    }
    else {
      push @@f, @@g;
    }
  }

  return ( \@@f, \@@d );
}

@


1.1.1.1
log
@morhhix
@
text
@@
