Index: ossp-pkg/rc/00TODO RCS File: /v/ossp/cvs/ossp-pkg/rc/00TODO,v rcsdiff -q -kk '-r1.27' '-r1.28' -u '/v/ossp/cvs/ossp-pkg/rc/00TODO,v' 2>/dev/null --- 00TODO 2002/06/28 17:43:23 1.27 +++ 00TODO 2002/06/28 18:23:10 1.28 @@ -33,6 +33,7 @@ Write interlocking increment for thread-safe increments. Convert some normal assert() to real runtime checks. Use str_hash von ossp str or static RC_XXX_VAL array from rc_option.h. + Restore lost multiple location merging logic. Implementation Correct assertion, sanity check, and if () checks according to one standard. Index: ossp-pkg/rc/rc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.c,v rcsdiff -q -kk '-r1.35' '-r1.36' -u '/v/ossp/cvs/ossp-pkg/rc/rc.c,v' 2>/dev/null --- rc.c 2002/06/28 17:43:23 1.35 +++ rc.c 2002/06/28 18:23:10 1.36 @@ -33,38 +33,52 @@ /************************************************ -* main(int, char **) * -* Main rc control block * +* rcError(ex_t) * +* Main rc error handler * ************************************************/ -int main(int argc, char *argv[]) +void rcError(ex_t Localerr) { - ex_t Except; - - try { /* Configuration block */ - configNew(); /* Construct a new configuration */ - configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ - configVerify(); /* Test for usage, help, and version options */ - } - catch(Except) { /* Exceptions of the configuration block */ - if ((rc_return_t)Except.ex_value == RC_WRN_TRM) + if (FAILED((rc_return_t)Localerr.ex_value)) { /* Error condition */ + if ((rc_return_t)Localerr.ex_value == RC_WRN_TRM) exit(0); - else if ((rc_return_t)Except.ex_value == RC_ERR_USE) + else if ((rc_return_t)Localerr.ex_value == RC_ERR_USE) clioptPrintusage(); + else if ((rc_return_t)Localerr.ex_value == RC_ERR_FNC) + fprintf(stderr, " Error condition, function file could not be opened.\n"); + else if ((rc_return_t)Localerr.ex_value == RC_ERR_DIR) + fprintf(stderr, " Error condition, location dir could not be opened.\n"); + else if ((rc_return_t)Localerr.ex_value == RC_ERR_RCF) + fprintf(stderr, " Error condition, rc file could not be opened.\n"); else - if (FAILED((rc_return_t)Except.ex_value)) { /* Error condition */ - fprintf(stderr, " Error condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); - exit(1); /* Return failure */ - } + fprintf(stderr, " Error condition of class '%s',\n exception %d in %s:%s():%d.\n", (char *)Localerr.ex_class, (int)Localerr.ex_value, Localerr.ex_file, Localerr.ex_func, Localerr.ex_line); + exit(1); /* Return failure */ + } #ifdef DEBUG - else /* Warning condition */ - fprintf(stderr, " Warning condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); + else /* Warning condition */ + fprintf(stderr, " Warning condition of class '%s',\n exception %d in %s:%s():%d.\n", (char *)Localerr.ex_class, (int)Localerr.ex_value, Localerr.ex_file, Localerr.ex_func, Localerr.ex_line); #else - else /* Warning condition */ - RC_NOP; /* No operation on warnings */ + else /* Warning condition */ + RC_NOP; /* No operation on warnings */ #endif +} + +/************************************************ +* main(int, char **) * +* Main rc control block * +************************************************/ +int main(int argc, char *argv[]) +{ + ex_t Except; + + try { /* Configuration block */ + configNew(); /* Construct a new configuration */ + configLoad(argc, (const char **)argv); /* Load cli, env, and conf */ + configVerify(); /* Test for usage, help and version options */ } + catch(Except) /* Exceptions of the configuration block */ + rcError(Except); - try { /* Main processing block, the script is built here */ + try { /* Main processing block, script built here */ rc_proc_t *pProc = NULL; pProc = procNew(); /* Construct a new processor, build script */ procPopulate(pProc); /* Populate with run commands */ @@ -72,27 +86,9 @@ procDelete(pProc); /* Destroy the processor */ configDelete(); /* Destroy the configuration */ } - catch(Except) { /* Error exceptions thrown during script processing */ - if (FAILED((rc_return_t)Except.ex_value)) { /* Error condition */ - if ((rc_return_t)Except.ex_value == RC_ERR_FNC) - fprintf(stderr, " Error condition, function file could not be opened.\n"); - else if ((rc_return_t)Except.ex_value == RC_ERR_DIR) - fprintf(stderr, " Error condition, location dir could not be opened.\n"); - else if ((rc_return_t)Except.ex_value == RC_ERR_RCF) - fprintf(stderr, " Error condition, rc file could not be opened.\n"); - else - fprintf(stderr, " Error condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); - exit(1); /* Return failure */ - } -#ifdef DEBUG - else /* Warning condition */ - fprintf(stderr, " Warning condition in proc, class '%s',\n exception %d in %s:%s():%d.\n", (char *)Except.ex_class, (int)Except.ex_value, Except.ex_file, Except.ex_func, Except.ex_line); -#else - else /* Warning condition */ - RC_NOP; /* No operation on warnings */ -#endif - } + catch(Except) /* Exception thrown while script processing */ + rcError(Except); - exit(0); /* Return success */ + exit(0); /* Return success */ } Index: ossp-pkg/rc/rc_proc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v' 2>/dev/null --- rc_proc.c 2002/06/28 17:43:23 1.8 +++ rc_proc.c 2002/06/28 18:23:10 1.9 @@ -132,7 +132,7 @@ if (szSec) /* Only call append if the section lookup succeeded */ scriptAppend(pRc->m_pScript, szSec, strlen(szSec)); - else + else if (configGetval(RC_DBG_VAL)) /* Only show when debug is set */ fprintf(stderr, "#Warning: Missing section '%s' in %s!\n", pRc->m_pAnal->m_pszSecs[i], pRc->m_pAnal->m_szRcs[nIter]); if (szSec) { /* Cleanup section string */