X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffilexml.C;h=fe0ec15fa082e247f3f48cf3a04108303dc91dc5;hp=8b7315ca9640288fd9b26b0380587bff3942b658;hb=096e197a21d85fa8c60547cd54944fb379c08bb9;hpb=83bfb86d01b353bab485d0ccc336e0572bcb63c6 diff --git a/cinelerra-5.1/cinelerra/filexml.C b/cinelerra-5.1/cinelerra/filexml.C index 8b7315ca..fe0ec15f 100644 --- a/cinelerra-5.1/cinelerra/filexml.C +++ b/cinelerra-5.1/cinelerra/filexml.C @@ -46,7 +46,7 @@ XMLBuffer::XMLBuffer(long buf_size, long max_size, int del) lmt = bfr + bsz; isz = max_size; destroy = del; - share_lock = new Mutex("XMLBuffer::share_lock"); + share_lock = new Mutex("XMLBuffer::share_lock", 1); } XMLBuffer::XMLBuffer(const char *buf, long buf_size, int del) @@ -264,7 +264,7 @@ int XMLTag::write_tag(FileXML *xml) const char *prop = properties[i]->prop; const char *value = properties[i]->value; int plen = strlen(prop), vlen = strlen(value); - bool need_quotes = !vlen || strchr(value,' '); + bool need_quotes = !vlen || strchr(value,' ') || strchr(value,'\n'); buf->next(' '); xml->append_text(prop, plen); buf->next('='); @@ -452,8 +452,9 @@ int FileXML::append_text(const char *text, long len) char* FileXML::get_data() { + char *data = (char *)buffer->cstr(); long ofs = buffer->itell(); - return (char *)buffer->pos(ofs); + return data + ofs; } char* FileXML::string() { @@ -470,18 +471,34 @@ char* FileXML::read_text() int ch = buffer->next(); // filter out first char is new line if( ch == '\n' ) ch = buffer->next(); - long ipos = buffer->itell()-1; + long ipos = buffer->itell(); + if( ch >= 0 ) --ipos; + long pos = ipos; // scan for delimiter - while( ch >= 0 && ch != left_delm ) ch = buffer->next(); - long pos = buffer->itell()-1; - if( ch >= 0 ) buffer->iseek(pos); + while( ch >= 0 ) { + while( ch >= 0 && ch != left_delm ) ch = buffer->next(); + if( ch < 0 ) break; + pos = buffer->itell()-1; + if( (ch = buffer->next()) != '/' ) continue; + char *cp = tag.title; + while( (ch=buffer->next()) >= 0 && ch == *cp ) ++cp; + if( ch < 0 ) break; + if( *cp ) continue; + while( ch == ' ' ) ch = buffer->next(); + if( ch == right_delm ) break; + } + if( ch < 0 ) + pos = buffer->itell(); + buffer->iseek(pos); long len = pos - ipos; if( len >= output_length ) { delete [] output; output_length = len+1; output = new char[output_length]; } - decode(output,(const char *)buffer->pos(ipos), len); + if( len > 0 ) + decode(output,(const char *)buffer->pos(ipos), len); + output[len] = 0; return output; }