diff --git a/.github/workflows/ci-unixish.yml b/.github/workflows/ci-unixish.yml new file mode 100644 index 0000000..ab17d94 --- /dev/null +++ b/.github/workflows/ci-unixish.yml @@ -0,0 +1,20 @@ +name: C/C++ CI Unixish + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: make + run: make + - name: make check + run: make check + - name: Install + run: sudo make install diff --git a/tinyxml2.cpp b/tinyxml2.cpp index b9c94e9..deed12a 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -2659,22 +2659,33 @@ void XMLPrinter::PushHeader( bool writeBOM, bool writeDec ) } } - -void XMLPrinter::OpenElement( const char* name, bool compactMode ) +void XMLPrinter::PrepareForNewNode( bool compactMode ) { SealElementIfJustOpened(); - _stack.Push( name ); - if ( _textDepth < 0 && !_firstElement && !compactMode ) { + if ( compactMode ) { + return; + } + + if ( _firstElement ) { + PrintSpace (_depth); + } else if ( _textDepth < 0) { Putc( '\n' ); PrintSpace( _depth ); } + _firstElement = false; +} + +void XMLPrinter::OpenElement( const char* name, bool compactMode ) +{ + PrepareForNewNode( compactMode ); + _stack.Push( name ); + Write ( "<" ); Write ( name ); _elementJustOpened = true; - _firstElement = false; ++_depth; } @@ -2850,12 +2861,7 @@ void XMLPrinter::PushText( double value ) void XMLPrinter::PushComment( const char* comment ) { - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Putc( '\n' ); - PrintSpace( _depth ); - } - _firstElement = false; + PrepareForNewNode( _compactMode ); Write( "