This commit is contained in:
Miloslav Ciz 2023-03-23 21:27:33 +01:00
parent c4013d7128
commit 616f5729ec
2 changed files with 57 additions and 0 deletions

52
mark_dead_links.c Normal file
View file

@ -0,0 +1,52 @@
#include <stdio.h>
int main(void)
{
int c, state = 0, filenameLen = 0;
char filename[256];
while ((c = getchar()) != EOF)
{
putchar(c);
switch (state)
{
case 0: if (c == '<') state = 1; break;
case 1: state = c == 'a' ? 2 : 0; break;
case 2: state = c == ' ' ? 3 : 0; break;
case 3: state = c == 'h' ? 4 : 0; break;
case 4: state = c == 'r' ? 5 : 0; break;
case 5: state = c == 'e' ? 6 : 0; break;
case 6: state = c == 'f' ? 7 : 0; break;
case 7: state = c == '=' ? 8 : 0; break;
case 8: state = c == '"' ? 9 : 0; break;
case 9:
if (c == '"')
{
filename[filenameLen] = 0;
FILE *f = fopen(filename,"r");
if (!f)
printf(" class=\"dead\"");
else
fclose(f);
filenameLen = 0;
state = 0;
}
else if (filenameLen < 128)
{
filename[filenameLen] = c;
filenameLen++;
}
break;
default: break;
}
}
return 0;
}

View file

@ -13,3 +13,8 @@ table td, th
border: 1px solid black;
padding: 4px;
}
.dead
{
color: red;
}