wok rev 3869

syslinux/ifmem: more generic algorithm for cmdline
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 08 16:33:21 2009 +0200 (2009-08-08)
parents b6b64851e9aa
children 773f5d910570
files syslinux/stuff/extra/ifmem.c
line diff
     1.1 --- a/syslinux/stuff/extra/ifmem.c	Sat Aug 08 16:06:48 2009 +0200
     1.2 +++ b/syslinux/stuff/extra/ifmem.c	Sat Aug 08 16:33:21 2009 +0200
     1.3 @@ -54,7 +54,7 @@
     1.4  int main(int argc, char *argv[])
     1.5  {
     1.6    char *s;
     1.7 -  int i;
     1.8 +  int i, j;
     1.9  
    1.10    for (s = argv[1]; *s && (*s < '0' || *s > '9'); s++);
    1.11  
    1.12 @@ -66,15 +66,17 @@
    1.13  
    1.14    // find target according to ram size
    1.15    for (i = 1; i + 2 < argc; ) { 
    1.16 -    i++; // size
    1.17 +    j = i++; // size
    1.18      if (memory_size() >= strtoul(s, NULL, 0)) break;
    1.19      s = argv[++i];
    1.20    }
    1.21  
    1.22    // find and copy extra parameters to command line
    1.23 -  // assume last parameter is "noram"
    1.24 -  for (s = argv[i]; i < argc; i++) { 
    1.25 -	if (!strcmp(argv[i],"noram") && ++i < argc) {
    1.26 +  // assume the command line ends with two words (not number)
    1.27 +  for (s = argv[i++]; i < argc; i++) { 
    1.28 +	char c = argv[i];
    1.29 +	if (c >= '0' && c <= '9') j = i;
    1.30 +	if (i - j > 2 && ++i < argc) {
    1.31  #define SZ 512
    1.32  		static char cmdline[SZ];
    1.33  		char *p = cmdline, *q = s;