bugfixing

This commit is contained in:
Alexander S. Aganichev
2001-05-09 20:45:13 +00:00
parent 61f978c8cd
commit 2e70dec322
17 changed files with 169 additions and 199 deletions

View File

@@ -207,16 +207,12 @@ void AreaList::AddNewArea(AreaCfg* aa) {
#endif
#ifndef GMB_NOXBBS
case MT_ADEPTXBBS:
#if !defined(__OS2__)
return;
#else
if(*aa->path == NUL)
return;
MapPath(aa->path);
StripBackslash(aa->path);
strschg_environ(aa->path);
break;
#endif
#endif
#ifndef GMB_NOSQSH
case MT_SQUISH:

View File

@@ -37,6 +37,7 @@
const uint MAX_COMM = 25; // Editor comments
const uint MAX_FIND = 10; // Max number of search strings
const uint MAXQUOTELEN = 40; // Max length of quote
// ------------------------------------------------------------------

View File

@@ -611,7 +611,8 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
_test_halt(*__currline == NULL);
uint _quotelen;
char _quotebuf[100];
char _quotebuf[MAXQUOTELEN];
*_quotebuf = NUL;
uint _curscol = *__curr_col;
uint _cursrow = *__curr_row;
@@ -692,7 +693,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
}
// Did we search all the way back to the beginning of the line?
if(_wrappos == 0 or _wrappos == _quotelen or _thisline->txt[_spacepos] == ' ') {
if((_wrappos == 0) or (_wrappos == _quotelen) or (_thisline->txt[_spacepos] == ' ')) {
// Case 3: There are no spaces within the margin or we hit leading spaces
@@ -703,31 +704,24 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
// The wrapptr now points to the location to be wrapped or NUL
// Get length of the wrapped part
uint _wraplen = _thisline->txt.length() - _wrappos;
// Is the line hard-terminated?
if(_thisline->txt.find('\n', _wrappos) != _thisline->txt.npos) {
// The line is hard-terminated.
//
// The wrapped part must be placed on a new line below.
Line* _wrapline = _lastadded = insertlinebelow(_thisline, NULL, BATCH_MODE);
// Copy the quote string, if any, to the new line first
if(_quotelen)
_wrapline->txt = _quotebuf;
else
_wrapline->txt = "";
string _wrapbuf = _quotebuf;
// Copy/append the wrapped part to the new line
_wrapline->txt += _thisline->txt.substr(_wrappos);
_wrapbuf += _thisline->txt.substr(_wrappos);
// The wrapped part must be placed on a new line below.
Line* _wrapline = _lastadded = insertlinebelow(_thisline, _wrapbuf.c_str(), BATCH_MODE);
// Saves pointer to a line where from the wrapped part was copied, its begining
// and length. While in Undo, appends the copied part to previous line and deletes
// it on current, moving the rest over deleted.
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _thisline, _quotelen, _wraplen);
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _thisline, _quotelen, _wrapbuf.length() - _quotelen);
_wrapline->type = _thisline->type;
// Make sure the type of the line is correct
@@ -759,6 +753,12 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
// Pointer to the next line
Line* _nextline = _thisline->next;
// Copy the quote string, if any, to the new line first
string _wrapbuf = _quotebuf;
// Copy/append the wrapped part to the new line
_wrapbuf += _thisline->txt.substr(_wrappos);
// Flag to indicate if a new line was added below
bool _line_added_below = false;
@@ -766,21 +766,19 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
if((_nextline == NULL) or (_nextline->type & GLINE_QUOT)) {
// The wrapped part must be placed on a new line below
_lastadded = _nextline = insertlinebelow(_thisline, "", BATCH_MODE);
_lastadded = _nextline = insertlinebelow(_thisline, _wrapbuf.c_str(), BATCH_MODE);
_line_added_below = true;
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _thisline, _quotelen, _wrapbuf.length() - _quotelen);
}
else {
// Was this line quoted?
if(_quotelen) {
// Copy the quote string
_nextline->txt.insert(0, _quotebuf, _quotelen);
_nextline->txt.insert(0, _wrapbuf);
if(_quotelen)
Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, _nextline, 0, _quotelen);
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _thisline, _quotelen, _wrapbuf.length() - _quotelen);
}
_nextline->txt.insert(_quotelen, _thisline->txt.substr(_wrappos));
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _thisline, 0, _quotelen+_wraplen);
// Make sure the type of the line is correct
setlinetype(_nextline);
@@ -859,6 +857,10 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
if(_thisline->next->txt.length() <= _wrapmargin)
break;
}
else if(_thisline->type & GLINE_QUOT) {
Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, _thisline, _thisline->txt.length(), 1);
_thisline->txt += '\n';
}
// Go to the next line
_thisline = _thisline->next;
@@ -1023,8 +1025,8 @@ void IEclass::DelChar() {
if((_nextline->type & GLINE_QUOT) and col) {
// Get quote string length
char _dummybuf[100];
GetQuotestr(_nextline->txt.c_str(), _dummybuf, &_quotelen);
char _quotebuf[MAXQUOTELEN];
GetQuotestr(_nextline->txt.c_str(), _quotebuf, &_quotelen);
}
// Copy the next line's text to this line without quote string
@@ -1180,27 +1182,28 @@ void IEclass::Newline() {
// Pointer to the split position
int _splitpos = col;
char _quotebuf[MAXQUOTELEN];
*_quotebuf = NUL;
// Buffer for the second part of the split line
char* _splitbuf = (char*)throw_malloc(EDIT_BUFLEN);
*_splitbuf = NUL;
string _splitbuf;
// If the split line was quoted, get the quotestring
// But do not get it if the cursor points to a linefeed or is
uint _quotelen = 0;
if(is_quote(currline->txt.c_str())) {
GetQuotestr(currline->txt.c_str(), _splitbuf, &_quotelen);
THROW_CHECKPTR(_splitbuf);
}
uint _quotelen;
GetQuotestr(currline->txt.c_str(), _quotebuf, &_quotelen);
// Eliminate the quotestring if
// - the cursor points to a linefeed or
// - the cursor is located inside the quotestring
if(_quotelen and ((currline->txt.length() == col) or (currline->txt[_splitpos] == '\n') or (col < _quotelen)))
*_splitbuf = _quotelen = 0;
if(_quotelen and ((currline->txt.length() == col) or (currline->txt[_splitpos] == '\n') or (col < _quotelen))) {
*_quotebuf = NUL;
_quotelen = 0;
}
// Append the second part to the split buffer
strcat(_splitbuf, currline->txt.substr(_splitpos).c_str());
THROW_CHECKPTR(_splitbuf);
_splitbuf = _quotebuf;
_splitbuf += currline->txt.substr(_splitpos);
Undo->PushItem(EDIT_UNDO_INS_TEXT|batch_mode, currline, col, 1);
batch_mode = BATCH_MODE;
@@ -1214,17 +1217,16 @@ void IEclass::Newline() {
displine(currline, row);
// Insert a new line below, set the line text to the split-off part
currline = insertlinebelow(currline, _splitbuf);
currline = insertlinebelow(currline, _splitbuf.c_str());
// --v--
// This line would be wrapped
// This line would be
// wrapped
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, currline->prev, _quotelen, strlen(_splitbuf) - _quotelen);
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, currline->prev, _quotelen, _splitbuf.length() - _quotelen);
setlinetype(currline);
throw_free(_splitbuf);
// Move down the cursor
col = 0;
@@ -1768,9 +1770,9 @@ int IEclass::reflowok(char* __qstr) {
// Stop reflow if the quotestring on the next line is not the same
uint _qlen2;
char _qstr2[100];
char _qstr2[MAXQUOTELEN];
GetQuotestr(currline->next->txt.c_str(), _qstr2, &_qlen2);
if(not strieql(__qstr, _qstr2))
if(not cmp_quotes(__qstr, _qstr2))
return false;
return true;
@@ -1795,7 +1797,7 @@ void IEclass::Reflow() {
// Get the first quotestring
uint _qlen1;
char _qstr1[100];
char _qstr1[MAXQUOTELEN];
GetQuotestr(currline->txt.c_str(), _qstr1, &_qlen1);
const char* _qlenptr = currline->txt.c_str() + _qlen1;
@@ -2431,7 +2433,7 @@ void UndoStack::PushItem(uint action, Line* __line, uint __col, uint __len) {
case EDIT_UNDO_WRAP_TEXT:
last_item->line = __line;
if(__len == NO_VALUE)
__len = __line->txt.length() - __col + 1;
__len = __line->txt.length() - __col;
throw_new(last_item->data.text_ptr = new text_item(__col, __len));
break;
case EDIT_UNDO_NEW_LINE:
@@ -2571,7 +2573,7 @@ void UndoStack::PlayItem() {
throw_delete(text_data);
break;
}
editor->setlinetype(currline);
editor->setlinetype((undo_action == EDIT_UNDO_WRAP_TEXT) ? currline->next : currline);
break;
}

View File

@@ -1576,37 +1576,39 @@ void ScanKludges(GMsg* msg, int getvalue) {
} while((line = line->prev) != NULL);
for(line = msg->lin; line; line = line->next)
if(line->type & GLINE_KLUDGE)
continue;
else {
if(strnieql(line->txt.c_str(), "From:", 5)) {
const char* ptr = line->txt.c_str() + 5;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeFROM(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
if(getvalue) {
for(line = msg->lin; line; line = line->next)
if(line->type & GLINE_KLUDGE)
continue;
else {
if(strnieql(line->txt.c_str(), "From:", 5)) {
const char* ptr = line->txt.c_str() + 5;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeFROM(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
}
else if(strnieql(line->txt.c_str(), "To:", 3)) {
const char* ptr = line->txt.c_str() + 3;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeTO(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
}
else if(strnieql(line->txt.c_str(), "Reply-To:", 9)) {
const char* ptr = line->txt.c_str() + 9;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeREPLY_TO(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
}
else
break;
}
else if(strnieql(line->txt.c_str(), "To:", 3)) {
const char* ptr = line->txt.c_str() + 3;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeTO(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
}
else if(strnieql(line->txt.c_str(), "Reply-To:", 9)) {
const char* ptr = line->txt.c_str() + 9;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeREPLY_TO(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
}
else
break;
}
}
if(not gottag)
*msg->tagline = NUL;
@@ -1784,7 +1786,7 @@ char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded
// ------------------------------------------------------------------
static int cmp_quotes(char* q1, char* q2) {
int cmp_quotes(char* q1, char* q2) {
q1--;
q2--;
@@ -1866,7 +1868,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
char* tptr;
char* escp;
char* bptr;
char buf[256], qbuf[500], qbuf2[500], chsbuf[100];
char buf[256], qbuf[MAXQUOTELEN], qbuf2[MAXQUOTELEN], chsbuf[100];
char* ptr;
char* qptr;
char* tmp=NULL;
@@ -1954,7 +1956,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
if(line->prev) {
line->prev->next = line;
if((line->prev->type & (GLINE_HARD|GLINE_WRAP|GLINE_QUOT)) == (GLINE_HARD|GLINE_WRAP)) {
line->prev->type ^= GLINE_HARD;
line->prev->type &= ~GLINE_HARD;
line->type |= GLINE_HARD;
}
}
@@ -2620,8 +2622,8 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
msg->lines = 0;
line = msg->lin;
char qbuf[50];
char qbuf0[50];
char qbuf[MAXQUOTELEN];
char qbuf0[MAXQUOTELEN];
uint qlen = 0;
int qmatches = 0;
@@ -2646,8 +2648,7 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
else if(line->type & GLINE_QUOT) {
if(not viewquote) {
GetQuotestr(line->txt.c_str(), qbuf, &qlen);
strtrim(qbuf);
if(not strieql(qbuf0, qbuf)) {
if(not cmp_quotes(qbuf0, qbuf)) {
strcpy(qbuf0, qbuf);
qmatches = 0;
}

View File

@@ -686,8 +686,20 @@ void GThreadlist::do_delayed() {
wactiv_(mlstwh);
}
if(CFG->switches.get(msglistviewsubj))
if(CFG->switches.get(msglistviewsubj)) {
// Reload message if not sure that just reread
if(not AA->Msglistheader()) {
t = list[index];
if(AA->Msglistfast()) {
AA->LoadHdr(&msg, t.msgno);
}
else {
AA->LoadMsg(&msg, t.msgno, CFG->dispmargin-(int)CFG->switches.get(disppagebar));
}
}
wtitle(msg.re, TCENTER|TBOTTOM, tattr);
}
if(CFG->switches.get(msglistpagebar))
wscrollbar(W_VERT, maximum_index+1, maximum_index, index);
@@ -772,7 +784,12 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) {
tdlen = xlen - ((AA->Msglistdate() == MSGLISTDATE_NONE) ? 8 : 18);
AA->LoadHdr(&msg, t.msgno);
if(AA->Msglistfast()) {
AA->LoadHdr(&msg, t.msgno);
}
else {
AA->LoadMsg(&msg, t.msgno, CFG->dispmargin-(int)CFG->switches.get(disppagebar));
}
if(msg.attr.uns() and not msg.attr.rcv() and not msg.attr.del()) {
attrw = C_MENUW_UNSENT;

View File

@@ -380,6 +380,7 @@ int edit_string(char* buf, int buf_size, char* title, int helpcat);
bool edit_pathname(char* buf, int buf_size, char* title, int helpcat);
int GetAkaNo(const ftn_addr& __aka);
int GetQuotestr(const char* ptr, char* qbuf, uint* qlen);
int cmp_quotes(char* q1, char* q2);
int is_quote(const char* ptr);
int IsQuoteChar(const char* s);
void maketitle();

View File

@@ -365,7 +365,7 @@ int is_quote(const char* ptr) {
int quotecolor(const char* line) {
char buf[100];
char buf[MAXQUOTELEN];
uint len;
GetQuotestr(line, buf, &len);
@@ -385,52 +385,51 @@ int GetQuotestr(const char* ptr, char* qbuf, uint* qlen) {
if(is_quote(ptr)) {
char* qptr;
const char* tmp;
const char* lp = ptr;
int n, x;
MoreQuotes: // Naughty goto-point for quotestring skipping
for(;;) {
// Skip leading spaces
while(isspace(*lp) or issoftcr(*lp))
lp++;
if(IsQuoteChar(lp)) { // Type 1 : ">xxxx>" and ">xxxx:"
lp++;
// Skip leading spaces
while(isspace(*lp) or issoftcr(*lp))
lp++;
if(is_quote(lp))
goto MoreQuotes;
if(not (IsQuoteChar(lp-1) or (*(lp-1) == ':'))) {
while(not IsQuoteChar(lp))
lp--;
if(IsQuoteChar(lp)) { // Type 1 : ">xxxx>" and ">xxxx:"
lp++;
while(isspace(*lp) or issoftcr(*lp))
lp++;
if(is_quote(lp))
continue;
if(not (IsQuoteChar(lp-1) or (*(lp-1) == ':'))) {
while(not IsQuoteChar(lp))
lp--;
lp++;
}
}
}
else { // Type 2: "xxxx>"
while(not (IsQuoteChar(lp) and not IsQuoteChar(lp+1)) and *lp != CR and *lp)
++lp;
if(is_quote(lp))
goto MoreQuotes;
if(*lp)
lp++;
else { // Type 2: "xxxx>"
while(not (IsQuoteChar(lp) and not IsQuoteChar(lp+1)) and (*lp != CR) and (*lp != NUL))
++lp;
if(is_quote(lp))
continue;
if(*lp)
lp++;
}
break;
}
// lp now points to the character after the quotestring
*qlen = (int)((dword)lp - (dword)ptr);
if(isspace(*lp) or issoftcr(*lp))
(*qlen)++;
x = lp - ptr;
if((*lp != NUL) and (isspace(*lp) or issoftcr(*lp)))
x++;
for(x=*qlen,n=0,tmp=ptr,qptr=qbuf; n<x and n<40; n++,tmp++) {
if(*tmp != LF and not issoftcr(*tmp))
*qptr++ = *tmp;
else
(*qlen)--;
for(*qlen = n = 0; (n < x) and ((*qlen) < MAXQUOTELEN); n++, ptr++) {
if((*ptr != LF) and not issoftcr(*ptr)) {
*qbuf++ = *ptr;
(*qlen)++;
}
}
*qptr = NUL;
if(*qlen > 40)
*qlen = 40;
*qbuf = NUL;
}
else {
*qbuf = NUL;