diff options
Diffstat (limited to 'LangMan/langpack.c')
-rw-r--r-- | LangMan/langpack.c | 82 |
1 files changed, 46 insertions, 36 deletions
diff --git a/LangMan/langpack.c b/LangMan/langpack.c index be30cae..6ce827c 100644 --- a/LangMan/langpack.c +++ b/LangMan/langpack.c @@ -26,9 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void TrimString(char *str)
{
int len,start;
- len=lstrlenA(str);
- while(str[0]!='\0' && (unsigned char)str[len-1]<=' ') str[--len]=0;
- for(start=0;str[start] && (unsigned char)str[start]<=' ';++start);
+ len = lstrlenA(str);
+ while (str[0]!='\0' && (unsigned char)str[len-1]<=' ') str[--len]=0;
+ for (start=0; str[start] && (unsigned char)str[start]<=' '; ++start);
MoveMemory(str,str+start,len-start+1);
}
@@ -153,49 +153,60 @@ static BOOL LoadPackData(LANGPACK_INFO *pack,BOOL fEnabledPacks,const char *pszF X-Version: 1.2.3.4 (non-standard extension)
see 'LangMan-Translation.txt' for some header quidelines
*/
- if(!GetPackPath(szFileName,SIZEOF(szFileName),fEnabledPacks,pack->szFileName)) return FALSE;
- fp=_tfopen(szFileName,_T("rt"));
- if(fp==NULL) return FALSE;
- fgets(line,sizeof(line),fp);
+ if ( !GetPackPath( szFileName, SIZEOF(szFileName), fEnabledPacks, pack->szFileName))
+ return FALSE;
+
+ fp = _tfopen(szFileName,_T("rt"));
+ if (fp == NULL)
+ return FALSE;
+
+ fgets(line, sizeof(line), fp);
TrimString(line);
- if(lstrcmpA(line,pszFileVersionHeader)) {
+ buf = line;
+
+ if (strlen(line) >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf') {
+ pack->codepage = CP_UTF8;
+ buf += 3;
+ }
+
+ if ( lstrcmpA(buf, pszFileVersionHeader )) {
fclose(fp);
return FALSE;
}
- pack->flags=LPF_NOLOCALE;
- szLanguageA[0]='\0';
- while(!feof(fp)) {
- if(fgets(line,sizeof(line),fp)==NULL) break;
+ pack->flags = LPF_NOLOCALE;
+ szLanguageA[0] = '\0';
+ while( !feof( fp )) {
+ if ( fgets(line, sizeof(line), fp) == NULL) break;
TrimString(line);
- if(IsEmpty(line) || line[0]==';' || line[0]=='\0') continue;
- if(line[0]=='[') break;
- pszColon=strchr(line,':');
- if(pszColon==NULL) continue;
- *pszColon='\0';
+ if ( IsEmpty(line) || line[0]==';' || line[0]=='\0') continue;
+ if ( line[0]=='[' ) break;
+ pszColon = strchr(line,':');
+ if ( pszColon == NULL ) continue;
+ *pszColon = '\0';
TrimString(pszColon+1);
- if(!lstrcmpA(line,"Language") && !pack->szLanguage[0])
- lstrcpynA(szLanguageA,pszColon+1,sizeof(szLanguageA)); /* buffer safe */
- else if(!lstrcmpA(line,"Last-Modified-Using") && !pack->szLastModifiedUsing[0])
- lstrcpynA(pack->szLastModifiedUsing,pszColon+1,sizeof(pack->szLastModifiedUsing)); /* buffer safe */
- else if(!lstrcmpA(line, "Authors")) {
+ if ( !lstrcmpA(line,"Language") && !pack->szLanguage[0] )
+ lstrcpynA(szLanguageA, pszColon+1, sizeof(szLanguageA)); /* buffer safe */
+ else if ( !lstrcmpA(line, "Last-Modified-Using") && !pack->szLastModifiedUsing[0] )
+ lstrcpynA(pack->szLastModifiedUsing, pszColon+1, sizeof(pack->szLastModifiedUsing)); /* buffer safe */
+ else if ( !lstrcmpA(line, "Authors")) {
buf=pack->szAuthors+lstrlenA(pack->szAuthors); /* allow multiple tags */
if((sizeof(pack->szAuthors)-lstrlenA(pack->szAuthors))>0) /* buffer safe */
mir_snprintf(buf,sizeof(pack->szAuthors)-lstrlenA(pack->szAuthors),(pack->szAuthors[0]=='\0')?"%s":" %s",pszColon+1);
- } else if(!lstrcmpA(line, "Author-email") && !pack->szAuthorEmail[0])
- lstrcpynA(pack->szAuthorEmail,pszColon+1,sizeof(pack->szAuthorEmail)); /* buffer safe */
- else if(!lstrcmpA(line,"Locale") && pack->flags&LPF_NOLOCALE) {
- pack->Locale=MAKELCID((USHORT)strtol(pszColon+1,NULL,16),SORT_DEFAULT);
- if(pack->Locale) pack->flags&=~LPF_NOLOCALE;
+ } else if ( !lstrcmpA(line, "Author-email") && !pack->szAuthorEmail[0])
+ lstrcpynA(pack->szAuthorEmail, pszColon+1, sizeof(pack->szAuthorEmail)); /* buffer safe */
+ else if ( !lstrcmpA(line,"Locale") && (pack->flags & LPF_NOLOCALE)) {
+ pack->Locale = MAKELCID((USHORT)strtol(pszColon+1, NULL, 16), SORT_DEFAULT);
+ if(pack->Locale) pack->flags &= ~LPF_NOLOCALE;
}
- else if(!lstrcmpA(line,"Plugins-included")) {
- buf=pack->szPluginsIncluded+lstrlenA(pack->szPluginsIncluded); /* allow multiple tags */
- if((sizeof(pack->szPluginsIncluded)-lstrlenA(pack->szPluginsIncluded))>0) /* buffer safe */
- mir_snprintf(buf,sizeof(pack->szPluginsIncluded)-lstrlenA(pack->szPluginsIncluded),(pack->szPluginsIncluded[0]=='\0')?"%s":", %s",CharLowerA(pszColon+1));
+ else if ( !lstrcmpA(line,"Plugins-included")) {
+ buf = pack->szPluginsIncluded + lstrlenA(pack->szPluginsIncluded); /* allow multiple tags */
+ if (( sizeof(pack->szPluginsIncluded)-lstrlenA(pack->szPluginsIncluded)) > 0 ) /* buffer safe */
+ mir_snprintf(buf, sizeof(pack->szPluginsIncluded)-lstrlenA(pack->szPluginsIncluded),(pack->szPluginsIncluded[0]=='\0')?"%s":", %s",CharLowerA(pszColon+1));
}
- else if(!lstrcmpA(line,"X-Version") && !pack->szVersion[0])
- lstrcpynA(pack->szVersion,pszColon+1,sizeof(pack->szVersion)); /* buffer safe */
- else if(!lstrcmpA(line,"X-FLName") && !pack->szFLName[0])
- lstrcpynA(pack->szFLName,pszColon+1,sizeof(pack->szFLName)); /* buffer safe */
+ else if ( !lstrcmpA(line,"X-Version") && !pack->szVersion[0] )
+ lstrcpynA(pack->szVersion, pszColon+1, sizeof(pack->szVersion)); /* buffer safe */
+ else if ( !lstrcmpA(line,"X-FLName") && !pack->szFLName[0] )
+ lstrcpynA(pack->szFLName, pszColon+1, sizeof(pack->szFLName)); /* buffer safe */
}
CleanupLanguage(szLanguageA);
CleanupAuthors(pack->szAuthors);
@@ -343,7 +354,6 @@ BOOL IsPluginIncluded(const LANGPACK_INFO *pack,char *pszFileBaseName) }
else p+=lstrlenA(pszFileBaseName)+1;
}
- return FALSE;
}
/************************* Switch *************************************/
|