diff --git a/hmml_to_html/hmml_to_html.c b/hmml_to_html/hmml_to_html.c index ba18259..00197dd 100644 --- a/hmml_to_html/hmml_to_html.c +++ b/hmml_to_html/hmml_to_html.c @@ -23,6 +23,15 @@ typedef struct int Size; } buffer; +void +ClaimBuffer(char *MemoryArena, int *ClaimedMemory, buffer *Buffer, int Size) +{ + Buffer->Location = MemoryArena + *ClaimedMemory; + Buffer->Size = Size; + *ClaimedMemory += Buffer->Size; + Buffer->Ptr = Buffer->Location; +} + int TimecodeToSeconds(char *Timecode) { @@ -55,6 +64,25 @@ TimecodeToSeconds(char *Timecode) return HMS[2] * 60 * 60 + HMS[1] * 60 + HMS[0]; } +void +CopyBuffer(buffer *Src, buffer *Dest) +{ + Src->Ptr = Src->Location; + while(*Src->Ptr) + { + *Dest->Ptr++ = *Src->Ptr++; + } +} + +void +CopyStringToBuffer(char *Src, buffer *Dest) +{ + while(*Src) + { + *Dest->Ptr++ = *Src++; + } +} + int main(int ArgC, char **Args) { @@ -66,8 +94,7 @@ main(int ArgC, char **Args) // NOTE(matt): Init MemoryArena char *MemoryArena; - // TODO(matt): Actually calculate how much memory I'll need - int ArenaSize = 1024 * 512; + int ArenaSize = 1024 * 1024; if(!(MemoryArena = calloc(ArenaSize, 1))) { perror(Args[0]); @@ -81,10 +108,8 @@ main(int ArgC, char **Args) buffer Text; buffer Out; - Out.Location = MemoryArena + ClaimedMemory; - Out.Size = 1024 * 200; - ClaimedMemory += Out.Size; - + ClaimBuffer(MemoryArena, &ClaimedMemory, &Out, 1024 * 512); + for(int FileIndex = 1; FileIndex < ArgC; ++FileIndex) { FILE *InFile; @@ -100,9 +125,7 @@ main(int ArgC, char **Args) if(HMML.well_formed) { - Working.Location = MemoryArena + ClaimedMemory; - Working.Size = 1024 * 1; - ClaimedMemory += Working.Size; + ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024); sprintf(Working.Location, "\n" @@ -117,13 +140,9 @@ main(int ArgC, char **Args) "
\n" " %s\n", HMML.metadata.title); - Working.Ptr = Working.Location; Out.Ptr = Out.Location; - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + CopyBuffer(&Working, &Out); int AnnotationIndex = 0; int ReferenceIndex = 1; @@ -137,11 +156,7 @@ main(int ArgC, char **Args) "
\n" "
\n"); - Working.Ptr = Working.Location; - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + CopyBuffer(&Working, &Out); while(AnnotationIndex < HMML.annotation_count) { @@ -169,11 +184,7 @@ TimecodeToSeconds(HMML.annotations[AnnotationIndex].time), ReferenceIndex, HMML.annotations[AnnotationIndex].time); - Working.Ptr = Working.Location; - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + CopyBuffer(&Working, &Out); ++ReferenceIndex; } ++AnnotationIndex; @@ -191,12 +202,7 @@ HMML.annotations[AnnotationIndex].time); "
\n" "
\n", HMML.metadata.annotator, HMML.metadata.id); - Working.Ptr = Working.Location; - - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + CopyBuffer(&Working, &Out); int DataRef = 1; @@ -204,10 +210,7 @@ HMML.annotations[AnnotationIndex].time); { InPtr = HMML.annotations[AnnotationIndex].text; - Text.Location = MemoryArena + ClaimedMemory; - Text.Size = 256; - ClaimedMemory += Text.Size; - Text.Ptr = Text.Location; + ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 256); if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote) { @@ -257,28 +260,18 @@ HMML.annotations[AnnotationIndex].time); Text.Ptr += Inc; ++DataRef; } - while(*InPtr) - { - *Text.Ptr++ = *InPtr++; - } + CopyStringToBuffer(InPtr, &Text); } else { sprintf(Working.Location, "
\n", TimecodeToSeconds(HMML.annotations[AnnotationIndex].time)); - while(*InPtr) - { - *Text.Ptr++ = *InPtr++; - } + CopyStringToBuffer(InPtr, &Text); } *Text.Ptr = '\0'; - Text.Ptr = Text.Location; - Working.Ptr = Working.Location; - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + + CopyBuffer(&Working, &Out); sprintf(Working.Location, "
%s%s
\n" @@ -295,14 +288,10 @@ HMML.annotations[AnnotationIndex].time); Text.Location, HMML.annotations[AnnotationIndex].time, Text.Location); - Working.Ptr = Working.Location; ClaimedMemory -= Text.Size; - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + CopyBuffer(&Working, &Out); } sprintf(Working.Location, @@ -376,11 +365,7 @@ HMML.annotations[AnnotationIndex].time); " \n" "\n"); - Working.Ptr = Working.Location; - while(*Working.Ptr) - { - *Out.Ptr++ = *Working.Ptr++; - } + CopyBuffer(&Working, &Out); hmml_free(&HMML); diff --git a/hmml_to_html/out.html b/hmml_to_html/out.html index 3cd8126..5987a9f 100644 --- a/hmml_to_html/out.html +++ b/hmml_to_html/out.html @@ -18,42 +18,54 @@
GitHub
instructions.scala
- [1]9:03 +
+ [1]9:03 +
Wikipedia
Register-transfer level
- [2]9:03 +
+ [2]9:03 +
SiFive Forums
Confusion Regarding Freedom E SDK inline asm
- [3]15:55 +
+ [3]15:55 +
-
RISC-V"
+
RISC-V
User-Level ISA Specification v2.1
- [4]22:24 +
+ [4]22:24 +
ericw.
A Tiny Guide to GCC Inline Assembly
- [5]28:53 +
+ [5]28:53 +
RISC-V
Draft Privileged ISA Specification v1.9.1
- [6]40:21 +
+ [6]40:21 +
diff --git a/hmml_to_html/style.css b/hmml_to_html/style.css index 0f7d53e..20a390b 100644 --- a/hmml_to_html/style.css +++ b/hmml_to_html/style.css @@ -213,7 +213,6 @@ body { .refs .ref .ref_content { width: 100%; - text-align: center; } .refs .ref .source { @@ -222,6 +221,10 @@ body { line-height: 8px; } +.refs .ref .ref_title { + font-style: oblique; +} + .refs .ref .timecode .ref_index { margin-right: 4px; }