@@ -45,7 +45,7 @@ void show_help() {
45
45
(int )sizeof (var_int_t ), (int )sizeof (var_num_t ));
46
46
fprintf (stdout, " usage: sbasic [options]...\n " );
47
47
int i = 0 ;
48
- while (OPTIONS[i].name != NULL ) {
48
+ while (OPTIONS[i].name != nullptr ) {
49
49
fprintf (stdout, OPTIONS[i].has_arg ?
50
50
" -%c, --%s='<argument>'\n " : " -%c, --%s\n " ,
51
51
OPTIONS[i].val , OPTIONS[i].name );
@@ -82,9 +82,9 @@ void command_help(const char *selection) {
82
82
}
83
83
}
84
84
if (!found) {
85
- const char *last_package = NULL ;
85
+ const char *last_package = nullptr ;
86
86
for (int i = 0 ; i < keyword_help_len; i++) {
87
- if (last_package == NULL || strcmp (last_package, keyword_help[i].package ) != 0 ) {
87
+ if (last_package == nullptr || strcmp (last_package, keyword_help[i].package ) != 0 ) {
88
88
fprintf (stdout, " %s\n " , keyword_help[i].package );
89
89
last_package = keyword_help[i].package ;
90
90
}
@@ -160,7 +160,7 @@ bool setup_command_program(const char *program, char **runFile) {
160
160
FILE *fp = fopen (file, " wb" );
161
161
bool result;
162
162
if (fp) {
163
- if (program != NULL ) {
163
+ if (program != nullptr ) {
164
164
fputs (program, fp);
165
165
} else {
166
166
// read from stdin
@@ -247,7 +247,7 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile) {
247
247
for (int i = 1 ; i < argc; i++) {
248
248
const char *s = argv[i];
249
249
int len = strlen (s);
250
- if (*runFile == NULL &&
250
+ if (*runFile == nullptr &&
251
251
((strcasecmp (s + len - 4 , " .bas" ) == 0 ||
252
252
strcasecmp (s + len - 4 , " .sbx" ) == 0 ) && access (s, 0 ) == 0 )) {
253
253
*runFile = strdup (s);
@@ -264,7 +264,7 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile) {
264
264
case ' h' :
265
265
if (optarg) {
266
266
command_help (optarg);
267
- } else if (argv[optind] != NULL && argv[optind][0 ] != ' -' ) {
267
+ } else if (argv[optind] != nullptr && argv[optind][0 ] != ' -' ) {
268
268
command_help (argv[optind]);
269
269
} else {
270
270
show_help ();
@@ -317,30 +317,45 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile) {
317
317
}
318
318
}
319
319
320
- if (getenv (" SBASICPATH" ) != NULL ) {
320
+ if (getenv (" SBASICPATH" ) != nullptr ) {
321
321
opt_loadmod = 1 ;
322
322
}
323
323
324
324
if (strcmp (" --" , argv[argc - 1 ]) == 0 ) {
325
- if (*runFile != NULL ) {
325
+ if (*runFile != nullptr ) {
326
326
// run file already set
327
327
result = false ;
328
- } else if (setup_command_program (NULL , runFile)) {
328
+ } else if (setup_command_program (nullptr , runFile)) {
329
329
*tmpFile = true ;
330
330
} else {
331
331
// failed to read from stdin
332
332
result = false ;
333
333
}
334
334
}
335
335
336
- if (*runFile == NULL && result) {
336
+ if (*runFile == nullptr && result) {
337
337
show_brief_help ();
338
338
result = false ;
339
339
}
340
340
341
- if (opt_modpath[0 ] != ' \0 ' && access (opt_modpath, R_OK) != 0 ) {
342
- fprintf (stdout, " sbasic: can't open path '%s': [Errno %d] %s\n " , opt_modpath, errno, strerror (errno));
343
- result = false ;
341
+ if (opt_modpath[0 ] != ' \0 ' ) {
342
+ char *path = opt_modpath;
343
+ while (result && path && path[0 ] != ' \0 ' ) {
344
+ char *sep = strchr (path, ' :' );
345
+ if (sep) {
346
+ *sep = ' \0 ' ;
347
+ }
348
+ if (access (path, R_OK) != 0 ) {
349
+ fprintf (stdout, " sbasic: can't open path '%s': [Errno %d] %s\n " , path, errno, strerror (errno));
350
+ result = false ;
351
+ }
352
+ if (sep) {
353
+ *sep = ' :' ;
354
+ path = sep + 1 ;
355
+ } else {
356
+ path = nullptr ;
357
+ }
358
+ }
344
359
}
345
360
346
361
return result;
@@ -367,7 +382,7 @@ int main(int argc, char *argv[]) {
367
382
368
383
console_init ();
369
384
370
- char *file = NULL ;
385
+ char *file = nullptr ;
371
386
bool tmpFile = false ;
372
387
if (process_options (argc, argv, &file, &tmpFile)) {
373
388
char prev_cwd[OS_PATHNAME_SIZE + 1 ];
0 commit comments