jim: fix bug in tcl "puts"

tcl "puts" didn't work because the logging code sensored strings
that did not include a '\n'. The correct thing is to sensor
empty strings, which are used to keep gdb connection alive.

The tcl "puts" code broke apart strings which do contain '\n' in
order to implement the -nonewline argument, which is how it
got hurt by the bug in log.c

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
This commit is contained in:
Øyvind Harboe 2010-05-18 12:34:12 +02:00
parent e804a34a63
commit c86d7bdad4
1 changed files with 4 additions and 9 deletions

View File

@ -139,7 +139,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
if (f != NULL) if (f != NULL)
file = f + 1; file = f + 1;
if (strchr(string, '\n') != NULL) if (strlen(string) > 0)
{ {
if (debug_level >= LOG_LVL_DEBUG) if (debug_level >= LOG_LVL_DEBUG)
{ {
@ -163,17 +163,12 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
{ {
/* if we are using gdb through pipes then we do not want any output /* if we are using gdb through pipes then we do not want any output
* to the pipe otherwise we get repeated strings */ * to the pipe otherwise we get repeated strings */
if (strcmp(string, "\n") != 0) fprintf(log_output, "%s%s",
{ (level > LOG_LVL_USER)?log_strings[level + 1]:"", string);
/* print human readable output - but skip empty lines */
fprintf(log_output, "%s%s",
(level > LOG_LVL_USER)?log_strings[level + 1]:"", string);
}
} }
} else } else
{ {
/* only entire lines are logged. Otherwise it's /* Empty strings are sent to log callbacks to keep e.g. gdbserver alive, here we do nothing. */
* single chars intended for the log callbacks. */
} }
fflush(log_output); fflush(log_output);