@@ -45,7 +45,7 @@ void show_help() {
4545 (int )sizeof (var_int_t ), (int )sizeof (var_num_t ));
4646 fprintf (stdout, " usage: sbasic [options]...\n " );
4747 int i = 0 ;
48- while (OPTIONS[i].name != NULL ) {
48+ while (OPTIONS[i].name != nullptr ) {
4949 fprintf (stdout, OPTIONS[i].has_arg ?
5050 " -%c, --%s='<argument>'\n " : " -%c, --%s\n " ,
5151 OPTIONS[i].val , OPTIONS[i].name );
@@ -82,9 +82,9 @@ void command_help(const char *selection) {
8282 }
8383 }
8484 if (!found) {
85- const char *last_package = NULL ;
85+ const char *last_package = nullptr ;
8686 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 ) {
8888 fprintf (stdout, " %s\n " , keyword_help[i].package );
8989 last_package = keyword_help[i].package ;
9090 }
@@ -160,7 +160,7 @@ bool setup_command_program(const char *program, char **runFile) {
160160 FILE *fp = fopen (file, " wb" );
161161 bool result;
162162 if (fp) {
163- if (program != NULL ) {
163+ if (program != nullptr ) {
164164 fputs (program, fp);
165165 } else {
166166 // read from stdin
@@ -247,7 +247,7 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile) {
247247 for (int i = 1 ; i < argc; i++) {
248248 const char *s = argv[i];
249249 int len = strlen (s);
250- if (*runFile == NULL &&
250+ if (*runFile == nullptr &&
251251 ((strcasecmp (s + len - 4 , " .bas" ) == 0 ||
252252 strcasecmp (s + len - 4 , " .sbx" ) == 0 ) && access (s, 0 ) == 0 )) {
253253 *runFile = strdup (s);
@@ -264,7 +264,7 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile) {
264264 case ' h' :
265265 if (optarg) {
266266 command_help (optarg);
267- } else if (argv[optind] != NULL && argv[optind][0 ] != ' -' ) {
267+ } else if (argv[optind] != nullptr && argv[optind][0 ] != ' -' ) {
268268 command_help (argv[optind]);
269269 } else {
270270 show_help ();
@@ -317,30 +317,45 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile) {
317317 }
318318 }
319319
320- if (getenv (" SBASICPATH" ) != NULL ) {
320+ if (getenv (" SBASICPATH" ) != nullptr ) {
321321 opt_loadmod = 1 ;
322322 }
323323
324324 if (strcmp (" --" , argv[argc - 1 ]) == 0 ) {
325- if (*runFile != NULL ) {
325+ if (*runFile != nullptr ) {
326326 // run file already set
327327 result = false ;
328- } else if (setup_command_program (NULL , runFile)) {
328+ } else if (setup_command_program (nullptr , runFile)) {
329329 *tmpFile = true ;
330330 } else {
331331 // failed to read from stdin
332332 result = false ;
333333 }
334334 }
335335
336- if (*runFile == NULL && result) {
336+ if (*runFile == nullptr && result) {
337337 show_brief_help ();
338338 result = false ;
339339 }
340340
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+ }
344359 }
345360
346361 return result;
@@ -367,7 +382,7 @@ int main(int argc, char *argv[]) {
367382
368383 console_init ();
369384
370- char *file = NULL ;
385+ char *file = nullptr ;
371386 bool tmpFile = false ;
372387 if (process_options (argc, argv, &file, &tmpFile)) {
373388 char prev_cwd[OS_PATHNAME_SIZE + 1 ];
0 commit comments