DogLooksGood / emacs-rime

RIME ㄓ in Emacs
GNU General Public License v3.0
478 stars 68 forks source link

Initialize first_run to ensure setup() is called #229

Closed jian-lin closed 9 months ago

DogLooksGood commented 9 months ago

Hey, @jian-lin, thanks for the contribution. Can you explain more about this?

jian-lin commented 9 months ago

From The GNU C Library Reference Manual of malloc1

The contents of the block (allocated by malloc) are undefined; you must initialize it yourself

If first_run is not initialized, its initial value can be false. As a result, rime->api->setup()2 will never be called. However, according to the comment3 of setup() in librime, it must be called before any other API is accessed.

The issue I observe is that logging of librime does not work well: if setup() is not called, there are no log files and there is a warning in the stderr as follows:

WARNING: Logging before InitGoogleLogging() is written to STDERR

DogLooksGood commented 9 months ago

Thanks for the explanation.