コード例 #1
0
ファイル: proc.cpp プロジェクト: msteed/fish-shell
void proc_sanity_check() {
    job_t *j;
    job_t *fg_job = 0;

    job_iterator_t jobs;
    while ((j = jobs.next())) {
        process_t *p;

        if (!job_get_flag(j, JOB_CONSTRUCTED)) continue;

        validate_pointer(j->first_process, _(L"Process list pointer"), 0);

        // More than one foreground job?
        if (job_get_flag(j, JOB_FOREGROUND) && !(job_is_stopped(j) || job_is_completed(j))) {
            if (fg_job != 0) {
                debug(0, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"),
                      fg_job->command_wcstr(), j->command_wcstr());
                sanity_lose();
            }
            fg_job = j;
        }

        p = j->first_process;
        while (p) {
            // Internal block nodes do not have argv - see issue #1545.
            bool null_ok = (p->type == INTERNAL_BLOCK_NODE);
            validate_pointer(p->get_argv(), _(L"Process argument list"), null_ok);
            validate_pointer(p->argv0(), _(L"Process name"), null_ok);
            validate_pointer(p->next, _(L"Process list pointer"), true);

            if ((p->stopped & (~0x00000001)) != 0) {
                debug(0, _(L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d"),
                      j->command_wcstr(), p->argv0(), p->stopped);
                sanity_lose();
            }

            if ((p->completed & (~0x00000001)) != 0) {
                debug(0, _(L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d"),
                      j->command_wcstr(), p->argv0(), p->completed);
                sanity_lose();
            }

            p = p->next;
        }
    }
}
コード例 #2
0
bool parser_t::job_remove(job_t *j) {
    job_list_t::iterator iter = std::find(my_job_list.begin(), my_job_list.end(), j);
    if (iter != my_job_list.end()) {
        my_job_list.erase(iter);
        return true;
    } else {
        debug(1, _(L"Job inconsistency"));
        sanity_lose();
        return false;
    }
}
コード例 #3
0
ファイル: parser.cpp プロジェクト: moverest/fish-shell
bool parser_t::job_remove(job_t *job) {
    for (auto iter = my_job_list.begin(); iter != my_job_list.end(); ++iter) {
        if (iter->get() == job) {
            my_job_list.erase(iter);
            return true;
        }
    }

    debug(1, _(L"Job inconsistency"));
    sanity_lose();
    return false;
}
コード例 #4
0
ファイル: env.cpp プロジェクト: lnsoso/fish-shell
void env_pop()
{
    if (&top->env != global)
    {
        int i;
        int locale_changed = 0;

        env_node_t *killme = top;

        for (i=0; locale_variable[i]; i++)
        {
            var_table_t::iterator result =  killme->env.find(locale_variable[i]);
            if (result != killme->env.end())
            {
                locale_changed = 1;
                break;
            }
        }

        if (killme->new_scope)
        {
            if (killme->exportv || local_scope_exports(killme->next))
                mark_changed_exported();
        }

        top = top->next;

        var_table_t::iterator iter;
        for (iter = killme->env.begin(); iter != killme->env.end(); ++iter)
        {
            const var_entry_t &entry = iter->second;
            if (entry.exportv)
            {
                mark_changed_exported();
                break;
            }
        }

        delete killme;

        if (locale_changed)
            handle_locale();

    }
    else
    {
        debug(0,
              _(L"Tried to pop empty environment stack."));
        sanity_lose();
    }
}
コード例 #5
0
ファイル: history.cpp プロジェクト: ecraven/fish-shell
bool history_item_t::matches_search(const wcstring &term, enum history_search_type_t type) const {
    switch (type) {
    
        case HISTORY_SEARCH_TYPE_CONTAINS:
        /* We consider equal strings to NOT match a contains search (so that you don't have to see history equal to what you typed). The length check ensures that. */
            return contents.size() > term.size() && contents.find(term) != wcstring::npos;
            
        case HISTORY_SEARCH_TYPE_PREFIX:
            /* We consider equal strings to match a prefix search, so that autosuggest will allow suggesting what you've typed */
            return string_prefixes_string(term, contents);
            
        default:
            sanity_lose();
            return false;
    }
}
コード例 #6
0
ファイル: proc.cpp プロジェクト: asheidan/fish-shell
void proc_sanity_check()
{
	job_t *j;
	job_t *fg_job=0;
	
    job_iterator_t jobs;
    while ((j = jobs.next()))
	{
		process_t *p;

		if( !job_get_flag( j, JOB_CONSTRUCTED ) )
			continue;
		
		
		validate_pointer( j->first_process,
						  _( L"Process list pointer" ),
						  0 );

		/*
		  More than one foreground job?
		*/
		if( job_get_flag( j, JOB_FOREGROUND ) && !(job_is_stopped(j) || job_is_completed(j) ) )
		{
			if( fg_job != 0 )
			{
				debug( 0, 
					   _( L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"),
					   fg_job->command_wcstr(),
					   j->command_wcstr() );
				sanity_lose();
			}
			fg_job = j;
		}
		
   		p = j->first_process;
		while( p )
		{			
			validate_pointer( p->get_argv(), _( L"Process argument list" ), 0 );
			validate_pointer( p->argv0(), _( L"Process name" ), 0 );
			validate_pointer( p->next, _( L"Process list pointer" ), 1 );
			validate_pointer( p->actual_cmd, _( L"Process command" ), 1 );
			
			if ( (p->stopped & (~0x00000001)) != 0 )
			{
				debug( 0,
					   _( L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d" ),
					   j->command_wcstr(), 
					   p->argv0(),
					   p->stopped );
				sanity_lose();
			}
			
			if ( (p->completed & (~0x00000001)) != 0 )
			{
				debug( 0,
					   _( L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d" ),
					   j->command_wcstr(), 
					   p->argv0(),
					   p->completed );
				sanity_lose();
			}
			
			p=p->next;
		}
		
	}	
}