Commit 6c7a2eee authored by claes's avatar claes

Bug when loading strings with linefeed fixed

parent 73a94d98
...@@ -802,7 +802,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix) ...@@ -802,7 +802,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
pwr_eType type; pwr_eType type;
char buf[2048]; char buf[2048];
int int_val, current_int_val; int int_val, current_int_val;
bool add_newline = false; bool string_continue = false;
switch ( getType()) { switch ( getType()) {
case tokens.ATTRIBUTE: case tokens.ATTRIBUTE:
...@@ -836,10 +836,8 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix) ...@@ -836,10 +836,8 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
(type == pwr_eType_String || type == pwr_eType_Text)) { (type == pwr_eType_String || type == pwr_eType_Text)) {
// Index in string attribute marks a new row // Index in string attribute marks a new row
int index = n.attrIndex(); int index = n.attrIndex();
if ( index > 0) { if ( index > 0)
add_newline = true; string_continue = true;
index--;
}
offset += index; offset += index;
size = size - index; size = size - index;
} }
...@@ -872,17 +870,12 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix) ...@@ -872,17 +870,12 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
return; return;
} }
if ( !add_newline) strncpy( value, second_child->name(), sizeof(value));
strncpy( value, second_child->name(), sizeof(value));
else {
strncpy( &value[1], second_child->name(), sizeof(value)-1);
value[0] = '\n';
}
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value); // printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if ( size == sizeof(int_val) && convconst( &int_val, value)) { if ( size == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) { if ( oper == tokens.EQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->o->rbody + offset), memcpy( (char *)((unsigned int) object->o->rbody + offset),
&int_val, size); &int_val, size);
else if ( bix == pwr_eBix_dev) else if ( bix == pwr_eBix_dev)
...@@ -905,12 +898,20 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix) ...@@ -905,12 +898,20 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
} }
} }
else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) { else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) {
if ( string_continue && ! *(char *)((unsigned int) object->o->rbody + offset - 1))
// If previous char is null, this was originally linefeed
*(char *)((unsigned int) object->o->rbody + offset - 1) = '\n';
memcpy( (char *)((unsigned int) object->o->rbody + offset), memcpy( (char *)((unsigned int) object->o->rbody + offset),
buf, size); buf, size);
else if ( bix == pwr_eBix_dev) }
else if ( bix == pwr_eBix_dev) {
if ( string_continue && ! *(char *)((unsigned int) object->o->dbody + offset - 1))
// If previous char is null, this was originally linefeed
*(char *)((unsigned int) object->o->dbody + offset - 1) = '\n';
memcpy( (char *)((unsigned int) object->o->dbody + offset), memcpy( (char *)((unsigned int) object->o->dbody + offset),
buf, size); buf, size);
}
} }
else { else {
// Attr conversion exception // Attr conversion exception
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment