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[0] );
|
||||||
InitIndent( &doc->pprint.indent[1] );
|
InitIndent( &doc->pprint.indent[1] );
|
||||||
doc->pprint.allocator = doc->allocator;
|
doc->pprint.allocator = doc->allocator;
|
||||||
|
doc->pprint.line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TY_(FreePrintBuf)( TidyDocImpl* doc )
|
void TY_(FreePrintBuf)( TidyDocImpl* doc )
|
||||||
|
@ -613,6 +614,7 @@ static void WrapLine( TidyDocImpl* doc )
|
||||||
TY_(WriteChar)( '\\', doc->docOut );
|
TY_(WriteChar)( '\\', doc->docOut );
|
||||||
|
|
||||||
TY_(WriteChar)( '\n', doc->docOut );
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
pprint->line++;
|
||||||
ResetLineAfterWrap( pprint );
|
ResetLineAfterWrap( pprint );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,6 +668,7 @@ static void WrapAttrVal( TidyDocImpl* doc )
|
||||||
TY_(WriteChar)( ' ', doc->docOut );
|
TY_(WriteChar)( ' ', doc->docOut );
|
||||||
|
|
||||||
TY_(WriteChar)( '\n', doc->docOut );
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
pprint->line++;
|
||||||
ResetLineAfterWrap( pprint );
|
ResetLineAfterWrap( pprint );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,6 +704,7 @@ void TY_(PFlushLine)( TidyDocImpl* doc, uint indent )
|
||||||
PFlushLineImpl( doc );
|
PFlushLineImpl( doc );
|
||||||
|
|
||||||
TY_(WriteChar)( '\n', doc->docOut );
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
pprint->line++;
|
||||||
pprint->indent[ 0 ].spaces = indent;
|
pprint->indent[ 0 ].spaces = indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,6 +717,7 @@ static void PCondFlushLine( TidyDocImpl* doc, uint indent )
|
||||||
PFlushLineImpl( doc );
|
PFlushLineImpl( doc );
|
||||||
|
|
||||||
TY_(WriteChar)( '\n', doc->docOut );
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
pprint->line++;
|
||||||
pprint->indent[ 0 ].spaces = indent;
|
pprint->indent[ 0 ].spaces = indent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -733,6 +738,7 @@ void TY_(PFlushLineSmart)( TidyDocImpl* doc, uint indent )
|
||||||
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
if(TidyAddVS) {
|
if(TidyAddVS) {
|
||||||
TY_(WriteChar)( '\n', doc->docOut );
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
pprint->line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pprint->indent[ 0 ].spaces = indent;
|
pprint->indent[ 0 ].spaces = indent;
|
||||||
|
@ -749,6 +755,7 @@ static void PCondFlushLineSmart( TidyDocImpl* doc, uint indent )
|
||||||
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
if(TidyAddVS) {
|
if(TidyAddVS) {
|
||||||
TY_(WriteChar)( '\n', doc->docOut );
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
pprint->line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pprint->indent[ 0 ].spaces = indent;
|
pprint->indent[ 0 ].spaces = indent;
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct _TidyPrintImpl
|
||||||
uint lbufsize;
|
uint lbufsize;
|
||||||
uint linelen;
|
uint linelen;
|
||||||
uint wraphere;
|
uint wraphere;
|
||||||
|
uint line;
|
||||||
|
|
||||||
uint ixInd;
|
uint ixInd;
|
||||||
TidyIndent indent[2]; /* Two lines worth of indent state */
|
TidyIndent indent[2]; /* Two lines worth of indent state */
|
||||||
|
|
Loading…
Reference in a new issue