From 6aad57da86147b6e2d7964b7413c51fac787cf40 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 20 Jul 1998 13:07:00 +0000 Subject: [PATCH] Patch level : Files correlati : Ricompilazione Demo : [ ] Commento : controls.cpp Corretta gestione list box aperti durante la chiusura default.url Aggiunto BMP_STOP dongle.cpp Gestito utente GUEST expr.cpp Aggiunto errore su radice negativa files.cpp Tolti spazi inutili isam.cpp Migliorata conversione git-svn-id: svn://10.65.10.50/trunk@6851 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/controls.cpp | 7 +- include/default.url | 1 + include/dongle.cpp | 9 +-- include/expr.cpp | 27 +++++-- include/files.cpp | 6 +- include/isam.cpp | 167 ++++++++++++++++++++++--------------------- 6 files changed, 122 insertions(+), 95 deletions(-) diff --git a/include/controls.cpp b/include/controls.cpp index 1f0931205..b690cf3d7 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -1957,8 +1957,11 @@ void TDropDownList::close() if (_open) { _open = FALSE; - xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), FALSE); - xvt_dwin_update (xi_get_window(_obj->itf)); + if (_xi_lst) + { + xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), FALSE); + xvt_dwin_update (xi_get_window(_obj->itf)); + } } } diff --git a/include/default.url b/include/default.url index 5dfcbf331..55bdb0bd2 100755 --- a/include/default.url +++ b/include/default.url @@ -156,6 +156,7 @@ image BMP_EMAIL QRESDIR"email.bmp" image BMP_DIR QRESDIR"dir.bmp" image BMP_DIRDN QRESDIR"dirdn.bmp" image BMP_FILE QRESDIR"file.bmp" +image BMP_STOP QRESDIR"stop.bmp" #scan #transparent $$$ diff --git a/include/dongle.cpp b/include/dongle.cpp index 6649a85b8..903cdc8be 100755 --- a/include/dongle.cpp +++ b/include/dongle.cpp @@ -411,11 +411,12 @@ bool TDongle::network_login(bool test_all_keys) TConfig ini(CONFIG_INSTALL, "Server"); const char* server = ini.get("Dongle"); - const char* guest = "******"; - const TString appname = main_app().firm_change_enabled() ? main_app().name() : "ba0100"; - const char* utente = (!xvt_running() && appname == "ba0100") ? guest : user(); + const TString16 appname = main_app().name(); + TString16 utente = user(); + if (utente.empty() || (!xvt_running() && appname == "ba0100")) + utente = "GUEST"; - const bool ok = rpc_UserLogin(server, utente, guest, appname); + const bool ok = rpc_UserLogin(server, utente, "******", appname); if (ok) { _hardware = _dongle_network; diff --git a/include/expr.cpp b/include/expr.cpp index ead834276..a3461081e 100755 --- a/include/expr.cpp +++ b/include/expr.cpp @@ -381,15 +381,18 @@ void TExpression::eval() break; case _divide: { - real& r = evalstack.pop_real(); + const real& r = evalstack.pop_real(); if (r.is_zero()) { if (!evalstack.peek_real().is_zero()) + { if (_ignore_error) _error=1; else print_error("Divisione per zero!"); - } else + } + } + else evalstack.peek_real() /= r; } break; @@ -519,7 +522,18 @@ void TExpression::eval() } break; case _sqrt: - evalstack.peek_real() = sqrt(evalstack.peek_real()); + { + real& r = evalstack.peek_real(); + if (r < ZERO) + { + if (_ignore_error) + _error=1; + else + print_error("Radice negativa!"); + r = -r; + } + r = sqrt(r); + } break; case _sqr: evalstack.peek_real() = sqr(evalstack.peek_real()); @@ -1143,8 +1157,7 @@ bool TExpression::set(const char* expression, TTypeexp type) bool TExpression::compile(const char* expression, TTypeexp type) { - TCodesym currsym; - + _error=0; _user_func_defined = FALSE; _s = expression; _type = type; @@ -1152,7 +1165,9 @@ bool TExpression::compile(const char* expression, TTypeexp type) _code.clear(); if (*_s == '\0') return TRUE; - if ((currsym = __gettoken()) == _invalid) + + TCodesym currsym = __gettoken(); + if (currsym == _invalid) return FALSE; return __expression(currsym) == _endsym; } diff --git a/include/files.cpp b/include/files.cpp index 6adbe551a..bcad0eb42 100755 --- a/include/files.cpp +++ b/include/files.cpp @@ -272,12 +272,12 @@ void TDir::get ( TDirop op) // @parm Tipo di operazioni effettuabili sul file (default _nordirop) { - int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR); + int whichdir = (dirtype == _nordir ? NORDIR : COMDIR); if (op == _nordirop) - COpenFile (nfile, _dir, int (lock), _whichdir); + COpenFile (nfile, _dir, int(lock), whichdir); else - CGetFile (nfile, _dir, int (lock), _whichdir); + CGetFile (nfile, _dir, int(lock), whichdir); _num = nfile; _com = _dir->SysName[0] != '$'; } diff --git a/include/isam.cpp b/include/isam.cpp index 76eb7ca0e..cb6d6a0e5 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -406,6 +406,8 @@ HIDDEN int __build_key(const RecDes *recd, int numkey, RecType recin, char *key HIDDEN int cisread(int fhnd, int knum, TRectype& record, int mode, TRecnotype& curr_recno) { + CHECKD(fhnd >= 0, "Can't use codebase handle ", fhnd); + const int rmode = (mode & READTYPES); const int lmode = (mode & RECLOCKTYPES); @@ -1604,101 +1606,107 @@ int TSystemisamfile::update( if (toconvert) fname = filename(); - if (toconvert && (dir.eox() > 0L || fname.exist())) + if (toconvert) //&& (dir.eox() > 0L || fname.exist())) { TRecnotype ni = 0L; TFilename tmpfname; tmpfname.temp("tf"); - err = _open_ex(_excllock); - if (err != NOERR) - return err; - err=DB_build(tmpfname, wrec.rec()); + if (err != NOERR) { err=get_error(err); return (err); } - // Apro il file destinazione in modo esclusivo e senza indici - int tmpnum = num(); - TIsam_handle ishandle = prefix().open_isamfile(tmpnum, tmpfname, TRUE, FALSE); - TCodeb_handle fhnd = prefix().get_handle(ishandle); - if (fhnd < 0 ) + if (dir.eod() > 0 && fname.exist() && oldrec.len()) { - err=get_error(fhnd); - return err; - } - - TString s(80); - s.format("Aggiornamento archivio %s\nTempo stimato alla fine del processo: ", (const char*) fname); - - const TRecnotype nitems = items(); - TProgind p(nitems > 0 ? nitems : 1, s, FALSE, TRUE, 70); - - TExtrectype nrec(wrec); - - const int nflds = curr().items(); - TArray infld, outfld; - for (int j = 0; j < nflds; j++) - { - const char* fld_name = curr().fieldname(j); - infld.add(new TRecfield(curr(), fld_name), j); - if (nrec.exist(fld_name)) - outfld.add(new TRecfield(nrec, fld_name), j); - } - - const clock_t start_time = clock(); - for (first(); good(); next()) - { - const bool tick = p.addstatus(1); - ni++; - - if (curr().isdeleted()) - continue; - - nrec.zero(); - for (j = outfld.first(); j < nflds; j = outfld.succ(j)) - { - TRecfield& in_fld = (TRecfield&)infld[j]; - TRecfield& out_fld = (TRecfield&)outfld[j]; - const char* fld_val = in_fld; - out_fld = fld_val; - } - if (lcf) - makelc((TRectype &)nrec); - browse_null(nrec.string(),lenr/*DB_reclen(fhnd)*/); - memcpy(DB_getrecord(fhnd),nrec.string(),lenr/*DB_reclen(fhnd)*/); - err=DB_add(fhnd); - if ( err == NOERR && nrec.has_memo()) - nrec.write_memo(fhnd, DB_recno(fhnd)); + err = _open_ex(_excllock); if (err != NOERR) - err=get_error(err); - setstatus(err); + return err; - if (tick) + + // Apro il file destinazione in modo esclusivo e senza indici + int tmpnum = num(); + TIsam_handle ishandle = prefix().open_isamfile(tmpnum, tmpfname, TRUE, FALSE); + TCodeb_handle fhnd = prefix().get_handle(ishandle); + if (fhnd < 0 ) { - const clock_t elapsed_ticks = clock() - start_time; - const clock_t total_ticks = elapsed_ticks * nitems / ni; - const clock_t estimated_ticks = total_ticks - elapsed_ticks; - long secs = estimated_ticks / CLOCKS_PER_SEC; - CHECK(secs >= 0, "Bad time estimation"); - const int hours = int(secs / 3600L); - secs %= 3600L; - const int mins = int(secs / 60L); - secs %= 60L; - const int append_pos = s.find("o: ")+3; - s.cut(append_pos); - s << format("%02d:%02d:%02ld", hours, mins, secs); - p.set_text(s); + err=get_error(fhnd); + return err; } + + TString s(80); + s.format("Aggiornamento archivio %s\nTempo stimato alla fine del processo: ", (const char*) fname); + + const TRecnotype nitems = items(); + TProgind p(nitems > 0 ? nitems : 1, s, FALSE, TRUE, 70); + + TExtrectype nrec(wrec); + + const int nflds = curr().items(); + TArray infld, outfld; + for (int j = 0; j < nflds; j++) + { + const char* fld_name = curr().fieldname(j); + infld.add(new TRecfield(curr(), fld_name), j); + if (nrec.exist(fld_name)) + outfld.add(new TRecfield(nrec, fld_name), j); + } + + const clock_t start_time = clock(); + for (first(); good(); next()) + { + const bool tick = p.addstatus(1); + ni++; + + if (curr().isdeleted()) + continue; + + nrec.zero(); + for (j = outfld.first(); j < nflds; j = outfld.succ(j)) + { + TRecfield& in_fld = (TRecfield&)infld[j]; + TRecfield& out_fld = (TRecfield&)outfld[j]; + const char* fld_val = in_fld; + out_fld = fld_val; + } + if (lcf) + makelc((TRectype &)nrec); + browse_null(nrec.string(),lenr/*DB_reclen(fhnd)*/); + memcpy(DB_getrecord(fhnd),nrec.string(),lenr/*DB_reclen(fhnd)*/); + err=DB_add(fhnd); + if ( err == NOERR && nrec.has_memo()) + nrec.write_memo(fhnd, DB_recno(fhnd)); + if (err != NOERR) + err=get_error(err); + setstatus(err); + + if (tick) + { + const clock_t elapsed_ticks = clock() - start_time; + const clock_t total_ticks = elapsed_ticks * nitems / ni; + const clock_t estimated_ticks = total_ticks - elapsed_ticks; + long secs = estimated_ticks / CLOCKS_PER_SEC; + CHECK(secs >= 0, "Bad time estimation"); + const int hours = int(secs / 3600L); + secs %= 3600L; + const int mins = int(secs / 60L); + secs %= 60L; + const int append_pos = s.find("o: ")+3; + s.cut(append_pos); + s << format("%02d:%02d:%02ld", hours, mins, secs); + p.set_text(s); + } + } + close(); + prefix().close_isamfile(ishandle); + + if (err!=NOERR) err=get_error(err); + + p.setstatus(nitems); } - close(); - prefix().close_isamfile(ishandle); - if (err!=NOERR) err=get_error(err); - - p.setstatus(nitems); if (err == NOERR) { long c = DB_getconf(); @@ -1752,9 +1760,8 @@ int TSystemisamfile::update( if (toconvert) { - if (dir.eox() > 0L) - packindex(); - if (err == NOERR) + packindex(); + if (err == NOERR) err = exec_convapp(lev, FALSE); // Post - conversion } }