/[zanavi_public1]/navit/navit/country.c
ZANavi

Diff of /navit/navit/country.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 30 Revision 31
367 ret->item.priv_data=ret; 367 ret->item.priv_data=ret;
368 368
369 return ret; 369 return ret;
370} 370}
371 371
372char* str_tolower(char *name)
373{
374 int i;
375 char *str;
376 str = g_strdup(name);
377 for(i = 0; str[i]; i++)
378 {
379 str[i] = tolower(str[i]);
380 }
381 return str;
382}
372 383
373static int 384static int
374match(struct country_search *this_, enum attr_type type, const char *name) 385match(struct country_search *this_, enum attr_type type, const char *name)
375{ 386{
376 int ret; 387 int ret;
377 char *s1 = NULL; 388 char *s1 = NULL;
378 char *s2 = NULL; 389 char *s2 = NULL;
390
379 if (!name) 391 if (!name)
380 return 0; 392 return 0;
393
394 if (!this_->search.u.str)
395 {
396 return 0;
397 }
398
381 if (this_->search.type != type && this_->search.type != attr_country_all) 399 if (this_->search.type != type && this_->search.type != attr_country_all)
382 return 0; 400 return 0;
401
402
403 //fprintf(stderr, "1 name=%s str=%s\n", name, this_->search.u.str);
404
383 s1=linguistics_casefold(this_->search.u.str); 405 //s1=linguistics_casefold(this_->search.u.str);
406 s1=str_tolower(this_->search.u.str);
407
408 //fprintf(stderr, "2 name=%s str=%s\n", name, this_->search.u.str);
409 //fprintf(stderr, "3 s1=%s\n", s1);
410
384 s2=linguistics_casefold(name); 411 //s2=linguistics_casefold(name);
412 s2=str_tolower(name);
413
414 //fprintf(stderr, "4 name=%s str=%s\n", name, this_->search.u.str);
415 //fprintf(stderr, "5 s2=%s\n", s2);
416
417 //if ((s1 == NULL)||(s2 == NULL))
418 //{
419 // // ok i give up, i cant find the damn bug. so here is a stupid!! stupid!! workaround
420 // fprintf(stderr, "2 name=%s str=%s\n", name, this_->search.u.str);
421 // fprintf(stderr, "3 s1=%s\n", s1);
422 // fprintf(stderr, "5 s2=%s\n", s2);
423 // return 0;
424 //}
425 //else
426 //{
385 ret=linguistics_compare(s2,s1,this_->partial)==0; 427 ret=linguistics_compare(s2,s1,this_->partial)==0;
428 //}
429 //fprintf(stderr, "6 s1=%s\n", s1);
430 //fprintf(stderr, "7 s2=%s\n", s2);
431
432 if (s1)
433 {
386 g_free(s1); 434 g_free(s1);
435 }
436
437 if (s2)
438 {
387 g_free(s2); 439 g_free(s2);
440 }
441
388 return ret; 442 return ret;
389} 443}
390 444
391 445
392struct item * 446struct item *

Legend:
Removed from v.30  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki