@@ -390,10 +390,10 @@ void pat_init_patnames(void)
390390 isdrumset = 0 ;
391391 _mm_fgets (mmcfg, line, PATH_MAX);
392392 while ( !_mm_feof (mmcfg) ) {
393- if ( isdigit (line[0 ]) || (isblank (line[0 ]) && isdigit (line[1 ])) ) {
394- p = line;
393+ p = line;
394+ while ( isspace (*p) ) p ++;
395+ if ( isdigit (p[0 ]) ) {
395396 // get pat number
396- while ( isspace (*p) ) p ++;
397397 i = atoi (p);
398398 while ( isdigit (*p) ) p ++;
399399 while ( isspace (*p) ) p ++;
@@ -421,10 +421,25 @@ void pat_init_patnames(void)
421421 *q++ = ' \0 ' ;
422422 }
423423 }
424- if ( !strncmp (line," drumset" ,7 ) ) isdrumset = 1 ;
425- if ( !strncmp (line," source" ,6 ) && nsources < 5 ) {
424+ else if ( !strncmp (p," bank" ,4 ) ) isdrumset = 0 ;
425+ else if ( !strncmp (p," drumset" ,7 ) ) isdrumset = 1 ;
426+ else if ( !strncmp (p," soundfont" ,9 ) ) {
427+ fprintf (stderr, " warning: soundfont directive unsupported!\n " );
428+ }
429+ else if ( !strncmp (p," dir" ,3 ) ) {
430+ p += 3 ;
431+ while ( isspace (*p) ) p ++;
432+ q = p + strlen (p);
433+ if (q > p) {
434+ --q;
435+ while ( q > p && isspace (*q) ) *(q--) = 0 ;
436+ strncpy (pathforpat, p, PATH_MAX - 1 );
437+ pathforpat[PATH_MAX - 1 ] = 0 ;
438+ }
439+ }
440+ else if ( !strncmp (p," source" ,6 ) && nsources < 5 ) {
426441 q = cfgsources[nsources];
427- p = &line[ 7 ] ;
442+ p += 6 ;
428443 while ( isspace (*p) ) p ++;
429444 pfnlen = 0 ;
430445 while ( *p && *p != ' #' && !isspace (*p) && pfnlen < 128 ) {
@@ -462,17 +477,19 @@ void pat_init_patnames(void)
462477
463478static char *pat_build_path (char *fname, int pat)
464479{
465- char *ps;
480+ char *ps, *p ;
466481 char *patfile = midipat[pat];
467- int isabspath = (patfile[0 ] == ' /' );
482+ int has_ext = 0 , isabspath = (patfile[0 ] == ' /' );
468483 if ( isabspath ) patfile ++;
469484 ps = strrchr (patfile, ' :' );
470485 if ( ps ) {
471486 sprintf (fname, " %s%c%s" , isabspath ? " " : pathforpat, DIRDELIM, patfile);
472487 strcpy (strrchr (fname, ' :' ), " .pat" );
473488 return ps;
474489 }
475- sprintf (fname, " %s%c%s.pat" , isabspath ? " " : pathforpat, DIRDELIM, patfile);
490+ p = strrchr (patfile, ' .' );
491+ if (p && !strcasecmp (p, " .pat" )) has_ext = 1 ;
492+ sprintf (fname, " %s%c%s%s" , isabspath ? " " : pathforpat, DIRDELIM, patfile, has_ext ? " " : " .pat" );
476493 return 0 ;
477494}
478495
0 commit comments