[LOG2LINES] Fix indentation.

This commit is contained in:
Hermès Bélusca-Maïto 2018-12-08 17:31:17 +01:00
parent f5f515c17c
commit dbaa875f05
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -420,120 +420,120 @@ translate_files(FILE *inFile, FILE *outFile)
const char *p = kdbg_prompt; const char *p = kdbg_prompt;
const char *p_eos = p + sizeof(KDBG_PROMPT) - 1; //end of string pos const char *p_eos = p + sizeof(KDBG_PROMPT) - 1; //end of string pos
memset(Line, '\0', LINESIZE + 1); memset(Line, '\0', LINESIZE + 1);
if (opt_console) if (opt_console)
{
while ((c = fgetc(inFile)) != EOF)
{ {
while ((c = fgetc(inFile)) != EOF) if (opt_quit)break;
ch = (unsigned char)c;
if (!opt_raw)
{ {
if (opt_quit)break; switch (ch)
ch = (unsigned char)c;
if (!opt_raw)
{ {
switch (ch) case '\n':
if ( strncmp(Line, KDBG_DISCARD, sizeof(KDBG_DISCARD)-1) == 0 )
{ {
case '\n': memset(Line, '\0', LINESIZE); // flushed
if ( strncmp(Line, KDBG_DISCARD, sizeof(KDBG_DISCARD)-1) == 0 ) }
else
{
Line[1] = handle_escape_cmd(outFile, Line, path, LineOut);
if (Line[1] != KDBG_ESC_CHAR)
{ {
memset(Line, '\0', LINESIZE); // flushed if (p == p_eos)
}
else
{
Line[1] = handle_escape_cmd(outFile, Line, path, LineOut);
if (Line[1] != KDBG_ESC_CHAR)
{ {
if (p == p_eos) // kdbg prompt, so already echoed char by char
{ memset(Line, '\0', LINESIZE);
// kdbg prompt, so already echoed char by char translate_char(c, outFile);
memset(Line, '\0', LINESIZE);
translate_char(c, outFile);
}
else
{
if (match_line(outFile, Line))
{
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
report(outFile);
}
}
}
}
i = 0;
p = kdbg_prompt;
pc = kdbg_cont;
break;
case '<':
i = 0;
Line[i++] = ch;
break;
case '>':
if (ch == *p)
{
p = p_eos;
translate_line(outFile, Line, path, LineOut);
}
if (p != p_eos)
{
if (i < LINESIZE)
{
Line[i++] = ch;
translate_line(outFile, Line, path, LineOut);
} }
else else
{ {
translate_line(outFile, Line, path, LineOut); if (match_line(outFile, Line))
translate_char(c, outFile); {
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
report(outFile);
}
} }
} }
else }
translate_char(c, outFile); i = 0;
i = 0; p = kdbg_prompt;
break; pc = kdbg_cont;
default: break;
if (ch == *p)p++; case '<':
if (ch == *pc)pc++; i = 0;
Line[i++] = ch;
break;
case '>':
if (ch == *p)
{
p = p_eos;
translate_line(outFile, Line, path, LineOut);
}
if (p != p_eos)
{
if (i < LINESIZE) if (i < LINESIZE)
{ {
Line[i++] = ch; Line[i++] = ch;
if (p == p_eos) translate_line(outFile, Line, path, LineOut);
{
translate_char(c, outFile);
}
else if (!*pc)
{
translate_line(outFile, Line, path, LineOut);
i = 0;
}
} }
else else
{ {
translate_line(outFile, Line, path, LineOut); translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile); translate_char(c, outFile);
}
}
else
translate_char(c, outFile);
i = 0;
break;
default:
if (ch == *p)p++;
if (ch == *pc)pc++;
if (i < LINESIZE)
{
Line[i++] = ch;
if (p == p_eos)
{
translate_char(c, outFile);
}
else if (!*pc)
{
translate_line(outFile, Line, path, LineOut);
i = 0; i = 0;
} }
} }
else
{
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
i = 0;
}
} }
else
translate_char(c, outFile);
} }
else
translate_char(c, outFile);
} }
else }
{ // Line by line, slightly faster but less interactive else
while (fgets(Line, LINESIZE, inFile) != NULL) { // Line by line, slightly faster but less interactive
{ while (fgets(Line, LINESIZE, inFile) != NULL)
if (opt_quit)break; {
if (opt_quit)break;
if (!opt_raw) if (!opt_raw)
{ {
translate_line(outFile, Line, path, LineOut); translate_line(outFile, Line, path, LineOut);
report(outFile); report(outFile);
}
else
log(outFile, "%s", Line);
} }
else
log(outFile, "%s", Line);
} }
}
if (opt_Revision && (strstr(opt_Revision, "regscan") == opt_Revision)) if (opt_Revision && (strstr(opt_Revision, "regscan") == opt_Revision))
{ {