1
0
Fork 0
forked from len0rd/rockbox

fix FS#10674 - make skin debugger count the lines correctly so the line number in the output is actually useful!

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23825 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2009-12-03 05:36:23 +00:00
parent e83e2eceba
commit 58ca43dc9d

View file

@ -202,7 +202,7 @@ static const struct wps_tag all_tags[] = {
{ WPS_TOKEN_BATTERY_CHARGER_CONNECTED,"bp", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_BATTERY_CHARGER_CONNECTED,"bp", WPS_REFRESH_DYNAMIC, NULL },
#endif #endif
#ifdef HAVE_USB_POWER #ifdef HAVE_USB_POWER
{ WPS_TOKEN_USB_POWERED, "bu", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_USB_POWERED, "bu", WPS_REFRESH_DYNAMIC, NULL },
#endif #endif
{ WPS_TOKEN_RTC_PRESENT , "cc", WPS_REFRESH_STATIC, NULL }, { WPS_TOKEN_RTC_PRESENT , "cc", WPS_REFRESH_STATIC, NULL },
@ -447,8 +447,8 @@ static struct skin_token_list *new_skin_token_list_item(struct wps_token *token,
return NULL; return NULL;
llitem->next = NULL; llitem->next = NULL;
llitem->token = token; llitem->token = token;
if (token_data) if (token_data)
llitem->token->value.data = token_data; llitem->token->value.data = token_data;
return llitem; return llitem;
} }
@ -515,7 +515,6 @@ static bool skin_start_new_line(struct skin_viewport *vp, int curr_token)
curr_line = line; curr_line = line;
if (!vp->lines) if (!vp->lines)
vp->lines = line; vp->lines = line;
line_number++;
return true; return true;
} }
@ -582,7 +581,7 @@ static int parse_image_display(const char *wps_bufptr,
{ {
char label = wps_bufptr[0]; char label = wps_bufptr[0];
int subimage; int subimage;
struct gui_img *img;; struct gui_img *img;;
/* sanity check */ /* sanity check */
img = find_image(label, wps_data); img = find_image(label, wps_data);
@ -616,7 +615,7 @@ static int parse_image_load(const char *wps_bufptr,
const char* id; const char* id;
const char *newline; const char *newline;
int x,y; int x,y;
struct gui_img *img; struct gui_img *img;
/* format: %x|n|filename.bmp|x|y| /* format: %x|n|filename.bmp|x|y|
or %xl|n|filename.bmp|x|y| or %xl|n|filename.bmp|x|y|
@ -642,14 +641,14 @@ static int parse_image_load(const char *wps_bufptr,
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
} }
img = skin_buffer_alloc(sizeof(struct gui_img)); img = skin_buffer_alloc(sizeof(struct gui_img));
if (!img) if (!img)
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
/* save a pointer to the filename */ /* save a pointer to the filename */
img->bm.data = (char*)filename; img->bm.data = (char*)filename;
img->label = *id; img->label = *id;
img->x = x; img->x = x;
img->y = y; img->y = y;
img->num_subimages = 1; img->num_subimages = 1;
img->always_display = false; img->always_display = false;
/* save current viewport */ /* save current viewport */
@ -671,10 +670,10 @@ static int parse_image_load(const char *wps_bufptr,
if (img->num_subimages <= 0) if (img->num_subimages <= 0)
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
} }
struct skin_token_list *item = new_skin_token_list_item(NULL, img); struct skin_token_list *item = new_skin_token_list_item(NULL, img);
if (!item) if (!item)
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
add_to_ll_chain(&wps_data->images, item); add_to_ll_chain(&wps_data->images, item);
/* Skip the rest of the line */ /* Skip the rest of the line */
return skip_end_of_line(wps_bufptr); return skip_end_of_line(wps_bufptr);
@ -935,8 +934,8 @@ static int parse_progressbar(const char *wps_bufptr,
struct progressbar *pb = skin_buffer_alloc(sizeof(struct progressbar)); struct progressbar *pb = skin_buffer_alloc(sizeof(struct progressbar));
struct skin_token_list *item = new_skin_token_list_item(token, pb); struct skin_token_list *item = new_skin_token_list_item(token, pb);
if (!pb || !item) if (!pb || !item)
return WPS_ERROR_INVALID_PARAM; return WPS_ERROR_INVALID_PARAM;
struct viewport *vp = &curr_vp->vp; struct viewport *vp = &curr_vp->vp;
#ifndef __PCTOOL__ #ifndef __PCTOOL__
@ -954,7 +953,7 @@ static int parse_progressbar(const char *wps_bufptr,
line = line->next; line = line->next;
} }
pb->have_bitmap_pb = false; pb->have_bitmap_pb = false;
pb->bm.data = NULL; /* no bitmap specified */ pb->bm.data = NULL; /* no bitmap specified */
if (*wps_bufptr != '|') /* regular old style */ if (*wps_bufptr != '|') /* regular old style */
{ {
@ -1491,7 +1490,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
int ret; int ret;
int max_tokens = TOKEN_BLOCK_SIZE; int max_tokens = TOKEN_BLOCK_SIZE;
size_t buf_free = 0; size_t buf_free = 0;
line_number = 1; line_number = 0;
level = -1; level = -1;
/* allocate enough RAM for a reasonable skin, grow as needed. /* allocate enough RAM for a reasonable skin, grow as needed.
@ -1637,6 +1636,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
fail = PARSE_FAIL_LIMITS_EXCEEDED; fail = PARSE_FAIL_LIMITS_EXCEEDED;
break; break;
} }
line_number++;
break; break;
@ -1659,15 +1659,15 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
/* look if we already have that string */ /* look if we already have that string */
char *str; char *str;
bool found = false; bool found = false;
struct skin_token_list *list = data->strings; struct skin_token_list *list = data->strings;
while (list) while (list)
{ {
str = (char*)list->token->value.data; str = (char*)list->token->value.data;
found = (strlen(str) == len && found = (strlen(str) == len &&
strncmp(string_start, str, len) == 0); strncmp(string_start, str, len) == 0);
if (found) if (found)
break; /* break here because the list item is break; /* break here because the list item is
used if its found */ used if its found */
list = list->next; list = list->next;
} }
/* If a matching string is found, found is true and i is /* If a matching string is found, found is true and i is
@ -1676,21 +1676,21 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
if (!found) if (!found)
{ {
/* new string */ /* new string */
str = (char*)skin_buffer_alloc(len+1); str = (char*)skin_buffer_alloc(len+1);
if (!str) if (!str)
{ {
fail = PARSE_FAIL_LIMITS_EXCEEDED; fail = PARSE_FAIL_LIMITS_EXCEEDED;
break; break;
} }
strlcpy(str, string_start, len+1); strlcpy(str, string_start, len+1);
struct skin_token_list *item = struct skin_token_list *item =
new_skin_token_list_item(&data->tokens[data->num_tokens], str); new_skin_token_list_item(&data->tokens[data->num_tokens], str);
if(!item) if(!item)
{ {
fail = PARSE_FAIL_LIMITS_EXCEEDED; fail = PARSE_FAIL_LIMITS_EXCEEDED;
break; break;
} }
add_to_ll_chain(&data->strings, item); add_to_ll_chain(&data->strings, item);
} }
else else
{ {
@ -1775,13 +1775,13 @@ void skin_data_reset(struct wps_data *wps_data)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* bmpdir) static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* bmpdir)
{ {
(void)wps_data; /* only needed for remote targets */ (void)wps_data; /* only needed for remote targets */
bool loaded = false; bool loaded = false;
char img_path[MAX_PATH]; char img_path[MAX_PATH];
get_image_filename(bitmap->data, bmpdir, get_image_filename(bitmap->data, bmpdir,
img_path, sizeof(img_path)); img_path, sizeof(img_path));
/* load the image */ /* load the image */
int format; int format;
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
if (curr_screen == SCREEN_REMOTE) if (curr_screen == SCREEN_REMOTE)
@ -1790,22 +1790,22 @@ static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char
#endif #endif
format = FORMAT_ANY|FORMAT_TRANSPARENT; format = FORMAT_ANY|FORMAT_TRANSPARENT;
size_t max_buf; size_t max_buf;
char* imgbuf = (char*)skin_buffer_grab(&max_buf); char* imgbuf = (char*)skin_buffer_grab(&max_buf);
bitmap->data = imgbuf; bitmap->data = imgbuf;
int ret = read_bmp_file(img_path, bitmap, max_buf, format, NULL); int ret = read_bmp_file(img_path, bitmap, max_buf, format, NULL);
if (ret > 0) if (ret > 0)
{ {
skin_buffer_increment(ret, true); skin_buffer_increment(ret, true);
loaded = true; loaded = true;
} }
else else
{ {
/* Abort if we can't load an image */ /* Abort if we can't load an image */
loaded = false; loaded = false;
} }
return loaded; return loaded;
} }
static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
@ -1820,20 +1820,20 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
{ {
pb->have_bitmap_pb = load_skin_bmp(wps_data, &pb->bm, bmpdir); pb->have_bitmap_pb = load_skin_bmp(wps_data, &pb->bm, bmpdir);
} }
list = list->next; list = list->next;
} }
/* regular images */ /* regular images */
list = wps_data->images; list = wps_data->images;
while (list) while (list)
{ {
struct gui_img *img = (struct gui_img*)list->token->value.data; struct gui_img *img = (struct gui_img*)list->token->value.data;
if (img->bm.data) if (img->bm.data)
{ {
img->loaded = load_skin_bmp(wps_data, &img->bm, bmpdir); img->loaded = load_skin_bmp(wps_data, &img->bm, bmpdir);
if (img->loaded) if (img->loaded)
img->subimage_height = img->bm.height / img->num_subimages; img->subimage_height = img->bm.height / img->num_subimages;
} }
list = list->next; list = list->next;
} }
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))