zipl/libc: Indicate truncated lines in printf with '...'

Append '...' to lines exceeding the maximum line length instead of
silently truncating them.

Suggested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Philipp Rudo
2020-02-12 14:08:24 +01:00
committed by Jan Höppner
parent f7430027b4
commit 36fed0e6c6
3 changed files with 9 additions and 3 deletions

View File

@@ -410,11 +410,17 @@ void snprintf(char *buf, unsigned long size, const char *fmt, ...)
*/
void printf(const char *fmt, ...)
{
char buf[81];
char buf[LINE_LENGTH + 1];
int len;
va_list va;
va_start(va, fmt);
vsnprintf(buf, sizeof(buf), fmt, va);
len = vsnprintf(buf, sizeof(buf), fmt, va);
if (len > LINE_LENGTH) {
buf[LINE_LENGTH - 1] = '.';
buf[LINE_LENGTH - 2] = '.';
buf[LINE_LENGTH - 3] = '.';
}
sclp_print(buf);
va_end(va);
}

View File

@@ -42,6 +42,7 @@
#define ENOTTY 25 /* Not a typewriter */
#define MIB (1024ULL * 1024)
#define LINE_LENGTH 80 /* max line length printed by printf */
void printf(const char *, ...);
void snprintf(char *buf, unsigned long size, const char *fmt, ...);

View File

@@ -20,7 +20,6 @@
/* max command line length */
#define COMMAND_LINE_SIZE 896
#define BOOT_MENU_ENTRIES 63
#define LINE_LENGTH 80
#define PARAM_SIZE 8
#define TEXT_OFFSET 4