File 0006-If-the-title-is-too-long-print-remaining-seconds-on-.patch of Package grub

From bdde4cf1175d75588f491c106e4efca2897ea594 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Pavl=C3=ADn?= <vpavlin@redhat.com>
Date: Mon, 29 Jul 2013 14:47:41 +0200
Subject: [PATCH 6/7] If the title is too long, print remaining seconds on the
 new line

Resolves: rhbz#851706
---
 stage2/stage2.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/stage2/stage2.c b/stage2/stage2.c
index cca4332..3b87aa3 100644
--- a/stage2/stage2.c
+++ b/stage2/stage2.c
@@ -267,6 +267,10 @@ restart:
       /* Don't show the "Booting in blah seconds message" if the timeout is 0 */
       int print_message = grub_timeout != 0;
 
+      /* If the title is too long, we need to cut the message into two pieces -
+         and we need to remember if the first one is already printed */
+      int title_printed = 0;
+
       /* Get current time.  */
       while ((time1 = getrtsecs ()) == 0xFF)
 	;
@@ -308,11 +312,24 @@ restart:
 	      grub_timeout--;
 	      
 	      /* Print a message.  */
-	      if (print_message)
-		grub_printf ("\rBooting %s in %d seconds...",
-		             get_entry(menu_entries, first_entry + entryno, 0),
-		             grub_timeout);
-	    }
+	      if (print_message) {
+                int max_len = 53; /* 26 ('Booting  in 000 seconds...') + 53 (title) + 1 (cursor) = 80 */
+                char *title = get_entry(menu_entries, first_entry + entryno, 0);
+
+                /* If title + "Booting " exceedes 80 characters, print the timeout to the next line */
+                if (grub_strlen(title) > max_len) {
+                        if (!title_printed) {
+                                grub_printf("Booting %s\n", title);
+                                title_printed = 1;
+                        }
+
+                        grub_printf("\rin %d seconds...", grub_timeout);
+                } else
+			grub_printf ("\rBooting %s in %d seconds...",
+			                title,
+		                        grub_timeout);
+              }
+            }
 	}
     }
 
-- 
1.8.3.1

openSUSE Build Service is sponsored by