Remove some dead variables.

Fix screwy output for invalid tilde expansion in expand.cpp
Some cleanup per clang static analyzer
This commit is contained in:
ridiculousfish 2012-03-25 23:31:03 -07:00
parent a11687fc5c
commit 31b7d076b7
6 changed files with 17 additions and 19 deletions

View file

@ -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');

View file

@ -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;
}

View file

@ -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];
/*

View file

@ -1154,7 +1154,6 @@ static int expand_cmdsubst( parser_t &parser, const wcstring &input, std::vector
wchar_t prev=0;
std::vector<wcstring> 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
{

View file

@ -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
}

View file

@ -211,7 +211,6 @@ int main( int argc, char **argv )
char *fgcolor=0;
bool bold=false;
bool underline=false;
char *bg_seq, *fg_seq;
while( 1 )
{