chromium/third_party/hunspell/src/hunspell/hunspell.cxx

/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (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.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Hunspell, based on MySpell.
 *
 * The Initial Developers of the Original Code are
 * Kevin Hendricks (MySpell) and Németh László (Hunspell).
 * Portions created by the Initial Developers are Copyright (C) 2002-2005
 * the Initial Developers. All Rights Reserved.
 *
 * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno,
 * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád,
 * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter,
 * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls,
 * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */
/*
 * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada
 * And Contributors.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. All modifications to the source code must be clearly marked as
 *    such.  Binary redistributions based on modified source code
 *    must be clearly marked as modified versions in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "affixmgr.hxx"
#include "hunspell.hxx"
#include "suggestmgr.hxx"
#include "hunspell.h"
#ifndef HUNSPELL_CHROME_CLIENT
#    include "config.h"
#endif
#include "csutil.hxx"

#include <limits>
#include <string>

#define MAXWORDUTF8LEN

class HunspellImpl
{};

#ifdef HUNSPELL_CHROME_CLIENT
Hunspell::Hunspell(base::span<const unsigned char> bdict_data)
  :{}

#ifdef HUNSPELL_CHROME_CLIENT
HunspellImpl::HunspellImpl(base::span<const unsigned char> bdict_data) {}

Hunspell::~Hunspell() {}

HunspellImpl::~HunspellImpl() {}

#ifndef HUNSPELL_CHROME_CLIENT
// load extra dictionaries
int Hunspell::add_dic(const char* dpath, const char* key) {
  return m_Impl->add_dic(dpath, key);
}

// load extra dictionaries
int HunspellImpl::add_dic(const char* dpath, const char* key) {
  if (!affixpath)
    return 1;
  m_HMgrs.push_back(new HashMgr(dpath, affixpath, key));
  return 0;
}
#endif

// make a copy of src at destination while removing all leading
// blanks and removing any trailing periods after recording
// their presence with the abbreviation flag
// also since already going through character by character,
// set the capitalization type
// return the length of the "cleaned" (and UTF-8 encoded) word

size_t HunspellImpl::cleanword2(std::string& dest,
                         std::vector<w_char>& dest_utf,
                         const std::string& src,
                         int* pcaptype,
                         size_t* pabbrev) {}

void HunspellImpl::cleanword(std::string& dest,
                        const std::string& src,
                        int* pcaptype,
                        int* pabbrev) {}

void HunspellImpl::mkallcap(std::string& u8) {}

int HunspellImpl::mkallsmall2(std::string& u8, std::vector<w_char>& u16) {}

// convert UTF-8 sharp S codes to latin 1
std::string HunspellImpl::sharps_u8_l1(const std::string& source) {}

// recursive search for right ss - sharp s permutations
hentry* HunspellImpl::spellsharps(std::string& base,
                              size_t n_pos,
                              int n,
                              int repnum,
                              int* info,
                              std::string* root) {}

int HunspellImpl::is_keepcase(const hentry* rv) {}

/* insert a word to the beginning of the suggestion array */
void HunspellImpl::insert_sug(std::vector<std::string>& slst, const std::string& word) {}

bool Hunspell::spell(const std::string& word, int* info, std::string* root) {}

bool HunspellImpl::spell(const std::string& word, int* info, std::string* root) {}

struct hentry* HunspellImpl::checkword(const std::string& w, int* info, std::string* root) {}

std::vector<std::string> Hunspell::suggest(const std::string& word) {}

std::vector<std::string> HunspellImpl::suggest(const std::string& word) {}

const std::string& Hunspell::get_dict_encoding() const {}

const std::string& HunspellImpl::get_dict_encoding() const {}

std::vector<std::string> Hunspell::stem(const std::vector<std::string>& desc) {}

std::vector<std::string> HunspellImpl::stem(const std::vector<std::string>& desc) {}

std::vector<std::string> Hunspell::stem(const std::string& word) {}

std::vector<std::string> HunspellImpl::stem(const std::string& word) {}

const char* Hunspell::get_wordchars() const {}

const std::string& Hunspell::get_wordchars_cpp() const {}

const std::string& HunspellImpl::get_wordchars() const {}

const std::vector<w_char>& Hunspell::get_wordchars_utf16() const {}

const std::vector<w_char>& HunspellImpl::get_wordchars_utf16() const {}

void HunspellImpl::mkinitcap(std::string& u8) {}

int HunspellImpl::mkinitcap2(std::string& u8, std::vector<w_char>& u16) {}

int HunspellImpl::mkinitsmall2(std::string& u8, std::vector<w_char>& u16) {}

int Hunspell::add(const std::string& word) {}

int HunspellImpl::add(const std::string& word) {}

int Hunspell::add_with_affix(const std::string& word, const std::string& example) {}

int HunspellImpl::add_with_affix(const std::string& word, const std::string& example) {}

int Hunspell::remove(const std::string& word) {}

int HunspellImpl::remove(const std::string& word) {}

const char* Hunspell::get_version() const {}

const std::string& Hunspell::get_version_cpp() const {}

const std::string& HunspellImpl::get_version() const {}

struct cs_info* HunspellImpl::get_csconv() {}

struct cs_info* Hunspell::get_csconv() {}

void HunspellImpl::cat_result(std::string& result, const std::string& st) {}

std::vector<std::string> Hunspell::analyze(const std::string& word) {}

std::vector<std::string> HunspellImpl::analyze(const std::string& word) {}

std::vector<std::string> Hunspell::generate(const std::string& word, const std::vector<std::string>& pl) {}

std::vector<std::string> HunspellImpl::generate(const std::string& word, const std::vector<std::string>& pl) {}

std::vector<std::string> Hunspell::generate(const std::string& word, const std::string& pattern) {}

std::vector<std::string> HunspellImpl::generate(const std::string& word, const std::string& pattern) {}

// minimal XML parser functions
std::string HunspellImpl::get_xml_par(const char* par) {}

int Hunspell::get_langnum() const {}

int HunspellImpl::get_langnum() const {}

bool Hunspell::input_conv(const std::string& word, std::string& dest) {}

int Hunspell::input_conv(const char* word, char* dest, size_t destsize) {}

bool HunspellImpl::input_conv(const std::string& word, std::string& dest) {}

// return the beginning of the element (attr == NULL) or the attribute
const char* HunspellImpl::get_xml_pos(const char* s, const char* attr) {}

int HunspellImpl::check_xml_par(const char* q,
                            const char* attr,
                            const char* value) {}

std::vector<std::string> HunspellImpl::get_xml_list(const char* list, const char* tag) {}

std::vector<std::string> HunspellImpl::spellml(const std::string& in_word) {}

int Hunspell::spell(const char* word, int* info, char** root) {}

namespace {
  int munge_vector(char*** slst, const std::vector<std::string>& items) {}
}

void Hunspell::free_list(char*** slst, int n) {}

int Hunspell::suggest(char*** slst, const char* word) {}

int Hunspell::suffix_suggest(char*** slst, const char* root_word) {}

char* Hunspell::get_dic_encoding() {}

int Hunspell::stem(char*** slst, char** desc, int n) {}

int Hunspell::stem(char*** slst, const char* word) {}

int Hunspell::analyze(char*** slst, const char* word) {}

int Hunspell::generate(char*** slst, const char* word, char** pl, int pln) {}

int Hunspell::generate(char*** slst, const char* word, const char* pattern) {}

Hunhandle* Hunspell_create(const char* affpath, const char* dpath) {}

Hunhandle* Hunspell_create_key(const char* affpath,
                               const char* dpath,
                               const char* key) {}

void Hunspell_destroy(Hunhandle* pHunspell) {}

#ifndef HUNSPELL_CHROME_CLIENT
int Hunspell_add_dic(Hunhandle* pHunspell, const char* dpath) {
  return reinterpret_cast<Hunspell*>(pHunspell)->add_dic(dpath);
}
#endif

int Hunspell_spell(Hunhandle* pHunspell, const char* word) {}

char* Hunspell_get_dic_encoding(Hunhandle* pHunspell) {}

int Hunspell_suggest(Hunhandle* pHunspell, char*** slst, const char* word) {}

int Hunspell_analyze(Hunhandle* pHunspell, char*** slst, const char* word) {}

int Hunspell_stem(Hunhandle* pHunspell, char*** slst, const char* word) {}

int Hunspell_stem2(Hunhandle* pHunspell, char*** slst, char** desc, int n) {}

int Hunspell_generate(Hunhandle* pHunspell,
                      char*** slst,
                      const char* word,
                      const char* pattern) {}

int Hunspell_generate2(Hunhandle* pHunspell,
                       char*** slst,
                       const char* word,
                       char** desc,
                       int n) {}

/* functions for run-time modification of the dictionary */

/* add word to the run-time dictionary */

int Hunspell_add(Hunhandle* pHunspell, const char* word) {}

/* add word to the run-time dictionary with affix flags of
 * the example (a dictionary word): Hunspell will recognize
 * affixed forms of the new word, too.
 */

int Hunspell_add_with_affix(Hunhandle* pHunspell,
                            const char* word,
                            const char* example) {}

/* remove word from the run-time dictionary */

int Hunspell_remove(Hunhandle* pHunspell, const char* word) {}

void Hunspell_free_list(Hunhandle*, char*** list, int n) {}

std::vector<std::string> Hunspell::suffix_suggest(const std::string& root_word) {}

std::vector<std::string> HunspellImpl::suffix_suggest(const std::string& root_word) {}