office-gobmx/l10ntools/source/treex.cxx
Stephan Bergmann 206b5b2661 New loplugin:external
...warning about (for now only) functions and variables with external linkage
that likely don't need it.

The problems with moving entities into unnamed namespacs and breaking ADL
(as alluded to in comments in compilerplugins/clang/external.cxx) are
illustrated by the fact that while

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

returns 1, both moving just the struct S2 into an nunnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    namespace { struct S2: S1 { int f() { return 1; } }; }
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

as well as moving just the function f overload into an unnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    namespace { int f(S2 s) { return s.f(); } }
  }
  int main() { return f(N::S2()); }

would each change the program to return 0 instead.

Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c
Reviewed-on: https://gerrit.libreoffice.org/60539
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-17 09:05:38 +02:00

72 lines
1.9 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*/
#include <iostream>
#include <cstring>
#include <sal/main.h>
#include <common.hxx>
#include <treemerge.hxx>
static void WriteUsage()
{
std::cout
<< ("Syntax: Treex [-r Root] -i FileIn -o FileOut"
" [-m DataBase] [-l Lang]\n"
" Root: Path to root of localized xhp files\n"
" FileIn: Source files (*.tree)\n"
" FileOut: Destination file (*.*)\n"
" DataBase: Mergedata (*.po)\n"
" Lang: Restrict the handled languages; one element of\n"
" (de, en-US, ...) or all\n");
}
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
{
OString sXHPRoot;
for (int nIndex = 1; nIndex != argc; ++nIndex)
{
if (std::strcmp(argv[nIndex], "-r") == 0)
{
sXHPRoot = OString( argv[nIndex + 1] );
for( int nIndex2 = nIndex+3; nIndex2 < argc; nIndex2 = nIndex2 + 2 )
{
argv[nIndex-3] = argv[nIndex-1];
argv[nIndex-2] = argv[nIndex];
}
argc = argc - 2;
break;
}
}
common::HandledArgs aArgs;
if( !common::handleArguments(argc, argv, aArgs) )
{
WriteUsage();
return 1;
}
TreeParser aParser(aArgs.m_sInputFile, aArgs.m_sLanguage );
if( !aParser.isInitialized() )
{
return 1;
}
if( aArgs.m_bMergeMode || !sXHPRoot.isEmpty() )
{
aParser.Merge( aArgs.m_sMergeSrc, aArgs.m_sOutputFile, sXHPRoot );
}
else
{
aParser.Extract( aArgs.m_sOutputFile );
}
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */