aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--builtin.c126
-rw-r--r--env.c4
-rw-r--r--event.c27
-rw-r--r--event.h3
-rw-r--r--exec.c70
-rw-r--r--io.c31
-rw-r--r--io.h4
-rw-r--r--parser.c54
-rw-r--r--parser.h9
-rw-r--r--proc.c13
-rw-r--r--reader.c4
-rw-r--r--signal.c2
12 files changed, 174 insertions, 173 deletions
diff --git a/builtin.c b/builtin.c
index 394231b9..be14bdb1 100644
--- a/builtin.c
+++ b/builtin.c
@@ -822,7 +822,7 @@ static int builtin_function( wchar_t **argv )
if( !e )
die_mem();
e->type = EVENT_SIGNAL;
- e->signal = sig;
+ e->param1.signal = sig;
e->function_name=0;
al_push( events, e );
break;
@@ -846,7 +846,7 @@ static int builtin_function( wchar_t **argv )
if( !e )
die_mem();
e->type = EVENT_VARIABLE;
- e->variable = wcsdup( woptarg );
+ e->param1.variable = wcsdup( woptarg );
e->function_name=0;
al_push( events, e );
break;
@@ -875,7 +875,7 @@ static int builtin_function( wchar_t **argv )
if( !e )
die_mem();
e->type = EVENT_EXIT;
- e->pid = (opt=='j'?-1:1)*abs(pid);
+ e->param1.pid = (opt=='j'?-1:1)*abs(pid);
e->function_name=0;
al_push( events, e );
break;
@@ -970,14 +970,14 @@ static int builtin_function( wchar_t **argv )
int i;
parser_push_block( FUNCTION_DEF );
- current_block->function_name=wcsdup(argv[woptind]);
- current_block->function_description=desc?wcsdup(desc):0;
- current_block->function_is_binding = is_binding;
- current_block->function_events = events;
+ current_block->param1.function_name=wcsdup(argv[woptind]);
+ current_block->param2.function_description=desc?wcsdup(desc):0;
+ current_block->param3.function_is_binding = is_binding;
+ current_block->param4.function_events = events;
for( i=0; i<al_get_count( events ); i++ )
{
event_t *e = (event_t *)al_get( events, i );
- e->function_name = wcsdup( current_block->function_name );
+ e->function_name = wcsdup( current_block->param1.function_name );
}
}
@@ -2385,19 +2385,19 @@ static int builtin_for( wchar_t **argv )
else
{
parser_push_block( FOR );
- al_init( &current_block->for_vars);
+ al_init( &current_block->param2.for_vars);
int i;
current_block->tok_pos = parser_get_pos();
- current_block->for_variable = wcsdup( argv[1] );
+ current_block->param1.for_variable = wcsdup( argv[1] );
for( i=argc-1; i>3; i-- )
{
- al_push( &current_block->for_vars, wcsdup(argv[ i ] ));
+ al_push( &current_block->param2.for_vars, wcsdup(argv[ i ] ));
}
if( argc > 3 )
{
- env_set( current_block->for_variable, argv[3], ENV_LOCAL );
+ env_set( current_block->param1.for_variable, argv[3], ENV_LOCAL );
}
else
{
@@ -2456,7 +2456,7 @@ static int builtin_end( wchar_t **argv )
current_block->skip = 0;
kill_block = 0;
parser_set_pos( current_block->tok_pos);
- current_block->while_state = WHILE_TEST_AGAIN;
+ current_block->param1.while_state = WHILE_TEST_AGAIN;
}
break;
@@ -2478,16 +2478,16 @@ static int builtin_end( wchar_t **argv )
*/
if( current_block->loop_status == LOOP_BREAK )
{
- while( al_get_count( &current_block->for_vars ) )
+ while( al_get_count( &current_block->param2.for_vars ) )
{
- free( (void *)al_pop( &current_block->for_vars ) );
+ free( (void *)al_pop( &current_block->param2.for_vars ) );
}
}
- if( al_get_count( &current_block->for_vars ) )
+ if( al_get_count( &current_block->param2.for_vars ) )
{
- wchar_t *val = (wchar_t *)al_pop( &current_block->for_vars );
- env_set( current_block->for_variable, val, ENV_LOCAL);
+ wchar_t *val = (wchar_t *)al_pop( &current_block->param2.for_vars );
+ env_set( current_block->param1.for_variable, val, ENV_LOCAL);
current_block->loop_status = LOOP_NORMAL;
current_block->skip = 0;
free(val);
@@ -2515,11 +2515,11 @@ static int builtin_end( wchar_t **argv )
//fwprintf( stderr, L"Function: %ls\n", def );
if( !parser_test( def, 1 ) )
{
- function_add( current_block->function_name,
+ function_add( current_block->param1.function_name,
def,
- current_block->function_description,
- current_block->function_events,
- current_block->function_is_binding );
+ current_block->param2.function_description,
+ current_block->param4.function_events,
+ current_block->param3.function_is_binding );
}
free(def);
@@ -2548,7 +2548,7 @@ static int builtin_else( wchar_t **argv )
{
if( current_block == 0 ||
current_block->type != IF ||
- current_block->if_state != 1)
+ current_block->param1.if_state != 1)
{
sb_append2( sb_err,
argv[0],
@@ -2559,7 +2559,7 @@ static int builtin_else( wchar_t **argv )
}
else
{
- current_block->if_state++;
+ current_block->param1.if_state++;
current_block->skip = !current_block->skip;
env_pop();
env_push(0);
@@ -2711,9 +2711,9 @@ static int builtin_switch( wchar_t **argv )
else
{
parser_push_block( SWITCH );
- current_block->switch_value = wcsdup( argv[1]);
+ current_block->param1.switch_value = wcsdup( argv[1]);
current_block->skip=1;
- current_block->switch_taken=0;
+ current_block->param2.switch_taken=0;
}
return res;
@@ -2740,7 +2740,7 @@ static int builtin_case( wchar_t **argv )
current_block->skip = 1;
- if( current_block->switch_taken )
+ if( current_block->param2.switch_taken )
{
return 0;
}
@@ -2750,10 +2750,10 @@ static int builtin_case( wchar_t **argv )
free( unescaped );
unescaped = expand_unescape( argv[i], 1);
- if( wildcard_match( current_block->switch_value, unescaped ) )
+ if( wildcard_match( current_block->param1.switch_value, unescaped ) )
{
current_block->skip = 0;
- current_block->switch_taken = 1;
+ current_block->param2.switch_taken = 1;
break;
}
}
@@ -2772,52 +2772,52 @@ void builtin_init()
al_init( &io_stack );
hash_init( &builtin, &hash_wcs_func, &hash_wcs_cmp );
- hash_put( &builtin, L"exit", &builtin_exit );
- hash_put( &builtin, L"builtin", &builtin_builtin );
- hash_put( &builtin, L"cd", &builtin_cd );
- hash_put( &builtin, L"function", &builtin_function );
- hash_put( &builtin, L"functions", &builtin_functions );
- hash_put( &builtin, L"complete", &builtin_complete );
- hash_put( &builtin, L"end", &builtin_end );
- hash_put( &builtin, L"else", &builtin_else );
- hash_put( &builtin, L"eval", &builtin_eval );
- hash_put( &builtin, L"for", &builtin_for );
- hash_put( &builtin, L".", &builtin_source );
- hash_put( &builtin, L"set", &builtin_set );
- hash_put( &builtin, L"fg", &builtin_fg );
- hash_put( &builtin, L"bg", &builtin_bg );
- hash_put( &builtin, L"jobs", &builtin_jobs );
- hash_put( &builtin, L"read", &builtin_read );
- hash_put( &builtin, L"break", &builtin_break_continue );
- hash_put( &builtin, L"continue", &builtin_break_continue );
- hash_put( &builtin, L"return", &builtin_return );
- hash_put( &builtin, L"commandline", &builtin_commandline );
- hash_put( &builtin, L"switch", &builtin_switch );
- hash_put( &builtin, L"case", &builtin_case );
- hash_put( &builtin, L"bind", &builtin_bind );
- hash_put( &builtin, L"random", &builtin_random );
- hash_put( &builtin, L"status", &builtin_status );
+ hash_put( &builtin, L"exit", (void*) &builtin_exit );
+ hash_put( &builtin, L"builtin", (void*) &builtin_builtin );
+ hash_put( &builtin, L"cd", (void*) &builtin_cd );
+ hash_put( &builtin, L"function", (void*) &builtin_function );
+ hash_put( &builtin, L"functions", (void*) &builtin_functions );
+ hash_put( &builtin, L"complete", (void*) &builtin_complete );
+ hash_put( &builtin, L"end", (void*) &builtin_end );
+ hash_put( &builtin, L"else", (void*) &builtin_else );
+ hash_put( &builtin, L"eval", (void*) &builtin_eval );
+ hash_put( &builtin, L"for", (void*) &builtin_for );
+ hash_put( &builtin, L".", (void*) &builtin_source );
+ hash_put( &builtin, L"set", (void*) &builtin_set );
+ hash_put( &builtin, L"fg", (void*) &builtin_fg );
+ hash_put( &builtin, L"bg", (void*) &builtin_bg );
+ hash_put( &builtin, L"jobs", (void*) &builtin_jobs );
+ hash_put( &builtin, L"read", (void*) &builtin_read );
+ hash_put( &builtin, L"break", (void*) &builtin_break_continue );
+ hash_put( &builtin, L"continue", (void*) &builtin_break_continue );
+ hash_put( &builtin, L"return", (void*) &builtin_return );
+ hash_put( &builtin, L"commandline", (void*) &builtin_commandline );
+ hash_put( &builtin, L"switch", (void*) &builtin_switch );
+ hash_put( &builtin, L"case", (void*) &builtin_case );
+ hash_put( &builtin, L"bind", (void*) &builtin_bind );
+ hash_put( &builtin, L"random", (void*) &builtin_random );
+ hash_put( &builtin, L"status", (void*) &builtin_status );
/*
Builtins that are handled directly by the parser. They are
bound to a noop function only so that they show up in the
listings of builtin commands, etc..
*/
- hash_put( &builtin, L"command", &builtin_ignore );
- hash_put( &builtin, L"if", &builtin_ignore );
- hash_put( &builtin, L"while", &builtin_ignore );
- hash_put( &builtin, L"not", &builtin_generic );
- hash_put( &builtin, L"and", &builtin_generic );
- hash_put( &builtin, L"or", &builtin_generic );
- hash_put( &builtin, L"exec", &builtin_exec );
- hash_put( &builtin, L"begin", &builtin_begin );
+ hash_put( &builtin, L"command", (void*) &builtin_ignore );
+ hash_put( &builtin, L"if", (void*) &builtin_ignore );
+ hash_put( &builtin, L"while", (void*) &builtin_ignore );
+ hash_put( &builtin, L"not", (void*) &builtin_generic );
+ hash_put( &builtin, L"and", (void*) &builtin_generic );
+ hash_put( &builtin, L"or", (void*) &builtin_generic );
+ hash_put( &builtin, L"exec", (void*) &builtin_exec );
+ hash_put( &builtin, L"begin", (void*) &builtin_begin );
/*
This is not a builtin, but fish handles it's help display
internally, to do some ugly special casing to make sure 'count
-h', but 'count (echo -h)' does not.
*/
- hash_put( &builtin, L"count", &builtin_ignore );
+ hash_put( &builtin, L"count", (void*) &builtin_ignore );
intern_static( L"exit" );
intern_static( L"builtin" );
diff --git a/env.c b/env.c
index 8ffa9565..0971840f 100644
--- a/env.c
+++ b/env.c
@@ -219,7 +219,7 @@ static void universal_callback( int type,
has_changed=1;
ev.type=EVENT_VARIABLE;
- ev.variable=name;
+ ev.param1.variable=name;
ev.function_name=0;
al_init( &arg );
@@ -520,7 +520,7 @@ void env_set( const wchar_t *key,
if( !is_universal )
{
ev.type=EVENT_VARIABLE;
- ev.variable = key;
+ ev.param1.variable = key;
ev.function_name = 0;
al_init( &ev_list );
diff --git a/event.c b/event.c
index 47d93c00..3c2ff486 100644
--- a/event.c
+++ b/event.c
@@ -83,17 +83,18 @@ static int event_match( event_t *class, event_t *instance )
{
case EVENT_SIGNAL:
- if( class->signal == EVENT_ANY_SIGNAL )
+ if( class->param1.signal == EVENT_ANY_SIGNAL )
return 1;
- return class->signal == instance->signal;
+ return class->param1.signal == instance->param1.signal;
case EVENT_VARIABLE:
- return wcscmp( instance->variable, class->variable )==0;
+ return wcscmp( instance->param1.variable,
+ class->param1.variable )==0;
case EVENT_EXIT:
- if( class->pid == EVENT_ANY_PID )
+ if( class->param1.pid == EVENT_ANY_PID )
return 1;
- return class->pid == instance->pid;
+ return class->param1.pid == instance->param1.pid;
}
/**
@@ -118,7 +119,7 @@ static event_t *event_copy( event_t *event )
e->function_name = wcsdup( e->function_name );
if( e->type == EVENT_VARIABLE )
- e->variable = wcsdup( e->variable );
+ e->param1.variable = wcsdup( e->param1.variable );
return e;
}
@@ -132,7 +133,7 @@ void event_add_handler( event_t *event )
if( e->type == EVENT_SIGNAL )
{
- signal_handle( e->signal, 1 );
+ signal_handle( e->param1.signal, 1 );
}
al_push( events, e );
@@ -171,12 +172,12 @@ void event_remove( event_t *criterion )
if( n->type == EVENT_SIGNAL )
{
e.type = EVENT_SIGNAL;
- e.signal = n->signal;
+ e.param1.signal = n->param1.signal;
e.function_name = 0;
if( event_get( &e, 0 ) == 1 )
{
- signal_handle( e.signal, 0 );
+ signal_handle( e.param1.signal, 0 );
}
}
@@ -389,8 +390,8 @@ static void event_fire_signal_events()
for( i=0; i<lst->count; i++ )
{
- e.signal = lst->signal[i];
- al_set( &a, 0, sig2wcs( e.signal ) );
+ e.param1.signal = lst->signal[i];
+ al_set( &a, 0, sig2wcs( e.param1.signal ) );
event_fire_internal( &e, &a );
}
@@ -414,7 +415,7 @@ void event_fire( event_t *event, array_list_t *arguments )
signal handler.
*/
if( sig_list[active_list].count < SIG_UNHANDLED_MAX )
- sig_list[active_list].signal[sig_list[active_list].count++]=event->signal;
+ sig_list[active_list].signal[sig_list[active_list].count++]=event->param1.signal;
else
sig_list[active_list].overflow=1;
@@ -458,7 +459,7 @@ void event_free( event_t *e )
{
free( (void *)e->function_name );
if( e->type == EVENT_VARIABLE )
- free( (void *)e->variable );
+ free( (void *)e->param1.variable );
free( e );
}
diff --git a/event.h b/event.h
index 8e9685a9..c691e6bd 100644
--- a/event.h
+++ b/event.h
@@ -53,8 +53,7 @@ typedef struct
Process id for process-type events. Use EVENT_ANY_PID to match any pid.
*/
pid_t pid;
- }
- ;
+ } param1;
const wchar_t *function_name;
}
diff --git a/exec.c b/exec.c
index dc0ca1ee..08ec35a4 100644
--- a/exec.c
+++ b/exec.c
@@ -144,8 +144,8 @@ static int use_fd_in_pipe( int fd, io_data_t *io )
if( ( io->io_mode == IO_BUFFER ) ||
( io->io_mode == IO_PIPE ) )
{
- if( io->pipe_fd[0] == fd ||
- io->pipe_fd[1] == fd )
+ if( io->param1.pipe_fd[0] == fd ||
+ io->param1.pipe_fd[1] == fd )
return 1;
}
@@ -206,11 +206,11 @@ void free_fd( io_data_t *io, int fd )
int i;
for( i=0; i<2; i++ )
{
- if(io->pipe_fd[i] == fd )
+ if(io->param1.pipe_fd[i] == fd )
{
while(1)
{
- if( (io->pipe_fd[i] = dup(fd)) == -1)
+ if( (io->param1.pipe_fd[i] = dup(fd)) == -1)
{
if( errno != EINTR )
{
@@ -242,7 +242,7 @@ static void handle_child_io( io_data_t *io )
{
int tmp;
- if( io->io_mode == IO_FD && io->fd == io->old_fd )
+ if( io->io_mode == IO_FD && io->fd == io->param1.old_fd )
{
continue;
}
@@ -276,11 +276,12 @@ static void handle_child_io( io_data_t *io )
case IO_CLOSE:
break;
case IO_FILE:
- if( (tmp=wopen( io->filename, io->flags, 0666 ))==-1 )
+ if( (tmp=wopen( io->param1.filename,
+ io->param2.flags, 0666 ))==-1 )
{
debug( 1,
FILE_ERROR,
- io->filename );
+ io->param1.filename );
wperror( L"open" );
exit(1);
@@ -305,7 +306,7 @@ static void handle_child_io( io_data_t *io )
p->pid,
io->old_fd );
*/
- if( dup2( io->old_fd, io->fd ) == -1 )
+ if( dup2( io->param1.old_fd, io->fd ) == -1 )
{
debug( 1,
FD_ERROR,
@@ -327,7 +328,7 @@ static void handle_child_io( io_data_t *io )
*/
int fd_to_dup = io->fd;
- if( dup2( io->pipe_fd[fd_to_dup?1:0], io->fd ) == -1 )
+ if( dup2( io->param1.pipe_fd[fd_to_dup?1:0], io->fd ) == -1 )
{
debug( 1, PIPE_ERROR );
wperror( L"dup2" );
@@ -336,11 +337,11 @@ static void handle_child_io( io_data_t *io )
if( fd_to_dup != 0 )
{
- exec_close( io->pipe_fd[0]);
- exec_close( io->pipe_fd[1]);
+ exec_close( io->param1.pipe_fd[0]);
+ exec_close( io->param1.pipe_fd[1]);
}
else
- exec_close( io->pipe_fd[0] );
+ exec_close( io->param1.pipe_fd[0] );
/*
if( close( io[i].pipe_fd[ io->fd ] ) == -1 )
@@ -458,7 +459,7 @@ static io_data_t *io_transmogrify( io_data_t * in )
out->fd = in->fd;
out->io_mode = IO_FD;
- out->close_old = 1;
+ out->param2.close_old = 1;
switch( in->io_mode )
{
@@ -481,17 +482,17 @@ static io_data_t *io_transmogrify( io_data_t * in )
{
int fd;
- if( (fd=wopen( in->filename, in->flags, 0666 ))==-1 )
+ if( (fd=wopen( in->param1.filename, in->param2.flags, 0666 ))==-1 )
{
debug( 1,
FILE_ERROR,
- in->filename );
+ in->param1.filename );
wperror( L"open" );
exit(1);
}
- out->old_fd = fd;
+ out->param1.old_fd = fd;
break;
}
}
@@ -514,7 +515,7 @@ static void io_untransmogrify( io_data_t * in, io_data_t *out )
switch( in->io_mode )
{
case IO_FILE:
- exec_close( out->old_fd );
+ exec_close( out->param1.old_fd );
break;
}
free(out);
@@ -669,12 +670,12 @@ void exec( job_t *j )
pipe_read.fd=0;
pipe_write.fd=1;
pipe_read.io_mode=IO_PIPE;
- pipe_read.pipe_fd[0] = -1;
- pipe_read.pipe_fd[1] = -1;
+ pipe_read.param1.pipe_fd[0] = -1;
+ pipe_read.param1.pipe_fd[1] = -1;
pipe_write.io_mode=IO_PIPE;
pipe_read.next=0;
pipe_write.next=0;
- pipe_write.pipe_fd[0]=pipe_write.pipe_fd[1]=0;
+ pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=0;
//fwprintf( stderr, L"Run command %ls\n", j->command );
@@ -730,7 +731,7 @@ void exec( job_t *j )
mypipe[0],
mypipe[1] );
*/
- memcpy( pipe_write.pipe_fd, mypipe, sizeof(int)*2);
+ memcpy( pipe_write.param1.pipe_fd, mypipe, sizeof(int)*2);
}
else
{
@@ -823,7 +824,7 @@ void exec( job_t *j )
case IO_FD:
{
- builtin_stdin = in->old_fd;
+ builtin_stdin = in->param1.old_fd;
/* fwprintf( stderr,
L"Input redirection for builtin '%ls' from fd %d\n",
p->argv[0],
@@ -833,7 +834,7 @@ void exec( job_t *j )
}
case IO_PIPE:
{
- builtin_stdin = in->pipe_fd[0];
+ builtin_stdin = in->param1.pipe_fd[0];
break;
}
@@ -845,7 +846,8 @@ void exec( job_t *j )
L"Input redirection for builtin from file %ls\n",
in->filename);
*/
- new_fd=wopen( in->filename, in->flags, 0666 );
+ new_fd=wopen( in->param1.filename,
+ in->param2.flags, 0666 );
if( new_fd == -1 )
{
wperror( L"wopen" );
@@ -873,7 +875,7 @@ void exec( job_t *j )
}
else
{
- builtin_stdin = pipe_read.pipe_fd[0];
+ builtin_stdin = pipe_read.param1.pipe_fd[0];
}
builtin_push_io( builtin_stdin );
@@ -934,7 +936,7 @@ void exec( job_t *j )
io_buffer_read( io_buffer );
- if( io_buffer->out_buffer->used != 0 )
+ if( io_buffer->param2.out_buffer->used != 0 )
{
/*Temporary signal block for SIGCHLD */
@@ -948,8 +950,8 @@ void exec( job_t *j )
p->pid = getpid();
setup_child_process( j );
write( io_buffer->fd,
- io_buffer->out_buffer->buff,
- io_buffer->out_buffer->used );
+ io_buffer->param2.out_buffer->buff,
+ io_buffer->param2.out_buffer->used );
exit( status );
}
else if (pid < 0)
@@ -1008,7 +1010,7 @@ void exec( job_t *j )
{
// fwprintf( stderr, L"Skip fork of %ls\n", j->command );
char *res = wcs2str( (wchar_t *)sb_out->buff );
- b_append( io->out_buffer, res, strlen( res ) );
+ b_append( io->param2.out_buffer, res, strlen( res ) );
skip_fork = 1;
free( res );
}
@@ -1123,13 +1125,13 @@ void exec( job_t *j )
/*
Close the pipe the current process uses to read from the previous process_t
*/
- if( pipe_read.pipe_fd[0] >= 0 )
- exec_close( pipe_read.pipe_fd[0] );
+ if( pipe_read.param1.pipe_fd[0] >= 0 )
+ exec_close( pipe_read.param1.pipe_fd[0] );
/*
Set up the pipe the next process uses to read from the current process_t
*/
if( p->next )
- pipe_read.pipe_fd[0] = mypipe[0];
+ pipe_read.param1.pipe_fd[0] = mypipe[0];
/*
If there is a next process, close the output end of the
@@ -1192,9 +1194,9 @@ int exec_subshell( const wchar_t *cmd,
is_subshell = prev_subshell;
- b_append( io_buffer->out_buffer, &z, 1 );
+ b_append( io_buffer->param2.out_buffer, &z, 1 );
- begin=end=io_buffer->out_buffer->buff;
+ begin=end=io_buffer->param2.out_buffer->buff;
if( l )
{
diff --git a/io.c b/io.c
index 0c868d0e..498d9b03 100644
--- a/io.c
+++ b/io.c
@@ -38,22 +38,21 @@ Utilities for io redirection.
void io_buffer_read( io_data_t *d )
{
- exec_close(d->pipe_fd[1] );
+ exec_close(d->param1.pipe_fd[1] );
if( d->io_mode == IO_BUFFER )
{
- if( fcntl( d->pipe_fd[0], F_SETFL, 0 ) )
+ if( fcntl( d->param1.pipe_fd[0], F_SETFL, 0 ) )
{
wperror( L"fcntl" );
return;
}
- debug( 4, L"exec_read_io_buffer: blocking read on fd %d", d->pipe_fd[0] );
-
+ debug( 4, L"exec_read_io_buffer: blocking read on fd %d", d->param1.pipe_fd[0] );
while(1)
{
char b[4096];
int l;
- l=read_blocked( d->pipe_fd[0], b, 4096 );
+ l=read_blocked( d->param1.pipe_fd[0], b, 4096 );
if( l==0 )
{
break;
@@ -71,7 +70,7 @@ void io_buffer_read( io_data_t *d )
{
debug( 1,
L"An error occured while reading output from code block on fd %d",
- d->pipe_fd[0] );
+ d->param1.pipe_fd[0] );
wperror( L"exec_read_io_buffer" );
}
@@ -79,7 +78,7 @@ void io_buffer_read( io_data_t *d )
}
else
{
- b_append( d->out_buffer, b, l );
+ b_append( d->param2.out_buffer, b, l );
}
}
}
@@ -92,26 +91,26 @@ io_data_t *io_buffer_create()
buffer_redirect->io_mode=IO_BUFFER;
buffer_redirect->next=0;
- buffer_redirect->out_buffer= malloc( sizeof(buffer_t));
- b_init( buffer_redirect->out_buffer );
+ buffer_redirect->param2.out_buffer= malloc( sizeof(buffer_t));
+ b_init( buffer_redirect->param2.out_buffer );
buffer_redirect->fd=1;
- if( exec_pipe( buffer_redirect->pipe_fd ) == -1 )
+ if( exec_pipe( buffer_redirect->param1.pipe_fd ) == -1 )
{
debug( 1, PIPE_ERROR );
wperror (L"pipe");
- free( buffer_redirect->out_buffer );
+ free( buffer_redirect->param2.out_buffer );
free( buffer_redirect );
return 0;
}
- else if( fcntl( buffer_redirect->pipe_fd[0],
+ else if( fcntl( buffer_redirect->param1.pipe_fd[0],
F_SETFL,
O_NONBLOCK ) )
{
debug( 1, PIPE_ERROR );
wperror( L"fcntl" );
- free( buffer_redirect->out_buffer );
+ free( buffer_redirect->param2.out_buffer );
free( buffer_redirect );
return 0;
}
@@ -121,16 +120,16 @@ io_data_t *io_buffer_create()
void io_buffer_destroy( io_data_t *io_buffer )
{
- exec_close( io_buffer->pipe_fd[0] );
+ exec_close( io_buffer->param1.pipe_fd[0] );
/*
Dont free fd for writing. This should already be free'd before
calling exec_read_io_buffer on the buffer
*/
- b_destroy( io_buffer->out_buffer );
+ b_destroy( io_buffer->param2.out_buffer );
- free( io_buffer->out_buffer );
+ free( io_buffer->param2.out_buffer );
free( io_buffer );
}
diff --git a/io.h b/io.h
index 6cb103be..89916c5a 100644
--- a/io.h
+++ b/io.h
@@ -26,7 +26,7 @@ typedef struct io_data
wchar_t *filename;
/** fd to redirect specified fd to, for IO_FD*/
int old_fd;
- }
+ } param1
;
union
{
@@ -37,7 +37,7 @@ typedef struct io_data
/** Whether to close old_fd for IO_FD */
int close_old;
- }
+ } param2
;
/** Pointer to the next IO redirection */
diff --git a/parser.c b/parser.c
index 17ce457a..f0ca2f27 100644
--- a/parser.c
+++ b/parser.c
@@ -208,27 +208,27 @@ void parser_pop_block()
{
case FOR:
{
- free( current_block->for_variable );
- al_foreach( &current_block->for_vars,
+ free( current_block->param1.for_variable );
+ al_foreach( &current_block->param2.for_vars,
(void (*)(const void *))&free );
- al_destroy( &current_block->for_vars );
+ al_destroy( &current_block->param2.for_vars );
break;
}
case SWITCH:
{
- free( current_block->switch_value );
+ free( current_block->param1.switch_value );
break;
}
case FUNCTION_DEF:
{
- free( current_block->function_name );
- free( current_block->function_description );
- al_foreach( current_block->function_events,
+ free( current_block->param1.function_name );
+ free( current_block->param2.function_description );
+ al_foreach( current_block->param4.function_events,
(void (*)(const void *))&event_free );
- al_destroy( current_block->function_events );
- free( current_block->function_events );
+ al_destroy( current_block->param4.function_events );
+ free( current_block->param4.function_events );
break;
}
@@ -1110,20 +1110,20 @@ static void parse_job_main_loop( process_t *p,
{
case TOK_REDIRECT_APPEND:
new_io->io_mode = IO_FILE;
- new_io->flags = O_CREAT | O_APPEND | O_WRONLY;
- new_io->filename = target;
+ new_io->param2.flags = O_CREAT | O_APPEND | O_WRONLY;
+ new_io->param1.filename = target;
break;
case TOK_REDIRECT_OUT:
new_io->io_mode = IO_FILE;
- new_io->flags = O_CREAT | O_WRONLY | O_TRUNC;
- new_io->filename = target;
+ new_io->param2.flags = O_CREAT | O_WRONLY | O_TRUNC;
+ new_io->param1.filename = target;
break;
case TOK_REDIRECT_IN:
new_io->io_mode = IO_FILE;
- new_io->flags = O_RDONLY;
- new_io->filename = target;
+ new_io->param2.flags = O_RDONLY;
+ new_io->param1.filename = target;
break;
case TOK_REDIRECT_FD:
@@ -1134,11 +1134,11 @@ static void parse_job_main_loop( process_t *p,
else
{
new_io->io_mode = IO_FD;
- new_io->old_fd = wcstol( target,
+ new_io->param1.old_fd = wcstol( target,
0,
10 );
- if( ( new_io->old_fd < 0 ) ||
- ( new_io->old_fd > 10 ) )
+ if( ( new_io->param1.old_fd < 0 ) ||
+ ( new_io->param1.old_fd > 10 ) )
{
error_arg( SYNTAX_ERROR,
L"Requested redirection to something "
@@ -1358,9 +1358,9 @@ static int parse_job( process_t *p,
{
new_block = 1;
}
- else if( current_block->while_state == WHILE_TEST_AGAIN )
+ else if( current_block->param1.while_state == WHILE_TEST_AGAIN )
{
- current_block->while_state = WHILE_TEST_FIRST;
+ current_block->param1.while_state = WHILE_TEST_FIRST;
}
else
{
@@ -1370,7 +1370,7 @@ static int parse_job( process_t *p,
if( new_block )
{
parser_push_block( WHILE );
- current_block->while_state=WHILE_TEST_FIRST;
+ current_block->param1.while_state=WHILE_TEST_FIRST;
current_block->tok_pos = mark;
}
@@ -1385,7 +1385,7 @@ static int parse_job( process_t *p,
parser_push_block( IF );
- current_block->if_state=0;
+ current_block->param1.if_state=0;
current_block->tok_pos = mark;
free( nxt );
@@ -1627,7 +1627,7 @@ static void skipped_exec( job_t * j )
else if( wcscmp( p->argv[0], L"else" )==0)
{
if( (current_block->type == IF ) &&
- (current_block->if_state != 0))
+ (current_block->param1.if_state != 0))
{
exec( j );
return;
@@ -1757,12 +1757,12 @@ static void eval_job( tokenizer *tok )
{
// debug( 2, L"We are at begining of a while block\n" );
- switch( current_block->while_state )
+ switch( current_block->param1.while_state )
{
case WHILE_TEST_FIRST:
{
current_block->skip = proc_get_last_status()!= 0;
- current_block->while_state=WHILE_TESTED;
+ current_block->param1.while_state=WHILE_TESTED;
}
break;
}
@@ -1770,13 +1770,13 @@ static void eval_job( tokenizer *tok )
if( current_block->type == IF )
{
- if( (!current_block->if_state) &&
+ if( (!current_block->param1.if_state) &&
(!current_block->skip) )
{
// debug( 2, L"Result of if block is %d\n", proc_get_last_status() );
current_block->skip = proc_get_last_status()!= 0;
- current_block->if_state++;
+ current_block->param1.if_state++;
}
}
diff --git a/parser.h b/parser.h
index a6101eff..d02edf13 100644
--- a/parser.h
+++ b/parser.h
@@ -35,7 +35,7 @@ typedef struct block
int if_state; /**< The state of the if block */
wchar_t *switch_value; /**< The value to test in a switch block */
wchar_t *function_name; /**< The name of the function to define */
- };
+ } param1;
/**
Second block type specific variable
@@ -45,7 +45,7 @@ typedef struct block
array_list_t for_vars; /**< List of values for a for block */
int switch_taken; /**< Whether a switch match has already been found */
wchar_t *function_description; /**< The description of the function to define */
- };
+ } param2;
/**
Third block type specific variable
@@ -53,7 +53,7 @@ typedef struct block
union
{
int function_is_binding; /**< Whether a function is a keybinding */
- };
+ } param3;
/**
Fourth block type specific variable
@@ -61,8 +61,7 @@ typedef struct block
union
{
array_list_t *function_events;
- }
- ;
+ } param4;
diff --git a/proc.c b/proc.c
index 1389c6cc..72d6a50f 100644
--- a/proc.c
+++ b/proc.c
@@ -154,7 +154,7 @@ void job_free( job_t * j )
// fwprintf( stderr, L"Kill redirect %d of type %d\n", ionext, io->io_mode );
if( io->io_mode == IO_FILE )
{
- free( io->filename );
+ free( io->param1.filename );
}
free( io );
}
@@ -481,7 +481,7 @@ static void fire_process_event( const wchar_t *msg, pid_t pid, int status )
e.function_name=0;
ev.type=EVENT_EXIT;
- ev.pid = pid;
+ ev.param1.pid = pid;
al_push( &event_arg, msg );
@@ -734,10 +734,10 @@ static int select_try( job_t *j )
{
if( d->io_mode == IO_BUFFER )
{
- int fd = d->pipe_fd[0];
+ int fd = d->param1.pipe_fd[0];
// fwprintf( stderr, L"fd %d on job %ls\n", fd, j->command );
FD_SET( fd, &fds );
- maxfd=maxi( maxfd, d->pipe_fd[0] );
+ maxfd=maxi( maxfd, d->param1.pipe_fd[0] );
debug( 3, L"select_try on %d\n", fd );
}
}
@@ -785,7 +785,8 @@ static void read_try( job_t *j )
char b[BUFFER_SIZE];
int l;
- l=read_blocked( buff->pipe_fd[0], b, BUFFER_SIZE );
+ l=read_blocked( buff->param1.pipe_fd[0],
+ b, BUFFER_SIZE );
if( l==0 )
{
break;
@@ -802,7 +803,7 @@ static void read_try( job_t *j )
}
else
{
- b_append( buff->out_buffer, b, l );
+ b_append( buff->param2.out_buffer, b, l );
}
}
diff --git a/reader.c b/reader.c
index 2b283865..dfc137f7 100644
--- a/reader.c
+++ b/reader.c
@@ -1271,10 +1271,10 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
int nil=0;
- b_append( out->out_buffer, &nil, 1 );
+ b_append( out->param2.out_buffer, &nil, 1 );
wchar_t *tmp;
- wchar_t *str = str2wcs((char *)out->out_buffer->buff);
+ wchar_t *str = str2wcs((char *)out->param2.out_buffer->buff);
if( str )
{
diff --git a/signal.c b/signal.c
index f2f1f276..b31a1390 100644
--- a/signal.c
+++ b/signal.c
@@ -302,7 +302,7 @@ static void default_handler(int signal, siginfo_t *info, void *context)
{
event_t e;
e.type=EVENT_SIGNAL;
- e.signal = signal;
+ e.param1.signal = signal;
e.function_name=0;
event_fire( &e, 0 );