From 00aa150b320578cde04abfd86fa143ff9a9cd689 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 12 Mar 2004 15:41:25 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://10.65.10.50/trunk@11845 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/sheet.cpp | 28 +++++++++------- include/spies.cpp | 3 +- include/spies.h | 2 +- include/stdtypes.h | 4 +++ include/strings.cpp | 80 +++++++++++++++++++++++++++++++++------------ include/strings.h | 10 +++--- include/text.cpp | 17 +++++----- include/tree.cpp | 12 ++++--- 8 files changed, 105 insertions(+), 51 deletions(-) diff --git a/include/sheet.cpp b/include/sheet.cpp index 449e5cf69..b7e2633b5 100755 --- a/include/sheet.cpp +++ b/include/sheet.cpp @@ -121,8 +121,9 @@ TSheet_control::TSheet_control( int f_width = NUMBER_WIDTH; // Stima larghezza colonne fisse int max_width = f_width; // Stima larghezza della colonna piu' grande int lines_in_header = 1; + const char * h; - for (const char* h = header.get(); h; h = header.get(), i++) + for (h = header.get(); h; h = header.get(), i++) { CHECKD(i < MAX_COL, "Tu meni calumns in scit: ", i); _type[i] = ' '; @@ -435,7 +436,9 @@ XI_OBJ* TSheet_control::find_column( int num; XI_OBJ** columns = xi_get_member_list(_obj, &num); - for (int c = num-1; c >= 0; c--) + int c; + + for (c = num-1; c >= 0; c--) { if (columns[c]->cid == col) break; @@ -448,7 +451,9 @@ XI_OBJ* TSheet_control::find_column( { int num; XI_OBJ** column = xi_get_member_list(_obj, &num); - for (int c = num-1; c >= 0; c--) + int c; + + for (c = num-1; c >= 0; c--) { char str[80]; xi_get_text(column[c], str, sizeof(str)); @@ -623,7 +628,7 @@ void TSheet_control::load_columns_order(const TMask_field& field) TFilename parag; field2parag(field, parag); TConfig config(CONFIG_USER, parag); const int index = field.dlg(); - TToken_string order = config.get("Browse", NULL, index); + TToken_string order(config.get("Browse", NULL, index)); if (order.empty_items()) config.remove("Browse", index); else @@ -652,7 +657,7 @@ void TSheet_control::set_columns_order(TToken_string* order) xi_set_focus(itf); int num_cols; - XI_OBJ** column = xi_get_member_list(_obj, &num_cols); + xi_get_member_list(_obj, &num_cols); //verificare // Costante da sottrarre nella xi_column_set_pixel_width altrimenti la somma due volte! const int offset = 2 * (int)xi_get_pref(XI_PREF_COLUMN_OFFSET); @@ -985,7 +990,7 @@ TSheet::TSheet(short x, short y, short dx, short dy, const char* title, const char* head, byte buttons, short sht_y, WINDOW parent) : TMask(title, sht_y == 0 ? 1 : 2, dx, dy, x, y, parent), - _parked(-1), _sheet(NULL), _select_row(-1) + _sheet(NULL), _select_row(-1), _parked(-1) { TQuery_field* qf = new TQuery_field(this); qf->construct(25883, head, 1, sht_y, -3, win(), "", -1); @@ -1035,8 +1040,8 @@ void TSheet::repos_buttons() const return; // Sono ancora in fase di creazione: aspetta! RCT br; - int buttons = 0; - for (int f = fields()-1; f >= 0; f--) + int buttons = 0, f; + for (f = fields()-1; f >= 0; f--) { TMask_field& c = fld(f); if (c.is_kind_of(CLASS_BUTTON_FIELD)) @@ -1326,7 +1331,7 @@ TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields, byte buttons, short sht_y, WINDOW parent) : TSheet(sht_y ? 3 : 0, sht_y ? 3 : 0, sht_y ? -3 : 0, sht_y ? -3 : 0, title, head, buttons, sht_y, parent), - _cursor(cursor), _records(cursor->items()) + _records(cursor->items()), _cursor(cursor) { TToken_string fldlst(fields); int campo = 0; @@ -1586,9 +1591,10 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields, if (p.empty()) { - p = c.prompt(); + p = c.prompt(); + int a; // Toglie spazi e simboli iniziali dal prompt - for (int a = 0; p[a] && !isalnum(p[a]); a++); + for (a = 0; p[a] && !isalnum(p[a]); a++); p.ltrim(a); } p.left_just(16); diff --git a/include/spies.cpp b/include/spies.cpp index 8e6d49af2..08e3991a7 100755 --- a/include/spies.cpp +++ b/include/spies.cpp @@ -32,7 +32,8 @@ bool TSpy_target::add_spy(TSpy* spy) bool TSpy_target::kill_spy(const TSpy* spy) { - for (int i = _spies.last(); i >= 0; i--) + int i; + for (i = _spies.last(); i >= 0; i--) { TSpy* s = (TSpy*)_spies.objptr(i); if (s == spy) diff --git a/include/spies.h b/include/spies.h index bf2ee42d5..db3f995fa 100755 --- a/include/spies.h +++ b/include/spies.h @@ -51,4 +51,4 @@ public: virtual ~TSpy(); }; -#endif \ No newline at end of file +#endif diff --git a/include/stdtypes.h b/include/stdtypes.h index 25e906383..407f9398d 100755 --- a/include/stdtypes.h +++ b/include/stdtypes.h @@ -65,6 +65,10 @@ bool test_assistance_year(); void init_global_vars(); void free_global_vars(); +#ifdef LINUX +#define __int64 long long //verificare +#endif + #endif // __STDTYPES_H diff --git a/include/strings.cpp b/include/strings.cpp index a15c720d5..82f84637e 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -1,5 +1,16 @@ -#include +#include +#ifdef WIN32 +#include #include +#endif +#include +#include +#include +#ifndef INCSTR_H +#include +#endif +#include + #include #include @@ -7,6 +18,11 @@ #include #include +#ifdef LINUX + const char * _c_user = NULL; + bool _is_admin = FALSE; +#endif + // @doc EXTERNAL // @func Ritorna il nome dell'utente attuale @@ -15,6 +31,11 @@ TString& user() { static TString16 _user; +#ifdef LINUX + if (_c_user == NULL) + _c_user = (const char *) _user; + _is_admin = (_user == ::dongle().administrator()); +#endif return _user; } @@ -194,7 +215,11 @@ TString& TString::operator <<(double n) TString& TString::operator <<(const TObject& obj) { TString256 spark; +#ifdef WIN32 ostrstream out(spark.get_buffer(), spark.size()); +#else + ostringstream out(spark.get_buffer()); +#endif obj.print_on(out); out << ends; return operator <<(spark); @@ -576,9 +601,10 @@ TString& TString::rtrim( TString& TString::trim() { char* last = _str; + const char * s; // Salta spazi iniziali - for (const char* s = _str; *s && is_space(*s); s++); + for (s = _str; *s && is_space(*s); s++); // Copia stringa if (s > _str) @@ -610,13 +636,13 @@ int TString::compare( int max, // @parm Numero di caratteri da conforntare (default tutta la stringa) bool ignorecase) const // @parm Ignorare la differenza maiuscolo/minuscolo (default FALSE) { - int res; + int res = 0; if (s == NULL) s = ""; if (ignorecase) { if (max < 0) - res = stricmp(_str, s); + res = xvt_str_compare_ignoring_case(_str, s); else { for (int i = 0; i < max; i++) @@ -799,7 +825,7 @@ TString& TString::format( char spark[512]; va_list pars; va_start(pars, fmt); - const int tot = vsprintf(spark, fmt, pars); + const unsigned int tot = vsprintf(spark, fmt, pars); va_end(pars); CHECK(tot < sizeof(spark), "Ue'! Quanto scrivi?"); @@ -1010,7 +1036,8 @@ void TFilename::ext(const char* e) start = len()-1; bool can_cut = TRUE; - for (int i = start; i > 0 && _str[i] != '.'; i--) + int i; + for (i = start; i > 0 && _str[i] != '.'; i--) if (is_slash(_str[i]) || _str[i] == ':') { can_cut = FALSE; @@ -1035,7 +1062,8 @@ const char* TFilename::name() const int start = find(' ')-1; if (start < 0) start = len()-1; - for (int i = start; i >= 0; i--) + int i; + for (i = start; i >= 0; i--) if (is_slash(_str[i]) || _str[i] == ':') break; @@ -1051,7 +1079,8 @@ const char* TFilename::path() const int start = find(' ')-1; if (start < 0) start = len()-1; - for (int i = start; i >= 0; i--) + int i; + for (i = start; i >= 0; i--) if (is_slash(_str[i]) || _str[i] == ':') break; TString& spark = get_tmp_string(); @@ -1137,6 +1166,8 @@ const TFilename& TFilename::tempdir() _tempdir = getenv("TMP"); if (_tempdir.empty()) _tempdir << SLASH << "temp"; + if (!_tempdir.exist()) + _tempdir.format("%c%s", SLASH, "tmp"); const int last = len()-1; if (!is_not_slash(_str[last])) @@ -1168,7 +1199,7 @@ const TFilename& TFilename::tempdir() TString tmp = _tempdir; tmp.insert("TMP=", 0); - putenv(tmp); + putenv((char *)(const char *) tmp); } set(_tempdir); @@ -1176,10 +1207,13 @@ const TFilename& TFilename::tempdir() } const TFilename& TFilename::currdir() -{ - DIRECTORY dir; - xvt_fsys_get_dir(&dir); - xvt_fsys_convert_dir_to_str(&dir, get_buffer(), size()); +{ + DIRECTORY d; + + xvt_fsys_get_dir(&d); // verificare + xvt_fsys_convert_dir_to_str(&d, get_buffer(), size()); + + return *this; } // Certified 50% @@ -1276,9 +1310,9 @@ bool TFilename::exist() const bool TFilename::search_in_path(TFilename& path) const { - _searchenv(_str, "PATH", path.get_buffer()); + xvt_sys_searchenv(_str, "PATH", path.get_buffer()); if (path.empty()) - _searchenv(_str, "path", path.get_buffer()); + xvt_sys_searchenv(_str, "path", path.get_buffer()); return path.not_empty(); } @@ -1431,7 +1465,9 @@ const char* TToken_string::get( else return get(); } int sep = 0; - for (const char* s = _str; sep < n && *s; s++) + const char * s; + + for (s = _str; sep < n && *s; s++) if (*s == _separator) sep++; if (sep >= n) @@ -1511,7 +1547,8 @@ bool TToken_string::get( } int sep = 0; - for (const char* s = _str; *s && sep < n; s++) + const char* s; + for (s = _str; *s && sep < n; s++) if (*s == _separator) sep++; bool found = sep == n; @@ -1585,8 +1622,8 @@ bool TToken_string::set_item(const char* v, int n) CHECK(_separator, "Corrupted TToken_string: NULL separator"); TString& spark = get_tmp_string(); - int sep = 0; - for (int i = 0; sep < n && _str[i]; i++) + int sep = 0, i; + for (i = 0; sep < n && _str[i]; i++) if (_str[i] == _separator) sep++; if (sep < n) // Aggiunge items mancanti prima della posizione n @@ -1717,7 +1754,8 @@ void TToken_string::destroy(int n) else { int sep = 0; - for (char* s = _str; sep < n && *s; s++) + char * s; + for (s = _str; sep < n && *s; s++) if (*s == _separator) sep++; if (sep >= n) @@ -1742,7 +1780,7 @@ TAuto_token_string& TAuto_token_string::create(const char* ts) // Calcola il separatore for (const char* s = ts; s && *s; s++) { - if (strchr("|¦\t\n^;,!&+", *s) != NULL) + if (strchr("|?\t\n^;,!&+", *s) != NULL) { separator(*s); break; diff --git a/include/strings.h b/include/strings.h index 5acaa8ffc..d68e692b4 100755 --- a/include/strings.h +++ b/include/strings.h @@ -728,14 +728,16 @@ const TToken_string& empty_string(); #define FOR_EACH_ARRAY_ROW(__arr, __r, __riga) \ TToken_string* __riga; \ - for (int __r = (__arr).first(); \ - __riga = (TToken_string*)(__arr).objptr(__r); \ + int __r; \ + for (__r = (__arr).first(); \ + (__riga = (TToken_string*)(__arr).objptr(__r)); \ __r = (__arr).succ(__r)) #define FOR_EACH_ARRAY_ROW_BACK(__arr, __r, __riga) \ TToken_string* __riga; \ - for (int __r = (__arr).last(); \ - __riga = (TToken_string*)(__arr).objptr(__r); \ + int __r; \ + for (__r = (__arr).last(); \ + (__riga = (TToken_string*)(__arr).objptr(__r)); \ __r = (__arr).pred(__r)) const char SLASH = diff --git a/include/text.cpp b/include/text.cpp index 8957f98e8..a2f3ebbde 100755 --- a/include/text.cpp +++ b/include/text.cpp @@ -179,7 +179,7 @@ void TTextfile::_read_page (long n) int len = 0; const char *cp; read_line (i, 0, FALSE); - while (cp = piece ()) + while ((cp = piece ())) { for (int z = 0; z < _hotspots.items (); z++) { @@ -234,7 +234,7 @@ void TTextfile::read_line ( int col = ((int) 'w' << 8) | (int) 'n'; long stl = (long) col << 16; - while (ch = *sp++) + while ((ch = *sp++)) { if (ch == '<' && *(sp) == '@') { @@ -344,7 +344,7 @@ void TTextfile::read_line ( txt.left_just(len); } // ficca il testo cola' dove si puote - const txtlen = txt.len(); + const int txtlen = txt.len(); for (int k = 0; k < txtlen; k++) TEXT_TMP[ndx++] = txt[k]; } // see (!terminated) above @@ -723,7 +723,7 @@ bool TTextfile::append ( int len = 0; const char *cp; read_line (_lines - 1); - while (cp = piece ()) + while ((cp = piece ())) { for (int z = 0; z < _hotspots.items (); z++) { @@ -872,11 +872,10 @@ void TTextfile::destroy () TTextfile ::TTextfile (const char *file, int pagesize, direction preferred, bool interactive): - _page_size (pagesize), _page (pagesize), _filename (file), _lines (0l), - _index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred), - _dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1), - _hotspots (4), _accept (TRUE), _dirty_lines(pagesize), - _interactive(interactive), _rel(NULL) + _page (pagesize), _dirty_lines(pagesize), _page_start (0l), _page_end (-1l), _page_size (pagesize), + _lines (0l), _cur_line (-1), _filename (file), _index (NULL), + _direction (preferred), _item (0), _line (256), _hotspots (4), _dirty (FALSE), + _istemp (FALSE), _accept (TRUE), _interactive(interactive), _rel(NULL) { // open file & build index diff --git a/include/tree.cpp b/include/tree.cpp index 0dc6f1e9e..7ce3cd061 100755 --- a/include/tree.cpp +++ b/include/tree.cpp @@ -777,7 +777,8 @@ void TNode_info_array::reset() int TNode_info_array::last() const { - for (int i = _data.last(); i >= 0; i = _data.pred(i)) + int i; + for (i = _data.last(); i >= 0; i = _data.pred(i)) if (_data[i].ok()) break; return i; @@ -785,7 +786,8 @@ int TNode_info_array::last() const int TNode_info_array::find(const TNode_info& ni) const { - for (int i = last(); i >= 0; i = _data.pred(i)) + int i; + for (i = last(); i >= 0; i = _data.pred(i)) { if (((TNode_info*)_data.objptr(i))->compare(ni) == 0) break; @@ -929,7 +931,9 @@ bool TTree_window::callback_draw_node(TTree& node, void* jolly, word when) } const int ry = int(ui->_y - ui->_firsty); - for (int by = ry-1; by >= 0; by--) + int by; + + for (by = ry-1; by >= 0; by--) { long rx = (*ui->_node_info)[by]._startx; if (rx < ui->_x) @@ -1425,4 +1429,4 @@ void TTree_field::set_row_height(int rh) TField_window* TTree_field::create_window(int x, int y, int dx, int dy, WINDOW parent) { return new TTree_window(x, y, dx, dy, parent, this); -} \ No newline at end of file +}