--- capa/capa51/pProj/capaUnit.c 1999/09/28 21:26:21 1.1 +++ capa/capa51/pProj/capaUnit.c 2000/02/09 22:10:24 1.2 @@ -856,7 +856,7 @@ u_copy_unit(Unit_t *a_p, Unit_t *b_p, do a_p->u_scale = a_p->u_scale * scale; /* printf("Found scale=%g=%g\n",a_p->u_scale,b_p->u_scale); */ } else { - if( b_p->u_type == U_BASE || b_p->u_type == U_DERIVED) { + if( b_p->u_type == U_BASE ) { /* *b_p is a base unit, so create a one element unit */ ne_p = (Unit_E *) capa_malloc(1, sizeof(Unit_E)); /* *** */ ne_p->ue_scale = b_p->u_scale; @@ -870,6 +870,9 @@ u_copy_unit(Unit_t *a_p, Unit_t *b_p, do } last_p = ne_p; a_p->u_count++; + } else if( b_p->u_type == U_DERIVED) { + /* derived units but without any units elements (scalar) */ + /* do nothing, ignore this units */ } else if( b_p->u_type == U_CONSTANT ) { scale = pow(b_p->u_scale, exp_scale); a_p->u_scale = a_p->u_scale * scale; @@ -1363,9 +1366,10 @@ u_insert_derived(n_p,s_p,c_p,u_p)char * strcpy(new_p->u_comment,c_p); simplify_unit(new_p); - - /* print_unit_t(new_p); */ - + /* + printf("Derived Unit:%s\n",new_p->u_name); + print_unit_t(new_p); + */ if (c_result < 0 ) { new_p->u_left = t->u_left; new_p->u_right = t; t->u_left = NULL; @@ -1411,6 +1415,10 @@ simplify_unit(u_p) Unit_t *u_p; CScale[ii] = 0.0; CExp[ii] = 0.0; } + /* + printf("Before Simplify:: \n"); + print_unit_t(u_p); + */ if( u_p->u_count > 0 ) { for(eu_p=u_p->u_list; eu_p; eu_p = eu_p->ue_nextp) { @@ -1422,11 +1430,14 @@ simplify_unit(u_p) Unit_t *u_p; CScale[idx] = CScale[idx] * eu_p->ue_scale; CExp[idx] = CExp[idx] + eu_p->ue_exp; } - /* + /* debugging for(ii=0;iiu_list); @@ -1448,10 +1459,11 @@ simplify_unit(u_p) Unit_t *u_p; u_p->u_count++; } } - - } - + /* + printf("After Simplify:: \n"); + print_unit_t(u_p); + */ } /* before comparing two units, make sure they are of basic form */