Xmas fixes

This commit is contained in:
Alexander S. Aganichev
2000-12-24 19:47:06 +00:00
parent 4156d37847
commit 748f2ea804
13 changed files with 81 additions and 28 deletions

View File

@@ -767,6 +767,7 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
if(not _gotcond) {
switch(crc) {
case CRC_INCLUDE:
strschg_environ(val);
if(not quiet)
cout << "* Including " << val << endl;
ReadCfg(val); // NOTE! This is a recursive call!
@@ -774,6 +775,7 @@ int ReadCfg(const char* cfgfile, int ignoreunknown) {
cout << "* Resuming " << cfg << endl;
break;
case CRC_AREAFILE:
strschg_environ(val);
if(not quiet)
cout << "* Handling " << key << " " << val << endl;
AL.GetAreafile(val);

View File

@@ -449,7 +449,7 @@ void GPickArealist::AreaCatchUp(uint n) {
// Do not do catch up if there's active area
if(AA->isopen())
return false;
return;
GMenuAreaCatchup MenuAreaCatchup;
GMsg* msg = (GMsg*)throw_calloc(1, sizeof(GMsg));
@@ -735,10 +735,10 @@ bool GPickArealist::handle_key() {
default:
if(key < KK_Macro) {
n = toupper(key & 0xFF);
if((area_fuzidx < area_maxfuz) or key == Key_BS) {
if((area_fuzidx < area_maxfuz) or (key == Key_BS)) {
// Incremental search in the echoids
if(not (n < ' ') or key == Key_BS) {
if(not iscntrl(n) or (key == Key_BS)) {
if(n == ' ')
n = '_';
if(key != Key_BS)

View File

@@ -159,7 +159,7 @@ char* mime_header_encode(char* dest, const char* source, GMsg* msg) {
lp--;
for(const char* ptr = s; *ptr and (ptr<=lp); ptr++) {
if((*ptr < ' ') or (*ptr > '\x7F') or (inmime and strchr(" =?", *ptr))) {
if(iscntrl(*ptr) or not isascii(*ptr) or (inmime and strchr(" =?", *ptr))) {
if(not inmime) {
if(msg->charset) {
bp = stpcpy(bp, "=?");

View File

@@ -78,7 +78,7 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, bool clip) {
while(p != line->txt.end()) {
if(mode == MODE_WRITE) {
// Replace control codes, except the ANSI escape code
if(*p < ' ') {
if(iscntrl(*p)) {
// only allow ESC in file write
if(prn or (*p != '\x1B')) {
*p = (*p == CTRL_A) ? '@' : '.';

View File

@@ -800,6 +800,9 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
}
}
// Was this line truncated at space?
bool truncated_at_space = isspace(_thisline->txt[_wrappos]);
// Truncate at the wrapping location
_thisline->txt.erase(_wrappos);
@@ -808,17 +811,15 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
// Trim spaces off the end of the line
int _trimpos = _wrappos - 1;
if(_thisline->txt[_trimpos] == ' ') {
while(_trimpos > 0 and _thisline->txt[_trimpos-1] == ' ')
if(isspace(_thisline->txt[_trimpos])) {
while(_trimpos > 0 and isspace(_thisline->txt[_trimpos-1]))
_trimpos--;
if(_quotelen and _trimpos < _quotelen)
if(_quotelen and (_trimpos < _quotelen))
_trimpos++;
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimpos);
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimpos+1);
_thisline->txt.erase(_trimpos);
}
else
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _wrappos);
Undo->PushItem((truncated_at_space?EDIT_UNDO_OVR_CHAR:EDIT_UNDO_INS_CHAR)|BATCH_MODE, _thisline, _trimpos+1);
// Append a new linefeed
_thisline->txt += "\n";
@@ -1990,7 +1991,7 @@ void IEclass::statusline() {
int IEclass::handlekey(gkey __key) {
int rc = YES;
int rc = true;
switch(__key) {
case KK_EditBlockRight: __key = KK_EditGoRight; break;
@@ -2019,6 +2020,10 @@ int IEclass::handlekey(gkey __key) {
break;
default:
rc = PlayMacro(__key, KT_E);
if(rc == true)
return rc;
rc = true;
if(selecting) {
Line *_line;
selecting = NO;
@@ -2113,7 +2118,8 @@ noselecting:
case KK_EditPaste: BlockPaste(); break;
default:
rc = PlayMacro(__key, KT_E);
rc = false;
break;
}
if(__key != KK_EditUndo)
@@ -2402,8 +2408,7 @@ void UndoStack::PushItem(uint action, Line* __line, uint __col, uint __len) {
case EDIT_UNDO_INS_TEXT:
case EDIT_UNDO_WRAP_TEXT:
last_item->line = __line;
throw_new(last_item->data.text_ptr = new(__len) text_item(__col, __len));
memcpy(last_item->data.text_ptr->text, __line->txt.c_str() + __col, __len);
throw_new(last_item->data.text_ptr = new text_item(__col, __len));
break;
case EDIT_UNDO_NEW_LINE:
last_item->line = last_item->data.line_ptr = __line;

View File

@@ -750,7 +750,7 @@ void IEclass::BlockPaste() {
// insert into current line
currline->txt.insert(col, _pasteline->txt);
Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, currline, col, pastelen);
col += _pasteline->txt.length();
col += pastelen;
wrapins(&currline, &col, &row, NO);
}

View File

@@ -37,7 +37,7 @@ char* strconv(char* str, char* conv) {
NW(conv); // Dummy
while(*str) {
if((*str < ' ') and (*str != '\n') and (*str != '\r')) // Control codes
if(iscntrl(*str) and (*str != '\n') and (*str != '\r')) // Control codes
*p++ = '.';
else
*p++ = *str;

View File

@@ -1605,6 +1605,14 @@ void ScanKludges(GMsg* msg, int getvalue) {
if(not AA->isinternet())
*msg->ito = NUL;
}
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);
KludgeREPLYADDR(msg, tmp ? tmp : ptr);
if(tmp)
throw_free(tmp);
}
else
break;
}

View File

@@ -34,6 +34,25 @@ uint position;
ulong msgcount = 0;
// ------------------------------------------------------------------
string &strtrimline(string &p) {
if(not p.empty()) {
string::iterator trail = p.end();
while(trail != p.begin()) {
--trail;
if(not strchr(" \t\r\n", *trail) and not issoftcr(*trail)) {
++trail;
break;
}
}
p.erase(trail, p.end());
}
return p;
}
// ------------------------------------------------------------------
const char* get_subject_re_info(const char* s, ulong& n) {
@@ -549,7 +568,7 @@ static void MakeMsg2(int& mode, int& status, int& forwstat, int& topline, GMsg*
if(((line->type & GLINE_HIDD) and not AA->Viewhidden()) or ((line->type & GLINE_KLUD) and not AA->Viewkludge()))
newline = line = DeleteLine(line);
else {
strtrim(line->txt);
strtrimline(line->txt);
if(line->type & GLINE_HARD)
line->txt += "\n";
else
@@ -570,13 +589,13 @@ static void MakeMsg2(int& mode, int& status, int& forwstat, int& topline, GMsg*
if(status != MODE_QUIT) {
line = msg->lin;
while(line) {
if(line->txt.find(LF) != line->txt.npos)
if(line->txt.find('\n') != line->txt.npos)
line->type = GLINE_HARD;
else if(line->next and (line->next->type & GLINE_QUOT))
line->type = GLINE_HARD;
else
line->type = 0;
strtrim(line->txt);
strtrimline(line->txt);
if(AA->isinternet()) {
// Check for signature indicator
if(streql(line->txt.c_str(), "--")) {

View File

@@ -325,7 +325,7 @@ int is_quote(const char* ptr) {
if(spaces > 1)
return false;
}
else if((*ptr < ' ') or strchr(AA->Quotestops(), *ptr)) {
else if(iscntrl(*ptr) or strchr(AA->Quotestops(), *ptr)) {
// Found a char that cannot occur in a quotestring
return false;
}