@ -211,8 +211,8 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
list_t * res_list = create_list ( ) ;
list_t * res_list = create_list ( ) ;
char * exec = strdup ( _exec ) ;
char * exec = strdup ( _exec ) ;
char * head = exec ;
char * head = exec ;
char * cmdlist ;
char * cmd ;
char * cmd ;
char matched_delim = ' ; ' ;
list_t * views = NULL ;
list_t * views = NULL ;
if ( seat = = NULL ) {
if ( seat = = NULL ) {
@ -227,16 +227,13 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
head = exec ;
head = exec ;
do {
do {
// Split command list
for ( ; isspace ( * head ) ; + + head ) { }
cmdlist = argsep ( & head , " ; " ) ;
// Extract criteria (valid for this command list only).
do {
if ( matched_delim = = ' ; ' ) {
// Skip leading whitespace
for ( ; isspace ( * cmdlist ) ; + + cmdlist ) { }
// Extract criteria (valid for this command chain only).
config - > handler_context . using_criteria = false ;
config - > handler_context . using_criteria = false ;
if ( * cmdlist = = ' [ ' ) {
if ( * head = = ' [ ' ) {
char * error = NULL ;
char * error = NULL ;
struct criteria * criteria = criteria_parse ( cmdlist , & error ) ;
struct criteria * criteria = criteria_parse ( head , & error ) ;
if ( ! criteria ) {
if ( ! criteria ) {
list_add ( res_list ,
list_add ( res_list ,
cmd_results_new ( CMD_INVALID , " %s " , error ) ) ;
cmd_results_new ( CMD_INVALID , " %s " , error ) ) ;
@ -245,15 +242,17 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
}
}
list_free ( views ) ;
list_free ( views ) ;
views = criteria_get_views ( criteria ) ;
views = criteria_get_views ( criteria ) ;
cmdlist + = strlen ( criteria - > raw ) ;
head + = strlen ( criteria - > raw ) ;
criteria_destroy ( criteria ) ;
criteria_destroy ( criteria ) ;
config - > handler_context . using_criteria = true ;
config - > handler_context . using_criteria = true ;
// Skip leading whitespace
// Skip leading whitespace
for ( ; isspace ( * cmdlist ) ; + + cmdlist ) { }
for ( ; isspace ( * head ) ; + + head ) { }
}
}
}
// Split command chain into commands
// Split command list
cmd = argsep ( & cmdlist, " , " ) ;
cmd = argsep ( & head, " ;, " , & matched_delim ) ;
for ( ; isspace ( * cmd ) ; + + cmd ) { }
for ( ; isspace ( * cmd ) ; + + cmd ) { }
if ( strcmp ( cmd , " " ) = = 0 ) {
if ( strcmp ( cmd , " " ) = = 0 ) {
sway_log ( SWAY_INFO , " Ignoring empty command. " ) ;
sway_log ( SWAY_INFO , " Ignoring empty command. " ) ;
continue ;
continue ;
@ -265,8 +264,7 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
if ( strcmp ( argv [ 0 ] , " exec " ) ! = 0 & &
if ( strcmp ( argv [ 0 ] , " exec " ) ! = 0 & &
strcmp ( argv [ 0 ] , " exec_always " ) ! = 0 & &
strcmp ( argv [ 0 ] , " exec_always " ) ! = 0 & &
strcmp ( argv [ 0 ] , " mode " ) ! = 0 ) {
strcmp ( argv [ 0 ] , " mode " ) ! = 0 ) {
int i ;
for ( int i = 1 ; i < argc ; + + i ) {
for ( i = 1 ; i < argc ; + + i ) {
if ( * argv [ i ] = = ' \" ' | | * argv [ i ] = = ' \' ' ) {
if ( * argv [ i ] = = ' \" ' | | * argv [ i ] = = ' \' ' ) {
strip_quotes ( argv [ i ] ) ;
strip_quotes ( argv [ i ] ) ;
}
}
@ -309,7 +307,6 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
}
}
}
}
free_argv ( argc , argv ) ;
free_argv ( argc , argv ) ;
} while ( cmdlist ) ;
} while ( head ) ;
} while ( head ) ;
cleanup :
cleanup :
free ( exec ) ;
free ( exec ) ;