(file) Return to LanguageParser.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/LanguageParser.cpp between version 1.3 and 1.11

version 1.3, 2003/08/22 14:56:48 version 1.11, 2005/02/05 22:59:23
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 83 
Line 89 
         if(i != PEG_NOT_FOUND){ // extract and store language and quality         if(i != PEG_NOT_FOUND){ // extract and store language and quality
                 if(isValid(hdr.subString(0,i), validate_length)){                 if(isValid(hdr.subString(0,i), validate_length)){
                         language_tag = hdr.subString(0,i);                         language_tag = hdr.subString(0,i);
                           if(hdr.size() > i + 3)
                         hdr.remove(0,i+3);  // remove everything but the quality value                         hdr.remove(0,i+3);  // remove everything but the quality value
                           else{
                                   MessageLoaderParms parms("Common.LanguageParser.INVALID_QUALITY_VALUE",
                                                                            "AcceptLanguage contains an invalid quality value");
                                   throw InvalidAcceptLanguageHeader(MessageLoader::getMessage(parms));
                           }
                 }                 }
                 else{                 else{
                         //l10n                         //l10n
Line 205 
Line 217 
         Array<String> subtags;         Array<String> subtags;
         parseLanguageSubtags(subtags, language_tag);         parseLanguageSubtags(subtags, language_tag);
         if(subtags.size() > 0){         if(subtags.size() > 0){
                 for(int i = 0; i < subtags.size(); i++){                  for(Uint32 i = 0; i < subtags.size(); i++){
                         //length should be 8 or less AND all characters should be A-Z or a-z                         //length should be 8 or less AND all characters should be A-Z or a-z
                         if((validate_length && subtags[i].size() > 8) || !checkAlpha(subtags[i].getCString()))                         if((validate_length && subtags[i].size() > 8) || !checkAlpha(subtags[i].getCString()))
                                 return false;                                 return false;
Line 219 
Line 231 
  
 String LanguageParser::convertPrivateLanguageTag(String language_tag){ String LanguageParser::convertPrivateLanguageTag(String language_tag){
         // figure out if its a unix style locale or windows locale         // figure out if its a unix style locale or windows locale
         int i;          Uint32 i;
         if(( i = language_tag.find("pegasus-")) != PEG_NOT_FOUND ){         if(( i = language_tag.find("pegasus-")) != PEG_NOT_FOUND ){
                 language_tag = language_tag.subString(i+5);  // capture the remainder of the string                 language_tag = language_tag.subString(i+5);  // capture the remainder of the string
                 return String(replaceSeparator(language_tag.getCString(), '-'));                 return String(replaceSeparator(language_tag.getCString(), '-'));
Line 234 
Line 246 
 } }
  
 Boolean LanguageParser::checkAlpha(CString _str){ Boolean LanguageParser::checkAlpha(CString _str){
         for(int i = 0; i < strlen(_str); i++)          Uint32 length = (Uint32) strlen(_str);
           for(Uint32 i = 0; i < length; i++)
                 if( !isalpha(_str[i]) )                 if( !isalpha(_str[i]) )
                         return false;                         return false;
         return true;         return true;
 } }
  
 char LanguageParser::findSeparator(CString _str){ char LanguageParser::findSeparator(CString _str){
         for(int i = 0; i < strlen(_str); i++)          Uint32 length = (Uint32) strlen(_str);
           for(Uint32 i = 0; i < length; i++)
                 if(!isalnum(_str[i]))                 if(!isalnum(_str[i]))
                         return _str[i];                         return _str[i];
         return '\0';         return '\0';
Line 249 
Line 263 
  
 CString LanguageParser::replaceSeparator(CString _s, char new_sep){ CString LanguageParser::replaceSeparator(CString _s, char new_sep){
         char * _str = const_cast<char *>((const char*)_s);         char * _str = const_cast<char *>((const char*)_s);
         for(int i = 0; i < strlen(_str); i++)          Uint32 length = (Uint32) strlen(_str);
           for(Uint32 i = 0; i < length; i++)
                 _str[i] = (!isalnum(_str[i])) ? new_sep : _str[i];                 _str[i] = (!isalnum(_str[i])) ? new_sep : _str[i];
         return (String(_str)).getCString();         return (String(_str)).getCString();
 } }


Legend:
Removed from v.1.3  
changed lines
  Added in v.1.11

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2