├── lib5 ├── aspell-dummy.cpp ├── pspell-dummy.cpp └── Makefile.am ├── common ├── stamp-h.in ├── Makefile.in ├── filter_debug.hpp ├── ndebug.hpp ├── version.cpp ├── iostream.cpp ├── gettext_init.cpp ├── char_vector.hpp ├── itemize.hpp ├── speller.cpp ├── strtonum.hpp ├── file_data_util.hpp ├── string_pair.hpp ├── can_have_error.cpp ├── iostream.hpp ├── tokenizer.cpp ├── can_have_error.hpp ├── mutable_container.hpp ├── istream.hpp ├── error.hpp ├── istream_enumeration.hpp ├── asc_ctype.hpp ├── filter_char_vector.hpp ├── string_enumeration.hpp ├── clone_ptr-t.hpp ├── error.cpp ├── vararray.hpp ├── clone_ptr.hpp ├── filter_char.hpp ├── stack_ptr.hpp ├── block_slist-t.hpp ├── copy_ptr.hpp ├── ostream.hpp ├── generic_copy_ptr-t.hpp ├── lock.hpp ├── vector.hpp ├── document_checker.hpp ├── objstack.cpp ├── simple_string.hpp ├── generic_copy_ptr.hpp ├── file_util.hpp ├── hash_fun.hpp ├── tokenizer.hpp ├── filter.hpp ├── mutable_string.hpp ├── suggestions.hpp ├── block_slist.hpp ├── getdata.hpp ├── strtonum.cpp ├── string.cpp ├── file_data_util.cpp ├── cache.hpp ├── string_map.cpp ├── string_list.hpp ├── itemize.cpp ├── cache.cpp ├── document_checker.cpp ├── fstream.hpp ├── cache-t.hpp └── basic_list.hpp ├── modules ├── filter │ ├── latex.flt │ ├── Makefile.in │ ├── context.cpp │ ├── modes │ │ ├── none.amf │ │ ├── url.amf │ │ ├── email.amf │ │ ├── texinfo.amf │ │ ├── nroff.amf │ │ ├── tex.amf │ │ ├── comment.amf │ │ ├── markdown.amf │ │ ├── sgml.amf │ │ ├── html.amf │ │ ├── perl.amf │ │ └── ccpp.amf │ ├── url-filter.info │ ├── nroff-filter.info │ ├── sgml-filter.info │ ├── email-filter.info │ ├── context-filter.info │ ├── html-filter.info │ ├── texinfo-filter.info │ ├── markdown-filter.info │ ├── url.cpp │ └── tex-filter.info ├── Makefile.in ├── speller │ ├── Makefile.in │ └── default │ │ ├── Makefile.in │ │ ├── phonet.cpp │ │ ├── phonet.hpp │ │ ├── data_id.hpp │ │ ├── matrix.hpp │ │ ├── editdist2.hpp │ │ ├── weights.hpp │ │ ├── phonetic.hpp │ │ ├── editdist.hpp │ │ ├── data_util.hpp │ │ ├── asuggest.hpp │ │ ├── suggest.hpp │ │ ├── check_list.hpp │ │ ├── editdist.cpp │ │ ├── primes.cpp │ │ ├── wordinfo.hpp │ │ ├── block_vector.hpp │ │ ├── multi_ws.cpp │ │ ├── leditdist.hpp │ │ └── typo_editdist.hpp └── tokenizer │ ├── Makefile.in │ └── basic.cpp ├── lib ├── dummy.cpp ├── new_fmode.cpp ├── new_filter.cpp ├── Makefile.in ├── filter_entry.hpp ├── new_config.cpp └── new_checker.cpp ├── test ├── en_repl.dat ├── en.prepl ├── en.dat ├── .gitignore ├── suggest │ ├── filter.pl │ ├── 00-special.tab │ ├── refresh │ ├── 00-special-ultra-expect.res │ ├── 00-special-ultra-nokbd-expect.res │ ├── run-batch │ ├── mkmk │ └── comp ├── misc │ └── commonmark-proc ├── sanity ├── warning-settings.cpp ├── filter-test ├── wide_test_valid.c └── wide_test_invalid.c ├── po ├── es.po ├── fr.po ├── it.po ├── LINGUAS └── POTFILES.in ├── auto ├── Makefile.in ├── mk-doc.pl ├── MkSrc │ ├── Methods.pm │ ├── Util.pm │ ├── Type.pm │ └── ProcNativeImpl.pm └── mk-src.pl ├── data ├── Makefile.in ├── split.kbd ├── dvorak.kbd └── standard.kbd ├── gen ├── Makefile.in ├── mk-dirs_h.pl └── mk-filter-pot.pl ├── m4 └── Makefile.in ├── myspell ├── CONTRIBUTORS ├── Makefile.am ├── README ├── README_en_US.txt ├── README.munch ├── README.replacetable └── munch.h ├── prog ├── Makefile.in └── check_funs.hpp ├── interfaces ├── Makefile.in └── cc │ └── Makefile.in ├── scripts ├── Makefile.in ├── run-with-aspell.create ├── spell ├── mkconfig ├── ispell └── aspell-import ├── TODO ├── sanity-check.sh ├── rm-auto ├── config-opt ├── config-debug ├── examples ├── Makefile.am └── list-dicts.c ├── manual ├── lang-unsupported.texi ├── oo-only.texi ├── Makefile.am ├── pspell-config.1 ├── aspell-import.1 ├── run-with-aspell.1 └── crubadan.texi ├── FIXMEs ├── autogen ├── .gitignore ├── README.md └── win32 └── settings.h /lib5/aspell-dummy.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib5/pspell-dummy.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /common/stamp-h.in: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /modules/filter/latex.flt: -------------------------------------------------------------------------------- 1 | add-filter tex 2 | -------------------------------------------------------------------------------- /lib/dummy.cpp: -------------------------------------------------------------------------------- 1 | void pspell_aspell_dummy() {} 2 | -------------------------------------------------------------------------------- /test/en_repl.dat: -------------------------------------------------------------------------------- 1 | REP 1 2 | REP zphb xenophobia 3 | -------------------------------------------------------------------------------- /po/es.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/po/es.po -------------------------------------------------------------------------------- /po/fr.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/po/fr.po -------------------------------------------------------------------------------- /po/it.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/po/it.po -------------------------------------------------------------------------------- /test/en.prepl: -------------------------------------------------------------------------------- 1 | personal_repl-1.1 en 0 2 | hjk hijack 3 | zkw zip line 4 | -------------------------------------------------------------------------------- /lib/new_fmode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/lib/new_fmode.cpp -------------------------------------------------------------------------------- /lib/new_filter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/lib/new_filter.cpp -------------------------------------------------------------------------------- /auto/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /common/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /data/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /gen/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /lib/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /m4/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /myspell/CONTRIBUTORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/myspell/CONTRIBUTORS -------------------------------------------------------------------------------- /prog/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /common/filter_debug.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/common/filter_debug.hpp -------------------------------------------------------------------------------- /interfaces/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /modules/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /scripts/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /interfaces/cc/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /modules/filter/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /modules/filter/context.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/modules/filter/context.cpp -------------------------------------------------------------------------------- /modules/speller/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Consider adding support for recognizing options translated in a 2 | different language. 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /modules/tokenizer/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /sanity-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | make -C test clean 6 | make -k -j2 -C test sanity 7 | 8 | -------------------------------------------------------------------------------- /modules/filter/modes/none.amf: -------------------------------------------------------------------------------- 1 | MODE none 2 | 3 | ASPELL >=0.60.1 4 | 5 | DESCRIPTION mode to disable all filters 6 | -------------------------------------------------------------------------------- /modules/speller/default/Makefile.in: -------------------------------------------------------------------------------- 1 | top_srcdir = @top_srcdir@ 2 | 3 | subsystem: 4 | $(MAKE) -C ${top_srcdir} 5 | -------------------------------------------------------------------------------- /modules/speller/default/phonet.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/modules/speller/default/phonet.cpp -------------------------------------------------------------------------------- /modules/speller/default/phonet.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/binhetech/aspell/master/modules/speller/default/phonet.hpp -------------------------------------------------------------------------------- /myspell/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = munch 2 | 3 | munch_SOURCES = munch.c 4 | 5 | EXTRA_DIST = README* en_US.aff *.h -------------------------------------------------------------------------------- /test/en.dat: -------------------------------------------------------------------------------- 1 | name en 2 | charset iso8859-1 3 | special ' -*- 4 | soundslike en 5 | affix en 6 | repl-table en_repl.dat 7 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | inst/ 3 | tmp/ 4 | aspell6-en-2018.04.16-0/ 5 | 6 | test-res 7 | aspell6-en-2018.04.16-0.tar.bz2 8 | -------------------------------------------------------------------------------- /scripts/run-with-aspell.create: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "#!/bin/sh" 4 | echo "PATH=$1:\$PATH" 5 | echo "export PATH" 6 | echo "exec \$@" 7 | 8 | -------------------------------------------------------------------------------- /rm-auto: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . \( -name '*.?pp' -o -name '*.h' \) -print | 4 | xargs grep -l "Automatically generated file."| 5 | xargs rm 6 | 7 | -------------------------------------------------------------------------------- /modules/filter/modes/url.amf: -------------------------------------------------------------------------------- 1 | MODE url 2 | 3 | ASPELL >=0.60 4 | 5 | DESCRIPTION mode to skip URL like constructs (default mode) 6 | 7 | FILTER url 8 | -------------------------------------------------------------------------------- /scripts/spell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # aspell list mimics the standard unix spell program, roughly. 4 | 5 | cat "$@" | aspell list --mode=none | sort -u 6 | 7 | -------------------------------------------------------------------------------- /modules/filter/modes/email.amf: -------------------------------------------------------------------------------- 1 | MODE email 2 | 3 | ASPELL >=0.60 4 | 5 | DESCRIPTION mode for skipping quoted text in email messages 6 | 7 | FILTER url 8 | FILTER email 9 | -------------------------------------------------------------------------------- /test/suggest/filter.pl: -------------------------------------------------------------------------------- 1 | while (<>) { 2 | chomp; 3 | my @data = split "\t"; 4 | die unless @data == 4; 5 | next if $data[2] == -1 && $data[3] == -1; 6 | print "$data[0]\t$data[1]\n"; 7 | } 8 | -------------------------------------------------------------------------------- /common/ndebug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NDEBUG__HPP 2 | #define NDEBUG__HPP 3 | 4 | #ifdef NDEBUG 5 | #warning "Binaries compiled with NDEBUG defined are unsupported see http://aspell.net/ndebug.html." 6 | #endif 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /modules/filter/modes/texinfo.amf: -------------------------------------------------------------------------------- 1 | MODE texinfo 2 | 3 | ASPELL >=0.60.1 4 | 5 | MAGIC //texi/texinfo 6 | 7 | DESCRIPTION mode for checking Texinfo documents 8 | 9 | FILTER url 10 | FILTER texinfo 11 | -------------------------------------------------------------------------------- /data/split.kbd: -------------------------------------------------------------------------------- 1 | # Natural (split) keyboard data file 2 | 3 | qw 4 | we 5 | er 6 | rt 7 | yu 8 | ui 9 | io 10 | op 11 | as 12 | sd 13 | df 14 | fg 15 | hj 16 | jk 17 | kl 18 | zx 19 | xc 20 | cv 21 | bn 22 | nm 23 | 24 | -------------------------------------------------------------------------------- /modules/filter/modes/nroff.amf: -------------------------------------------------------------------------------- 1 | MODE nroff 2 | 3 | ASPELL >=0.60.1 4 | 5 | MAGIC /0:3:\.\/"/0/1/2/3/4/5/6/7/8/9/n/man/tmac 6 | 7 | DESCRIPTION mode for checking Nroff documents 8 | 9 | FILTER url 10 | FILTER nroff 11 | -------------------------------------------------------------------------------- /data/dvorak.kbd: -------------------------------------------------------------------------------- 1 | # Dvorak keyboard data file 2 | 3 | py 4 | yf 5 | fg 6 | gc 7 | cr 8 | rl 9 | ao 10 | oe 11 | eu 12 | ui 13 | id 14 | dh 15 | ht 16 | tn 17 | ns 18 | qj 19 | jk 20 | kx 21 | xb 22 | bm 23 | mw 24 | wv 25 | vz 26 | -------------------------------------------------------------------------------- /data/standard.kbd: -------------------------------------------------------------------------------- 1 | # Standard keyboard data file 2 | 3 | qw 4 | we 5 | er 6 | rt 7 | ty 8 | yu 9 | ui 10 | io 11 | op 12 | as 13 | sd 14 | df 15 | fg 16 | gh 17 | hj 18 | jk 19 | kl 20 | zx 21 | xc 22 | cv 23 | vb 24 | bn 25 | nm 26 | -------------------------------------------------------------------------------- /modules/filter/modes/tex.amf: -------------------------------------------------------------------------------- 1 | MODE tex 2 | 3 | ASPELL >=0.60 4 | 5 | MAGIC /0:256:^[ \t]*\\documentclass\[[^\[\]]*\]\{[^\{\}]*\}/tex 6 | 7 | DESCRIPTION mode for checking TeX/LaTeX documents 8 | 9 | FILTER url 10 | FILTER tex 11 | -------------------------------------------------------------------------------- /myspell/README: -------------------------------------------------------------------------------- 1 | This directory contains some utilities and documentation from the 2 | standalone MySpell utility with some minor modifications. 3 | 4 | You can find MySpell at 5 | http://lingucomponent.openoffice.org/dictionary.html 6 | 7 | 8 | -------------------------------------------------------------------------------- /config-opt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p build 4 | cd build 5 | ../configure --enable-maintainer-mode --disable-shared --disable-pspell-compatibility \ 6 | --prefix="`pwd`/../inst" CFLAGS='-g -O -Wall' CXXFLAGS='-g -O -Wall' "$@" 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /config-debug: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p build 4 | cd build 5 | ../configure --enable-maintainer-mode \ 6 | --disable-shared --disable-pspell-compatibility\ 7 | --prefix="`pwd`/../inst" CFLAGS='-g -Wall -Wno-unused' CXXFLAGS='-g -Wall -Wno-unused' "$@" 8 | -------------------------------------------------------------------------------- /modules/filter/modes/comment.amf: -------------------------------------------------------------------------------- 1 | MODE comment 2 | 3 | ASPELL >=0.60 4 | 5 | DESCRIPTION mode to check any lines starting with a \# 6 | 7 | FILTER url 8 | FILTER context 9 | OPTION clear-context-delimiters 10 | OPTION add-context-delimiters \# \0 11 | 12 | 13 | -------------------------------------------------------------------------------- /modules/filter/url-filter.info: -------------------------------------------------------------------------------- 1 | # URL filter option file 2 | 3 | #This Filter is usable with the following version(s) of Aspell 4 | ASPELL >=0.50 5 | 6 | #This line will be printed when typing `aspell help url' 7 | DESCRIPTION filter to skip URL like constructs 8 | 9 | STATIC filter 10 | -------------------------------------------------------------------------------- /modules/filter/modes/markdown.amf: -------------------------------------------------------------------------------- 1 | # Markdown mode description file 2 | 3 | MODE markdown 4 | 5 | ASPELL >=0.60 6 | 7 | MAGIC //md/markdown/mdown 8 | 9 | DESCRIPTION mode for checking Markdown/CommonMark documents 10 | 11 | FILTER url 12 | FILTER markdown 13 | FILTER sgml 14 | 15 | -------------------------------------------------------------------------------- /modules/filter/nroff-filter.info: -------------------------------------------------------------------------------- 1 | # sgml filter option file 2 | 3 | #This Filter is usable with the following version(s) of Aspell 4 | ASPELL >=0.51 5 | 6 | #This line will be printed when typing `aspell help nroff' 7 | DESCRIPTION filter for dealing with Nroff documents 8 | 9 | STATIC filter 10 | 11 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = example-c list-dicts 2 | 3 | AM_CPPFLAGS = -I${top_srcdir}/interfaces/cc/ -I${top_srcdir}/common 4 | 5 | example_c_SOURCES = example-c.c 6 | 7 | example_c_LDADD = ../libaspell.la 8 | 9 | 10 | list_dicts_SOURCES = list-dicts.c 11 | 12 | list_dicts_LDADD = ../libaspell.la 13 | 14 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | # Set of available languages. 2 | ast 3 | be 4 | ca 5 | cs 6 | da 7 | de 8 | en_GB 9 | eo 10 | es 11 | fi 12 | fr 13 | fur 14 | ga 15 | hr 16 | id 17 | it 18 | ja 19 | mn 20 | ms 21 | nl 22 | pl 23 | pt 24 | pt_BR 25 | ro 26 | ru 27 | rw 28 | sk 29 | sl 30 | sr 31 | sv 32 | tg 33 | uk 34 | vi 35 | wa 36 | zh_CN 37 | -------------------------------------------------------------------------------- /modules/filter/modes/sgml.amf: -------------------------------------------------------------------------------- 1 | MODE sgml 2 | 3 | ASPELL >=0.60 4 | 5 | MAGIC /0:256:^[ \t]*<[Hh][Tt][Mm][Ll]([ \t]*(<[^>]*>|[^<>]*))*>/htm/html 6 | MAGIC /0:256:^[ \t]*<[h][Tt][Mm][Ll]([ \t]*(<[^>]*>|[^<>]*))*>/HTM/HTML 7 | 8 | DESCRIPTION mode for checking generic SGML/XML documents 9 | 10 | FILTER url 11 | FILTER sgml 12 | 13 | -------------------------------------------------------------------------------- /modules/filter/modes/html.amf: -------------------------------------------------------------------------------- 1 | # HTML mode description file 2 | 3 | MODE html 4 | 5 | ASPELL >=0.60 6 | 7 | MAGIC /0:256:^[ \t]*<[Hh][Tt][Mm][Ll]([ \t]*(<[^>]*>|[^<>]*))*>/htm/html 8 | MAGIC /0:256:^[ \t]*<[h][Tt][Mm][Ll]([ \t]*(<[^>]*>|[^<>]*))*>/HTM/HTML 9 | 10 | DESCRIPTION mode for checking HTML documents 11 | 12 | FILTER url 13 | FILTER html 14 | -------------------------------------------------------------------------------- /test/suggest/00-special.tab: -------------------------------------------------------------------------------- 1 | colour color 2 | hjk hijack 3 | hjkk hijack 4 | jk hijack 5 | Hjk Hijack 6 | HJK HIJACK 7 | hk hijack 8 | sjk hijack 9 | zphb xenophobia 10 | zkw zip line 11 | Joeuser JoeUser 12 | JoeuSer JoeUser 13 | JooUser JoeUser 14 | camelCasWord camelCaseWord 15 | camelcaseWord camelCaseWord 16 | cmlCaseWord camelCaseWord 17 | mcdonalds McDonald's 18 | -------------------------------------------------------------------------------- /manual/lang-unsupported.texi: -------------------------------------------------------------------------------- 1 | @multitable {Code} {Language Name} {Han, Hangul} 2 | @item @b{Code} @tab @b{Language Name} @tab @b{Script} 3 | @item ja @tab Japanese @tab Japanese 4 | @item km @tab Khmer @tab Khmer 5 | @item ko @tab Korean @tab Han, Hangul 6 | @item lo @tab Lao @tab Lao 7 | @item th @tab Thai @tab Thai 8 | @item zh @tab Chinese @tab Han 9 | 10 | @end multitable 11 | -------------------------------------------------------------------------------- /common/version.cpp: -------------------------------------------------------------------------------- 1 | #include "settings.h" 2 | 3 | #ifdef NDEBUG 4 | # define NDEBUG_STR " NDEBUG" 5 | #else 6 | # define NDEBUG_STR 7 | #endif 8 | 9 | #ifdef SLOPPY_NULL_TERM_STRINGS 10 | # define SLOPPY_STR " SLOPPY" 11 | #else 12 | # define SLOPPY_STR 13 | #endif 14 | 15 | extern "C" const char * aspell_version_string() { 16 | return VERSION NDEBUG_STR SLOPPY_STR; 17 | } 18 | -------------------------------------------------------------------------------- /lib/filter_entry.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILTER_ENTRY_HEADER 2 | #define FILTER_ENTRY_HEADER 3 | 4 | #include "indiv_filter.hpp" 5 | 6 | namespace acommon { 7 | 8 | typedef IndividualFilter * (FilterFun) (); 9 | 10 | struct FilterEntry 11 | { 12 | const char * name; 13 | FilterFun * decoder; 14 | FilterFun * filter; 15 | FilterFun * encoder; 16 | }; 17 | }; 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /FIXMEs: -------------------------------------------------------------------------------- 1 | FIXME: Find a correct solution to the Upper Sorbian problem 2 | 3 | FIXME: allow soundslike to be "stripped" instead of "clean" 4 | 5 | FIXME: consider Eliminate string classes and use VirEnumeration 6 | FIXME: make each methods collection a (possible templates) base class 7 | 8 | FIXME: figure out how to include instructions about the format of 9 | translated strings such as the length. 10 | -------------------------------------------------------------------------------- /modules/filter/modes/perl.amf: -------------------------------------------------------------------------------- 1 | MODE perl 2 | 3 | ASPELL >=0.60.1 4 | 5 | MAGIC /0:256:^[ \t]*\#!((\/\w*)+)\/perl/pl/pm 6 | MAGIC //pl/pm 7 | 8 | DESCRIPTION mode for checking Perl comments and string literals 9 | 10 | FILTER url 11 | FILTER context 12 | OPTION clear-context-delimiters 13 | OPTION add-context-delimiters " " 14 | OPTION add-context-delimiters \# \0 15 | OPTION disable-context-visible-first 16 | 17 | -------------------------------------------------------------------------------- /manual/oo-only.texi: -------------------------------------------------------------------------------- 1 | @itemize 2 | @item Coptic (cop) 3 | @item Dyula (dyu) 4 | @item Fulah (ff) 5 | @item Fijian (fj) 6 | @item Friulian (fur) 7 | @item Khmer (km) 8 | @item Luxembourgish (lb) 9 | @item Mossi (mos) 10 | @item Nepali (ne) 11 | @item South Ndebele (nr) 12 | @item Northern Sotho (nso) 13 | @item Swati (ss) 14 | @item Southern Sotho (st) 15 | @item Tsonga (ts) 16 | @item Venda (ve) 17 | @item Xhosa (xh) 18 | @end itemize 19 | -------------------------------------------------------------------------------- /lib5/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if INCREMENTED_SONAME 3 | 4 | lib_LTLIBRARIES = libaspell.la 5 | libaspell_la_SOURCES = aspell-dummy.cpp 6 | libaspell_la_LDFLAGS = -version-info 16:0:1 7 | libaspell_la_LIBADD = ../libaspell.la 8 | 9 | if PSPELL_COMPATIBILITY 10 | lib_LTLIBRARIES += libpspell.la 11 | libpspell_la_SOURCES = pspell-dummy.cpp 12 | libpspell_la_LDFLAGS = -version-info 16:0:1 13 | libpspell_la_LIBADD = ../libaspell.la 14 | endif 15 | 16 | endif 17 | -------------------------------------------------------------------------------- /modules/filter/modes/ccpp.amf: -------------------------------------------------------------------------------- 1 | MODE ccpp 2 | 3 | ASPELL >=0.60.1 4 | 5 | MAGIC //c/cc/cpp 6 | MAGIC //h/hpp 7 | 8 | DESCRIPTION mode for checking C++ comments and string literals 9 | 10 | FILTER url 11 | FILTER context 12 | OPTION clear-context-delimiters 13 | OPTION add-context-delimiters /* */ 14 | OPTION add-context-delimiters // \0 15 | OPTION add-context-delimiters " " 16 | OPTION disable-context-visible-first 17 | 18 | 19 | -------------------------------------------------------------------------------- /myspell/README_en_US.txt: -------------------------------------------------------------------------------- 1 | This dictionary is based on a subset of the original 2 | English wordlist created by Kevin Atkinson for Pspell 3 | and Aspell and thus is covered by his original 4 | LGPL license. The affix file is a heavily modified 5 | version of the original english.aff file which was 6 | released as part of Geoff Kuenning's Ispell and as 7 | such is covered by his BSD license. 8 | 9 | Thanks to both authors for there wonderful work. 10 | -------------------------------------------------------------------------------- /test/misc/commonmark-proc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use autodie; 6 | 7 | binmode(STDOUT, ":utf8"); 8 | 9 | use JSON; 10 | 11 | $/ = undef; 12 | open F, "commonmark-examples.json"; 13 | 14 | my $data = decode_json(); 15 | 16 | my $i = 1; 17 | foreach my $obj (@$data) { 18 | open F, ">tmp/$i.md"; 19 | binmode(F, ":utf8"); 20 | print F $obj->{markdown}; 21 | print F "\n"; 22 | close F; 23 | $i++; 24 | } 25 | -------------------------------------------------------------------------------- /common/iostream.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include "iostream.hpp" 8 | 9 | namespace acommon { 10 | FStream CIN(stdin, false); 11 | FStream COUT(stdout, false); 12 | FStream CERR(stderr, false); 13 | } 14 | -------------------------------------------------------------------------------- /common/gettext_init.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "gettext.h" 3 | 4 | #if ENABLE_NLS 5 | 6 | #include "lock.hpp" 7 | 8 | static acommon::Mutex lock; 9 | 10 | static bool did_init = false; 11 | 12 | extern "C" void aspell_gettext_init() 13 | { 14 | { 15 | acommon::Lock l(&lock); 16 | if (did_init) return; 17 | did_init = true; 18 | } 19 | bindtextdomain("aspell", LOCALEDIR); 20 | } 21 | 22 | #else 23 | 24 | extern "C" void aspell_gettext_init() 25 | { 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /gen/mk-dirs_h.pl: -------------------------------------------------------------------------------- 1 | 2 | foreach (@ARGV) {s|/+|/|g; s|/$||;} 3 | 4 | ($prefix, $data, $lib, $conf) = @ARGV; 5 | 6 | sub def ( $ ) { 7 | return qq|""| if $_[0] =~ m|^$prefix/?(.+)$|; 8 | return qq|"$_[0]"|; 9 | } 10 | 11 | printf qq|#define PREFIX "%s"\n|, $prefix; 12 | printf qq|#define DATA_DIR %s\n|, def($data); 13 | print qq|#define DICT_DIR ""\n| if $lib eq $data; 14 | printf qq|#define DICT_DIR %s\n|, def($lib) if $lib ne $data; 15 | printf qq|#define CONF_DIR %s\n|, def($conf); 16 | 17 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | common/info.cpp 2 | common/config.cpp 3 | common/convert.cpp 4 | common/errors.cpp 5 | common/posib_err.cpp 6 | lib/new_fmode.cpp 7 | prog/aspell.cpp 8 | prog/check_funs.cpp 9 | modules/speller/default/language.cpp 10 | modules/speller/default/affix.cpp 11 | modules/speller/default/readonly_ws.cpp 12 | modules/speller/default/multi_ws.cpp 13 | modules/speller/default/suggest.cpp 14 | modules/speller/default/data.cpp 15 | modules/speller/default/speller_impl.cpp 16 | modules/filter/tex.cpp 17 | gen/filter.pot 18 | -------------------------------------------------------------------------------- /common/char_vector.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001-2003 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_CHAR_VECTOR__HPP 8 | #define ASPELL_CHAR_VECTOR__HPP 9 | 10 | #include "string.hpp" 11 | #include "ostream.hpp" 12 | 13 | namespace acommon 14 | { 15 | typedef String CharVector; 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /myspell/README.munch: -------------------------------------------------------------------------------- 1 | Munch will take a word list and output an affix compressed version of 2 | the list to stdout. Is syntax is 3 | 4 | munch 5 | 6 | The input word list for munch MUST start with a number indicating the 7 | number of words in the list. A good way to find it is 'wc -l'. 8 | 9 | To use the list to create an Aspell dictionary you need to remove the 10 | first line in the output which is the number of words in the output 11 | list. 12 | 13 | I hope to eventually integrate this program with the rest of Aspell. -------------------------------------------------------------------------------- /scripts/mkconfig: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | cat < scripts/pspell-config 5 | #!/bin/sh 6 | 7 | # This script is provided for backward compatibility with programs 8 | # that use pspell. Do not use as it will eventually go away. 9 | 10 | case \$1 in 11 | --version | version) 12 | echo $1 13 | ;; 14 | --datadir | datadir) 15 | echo "$2" 16 | ;; 17 | --pkgdatadir | pkgdatadir) 18 | echo "$3" 19 | ;; 20 | *) 21 | echo "usage: pspell-config version|datadir|pkgdatadir" 22 | ;; 23 | esac 24 | EOF 25 | 26 | chmod +x scripts/pspell-config 27 | 28 | -------------------------------------------------------------------------------- /autogen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | test -d interfaces || mkdir interfaces 6 | test -d interfaces/cc || mkdir interfaces/cc 7 | cd auto/ 8 | perl -I ./ mk-src.pl 9 | perl -I ./ mk-doc.pl 10 | touch auto 11 | cd .. 12 | 13 | cd scripts/ 14 | test -e preunzip || ln -s prezip preunzip 15 | test -e precat || ln -s prezip precat 16 | cd .. 17 | 18 | autopoint -f || exit 1 19 | libtoolize --automake || exit 1 20 | aclocal -I m4 $ACLOCAL_FLAGS || exit 1 21 | autoheader || exit 1 22 | automake --add-missing --foreign || exit 1 23 | autoconf || exit 1 24 | 25 | -------------------------------------------------------------------------------- /modules/filter/sgml-filter.info: -------------------------------------------------------------------------------- 1 | # SGML filter option file 2 | 3 | LIB-FILE sgml-filter 4 | 5 | #THIS Filter is usable with the following version(s) of Aspell 6 | ASPELL >=0.51 7 | 8 | #This line will be printed when typing `Aspell help SGML' 9 | DESCRIPTION filter for dealing with generic SGML/XML documents 10 | 11 | STATIC filter 12 | 13 | OPTION check 14 | TYPE list 15 | DESCRIPTION SGML attributes to always check 16 | ENDOPTION 17 | 18 | OPTION skip 19 | TYPE list 20 | DESCRIPTION SGML tags to always skip the contents of 21 | ENDOPTION 22 | 23 | STATIC decoder 24 | -------------------------------------------------------------------------------- /modules/filter/email-filter.info: -------------------------------------------------------------------------------- 1 | # email filter option file 2 | 3 | #This Filter is usable with the following version(s) of Aspell 4 | ASPELL >=0.51 5 | 6 | #This line will be printed when typing `Aspell help email' 7 | DESCRIPTION filter for skipping quoted text in email messages 8 | 9 | STATIC filter 10 | 11 | OPTION quote 12 | TYPE list 13 | DESCRIPTION email quote characters 14 | DEFAULT > 15 | DEFAULT | 16 | FLAGS utf-8 17 | ENDOPTION 18 | 19 | OPTION margin 20 | TYPE int 21 | DESCRIPTION num chars that can appear before the quote char 22 | DEFAULT 10 23 | ENDOPTION 24 | -------------------------------------------------------------------------------- /common/itemize.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ITEMIZE__HPP 8 | #define ITEMIZE__HPP 9 | 10 | #include "parm_string.hpp" 11 | #include "posib_err.hpp" 12 | 13 | namespace acommon { 14 | 15 | class MutableContainer; 16 | PosibErr itemize(ParmString, MutableContainer &); 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /common/speller.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #include "speller.hpp" 8 | #include "convert.hpp" 9 | #include "clone_ptr-t.hpp" 10 | #include "config.hpp" 11 | 12 | namespace acommon { 13 | 14 | Speller::Speller(SpellerLtHandle h) : lt_handle_(h) {} 15 | 16 | Speller::~Speller() {} 17 | } 18 | 19 | -------------------------------------------------------------------------------- /modules/filter/context-filter.info: -------------------------------------------------------------------------------- 1 | # context filter option file 2 | 3 | #This Filter is usable with the following version(s) of Aspell 4 | ASPELL >=0.51 5 | 6 | #This line will be printed when typing `aspell help context' 7 | DESCRIPTION experimental filter for hiding delimited contexts 8 | 9 | STATIC filter 10 | 11 | OPTION delimiters 12 | TYPE list 13 | DESCRIPTION context delimiters (separated by spaces) 14 | DEFAULT " " 15 | DEFAULT /* */ 16 | DEFAULT // \0 17 | ENDOPTION 18 | 19 | OPTION visible-first 20 | TYPE bool 21 | DESCRIPTION swaps visible and invisible text 22 | DEFAULT false 23 | ENDOPTION 24 | -------------------------------------------------------------------------------- /manual/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | info_TEXINFOS = aspell.texi aspell-dev.texi 3 | 4 | MAKEINFOFLAGS = --enable-encoding \ 5 | --set-customization-variable 'EXTRA_HEAD ' 6 | 7 | aspell_TEXINFOS = readme.texi fdl.texi lgpl.texi \ 8 | lang-supported.texi lang-unsupported.texi crubadan.texi oo-only.texi 9 | aspell_dev_TEXINFOS = mksrc.texi fdl.texi 10 | 11 | man_MANS = aspell.1 pspell-config.1 word-list-compress.1\ 12 | aspell-import.1 run-with-aspell.1 prezip-bin.1 13 | 14 | EXTRA_DIST = $(man_MANS) aspell.html aspell-dev.html 15 | 16 | -------------------------------------------------------------------------------- /modules/filter/html-filter.info: -------------------------------------------------------------------------------- 1 | # SGML filter option file 2 | 3 | LIB-FILE sgml-filter 4 | 5 | #This Filter is usable with the following version(s) of Aspell 6 | ASPELL >=0.51 7 | 8 | #This line will be printed when typing `Aspell help SGML' 9 | DESCRIPTION filter for dealing with HTML documents 10 | 11 | STATIC filter 12 | 13 | OPTION check 14 | TYPE list 15 | DESCRIPTION HTML attributes to always check 16 | DEFAULT alt 17 | ENDOPTION 18 | 19 | OPTION skip 20 | TYPE list 21 | DESCRIPTION HTML tags to always skip the contents of 22 | DEFAULT script 23 | DEFAULT style 24 | ENDOPTION 25 | 26 | STATIC decoder 27 | -------------------------------------------------------------------------------- /modules/speller/default/data_id.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ASPELLER_DATA_ID__HPP 2 | #define ASPELLER_DATA_ID__HPP 3 | 4 | #include "settings.h" 5 | 6 | #include 7 | 8 | namespace aspeller { 9 | 10 | class Dict::Id { 11 | public: // but don't use 12 | const Dict * ptr; 13 | const char * file_name; 14 | #ifdef USE_FILE_INO 15 | ino_t ino; 16 | dev_t dev; 17 | #endif 18 | public: 19 | Id(Dict * p, const FileName & fn = FileName()); 20 | }; 21 | 22 | inline bool Dict::cache_key_eq(const Id & o) 23 | { 24 | return *id_ == o; 25 | } 26 | 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /modules/speller/default/matrix.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __aspeller_matrix_hh__ 2 | #define __aspeller_matrix_hh__ 3 | 4 | #include 5 | 6 | namespace aspeller { 7 | 8 | class ShortMatrix { 9 | int x_size; 10 | int y_size; 11 | short * data; 12 | public: 13 | void init(int sx, int sy, short * d) {x_size = sx; y_size = sy; data = d;} 14 | ShortMatrix() {} 15 | ShortMatrix(int sx, int sy, short * d) {init(sx,sy,d);} 16 | short operator() (int x, int y) const {return data[x + y*x_size];} 17 | short & operator() (int x, int y) {return data[x + y*x_size];} 18 | }; 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /common/strtonum.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Melvin Hadasht and Kevin Atkinson under the 3 | // GNU LGPL license version 2.0 or 2.1. You should have received a 4 | // copy of the LGPL license along with this library if you did not you 5 | // can find it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_STRTONUM__HPP 8 | #define ASPELL_STRTONUM__HPP 9 | 10 | namespace acommon { 11 | 12 | // Local independent numeric conversion. It is OK if 13 | // nptr == *endptr 14 | double strtod_c(const char * nptr, const char ** endptr); 15 | long strtoi_c(const char * npter, const char ** endptr); 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/new_config.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL 3 | // license version 2.0 or 2.1. You should have received a copy of the 4 | // LGPL license along with this library if you did not you can find it 5 | // at http://www.gnu.org/. 6 | 7 | #include 8 | 9 | #include "config.hpp" 10 | #include "errors.hpp" 11 | #include "filter.hpp" 12 | 13 | namespace acommon { 14 | 15 | extern void setup_static_filters(Config * config); 16 | 17 | Config * new_config() 18 | { 19 | Config * config = new_basic_config(); 20 | setup_static_filters(config); 21 | return config; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /myspell/README.replacetable: -------------------------------------------------------------------------------- 1 | We can define language-dependent phonetic information 2 | in the affix file (.aff) by a replacement table. With this 3 | table, MySpell can suggest the right forms for the typical 4 | faults of spelling when the incorrect form differs by more, 5 | than 1 letter from the right form. 6 | 7 | Replacement table syntax: 8 | 9 | REP [number_of_replacement_definitions] 10 | REP [what] [replacement] 11 | REP [what] [replacement] 12 | ... 13 | 14 | For example a possible English replacement table definition 15 | to handle misspelt consonants: 16 | 17 | REP 8 18 | REP f ph 19 | REP ph f 20 | REP f gh 21 | REP gh f 22 | REP j dg 23 | REP dg j 24 | REP k ch 25 | REP ch k 26 | -------------------------------------------------------------------------------- /common/file_data_util.hpp: -------------------------------------------------------------------------------- 1 | #ifndef aspeller_file_data_util__hh 2 | #define aspeller_file_data_util__hh 3 | 4 | #include "parm_string.hpp" 5 | 6 | namespace acommon {class Config;} 7 | 8 | namespace acommon { 9 | 10 | void fill_data_dir(const Config *, String & dir1, String & dir2); 11 | const String & find_file(String & path, 12 | const String & dir1, const String & dir2, 13 | const String & name, const char * extension); 14 | bool find_file(String & file, 15 | const String & dir1, const String & dir2, 16 | const String & name, 17 | ParmString preext, ParmString ext); 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /test/sanity: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | export PATH="`pwd`"/inst/bin:$PATH 7 | 8 | echo 'swimmer' | aspell -d en_US -a > tmp/res 9 | if cat tmp/res | fgrep '*'; then 10 | echo "pass" 11 | else 12 | echo "fail:" 13 | cat tmp/res 14 | exit 1 15 | fi 16 | 17 | echo 'swimer' | aspell -d en_US -a > tmp/res 18 | if cat tmp/res | fgrep '& swimer' | fgrep 'swimmer'; then 19 | echo "pass" 20 | else 21 | echo "fail:" 22 | cat tmp/res 23 | exit 1 24 | fi 25 | 26 | aspell -d en_US dump master | aspell -d en_US list > tmp/incorrect 27 | if [ -e tmp/incorrect -a ! -s tmp/incorrect ]; then 28 | echo "pass" 29 | else 30 | echo "fail:" 31 | cat tmp/incorrect 32 | exit 1 33 | fi 34 | 35 | -------------------------------------------------------------------------------- /common/string_pair.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_STRING_PAIR__HPP 8 | #define ASPELL_STRING_PAIR__HPP 9 | 10 | namespace acommon { 11 | 12 | struct StringPair { 13 | const char * first; 14 | const char * second; 15 | StringPair(const char * f, const char * s) 16 | : first(f), second(s) {} 17 | StringPair() : first(""), second("") {} 18 | }; 19 | 20 | } 21 | 22 | #endif /* ASPELL_STRING_PAIR__HPP */ 23 | -------------------------------------------------------------------------------- /test/suggest/refresh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | for f in 00-special 02-orig 05-common 6 | do 7 | for mode in ultra fast normal slow bad-spellers 8 | do 9 | echo "** $f $mode" 10 | time ./run-batch "../inst/bin/aspell --sug-mode=$mode" $f.tab $f-$mode-expect 11 | done 12 | for mode in ultra normal 13 | do 14 | echo "** $f $mode" 15 | time ./run-batch "../inst/bin/aspell --keyboard=none --sug-mode=$mode" $f.tab $f-$mode-nokbd-expect 16 | done 17 | done 18 | for f in 00-special 19 | do 20 | for mode in ultra fast normal slow bad-spellers 21 | do 22 | echo "** $f $mode" 23 | time ./run-batch "../inst/bin/aspell --sug-mode=$mode --camel-case" $f.tab $f-$mode-camel-expect 24 | done 25 | done 26 | -------------------------------------------------------------------------------- /modules/speller/default/editdist2.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include "leditdist.hpp" 3 | #include "editdist.hpp" 4 | 5 | #include 6 | 7 | namespace aspeller { 8 | inline int edit_distance(ParmString a, ParmString b, 9 | int level, // starting level 10 | int limit, // maximum level 11 | const EditDistanceWeights & w 12 | = EditDistanceWeights()) 13 | { 14 | int score; 15 | assert(level > 0 && limit >= level); 16 | do { 17 | if (level == 2) { 18 | score = limit2_edit_distance(a,b,w); 19 | } else if (level < 5) { 20 | score = limit_edit_distance(a,b,level,w); 21 | } else { 22 | score = edit_distance(a,b,w); 23 | } 24 | ++level; 25 | } while (score >= LARGE_NUM && level <= limit); 26 | return score; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/can_have_error.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include "error.hpp" 8 | #include "can_have_error.hpp" 9 | 10 | namespace acommon { 11 | 12 | CanHaveError::CanHaveError(Error * e) 13 | : err_(e) 14 | {} 15 | 16 | CanHaveError::~CanHaveError() 17 | {} 18 | 19 | CanHaveError::CanHaveError(const CanHaveError & other) 20 | : err_(other.err_) {} 21 | 22 | 23 | CanHaveError & CanHaveError::operator=(const CanHaveError & other) 24 | { 25 | err_ = other.err_; 26 | return *this; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /common/iostream.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_IOSTREAM__HPP 8 | #define ASPELL_IOSTREAM__HPP 9 | 10 | #include "fstream.hpp" 11 | 12 | namespace acommon { 13 | 14 | // These streams for the time being will be based on stdin, stdout, 15 | // and stderr respectfully. So it is safe to use the standard C 16 | // functions. It is also safe to assume that modifications to the 17 | // state of the standard streams will effect these. 18 | 19 | extern FStream CIN; 20 | extern FStream COUT; 21 | extern FStream CERR; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /manual/pspell-config.1: -------------------------------------------------------------------------------- 1 | .TH PSPELL\-CONFIG 1 "2004-03-02" "GNU" "Aspell Abbreviated User's Manual" 2 | .SH NAME 3 | pspell\-config \- prints information about a libpspell installation 4 | .SH SYNOPSIS 5 | .B pspell\-config 6 | .I "[options]" 7 | .br 8 | .SH DESCRIPTION 9 | .B pspell\-config 10 | displays information about libpspell installation, mostly for use in 11 | build scripts. Note that this script is provided for backward 12 | compatibility with programs that use pspell. Do not use as it will 13 | eventually go away. 14 | .SH OPTIONS 15 | .TP 16 | .B "\-\-version" 17 | outputs version information about the installed pspell 18 | .TP 19 | .B "\-\-datadir" 20 | displays the data directory 21 | .TP 22 | .B "\-\-pkgdatadir" 23 | displays the aspell package directory 24 | .SH AUTHOR 25 | This manual page was written by Brian Nelson . 26 | -------------------------------------------------------------------------------- /common/tokenizer.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include "tokenizer.hpp" 8 | #include "convert.hpp" 9 | 10 | namespace acommon 11 | { 12 | 13 | Tokenizer::Tokenizer() 14 | : word_begin(0), word_end(0), end(0), 15 | begin_pos(0), end_pos(0), 16 | conv_(0) 17 | {} 18 | 19 | Tokenizer::~Tokenizer() 20 | {} 21 | 22 | void Tokenizer::reset (FilterChar * start, FilterChar * stop) 23 | { 24 | bool can_encode = conv_->encode(start, stop, buf_); 25 | assert(can_encode); 26 | end_pos = 0; 27 | word_end = start; 28 | end = stop; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /gen/mk-filter-pot.pl: -------------------------------------------------------------------------------- 1 | sub prep_str($) 2 | { 3 | local $_ = $_[0]; 4 | s/\\(.)/$1/g; 5 | s/([\"\\])/\\$1/g; 6 | return $_; 7 | } 8 | 9 | open OUT, ">gen/filter.pot"; 10 | 11 | print OUT <<'---'; 12 | #. TRANSLATORS: Like the strings in config.cpp, all strings in *-filter.opt 13 | #. should be under 50 characters, begin with a lower case character and 14 | #. not include any trailing punctuation marks. 15 | --- 16 | 17 | @files = (, ); 18 | 19 | foreach $f (@files) 20 | { 21 | open IN, $f; 22 | while () 23 | { 24 | next unless /^\s*(description|desc)\s+(.+?)\s*$/i; 25 | $_ = prep_str($2); 26 | print OUT "\#: $f:$.\n"; 27 | print OUT "msgid \"$_\"\n"; 28 | print OUT "msgstr \"\"\n"; 29 | print OUT "\n"; 30 | } 31 | close IN; 32 | } 33 | 34 | close OUT; 35 | -------------------------------------------------------------------------------- /common/can_have_error.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_CAN_HAVE_ERROR__HPP 8 | #define ASPELL_CAN_HAVE_ERROR__HPP 9 | 10 | #include "copy_ptr.hpp" 11 | #include "error.hpp" 12 | 13 | namespace acommon { 14 | 15 | struct Error; 16 | 17 | class CanHaveError { 18 | public: 19 | CanHaveError(Error * e = 0); 20 | CopyPtr err_; 21 | virtual ~CanHaveError(); 22 | CanHaveError(const CanHaveError &); 23 | CanHaveError & operator=(const CanHaveError &); 24 | }; 25 | 26 | 27 | } 28 | 29 | #endif /* ASPELL_CAN_HAVE_ERROR__HPP */ 30 | -------------------------------------------------------------------------------- /modules/speller/default/weights.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __aspeller_weights_hh__ 3 | #define __aspeller_weights_hh__ 4 | 5 | namespace aspeller { 6 | 7 | struct EditDistanceWeights { 8 | int del1; // the cost of deleting a char in the first string 9 | int del2; // the cost of inserting a character or deleting a char 10 | // in the second string 11 | int swap; // the cost of swapping two adjacent letters 12 | int sub; // the cost of replacing one letter with another 13 | int similar; // the cost of a "similar" but not exact match for 14 | // two characters 15 | int min; // the min of del1, del2, swap and sub. 16 | int max; // the max of del1, del2, swap and sub. 17 | EditDistanceWeights() 18 | : del1(1), del2(1), swap(1), sub(1), similar(0), min(1), max(1) {} 19 | }; 20 | 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /common/mutable_container.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_MUTABLE_CONTAINER__HPP 8 | #define ASPELL_MUTABLE_CONTAINER__HPP 9 | 10 | #include "parm_string.hpp" 11 | 12 | namespace acommon { 13 | 14 | class AddableContainer { 15 | public: 16 | virtual PosibErr add(ParmStr to_add) = 0; 17 | virtual ~AddableContainer() {} 18 | }; 19 | 20 | 21 | class MutableContainer : public AddableContainer { 22 | public: 23 | virtual PosibErr remove(ParmStr to_rem) = 0; 24 | virtual PosibErr clear() = 0; 25 | }; 26 | 27 | 28 | } 29 | 30 | #endif /* ASPELL_MUTABLE_CONTAINER__HPP */ 31 | -------------------------------------------------------------------------------- /manual/aspell-import.1: -------------------------------------------------------------------------------- 1 | .TH ASPELL-IMPORT 1 "2004-03-03" "GNU" "Aspell Abbreviated User's Manual" 2 | .SH NAME 3 | aspell-import \- import old personal dictionaries into GNU Aspell 4 | .SH SYNOPSIS 5 | .B aspell-import 6 | .br 7 | .SH DESCRIPTION 8 | .B aspell-import 9 | is a command that will search for old personal dictionaries and will 10 | import them into GNU Aspell. It will look for both Ispell and Aspell 11 | dictionaries. To use it just run it from the command prompt. 12 | .SH OPTIONS 13 | This program does not accept any command-line options. 14 | .SH SEE ALSO 15 | .PP 16 | .BR aspell (1), 17 | .BR run\-with\-aspell (1), 18 | .BR word\-list\-compress (1) 19 | .PP 20 | The full documentation for 21 | .BR Aspell 22 | is maintained as a Texinfo manual 23 | The 24 | .RB "`\|" aspell "\|'" 25 | entry in 26 | .B info 27 | for more complete documentation. 28 | .SH AUTHOR 29 | This manual page was written by Brian Nelson . 30 | -------------------------------------------------------------------------------- /lib/new_checker.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL 3 | // license version 2.0 or 2.1. You should have received a copy of the 4 | // LGPL license along with this library if you did not you can find it 5 | // at http://www.gnu.org/. 6 | 7 | #include "speller.hpp" 8 | #include "document_checker.hpp" 9 | #include "stack_ptr.hpp" 10 | #include "convert.hpp" 11 | #include "tokenizer.hpp" 12 | 13 | namespace acommon { 14 | 15 | PosibErr 16 | new_document_checker(Speller * speller) 17 | { 18 | StackPtr checker(new DocumentChecker()); 19 | StackPtr tokenizer(new_tokenizer(speller)); 20 | StackPtr filter(new Filter); 21 | RET_ON_ERR(setup_filter(*filter, speller->config(), true, true, false)); 22 | RET_ON_ERR(checker->setup(tokenizer.release(), speller, filter.release())); 23 | return checker.release(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /common/istream.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_ISTREAM__HPP 8 | #define ASPELL_ISTREAM__HPP 9 | 10 | namespace acommon { 11 | 12 | class String; 13 | 14 | class IStream { 15 | private: 16 | char delem; 17 | public: 18 | IStream(char d = '\n') : delem(d) {} 19 | 20 | char delim() const {return delem;} 21 | 22 | // getline will read until delem 23 | virtual bool append_line(String &, char c) = 0; 24 | bool append_line(String & str) {return append_line(str, delem);} 25 | bool getline(String & str, char c); 26 | bool getline(String & str); 27 | 28 | virtual bool read(void *, unsigned int) = 0; 29 | 30 | virtual ~IStream() {} 31 | }; 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /modules/speller/default/phonetic.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2000 by Kevin Atkinson under the terms of the LGPL 2 | 3 | #ifndef __aspeller_phonetic__ 4 | #define __aspeller_phonetic__ 5 | 6 | #include "string.hpp" 7 | 8 | using namespace acommon; 9 | 10 | namespace acommon {struct Conv;} 11 | 12 | namespace aspeller { 13 | 14 | class Language; 15 | 16 | class Soundslike { 17 | public: 18 | virtual String soundslike_chars() const = 0; 19 | // string must be null terminated even if len is given 20 | virtual char * to_soundslike(char *, const char *, int len = -1) const = 0; 21 | virtual const char * name() const = 0; 22 | virtual const char * version() const = 0; 23 | virtual PosibErr setup(Conv &) = 0; 24 | virtual ~Soundslike() {} 25 | }; 26 | 27 | PosibErr new_soundslike(ParmString name, 28 | Conv & conv, 29 | const Language * lang); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/error.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_ERROR__HPP 8 | #define ASPELL_ERROR__HPP 9 | 10 | namespace acommon { 11 | 12 | struct ErrorInfo; 13 | 14 | struct Error { 15 | const char * mesg; // expected to be allocated with malloc 16 | const ErrorInfo * err; 17 | 18 | Error() : mesg(0), err(0) {} 19 | 20 | Error(const Error &); 21 | Error & operator=(const Error &); 22 | ~Error(); 23 | 24 | bool is_a(const ErrorInfo * e) const; 25 | }; 26 | 27 | struct ErrorInfo { 28 | const ErrorInfo * isa; 29 | const char * mesg; 30 | unsigned int num_parms; 31 | const char * parms[3]; 32 | }; 33 | 34 | 35 | } 36 | 37 | #endif /* ASPELL_ERROR__HPP */ 38 | -------------------------------------------------------------------------------- /modules/speller/default/editdist.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __aspeller_edit_distance_hh__ 2 | #define __aspeller_edit_distance_hh__ 3 | 4 | #include "parm_string.hpp" 5 | #include "weights.hpp" 6 | 7 | namespace aspeller { 8 | 9 | using acommon::ParmString; 10 | 11 | // edit_distance finds the shortest edit distance. The edit distance is 12 | // (cost of swap)(# of swaps) + (cost of deletion)(# of deletions) 13 | // + (cost of insertion)(# of insertions) 14 | // + (cost of substitutions)(# of substitutions) 15 | 16 | // Preconditions: 17 | // max(strlen(a), strlen(b))*max(of the edit weights) <= 2^15 18 | // if violated than an incorrect result may be returned (which may be negative) 19 | // due to overflow of a short integer 20 | // a,b are not null pointers 21 | // Returns: 22 | // the edit distance between a and b 23 | 24 | // the running time is tightly asymptotically bounded by strlen(a)*strlen(b) 25 | 26 | short edit_distance(ParmString a, ParmString b, 27 | const EditDistanceWeights & w = EditDistanceWeights()); 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /common/istream_enumeration.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2019 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_ISTREAM_ENUMERATION__HPP 8 | #define ASPELL_ISTREAM_ENUMERATION__HPP 9 | 10 | #include "fstream.hpp" 11 | #include "string_enumeration.hpp" 12 | 13 | namespace acommon { 14 | 15 | class IstreamEnumeration : public StringEnumeration { 16 | FStream * in; 17 | String data; 18 | public: 19 | IstreamEnumeration(FStream & i) : in(&i) {} 20 | IstreamEnumeration * clone() const { 21 | return new IstreamEnumeration(*this); 22 | } 23 | void assign (const StringEnumeration * other) { 24 | *this = *static_cast(other); 25 | } 26 | Value next() { 27 | if (!in->getline(data)) return 0; 28 | else return data.c_str(); 29 | } 30 | bool at_end() const {return *in;} 31 | }; 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /scripts/ispell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Ispell compatibility script for Aspell 4 | 5 | # Uncomment this (remove the leading '#') to use the Ispell key 6 | # mapping when checking files with the "ispell command". 7 | #CHECK_FLAGS="--keymapping=ispell" 8 | 9 | command="" 10 | 11 | for p 12 | do 13 | case $p in 14 | -a|-A|-l|-c|-e*|-v*|-D) command=$p ;; 15 | -* ) ;; 16 | * ) command=${command:="-"} ;; 17 | esac 18 | done 19 | 20 | case $command in 21 | -A ) echo "Aspell does not support the $command mode.";; 22 | -a|-v* ) exec aspell "$@" ;; 23 | -l ) shift; exec aspell list "$@" ;; 24 | -c ) shift; exec aspell munch "$@" ;; 25 | -e ) shift; exec aspell expand "$@" ;; 26 | -e? ) shift; exec aspell expand `expr "x$command" : '...\(.\)'` "$@" ;; 27 | -D ) shift; exec aspell dump affix "$@" ;; 28 | "-" ) exec aspell check $CHECK_FLAGS "$@" ;; 29 | * ) echo "Ispell compatibility script for Aspell." 30 | echo "Usage: $0 [options] -a|-l|-v[v]|-c|-e[1-4]|" 31 | exit 1 ;; 32 | esac 33 | -------------------------------------------------------------------------------- /modules/filter/texinfo-filter.info: -------------------------------------------------------------------------------- 1 | # TeX filter option file 2 | 3 | #This Filter is usable with the following version(s) of Aspell 4 | ASPELL >=0.60 5 | 6 | #This line will be printed when typing `Aspell help TeX' 7 | DESCRIPTION filter for dealing with Texinfo documents 8 | 9 | STATIC filter 10 | 11 | OPTION ignore 12 | TYPE list 13 | DESCRIPTION Texinfo commands to ignore the parameters of 14 | DEFAULT setfilename 15 | DEFAULT syncodeindex 16 | DEFAULT documentencoding 17 | DEFAULT vskip 18 | DEFAULT code 19 | DEFAULT kbd 20 | DEFAULT key 21 | DEFAULT samp 22 | DEFAULT verb 23 | DEFAULT var 24 | DEFAULT env 25 | DEFAULT file 26 | DEFAULT command 27 | DEFAULT option 28 | DEFAULT url 29 | DEFAULT uref 30 | DEFAULT email 31 | DEFAULT verbatiminclude 32 | DEFAULT xref 33 | DEFAULT ref 34 | DEFAULT pxref 35 | DEFAULT inforef 36 | DEFAULT c 37 | ENDOPTION 38 | 39 | OPTION ignore-env 40 | TYPE list 41 | DESCRIPTION Texinfo environments to ignore 42 | DEFAULT example 43 | DEFAULT smallexample 44 | DEFAULT verbatim 45 | DEFAULT lisp 46 | DEFAULT smalllisp 47 | DEFAULT small 48 | DEFAULT display 49 | DEFAULT snalldisplay 50 | DEFAULT format 51 | DEFAULT smallformat 52 | ENDOPTION 53 | -------------------------------------------------------------------------------- /common/asc_ctype.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASC_CTYPE__HPP 8 | #define ASC_CTYPE__HPP 9 | 10 | namespace acommon { 11 | 12 | static inline bool asc_isspace(int c) 13 | { 14 | return c==' ' || c=='\n' || c=='\r' || c=='\t' || c=='\f' || c=='\v'; 15 | } 16 | 17 | static inline bool asc_isdigit(int c) 18 | { 19 | return '0' <= c && c <= '9'; 20 | } 21 | static inline bool asc_islower(int c) 22 | { 23 | return 'a' <= c && c <= 'z'; 24 | } 25 | static inline bool asc_isupper(int c) 26 | { 27 | return 'A' <= c && c <= 'Z'; 28 | } 29 | static inline bool asc_isalpha(int c) 30 | { 31 | return asc_islower(c) || asc_isupper(c); 32 | } 33 | static inline int asc_tolower(int c) 34 | { 35 | return asc_isupper(c) ? c + 0x20 : c; 36 | } 37 | static inline int asc_toupper(int c) 38 | { 39 | return asc_islower(c) ? c - 0x20 : c; 40 | } 41 | 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /prog/check_funs.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef check_fun__hh 8 | #define check_fun__hh 9 | 10 | #include "checker_string.hpp" 11 | #include "parm_string.hpp" 12 | #include "stack_ptr.hpp" 13 | #include "vector.hpp" 14 | 15 | #define MENU_HEIGHT 9 16 | 17 | using namespace acommon; 18 | 19 | extern StackPtr state; 20 | 21 | extern const char * last_prompt; 22 | struct Choice { 23 | char choice; 24 | const char * desc; 25 | Choice() {} 26 | Choice(char c, ParmString d) : choice(c), desc(d) {} 27 | }; 28 | typedef Vector Choices; 29 | extern StackPtr word_choices; 30 | extern StackPtr menu_choices; 31 | 32 | void get_choice(int & choice); 33 | void get_line(String & line); 34 | void begin_check(); 35 | void display_misspelled_word(); 36 | void display_menu(); 37 | void prompt(const char * prompt); 38 | void error(const char * error); 39 | 40 | #define control(key) (1 + (key-'a')) 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /manual/run-with-aspell.1: -------------------------------------------------------------------------------- 1 | .TH RUN-WITH-ASPELL 1 "2004-03-03" "GNU" "Aspell Abbreviated User's Manual" 2 | .SH NAME 3 | run\-with\-aspell \- script to help use GNU Aspell as an ispell 4 | replacement 5 | .SH SYNOPSIS 6 | .B run\-with\-aspell 7 | .I "" 8 | .br 9 | .SH "DESCRIPTION" 10 | The recommended way to use 11 | .B Aspell 12 | as a replacement for 13 | .B Ispell 14 | is to change the 15 | .B Ispell 16 | command from within the program being used. If that is not possible, 17 | the 18 | .B run-with-aspell 19 | script may be used instead. 20 | .SH OPTIONS 21 | .TP 22 | .B 23 | is the name of the program with any optional arguments. 24 | .PP 25 | The old method of mapping ispell to Aspell is discouraged because it can 26 | create compatibility problems with programs that actually require ispell 27 | such as ispell's own scripts. 28 | .SH SEE ALSO 29 | .PP 30 | .BR aspell (1), 31 | .BR aspell\-import (1), 32 | .BR word\-list\-compress (1) 33 | .PP 34 | Aspell is fully documented in its Texinfo manual. See the 35 | .RB "`\|" aspell "\|'" 36 | entry in 37 | .B info 38 | for more complete documentation. 39 | .SH AUTHOR 40 | This manual page was written by Sudhakar Chandrasekharan 41 | and Brian Nelson . 42 | -------------------------------------------------------------------------------- /common/filter_char_vector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef acommon_filter_char_vector__hh 2 | #define acommon_filter_char_vector__hh 3 | 4 | // This file is part of The New Aspell 5 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL license 6 | // version 2.0 or 2.1. You should have received a copy of the LGPL 7 | // license along with this library if you did not you can find 8 | // it at http://www.gnu.org/. 9 | 10 | #include "vector.hpp" 11 | #include "filter_char.hpp" 12 | 13 | namespace acommon { 14 | 15 | class FilterCharVector : public Vector 16 | { 17 | typedef Vector Base; 18 | public: 19 | void append(const char * str, FilterChar::Width w) { 20 | Base::append(FilterChar(*str, w)); 21 | ++str; 22 | for (;*str; ++str) 23 | Base::append(FilterChar(*str, 1)); 24 | } 25 | void append(FilterChar::Chr c, FilterChar::Width w) { 26 | Base::append(FilterChar(c, w)); 27 | } 28 | void append(FilterChar t) { 29 | Base::append(t); 30 | } 31 | void append(FilterChar::Chr t) { 32 | Base::append(FilterChar(t)); 33 | } 34 | void append(const FilterChar * begin, unsigned int size) { 35 | Base::append(begin, size); 36 | } 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /modules/speller/default/data_util.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __aspeller_data_util_hh__ 2 | #define __aspeller_data_util_hh__ 3 | 4 | #include 5 | 6 | //POSIX headers 7 | #include 8 | 9 | #include "parm_string.hpp" 10 | 11 | using namespace acommon; 12 | 13 | namespace aspeller { 14 | 15 | template 16 | struct CharStrParms { 17 | typedef const char * Value; 18 | typedef Itr Iterator; 19 | Iterator end_; 20 | CharStrParms(Iterator e) : end_(e) {} 21 | bool endf(Iterator i) const {return i == end_;} 22 | Value deref(Iterator i) const {return *i;} 23 | Value end_state() const {return 0;} 24 | }; 25 | 26 | template 27 | struct StrParms { 28 | typedef const char * Value; 29 | typedef Itr Iterator; 30 | Iterator end_; 31 | StrParms(Iterator e) : end_(e) {} 32 | bool endf(Iterator i) const {return i == end_;} 33 | Value deref(Iterator i) const {return i->c_str();} 34 | Value end_state() const {return 0;} 35 | }; 36 | 37 | inline time_t modification_date(ParmString file) { 38 | struct stat file_stat; 39 | if (stat(file, &file_stat) == 0) 40 | return file_stat.st_mtime; 41 | else 42 | return 0; 43 | } 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /auto/mk-doc.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | my @files = qw(mk-src.in MkSrc/Info.pm 4 | MkSrc/Util.pm 5 | MkSrc/Read.pm MkSrc/Create.pm 6 | MkSrc/CcHelper.pm); 7 | 8 | my $final; 9 | 10 | foreach (@files) 11 | { 12 | open IN, $_; 13 | $final .= "\n\n### FILE: $_\n\n"; 14 | while () 15 | { 16 | s/^\#pod\s*/\n\=pod\n\n/; 17 | s/^\#cut\s*/\n\=cut\n\n/; 18 | $final .= $_; 19 | } 20 | close IN; 21 | } 22 | 23 | open OUT, ">mk-src.pod" or die; 24 | print OUT $final; 25 | close OUT; 26 | 27 | use Pod::Checker; 28 | $parser = Pod::Checker->new(); 29 | $parser->parse_from_file('mk-src.pod', \*STDERR); 30 | 31 | use Pod::Text; 32 | $parser = Pod::Text->new(loose=>1); 33 | $parser->parse_from_file('mk-src.pod', 'mk-src.txt'); 34 | 35 | #use Pod::LaTeX; 36 | #$parser = Pod::LaTeX->new(AddPreamble => 0, AddPostamble => 0); 37 | #$parser->parse_from_file('mk-src.pod', '../manual/mk-src.tex.new'); 38 | 39 | #$/ = undef; 40 | #open IN, '../manual/mk-src.tex'; 41 | #$orig = ; 42 | #open IN, '../manual/mk-src.tex.new'; 43 | #$new = ; 44 | #close IN; 45 | #if ($orig eq $new) { 46 | # print "mk-src.tex unchanged\n"; 47 | #} else { 48 | # rename '../manual/mk-src.tex.new', '../manual/mk-src.tex'; 49 | #} 50 | 51 | #unlink "mk-src.pod"; 52 | -------------------------------------------------------------------------------- /modules/speller/default/asuggest.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2000 by Kevin Atkinson under the terms of the LGPL 2 | 3 | #ifndef _asuggest_hh_ 4 | #define _asuggest_hh_ 5 | 6 | #include "suggest.hpp" 7 | #include "editdist.hpp" 8 | #include "typo_editdist.hpp" 9 | #include "cache.hpp" 10 | 11 | namespace aspeller { 12 | class Speller; 13 | class SpellerImpl; 14 | class Suggest; 15 | 16 | struct SuggestParms { 17 | // implementation at the end of suggest.cc 18 | 19 | EditDistanceWeights edit_distance_weights; 20 | CachePtr ti; 21 | 22 | bool try_one_edit_word, try_scan_0, try_scan_1, try_scan_2, try_ngram; 23 | 24 | int ngram_threshold, ngram_keep; 25 | 26 | bool check_after_one_edit_word; 27 | 28 | bool use_typo_analysis; 29 | bool use_repl_table; 30 | 31 | int soundslike_weight; 32 | int word_weight; 33 | 34 | int skip; 35 | int span; 36 | int limit; 37 | 38 | String split_chars; 39 | bool camel_case; 40 | 41 | SuggestParms() {} 42 | 43 | PosibErr init(ParmString mode, SpellerImpl * sp); 44 | PosibErr init(ParmString mode, SpellerImpl * sp, Config *); 45 | }; 46 | 47 | Suggest * new_default_suggest(const Speller *, const SuggestParms &); 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /common/string_enumeration.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_STRING_ENUMERATION__HPP 8 | #define ASPELL_STRING_ENUMERATION__HPP 9 | 10 | #include "parm_string.hpp" 11 | #include "type_id.hpp" 12 | #include "char_vector.hpp" 13 | 14 | namespace acommon { 15 | 16 | class StringEnumeration; 17 | class Convert; 18 | 19 | class StringEnumeration { 20 | public: 21 | typedef const char * Value; 22 | virtual bool at_end() const = 0; 23 | virtual const char * next() = 0; 24 | int ref_count_; 25 | TypeId type_id_; 26 | unsigned int type_id() { return type_id_.num; } 27 | int copyable_; 28 | int copyable() { return copyable_; } 29 | virtual StringEnumeration * clone() const = 0; 30 | virtual void assign(const StringEnumeration * other) = 0; 31 | CharVector temp_str; 32 | Convert * from_internal_; 33 | StringEnumeration() : ref_count_(0), copyable_(2), from_internal_(0) {} 34 | virtual ~StringEnumeration() {} 35 | }; 36 | 37 | } 38 | 39 | #endif /* ASPELL_STRING_ENUMERATION__HPP */ 40 | -------------------------------------------------------------------------------- /examples/list-dicts.c: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "aspell.h" 13 | 14 | int main(int argc, const char *argv[]) 15 | { 16 | AspellConfig * config; 17 | AspellDictInfoList * dlist; 18 | AspellDictInfoEnumeration * dels; 19 | const AspellDictInfo * entry; 20 | 21 | config = new_aspell_config(); 22 | 23 | /* the returned pointer should _not_ need to be deleted */ 24 | dlist = get_aspell_dict_info_list(config); 25 | 26 | /* config is no longer needed */ 27 | delete_aspell_config(config); 28 | 29 | dels = aspell_dict_info_list_elements(dlist); 30 | 31 | printf("%-30s%-8s%-20s%-6s%-10s\n", "NAME", "CODE", "JARGON", "SIZE", "MODULE"); 32 | while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) 33 | { 34 | printf("%-30s%-8s%-20s%-6s%-10s\n", 35 | entry->name, 36 | entry->code, entry->jargon, 37 | entry->size_str, entry->module->name); 38 | } 39 | 40 | delete_aspell_dict_info_enumeration(dels); 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /modules/speller/default/suggest.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2000 by Kevin Atkinson under the terms of the LGPL 2 | 3 | #ifndef ASPELLER_SUGGEST__HPP 4 | #define ASPELLER_SUGGEST__HPP 5 | 6 | #include "word_list.hpp" 7 | #include "enumeration.hpp" 8 | #include "parm_string.hpp" 9 | #include "suggestions.hpp" 10 | 11 | using namespace acommon; 12 | 13 | namespace aspeller { 14 | 15 | class SpellerImpl; 16 | 17 | class SuggestionList : public WordList { 18 | public: 19 | typedef StringEnumeration VirEmul; 20 | typedef Enumeration Emul; 21 | typedef const char * Value; 22 | typedef unsigned int Size; 23 | 24 | //virtual SuggestionList * clone() const = 0; 25 | //virtual void assign(const SuggestionList *) = 0; 26 | 27 | virtual bool empty() const = 0; 28 | virtual Size size() const = 0; 29 | virtual VirEmul * elements() const = 0; 30 | virtual ~SuggestionList() {} 31 | }; 32 | 33 | class Suggest { 34 | public: 35 | virtual PosibErr set_mode(ParmString) = 0; 36 | virtual SuggestionList & suggest(const char * word) = 0; 37 | virtual SuggestionsData & suggestions(const char * word) = 0; 38 | virtual ~Suggest() {} 39 | }; 40 | 41 | PosibErr new_default_suggest(SpellerImpl *); 42 | 43 | } 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /common/clone_ptr-t.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2001 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef autil__clone_ptr_t 14 | #define autil__clone_ptr_t 15 | 16 | #include "clone_ptr.hpp" 17 | #include 18 | #include "generic_copy_ptr-t.hpp" 19 | 20 | namespace acommon { 21 | 22 | template 23 | inline T * ClonePtr::Parms::clone(const T * ptr) const { 24 | return ptr->clone(); 25 | } 26 | 27 | template 28 | void ClonePtr::Parms::assign(T * & rhs, const T * lhs) const { 29 | if (typeid(*rhs) == typeid(*lhs)) { 30 | rhs->assign(lhs); 31 | } else { 32 | T * temp = rhs; 33 | rhs = lhs->clone(); 34 | delete temp; 35 | } 36 | } 37 | 38 | template 39 | inline void ClonePtr::Parms::del(T * ptr) { 40 | delete ptr; 41 | } 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /common/error.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include 8 | #include 9 | 10 | #include "error.hpp" 11 | 12 | namespace acommon { 13 | 14 | bool Error::is_a(ErrorInfo const * to_find) const 15 | { 16 | const ErrorInfo * e = err; 17 | while (e) { 18 | if (e == to_find) return true; 19 | e = e->isa; 20 | } 21 | return false; 22 | } 23 | 24 | Error::Error(const Error & other) 25 | { 26 | if (other.mesg) { 27 | mesg = (char *)malloc(strlen(other.mesg) + 1); 28 | strcpy(const_cast(mesg), other.mesg); 29 | } 30 | err = other.err; 31 | } 32 | 33 | Error & Error::operator=(const Error & other) 34 | { 35 | if (mesg) 36 | free(const_cast(mesg)); 37 | if (other.mesg) { 38 | unsigned int len = strlen(other.mesg) + 1; 39 | mesg = (char *)malloc(len); 40 | memcpy(const_cast(mesg), other.mesg, len); 41 | } 42 | err = other.err; 43 | return *this; 44 | } 45 | 46 | Error::~Error() 47 | { 48 | if (mesg) 49 | free(const_cast(mesg)); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /modules/speller/default/check_list.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2004 by Kevin Atkinson under the GNU LGPL 3 | // license version 2.0 or 2.1. You should have received a copy of the 4 | // LGPL license along with this library if you did not you can find it 5 | // at http://www.gnu.org/. 6 | 7 | #ifndef __aspeller_check_list__ 8 | #define __aspeller_check_list__ 9 | 10 | #include "objstack.hpp" 11 | #include "speller.hpp" 12 | 13 | namespace aspeller { 14 | 15 | using acommon::CheckInfo; 16 | 17 | static inline void clear_check_info(CheckInfo & ci) 18 | { 19 | memset(static_cast(&ci), 0, sizeof(ci)); 20 | } 21 | 22 | struct GuessInfo 23 | { 24 | int num; 25 | CheckInfo * head; 26 | GuessInfo() : num(0), head(0) {} 27 | void reset() { buf.reset(); num = 0; head = 0; } 28 | CheckInfo * add() { 29 | num++; 30 | CheckInfo * tmp = (CheckInfo *)buf.alloc_top(sizeof(CheckInfo), 31 | sizeof(void*)); 32 | clear_check_info(*tmp); 33 | tmp->next = head; 34 | head = tmp; 35 | head->guess = true; 36 | return head; 37 | } 38 | void * alloc(unsigned s) {return buf.alloc_bottom(s);} 39 | char * dup(ParmString str) {return buf.dup(str);} 40 | private: 41 | ObjStack buf; 42 | }; 43 | 44 | 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /test/warning-settings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __GNUC__ 4 | static const int GCC = __GNUC__, GCC_MINOR = __GNUC_MINOR__; 5 | #else 6 | static const int GCC = 0, GCC_MINOR = 0; 7 | #endif 8 | 9 | #ifdef __clang__ 10 | #define has_gcc_warning(str) __has_warning(str) 11 | #else 12 | #define __has_warning(str) false 13 | #define has_gcc_warning(str) true 14 | #endif 15 | 16 | #define disable_clang_warning(str) if (__has_warning("-W" str)) printf("-Wno-%s ", str) 17 | #define disable_gcc_warning(str) if (has_gcc_warning("-W" str)) printf("-Wno-%s ", str) 18 | #define disable_gcc_error(str) if (has_gcc_warning("-W" str)) printf("-Wno-error=%s ", str) 19 | 20 | int main() { 21 | if (!GCC) return 0; 22 | fprintf(stderr, "gcc version = %d.%d\n", GCC, GCC_MINOR); 23 | printf("EXTRA_CXXFLAGS = -Wall -Wno-sign-compare -Wno-unused -Werror "); 24 | printf("-Wno-error=unused-result "); // FIXME: Remove this once the cause of the warning is fixed 25 | if ((GCC == 4 && GCC_MINOR >= 7) || GCC >= 5) 26 | disable_gcc_error("maybe-uninitialized"); 27 | if (GCC >= 6) 28 | disable_gcc_warning("misleading-indentation"); 29 | if (GCC == 7) // FIXME: I _think_ this is a false positive but need 30 | // to double check 31 | printf("-Walloc-size-larger-than=-1 "); 32 | disable_clang_warning("return-type-c-linkage"); 33 | disable_clang_warning("tautological-compare"); 34 | printf("\n"); 35 | } 36 | -------------------------------------------------------------------------------- /common/vararray.hpp: -------------------------------------------------------------------------------- 1 | 2 | // This file is part of The New Aspell 3 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 4 | // version 2.0 or 2.1. You should have received a copy of the LGPL 5 | // license along with this library if you did not you can find 6 | // it at http://www.gnu.org/. 7 | 8 | #ifndef ASPELL_VARARRAY__HPP 9 | #define ASPELL_VARARRAY__HPP 10 | 11 | #ifndef __GNUC__ 12 | # include 13 | #endif 14 | 15 | namespace acommon { 16 | 17 | // only use this on types with a trivial constructors destructor 18 | 19 | #ifdef __GNUC__ // use variable arrays 20 | 21 | #define VARARRAY(type, name, num) type name[num] 22 | #define VARARRAYM(type, name, num, max) type name[num] 23 | 24 | #else // use malloc 25 | 26 | struct MallocPtr { 27 | void * ptr; 28 | MallocPtr() : ptr(0) {}; 29 | ~MallocPtr() {if (ptr) free(ptr);} 30 | }; 31 | 32 | #define VARARRAY(type, name, num) \ 33 | acommon::MallocPtr name##_data; \ 34 | name##_data.ptr = malloc(sizeof(type) * (num)); \ 35 | type * name = (type *)name##_data.ptr 36 | 37 | #define VARARRAYM(type, name, num, max) type name[max] 38 | 39 | #endif 40 | 41 | #if 0 // this version uses alloca 42 | 43 | #define VARARRAY(type, name, num) \ 44 | type * name = (type *)alloca(sizeof(type) * (num)) 45 | 46 | #define VARARRAYM(type, name, num, max) \ 47 | type * name = (type *)alloca(sizeof(type) * (num)) 48 | 49 | #endif 50 | 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /test/suggest/00-special-ultra-expect.res: -------------------------------------------------------------------------------- 1 | colour color 1 21 color, cooler, collar, co lour, co-lour, col our, col-our, Collier, collier, Clair, clear, calorie, colliery, glory, caller, Claire, Clara, Clare, jollier, jowlier, galore 2 | hjk hijack 1 4 hijack, hajj, hajji, Hickok 3 | hjkk hijack 1 4 hijack, hajj, Hickok, hajji 4 | jk hijack 10 56 JFK, J, K, j, k, Gk, jg, Jake, joke, hijack, KC, kc, kg, Jo, ck, wk, AK, Bk, JD, JP, JV, Jr, Mk, OK, SK, UK, bk, jr, pk, Jack, Jock, jack, jock, jag, jig, jog, jug, kike, QC, cg, Jacky, Keck, jokey, kick, kook, keg, Coke, J's, cake, coke, Cook, cock, cook, gawk, geek, gook 5 | Hjk Hijack 1 4 Hijack, Hajj, Hajji, Hickok 6 | HJK HIJACK 1 4 HIJACK, HAJJ, HAJJI, HICKOK 7 | hk hijack 1 64 hijack, Gk, H, K, h, k, HQ, Hg, haj, hake, hike, hoke, HI, Ha, He, Ho, ck, ha, he, hi, ho, wk, AK, Bk, HF, HM, HP, HR, HS, HT, Hf, Hz, Mk, OK, SK, UK, bk, hf, hp, hr, ht, pk, Huck, hack, hawk, heck, hick, hock, hook, hag, hog, hug, Hakka, Hooke, haiku, hokey, hooky, hgwy, Hayek, hoick, H's, Hugo, h'm, huge 8 | sjk hijack 4 6 SJ, SK, SJW, hijack, sqq, scag 9 | zphb xenophobia 1 1 xenophobia 10 | zkw zip line 1 21 zip line, kW, kw, Zeke, SJW, Zika, skew, SK, ska, ski, sky, SJ, Sq, sq, xx, sake, skua, SC, Sc, Saki, scow 11 | Joeuser JoeUser -1 -1 12 | JoeuSer JoeUser -1 -1 13 | JooUser JoeUser -1 -1 14 | camelCasWord camelCaseWord -1 -1 15 | camelcaseWord camelCaseWord -1 -1 16 | cmlCaseWord camelCaseWord -1 -1 17 | mcdonalds McDonald's 1 3 McDonald's, McDonald, MacDonald's 18 | -------------------------------------------------------------------------------- /test/suggest/00-special-ultra-nokbd-expect.res: -------------------------------------------------------------------------------- 1 | colour color 1 21 color, cooler, collar, co lour, co-lour, col our, col-our, Collier, collier, Clair, clear, caller, Clara, Clare, glory, colliery, calorie, Claire, galore, jollier, jowlier 2 | hjk hijack 1 4 hijack, hajj, hajji, Hickok 3 | hjkk hijack 1 4 hijack, Hickok, hajj, hajji 4 | jk hijack 10 56 JFK, J, K, j, k, Gk, jg, Jake, joke, hijack, KC, kc, kg, Jo, ck, wk, AK, Bk, JD, JP, JV, Jr, Mk, OK, SK, UK, bk, jr, pk, Jack, Jock, jack, jock, jag, jig, jog, jug, QC, cg, Jacky, jokey, keg, Coke, J's, cake, coke, kike, Cook, Keck, cock, cook, gawk, geek, gook, kick, kook 5 | Hjk Hijack 1 4 Hijack, Hajj, Hajji, Hickok 6 | HJK HIJACK 1 4 HIJACK, HAJJ, HAJJI, HICKOK 7 | hk hijack 1 64 hijack, H, K, h, k, HQ, Hg, hake, hike, hoke, HI, Ha, He, Ho, ck, ha, he, hi, ho, wk, AK, Bk, Gk, HF, HM, HP, HR, HS, HT, Hf, Hz, Mk, OK, SK, UK, bk, hf, hp, hr, ht, pk, Huck, hack, hawk, heck, hick, hock, hook, hag, haj, hog, hug, Hakka, Hooke, haiku, hokey, hooky, Hayek, hoick, H's, Hugo, h'm, hgwy, huge 8 | sjk hijack 4 6 SJ, SK, SJW, hijack, sqq, scag 9 | zphb xenophobia 1 1 xenophobia 10 | zkw zip line 1 21 zip line, kW, kw, Zeke, Zika, skew, SK, SJW, ska, ski, sky, skua, SC, SJ, Sc, Sq, sq, xx, Saki, sake, scow 11 | Joeuser JoeUser -1 -1 12 | JoeuSer JoeUser -1 -1 13 | JooUser JoeUser -1 -1 14 | camelCasWord camelCaseWord -1 -1 15 | camelcaseWord camelCaseWord -1 -1 16 | cmlCaseWord camelCaseWord -1 -1 17 | mcdonalds McDonald's 1 3 McDonald's, McDonald, MacDonald's 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | 3 | Makefile 4 | *.gmo 5 | *.o 6 | *.lo 7 | .deps 8 | .libs 9 | .dirstamp 10 | *.la 11 | 12 | # make dist generated files 13 | /README 14 | /aspell-*.tar.gz 15 | /aspell-*.tar.gz.sig 16 | /aspell-*.directive 17 | /aspell-*.directive.asc 18 | 19 | /inst/ 20 | /build/ 21 | 22 | /ABOUT-NLS 23 | /Makefile.in 24 | /aclocal.m4 25 | /aspell 26 | /auto/auto 27 | /auto/mk-src.pod 28 | /auto/mk-src.txt 29 | /autom4te.cache/ 30 | /common/errors.cpp 31 | /common/errors.hpp 32 | /common/key_info.hpp 33 | /common/string_pair_enumeration.hpp 34 | /common/type_id.hpp 35 | /common/word_list.hpp 36 | /compile 37 | /config.* 38 | /configure 39 | /depcomp 40 | /examples/Makefile.in 41 | /gen/dirs.h 42 | /gen/filter.pot 43 | /gen/settings.h 44 | /gen/settings.h.in 45 | /gen/stamp-h1 46 | /gen/static_filters.src.cpp 47 | /install-sh 48 | /interfaces/cc/aspell.h 49 | /lib/*-c.cpp 50 | /lib5/Makefile.in 51 | /libtool 52 | /ltmain.sh 53 | /m4 54 | /manual/Makefile.in 55 | /manual/aspell-dev.html/ 56 | /manual/aspell-dev.info 57 | /manual/aspell.html/ 58 | /manual/aspell.info 59 | /manual/texinfo.tex 60 | /missing 61 | /myspell/Makefile.in 62 | /po/Makefile.in 63 | /po/Makefile.in.in 64 | /po/Makevars.template 65 | /po/POTFILES 66 | /po/Rules-quot 67 | /po/boldquot.sed 68 | /po/en@boldquot.header 69 | /po/en@quot.header 70 | /po/insert-header.sin 71 | /po/quot.sed 72 | /po/remove-potcdate.sed 73 | /po/remove-potcdate.sin 74 | /po/stamp-po 75 | /prezip-bin 76 | /scripts/precat 77 | /scripts/preunzip 78 | /scripts/pspell-config 79 | /scripts/run-with-aspell 80 | /word-list-compress 81 | -------------------------------------------------------------------------------- /modules/speller/default/editdist.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "editdist.hpp" 5 | #include "matrix.hpp" 6 | #include "vararray.hpp" 7 | 8 | // edit_distance is implemented using a straight forward dynamic 9 | // programming algorithm with out any special tricks. Its space 10 | // usage AND running time is tightly asymptotically bounded by 11 | // strlen(a)*strlen(b) 12 | 13 | namespace aspeller { 14 | 15 | short edit_distance(ParmString a0, ParmString b0, 16 | const EditDistanceWeights & w) 17 | { 18 | int a_size = a0.size() + 1; 19 | int b_size = b0.size() + 1; 20 | VARARRAY(short, e_d, a_size * b_size); 21 | ShortMatrix e(a_size,b_size,e_d); 22 | e(0, 0) = 0; 23 | for (int j = 1; j != b_size; ++j) 24 | e(0, j) = e(0, j-1) + w.del1; 25 | const char * a = a0.str() - 1; 26 | const char * b = b0.str() - 1; 27 | short te; 28 | for (int i = 1; i != a_size; ++i) { 29 | e(i, 0) = e(i-1, 0) + w.del2; 30 | for (int j = 1; j != b_size; ++j) { 31 | if (a[i] == b[j]) { 32 | 33 | e(i, j) = e(i-1, j-1); 34 | 35 | } else { 36 | 37 | e(i, j) = w.sub + e(i-1, j-1); 38 | 39 | if (i != 1 && j != 1 && 40 | a[i] == b[j-1] && a[i-1] == b[j]) 41 | { 42 | te = w.swap + e(i-2, j-2); 43 | if (te < e(i, j)) e(i, j) = te; 44 | } 45 | 46 | te = w.del1 + e(i-1, j); 47 | if (te < e(i, j)) e(i, j) = te; 48 | te = w.del2 + e(i, j-1); 49 | if (te < e(i, j)) e(i, j) = te; 50 | 51 | } 52 | } 53 | } 54 | return e(a_size-1, b_size-1); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /modules/speller/default/primes.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2000 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #include "primes.hpp" 14 | #include 15 | #include 16 | 17 | namespace aspeller { 18 | 19 | using namespace std; 20 | 21 | void Primes::resize(size_type s) { 22 | size_type i, j = 2; 23 | data.resize(s); 24 | for(i = 0; i < s; ++i) 25 | data[i] = true; 26 | if (s > 0) 27 | data[0] = false; 28 | if (s > 1) 29 | data[1] = false; 30 | size_type sqrt_s = static_cast(sqrt(static_cast(s))); 31 | while (j < sqrt_s) { 32 | for (i = 2*j; i < s; i += j) { 33 | data[i] = false; 34 | } 35 | ++j; 36 | for (;j < sqrt_s && !data[j]; ++j); 37 | } 38 | } 39 | 40 | bool Primes::is_prime(size_type n) const { 41 | if (n < size()) { 42 | return data[n]; 43 | } else { 44 | size_type e = static_cast(sqrt(static_cast(n))); 45 | assert(e < size()); 46 | for (const_iterator i = begin(); *i <= e; ++i) 47 | if (!(n % *i)) return false; 48 | return true; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /auto/MkSrc/Methods.pm: -------------------------------------------------------------------------------- 1 | # This file is part of The New Aspell 2 | # Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | # license version 2.0 or 2.1. You should have received a copy of the 4 | # LGPL license along with this library if you did not you can find it 5 | # at http://www.gnu.org/. 6 | 7 | package MkSrc::Methods; 8 | 9 | BEGIN { 10 | use Exporter; 11 | our @ISA = qw(Exporter); 12 | our @EXPORT = qw(copy_methods); 13 | } 14 | 15 | use strict; 16 | use warnings; 17 | no warnings qw(uninitialized); 18 | no locale; 19 | 20 | use MkSrc::Info; 21 | 22 | sub copy_n_sub ( $ $ ); 23 | sub copy_methods ( $ $ $ ) { 24 | my ($d, $data, $class_name) = @_; 25 | my $ms = $methods{$d->{type}}; 26 | if (not defined $d->{name}) { 27 | $d->{name} = $class_name; 28 | $d->{name} =~ s/ [^ ]+$// if $ms->{strip} == 1; 29 | } 30 | my @lst; 31 | if (defined $ms->{'c impl headers'}) { 32 | $data->{'c impl headers'} .= ",$ms->{'c impl headers'}"; 33 | } 34 | foreach my $m (@{$ms->{data}}) { 35 | push @lst, copy_n_sub($m, $d->{name}); 36 | $lst[-1]{prefix} = $m->{prefix} if exists $d->{prefix}; 37 | } 38 | return @lst 39 | } 40 | 41 | sub copy_n_sub ( $ $ ) { 42 | my ($d, $name) = @_; 43 | my $new_d = {}; 44 | foreach my $k (keys %$d) { 45 | if ($k eq 'data') { 46 | $new_d->{data} = []; 47 | foreach my $d0 (@{$d->{data}}) { 48 | push @{$new_d->{data}}, copy_n_sub($d0, $name); 49 | } 50 | } else { 51 | $new_d->{$k} = $d->{$k}; 52 | $new_d->{$k} =~ s/\$/$name/g unless ref $new_d->{$k}; 53 | } 54 | } 55 | return $new_d; 56 | } 57 | 58 | 1; 59 | -------------------------------------------------------------------------------- /test/suggest/run-batch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use autodie; 6 | no warnings 'uninitialized'; 7 | 8 | use IPC::Open2; 9 | use IO::Handle; 10 | use POSIX qw(clock CLOCKS_PER_SEC); 11 | 12 | my $in = new IO::Handle; 13 | my $out = new IO::Handle; 14 | my $data = new IO::Handle; 15 | 16 | die "Usage: $0 \n" unless @ARGV == 3; 17 | 18 | my $command = $ARGV[0]; 19 | my $base = $ARGV[2]; 20 | 21 | open $data, $ARGV[1]; 22 | 23 | open R, ">$base.res"; 24 | 25 | my $pid = open2($in, $out, "$command -d en_US-w_repl --dont-use-other-dicts --per-conf=/dev/null -a"); 26 | print $out "!\n"; 27 | <$in>; 28 | 29 | while (<$data>) { 30 | chop; 31 | my ($mis, $cor) = split /\t/; 32 | die ":$mis: :$cor:" if $mis !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/; 33 | die ":$mis: :$cor:" if $cor !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/; 34 | print $out "$cor\n"; 35 | my $res = <$in>; 36 | chop $res; 37 | if ($res) { 38 | print R "$mis\t$cor\t-1\t-1\n"; 39 | $res = <$in>; 40 | } else { 41 | print $out "$mis\n"; 42 | $res = <$in>; 43 | chop $res; 44 | if (!$res) { 45 | print R "$mis\t$cor\t-1\t-1\n"; 46 | } else { 47 | my ($info, $list) = split /: /, $res; 48 | my ($key, undef, $num, undef) = split / /, $info; 49 | my @list = split /, /, $list; 50 | my $i; 51 | for ($i = 0; $list[$i] && $list[$i] ne $cor; $i++) {} 52 | if ($list[$i]) {$i++} 53 | else {$i = 0;} 54 | print R "$mis\t$cor\t$i\t$num\t$list\n"; 55 | $res = <$in>; 56 | } 57 | } 58 | } 59 | 60 | close $out; 61 | close R; 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /common/clone_ptr.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2001 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef autil__clone_ptr 14 | #define autil__clone_ptr 15 | 16 | #include "generic_copy_ptr.hpp" 17 | 18 | namespace acommon { 19 | 20 | template 21 | class ClonePtr 22 | { 23 | struct Parms { 24 | T * clone(const T * ptr) const; 25 | void assign(T * & rhs, const T * lhs) const; 26 | void del(T * ptr); 27 | }; 28 | GenericCopyPtr impl; 29 | 30 | public: 31 | 32 | explicit ClonePtr(T * p = 0) : impl(p) {} 33 | ClonePtr(const ClonePtr & other) : impl(other.impl) {} 34 | 35 | ClonePtr & operator=(const ClonePtr & other) { 36 | impl = other.impl; 37 | return *this; 38 | } 39 | 40 | void assign(const T * other) {impl.assign(other);} 41 | void reset(T * other = 0) {impl.reset(other);} 42 | 43 | T & operator* () const {return *impl;} 44 | T * operator-> () const {return impl;} 45 | T * get() const {return impl;} 46 | operator T * () const {return impl;} 47 | 48 | T * release() {return impl.release();} 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /common/filter_char.hpp: -------------------------------------------------------------------------------- 1 | #ifndef acommon_filter_char_hh 2 | #define acommon_filter_char_hh 3 | 4 | // This file is part of The New Aspell 5 | // Copyright (C) 2002 by Kevin Atkinson under the GNU LGPL license 6 | // version 2.0 or 2.1. You should have received a copy of the LGPL 7 | // license along with this library if you did not you can find 8 | // it at http://www.gnu.org/. 9 | 10 | namespace acommon { 11 | 12 | struct FilterChar { 13 | unsigned int chr; 14 | unsigned int width; // width must always be < 256 15 | typedef unsigned int Chr; 16 | typedef unsigned int Width; 17 | explicit FilterChar(Chr c = 0, Width w = 1) 18 | : chr(c), width(w) {} 19 | FilterChar(Chr c, FilterChar o) 20 | : chr(c), width(o.width) {} 21 | static Width sum(const FilterChar * o, const FilterChar * stop) { 22 | Width total = 0; 23 | for (; o != stop; ++o) 24 | total += o->width; 25 | return total; 26 | } 27 | static Width sum(const FilterChar * o, unsigned int size) { 28 | return sum(o, o+size); 29 | } 30 | FilterChar(Chr c, const FilterChar * o, unsigned int size) 31 | : chr(c), width(sum(o,size)) {} 32 | FilterChar(Chr c, const FilterChar * o, const FilterChar * stop) 33 | : chr(c), width(sum(o,stop)) {} 34 | operator Chr () const {return chr;} 35 | FilterChar & operator= (Chr c) {chr = c; return *this;} 36 | }; 37 | 38 | static inline bool operator==(FilterChar lhs, FilterChar rhs) 39 | { 40 | return lhs.chr == rhs.chr; 41 | } 42 | 43 | static inline bool operator!=(FilterChar lhs, FilterChar rhs) 44 | { 45 | return lhs.chr != rhs.chr; 46 | } 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /common/stack_ptr.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef stack_ptr 8 | #define stack_ptr 9 | 10 | #include 11 | 12 | namespace acommon { 13 | 14 | template 15 | class StackPtr { 16 | T * ptr; 17 | 18 | // to avoid operator* being used unexpectedly. for example 19 | // without this the following will compile 20 | // PosibErr fun(); 21 | // PosibErr > pe = fun(); 22 | // and operator* and StackPtr(T *) will be used. The explicit 23 | // doesn't protect us here due to PosibErr 24 | StackPtr(const StackPtr & other); 25 | // because I am paranoid 26 | StackPtr & operator=(const StackPtr & other); 27 | 28 | public: 29 | 30 | explicit StackPtr(T * p = 0) : ptr(p) {} 31 | 32 | StackPtr(StackPtr & other) : ptr (other.release()) {} 33 | 34 | ~StackPtr() {del();} 35 | 36 | StackPtr & operator=(StackPtr & other) 37 | {reset(other.release()); return *this;} 38 | 39 | T & operator* () const {return *ptr;} 40 | T * operator-> () const {return ptr;} 41 | T * get() const {return ptr;} 42 | operator T * () const {return ptr;} 43 | 44 | T * release () {T * p = ptr; ptr = 0; return p;} 45 | 46 | void del() {delete ptr; ptr = 0;} 47 | void reset(T * p) {assert(ptr==0); ptr = p;} 48 | StackPtr & operator=(T * p) {reset(p); return *this;} 49 | 50 | }; 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /common/block_slist-t.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef autil__block_slist_t_hh 8 | #define autil__block_slist_t_hh 9 | 10 | #include 11 | #include 12 | 13 | #include "block_slist.hpp" 14 | 15 | namespace acommon { 16 | 17 | template 18 | void BlockSList::add_block(unsigned int num) 19 | { 20 | assert (reinterpret_cast(&(first_available->next)) 21 | == 22 | reinterpret_cast(first_available)); 23 | const unsigned int ptr_offset = 24 | reinterpret_cast(&(first_available->data)) 25 | - reinterpret_cast(&(first_available->next)); 26 | void * block = malloc( ptr_offset + sizeof(Node) * num ); 27 | *reinterpret_cast(block) = first_block; 28 | first_block = block; 29 | Node * first = reinterpret_cast(reinterpret_cast(block) + ptr_offset); 30 | Node * i = first; 31 | Node * last = i + num; 32 | while (i + 1 != last) { 33 | i->next = i + 1; 34 | i = i + 1; 35 | } 36 | i->next = 0; 37 | first_available = first; 38 | } 39 | 40 | template 41 | void BlockSList::clear() 42 | { 43 | void * i = first_block; 44 | while (i != 0) { 45 | void * n = *reinterpret_cast(i); 46 | free(i); 47 | i = n; 48 | } 49 | first_block = 0; 50 | first_available = 0; 51 | } 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /common/copy_ptr.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2001 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef autil__copy_ptr 14 | #define autil__copy_ptr 15 | 16 | #include "generic_copy_ptr-t.hpp" 17 | 18 | namespace acommon { 19 | 20 | template 21 | class CopyPtr 22 | { 23 | struct Parms { 24 | T * clone(const T * ptr) const 25 | { return new T(*ptr);} 26 | void assign(T * & rhs, const T * lhs) const 27 | { *rhs = *lhs; } 28 | void del(T * ptr) 29 | { delete ptr; } 30 | 31 | }; 32 | GenericCopyPtr impl; 33 | 34 | public: 35 | 36 | explicit CopyPtr(T * p = 0) : impl(p) {} 37 | CopyPtr(const CopyPtr & other) : impl(other.impl) {} 38 | 39 | CopyPtr & operator=(const CopyPtr & other) { 40 | impl = other.impl; 41 | return *this; 42 | } 43 | 44 | void assign(const T * other) {impl.assign(other);} 45 | void reset(T * other = 0) {impl.reset(other);} 46 | 47 | T & operator* () const {return *impl;} 48 | T * operator-> () const {return impl;} 49 | T * get() const {return impl;} 50 | operator T * () const {return impl;} 51 | 52 | T * release() {return impl.release();} 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /modules/speller/default/wordinfo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2000 by Kevin Atkinson under the terms of the LGPL 2 | 3 | #ifndef __aspeller_wordinfo__ 4 | #define __aspeller_wordinfo__ 5 | 6 | #include 7 | #include "string.hpp" 8 | 9 | namespace acommon { 10 | class OStream; 11 | class Convert; 12 | } 13 | 14 | namespace aspeller { 15 | 16 | // WordInfo 17 | 18 | typedef unsigned int WordInfo; // 4 bits 19 | 20 | enum CasePattern {Other, FirstUpper, AllLower, AllUpper}; 21 | // Other 00 22 | // FirstUpper 01 23 | // AllLower 10 24 | // AllUpper 11 25 | // First bit : is upper 26 | // Second bit: uniform case 27 | 28 | static const WordInfo CASE_PATTERN = 3; 29 | static const WordInfo ALL_PLAIN = (1 << 2); 30 | static const WordInfo ALL_CLEAN = (1 << 3); 31 | 32 | using namespace acommon; 33 | 34 | class Language; 35 | struct ConvertWord; 36 | 37 | // WordEntry is an entry in the dictionary. 38 | struct WordEntry 39 | { 40 | const char * word; 41 | const char * aff; 42 | const char * catg; 43 | void (* adv_)(WordEntry *); 44 | void * intr[3]; 45 | unsigned word_size; 46 | enum What {Other, Word, Soundslike, Clean, Misspelled} what; 47 | WordInfo word_info; 48 | int frequency; // 0 .. 255 49 | // if type is Word than aff will be defined, otherwise it won't 50 | bool at_end() {return !word;} 51 | bool adv() {if (adv_) {adv_(this); return true;} word = 0; return false;} 52 | operator bool () const {return word != 0;} 53 | OStream & write(OStream & o, const Language & l, Convert * c = 0) const; 54 | WordEntry() {memset(this, 0, sizeof(WordEntry));} 55 | void clear() {memset(this, 0, sizeof(WordEntry));} 56 | ~WordEntry() {} 57 | }; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /auto/mk-src.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # mk-src.pl -- Perl program to automatically generate interface code. 5 | # 6 | # This file is part of The New Aspell 7 | # Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 8 | # license version 2.0 or 2.1. You should have received a copy of the 9 | # LGPL license along with this library if you did not you can find it 10 | # at http://www.gnu.org/. 11 | 12 | ###################################################################### 13 | # 14 | # Prologue 15 | # 16 | 17 | use strict; 18 | use warnings; 19 | no warnings qw(uninitialized); 20 | no locale; 21 | 22 | use Data::Dumper; 23 | 24 | use MkSrc::Info; 25 | use MkSrc::Read; 26 | use MkSrc::Util; 27 | use MkSrc::Type; 28 | use MkSrc::Create; 29 | 30 | 31 | ###################################################################### 32 | # 33 | # Main 34 | # 35 | 36 | my $master_data = read; 37 | 38 | # Pure C 39 | use MkSrc::ProcCc; 40 | create_cc_file (type => 'cc', 41 | dir => 'interfaces/cc', 42 | name => 'aspell', 43 | header => true, 44 | data => $master_data); 45 | 46 | # C++ over C 47 | # Currently incomplete and broken 48 | #use MkSrc::ProcCxx; 49 | #create_cc_file (type => 'cxx', 50 | # cxx => true, 51 | # namespace => 'aspell', 52 | # dir => 'interfaces/cxx', 53 | # name => 'aspell-cxx', 54 | # header => true, 55 | # data => $master_data); 56 | 57 | # Native 58 | use MkSrc::ProcNative; 59 | foreach my $d (@{$master_data->{data}}) { 60 | $info{group}{proc}{native}->($d); 61 | } 62 | 63 | # C for C++ 64 | use MkSrc::ProcImpl; 65 | foreach my $d (@{$master_data->{data}}) { 66 | $info{group}{proc}{impl}->($d); 67 | } 68 | 69 | # Impl 70 | use MkSrc::ProcNativeImpl; 71 | foreach my $d (@{$master_data->{data}}) { 72 | $info{group}{proc}{native_impl}->($d); 73 | } 74 | -------------------------------------------------------------------------------- /common/ostream.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_OSTREAM__HPP 8 | #define ASPELL_OSTREAM__HPP 9 | 10 | #include 11 | 12 | #include "parm_string.hpp" 13 | 14 | namespace acommon { 15 | 16 | // FIXME: Add Print Method compatible with printf and friends. 17 | // Than avoid code bloat by using it in many places instead of 18 | // out << "Bla " << something << " djdkdk " << something else << "\n" 19 | 20 | class OStream { 21 | public: 22 | virtual void write (char c) = 0; 23 | virtual void write (ParmStr) = 0; 24 | virtual void write (const void *, unsigned int) = 0; 25 | 26 | virtual int vprintf(const char *format, va_list ap) = 0; 27 | 28 | #ifdef __GNUC__ 29 | __attribute__ ((format (printf,2,3))) 30 | #endif 31 | int printf(const char * format, ...) 32 | { 33 | va_list ap; 34 | va_start(ap, format); 35 | int res = vprintf(format, ap); 36 | va_end(ap); 37 | return res; 38 | } 39 | 40 | void put (char c) {write(c);} 41 | void put (ParmStr str) {write(str);} 42 | 43 | virtual void printl(ParmStr l) 44 | { 45 | write(l); 46 | write('\n'); 47 | } 48 | 49 | void write16(unsigned short v) {write(&v, 2);} 50 | void write32(unsigned int v) {write(&v, 4);} 51 | 52 | OStream & operator << (char c) { 53 | write(c); 54 | return *this; 55 | } 56 | 57 | OStream & operator << (ParmStr in) { 58 | write(in); 59 | return *this; 60 | } 61 | 62 | virtual ~OStream() {} 63 | }; 64 | 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the Git repository for GNU Aspell 2 | 3 | http://aspell.net 4 | 5 | The following packages need to be installed to build this package 6 | from Git: 7 | * perl (I use v5.6.0 but other versions may work) 8 | * libtool 9 | * gettext 10 | * autoconf 11 | * automake 12 | * makeinfo 13 | 14 | Before the build: 15 | ``` 16 | ./autogen 17 | 18 | ./configure --disable-static 19 | # or ./config-opt or ./config-debug 20 | ``` 21 | 22 | The `./config-*` will set things up for easier development. If you want 23 | to install Aspell to use it rather than develop with it than use the 24 | normal `configure`. When `config-*` is used the default things will be 25 | installed in `/inst` for easier testing and debugging. You 26 | can change that by using the `--prefix` option. 27 | 28 | Autogen should be run when ever anything but the source files or 29 | Makefile.am files are modified. 30 | 31 | Than to build and install: 32 | ``` 33 | make 34 | make install 35 | ``` 36 | 37 | You will then need to install a dictionary package for the new Aspell. 38 | You can find them at http://aspell.net. If Aspell is installed 39 | somewhere other than `/usr/local` you will probably need to add 40 | `/bin` to your PATH or make symbolic links to the executable in 41 | order for the dictionary to build correctly. 42 | 43 | To run the debugger on these programs if there are not installed use 44 | ``` 45 | libtool gdb 46 | ``` 47 | or 48 | ``` 49 | libtool --mode execute 50 | ``` 51 | For example to debug aspell with ddd use 52 | ``` 53 | libtool --mode execute ddd prog/.libs/aspell 54 | ``` 55 | 56 | Using libtool is necessary to make sure the shared libraries get loaded 57 | right. If you debug them after they are installed this will not be 58 | necessary. 59 | -------------------------------------------------------------------------------- /test/suggest/mkmk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use autodie; 6 | 7 | my $targets = ''; 8 | foreach my $f (qw (00-special 02-orig 05-common)) { 9 | my @modes = qw(ultra fast normal slow bad-spellers); 10 | foreach my $mode (@modes) { 11 | print <<"---"; 12 | suggest-$f-${mode}: prep 13 | suggest/run-batch "\${ASPELL_WRAP} \${ASPELL} --sug-mode=$mode" suggest/$f.tab tmp/$f-$mode-actual 14 | suggest/comp suggest/$f-$mode-expect.res tmp/$f-$mode-actual.res 1 > tmp/$f-$mode.diff 15 | rm tmp/$f-$mode.diff 16 | echo "ok (suggest reg. $f $mode)" >> test-res 17 | --- 18 | last if $f eq '05-common' && $mode eq 'bad-spellers'; 19 | $targets .= " suggest-$f-${mode}"; 20 | } 21 | foreach my $mode (qw(ultra normal)) { 22 | print <<"---"; 23 | suggest-$f-${mode}-nokbd: prep 24 | suggest/run-batch "\${ASPELL_WRAP} \${ASPELL} --keyboard=none --sug-mode=$mode" suggest/$f.tab tmp/$f-$mode-nokbd-actual 25 | suggest/comp suggest/$f-$mode-nokbd-expect.res tmp/$f-$mode-nokbd-actual.res 1 > tmp/$f-$mode-nokbd.diff 26 | rm tmp/$f-$mode-nokbd.diff 27 | echo "ok (suggest reg. $f $mode nokbd)" >> test-res 28 | --- 29 | $targets .= " suggest-$f-${mode}-nokbd"; 30 | } 31 | } 32 | my $f = '00-special'; 33 | foreach my $mode (qw(ultra fast normal slow bad-spellers)) { 34 | print <<"---"; 35 | suggest-$f-${mode}-camel: prep 36 | suggest/run-batch "\${ASPELL_WRAP} \${ASPELL} --camel-case --sug-mode=$mode" suggest/$f.tab tmp/$f-$mode-camel-actual 37 | suggest/comp suggest/$f-$mode-camel-expect.res tmp/$f-$mode-camel-actual.res 1 > tmp/$f-$mode-camel.diff 38 | rm tmp/$f-$mode-camel.diff 39 | echo "ok (suggest reg. $f $mode camel)" >> test-res 40 | --- 41 | $targets .= " suggest-$f-${mode}-camel"; 42 | } 43 | 44 | print ".PHONY: $targets\n"; 45 | print "suggest: $targets\n"; 46 | 47 | 48 | -------------------------------------------------------------------------------- /common/generic_copy_ptr-t.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2001 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef autil__generic_copy_ptr_t 14 | #define autil__generic_copy_ptr_t 15 | 16 | #include "generic_copy_ptr.hpp" 17 | 18 | namespace acommon { 19 | 20 | template 21 | GenericCopyPtr::GenericCopyPtr(const GenericCopyPtr & other) 22 | { 23 | if (other.ptr_ != 0) 24 | ptr_ = parms_.clone(other.ptr_); 25 | else 26 | ptr_ = 0; 27 | parms_ = other.parms_; 28 | } 29 | 30 | template 31 | void GenericCopyPtr::assign(const T * other_ptr, 32 | const Parms & other_parms) 33 | { 34 | if (other_ptr == 0) { 35 | if (ptr_ != 0) parms_.del(ptr_); 36 | ptr_ = 0; 37 | } else if (ptr_ == 0) { 38 | ptr_ = parms_.clone(other_ptr); 39 | } else { 40 | parms_.assign(ptr_, other_ptr); 41 | } 42 | parms_ = other_parms; 43 | } 44 | 45 | template 46 | void GenericCopyPtr::reset (T * other, const Parms & other_parms) 47 | { 48 | if (ptr_ != 0) 49 | parms_.del(ptr_); 50 | ptr_ = other; 51 | parms_ = other_parms; 52 | } 53 | 54 | template 55 | GenericCopyPtr::~GenericCopyPtr() 56 | { 57 | if (ptr_ != 0) 58 | parms_.del(ptr_); 59 | } 60 | 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /modules/tokenizer/basic.cpp: -------------------------------------------------------------------------------- 1 | 2 | // This file is part of The New Aspell 3 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 4 | // version 2.0 or 2.1. You should have received a copy of the LGPL 5 | // license along with this library if you did not you can find 6 | // it at http://www.gnu.org/. 7 | 8 | #include "tokenizer.hpp" 9 | #include "convert.hpp" 10 | #include "speller.hpp" 11 | 12 | 13 | namespace acommon { 14 | 15 | class TokenizerBasic : public Tokenizer 16 | { 17 | public: 18 | bool advance(); 19 | }; 20 | 21 | bool TokenizerBasic::advance() { 22 | word_begin = word_end; 23 | begin_pos = end_pos; 24 | FilterChar * cur = word_begin; 25 | unsigned int cur_pos = begin_pos; 26 | word.clear(); 27 | 28 | // skip spaces (non-word characters) 29 | while (*cur != 0 && 30 | !(is_word(*cur) 31 | || (is_begin(*cur) && is_word(cur[1])))) 32 | { 33 | cur_pos += cur->width; 34 | ++cur; 35 | } 36 | 37 | if (*cur == 0) return false; 38 | 39 | word_begin = cur; 40 | begin_pos = cur_pos; 41 | 42 | if (is_begin(*cur) && is_word(cur[1])) 43 | { 44 | cur_pos += cur->width; 45 | ++cur; 46 | } 47 | 48 | while (is_word(*cur) || 49 | (is_middle(*cur) && 50 | cur > word_begin && is_word(cur[-1]) && 51 | is_word(cur[1]) )) 52 | { 53 | word.append(*cur); 54 | cur_pos += cur->width; 55 | ++cur; 56 | } 57 | 58 | if (is_end(*cur)) 59 | { 60 | word.append(*cur); 61 | cur_pos += cur->width; 62 | ++cur; 63 | } 64 | 65 | word.append('\0'); 66 | word_end = cur; 67 | end_pos = cur_pos; 68 | 69 | return true; 70 | } 71 | #undef increment__ 72 | 73 | PosibErr new_tokenizer(Speller * speller) 74 | { 75 | Tokenizer * tok = new TokenizerBasic(); 76 | speller->setup_tokenizer(tok); 77 | return tok; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /common/lock.hpp: -------------------------------------------------------------------------------- 1 | // File: lock.hpp 2 | // 3 | // Copyright (c) 2002,2003,2011 4 | // Kevin Atkinson 5 | // 6 | // Permission to use, copy, modify, distribute and sell this software 7 | // and its documentation for any purpose is hereby granted without 8 | // fee, provided that the above copyright notice appear in all copies 9 | // and that both that copyright notice and this permission notice 10 | // appear in supporting documentation. Kevin Atkinson makes no 11 | // representations about the suitability of this software for any 12 | // purpose. It is provided "as is" without express or implied 13 | // warranty. 14 | 15 | #ifndef DISTRIBNET_LOCK__HPP 16 | #define DISTRIBNET_LOCK__HPP 17 | 18 | #include 19 | 20 | #include "settings.h" 21 | 22 | #ifdef USE_POSIX_MUTEX 23 | # include 24 | #endif 25 | 26 | namespace acommon { 27 | 28 | #define LOCK(l) const Lock the_lock(l); 29 | 30 | #ifdef USE_POSIX_MUTEX 31 | class Mutex { 32 | pthread_mutex_t l_; 33 | private: 34 | Mutex(const Mutex &); 35 | void operator=(const Mutex &); 36 | public: 37 | Mutex() {pthread_mutex_init(&l_, 0);} 38 | ~Mutex() {pthread_mutex_destroy(&l_);} 39 | void lock() {pthread_mutex_lock(&l_);} 40 | void unlock() {pthread_mutex_unlock(&l_);} 41 | }; 42 | #else 43 | class Mutex { 44 | private: 45 | Mutex(const Mutex &); 46 | void operator=(const Mutex &); 47 | public: 48 | Mutex() {} 49 | ~Mutex() {} 50 | void lock() {} 51 | void unlock() {} 52 | }; 53 | #endif 54 | 55 | class Lock { 56 | private: 57 | Lock(const Lock &); 58 | void operator= (const Lock &); 59 | Mutex * lock_; 60 | public: 61 | Lock(Mutex * l) : lock_(l) {if (lock_) lock_->lock();} 62 | void set(Mutex * l) {assert(!lock_); lock_ = l; if (lock_) lock_->lock();} 63 | void release() {if (lock_) lock_->unlock(); lock_ = NULL;} 64 | ~Lock() {if (lock_) lock_->unlock();} 65 | }; 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /common/vector.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001-2003 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_VECTOR__HPP 8 | #define ASPELL_VECTOR__HPP 9 | 10 | #include 11 | 12 | namespace acommon 13 | { 14 | template 15 | class Vector : public std::vector 16 | { 17 | public: 18 | 19 | Vector() {} 20 | Vector(unsigned int s) : std::vector(s) {} 21 | Vector(unsigned int s, const T & val) : std::vector(s, val) {} 22 | 23 | void append(T t) { 24 | this->push_back(t); 25 | } 26 | void append(const T * begin, unsigned int size) { 27 | this->insert(this->end(), begin, begin+size); 28 | } 29 | void append(const T * begin, const T * end) { 30 | this->insert(this->end(), begin, end); 31 | } 32 | int alloc(int s) { 33 | int pos = this->size(); 34 | this->resize(pos + s); 35 | return pos; 36 | } 37 | T * data() {return &*this->begin();} 38 | T * data(int pos) {return &*this->begin() + pos;} 39 | T * data_end() {return &*this->begin() + this->size();} 40 | 41 | T * pbegin() {return &*this->begin();} 42 | T * pend() {return &*this->begin() + this->size();} 43 | 44 | const T * pbegin() const {return &*this->begin();} 45 | const T * pend() const {return &*this->begin() + this->size();} 46 | 47 | template 48 | U * datap() { 49 | return reinterpret_cast(&this->front()); 50 | } 51 | template 52 | U * datap(int pos) { 53 | return reinterpret_cast(&this->front() + pos); 54 | } 55 | 56 | void pop_front() {this->erase(this->begin());} 57 | void push_front(const T & v) {this->insert(this->begin(), v);} 58 | }; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /common/document_checker.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_DOCUMENT_CHECKER__HPP 8 | #define ASPELL_DOCUMENT_CHECKER__HPP 9 | 10 | #include "filter.hpp" 11 | #include "char_vector.hpp" 12 | #include "copy_ptr.hpp" 13 | #include "can_have_error.hpp" 14 | #include "filter_char.hpp" 15 | #include "filter_char_vector.hpp" 16 | 17 | namespace acommon { 18 | 19 | class Config; 20 | class Speller; 21 | class Tokenizer; 22 | class Convert; 23 | 24 | struct Token { 25 | unsigned int offset; 26 | unsigned int len; 27 | operator bool () const {return len != 0;} 28 | }; 29 | 30 | 31 | class DocumentChecker : public CanHaveError { 32 | public: 33 | // will take ownership of tokenizer and filter (even if there is an error) 34 | // config only used for this method. 35 | // speller expected to stick around. 36 | PosibErr setup(Tokenizer *, Speller *, Filter *); 37 | void reset(); 38 | void process(const char * str, int size); 39 | void process_wide(const void * str, int size, int type_width); 40 | Token next_misspelling(); 41 | 42 | Filter * filter() {return filter_;} 43 | 44 | void set_status_fun(void (*)(void *, Token, int), void *); 45 | 46 | DocumentChecker(); 47 | ~DocumentChecker(); 48 | 49 | private: 50 | CopyPtr filter_; 51 | CopyPtr tokenizer_; 52 | void (* status_fun_)(void *, Token, int); 53 | void * status_fun_data_; 54 | Speller * speller_; 55 | Convert * conv_; 56 | FilterCharVector proc_str_; 57 | }; 58 | 59 | PosibErr new_document_checker(Speller *); 60 | 61 | } 62 | 63 | #endif /* ASPELL_DOCUMENT_CHECKER__HPP */ 64 | -------------------------------------------------------------------------------- /modules/filter/markdown-filter.info: -------------------------------------------------------------------------------- 1 | # SGML filter option file 2 | 3 | LIB-FILE markdown-filter 4 | 5 | #This Filter is usable with the following version(s) of Aspell 6 | ASPELL >=0.60 7 | 8 | DESCRIPTION filter for Markdown/CommonMark documents 9 | 10 | STATIC filter 11 | 12 | OPTION skip-ref-labels 13 | TYPE bool 14 | DESCRIPTION skip link labels in link reference definitions 15 | DEFAULT true 16 | ENDOPTION 17 | 18 | OPTION multiline-tags 19 | TYPE bool 20 | DESCRIPTION support tags that span multiple lines outside of HTML blocks 21 | DEFAULT true 22 | ENDOPTION 23 | 24 | OPTION raw-start-tags 25 | TYPE list 26 | DESCRIPTION HTML tags that start an HTML block that allows blank lines 27 | DEFAULT script 28 | DEFAULT pre 29 | DEFAULT style 30 | ENDOPTION 31 | 32 | OPTION block-start-tags 33 | TYPE list 34 | DESCRIPTION HTML tags that start an HTML block that ends with a blank line 35 | DEFAULT address 36 | DEFAULT article 37 | DEFAULT aside 38 | DEFAULT base 39 | DEFAULT basefont 40 | DEFAULT blockquote 41 | DEFAULT body 42 | DEFAULT caption 43 | DEFAULT center 44 | DEFAULT col 45 | DEFAULT colgroup 46 | DEFAULT dd 47 | DEFAULT details 48 | DEFAULT dialog 49 | DEFAULT dir 50 | DEFAULT div 51 | DEFAULT dl 52 | DEFAULT dt 53 | DEFAULT fieldset 54 | DEFAULT figcaption 55 | DEFAULT figure 56 | DEFAULT footer 57 | DEFAULT form 58 | DEFAULT frame 59 | DEFAULT frameset 60 | DEFAULT h1 61 | DEFAULT h2 62 | DEFAULT h3 63 | DEFAULT h4 64 | DEFAULT h5 65 | DEFAULT h6 66 | DEFAULT head 67 | DEFAULT header 68 | DEFAULT hr 69 | DEFAULT html 70 | DEFAULT iframe 71 | DEFAULT legend 72 | DEFAULT li 73 | DEFAULT link 74 | DEFAULT main 75 | DEFAULT menu 76 | DEFAULT menuitem 77 | DEFAULT nav 78 | DEFAULT noframes 79 | DEFAULT ol 80 | DEFAULT optgroup 81 | DEFAULT option 82 | DEFAULT p 83 | DEFAULT param 84 | DEFAULT section 85 | DEFAULT source 86 | DEFAULT summary 87 | DEFAULT table 88 | DEFAULT tbody 89 | DEFAULT td 90 | DEFAULT tfoot 91 | DEFAULT th 92 | DEFAULT thead 93 | DEFAULT title 94 | DEFAULT tr 95 | DEFAULT track 96 | DEFAULT ul 97 | ENDOPTION 98 | -------------------------------------------------------------------------------- /common/objstack.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "objstack.hpp" 3 | 4 | namespace acommon { 5 | 6 | void ObjStack::setup_chunk() 7 | { 8 | bottom = first_free->data; 9 | align_bottom(min_align); 10 | top = (byte *)first_free + chunk_size; 11 | align_top(min_align); 12 | } 13 | 14 | 15 | ObjStack::ObjStack(size_t chunk_s, size_t align) 16 | : chunk_size(chunk_s), min_align(align), temp_end(0) 17 | { 18 | first_free = first = (Node *)malloc(chunk_size); 19 | first->next = 0; 20 | reserve = 0; 21 | setup_chunk(); 22 | } 23 | 24 | ObjStack::~ObjStack() 25 | { 26 | while (first) { 27 | Node * tmp = first->next; 28 | free(first); 29 | first = tmp; 30 | } 31 | trim(); 32 | } 33 | 34 | size_t ObjStack::calc_size() 35 | { 36 | size_t size = 0; 37 | for (Node * p = first; p; p = p->next) 38 | size += chunk_size; 39 | return size; 40 | } 41 | 42 | void ObjStack::new_chunk() 43 | { 44 | if (reserve) { 45 | first_free->next = reserve; 46 | reserve = reserve->next; 47 | first_free = first_free->next; 48 | first_free->next = 0; 49 | } else { 50 | first_free->next = (Node *)malloc(chunk_size); 51 | first_free = first_free->next; 52 | } 53 | first_free->next = 0; 54 | setup_chunk(); 55 | } 56 | 57 | void ObjStack::reset() 58 | { 59 | assert(first_free->next == 0); 60 | if (first->next) { 61 | first_free->next = reserve; 62 | reserve = first->next; 63 | first->next = 0; 64 | } 65 | first_free = first; 66 | setup_chunk(); 67 | } 68 | 69 | void ObjStack::trim() 70 | { 71 | while (reserve) { 72 | Node * tmp = reserve->next; 73 | free(reserve); 74 | reserve = tmp; 75 | } 76 | } 77 | 78 | ObjStack::Memory * ObjStack::freeze() { 79 | trim(); 80 | Node * tmp = first; 81 | first = 0; 82 | first_free = 0; 83 | top = 0; 84 | bottom = 0; 85 | temp_end = 0; 86 | return tmp; 87 | } 88 | 89 | void ObjStack::dealloc(Memory * ptr) { 90 | while (ptr) { 91 | Node * tmp = ptr->next; 92 | free(ptr); 93 | ptr = tmp; 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /modules/speller/default/block_vector.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2000 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef __autil_block_vector__ 14 | #define __autil_block_vector__ 15 | 16 | #include 17 | //#include 18 | 19 | namespace aspeller { 20 | 21 | template 22 | class BlockVector { 23 | T * begin_; 24 | T * end_; 25 | public: 26 | typedef T value_type; 27 | typedef size_t size_type; 28 | typedef ptrdiff_t difference_type; 29 | typedef T * iterator; 30 | typedef T * const_iterator; 31 | typedef T & reference; 32 | typedef const T & const_reference; 33 | typedef T * pointer; 34 | typedef T * const_pointer; 35 | //typedef std::random_access_iterator_tag iterator_category; 36 | typedef ptrdiff_t distance_type; 37 | 38 | BlockVector() : begin_(0), end_(0) {} 39 | BlockVector(size_type) : begin_(0), end_(0) {} // noop 40 | BlockVector(T * b, T * e) : begin_(b), end_(e) {} 41 | void set(T * b, T * e) {begin_ = b; end_ = e;} 42 | iterator begin() {return begin_;} 43 | iterator end() {return end_;} 44 | const_iterator begin() const {return begin_;} 45 | const_iterator end() const {return end_;} 46 | size_type size() const {return end_ - begin_;} 47 | bool empty() const {return begin_ != end_;} 48 | reference operator[](size_type i) {return *(begin_ + i);} 49 | const_reference operator[](size_type i) const {return *(begin_ + i);} 50 | }; 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /common/simple_string.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_SIMPLE_STRING__HPP 8 | #define ASPELL_SIMPLE_STRING__HPP 9 | 10 | #include 11 | 12 | #include "parm_string.hpp" 13 | 14 | namespace acommon { 15 | 16 | struct SimpleString { 17 | const char * str; 18 | unsigned int size; 19 | 20 | SimpleString() : str(0), size(0) {} 21 | SimpleString(const char * str0) : str(str0), size(strlen(str)) {} 22 | SimpleString(const char * str0, unsigned int sz) : str(str0), size(sz) {} 23 | SimpleString(ParmString str0) : str(str0), size(str0.size()) {} 24 | 25 | bool empty() const {return size == 0;} 26 | operator const char * () const {return str;} 27 | operator ParmString () const {return ParmString(str, size);} 28 | const char * begin() const {return str;} 29 | const char * end() const {return str + size;} 30 | }; 31 | 32 | static inline bool operator==(SimpleString s1, SimpleString s2) 33 | { 34 | if (s1.size != s2.size) 35 | return false; 36 | else 37 | return memcmp(s1,s2,s1.size) == 0; 38 | } 39 | static inline bool operator==(const char * s1, SimpleString s2) 40 | { 41 | return strcmp(s1,s2) == 0; 42 | } 43 | static inline bool operator==(SimpleString s1, const char * s2) 44 | { 45 | return strcmp(s1,s2) == 0; 46 | } 47 | 48 | static inline bool operator!=(SimpleString s1, SimpleString s2) 49 | { 50 | if (s1.size != s2.size) 51 | return true; 52 | else 53 | return memcmp(s1,s2,s1.size) != 0; 54 | } 55 | static inline bool operator!=(const char * s1, SimpleString s2) 56 | { 57 | return strcmp(s1,s2) != 0; 58 | } 59 | static inline bool operator!=(SimpleString s1, const char * s2) 60 | { 61 | return strcmp(s1,s2) != 0; 62 | } 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /modules/filter/url.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include "settings.h" 8 | #include "indiv_filter.hpp" 9 | #include "key_info.hpp" 10 | 11 | namespace { 12 | using namespace acommon; 13 | 14 | class UrlFilter : public IndividualFilter { 15 | public: 16 | PosibErr setup(Config *); 17 | void reset() {} 18 | void process(FilterChar * &, FilterChar * &); 19 | }; 20 | 21 | PosibErr UrlFilter::setup(Config *) 22 | { 23 | name_ = "url-filter"; 24 | order_num_ = 0.95; 25 | return true; 26 | } 27 | 28 | static bool url_char(char c) 29 | { 30 | return c != '"' && c != ' ' && c != '\n' && c != '\t'; 31 | } 32 | 33 | void UrlFilter::process(FilterChar * & str, FilterChar * & end) 34 | { 35 | for (FilterChar * cur = str; cur < end; ++cur) 36 | { 37 | if (!url_char(*cur)) continue; 38 | FilterChar * cur0 = cur; 39 | bool blank_out = false; 40 | int point_chars = 0; 41 | // only consider special url deciding characters if they are in 42 | // the middle of a word 43 | for (++cur; cur + 1 < end && url_char(cur[1]); ++cur) { 44 | if (blank_out) continue; 45 | if ((cur[0] == '/' && (point_chars > 0 || cur[1] == '/')) 46 | || cur[0] == '@') { 47 | blank_out = true; 48 | } else if (cur[0] == '.' && cur[1] != '.') { 49 | // count multiple '.' as one 50 | if (point_chars < 1) ++point_chars; 51 | else blank_out = true; 52 | } 53 | } 54 | ++cur; 55 | if (blank_out) { 56 | for (; cur0 != cur; ++cur0) *cur0 = ' '; 57 | } 58 | } 59 | } 60 | } 61 | 62 | C_EXPORT 63 | IndividualFilter * new_aspell_url_filter() { 64 | return new UrlFilter; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /common/generic_copy_ptr.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2001 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef autil__generic_copy_ptr 14 | #define autil__generic_copy_ptr 15 | 16 | namespace acommon { 17 | 18 | // Parms is expected to have the following members 19 | // T * Parms::clone(const T *); 20 | // void Parms::assign(T * &, const T *); 21 | // void Parms::del(T *); 22 | // All members can assume that all pointers are not null 23 | 24 | template 25 | class GenericCopyPtr { 26 | 27 | T * ptr_; 28 | Parms parms_; 29 | 30 | public: 31 | 32 | explicit GenericCopyPtr(T * p = 0, const Parms & parms = Parms()) 33 | : ptr_(p), parms_(parms) {} 34 | 35 | GenericCopyPtr(const GenericCopyPtr & other); 36 | GenericCopyPtr & operator= (const GenericCopyPtr & other) { 37 | assign(other.ptr_, parms_); 38 | return *this; 39 | } 40 | 41 | // assign makes a copy of other 42 | void assign(const T * other, const Parms & parms = Parms()); 43 | 44 | // reset takes ownership of other 45 | void reset(T * other = 0, const Parms & parms = Parms()); 46 | 47 | T & operator* () const {return *ptr_;} 48 | T * operator-> () const {return ptr_;} 49 | T * get() const {return ptr_;} 50 | operator T * () const {return ptr_;} 51 | 52 | T * release() {T * tmp = ptr_; ptr_ = 0; return tmp;} 53 | 54 | const Parms & parms() {return parms_;} 55 | const Parms & parms() const {return parms_;} 56 | 57 | ~GenericCopyPtr(); 58 | }; 59 | 60 | } 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /common/file_util.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_FILE_UTIL__HPP 8 | #define ASPELL_FILE_UTIL__HPP 9 | 10 | #include 11 | 12 | #include "string.hpp" 13 | #include "posib_err.hpp" 14 | 15 | namespace acommon { 16 | 17 | class FStream; 18 | class Config; 19 | class StringList; 20 | 21 | bool need_dir(ParmString file); 22 | String add_possible_dir(ParmString dir, ParmString file); 23 | String figure_out_dir(ParmString dir, ParmString file); 24 | 25 | // FIXME: Possible remove 26 | //void open_file(FStream & in, const string & file, 27 | // ParmString mode = "r"); 28 | time_t get_modification_time(FStream & f); 29 | PosibErr open_file_readlock(FStream& in, ParmString file); 30 | PosibErr open_file_writelock(FStream & in, ParmString file); 31 | // returns true if the file already exists 32 | void truncate_file(FStream & f, ParmString name); 33 | bool remove_file(ParmString name); 34 | bool file_exists(ParmString name); 35 | bool rename_file(ParmString orig, ParmString new_name); 36 | // will return NULL if path is NULL. 37 | const char * get_file_name(const char * path); 38 | 39 | // expands filename to the full path 40 | // returns the length of the directory part or 0 if nothing found 41 | unsigned find_file(const Config *, const char * option, String & filename); 42 | unsigned find_file(const StringList &, String & filename); 43 | 44 | class StringEnumeration; 45 | 46 | class PathBrowser 47 | { 48 | String suffix; 49 | String path; 50 | StringEnumeration * els; 51 | void * dir_handle; 52 | const char * dir; 53 | PathBrowser(const PathBrowser &); 54 | void operator= (const PathBrowser &); 55 | public: 56 | PathBrowser(const StringList &, const char * suf = ""); 57 | ~PathBrowser(); 58 | const char * next(); 59 | }; 60 | 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /common/hash_fun.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2001 2 | // Kevin Atkinson 3 | // 4 | // Permission to use, copy, modify, distribute and sell this software 5 | // and its documentation for any purpose is hereby granted without 6 | // fee, provided that the above copyright notice appear in all copies 7 | // and that both that copyright notice and this permission notice 8 | // appear in supporting documentation. Kevin Atkinson makes no 9 | // representations about the suitability of this software for any 10 | // purpose. It is provided "as is" without express or implied 11 | // warranty. 12 | 13 | #ifndef acommon_hash_fun__hpp 14 | #define acommon_hash_fun__hpp 15 | 16 | namespace acommon { 17 | 18 | template struct hash {}; 19 | 20 | template <> struct hash {unsigned long operator()(char v) const {return v;}}; 21 | template <> struct hash {unsigned long operator()(short v) const {return v;}}; 22 | template <> struct hash {unsigned long operator()(int v) const {return v;}}; 23 | template <> struct hash {unsigned long operator()(long v) const {return v;}}; 24 | template <> struct hash {unsigned long operator()(unsigned char v) const {return v;}}; 25 | template <> struct hash {unsigned long operator()(unsigned short v) const {return v;}}; 26 | template <> struct hash {unsigned long operator()(unsigned int v) const {return v;}}; 27 | template <> struct hash {unsigned long operator()(unsigned long v) const {return v;}}; 28 | 29 | template <> struct hash { 30 | inline unsigned long operator() (const char * s) const { 31 | unsigned long h = 0; 32 | for (; *s; ++s) 33 | h=5*h + *s; 34 | return h; 35 | } 36 | }; 37 | 38 | template 39 | struct HashString { 40 | inline unsigned long operator() (const Str &str) const { 41 | unsigned long h = 0; 42 | typename Str::const_iterator end = str.end(); 43 | for (typename Str::const_iterator s = str.begin(); 44 | s != end; 45 | ++s) 46 | h=5*h + *s; 47 | return h; 48 | } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /test/filter-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use autodie qw(:all); 6 | 7 | my $parms; 8 | my @tests; 9 | 10 | if (@ARGV != 1) { 11 | die("usage $0 \n"); 12 | } 13 | 14 | my $ASPELL=$ARGV[0]; 15 | 16 | sub sys($) { 17 | #print "@_\n"; 18 | system "@_"; 19 | } 20 | 21 | my $passed = 0; 22 | my $failed = 0; 23 | my $skipped = 0; 24 | 25 | while () { 26 | next if /^\s+$/; 27 | #print ">>$_"; 28 | if (/^-/) { 29 | chomp; 30 | $parms = $_; 31 | next; 32 | } 33 | chomp; 34 | my $desc = $_; 35 | my $in = ''; 36 | my $out = ''; 37 | $_ = ; 38 | my $skip = 0; 39 | if (/^\! (.+)/) { 40 | die "Unknown directive: $1" unless $1 eq 'SKIP'; 41 | $skip = 1; 42 | $_ = ; 43 | } 44 | if (/^-/) { 45 | my $sep = $_; 46 | while () { 47 | #print ">$sep>$_"; 48 | last if $_ eq $sep; 49 | $in .= $_; 50 | } 51 | while () { 52 | last if $_ eq $sep; 53 | $out .= $_; 54 | } 55 | } else { 56 | $in = $_; 57 | $out = ; 58 | } 59 | #print "$parms\n"; 60 | #print ">>>IN>>>\n"; 61 | #print $in; 62 | #print ">>>OUT>>>\n"; 63 | #print $out; 64 | #print "^^^^^^^^^\n"; 65 | 66 | if ($skip) { 67 | $skipped++; 68 | next; 69 | } 70 | 71 | open F, ">tmp/test-data.in"; 72 | print F $in; 73 | open F, ">tmp/test-data.expect"; 74 | print F $out; 75 | eval { 76 | sys "$ASPELL filter --mode=none $parms < tmp/test-data.in > tmp/test-data.out"; 77 | sys "diff -u -Z tmp/test-data.expect tmp/test-data.out"; 78 | }; 79 | if ($@) { 80 | $failed++; 81 | print STDERR "FAILED: $desc: $@\n"; 82 | } else { 83 | $passed++; 84 | #print STDERR "passed: $desc\n"; 85 | } 86 | } 87 | 88 | if ($failed > 0) { 89 | printf("FAILED %d/%d tests (%d skipped)\n", $failed, $failed + $passed, $skipped); 90 | exit 1; 91 | } else { 92 | printf("all ok (%d skipped)\n", $skipped); 93 | exit 0; 94 | } 95 | -------------------------------------------------------------------------------- /common/tokenizer.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ACOMMON_TOKENIZER__HPP 8 | #define ACOMMON_TOKENIZER__HPP 9 | 10 | #include "char_vector.hpp" 11 | #include "filter_char.hpp" 12 | #include "filter_char_vector.hpp" 13 | 14 | namespace acommon { 15 | 16 | class Convert; 17 | class Speller; 18 | class Config; 19 | 20 | class Tokenizer { 21 | 22 | public: 23 | Tokenizer(); 24 | virtual ~Tokenizer(); 25 | 26 | FilterChar * word_begin; 27 | FilterChar * word_end; 28 | FilterChar * end; 29 | 30 | CharVector word; // this word is in the final encoded form 31 | unsigned int begin_pos; // pointers back to the original word 32 | unsigned int end_pos; 33 | 34 | // The string passed in _must_ have a null character 35 | // at stop - 1. (ie stop must be one past the end) 36 | void reset (FilterChar * in, FilterChar * stop); 37 | bool at_end() const {return word_begin == word_end;} 38 | 39 | virtual bool advance() = 0; // returns false if there is nothing left 40 | 41 | bool is_begin(unsigned char c) const 42 | {return char_type_[c].begin;} 43 | bool is_middle(unsigned char c) const 44 | {return char_type_[c].middle;} 45 | bool is_end(unsigned char c) const 46 | {return char_type_[c].end;} 47 | bool is_word(unsigned char c) const 48 | {return char_type_[c].word;} 49 | 50 | public: // but don't use 51 | // The speller class is expected to fill these members in 52 | struct CharType { 53 | bool begin; 54 | bool middle; 55 | bool end; 56 | bool word; 57 | CharType() : begin(false), middle(false), end(false), word(false) {} 58 | }; 59 | 60 | CharType char_type_[256]; 61 | Convert * conv_; 62 | FilterCharVector buf_; 63 | }; 64 | 65 | // returns a new tokenizer and sets it up with the given speller 66 | // class 67 | 68 | PosibErr new_tokenizer(Speller *); 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /common/filter.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_FILTER__HPP 8 | #define ASPELL_FILTER__HPP 9 | 10 | #include "can_have_error.hpp" 11 | #include "copy_ptr.hpp" 12 | #include "filter_char.hpp" 13 | #include "posib_err.hpp" 14 | #include "vector.hpp" 15 | #include "string_pair_enumeration.hpp" 16 | 17 | #include 18 | 19 | namespace acommon { 20 | 21 | class Config; 22 | class Speller; 23 | class IndividualFilter; 24 | class StringList; 25 | struct ConfigModule; 26 | 27 | class Filter : public CanHaveError { 28 | public: 29 | 30 | bool empty() const {return filters_.empty();} 31 | void clear(); 32 | void reset(); 33 | void process(FilterChar * & start, FilterChar * & stop); 34 | void add_filter(IndividualFilter * filter); 35 | // setup the filter where the string list is the list of 36 | // filters to use. 37 | Filter(); 38 | ~Filter(); 39 | 40 | private: 41 | typedef Vector Filters; 42 | Filters filters_; 43 | }; 44 | 45 | PosibErr set_mode_from_extension(Config * config, 46 | ParmString filename, 47 | FILE * in = NULL); 48 | 49 | PosibErr setup_filter(Filter &, Config *, 50 | bool use_decoder, 51 | bool use_filter, 52 | bool use_encoder); 53 | void activate_dynamic_filteroptions(Config *c); 54 | void activate_filter_modes(Config * config); 55 | 56 | void load_all_filters(Config * config); 57 | 58 | PosibErr verify_version(const char * relOp, 59 | const char * actual, const char * required); 60 | PosibErr check_version(const char * requirement); 61 | 62 | PosibErr available_filters(Config *); 63 | PosibErr available_filter_modes(Config *); 64 | 65 | }; 66 | 67 | #endif /* ASPELL_FILTER__HPP */ 68 | -------------------------------------------------------------------------------- /common/mutable_string.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_MUTABLE_STRING__HPP 8 | #define ASPELL_MUTABLE_STRING__HPP 9 | 10 | #include 11 | 12 | #include "parm_string.hpp" 13 | 14 | namespace acommon { 15 | 16 | struct MutableString { 17 | char * str; 18 | unsigned int size; 19 | 20 | MutableString() : str(0), size(0) {} 21 | MutableString(char * str0) : str(str0), size(strlen(str)) {} 22 | MutableString(char * str0, unsigned int sz) : str(str0), size(sz) {} 23 | 24 | bool empty() const {return size == 0;} 25 | operator char * () const {return str;} 26 | operator ParmString () const {return ParmString(str, size);} 27 | char * begin() const {return str;} 28 | char * end() const {return str + size;} 29 | }; 30 | 31 | static inline bool operator==(MutableString s1, MutableString s2) 32 | { 33 | if (s1.size != s2.size) 34 | return false; 35 | else 36 | return memcmp(s1,s2,s1.size) == 0; 37 | } 38 | static inline bool operator==(const char * s1, MutableString s2) 39 | { 40 | if ( s1 == NULL ) { 41 | return s2.size == 0; 42 | } 43 | return strcmp(s1,s2) == 0; 44 | } 45 | static inline bool operator==(MutableString s1, const char * s2) 46 | { 47 | if ( s2 == NULL ) { 48 | return s1.size == 0; 49 | } 50 | return strcmp(s1,s2) == 0; 51 | } 52 | 53 | static inline bool operator!=(MutableString s1, MutableString s2) 54 | { 55 | if (s1.size != s2.size) 56 | return true; 57 | else 58 | return memcmp(s1,s2,s1.size) != 0; 59 | } 60 | static inline bool operator!=(const char * s1, MutableString s2) 61 | { 62 | if ( s1 == NULL ) { 63 | return s2.size != 0; 64 | } 65 | return strcmp(s1,s2) != 0; 66 | } 67 | static inline bool operator!=(MutableString s1, const char * s2) 68 | { 69 | if ( s2 == NULL ) { 70 | return s1.size != 0; 71 | } 72 | return strcmp(s1,s2) != 0; 73 | } 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /common/suggestions.hpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #ifndef ASPELL_SUGGESTIONS__HPP 8 | #define ASPELL_SUGGESTIONS__HPP 9 | 10 | #include "vector.hpp" 11 | #include "char_vector.hpp" 12 | #include "convert.hpp" 13 | 14 | namespace acommon { 15 | 16 | class SuggestionsData { 17 | public: 18 | virtual void get_words(Convert *, Vector &) = 0; 19 | virtual void get_normalized_scores(Vector &) = 0; 20 | virtual void get_distances(Vector &) = 0; 21 | virtual ~SuggestionsData() {} 22 | }; 23 | 24 | class Suggestions { 25 | public: 26 | SuggestionsData * sugs_; 27 | Convert * from_internal_; 28 | Vector words_buffer_; 29 | Vector words_; 30 | Vector normalized_scores_; 31 | Vector distances_; 32 | void reset() { 33 | words_buffer_.clear(); 34 | words_.clear(); 35 | normalized_scores_.clear(); 36 | distances_.clear(); 37 | } 38 | const char * * words(unsigned * len) { 39 | if (words_.empty()) { 40 | sugs_->get_words(from_internal_, words_buffer_); 41 | words_.reserve(words_buffer_.size()); 42 | for (Vector::iterator i = words_buffer_.begin(), e = words_buffer_.end(); i != e; ++i) 43 | words_.push_back(i->data()); 44 | } 45 | if (len) *len = words_.size(); 46 | return words_.data(); 47 | } 48 | double * normalized_scores(unsigned * len) { 49 | if (normalized_scores_.empty()) { 50 | sugs_->get_normalized_scores(normalized_scores_); 51 | } 52 | if (len) *len = normalized_scores_.size(); 53 | return normalized_scores_.data(); 54 | } 55 | double * distances(unsigned * len) { 56 | if (distances_.empty()) { 57 | sugs_->get_distances(distances_); 58 | } 59 | if (len) *len = distances_.size(); 60 | return distances_.data(); 61 | } 62 | }; 63 | 64 | } 65 | 66 | #endif /* ASPELL_SUGGESTIONS__HPP */ 67 | -------------------------------------------------------------------------------- /common/block_slist.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef autil__block_slist_hh 8 | #define autil__block_slist_hh 9 | 10 | // BlockSList provided a pool of nodes which can be used for singly 11 | // linked lists. Nodes are allocated in large chunks instead of 12 | // one at a time which means that getting a new node is very fast. 13 | // Nodes returned are not initialized in any way. A placement new 14 | // must be used to construct the the data member and the destructor 15 | // must explicitly be called. 16 | 17 | namespace acommon { 18 | 19 | template 20 | class BlockSList { 21 | 22 | public: 23 | 24 | struct Node { 25 | Node * next; 26 | T data; 27 | }; 28 | 29 | private: 30 | 31 | void * first_block; 32 | Node * first_available; 33 | 34 | BlockSList(const BlockSList &); 35 | BlockSList & operator= (const BlockSList &); 36 | 37 | public: 38 | 39 | BlockSList() 40 | // Default constructor. 41 | // add_block must be called before any nodes are available 42 | : first_block(0), first_available(0) {}; 43 | 44 | Node * new_node() 45 | // return a new_node if one is available or null otherwise 46 | // Note: the node's data member is NOT initialized in any way. 47 | { 48 | Node * n = first_available; 49 | if (n != 0) 50 | first_available = first_available->next; 51 | return n; 52 | } 53 | 54 | void remove_node(Node * n) 55 | // marks the node as available 56 | // Note: the node's data memeber destructor is NOT called 57 | { 58 | n->next = first_available; 59 | first_available = n; 60 | } 61 | 62 | void add_block(unsigned int num); 63 | // allocate enough memory for an additional num nodes 64 | 65 | void clear(); 66 | // free all memory. add_block must then be called before any nodes 67 | // are available 68 | // Note: the node's data member destructor is NOT called 69 | 70 | 71 | ~BlockSList() {clear();} 72 | 73 | }; 74 | 75 | } 76 | #endif 77 | -------------------------------------------------------------------------------- /manual/crubadan.texi: -------------------------------------------------------------------------------- 1 | @itemize 2 | @item Afrikaans (af) 3 | @item Asturian / Bable (ast) 4 | @item Azerbaijani (az) 5 | @item Balinese (ban) 6 | @item Bemba (bem) 7 | @item Bislama (bi) 8 | @item Breton (br) 9 | @item Catalan / Valencian (ca) 10 | @item Cebuano (ceb) 11 | @item Chamorro (ch) 12 | @item Chuukese (chk) 13 | @item Corsican (co) 14 | @item Kashubian (csb) 15 | @item Welsh (cy) 16 | @item Basque (eu) 17 | @item Fijian (fj) 18 | @item Faroese (fo) 19 | @item Friulian (fur) 20 | @item Frisian (fy) 21 | @item Irish (ga) 22 | @item Scottish Gaelic (gd) 23 | @item Gallegan (gl) 24 | @item Guarani (gn) 25 | @item Manx Gaelic (gv) 26 | @item Hausa (ha) 27 | @item Hawaiian (haw) 28 | @item Hiligaynon (hil) 29 | @item Haitian Creole (ht) 30 | @item Iban (iba) 31 | @item Igbo (ig) 32 | @item Iloko (ilo) 33 | @item Javanese (jv) 34 | @item Kachin (kac) 35 | @item Khasi (kha) 36 | @item Kalaallisut / Greenlandic (kl) 37 | @item Konkani (kok) 38 | @item Kurdish (ku) 39 | @item Cornish (kw) 40 | @item Luxembourgish (lb) 41 | @item Ganda (lg) 42 | @item Limburgian (li) 43 | @item Lingala (ln) 44 | @item Lozi (loz) 45 | @item Luo (Kenya and Tanzania) (luo) 46 | @item Malagasy (mg) 47 | @item Marshallese (mh) 48 | @item Maori (mi) 49 | @item Minangkabau (min) 50 | @item Mongolian (mn) 51 | @item Maltese (mt) 52 | @item North Ndebele (nd) 53 | @item Low Saxon (nds) 54 | @item Ndonga (ng) 55 | @item Niuean (niu) 56 | @item Norwegian Nynorsk (nn) 57 | @item Northern Sotho (nso) 58 | @item Navajo (nv) 59 | @item Nyanja (ny) 60 | @item Occitan / Provencal (oc) 61 | @item Pampanga (pam) 62 | @item Papiamento (pap) 63 | @item Quechua (qu) 64 | @item Rarotongan (rar) 65 | @item Rundi (rn) 66 | @item Kinyarwanda (rw) 67 | @item Sardinian (sc) 68 | @item Northern Sami (se) 69 | @item Sango (sg) 70 | @item Samoan (sm) 71 | @item Shona (sn) 72 | @item Somali (so) 73 | @item Swati (ss) 74 | @item Southern Sotho (st) 75 | @item Sundanese (su) 76 | @item Swahili (sw) 77 | @item Tetum (tet) 78 | @item Tajik (tg) 79 | @item Turkmen (tk) 80 | @item Tokelau (tkl) 81 | @item Tagalog (tl) 82 | @item Tswana (tn) 83 | @item Tonga (to) 84 | @item Tok Pisin (tpi) 85 | @item Tsonga (ts) 86 | @item Tahitian (ty) 87 | @item Venda (ve) 88 | @item Walloon (wa) 89 | @item Wolof (wo) 90 | @item Xhosa (xh) 91 | @item Yoruba (yo) 92 | @item Zulu (zu) 93 | @end itemize 94 | -------------------------------------------------------------------------------- /auto/MkSrc/Util.pm: -------------------------------------------------------------------------------- 1 | # This file is part of The New Aspell 2 | # Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | # license version 2.0 or 2.1. You should have received a copy of the 4 | # LGPL license along with this library if you did not you can find it 5 | # at http://www.gnu.org/. 6 | 7 | package MkSrc::Util; 8 | 9 | BEGIN { 10 | use Exporter; 11 | our @ISA = qw(Exporter); 12 | our @EXPORT = qw(false true 13 | cmap one_of 14 | to_upper to_lower to_mixed); 15 | } 16 | 17 | use strict; 18 | use warnings; 19 | no warnings qw(uninitialized); 20 | no locale; 21 | 22 | =head1 MkSrc::Util 23 | 24 | This module contains various useful utility functions: 25 | 26 | =over 27 | 28 | =cut 29 | 30 | =item false 31 | 32 | Returns 0. 33 | 34 | =item true 35 | 36 | Returns 1. 37 | 38 | =cut 39 | 40 | sub false () {return 0} 41 | sub true () {return 1} 42 | 43 | =item cmap EXPR LIST 44 | 45 | Apply EXPR to each item in LIST and than concatenate the result into 46 | a string 47 | 48 | =cut 49 | 50 | sub cmap ( & @ ) 51 | { 52 | my ($sub, @d) = @_; 53 | return join '', map &$sub, @d; 54 | } 55 | 56 | =item one_of STR LIST 57 | 58 | Returns true if LIST contains at least one of STR. 59 | 60 | =cut 61 | 62 | sub one_of ( $ @ ) { 63 | my ($v, @l) = @_; 64 | return scalar grep {$_ eq $v} @l; 65 | } 66 | 67 | =item to_upper STR 68 | 69 | Convert STR to all uppercase and substitute spaces with underscores. 70 | 71 | =cut 72 | 73 | sub to_upper( $ ) { 74 | local ($_) = @_; 75 | s/\-/ /g; 76 | s/^\s+//; s/\s+$//; s/(\S)\s+(\S)/$1_$2/g; 77 | return uc($_); 78 | } 79 | 80 | =item to_lower STR 81 | 82 | Convert STR to all lowercase and substitute spaces with underscores. 83 | 84 | =cut 85 | 86 | sub to_lower( $ ) { 87 | local ($_) = @_; 88 | s/\-/ /g; 89 | s/^\s+//; s/\s+$//; s/(\S)\s+(\S)/$1_$2/g; 90 | return lc($_); 91 | } 92 | 93 | =item to_mixed STR 94 | 95 | Convert STR to mixed case where each new word startes with a 96 | uppercase letter. For example "feed me" would become "FeedMe". 97 | 98 | =cut 99 | 100 | sub to_mixed( $ ) { 101 | local ($_) = @_; 102 | s/\-/ /g; 103 | s/\s*(\S)(\S*)/\u$1\l$2\E/g; 104 | return $_; 105 | } 106 | 107 | =back 108 | 109 | =cut 110 | 111 | 1; 112 | -------------------------------------------------------------------------------- /common/getdata.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_GET_DATA__HPP 8 | #define ASPELL_GET_DATA__HPP 9 | 10 | #include 11 | #include 12 | #include "string.hpp" 13 | #include "mutable_string.hpp" 14 | 15 | namespace acommon { 16 | 17 | class IStream; 18 | class String; 19 | 20 | // NOTE: getdata_pair WILL NOT unescape a string 21 | 22 | struct DataPair { 23 | MutableString key; 24 | MutableString value; 25 | size_t line_num; 26 | DataPair() : line_num(0) {} 27 | }; 28 | 29 | bool getdata_pair(IStream & in, DataPair & d, String & buf); 30 | 31 | char * unescape(char * dest, const char * src); 32 | static inline char * unescape(char * dest) {return unescape(dest, dest);} 33 | static inline void unescape(MutableString & d) { 34 | char * e = unescape(d.str, d.str); 35 | d.size = e - d.str; 36 | } 37 | static inline void unescape(String & d) { 38 | d.ensure_null_end(); 39 | char * e = unescape(d.data(), d.data()); 40 | d.resize(e - d.data()); 41 | } 42 | 43 | // if limit is not given than dest should have enough space for 44 | // twice the number of characters of src 45 | bool escape(char * dest, const char * src, 46 | size_t limit = INT_MAX, const char * others = 0); 47 | 48 | void to_lower(char *); 49 | void to_lower(String &, const char *); 50 | 51 | // extract the first whitespace delimited word from d.value and put 52 | // it in d.key. d.value is expected not to have any leading 53 | // whitespace. The string is modified in place so that d.key will be 54 | // null terminated. d.value is modified to point to any additional 55 | // data after key with any leading white space removed. Returns 56 | // false when there are no more words to extract 57 | bool split(DataPair & d); 58 | 59 | // preps a string for split 60 | void init(ParmString str, DataPair & d, String & buf); 61 | 62 | bool getline(IStream & in, DataPair & d, String & buf); 63 | 64 | char * get_nb_line(IStream & in, String & buf); 65 | void remove_comments(String & buf); 66 | 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /scripts/aspell-import: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # 4 | # aspell-import -- Perl script to import old dictionaries 5 | # 6 | # This file is part of The New Aspell 7 | # Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 8 | # license version 2.0 or 2.1. You should have received a copy of the 9 | # LGPL license along with this library if you did not you can find it 10 | # at http://www.gnu.org/. 11 | 12 | 13 | 14 | %abrv = qw( american en 15 | british en 16 | canadian en 17 | catala ca 18 | czech cs 19 | dansk da 20 | deutsch de 21 | ellhnika el 22 | english en 23 | espanol es 24 | esperanto eo 25 | francais fr 26 | german de 27 | italian it 28 | liet lt 29 | nederlands nl 30 | norsk no 31 | polish pl 32 | portugues pt 33 | russian ru 34 | svenska sv); 35 | 36 | chdir $ENV{HOME}; 37 | 38 | foreach $file (<.ispell_*>, <.aspell.*.*>) 39 | { 40 | $_ = $file; 41 | if (/^.ispell_(.+)$/) {$lang = $1; $type = 'ispell'} 42 | elsif (/^.aspell.(.+?).(per|pws)$/) {$lang = $1; $type = 'personal'} 43 | elsif (/^.aspell.(.+?).(prepl)$/) {$lang = $1; $type = 'repl'} 44 | $abrv = $abrv{$lang}; 45 | if (not defined $abrv) { 46 | print "Warning language \"$lang\" is not known\n" unless length $lang == 2; 47 | next; 48 | } 49 | open IN, $file; 50 | print "Processing \"~/$file\", lang = $abrv\n"; 51 | if ($type eq 'ispell' || $type eq 'personal') { 52 | if $type eq 'personal'; 53 | while () { 54 | chop; 55 | push @{$words{$abrv}{per}}, $_; 56 | } 57 | } elsif ($type eq 'repl') { 58 | $_ = ; 59 | if (!/^personal\_repl\-1\.1/) { 60 | print "$file not in a supported format\n"; 61 | next; 62 | } 63 | while () { 64 | /^([^ ]+) (.+)\n$/ or die; 65 | push @{$words{$abrv}{repl}}, [$1,$2]; 66 | } 67 | } 68 | close IN; 69 | } 70 | 71 | $SIG{PIPE} = 'IGNORE'; 72 | 73 | foreach $abrv (keys %words) { 74 | print "Merging $abrv\n"; 75 | open P, "| aspell -a --lang=$abrv --sug-mode=ultra" or next; 76 | foreach (@{$words{$abrv}{per}}) { 77 | print P "* $_\n"; 78 | } 79 | foreach (@{$words{$abrv}{repl}}) { 80 | print P "\$\$ra $_->[0],$_->[1]\n"; 81 | } 82 | print P "#\n"; 83 | close P; 84 | } 85 | -------------------------------------------------------------------------------- /modules/speller/default/multi_ws.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "config.hpp" 3 | #include "data.hpp" 4 | #include "file_util.hpp" 5 | #include "fstream.hpp" 6 | #include "getdata.hpp" 7 | #include "string.hpp" 8 | #include "parm_string.hpp" 9 | #include "errors.hpp" 10 | #include "vector.hpp" 11 | 12 | #include "gettext.h" 13 | 14 | namespace { 15 | 16 | using namespace acommon; 17 | using namespace aspeller; 18 | 19 | typedef Vector Wss; 20 | 21 | class MultiDictImpl : public Dictionary 22 | { 23 | public: 24 | MultiDictImpl() : Dictionary(multi_dict, "MultiDictImpl") {} 25 | PosibErr load(ParmString, Config &, DictList *, SpellerImpl *); 26 | DictsEnumeration * dictionaries() const; 27 | private: 28 | Wss wss; 29 | }; 30 | 31 | PosibErr MultiDictImpl::load(ParmString fn, 32 | Config & config, 33 | DictList * new_dicts, 34 | SpellerImpl * speller) 35 | { 36 | String dir = figure_out_dir("",fn); 37 | FStream in; 38 | RET_ON_ERR(in.open(fn, "r")); 39 | set_file_name(fn); 40 | String buf; DataPair d; 41 | while(getdata_pair(in, d, buf)) 42 | { 43 | if (d.key == "add") { 44 | 45 | RET_ON_ERR_SET(add_data_set(d.value, config, new_dicts, speller, dir), Dict *, res); 46 | RET_ON_ERR(set_check_lang(res->lang()->name(), config)); 47 | wss.push_back(res); 48 | 49 | } else { 50 | 51 | return make_err(unknown_key, d.key).with_file(fn, d.line_num); 52 | 53 | } 54 | } 55 | 56 | if (wss.empty()) { 57 | return make_err(bad_file_format, fn, 58 | _("There must be at least one \"add\" line.")); 59 | } 60 | 61 | return no_err; 62 | } 63 | 64 | struct Parms 65 | { 66 | typedef Dict * Value; 67 | typedef Wss::const_iterator Iterator; 68 | Iterator end; 69 | Parms(Iterator e) : end(e) {} 70 | bool endf(Iterator i) const {return i == end;} 71 | Value end_state() const {return 0;} 72 | Value deref(Iterator i) const {return *i;} 73 | }; 74 | 75 | DictsEnumeration * MultiDictImpl::dictionaries() const 76 | { 77 | return new MakeEnumeration(wss.begin(), wss.end()); 78 | } 79 | } 80 | 81 | namespace aspeller { 82 | 83 | MultiDict * new_default_multi_dict() 84 | { 85 | return new MultiDictImpl(); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /common/strtonum.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2002 by Melvin Hadasht and Kevin Atkinson under the 3 | // GNU LGPL license version 2.0 or 2.1. You should have received a 4 | // copy of the LGPL license along with this library if you did not you 5 | // can find it at http://www.gnu.org/. 6 | 7 | #include 8 | 9 | #include "strtonum.hpp" 10 | #include "asc_ctype.hpp" 11 | 12 | namespace acommon { 13 | 14 | static double strtodbl_c(const char * nptr, const char ** endptr) 15 | { 16 | double x = 0.0; 17 | double y = 0.0; 18 | double decimal = 1.0; 19 | int negative = 0; 20 | const char * str = nptr; 21 | 22 | while (asc_isspace(*str)) 23 | str++; 24 | if (!*str) 25 | goto END_STRTODBL_C; 26 | if (*str == '-') { 27 | negative = 1; 28 | str++; 29 | } else if (*str == '+') 30 | str++; 31 | if (!*str) 32 | goto END_STRTODBL_C; 33 | while (*str >= '0' && *str <= '9') { 34 | x = x * 10.0 + (*str - '0'); 35 | str++; 36 | } 37 | if (!*str || *str != '.') 38 | goto END_STRTODBL_C; 39 | str++; 40 | decimal = 1.0; 41 | while (*str >= '0' && *str <= '9') { 42 | decimal *= 0.1; 43 | y = y + (*str - '0')*decimal; 44 | str++; 45 | } 46 | END_STRTODBL_C: 47 | if (endptr) 48 | *endptr = (char *) str; 49 | return negative ? -(x + y) : (x + y); 50 | } 51 | 52 | double strtod_c(const char * nptr, const char ** endptr) 53 | { 54 | double x; 55 | const char * eptr; 56 | x = strtodbl_c(nptr, &eptr); 57 | if (*eptr == 'E' || *eptr == 'e') { 58 | const char *nptr2 = eptr; 59 | long int y, i; 60 | double e = 1.0; 61 | nptr2++; 62 | y = strtol(nptr2, (char **)&eptr, 10); 63 | if (y) { 64 | for (i=0; i < ( y < 0 ? -y : y); i++) 65 | e *= 10.0; 66 | x = (y < 0) ? x / e : x * e; 67 | } 68 | } 69 | if (endptr) 70 | *endptr = eptr; 71 | return x; 72 | } 73 | 74 | long strtoi_c(const char * npter, const char ** endptr) { 75 | 76 | char * str = (char*)npter; 77 | long num = 0; 78 | long sign = 1; 79 | 80 | *endptr = str; 81 | while (asc_isspace(*str)) { 82 | str++; 83 | } 84 | if (*str == '-' || *str == '+') { 85 | sign = *(str++) == '-' ? -1 : 1; 86 | } 87 | while (*str >= '0' && *str <= '9' ) { 88 | num = num * 10 + (long)(*str - '0'); 89 | str++; 90 | } 91 | *endptr = str; 92 | return num; 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /auto/MkSrc/Type.pm: -------------------------------------------------------------------------------- 1 | # This file is part of The New Aspell 2 | # Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | # license version 2.0 or 2.1. You should have received a copy of the 4 | # LGPL license along with this library if you did not you can find it 5 | # at http://www.gnu.org/. 6 | 7 | package MkSrc::Type; 8 | 9 | BEGIN { 10 | use Exporter; 11 | our @ISA = qw(Exporter); 12 | our @EXPORT = qw(creates_type update_type finalized_type); 13 | } 14 | 15 | use strict; 16 | use warnings; 17 | no warnings qw(uninitialized); 18 | no locale; 19 | 20 | sub creates_type ( $ ); 21 | sub update_type ( $ ; $ ); 22 | sub finalized_type ( $ ); 23 | 24 | use MkSrc::Util; 25 | use MkSrc::Info; 26 | 27 | # 28 | # Type Functions 29 | # 30 | 31 | 32 | sub creates_type ( $ ) 33 | { 34 | my ($i) = @_; 35 | my $d; 36 | $d->{type} = $info{$i->{type}}{creates_type}; 37 | return undef unless defined $d->{type}; 38 | $d->{name} = $i->{name}; 39 | $d->{treat_as} = 40 | ($i->{type} eq 'basic' ? 'special' 41 | : exists $i->{'treat as object'} || $i->{type} eq 'enum' ? 'object' 42 | : 'pointer'); 43 | if (my $name = $info{$i->{type}}{creates_name}) { 44 | $d->{name} = $name->($i); 45 | } 46 | return $d; 47 | } 48 | 49 | sub update_type ( $ ; $ ) 50 | { 51 | my ($name, $data) = @_; 52 | my $d = $types{$name}; 53 | $types{$name} = $d = {} unless defined $d; 54 | $d->{data} = $data if defined $data; 55 | $d->{data} = {} unless defined $d->{data}; 56 | return $d; 57 | } 58 | 59 | sub finalized_type ( $ ) 60 | { 61 | my ($name) = @_; 62 | 63 | my $d = $types{$name}; 64 | $types{$name} = $d = {data=>{}} unless defined $d; 65 | return $d unless exists $d->{data}; 66 | 67 | while (my ($k,$v) = each %{$d->{data}}) { 68 | $d->{$k} = defined $v ? $v : true; 69 | } 70 | delete $d->{data}; 71 | 72 | local $_ = $name; 73 | 74 | s/^const // and $d->{const} = true; 75 | s/^array (\d+) // and $d->{array} = $1; 76 | s/ ?pointer$// and $d->{pointer} = true; 77 | s/ ?object$// and $d->{pointer} = false; 78 | 79 | $_ = 'void' if length $_ == 0; 80 | 81 | my $r = finalized_type $_; 82 | 83 | $d->{type} = exists $r->{type} ? $r->{type} : 'unknown'; 84 | $d->{name} = $_; 85 | $d->{orig_name} = $name; 86 | $d->{pointer} = ($r->{treat_as} eq 'pointer') 87 | unless exists $d->{pointer}; 88 | $d->{const} = false unless $d->{pointer}; 89 | $d->{created_in} = $r->{created_in}; 90 | 91 | return $d; 92 | 93 | } 94 | 1; 95 | -------------------------------------------------------------------------------- /common/string.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include 8 | #include 9 | 10 | #ifndef va_copy 11 | # ifdef __va_copy 12 | # define va_copy __va_copy 13 | # else 14 | # define va_copy(dst, src) memcpy(&dst, &src, sizeof(va_list)) 15 | # endif 16 | #endif 17 | 18 | #include "string.hpp" 19 | #include "asc_ctype.hpp" 20 | 21 | namespace acommon { 22 | 23 | // reserve space for at least s+1 characters 24 | void String::reserve_i(size_t s) 25 | { 26 | size_t old_size = end_ - begin_; 27 | size_t new_size = (storage_end_ - begin_) * 3 / 2; 28 | if (new_size < 64) new_size = 64; 29 | if (new_size < s + 1) new_size = s + 1; 30 | if (old_size == 0) { 31 | if (begin_) free(begin_); 32 | begin_ = (char *)malloc(new_size); 33 | } else { 34 | begin_ = (char *)realloc(begin_, new_size); 35 | } 36 | end_ = begin_ + old_size; 37 | storage_end_ = begin_ + new_size; 38 | } 39 | 40 | int String::vprintf(const char * format, va_list ap0) 41 | { 42 | reserve(size() + 64); 43 | int res = 0; 44 | va_list ap; 45 | loop: { 46 | int avail = storage_end_ - end_; 47 | if (res < 0 && avail > 1024*1024) 48 | return -1; // to avoid an infinite loop in case a neg result 49 | // really means an error and not just "not enough 50 | // space" 51 | va_copy(ap,ap0); 52 | res = vsnprintf(end_, avail, format, ap); 53 | va_end(ap); 54 | if (res < 0) { 55 | reserve_i(); goto loop; 56 | } else if (res > avail) { 57 | reserve_i(size() + res); goto loop; 58 | } 59 | } 60 | end_ += res; 61 | return res; 62 | } 63 | 64 | bool StringIStream::append_line(String & str, char d) 65 | { 66 | if (in_str[0] == '\0') return false; 67 | const char * end = in_str; 68 | while (*end != d && *end != '\0') ++end; 69 | str.append(in_str, end - in_str); 70 | in_str = end; 71 | if (*in_str == d) ++in_str; 72 | return true; 73 | } 74 | 75 | bool StringIStream::read(void * data, unsigned int size) 76 | { 77 | char * str = static_cast(data); 78 | while (*in_str != '\0' && size != 0) { 79 | *str = *in_str; 80 | ++in_str; 81 | ++str; 82 | ++size; 83 | } 84 | return size == 0; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /test/suggest/comp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use autodie; 6 | 7 | use Symbol 'qualify_to_ref'; 8 | 9 | open A, $ARGV[0]; 10 | open B, $ARGV[1]; 11 | my $level = $ARGV[2]; 12 | $level = 0 unless defined $level; 13 | 14 | my %score; 15 | $score{orig} = [0,0,0,0,0,0]; 16 | $score{new} = [0,0,0,0,0,0]; 17 | sub get_line(*$) { 18 | my $fh = qualify_to_ref(shift, caller); 19 | my $id = shift; 20 | local $_ = <$fh>; 21 | chomp; 22 | my @d = split "\t", $_, -1; 23 | push @d, '' if @d == 4; 24 | die "bad line: $_" unless @d == 5; 25 | my %v = (key => "$d[0] => $d[1]", 26 | mis => $d[0], cur => $d[1], pos => $d[2], num => $d[3], sugs => $d[4]); 27 | $v{pos} = 'inf' if $v{pos} == 0; 28 | $score{$id}[0]++ if $v{pos} == 1; 29 | $score{$id}[1]++ if $v{pos} <= 5; 30 | $score{$id}[2]++ if $v{pos} <= 10; 31 | $score{$id}[3]++ if $v{pos} <= 25; 32 | $score{$id}[4]++ if $v{pos} <= 50; 33 | $score{$id}[5]++ if $v{pos} < 'inf'; 34 | my @sugs = split ', ', $v{sugs}; 35 | foreach (@sugs) {$_ = "*$_*" if $_ eq $v{cur};} 36 | $v{sugs} = join ', ', @sugs; 37 | return %v; 38 | } 39 | 40 | my @tally = (0,0,0,0); 41 | my $fail = 0; 42 | 43 | while (!eof(A) && !eof(B)) { 44 | my %a = get_line A, 'orig'; 45 | my %b = get_line B, 'new'; 46 | my $prefix = ' '; 47 | if ($a{sugs} eq $b{sugs}) { 48 | $tally[0]++; 49 | next if ($level > 0); 50 | print "$prefix$a{key}: same\n"; 51 | next; 52 | } elsif ($a{pos} eq $b{pos}) { 53 | $tally[1]++; 54 | next if ($level > 1); 55 | print "$prefix$a{key}: differ:\n"; 56 | $fail++; 57 | } elsif ($a{pos} > $b{pos}) { 58 | $tally[2]++; 59 | next if ($level > 2); 60 | $prefix = '. '; 61 | print "$prefix$a{key}: better: $a{pos} > $b{pos}:\n"; 62 | $fail++; 63 | } else { 64 | $tally[3]++; 65 | $prefix = '!!'; 66 | print "$prefix$a{key}: WORSE: $a{pos} < $b{pos}:\n"; 67 | $fail++; 68 | } 69 | printf "$prefix %3d: $a{sugs}\n", $a{num}; 70 | printf "$prefix %3d: $b{sugs}\n", $b{num}; 71 | } 72 | 73 | my @fh = (*STDOUT); 74 | print STDERR "RESULTS DIFFER ($ARGV[0] $ARGV[1])!\n" if $fail; 75 | push @fh, *STDERR if $fail; 76 | for my $fh (@fh) { 77 | printf $fh "STATS orig: ".join(" ", @{$score{orig}})."\n"; 78 | printf $fh "STATS diff: ".join(" ", map {sprintf("%+3d", $score{new}[$_] - $score{orig}[$_])} (0..5))."\n"; 79 | printf $fh "TOTALS: same: %d, differ: %d, better: %d, WORSE: %d\n", @tally; 80 | } 81 | 82 | exit 1 if $fail != 0; 83 | -------------------------------------------------------------------------------- /modules/filter/tex-filter.info: -------------------------------------------------------------------------------- 1 | # TeX filter option file 2 | 3 | #This Filter is usable with the following version(s) of Aspell 4 | ASPELL >=0.51 5 | 6 | #This line will be printed when typing `Aspell help TeX' 7 | DESCRIPTION filter for dealing with TeX/LaTeX documents 8 | 9 | STATIC filter 10 | #STATIC encoder 11 | #STATIC decoder 12 | 13 | OPTION check-comments 14 | TYPE bool 15 | DESCRIPTION check TeX comments 16 | DEFAULT false 17 | ENDOPTION 18 | 19 | OPTION command 20 | TYPE list 21 | DESCRIPTION TeX commands 22 | DEFAULT addtocounter pp 23 | DEFAULT addtolength pp 24 | DEFAULT alpha p 25 | DEFAULT arabic p 26 | DEFAULT fnsymbol p 27 | DEFAULT roman p 28 | DEFAULT stepcounter p 29 | DEFAULT setcounter pp 30 | DEFAULT usecounter p 31 | DEFAULT value p 32 | DEFAULT newcounter po 33 | DEFAULT refstepcounter p 34 | DEFAULT label p 35 | DEFAULT pageref p 36 | DEFAULT ref p 37 | DEFAULT newcommand poOP 38 | DEFAULT renewcommand poOP 39 | DEFAULT newenvironment poOPP 40 | DEFAULT renewenvironment poOPP 41 | DEFAULT newtheorem poPo 42 | DEFAULT newfont pp 43 | DEFAULT documentclass op 44 | DEFAULT usepackage op 45 | DEFAULT begin po 46 | DEFAULT end p 47 | DEFAULT setlength pp 48 | DEFAULT addtolength pp 49 | DEFAULT settowidth pp 50 | DEFAULT settodepth pp 51 | DEFAULT settoheight pp 52 | DEFAULT enlargethispage p 53 | DEFAULT hyphenation p 54 | DEFAULT pagenumbering p 55 | DEFAULT pagestyle p 56 | DEFAULT addvspace p 57 | DEFAULT framebox ooP 58 | DEFAULT hspace p 59 | DEFAULT vspace p 60 | DEFAULT makebox ooP 61 | DEFAULT parbox ooopP 62 | DEFAULT raisebox pooP 63 | DEFAULT rule opp 64 | DEFAULT sbox pO 65 | DEFAULT savebox pooP 66 | DEFAULT usebox p 67 | DEFAULT include p 68 | DEFAULT includeonly p 69 | DEFAULT input p 70 | DEFAULT addcontentsline ppP 71 | DEFAULT addtocontents pP 72 | DEFAULT fontencoding p 73 | DEFAULT fontfamily p 74 | DEFAULT fontseries p 75 | DEFAULT fontshape p 76 | DEFAULT fontsize pp 77 | DEFAULT usefont pppp 78 | DEFAULT documentstyle op 79 | DEFAULT cite p 80 | DEFAULT nocite p 81 | DEFAULT psfig p 82 | DEFAULT selectlanguage p 83 | DEFAULT includegraphics op 84 | DEFAULT bibitem op 85 | DEFAULT geometry p 86 | ENDOPTION 87 | 88 | #OPTION multi-byte 89 | #TYPE list 90 | #DESCRIPTION multi character coded letters (,[,[...]]) 91 | #DEFAULT Ä,\\"A,"A 92 | #DEFAULT ä,\\"a,"a 93 | #DEFAULT Ö,\\"O,"O 94 | #DEFAULT ö,\\"o,"o 95 | #DEFAULT Ü,\\"U,"U 96 | #DEFAULT ü,\\"u,"u 97 | #DEFAULT ß,\\"s,"s 98 | #FLAGS utf-8 99 | #ENDOPTION 100 | 101 | #OPTION hyphen 102 | #TYPE list 103 | #DESCRIPTION characters used to encode hyphenation locations 104 | #DEFAULT \\- 105 | #ENDOPTION 106 | -------------------------------------------------------------------------------- /test/wide_test_valid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | const uint16_t test_word[] = {'c','a','f', 0x00E9, 0}; 9 | const uint16_t test_incorrect[] = {'c','a','f', 'e', 0}; 10 | const uint16_t test_doc[] = {'T', 'h', 'e', ' ', 'c','a','f', 'e', '.', 0}; 11 | 12 | int fail = 0; 13 | 14 | int main() { 15 | AspellConfig * spell_config = new_aspell_config(); 16 | aspell_config_replace(spell_config, "master", "en_US-w_accents"); 17 | aspell_config_replace(spell_config, "encoding", "ucs-2"); 18 | AspellCanHaveError * possible_err = new_aspell_speller(spell_config); 19 | AspellSpeller * spell_checker = 0; 20 | if (aspell_error_number(possible_err) != 0) { 21 | fprintf(stderr, "%s", aspell_error_message(possible_err)); 22 | return 2; 23 | } else { 24 | spell_checker = to_aspell_speller(possible_err); 25 | } 26 | int correct = aspell_speller_check_w(spell_checker, test_word, -1); 27 | if (!correct) { 28 | fprintf(stderr, "%s", "fail: expected word to be correct\n"); 29 | fail = 1; 30 | } 31 | correct = aspell_speller_check_w(spell_checker, test_incorrect, -1); 32 | if (correct) { 33 | fprintf(stderr, "%s", "fail: expected word to be incorrect\n"); 34 | fail = 1; 35 | } 36 | const AspellWordList * suggestions = aspell_speller_suggest_w(spell_checker, test_incorrect, -1); 37 | AspellStringEnumeration * elements = aspell_word_list_elements(suggestions); 38 | const uint16_t * word = aspell_string_enumeration_next_w(uint16_t, elements); 39 | if (memcmp(word, test_word, sizeof(test_incorrect)) != 0) { 40 | fprintf(stderr, "%s", "fail: first suggesion is not what is expected\n"); 41 | fail = 1; 42 | } 43 | delete_aspell_string_enumeration(elements); 44 | 45 | possible_err = new_aspell_document_checker(spell_checker); 46 | if (aspell_error(possible_err) != 0) { 47 | fprintf(stderr, "Error: %s\n",aspell_error_message(possible_err)); 48 | return 2; 49 | } 50 | AspellDocumentChecker * checker = to_aspell_document_checker(possible_err); 51 | aspell_document_checker_process_w(checker, test_doc, -1); 52 | 53 | AspellToken token = aspell_document_checker_next_misspelling_w(uint16_t, checker); 54 | if (4 != token.len) { 55 | fprintf(stderr, "fail: size of first misspelling (%d) is not what is expected (%d)\n", 56 | token.len, 4); 57 | fail = 1; 58 | } else if (memcmp(test_incorrect, test_doc + token.offset, token.len) != 0) { 59 | fprintf(stderr, "%s", "fail: first misspelling is not what is expected\n"); 60 | fail = 1; 61 | } 62 | if (fail) { 63 | printf("not ok\n"); 64 | return 1; 65 | } else { 66 | printf("ok\n"); 67 | return 0; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /common/file_data_util.cpp: -------------------------------------------------------------------------------- 1 | #include "config.hpp" 2 | #include "file_util.hpp" 3 | #include "file_data_util.hpp" 4 | 5 | namespace acommon { 6 | 7 | // Fill in values for a local data directory and a system data directory 8 | // The values are stored under the keys local-data-dir and data-dir. 9 | // If the is no local-data-dir value, use the directory from master-path. 10 | // If there is no directory in master-path, use the current working dir. 11 | // FIXME: The case when there is no "/" in the master-path should not 12 | // happen since it is an internal option. Unofficially, it can still 13 | // be set by the user. This needs to eventually be fixed. 14 | void fill_data_dir(const Config * config, String & dir1, String & dir2) { 15 | if (config->have("local-data-dir")) { 16 | dir1 = config->retrieve("local-data-dir"); 17 | if (!dir1.empty() && dir1[dir1.size()-1] != '/') dir1 += '/'; 18 | } else { 19 | dir1 = config->retrieve("master-path"); 20 | size_t pos = dir1.rfind('/'); 21 | if (pos != String::npos) 22 | dir1.resize(pos + 1); 23 | else 24 | dir1 = "./"; 25 | } 26 | dir2 = config->retrieve("data-dir"); 27 | if (dir2[dir2.size()-1] != '/') dir2 += '/'; 28 | } 29 | 30 | const String & find_file(String & file, 31 | const String & dir1, const String & dir2, 32 | const String & name, const char * extension) 33 | { 34 | file = dir1 + name + extension; 35 | if (file_exists(file)) return dir1; 36 | file = dir2 + name + extension; 37 | return dir2; 38 | } 39 | 40 | bool find_file(String & file, 41 | const String & dir1, const String & dir2, 42 | const String & name, 43 | ParmString preext, ParmString ext) 44 | { 45 | bool try_name_only = false; 46 | if (name.size() > ext.size() 47 | && memcmp(name.c_str() + name.size() - ext.size(), 48 | ext, ext.size()) == 0) try_name_only = true; 49 | if (!try_name_only) { 50 | String n = name; n += preext; n += ext; 51 | file = dir1 + n; 52 | if (file_exists(file)) return true; 53 | file = dir2 + n; 54 | if (file_exists(file)) return true; 55 | 56 | n = name; n += ext; 57 | file = dir1 + n; 58 | if (file_exists(file)) return true; 59 | file = dir2 + n; 60 | if (file_exists(file)) return true; 61 | } 62 | 63 | file = dir1 + name; 64 | if (file_exists(file)) return true; 65 | file = dir2 + name; 66 | if (file_exists(file)) return true; 67 | 68 | if (try_name_only) {file = dir1 + name;} 69 | else {file = dir1 + name; file += preext; file += ext;} 70 | 71 | return false; 72 | } 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /common/cache.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ACOMMON_CACHE__HPP 2 | #define ACOMMON_CACHE__HPP 3 | 4 | #include "posib_err.hpp" 5 | 6 | namespace acommon { 7 | 8 | class GlobalCacheBase; 9 | template class GlobalCache; 10 | 11 | // get_cache_data (both versions) and release_cache_data will acquires 12 | // the cache's lock 13 | 14 | template 15 | PosibErr get_cache_data(GlobalCache *, 16 | typename Data::CacheConfig *, 17 | const typename Data::CacheKey &); 18 | template 19 | PosibErr get_cache_data(GlobalCache *, 20 | typename Data::CacheConfig *, 21 | typename Data::CacheConfig2 *, 22 | const typename Data::CacheKey &); 23 | 24 | class Cacheable; 25 | void release_cache_data(GlobalCacheBase *, const Cacheable *); 26 | static inline void release_cache_data(const GlobalCacheBase * c, const Cacheable * d) 27 | { 28 | release_cache_data(const_cast(c),d); 29 | } 30 | 31 | class Cacheable 32 | { 33 | public: // but don't use 34 | Cacheable * next; 35 | Cacheable * * prev; 36 | mutable int refcount; 37 | GlobalCacheBase * cache; 38 | public: 39 | bool attached() {return prev;} 40 | void copy_no_lock() const {refcount++;} 41 | void copy() const; // Acquires cache->lock 42 | void release() const {release_cache_data(cache,this);} // Acquires cache->lock 43 | Cacheable(GlobalCacheBase * c = 0) : next(0), prev(0), refcount(1), cache(c) {} 44 | virtual ~Cacheable() {} 45 | }; 46 | 47 | template 48 | class CachePtr 49 | { 50 | Data * ptr; 51 | 52 | public: 53 | void reset(Data * p) { 54 | if (ptr) ptr->release(); 55 | ptr = p; 56 | } 57 | void copy(Data * p) {if (p) p->copy(); reset(p);} 58 | Data * release() {Data * tmp = ptr; ptr = 0; return tmp;} 59 | 60 | Data & operator* () const {return *ptr;} 61 | Data * operator-> () const {return ptr;} 62 | Data * get() const {return ptr;} 63 | operator Data * () const {return ptr;} 64 | 65 | CachePtr() : ptr(0) {} 66 | CachePtr(const CachePtr & other) {ptr = other.ptr; if (ptr) ptr->copy();} 67 | void operator=(const CachePtr & other) {copy(other.ptr);} 68 | ~CachePtr() {reset(0);} 69 | }; 70 | 71 | template 72 | PosibErr setup(CachePtr & res, 73 | GlobalCache * cache, 74 | typename Data::CacheConfig * config, 75 | const typename Data::CacheKey & key) { 76 | PosibErr pe = get_cache_data(cache, config, key); 77 | if (pe.has_err()) return pe; 78 | res.reset(pe.data); 79 | return no_err; 80 | } 81 | 82 | bool reset_cache(const char * = 0); 83 | 84 | } 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /modules/speller/default/leditdist.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __aspeller_leditdist_hh__ 3 | #define __aspeller_leditdist_hh__ 4 | 5 | #include "weights.hpp" 6 | 7 | namespace aspeller { 8 | 9 | // limit_edit_distance finds the shortest edit distance but will 10 | // stop and return a number at least as large as LARGE_NUM if it has 11 | // to do more edits than a set limit. 12 | // Note that this does NOT mean that the score returned is <= limit*w.max 13 | // as "sub" vs "submarine" will return 6*(cost of insertion) no matter what 14 | // the limit is. 15 | // The edit distance is 16 | // (cost of swap)(# of swaps) + (cost of deletion)(# of deletions) 17 | // + (cost of insertion)(# of insertions) 18 | // + (cost of substitutions)(# of substitutions) 19 | 20 | // Preconditions: 21 | // max(strlen(a), strlen(b))*max(of the edit weights) <= 2^15 22 | // if violated than an incorrect result may be returned (which may be negative) 23 | // due to overflow of a short integer 24 | // (limit+1)*w.min < limit*w.max 25 | // limit <= 5 (use edit_distance if limit > 5) 26 | // where w.min and w.max is the minimum and maximum cost of an edit 27 | // respectfully. 28 | 29 | // The running time is asymptotically bounded above by 30 | // (3^l)*n where l is the limit and n is the maximum of strlen(a),strlen(b) 31 | // Based on my informal tests, however, the n does not really matter 32 | // and the running time is more like (3^l). 33 | 34 | // limit_edit_distance, based on my informal tests, turns out to be 35 | // faster than edit_dist for l < 5. For l == 5 it is about the 36 | // smaller for short strings (<= 5) and less than for longer strings 37 | 38 | // limit2_edit_distance(a,b,w) = limit_edit_distance(a,b,2,w) 39 | // but is roughly 2/3's faster 40 | 41 | struct EditDist { 42 | int score; 43 | const char * stopped_at; 44 | EditDist() {} 45 | EditDist(int s, const char * p) 46 | : score(s), stopped_at(p) {} 47 | operator int () const {return score;} 48 | }; 49 | 50 | static const int LARGE_NUM = 0xFFFFF; 51 | // this needs to be SMALLER than INT_MAX since it may be incremented 52 | // a few times 53 | 54 | int limit_edit_distance(const char * a, const char * b, int limit, 55 | const EditDistanceWeights & w 56 | = EditDistanceWeights()); 57 | 58 | EditDist limit0_edit_distance(const char * a, const char * b, 59 | const EditDistanceWeights & w 60 | = EditDistanceWeights()); 61 | 62 | EditDist limit1_edit_distance(const char * a, const char * b, 63 | const EditDistanceWeights & w 64 | = EditDistanceWeights()); 65 | 66 | EditDist limit2_edit_distance(const char * a, const char * b, 67 | const EditDistanceWeights & w 68 | = EditDistanceWeights()); 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /common/string_map.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "parm_string.hpp" 5 | #include "string_map.hpp" 6 | #include "string_pair.hpp" 7 | #include "string_pair_enumeration.hpp" 8 | 9 | #include "hash-t.hpp" 10 | 11 | // This file is part of The New Aspell 12 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 13 | // version 2.0 or 2.1. You should have received a copy of the LGPL 14 | // license along with this library if you did not you can find 15 | // it at http://www.gnu.org/. 16 | 17 | namespace acommon { 18 | 19 | // needed for darwin 20 | template HashTable::iterator 21 | HashTable::find_i(char const* const&, bool&); 22 | template std::pair::iterator,bool> 23 | HashTable::insert(const StringPair &); 24 | template void HashTable::init(unsigned int); 25 | template void HashTable::del(void); 26 | template HashTable::size_type 27 | HashTable::erase(char const* const&); 28 | template void BlockSList::clear(void); 29 | 30 | void StringMap::copy(const StringMap & other) 31 | { 32 | lookup_ = other.lookup_; 33 | for (Iter_ i = lookup_.begin(); 34 | !(i == lookup_.end()); // i != lookup_.end() causes problems 35 | // with gcc-2.95 36 | ++i) 37 | { 38 | i->first = buffer_.dup(i->first); 39 | i->second = buffer_.dup(i->second); 40 | } 41 | } 42 | 43 | 44 | class StringMapEnumeration : public StringPairEnumeration { 45 | StringMap::CIter_ i; 46 | StringMap::CIter_ end; 47 | public: 48 | StringMapEnumeration(StringMap::CIter_ i0, StringMap::CIter_ e0) 49 | : i(i0), end(e0) {} 50 | StringPairEnumeration * clone() const; 51 | void assign(const StringPairEnumeration *); 52 | bool at_end() const; 53 | StringPair next(); 54 | }; 55 | 56 | StringPairEnumeration * StringMapEnumeration::clone() const { 57 | return new StringMapEnumeration(*this); 58 | } 59 | 60 | void 61 | StringMapEnumeration::assign 62 | (const StringPairEnumeration * other) 63 | { 64 | *this = *(const StringMapEnumeration *)(other); 65 | } 66 | 67 | bool StringMapEnumeration::at_end() const { 68 | return i == end; 69 | } 70 | 71 | StringPair StringMapEnumeration::next() { 72 | StringPair temp; 73 | if (i == end) 74 | return temp; 75 | temp = *i; 76 | ++i; 77 | return temp; 78 | } 79 | 80 | StringPairEnumeration * StringMap::elements() const { 81 | return new StringMapEnumeration(lookup_.begin(), lookup_.end()); 82 | } 83 | 84 | StringMap * new_string_map() 85 | { 86 | return new StringMap(); 87 | } 88 | } 89 | 90 | -------------------------------------------------------------------------------- /common/string_list.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | #ifndef STRING_LIST_HP_HEADER 7 | #define STRING_LIST_HP_HEADER 8 | 9 | #include "string.hpp" 10 | #include "string_enumeration.hpp" 11 | #include "mutable_container.hpp" 12 | #include "posib_err.hpp" 13 | #include 14 | #include 15 | 16 | namespace acommon { 17 | 18 | struct StringListNode { 19 | // private data structure 20 | // default copy & destructor unsafe 21 | String data; 22 | StringListNode * next; 23 | StringListNode(ParmStr str, StringListNode * n = 0) 24 | : data(str), next(n) { 25 | } 26 | }; 27 | 28 | class StringListEnumeration : public StringEnumeration { 29 | // default copy and destructor safe 30 | private: 31 | StringListNode * n_; 32 | public: 33 | StringEnumeration * clone() const; 34 | void assign(const StringEnumeration *); 35 | 36 | StringListEnumeration(StringListNode * n) : n_(n) {} 37 | const char * next() { 38 | const char * temp; 39 | if (n_ == 0) { 40 | temp = 0; 41 | } else { 42 | temp = n_->data.c_str(); 43 | n_ = n_->next; 44 | } 45 | return temp; 46 | } 47 | bool at_end() const { 48 | return n_ == 0; 49 | } 50 | }; 51 | 52 | 53 | class StringList : public MutableContainer { 54 | // copy and destructor provided 55 | private: 56 | StringListNode * first; 57 | 58 | StringListNode * * find (ParmStr str); 59 | void copy(const StringList &); 60 | void destroy(); 61 | public: 62 | friend bool operator==(const StringList &, const StringList &); 63 | StringList() : first(0) {} 64 | StringList(const StringList & other) 65 | { 66 | copy(other); 67 | } 68 | StringList & operator= (const StringList & other) 69 | { 70 | destroy(); 71 | copy(other); 72 | return *this; 73 | } 74 | virtual ~StringList() 75 | { 76 | destroy(); 77 | } 78 | 79 | StringList * clone() const; 80 | void assign(const StringList *); 81 | 82 | PosibErr add(ParmStr); 83 | PosibErr remove(ParmStr); 84 | PosibErr clear(); 85 | 86 | StringEnumeration * elements() const; 87 | StringListEnumeration elements_obj() const 88 | { 89 | return StringListEnumeration(first); 90 | } 91 | 92 | bool empty() const { return first == 0; } 93 | unsigned int size() const { abort(); return 0; } 94 | 95 | }; 96 | 97 | StringList * new_string_list(); 98 | 99 | } 100 | #endif 101 | -------------------------------------------------------------------------------- /test/wide_test_invalid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | const uint16_t test_word[] = {'c','a','f', 0x00E9, 0}; 9 | const uint16_t test_incorrect[] = {'c','a','f', 'e', 0}; 10 | const uint16_t test_doc[] = {'T', 'h', 'e', ' ', 'c','a','f', 'e', '.', 0}; 11 | 12 | int fail = 0; 13 | 14 | int main() { 15 | AspellConfig * spell_config = new_aspell_config(); 16 | aspell_config_replace(spell_config, "master", "en_US-w_accents"); 17 | aspell_config_replace(spell_config, "encoding", "ucs-2"); 18 | AspellCanHaveError * possible_err = new_aspell_speller(spell_config); 19 | AspellSpeller * spell_checker = 0; 20 | if (aspell_error_number(possible_err) != 0) { 21 | fprintf(stderr, "%s", aspell_error_message(possible_err)); 22 | return 2; 23 | } else { 24 | spell_checker = to_aspell_speller(possible_err); 25 | } 26 | int correct = aspell_speller_check(spell_checker, (const char *)test_word, -1); 27 | if (!correct) { 28 | fprintf(stderr, "%s", "fail: expected word to be correct\n"); 29 | fail = 1; 30 | } 31 | correct = aspell_speller_check(spell_checker, (const char *)test_incorrect, -1); 32 | if (correct) { 33 | fprintf(stderr, "%s", "fail: expected word to be incorrect\n"); 34 | fail = 1; 35 | } 36 | const AspellWordList * suggestions = aspell_speller_suggest(spell_checker, (const char *)test_incorrect, -1); 37 | AspellStringEnumeration * elements = aspell_word_list_elements(suggestions); 38 | const char * word = aspell_string_enumeration_next(elements); 39 | if (memcmp(word, test_word, sizeof(test_incorrect)) != 0) { 40 | fprintf(stderr, "%s", "fail: first suggesion is not what is expected\n"); 41 | fail = 1; 42 | } 43 | delete_aspell_string_enumeration(elements); 44 | 45 | possible_err = new_aspell_document_checker(spell_checker); 46 | if (aspell_error(possible_err) != 0) { 47 | fprintf(stderr, "Error: %s\n",aspell_error_message(possible_err)); 48 | return 2; 49 | } 50 | AspellDocumentChecker * checker = to_aspell_document_checker(possible_err); 51 | aspell_document_checker_process(checker, (const char *)test_doc, -1); 52 | 53 | AspellToken token = aspell_document_checker_next_misspelling(checker); 54 | if (sizeof(test_incorrect) - sizeof(uint16_t) != token.len) { 55 | fprintf(stderr, "fail: size of first misspelling (%d) is not what is expected (%lu)\n", 56 | token.len, sizeof(test_incorrect) - sizeof(uint16_t)); 57 | fail = 1; 58 | } else if (memcmp(test_incorrect, (const char *)test_doc + token.offset, token.len) != 0) { 59 | fprintf(stderr, "%s", "fail: first misspelling is not what is expected\n"); 60 | fail = 1; 61 | } 62 | if (fail) { 63 | printf("not ok\n"); 64 | return 1; 65 | } else { 66 | printf("ok\n"); 67 | return 0; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /auto/MkSrc/ProcNativeImpl.pm: -------------------------------------------------------------------------------- 1 | # This file is part of The New Aspell 2 | # Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL 3 | # license version 2.0 or 2.1. You should have received a copy of the 4 | # LGPL license along with this library if you did not you can find it 5 | # at http://www.gnu.org/. 6 | 7 | package MkSrc::ProcNativeImpl; 8 | 9 | BEGIN { 10 | use Exporter; 11 | our @ISA = qw(Exporter); 12 | our @EXPORT = qw(%info %types %methods); 13 | } 14 | 15 | use strict; 16 | use warnings; 17 | no warnings qw(uninitialized); 18 | no locale; 19 | 20 | use MkSrc::Util; 21 | use MkSrc::CcHelper; 22 | use MkSrc::Info; 23 | use MkSrc::Create; 24 | 25 | $info{forward}{proc}{native_impl} = sub { 26 | my ($type) = @_; 27 | return "$type->{type} ".to_mixed($type->{name}).";\n"; 28 | }; 29 | 30 | $info{group}{proc}{native_impl} = sub { 31 | my ($data) = @_; 32 | create_cc_file (type => 'native_impl', 33 | cxx => true, 34 | namespace => 'acommon', 35 | dir => "common", 36 | header => false, 37 | data => $data, 38 | accum => {headers => {$data->{name} => true} } 39 | ); 40 | }; 41 | 42 | $info{errors}{proc}{native_impl} = sub { 43 | my $ret; 44 | my $p; 45 | $p = sub { 46 | my ($isa, $parms, $data) = @_; 47 | my @parms = (@$parms, (split /, */, $data->{parms})); 48 | my $parm_idx = sub { 49 | my ($p) = @_; 50 | return 0 if $p eq 'prim'; 51 | for (my $i = 0; $i != @parms; ++$i) { 52 | return $i+1 if $parms[$i] eq $p; 53 | } 54 | die "can't find parm for \"$p\""; 55 | }; 56 | my $proc_mesg = sub { 57 | my @mesg = split /\%(\w+)/, $_[0]; 58 | my $mesg = ''; 59 | while (true) { 60 | my $m = shift @mesg; 61 | $m =~ s/\"/\\\"/g; 62 | $mesg .= $m; 63 | my $p = shift @mesg; 64 | last unless defined $p; 65 | $mesg .= "%$p:"; 66 | $mesg .= $parm_idx->($p); 67 | } 68 | if (length $mesg == 0) { 69 | $mesg = 0; 70 | } else { 71 | $mesg = "N_(\"$mesg\")"; 72 | } 73 | return $mesg; 74 | }; 75 | my $mesg = $proc_mesg->($data->{mesg}); 76 | my $name = "aerror_".to_lower($data->{type}); 77 | $ret .= "static const ErrorInfo $name\_obj = {\n"; 78 | $ret .= " ".(defined $isa ? "$isa": 0).", // isa\n"; 79 | $ret .= " $mesg, // mesg\n"; 80 | $ret .= " ".scalar @parms.", // num_parms\n"; 81 | $ret .= " {".(join ', ', map {"\"$_\""} (@parms ? @parms : ("")))."} // parms\n"; 82 | $ret .= "};\n"; 83 | $ret .= "extern \"C\" const ErrorInfo * const $name = &$name\_obj;\n"; 84 | $ret .= "\n"; 85 | foreach my $d (@{$data->{data}}) { 86 | $ret .= $p->($name, \@parms, $d); 87 | } 88 | }; 89 | my ($data, $accum) = @_; 90 | $accum->{headers}{'error'} = true; 91 | foreach my $d (@{$data->{data}}) { 92 | $ret .= $p->(undef, [], $d); 93 | } 94 | return $ret; 95 | }; 96 | 97 | 1; 98 | -------------------------------------------------------------------------------- /modules/speller/default/typo_editdist.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __aspeller_typo_edit_distance_hh__ 2 | #define __aspeller_typo_edit_distance_hh__ 3 | 4 | #include "cache.hpp" 5 | #include "matrix.hpp" 6 | 7 | namespace acommon { 8 | class Config; 9 | } 10 | 11 | namespace aspeller { 12 | 13 | class Language; 14 | 15 | using namespace acommon; 16 | 17 | struct TypoEditDistanceInfo : public Cacheable { 18 | int missing; // the cost of having to insert a character 19 | int swap; // the cost of swapping two adjecent letters 20 | short * data; // memory for repl and extra 21 | ShortMatrix repl; // the cost of replacing one letter with another 22 | ShortMatrix extra; // the cost of removing an extra letter 23 | 24 | int repl_dis1; // the cost of replace when the distance is 1 25 | int repl_dis2; // " " otherwise 26 | int extra_dis1;// 27 | int extra_dis2;// 28 | 29 | int max; // maximum edit dist 30 | 31 | unsigned char to_normalized_[256]; 32 | int max_normalized; 33 | 34 | unsigned char to_normalized(char c) const { 35 | return to_normalized_[(unsigned char)c];} 36 | 37 | // IMPORTANT: It is still necessary to initialize and fill in 38 | // repl and extra 39 | private: 40 | TypoEditDistanceInfo(int m = 85, int s = 60, 41 | int r1 = 70, int r = 110, 42 | int e1 = 70, int e = 100) 43 | : missing(m), swap(s), data(0) 44 | , repl_dis1(r1), repl_dis2(r) 45 | , extra_dis1(e1), extra_dis2(e) 46 | , max(-1) {set_max();} 47 | void set_max(); 48 | public: 49 | ~TypoEditDistanceInfo() {if (data) free(data);} 50 | 51 | String keyboard; 52 | typedef const Config CacheConfig; 53 | typedef const Language CacheConfig2; 54 | typedef const char * CacheKey; 55 | bool cache_key_eq(const char * kb) const {return keyboard == kb;} 56 | static PosibErr get_new(const char *, const Config *, const Language *); 57 | private: 58 | TypoEditDistanceInfo(const TypoEditDistanceInfo &); 59 | void operator=(const TypoEditDistanceInfo &); 60 | }; 61 | 62 | PosibErr setup(CachePtr & res, 63 | const Config * c, const Language * l, ParmString kb); 64 | 65 | // edit_distance finds the shortest edit distance. 66 | // Preconditions: 67 | // max(strlen(word), strlen(target))*max(of the edit weights) <= 2^15 68 | // word,target are not null pointers 69 | // w.repl and w.extra are square matrices 70 | // the maximum character value is less than the size of w.repl and w.extra 71 | // Returns: 72 | // the edit distance between a and b 73 | 74 | // the running time is tightly asymptotically bounded by strlen(a)*strlen(b) 75 | 76 | short typo_edit_distance(ParmString word, 77 | ParmString target, 78 | const TypoEditDistanceInfo & w); 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /common/itemize.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #include 8 | #include 9 | 10 | #include "asc_ctype.hpp" 11 | #include "itemize.hpp" 12 | #include "mutable_container.hpp" 13 | #include 14 | #include 15 | 16 | //FIXME: it should be possible to escape ',' '+' '-' '!' so that they can 17 | // appear in values 18 | // If '\' is used than what about when the option file is parsed 19 | // as it strips away all '\' escapes. 20 | 21 | namespace acommon { 22 | 23 | struct ItemizeItem { 24 | char action; 25 | const char * name; 26 | ItemizeItem() : action('\0'), name(0) {} 27 | }; 28 | 29 | class ItemizeTokenizer { 30 | private: 31 | char * list; 32 | char * i; 33 | public: 34 | ItemizeTokenizer(const char * l); 35 | ~ItemizeTokenizer(); 36 | private: 37 | ItemizeTokenizer(const ItemizeTokenizer & other) ; 38 | ItemizeTokenizer & operator=(const ItemizeTokenizer & other); 39 | public: 40 | ItemizeItem next(); 41 | }; 42 | 43 | ItemizeTokenizer::ItemizeTokenizer(const char * l) 44 | { 45 | size_t size = strlen(l) + 1; 46 | list = new char[size]; 47 | i = list; 48 | strncpy(list, l, size); 49 | } 50 | 51 | ItemizeTokenizer::~ItemizeTokenizer() 52 | { 53 | delete[] list; 54 | } 55 | 56 | 57 | ItemizeItem ItemizeTokenizer::next() 58 | { 59 | ItemizeItem li; 60 | while (*i != '\0' && (asc_isspace(*i) || *i == ',')) ++i; 61 | if (*i == '\0') return li; 62 | li.action = *i; 63 | if (*i == '+' || *i == '-') { 64 | ++i; 65 | } else if (*i == '!') { 66 | li.name = ""; 67 | ++i; 68 | return li; 69 | } else { 70 | li.action = '+'; 71 | } 72 | while (*i != '\0' && *i != ',' && asc_isspace(*i)) ++i; 73 | if (*i == '\0' || *i == ',') return next(); 74 | li.name = i; 75 | while (*i != '\0' && *i != ',') ++i; 76 | while (i != list && asc_isspace(*(i-1))) --i; 77 | if (*i != '\0') { 78 | *i = '\0'; 79 | ++i; 80 | } 81 | return li; 82 | } 83 | 84 | 85 | PosibErr itemize (ParmString s, MutableContainer & d) { 86 | ItemizeTokenizer els(s); 87 | ItemizeItem li; 88 | while (li = els.next(), li.name != 0) { 89 | switch (li.action) { 90 | case '+': 91 | RET_ON_ERR(d.add(li.name)); 92 | break; 93 | case '-': 94 | RET_ON_ERR(d.remove(li.name)); 95 | break; 96 | case '!': 97 | RET_ON_ERR(d.clear()); 98 | break; 99 | default: 100 | abort(); 101 | } 102 | } 103 | return no_err; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /win32/settings.h: -------------------------------------------------------------------------------- 1 | /* common/settings.h. Generated by configure. */ 2 | /* common/settings.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Defined if no special Workarounds are needed for Curses headers */ 5 | /* #undef CURSES_INCLUDE_STANDARD */ 6 | 7 | /* Defined if special Wordaround I is need for Curses headers */ 8 | /* #undef CURSES_INCLUDE_WORKAROUND_1 */ 9 | 10 | /* Defined if curses like POSIX Functions should be used */ 11 | /* #undef CURSES_ONLY */ 12 | 13 | /* Defined if win32 relocation should be used */ 14 | /* #undef ENABLE_WIN32_RELOCATABLE */ 15 | 16 | /* Define to 1 if you have the header file. */ 17 | /* #undef HAVE_DLFCN_H */ 18 | 19 | /* Defined if msdos getch is supported */ 20 | /* #undef HAVE_GETCH */ 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_INTTYPES_H 1 24 | 25 | /* Defined if the curses library is available */ 26 | /* #undef HAVE_LIBCURSES */ 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_MEMORY_H 1 30 | 31 | /* Defined if mmap and friends is supported */ 32 | /* #undef HAVE_MMAP */ 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STDINT_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_STDLIB_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_STRINGS_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_STRING_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_SYS_STAT_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_SYS_TYPES_H 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_UNISTD_H 1 54 | 55 | /* Name of package */ 56 | #define PACKAGE "aspell" 57 | 58 | /* Define to the address where bug reports for this package should be sent. */ 59 | #define PACKAGE_BUGREPORT "" 60 | 61 | /* Define to the full name of this package. */ 62 | #define PACKAGE_NAME "" 63 | 64 | /* Define to the full name and version of this package. */ 65 | #define PACKAGE_STRING "" 66 | 67 | /* Define to the one symbol short name of this package. */ 68 | #define PACKAGE_TARNAME "" 69 | 70 | /* Define to the version of this package. */ 71 | #define PACKAGE_VERSION "" 72 | 73 | /* Defined if Posix Termios is Supported */ 74 | /* #undef POSIX_TERMIOS */ 75 | 76 | /* Defined if STL rel_ops polute the global namespace */ 77 | /* #undef REL_OPS_POLLUTION */ 78 | 79 | /* Define to 1 if you have the ANSI C header files. */ 80 | #define STDC_HEADERS 1 81 | 82 | /* Defined if file ino is supported */ 83 | /* #undef USE_FILE_INO */ 84 | 85 | /* Defined if file locking and truncating is supported */ 86 | /* #undef USE_FILE_LOCKS */ 87 | 88 | /* Defined if Posix locales are supported */ 89 | /* #undef USE_LOCALE */ 90 | 91 | /* Version number of package */ 92 | #define VERSION "0.50.3" 93 | -------------------------------------------------------------------------------- /common/cache.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "stack_ptr.hpp" 4 | #include "cache-t.hpp" 5 | 6 | namespace acommon { 7 | 8 | static GlobalCacheBase * first_cache = 0; 9 | Mutex GlobalCacheBase::global_cache_lock; 10 | 11 | void Cacheable::copy() const 12 | { 13 | //CERR << "COPY\n"; 14 | LOCK(&cache->lock); 15 | copy_no_lock(); 16 | } 17 | 18 | void GlobalCacheBase::del(Cacheable * n) 19 | { 20 | *n->prev = n->next; 21 | if (n->next) n->next->prev = n->prev; 22 | n->next = 0; 23 | n->prev = 0; 24 | } 25 | 26 | void GlobalCacheBase::add(Cacheable * n) 27 | { 28 | assert(n->refcount > 0); 29 | n->next = first; 30 | n->prev = &first; 31 | if (first) first->prev = &n->next; 32 | first = n; 33 | n->cache = this; 34 | } 35 | 36 | void GlobalCacheBase::release(Cacheable * d) 37 | { 38 | //CERR << "RELEASE\n"; 39 | LOCK(&lock); 40 | d->refcount--; 41 | assert(d->refcount >= 0); 42 | if (d->refcount != 0) return; 43 | //CERR << "DEL\n"; 44 | if (d->attached()) del(d); 45 | delete d; 46 | } 47 | 48 | void GlobalCacheBase::detach(Cacheable * d) 49 | { 50 | LOCK(&lock); 51 | if (d->attached()) del(d); 52 | } 53 | 54 | void GlobalCacheBase::detach_all() 55 | { 56 | LOCK(&lock); 57 | Cacheable * p = first; 58 | while (p) { 59 | *p->prev = 0; 60 | p->prev = 0; 61 | p = p->next; 62 | } 63 | } 64 | 65 | void release_cache_data(GlobalCacheBase * cache, const Cacheable * d) 66 | { 67 | cache->release(const_cast(d)); 68 | } 69 | 70 | GlobalCacheBase::GlobalCacheBase(const char * n) 71 | : name (n) 72 | { 73 | LOCK(&global_cache_lock); 74 | next = first_cache; 75 | prev = &first_cache; 76 | if (first_cache) first_cache->prev = &next; 77 | first_cache = this; 78 | } 79 | 80 | GlobalCacheBase::~GlobalCacheBase() 81 | { 82 | detach_all(); 83 | LOCK(&global_cache_lock); 84 | *prev = next; 85 | if (next) next->prev = prev; 86 | } 87 | 88 | bool reset_cache(const char * which) 89 | { 90 | LOCK(&GlobalCacheBase::global_cache_lock); 91 | bool any = false; 92 | for (GlobalCacheBase * i = first_cache; i; i = i->next) 93 | { 94 | if (which && strcmp(i->name, which) == 0) {i->detach_all(); any = true;} 95 | } 96 | return any; 97 | } 98 | 99 | extern "C" 100 | int aspell_reset_cache(const char * which) 101 | { 102 | return reset_cache(which); 103 | } 104 | 105 | #if 0 106 | 107 | struct CacheableImpl : public Cacheable 108 | { 109 | class CacheConfig; 110 | typedef String CacheKey; 111 | bool cache_key_eq(const CacheKey &); 112 | static PosibErr get_new(const CacheKey &, CacheConfig *); 113 | }; 114 | 115 | template 116 | PosibErr get_cache_data(GlobalCache *, 117 | CacheableImpl::CacheConfig *, 118 | const CacheableImpl::CacheKey &); 119 | 120 | #endif 121 | 122 | } 123 | -------------------------------------------------------------------------------- /common/document_checker.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of The New Aspell 2 | * Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL 3 | * license version 2.0 or 2.1. You should have received a copy of the 4 | * LGPL license along with this library if you did not you can find it 5 | * at http://www.gnu.org/. */ 6 | 7 | #include "document_checker.hpp" 8 | #include "tokenizer.hpp" 9 | #include "convert.hpp" 10 | #include "speller.hpp" 11 | #include "config.hpp" 12 | 13 | namespace acommon { 14 | 15 | DocumentChecker::DocumentChecker() 16 | : status_fun_(0), speller_(0) {} 17 | DocumentChecker::~DocumentChecker() 18 | { 19 | } 20 | 21 | PosibErr DocumentChecker 22 | ::setup(Tokenizer * tokenizer, Speller * speller, Filter * filter) 23 | { 24 | tokenizer_.reset(tokenizer); 25 | filter_.reset(filter); 26 | speller_ = speller; 27 | conv_ = speller->to_internal_; 28 | return no_err; 29 | } 30 | 31 | void DocumentChecker::set_status_fun(void (* sf)(void *, Token, int), 32 | void * d) 33 | { 34 | status_fun_ = sf; 35 | status_fun_data_ = d; 36 | } 37 | 38 | void DocumentChecker::reset() 39 | { 40 | if (filter_) 41 | filter_->reset(); 42 | } 43 | 44 | void DocumentChecker::process(const char * str, int size) 45 | { 46 | proc_str_.clear(); 47 | PosibErr fixed_size = get_correct_size("aspell_document_checker_process", conv_->in_type_width(), size); 48 | if (!fixed_size.has_err()) 49 | conv_->decode(str, fixed_size, proc_str_); 50 | proc_str_.append(0); 51 | FilterChar * begin = proc_str_.pbegin(); 52 | FilterChar * end = proc_str_.pend() - 1; 53 | if (filter_) 54 | filter_->process(begin, end); 55 | tokenizer_->reset(begin, end); 56 | } 57 | 58 | void DocumentChecker::process_wide(const void * str, int size, int type_width) 59 | { 60 | proc_str_.clear(); 61 | int fixed_size = get_correct_size("aspell_document_checker_process", conv_->in_type_width(), size, type_width); 62 | conv_->decode(static_cast(str), fixed_size, proc_str_); 63 | proc_str_.append(0); 64 | FilterChar * begin = proc_str_.pbegin(); 65 | FilterChar * end = proc_str_.pend() - 1; 66 | if (filter_) 67 | filter_->process(begin, end); 68 | tokenizer_->reset(begin, end); 69 | } 70 | 71 | Token DocumentChecker::next_misspelling() 72 | { 73 | bool correct; 74 | Token tok; 75 | do { 76 | if (!tokenizer_->advance()) { 77 | tok.offset = proc_str_.size(); 78 | tok.len = 0; 79 | return tok; 80 | } 81 | correct = speller_->check(MutableString(tokenizer_->word.data(), 82 | tokenizer_->word.size() - 1)); 83 | tok.len = tokenizer_->end_pos - tokenizer_->begin_pos; 84 | tok.offset = tokenizer_->begin_pos; 85 | if (status_fun_) 86 | (*status_fun_)(status_fun_data_, tok, correct); 87 | } while (correct); 88 | return tok; 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /common/fstream.hpp: -------------------------------------------------------------------------------- 1 | // This file is part of The New Aspell 2 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 3 | // version 2.0 or 2.1. You should have received a copy of the LGPL 4 | // license along with this library if you did not you can find 5 | // it at http://www.gnu.org/. 6 | 7 | #ifndef ASPELL_FSTREAM__HPP 8 | #define ASPELL_FSTREAM__HPP 9 | 10 | #include 11 | 12 | #include "string.hpp" 13 | #include "istream.hpp" 14 | #include "ostream.hpp" 15 | #include "posib_err.hpp" 16 | 17 | // NOTE: See iostream.hpp for the standard stream (ie standard input, 18 | // output, error) 19 | 20 | namespace acommon { 21 | class String; 22 | 23 | class FStream : public IStream, public OStream 24 | { 25 | private: 26 | FILE * file_; 27 | bool own_; 28 | 29 | public: 30 | FStream(char d = '\n') 31 | : IStream(d), file_(0), own_(true) {} 32 | FStream(FILE * f, bool own = true) 33 | : IStream('\n'), file_(f), own_(own) {} 34 | ~FStream() {close();} 35 | 36 | PosibErr open(ParmStr, const char *); 37 | void close(); 38 | 39 | operator bool() {return file_ != 0 && !feof(file_) && !ferror(file_);} 40 | 41 | int get() {return getc(file_);} 42 | void ignore() {getc(file_);} 43 | int peek() {int c = getc(file_); ungetc(c, file_); return c;} 44 | 45 | FILE * c_stream(); 46 | int file_no(); 47 | 48 | int vprintf(const char * format, va_list ap) 49 | { 50 | return vfprintf(file_, format, ap); 51 | } 52 | 53 | void flush() {fflush(file_);} 54 | 55 | // flushes the stream and goes to the beginning of the file 56 | void restart(); 57 | 58 | void skipws(); 59 | 60 | // Will return false if there is no more data 61 | bool append_line(String &, char d); 62 | 63 | // These perform raw io with any sort of formatting 64 | bool read(void *, unsigned int i); 65 | void write(ParmStr); 66 | void write(char c); 67 | void write(const void *, unsigned int i); 68 | 69 | long int tell() {return ftell(file_);} 70 | bool seek(long int offset, int whence = SEEK_SET) { 71 | return fseek(file_, offset, whence) == 0; 72 | } 73 | 74 | 75 | // The << >> operators are designed to work about they same 76 | // as they would with A C++ stream. 77 | FStream & operator>> (char & c) 78 | { 79 | skipws(); 80 | c = getc(file_); 81 | return *this; 82 | } 83 | 84 | FStream & operator<< (char c) 85 | { 86 | putc(c, file_); 87 | return *this; 88 | } 89 | 90 | FStream & operator>> (String &); 91 | FStream & operator>> (unsigned int &); 92 | FStream & operator>> (int &); 93 | FStream & operator<< (ParmStr); 94 | FStream & operator<< (unsigned long); 95 | FStream & operator<< (unsigned int); 96 | FStream & operator<< (int); 97 | FStream & operator<< (double); 98 | 99 | }; 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /common/cache-t.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ACOMMON_CACHE_T__HPP 2 | #define ACOMMON_CACHE_T__HPP 3 | 4 | #include "lock.hpp" 5 | #include "cache.hpp" 6 | 7 | //#include "iostream.hpp" 8 | 9 | namespace acommon { 10 | 11 | class GlobalCacheBase 12 | { 13 | public: 14 | mutable Mutex lock; 15 | public: // but don't use 16 | const char * name; 17 | GlobalCacheBase * next; 18 | GlobalCacheBase * * prev; 19 | // The global cache lock must exist while any cache instance is active 20 | static Mutex global_cache_lock; 21 | protected: 22 | Cacheable * first; 23 | void del(Cacheable * d); 24 | void add(Cacheable * n); 25 | GlobalCacheBase(const char * n); 26 | ~GlobalCacheBase(); 27 | public: 28 | void release(Cacheable * d); 29 | void detach(Cacheable * d); 30 | void detach_all(); 31 | }; 32 | 33 | template 34 | class GlobalCache : public GlobalCacheBase 35 | { 36 | public: 37 | typedef D Data; 38 | typedef typename Data::CacheKey Key; 39 | public: 40 | GlobalCache(const char * n) : GlobalCacheBase(n) {} 41 | // "find" and "add" will _not_ acquire a lock 42 | Data * find(const Key & key) { 43 | D * cur = static_cast(first); 44 | while (cur && !cur->cache_key_eq(key)) 45 | cur = static_cast(cur->next); 46 | return cur; 47 | } 48 | void add(Data * n) {GlobalCacheBase::add(n);} 49 | // "release" and "detach" _will_ acquire a lock 50 | void release(Data * d) {GlobalCacheBase::release(d);} 51 | void detach(Data * d) {GlobalCacheBase::detach(d);} 52 | }; 53 | 54 | template 55 | PosibErr get_cache_data(GlobalCache * cache, 56 | typename Data::CacheConfig * config, 57 | const typename Data::CacheKey & key) 58 | { 59 | LOCK(&cache->lock); 60 | Data * n = cache->find(key); 61 | //CERR << "Getting " << key << " for " << cache->name << "\n"; 62 | if (n) { 63 | n->refcount++; 64 | return n; 65 | } 66 | PosibErr res = Data::get_new(key, config); 67 | if (res.has_err()) { 68 | //CERR << "ERROR\n"; 69 | return res; 70 | } 71 | n = res.data; 72 | cache->add(n); 73 | //CERR << "LOADED FROM DISK\n"; 74 | return n; 75 | } 76 | 77 | template 78 | PosibErr get_cache_data(GlobalCache * cache, 79 | typename Data::CacheConfig * config, 80 | typename Data::CacheConfig2 * config2, 81 | const typename Data::CacheKey & key) 82 | { 83 | LOCK(&cache->lock); 84 | Data * n = cache->find(key); 85 | //CERR << "Getting " << key << "\n"; 86 | if (n) { 87 | n->refcount++; 88 | return n; 89 | } 90 | PosibErr res = Data::get_new(key, config, config2); 91 | if (res.has_err()) { 92 | //CERR << "ERROR\n"; 93 | return res; 94 | } 95 | n = res.data; 96 | cache->add(n); 97 | //CERR << "LOADED FROM DISK\n"; 98 | return n; 99 | } 100 | 101 | } 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /common/basic_list.hpp: -------------------------------------------------------------------------------- 1 | #ifndef autil__basic_list_hh 2 | #define autil__basic_list_hh 3 | 4 | #include 5 | //#include 6 | 7 | //#include 8 | 9 | // This file is part of The New Aspell 10 | // Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license 11 | // version 2.0 or 2.1. You should have received a copy of the LGPL 12 | // license along with this library if you did not you can find 13 | // it at http://www.gnu.org/. 14 | 15 | // BasicList is a simple list structure which can either be 16 | // implemented as a singly or doubly linked list. I created it 17 | // because a Singly liked list is not part of the C++ standard however 18 | // the Doubly Linked list does not have the same methods as the doubly 19 | // linked list because the singly linked list has a bunch of special 20 | // methods to address the fact that it is far faster to insert 21 | // elements before the position pointed to by an iterator is far faster 22 | // than inserting elements after the current position which is what is 23 | // normally done. Thus it is not possibly to simply substitute a singly 24 | // linked list with a doubly linked list by changing the name of the 25 | // container used. This list currently acts as a wrapper for the list 26 | // (doubly linked list) STL class however it can also very easily be 27 | // written as a wrapper for the slist (singly linked list) class when 28 | // it is available (slist is part of the SGI STL but not the C++ 29 | // standard) for better performance. 30 | 31 | namespace acommon { 32 | 33 | template 34 | class BasicList { 35 | //typedef __gnu_cxx::slist List; 36 | typedef std::list List; 37 | List data_; 38 | public: 39 | // treat the iterators as forward iterators only 40 | typedef typename List::iterator iterator; 41 | typedef typename List::const_iterator const_iterator; 42 | typedef typename List::size_type size_type; 43 | bool empty() {return data_.empty();} 44 | void clear() {data_.clear();} 45 | size_type size() {return data_.size();} 46 | iterator begin() {return data_.begin();} 47 | iterator end() {return data_.end();} 48 | const_iterator begin() const {return data_.begin();} 49 | const_iterator end() const {return data_.end();} 50 | void push_front(const T & item) {data_.push_front(item);} 51 | void pop_front() {data_.pop_front();} 52 | T & front() {return data_.front();} 53 | const T & front() const {return data_.front();} 54 | void swap(BasicList & other) {data_.swap(other.data_);} 55 | void sort() {data_.sort();} 56 | template void sort(Pred pr) {data_.sort(pr);} 57 | void splice_into (BasicList & other, iterator prev, iterator cur) 58 | { 59 | //++prev; 60 | //assert (prev == cur); 61 | data_.splice(data_.begin(),other.data_,cur); 62 | //data_.splice_after(data_.begin(), prev); 63 | } 64 | template 65 | void merge(BasicList & other, Pred pr) {data_.merge(other.data_, pr);} 66 | }; 67 | 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /myspell/munch.h: -------------------------------------------------------------------------------- 1 | /* munch header file */ 2 | 3 | #define MAX_LN_LEN 200 4 | #define MAX_WD_LEN 200 5 | #define MAX_PREFIXES 256 6 | #define MAX_SUFFIXES 256 7 | #define MAX_ROOTS 20 8 | #define MAX_WORDS 5000 9 | 10 | #define ROTATE_LEN 5 11 | 12 | #define ROTATE(v,q) \ 13 | (v) = ((v) << (q)) | (((v) >> (32 - q)) & ((1 << (q))-1)); 14 | 15 | #define SET_SIZE 256 16 | 17 | #define XPRODUCT (1 << 0) 18 | 19 | /* the affix table entry */ 20 | 21 | struct affent 22 | { 23 | char * appnd; 24 | char * strip; 25 | short appndl; 26 | short stripl; 27 | char achar; 28 | char xpflg; 29 | short numconds; 30 | char conds[SET_SIZE]; 31 | }; 32 | 33 | 34 | struct affixptr 35 | { 36 | struct affent * aep; 37 | int num; 38 | }; 39 | 40 | /* the prefix and suffix table */ 41 | int numpfx; /* Number of prefixes in table */ 42 | int numsfx; /* Number of suffixes in table */ 43 | 44 | /* the prefix table */ 45 | struct affixptr ptable[MAX_PREFIXES]; 46 | 47 | /* the suffix table */ 48 | struct affixptr stable[MAX_SUFFIXES]; 49 | 50 | 51 | /* data structure to store results of lookups */ 52 | struct matches 53 | { 54 | struct hentry * hashent; /* hash table entry */ 55 | struct affent * prefix; /* Prefix used, or NULL */ 56 | struct affent * suffix; /* Suffix used, or NULL */ 57 | }; 58 | 59 | int numroots; /* number of root words found */ 60 | struct matches roots[MAX_ROOTS]; /* list of root words found */ 61 | 62 | /* hashing stuff */ 63 | 64 | struct hentry 65 | { 66 | char * word; 67 | char * affstr; 68 | struct hentry * next; 69 | int keep; 70 | }; 71 | 72 | 73 | int tablesize; 74 | struct hentry * tableptr; 75 | 76 | /* unmunch stuff */ 77 | 78 | int numwords; /* number of words found */ 79 | struct dwords 80 | { 81 | char * word; 82 | int pallow; 83 | }; 84 | 85 | struct dwords wlist[MAX_WORDS]; /* list words found */ 86 | 87 | 88 | /* the routines */ 89 | 90 | void parse_aff_file(FILE* afflst); 91 | 92 | void encodeit(struct affent * ptr, char * cs); 93 | 94 | int load_tables(FILE * wrdlst); 95 | 96 | int hash(const char *); 97 | 98 | int add_word(char *); 99 | 100 | struct hentry * lookup(const char *); 101 | 102 | void aff_chk (const char * word, int len); 103 | 104 | void pfx_chk (const char * word, int len, struct affent* ep, int num); 105 | 106 | void suf_chk (const char * word, int len, struct affent * ep, int num, 107 | struct affent * pfxent, int cpflag); 108 | 109 | void add_affix_char(struct hentry * hent, char ac); 110 | 111 | int expand_rootword(const char *, int, const char*, int); 112 | 113 | void pfx_add (const char * word, int len, struct affent* ep, int num); 114 | 115 | void suf_add (const char * word, int len, struct affent * ep, int num); 116 | 117 | char * mystrsep(char ** stringp, const char delim); 118 | 119 | char * mystrdup(const char * s); 120 | 121 | void mychomp(char * s); 122 | --------------------------------------------------------------------------------