target: mbedos5: Add carriage return in jerry_port_console (#1427)
Serial monitors (like screen on macOS / Linux) expect both CR and LF characters for new lines. Due to jerryscript only printing a line feed after calls to `print()` this makes log messages look wrong. This patch adds a CR when it encounters a LF character in jerry_port_console or jerry_port_log for the mbedos5 target. JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
This commit is contained in:
committed by
Zoltan Herczeg
parent
415ff37a8f
commit
6a2f54456f
@@ -33,6 +33,11 @@ jerry_port_console (const char *format, /**< format string */
|
|||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
vfprintf (stdout, format, args);
|
vfprintf (stdout, format, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
|
if (strlen (format) == 1 && format[0] == 0x0a) /* line feed (\n) */
|
||||||
|
{
|
||||||
|
printf ("\r"); /* add CR for proper display in serial monitors */
|
||||||
|
}
|
||||||
} /* jerry_port_console */
|
} /* jerry_port_console */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +54,11 @@ jerry_port_log (jerry_log_level_t level, /**< log level */
|
|||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
vfprintf (stderr, format, args);
|
vfprintf (stderr, format, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
|
if (strlen (format) == 1 && format[0] == 0x0a) /* line feed (\n) */
|
||||||
|
{
|
||||||
|
printf ("\r"); /* add CR for proper display in serial monitors */
|
||||||
|
}
|
||||||
} /* jerry_port_log */
|
} /* jerry_port_log */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user