mr->b.p=mr->file->begin+0x2000;
else
mr->b.p=mr->b.block_start+mr->b.b->blocks*512;
- if (mr->b.p >= mr->file->end)
+ if (mr->b.p >= mr->file->end) {
+ dbg(1,"end of blocks %p vs %p\n", mr->b.p, mr->file->end);
return 0;
+ }
mr->b.block_start=mr->b.p;
mr->b.b=block_get(&mr->b.p);
mr->b.p_start=mr->b.p;
mr->b.end=mr->b.block_start+mr->b.b->size;
- if (mr->b.b->count == -1)
+ if (mr->b.b->count == -1) {
+ dbg(1,"empty blocks\n");
return 0;
+ }
if (!mr->cur_sel || coord_rect_overlap(&mr->cur_sel->rect, &mr->b.b->r)) {
block_active_count++;
block_active_mem+=mr->b.b->blocks*512-sizeof(struct block *);
+ dbg(1,"block ok\n");
return 1;
}
+ dbg(2,"block not in cur_sel\n");
}
}
if (item->type != type_country_label)
return NULL;
tree_search_init(map->dirname, "town.b2", &mr->ts, 0x1000);
+ mr->current_file=file_town_twn;
break;
case attr_street_name:
if (item->type != type_town_streets)
return NULL;
dbg(1,"street_assoc=0x%x\n", item->id_lo);
tree_search_init(map->dirname, "strname.b1", &mr->ts, 0);
+ mr->current_file=file_strname_stn;
break;
default:
dbg(0,"unknown search\n");
mr->search_country=item->id_lo;
mr->search_str=search->u.str;
mr->search_partial=partial;
- mr->current_file=file_town_twn-1;
- file_next(mr);
+ mr->file=mr->m->file[mr->current_file];
+ block_init(mr);
return (struct map_search_priv *)mr;
}
struct street_name_numbers snns;
unsigned char *p=mr->street.name.aux_data;
- dbg(0,"aux_data=%p\n", p);
+ dbg(1,"aux_data=%p\n", p);
if (count) {
street_name_numbers_get(&snns, &p);
*c=*(snns.c);
while ((leaf=tree_search_next(&mr->ts, &mr->search_p, dir)) != -1) {
dir=street_search_compare(&mr->search_p, mr);
}
+ dbg(1,"dir=%d mr->search_block=0x%x\n", dir, mr->search_block);
if (mr->search_block == -1)
return NULL;
- dbg(1,"mr->search_block=0x%x\n", mr->search_block);
+ if (dir > 0)
+ mr->search_block++;
mr->search_blk_count=1;
block_get_byindex(mr->m->file[file_strname_stn], mr->search_block, &mr->b);
mr->b.p=mr->b.block_start+12;
dbg(1,"name id 0x%x\n", mr->b.p-mr->m->file[file_strname_stn]->begin);
if (! mr->search_blk_count)
return NULL;
- if (mr->b.p >= mr->b.end) {
- if (!block_next_lin(mr))
- return NULL;
- mr->b.p=mr->b.block_start+12;
- }
- while (mr->b.p < mr->b.end) {
- last=mr->b.p;
- street_name_get(&mr->street.name, &mr->b.p);
- dir=street_search_compare_do(mr, mr->street.name.country, mr->street.name.townassoc, mr->street.name.name2);
- dbg(1,"country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d\n", mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir);
- if (dir < 0) {
- mr->search_blk_count=0;
- return NULL;
+ for (;;) {
+ if (mr->b.p >= mr->b.end) {
+ if (!block_next_lin(mr)) {
+ dbg(1,"end of blocks in %p, %p\n", mr->m->file[file_strname_stn]->begin, mr->m->file[file_strname_stn]->end);
+ return NULL;
+ }
+ mr->b.p=mr->b.block_start+12;
}
- if (!dir) {
- dbg(0,"result country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d aux_data=%p len=0x%x\n", mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir, mr->street.name.aux_data, mr->street.name.aux_len);
- mr->item.type = type_street_name;
- mr->item.id_hi=mr->street.name.country | (mr->current_file << 16) | 0x10000000;
- mr->item.id_lo=last-mr->m->file[mr->current_file]->begin;
- mr->item.meth=&street_name_meth;
- mr->item.map=NULL;
- mr->item.priv_data=mr;
- return &mr->item;
+ while (mr->b.p < mr->b.end) {
+ last=mr->b.p;
+ street_name_get(&mr->street.name, &mr->b.p);
+ dir=street_search_compare_do(mr, mr->street.name.country, mr->street.name.townassoc, mr->street.name.name2);
+ dbg(1,"country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d\n", mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir);
+ if (dir < 0) {
+ dbg(1,"end of data\n");
+ mr->search_blk_count=0;
+ return NULL;
+ }
+ if (!dir) {
+ dbg(1,"result country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d aux_data=%p len=0x%x\n", mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir, mr->street.name.aux_data, mr->street.name.aux_len);
+ mr->item.type = type_street_name;
+ mr->item.id_hi=mr->street.name.country | (mr->current_file << 16) | 0x10000000;
+ mr->item.id_lo=last-mr->m->file[mr->current_file]->begin;
+ mr->item.meth=&street_name_meth;
+ mr->item.map=NULL;
+ mr->item.priv_data=mr;
+ return &mr->item;
+ }
}
}
- return NULL;
}
if (search_attr->type >= attr_country_all && search_attr->type <= attr_country_name)
this->priv=country_search_new(&this->search_attr, partial);
else {
- if (m->meth.map_search_new)
- this->priv=m->meth.map_search_new(m->priv, item, search_attr, partial);
- else {
+ if (m->meth.map_search_new) {
+ if (m->meth.charset)
+ this->search_attr.u.str=g_convert(this->search_attr.u.str, -1,m->meth.charset,"utf-8",NULL,NULL,NULL);
+ this->priv=m->meth.map_search_new(m->priv, item, &this->search_attr, partial);
+ } else {
g_free(this);
this=NULL;
}
return;
if (this->search_attr.type >= attr_country_all && this->search_attr.type <= attr_country_name)
country_search_destroy(this->priv);
- else
+ else {
+ if (this->m->meth.charset)
+ g_free(this->search_attr.u.str);
this->m->meth.map_search_destroy(this->priv);
+ }
g_free(this);
}