Fixed disk-label partition parsing to also work with single partition arguments

The parse-partition function was not able to deal with arguments that only
contained a partition number (without comma), e.g. "boot disk:1" failed.
Also limited the size that we load from a PReP partition in case the hard disk
is smaller than max-prep-partition-blocks.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
diff --git a/slof/fs/base.fs b/slof/fs/base.fs
index 4bd0b4d..da990f3 100644
--- a/slof/fs/base.fs
+++ b/slof/fs/base.fs
@@ -156,6 +156,10 @@
 \ Duplicate string and replace \ with /
 : \-to-/ ( str len -- str' len ) strdup 2dup [char] \ [char] / replace-char ;
 
+: isdigit ( char -- true | false )
+   30 39 between
+;
+
 : //  dup >r 1- + r> / ; \ division, round up
 
 : c@+ ( adr -- c adr' )  dup c@ swap char+ ;
diff --git a/slof/fs/envvar.fs b/slof/fs/envvar.fs
index 70223cc..f8d7946 100644
--- a/slof/fs/envvar.fs
+++ b/slof/fs/envvar.fs
@@ -66,10 +66,6 @@
    string=ci or or
 ;
 
-: isdigit ( char -- true | false )
-   30 39 between
-;
-
 : test-int ( param len -- true | false )
   drop c@ isdigit if true else false then ;
 
diff --git a/slof/fs/packages/disk-label.fs b/slof/fs/packages/disk-label.fs
index 065f32c..236be87 100644
--- a/slof/fs/packages/disk-label.fs
+++ b/slof/fs/packages/disk-label.fs
@@ -247,7 +247,8 @@
 
    partition find-dos-partition IF
      ( offset count active? id )
-     2drop drop
+     2drop
+     to part-size
      block-size * to part-offset
      true
    ELSE
@@ -394,14 +395,25 @@
 : parse-partition ( -- okay? )
    0 to partition
    0 to part-offset
+   0 to part-size
 
    my-args to args-len to args
 
-   \ Fix up the "0" thing yaboot does.
-   args-len 1 = IF args c@ [char] 0 = IF 0 to args-len THEN THEN
+   debug-disk-label? IF
+      cr ." disk-label parse-partition: my-args=" my-args type cr
+   THEN
+
+   \ Called without arguments?
+   args-len 0 = IF true EXIT THEN
 
    \ Check for "full disk" arguments.
-   my-args [char] , findchar 0= IF true EXIT THEN drop \ no comma
+   my-args [char] , findchar 0= IF \ no comma?
+      args c@ isdigit not IF       \ ... and not a partition number?
+         true EXIT                 \ ... then it's not a partition we can parse
+      THEN
+   ELSE
+      drop
+   THEN
    my-args [char] , split to args-len to args
    dup 0= IF 2drop true EXIT THEN \ no first argument
 
@@ -509,7 +521,12 @@
    ELSE
       partition IF
          0 0 seek drop
-         max-prep-partition-blocks 200 *  read
+         part-size IF
+            part-size max-prep-partition-blocks min   \ Load size
+         ELSE
+            max-prep-partition-blocks
+         THEN
+         200 *  read
       ELSE
          has-iso9660-filesystem IF
              dup load-chrp-boot-file ?dup 0 > IF nip EXIT THEN