@@ -187,18 +187,20 @@ int slib_add_external_func(const char *func_name, uint32_t lib_id) {
187
187
*/
188
188
int slib_get_kid (int lib_id , const char * name ) {
189
189
slib_t * lib = get_lib (lib_id );
190
- const char * dot = strchr (name , '.' );
191
- const char * field = (dot != NULL ? dot + 1 : name );
192
- for (int i = 0 ; i < lib -> proc_count ; i ++ ) {
193
- if (lib -> proc_list [i ].lib_id == lib_id &&
194
- strcmp (lib -> proc_list [i ].name , field ) == 0 ) {
195
- return i ;
190
+ if (lib != NULL ) {
191
+ const char * dot = strchr (name , '.' );
192
+ const char * field = (dot != NULL ? dot + 1 : name );
193
+ for (int i = 0 ; i < lib -> proc_count ; i ++ ) {
194
+ if (lib -> proc_list [i ].lib_id == lib_id &&
195
+ strcmp (lib -> proc_list [i ].name , field ) == 0 ) {
196
+ return i ;
197
+ }
196
198
}
197
- }
198
- for ( int i = 0 ; i < lib -> func_count ; i ++ ) {
199
- if (lib -> func_list [i ].lib_id == lib_id &&
200
- strcmp ( lib -> func_list [ i ]. name , field ) == 0 ) {
201
- return i ;
199
+ for ( int i = 0 ; i < lib -> func_count ; i ++ ) {
200
+ if ( lib -> func_list [ i ]. lib_id == lib_id &&
201
+ strcmp (lib -> func_list [i ].name , field ) == 0 ) {
202
+ return i ;
203
+ }
202
204
}
203
205
}
204
206
return -1 ;
@@ -272,7 +274,7 @@ void slib_import_routines(slib_t *lib, int comp) {
272
274
}
273
275
274
276
if (!total ) {
275
- log_printf ("LIB: module has no exports... \n" );
277
+ log_printf ("LIB: module '%s' has no exports\n" , lib -> name );
276
278
}
277
279
}
278
280
@@ -312,13 +314,10 @@ void slib_open(const char *fullname, const char *name) {
312
314
lib -> imported = 0 ;
313
315
314
316
if (!opt_quiet ) {
315
- log_printf ("LIB: importing %s " , fullname );
317
+ log_printf ("LIB: registering '%s' " , fullname );
316
318
}
317
319
if (slib_llopen (lib )) {
318
320
slib_count ++ ;
319
- if (!opt_quiet ) {
320
- log_printf ("... done\n" );
321
- }
322
321
// override default name
323
322
sblib_get_module_name_fn get_module_name = slib_getoptptr (lib , "sblib_get_module_name" );
324
323
if (get_module_name ) {
@@ -383,7 +382,7 @@ void slib_scan_path(const char *path) {
383
382
}
384
383
}
385
384
} else if (!opt_quiet ) {
386
- log_printf ("LIB: module path %s not found.\n" , path );
385
+ log_printf ("LIB: module path '%s' not found.\n" , path );
387
386
}
388
387
}
389
388
@@ -410,17 +409,15 @@ void slib_init() {
410
409
slib_count = 0 ;
411
410
412
411
if (!prog_error && opt_loadmod ) {
413
- if (!opt_quiet ) {
414
- log_printf ("LIB: scanning for modules...\n" );
415
- }
416
-
417
412
if (opt_modpath [0 ] == '\0' ) {
418
413
const char * modpath = getenv ("SBASICPATH" );
419
414
if (modpath != NULL ) {
420
415
strlcpy (opt_modpath , modpath , OPT_MOD_SZ );
421
416
}
422
417
}
423
-
418
+ if (!opt_quiet ) {
419
+ log_printf ("LIB: scanning for modules in '%s'\n" , opt_modpath );
420
+ }
424
421
slib_init_path ();
425
422
}
426
423
}
0 commit comments