From aef88fb773a5f8e70447c3fc6c00c59e17248015 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Tue, 12 May 2009 18:48:30 +0200 Subject: [PATCH] Removed the ST_QUIT state There shouldn't be a need for such a state when there's a central place where the program execution keeps returning to. --- src/calc.c | 12 ++++++++---- src/calc.h | 2 +- src/global.h | 1 - src/main.c | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/calc.c b/src/calc.c index 97f1c48..23f142a 100644 --- a/src/calc.c +++ b/src/calc.c @@ -300,7 +300,7 @@ int calc_key(int ch) { } -void calc_process() { +int calc_process() { char *path, *name; struct stat fs; struct dir *t; @@ -414,7 +414,7 @@ void calc_process() { link_del(root); browse_init(root->sub); - return; + return 0; } /* something went wrong... */ @@ -422,8 +422,12 @@ void calc_process() { calc_fail: while(failed && !input_handle(0)) ; - pstate = orig ? ST_BROWSE : ST_QUIT; - return; + if(orig == NULL) + return 1; + else { + browse_init(NULL); + return 0; + } } diff --git a/src/calc.h b/src/calc.h index e2f11ad..b3d4cb6 100644 --- a/src/calc.h +++ b/src/calc.h @@ -30,7 +30,7 @@ extern char calc_smfs; /* stay on the same filesystem */ -void calc_process(void); +int calc_process(void); int calc_key(int); void calc_draw(void); void calc_init(char *, struct dir *); diff --git a/src/global.h b/src/global.h index 43bbb3f..3d5295f 100644 --- a/src/global.h +++ b/src/global.h @@ -47,7 +47,6 @@ #define ST_BROWSE 1 #define ST_DEL 2 #define ST_HELP 3 -#define ST_QUIT 4 /* structure representing a file or directory */ diff --git a/src/main.c b/src/main.c index cc735c8..d3f22d6 100644 --- a/src/main.c +++ b/src/main.c @@ -159,9 +159,9 @@ int main(int argc, char **argv) { if(ncresize(min_rows, min_cols)) min_rows = min_cols = 0; - while(pstate != ST_QUIT) { - if(pstate == ST_CALC) - calc_process(); + while(1) { + if(pstate == ST_CALC && calc_process()) + break; else if(pstate == ST_DEL) delete_process(); else if(input_handle(0))