mirror of
https://github.com/morgant/mlvwm.git
synced 2025-01-01 03:31:19 +00:00
Fixed config file parsing to prevent false-positive command matches in some edge cases
This commit is contained in:
parent
692432b807
commit
f6b4a84199
@ -763,8 +763,9 @@ config_func main_config[]={
|
|||||||
void ReadConfigFile( char *configfile )
|
void ReadConfigFile( char *configfile )
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char str[1024], *file, *cmp;
|
char str[1024], cmp[1024], *file, *str_start, *cmp_end;
|
||||||
int lp;
|
int lp;
|
||||||
|
size_t len;
|
||||||
#ifdef MLVWMLIBDIR
|
#ifdef MLVWMLIBDIR
|
||||||
char *sysrc;
|
char *sysrc;
|
||||||
size_t sysrc_size;
|
size_t sysrc_size;
|
||||||
@ -796,14 +797,21 @@ void ReadConfigFile( char *configfile )
|
|||||||
while( fgetline( str, sizeof(str), fp )!=NULL ){
|
while( fgetline( str, sizeof(str), fp )!=NULL ){
|
||||||
if( Scr.flags & DEBUGOUT )
|
if( Scr.flags & DEBUGOUT )
|
||||||
DrawStringMenuBar( str );
|
DrawStringMenuBar( str );
|
||||||
cmp = str;
|
|
||||||
|
|
||||||
if( *cmp == '#' ) continue;
|
str_start = str;
|
||||||
cmp = SkipSpace( cmp );
|
if( *str_start == '#' ) continue;
|
||||||
if( *cmp == '\n' ) continue;
|
str_start = SkipSpace( str_start );
|
||||||
|
if( *str_start == '\n' ) continue;
|
||||||
|
|
||||||
|
snprintf( cmp, sizeof(cmp), "%s", str_start );
|
||||||
|
cmp_end = SkipNonSpace( cmp );
|
||||||
|
*cmp_end = '\0';
|
||||||
|
|
||||||
for( lp=0; main_config[lp].label!=NULL; lp++ ){
|
for( lp=0; main_config[lp].label!=NULL; lp++ ){
|
||||||
if( !strncmp( cmp, main_config[lp].label,
|
len = strlen(cmp);
|
||||||
strlen(main_config[lp].label) )){
|
if( strlen(main_config[lp].label) > len )
|
||||||
|
len = strlen(main_config[lp].label);
|
||||||
|
if( !strncmp( cmp, main_config[lp].label, len )){
|
||||||
main_config[lp].action( str, fp );
|
main_config[lp].action( str, fp );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ char *LookUpFiles( char *path, char *filename, int mode )
|
|||||||
|
|
||||||
char *SkipNonSpace( char *str )
|
char *SkipNonSpace( char *str )
|
||||||
{
|
{
|
||||||
for( ; *str!=' ' && *str!='\t' && *str; str++ );
|
for( ; *str!=' ' && *str!='\t' && *str!='\n' && *str; str++ );
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user