[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UDUNITS #BUK-910616]: ut_get_name() returning NULL?



David,

Would you please move the "<symbol>lb</symbol>" out of the "aliases" section to 
just after the "<name>pound</name>" entry and re-run your test. I'd like to 
verify its effect on the ut_get_symbol() calls.

> OK, the XML file now looks like:
> 
> <unit>
> <def>4.5359237e-1 kg</def>
> <name> <singular>pound</singular> </name>
> <aliases>
> <name> <singular>avoirdupois_pound</singular> </name>
> <symbol>lb</symbol>
> </aliases>
> <definition>unit of mass in avoirdupois system of weights
> (a system commonly used in United States)</definition>
> </unit>
> 
> The code is unchanged:
> 
> theUnitsSystem = ut_read_xml( NULL );
> unit1 = ut_get_unit_by_name( theUnitsSystem, "kilograms" );
> if( !unit1 ) {
> printf( "***** ut_get_unit_by_name for \"kilograms\" returned
> NULL\n" );
> } else {
> printf( "ut_get_unit_by_name( \"kilograms\" ) returned
> \"%s\"\n", ut_get_name( unit1, UT_ASCII ) );
> }
> unit2 = ut_get_unit_by_name( theUnitsSystem, "pound" );
> if( !unit2 ) {
> printf( "***** ut_get_unit_by_name for \"pound\" returned
> NULL\n" );
> } else {
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"
> (ASCII)\n", ut_get_name( unit2, UT_ASCII ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"
> (LATIN1)\n", ut_get_name( unit2, UT_LATIN1 ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"
> (UTF8)\n", ut_get_name( unit2, UT_UTF8 ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"\n",
> ut_get_symbol( unit2, UT_ASCII ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"\n",
> ut_get_symbol( unit2, UT_LATIN1 ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"\n",
> ut_get_symbol( unit2, UT_UTF8 ) );
> }
> 
> And the output is:
> 
> ut_get_unit_by_name( "kilograms" ) returned "kilogram"
> ut_get_unit_by_name( "pound" ) returned "pound" (ASCII)
> ut_get_unit_by_name( "pound" ) returned "pound" (LATIN1)
> ut_get_unit_by_name( "pound" ) returned "pound" (UTF8)
> ut_get_unit_by_name( "pound" ) returned "(null)"
> ut_get_unit_by_name( "pound" ) returned "(null)"
> ut_get_unit_by_name( "pound" ) returned "(null)"
> 
> So it seems to work, as long as it does not break any of the assumptions
> you built in that are not apparent in this test. I did run the 'make
> check' and did not get any errors. I am not doing any parsing or sorts
> of units arithmetic or manipulations so I am not sure if it is that
> simple but it would be nice.
> 
> David

Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: BUK-910616
Department: Support UDUNITS
Priority: Normal
Status: Closed