From d690a15b29e69b2dcd762541e5ed708c4f304c27 Mon Sep 17 00:00:00 2001 From: axel Date: Fri, 28 Apr 2006 23:21:37 +1000 Subject: Make job id numbering start from 1, not 0 darcs-hash:20060428132137-ac50b-8e5adcdbc18ad7627b66e9129a13b037a669dd02.gz --- expand.c | 18 ++++++++++-------- proc.c | 4 ++-- proc.h | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/expand.c b/expand.c index 6dd512b5..0ae783a5 100644 --- a/expand.c +++ b/expand.c @@ -421,16 +421,18 @@ static int find_process( const wchar_t *proc, { int jid = wcstol( proc, 0, 10 ); - - j = job_get( jid ); - if( (j != 0) && (j->command != 0 ) ) + if( jid > 0 ) { - + j = job_get( jid ); + if( (j != 0) && (j->command != 0 ) ) { - result = malloc(sizeof(wchar_t)*16 ); - swprintf( result, 16, L"%d", j->pgid ); - al_push( out, result ); - found = 1; + + { + result = malloc(sizeof(wchar_t)*16 ); + swprintf( result, 16, L"%d", j->pgid ); + al_push( out, result ); + found = 1; + } } } } diff --git a/proc.c b/proc.c index 79e89950..b3519e2d 100644 --- a/proc.c +++ b/proc.c @@ -182,7 +182,7 @@ int proc_get_last_status() job_t *job_create() { - int free_id=0; + int free_id=1; job_t *res; while( job_get( free_id ) != 0 ) @@ -204,7 +204,7 @@ job_t *job_create() job_t *job_get( int id ) { job_t *res = first_job; - if( id == -1 ) + if( id <= 0 ) { return res; } diff --git a/proc.h b/proc.h index 27496660..94d027e0 100644 --- a/proc.h +++ b/proc.h @@ -261,7 +261,7 @@ job_t *job_create(); /** Return the job with the specified job id. - If id is -1, return the last job used. + If id is 0 or less, return the last job used. */ job_t *job_get(int id); -- cgit v1.2.3