From ad48fd1db981ca9f9e9e02a5f1f4c136740ae877 Mon Sep 17 00:00:00 2001 From: Arystanbek Dyussenov Date: Thu, 9 Sep 2010 08:14:36 +0000 Subject: Patch by Jan Diederich, fixes bug #23715 in the COLLADA exporter. Allow IDs to start only with an alphabetic character replacing digits with an '_'. --- source/blender/collada/DocumentExporter.cpp | 107 +++++++++++++++++++--------- 1 file changed, 72 insertions(+), 35 deletions(-) (limited to 'source/blender/collada/DocumentExporter.cpp') diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 72f280d7ce2..ae00942b89d 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -162,47 +162,84 @@ like special chars (e.g. micro sign), umlauts and so on. The COLLADA spec also allows additional chars for member access ('.'), these must obviously be removed too, otherwise they would be heavily misinterpreted. */ -const unsigned char translate_map[256] = { - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 45, 95, 95, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 95, 95, 95, 95, 95, 95, - 95, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 95, 95, 95, 95, 95, - 95, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 183, - 95, 95, 95, 95, 95, 95, 95, 95, - 192, 193, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 95, - 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, - 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 95, - 248, 249, 250, 251, 252, 253, 254, 255}; +const unsigned char translate_start_name_map[256] = { +95, 95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +65, 66, 67, 68, 69, 70, 71, 72, +73, 74, 75, 76, 77, 78, 79, 80, +81, 82, 83, 84, 85, 86, 87, 88, +89, 90, 95, 95, 95, 95, 95, 95, +97, 98, 99, 100, 101, 102, 103, 104, +105, 106, 107, 108, 109, 110, 111, 112, +113, 114, 115, 116, 117, 118, 119, 120, +121, 122, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 192, +193, 194, 195, 196, 197, 198, 199, 200, +201, 202, 203, 204, 205, 206, 207, 208, +209, 210, 211, 212, 213, 214, 95, 216, +217, 218, 219, 220, 221, 222, 223, 224, +225, 226, 227, 228, 229, 230, 231, 232, +233, 234, 235, 236, 237, 238, 239, 240, +241, 242, 243, 244, 245, 246, 95, 248, +249, 250, 251, 252, 253, 254, 255}; + +const unsigned char translate_name_map[256] = { +95, 95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 45, 95, 95, 48, +49, 50, 51, 52, 53, 54, 55, 56, +57, 95, 95, 95, 95, 95, 95, 95, +65, 66, 67, 68, 69, 70, 71, 72, +73, 74, 75, 76, 77, 78, 79, 80, +81, 82, 83, 84, 85, 86, 87, 88, +89, 90, 95, 95, 95, 95, 95, 95, +97, 98, 99, 100, 101, 102, 103, 104, +105, 106, 107, 108, 109, 110, 111, 112, +113, 114, 115, 116, 117, 118, 119, 120, +121, 122, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 95, 95, +95, 95, 95, 95, 95, 95, 183, 95, +95, 95, 95, 95, 95, 95, 95, 192, +193, 194, 195, 196, 197, 198, 199, 200, +201, 202, 203, 204, 205, 206, 207, 208, +209, 210, 211, 212, 213, 214, 95, 216, +217, 218, 219, 220, 221, 222, 223, 224, +225, 226, 227, 228, 229, 230, 231, 232, +233, 234, 235, 236, 237, 238, 239, 240, +241, 242, 243, 244, 245, 246, 95, 248, +249, 250, 251, 252, 253, 254, 255}; /** Look at documentation of translate_map */ static std::string translate_id(const std::string &id) { + if (id.size() == 0) + { return id; } std::string id_translated = id; - for (unsigned int i=0; i < id_translated.size(); i++) + id_translated[0] = translate_start_name_map[(unsigned int)id_translated[0]]; + for (unsigned int i=1; i < id_translated.size(); i++) { - id_translated[i] = translate_map[(unsigned int)id_translated[i]]; + id_translated[i] = translate_name_map[(unsigned int)id_translated[i]]; } return id_translated; } -- cgit v1.2.3