summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2014-02-17 10:44:59 (GMT)
committerJan Huwald <jh@sotun.de>2014-02-17 10:44:59 (GMT)
commitfbc0d7357623346c5b1b3493f6bd117a77397c5b (patch)
treefa4eabcc0093d5eec0192aba7f8b9b79fee905fe
parent7de7b1618c85d21d3f737d0981f8ae3784ac1036 (diff)
cmdline(): fix crash on file names without suffix
- fix witespace - fix error message: print file name
-rw-r--r--src/openscad.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/openscad.cc b/src/openscad.cc
index b815ead..7a7d077 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -281,19 +281,20 @@ int cmdline(optional<string> action, optional<string> output_file,
// Set action and output filename; both are optional
if (!action && (!output_file || (*output_file == "-")))
- action = "stl";
+ action = "stl";
if (!action) {
- // Guess action from filename suffix
- action = boosty::extension_str(*output_file);
- boost::algorithm::to_lower(*action);
- action = action->substr(1); // remove leading dot
- if (!actions.count(*action)) {
- PRINTB("Unknown suffix for output file %s\n", output_file);
- return 1;
- }
+ // Guess action from filename suffix
+ action = boosty::extension_str(*output_file);
+ boost::algorithm::to_lower(*action);
+ if (action->length() > 0)
+ action = action->substr(1); // remove leading dot
+ if (!actions.count(*action)) {
+ PRINTB("Unknown suffix for output file %s\n", *output_file);
+ return 1;
+ }
}
if (!output_file)
- output_file = filename + "." + *action;
+ output_file = filename + "." + *action;
// Open output stream. If it refers to a file, use a temporary
// file first. Filename "-" refers to standard output
contact: Jan Huwald // Impressum