InternetRFCBody, ZapQuotesBelow, EditNewLine and other fixes

This commit is contained in:
Alexander S. Aganichev 2001-06-12 17:31:12 +00:00
parent 4dc91867e5
commit 9008bc555d
9 changed files with 78 additions and 43 deletions

View File

@ -12,6 +12,12 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________
- Fixed crash on very long name in Internet messages.
! ZapQuotesBelow now acts only on the single quotation block, not on
the all quotes below. It's more handy, especially in case of
removing attach from the file.
! A lot of improvements in charset handling added. QP postfix now
could be used with any charset, not only with LATIN1. Completely
untested!

View File

@ -902,7 +902,10 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
}
if(__display and (scroll != 0)) {
if((*__currline)->next != NULL)
refresh((*__currline)->next, _cursrow+1);
else
refresh(*__currline, _cursrow);
}
// Update cursor position
@ -1204,15 +1207,13 @@ 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
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;
char _quotebuf[MAXQUOTELEN];
GetQuotestr(currline->txt.c_str(), _quotebuf, &_quotelen);
// Eliminate the quotestring if
@ -1238,6 +1239,13 @@ void IEclass::Newline() {
setlinetype(currline);
displine(currline, row);
uint _quotelen1 = 0;
char _quotebuf1[MAXQUOTELEN] = "";
if(currline->next != NULL) {
GetQuotestr(currline->next->txt.c_str(), _quotebuf1, &_quotelen1);
}
if((_splitbuf.find('\n') != _splitbuf.npos) or (currline->next == NULL) or not strieql(_quotebuf, _quotebuf1)) {
// Insert a new line below, set the line text to the split-off part
currline = insertlinebelow(currline, _splitbuf.c_str());
@ -1249,6 +1257,14 @@ void IEclass::Newline() {
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, currline->prev, _quotelen, _splitbuf.length() - _quotelen);
setlinetype(currline);
}
else {
currline = currline->next;
currline->txt.insert(_quotelen1, _splitbuf.substr(_quotelen1));
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, currline->prev, _quotelen1, _splitbuf.length() - _quotelen1);
}
// Move down the cursor
col = 0;
@ -1259,7 +1275,8 @@ void IEclass::Newline() {
scrolldown(mincol, row, maxcol, maxrow);
// Rewrap the split-off line
wrapdel(&currline, &col, &row);
wrapdel(&currline, &col, &row, true);
refresh(currline, row);
GFTRK(NULL);
}
@ -1504,14 +1521,33 @@ void IEclass::deleteline(bool zapquotesbelow) {
GFTRK("Editdeleteline");
if(zapquotesbelow and not (currline->type & GLINE_QUOT)) {
GFTRK(NULL);
return;
}
// Stop reflow if the quotestring on the next line is not the same
uint _qlen1;
char _qstr1[MAXQUOTELEN];
GetQuotestr(currline->txt.c_str(), _qstr1, &_qlen1);
bool done = false;
do {
// Break if need to zap quotes, but the current line is not quote and is not empty
if(zapquotesbelow and not ((currline->type & GLINE_QUOT) or strblank(currline->txt.c_str())))
if(zapquotesbelow) {
if(isempty(currline) or (currline->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG|GLINE_TAGL)))
break;
// Stop zap if the quotestring on the line is not the same
uint _qlen2;
char _qstr2[MAXQUOTELEN];
GetQuotestr(currline->txt.c_str(), _qstr2, &_qlen2);
if(not cmp_quotes(_qstr1, _qstr2))
break;
}
// Pointer to the deleted line
Line* _deletedline = currline;
@ -1647,7 +1683,6 @@ void IEclass::ZapQuoteBelow() {
if(row) {
GoUp();
GoEOL();
Newline();
}
else {
UndoItem* i = Undo->last_item;

View File

@ -160,6 +160,7 @@ enum {
RFC_MIME_VERSION,
RFC_NEWSGROUPS,
RFC_NEWS_SOFTWARE,
RFC_NNTP_POSTING_DATE,
RFC_NNTP_POSTING_HOST,
RFC_NNTP_POSTING_USER,
RFC_OLD_DATE,
@ -335,6 +336,7 @@ static const Kludges rfc_list[] = {
{ "MIME-Version" , RFC_MIME_VERSION , KCRQ_COLON },
{ "Newsgroups" , RFC_NEWSGROUPS , KCRQ_COLON },
{ "News-Software" , RFC_NEWS_SOFTWARE , KCRQ_COLON },
{ "NNTP-Posting-Date" , RFC_NNTP_POSTING_DATE , KCRQ_COLON },
{ "NNTP-Posting-Host" , RFC_NNTP_POSTING_HOST , KCRQ_COLON },
{ "NNTP-Posting-User" , RFC_NNTP_POSTING_USER , KCRQ_COLON },
{ "Old-Date" , RFC_OLD_DATE , KCRQ_COLON },
@ -1266,6 +1268,7 @@ int HandleRFCs(GMsg* msg, Line* line, int kludgenum, const char* ptr, int getval
case RFC_LINES:
case RFC_MAILING_LIST:
case RFC_NEWS_SOFTWARE:
case RFC_NNTP_POSTING_DATE:
case RFC_NNTP_POSTING_HOST:
case RFC_NNTP_POSTING_USER:
case RFC_OLD_DATE:
@ -2469,7 +2472,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
char lwsp = *linep->next->txt.c_str();
while((lwsp == ' ') or (lwsp == '\t') or (linep->type & GLINE_WRAP)) {
linep = linep->next;
linep->type |= linep->prev->type;
linep->type |= linep->prev->type & (GLINE_KLUD|GLINE_HIDD);
linep->color = linep->prev->color;
if(linep->next)
lwsp = *linep->next->txt.c_str();
@ -2928,8 +2931,6 @@ Line* AddHexdump(Line*& line, void* data, size_t datalen) {
char* ParseInternetAddr(char* __string, char* __name, char* __addr) {
*__name = *__addr = NUL;
char* name = __name;
char* addr = __addr;
char* commaptr = NULL;
if(strchr(__string, ',')) {
@ -2968,12 +2969,8 @@ char* ParseInternetAddr(char* __string, char* __name, char* __addr) {
}
if(*begchar == '(' /*)*/)
begchar++;
if(not strchr(__string, '@') and strchr(begchar, '@')) {
name = __addr;
addr = __name;
}
strbtrim(strxcpy(name, begchar, (uint)(endchar-begchar)+1));
strbtrim(strxcpy(addr, __string, (uint)(begchar-__string)));
strbtrim(strxcpy(__name, begchar, MinV((uint)(endchar-begchar)+1, sizeof(INam))));
strbtrim(strxcpy(__addr, __string, MinV((uint)(begchar-__string), sizeof(IAdr))));
}
else if(*endchar == '>') {
char* endaddr = endchar;
@ -2985,15 +2982,11 @@ char* ParseInternetAddr(char* __string, char* __name, char* __addr) {
endchar--;
}
__string = strskip_wht(__string);
if(not strchr(begaddr, '@') and strchr(__string, '@')) {
name = __addr;
addr = __name;
}
strbtrim(strxcpy(name, __string, (uint)(endchar-__string)+1));
strbtrim(strxcpy(addr, begaddr, (uint)(endaddr-begaddr)+1));
strbtrim(strxcpy(__name, __string, MinV((uint)(endchar-__string)+1, sizeof(INam))));
strbtrim(strxcpy(__addr, begaddr, MinV((uint)(endaddr-begaddr)+1, sizeof(IAdr))));
}
else {
strcpy(__addr, __string);
strxcpy(__addr, __string, sizeof(IAdr));
}
if(*__addr == '@') {
@ -3007,6 +3000,9 @@ char* ParseInternetAddr(char* __string, char* __name, char* __addr) {
StripQuotes(__name);
if(not strchr(__addr, '@'))
*__addr = NUL;
strxmimecpy(__name, __name, 0, strlen(__name)+1, true);
return __name;

View File

@ -30,8 +30,6 @@
// ------------------------------------------------------------------
#include <gdefs.h>
#include <gutlos.h>
#ifdef __BORLANDC__
#define __USELOCALES__
#elif defined(__EMX__)
@ -47,14 +45,14 @@
extern "C" {
#endif
extern char tl[256], tu[256];
inline int _nls_tolower(int c) { return tl[c]; }
inline int _nls_toupper(int c) { return tu[c]; }
__inline__ int _nls_tolower(int c) { return tl[c]; }
__inline__ int _nls_toupper(int c) { return tu[c]; }
#ifdef __cplusplus
}
#endif
#define tolower(a) _nls_tolower((unsigned char)(a))
#define toupper(a) _nls_toupper((unsigned char)(a))
#endif
#endif
// ------------------------------------------------------------------
@ -63,7 +61,7 @@ inline int _nls_toupper(int c) { return tu[c]; }
extern "C" {
#endif
// NLS chars detected by converting to lower or upper case and in case they don't match they treated as characters
inline int isxalnum(char c) { return isascii(c) ? isalnum(c) : (c != tolower(c)) or (c != toupper(c)); }
__inline__ int isxalnum(char c) { return isascii(c) ? isalnum(c) : (c != tolower(c)) || (c != toupper(c)); }
#ifdef __cplusplus
}
#endif

View File

@ -26,9 +26,8 @@
// ------------------------------------------------------------------
#include <cstdlib>
#include <gctype.h>
#include <gstrall.h>
#include <gutlmisc.h>
#include <gstrall.h>
// ------------------------------------------------------------------

View File

@ -31,6 +31,7 @@
// ------------------------------------------------------------------
#include <gdefs.h>
#include <gctype.h>
#include <cstdlib>

View File

@ -2,7 +2,7 @@
TOP=../..
TARGET=glibc
INCS=-I$(TOP)/goldlib/glibc
INCS=-I$(TOP)/goldlib/glibc -I$(TOP)/goldlib/gall
CFLAGS=-DHAVE_CONFIG_H
include $(TOP)/GNUmakef.inc

View File

@ -27,7 +27,7 @@
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
#include <gctype.h>
#if HAVE_STRING_H
# include <string.h>

View File

@ -210,7 +210,7 @@ init_syntax_once ()
#include "regex.h"
/* isalpha etc. are used for the character classes. */
#include <ctype.h>
#include <gctype.h>
/* Jim Meyering writes: