Removed 'altstrfunc.cxx' and .hxx

renamed and moved 'start()' to  it's only call site -
as 'startsAsciiCaseInsensitive' lingucomponent/source/languageguessing/simpleguesser.cxx.
moved inline bool to it's only call site -
as 'isSeparator(const char)' from altstrfunc.hxx to lingucomponent/source/languageguessing/guess.cxx.

Change-Id: Ic624ba3cab90bd454311219966c19fb550388da1
Reviewed-on: https://gerrit.libreoffice.org/24864
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
Krishna Keshav
2016-05-11 03:42:21 +05:30
committed by Michael Meeks
parent 1d54b93670
commit aa74c30edd
5 changed files with 23 additions and 80 deletions

View File

@@ -29,7 +29,6 @@ $(eval $(call gb_Library_use_libraries,guesslang,\
))
$(eval $(call gb_Library_add_exception_objects,guesslang,\
lingucomponent/source/languageguessing/altstrfunc \
lingucomponent/source/languageguessing/guess \
lingucomponent/source/languageguessing/guesslang \
lingucomponent/source/languageguessing/simpleguesser \

View File

@@ -1,42 +0,0 @@
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "altstrfunc.hxx"
#include <sal/types.h>
#include<rtl/character.hxx>
using namespace rtl;
int start(const std::string &s1, const std::string &s2){
size_t i;
int ret = 0;
size_t min = s1.length();
if (min > s2.length())
min = s2.length();
for(i = 0; i < min && s2[i] && s1[i] && !ret; i++){
ret = toAsciiUpperCase(s1[i]) - toAsciiUpperCase(s2[i]);
if(s1[i] == '.' || s2[i] == '.'){ret = 0;}//. is a neutral character
}
return ret;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1,34 +0,0 @@
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_LINGUCOMPONENT_SOURCE_LANGUAGEGUESSING_ALTSTRFUNC_HXX
#define INCLUDED_LINGUCOMPONENT_SOURCE_LANGUAGEGUESSING_ALTSTRFUNC_HXX
#include <string>
#include <guess.hxx>
inline bool isSeparator(const char c){
return c == GUESS_SEPARATOR_OPEN || c == GUESS_SEPARATOR_SEP || c == GUESS_SEPARATOR_CLOSE || c == '\0';
}
int start(const std::string &s1, const std::string &s2);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -25,7 +25,7 @@
#else
#include <textcat.h>
#endif
#include <altstrfunc.hxx>
#include <guess.hxx>
/* Old textcat.h versions defined bad spelled constants. */
@@ -39,6 +39,11 @@
using namespace std;
inline bool isSeparator(const char c){
return c == GUESS_SEPARATOR_OPEN || c == GUESS_SEPARATOR_SEP || c == GUESS_SEPARATOR_CLOSE || c == '\0';
}
Guess::Guess()
: language_str(DEFAULT_LANGUAGE)
, country_str(DEFAULT_COUNTRY)

View File

@@ -47,11 +47,26 @@
#include <sal/types.h>
#include "altstrfunc.hxx"
#include<rtl/character.hxx>
#include "simpleguesser.hxx"
using namespace std;
static int startsAsciiCaseInsensitive(const std::string &s1, const std::string &s2){
size_t i;
int ret = 0;
size_t min = s1.length();
if (min > s2.length())
min = s2.length();
for(i = 0; i < min && s2[i] && s1[i] && !ret; i++){
ret = rtl::toAsciiUpperCase(s1[i]) - rtl::toAsciiUpperCase(s2[i]);
if(s1[i] == '.' || s2[i] == '.') {ret = 0;} //. is a neutral character
}
return ret;
}
/**
* This 3 following structures are from fingerprint.c and textcat.c
*/
@@ -197,7 +212,7 @@ void SimpleGuesser::XableLanguage(const string& lang, char mask)
for (size_t i=0; i<tables->size; i++)
{
string language(fp_Name(tables->fprint[i]));
if (start(language,lang) == 0)
if (startsAsciiCaseInsensitive(language,lang) == 0)
tables->fprint_disable[i] = mask;
}
}