ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/main_sdl.cpp
(Generate patch)

Comparing SIDPlayer/src/main_sdl.cpp (file contents):
Revision 1.7 by cebix, 2001-01-21T18:42:24Z vs.
Revision 1.8 by cebix, 2001-04-01T12:13:49Z

# Line 69 | Line 69 | int main(int argc, char **argv)
69          int32 selected_speed = PrefsFindInt32("speed");
70  
71          // Parse non-option arguments
72 <        if (argc < 2)
73 <                usage(argv[0]);
74 <        char *file_name = argv[argc - 1];
72 >        const char *file_name = NULL;
73          int song = 0;
74 <        if (argc >= 3) {
75 <                bool only_numbers = true;
76 <                for (int i=0; i<strlen(file_name); i++)
77 <                        if (!isdigit(file_name[i])) {
78 <                                only_numbers = false;
79 <                                break;
80 <                        }
81 <                if (only_numbers) {
82 <                        song = atoi(file_name);
83 <                        file_name = argv[argc - 2];
74 >        for (int i=1; i<argc; i++) {
75 >                if (strcmp(argv[i], "--help") == 0)
76 >                        usage(argv[0]);
77 >                else if (argv[i][0] == '-') {
78 >                        fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
79 >                        usage(argv[0]);
80 >                } else {
81 >                        if (file_name == NULL)
82 >                                file_name = argv[i];  // First non-option argument is file name
83 >                        else
84 >                                song = atoi(argv[i]); // Second non-option argument is song number
85                  }
86          }
87 +        if (file_name == NULL)
88 +                usage(argv[0]);
89  
90          // Load given PSID file
91          if (!LoadPSIDFile(file_name)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines