| Server IP : 82.208.35.60 / Your IP : 216.73.216.168 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/local/share/doc/slang/tm/rtl/ |
Upload File : |
#!/usr/bin/env slsh
private define check_file (file)
{
variable infun = 0, inexample = 0, innotes = 0, indescr = 0;
variable fp = fopen (file, "r");
variable fun_name = "";
variable line, strs;
variable lineno = 0;
while (-1 != fgets (&line, fp))
{
lineno++;
if (line[0] != '\\')
{
if (inexample) inexample++;
if (innotes) innotes++;
if (indescr) indescr++;
continue;
}
if (0 == strncmp (line, "\function{"R, 10))
{
strs = string_matches (line, "\\function{\([^}]*\)}"R, 1);
if (strs == NULL)
{
() = fprintf (stderr, "%s:%d:Bad function start after function %s\n",
file, lineno, fun_name);
continue;
}
if (infun)
{
() = fprintf (stderr, "%s:%d:Missing \\done for function %s\n",
file, lineno, fun_name);
infun = 0;
}
fun_name = strs[1];
infun++;
inexample=0;
innotes=0;
indescr=0;
continue;
}
if (inexample == 1)
{
() = fprintf (stderr, "%s:%d:Empty Example in %s\n",
file, lineno, fun_name);
inexample = 0;
}
if (innotes == 1)
{
() = fprintf (stderr, "%s:%d:Empty Notes in %s\n",
file, lineno, fun_name);
innotes = 0;
}
if (indescr == 1)
{
() = fprintf (stderr, "%s:%d:Empty Description in %s\n",
file, lineno, fun_name);
indescr = 0;
}
if (0 == strncmp (line, "\example"R, 8))
{
inexample++;
continue;
}
if (0 == strncmp (line, "\description"R, 12))
{
indescr++;
continue;
}
if (0 == strncmp (line, "\notes"R, 6))
{
innotes++;
continue;
}
if (strncmp (line, "\done"R, 5))
infun = 0;
}
}
define slsh_main ()
{
if (__argc < 2)
{
() = fprintf (stderr, "Usage: %s files...\n", __argv[0]);
exit (1);
}
variable files = __argv[[1:]];
foreach (files)
{
variable file = ();
check_file (file);
}
}