[Super-tux-commit] supertux/src lispreader.cpp,1.29,1.30 worldmap.cpp,1.91,1.92
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-07-09 22:16:59
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24260/src Modified Files: lispreader.cpp worldmap.cpp Log Message: Fixed crash when LANG system's variable is not defined. Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- worldmap.cpp 9 Jul 2004 14:43:44 -0000 1.91 +++ worldmap.cpp 9 Jul 2004 22:16:50 -0000 1.92 @@ -361,7 +361,7 @@ input_direction = D_NONE; enter_level = false; - name = "<no file>"; + name = "<no title>"; music = "SALCON.MOD"; } Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/lispreader.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- lispreader.cpp 8 Jul 2004 10:11:08 -0000 1.29 +++ lispreader.cpp 9 Jul 2004 22:16:49 -0000 1.30 @@ -1218,19 +1218,26 @@ (text-fr "Bonjour Monde!") being fr the value of LANG (echo $LANG) for the language we want to translate to */ + char* lang = getenv("LANG"); + char str_[1024]; // check, for instance, for (title-fr_FR "Bonjour") - sprintf(str_, "%s-%s", name, getenv("LANG")); + sprintf(str_, "%s-%s", name, lang); obj = search_for (str_); if(!obj) // check, for instance, for (title-fr "Bonjour") { - char lang[3]; - strncpy(lang, getenv("LANG"), 2); - lang[2] = '\0'; - sprintf(str_, "%s-%s", name, lang); + if(strlen(lang) >= 2) + { + char lang_[3]; + strncpy(lang_, lang, 2); + lang_[2] = '\0'; + sprintf(str_, "%s-%s", name, lang_); - obj = search_for (str_); + obj = search_for (str_); + } + else + obj = 0; } if(!obj) // check, for instance, for (title "Hello") |