From 6a65f76af9673bfb8c9e833fd199f9ec367e472f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 3 May 2009 15:07:52 -0700 Subject: [PATCH] movebits: make the user-space test cases slightly easier Make it a bit easier to write user-space test cases; use fgets+sscanf so comment lines end up getting ignored. Signed-off-by: H. Peter Anvin --- com32/lib/syslinux/movebits.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/com32/lib/syslinux/movebits.c b/com32/lib/syslinux/movebits.c index 1114bfb..fbf0a34 100644 --- a/com32/lib/syslinux/movebits.c +++ b/com32/lib/syslinux/movebits.c @@ -663,23 +663,26 @@ int main(int argc, char *argv[]) struct syslinux_movelist **fep = &frags; struct syslinux_movelist *mv, *moves; struct syslinux_memmap *memmap; + char line[BUFSIZ]; (void)argc; memmap = syslinux_init_memmap(); f = fopen(argv[1], "r"); - while ( fscanf(f, "%lx %lx %lx", &s, &d, &l) == 3 ) { - if ( d ) { - if (s == -1UL) { - syslinux_add_memmap(&memmap, d, l, SMT_ZERO); + while ( fgets(line, sizeof line, f) != NULL ) { + if ( sscanf(line, "%lx %lx %lx", &s, &d, &l) == 3 ) { + if ( d ) { + if (s == -1UL) { + syslinux_add_memmap(&memmap, d, l, SMT_ZERO); + } else { + mv = new_movelist(d, s, l); + *fep = mv; + fep = &mv->next; + } } else { - mv = new_movelist(d, s, l); - *fep = mv; - fep = &mv->next; + syslinux_add_memmap(&memmap, s, l, SMT_FREE); } - } else { - syslinux_add_memmap(&memmap, s, l, SMT_FREE); } } fclose(f); -- 2.7.4