From 6ced2b00058c7416667ad08b48b91eb6d7e8e527 Mon Sep 17 00:00:00 2001 From: angelo Date: Thu, 16 Oct 1997 13:56:15 +0000 Subject: [PATCH] Correzione MI3623, relativo alla stampa di righe che terminano proprio con il carattere <. git-svn-id: svn://10.65.10.50/trunk@5385 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/text.cpp | 181 +++++++++++++++++++++++++---------------------- 1 file changed, 95 insertions(+), 86 deletions(-) diff --git a/include/text.cpp b/include/text.cpp index 94c34d535..7c6083ebb 100755 --- a/include/text.cpp +++ b/include/text.cpp @@ -234,6 +234,8 @@ void TTextfile::read_line ( { // merge field if rel != NULL; // else fill with whitespace + const char * save_sp = sp; + TToken_string id(80, '@'); sp++; bool terminated = FALSE; @@ -241,102 +243,109 @@ void TTextfile::read_line ( if (ch != '\0') id << ch; else terminated = TRUE; - if (terminated) break; // Esce dal ciclo se non trova la matching > - // id contains tokenstring separated by @ - // but with casinations for possible lack of spacing - // add spaces if needed - for (int i = 0; i < id.len(); i++) - { - if (id[i] == '@' && id [i+1] == '@') - { - id.insert(" ", i+1); - i+= 2; - } - } - // parse string - int len; - TString80 file; - TString16 field; - TString80 format; - char just; - - file = id.get(); - format = id.get(); - len = (int)id.get_long(); - just = id.get_char(); - - int pos = 0; - if ((pos = file.find("->")) == -1) - error_box("field specification error"); - else + if (!terminated) // Prosegue normalmente se non trova la matching > { - file.cut(pos); - field = file.mid(pos+2); - } - - if (len == 0) len = id.len(); - - TString txt(512); - TFieldtypes type; - - if (_rel != NULL) - { - // retrieve file and field - if (atoi(file) == 0) - { - // tabella - TLocalisamfile& t = _rel->lfile(file); - txt = t.get(field); - type = t.curr().type(field); - } + // id contains tokenstring separated by @ + // but with casinations for possible lack of spacing + // add spaces if needed + for (int i = 0; i < id.len(); i++) + { + if (id[i] == '@' && id [i+1] == '@') + { + id.insert(" ", i+1); + i+= 2; + } + } + // parse string + int len; + TString80 file; + TString16 field; + TString80 format; + char just; + + file = id.get(); + format = id.get(); + len = (int)id.get_long(); + just = id.get_char(); + + int pos = 0; + if ((pos = file.find("->")) == -1) + error_box("field specification error"); else - { - TLocalisamfile& f = _rel->lfile(atoi(file)); - txt = f.get(field); - type = f.curr().type(field); - } - // apply format to date and number - switch (type) { - case _longfld: - case _realfld: - { - real r(txt); - txt = r.string(format); + file.cut(pos); + field = file.mid(pos+2); } - break; - case _datefld: - { - TDate dd(txt); - TFormatted_date d(dd, format); - txt = d.string(); - } - break; - default: - break; - } - // justify as requested - if (txt.len() < len) - { - switch(type) + + if (len == 0) len = id.len(); + + TString txt(512); + TFieldtypes type; + + if (_rel != NULL) + { + // retrieve file and field + if (atoi(file) == 0) + { + // tabella + TLocalisamfile& t = _rel->lfile(file); + txt = t.get(field); + type = t.curr().type(field); + } + else + { + TLocalisamfile& f = _rel->lfile(atoi(file)); + txt = f.get(field); + type = f.curr().type(field); + } + // apply format to date and number + switch (type) { case _longfld: - case _realfld: - txt.right_just(len); - break; - default: - txt.left_just(len); - break; + case _realfld: + { + real r(txt); + txt = r.string(format); + } + break; + case _datefld: + { + TDate dd(txt); + TFormatted_date d(dd, format); + txt = d.string(); + } + break; + default: + break; + } + // justify as requested + if (txt.len() < len) + { + switch(type) + { + case _longfld: + case _realfld: + txt.right_just(len); + break; + default: + txt.left_just(len); + break; + } } } - } - else + else + { + txt.left_just(len); + } + // ficca il testo cola' dove si puote + for (int k = 0; k < txt.len(); k++) + TEXT_TMP[ndx++] = txt[k]; + } // see (!terminated) above + else // Restore sp pointer { - txt.left_just(len); + sp = save_sp; + ch = '<'; } - // ficca il testo cola' dove si puote - for (int k = 0; k < txt.len(); k++) - TEXT_TMP[ndx++] = txt[k]; } if (ch == '@' || (ch == '$' && *(sp) == '['))