diff options
author | Dave Chapman <dave@dchapman.com> | 2007-05-29 19:00:36 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-05-29 19:00:36 +0000 |
commit | f0d4fc6c6b146197c0fc51753d838252766aeda2 (patch) | |
tree | 14a80b9a30d14b63c50f3350f9c2cececdc1baef /apps/gui | |
parent | be0cbc940641264fe536ea1b3c1153f627367f55 (diff) | |
download | rockbox-f0d4fc6c6b146197c0fc51753d838252766aeda2.tar.gz rockbox-f0d4fc6c6b146197c0fc51753d838252766aeda2.zip |
Commit my patch from FS#7179 - a standalone command-line checkwps tool. To build, just type "make checkwps" in tools and run it with "checkwps wpsname.wps".
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13517 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps-common.c | 26 | ||||
-rw-r--r-- | apps/gui/wps_debug.c | 8 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 32 |
3 files changed, 38 insertions, 28 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index b25168f252..2cdb92d964 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -1969,29 +1969,3 @@ bool gui_wps_refresh(struct gui_wps *gwps, | |||
1969 | return true; | 1969 | return true; |
1970 | } | 1970 | } |
1971 | 1971 | ||
1972 | int wps_subline_index(struct wps_data *data, int line, int subline) | ||
1973 | { | ||
1974 | return data->lines[line].first_subline_idx + subline; | ||
1975 | } | ||
1976 | |||
1977 | int wps_first_token_index(struct wps_data *data, int line, int subline) | ||
1978 | { | ||
1979 | int first_subline_idx = data->lines[line].first_subline_idx; | ||
1980 | return data->sublines[first_subline_idx + subline].first_token_idx; | ||
1981 | } | ||
1982 | |||
1983 | int wps_last_token_index(struct wps_data *data, int line, int subline) | ||
1984 | { | ||
1985 | int first_subline_idx = data->lines[line].first_subline_idx; | ||
1986 | int idx = first_subline_idx + subline; | ||
1987 | if (idx < data->num_sublines - 1) | ||
1988 | { | ||
1989 | /* This subline ends where the next begins */ | ||
1990 | return data->sublines[idx+1].first_token_idx - 1; | ||
1991 | } | ||
1992 | else | ||
1993 | { | ||
1994 | /* The last subline goes to the end */ | ||
1995 | return data->num_tokens - 1; | ||
1996 | } | ||
1997 | } | ||
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index 8ba4b6f000..ae542785ae 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c | |||
@@ -22,13 +22,17 @@ | |||
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | #include <string.h> | 23 | #include <string.h> |
24 | #include "gwps.h" | 24 | #include "gwps.h" |
25 | #ifdef __PCTOOL__ | ||
26 | #define DEBUGF printf | ||
27 | #else | ||
25 | #include "debug.h" | 28 | #include "debug.h" |
29 | #endif | ||
26 | 30 | ||
27 | #define PARSE_FAIL_UNCLOSED_COND 1 | 31 | #define PARSE_FAIL_UNCLOSED_COND 1 |
28 | #define PARSE_FAIL_INVALID_CHAR 2 | 32 | #define PARSE_FAIL_INVALID_CHAR 2 |
29 | #define PARSE_FAIL_COND_SYNTAX_ERROR 3 | 33 | #define PARSE_FAIL_COND_SYNTAX_ERROR 3 |
30 | 34 | ||
31 | #ifdef SIMULATOR | 35 | #if defined(SIMULATOR) || defined(__PCTOOL__) |
32 | extern bool debug_wps; | 36 | extern bool debug_wps; |
33 | #endif | 37 | #endif |
34 | 38 | ||
@@ -467,7 +471,7 @@ static void print_img_cond_indexes(struct wps_data *data) | |||
467 | 471 | ||
468 | void print_debug_info(struct wps_data *data, int fail, int line) | 472 | void print_debug_info(struct wps_data *data, int fail, int line) |
469 | { | 473 | { |
470 | #ifdef SIMULATOR | 474 | #if defined(SIMULATOR) || defined(__PCTOOL__) |
471 | if (debug_wps) | 475 | if (debug_wps) |
472 | { | 476 | { |
473 | dump_wps_tokens(data); | 477 | dump_wps_tokens(data); |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index be0ef4e271..d363d6d8cb 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <string.h> | 24 | #include <string.h> |
25 | #include "atoi.h" | 25 | #include "atoi.h" |
26 | #include "gwps.h" | 26 | #include "gwps.h" |
27 | #ifndef __PCTOOL__ | ||
27 | #include "settings.h" | 28 | #include "settings.h" |
28 | #include "debug.h" | 29 | #include "debug.h" |
29 | #include "plugin.h" | 30 | #include "plugin.h" |
@@ -36,6 +37,8 @@ | |||
36 | #include "backdrop.h" | 37 | #include "backdrop.h" |
37 | #endif | 38 | #endif |
38 | 39 | ||
40 | #endif | ||
41 | |||
39 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" | 42 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" |
40 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" | 43 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" |
41 | 44 | ||
@@ -1008,6 +1011,7 @@ bool wps_data_load(struct wps_data *wps_data, | |||
1008 | * wants to be a virtual file. Feel free to modify dirbrowse() | 1011 | * wants to be a virtual file. Feel free to modify dirbrowse() |
1009 | * if you're feeling brave. | 1012 | * if you're feeling brave. |
1010 | */ | 1013 | */ |
1014 | #ifndef __PCTOOL__ | ||
1011 | if (! strcmp(buf, WPS_DEFAULTCFG) ) | 1015 | if (! strcmp(buf, WPS_DEFAULTCFG) ) |
1012 | { | 1016 | { |
1013 | global_settings.wps_file[0] = 0; | 1017 | global_settings.wps_file[0] = 0; |
@@ -1021,6 +1025,7 @@ bool wps_data_load(struct wps_data *wps_data, | |||
1021 | return false; | 1025 | return false; |
1022 | } | 1026 | } |
1023 | #endif | 1027 | #endif |
1028 | #endif /* __PCTOOL__ */ | ||
1024 | 1029 | ||
1025 | int fd = open(buf, O_RDONLY); | 1030 | int fd = open(buf, O_RDONLY); |
1026 | 1031 | ||
@@ -1080,3 +1085,30 @@ bool wps_data_load(struct wps_data *wps_data, | |||
1080 | return true; | 1085 | return true; |
1081 | } | 1086 | } |
1082 | } | 1087 | } |
1088 | |||
1089 | int wps_subline_index(struct wps_data *data, int line, int subline) | ||
1090 | { | ||
1091 | return data->lines[line].first_subline_idx + subline; | ||
1092 | } | ||
1093 | |||
1094 | int wps_first_token_index(struct wps_data *data, int line, int subline) | ||
1095 | { | ||
1096 | int first_subline_idx = data->lines[line].first_subline_idx; | ||
1097 | return data->sublines[first_subline_idx + subline].first_token_idx; | ||
1098 | } | ||
1099 | |||
1100 | int wps_last_token_index(struct wps_data *data, int line, int subline) | ||
1101 | { | ||
1102 | int first_subline_idx = data->lines[line].first_subline_idx; | ||
1103 | int idx = first_subline_idx + subline; | ||
1104 | if (idx < data->num_sublines - 1) | ||
1105 | { | ||
1106 | /* This subline ends where the next begins */ | ||
1107 | return data->sublines[idx+1].first_token_idx - 1; | ||
1108 | } | ||
1109 | else | ||
1110 | { | ||
1111 | /* The last subline goes to the end */ | ||
1112 | return data->num_tokens - 1; | ||
1113 | } | ||
1114 | } | ||