1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 #include <comphelper/string.hxx>
15 #include <rtl/ustring.hxx>
17 namespace comphelper
{ namespace string
{
21 // BSD licensed, from http://git.musl-libc.org/cgit/musl/plain/src/string/strverscmp.c
23 int strverscmp(const char *l
, const char *r
)
33 } else if (isdigit(*l
)) {
42 if (haszero
==1 && (*l
=='0' || *r
=='0')) {
45 if ((isdigit(*l
) && isdigit(*r
) ) && haszero
) {
46 size_t lenl
=0, lenr
=0;
47 while (isdigit(l
[lenl
]) ) lenl
++;
48 while (isdigit(r
[lenr
]) ) lenr
++;
51 } else if (lenl
>lenr
) {
61 } // anonymous namespace
63 int compareVersionStrings(const OUString
& a
, const OUString
& b
)
65 return strverscmp(OUStringToOString(a
, RTL_TEXTENCODING_UTF8
).getStr(), OUStringToOString(b
, RTL_TEXTENCODING_UTF8
).getStr());
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */