Line->txt now STL-based.

This commit is contained in:
Alexander S. Aganichev 2000-03-22 17:59:18 +00:00
parent 99bd4b886f
commit 5b4f35d9ed
35 changed files with 518 additions and 687 deletions

View File

@ -21,7 +21,8 @@ ifeq ($(FDEPPATH)/dep,$(wildcard $(FDEPPATH)/de?))
$(FDEPPATH)/$(TARGET)/%.d: %.cpp $(FDEPPATH)/$(TARGET)/%.d: %.cpp
@echo making depends for $< @echo making depends for $<
@$(SHELL) -ec '$(CXX) -c -M $(CPPFLAGS) $< \ @$(SHELL) -ec '$(CXX) -c -M $(CPPFLAGS) $< \
| sed '\''s;\($*\)\$(OBJEXT)[ :]*;$(subst /,\/,$(FOBJPATH))\/\1\$(OBJEXT) $(subst /,\/,$@): ;g'\'' > $@' | sed '\''s;\($*\)\$(OBJEXT)[ :]*;$(subst /,\/,$(FOBJPATH))\/\1\$(OBJEXT) $(subst /,\/,$@): ;g'\'' > $@; \
[ -s $@ ] || rm -f $@'
$(FDEPPATH)/$(TARGET)/%.d: %.c $(FDEPPATH)/$(TARGET)/%.d: %.c
@echo making depends for $< @echo making depends for $<
@ -50,7 +51,7 @@ $(FOBJPATH)/%.res: %.rc
endif endif
SOURCES= SOURCES=
include bld$(PLATFORM).inc -include bld$(PLATFORM).inc
ifeq ($(PLATFORM),cyg) ifeq ($(PLATFORM),cyg)
OBJS=$(addprefix $(FOBJPATH)/,$(patsubst %.rc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(filter %.c %.cpp %.rc,$(SOURCES)))))) OBJS=$(addprefix $(FOBJPATH)/,$(patsubst %.rc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(filter %.c %.cpp %.rc,$(SOURCES))))))
else else
@ -71,4 +72,3 @@ ifneq ($(DEPS),)
-include $(DEPS) -include $(DEPS)
endif endif
endif endif

View File

@ -11,6 +11,12 @@ To compile GoldED+ and utilities you'll need:
- vi, emacs, or any other editor you like - vi, emacs, or any other editor you like
- boldness ;-) - boldness ;-)
--- MINGW32 ONLY ---
Remove alloc.h from the $(include)/mingw32 to avoid unpredictable problems.
Change arguments to sopen (to be `const char *' instead of `char *') and
atexit (to be `void (func *)(void)' instead of `void (func *)()'.
------ COMMON ------
First, edit GNUmakef.def for the preferrable compilation options. First, edit GNUmakef.def for the preferrable compilation options.
Now go to golded3 and áopy mygolded.__h to mygolded.h and adjust it for Now go to golded3 and áopy mygolded.__h to mygolded.h and adjust it for

View File

@ -37,7 +37,8 @@ assistance!
*A:* Чтобы GoldED+ глючил поменьше, надо настроить региональные установки: *A:* Чтобы GoldED+ глючил поменьше, надо настроить региональные установки:
для DPMI32: country.sys, переменная TZ для DPMI32: country.sys, переменная TZ
для Win32: control panel для Win32: control panel
для OS/2: [не знаю где настраивается, но региональные настройки - свои], переменная TZ для OS/2: [не знаю где настраивается, но региональные настройки - свои],
переменная TZ
для UNIX: переменные LANG и TZ. для UNIX: переменные LANG и TZ.
*Q:* А как же все-таки правильно менять SoftCR при наборе и иметь с этим *Q:* А как же все-таки правильно менять SoftCR при наборе и иметь с этим
@ -115,7 +116,7 @@ assistance!
*Q:* Типа эта... А писать куда автору? ;-) *Q:* Типа эта... А писать куда автору? ;-)
*A:* Писать лучше всего в Ru.GoldED. Даже лучше сначала его почитать, потом *A:* Писать лучше всего в Ru.GoldED. Даже лучше сначала его почитать, потом
писать. Если уж сильно приспичит, то можно писать на asa@eed.miee.ru, писать. Если уж сильно приспичит, то можно писать на asa@eed.miee.ru
2:5020/201.58 или 2:5049/49.50, но я совсем не гарантирую, что я отвечу. или 2:5020/201.58, но я совсем не гарантирую, что я отвечу.
>============================================================================== >==============================================================================

View File

@ -91,7 +91,7 @@ void AddCCList(const char *ptr, bool cchide, GMsg* msg, GMsg** carbon, int &cc,
int DoCarboncopy(GMsg* msg, GMsg** carbon) { int DoCarboncopy(GMsg* msg, GMsg** carbon) {
int n, cc = 0; int n, cc = 0;
char* ptr; const char* ptr;
Attr attr; Attr attr;
bool cchide; bool cchide;
bool ignorecc = false; bool ignorecc = false;
@ -108,7 +108,8 @@ int DoCarboncopy(GMsg* msg, GMsg** carbon) {
// Insert empty line at the top first for practical purposes // Insert empty line at the top first for practical purposes
newline = (Line*)throw_xcalloc(1, sizeof(Line)); newline = new Line("");
throw_xnew(newline);
msg->lin = newline = line = InsertLine(newline, msg->lin, DIR_PREV); msg->lin = newline = line = InsertLine(newline, msg->lin, DIR_PREV);
// Deal with carbon copies // Deal with carbon copies
@ -130,8 +131,8 @@ int DoCarboncopy(GMsg* msg, GMsg** carbon) {
int xc2to = 0; int xc2to = 0;
do { do {
ptr = newline->text; ptr = newline->txt.c_str();
if(ptr and strnieql(ptr, "CC:", 3)) { if(strnieql(ptr, "CC:", 3)) {
if(not ignorecc) { if(not ignorecc) {
if(ask) { if(ask) {
msg->attr.nwm1(); msg->attr.nwm1();
@ -316,7 +317,7 @@ void DoCrosspost(GMsg* msg, vector<int> &postareas) {
if(CFG->crosspost == NO) if(CFG->crosspost == NO)
return; return;
char buf[256]; char buf[256];
char *ptr; const char *ptr;
bool ignorexc = false; bool ignorexc = false;
Line* newline; Line* newline;
Line* xcline = NULL; Line* xcline = NULL;
@ -328,7 +329,8 @@ void DoCrosspost(GMsg* msg, vector<int> &postareas) {
// Insert empty line at the top first for practical purposes // Insert empty line at the top first for practical purposes
newline = (Line*)throw_xcalloc(1, sizeof(Line)); newline = new Line("");
throw_xnew(newline);
msg->lin = newline = InsertLine(newline, msg->lin, DIR_PREV); msg->lin = newline = InsertLine(newline, msg->lin, DIR_PREV);
// Deal with carbon copies // Deal with carbon copies
@ -348,8 +350,8 @@ void DoCrosspost(GMsg* msg, vector<int> &postareas) {
if(not (newline->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) { if(not (newline->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) {
ptr = newline->text; ptr = newline->txt.c_str();
if(not ignorexc and ptr and (strnieql(ptr, "XC:", 3) or strnieql(ptr, "XP:", 3))) { if(not ignorexc and (strnieql(ptr, "XC:", 3) or strnieql(ptr, "XP:", 3))) {
if(ask) { if(ask) {
GMenuCross MenuCross; GMenuCross MenuCross;
ignorexc = (CFG->crosspost != ASK) or MenuCross.Run(msg) ? false : true; ignorexc = (CFG->crosspost != ASK) or MenuCross.Run(msg) ? false : true;

View File

@ -31,12 +31,12 @@
inline int isstylechar(char c) { return (c == '*') or (c == '/') or (c == '_') or (c == '#'); } inline int isstylechar(char c) { return (c == '*') or (c == '/') or (c == '_') or (c == '#'); }
void Container::StyleCodeHighlight(char* text, int row, int col, bool dohide, int color) { void Container::StyleCodeHighlight(const char* text, int row, int col, bool dohide, int color) {
uint sclen = 0; uint sclen = 0;
char* txptr = text; char* txptr = text;
char buf[200]; char buf[200];
char* ptr = text; const char* ptr = text;
const char* stylemargins = " -|\\"; // we probably have to make a keyword for it const char* stylemargins = " -|\\"; // we probably have to make a keyword for it
char* punctchars = CFG->stylecodepunct; char* punctchars = CFG->stylecodepunct;
char* stylestopchars = CFG->stylecodestops; char* stylestopchars = CFG->stylecodestops;
@ -47,7 +47,7 @@ void Container::StyleCodeHighlight(char* text, int row, int col, bool dohide, in
if(isstylechar(*ptr)) { if(isstylechar(*ptr)) {
if(strchr(punctchars, prevchar)) { if(strchr(punctchars, prevchar)) {
int bb = 0, bi = 0, bu = 0, br = 0; int bb = 0, bi = 0, bu = 0, br = 0;
char* beginstyle = ptr; const char* beginstyle = ptr;
while(isstylechar(*ptr)) { while(isstylechar(*ptr)) {
switch(*ptr) { switch(*ptr) {
case '*': bb++; break; case '*': bb++; break;
@ -58,7 +58,7 @@ void Container::StyleCodeHighlight(char* text, int row, int col, bool dohide, in
ptr++; ptr++;
} }
if((bb <= 1) and (bi <= 1) and (br <= 1) and (bu <= 1) and *ptr) { if((bb <= 1) and (bi <= 1) and (br <= 1) and (bu <= 1) and *ptr) {
char* beginword = ptr; // _/*>another*/_ const char* beginword = ptr; // _/*>another*/_
char endchar = NUL; char endchar = NUL;
char* end = ptr; char* end = ptr;
do { do {

View File

@ -24,6 +24,8 @@
// Container class. // Container class.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#ifndef __gectnr_h
#define __gectnr_h
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -35,8 +37,12 @@ public:
virtual ~Container() { } virtual ~Container() { }
void StyleCodeHighlight(char* text, int row, int col, bool dohide, int color); void StyleCodeHighlight(const char* text, int row, int col, bool dohide, int color);
}; };
// ------------------------------------------------------------------
#endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -223,7 +223,8 @@ void DoKludges(int mode, GMsg* msg, bool attronly) {
// Insert empty line at the top for practical purposes // Insert empty line at the top for practical purposes
newline = (Line*)throw_xcalloc(1, sizeof(Line)); newline = new Line("");
throw_xnew(newline);
newline = line = InsertLine(newline, line, DIR_PREV); newline = line = InsertLine(newline, line, DIR_PREV);
// Strip all the kludges we insert ourselves // Strip all the kludges we insert ourselves
@ -260,6 +261,13 @@ void DoKludges(int mode, GMsg* msg, bool attronly) {
if(AA->isnet()) { if(AA->isnet()) {
Line* firstline = FirstLine(line);
firstline = firstline->next;
// 123456789012345678901234567
if(strneql(firstline->txt.c_str(), "-----BEGIN PGP MESSAGE-----", 27)) {
line = AddKludge(line, "\001ENC: PGP");
}
// The INTL kludge for zone crossing // The INTL kludge for zone crossing
if(CFG->useintl and (CFG->useintl == YES or (msg->dest.zone != msg->orig.zone))) { if(CFG->useintl and (CFG->useintl == YES or (msg->dest.zone != msg->orig.zone))) {
sprintf(buf, "\001INTL %u:%u/%u %u:%u/%u", sprintf(buf, "\001INTL %u:%u/%u %u:%u/%u",
@ -516,20 +524,13 @@ void DoKludges(int mode, GMsg* msg, bool attronly) {
line->kludge = GKLUD_RFC; line->kludge = GKLUD_RFC;
} }
if(AA->Internetrfcbody() and line->next and not strblank(line->next->text)) { if(AA->Internetrfcbody() and line->next and not strblank(line->next->txt.c_str())) {
line = AddKludge(line, ""); line = AddKludge(line, "");
line->kludge = GKLUD_RFC; line->kludge = GKLUD_RFC;
} }
} }
if(AA->isnet()) { if(AA->isnet()) {
Line* firstline = FirstLine(line);
firstline = firstline->next;
// 123456789012345678901234567
if(strneql(firstline->text, "-----BEGIN PGP MESSAGE-----", 27)) {
line = AddKludge(line, "\001ENC: PGP");
}
if(*msg->iaddr and not AA->isinternet()) { if(*msg->iaddr and not AA->isinternet()) {
if(*msg->To() and (strpbrk(msg->iaddr, "<>()\"") == NULL) and not strieql(msg->To(), *AA->Internetgate().name ? AA->Internetgate().name : "UUCP")) { if(*msg->To() and (strpbrk(msg->iaddr, "<>()\"") == NULL) and not strieql(msg->To(), *AA->Internetgate().name ? AA->Internetgate().name : "UUCP")) {
Name name; Name name;
@ -602,12 +603,14 @@ void DoTearorig(int mode, GMsg* msg) {
line = LastLine(msg->lin); line = LastLine(msg->lin);
if(line == NULL) if(line == NULL)
msg->lin = line = AddLine(NULL, ""); msg->lin = line = AddLine(NULL, "");
#if 0
else { else {
ptr = line->text; ptr = line->txt.c_str();
if(not strblank(ptr)) if(not strblank(ptr))
if(not ((ptr[0] == ptr[1]) and (ptr[1] == ptr[2]))) if(not ((ptr[0] == ptr[1]) and (ptr[1] == ptr[2])))
line = AddLine(line, ""); line = AddLine(line, "");
} }
#endif
// Check and fix originline // Check and fix originline
if(*msg->origin) { if(*msg->origin) {

View File

@ -80,23 +80,22 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, bool clip) {
if(lin and not (prnheader & WRITE_ONLY_HEADER)) { if(lin and not (prnheader & WRITE_ONLY_HEADER)) {
Line* line = lin[n]; Line* line = lin[n];
while(line) { while(line) {
if(line->text) {
uint lineisctrl = line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE); uint lineisctrl = line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE);
if(not ((mode == MODE_SAVENOCTRL) and lineisctrl)) { if(not ((mode == MODE_SAVENOCTRL) and lineisctrl)) {
char* ptr = line->text; string::iterator p = line->txt.begin();
while(*ptr) { while(p != line->txt.end()) {
if(mode == MODE_WRITE) { if(mode == MODE_WRITE) {
// Replace control codes, except the ANSI escape code // Replace control codes, except the ANSI escape code
if(*ptr < ' ') { if(*p < ' ') {
// only allow ESC in file write // only allow ESC in file write
if(prn or (*ptr != '\x1B')) { if(prn or (*p != '\x1B')) {
*ptr = (*ptr == CTRL_A) ? '@' : '.'; *p = (*p == CTRL_A) ? '@' : '.';
} }
} }
} }
ptr++; p++;
} }
ptr = line->text; const char *ptr = line->txt.c_str();
fwrite(ptr, strlen(ptr), 1, prnfp); fwrite(ptr, strlen(ptr), 1, prnfp);
if(mode == MODE_NEW) { if(mode == MODE_NEW) {
if(EDIT->HardLines()) { if(EDIT->HardLines()) {
@ -115,7 +114,6 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, bool clip) {
} }
} }
} }
}
line = lin[++n]; line = lin[++n];
} }
} }

View File

@ -99,73 +99,15 @@ void IEclass::debugtest(char* __test, int __a, int __b, char* __file, int __line
void IEclass::setlinetype(Line* __line) { void IEclass::setlinetype(Line* __line) {
_test_halt(__line == NULL); _test_halt(__line == NULL);
_test_halt(__line->text == NULL);
__line->type &= ~GLINE_ALL; __line->type &= ~GLINE_ALL;
__line->type |= is_quote(__line->text) ? GLINE_QUOT : (*__line->text == CTRL_A) ? GLINE_HIDD : 0; __line->type |= is_quote(__line->txt.c_str()) ? GLINE_QUOT : (__line->txt[0] == CTRL_A) ? GLINE_HIDD : 0;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Insert character in string at position // Insert character in string at position
void IEclass::strinschr(char*& __string, char __ch, uint __position) {
_test_halt(__string == NULL);
// 0123456789 _position = 2
// 1234567890 length = 4
// helo< < = nul
// he lo<
// hello<
// Get string length
uint _length = strlen(__string);
// Is position beyond the nul-terminator in the string?
_test_haltab(__position > _length, __position, _length);
// Reallocate string to make room for the char (3=nul+newchar+possible space)
__string = (char*)throw_realloc(__string, _length+3);
// Make room for the char to insert
memmove(__string+__position+1, __string+__position, _length-__position+1);
THROW_CHECKPTR(__string);
// Put in the char
__string[__position] = __ch;
THROW_CHECKPTR(__string);
if((__string[__position+1] == NUL) and (__ch != ' ') and (__ch != '\n')) {
__string[__position+1] = ' ';
__string[__position+2] = NUL;
THROW_CHECKPTR(__string);
}
}
// ------------------------------------------------------------------
// Delete character in string at position
void IEclass::strdelchr(char* __string, uint __position) {
_test_halt(__string == NULL);
// 0123456789 _position = 1
// 1234567890 length = 5
// hello< < = nul
// hllo<
uint _length = strlen(__string);
// Is position at or beyond the nul-terminator in the string?
_test_haltab(__position >= _length, __position, _length);
// Delete the character
memmove(__string+__position, __string+__position+1, _length-__position);
THROW_CHECKPTR(__string);
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Zero-based // Zero-based
@ -290,7 +232,7 @@ void IEclass::gotorowcol(uint __col, uint __row) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void IEclass::dispstring(char* __string, uint __row, int attr, Line* line) { void IEclass::dispstring(const char* __string, uint __row, int attr, Line* line) {
GFTRK("Editdispstring"); GFTRK("Editdispstring");
@ -315,7 +257,7 @@ void IEclass::dispstring(char* __string, uint __row, int attr, Line* line) {
if(attr == -1) { if(attr == -1) {
char* _bufptr = _buf; char* _bufptr = _buf;
uint _position = 0; uint _position = 0;
char* __str = __string; const char* __str = __string;
while(_position < _length) { while(_position < _length) {
switch(*__str) { switch(*__str) {
case ' ': *_bufptr = EDIT->CharSpace(); break; case ' ': *_bufptr = EDIT->CharSpace(); break;
@ -390,7 +332,7 @@ void IEclass::setcolor(Line* __line) {
else if(__line->type & GLINE_ORIG) else if(__line->type & GLINE_ORIG)
editwin.text_color(C_READO); editwin.text_color(C_READO);
else if(__line->type & GLINE_QUOT) else if(__line->type & GLINE_QUOT)
editwin.text_color(quotecolor(__line->text)); editwin.text_color(quotecolor(__line->txt.c_str()));
else if(__line->type & GLINE_SIGN) else if(__line->type & GLINE_SIGN)
editwin.text_color(C_READS); editwin.text_color(C_READS);
else else
@ -407,12 +349,11 @@ void IEclass::displine(Line* __line, uint __row) {
GFTRK("Editdispline"); GFTRK("Editdispline");
_test_halt(__line == NULL); _test_halt(__line == NULL);
_test_halt(__line->text == NULL);
_test_haltab(__row > maxrow, __row, maxrow); _test_haltab(__row > maxrow, __row, maxrow);
// Display line // Display line
setcolor(__line); setcolor(__line);
dispstring(__line->text, __row, -1, __line); dispstring(__line->txt.c_str(), __row, -1, __line);
GFTRK(NULL); GFTRK(NULL);
} }
@ -472,12 +413,12 @@ void IEclass::refresh(Line* __currline, uint __row) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
Line* IEclass::insertlinebelow(Line* __currline, char* __text, long __batch_mode) { Line* IEclass::insertlinebelow(Line* __currline, const char* __text, long __batch_mode) {
GFTRK("Editinsertlinebelow"); GFTRK("Editinsertlinebelow");
Line* _nextline = (Line*)throw_xcalloc(1, sizeof(Line)); Line* _nextline = new Line(__text ? __text : "");
_nextline->text = __text ? throw_strdup(__text) : (char*)NULL; throw_xnew(_nextline);
if(__currline) { if(__currline) {
@ -527,7 +468,7 @@ void IEclass::GoEOL() {
GFTRK("EditGoEOL"); GFTRK("EditGoEOL");
// Move cursor to the last char on the line // Move cursor to the last char on the line
col = strlen(currline->text); col = currline->txt.length();
if(col) if(col)
col--; col--;
@ -568,7 +509,7 @@ void IEclass::GoUp() {
} }
} }
if((col+1) > strlen(currline->text)) if((col+1) > currline->txt.length())
GoEOL(); GoEOL();
} }
@ -603,7 +544,7 @@ void IEclass::GoDown() {
} }
} }
if((col+1) > strlen(currline->text)) if((col+1) > currline->txt.length())
GoEOL(); GoEOL();
} }
@ -643,7 +584,7 @@ void IEclass::GoRight() {
_test_haltab(col > maxcol, col, maxcol); _test_haltab(col > maxcol, col, maxcol);
char _cursorchar = currline->text[col]; char _cursorchar = currline->txt[col];
if((col == maxcol) or (_cursorchar == '\n') or (_cursorchar == NUL)) { if((col == maxcol) or (_cursorchar == '\n') or (_cursorchar == NUL)) {
if(currline->next != NULL) { if(currline->next != NULL) {
@ -684,12 +625,12 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
while(_thisline) { while(_thisline) {
// Length of this line // Length of this line
uint _thislen = strlen(_thisline->text); uint _thislen = _thisline->txt.length();
uint _wrapmargin = (_thisline->type & GLINE_QUOT) ? marginquotes : margintext; uint _wrapmargin = (_thisline->type & GLINE_QUOT) ? marginquotes : margintext;
// Does this line need wrapping? // Does this line need wrapping?
if(_thislen > _wrapmargin or (_thislen == _wrapmargin and not isspace(_thisline->text[_thislen-1]))) { if(_thislen > _wrapmargin or (_thislen == _wrapmargin and not isspace(_thisline->txt[_thislen-1]))) {
// Reset quote string length // Reset quote string length
_quotelen = 0; _quotelen = 0;
@ -698,7 +639,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
if((_thisline->type & GLINE_QUOT) and CFG__editquotewrap) { if((_thisline->type & GLINE_QUOT) and CFG__editquotewrap) {
// Get quote string and length // Get quote string and length
GetQuotestr(_thisline->text, _quotebuf, &_quotelen); GetQuotestr(_thisline->txt.c_str(), _quotebuf, &_quotelen);
} }
// wrapmargin = 40 // wrapmargin = 40
@ -712,12 +653,12 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
// Case 4: >thisxisxaxtestxwithxaxlinexthatxneedxwrapping. // Case 4: >thisxisxaxtestxwithxaxlinexthatxneedxwrapping.
// Point to the last char inside the margin // Point to the last char inside the margin
char* _wrapptr = _thisline->text + _wrapmargin - 1; int _wrappos = _wrapmargin - 1;
// Locate the word to be wrapped // Locate the word to be wrapped
// Did we find a space? // Did we find a space?
if(*_wrapptr == ' ') { if(_thisline->txt[_wrappos] == ' ') {
// Case 1: A space was found as the last char inside the margin // Case 1: A space was found as the last char inside the margin
// //
@ -725,7 +666,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
// NOTE: Leading spaces to this word will be nulled out! // NOTE: Leading spaces to this word will be nulled out!
// Begin at the first char outside the margin // Begin at the first char outside the margin
_wrapptr++; _wrappos++;
} }
else { else {
@ -734,59 +675,52 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
// Now we must locate the beginning of the word we found. // Now we must locate the beginning of the word we found.
// Keep copy of original pointer // Keep copy of original pointer
char* _atmargin = _wrapptr; int _atmargin = _wrappos;
// Search backwards until a space or the beginning of the line is found // Search backwards until a space or the beginning of the line is found
while((_wrapptr > _thisline->text) and (*(_wrapptr-1) != ' ')) while(_wrappos > 0 and (_thisline->txt[_wrappos-1] != ' '))
_wrapptr--; _wrappos--;
// Check if we hit leading spaces // Check if we hit leading spaces
char* _spaceptr = _wrapptr; int _spacepos = _wrappos;
if(_spaceptr > _thisline->text) { if(_spacepos > 0) {
_spaceptr--; do {
while((_spaceptr > _thisline->text) and (*_spaceptr == ' ')) _spacepos--;
_spaceptr--; } while(_spacepos > 0 and _thisline->txt[_spacepos] == ' ');
} }
// Did we search all the way back to the beginning of the line? // Did we search all the way back to the beginning of the line?
if((_wrapptr == _thisline->text) or (_wrapptr == (_thisline->text+_quotelen)) or (*_spaceptr == ' ')) { if(_wrappos == 0 or _wrappos == _quotelen or _thisline->txt[_spacepos] == ' ') {
// Case 3: There are no spaces within the margin or we hit leading spaces // Case 3: There are no spaces within the margin or we hit leading spaces
// We have to break it up at the margin // We have to break it up at the margin
_wrapptr = _atmargin; _wrappos = _atmargin;
} }
} }
// The wrapptr now points to the location to be wrapped or NUL // The wrapptr now points to the location to be wrapped or NUL
// Get length of the wrapped part // Get length of the wrapped part
uint _wraplen = strlen(_wrapptr); uint _wraplen = _thisline->txt.length() - _wrappos;
// Is the line hard-terminated? // Is the line hard-terminated?
if(strchr(_wrapptr, '\n')) { if(_thisline->txt.find('\n', _wrappos) != _thisline->txt.npos) {
// The line is hard-terminated. // The line is hard-terminated.
// //
// The wrapped part must be placed on a new line below. // The wrapped part must be placed on a new line below.
Line* _wrapline = _lastadded = insertlinebelow(_thisline, NULL, BATCH_MODE); Line* _wrapline = _lastadded = insertlinebelow(_thisline, NULL, BATCH_MODE);
// Allocate space for the new line
_wrapline->text = (char*)throw_malloc(_quotelen + _wraplen + 1);
// Copy the quote string, if any, to the new line first // Copy the quote string, if any, to the new line first
if(_quotelen) { if(_quotelen)
strcpy(_wrapline->text, _quotebuf); _wrapline->txt = _quotebuf;
THROW_CHECKPTR(_wrapline->text); else
} _wrapline->txt = "";
else {
*_wrapline->text = NUL;
THROW_CHECKPTR(_wrapline->text);
}
// Copy/append the wrapped part to the new line // Copy/append the wrapped part to the new line
strcat(_wrapline->text, _wrapptr); _wrapline->txt += _thisline->txt.substr(_wrappos);
THROW_CHECKPTR(_wrapline->text);
// Saves pointer to a line where from the wrapped part was copied, its begining // 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 // and length. While in Undo, appends the copied part to previous line and deletes
@ -806,7 +740,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
scrolldown(mincol, _thisrow+1, maxcol, maxrow); scrolldown(mincol, _thisrow+1, maxcol, maxrow);
// Display the new line // Display the new line
if(strlen(_wrapline->text) <= (maxcol+1)) if(_wrapline->txt.length() <= (maxcol+1))
displine(_wrapline, _thisrow+1); displine(_wrapline, _thisrow+1);
} }
} }
@ -834,31 +768,16 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
_line_added_below = true; _line_added_below = true;
} }
// Get length of the text of next line
uint _nextlen = _nextline->text ? strlen(_nextline->text) : 0;
// Reallocate next line's text to make room for the wrapped part
_nextline->text = (char*)throw_realloc(_nextline->text, _quotelen+_wraplen+_nextlen+1);
// Move the next line's text to make room for the wrapped part and the quote string, if any
memmove(_nextline->text+_quotelen+_wraplen, _nextline->text, _nextlen+1);
THROW_CHECKPTR(_nextline->text);
// Copy the wrapped part
memmove(_nextline->text+_quotelen, _wrapptr, _wraplen);
THROW_CHECKPTR(_nextline->text);
// Was this line quoted? // Was this line quoted?
if(_quotelen) { if(_quotelen) {
// Copy the quote string // Copy the quote string
memmove(_nextline->text, _quotebuf, _quotelen); _nextline->txt.insert(0, _quotebuf, _quotelen);
THROW_CHECKPTR(_nextline->text);
Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, _nextline, 0, _quotelen);
} }
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _nextline, _quotelen, _wraplen); _nextline->txt.insert(_quotelen, _thisline->txt.substr(_wrappos));
Undo->PushItem(EDIT_UNDO_WRAP_TEXT|BATCH_MODE, _nextline, 0, _quotelen+_wraplen);
// Make sure the type of the line is correct // Make sure the type of the line is correct
setlinetype(_nextline); setlinetype(_nextline);
@ -873,35 +792,33 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
} }
// Display the new/wrapped line // Display the new/wrapped line
if((_thisrow+1) <= maxrow and strlen(_nextline->text) <= (maxcol+1)) if((_thisrow+1) <= maxrow and _nextline->txt.length() <= (maxcol+1))
displine(_nextline, _thisrow+1); displine(_nextline, _thisrow+1);
} }
} }
// Nul-terminate at the wrapping location // Truncate at the wrapping location
*_wrapptr = NUL; _thisline->txt.erase(_wrappos);
THROW_CHECKPTR(_thisline->text);
// Was this line quoted? // Was this line quoted?
if(_quotelen) { if(_quotelen) {
// Trim spaces off the end of the line // Trim spaces off the end of the line
char* _trimptr = _wrapptr - 1; int _trimpos = _wrappos - 1;
if(*_trimptr == ' ') { if(_thisline->txt[_trimpos] == ' ') {
while(*(_trimptr-1) == ' ') while(_trimpos > 0 and _thisline->txt[_trimpos-1] == ' ')
_trimptr--; _trimpos--;
if(_quotelen and _trimptr-_thisline->text < _quotelen) if(_quotelen and _trimpos < _quotelen)
_trimptr++; _trimpos++;
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimptr - _thisline->text); Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimpos);
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimptr - _thisline->text + 1); Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimpos+1);
*_trimptr = NUL; _thisline->txt.erase(_trimpos);
} }
else else
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _wrapptr - _thisline->text); Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _wrappos);
// Append a new linefeed // Append a new linefeed
strcat(_thisline->text, "\n"); _thisline->txt += "\n";
THROW_CHECKPTR(_thisline->text);
} }
// Make sure the line type still is correct // Make sure the line type still is correct
@ -915,13 +832,12 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
} }
// If we are on the cursor line, check if the cursor char was wrapped // If we are on the cursor line, check if the cursor char was wrapped
if(_thisrow == *__curr_row and strlen(_thisline->text) <= *__curr_col) { if(_thisrow == *__curr_row and _thisline->txt.length() <= *__curr_col) {
char* _colptr = _thisline->text + *__curr_col; _curscol = _quotelen + ((*__curr_col > _wrappos) ? *__curr_col-_wrappos : 0);
_curscol = _quotelen + ((_colptr > _wrapptr) ? _colptr - _wrapptr : 0);
_cursrow++, thisrow++; _cursrow++, thisrow++;
UndoItem* i = Undo->last_item; UndoItem* i = Undo->last_item;
do { i = i->prev; } while(i->action & BATCH_MODE); do { i = i->prev; } while(i->action & BATCH_MODE);
if(i->col.num >= strlen(i->line->text)) { if(i->col.num >= i->line->txt.length()) {
i->action |= PREV_LINE; i->action |= PREV_LINE;
i->col.sav = i->col.num; i->col.sav = i->col.num;
i->col.num = _curscol; i->col.num = _curscol;
@ -931,11 +847,11 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
// If this line is hard-terminated, we have finished wrapping // If this line is hard-terminated, we have finished wrapping
// Unless the next line has grown too large // Unless the next line has grown too large
if(strchr(_thisline->text, '\n')) { if(_thisline->txt.find('\n') != _thisline->txt.npos) {
if(_thisline->next == NULL) if(_thisline->next == NULL)
break; break;
_wrapmargin = (_thisline->next->type & GLINE_QUOT) ? marginquotes : margintext; _wrapmargin = (_thisline->next->type & GLINE_QUOT) ? marginquotes : margintext;
if(strlen(_thisline->next->text) <= _wrapmargin) if(_thisline->next->txt.length() <= _wrapmargin)
break; break;
} }
@ -1014,19 +930,20 @@ void IEclass::insertchar(char __ch) {
GFTRK("Editinsertchar"); GFTRK("Editinsertchar");
// Insert or overwrite the char, replacing the block if any
if((selecting ? (BlockCut(true), batch_mode = BATCH_MODE) : false) or
(currline->text[col] == '\n') or (currline->text[col] == NUL) or insert) {
Undo->PushItem(EDIT_UNDO_INS_CHAR|batch_mode);
strinschr(currline->text, __ch, col);
} else {
#ifndef NDEBUG #ifndef NDEBUG
uint _currline_len = strlen(currline->text); uint _currline_len = currline->txt.length();
_test_haltab(col > _currline_len, col, _currline_len); _test_haltab(col > _currline_len, col, _currline_len);
#endif #endif
// Insert or overwrite the char, replacing the block if any
if((selecting ? (BlockCut(true), batch_mode = BATCH_MODE) : false) or
(currline->txt[col] == '\n') or (currline->txt[col] == NUL) or insert) {
Undo->PushItem(EDIT_UNDO_INS_CHAR|batch_mode);
if(col == currline->txt.length() and __ch != ' ' and __ch != '\n')
currline->txt += ' ';
currline->txt.insert(col, 1, __ch);
} else {
Undo->PushItem(EDIT_UNDO_OVR_CHAR|batch_mode); Undo->PushItem(EDIT_UNDO_OVR_CHAR|batch_mode);
currline->text[col] = __ch; currline->txt[col] = __ch;
THROW_CHECKPTR(currline->text);
} }
batch_mode = BATCH_MODE; batch_mode = BATCH_MODE;
@ -1069,12 +986,12 @@ void IEclass::DelChar() {
Line* _thisline = currline; Line* _thisline = currline;
Line* _nextline = currline->next; Line* _nextline = currline->next;
uint _thislen = strlen(_thisline->text); uint _thislen = _thisline->txt.length();
// Cannot delete at or beyond the nul-terminator // Cannot delete at or beyond the nul-terminator
if(col < _thislen) { if(col < _thislen) {
Undo->PushItem(EDIT_UNDO_DEL_CHAR|batch_mode); Undo->PushItem(EDIT_UNDO_DEL_CHAR|batch_mode);
strdelchr(_thisline->text, col); _thisline->txt.erase(col, 1);
batch_mode = BATCH_MODE; batch_mode = BATCH_MODE;
} }
@ -1092,21 +1009,17 @@ void IEclass::DelChar() {
// Get quote string length // Get quote string length
char _dummybuf[100]; char _dummybuf[100];
GetQuotestr(_nextline->text, _dummybuf, &_quotelen); GetQuotestr(_nextline->txt.c_str(), _dummybuf, &_quotelen);
} }
// Reallocate this line's text to make room for the next
_thisline->text = (char*)throw_realloc(_thisline->text, _thislen + strlen(_nextline->text) - _quotelen + 1);
// Copy the next line's text to this line // Copy the next line's text to this line
// Skip past the next line's quote string and blanks, if any // Skip past the next line's quote string and blanks, if any
char* _nextptr = _nextline->text+_quotelen; const char* _nextptr = _nextline->txt.c_str()+_quotelen;
if(not ((_nextline->type & GLINE_QUOT) and (col == 0))) { if(not ((_nextline->type & GLINE_QUOT) and (col == 0))) {
while(*_nextptr == ' ') while(*_nextptr == ' ')
_nextptr++; _nextptr++;
} }
strcat(_thisline->text, _nextptr); _thisline->txt += _nextptr;
THROW_CHECKPTR(_thisline->text);
Undo->PushItem(EDIT_UNDO_CUT_TEXT|batch_mode, _thisline, col); Undo->PushItem(EDIT_UNDO_CUT_TEXT|batch_mode, _thisline, col);
@ -1168,14 +1081,14 @@ void IEclass::GoWordLeft() {
col--; col--;
if(not isxalnum(currline->text[col])) { if(not isxalnum(currline->txt[col])) {
while(not isxalnum(currline->text[col]) and (col > 0)) while(not isxalnum(currline->txt[col]) and (col > 0))
col--; col--;
while(isxalnum(currline->text[col]) and (col > 0)) while(isxalnum(currline->txt[col]) and (col > 0))
col--; col--;
} }
else { else {
while(isxalnum(currline->text[col]) and (col > 0)) while(isxalnum(currline->txt[col]) and (col > 0))
col--; col--;
} }
@ -1196,28 +1109,28 @@ void IEclass::GoWordRight() {
GFTRK("EditGoWordRight"); GFTRK("EditGoWordRight");
if((currline->text[col] == NUL) or (currline->text[col] == '\n')) { if(currline->txt.length() == col or currline->txt[col] == '\n') {
if(currline->next) { if(currline->next) {
GoDown(); GoDown();
col = 0; col = 0;
} }
} }
else { else {
if(not isxalnum(currline->text[col])) { if(not isxalnum(currline->txt[col])) {
while(not isxalnum(currline->text[col]) and ((col+1) <= strlen(currline->text))) while(not isxalnum(currline->txt[col]) and ((col+1) <= currline->txt.length()))
col++; col++;
} }
else { else {
while(isxalnum(currline->text[col]) and ((col+1) <= strlen(currline->text))) while(isxalnum(currline->txt[col]) and ((col+1) <= currline->txt.length()))
col++; col++;
while(not isxalnum(currline->text[col]) and ((col+1) <= strlen(currline->text))) while(not isxalnum(currline->txt[col]) and ((col+1) <= currline->txt.length()))
col++; col++;
} }
if(currline->text[col-1] == '\n') if(currline->txt[col-1] == '\n')
col--; col--;
if(currline->text[col] == NUL) { if(currline->txt.length() == col) {
if(currline->next) { if(currline->next) {
GoDown(); GoDown();
col = 0; col = 0;
@ -1240,14 +1153,8 @@ void IEclass::Newline() {
GFTRK("EditNewline"); GFTRK("EditNewline");
char* _text = currline->text;
// If the line is not hard-terminated, make room for it
if(not strchr(_text, '\n') and (_text[col] == NUL))
_text = currline->text = (char*)throw_realloc(_text, strlen(_text)+3);
// Pointer to the split position // Pointer to the split position
char* _splitptr = _text + col; int _splitpos = col;
// Buffer for the second part of the split line // Buffer for the second part of the split line
char* _splitbuf = (char*)throw_malloc(EDIT_BUFLEN); char* _splitbuf = (char*)throw_malloc(EDIT_BUFLEN);
@ -1256,27 +1163,27 @@ void IEclass::Newline() {
// If the split line was quoted, get the quotestring // If the split line was quoted, get the quotestring
// But do not get it if the cursor points to a linefeed or is // But do not get it if the cursor points to a linefeed or is
uint _quotelen = 0; uint _quotelen = 0;
if(is_quote(_text)) { if(is_quote(currline->txt.c_str())) {
GetQuotestr(_text, _splitbuf, &_quotelen); GetQuotestr(currline->txt.c_str(), _splitbuf, &_quotelen);
THROW_CHECKPTR(_splitbuf); THROW_CHECKPTR(_splitbuf);
} }
// Eliminate the quotestring if // Eliminate the quotestring if
// - the cursor points to a linefeed or // - the cursor points to a linefeed or
// - the cursor is located inside the quotestring // - the cursor is located inside the quotestring
if(_quotelen and ((*_splitptr == '\n') or (*_splitptr == NUL) or (col < _quotelen))) if(_quotelen and ((currline->txt.length() == col) or (currline->txt[_splitpos] == '\n') or (col < _quotelen)))
*_splitbuf = _quotelen = 0; *_splitbuf = _quotelen = 0;
// Append the second part to the split buffer // Append the second part to the split buffer
strcat(_splitbuf, _splitptr); strcat(_splitbuf, currline->txt.substr(_splitpos).c_str());
THROW_CHECKPTR(_splitbuf); THROW_CHECKPTR(_splitbuf);
Undo->PushItem(EDIT_UNDO_INS_TEXT|batch_mode, currline, col, 1); Undo->PushItem(EDIT_UNDO_INS_TEXT|batch_mode, currline, col, 1);
batch_mode = BATCH_MODE; batch_mode = BATCH_MODE;
// Copy linefeed+nul to the split position // Copy linefeed+nul to the split position
strcpy(_splitptr, "\n"); currline->txt.erase(_splitpos);
THROW_CHECKPTR(currline->text); currline->txt += "\n";
// Re-type and display the split line // Re-type and display the split line
setlinetype(currline); setlinetype(currline);
@ -1318,10 +1225,9 @@ void IEclass::CopyAboveChar() {
char _ch = ' '; char _ch = ' ';
if(currline->prev) { if(currline->prev) {
char* _ptr = currline->prev->text; uint _len = currline->prev->txt.length();
uint _len = strlen(_ptr);
if(_len and _len > col) if(_len and _len > col)
_ch = _ptr[col]; _ch = currline->prev->txt[col];
if(_ch == '\n') if(_ch == '\n')
_ch = ' '; _ch = ' ';
} }
@ -1339,7 +1245,7 @@ void IEclass::DupLine() {
Undo->PushItem(EDIT_UNDO_VOID); Undo->PushItem(EDIT_UNDO_VOID);
Line* _nextline = insertlinebelow(currline, currline->text, BATCH_MODE); Line* _nextline = insertlinebelow(currline, currline->txt.c_str(), BATCH_MODE);
_nextline->type = currline->type & ~GLINE_BLOK; _nextline->type = currline->type & ~GLINE_BLOK;
_nextline->color = currline->color; _nextline->color = currline->color;
_nextline->kludge = currline->kludge; _nextline->kludge = currline->kludge;
@ -1411,7 +1317,7 @@ void IEclass::GoPgUp() {
GoTopMsg(); GoTopMsg();
} }
if((col+1) > strlen(currline->text)) if(col+1 > currline->txt.length())
GoEOL(); GoEOL();
GFTRK(NULL); GFTRK(NULL);
@ -1469,7 +1375,7 @@ void IEclass::GoPgDn() {
GoBotMsg(); GoBotMsg();
} }
if((col+1) > strlen(currline->text)) if(col+1 > currline->txt.length())
GoEOL(); GoEOL();
GFTRK(NULL); GFTRK(NULL);
@ -1488,7 +1394,7 @@ void IEclass::Tab() {
do { do {
if(insert) if(insert)
insertchar(' '); insertchar(' ');
else if(currline->text[col] != '\n') else if(currline->txt[col] != '\n')
GoRight(); GoRight();
else else
break; break;
@ -1528,17 +1434,14 @@ void IEclass::DeleteEOL() {
GFTRK("EditDeleteEOL"); GFTRK("EditDeleteEOL");
bool _has_linefeed = strchr(currline->text, '\n') ? true : false; bool _has_linefeed = currline->txt.find('\n') != currline->txt.npos ? true : false;
Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline); Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline);
currline->text[col] = NUL; currline->txt.erase(col);
THROW_CHECKPTR(currline->text);
if(_has_linefeed) { if(_has_linefeed)
strcat(currline->text, "\n"); currline->txt += "\n";
THROW_CHECKPTR(currline->text);
}
clreol(); clreol();
@ -1557,7 +1460,7 @@ void IEclass::deleteline(bool zapquotesbelow) {
do { do {
// Break if need to zap quotes, but the current line is not quote and is not empty // 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->text))) if(zapquotesbelow and not ((currline->type & GLINE_QUOT) or strblank(currline->txt.c_str())))
break; break;
// Pointer to the deleted line // Pointer to the deleted line
@ -1565,7 +1468,7 @@ void IEclass::deleteline(bool zapquotesbelow) {
// If last line to be deleted delete to EOL and exit // If last line to be deleted delete to EOL and exit
if(currline->next == NULL) { if(currline->next == NULL) {
if(currline->text[0] == NUL) if(currline->txt.empty())
break; break;
insertlinebelow(currline, "", batch_mode); insertlinebelow(currline, "", batch_mode);
batch_mode = BATCH_MODE; batch_mode = BATCH_MODE;
@ -1612,7 +1515,7 @@ void IEclass::deleteline(bool zapquotesbelow) {
Edit__killbuf->next = NULL; Edit__killbuf->next = NULL;
// Move the cursor to EOL if necessary // Move the cursor to EOL if necessary
if((col+1) > strlen(currline->text)) if(col+1 > currline->txt.length())
GoEOL(); GoEOL();
if(not zapquotesbelow) if(not zapquotesbelow)
@ -1666,7 +1569,7 @@ void IEclass::UnDelete(bool before) {
Undo->PushItem(EDIT_UNDO_POP_LINE); Undo->PushItem(EDIT_UNDO_POP_LINE);
// Move the cursor to EOL if necessary // Move the cursor to EOL if necessary
if((col+1) > strlen(currline->text)) if(col+1 > currline->txt.length())
GoEOL(); GoEOL();
if(down) if(down)
@ -1762,7 +1665,7 @@ void IEclass::savefile(int __status) {
// Copy the line to a buffer // Copy the line to a buffer
char _buf[EDIT_BUFLEN]; char _buf[EDIT_BUFLEN];
strcpy(_buf, _saveline->text); strcpy(_buf, _saveline->txt.c_str());
// If a LF was found, replace it with a CR/LF combo // If a LF was found, replace it with a CR/LF combo
char* _lfptr = strchr(_buf, '\n'); char* _lfptr = strchr(_buf, '\n');
@ -1820,7 +1723,7 @@ int IEclass::isempty(Line* __line) {
if(__line == NULL) if(__line == NULL)
__line = currline; __line = currline;
return (*__line->text == '\n') or (*__line->text == NUL); return (__line->txt.empty() or __line->txt[0] == '\n');
} }
@ -1843,7 +1746,7 @@ int IEclass::reflowok(char* __qstr) {
// Stop reflow if the quotestring on the next line is not the same // Stop reflow if the quotestring on the next line is not the same
uint _qlen2; uint _qlen2;
char _qstr2[100]; char _qstr2[100];
GetQuotestr(currline->next->text, _qstr2, &_qlen2); GetQuotestr(currline->next->txt.c_str(), _qstr2, &_qlen2);
if(not strieql(__qstr, _qstr2)) if(not strieql(__qstr, _qstr2))
return false; return false;
@ -1870,14 +1773,14 @@ void IEclass::Reflow() {
// Get the first quotestring // Get the first quotestring
uint _qlen1; uint _qlen1;
char _qstr1[100]; char _qstr1[100];
GetQuotestr(currline->text, _qstr1, &_qlen1); GetQuotestr(currline->txt.c_str(), _qstr1, &_qlen1);
char* _qlenptr = currline->text + _qlen1; const char* _qlenptr = currline->txt.c_str() + _qlen1;
// Strip leading spaces from the first line // Strip leading spaces from the first line
char* ptr = strskip_wht(_qlenptr); const char* ptr = strskip_wht(_qlenptr);
if(ptr != _qlenptr) { if(ptr != _qlenptr) {
Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline, _qlen1, ptr-_qlenptr); Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline, _qlen1, ptr-_qlenptr);
memmove(_qlenptr, ptr, strlen(ptr) + 1); currline->txt.erase(_qlen1, ptr-_qlenptr);
} }
// Perform the reflow // Perform the reflow
@ -1944,7 +1847,7 @@ void IEclass::ToUpper() {
GFTRK("EditToUpper"); GFTRK("EditToUpper");
Undo->PushItem(EDIT_UNDO_OVR_CHAR); Undo->PushItem(EDIT_UNDO_OVR_CHAR);
currline->text[col] = toupper(currline->text[col]); currline->txt[col] = toupper(currline->txt[col]);
GFTRK(NULL); GFTRK(NULL);
} }
@ -1957,7 +1860,7 @@ void IEclass::ToLower() {
GFTRK("EditToLower"); GFTRK("EditToLower");
Undo->PushItem(EDIT_UNDO_OVR_CHAR); Undo->PushItem(EDIT_UNDO_OVR_CHAR);
currline->text[col] = tolower(currline->text[col]); currline->txt[col] = tolower(currline->txt[col]);
GFTRK(NULL); GFTRK(NULL);
} }
@ -1970,10 +1873,10 @@ void IEclass::ToggleCase() {
GFTRK("EditToggleCase"); GFTRK("EditToggleCase");
Undo->PushItem(EDIT_UNDO_OVR_CHAR); Undo->PushItem(EDIT_UNDO_OVR_CHAR);
if(toupper(currline->text[col]) == currline->text[col]) if(toupper(currline->txt[col]) == currline->txt[col])
currline->text[col] = tolower(currline->text[col]); currline->txt[col] = tolower(currline->txt[col]);
else else
currline->text[col] = toupper(currline->text[col]); currline->txt[col] = toupper(currline->txt[col]);
GFTRK(NULL); GFTRK(NULL);
} }
@ -1985,7 +1888,7 @@ void IEclass::LookupCursor() {
GFTRK("EditLookupCursor"); GFTRK("EditLookupCursor");
LookupNode(msgptr, currline->text+col, LOOK_NAME); LookupNode(msgptr, currline->txt.c_str()+col, LOOK_NAME);
GFTRK(NULL); GFTRK(NULL);
} }
@ -2033,7 +1936,7 @@ void IEclass::statusline() {
const char* trig = EDIT->Completion.Trigger(); const char* trig = EDIT->Completion.Trigger();
uint tlen = strlen(trig); uint tlen = strlen(trig);
if(col >= tlen) { if(col >= tlen) {
if(strneql(trig, currline->text+col-tlen, tlen)) { if(strneql(trig, currline->txt.c_str()+col-tlen, tlen)) {
uint n; uint n;
for(n=0; n<tlen; n++) for(n=0; n<tlen; n++)
DelLeft(); DelLeft();
@ -2057,7 +1960,7 @@ void IEclass::statusline() {
const char* trig = EDIT->Comment.Trigger(); const char* trig = EDIT->Comment.Trigger();
uint tlen = strlen(trig); uint tlen = strlen(trig);
if(col >= tlen) { if(col >= tlen) {
if(strnieql(trig, currline->text+col-tlen, tlen)) { if(strnieql(trig, currline->txt.c_str()+col-tlen, tlen)) {
strcpy(_buf, EDIT->Comment.Text()); strcpy(_buf, EDIT->Comment.Text());
break; break;
} }
@ -2235,8 +2138,8 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
whelppcat(H_Editor); whelppcat(H_Editor);
if(currline == NULL) { if(currline == NULL) {
currline = (Line*)throw_xcalloc(1, sizeof(Line)); currline = new Line("\n");
currline->text = throw_strdup("\n"); throw_xnew(currline);
} }
// Check if there is an unfinished backup message // Check if there is an unfinished backup message
@ -2294,7 +2197,7 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
int backattr = 0; int backattr = 0;
if(blockcol == -1) { if(blockcol == -1) {
backattr = dispchar(currline->text[col], C_READC); backattr = dispchar(currline->txt[col], C_READC);
gotorowcol(col, row); gotorowcol(col, row);
} }
@ -2334,7 +2237,7 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
} }
if(blockcol == -1) if(blockcol == -1)
dispchar(currline->text[col], backattr); dispchar(currline->txt[col], backattr);
chartyped = false; chartyped = false;
if((_ch < KK_Commands) and (_ch & 0xFF) and not ismacro) { if((_ch < KK_Commands) and (_ch & 0xFF) and not ismacro) {
@ -2377,14 +2280,12 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
} }
} }
else { else {
throw_release(__line->text);
if(__line->prev) { if(__line->prev) {
__line = __line->prev; __line = __line->prev;
throw_xrelease(__line->next); throw_xdelete(__line->next);
}
else {
throw_xrelease(__line);
} }
else
throw_xdelete(__line);
} }
} }
} }
@ -2425,12 +2326,10 @@ UndoStack::~UndoStack() {
switch(last_item->action & EDIT_UNDO_ACTION) { switch(last_item->action & EDIT_UNDO_ACTION) {
case EDIT_UNDO_DEL_TEXT: case EDIT_UNDO_DEL_TEXT:
case EDIT_UNDO_WRAP_TEXT: case EDIT_UNDO_WRAP_TEXT:
delete last_item->data.text_ptr; throw_delete(last_item->data.text_ptr);
break; break;
case EDIT_UNDO_DEL_LINE: case EDIT_UNDO_DEL_LINE:
if(last_item->data.line_ptr->isallocated()) throw_xdelete(last_item->data.line_ptr);
throw_release(last_item->data.line_ptr->text);
throw_xfree(last_item->data.line_ptr);
} }
delete last_item; delete last_item;
} }
@ -2476,14 +2375,14 @@ void UndoStack::PushItem(uint action, Line* __line, uint __col, uint __len) {
case EDIT_UNDO_DEL_CHAR: case EDIT_UNDO_DEL_CHAR:
case EDIT_UNDO_OVR_CHAR: case EDIT_UNDO_OVR_CHAR:
last_item->line = __line ? __line : currline; last_item->line = __line ? __line : currline;
last_item->data.char_int = last_item->line->text[last_item->col.num]; last_item->data.char_int = last_item->line->txt[last_item->col.num];
break; break;
case EDIT_UNDO_DEL_TEXT: case EDIT_UNDO_DEL_TEXT:
last_item->line = __line; last_item->line = __line;
if(__len == NO_VALUE) if(__len == NO_VALUE)
__len = strlen(__line->text + __col) + 1; __len = strlen(__line->txt.c_str() + __col) + 1;
throw_new(last_item->data.text_ptr = new(__len) text_item(__col, __len)); throw_new(last_item->data.text_ptr = new(__len) text_item(__col, __len));
memcpy(last_item->data.text_ptr->text, __line->text + __col, __len); memcpy(last_item->data.text_ptr->text, __line->txt.c_str() + __col, __len);
break; break;
case EDIT_UNDO_CUT_TEXT: case EDIT_UNDO_CUT_TEXT:
last_item->line = __line; last_item->line = __line;
@ -2543,7 +2442,7 @@ void UndoStack::PlayItem() {
// Let user to see the position before performing Undo, unless it's a // Let user to see the position before performing Undo, unless it's a
// neighbour line and the same column. // neighbour line and the same column.
undo_ready = (abs(int(curr_row_num - thisrow)) < 2 and (curr_col_num == col or col+1 > strlen(currline->text))); undo_ready = (abs(int(curr_row_num - thisrow)) < 2 and (curr_col_num == col or col+1 > currline->txt.length()));
// Move cursor up or down depending on where the undo line is, // Move cursor up or down depending on where the undo line is,
// then refresh window if the line is invisible. // then refresh window if the line is invisible.
@ -2569,7 +2468,7 @@ void UndoStack::PlayItem() {
} while(curr_row_num != thisrow); } while(curr_row_num != thisrow);
} }
else else
undo_ready = (abs(int(curr_col_num - col)) < 2 or col+1 > strlen(currline->text)); undo_ready = (abs(int(curr_col_num - col)) < 2 or col+1 > currline->txt.length());
uint _pcol = item->pcol; uint _pcol = item->pcol;
uint _prow = item->prow; uint _prow = item->prow;
@ -2597,13 +2496,15 @@ void UndoStack::PlayItem() {
case EDIT_UNDO_CHAR: case EDIT_UNDO_CHAR:
switch(undo_action) { switch(undo_action) {
case EDIT_UNDO_INS_CHAR: case EDIT_UNDO_INS_CHAR:
editor->strdelchr(currline->text, last_item->col.num); currline->txt.erase(last_item->col.num,1);
break; break;
case EDIT_UNDO_DEL_CHAR: case EDIT_UNDO_DEL_CHAR:
editor->strinschr(currline->text, last_item->data.char_int, last_item->col.num); if(last_item->col.num == currline->txt.length() and last_item->data.char_int != ' ' and last_item->data.char_int != '\n')
currline->txt += ' ';
currline->txt.insert(last_item->col.num, 1, last_item->data.char_int);
break; break;
case EDIT_UNDO_OVR_CHAR: case EDIT_UNDO_OVR_CHAR:
currline->text[last_item->col.num] = last_item->data.char_int; currline->txt[last_item->col.num] = last_item->data.char_int;
break; break;
} }
editor->setlinetype(currline); editor->setlinetype(currline);
@ -2611,27 +2512,22 @@ void UndoStack::PlayItem() {
case EDIT_UNDO_TEXT: { case EDIT_UNDO_TEXT: {
text_item* text_data = last_item->data.text_ptr; text_item* text_data = last_item->data.text_ptr;
char *dest_ptr, *from_ptr, *thistext = currline->text; string& txt = currline->txt;
switch(undo_action) { switch(undo_action) {
case EDIT_UNDO_DEL_TEXT: case EDIT_UNDO_DEL_TEXT:
thistext = currline->text = (char*)throw_realloc(thistext, strlen(thistext) + text_data->len + 1); txt.insert(text_data->col, text_data->text, text_data->len);
memmove(thistext + text_data->col + text_data->len, thistext + text_data->col, strlen(thistext + text_data->col) + 1); throw_delete(text_data);
memcpy(thistext + text_data->col, text_data->text, text_data->len);
delete text_data;
break; break;
case EDIT_UNDO_CUT_TEXT: case EDIT_UNDO_CUT_TEXT:
thistext[last_item->col.num] = NUL; txt.erase(last_item->col.num);
break; break;
case EDIT_UNDO_WRAP_TEXT: case EDIT_UNDO_WRAP_TEXT:
thistext = currline->text = (char*)throw_realloc(thistext, strlen(thistext) + text_data->len + 1); txt.append(currline->next->txt.c_str()+text_data->col, text_data->len);
strncat(thistext, currline->next->text + text_data->col, text_data->len); txt = currline->next->txt;
thistext = currline->next->text;
// fall through... // fall through...
case EDIT_UNDO_INS_TEXT: case EDIT_UNDO_INS_TEXT:
dest_ptr = thistext + text_data->col; txt.erase(text_data->col, text_data->len);
from_ptr = dest_ptr + text_data->len; throw_delete(text_data);
memmove(dest_ptr, from_ptr, strlen(from_ptr) + 1);
delete text_data;
break; break;
} }
editor->setlinetype(currline); editor->setlinetype(currline);
@ -2650,16 +2546,13 @@ void UndoStack::PlayItem() {
} }
else else
currline = thisline->next; currline = thisline->next;
throw_release(thisline->text); throw_xdelete(thisline);
throw_xfree(thisline);
break; break;
case EDIT_UNDO_ORPHAN_LINE: case EDIT_UNDO_ORPHAN_LINE:
if(last_item->action & LAST_LINE) { if(last_item->action & LAST_LINE) {
thisline->prev = currline; thisline->prev = currline;
thisline->next = currline ? currline->next : NULL; thisline->next = currline ? currline->next : NULL;
/*if(row == maxrow) if((row < maxrow) and currline)
down = true;
else*/ if((row < maxrow) and currline)
row++; row++;
} }
else { else {
@ -2730,7 +2623,7 @@ void UndoStack::PlayItem() {
} }
} }
// Move the cursor to EOL if necessary // Move the cursor to EOL if necessary
else if((col+1) > strlen(currline->text)) else if(col+1 > currline->txt.length())
editor->GoEOL(); editor->GoEOL();
undo_ready = YES; undo_ready = YES;
} }

View File

@ -291,7 +291,7 @@ protected:
int dispchar (vchar __ch, int attr=-1); int dispchar (vchar __ch, int attr=-1);
void dispins (); void dispins ();
void displine (Line* __line, uint __row); void displine (Line* __line, uint __row);
void dispstring (char* __string, uint __row, int attr=-1, Line* line=NULL); void dispstring (const char* __string, uint __row, int attr=-1, Line* line=NULL);
int downoneline (uint __row); int downoneline (uint __row);
void editexport (Line* __exportline, int __endat); void editexport (Line* __exportline, int __endat);
Line* findanchor (); Line* findanchor ();
@ -303,7 +303,7 @@ protected:
void editimport (Line* __line, char* __filename, bool imptxt = false); void editimport (Line* __line, char* __filename, bool imptxt = false);
void imptxt (char* __filename, bool imptxt = false); void imptxt (char* __filename, bool imptxt = false);
void insertchar (char __ch); void insertchar (char __ch);
Line* insertlinebelow (Line* __currline, char* __text = NULL, long __batch_mode = 0); Line* insertlinebelow (Line* __currline, const char* __text = NULL, long __batch_mode = 0);
int isempty (Line* __line=NULL); int isempty (Line* __line=NULL);
void killkillbuf (); void killkillbuf ();
void killpastebuf (); void killpastebuf ();
@ -316,8 +316,6 @@ protected:
void setcolor (Line* __line); void setcolor (Line* __line);
void setlinetype (Line* __line); void setlinetype (Line* __line);
void statusline (); void statusline ();
void strdelchr (char* __string, uint __position);
void strinschr (char*& __string, char __ch, uint __position);
void windowclose (); void windowclose ();
void windowopen (); void windowopen ();
Line* wrapit (Line** __currline, uint* __curr_col, uint* __curr_row, int __display=YES); Line* wrapit (Line** __currline, uint* __curr_col, uint* __curr_row, int __display=YES);

View File

@ -109,14 +109,12 @@ void IEclass::windowclose() {
void Edit__killpastebuf() { void Edit__killpastebuf() {
while(Edit__pastebuf) { while(Edit__pastebuf) {
throw_release(Edit__pastebuf->text);
if(Edit__pastebuf->next) { if(Edit__pastebuf->next) {
Edit__pastebuf = Edit__pastebuf->next; Edit__pastebuf = Edit__pastebuf->next;
throw_xrelease(Edit__pastebuf->prev); throw_xdelete(Edit__pastebuf->prev);
}
else {
throw_xrelease(Edit__pastebuf);
} }
else
throw_xdelete(Edit__pastebuf);
} }
} }
@ -126,14 +124,12 @@ void Edit__killpastebuf() {
void Edit__killkillbuf() { void Edit__killkillbuf() {
while(Edit__killbuf) { while(Edit__killbuf) {
throw_release(Edit__killbuf->text);
if(Edit__killbuf->prev) { if(Edit__killbuf->prev) {
Edit__killbuf = Edit__killbuf->prev; Edit__killbuf = Edit__killbuf->prev;
throw_xrelease(Edit__killbuf->next); throw_xdelete(Edit__killbuf->next);
}
else {
throw_xrelease(Edit__killbuf);
} }
else
throw_xdelete(Edit__killbuf);
} }
} }
@ -153,14 +149,12 @@ void IEclass::killkillbuf() {
} }
} }
else { else {
throw_release(Edit__killbuf->text);
if(Edit__killbuf->prev) { if(Edit__killbuf->prev) {
Edit__killbuf = Edit__killbuf->prev; Edit__killbuf = Edit__killbuf->prev;
throw_xrelease(Edit__killbuf->next); throw_xdelete(Edit__killbuf->next);
}
else {
throw_xrelease(Edit__killbuf);
} }
else
throw_xdelete(Edit__killbuf);
} }
} }
} }
@ -222,36 +216,32 @@ void IEclass::DelLtWord() {
GFTRK("EditDelLtWord"); GFTRK("EditDelLtWord");
char* _ptr;
char* _ptr2;
char* _bptr;
if(col == 0) { if(col == 0) {
DelLeft(); DelLeft();
GFTRK(NULL); GFTRK(NULL);
return; return;
} }
_bptr = currline->text; int _ptr, _ptr2;
_ptr = _ptr2 = currline->text + col; _ptr = _ptr2 = col;
_ptr--; _ptr--;
// test test test test test test test test // test test test test test test test test
// test test test test , test test test test // test test test test , test test test test
// test test test test ,, test test test test // test test test test ,, test test test test
if(*_ptr == ' ') { if(currline->txt[_ptr] == ' ') {
while((*_ptr == ' ') and (_bptr < _ptr)) while((currline->txt[_ptr] == ' ') and (_ptr > 0))
_ptr--; _ptr--;
if(*_ptr != ' ') if(currline->txt[_ptr] != ' ')
_ptr++; _ptr++;
} }
else if(isxalnum(*_ptr)) { else if(isxalnum(currline->txt[_ptr])) {
while(isxalnum(*_ptr) and (_bptr < _ptr)) while(isxalnum(currline->txt[_ptr]) and (_ptr > 0))
_ptr--; _ptr--;
while((*_ptr == ' ') and (_bptr < _ptr)) while((currline->txt[_ptr] == ' ') and (_ptr > 0))
_ptr--; _ptr--;
if((*_ptr != ' ') and (_bptr < _ptr)) if((currline->txt[_ptr] != ' ') and (_ptr > 0))
_ptr++; _ptr++;
} }
else { else {
@ -260,11 +250,10 @@ void IEclass::DelLtWord() {
return; return;
} }
col -= (int)(_ptr2-_ptr); col -= _ptr2-_ptr;
Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline, col, _ptr2-_ptr); Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline, col, _ptr2-_ptr);
memmove(_ptr, _ptr2, strlen(_ptr2)+1); currline->txt.erase(_ptr, _ptr2-_ptr);
THROW_CHECKPTR(currline->text);
wrapdel(&currline, &col, &row); wrapdel(&currline, &col, &row);
@ -278,30 +267,28 @@ void IEclass::DelRtWord() {
GFTRK("EditDelRtWord"); GFTRK("EditDelRtWord");
char* _ptr; if((currline->txt.length() == col+1) or (currline->txt[col+1] == '\n')) {
char* _ptr2;
if((currline->text[col+1] == NUL) or (currline->text[col+1] == '\n')) {
DelChar(); DelChar();
GFTRK(NULL); GFTRK(NULL);
return; return;
} }
_ptr = _ptr2 = currline->text + col; int _ptr, _ptr2;
_ptr = _ptr2 = col;
// test test test test, test test test test // test test test test, test test test test
// test test test test, test test test test // test test test test, test test test test
if(*_ptr == ' ') { if(currline->txt[_ptr] == ' ') {
while((*_ptr == ' ') and (*_ptr != '\n') and *_ptr) while(_ptr != currline->txt.length() and currline->txt[_ptr] == ' ')
_ptr++; _ptr++;
} }
else if(isxalnum(*_ptr)) { else if(isxalnum(currline->txt[_ptr])) {
// Delete word // Delete word
while(isxalnum(*_ptr) and (*_ptr != '\n') and *_ptr) while(_ptr != currline->txt.length() and isxalnum(currline->txt[_ptr]))
_ptr++; _ptr++;
// Delete spaces after word // Delete spaces after word
while((*_ptr == ' ') and (*_ptr != '\n') and *_ptr) while(_ptr != currline->txt.length() and currline->txt[_ptr] == ' ')
_ptr++; _ptr++;
} }
else { else {
@ -311,8 +298,7 @@ void IEclass::DelRtWord() {
} }
Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline, col, _ptr-_ptr2); Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline, col, _ptr-_ptr2);
memmove(_ptr2, _ptr, strlen(_ptr2)+1); currline->txt.erase(_ptr2, _ptr-_ptr2);
THROW_CHECKPTR(currline->text);
wrapdel(&currline, &col, &row); wrapdel(&currline, &col, &row);
@ -546,18 +532,19 @@ void IEclass::BlockCopy() {
while(1) { while(1) {
// Allocate a new line // Allocate a new line
Line* _copyline = (Line*)throw_xcalloc(1, sizeof(Line)); Line* _copyline;
// Copy text and type // Copy text and type
if(_prevline == NULL) if(_prevline == NULL)
_copyline->text = throw_strdup(_firstcopyline->text + firstcol); _copyline = new Line(_firstcopyline->txt.c_str() + firstcol);
else else
_copyline->text = throw_strdup(_firstcopyline->text); _copyline = new Line(_firstcopyline->txt.c_str());
throw_xnew(_copyline);
if(_firstcopyline == _lastcopyline) { if(_firstcopyline == _lastcopyline) {
if(_prevline) if(_prevline)
_copyline->text[lastcol] = NUL; _copyline->txt.erase(lastcol);
else else
_copyline->text[lastcol-firstcol] = NUL; _copyline->txt.erase(lastcol-firstcol);
} }
_copyline->type = _firstcopyline->type & ~GLINE_BLOK; _copyline->type = _firstcopyline->type & ~GLINE_BLOK;
@ -643,11 +630,8 @@ void IEclass::BlockDel(Line* anchor) {
// are now pointing where they should // are now pointing where they should
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol); Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol);
char *newtext = (char *)throw_malloc(firstcol+strlen(lastcutline->text)-lastcol+1); firstcutline->txt.erase(firstcol);
strxcpy(newtext, firstcutline->text, firstcol+1); firstcutline->txt += lastcutline->txt.c_str()+lastcol;
strcat(newtext, lastcutline->text+lastcol);
throw_free(firstcutline->text);
firstcutline->text = newtext;
setlinetype(firstcutline); setlinetype(firstcutline);
firstcutline->type &= ~GLINE_BLOK; firstcutline->type &= ~GLINE_BLOK;
blockcol = -1; blockcol = -1;
@ -734,21 +718,20 @@ void IEclass::BlockPaste() {
// For each of the lines in the paste buffer // For each of the lines in the paste buffer
while(_pasteline) { while(_pasteline) {
uint curlen = strlen(currline->text); uint curlen = currline->txt.length();
uint pastelen = strlen(_pasteline->text); uint pastelen = _pasteline->txt.length();
char *newtext = NULL;
if(col > curlen) if(col > curlen)
col = curlen; col = curlen;
if(strchr(_pasteline->text, '\n')) { if(_pasteline->txt.find('\n') != _pasteline->txt.npos) {
// append to current line // append to current line
Undo->PushItem(EDIT_UNDO_DEL_TEXT|BATCH_MODE, currline, col); Undo->PushItem(EDIT_UNDO_DEL_TEXT|BATCH_MODE, currline, col);
Line* _newline = insertlinebelow(currline, currline->text + col, BATCH_MODE); Line* _newline = insertlinebelow(currline, currline->txt.c_str()+col, BATCH_MODE);
currline->text = (char*)throw_realloc(currline->text, pastelen + col + 1); currline->txt.erase(col);
strcpy(currline->text+col, _pasteline->text); currline->txt += _pasteline->txt;
setlinetype(currline); setlinetype(currline);
col = strlen(currline->text); col = currline->txt.length();
wrapins(&currline, &col, &row, NO); wrapins(&currline, &col, &row, NO);
currline = _newline; currline = _newline;
col = 0; col = 0;
@ -757,13 +740,9 @@ void IEclass::BlockPaste() {
} }
else { else {
// insert into current line // insert into current line
newtext = (char*)throw_malloc(curlen + pastelen + 1); currline->txt.insert(col, _pasteline->txt);
strxcpy(newtext, currline->text, col+1);
strcpy(stpcpy(newtext+col, _pasteline->text), currline->text + col);
throw_free(currline->text);
currline->text = newtext;
Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, currline, col, pastelen); Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, currline, col, pastelen);
col += strlen(_pasteline->text); col += _pasteline->txt.length();
wrapins(&currline, &col, &row, NO); wrapins(&currline, &col, &row, NO);
} }
@ -809,8 +788,7 @@ void IEclass::LoadFile() {
// Remove all lines // Remove all lines
while(_line) { while(_line) {
Line* _nextline = _line->next; Line* _nextline = _line->next;
throw_release(_line->text); throw_xdelete(_line);
throw_xfree(_line);
_line = _nextline; _line = _nextline;
} }
@ -837,15 +815,11 @@ void IEclass::LoadFile() {
// Change lines to internal editor format // Change lines to internal editor format
while(_line) { while(_line) {
strtrim(_line->text); strtrim(_line->txt);
if(_line->type & GLINE_HARD) { if(_line->type & GLINE_HARD)
strcat(_line->text, "\n"); _line->txt += "\n";
THROW_CHECKPTR(_line->text); else
} _line->txt += " ";
else {
strcat(_line->text, " ");
THROW_CHECKPTR(_line->text);
}
_line = _line->next; _line = _line->next;
} }
@ -1083,7 +1057,10 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
XlatStr(buf, _parabuf, level, CharTable); XlatStr(buf, _parabuf, level, CharTable);
if(not quoteit) { // Insert a quotestring if asked
if(quoteit)
strins(" > ", buf, 0);
else {
// Invalidate tearline // Invalidate tearline
if(not CFG->invalidate.tearline.first.empty()) if(not CFG->invalidate.tearline.first.empty())
doinvalidate(buf, CFG->invalidate.tearline.first.c_str(), CFG->invalidate.tearline.second.c_str(), true); doinvalidate(buf, CFG->invalidate.tearline.first.c_str(), CFG->invalidate.tearline.second.c_str(), true);
@ -1109,10 +1086,6 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
doinvalidate(buf, CFG->invalidate.xp.first.c_str(), CFG->invalidate.xp.second.c_str()); doinvalidate(buf, CFG->invalidate.xp.first.c_str(), CFG->invalidate.xp.second.c_str());
} }
// Insert a quotestring if asked
if(quoteit)
strins(" > ", buf, 0);
// Replace tabs // Replace tabs
char *ht = buf; char *ht = buf;
while((ht = strchr(ht, '\t')) != NULL) { while((ht = strchr(ht, '\t')) != NULL) {
@ -1129,7 +1102,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// If the paragraph is longer than one line // If the paragraph is longer than one line
uint _wrapmargin = (_newline->type & GLINE_QUOT) ? marginquotes : margintext; uint _wrapmargin = (_newline->type & GLINE_QUOT) ? marginquotes : margintext;
if(strlen(_newline->text) >= _wrapmargin) { if(_newline->txt.length() >= _wrapmargin) {
// Wrap it // Wrap it
uint _tmpcol = 0; uint _tmpcol = 0;
@ -1140,11 +1113,11 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
__line = _newline; __line = _newline;
} }
while(__line->next and __line->next->text) while(__line->next)
__line = __line->next; __line = __line->next;
if(__line->text and __line->text[0] and (__line->text[strlen(__line->text)-1] != '\n')) { if(not __line->txt.empty() and (*(__line->txt.end()-1) != '\n')) {
Undo->PushItem(EDIT_UNDO_INS_CHAR|BATCH_MODE, __line, strlen(__line->text)); Undo->PushItem(EDIT_UNDO_INS_CHAR|BATCH_MODE, __line, __line->txt.length());
strinschr(__line->text, '\n', strlen(__line->text)); __line->txt += '\n';
// Wrap it // Wrap it
uint _tmpcol = 0; uint _tmpcol = 0;
uint _tmprow = 0; uint _tmprow = 0;
@ -1248,8 +1221,8 @@ void IEclass::editexport(Line* __exportline, int __endat) {
fputc('\n', _fp); fputc('\n', _fp);
while((__endat ? __exportline != currline : 1) and __exportline) { while((__endat ? __exportline != currline : 1) and __exportline) {
fputs(__exportline->text, _fp); fputs(__exportline->txt.c_str(), _fp);
if(not strchr(__exportline->text, '\n')) if(__exportline->txt.find('\n') != __exportline->txt.npos)
fputc('\n', _fp); fputc('\n', _fp);
__exportline = __exportline->next; __exportline = __exportline->next;
} }

View File

@ -60,22 +60,10 @@ void IEclass::Clip2Buf() {
} }
// Copy the paragraph to the new line and retype it // Copy the paragraph to the new line and retype it
Line* _newline = __line = insertlinebelow(__line, buf); __line = insertlinebelow(__line, buf);
if(Edit__pastebuf == NULL) if(Edit__pastebuf == NULL)
Edit__pastebuf = _newline; Edit__pastebuf = __line;
setlinetype(_newline); setlinetype(__line);
// If the paragraph is longer than one line
uint _wrapmargin = (_newline->type & GLINE_QUOT) ? marginquotes : margintext;
if(strlen(_newline->text) >= _wrapmargin) {
// Wrap it
uint _tmpcol = 0;
uint _tmprow = 0;
_newline = wrapins(&_newline, &_tmpcol, &_tmprow, NO);
}
__line = _newline;
} }
Undo->undo_enabled = YES; Undo->undo_enabled = YES;
throw_free(buf); throw_free(buf);
@ -86,25 +74,15 @@ void IEclass::Clip2Buf() {
void IEclass::Buf2Clip() { void IEclass::Buf2Clip() {
gclipbrd clipbrd; gclipbrd clipbrd;
int buflen = 0;
Line *_bufline; Line *_bufline;
string clipdata;
for(_bufline = Edit__pastebuf; _bufline; _bufline = _bufline->next) for(_bufline = Edit__pastebuf; _bufline; _bufline = _bufline->next)
buflen += strlen(_bufline->text) + 1; if(not _bufline->txt.empty()) {
clipdata += _bufline->txt;
char *clipdata = (char *)throw_malloc(buflen); if(*(clipdata.end()-1) == '\n')
clipdata.replace(clipdata.end()-1, clipdata.end(), "\r\n");
char *curptr = clipdata;
*curptr = NUL;
for(_bufline = Edit__pastebuf; _bufline; _bufline = _bufline->next) {
strcpy(curptr, _bufline->text);
if(*curptr) {
curptr += strlen(curptr) - 1;
if(*curptr == '\n') strcpy(curptr, "\r\n");
}
curptr += strlen(curptr);
} }
clipbrd.writeclipbrd(clipdata); clipbrd.writeclipbrd(clipdata.c_str());
throw_free(clipdata);
} }

View File

@ -592,9 +592,9 @@ static int frqchkdesc(char* desc) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
static int frqgetfile(char* file, char* desc, char* filesize, char* txt) { static int frqgetfile(char* file, char* desc, char* filesize, const char* txt) {
char* ptr = txt; const char* ptr = txt;
// Scan filename for first invalid char (.extension) // Scan filename for first invalid char (.extension)
while(*ptr and not invalidfilechar(*ptr)) while(*ptr and not invalidfilechar(*ptr))
@ -626,7 +626,7 @@ static int frqgetfile(char* file, char* desc, char* filesize, char* txt) {
while(strchr(CFG__frqskipwordchars, *ptr) and *ptr) { while(strchr(CFG__frqskipwordchars, *ptr) and *ptr) {
if(not *filesize) { if(not *filesize) {
// is a file-size given? // is a file-size given?
char* p = ptr; const char* p = ptr;
while(strchr(".,0123456789bBkKmMgG", *p)) while(strchr(".,0123456789bBkKmMgG", *p))
p++; p++;
@ -669,10 +669,10 @@ void FileRequest(GMsg* msg) {
if(AA->Msgn.Count() and msg->line and msg->lines) { if(AA->Msgn.Count() and msg->line and msg->lines) {
char buf[256]; char buf[256];
char* ptr; const char* ptr;
char* ptr1; const char* ptr1 = NULL;
char* ptr2; const char* ptr2;
char* txtptr; const char* txtptr;
char** freqfile = NULL; char** freqfile = NULL;
int gotticket = false; int gotticket = false;
int getnextdesc = false; int getnextdesc = false;
@ -697,7 +697,7 @@ void FileRequest(GMsg* msg) {
if(lin[n]->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG)) if(lin[n]->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))
continue; continue;
ptr = txtptr = lin[n]->text; ptr = txtptr = lin[n]->txt.c_str();
// Skip past whitespace and highbit junk // Skip past whitespace and highbit junk
while(((*ptr < '!') or (*ptr > '\x7F')) and *ptr) while(((*ptr < '!') or (*ptr > '\x7F')) and *ptr)
@ -727,8 +727,9 @@ void FileRequest(GMsg* msg) {
else else
ptr1 = ptr2; ptr1 = ptr2;
ptr2 = strskip_txt(ptr1); ptr2 = strskip_txt(ptr1);
*ptr2 = NUL; __extension__ char tmpbuf[ptr2-ptr1+1];
frqgetfile(file, desc, filesize, ptr1); strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
frqgetfile(file, desc, filesize, tmpbuf);
*desc = NUL; // Description never comes before filename *desc = NUL; // Description never comes before filename
continue; continue;
} }
@ -764,8 +765,9 @@ void FileRequest(GMsg* msg) {
if(txtptr[16] == '/' and txtptr[19] == '/' and txtptr[24] == '(' /*)*/) { if(txtptr[16] == '/' and txtptr[19] == '/' and txtptr[24] == '(' /*)*/) {
ptr1 = strskip_wht(txtptr); ptr1 = strskip_wht(txtptr);
ptr2 = strskip_txt(ptr1); ptr2 = strskip_txt(ptr1);
*ptr2 = NUL; __extension__ char tmpbuf[ptr2-ptr1+1];
frqgetfile(file, desc, filesize, ptr1); strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
frqgetfile(file, desc, filesize, tmpbuf);
*desc = NUL; // Description never comes before filename *desc = NUL; // Description never comes before filename
gotticket = true; gotticket = true;
continue; continue;
@ -802,7 +804,7 @@ void FileRequest(GMsg* msg) {
for(e = CFG->frqext.begin(); e != CFG->frqext.end(); e++) { for(e = CFG->frqext.begin(); e != CFG->frqext.end(); e++) {
if(strnicmpw(e->c_str(), ptr2, MinV(e->length(), strlen(ptr2))) == 0) { if(strnicmpw(e->c_str(), ptr2, MinV(e->length(), strlen(ptr2))) == 0) {
// Find beginning of filename // Find beginning of filename
char* ptr3 = ptr2-1; const char* ptr3 = ptr2-1;
while((ptr3 > ptr) and not invalidfilechar(*ptr3)) while((ptr3 > ptr) and not invalidfilechar(*ptr3))
ptr3--; ptr3--;
if(invalidfilechar(*ptr3)) if(invalidfilechar(*ptr3))
@ -895,13 +897,14 @@ void FileRequest(GMsg* msg) {
msg->attr.frq1(); msg->attr.frq1();
ptr = freqfile[n]+1; // 01234567890123456 ptr = freqfile[n]+1; // 01234567890123456
ptr2 = strskip_txt(ptr); ptr2 = strskip_txt(ptr);
*ptr2++ = NUL; __extension__ char tmpbuf[ptr2-ptr1+1];
strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
ptr2 = strskip_wht(ptr2); ptr2 = strskip_wht(ptr2);
if((strlen(msg->re) + strlen(ptr)) < sizeof(ISub)) { // We can only fill one subject line in this version... if((strlen(msg->re) + strlen(tmpbuf)) < sizeof(ISub)) { // We can only fill one subject line in this version...
strcat(msg->re, ptr); strcat(msg->re, tmpbuf);
strcat(msg->re, " "); strcat(msg->re, " ");
if(fh != -1) { if(fh != -1) {
sprintf(buf, "%-12s %s\n", ptr, ptr2); sprintf(buf, "%-12s %s\n", tmpbuf, ptr2);
write(fh, buf, strlen(buf)); write(fh, buf, strlen(buf));
} }
freqs++; freqs++;
@ -913,13 +916,14 @@ void FileRequest(GMsg* msg) {
msg->attr.frq1(); msg->attr.frq1();
ptr = freqfile[crsr]+1; // 01234567890123456 ptr = freqfile[crsr]+1; // 01234567890123456
ptr2 = strskip_txt(ptr); ptr2 = strskip_txt(ptr);
*ptr2++ = NUL; __extension__ char tmpbuf[ptr2-ptr1+1];
strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
ptr2 = strskip_wht(ptr2); ptr2 = strskip_wht(ptr2);
if((strlen(msg->re) + strlen(ptr)) < sizeof(ISub)) { // We can only fill one subject line in this version... if((strlen(msg->re) + strlen(tmpbuf)) < sizeof(ISub)) { // We can only fill one subject line in this version...
strcat(msg->re, ptr); strcat(msg->re, tmpbuf);
strcat(msg->re, " "); strcat(msg->re, " ");
if(fh != -1) { if(fh != -1) {
sprintf(buf, "%-12s %s\n", ptr, ptr2); sprintf(buf, "%-12s %s\n", tmpbuf, ptr2);
write(fh, buf, strlen(buf)); write(fh, buf, strlen(buf));
} }
freqs++; freqs++;

View File

@ -445,7 +445,7 @@ char* strxmimecpy(char* dest, const char* source, int level, int size, bool dete
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeAREA(GMsg* msg, char* echoid) { static void KludgeAREA(GMsg* msg, const char* echoid) {
Area* ap = AL.AreaEchoToPtr(echoid); Area* ap = AL.AreaEchoToPtr(echoid);
if(ap) if(ap)
@ -455,7 +455,7 @@ void KludgeAREA(GMsg* msg, char* echoid) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeINTL(GMsg* msg, char* ptr) { static void KludgeINTL(GMsg* msg, const char* ptr) {
char buf1[201], buf2[201]; char buf1[201], buf2[201];
word fmpt = msg->orig.point; word fmpt = msg->orig.point;
@ -470,7 +470,7 @@ void KludgeINTL(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFMPT(GMsg* msg, char* ptr) { static void KludgeFMPT(GMsg* msg, const char* ptr) {
msg->orig.point = atow(ptr); msg->orig.point = atow(ptr);
} }
@ -478,7 +478,7 @@ void KludgeFMPT(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeTOPT(GMsg* msg, char* ptr) { static void KludgeTOPT(GMsg* msg, const char* ptr) {
msg->dest.point = atow(ptr); msg->dest.point = atow(ptr);
} }
@ -486,7 +486,7 @@ void KludgeTOPT(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeMSGID(GMsg* msg, char* ptr) { static void KludgeMSGID(GMsg* msg, const char* ptr) {
strxcpy(msg->msgids, ptr, sizeof(msg->msgids)); strxcpy(msg->msgids, ptr, sizeof(msg->msgids));
msg->msgid.reset(msg->msgids, msg->odom); msg->msgid.reset(msg->msgids, msg->odom);
@ -495,7 +495,7 @@ void KludgeMSGID(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeREPLY(GMsg* msg, char* ptr) { static void KludgeREPLY(GMsg* msg, const char* ptr) {
strxcpy(msg->replys, ptr, sizeof(msg->replys)); strxcpy(msg->replys, ptr, sizeof(msg->replys));
} }
@ -503,7 +503,7 @@ void KludgeREPLY(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeDOMAIN(GMsg* msg, char* ptr) { static void KludgeDOMAIN(GMsg* msg, const char* ptr) {
char buf1[201], buf2[201]; char buf1[201], buf2[201];
sscanf(ptr, "%s %s %s %s", msg->ddom, buf1, msg->odom, buf2); sscanf(ptr, "%s %s %s %s", msg->ddom, buf1, msg->odom, buf2);
@ -514,7 +514,7 @@ void KludgeDOMAIN(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFLAGS(GMsg* msg, char* ptr) { static void KludgeFLAGS(GMsg* msg, const char* ptr) {
GetAttribstr(&msg->attr, ptr); GetAttribstr(&msg->attr, ptr);
} }
@ -522,7 +522,7 @@ void KludgeFLAGS(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeMSGTO(GMsg* msg, char* ptr) { static void KludgeMSGTO(GMsg* msg, const char* ptr) {
msg->dest.reset(ptr, msg->ddom); msg->dest.reset(ptr, msg->ddom);
} }
@ -530,7 +530,7 @@ void KludgeMSGTO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgePID(GMsg* msg, char* ptr) { static void KludgePID(GMsg* msg, const char* ptr) {
strxcpy(msg->pid, ptr, sizeof(msg->pid)); strxcpy(msg->pid, ptr, sizeof(msg->pid));
@ -544,7 +544,7 @@ void KludgePID(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeREPLYADDR(GMsg* msg, char* ptr) { static void KludgeREPLYADDR(GMsg* msg, const char* ptr) {
Name name; Name name;
name[0] = NUL; name[0] = NUL;
@ -558,7 +558,7 @@ void KludgeREPLYADDR(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeREPLYTO(GMsg* msg, char* ptr) { static void KludgeREPLYTO(GMsg* msg, const char* ptr) {
strcpy(msg->igate, ptr); strcpy(msg->igate, ptr);
} }
@ -566,7 +566,7 @@ void KludgeREPLYTO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFROM(GMsg* msg, char* ptr) { static void KludgeFROM(GMsg* msg, const char* ptr) {
INam fromname; INam fromname;
IAdr fromaddr; IAdr fromaddr;
@ -581,7 +581,7 @@ void KludgeFROM(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeTO(GMsg* msg, char* ptr) { static void KludgeTO(GMsg* msg, const char* ptr) {
INam _toname; INam _toname;
IAdr _toaddr; IAdr _toaddr;
@ -598,7 +598,7 @@ void KludgeTO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeBCC(GMsg* msg, char* ptr) { static void KludgeBCC(GMsg* msg, const char* ptr) {
char* ibcc = msg->ibcc; char* ibcc = msg->ibcc;
char* buf = (char*)throw_malloc(strlen(ibcc) + strlen(ptr) + 3); char* buf = (char*)throw_malloc(strlen(ibcc) + strlen(ptr) + 3);
@ -610,7 +610,7 @@ void KludgeBCC(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeCC(GMsg* msg, char* ptr) { static void KludgeCC(GMsg* msg, const char* ptr) {
char* icc = msg->icc; char* icc = msg->icc;
char* buf = (char*)throw_malloc(strlen(icc) + strlen(ptr) + 3); char* buf = (char*)throw_malloc(strlen(icc) + strlen(ptr) + 3);
@ -622,7 +622,7 @@ void KludgeCC(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeREPLY_TO(GMsg* msg, char* ptr) { static void KludgeREPLY_TO(GMsg* msg, const char* ptr) {
INam _rtname; INam _rtname;
IAdr _rtaddr; IAdr _rtaddr;
@ -636,7 +636,7 @@ void KludgeREPLY_TO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeSUBJECT(GMsg* msg, char* ptr) { static void KludgeSUBJECT(GMsg* msg, const char* ptr) {
char* buf = throw_strdup(ptr); char* buf = throw_strdup(ptr);
if(not msg->attr.att()) if(not msg->attr.att())
@ -647,7 +647,7 @@ void KludgeSUBJECT(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeTZUTC(GMsg* msg, char* ptr) { static void KludgeTZUTC(GMsg* msg, const char* ptr) {
msg->tzutc = atoi(ptr); msg->tzutc = atoi(ptr);
} }
@ -655,7 +655,7 @@ void KludgeTZUTC(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeDATE(GMsg* msg, char* ptr) { void KludgeDATE(GMsg* msg, const char* ptr) {
// RFC822 Date: BNF // RFC822 Date: BNF
// //
@ -722,10 +722,7 @@ void KludgeDATE(GMsg* msg, char* ptr) {
// Setting timezone // Setting timezone
ptr = strskip_wht(strskip_digits(ptr)); ptr = strskip_wht(strskip_digits(ptr));
if(*ptr) { if(*ptr) {
if(*ptr == '(' /*)*/ ) { if(*ptr == '(' /*)*/ ) ++ptr;
char* p;
if((p = strskip_to(++ptr, /*(*/ ')')) != NULL) *p = 0;
}
msg->tzutc = atoi(ptr); msg->tzutc = atoi(ptr);
} }
} }
@ -755,7 +752,7 @@ void KludgeDATE(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeMESSAGE_ID(GMsg* msg, char* ptr) { static void KludgeMESSAGE_ID(GMsg* msg, const char* ptr) {
char buf[201]; char buf[201];
throw_free(msg->messageid); throw_free(msg->messageid);
@ -767,7 +764,7 @@ void KludgeMESSAGE_ID(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeREFERENCES(GMsg* msg, char* ptr) { static void KludgeREFERENCES(GMsg* msg, const char* ptr) {
throw_free(msg->references); throw_free(msg->references);
msg->references = throw_strdup(ptr); msg->references = throw_strdup(ptr);
@ -776,7 +773,7 @@ void KludgeREFERENCES(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeIN_REPLY_TO(GMsg* msg, char* ptr) { static void KludgeIN_REPLY_TO(GMsg* msg, const char* ptr) {
throw_free(msg->inreplyto); throw_free(msg->inreplyto);
msg->inreplyto = throw_strdup(ptr); msg->inreplyto = throw_strdup(ptr);
@ -785,7 +782,7 @@ void KludgeIN_REPLY_TO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeORGANIZATION(GMsg* msg, char* ptr) { static void KludgeORGANIZATION(GMsg* msg, const char* ptr) {
strxcpy(msg->organization, ptr, sizeof(msg->organization)); strxcpy(msg->organization, ptr, sizeof(msg->organization));
} }
@ -793,7 +790,7 @@ void KludgeORGANIZATION(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeX_FTN_TO(GMsg* msg, char* ptr) { static void KludgeX_FTN_TO(GMsg* msg, const char* ptr) {
strxcpy(msg->realto, ptr, sizeof(msg->realto)); strxcpy(msg->realto, ptr, sizeof(msg->realto));
} }
@ -801,7 +798,7 @@ void KludgeX_FTN_TO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDFROM(GMsg* msg, char* ptr) { static void KludgeFWDFROM(GMsg* msg, const char* ptr) {
strxcpy(msg->fwdfrom, ptr, sizeof(msg->fwdfrom)); strxcpy(msg->fwdfrom, ptr, sizeof(msg->fwdfrom));
} }
@ -809,7 +806,7 @@ void KludgeFWDFROM(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDORIG(GMsg* msg, char* ptr) { static void KludgeFWDORIG(GMsg* msg, const char* ptr) {
msg->fwdorig.reset(ptr); msg->fwdorig.reset(ptr);
} }
@ -817,7 +814,7 @@ void KludgeFWDORIG(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDTO(GMsg* msg, char* ptr) { static void KludgeFWDTO(GMsg* msg, const char* ptr) {
strxcpy(msg->fwdto, ptr, sizeof(msg->fwdto)); strxcpy(msg->fwdto, ptr, sizeof(msg->fwdto));
} }
@ -825,7 +822,7 @@ void KludgeFWDTO(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDDEST(GMsg* msg, char* ptr) { static void KludgeFWDDEST(GMsg* msg, const char* ptr) {
msg->fwddest.reset(ptr); msg->fwddest.reset(ptr);
} }
@ -833,7 +830,7 @@ void KludgeFWDDEST(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDSUBJ(GMsg* msg, char* ptr) { static void KludgeFWDSUBJ(GMsg* msg, const char* ptr) {
strxcpy(msg->fwdsubj, ptr, sizeof(msg->fwdsubj)); strxcpy(msg->fwdsubj, ptr, sizeof(msg->fwdsubj));
} }
@ -841,7 +838,7 @@ void KludgeFWDSUBJ(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDAREA(GMsg* msg, char* ptr) { static void KludgeFWDAREA(GMsg* msg, const char* ptr) {
strxcpy(msg->fwdarea, ptr, sizeof(msg->fwdarea)); strxcpy(msg->fwdarea, ptr, sizeof(msg->fwdarea));
} }
@ -849,7 +846,7 @@ void KludgeFWDAREA(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeFWDMSGID(GMsg* msg, char* ptr) { static void KludgeFWDMSGID(GMsg* msg, const char* ptr) {
strxcpy(msg->fwdmsgid, ptr, sizeof(msg->fwdmsgid)); strxcpy(msg->fwdmsgid, ptr, sizeof(msg->fwdmsgid));
} }
@ -857,20 +854,20 @@ void KludgeFWDMSGID(GMsg* msg, char* ptr) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char* UnwrapLine(Line* line, char* ptr, int addspace = false) { char* UnwrapLine(Line* line, const char* ptr, int addspace = false) {
if(line->type & GLINE_WRAP) { if(line->type & GLINE_WRAP) {
uint len = strlen(ptr); uint len = strlen(ptr);
char* uptr = throw_strdup(ptr); char* uptr = throw_strdup(ptr);
while(line and (line->type & GLINE_WRAP)) { while(line and (line->type & GLINE_WRAP)) {
if(line->next) { if(line->next) {
uint nextlen = strlen(line->next->text); uint nextlen = line->next->txt.length();
uptr = (char*)throw_realloc(uptr, len+nextlen+2); uptr = (char*)throw_realloc(uptr, len+nextlen+2);
if(addspace and len and (uptr[len-1] != ' ')) { if(addspace and len and (uptr[len-1] != ' ')) {
strcat(uptr, " "); strcat(uptr, " ");
len++; len++;
} }
strcpy(uptr+len, line->next->text); strcpy(uptr+len, line->next->txt.c_str());
len += nextlen; len += nextlen;
} }
line = line->next; line = line->next;
@ -884,7 +881,7 @@ char* UnwrapLine(Line* line, char* ptr, int addspace = false) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int HandleKludges(GMsg* msg, Line* line, int kludgenum, char* ptr, int getvalue) { static int HandleKludges(GMsg* msg, Line* line, int kludgenum, const char* ptr, int getvalue) {
switch(kludgenum) { switch(kludgenum) {
@ -1100,7 +1097,7 @@ int HandleKludges(GMsg* msg, Line* line, int kludgenum, char* ptr, int getvalue)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int HandleRFCs(GMsg* msg, Line* line, int kludgenum, char* ptr, int getvalue) { int HandleRFCs(GMsg* msg, Line* line, int kludgenum, const char* ptr, int getvalue) {
switch(kludgenum) { switch(kludgenum) {
@ -1308,26 +1305,28 @@ int ScanCtrlList(Kludges* k, char* kludge, char endchar) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int ScanLine(GMsg* msg, Line* line, char* ptr, int getvalue, int mask) { int ScanLine(GMsg* msg, Line* line, const char* ptr, int getvalue, int mask) {
// Kludge number // Kludge number
int kludgenum = 0; int kludgenum = 0;
// Pointer to kludge id // Pointer to kludge id
char* kludge = ptr; const char* kludge1 = ptr;
// Skip past "RFC" string, if any // Skip past "RFC" string, if any
if(strnieql(kludge, "RFC", 3) and (kludge[3] != ':')) { if(strnieql(kludge1, "RFC", 3) and (kludge1[3] != ':')) {
kludge += 3; kludge1 += 3;
if(not isalpha(*kludge)) if(not isalpha(*kludge1))
kludge++; kludge1++;
} }
// Keep copy of id terminating char // Keep copy of id terminating char
while((*ptr != ' ') and (*ptr != ':') and *ptr) while((*ptr != ' ') and (*ptr != ':') and *ptr)
ptr++; ptr++;
char endchar = *ptr; char endchar = *ptr;
*ptr = NUL;
__extension__ char kludge[ptr-kludge1+1];
strxcpy(kludge, kludge1, ptr-kludge1+1);
// Search for it in the known kludges list // Search for it in the known kludges list
if(*kludge) { if(*kludge) {
@ -1362,7 +1361,6 @@ int ScanLine(GMsg* msg, Line* line, char* ptr, int getvalue, int mask) {
} }
// Restore terminating char // Restore terminating char
*ptr = endchar;
if(*ptr != ' ') if(*ptr != ' ')
ptr++; ptr++;
@ -1402,7 +1400,7 @@ Line* next_non_empty(Line *line) {
Line* nl = line; Line* nl = line;
while(nl) { while(nl) {
if(nl->text and not *nl->text) if(nl->txt.empty())
nl = nl->next; nl = nl->next;
else else
break; break;
@ -1414,7 +1412,7 @@ Line* next_non_empty(Line *line) {
void ScanKludges(GMsg* msg, int getvalue) { void ScanKludges(GMsg* msg, int getvalue) {
char* ptr; const char* ptr;
int tearlineno = INT_MAX; int tearlineno = INT_MAX;
int originlineno = INT_MAX; int originlineno = INT_MAX;
int gotorig=NO, gottear=NO, gottag=NO; int gotorig=NO, gottear=NO, gottag=NO;
@ -1430,7 +1428,7 @@ void ScanKludges(GMsg* msg, int getvalue) {
Line* line = LastLine(msg->lin); Line* line = LastLine(msg->lin);
do { do {
ptr = line->text; ptr = line->txt.c_str();
if(*ptr == CTRL_A) { if(*ptr == CTRL_A) {
// Set kludge/hidden color // Set kludge/hidden color
@ -1444,11 +1442,11 @@ void ScanKludges(GMsg* msg, int getvalue) {
} }
else { else {
if(strneql(ptr, "AREA:", 5) and ((line->prev == NULL) or line->prev->text[0] == CTRL_A)) { if(strneql(ptr, "AREA:", 5) and (line->prev == NULL or *line->prev->txt.c_str() == CTRL_A)) {
line->color = C_READK; line->color = C_READK;
line->kludge = GKLUD_AREA; line->kludge = GKLUD_AREA;
line->type |= GLINE_KLUD; line->type |= GLINE_KLUD;
char* areakludgeptr = ptr+5; // Extract echoid from kludge const char* areakludgeptr = ptr+5; // Extract echoid from kludge
areakludgeptr = strskip_wht(areakludgeptr); areakludgeptr = strskip_wht(areakludgeptr);
Area* ap = AL.AreaEchoToPtr(areakludgeptr); Area* ap = AL.AreaEchoToPtr(areakludgeptr);
if(ap) if(ap)
@ -1515,20 +1513,20 @@ void ScanKludges(GMsg* msg, int getvalue) {
else if(not (gotorig or gottear or gottag) and strneql(" * Origin: ", ptr, 11)) { else if(not (gotorig or gottear or gottag) and strneql(" * Origin: ", ptr, 11)) {
// Found Origin line // Found Origin line
bool cnd = line->next and line->next->text; bool cnd = line->next != NULL;
Line* nnel = next_non_empty(line->next); Line* nnel = next_non_empty(line->next);
bool nextkl = cnd ? not nnel or nnel->type & GLINE_KLUDGE : false; bool nextkl = cnd ? not nnel or nnel->type & GLINE_KLUDGE : false;
nnel = cnd ? next_non_empty(line->next->next) : NULL; nnel = cnd ? next_non_empty(line->next->next) : NULL;
bool nextor = cnd ? (not nnel or nnel->type & GLINE_KLUDGE) and strchr(line->next->text, ')') : false; bool nextor = cnd ? (not nnel or nnel->type & GLINE_KLUDGE) and (line->next->txt.find(/*(*/')') != line->next->txt.npos) : false;
if(not line->next or nextkl or nextor) { if(not line->next or nextkl or nextor) {
gotorig = YES; gotorig = YES;
originlineno = lineno; originlineno = lineno;
line->type |= GLINE_ORIG; line->type |= GLINE_ORIG;
line->color = C_READO; line->color = C_READO;
strcpy(msg->origin, line->text+11); strcpy(msg->origin, line->txt.c_str()+11);
if(nextor) { // Get the next line too if(nextor) { // Get the next line too
strcat(msg->origin, line->next->text); strcat(msg->origin, line->next->txt.c_str());
line->next->color = C_READO; line->next->color = C_READO;
line->next->type |= GLINE_ORIG; // Mark next line as Origin too line->next->type |= GLINE_ORIG; // Mark next line as Origin too
} }
@ -1550,7 +1548,7 @@ void ScanKludges(GMsg* msg, int getvalue) {
q->type |= GLINE_SIGN; q->type |= GLINE_SIGN;
if(q != line) if(q != line)
q->type |= GLINE_HARD; q->type |= GLINE_HARD;
if(q->text and strneql("----", q->text, 4)) if(strneql("----", q->txt.c_str(), 4))
break; break;
} }
} }
@ -1577,9 +1575,9 @@ void ScanKludges(GMsg* msg, int getvalue) {
for(line = msg->lin; line; line = line->next) for(line = msg->lin; line; line = line->next)
if(line->type & GLINE_KLUDGE) if(line->type & GLINE_KLUDGE)
continue; continue;
else if(line->text) { else {
if(strnieql(line->text, "From:", 5)) { if(strnieql(line->txt.c_str(), "From:", 5)) {
char* ptr = line->text + 5; const char* ptr = line->txt.c_str() + 5;
ptr = strskip_wht(ptr); ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr); char* tmp = UnwrapLine(line, ptr);
KludgeFROM(msg, tmp ? tmp : ptr); KludgeFROM(msg, tmp ? tmp : ptr);
@ -1588,8 +1586,8 @@ void ScanKludges(GMsg* msg, int getvalue) {
if(not AA->isinternet()) if(not AA->isinternet())
*msg->ifrom = NUL; *msg->ifrom = NUL;
} }
else if(strnieql(line->text, "To:", 3)) { else if(strnieql(line->txt.c_str(), "To:", 3)) {
char* ptr = line->text + 3; const char* ptr = line->txt.c_str() + 3;
ptr = strskip_wht(ptr); ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr); char* tmp = UnwrapLine(line, ptr);
KludgeTO(msg, tmp ? tmp : ptr); KludgeTO(msg, tmp ? tmp : ptr);
@ -1601,8 +1599,6 @@ void ScanKludges(GMsg* msg, int getvalue) {
else else
break; break;
} }
else
break;
if(not gottag) if(not gottag)
*msg->tagline = NUL; *msg->tagline = NUL;
@ -1640,7 +1636,7 @@ void ScanKludges(GMsg* msg, int getvalue) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char* XlatStr(char* dest, char* src, int level, Chs* chrtbl, int qpencoded, bool i51) { char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded, bool i51) {
if(not chrtbl) if(not chrtbl)
return stpcpy(dest, src); return stpcpy(dest, src);
@ -1650,7 +1646,7 @@ char* XlatStr(char* dest, char* src, int level, Chs* chrtbl, int qpencoded, bool
int translated; int translated;
char* tptr; char* tptr;
char* escp; char* escp;
char* sptr = src; const char* sptr = src;
char* dptr = dest; char* dptr = dest;
char dochar; char dochar;
ChsTab* chrs = chrtbl ? chrtbl->t : (ChsTab*)NULL; ChsTab* chrs = chrtbl ? chrtbl->t : (ChsTab*)NULL;
@ -1880,8 +1876,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
line = msg->lin; line = msg->lin;
while(line) { while(line) {
nextline = line->next; nextline = line->next;
throw_release(line->text); throw_xdelete(line);
throw_xfree(line);
line = nextline; line = nextline;
} }
@ -1924,7 +1919,8 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
} }
} }
line = msg->lin = (Line*)throw_xcalloc(1, sizeof(Line)); line = msg->lin = new Line();
throw_xnew(line);
ptr = spanfeeds(ptr); ptr = spanfeeds(ptr);
@ -2118,7 +2114,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
if(wraps and not ((line->type & GLINE_HARD) and not (line->type & GLINE_QUOT))) { if(wraps and not ((line->type & GLINE_HARD) and not (line->type & GLINE_QUOT))) {
if(para != GLINE_QUOT) { if(para != GLINE_QUOT) {
if(quoteflag) { if(quoteflag) {
if(prevline and prevline->text[0] == CTRL_A and prevline->type & GLINE_WRAP) { if(prevline and *prevline->txt.c_str() == CTRL_A and prevline->type & GLINE_WRAP) {
wraps = 0; wraps = 0;
break; break;
} }
@ -2384,7 +2380,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
else else
line->type |= GLINE_HARD; line->type |= GLINE_HARD;
*(bp+1) = NUL; *(++bp/*+1*/) = NUL;
// Get line length // Get line length
uint tmplinelength = (uint)((long)bp-(long)bptr); uint tmplinelength = (uint)((long)bp-(long)bptr);
@ -2396,32 +2392,28 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
} }
// Store line // Store line
if(line->isallocated()) line->txt = linetmp+1; // .assign(linetmp+1, tmplinelength+5);
throw_free(line->text); prev_ptr[0] = line->txt.empty() ? 0xFF : line->txt[0];
line->text = (char*)throw_malloc(tmplinelength+10); prev_ptr[1] = line->txt.length() < 2 ? 0xFF : line->txt[1];
line->type &= ~GLINE_NOAL;
memcpy(line->text, linetmp+1, tmplinelength+5);
prev_ptr[0] = line->text[0];
prev_ptr[1] = line->text[1];
// Set line color and type // Set line color and type
if((line->type & GLINE_QUOT) and not is_quote(line->text)) if((line->type & GLINE_QUOT) and not is_quote(line->txt.c_str()))
line->type ^= GLINE_QUOT; line->type ^= GLINE_QUOT;
if(line->type & GLINE_QUOT) if(line->type & GLINE_QUOT)
line->color = quotecolor(line->text); line->color = quotecolor(line->txt.c_str());
else if(inheader) else if(inheader)
line->color = C_READT; line->color = C_READT;
else else
line->color = C_READW; line->color = C_READW;
// Scan msg body top for RFC headerlines // Scan msg body top for RFC headerlines
if((*line->text == NUL) and not firstemptyline) { if(line->txt.empty() and not firstemptyline) {
firstemptyline = true; firstemptyline = true;
if(AA->Internetrfcbody()) { if(AA->Internetrfcbody()) {
Line* linep = FirstLine(line); Line* linep = FirstLine(line);
int headerlines = 0; int headerlines = 0;
while(linep) { while(linep) {
char* tptr = linep->text; const char* tptr = linep->txt.c_str();
if(*tptr) { if(*tptr) {
if(*tptr != CTRL_A) { if(*tptr != CTRL_A) {
int kludgetype = ScanLine(msg, linep, tptr, getvalue, MASK_RFC); int kludgetype = ScanLine(msg, linep, tptr, getvalue, MASK_RFC);
@ -2441,7 +2433,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
gotmime = true; gotmime = true;
} }
else { else {
const char* keptr = linep->next ? linep->next->text : " "; const char* keptr = linep->next ? linep->next->txt.c_str() : " ";
if(check_multipart(ptr, keptr, boundary)) { if(check_multipart(ptr, keptr, boundary)) {
gotmultipart = true; gotmultipart = true;
gotmime = true; gotmime = true;
@ -2492,13 +2484,13 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
else else
linep->color = C_READK; linep->color = C_READK;
if(linep->next) { if(linep->next) {
char lwsp = *linep->next->text; char lwsp = *linep->next->txt.c_str();
while((lwsp == ' ') or (lwsp == '\t') or (linep->type & GLINE_WRAP)) { while((lwsp == ' ') or (lwsp == '\t') or (linep->type & GLINE_WRAP)) {
linep = linep->next; linep = linep->next;
linep->type |= linep->prev->type; linep->type |= linep->prev->type;
linep->color = linep->prev->color; linep->color = linep->prev->color;
if(linep->next) if(linep->next)
lwsp = *linep->next->text; lwsp = *linep->next->txt.c_str();
else else
break; break;
} }
@ -2526,16 +2518,15 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
} }
prevline = line; prevline = line;
line = (Line*)throw_xcalloc(1, sizeof(Line)); line = new Line();
throw_xnew(line);
line->prev = prevline; line->prev = prevline;
ptr = spanfeeds(ptr); ptr = spanfeeds(ptr);
} }
throw_release(linetmp); throw_release(linetmp);
if(line->isallocated()) throw_xdelete(line);
throw_free(line->text);
throw_xfree(line);
// Scan for kludge-, tear- and originlines // Scan for kludge-, tear- and originlines
ScanKludges(msg, getvalue); ScanKludges(msg, getvalue);
@ -2579,7 +2570,7 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
msg->lines++; msg->lines++;
if(line->next) { if(line->next) {
if(line->type & GLINE_QUOT) { if(line->type & GLINE_QUOT) {
if(not (line->next->type & GLINE_QUOT) and not strblank(line->next->text)) { if(not (line->next->type & GLINE_QUOT) and not strblank(line->next->txt.c_str())) {
if(CFG->switches.get(quotespacing)) { if(CFG->switches.get(quotespacing)) {
line = AddLine(line, ""); line = AddLine(line, "");
msg->lines++; msg->lines++;
@ -2587,10 +2578,12 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
} }
} }
else { else {
if(msg->attr.pos()) const char *posn, *posn2 = line->txt.c_str();
if(strischg(line->text, "@position", "")) if(msg->attr.pos() and ((posn = striinc("@position", posn2)) != NULL)) {
line->txt.erase(posn - posn2, 9);
line->type |= GLINE_POSI; line->type |= GLINE_POSI;
if((line->next->type & GLINE_QUOT) and not strblank(line->text)) { }
if((line->next->type & GLINE_QUOT) and not strblank(line->txt.c_str())) {
if(CFG->switches.get(quotespacing)) { if(CFG->switches.get(quotespacing)) {
line = AddLine(line, ""); line = AddLine(line, "");
msg->lines++; msg->lines++;
@ -2632,15 +2625,15 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
} }
else if(line->type & GLINE_QUOT) { else if(line->type & GLINE_QUOT) {
if(not viewquote) { if(not viewquote) {
GetQuotestr(line->text, qbuf, &qlen); GetQuotestr(line->txt.c_str(), qbuf, &qlen);
strtrim(qbuf); strtrim(qbuf);
if(strieql(qbuf0, qbuf)) { if(strieql(qbuf0, qbuf)) {
if(strpbrk(line->text+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) if(strpbrk(line->txt.c_str()+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
qmatches++; qmatches++;
} }
else { else {
strcpy(qbuf0, qbuf); strcpy(qbuf0, qbuf);
if(strpbrk(line->text+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) if(strpbrk(line->txt.c_str()+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
qmatches = 1; qmatches = 1;
else else
qmatches = 0; qmatches = 0;
@ -2668,8 +2661,8 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
line = msg->lin; line = msg->lin;
while(line) { while(line) {
if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) { if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) {
if(line->text) { if(line->txt.c_str()) {
int n = strlen(line->text); int n = line->txt.length();
nonquotes += n; nonquotes += n;
if(line->type & GLINE_QUOT) if(line->type & GLINE_QUOT)
quotes += n; quotes += n;
@ -2749,8 +2742,7 @@ Line* DeleteLine(Line* line) {
line->next->prev = line->prev; line->next->prev = line->prev;
nextline = line->next; nextline = line->next;
} }
throw_release(line->text); throw_xdelete(line);
throw_xfree(line);
} }
return nextline; return nextline;
@ -2807,13 +2799,10 @@ Line* LastLine(Line* line) {
Line* AddLine(Line* line, char* buf, int where) { Line* AddLine(Line* line, char* buf, int where) {
Line* newline; Line* newline = new Line(buf);
throw_xnew(newline);
newline = (Line*)throw_xcalloc(1, sizeof(Line));
newline->type = GLINE_HARD; newline->type = GLINE_HARD;
newline->text = (char*)throw_malloc(strlen(buf)+10);
newline->color = C_READW; newline->color = C_READW;
strcpy(newline->text, buf);
return InsertLine(newline, line, where); return InsertLine(newline, line, where);
} }
@ -2831,9 +2820,9 @@ Line* AddLine(Line* line, char* buf) {
Line* AddLineFast(Line* oldline, char* text) { Line* AddLineFast(Line* oldline, char* text) {
Line* newline = (Line*)throw_xcalloc(1, sizeof(Line)); Line* newline = new Line(text);
newline->type = GLINE_HARD|GLINE_NOAL; throw_xnew(newline);
newline->text = text; newline->type = GLINE_HARD;
newline->color = C_READW; newline->color = C_READW;
newline->prev = oldline; newline->prev = oldline;
newline->next = oldline->next; newline->next = oldline->next;
@ -2848,14 +2837,10 @@ Line* AddLineFast(Line* oldline, char* text) {
Line* AddKludge(Line* line, char* buf, int where) { Line* AddKludge(Line* line, char* buf, int where) {
Line* newline; Line* newline = new Line(buf);
throw_xnew(newline);
newline = (Line*)throw_xcalloc(1, sizeof(Line));
newline->type = GLINE_HARD|GLINE_KLUD; newline->type = GLINE_HARD|GLINE_KLUD;
newline->text = (char*)throw_malloc(strlen(buf)+10);
newline->color = C_READK; newline->color = C_READK;
strcpy(newline->text, buf);
return InsertLine(newline, line, where); return InsertLine(newline, line, where);
} }
@ -2996,9 +2981,9 @@ void InvalidateControlInfo(GMsg* msg) {
while(line) { while(line) {
if(line->text and not (line->type & (GLINE_TEAR | GLINE_ORIG))) { if(not (line->type & (GLINE_TEAR | GLINE_ORIG))) {
strcpy(buf, line->text); strcpy(buf, line->txt.c_str());
// Invalidate tearline // Invalidate tearline
if(not CFG->invalidate.tearline.first.empty()) if(not CFG->invalidate.tearline.first.empty())
@ -3018,11 +3003,9 @@ void InvalidateControlInfo(GMsg* msg) {
else else
doinvalidate(buf, "SEEN-BY: ", "SEEN+BY: "); doinvalidate(buf, "SEEN-BY: ", "SEEN+BY: ");
if(stricmp(buf, line->text)) { if(stricmp(buf, line->txt.c_str())) {
line->type &= ~GLINE_KLUDGE; line->type &= ~GLINE_KLUDGE;
throw_release(line->text); line->txt = buf;
line->text = (char*)throw_malloc(strlen(buf)+10);
strcpy(line->text, buf);
} }
} }

View File

@ -39,9 +39,7 @@ void ResetMsg(GMsg* msg) {
Line* line = msg->lin; Line* line = msg->lin;
while(line) { while(line) {
Line* nextline = line->next; Line* nextline = line->next;
if(line->isallocated()) throw_xdelete(line);
throw_free(line->text);
throw_xfree(line);
line = nextline; line = nextline;
} }
memset(msg, 0, sizeof(GMsg)); memset(msg, 0, sizeof(GMsg));

View File

@ -542,10 +542,9 @@ int GMenuEditfile::Run(GMsg* __msg) {
Line* _line = __msg->lin; Line* _line = __msg->lin;
while(_line) { while(_line) {
if(_line->type & GLINE_TAGL) { if(_line->type & GLINE_TAGL) {
throw_release(_line->text);
sprintf(_buf, "%c%c%c %s ", AA->Taglinechar(), AA->Taglinechar(), AA->Taglinechar(), __msg->tagline); sprintf(_buf, "%c%c%c %s ", AA->Taglinechar(), AA->Taglinechar(), AA->Taglinechar(), __msg->tagline);
_line->text = throw_strdup(_buf); strtrim(_buf);
strtrim(_line->text); _line->txt = _buf;
break; break;
} }
_line = _line->next; _line = _line->next;
@ -565,10 +564,9 @@ int GMenuEditfile::Run(GMsg* __msg) {
Line* _line = __msg->lin; Line* _line = __msg->lin;
while(_line) { while(_line) {
if(_line->type & GLINE_ORIG) { if(_line->type & GLINE_ORIG) {
throw_release(_line->text);
sprintf(_buf, " * Origin: %s ", __msg->origin); sprintf(_buf, " * Origin: %s ", __msg->origin);
_line->text = throw_strdup(_buf); strtrim(_buf);
strtrim(_line->text); _line->txt = _buf;
break; break;
} }
_line = _line->next; _line = _line->next;

View File

@ -353,7 +353,7 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea)
void Rot13(GMsg* msg) { void Rot13(GMsg* msg) {
char c; char c;
char* ptr; int ptr;
int n; int n;
Line* line; Line* line;
static char rot13_table[256]; static char rot13_table[256];
@ -375,9 +375,10 @@ void Rot13(GMsg* msg) {
line = msg->lin; line = msg->lin;
while(line) { while(line) {
if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) { if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) {
ptr = line->text; for(ptr = 0; ptr != line->txt.length(); ptr++) {
while((c = *ptr) != NUL) c = line->txt[ptr];
*ptr++ = ROT13_DECODE(c); line->txt[ptr] = ROT13_DECODE(c);
}
} }
line = line->next; line = line->next;
} }
@ -532,7 +533,7 @@ void GMsg::LinesToText() {
// Approximate the size of the text // Approximate the size of the text
while(_line) { while(_line) {
_alloc_size += strlen(_line->text); _alloc_size += _line->txt.length();
_line = _line->next; _line = _line->next;
_lines++; _lines++;
} }
@ -553,10 +554,10 @@ void GMsg::LinesToText() {
char* _bptr; char* _bptr;
bool _hterm = true; bool _hterm = true;
if(_line->isheader()) { if(_line->isheader()) {
_bptr = stpcpy(_buf, _line->text); _bptr = stpcpy(_buf, _line->txt.c_str());
while(_line->next and _line->iswrapped()) { while(_line->next and _line->iswrapped()) {
_line = _line->next; _line = _line->next;
_bptr = stpcpy(_bptr, _line->text); _bptr = stpcpy(_bptr, _line->txt.c_str());
if((_bptr-_buf) > (bufsize-256)) { if((_bptr-_buf) > (bufsize-256)) {
int bptrlen = (int)(_bptr - _buf); int bptrlen = (int)(_bptr - _buf);
bufsize += 4096; bufsize += 4096;
@ -566,11 +567,10 @@ void GMsg::LinesToText() {
} }
} }
else { else {
_bptr = XlatStr(_buf, _line->text, _xlat_level, _xlat_table); _bptr = XlatStr(_buf, _line->txt.c_str(), _xlat_level, _xlat_table);
if(*_buf and not _line->ishard()) { if(*_buf and not _line->ishard()) {
if(_line->next) { if(_line->next) {
if(_line->next->text) { if((*(_bptr-1) != ' ') and (*_line->next->txt.c_str() != ' '))
if((*(_bptr-1) != ' ') and (*_line->next->text != ' '))
if(_isezycom or not _hardterm) if(_isezycom or not _hardterm)
*_bptr++ = ' '; *_bptr++ = ' ';
if(not _hardterm) { if(not _hardterm) {
@ -581,7 +581,6 @@ void GMsg::LinesToText() {
} }
} }
} }
}
if(_hterm) { if(_hterm) {
*_bptr++ = CR; *_bptr++ = CR;
if(_lfterm) if(_lfterm)

View File

@ -1070,7 +1070,7 @@ void Lookup(GMsg* msg, Addr* addr, char* name, int topline, char* status) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Lookup and display info about the node // Lookup and display info about the node
void LookupNode(GMsg* msg, char* name, int what) { void LookupNode(GMsg* msg, const char* name, int what) {
Subj statuslinebak; Subj statuslinebak;
strcpy(statuslinebak, information); strcpy(statuslinebak, information);

View File

@ -373,19 +373,12 @@ static void MakeMsg3(int& mode, GMsg* msg) {
// remove unnessesary To: line from message if present // remove unnessesary To: line from message if present
for(Line* line = cmsg->lin; line; line = line->next) for(Line* line = cmsg->lin; line; line = line->next)
if(line->text) { if(strnieql(line->txt.c_str(), "To:", 3))
if(strnieql(line->text, "To:", 3)) {
line = DeleteLine(line); line = DeleteLine(line);
if(line and not line->text)
line = DeleteLine(line);
}
else if(line->type & GLINE_KLUDGE) else if(line->type & GLINE_KLUDGE)
continue; continue;
else else
break; break;
}
else
break;
DoKludges(mode, cmsg); DoKludges(mode, cmsg);
@ -551,11 +544,11 @@ 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())) if(((line->type & GLINE_HIDD) and not AA->Viewhidden()) or ((line->type & GLINE_KLUD) and not AA->Viewkludge()))
newline = line = DeleteLine(line); newline = line = DeleteLine(line);
else { else {
strtrim(line->text); strtrim(line->txt);
if(line->type & GLINE_HARD) if(line->type & GLINE_HARD)
strcat(line->text, "\n"); line->txt += "\n";
else else
strcat(line->text, " "); line->txt += " ";
line = line->next; line = line->next;
} }
} }
@ -572,24 +565,20 @@ static void MakeMsg2(int& mode, int& status, int& forwstat, int& topline, GMsg*
if(status != MODE_QUIT) { if(status != MODE_QUIT) {
line = msg->lin; line = msg->lin;
while(line) { while(line) {
if(line->text) { if(line->txt.find(LF) != line->txt.npos)
if(strchr(line->text, LF))
line->type = GLINE_HARD; line->type = GLINE_HARD;
else if(line->next and (line->next->type & GLINE_QUOT)) else if(line->next and (line->next->type & GLINE_QUOT))
line->type = GLINE_HARD; line->type = GLINE_HARD;
else else
line->type = 0; line->type = 0;
strtrim(line->text); strtrim(line->txt);
if(AA->isinternet()) { if(AA->isinternet()) {
// Check for signature indicator // Check for signature indicator
if(streql(line->text, "--")) { if(streql(line->txt.c_str(), "--")) {
if(line->isallocated()) line->txt = "-- ";
throw_free(line->text);
line->text = throw_strdup("-- ");
line->type = GLINE_HARD; line->type = GLINE_HARD;
} }
} }
}
line = line->next; line = line->next;
} }
LoadCharset("N/A", "N/A"); LoadCharset("N/A", "N/A");

View File

@ -172,7 +172,7 @@ Line* InsertLine(Line* newline, Line* oldline, int pos);
Line* LastLine(Line* line); Line* LastLine(Line* line);
void MakeLineIndex(GMsg* msg, int rmargin, bool header_recode = true); void MakeLineIndex(GMsg* msg, int rmargin, bool header_recode = true);
void MsgLineReIndex(GMsg* msg, int viewhidden=-1, int viewkludge=-1, int viewquote=-1); void MsgLineReIndex(GMsg* msg, int viewhidden=-1, int viewkludge=-1, int viewquote=-1);
char* XlatStr(char* dest, char* src, int level, Chs* chrtbl, int qpencoded=false, bool i51=false); char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded=false, bool i51=false);
char* mime_header_decode(char* decoded, const char* encoded, char* charset = NULL); char* mime_header_decode(char* decoded, const char* encoded, char* charset = NULL);
char* strxmimecpy(char* dest, const char* source, int level, int size, bool detect = false); char* strxmimecpy(char* dest, const char* source, int level, int size, bool detect = false);
void InvalidateControlInfo(GMsg *msg); void InvalidateControlInfo(GMsg *msg);
@ -227,7 +227,7 @@ bool Lookup2(Addr& addr, char* name, int topline, const char* status);
const char *lookup_nodelist(ftn_addr* addr); const char *lookup_nodelist(ftn_addr* addr);
void LookupNode(GMsg* msg, char* name, int what); void LookupNode(GMsg* msg, const char* name, int what);
void CheckNodelists(); void CheckNodelists();
@ -351,7 +351,7 @@ void CheckSemaphores();
// GESOUP prototypes // GESOUP prototypes
char* CvtMSGIDtoMessageID(char* midbuf, char* msgid, ftn_addr* addr, char* domain, char* from, char* to, char* subject, struct tm* datetime); char* CvtMSGIDtoMessageID(char* midbuf, char* msgid, ftn_addr* addr, char* domain, char* from, char* to, char* subject, struct tm* datetime);
char* CvtMessageIDtoMSGID(char* mptr, char* msgidbuf, const char* echoid, char* kludge); char* CvtMessageIDtoMSGID(const char* mptr, char* msgidbuf, const char* echoid, char* kludge);
int ImportSOUP(); int ImportSOUP();
int ExportSOUP(); int ExportSOUP();

View File

@ -417,7 +417,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
if(line->type & GLINE_KLUDGE) { if(line->type & GLINE_KLUDGE) {
if(AA->isinternet()) { if(AA->isinternet()) {
if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) { if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) {
XlatStr(mbuf, line->text, level, CharTable); XlatStr(mbuf, line->txt.c_str(), level, CharTable);
msglen += fp.printf("%s%c", mbuf, qwkterm); msglen += fp.printf("%s%c", mbuf, qwkterm);
} }
else if(line->type & GLINE_WRAP) { else if(line->type & GLINE_WRAP) {
@ -427,7 +427,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
} }
else { else {
if((line->type & GLINE_KLUDGE) and QWK->KludgesAllowed()) { if((line->type & GLINE_KLUDGE) and QWK->KludgesAllowed()) {
XlatStr(mbuf, line->text, level, CharTable); XlatStr(mbuf, line->txt.c_str(), level, CharTable);
msglen += fp.printf("%s%c", mbuf, qwkterm); msglen += fp.printf("%s%c", mbuf, qwkterm);
} }
} }
@ -444,7 +444,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
line = msg->lin; line = msg->lin;
while(line) { while(line) {
if(not (line->type & GLINE_KLUDGE)) { if(not (line->type & GLINE_KLUDGE)) {
XlatStr(mbuf, line->text, level, CharTable); XlatStr(mbuf, line->txt.c_str(), level, CharTable);
msglen += fp.printf("%s%c", mbuf, qwkterm); msglen += fp.printf("%s%c", mbuf, qwkterm);
} }
line = line->next; line = line->next;

View File

@ -776,7 +776,7 @@ void make_pathreport(const char* reportfile) {
Line* line = msg->lin; Line* line = msg->lin;
while(line) { while(line) {
if(line->kludge == GKLUD_PATH) if(line->kludge == GKLUD_PATH)
path += line->text + 6; path += line->txt.c_str() + 6;
line = line->next; line = line->next;
} }
if(path.length()) { if(path.length()) {

View File

@ -31,11 +31,11 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void KludgeDATE(GMsg* msg, char* ptr); void KludgeDATE(GMsg* msg, const char* ptr);
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char* CvtMessageIDtoMSGID(char* mptr, char* msgidbuf, const char* echoid, char* kludge) { char* CvtMessageIDtoMSGID(const char* mptr, char* msgidbuf, const char* echoid, char* kludge) {
sprintf(msgidbuf, "\x1""%s: ", kludge); sprintf(msgidbuf, "\x1""%s: ", kludge);
char* bptr = msgidbuf + strlen(msgidbuf); char* bptr = msgidbuf + strlen(msgidbuf);
@ -639,7 +639,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
while(line) { while(line) {
if(line->type & GLINE_KLUDGE) { if(line->type & GLINE_KLUDGE) {
if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) { if((line->kludge == GKLUD_RFC) or (line->kludge == 0)) {
strcpy(mbuf, (*line->text == CTRL_A) ? line->text+1 : line->text); strcpy(mbuf, (*line->txt.c_str() == CTRL_A) ? line->txt.c_str()+1 : line->txt.c_str());
msglen += fp.printf("%s%s", mbuf, (line->type & GLINE_WRAP) ? "" : "\n"); msglen += fp.printf("%s%s", mbuf, (line->type & GLINE_WRAP) ? "" : "\n");
} }
else if(line->type & GLINE_WRAP) { else if(line->type & GLINE_WRAP) {
@ -657,7 +657,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
line = msg->lin; line = msg->lin;
while(line) { while(line) {
if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) { if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) {
XlatStr(mbuf, line->text, level, CharTable); XlatStr(mbuf, line->txt.c_str(), level, CharTable);
char* mptr = mbuf; char* mptr = mbuf;
if(qp and strlen(mptr) > 76) { if(qp and strlen(mptr) > 76) {
// 12345v7890 // 12345v7890

View File

@ -304,7 +304,7 @@ bool golded_search_manager::search(GMsg* msg, bool quick, bool shortcircuit) {
if(item->where.kludges and (type & GLINE_KLUDGE)) if(item->where.kludges and (type & GLINE_KLUDGE))
search_this_line = true; search_this_line = true;
if(search_this_line) { if(search_this_line) {
if(item->search(line->text)) { if(item->search(line->txt.c_str())) {
line->type |= GLINE_HIGH; line->type |= GLINE_HIGH;
if(type & (GLINE_TAGL|GLINE_TEAR|GLINE_ORIG|GLINE_SIGN|GLINE_KLUDGE)) { if(type & (GLINE_TAGL|GLINE_TEAR|GLINE_ORIG|GLINE_SIGN|GLINE_KLUDGE)) {
if(type & GLINE_TAGL) if(type & GLINE_TAGL)

View File

@ -627,7 +627,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
n = 0; n = 0;
*buf = NUL; *buf = NUL;
while(oldmsg->line[n]) { while(oldmsg->line[n]) {
quote = strtrim(oldmsg->line[n]->text); quote = strtrim(oldmsg->line[n]->txt).c_str();
if(oldmsg->line[n]->type & GLINE_TEAR) { if(oldmsg->line[n]->type & GLINE_TEAR) {
// Invalidate tearline // Invalidate tearline
oldmsg->line[n]->type &= ~GLINE_TEAR; oldmsg->line[n]->type &= ~GLINE_TEAR;
@ -648,7 +648,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
// Invalidate kludge chars // Invalidate kludge chars
strchg(quote, CTRL_A, '@'); strchg(quote, CTRL_A, '@');
if(is_quote(oldmsg->line[n]->text)) { if(is_quote(oldmsg->line[n]->txt.c_str())) {
quote += GetQuotestr(quote, qbuf, &len); quote += GetQuotestr(quote, qbuf, &len);
strbtrim(qbuf); strbtrim(qbuf);
ptr = qbuf; ptr = qbuf;
@ -685,8 +685,8 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
if(mode == MODE_FORWARD or mode == MODE_CHANGE) { if(mode == MODE_FORWARD or mode == MODE_CHANGE) {
n = 0; n = 0;
while(oldmsg->line[n]) { while(oldmsg->line[n]) {
if(oldmsg->line[n]->text) { if(oldmsg->line[n]->txt.c_str()) {
strcpy(buf, oldmsg->line[n]->text); strcpy(buf, oldmsg->line[n]->txt.c_str());
if(mode == MODE_FORWARD) { if(mode == MODE_FORWARD) {
// Invalidate tearline // Invalidate tearline
if(not CFG->invalidate.tearline.first.empty()) if(not CFG->invalidate.tearline.first.empty())
@ -720,15 +720,13 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
} }
else { else {
if(oldmsg->line[n+1]) { if(oldmsg->line[n+1]) {
if(oldmsg->line[n+1]->text) { if(msg->txt[pos-1] != ' ' and *oldmsg->line[n+1]->txt.c_str() != ' ') {
if(msg->txt[pos-1] != ' ' and *oldmsg->line[n+1]->text != ' ') {
msg->txt[pos++] = ' '; msg->txt[pos++] = ' ';
size++; size++;
} }
} }
} }
} }
}
n++; n++;
} }
} }

View File

@ -63,19 +63,19 @@ guserbase::guserbase() {
strcpy(entry.name, "Alexander S. Aganichev"); strcpy(entry.name, "Alexander S. Aganichev");
entry.fidoaddr.reset(); entry.fidoaddr.reset();
entry.fidoaddr.zone = 2; entry.fidoaddr.zone = 2;
entry.fidoaddr.net = 5049; entry.fidoaddr.net = 5020;
entry.fidoaddr.node = 49; entry.fidoaddr.node = 201;
entry.fidoaddr.point = 50; entry.fidoaddr.point = 58;
strcpy(entry.iaddr, "asa@eed.miee.ru"); strcpy(entry.iaddr, "asa@eed.miee.ru");
entry.prefer_internet = YES; entry.prefer_internet = YES;
entry.is_deleted = NO; entry.is_deleted = NO;
strcpy(entry.pseudo, "As\'ka"); strcpy(entry.pseudo, "As\'ka");
strcpy(entry.organisation, "[unemployed]"); strcpy(entry.organisation, "Hypercom Europe Limited, Inc.");
strcpy(entry.snail1, "Zelenograd"); strcpy(entry.snail1, "Zelenograd");
strcpy(entry.snail2, "Moscow"); strcpy(entry.snail2, "Moscow");
strcpy(entry.snail3, "Russia"); strcpy(entry.snail3, "Russia");
entry.dataphone[0] = NUL; entry.dataphone[0] = NUL;
entry.voicephone[0] = NUL; strcpy(entry.voicephone, "+7-(095)-532-79-03";
entry.faxphone[0] = NUL; entry.faxphone[0] = NUL;
entry.firstdate = entry.lastdate = entry.times = 0; entry.firstdate = entry.lastdate = entry.times = 0;
strcpy(entry.homepage, "http://asa.i-connect.ru"); strcpy(entry.homepage, "http://asa.i-connect.ru");

View File

@ -370,7 +370,7 @@ void GMsgBodyView::Create() {
scrollbar_color scrollbar_color
); );
dummy_line.text = ""; dummy_line.txt = "";
dummy_line.type = 0; dummy_line.type = 0;
dummy_line.color = window_color; dummy_line.color = window_color;
@ -432,7 +432,7 @@ void GMsgBodyView::PaintLine(int row, Line *line) {
// Calculate effective coordinates for vputs // Calculate effective coordinates for vputs
int vrow = gwin.active->srow + row; int vrow = gwin.active->srow + row;
uint llen = strlen(line->text); uint llen = line->txt.length();
int color = (line->type & GLINE_HIGH) ? highlight_color : line->color; int color = (line->type & GLINE_HIGH) ? highlight_color : line->color;
@ -440,22 +440,22 @@ void GMsgBodyView::PaintLine(int row, Line *line) {
// cases, but always when hex dump displayed. // cases, but always when hex dump displayed.
if(llen > visible_width) { if(llen > visible_width) {
llen = visible_width; llen = visible_width;
line->text[llen] = NUL; line->txt.erase(llen);
} }
// Print it // Print it
if(not SearchHighlight(line, vrow, visible_width, highlight_color)) { if(not SearchHighlight(line, vrow, visible_width, highlight_color)) {
if(line->type & GLINE_ORIG and strneql(line->text, " * Origin: ", 11)) { if(line->type & GLINE_ORIG and strneql(line->txt.c_str(), " * Origin: ", 11)) {
vputs(vrow, 0, color, " * Origin: "); vputs(vrow, 0, color, " * Origin: ");
StyleCodeHighlight(line->text+11, vrow, 11, not AA->attr().hex() and CFG->hidestylies, color); StyleCodeHighlight(line->txt.c_str()+11, vrow, 11, not AA->attr().hex() and CFG->hidestylies, color);
} }
else else
StyleCodeHighlight(line->text, vrow, 0, not AA->attr().hex() and CFG->hidestylies, color); StyleCodeHighlight(line->txt.c_str(), vrow, 0, not AA->attr().hex() and CFG->hidestylies, color);
int tlen = strlen(line->text); int tlen = strlen(line->txt.c_str());
vputns(vrow, tlen, color, "", visible_width-tlen); vputns(vrow, tlen, color, "", visible_width-tlen);
} }
else else
vputns(vrow, 0, color, line->text, visible_width); vputns(vrow, 0, color, line->txt.c_str(), visible_width);
} }

View File

@ -96,7 +96,7 @@ bool gclipbrd::openread() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool gclipbrd::writeclipbrd(char* buf) { bool gclipbrd::writeclipbrd(const char* buf) {
if(not clipboard_available) { if(not clipboard_available) {
if(fake_clipboard) if(fake_clipboard)

View File

@ -58,7 +58,7 @@ public:
char* read(char* buffer, int maxlen); char* read(char* buffer, int maxlen);
void close(); void close();
bool writeclipbrd(char* buf); bool writeclipbrd(const char* buf);
gclipbrd(); gclipbrd();

View File

@ -271,7 +271,7 @@ char* g_get_clip_text(void) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int g_put_clip_text(char* buf) { int g_put_clip_text(const char* buf) {
if(winapi == NOAPI) if(winapi == NOAPI)
return -1; return -1;

View File

@ -64,7 +64,7 @@ void g_set_osicon(void);
bool g_is_clip_available(void); bool g_is_clip_available(void);
char* g_get_clip_text(void); char* g_get_clip_text(void);
int g_put_clip_text(char *cd); int g_put_clip_text(const char *cd);
void g_get_ostitle_name(char *); void g_get_ostitle_name(char *);
void g_set_ostitle_name(char *, int); void g_set_ostitle_name(char *, int);

View File

@ -322,7 +322,7 @@ static void leave_pm_clipboard(int mode) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int g_put_clip_text(char *cd) { int g_put_clip_text(const char *cd) {
ULONG len; ULONG len;
void *text; void *text;

View File

@ -261,7 +261,7 @@ char* g_get_clip_text(void) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int g_put_clip_text(char *Data) { int g_put_clip_text(const char *Data) {
long DataSize; long DataSize;
if((Data != NULL) and ((DataSize = strlen(Data)) != 0)) { if((Data != NULL) and ((DataSize = strlen(Data)) != 0)) {

View File

@ -38,7 +38,7 @@ static bool lame = false;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool gareafile::ReadHPTLine(FILE* f, string* s, bool add=false, int state=0) { bool gareafile::ReadHPTLine(FILE* f, string* s, bool add, int state) {
string str; string str;
char buf[81]; char buf[81];

View File

@ -143,10 +143,14 @@ public:
int color; // Line color int color; // Line color
uint type; // GLINE_* uint type; // GLINE_*
uint kludge; // GKLUD_* uint kludge; // GKLUD_*
char* text; // Pointer to the line text string txt; // The line text
Line* prev; // Pointer to previous line Line* prev; // Pointer to previous line
Line* next; // Pointer to next line Line* next; // Pointer to next line
Line() { txt = ""; color = type = kludge = 0; prev = next = NULL; }
Line(const char *str) { txt = str; color = type = kludge = 0; prev = next = NULL; }
~Line() {}
int istearline() { return !!(type & GLINE_TEAR); } int istearline() { return !!(type & GLINE_TEAR); }
int isorigin() { return !!(type & GLINE_ORIG); } int isorigin() { return !!(type & GLINE_ORIG); }
int ishidden() { return !!(type & GLINE_HIDD); } int ishidden() { return !!(type & GLINE_HIDD); }