Branch: Tag:

2009-02-16

2009-02-16 16:43:09 by 0

The sub-tag parsing in PrefLanguages could produce duplicate languages. The
half-baked support for sub-tags was not used so it's now gone in favor of a
more predictable handling of languages.

Rev: server/base_server/prototypes.pike:1.230

5:   #include <config.h>   #include <module.h>   #include <module_constants.h> - constant cvs_version="$Id: prototypes.pike,v 1.229 2009/01/22 09:03:25 mast Exp $"; + constant cvs_version="$Id: prototypes.pike,v 1.230 2009/02/16 16:43:09 jonasw Exp $";      #ifdef DAV_DEBUG   #define DAV_WERROR(X...) werror(X)
615:   {    int decoded=0;    int sorted=0; -  array(string) subtags=({}); +  // array(string) subtags=({});    array(string) languages=({});    array(float) qualities=({});   
659:    void sort_lang() {    if(sorted && decoded) return;    array(float) q; -  array(string) s=reverse(languages)-({""}), u=({}); +  array(string) s=reverse(languages)-({""}) /*, u=({})*/;       if(!decoded) {    q=({});
671:    sscanf(x, "%s-%s", x, sub);    if(x == "" ) return "";    q+=({n}); -  u+=({sub}); +  // u+=({sub});    return x;    });    s-=({""});
680:    else    q=reverse(qualities);    -  sort(q,s,u); +  sort(q, s /*, u */);    languages=reverse(s);    qualities=reverse(q); -  subtags=reverse(u); +  // subtags=reverse(u); +  +  // Remove duplicate entries caused by varying subtags +  multiset(string) known_langs = (< >); +  for (int i = 0; i < sizeof(languages); i++) { +  string l = languages[i]; +  if (known_langs[l]) { +  languages[i] = 0; +  qualities[i] = 0; +  } else { +  known_langs[l] = 1; +  } +  } +  languages -= ({ 0 }); +  qualities -= ({ 0 }); +     sorted=1;    }   }