From 182b649bded80fa42bf0b057c9b04a4328c47924 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 12 Jun 1995 16:05:26 +0000 Subject: [PATCH] Correezioni per compilazione git-svn-id: svn://10.65.10.50/trunk@1470 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/memo.cpp | 48 ++++++++++++++++++++++++------------------------ include/memo.h | 6 +++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/memo.cpp b/include/memo.cpp index 2c33766ee..50c61fefb 100755 --- a/include/memo.cpp +++ b/include/memo.cpp @@ -9,7 +9,7 @@ #define BLOCK_SIZE 1024 TMemo_file::TMemo_file(const char* a) : - _fname(a), _fp(NULL), _isnew(NULL) +_fname(a), _fp(NULL), _isnew(NULL) { // handles: open file or create _fname.ext("mem"); @@ -38,12 +38,12 @@ TMemo_file::~TMemo_file() { if (_fp) fclose(_fp); } - + bool TMemo_file::_find_id(long id) { if (id > _id_max && id < 0) error_box("File memo inconsistente"); - + bool dndir = FALSE /* id > (_id_max/2l) */ ; _current = -1l; @@ -52,7 +52,7 @@ bool TMemo_file::_find_id(long id) fseek(_fp, pos, dndir ? SEEK_END : SEEK_SET); int ok = 0; - + while (_current < id) { // se si va all'indietro, questa non funzia: nonostante @@ -64,8 +64,8 @@ bool TMemo_file::_find_id(long id) if (_current < id) { long ofs = dndir ? -_next_ofs-INFO_SIZE-INFO_SIZE : - _next_ofs+INFO_SIZE; - + _next_ofs+INFO_SIZE; + ok = fseek(_fp, ofs, SEEK_CUR); } if (ok) break; @@ -74,22 +74,22 @@ bool TMemo_file::_find_id(long id) _current = ok ? -1l : id; return _current == id; } - + bool TMemo_file::get_field(TTextfile& t, long id) { bool ok = _find_id(id); if (ok) { _current = id; - + // te lo faccio io, poi so' cazzi tua se sbagli t.destroy(); - + TString256 line; // block read until done; transfer block to txt // block by block - + long size = _next_ofs < BLOCK_SIZE ? _next_ofs : BLOCK_SIZE; int lcnt = 0; @@ -118,7 +118,7 @@ bool TMemo_file::get_field(TTextfile& t, long id) return ok; } -long TMemo_file::set_field(TTextfile& t, long id) +long TMemo_file::set_field(const TTextfile& t, long id) { bool ok = TRUE; long ret = 0; @@ -127,7 +127,7 @@ long TMemo_file::set_field(TTextfile& t, long id) bool at_end = id == -1 || (id != -1 && id > _id_max); // the casinating insertion in the middol bool in_mid = FALSE; - + if (!at_end) { ok = _find_id(id); @@ -137,17 +137,17 @@ long TMemo_file::set_field(TTextfile& t, long id) // vediamo dove long pos = HEADER_SIZE; fseek(_fp, pos, SEEK_SET); - + int ok = 0; - + while (_current < id) { fread(&_current, sizeof(long), 1, _fp); fread(&_next_ofs, sizeof(long), 1, _fp); if (_current < id) { - long ofs = _next_ofs+INFO_SIZE; - ok = fseek(_fp, ofs, SEEK_CUR); + long ofs = _next_ofs+INFO_SIZE; + ok = fseek(_fp, ofs, SEEK_CUR); } else { @@ -179,7 +179,7 @@ long TMemo_file::set_field(TTextfile& t, long id) { line = t.line(i); char c; - + for (int k = 0; c = line[k]; k++) { fwrite(&c, sizeof(char), 1, _fp); @@ -212,10 +212,10 @@ long TMemo_file::set_field(TTextfile& t, long id) FILE* tfp = fopen(tmp, "wb+"); fseek(_fp, 0, SEEK_SET); - + long size = BLOCK_SIZE; bool stop = FALSE; - + // copy file into temp up to TO pos // use 1k blocks for speed for (int i = 0; !stop; i++) @@ -240,7 +240,7 @@ long TMemo_file::set_field(TTextfile& t, long id) { line = t.line(i); char c; - + for (int k = 0; c = line[k]; k++) { fwrite(&c, sizeof(char), 1, tfp); @@ -283,7 +283,7 @@ long TMemo_file::set_field(TTextfile& t, long id) return ret; } - + bool TMemo_file::remove_field(long id) { bool ok = _find_id(id); @@ -296,10 +296,10 @@ bool TMemo_file::remove_field(long id) FILE* tfp = fopen(tmp, "wb+"); fseek(_fp, 0, SEEK_SET); - + long size = BLOCK_SIZE; bool stop = FALSE; - + // copy file into temp up to TO pos // use 1k blocks for speed for (int i = 0; !stop; i++) @@ -331,7 +331,7 @@ bool TMemo_file::remove_field(long id) } return ok; } - + bool TMemo_file::edit_field(long id) { return TRUE; diff --git a/include/memo.h b/include/memo.h index 774279e04..6e371ee82 100755 --- a/include/memo.h +++ b/include/memo.h @@ -20,7 +20,7 @@ class TMemo_file : public TObject long _next_ofs; bool _find_id(long id); - + public: // retrieves text with specified ID (or last one passed); @@ -33,10 +33,10 @@ public: bool remove_field(long id); // calls editor to edit text (specified as mem into config) bool edit_field(long id = -1l); - + // returns the maximum ID used (<= n. of fields in file) long max_id() const { return _id_max; } - + // must be passed the basename of archive TMemo_file(const char* archive); ~TMemo_file();