[Libreoffice-commits] .: 2 commits - o3tl/inc o3tl/qa solenv/gbuild sw/inc sw/source

Michael Stahl mst at kemper.freedesktop.org
Thu Aug 2 13:18:53 PDT 2012


 o3tl/inc/o3tl/sorted_vector.hxx                |   19 ++---
 o3tl/qa/test-sorted_vector.cxx                 |    6 -
 solenv/gbuild/filter-showIncludes.pl           |   85 -----------------------
 solenv/gbuild/platform/WNT_INTEL_MSC.mk        |    2 
 solenv/gbuild/platform/filter-showIncludes.awk |   91 +++++++++++++++++++++++++
 sw/inc/docary.hxx                              |    2 
 sw/inc/ndhints.hxx                             |    4 -
 sw/source/filter/html/htmlfly.hxx              |    3 
 sw/source/ui/utlui/content.cxx                 |    3 
 9 files changed, 109 insertions(+), 106 deletions(-)

New commits:
commit b4d5eebfdd095a75966f2fa0997817d3441a3b80
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Aug 2 22:07:30 2012 +0200

    filter-showIncludes: convert to AWK
    
    Change-Id: Iedc315550f4eafdf1612bc390044a4b1b0c8e80b

diff --git a/solenv/gbuild/filter-showIncludes.pl b/solenv/gbuild/filter-showIncludes.pl
deleted file mode 100755
index 1ed3679..0000000
--- a/solenv/gbuild/filter-showIncludes.pl
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env perl
-#
-# filter-showIncludes.pl depfile.d objfile.o orginal.cxx
-#
-# Create dependency information from the output of cl.exe's showInclude.  It
-# needs additional information - the output name to which to write, objfile
-# that depends on the includes, and the original file name.
-#
-# It also consolidates the file names to a canonical form, and filters out
-# duplicates.
-#
-# LGPL v3 / GPL v3 / MPL 1.1
-#
-# Original author: Jan Holesovsky <kendy at suse.cz>
-
-use File::Basename;
-use File::Copy;
-use File::Temp qw/tempfile/;
-
-my $outfile = $ARGV[0];
-my $objfile = $ARGV[1];
-my $srcfile = $ARGV[2];
-if ( !defined $outfile || !defined $objfile || !defined $srcfile ) {
-    die "Not enough parameters to create dependencies.";
-}
-
-my $showincludes_prefix = $ENV{'SHOWINCLUDES_PREFIX'};
-if ( !defined( $showincludes_prefix ) || $showincludes_prefix eq "" ) {
-    $showincludes_prefix = 'Note: including file:';
-}
-
-my ($OUT, $tmp_filename) = tempfile( 'showIncludesXXXXXX', DIR => dirname( $outfile ) ) or die "Cannot create a temp file.";
-
-print $OUT "$objfile: \\\n $srcfile";
-
-my %seen;
-my $first_line = 1;
-while ( <STDIN> ) {
-    if ( /^$showincludes_prefix/ ) {
-        s/^$showincludes_prefix\s*//;
-        s/\r$//;
-
-        chomp;
-        s/\\/\//g;
-
-
-        # skip system headers, i.e. everything not under source or build dirs
-        if ( /$ENV{'SRCDIR'}|$ENV{'OUTDIR'}|$ENV{'WORKDIR'}/ )
-        {
-
-        # X: -> /cygdrive/x/
-        s/^(.):/\/cygdrive\/\l\1/;
-
-        s/ /\\ /g;
-
-        if ( !defined $seen{$_} ) {
-            $seen{$_} = 1;
-            print $OUT " \\\n  $_";
-        }
-        }
-    }
-    else {
-        # skip the first line, it always just duplicates what is being
-        # compiled
-        print unless ( $first_line );
-    }
-    $first_line = 0;
-}
-
-print $OUT "\n";
-
-# fdo#40099 if header.h does not exist, it will simply be considered out of
-# date and any targets that use it as a prerequisite will be updated,
-# which avoid misery when the header is deliberately deleted and removed
-# as an include
-# see http://www.makelinux.net/make3/make3-CHP-8-SECT-3
-foreach my $key ( keys %seen ) {
-  print $OUT "\n$key:\n";
-}
-
-close( $OUT ) or die "Cannot close $tmp_filename.";
-
-move( $tmp_filename, $outfile ) or die "Cannot move $tmp_filename to $outfile.";
-
-# vim: shiftwidth=4 softtabstop=4 expandtab:
diff --git a/solenv/gbuild/platform/WNT_INTEL_MSC.mk b/solenv/gbuild/platform/WNT_INTEL_MSC.mk
index 9519a48..a060cc8 100644
--- a/solenv/gbuild/platform/WNT_INTEL_MSC.mk
+++ b/solenv/gbuild/platform/WNT_INTEL_MSC.mk
@@ -228,7 +228,7 @@ gb_COMPILERNOOPTFLAGS := -Od
 ifeq ($(gb_FULLDEPS),$(true))
 gb_COMPILERDEPFLAGS := -showIncludes
 define gb_create_deps
-| $(GBUILDDIR)/filter-showIncludes.pl $(1) $(2) $(3); exit $${PIPESTATUS[0]}
+| $(GBUILDDIR)/platform/filter-showIncludes.awk -vdepfile=$(1) -vobjectfile=$(2) -vsourcefile=$(3); exit $${PIPESTATUS[0]}
 endef
 else
 gb_COMPILERDEPFLAGS :=
diff --git a/solenv/gbuild/platform/filter-showIncludes.awk b/solenv/gbuild/platform/filter-showIncludes.awk
new file mode 100755
index 0000000..9d94f3b
--- /dev/null
+++ b/solenv/gbuild/platform/filter-showIncludes.awk
@@ -0,0 +1,91 @@
+#!/usr/bin/gawk -f
+# -*- tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+# Create dependency information from the output of cl.exe's showInclude.  It
+# needs additional information - the output name to which to write, objfile
+# that depends on the includes, and the original file name.
+# For best results all arguments should be absolute paths.
+#
+# It also consolidates the file names to a canonical form, and filters out
+# duplicates.
+#
+# based on filter-showInclude.pl by Jan Holesovsky <kendy at suse.cz>
+
+BEGIN {
+    if (!depfile || !objectfile || !sourcefile) {
+        print "usage: filter-showIncludes.awk -vdepfile=depfile.d " \
+          "-vobjectfile=objfile.o -vsourcefile=source.cxx" > "/dev/stderr"
+        exit 1
+    }
+    tempfile = depfile ".tmp"
+    print objectfile " : \\\n " sourcefile " \\" > tempfile
+
+    showincludes_prefix = ENVIRON["SHOWINCLUDES_PREFIX"];
+    if (!showincludes_prefix) {
+        showincludes_prefix = "Note: including file:"
+    }
+    regex = "^ *" showincludes_prefix " *"
+    pattern = "/" regex "/"
+
+    # to match especially drive letters in whitelist case insensitive
+    IGNORECASE = 1
+    whitelist = \
+        "^(" ENVIRON["SRCDIR"] "|" ENVIRON["OUTDIR"] "|" ENVIRON["WORKDIR"] ")"
+    firstline = 1
+}
+
+{
+    if ($0 ~ regex) {
+        sub(regex, "")
+        gsub(/\\/, "/")
+        gsub(/ /, "\\ ")
+        if ($0 ~ whitelist) { # filter out system headers
+            if (!($0 in incfiles)) {
+                incfiles[$0]
+                print " " $0 " \\" > tempfile
+            }
+        }
+    } else {
+        # because MSVC stupidly prints the include files on stderr, it's
+        # necessary to forward everything that isn't matched by the pattern
+        # so users get to see compiler errros
+        if (firstline) { # ignore the line that just prints name of sourcefile
+            firstline = 0
+        } else {
+            print $0 > "/dev/stderr"
+        }
+    }
+}
+
+END {
+    if (!tempfile) {
+        exit 1
+    }
+    print "" > tempfile
+
+    # fdo#40099 if header.h does not exist, it will simply be considered out of
+    # date and any targets that use it as a prerequisite will be updated,
+    # which avoid misery when the header is deliberately deleted and removed
+    # as an include
+    # see http://www.makelinux.net/make3/make3-CHP-8-SECT-3
+    for (file in incfiles) {
+        print file " :\n" > tempfile
+    }
+
+    close(tempfile)
+    movecmd = "mv " tempfile " " depfile
+    ret = system(movecmd)
+    if (ret) {
+        print "ERROR: " movecmd " FAILED with status " ret > "/dev/stderr"
+        exit ret
+    }
+}
+
+# vim: set noet sw=4 ts=4:
commit ebd2bfa2e748d9efa4ee759f5b9003d9e470d752
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Aug 2 21:30:45 2012 +0200

    Revert "Revert "sorted_vector: turn Find parameter into template""
    
    This reverts commit 8291d41667b1a63d35bf818aaf9d75529e1f12f0.
    
    Un-revert that, with a tweak: with the bizarre name lookup semantics
    in C++, the proper way to refer to a template (as opposed to a template
    instance) is by prefixing the name with its namespace, which does seem
    to work with MSVC2008 & GCC 4.7; thanks to Stephan Bergmann for the hint.
    
    Change-Id: Id9cccbe68fb3ce2dd070c4b3dbd21782c92170ca

diff --git a/o3tl/inc/o3tl/sorted_vector.hxx b/o3tl/inc/o3tl/sorted_vector.hxx
index 4d442dd..90aacbf 100644
--- a/o3tl/inc/o3tl/sorted_vector.hxx
+++ b/o3tl/inc/o3tl/sorted_vector.hxx
@@ -27,12 +27,13 @@ struct find_unique;
     @tpl Compare comparison method
     @tpl Find   look up index of a Value in the array
 */
-template<class Value, class Compare = std::less<Value>,
-         class Find = find_unique<Value, Compare> >
+template<typename Value, typename Compare = std::less<Value>,
+     template<typename, typename> class Find = find_unique >
 class sorted_vector
     : private std::vector<Value>
 {
 private:
+    typedef Find<Value, Compare> Find_t;
     typedef typename std::vector<Value> base_t;
     typedef typename std::vector<Value>::iterator  iterator;
 public:
@@ -47,7 +48,7 @@ public:
 
     std::pair<const_iterator,bool> insert( const Value& x )
     {
-        std::pair<const_iterator, bool> const ret(Find()(begin(), end(), x));
+        std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x));
         if (!ret.second)
         {
             const_iterator const it = base_t::insert(
@@ -59,7 +60,7 @@ public:
 
     size_type erase( const Value& x )
     {
-        std::pair<const_iterator, bool> const ret(Find()(begin(), end(), x));
+        std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x));
         if (ret.second)
         {
             base_t::erase(begin_nonconst() + (ret.first - begin()));
@@ -129,7 +130,7 @@ public:
      */
     const_iterator find( const Value& x ) const
     {
-        std::pair<const_iterator, bool> const ret(Find()(begin(), end(), x));
+        std::pair<const_iterator, bool> const ret(Find_t()(begin(), end(), x));
         return (ret.second) ? ret.first : end();
     }
 
@@ -180,8 +181,8 @@ template <class T> struct less_ptr_to : public std::binary_function <T*,T*,bool>
 template<class Value, class Compare>
 struct find_unique
 {
-    typedef typename sorted_vector<Value, Compare, find_unique>
-                ::const_iterator const_iterator;
+    typedef typename sorted_vector<Value, Compare,
+            o3tl::find_unique> ::const_iterator const_iterator;
     std::pair<const_iterator, bool> operator()(
             const_iterator first, const_iterator last,
             Value const& v)
@@ -197,8 +198,8 @@ struct find_unique
 template<class Value, class Compare>
 struct find_partialorder_ptrequals
 {
-    typedef typename sorted_vector<Value, Compare, find_partialorder_ptrequals>
-                ::const_iterator const_iterator;
+    typedef typename sorted_vector<Value, Compare,
+            o3tl::find_partialorder_ptrequals>::const_iterator const_iterator;
     std::pair<const_iterator, bool> operator()(
             const_iterator first, const_iterator last,
             Value const& v)
diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx
index 1b321c9..8e9e719 100644
--- a/o3tl/qa/test-sorted_vector.cxx
+++ b/o3tl/qa/test-sorted_vector.cxx
@@ -136,8 +136,7 @@ public:
     void testBasics_FindPtr()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
-            o3tl::find_partialorder_ptrequals<SwContent*,
-                o3tl::less_ptr_to<SwContent> > > aVec;
+            o3tl::find_partialorder_ptrequals> aVec;
         SwContent *p1 = new SwContent(1);
         SwContent *p2 = new SwContent(2);
         SwContent *p2_2 = new SwContent(2);
@@ -195,8 +194,7 @@ public:
     void testErase_FindPtr()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
-            o3tl::find_partialorder_ptrequals<SwContent*,
-                o3tl::less_ptr_to<SwContent> > > aVec;
+            o3tl::find_partialorder_ptrequals> aVec;
         SwContent *p1 = new SwContent(1);
         SwContent *p1_2 = new SwContent(1);
         SwContent *p1_3 = new SwContent(1);
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 7c9f928..4f9b9af 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -145,7 +145,7 @@ struct CompareSwRedlineTbl
 };
 class _SwRedlineTbl
     : public o3tl::sorted_vector<SwRedline*, CompareSwRedlineTbl,
-        o3tl::find_partialorder_ptrequals<SwRedline*, CompareSwRedlineTbl> >
+                o3tl::find_partialorder_ptrequals>
 {
 public:
     ~_SwRedlineTbl();
diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index 154c957..773bb1f 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -76,14 +76,14 @@ struct CompareSwpHtStart
     bool operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const;
 };
 class SwpHtStart : public o3tl::sorted_vector<SwTxtAttr*, CompareSwpHtStart,
-    o3tl::find_partialorder_ptrequals<SwTxtAttr*, CompareSwpHtStart> > {};
+    o3tl::find_partialorder_ptrequals> {};
 
 struct CompareSwpHtEnd
 {
     bool operator()(SwTxtAttr* const lhs, SwTxtAttr* const rhs) const;
 };
 class SwpHtEnd : public o3tl::sorted_vector<SwTxtAttr*, CompareSwpHtEnd,
-    o3tl::find_partialorder_ptrequals<SwTxtAttr*, CompareSwpHtEnd> > {};
+    o3tl::find_partialorder_ptrequals> {};
 
 // Class SwpHintsArr
 
diff --git a/sw/source/filter/html/htmlfly.hxx b/sw/source/filter/html/htmlfly.hxx
index 19b14e0..8184d5c 100644
--- a/sw/source/filter/html/htmlfly.hxx
+++ b/sw/source/filter/html/htmlfly.hxx
@@ -130,8 +130,7 @@ public:
 class SwHTMLPosFlyFrms
     : public o3tl::sorted_vector<SwHTMLPosFlyFrm*,
                 o3tl::less_ptr_to<SwHTMLPosFlyFrm>,
-                o3tl::find_partialorder_ptrequals<SwHTMLPosFlyFrm*,
-                    o3tl::less_ptr_to<SwHTMLPosFlyFrm> > >
+                o3tl::find_partialorder_ptrequals>
 {};
 
 #endif
diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx
index f150239..9330f46 100644
--- a/sw/source/ui/utlui/content.cxx
+++ b/sw/source/ui/utlui/content.cxx
@@ -106,8 +106,7 @@ using namespace ::com::sun::star::container;
 
 class SwContentArr
     : public o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
-                o3tl::find_partialorder_ptrequals<SwContent*,
-                    o3tl::less_ptr_to<SwContent> > >
+                o3tl::find_partialorder_ptrequals>
 {
 public:
     ~SwContentArr() { DeleteAndDestroyAll(); }


More information about the Libreoffice-commits mailing list