Skip to content

Commit

Permalink
need convert_LTYPE_strings_area also for out_dxf, svg, json
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Dec 31, 2023
1 parent 6960ff2 commit ac87d36
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3971,11 +3971,11 @@ DWG_TABLE (LTYPE)
END_REPEAT (dashes);

UNTIL (R_2004) {
#if !defined(IS_DECODER) && defined(USE_WRITE) && !defined(DECODE_TEST_C)
// downconvert from 512
ENCODER {
if (dwg->header.from_version > R_2004)
dwg_convert_LTYPE_strings_area (dwg, _obj);
}
if (dwg->header.from_version > R_2004)
dwg_convert_LTYPE_strings_area (dwg, _obj);
#endif
FIELD_BINARY (strings_area, 256, 0);
DECODER {
unsigned int dash_i = 0;
Expand All @@ -3998,12 +3998,12 @@ DWG_TABLE (LTYPE)
}
}
LATER_VERSIONS {
if (FIELD_VALUE (has_strings_area)) {
#if !defined(IS_DECODER) && defined(USE_WRITE) && !defined(DECODE_TEST_C)
// upconvert from 256
ENCODER {
if (dwg->header.from_version <= R_2004)
dwg_convert_LTYPE_strings_area (dwg, _obj);
}
if (dwg->header.from_version <= R_2004)
dwg_convert_LTYPE_strings_area (dwg, _obj);
#endif
if (FIELD_VALUE (has_strings_area)) {
FIELD_BINARY (strings_area, 512, 0);
DECODER {
BITCODE_RS dash_i = 0;
Expand Down
28 changes: 25 additions & 3 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7412,25 +7412,47 @@ dwg_convert_LTYPE_strings_area (const Dwg_Data *restrict dwg,
{
// upconvert to 512
BITCODE_TF old = _obj->strings_area;
if (!old)
{
_obj->has_strings_area = 0;
return;
}
_obj->strings_area = calloc (1, 512);
if (!_obj->strings_area || !old)
return;
if (!_obj->strings_area)
{
_obj->has_strings_area = 0;
free (old);
return;
}
_obj->has_strings_area = 1;
for (int i = 0; i < 256; i++)
{
_obj->strings_area[i * 2] = old[i];
}
free (old);
}
else if (dwg->header.from_version > R_2004 && dwg->header.version <= R_2004)
{
// downconvert to 256
BITCODE_TF old = _obj->strings_area;
if (!old)
_obj->has_strings_area = 0;
_obj->strings_area = calloc (1, 256);
if (!_obj->strings_area || !old)
return;
{ // all empty
if (old)
free (old);
if (_obj->strings_area)
free (_obj->strings_area);
_obj->strings_area = NULL;
return;
}
_obj->has_strings_area = 1;
for (int i = 0; i < 256; i++)
{
_obj->strings_area[i] = old[i * 2];
}
free (old);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ bool dwg_encode_unknown_bits (Bit_Chain *restrict dat,
Dwg_Object *restrict obj);
void downconvert_TABLESTYLE (Dwg_Object *restrict obj);


#endif

0 comments on commit ac87d36

Please sign in to comment.