From dcc953eecb077923049b6e6b50fbef3055122a2e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 28 Aug 2010 11:35:02 +0200 Subject: [PATCH] Fallback to dumb printf if malloc failes --- grub-core/normal/term.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index 4f5779abe..a5fdbe4e9 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -751,6 +751,34 @@ grub_xputs_normal (const char *str) if (!unicode_str) { grub_errno = GRUB_ERR_NONE; + for (; *str; str++) + { + grub_term_output_t term; + grub_uint32_t code = *str; + if (code > 0x7f) + code = '?'; + + FOR_ACTIVE_TERM_OUTPUTS(term) + { + struct grub_unicode_glyph c = + { + .base = code, + .variant = 0, + .attributes = 0, + .ncomb = 0, + .combining = 0, + .estimated_width = 1 + }; + + (term->putchar) (term, &c); + if (code == '\n') + { + c.base = '\r'; + (term->putchar) (term, &c); + } + } + } + return; }