Author: sparky
Date: Sun Mar 19 01:53:10 2006
New Revision: 7221

Modified:
   ppcrcd/trunk/yaboot/yaboot.c
Log:
- print at most 20 lines (1000 bytes may be too much)


Modified: ppcrcd/trunk/yaboot/yaboot.c
==============================================================================
--- ppcrcd/trunk/yaboot/yaboot.c        (original)
+++ ppcrcd/trunk/yaboot/yaboot.c        Sun Mar 19 01:53:10 2006
@@ -304,12 +304,11 @@
                goto done;
        }
 
-       /* 2000 for not paged messages, 1000 for paged*/
-       msg = malloc(2001 - paging * 1000);
+       msg = malloc(2001);
        if (!msg)
                goto done;
        else
-               memset(msg, 0, (2001 - paging * 1000));
+               memset(msg, 0, 2001);
 
        result = open_file(&msgfile, &file);
        if (result != FILE_ERR_OK) {
@@ -319,29 +318,36 @@
        }
        opened = 1;
 
-       if ( file.fs->read(&file, (2000 - paging * 1000), msg) <= 0)
+       if ( file.fs->read(&file, 2000, msg) <= 0)
                goto done;
 
-       if ( paging && (*(msg + 999) != 0) ) {
-               /* file longer than 1000 and paging is 1 */
-               char *last_nl;
+       if ( paging ) {
+               char *nlp;
                int len = 0;
+               int new_lines;
 
-               while ( *(msg + 999) != 0 ) {
-                       last_nl = strrchr(msg, '\n');
-                       *last_nl = 0;
+               while ( *msg != '\0' ) {
+                       new_lines = 20;
+                       nlp = msg;
+                       while (--new_lines > 0) {
+                               nlp = strchr((nlp+1), '\n');
+                               if ( nlp == NULL ) { /* less than 20 lines */
+                                       prom_printf("\r         \r%s", msg);
+                                       goto done;
+                               }
+                       }
+                       *++nlp = '\0';
 
-                       prom_printf("\r         \r%s\n[Press a key]", msg);
-                       len += last_nl - msg + 1;
+                       prom_printf("\r         \r%s[Press a key]", msg);
+                       len += nlp - msg;
 
-                       memset(msg, 0, 1001);
+                       memset(msg, 0, 2001);
                        file.fs->seek(&file, len);
-                       file.fs->read(&file, 1000, msg);
+                       file.fs->read(&file, 2000, msg);
 
                        /* wait until key */
                        while ( prom_nbgetchar() == -1 );
                }
-               prom_printf("\r         \r%s", msg);
        } else
                prom_printf("%s", msg);
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to