Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 1 | // Copyright 2007-2010 Baptiste Lepilleur |
| 2 | // Distributed under MIT license, or public domain if desired and |
| 3 | // recognized in your jurisdiction. |
| 4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE |
| 5 | |
Baptiste Lepilleur | fa130ef | 2010-12-24 12:47:14 +0000 | [diff] [blame] | 6 | /* This executable is used for testing parser/writer using real JSON files. |
| 7 | */ |
| 8 | |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 9 | #include <json/json.h> |
| 10 | #include <algorithm> // sort |
Christopher Dunn | 2160c9a | 2015-01-23 09:02:44 -0600 | [diff] [blame] | 11 | #include <sstream> |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 12 | #include <stdio.h> |
| 13 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 14 | #if defined(_MSC_VER) && _MSC_VER >= 1310 |
| 15 | #pragma warning(disable : 4996) // disable fopen deprecation warning |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 16 | #endif |
| 17 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 18 | static std::string normalizeFloatingPointStr(double value) { |
| 19 | char buffer[32]; |
Aaron Jacobs | d261880 | 2013-08-08 23:08:28 +0000 | [diff] [blame] | 20 | #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 21 | sprintf_s(buffer, sizeof(buffer), "%.16g", value); |
Aaron Jacobs | d261880 | 2013-08-08 23:08:28 +0000 | [diff] [blame] | 22 | #else |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 23 | snprintf(buffer, sizeof(buffer), "%.16g", value); |
Aaron Jacobs | d261880 | 2013-08-08 23:08:28 +0000 | [diff] [blame] | 24 | #endif |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 25 | buffer[sizeof(buffer) - 1] = 0; |
| 26 | std::string s(buffer); |
| 27 | std::string::size_type index = s.find_last_of("eE"); |
| 28 | if (index != std::string::npos) { |
| 29 | std::string::size_type hasSign = |
| 30 | (s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0; |
| 31 | std::string::size_type exponentStartIndex = index + 1 + hasSign; |
| 32 | std::string normalized = s.substr(0, exponentStartIndex); |
| 33 | std::string::size_type indexDigit = |
| 34 | s.find_first_not_of('0', exponentStartIndex); |
| 35 | std::string exponent = "0"; |
| 36 | if (indexDigit != |
| 37 | std::string::npos) // There is an exponent different from 0 |
Baptiste Lepilleur | f0b24e7 | 2011-05-26 20:14:32 +0000 | [diff] [blame] | 38 | { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 39 | exponent = s.substr(indexDigit); |
Baptiste Lepilleur | f0b24e7 | 2011-05-26 20:14:32 +0000 | [diff] [blame] | 40 | } |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 41 | return normalized + exponent; |
| 42 | } |
| 43 | return s; |
Baptiste Lepilleur | f0b24e7 | 2011-05-26 20:14:32 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 46 | static std::string readInputTestFile(const char* path) { |
| 47 | FILE* file = fopen(path, "rb"); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 48 | if (!file) |
| 49 | return std::string(""); |
| 50 | fseek(file, 0, SEEK_END); |
| 51 | long size = ftell(file); |
| 52 | fseek(file, 0, SEEK_SET); |
| 53 | std::string text; |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 54 | char* buffer = new char[size + 1]; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 55 | buffer[size] = 0; |
| 56 | if (fread(buffer, 1, size, file) == (unsigned long)size) |
| 57 | text = buffer; |
| 58 | fclose(file); |
| 59 | delete[] buffer; |
| 60 | return text; |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 63 | static void |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 64 | printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") { |
Cory Quammen | 4d23492 | 2014-10-09 16:29:47 -0400 | [diff] [blame] | 65 | if (value.hasComment(Json::commentBefore)) { |
| 66 | fprintf(fout, "%s\n", value.getComment(Json::commentBefore).c_str()); |
| 67 | } |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 68 | switch (value.type()) { |
| 69 | case Json::nullValue: |
| 70 | fprintf(fout, "%s=null\n", path.c_str()); |
| 71 | break; |
| 72 | case Json::intValue: |
| 73 | fprintf(fout, |
| 74 | "%s=%s\n", |
| 75 | path.c_str(), |
| 76 | Json::valueToString(value.asLargestInt()).c_str()); |
| 77 | break; |
| 78 | case Json::uintValue: |
| 79 | fprintf(fout, |
| 80 | "%s=%s\n", |
| 81 | path.c_str(), |
| 82 | Json::valueToString(value.asLargestUInt()).c_str()); |
| 83 | break; |
| 84 | case Json::realValue: |
| 85 | fprintf(fout, |
| 86 | "%s=%s\n", |
| 87 | path.c_str(), |
| 88 | normalizeFloatingPointStr(value.asDouble()).c_str()); |
| 89 | break; |
| 90 | case Json::stringValue: |
| 91 | fprintf(fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str()); |
| 92 | break; |
| 93 | case Json::booleanValue: |
| 94 | fprintf(fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false"); |
| 95 | break; |
| 96 | case Json::arrayValue: { |
| 97 | fprintf(fout, "%s=[]\n", path.c_str()); |
| 98 | int size = value.size(); |
| 99 | for (int index = 0; index < size; ++index) { |
| 100 | static char buffer[16]; |
Aaron Jacobs | d261880 | 2013-08-08 23:08:28 +0000 | [diff] [blame] | 101 | #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 102 | sprintf_s(buffer, sizeof(buffer), "[%d]", index); |
Aaron Jacobs | d261880 | 2013-08-08 23:08:28 +0000 | [diff] [blame] | 103 | #else |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 104 | snprintf(buffer, sizeof(buffer), "[%d]", index); |
Aaron Jacobs | d261880 | 2013-08-08 23:08:28 +0000 | [diff] [blame] | 105 | #endif |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 106 | printValueTree(fout, value[index], path + buffer); |
| 107 | } |
| 108 | } break; |
| 109 | case Json::objectValue: { |
| 110 | fprintf(fout, "%s={}\n", path.c_str()); |
| 111 | Json::Value::Members members(value.getMemberNames()); |
| 112 | std::sort(members.begin(), members.end()); |
| 113 | std::string suffix = *(path.end() - 1) == '.' ? "" : "."; |
| 114 | for (Json::Value::Members::iterator it = members.begin(); |
| 115 | it != members.end(); |
| 116 | ++it) { |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 117 | const std::string& name = *it; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 118 | printValueTree(fout, value[name], path + suffix + name); |
| 119 | } |
| 120 | } break; |
| 121 | default: |
| 122 | break; |
| 123 | } |
Cory Quammen | 4d23492 | 2014-10-09 16:29:47 -0400 | [diff] [blame] | 124 | |
| 125 | if (value.hasComment(Json::commentAfter)) { |
| 126 | fprintf(fout, "%s\n", value.getComment(Json::commentAfter).c_str()); |
| 127 | } |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 130 | static int parseAndSaveValueTree(const std::string& input, |
| 131 | const std::string& actual, |
| 132 | const std::string& kind, |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 133 | const Json::Features& features, |
Christopher Dunn | 632c9b5 | 2015-01-23 11:09:04 -0600 | [diff] [blame] | 134 | bool parseOnly, |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 135 | Json::Value* root) |
| 136 | { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 137 | Json::Reader reader(features); |
Christopher Dunn | 632c9b5 | 2015-01-23 11:09:04 -0600 | [diff] [blame] | 138 | bool parsingSuccessful = reader.parse(input, *root); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 139 | if (!parsingSuccessful) { |
| 140 | printf("Failed to parse %s file: \n%s\n", |
| 141 | kind.c_str(), |
| 142 | reader.getFormattedErrorMessages().c_str()); |
| 143 | return 1; |
| 144 | } |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 145 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 146 | if (!parseOnly) { |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 147 | FILE* factual = fopen(actual.c_str(), "wt"); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 148 | if (!factual) { |
| 149 | printf("Failed to create %s actual file.\n", kind.c_str()); |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 150 | return 2; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 151 | } |
Christopher Dunn | 632c9b5 | 2015-01-23 11:09:04 -0600 | [diff] [blame] | 152 | printValueTree(factual, *root); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 153 | fclose(factual); |
| 154 | } |
| 155 | return 0; |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 156 | } |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 157 | // static std::string useFastWriter(Json::Value const& root) { |
| 158 | // Json::FastWriter writer; |
| 159 | // writer.enableYAMLCompatibility(); |
| 160 | // return writer.write(root); |
| 161 | // } |
| 162 | static std::string useStyledWriter( |
| 163 | Json::Value const& root) |
| 164 | { |
| 165 | Json::StyledWriter writer; |
| 166 | return writer.write(root); |
| 167 | } |
| 168 | static std::string useStyledStreamWriter( |
| 169 | Json::Value const& root) |
| 170 | { |
Christopher Dunn | 2160c9a | 2015-01-23 09:02:44 -0600 | [diff] [blame] | 171 | Json::StyledStreamWriter writer; |
| 172 | std::ostringstream sout; |
| 173 | writer.write(sout, root); |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 174 | return sout.str(); |
| 175 | } |
| 176 | static int rewriteValueTree( |
| 177 | const std::string& rewritePath, |
| 178 | const Json::Value& root, |
| 179 | std::string* rewrite) |
| 180 | { |
| 181 | *rewrite = useStyledWriter(root); |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 182 | FILE* fout = fopen(rewritePath.c_str(), "wt"); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 183 | if (!fout) { |
| 184 | printf("Failed to create rewrite file: %s\n", rewritePath.c_str()); |
| 185 | return 2; |
| 186 | } |
Christopher Dunn | 632c9b5 | 2015-01-23 11:09:04 -0600 | [diff] [blame] | 187 | fprintf(fout, "%s\n", rewrite->c_str()); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 188 | fclose(fout); |
| 189 | return 0; |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 192 | static std::string removeSuffix(const std::string& path, |
| 193 | const std::string& extension) { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 194 | if (extension.length() >= path.length()) |
| 195 | return std::string(""); |
| 196 | std::string suffix = path.substr(path.length() - extension.length()); |
| 197 | if (suffix != extension) |
| 198 | return std::string(""); |
| 199 | return path.substr(0, path.length() - extension.length()); |
| 200 | } |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 201 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 202 | static void printConfig() { |
| 203 | // Print the configuration used to compile JsonCpp |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 204 | #if defined(JSON_NO_INT64) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 205 | printf("JSON_NO_INT64=1\n"); |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 206 | #else |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 207 | printf("JSON_NO_INT64=0\n"); |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 208 | #endif |
| 209 | } |
| 210 | |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 211 | static int printUsage(const char* argv[]) { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 212 | printf("Usage: %s [--strict] input-json-file", argv[0]); |
| 213 | return 3; |
Baptiste Lepilleur | 8868147 | 2009-11-18 21:38:54 +0000 | [diff] [blame] | 214 | } |
| 215 | |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 216 | struct Options |
| 217 | { |
| 218 | std::string path; |
| 219 | Json::Features features; |
| 220 | bool parseOnly; |
| 221 | }; |
| 222 | static int parseCommandLine( |
| 223 | int argc, const char* argv[], Options* opts) |
| 224 | { |
| 225 | opts->parseOnly = false; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 226 | if (argc < 2) { |
| 227 | return printUsage(argv); |
| 228 | } |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 229 | int index = 1; |
| 230 | if (std::string(argv[1]) == "--json-checker") { |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 231 | opts->features = Json::Features::strictMode(); |
| 232 | opts->parseOnly = true; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 233 | ++index; |
| 234 | } |
Christopher Dunn | 08cfd02 | 2015-01-23 11:33:47 -0600 | [diff] [blame^] | 235 | if (std::string(argv[index]) == "--json-config") { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 236 | printConfig(); |
| 237 | return 3; |
| 238 | } |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 239 | if (index == argc || index + 1 < argc) { |
| 240 | return printUsage(argv); |
| 241 | } |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 242 | opts->path = argv[index]; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 243 | return 0; |
| 244 | } |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 245 | static void tryTest(Options const& opts) |
| 246 | { |
| 247 | } |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 248 | int main(int argc, const char* argv[]) { |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 249 | Options opts; |
| 250 | int exitCode = parseCommandLine(argc, argv, &opts); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 251 | if (exitCode != 0) { |
| 252 | return exitCode; |
| 253 | } |
| 254 | |
| 255 | try { |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 256 | std::string input = readInputTestFile(opts.path.c_str()); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 257 | if (input.empty()) { |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 258 | printf("Failed to read input or empty input: %s\n", opts.path.c_str()); |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 259 | return 3; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 260 | } |
Baptiste Lepilleur | 201fb2c | 2010-04-19 07:37:41 +0000 | [diff] [blame] | 261 | |
Christopher Dunn | 08cfd02 | 2015-01-23 11:33:47 -0600 | [diff] [blame^] | 262 | std::string basePath = removeSuffix(opts.path, ".json"); |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 263 | if (!opts.parseOnly && basePath.empty()) { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 264 | printf("Bad input path. Path does not end with '.expected':\n%s\n", |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 265 | opts.path.c_str()); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 266 | return 3; |
| 267 | } |
Baptiste Lepilleur | 8868147 | 2009-11-18 21:38:54 +0000 | [diff] [blame] | 268 | |
Christopher Dunn | 632c9b5 | 2015-01-23 11:09:04 -0600 | [diff] [blame] | 269 | std::string const actualPath = basePath + ".actual"; |
| 270 | std::string const rewritePath = basePath + ".rewrite"; |
| 271 | std::string const rewriteActualPath = basePath + ".actual-rewrite"; |
Baptiste Lepilleur | 8868147 | 2009-11-18 21:38:54 +0000 | [diff] [blame] | 272 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 273 | Json::Value root; |
| 274 | exitCode = parseAndSaveValueTree( |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 275 | input, actualPath, "input", |
| 276 | opts.features, opts.parseOnly, &root); |
| 277 | if (exitCode || opts.parseOnly) { |
Christopher Dunn | 942e2c9 | 2015-01-23 11:03:55 -0600 | [diff] [blame] | 278 | return exitCode; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 279 | } |
Christopher Dunn | 942e2c9 | 2015-01-23 11:03:55 -0600 | [diff] [blame] | 280 | std::string rewrite; |
Christopher Dunn | 632c9b5 | 2015-01-23 11:09:04 -0600 | [diff] [blame] | 281 | exitCode = rewriteValueTree(rewritePath, root, &rewrite); |
Christopher Dunn | 05810a7 | 2015-01-23 11:06:27 -0600 | [diff] [blame] | 282 | if (exitCode) { |
Christopher Dunn | 942e2c9 | 2015-01-23 11:03:55 -0600 | [diff] [blame] | 283 | return exitCode; |
| 284 | } |
| 285 | Json::Value rewriteRoot; |
Christopher Dunn | 05810a7 | 2015-01-23 11:06:27 -0600 | [diff] [blame] | 286 | exitCode = parseAndSaveValueTree( |
Christopher Dunn | 79211e1 | 2015-01-23 11:27:19 -0600 | [diff] [blame] | 287 | rewrite, rewriteActualPath, "rewrite", |
| 288 | opts.features, opts.parseOnly, &rewriteRoot); |
Christopher Dunn | 05810a7 | 2015-01-23 11:06:27 -0600 | [diff] [blame] | 289 | if (exitCode) { |
| 290 | return exitCode; |
| 291 | } |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 292 | } |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 293 | catch (const std::exception& e) { |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 294 | printf("Unhandled exception:\n%s\n", e.what()); |
| 295 | exitCode = 1; |
| 296 | } |
Baptiste Lepilleur | 842e9ac | 2010-12-27 17:45:23 +0000 | [diff] [blame] | 297 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 298 | return exitCode; |
Christopher Dunn | f986423 | 2007-06-14 21:01:26 +0000 | [diff] [blame] | 299 | } |