Make pretty printer keep track of line numbers as it prints.
This commit is contained in:
parent
dd4eb46bb3
commit
34d456aa80
|
@ -312,6 +312,7 @@ void TY_(InitPrintBuf)( TidyDocImpl* doc )
|
|||
InitIndent( &doc->pprint.indent[0] );
|
||||
InitIndent( &doc->pprint.indent[1] );
|
||||
doc->pprint.allocator = doc->allocator;
|
||||
doc->pprint.line = 0;
|
||||
}
|
||||
|
||||
void TY_(FreePrintBuf)( TidyDocImpl* doc )
|
||||
|
@ -613,6 +614,7 @@ static void WrapLine( TidyDocImpl* doc )
|
|||
TY_(WriteChar)( '\\', doc->docOut );
|
||||
|
||||
TY_(WriteChar)( '\n', doc->docOut );
|
||||
pprint->line++;
|
||||
ResetLineAfterWrap( pprint );
|
||||
}
|
||||
|
||||
|
@ -666,6 +668,7 @@ static void WrapAttrVal( TidyDocImpl* doc )
|
|||
TY_(WriteChar)( ' ', doc->docOut );
|
||||
|
||||
TY_(WriteChar)( '\n', doc->docOut );
|
||||
pprint->line++;
|
||||
ResetLineAfterWrap( pprint );
|
||||
}
|
||||
|
||||
|
@ -686,7 +689,7 @@ static void PFlushLineImpl( TidyDocImpl* doc )
|
|||
|
||||
for ( i = 0; i < pprint->linelen; ++i )
|
||||
TY_(WriteChar)( pprint->linebuf[i], doc->docOut );
|
||||
|
||||
|
||||
if ( IsInString(pprint) )
|
||||
TY_(WriteChar)( '\\', doc->docOut );
|
||||
ResetLine( pprint );
|
||||
|
@ -701,6 +704,7 @@ void TY_(PFlushLine)( TidyDocImpl* doc, uint indent )
|
|||
PFlushLineImpl( doc );
|
||||
|
||||
TY_(WriteChar)( '\n', doc->docOut );
|
||||
pprint->line++;
|
||||
pprint->indent[ 0 ].spaces = indent;
|
||||
}
|
||||
|
||||
|
@ -713,6 +717,7 @@ static void PCondFlushLine( TidyDocImpl* doc, uint indent )
|
|||
PFlushLineImpl( doc );
|
||||
|
||||
TY_(WriteChar)( '\n', doc->docOut );
|
||||
pprint->line++;
|
||||
pprint->indent[ 0 ].spaces = indent;
|
||||
}
|
||||
}
|
||||
|
@ -733,6 +738,7 @@ void TY_(PFlushLineSmart)( TidyDocImpl* doc, uint indent )
|
|||
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
||||
if(TidyAddVS) {
|
||||
TY_(WriteChar)( '\n', doc->docOut );
|
||||
pprint->line++;
|
||||
}
|
||||
|
||||
pprint->indent[ 0 ].spaces = indent;
|
||||
|
@ -749,6 +755,7 @@ static void PCondFlushLineSmart( TidyDocImpl* doc, uint indent )
|
|||
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
||||
if(TidyAddVS) {
|
||||
TY_(WriteChar)( '\n', doc->docOut );
|
||||
pprint->line++;
|
||||
}
|
||||
|
||||
pprint->indent[ 0 ].spaces = indent;
|
||||
|
|
|
@ -53,6 +53,7 @@ typedef struct _TidyPrintImpl
|
|||
uint lbufsize;
|
||||
uint linelen;
|
||||
uint wraphere;
|
||||
uint line;
|
||||
|
||||
uint ixInd;
|
||||
TidyIndent indent[2]; /* Two lines worth of indent state */
|
||||
|
|
Loading…
Reference in a new issue