--- capa/capa51/pProj/capaUnit.c 1999/09/28 21:26:21 1.1 +++ capa/capa51/pProj/capaUnit.c 2000/02/22 18:19:02 1.3 @@ -730,7 +730,11 @@ int check_correct_unit(char *u_symb,Uni if ((ufp=fopen("unit.DBUG","a"))==NULL) { fprintf(stderr,"Error: can't open login debug\n"); return; } #endif - while( isspace(*u_symb) ) u_symb++; + while( isspace(*u_symb) ) u_symb++; + /* <= change this to search from the end of string */ + /* or to get rid of all the white spaces */ + + ap = parse_unit_expr(u_symb); Ptopidx=0; postwalk_utree(ap); @@ -856,7 +860,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 +874,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 +1370,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 +1419,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 +1434,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 +1463,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 */