LCOV - code coverage report
Current view: top level - desktop/source/deployment/misc - dp_version.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 18 88.9 %
Date: 2012-08-25 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 24 75.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "sal/config.h"
      31                 :            : 
      32                 :            : #include "com/sun/star/deployment/XPackage.hpp"
      33                 :            : #include "rtl/ustring.hxx"
      34                 :            : 
      35                 :            : #include "dp_version.hxx"
      36                 :            : 
      37                 :            : namespace {
      38                 :            : 
      39                 :       1860 : ::rtl::OUString getElement(::rtl::OUString const & version, ::sal_Int32 * index)
      40                 :            : {
      41 [ +  + ][ +  + ]:       2108 :     while (*index < version.getLength() && version[*index] == '0') {
                 [ +  + ]
      42                 :        248 :         ++*index;
      43                 :            :     }
      44                 :       1860 :     return version.getToken(0, '.', *index);
      45                 :            : }
      46                 :            : 
      47                 :            : }
      48                 :            : 
      49                 :            : namespace dp_misc {
      50                 :            : 
      51                 :        496 : ::dp_misc::Order compareVersions(
      52                 :            :     ::rtl::OUString const & version1, ::rtl::OUString const & version2)
      53                 :            : {
      54 [ -  + ][ #  # ]:        930 :     for (::sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0;) {
                 [ +  - ]
      55                 :        930 :         ::rtl::OUString e1(getElement(version1, &i1));
      56                 :        930 :         ::rtl::OUString e2(getElement(version2, &i2));
      57         [ -  + ]:        930 :         if (e1.getLength() < e2.getLength()) {
      58                 :          0 :             return ::dp_misc::LESS;
      59         [ +  + ]:        930 :         } else if (e1.getLength() > e2.getLength()) {
      60                 :        248 :             return ::dp_misc::GREATER;
      61         [ -  + ]:        682 :         } else if (e1 < e2) {
      62                 :          0 :             return ::dp_misc::LESS;
      63         [ +  + ]:        682 :         } else if (e1 > e2) {
      64                 :        682 :             return ::dp_misc::GREATER;
      65                 :            :         }
      66 [ +  + ][ +  + ]:        930 :     }
      67                 :        496 :     return ::dp_misc::EQUAL;
      68                 :            : }
      69                 :            : 
      70                 :            : 
      71                 :            : }
      72                 :            : 
      73                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10