Hello!

It was reported[1] that the attr set subcommand doesn't always work as
desired and the following example was given:
attr set obj rgb 123/123/123

Since I didn't manage to find a situation where it completely ignores
the attribute given, I think that the report actually refers to the
following behavior concerning attribute aliases, which I find a bit
unintuitive:

mged> attr get sph1.r
los {100} material_id {1} region {R} region_id {1000}
mged> attr set sph1.r rgb 1/2/3
mged> attr get sph1.r rgb
Error: Object sph1.r does not have a rgb attribute

mged> attr get sph1.r
color {1/2/3} los {100} material_id {1} region {R} region_id {1000}
mged> attr set sph1.r rgb 4/5/6
mged> attr get sph1.r
color {1/2/3} los {100} material_id {1} region {R} region_id {1000} rgb {4/5/6}

That is, "rgb" was translated into "color" only the first time, then a
new custom attribute named "rgb" was created, although it is fairly
obvious that the user wanted to change the color to 4/5/6 the second
time.

The reason is simple: in src/libged/attr.c line 212, avs is
initialized to the original list of attributes, then (beginning from
line 299) the new attributes are added to it (those already existing
are overwritten, aliases are not translated), db5_standardize_avs()
then converts the aliases into the standard form only if they don't
already exist in the standard form (the others are completely
tolerated) and finally, db5_update_attributes() merges the list
created this way to the original list.

On the other hand, the attributes man page says: "Any code setting or
reading the value of one of these attributes must handle all aliases,
to ensure all functions asking for the value in question get a
consistent answer.", so I don't think that aliases should be ever kept
in attribute value sets without being transformed into the standard
form as soon as they are found (maybe in bu_avs_add()).

So my question is: is this the bug that was reported? And if yes,
should I only change ged_attr(), or I'd have to modify functions like
db5_standardize_avs() or bu_avs_add() (of course, testing all the side
effects) to make sure that attributes are never stored with an alias
name? Also, should I make other attr subcommands (get, rm, append and
show) recognize aliases too?

Cheers,
Stefan

[1] http://sourceforge.net/p/brlcad/code/HEAD/tree/brlcad/trunk/BUGS,
Ctrl+f "calling"

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to