diff --git a/builtin.cpp b/builtin.cpp index 500484076..eea5ae79c 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1171,7 +1171,7 @@ static void functions_def( const wcstring &name, wcstring &out ) /* This forced tab is sort of crummy - not all functions start with a tab */ append_format( out, L"\n\t%ls", def); - /* Append a newline before the end, unless there already is one there */ + /* Append a newline before the 'end', unless there already is one there */ size_t deflen = wcslen(def); if (deflen == 0 || def[deflen-1] != L'\n') { out.push_back(L'\n'); diff --git a/env.cpp b/env.cpp index 645dca02e..1450b68d1 100644 --- a/env.cpp +++ b/env.cpp @@ -714,11 +714,8 @@ static env_node_t *env_get_node( const wcstring &key ) while( env != 0 ) { - var_table_t::const_iterator result = env->env.find( key ); - - if ( result != env->env.end() ) + if ( env->env.find( key ) != env->env.end() ) { - res = result->second; return env; } diff --git a/exec.cpp b/exec.cpp index df35566ff..85c91f588 100644 --- a/exec.cpp +++ b/exec.cpp @@ -718,6 +718,7 @@ void exec( parser_t &parser, job_t *j ) for( p=j->first_process; p; p = p->next ) { + const bool p_wants_pipe = (p->next != NULL); mypipe[1]=-1; skip_fork=0; @@ -748,7 +749,7 @@ void exec( parser_t &parser, job_t *j ) j->io = io_add( j->io, &pipe_read ); } - if( p->next ) + if( p_wants_pipe ) { // debug( 1, L"%ls|%ls" , p->argv[0], p->next->argv[0]); @@ -1315,7 +1316,7 @@ void exec( parser_t &parser, job_t *j ) Set up the pipe the next process uses to read from the current process_t */ - if( p->next ) + if( p_wants_pipe ) pipe_read.param1.pipe_fd[0] = mypipe[0]; /* diff --git a/expand.cpp b/expand.cpp index 047d02e11..6ae935ccb 100644 --- a/expand.cpp +++ b/expand.cpp @@ -1154,7 +1154,6 @@ static int expand_cmdsubst( parser_t &parser, const wcstring &input, std::vector wchar_t prev=0; std::vector sub_res; size_t i, j; - const wchar_t *item_begin; wchar_t *tail_begin = 0; const wchar_t * const in = input.c_str(); @@ -1180,7 +1179,6 @@ static int expand_cmdsubst( parser_t &parser, const wcstring &input, std::vector len1 = (paran_begin-in); prev=0; - item_begin = paran_begin+1; const wcstring subcmd(paran_begin + 1, paran_end-paran_begin - 1); @@ -1328,16 +1326,14 @@ static void expand_tilde_internal( wcstring &input ) { tail_idx = wcslen( in ); } - tail_idx = name_end - in; - wcstring name_str = input.substr(1, name_end-in-1); - const char *name_cstr = wcs2str( name_str.c_str() ); - struct passwd *userinfo = - getpwnam( name_cstr ); - free((void *)name_cstr); + wcstring name_str = input.substr(1, tail_idx - 1); + std::string name_cstr = wcs2string(name_str); + struct passwd *userinfo = getpwnam( name_cstr.c_str() ); - if( userinfo == 0 ) + if( userinfo == NULL ) { tilde_error = 1; + input[0] = L'~'; } else { diff --git a/iothread.cpp b/iothread.cpp index 946d3a098..6b61b4422 100644 --- a/iothread.cpp +++ b/iothread.cpp @@ -203,10 +203,15 @@ void iothread_drain_all(void) { if (s_active_thread_count == 0) return; int thread_count = s_active_thread_count; +#define TIME_DRAIN 0 +#if TIME_DRAIN double now = timef(); +#endif while (s_active_thread_count > 0) { iothread_service_completion(); } +#if TIME_DRAIN double after = timef(); - //printf("(Waited %.02f msec for %d thread(s) to drain)\n", 1000 * (after - now), thread_count); + printf("(Waited %.02f msec for %d thread(s) to drain)\n", 1000 * (after - now), thread_count); +#endif } diff --git a/set_color.cpp b/set_color.cpp index 7366ba814..213d649c1 100644 --- a/set_color.cpp +++ b/set_color.cpp @@ -211,8 +211,7 @@ int main( int argc, char **argv ) char *fgcolor=0; bool bold=false; bool underline=false; - char *bg_seq, *fg_seq; - + while( 1 ) { static struct option