summaryrefslogtreecommitdiff
path: root/com32
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-03 15:07:52 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-03 15:07:52 -0700
commit6a65f76af9673bfb8c9e833fd199f9ec367e472f (patch)
tree228dda796fd82183dcbf946458a340a9554ce417 /com32
parentb55f8a80e17e7b9c1b003c808ea8048c49fbf59c (diff)
downloadsyslinux-6a65f76af9673bfb8c9e833fd199f9ec367e472f.tar.gz
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 <hpa@zytor.com>
Diffstat (limited to 'com32')
-rw-r--r--com32/lib/syslinux/movebits.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/com32/lib/syslinux/movebits.c b/com32/lib/syslinux/movebits.c
index 1114bfb8..fbf0a345 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);