- ls=&wanted_locales[i];
-
- extract_token(&buf[0],search, i,',',16);
- /** we are searching, if this list item has something like ;q=n*/
- if (num_tokens(&buf[0],'=')>1) {
- int sbuflen, k;
- extract_token(&sbuf[0],&buf[0], 1,'=',16);
- sbuflen=strlen(&sbuf[0]);
- for (k=0; k<sbuflen; k++) if (sbuf[k]=='.') sbuf[k]='0';
- ls->priority=atol(&sbuf[0]);
- }
- else {
- ls->priority=1000;
- }
- /** get the locale part */
- extract_token(&sbuf[0],&buf[0],0,';',16);
- /** get the lang part, which should be allways there */
- extract_token(&ls->lang[0],&sbuf[0],0,'-',16);
- /** get the area code if any. */
- if (num_tokens(&sbuf[0],'-')>1) {
- extract_token(&ls->region[0],&sbuf[0],1,'-',16);
- }
- else { /** no ara code? use lang code */
- blen=strlen(&ls->lang[0]);
- memcpy(&ls->region[0], ls->lang,blen);
- ls->region[blen]='\0';
- } /** area codes are uppercase */
- blen=strlen(&ls->region[0]);
- for (j=0; j<blen; j++)
- {
- int chars=toupper(ls->region[j]);
- ls->region[j]=(char)chars;/** \todo ?! */
- }
- sprintf(&lbuf[0],"%s_%s",&ls->lang[0],&ls->region[0]);
+ if (Buf == NULL) {
+ Buf = NewStrBuf();
+ SBuf = NewStrBuf();
+ }
+ else {
+ FlushStrBuf(Buf);
+ FlushStrBuf(SBuf);
+ }
+
+ ls = &wanted_locales[i];
+
+ StrBufExtract_token(Buf, LocaleString, i, ',');
+ /** we are searching, if this list item has something like ;q=n*/
+ if (StrBufNum_tokens(Buf, '=') > 1) {
+ int sbuflen, k;
+ StrBufExtract_token(SBuf, Buf, 1, '=');
+ sbuflen = StrLength(SBuf);
+ for (k = 0; k < sbuflen; k++)
+ if (ChrPtr(SBuf)[k] == '.')
+ StrBufPeek(SBuf, NULL, k, '0');
+ ls->priority = StrTol(SBuf);
+ }
+ else {
+ ls->priority = 1000;
+ }
+
+ /** get the locale part */
+ StrBufExtract_token(SBuf, Buf, 0, ';');
+
+ /** get the lang part, which should be allways there */
+ extract_token(&ls->lang[0],
+ ChrPtr(SBuf),
+ 0, '-',
+ sizeof(ls->lang));
+
+ /** get the area code if any. */
+ if (StrBufNum_tokens(SBuf, '-') > 1) {
+ extract_token(&ls->region[0],
+ ChrPtr(SBuf),
+ 1, '-',
+ sizeof(ls->region));
+ }
+ else { /** no ara code? use lang code */
+ blen=strlen(&ls->lang[0]);
+ memcpy(&ls->region[0], ls->lang, blen);
+ ls->region[blen] = '\0';
+ }
+
+ /* area codes are uppercase */
+ blen = strlen(&ls->region[0]);
+ for (j = 0; j < blen; j++)
+ {
+ int chars;
+ chars = toupper(ls->region[j]);
+ ls->region[j] = (char)chars;/** \todo ?! */
+ }
+ snprintf(&lbuf[0],
+ sizeof(lbuf),
+ "%s_%s",
+ &ls->lang[0],
+ &ls->region[0]);