Only allow character decoder compatibility mode if HAVE_ICU is defined since it relies on ICU to be available.

This commit is contained in:
Thomas Krijnen
2012-07-18 18:45:34 +00:00
parent 217a7c6599
commit 95d2cdc4b6
2 changed files with 68 additions and 63 deletions
+9 -4
View File
@@ -126,8 +126,9 @@ IfcCharacterDecoder::operator std::string() {
int codepage = 1; int codepage = 1;
unsigned int hex = 0; unsigned int hex = 0;
unsigned int hex_count = 0; unsigned int hex_count = 0;
#ifdef HAVE_ICU
unsigned int old_hex = 0; // for compatibility_mode unsigned int old_hex = 0; // for compatibility_mode
#endif
while ( current_char = file->Peek() ) { while ( current_char = file->Peek() ) {
if ( EXPECTS_CHARACTER(parse_state) ) { if ( EXPECTS_CHARACTER(parse_state) ) {
#ifdef HAVE_ICU #ifdef HAVE_ICU
@@ -181,6 +182,7 @@ IfcCharacterDecoder::operator std::string() {
if ( (hex_count == 2 && !(parse_state & EXTENDED2)) || if ( (hex_count == 2 && !(parse_state & EXTENDED2)) ||
(hex_count == 4 && !(parse_state & EXTENDED4)) || (hex_count == 4 && !(parse_state & EXTENDED4)) ||
(hex_count == 8) ) { (hex_count == 8) ) {
#ifdef HAVE_ICU
if (compatibility_mode) { if (compatibility_mode) {
if (old_hex == 0) { if (old_hex == 0) {
old_hex = hex; old_hex = hex;
@@ -193,8 +195,11 @@ IfcCharacterDecoder::operator std::string() {
} }
} }
else { else {
#endif
addChar(s,(UChar32) hex); addChar(s,(UChar32) hex);
#ifdef HAVE_ICU
} }
#endif
if ( hex_count == 2 ) parse_state = 0; if ( hex_count == 2 ) parse_state = 0;
else CLEAR_HEX(parse_state); else CLEAR_HEX(parse_state);
hex = hex_count = 0; hex = hex_count = 0;
@@ -281,13 +286,13 @@ int IfcCharacterDecoder::previous_codepage = -1;
UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR; UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
#endif #endif
//#ifdef HAVE_ICU #ifdef HAVE_ICU
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON; IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
// Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior // Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior
bool IfcCharacterDecoder::compatibility_mode = false; bool IfcCharacterDecoder::compatibility_mode = false;
std::string IfcCharacterDecoder::compatibility_charset = ""; std::string IfcCharacterDecoder::compatibility_charset = "";
//#else #else
char IfcCharacterDecoder::substitution_character = '_'; char IfcCharacterDecoder::substitution_character = '_';
//#endif #endif
+26 -26
View File
@@ -1,28 +1,28 @@
/******************************************************************************** /********************************************************************************
* * * *
* This file is part of IfcOpenShell. * * This file is part of IfcOpenShell. *
* * * *
* IfcOpenShell is free software: you can redistribute it and/or modify * * IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by * * it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or * * the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* IfcOpenShell is distributed in the hope that it will be useful, * * IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. * * Lesser GNU General Public License for more details. *
* * * *
* You should have received a copy of the Lesser GNU General Public License * * You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* * * *
********************************************************************************/ ********************************************************************************/
/******************************************************************************** /********************************************************************************
* * * *
* Implementation of character decoding as described in ISO 10303-21 table 2 and * * Implementation of character decoding as described in ISO 10303-21 table 2 and *
* table 4 * * table 4 *
* * * *
********************************************************************************/ ********************************************************************************/
#ifndef IFCCHARACTERDECODER_H #ifndef IFCCHARACTERDECODER_H
#define IFCCHARACTERDECODER_H #define IFCCHARACTERDECODER_H
@@ -52,7 +52,7 @@ namespace IfcParse {
#endif #endif
void addChar(std::stringstream& s,const UChar32& ch); void addChar(std::stringstream& s,const UChar32& ch);
public: public:
//#ifdef HAVE_ICU #ifdef HAVE_ICU
enum ConversionMode {DEFAULT,UTF8,LATIN,JSON,PYTHON}; enum ConversionMode {DEFAULT,UTF8,LATIN,JSON,PYTHON};
static ConversionMode mode; static ConversionMode mode;
@@ -62,9 +62,9 @@ namespace IfcParse {
static bool compatibility_mode; static bool compatibility_mode;
static std::string compatibility_charset; static std::string compatibility_charset;
//#else #else
static char substitution_character; static char substitution_character;
//#endif #endif
IfcCharacterDecoder(IfcParse::File* file); IfcCharacterDecoder(IfcParse::File* file);
~IfcCharacterDecoder(); ~IfcCharacterDecoder();
void dryRun(); void dryRun();