Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/intltool/Makefile.am,v
retrieving revision 1.31
diff -u -p -w -r1.31 Makefile.am
--- Makefile.am	6 Dec 2003 00:02:25 -0000	1.31
+++ Makefile.am	5 Jan 2004 18:55:58 -0000
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = . tests doc doc-i18n-tool modules
+SUBDIRS = . tests doc doc-i18n-tool
 
 NULL = 
 
Index: NEWS
===================================================================
RCS file: /cvs/gnome/intltool/NEWS,v
retrieving revision 1.37
diff -u -p -w -r1.37 NEWS
--- NEWS	8 Dec 2003 22:41:14 -0000	1.37
+++ NEWS	5 Jan 2004 18:55:58 -0000
@@ -14,6 +14,9 @@ an eye on intltool at the same time.
 
 Thanks guys!
 
+* Removed OrigTree in favor of more simply setting handlers directly
+  in intltool-merge (Brian Cameron)
+
 * made intltool-merge use XML::Parser (#116526 and others) [Brian Cameron]
 
   - added and updated tests
@@ -23,7 +26,7 @@ Thanks guys!
     before/after translation.
   - Added it to build, made it install (Kenneth Christiansen)
     - Added missing DESTDIR (Abel Cheung)
-    - Also nstall OrigTree.pm in the distribution tree (Malcolm Tredinnick)
+    - Also install OrigTree.pm in the distribution tree (Malcolm Tredinnick)
     - Check for the XML::Parser module at build time (Malcolm Tredinnick)
 
 * Added INTLTOOL_KBD_RULE for GOK\s *.kdb files (Bill Haneman)
Index: README
===================================================================
RCS file: /cvs/gnome/intltool/README,v
retrieving revision 1.20
diff -u -p -w -r1.20 README
--- README	6 Dec 2003 13:22:58 -0000	1.20
+++ README	5 Jan 2004 18:55:58 -0000
@@ -43,10 +43,9 @@ To use intltool in your module, do the f
 
 	AC_PROG_INTLTOOL([minimum required version])
 
- o Add intltool-extract.in, intltool-merge.in, intltool-update.in and
-   intltool-modules/XML/Parser/Style/OrigTree.pm to EXTRA_DIST in your
-   top-level Makefile.am and also to the top-level .cvsignore. Also add the
-   non-.in versions to .cvsignore
+ o Add intltool-extract.in, intltool-merge.in, and intltool-update.in
+   to EXTRA_DIST in your top-level Makefile.am and also to the top-level
+   .cvsignore. Also add the non-.in versions to .cvsignore.  
 
  o Remove po/desk.pl and po/update.* scripts.  intltool-update will take
    over their functionality.
Index: configure.in
===================================================================
RCS file: /cvs/gnome/intltool/configure.in,v
retrieving revision 1.45
diff -u -p -w -r1.45 configure.in
--- configure.in	1 Dec 2003 21:39:10 -0000	1.45
+++ configure.in	5 Jan 2004 18:55:58 -0000
@@ -66,7 +66,6 @@ AC_OUTPUT([
 Makefile
 doc-i18n-tool/Makefile
 doc/Makefile
-modules/Makefile
 intltool-extract.in
 intltool-merge.in
 intltool-prepare
Index: intltool-merge.in.in
===================================================================
RCS file: /cvs/gnome/intltool/intltool-merge.in.in,v
retrieving revision 1.84
diff -u -p -w -r1.84 intltool-merge.in.in
--- intltool-merge.in.in	22 Dec 2003 18:36:02 -0000	1.84
+++ intltool-merge.in.in	5 Jan 2004 18:55:59 -0000
@@ -47,17 +47,6 @@ if(!$ret) {
     die "You must have XML::Parser installed to run $0\n\n";
 } 
 
-## Add dir to own perl modules
-my $dir = dirname($0);
-push @INC, "@EXPANDED_DATADIR@/@PACKAGE@";
-push @INC, "$dir/modules";
-push @INC, "$dir/intltool-modules";
-
-$ret = eval 'require XML::Parser::Style::OrigTree';
-if(!$ret) {
-    die "The OrigTree module doesn't seem to be properly installed $0\n\n";
-}
-
 my $must_end_tag      = -1;
 my $last_depth        = -1;
 my $translation_depth = -1;
@@ -884,6 +873,56 @@ sub parseTree
     }
 }
 
+sub intltool_tree_char
+{
+    my $expat = shift;
+    my $text  = shift;
+    my $clist = $expat->{Curlist};
+    my $pos   = $#$clist;
+
+    # Use original_string so that we retain escaped entities
+    # in CDATA sections.
+    #
+    if ($pos > 0 and $clist->[$pos - 1] eq '0') {
+        $clist->[$pos] .= $expat->original_string();
+    } else {
+        push @$clist, 0 => $expat->original_string();
+    }
+}
+
+sub intltool_tree_start
+{
+    my $expat    = shift;
+    my $tag      = shift;
+    my @origlist = ();
+
+    # Use original_string so that we retain escaped entities
+    # in attribute values.  We must convert the string to an
+    # @origlist array to conform to the structure of the Tree
+    # Style.
+    #
+    my @original_array = split /\x/, $expat->original_string();
+    my $source         = $expat->original_string();
+
+    # Remove leading tag.
+    #
+    $source =~ s|^[ \t]*<[ \t]*(\S+)||s;
+
+    # Grab attribute key/value pairs and push onto @origlist array.
+    #
+    while ($source =~ s|^[ \t]*([\w:]+)[ \t]*[=][ \t]*["]([^"]*)["]||s)
+    {
+       push @origlist, $1;
+       push @origlist, $2;
+    }
+
+    my $ol = [ { @origlist } ];
+
+    push @{ $expat->{Lists} }, $expat->{Curlist};
+    push @{ $expat->{Curlist} }, $tag => $ol;
+    $expat->{Curlist} = $ol;
+}
+
 sub readXml
 {
     my $filename = shift || return;
@@ -891,7 +930,9 @@ sub readXml
         die "ERROR Cannot find filename: $filename\n";
     }
 
-    my $xp = new XML::Parser(Style => 'XML::Parser::Style::OrigTree');
+    my $xp = new XML::Parser(Style => 'Tree');
+    $xp->setHandlers(Char => \&intltool_tree_char);
+    $xp->setHandlers(Start => \&intltool_tree_start);
     my $tree = $xp->parsefile($filename);
 
 # <foo><head id="a">Hello <em>there</em></head><bar>Howdy<ref/></bar>do</foo>
@@ -902,6 +943,33 @@ sub readXml
     return $tree;
 }
 
+sub print_header
+{
+    my $infile = shift;
+    my $fh = shift;
+    my $source;
+
+    if(!-f $infile) {
+        die "ERROR Cannot find filename: $infile\n";
+    }
+
+    print $fh qq{<?xml version="1.0" encoding="UTF-8"?>\n};
+    {
+        local $/;
+        open DOCINPUT, "<${FILE}" or die;
+        $source = <DOCINPUT>;
+        close DOCINPUT;
+    }
+    if ($source =~ /(<!DOCTYPE.*\[.*\]\s*>)/s)
+    {
+        print $fh "$1\n";
+    }
+    elsif ($source =~ /(<!DOCTYPE.*>)/s)
+    {
+        print $fh "$1\n";
+    }
+}
+
 sub xml_merge_output
 {
     my $source;
@@ -913,7 +981,7 @@ sub xml_merge_output
             }
             open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
             my $tree = readXml($FILE);
-            print OUTPUT qq{<?xml version="1.0" encoding="UTF-8"?>\n};
+            print_header($FILE, \*OUTPUT);
             parseTree(\*OUTPUT, $tree, 0, $lang);
             close OUTPUT;
             print "CREATED $lang/$OUTFILE\n" unless $QUIET_ARG;
@@ -921,7 +989,7 @@ sub xml_merge_output
     } 
     open OUTPUT, ">$OUTFILE" or die "Cannot open $OUTFILE: $!\n";
     my $tree = readXml($FILE);
-    print OUTPUT qq{<?xml version="1.0" encoding="UTF-8"?>\n};
+    print_header($FILE, \*OUTPUT);
     parseTree(\*OUTPUT, $tree, 0);
     close OUTPUT;
     print "CREATED $OUTFILE\n" unless $QUIET_ARG;
Index: intltoolize.in
===================================================================
RCS file: /cvs/gnome/intltool/intltoolize.in,v
retrieving revision 1.17
diff -u -p -w -r1.17 intltoolize.in
--- intltoolize.in	31 Dec 2003 18:11:01 -0000	1.17
+++ intltoolize.in	5 Jan 2004 18:55:59 -0000
@@ -142,7 +142,6 @@ fi
 
 
 files='intltool-extract.in intltool-merge.in intltool-update.in'
-deep_files='XML/Parser/Style/OrigTree.pm'
 
 auxdir=.
 auxdirline=`egrep '^AC_CONFIG_AUX_DIR' $configure 2>/dev/null`
@@ -251,29 +250,6 @@ if test ! -d intltool-modules; then
   fi
 fi
 cd intltool-modules || exit 1
-
-for file in $deep_files; do
-  if test -f "$file" && test -z "$force"; then
-    test -z "$automake" && echo "$progname: '$file' exists: use '--force' to overwrite" 1>&2
-    continue
-  fi
-
-  dirname=`echo x$file | sed 's%^x\(.*/\).*$%\1%'`
-  $rm_rec $file
-  # mkinstalldirs is also put in auxdir
-  auxdir_absolute=`cd $cur && cd $auxdir && pwd`
-  if $auxdir_absolute/$mkinstalldirs $dirname; then
-    if test -n "$ln_s" && $ln_s $pkgdatadir/$file $dirname; then :
-    elif $cp $pkgdatadir/$file $dirname; then :
-    else
-      echo "$progname: cannot copy '$pkgdatadir/$file' to '$dirname'" 1>&2
-      status=1
-    fi
-  else
-    echo "$progname: cannot execute $mkinstalldirs" 1>&2
-    status=1
-  fi
-done
 exit $status
 # make sure this subshell exits with the exit value if it failed
 ) || exit $?
Index: tests/cases/merge6.xml.in
===================================================================
RCS file: /cvs/gnome/intltool/tests/cases/merge6.xml.in,v
retrieving revision 1.2
diff -u -p -w -r1.2 merge6.xml.in
--- tests/cases/merge6.xml.in	19 Aug 2001 07:43:19 -0000	1.2
+++ tests/cases/merge6.xml.in	5 Jan 2004 18:55:59 -0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<foo>
+<foo value="&lt;!DOCTYPE\ xbel">
   <_bar>This is a &quot; test</_bar>
   <_bar>This is another ' test</_bar>
 </foo>
Index: tests/results/merge6.xml
===================================================================
RCS file: /cvs/gnome/intltool/tests/results/merge6.xml,v
retrieving revision 1.8
diff -u -p -w -r1.8 merge6.xml
--- tests/results/merge6.xml	22 Dec 2003 18:36:03 -0000	1.8
+++ tests/results/merge6.xml	5 Jan 2004 18:55:59 -0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<foo>
+<foo value="&lt;!DOCTYPE\ xbel">
   <bar>This is a &quot; test</bar>
   <bar xml:lang="merge6">This is a &quot; test --> is this a success ?</bar>
   <bar>This is another ' test</bar>
