Mercurial > hg > forks > dxa
comparison main.c @ 4:0990d9322fc8
Implement address-ranged labels. Breaks compatibility of label files.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Feb 2015 04:15:07 +0200 |
parents | ec2f8f6f1dc9 |
children | b91c47026822 |
comparison
equal
deleted
inserted
replaced
3:a07eb3757bf0 | 4:0990d9322fc8 |
---|---|
420 | 420 |
421 goto Usage; | 421 goto Usage; |
422 } | 422 } |
423 | 423 |
424 while (!feof (file)) { | 424 while (!feof (file)) { |
425 int tmp; | |
425 fType = fgetc (file); | 426 fType = fgetc (file); |
426 | 427 |
427 if (feof (file)) | 428 if (feof (file)) |
428 break; | 429 break; |
429 | 430 |
430 ungetc (fType, file); | 431 ungetc (fType, file); |
431 | 432 |
432 #if(0) | |
433 /* This is the old behaviour. -- Cameron */ | |
434 if (!fscanf (file, "%X:", &address1) || address1 > 65535 || | |
435 !fgets (labelname, sizeof labelname, file)) { | |
436 #else | |
437 /* This is the xa-compatible label scanner. */ | 433 /* This is the xa-compatible label scanner. */ |
438 if (!fscanf(file, "%s%i", labelname, &address1) || | 434 if (!fscanf(file, "%s%i,%i,%i", labelname, &address1, &tmp, &address2) || |
439 address1 > 65535 || | 435 address1 > 65535 || |
440 !fgets(strig, sizeof strig, file)) { | 436 !fgets(strig, sizeof strig, file)) { |
441 #endif | 437 |
442 LabelError: | 438 LabelError: |
443 fprintf (stderr, "%s: Error in label file %s.\n", prog, optarg); | 439 fprintf (stderr, "%s: Error in label file %s.\n", prog, optarg); |
444 fprintf (stderr, "Address(?): 0x%x ... Label(?): \"%s\"\n\n", | 440 fprintf (stderr, "Address(?): 0x%x ... Label(?): \"%s\"\n\n", |
445 address1, labelname); | 441 address1, labelname); |
446 fclose (file); | 442 fclose (file); |
459 *scanner = 0; /* remove trailing control characters */ | 455 *scanner = 0; /* remove trailing control characters */ |
460 | 456 |
461 for (scanner = labelname; *(unsigned char *)scanner < 32; scanner++) | 457 for (scanner = labelname; *(unsigned char *)scanner < 32; scanner++) |
462 if (!*scanner) goto LabelError; /* label name missing */ | 458 if (!*scanner) goto LabelError; /* label name missing */ |
463 | 459 |
464 AddLabel (address1, scanner); | 460 AddLabel (address1, scanner, address2 != 0, address2); |
465 } | 461 } |
466 | 462 |
467 fclose (file); | 463 fclose (file); |
468 } | 464 } |
469 | 465 |