From 814f23ccf47e45aa99f50e9027235170da305a61 Mon Sep 17 00:00:00 2001 From: Per Hedbor <ph@opera.com> Date: Tue, 6 Apr 1999 09:37:13 +0200 Subject: [PATCH] Even better color space search support. Now it starts to search in _worse_ colorspaces than the one requested if there is no color for the wanted colorspace. Rev: lib/modules/_Image_XPM.pmod:1.3 --- lib/modules/_Image_XPM.pmod | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/modules/_Image_XPM.pmod b/lib/modules/_Image_XPM.pmod index 4c47c764cb..b800de8880 100644 --- a/lib/modules/_Image_XPM.pmod +++ b/lib/modules/_Image_XPM.pmod @@ -4,13 +4,31 @@ static mapping parse_color( array color ) for(int i=0; i<sizeof(color); i+=2 ) if(lower_case(color[i+1]) != "none") res[color[i]] = Colors.parse_color( color[i+1] ); - return res; + return sizeof(res)?res:0; } static array find_color( mapping in, string space ) { - return in && (in[space||"s"] || in->c || in->g || in->g4 || in->m); -} + if(!in) return 0; + switch(space) + { + default: + case "s": + if(in->s) return in->s; + case "c": + if(in->c) return in->c; + case "g": + if(in->g) return in->g; + case "g4": + if(in->g4) return in->g4; + case "m": + if(in->m) return in->m; + if(in->s) return in->s; + } + if(sizeof(in)) + return values(in)[0]; + return 0; +} mapping _decode( string what, void|mapping opts ) { -- GitLab