From 722cc78e6f2105108225212a0960f1b928fa71f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 2 Jun 2012 19:08:29 +0200 Subject: eiotas_particle_split_dst: to keep actual stringshare, check length && strncmp --- src/lib/eiotas_particle.c | 4 ++-- tests/particle.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 00ad145..f29eeda 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -162,7 +162,7 @@ EAPI void eiotas_particle_split_dst(Eiotas_Particle *particle) n=(sep-dst); /* door defined */ if(particle->cur_room) { - if(strncmp(particle->cur_room,dst,n)!=0) { + if( eina_stringshare_strlen(particle->cur_room)!=n || strncmp(particle->cur_room,dst,n)!=0) { eina_stringshare_del(particle->cur_room); particle->cur_room = eina_stringshare_add_length(dst,n); } @@ -175,7 +175,7 @@ EAPI void eiotas_particle_split_dst(Eiotas_Particle *particle) } /* door defined */ if(particle->cur_door) { - if(strncmp(particle->cur_door,sep,n)!=0) { + if( eina_stringshare_strlen(particle->cur_door)!=n || strncmp(particle->cur_door,sep,n)!=0) { eina_stringshare_del(particle->cur_door); particle->cur_door = eina_stringshare_add_length(sep,n); } diff --git a/tests/particle.c b/tests/particle.c index 2ee4951..199df27 100644 --- a/tests/particle.c +++ b/tests/particle.c @@ -106,10 +106,10 @@ void test_particle() check_cond((p2->cur_action==NULL),"action must be NULL"); eiotas_particle_next_dst(p2); - eiotas_particle_destinations_add(p2,"door?get"); + eiotas_particle_destinations_add(p2,"doora?get"); eiotas_particle_split_dst(p2); check_str((char*)p2->cur_action,"get","action is wrong"); - check_str((char*)p2->cur_door,"door","door is wrong"); + check_str((char*)p2->cur_door,"doora","door is wrong"); check_cond((p2->cur_room==NULL),"room must be NULL"); eiotas_particle_next_dst(p2); @@ -127,10 +127,10 @@ void test_particle() check_str((char*)p2->cur_room,"room/room","room is wrong"); eiotas_particle_next_dst(p2); - eiotas_particle_destinations_add(p2,"room/room/door?get"); + eiotas_particle_destinations_add(p2,"room/room/doorb?get"); eiotas_particle_split_dst(p2); check_str((char*)p2->cur_action,"get","action is wrong"); - check_str((char*)p2->cur_door,"door","door is wrong"); + check_str((char*)p2->cur_door,"doorb","door is wrong"); check_str((char*)p2->cur_room,"room/room","room is wrong"); p3 = eiotas_require_particle(dom0); -- cgit v1.1-2-g2b99