Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unoptimized compile of yml translation files may create zero size arrays #75

Closed
vortex-surfer opened this issue Jan 10, 2025 · 1 comment · Fixed by #76
Closed

Unoptimized compile of yml translation files may create zero size arrays #75

vortex-surfer opened this issue Jan 10, 2025 · 1 comment · Fixed by #76

Comments

@vortex-surfer
Copy link
Contributor

When compiling yml translation files that do not contain any plural strings

en-GB:
  s_en_only: english only
  s_translated: s translated
  s_untranslated: ~
ru-RU:
  s_en_only: ~
  s_translated: s переведено
  s_untranslated: ~

to lv_i18n.c/h file without optimization enabled, the created source file accomodates zero size arrays that cannot be compiled with the compiler option -Wpedantic enabled:

...
#ifndef LV_I18N_OPTIMIZE

static const char * singular_idx[] = {
"This is a new text",
"s_en_only",
"s_translated",
"s_untranslated",

};

static const char * plural_idx[] = {

};

#endif
...

The patch below adds a null pointer to the array when the translation memory does not contain any strings:
0001-Avoid-zero-size-array-creation.patch

...
#ifndef LV_I18N_OPTIMIZE

static const char * singular_idx[] = {
    "This is a new text",
    "s_en_only",
    "s_translated",
    "s_untranslated",

};

static const char * plural_idx[] = {
    NULL,
};

#endif
...
@kisvegabor
Copy link
Member

Hi,

Thank you reporting it. Could you open a PR with the proposed fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants