@@ -187,18 +187,20 @@ int slib_add_external_func(const char *func_name, uint32_t lib_id) {
187187 */
188188int slib_get_kid (int lib_id , const char * name ) {
189189 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+ }
196198 }
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+ }
202204 }
203205 }
204206 return -1 ;
@@ -272,7 +274,7 @@ void slib_import_routines(slib_t *lib, int comp) {
272274 }
273275
274276 if (!total ) {
275- log_printf ("LIB: module has no exports... \n" );
277+ log_printf ("LIB: module '%s' has no exports\n" , lib -> name );
276278 }
277279}
278280
@@ -312,13 +314,10 @@ void slib_open(const char *fullname, const char *name) {
312314 lib -> imported = 0 ;
313315
314316 if (!opt_quiet ) {
315- log_printf ("LIB: importing %s " , fullname );
317+ log_printf ("LIB: registering '%s' " , fullname );
316318 }
317319 if (slib_llopen (lib )) {
318320 slib_count ++ ;
319- if (!opt_quiet ) {
320- log_printf ("... done\n" );
321- }
322321 // override default name
323322 sblib_get_module_name_fn get_module_name = slib_getoptptr (lib , "sblib_get_module_name" );
324323 if (get_module_name ) {
@@ -383,7 +382,7 @@ void slib_scan_path(const char *path) {
383382 }
384383 }
385384 } 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 );
387386 }
388387}
389388
@@ -410,17 +409,15 @@ void slib_init() {
410409 slib_count = 0 ;
411410
412411 if (!prog_error && opt_loadmod ) {
413- if (!opt_quiet ) {
414- log_printf ("LIB: scanning for modules...\n" );
415- }
416-
417412 if (opt_modpath [0 ] == '\0' ) {
418413 const char * modpath = getenv ("SBASICPATH" );
419414 if (modpath != NULL ) {
420415 strlcpy (opt_modpath , modpath , OPT_MOD_SZ );
421416 }
422417 }
423-
418+ if (!opt_quiet ) {
419+ log_printf ("LIB: scanning for modules in '%s'\n" , opt_modpath );
420+ }
424421 slib_init_path ();
425422 }
426423}
0 commit comments