link-grammar icon indicating copy to clipboard operation
link-grammar copied to clipboard

Fix duplicate word detection

Open ampli opened this issue 3 years ago • 0 comments

dup_word_error() uses a static variable as a cache, which is of course wrong. I fixed it by caching in Dictionary_s. (In a branch in which I restored the ram dict of 4.0.dict, this enabled me to allow duplicate words w/o a #define.)

I also fixed dup_word_error() to again use dict_error2(), which prints the location of the duplicates in the dict file. For a dynamic dict, it uses the storage-node as the dict name in the message (I initialized it in lookup-atomese.cc).

Because the rewritten dup_word_error() may now call the function contains_underbar() more than once (with the same argument), I defined ontains_underbar() as "pure" (and in the same occasion also is_idiom_word()). I used ATTR_PURE for that (instead of GNUC_PURE) and later I will replace all the rest of GNUC_ with ATTR_ and add MSVC definitions.

ampli avatar Aug 09 '22 20:08 ampli