Update log2lines to ver. 2.1. Jan Roeloffzen, bug #4342.

svn path=/trunk/; revision=45551
This commit is contained in:
Dmitry Gorbachev 2010-02-10 12:10:23 +00:00
parent 9709c3dfb9
commit 909e0c1b43
23 changed files with 591 additions and 92 deletions

View file

@ -11,12 +11,10 @@
#include "util.h"
#include "version.h"
#include "compat.h"
#include "config.h"
#include "list.h"
#include "options.h"
#include "help.h"
#include "image.h"
#include "revision.h"
#include "log2lines.h"
static char *cache_name;
@ -77,11 +75,6 @@ check_directory(int force)
char *check_iso;
char *check_dir;
if (opt_Revision)
{
revinfo.rev = getRevision(NULL, 1);
revinfo.range = DEF_RANGE;
}
check_iso = strrchr(opt_dir, '.');
l2l_dbg(1, "Checking directory: %s\n", opt_dir);
if (check_iso && PATHCMP(check_iso, ".7z") == 0)
@ -139,11 +132,6 @@ check_directory(int force)
return 1;
}
}
if (opt_Revision)
{
revinfo.buildrev = getTBRevision(opt_dir);
l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev);
}
cache_name = malloc(MAX_PATH);
tmp_name = malloc(MAX_PATH);
strcpy(cache_name, opt_dir);
@ -238,10 +226,11 @@ create_cache(int force, int skipImageBase)
l2l_dbg(0, "Scanning %s ...\n", opt_dir);
snprintf(Line, LINESIZE, DIR_FMT, opt_dir, tmp_name);
l2l_dbg(1, "Executing: %s\n", Line);
if (system(Line) < 0)
if (system(Line) != 0)
{
l2l_dbg(0, "Cannot list directory %s\n", opt_dir);
l2l_dbg(1, "Failed to execute: '%s'\n", Line);
remove(tmp_name);
return 2;
}
l2l_dbg(0, "Creating cache ...");

View file

@ -13,3 +13,5 @@ int read_cache(void);
int create_cache(int force, int skipImageBase);
#endif /* __L2L_CACHE_H__ */
/* EOF */

View file

@ -0,0 +1,291 @@
/*
* ReactOS log2lines
* Written by Jan Roeloffzen
*
* - Cli for escape commands
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "util.h"
#include "cmd.h"
#include "options.h"
#include "log2lines.h"
#include "help.h"
/* When you edit the cmd line and/or use the history instead of just typing,
* a bunch of editing BS and space characters
* is inserted, so the string looks right on the console but still
* starts with the original string:
*/
static char
*backSpaceEdit(char *s)
{
char c;
char *edit = s;
char *text = s;
while (( c = *edit++ ))
{
switch (c)
{
case KDBG_BS_CHAR:
if (text > s)
text --;
break;
default:
*text++ = c;
}
}
*text = '\0';
return s;
}
static int
handle_switch(FILE *outFile, int *sw, char *arg, char *desc)
{
int changed =0;
int x = 0;
if (arg && (strcmp(arg,"") != 0))
{
x = atoi(arg);
if (x != *sw)
{
*sw = x;
changed = 1;
}
}
if (desc)
{
esclog(outFile, "%s is %d (%s)\n", desc, *sw, changed ? "changed":"unchanged");
if (!arg)
esclog(outFile, "(readonly)\n");
}
return changed;
}
static int
handle_switch_str(FILE *outFile, char *sw, char *arg, char *desc)
{
int changed =0;
if (arg)
{
if (strcmp(arg,"") != 0)
{
if (strcmp(arg,KDBG_ESC_OFF) == 0)
{
if (*sw)
changed = 1;
*sw = '\0';
}
else if (strcmp(arg, sw) != 0)
{
strcpy(sw, arg);
changed = 1;
}
}
}
if (desc)
{
esclog(outFile, "%s is \"%s\" (%s)\n", desc, sw, changed ? "changed":"unchanged");
if (!arg)
esclog(outFile, "(readonly)\n");
}
return changed;
}
static int
handle_switch_pstr(FILE *outFile, char **psw, char *arg, char *desc)
{
int changed =0;
if (arg)
{
if (strcmp(arg,"") != 0)
{
if (strcmp(arg,KDBG_ESC_OFF) == 0)
{
if (*psw)
changed = 1;
free(*psw);
*psw = NULL;
}
else
{
if (!*psw)
{
*psw = malloc(LINESIZE);
**psw = '\0';
}
if (strcmp(arg, *psw) != 0)
{
strcpy(*psw, arg);
changed = 1;
}
}
}
}
if (desc)
{
esclog(outFile, "%s is \"%s\" (%s)\n", desc, *psw, changed ? "changed":"unchanged");
if (!arg)
esclog(outFile, "(readonly)\n");
}
return changed;
}
char
handle_escape_cmd(FILE *outFile, char *Line, char *path, char *LineOut)
{
char cmd;
char sep = '\n';
char *arg;
char *l = Line;
int res = 1;
int cnt = 0;
int changed = 0;
l = backSpaceEdit(l);
if (l[1] != KDBG_ESC_CHAR)
return l[1]; //for reprocessing as not escaped
log(outFile, "\n");
l += 2; //skip space+escape character
if ( (cnt=sscanf(l,"%c%c",&cmd,&sep)) < 1)
{
esclog(outFile, "Command expected\n");
res = 0;
}
if (res && cnt==2 && sep != ' ')
{
esclog(outFile, "' ' expected\n");
res = 0;
}
l++; //skip cmd
while ( *l == ' ')l++; //skip more spaces
arg = l;
opt_cli = 1;
switch (cmd)
{
case 'h':
usage(1);
break;
case 'b':
if (handle_switch(outFile, &opt_buffered, arg, "-b Logfile buffering"))
set_LogFile(logFile); //re-open same logfile
break;
case 'c':
handle_switch(outFile, &opt_console, NULL, "-c Console option");
break;
case 'd':
handle_switch_str(outFile, opt_dir, NULL, "-d Directory option");
break;
case 'l':
if (handle_switch_str(outFile, opt_logFile, arg, "-l logfile"))
set_LogFile(logFile); //open new logfile
break;
case 'm':
handle_switch(outFile, &opt_Mark, arg, "-m mark (*)");
break;
case 'M':
handle_switch(outFile, &opt_Mark, arg, "-M Mark (?)");
break;
case 'P':
handle_switch_str(outFile, opt_Pipe, NULL, "-P Pipeline option");
break;
case 'q':
opt_quit = 1;
esclog(outFile, "Bye!\n");
break;
case 'r':
handle_switch(outFile, &opt_raw, arg, "-r Raw");
break;
case 'R':
changed = handle_switch_pstr(outFile, &opt_Revision, arg, NULL);
if (opt_Revision)
{
if (strstr(opt_Revision, "check") == opt_Revision)
{
esclog(outFile, "-R is \"%s\" (%s)\n", opt_Revision, changed ? "changed":"unchanged");
}
else if (strstr(opt_Revision, "regscan") == opt_Revision)
{
char *s = strchr(opt_Revision, ',');
revinfo.range = DEF_RANGE;
if (s)
{
*s++ = '\0';
revinfo.range = atoi(s);
}
regscan(outFile);
}
else if (strstr(opt_Revision, "regclear") == opt_Revision)
{
list_clear(&sources);
summ.regfound = 0;
esclog(outFile, "cleared regression scan results\n");
}
}
break;
case 's':
if (strcmp(arg,"clear") == 0)
{
memset(&summ, 0, sizeof(SUMM));
esclog(outFile, "Statistics cleared\n");
}
else
stat_print(outFile, &summ);
break;
case 'S':
cnt = sscanf(arg, "%d+%d", &opt_Source, &opt_SrcPlus);
if (opt_Source)
{
handle_switch(outFile, &opt_undo, "1", "-u Undo");
handle_switch(outFile, &opt_redo, "1", "-U Undo and reprocess");
}
esclog(outFile, "-S Sources option is %d+%d,\"%s\"\n", opt_Source, opt_SrcPlus, opt_SourcesPath);
esclog(outFile, "(Setting source tree not implemented)\n");
break;
case 't':
handle_switch(outFile, &opt_twice, arg, "-t Translate twice");
break;
case 'T':
handle_switch(outFile, &opt_twice, arg, NULL);
handle_switch(outFile, &opt_Twice, arg, "-T Translate for (address-1)");
break;
case 'u':
handle_switch(outFile, &opt_undo, arg, "-u undo");
break;
case 'U':
handle_switch(outFile, &opt_undo, arg, NULL);
handle_switch(outFile, &opt_redo, arg, "-U Undo and reprocess");
break;
case 'v':
handle_switch(outFile, &opt_verbose, arg, "-v Verbosity");
break;
case 'z':
handle_switch_str(outFile, opt_7z, NULL, "-z 7z path");
break;
default:
if (strchr(optchars, cmd))
esclog(outFile, "Command not implemented in cli: %c %s\n",cmd, arg)
else
esclog(outFile, "Unknown command: %c %s\n",cmd, arg);
}
opt_cli = 0;
memset(Line, '\0', LINESIZE); // flushed
return KDBG_ESC_CHAR; //handled escaped command
}

View file

@ -0,0 +1,26 @@
/*
* ReactOS log2lines
* Written by Jan Roeloffzen
*
* - Cli for escape commands
*/
#ifndef __L2L_CMD_H__
#define __L2L_CMD_H__
#include <stdio.h>
#define KDBG_BS_CHAR 0x08
#define KDBG_ESC_CHAR '`'
#define KDBG_ESC_STR "`"
#define KDBG_ESC_RESP "| L2L- "
#define KDBG_ESC_OFF "off"
#define KDBG_PROMPT "kdb:>" //Start interactive (-c) after this pattern
#define KDBG_CONT "---" //Also after this pattern (prompt with no line ending)
#define KDBG_DISCARD "Command '" KDBG_ESC_STR //Discard responses at l2l escape commands
char handle_escape_cmd(FILE *outFile, char *Line, char *path, char *LineOut);
#endif /* __L2L_CMD_H__ */
/* EOF */

View file

@ -37,3 +37,5 @@
#endif /* __L2L_COMPAT_H__ */
/* EOF */

View file

@ -15,7 +15,6 @@
#define CACHEFILE "log2lines.cache"
#define TRKBUILDPREFIX "bootcd-"
#define SVN_PREFIX "/trunk/reactos/"
#define KDBG_PROMPT "kdbg>"
#define PIPEREAD_CMD "piperead -c"
@ -32,3 +31,5 @@ PATH_STR "reactos" PATH_STR "reactos > " DEV_NULL
#define NAMESIZE 80
#endif /* __L2L_CONFIG_H__ */
/* EOF */

View file

@ -10,6 +10,7 @@
#include "compat.h"
#include "config.h"
#include "options.h"
#include "cmd.h"
#include "help.h"
char *verboseUsage =
@ -76,7 +77,7 @@ char *verboseUsage =
" - regscan[,<range>]:\n"
" Scan for regression candidates. Essentially it tries to find\n"
" matches between the SVN log entries and the sources hit by\n"
" the backtrace.\n"
" a backtrace (bt) command.\n"
" <range> is the amount of revisions to look back from the build\n"
" revision (default 500)\n"
" The output of '-R regscan' is printed after EOF. The 'Changed path'\n"
@ -130,7 +131,25 @@ char *verboseUsage =
" <path to 7z>: Specify path to 7z. See also option -d.\n"
" Default: '7z'\n"
"\n"
"Examples:\n"
"CLI escape commands:\n"
" It is possible to change options and perform actions from the 'kdb:>' prompt\n"
" By prepending the `(backquote) character to the option.\n"
" Example: 'kdb:> `l new.log' changes the current logfile to 'new.log'.\n"
" Flag options like 'b' are given a numeric value of 0 (off) or 1 (on).\n"
" Options accepting a string as argument can be cleared by the value '" KDBG_ESC_OFF "'.\n"
" Some ClI commands are read only or not (entirely) implemented.\n"
" If no value is provided, the current one is printed.\n"
" There are only a few extra ClI commands or with different behaviour:\n"
" - `h : shows this helptext (without exiting)\n"
" - `q : quits log2lines\n"
" - `R regscan : the output is printed immediately (do a 'bt' first)\n"
" - `R regclear : clears previous regscan matches\n"
" - `s : the output is printed immediately\n"
" - `s clear : clears all statistics.\n"
" - `S : only <context> and <add> can be set.\n"
" - `v <level> : sets the current debug loglevel\n"
"\n"
"Option Examples:\n"
" Setup: A VMware machine with its serial port set to: '\\\\.\\pipe\\kdbg'.\n\n"
" Just recreate cache after a svn update or a new module has been added:\n"
" log2lines -F\n\n"
@ -179,7 +198,42 @@ char *verboseUsage =
" <msi.dll:5262 (dll/win32/msi/action.c:2665 (ACTION_ProcessComponents))>\n"
" | R--- Conflict : source(44191) > build(43850)\n"
" | 2664 else\n"
" | 2665 rc = MSIREG_OpenUserDataKey(comp->ComponentId,\n"
" | 2665 rc = MSIREG_OpenUserDataKey(comp->ComponentId,\n\n"
"CLI Examples: (some are based on the option examples above)\n"
" Use '`R check' to show that action.c has been changed after the build:\n"
" kdb:> `R check\n"
" | L2L- -R is \"check\" (changed)\n"
" kdb:> bt\n"
" <msi.dll:35821 (dll/win32/msi/registry.c:781 (MSIREG_OpenUserDataKey))>\n"
" | 0780 if (create)\n"
" | 0781 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);\n"
" <msi.dll:5262 (dll/win32/msi/action.c:2665 (ACTION_ProcessComponents))>\n"
" | R--- Conflict : source(44191) > build(43850)\n"
" | 2664 else\n"
" | 2665 rc = MSIREG_OpenUserDataKey(comp->ComponentId,\n\n"
" kdb:>\n\n"
" Generate source lines. Show 2 lines of context plus 1 additional line.\n"
" The -Uu options are dependent on -S:\n"
" kdb:> `S 2+1\n"
" | L2L- -u Undo is 1 (changed)\n"
" | L2L- -U Undo and reprocess is 1 (changed)\n"
" | L2L- -S Sources option is 2+1,\"C:\\ROS\\reactos\\\" \n"
" | L2L- (Setting source tree not implemented)\n"
" kdb:> bt\n"
" <msi.dll:2e35d (dll/win32/msi/msiquery.c:189 (MSI_IterateRecords))>\n"
" | 0188 {\n"
" | 0189 r = MSI_ViewFetch( view, &rec );\n"
" | ----\n"
" | 0190 if( r != ERROR_SUCCESS )\n"
" kdb:>\n\n"
" Change logfile:\n"
" kdb:> `l\n"
" | L2L- -l logfile is "" (unchanged)\n"
" kdb:> `l new.log\n"
" | L2L- -l logfile is \"new.log\" (changed)\n"
" kdb:> `l off\n"
" | L2L- -l logfile is "" (changed)\n"
" kdb:>\n"
"\n";
void

View file

@ -13,3 +13,5 @@ extern char *verboseUsage;
void usage(int verbose);
#endif /* __L2L_HELP_H__ */
/* EOF */

View file

@ -4,6 +4,7 @@
*
* - Image functions for symbol info
*/
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <rsym.h>

View file

@ -20,3 +20,5 @@ int get_ImageBase(char *fname, size_t *ImageBase);
#endif /* __L2L_IMAGE_H__ */
/* EOF */

View file

@ -66,6 +66,19 @@ entry_insert(PLIST list, PLIST_MEMBER pentry)
return pentry;
}
void list_clear(PLIST list)
{
PLIST_MEMBER pentry = list->phead;
PLIST_MEMBER pnext;
while (pentry)
{
pnext = pentry->pnext;
entry_delete(pentry);
pentry = pnext;
}
list->phead = list->ptail = NULL;
}
#if 0
LIST_MEMBER *
entry_remove(LIST *list, LIST_MEMBER *pentry)

View file

@ -12,7 +12,6 @@ typedef struct entry_struct
typedef struct list_struct
{
off_t st_size;
PLIST_MEMBER phead;
PLIST_MEMBER ptail;
} LIST,*PLIST;
@ -22,5 +21,8 @@ PLIST_MEMBER entry_delete(PLIST_MEMBER pentry);
PLIST_MEMBER entry_insert(PLIST list, PLIST_MEMBER pentry);
PLIST_MEMBER cache_entry_create(char *Line);
PLIST_MEMBER sources_entry_create(PLIST list, char *path, char *prefix);
void list_clear(PLIST list);
#endif /* __L2L_LIST_H__ */
/* EOF */

View file

@ -2,7 +2,7 @@
* ReactOS log2lines
* Written by Jan Roeloffzen
*
* - Initialization and main loop
* - Initialization, translation and main loop
*/
#include <errno.h>
@ -13,17 +13,18 @@
#include "util.h"
#include "version.h"
#include "compat.h"
#include "config.h"
#include "list.h"
#include "options.h"
#include "image.h"
#include "cache.h"
#include "log2lines.h"
#include "help.h"
#include "cmd.h"
static FILE *stdIn = NULL;
static FILE *stdOut = NULL;
static const char *kdbg_prompt = KDBG_PROMPT;
static const char *kdbg_cont = KDBG_CONT;
LIST sources;
LINEINFO lastLine;
@ -65,6 +66,8 @@ log_file(FILE *outFile, char *fileName, int line)
i++;
}
fclose(src);
if ( i < min )
log(outFile, "| S--- source has only %d lines! (check source/revision)\n", i);
}
else
l2l_dbg(1, "Can't open: %s (check " SOURCES_ENV ")\n", s);
@ -332,7 +335,7 @@ translate_line(FILE *outFile, char *Line, char *path, char *LineOut)
/* Strip all lines added by this tool: */
char buf[NAMESIZE];
if (sscanf(s, "| %s", buf) == 1)
if (buf[0] == '0' || strcmp(buf, "----") == 0 || strcmp(buf, "R---") == 0 || atoi(buf))
if (buf[0] == '0' || strcmp(buf, "----") == 0 || strcmp(buf, "L2L-") == 0 || strcmp(buf, "S---") == 0 || strcmp(buf, "R---") == 0 || atoi(buf))
res = 0;
}
@ -410,6 +413,9 @@ translate_files(FILE *inFile, FILE *outFile)
int c;
unsigned char ch;
int i = 0;
const char *pc = kdbg_cont;
const char *p = kdbg_prompt;
const char *p_eos = p + sizeof(KDBG_PROMPT) - 1; //end of string pos
if (Line && path && LineOut)
{
@ -418,23 +424,53 @@ translate_files(FILE *inFile, FILE *outFile)
{
while ((c = fgetc(inFile)) != EOF)
{
if (opt_quit)break;
ch = (unsigned char)c;
if (!opt_raw)
{
switch (ch)
{
case '\n':
translate_line(outFile, Line, path, LineOut);
if ( strncmp(Line, KDBG_DISCARD, sizeof(KDBG_DISCARD)-1) == 0 )
{
memset(Line, '\0', LINESIZE); // flushed
}
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);
translate_char(c, outFile);
}
else
{
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
report(outFile);
}
}
}
i = 0;
translate_char(c, outFile);
report(outFile);
p = kdbg_prompt;
pc = kdbg_cont;
break;
case '<':
i = 0;
Line[i++] = ch;
break;
case '>':
if (i)
if (ch == *p)
{
p = p_eos;
translate_line(outFile, Line, path, LineOut);
}
if (p != p_eos)
{
if (i < LINESIZE)
{
@ -452,21 +488,27 @@ translate_files(FILE *inFile, FILE *outFile)
i = 0;
break;
default:
if (i)
if (ch == *p)p++;
if (ch == *pc)pc++;
if (i < LINESIZE)
{
if (i < LINESIZE)
Line[i++] = ch;
if (p == p_eos)
{
Line[i++] = ch;
translate_char(c, outFile);
}
else
else if (!*pc)
{
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
i = 0;
}
}
else
{
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
i = 0;
}
}
}
else
@ -477,6 +519,8 @@ translate_files(FILE *inFile, FILE *outFile)
{ // Line by line, slightly faster but less interactive
while (fgets(Line, LINESIZE, inFile) != NULL)
{
if (opt_quit)break;
if (!opt_raw)
{
translate_line(outFile, Line, path, LineOut);
@ -552,26 +596,8 @@ main(int argc, const char **argv)
read_cache();
l2l_dbg(4, "Cache read complete\n");
if (*opt_logFile)
{
logFile = fopen(opt_logFile, "a");
if (logFile)
{
// disable buffering so fflush is not needed
if (!opt_buffered)
{
l2l_dbg(1, "Disabling log buffering on %s\n", opt_logFile);
setbuf(logFile, NULL);
}
else
l2l_dbg(1, "Enabling log buffering on %s\n", opt_logFile);
}
else
{
l2l_dbg(0, "Could not open logfile %s (%s)\n", opt_logFile, strerror(errno));
return 2;
}
}
if (set_LogFile(logFile))
return 2;
l2l_dbg(4, "opt_logFile processed\n");
if (opt_Pipe)
@ -584,8 +610,6 @@ main(int argc, const char **argv)
l2l_dbg(0, "Could not popen '%s' (%s)\n", opt_Pipe, strerror(errno));
free(opt_Pipe); opt_Pipe = NULL;
}
free(opt_Pipe); opt_Pipe = NULL;
}
l2l_dbg(4, "opt_Pipe processed\n");

View file

@ -30,6 +30,7 @@ LOG2LINES_SOURCES = \
$(LOG2LINES_BASE_)image.c \
$(LOG2LINES_BASE_)stat.c \
$(LOG2LINES_BASE_)revision.c \
$(LOG2LINES_BASE_)cmd.c \
$(LOG2LINES_BASE_)log2lines.c \
$(RSYM_BASE_)rsym_common.c
@ -83,6 +84,10 @@ $(LOG2LINES_INT_)revision.o: $(LOG2LINES_BASE_)revision.c | $(LOG2LINES_INT)
$(ECHO_HOSTCC)
${host_gcc} $(LOG2LINES_HOST_CFLAGS) -c $< -o $@
$(LOG2LINES_INT_)cmd.o: $(LOG2LINES_BASE_)cmd.c | $(LOG2LINES_INT)
$(ECHO_HOSTCC)
${host_gcc} $(LOG2LINES_HOST_CFLAGS) -c $< -o $@
.PHONY: log2lines_clean
log2lines_clean:
-@$(rm) $(LOG2LINES_TARGET) $(LOG2LINES_OBJECTS) 2>$(NUL)

View file

@ -13,6 +13,7 @@
#include "compat.h"
#include "config.h"
#include "help.h"
#include "log2lines.h"
#include "options.h"
char *optchars = "bcd:fFhl:mMP:rR:sS:tTuUvz:";
@ -25,6 +26,8 @@ int opt_console = 0; // -c
int opt_mark = 0; // -m
int opt_Mark = 0; // -M
char *opt_Pipe = NULL; // -P
int opt_quit = 0; // -q (cli only)
int opt_cli = 0; // (cli internal)
int opt_raw = 0; // -r
int opt_stats = 0; // -s
int opt_Source = 0; // -S <opt_Source>[+<opt_SrcPlus>][,<sources_path>]
@ -46,29 +49,45 @@ int optionInit(int argc, const char **argv)
char *s;
strcpy(opt_dir, "");
strcpy(opt_logFile, "");
strcpy(opt_7z, CMD_7Z);
strcpy(opt_SourcesPath, "");
if ((s = getenv(SOURCES_ENV)))
strcpy(opt_SourcesPath, s);
revinfo.rev = getRevision(NULL, 1);
revinfo.range = DEF_RANGE;
revinfo.buildrev = getTBRevision(opt_dir);
l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev);
strcpy(opt_scanned, "");
for (i = 1; i < argc; i++)
{
if (strcmp(argv[i],"-P")==0)
if ((argv[i][0] == '-') && (i+1 < argc))
{
//Because its argument can contain spaces we cant use getopt(), a known bug:
if (i+1 < argc)
//Because these arguments can contain spaces we cant use getopt(), a known bug:
switch (argv[i][1])
{
case 'd':
strcpy(opt_dir, argv[i+1]);
break;
case 'l':
strcpy(opt_logFile, argv[i+1]);
break;
case 'P':
free(opt_Pipe);
opt_Pipe = malloc(LINESIZE);
strcpy(opt_Pipe, argv[i+1]);
break;
case 'z':
strcpy(opt_7z, argv[i+1]);
break;
}
}
strcat(opt_scanned, argv[i]);
strcat(opt_scanned, " ");
}
l2l_dbg(4,"opt_scanned=[%s]\n",opt_scanned);
strcpy(opt_logFile, "");
strcpy(opt_7z, CMD_7Z);
return 0;
}
@ -91,7 +110,7 @@ int optionParse(int argc, const char **argv)
break;
case 'd':
optCount++;
strcpy(opt_dir, optarg);
//just count, see optionInit()
break;
case 'f':
opt_force++;
@ -107,7 +126,7 @@ int optionParse(int argc, const char **argv)
break;
case 'l':
optCount++;
strcpy(opt_logFile, optarg);
//just count, see optionInit()
break;
case 'm':
opt_mark++;
@ -120,7 +139,7 @@ int optionParse(int argc, const char **argv)
break;
case 'P':
optCount++;
//just count, see above
//just count, see optionInit()
break;
case 'R':
optCount++;
@ -137,6 +156,12 @@ int optionParse(int argc, const char **argv)
if (i == 1)
sscanf(optarg, "%*d,%s", opt_SourcesPath);
l2l_dbg(3, "Sources option parse result: %d+%d,\"%s\"\n", opt_Source, opt_SrcPlus, opt_SourcesPath);
if (opt_Source)
{
/* need to retranslate for source info: */
opt_undo++;
opt_redo++;
}
break;
case 't':
opt_twice++;
@ -166,16 +191,15 @@ int optionParse(int argc, const char **argv)
}
optCount++;
}
if(opt_console)
{
l2l_dbg(2, "Note: use 's' command in console mode. Statistics option disabled\n");
opt_stats = 0;
}
if (opt_SourcesPath[0])
{
strcat(opt_SourcesPath, PATH_STR);
}
if (opt_Source)
{
/* need to retranslate for source info: */
opt_undo++;
opt_redo++;
}
if (!opt_dir[0])
{
strcpy(opt_dir, opt_SourcesPath);

View file

@ -18,6 +18,8 @@ extern int opt_console; // -c
extern int opt_mark; // -m
extern int opt_Mark; // -M
extern char *opt_Pipe; // -P
extern int opt_quit; // -q (cli only)
extern int opt_cli; // (cli internal)
extern int opt_raw; // -r
extern int opt_stats; // -s
extern int opt_Source; // -S <opt_Source>[+<opt_SrcPlus>][,<sources_path>]
@ -38,3 +40,5 @@ int optionInit(int argc, const char **argv);
int optionParse(int argc, const char **argv);
#endif /* __L2L_OPTIONS_H__ */
/* EOF */

View file

@ -13,7 +13,6 @@
#include "compat.h"
#include "util.h"
#include "options.h"
#include "revision.h"
#include "log2lines.h"
static void
@ -195,7 +194,7 @@ regscan(FILE *outFile)
char path[MAX_PATH];
char path2[MAX_PATH];
int wflag = 0;
log(outFile, "\nRegression candidates:\n");
clilog(outFile, "Regression candidates:\n");
while (( pos = findRev(finx, &r) ))
{
if (r < (revinfo.buildrev - revinfo.range))
@ -216,11 +215,11 @@ regscan(FILE *outFile)
{
if (wflag == 1)
{
log(outFile, "%sChanged paths:\n", line);
clilog(outFile, "%sChanged paths:\n", line);
summ.regfound++;
wflag = 2;
}
log(outFile, "%s", line2);
clilog(outFile, "%s", line2);
}
}
else
@ -229,11 +228,11 @@ regscan(FILE *outFile)
if (wflag == 2)
{
int i = 0;
log(outFile, "\n");
clilog(outFile, "\n");
while (fgets(line2, LINESIZE, flog))
{
i++;
log(outFile, "%s", line2);
clilog(outFile, "%s", line2);
if (strncmp(LOGBOTTOM, line2, sizeof(LOGBOTTOM) - 1) == 0)
break;
}

View file

@ -26,3 +26,5 @@ int regscan(FILE *outFile);
int updateSvnlog(void);
#endif /* __L2L_REVISION_H__ */
/* EOF */

View file

@ -10,7 +10,7 @@
#include "version.h"
#include "options.h"
#include "stat.h"
#include "util.h"
#include "log2lines.h"
void
@ -18,22 +18,22 @@ stat_print(FILE *outFile, PSUMM psumm)
{
if (outFile)
{
fprintf(outFile, "\n*** LOG2LINES SUMMARY ***\n");
fprintf(outFile, "Translated: %d\n", psumm->translated);
fprintf(outFile, "Reverted: %d\n", psumm->undo);
fprintf(outFile, "Retranslated: %d\n", psumm->redo);
fprintf(outFile, "Skipped: %d\n", psumm->skipped);
fprintf(outFile, "Differ: %d\n", psumm->diff);
fprintf(outFile, "Differ (function/source): %d\n", psumm->majordiff);
fprintf(outFile, "Revision conflicts: %d\n", psumm->revconflicts);
fprintf(outFile, "Regression candidates: %d\n", psumm->regfound);
fprintf(outFile, "Offset error: %d\n", psumm->offset_errors);
fprintf(outFile, "Total: %d\n", psumm->total);
fprintf(outFile, "-------------------------------\n");
fprintf(outFile, "Log2lines version: " LOG2LINES_VERSION "\n");
fprintf(outFile, "Directory: %s\n", opt_dir);
fprintf(outFile, "Passed options: %s\n", opt_scanned);
fprintf(outFile, "-------------------------------\n");
clilog(outFile, "*** LOG2LINES SUMMARY ***\n");
clilog(outFile, "Translated: %d\n", psumm->translated);
clilog(outFile, "Reverted: %d\n", psumm->undo);
clilog(outFile, "Retranslated: %d\n", psumm->redo);
clilog(outFile, "Skipped: %d\n", psumm->skipped);
clilog(outFile, "Differ: %d\n", psumm->diff);
clilog(outFile, "Differ (function/source): %d\n", psumm->majordiff);
clilog(outFile, "Revision conflicts: %d\n", psumm->revconflicts);
clilog(outFile, "Regression candidates: %d\n", psumm->regfound);
clilog(outFile, "Offset error: %d\n", psumm->offset_errors);
clilog(outFile, "Total: %d\n", psumm->total);
clilog(outFile, "-------------------------------\n");
clilog(outFile, "Log2lines version: " LOG2LINES_VERSION "\n");
clilog(outFile, "Directory: %s\n", opt_dir);
clilog(outFile, "Passed options: %s\n", opt_scanned);
clilog(outFile, "-------------------------------\n");
}
}

View file

@ -28,3 +28,5 @@ void stat_print(FILE *outFile, PSUMM psumm);
void stat_clear(PSUMM psumm);
#endif /* __L2L_STAT_H__ */
/* EOF */

View file

@ -15,6 +15,39 @@
#include "util.h"
#include "options.h"
int
set_LogFile(FILE *logFile)
{
if (*opt_logFile)
{
if (logFile)
fclose(logFile);
logFile = NULL;
if (strcmp(opt_logFile,"none") == 0)
return 0; //just close
logFile = fopen(opt_logFile, "a");
if (logFile)
{
// disable buffering so fflush is not needed
if (!opt_buffered)
{
l2l_dbg(1, "Disabling log buffering on %s\n", opt_logFile);
setbuf(logFile, NULL);
}
else
l2l_dbg(1, "Enabling log buffering on %s\n", opt_logFile);
}
else
{
l2l_dbg(0, "Could not open logfile %s (%s)\n", opt_logFile, strerror(errno));
return 2;
}
}
return 0;
}
int
file_exists(char *name)
{

View file

@ -8,6 +8,9 @@
#ifndef __L2L_UTIL_H__
#define __L2L_UTIL_H__
#include <stdio.h>
#include "cmd.h"
#define log(outFile, fmt, ...) \
{ \
@ -16,6 +19,19 @@
fprintf(logFile, fmt, ##__VA_ARGS__); \
}
#define esclog(outFile, fmt, ...) \
{ \
log(outFile, KDBG_ESC_RESP fmt, ##__VA_ARGS__); \
}
#define clilog(outFile, fmt, ...) \
{ \
if (opt_cli) \
esclog(outFile, fmt, ##__VA_ARGS__) \
else \
log(outFile, fmt, ##__VA_ARGS__); \
}
#define l2l_dbg(level, ...) \
{ \
if (opt_verbose >= level) \
@ -29,5 +45,8 @@ const char *getFmt(const char *a);
long my_atoi(const char *a);
int isOffset(const char *a);
int copy_file(char *src, char *dst);
int set_LogFile(FILE *logFile);
#endif /* __L2L_UTIL_H__ */
/* EOF */

View file

@ -8,6 +8,8 @@
#ifndef __L2L_VERSION_H__
#define __L2L_VERSION_H__
#define LOG2LINES_VERSION "1.12b"
#define LOG2LINES_VERSION "2.1"
#endif /* __L2L_VERSION_H__ */
/* EOF */