summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/wmf-print.cpp
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2013-03-13 20:59:06 +0000
committerKris <Kris.De.Gussem@hotmail.com>2013-03-13 20:59:06 +0000
commit22ae953dd3c437bc609f917c52c55a6a6814d46e (patch)
treee778d7493ff24aca309e60fb9e4691d5358fb918 /src/extension/internal/wmf-print.cpp
parentmerge from trunk (r12191) (diff)
downloadinkscape-22ae953dd3c437bc609f917c52c55a6a6814d46e.tar.gz
inkscape-22ae953dd3c437bc609f917c52c55a6a6814d46e.zip
Prevent crashing on windows systems due to locale issues
(bzr r11668.1.56)
Diffstat (limited to 'src/extension/internal/wmf-print.cpp')
-rw-r--r--src/extension/internal/wmf-print.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index c053f3222..8f75f19df 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -128,16 +128,28 @@ std::string path_to_ffconf;
//open the input
fffile.open(path_to_ffconf.c_str(), std::ios::in);
if(!fffile.is_open()){
- g_message("Unable to open file: %s\n", path_to_ffconf.c_str());
- throw "boom";
+ g_error("Unable to open file: %s\n", path_to_ffconf.c_str());
+ // throw "boom";
}
+
+ char *oldlocale = g_strdup (setlocale (LC_NUMERIC, NULL));
+ setlocale (LC_NUMERIC, "C");
+
while (std::getline(fffile,instr)){
- if(instr[0]=='#')continue;
+ if (instr.empty()) {
+ continue;
+ }
+ if(instr[0]=='#'){
+ continue;
+ }
// not a comment, get the 4 values from the line
- int elements=sscanf(instr.c_str(),"%lf %lf %lf %[^\n]",&f1,&f2,&f3, &fontname[0]);
+ int elements=sscanf(instr.c_str(),"%6lf %6lf %6lf %127[^\n]",&f1,&f2,&f3, &fontname[0]);
if(elements!=4){
- g_message("Expected \"f1 f2 f3 Fontname\" but did not find it in file: %s\n", path_to_ffconf.c_str());
- throw "boom";
+ setlocale (LC_NUMERIC, oldlocale);
+ g_free (oldlocale);
+ fffile.close();
+ g_error("Expected \"f1 f2 f3 Fontname\" but did not find it in file: %s\n", path_to_ffconf.c_str());
+ // throw "boom";
}
temp=(FFNEXUS *) calloc(1,sizeof(FFNEXUS)); //This will never be freed
temp->f1=f1;
@@ -153,6 +165,8 @@ std::string path_to_ffconf;
wmf_long_fflist=ptr=temp;
}
}
+ setlocale (LC_NUMERIC, oldlocale);
+ g_free (oldlocale);
fffile.close();
}