summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_parser.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2024-05-23 21:36:54 -0400
committerSolomon Peachy <pizza@shaftnet.org>2024-05-24 21:37:54 -0400
commit8b8c0c7c2ac40cd729a9eeb39189c184978b6d57 (patch)
tree09ab71d2b8f13ae47960d5508a5afd3ac135e588 /apps/gui/skin_engine/skin_parser.c
parentac20f8a73c9898ab66e176ab66f3ef89bb76692d (diff)
downloadrockbox-8b8c0c7c2ac40cd729a9eeb39189c184978b6d57.tar.gz
rockbox-8b8c0c7c2ac40cd729a9eeb39189c184978b6d57.zip
checkwps: Validate translated strings (%Sx)
In verbose mode it will log valid the strings found, otherwise it will only complain when we encounter a missing string. Unfortunately a missing string is not inherently a problem, due to conditional expressions. So all we can do is complain in checkwps or if wps debugging is turned on. Meanwhile, this is the first step in actually enumerating the translated strings used by themes. Change-Id: Ia93b333085e825d5b085c4d372ad8e13aa3e3ba1
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r--apps/gui/skin_engine/skin_parser.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index be25bd0125..867f2b6a18 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -44,6 +44,8 @@
44#else 44#else
45#include "action.h" 45#include "action.h"
46#include "checkwps.h" 46#include "checkwps.h"
47#include "language.h"
48#include "lang_enum.h"
47#include "audio.h" 49#include "audio.h"
48#define lang_is_rtl() (false) 50#define lang_is_rtl() (false)
49#define DEBUGF printf 51#define DEBUGF printf
@@ -804,22 +806,29 @@ static int parse_setting_and_lang(struct skin_element *element,
804 struct wps_token *token, 806 struct wps_token *token,
805 struct wps_data *wps_data) 807 struct wps_data *wps_data)
806{ 808{
807 /* NOTE: both the string validations that happen in here will
808 * automatically PASS on checkwps because its too hard to get
809 * settings_list.c and english.lang built for it.
810 * If that ever changes remove the #ifndef __PCTOOL__'s here
811 */
812 (void)wps_data; 809 (void)wps_data;
813 char *temp = get_param_text(element, 0); 810 char *temp = get_param_text(element, 0);
814 811
815 if (token->type == SKIN_TOKEN_TRANSLATEDSTRING) 812 if (token->type == SKIN_TOKEN_TRANSLATEDSTRING)
816 { 813 {
817#ifndef __PCTOOL__
818 int i = lang_english_to_id(temp); 814 int i = lang_english_to_id(temp);
819 if (i < 0) 815 if (i < 0) {
816 DEBUGF("Translated String [%s] NOT FOUND\n", temp);
817 /* Due to conditionals in a theme, a missing string
818 might never be hit. So currently we have to just treat
819 this as an advisory */
820#if 1
820 i = LANG_LAST_INDEX_IN_ARRAY; 821 i = LANG_LAST_INDEX_IN_ARRAY;
821 token->value.i = i; 822#else
823 return WPS_ERROR_INVALID_PARAM;
824#endif
825 }
826#ifdef DEBUG_SKIN_ENGINE
827 else if (debug_wps) {
828 DEBUGF("Translated String [%s] = %d\n", temp, i);
829 }
822#endif 830#endif
831 token->value.i = i;
823 } 832 }
824 else if (element->params_count > 1) 833 else if (element->params_count > 1)
825 { 834 {
@@ -830,11 +839,17 @@ static int parse_setting_and_lang(struct skin_element *element,
830 } 839 }
831 else 840 else
832 { 841 {
842 /* NOTE: The string validations that happen here will
843 * automatically PASS on checkwps because its too hard to get
844 * settings_list.c built for a specific target.
845 * If that ever changes remove the #ifndef __PCTOOL__ here
846 */
833#ifndef __PCTOOL__ 847#ifndef __PCTOOL__
834 const struct settings_list *setting = find_setting_by_cfgname(temp); 848 const struct settings_list *setting = find_setting_by_cfgname(temp);
835 if (!setting) 849 if (!setting) {
850 DEBUGF("Invalid setting [%s]\n", temp);
836 return WPS_ERROR_INVALID_PARAM; 851 return WPS_ERROR_INVALID_PARAM;
837 852 }
838 token->value.xdata = (void *)setting; 853 token->value.xdata = (void *)setting;
839#endif 854#endif
840 } 855 }