Commit Graph
76 Commits
Author SHA1 Message Date
Yury Popov 1e2404714d code cleanup: localize compiledict static objects 2022-11-15 00:07:45 +03:00
Juho Hiltunen 4a9f0e21be code cleanup: move Is*() helper functions to common.c 2022-09-17 18:57:20 +03:00
Juho Hiltunen 64f12fec87 code cleanup: move towlower2() 2022-09-17 17:22:01 +03:00
Juho Hiltunen b52d1f3afd code cleanup: move strncpy0 to common.c 2022-09-04 07:12:39 +03:00
Samuel Thibault f4133364d1 Add more const qualifiers 2022-06-11 16:20:19 +02:00
Samuel Thibault 24e1eaa0cc Mark static arrays undefined when they are reused
So valgrind can potentially catch e.g. missing \0.
2022-06-09 09:48:43 +02:00
Samuel Thibault a660fc04cc Add more const qualifiers on static arrays
So we know they are just tables, get protected from overflows, and get shared between processes
2022-06-09 08:43:50 +02:00
Samuel Thibault 15804e57a2 Constify tables
So they are protected from overflows, and shared between processes
2022-04-10 22:48:40 +02:00
Samuel Thibault c8de29dec9 Properly compare strings
Strictly speaking, we are not supposed to use memcmp to compare strings
since we are not supposed to read beyond \0, which memcmp is supposed to
potentially do. Sanitizers would warn about it, and using strncmp happens to
provide the proper semantic while being not really slower, so better
just use them.
2022-03-20 00:35:27 +01:00
Sergei Trofimovich ccb1c31ba3 compiledict.c: change 'temp' to "${dict}temp" temporary file
This way we can compile multiple dictionaries at a time without
stepping on 'temp' file from different compilation steps:

    $ make -j8 -B
    ...
    make[1]: *** [Makefile:3082: espeak-ng-data/an_dict] Segmentation fault (core dumped)
    make[1]: *** Deleting file 'espeak-ng-data/an_dict'
    make[1]: *** [Makefile:3082: espeak-ng-data/az_dict] Segmentation fault (core dumped)
    make[1]: *** Deleting file 'espeak-ng-data/az_dict'
2021-11-07 12:55:57 +00:00
Juho Hiltunen cffdfb837b code cleanup: move function declarations from speech.h to new file mnemonics.h
This adds a corresponding header file for mnemonics.c that was introduced in d5d93be.
2021-02-22 16:56:19 +02:00
Juho Hiltunen ee944700f8 code cleanup: Check all local includes with include-what-you-use
Going through files in src/libespeak-ng/, include-what-you-use removed a
few unnecessary includes and included explanations on why a certain
header should be included. This makes tracking globals and dependencies easier.

Running the codebase through IWYU should be repeated after each major
code restIncludes to standard c library weren't checked to avoid
breaking builds with other platforms.

See https://github.com/include-what-you-use/include-what-you-use
2020-07-24 07:29:47 +03:00
Reece H. Dunn 55c64036e0 Use UTF-8 strings in replace rules, instead of a packed UTF-16 pair. 2018-07-23 22:12:20 +01:00
Reece H. Dunn 424f705525 Revert the new (broken) replacement rule logic.
The replacement tests for bs, hr, and sr are no longer marked as
broken as they work using the old code. The mk tests keep the
broken annotation, as they don't work in the old code either.

This reverts commit 801a8d197c.
This reverts commit 64d5701e5e.
This reverts commit 3b51ebf617.
This reverts commit 1fd235d2c0.
This reverts commit 9f0667de86.
2018-07-23 19:38:46 +01:00
Valdis Vitolins 9f0667de86 Part of issue #199 — extend .replace rule to allow using groups of characters 2018-07-09 20:27:51 +03:00
Juho Hiltunen b23e8a7269 maintainability: pass Translator as to towlower2() instead of using a global 2018-03-25 12:40:57 +03:00
Juho Hiltunen 1bad240de8 maintainability: remove some unused variables and unnecessary extern declarations 2018-03-24 15:03:48 +02:00
Reece H. Dunn 87a2586bb0 Fix formatting of free_rules. 2018-03-22 07:19:26 +00:00
Reece H. Dunn a08d2c7bfb Ensure the allocated rules are properly cleaned up in compile_dictrules. 2018-03-21 20:58:55 +00:00
Juho Hiltunen e04ae259e0 headers: add new file compiledict.h with declarations of functions in compiledict.c 2018-03-10 12:51:24 +02:00
Juho Hiltunen 231a1d0944 headers: add new file dictionary.h with declarations of functions in dictionary.c 2018-03-10 12:47:02 +02:00
Juho Hiltunen 706df97b20 headers: add new file readclause.h with declarations of functions in readclause.c 2018-03-10 07:18:07 +02:00
Juho Hiltunen 738492100a make all headers (almost) self-contained by using include guards and #include statements within headers 2018-03-09 21:08:15 +02:00
Juho Hiltunen 78749f14f8 readability fix: use boolean instead of 0 and 1 for loop control 2018-02-17 18:17:00 +02:00
Reece H. Dunn 54e87adbb8 Move isspace2 from compiledict.c to translate.c. 2017-10-24 07:29:58 +01:00
Reece H. Dunn 7f42e0aaca compiledict.c: Fix -Wmissing-prototypes warnings. 2017-10-11 07:51:36 +01:00
Reece H. Dunn b8b0119b62 dictionary.c: Fix -Wmissing-prototypes warnings. 2017-10-11 07:46:17 +01:00
Reece H. Dunn 74f9f5e34b wavegen.c: Fix -Wmissing-prototypes warnings. 2017-10-10 21:37:46 +01:00
Reece H. Dunn ebfa320956 Fix storing the line length in the hash chain.
The length is stored as the first byte in the output from
compile_line. As the data pointer is char, if char is signed then
length could be negative resulting in undefined behaviour. This
commit fixes the issue by reading and writing that byte as a
uint8_t.

This bug was caused by 2a00ca79f6.
Previously, the entries could only be a maximum of 128 bytes, and
would not be negative on platforms with signed chars. That
commit was made to support long emoji entries, especially for
non-Latin languages where the utf-8 representations could be
longer than 128 bytes.

This change also adds some documentation to make it clearer what
is going on. NOTE: The code should really be using actual struct
objects instead of writing to opaque char buffers.

Reported by Reef Turner <reef@nvaccess.org>
2017-07-26 20:44:27 +01:00
Reece H. Dunn e7ac4b819d hash_counts is never used, so remove it.
Reported by Reef Turner <reef@nvaccess.org>
2017-07-26 20:21:05 +01:00
Reef Turner 0994206f71 address buffer overrun when dict listx file has no trailling newline
See ar_listx as an example.
2017-07-25 14:29:45 +08:00
Reece H. Dunn 2a00ca79f6 Increase dict_line to support long emoji entries. 2017-06-04 19:47:30 +01:00
Reece H. Dunn d5d980862e Guard against overflowing the dict_line bounds when compiling dictionary files. 2017-06-04 19:38:40 +01:00
Reece H. Dunn 8dde51ca87 Remove the now unused emoji_zwj specifier. 2017-05-25 07:23:21 +01:00
Reece H. Dunn 7e85b36b4d en: (emoji) -- Unicode Emoji 4.0 (Emoji Roles) 2017-05-18 07:16:05 +01:00
Reece H. Dunn dcc43bc30a Support _emoji dictionary lists for symbol and emoji pronunciations. 2017-05-14 11:05:43 +01:00
Reece H. Dunn 05cab4f2dc Extend compile_line to include pronunciation data after a space (e.g. multi-word pronunciation replacements). 2017-05-14 08:39:29 +01:00
Reece H. Dunn 94376c2d5f Use an enum and named values for the steps in compile_line to make the logic easier to read. 2017-05-11 19:40:43 +01:00
Reece H. Dunn 9af96da469 Make the encoding.h API public. 2017-05-02 18:40:16 +01:00
Reece H. Dunn 7c16ac543c Use the text decoder API in readclause.c. 2017-03-31 13:17:37 +01:00
Reece H. Dunn d5d93be00e Group the LookupMnem API implementations into mnemonics.c. 2017-03-27 21:08:07 +01:00
Reece H. Dunn 5975f07095 Replace the *2 wchar/wctype APIs with their standard versions. These will be fixed using compatibility headers. 2017-02-13 07:43:23 +00:00
Reece H. Dunn 71c010b712 Remove unused wchar.h and wctype.h includes. 2017-02-10 08:03:40 +00:00
Valdis Vitolins 92eae4f322 Updates for issue #103 Maximum group number which works is actually 62 2016-09-05 22:05:55 +03:00
Ondřej Lysoněk 3817ee1e16 Moved speak_lib.h to espeak-ng directory
Moved include/espeak/speak_lib.h to include/espeak-ng/speak_lib.h and
created a symlink from the original location.
2016-08-28 10:57:10 +01:00
Valdis Vitolins 252c894e59 Issue espeak-ng/espeak-ng#120
Allow to decrease the score in the rule by adding
2016-08-07 16:13:16 +03:00
Reece H. Dunn 5673065168 Fix a null pointer dereference in compile_rule(compiledict.c). [Coverity] 2016-01-22 20:22:24 +00:00
Reece H. Dunn 96c43f3eb2 Clean up the include files to make them consistent. 2016-01-16 17:54:39 +00:00
Reece H. Dunn 9c7179189b Add a stdint.h compatibility shim. 2016-01-09 13:09:50 +00:00
Reece H. Dunn aeb1639b2e Fix the error logic in espeak_ng_CompileDictionary(compiledict.c) [clang scan-build] 2016-01-06 22:41:57 +00:00