hmml_to_html.c: Fix integration [#25]

This commit is contained in:
Matt Mascarenhas 2017-06-15 23:10:36 +01:00
parent 811abe6271
commit d08f45a75a
1 changed files with 27 additions and 6 deletions

View File

@ -1,6 +1,6 @@
#if 0 #if 0
ctime -begin ${0%.*}.ctm ctime -begin ${0%.*}.ctm
gcc -g -Wall -fsanitize=address -std=c99 $0 -o ${0%.*} hmml.a gcc -g -Wall -fsanitize=address -std=c99 -pipe $0 -o ${0%.*} hmml.a
ctime -end ${0%.*}.ctm ctime -end ${0%.*}.ctm
exit exit
#endif #endif
@ -179,6 +179,7 @@ CopyStringNoFormat(char *Dest, char *String)
*Dest++ = *String++; *Dest++ = *String++;
++Length; ++Length;
} }
*Dest = '\0';
return Length; return Length;
} }
@ -2431,7 +2432,7 @@ HMML.metadata.project);
(TemplatePtr+2 - TemplateBuffer < TemplateSize && TemplatePtr[2] == '-')) (TemplatePtr+2 - TemplateBuffer < TemplateSize && TemplatePtr[2] == '-'))
{ {
char *CommentStart = &OutputPtr[-1]; char *CommentStart = &OutputPtr[-1];
while(TemplatePtr - TemplateBuffer < TemplateSize && *TemplatePtr != '>') while(TemplatePtr - TemplateBuffer < TemplateSize)
{ {
if(*TemplatePtr == '_') if(*TemplatePtr == '_')
{ {
@ -2445,11 +2446,16 @@ HMML.metadata.project);
FoundHeader = TRUE; FoundHeader = TRUE;
OutputPtr = CommentStart; OutputPtr = CommentStart;
OutputPtr += CopyStringNoFormat(OutputPtr, Header.Location); OutputPtr += CopyStringNoFormat(OutputPtr, Header.Location);
while(TemplatePtr - TemplateBuffer < TemplateSize && *TemplatePtr != '>') while(TemplatePtr - TemplateBuffer < TemplateSize)
{ {
if(TemplatePtr[0] == '>' && TemplatePtr[-1] == '-' && TemplatePtr[-2] == '-')
{
break;
}
++TemplatePtr; ++TemplatePtr;
} }
++TemplatePtr; ++TemplatePtr;
break;
} }
else if(!(StringsDifferT(TitleTag, TemplatePtr, '\0'))) else if(!(StringsDifferT(TitleTag, TemplatePtr, '\0')))
{ {
@ -2466,11 +2472,16 @@ HMML.metadata.project);
FoundTitle = TRUE; FoundTitle = TRUE;
OutputPtr = CommentStart; OutputPtr = CommentStart;
OutputPtr += CopyStringNoFormat(OutputPtr, Title.Location); OutputPtr += CopyStringNoFormat(OutputPtr, Title.Location);
while(TemplatePtr - TemplateBuffer < TemplateSize && *TemplatePtr != '>') while(TemplatePtr - TemplateBuffer < TemplateSize)
{ {
if(TemplatePtr[0] == '>' && TemplatePtr[-1] == '-' && TemplatePtr[-2] == '-')
{
break;
}
++TemplatePtr; ++TemplatePtr;
} }
++TemplatePtr; ++TemplatePtr;
break;
} }
else if(!(StringsDifferT(PlayerTag, TemplatePtr, '\0'))) else if(!(StringsDifferT(PlayerTag, TemplatePtr, '\0')))
{ {
@ -2482,11 +2493,16 @@ HMML.metadata.project);
FoundPlayer = TRUE; FoundPlayer = TRUE;
OutputPtr = CommentStart; OutputPtr = CommentStart;
OutputPtr += CopyStringNoFormat(OutputPtr, Player.Location); OutputPtr += CopyStringNoFormat(OutputPtr, Player.Location);
while(TemplatePtr - TemplateBuffer < TemplateSize && *TemplatePtr != '>') while(TemplatePtr - TemplateBuffer < TemplateSize)
{ {
if(TemplatePtr[0] == '>' && TemplatePtr[-1] == '-' && TemplatePtr[-2] == '-')
{
break;
}
++TemplatePtr; ++TemplatePtr;
} }
++TemplatePtr; ++TemplatePtr;
break;
} }
else if(!(StringsDifferT(ScriptTag, TemplatePtr, '\0'))) else if(!(StringsDifferT(ScriptTag, TemplatePtr, '\0')))
{ {
@ -2498,11 +2514,16 @@ HMML.metadata.project);
FoundScript = TRUE; FoundScript = TRUE;
OutputPtr = CommentStart; OutputPtr = CommentStart;
OutputPtr += CopyStringNoFormat(OutputPtr, Script.Location); OutputPtr += CopyStringNoFormat(OutputPtr, Script.Location);
while(TemplatePtr - TemplateBuffer < TemplateSize && *TemplatePtr != '>') while(TemplatePtr - TemplateBuffer < TemplateSize)
{ {
if(TemplatePtr[0] == '>' && TemplatePtr[-1] == '-' && TemplatePtr[-2] == '-')
{
break;
}
++TemplatePtr; ++TemplatePtr;
} }
++TemplatePtr; ++TemplatePtr;
break;
} }
} }
*OutputPtr++ = *TemplatePtr++; *OutputPtr++ = *TemplatePtr++;