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
@echo making depends for $<
@$(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
@echo making depends for $<
@ -50,7 +51,7 @@ $(FOBJPATH)/%.res: %.rc
endif
SOURCES=
include bld$(PLATFORM).inc
-include bld$(PLATFORM).inc
ifeq ($(PLATFORM),cyg)
OBJS=$(addprefix $(FOBJPATH)/,$(patsubst %.rc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(filter %.c %.cpp %.rc,$(SOURCES))))))
else
@ -71,4 +72,3 @@ ifneq ($(DEPS),)
-include $(DEPS)
endif
endif

View File

@ -11,6 +11,12 @@ To compile GoldED+ and utilities you'll need:
- vi, emacs, or any other editor you like
- 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.
Now go to golded3 and áopy mygolded.__h to mygolded.h and adjust it for

View File

@ -37,7 +37,8 @@ assistance!
*A:* Чтобы GoldED+ глючил поменьше, надо настроить региональные установки:
для DPMI32: country.sys, переменная TZ
для Win32: control panel
для OS/2: [не знаю где настраивается, но региональные настройки - свои], переменная TZ
для OS/2: [не знаю где настраивается, но региональные настройки - свои],
переменная TZ
для UNIX: переменные LANG и TZ.
*Q:* А как же все-таки правильно менять SoftCR при наборе и иметь с этим
@ -115,7 +116,7 @@ assistance!
*Q:* Типа эта... А писать куда автору? ;-)
*A:* Писать лучше всего в Ru.GoldED. Даже лучше сначала его почитать, потом
писать. Если уж сильно приспичит, то можно писать на asa@eed.miee.ru,
2:5020/201.58 или 2:5049/49.50, но я совсем не гарантирую, что я отвечу.
писать. Если уж сильно приспичит, то можно писать на asa@eed.miee.ru
или 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 n, cc = 0;
char* ptr;
const char* ptr;
Attr attr;
bool cchide;
bool ignorecc = false;
@ -108,7 +108,8 @@ int DoCarboncopy(GMsg* msg, GMsg** carbon) {
// 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);
// Deal with carbon copies
@ -130,8 +131,8 @@ int DoCarboncopy(GMsg* msg, GMsg** carbon) {
int xc2to = 0;
do {
ptr = newline->text;
if(ptr and strnieql(ptr, "CC:", 3)) {
ptr = newline->txt.c_str();
if(strnieql(ptr, "CC:", 3)) {
if(not ignorecc) {
if(ask) {
msg->attr.nwm1();
@ -316,7 +317,7 @@ void DoCrosspost(GMsg* msg, vector<int> &postareas) {
if(CFG->crosspost == NO)
return;
char buf[256];
char *ptr;
const char *ptr;
bool ignorexc = false;
Line* newline;
Line* xcline = NULL;
@ -328,7 +329,8 @@ void DoCrosspost(GMsg* msg, vector<int> &postareas) {
// 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);
// 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))) {
ptr = newline->text;
if(not ignorexc and ptr and (strnieql(ptr, "XC:", 3) or strnieql(ptr, "XP:", 3))) {
ptr = newline->txt.c_str();
if(not ignorexc and (strnieql(ptr, "XC:", 3) or strnieql(ptr, "XP:", 3))) {
if(ask) {
GMenuCross MenuCross;
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 == '#'); }
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;
char* txptr = text;
char buf[200];
char* ptr = text;
const char* ptr = text;
const char* stylemargins = " -|\\"; // we probably have to make a keyword for it
char* punctchars = CFG->stylecodepunct;
char* stylestopchars = CFG->stylecodestops;
@ -47,7 +47,7 @@ void Container::StyleCodeHighlight(char* text, int row, int col, bool dohide, in
if(isstylechar(*ptr)) {
if(strchr(punctchars, prevchar)) {
int bb = 0, bi = 0, bu = 0, br = 0;
char* beginstyle = ptr;
const char* beginstyle = ptr;
while(isstylechar(*ptr)) {
switch(*ptr) {
case '*': bb++; break;
@ -58,7 +58,7 @@ void Container::StyleCodeHighlight(char* text, int row, int col, bool dohide, in
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* end = ptr;
do {

View File

@ -24,6 +24,8 @@
// Container class.
// ------------------------------------------------------------------
#ifndef __gectnr_h
#define __gectnr_h
// ------------------------------------------------------------------
@ -35,8 +37,12 @@ public:
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
newline = (Line*)throw_xcalloc(1, sizeof(Line));
newline = new Line("");
throw_xnew(newline);
newline = line = InsertLine(newline, line, DIR_PREV);
// Strip all the kludges we insert ourselves
@ -260,6 +261,13 @@ void DoKludges(int mode, GMsg* msg, bool attronly) {
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
if(CFG->useintl and (CFG->useintl == YES or (msg->dest.zone != msg->orig.zone))) {
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;
}
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->kludge = GKLUD_RFC;
}
}
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->To() and (strpbrk(msg->iaddr, "<>()\"") == NULL) and not strieql(msg->To(), *AA->Internetgate().name ? AA->Internetgate().name : "UUCP")) {
Name name;
@ -602,12 +603,14 @@ void DoTearorig(int mode, GMsg* msg) {
line = LastLine(msg->lin);
if(line == NULL)
msg->lin = line = AddLine(NULL, "");
#if 0
else {
ptr = line->text;
ptr = line->txt.c_str();
if(not strblank(ptr))
if(not ((ptr[0] == ptr[1]) and (ptr[1] == ptr[2])))
line = AddLine(line, "");
}
#endif
// Check and fix originline
if(*msg->origin) {

View File

@ -80,41 +80,39 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, bool clip) {
if(lin and not (prnheader & WRITE_ONLY_HEADER)) {
Line* line = lin[n];
while(line) {
if(line->text) {
uint lineisctrl = line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE);
if(not ((mode == MODE_SAVENOCTRL) and lineisctrl)) {
char* ptr = line->text;
while(*ptr) {
if(mode == MODE_WRITE) {
// Replace control codes, except the ANSI escape code
if(*ptr < ' ') {
// only allow ESC in file write
if(prn or (*ptr != '\x1B')) {
*ptr = (*ptr == CTRL_A) ? '@' : '.';
}
}
}
ptr++;
}
ptr = line->text;
fwrite(ptr, strlen(ptr), 1, prnfp);
if(mode == MODE_NEW) {
if(EDIT->HardLines()) {
if(line->type & GLINE_HARD) {
if(not ((line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE|GLINE_QUOT)) or strblank(ptr))) {
fwrite(EDIT->HardLine(), strlen(EDIT->HardLine()), 1, prnfp);
}
uint lineisctrl = line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE);
if(not ((mode == MODE_SAVENOCTRL) and lineisctrl)) {
string::iterator p = line->txt.begin();
while(p != line->txt.end()) {
if(mode == MODE_WRITE) {
// Replace control codes, except the ANSI escape code
if(*p < ' ') {
// only allow ESC in file write
if(prn or (*p != '\x1B')) {
*p = (*p == CTRL_A) ? '@' : '.';
}
}
}
fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1, 1, prnfp);
if(prn) {
lines++;
if(lines%CFG->printlength == 0 and CFG->switches.get(printformfeed)) {
fwrite("\f", 1, 1, prnfp);
p++;
}
const char *ptr = line->txt.c_str();
fwrite(ptr, strlen(ptr), 1, prnfp);
if(mode == MODE_NEW) {
if(EDIT->HardLines()) {
if(line->type & GLINE_HARD) {
if(not ((line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE|GLINE_QUOT)) or strblank(ptr))) {
fwrite(EDIT->HardLine(), strlen(EDIT->HardLine()), 1, prnfp);
}
}
}
}
fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1, 1, prnfp);
if(prn) {
lines++;
if(lines%CFG->printlength == 0 and CFG->switches.get(printformfeed)) {
fwrite("\f", 1, 1, prnfp);
}
}
}
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) {
_test_halt(__line == NULL);
_test_halt(__line->text == NULL);
__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
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
@ -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");
@ -315,7 +257,7 @@ void IEclass::dispstring(char* __string, uint __row, int attr, Line* line) {
if(attr == -1) {
char* _bufptr = _buf;
uint _position = 0;
char* __str = __string;
const char* __str = __string;
while(_position < _length) {
switch(*__str) {
case ' ': *_bufptr = EDIT->CharSpace(); break;
@ -390,7 +332,7 @@ void IEclass::setcolor(Line* __line) {
else if(__line->type & GLINE_ORIG)
editwin.text_color(C_READO);
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)
editwin.text_color(C_READS);
else
@ -407,12 +349,11 @@ void IEclass::displine(Line* __line, uint __row) {
GFTRK("Editdispline");
_test_halt(__line == NULL);
_test_halt(__line->text == NULL);
_test_haltab(__row > maxrow, __row, maxrow);
// Display line
setcolor(__line);
dispstring(__line->text, __row, -1, __line);
dispstring(__line->txt.c_str(), __row, -1, __line);
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");
Line* _nextline = (Line*)throw_xcalloc(1, sizeof(Line));
_nextline->text = __text ? throw_strdup(__text) : (char*)NULL;
Line* _nextline = new Line(__text ? __text : "");
throw_xnew(_nextline);
if(__currline) {
@ -527,7 +468,7 @@ void IEclass::GoEOL() {
GFTRK("EditGoEOL");
// Move cursor to the last char on the line
col = strlen(currline->text);
col = currline->txt.length();
if(col)
col--;
@ -568,7 +509,7 @@ void IEclass::GoUp() {
}
}
if((col+1) > strlen(currline->text))
if((col+1) > currline->txt.length())
GoEOL();
}
@ -603,7 +544,7 @@ void IEclass::GoDown() {
}
}
if((col+1) > strlen(currline->text))
if((col+1) > currline->txt.length())
GoEOL();
}
@ -643,7 +584,7 @@ void IEclass::GoRight() {
_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(currline->next != NULL) {
@ -684,12 +625,12 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
while(_thisline) {
// Length of this line
uint _thislen = strlen(_thisline->text);
uint _thislen = _thisline->txt.length();
uint _wrapmargin = (_thisline->type & GLINE_QUOT) ? marginquotes : margintext;
// 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
_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) {
// Get quote string and length
GetQuotestr(_thisline->text, _quotebuf, &_quotelen);
GetQuotestr(_thisline->txt.c_str(), _quotebuf, &_quotelen);
}
// wrapmargin = 40
@ -712,12 +653,12 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
// Case 4: >thisxisxaxtestxwithxaxlinexthatxneedxwrapping.
// Point to the last char inside the margin
char* _wrapptr = _thisline->text + _wrapmargin - 1;
int _wrappos = _wrapmargin - 1;
// Locate the word to be wrapped
// Did we find a space?
if(*_wrapptr == ' ') {
if(_thisline->txt[_wrappos] == ' ') {
// 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!
// Begin at the first char outside the margin
_wrapptr++;
_wrappos++;
}
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.
// Keep copy of original pointer
char* _atmargin = _wrapptr;
int _atmargin = _wrappos;
// Search backwards until a space or the beginning of the line is found
while((_wrapptr > _thisline->text) and (*(_wrapptr-1) != ' '))
_wrapptr--;
while(_wrappos > 0 and (_thisline->txt[_wrappos-1] != ' '))
_wrappos--;
// Check if we hit leading spaces
char* _spaceptr = _wrapptr;
if(_spaceptr > _thisline->text) {
_spaceptr--;
while((_spaceptr > _thisline->text) and (*_spaceptr == ' '))
_spaceptr--;
int _spacepos = _wrappos;
if(_spacepos > 0) {
do {
_spacepos--;
} while(_spacepos > 0 and _thisline->txt[_spacepos] == ' ');
}
// 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
// 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
// Get length of the wrapped part
uint _wraplen = strlen(_wrapptr);
uint _wraplen = _thisline->txt.length() - _wrappos;
// Is the line hard-terminated?
if(strchr(_wrapptr, '\n')) {
if(_thisline->txt.find('\n', _wrappos) != _thisline->txt.npos) {
// The line is hard-terminated.
//
// The wrapped part must be placed on a new line below.
Line* _wrapline = _lastadded = insertlinebelow(_thisline, NULL, BATCH_MODE);
// 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
if(_quotelen) {
strcpy(_wrapline->text, _quotebuf);
THROW_CHECKPTR(_wrapline->text);
}
else {
*_wrapline->text = NUL;
THROW_CHECKPTR(_wrapline->text);
}
if(_quotelen)
_wrapline->txt = _quotebuf;
else
_wrapline->txt = "";
// Copy/append the wrapped part to the new line
strcat(_wrapline->text, _wrapptr);
THROW_CHECKPTR(_wrapline->text);
_wrapline->txt += _thisline->txt.substr(_wrappos);
// 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
@ -806,7 +740,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
scrolldown(mincol, _thisrow+1, maxcol, maxrow);
// Display the new line
if(strlen(_wrapline->text) <= (maxcol+1))
if(_wrapline->txt.length() <= (maxcol+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;
}
// 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?
if(_quotelen) {
// Copy the quote string
memmove(_nextline->text, _quotebuf, _quotelen);
THROW_CHECKPTR(_nextline->text);
Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, _nextline, 0, _quotelen);
_nextline->txt.insert(0, _quotebuf, _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
setlinetype(_nextline);
@ -873,35 +792,33 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int
}
// 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);
}
}
// Nul-terminate at the wrapping location
*_wrapptr = NUL;
THROW_CHECKPTR(_thisline->text);
// Truncate at the wrapping location
_thisline->txt.erase(_wrappos);
// Was this line quoted?
if(_quotelen) {
// Trim spaces off the end of the line
char* _trimptr = _wrapptr - 1;
if(*_trimptr == ' ') {
while(*(_trimptr-1) == ' ')
_trimptr--;
if(_quotelen and _trimptr-_thisline->text < _quotelen)
_trimptr++;
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimptr - _thisline->text);
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimptr - _thisline->text + 1);
*_trimptr = NUL;
int _trimpos = _wrappos - 1;
if(_thisline->txt[_trimpos] == ' ') {
while(_trimpos > 0 and _thisline->txt[_trimpos-1] == ' ')
_trimpos--;
if(_quotelen and _trimpos < _quotelen)
_trimpos++;
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimpos);
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _trimpos+1);
_thisline->txt.erase(_trimpos);
}
else
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _wrapptr - _thisline->text);
Undo->PushItem(EDIT_UNDO_OVR_CHAR|BATCH_MODE, _thisline, _wrappos);
// Append a new linefeed
strcat(_thisline->text, "\n");
THROW_CHECKPTR(_thisline->text);
_thisline->txt += "\n";
}
// 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(_thisrow == *__curr_row and strlen(_thisline->text) <= *__curr_col) {
char* _colptr = _thisline->text + *__curr_col;
_curscol = _quotelen + ((_colptr > _wrapptr) ? _colptr - _wrapptr : 0);
if(_thisrow == *__curr_row and _thisline->txt.length() <= *__curr_col) {
_curscol = _quotelen + ((*__curr_col > _wrappos) ? *__curr_col-_wrappos : 0);
_cursrow++, thisrow++;
UndoItem* i = Undo->last_item;
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->col.sav = i->col.num;
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
// 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)
break;
_wrapmargin = (_thisline->next->type & GLINE_QUOT) ? marginquotes : margintext;
if(strlen(_thisline->next->text) <= _wrapmargin)
if(_thisline->next->txt.length() <= _wrapmargin)
break;
}
@ -1014,19 +930,20 @@ void IEclass::insertchar(char __ch) {
GFTRK("Editinsertchar");
#ifndef NDEBUG
uint _currline_len = currline->txt.length();
_test_haltab(col > _currline_len, col, _currline_len);
#endif
// 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) {
(currline->txt[col] == '\n') or (currline->txt[col] == NUL) or insert) {
Undo->PushItem(EDIT_UNDO_INS_CHAR|batch_mode);
strinschr(currline->text, __ch, col);
if(col == currline->txt.length() and __ch != ' ' and __ch != '\n')
currline->txt += ' ';
currline->txt.insert(col, 1, __ch);
} else {
#ifndef NDEBUG
uint _currline_len = strlen(currline->text);
_test_haltab(col > _currline_len, col, _currline_len);
#endif
Undo->PushItem(EDIT_UNDO_OVR_CHAR|batch_mode);
currline->text[col] = __ch;
THROW_CHECKPTR(currline->text);
currline->txt[col] = __ch;
}
batch_mode = BATCH_MODE;
@ -1069,12 +986,12 @@ void IEclass::DelChar() {
Line* _thisline = currline;
Line* _nextline = currline->next;
uint _thislen = strlen(_thisline->text);
uint _thislen = _thisline->txt.length();
// Cannot delete at or beyond the nul-terminator
if(col < _thislen) {
Undo->PushItem(EDIT_UNDO_DEL_CHAR|batch_mode);
strdelchr(_thisline->text, col);
_thisline->txt.erase(col, 1);
batch_mode = BATCH_MODE;
}
@ -1092,21 +1009,17 @@ void IEclass::DelChar() {
// Get quote string length
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
// 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))) {
while(*_nextptr == ' ')
_nextptr++;
}
strcat(_thisline->text, _nextptr);
THROW_CHECKPTR(_thisline->text);
_thisline->txt += _nextptr;
Undo->PushItem(EDIT_UNDO_CUT_TEXT|batch_mode, _thisline, col);
@ -1168,14 +1081,14 @@ void IEclass::GoWordLeft() {
col--;
if(not isxalnum(currline->text[col])) {
while(not isxalnum(currline->text[col]) and (col > 0))
if(not isxalnum(currline->txt[col])) {
while(not isxalnum(currline->txt[col]) and (col > 0))
col--;
while(isxalnum(currline->text[col]) and (col > 0))
while(isxalnum(currline->txt[col]) and (col > 0))
col--;
}
else {
while(isxalnum(currline->text[col]) and (col > 0))
while(isxalnum(currline->txt[col]) and (col > 0))
col--;
}
@ -1196,28 +1109,28 @@ void IEclass::GoWordRight() {
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) {
GoDown();
col = 0;
}
}
else {
if(not isxalnum(currline->text[col])) {
while(not isxalnum(currline->text[col]) and ((col+1) <= strlen(currline->text)))
if(not isxalnum(currline->txt[col])) {
while(not isxalnum(currline->txt[col]) and ((col+1) <= currline->txt.length()))
col++;
}
else {
while(isxalnum(currline->text[col]) and ((col+1) <= strlen(currline->text)))
while(isxalnum(currline->txt[col]) and ((col+1) <= currline->txt.length()))
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++;
}
if(currline->text[col-1] == '\n')
if(currline->txt[col-1] == '\n')
col--;
if(currline->text[col] == NUL) {
if(currline->txt.length() == col) {
if(currline->next) {
GoDown();
col = 0;
@ -1240,14 +1153,8 @@ void IEclass::Newline() {
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
char* _splitptr = _text + col;
int _splitpos = col;
// Buffer for the second part of the split line
char* _splitbuf = (char*)throw_malloc(EDIT_BUFLEN);
@ -1256,27 +1163,27 @@ void IEclass::Newline() {
// If the split line was quoted, get the quotestring
// But do not get it if the cursor points to a linefeed or is
uint _quotelen = 0;
if(is_quote(_text)) {
GetQuotestr(_text, _splitbuf, &_quotelen);
if(is_quote(currline->txt.c_str())) {
GetQuotestr(currline->txt.c_str(), _splitbuf, &_quotelen);
THROW_CHECKPTR(_splitbuf);
}
// Eliminate the quotestring if
// - the cursor points to a linefeed or
// - 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;
// Append the second part to the split buffer
strcat(_splitbuf, _splitptr);
strcat(_splitbuf, currline->txt.substr(_splitpos).c_str());
THROW_CHECKPTR(_splitbuf);
Undo->PushItem(EDIT_UNDO_INS_TEXT|batch_mode, currline, col, 1);
batch_mode = BATCH_MODE;
// Copy linefeed+nul to the split position
strcpy(_splitptr, "\n");
THROW_CHECKPTR(currline->text);
currline->txt.erase(_splitpos);
currline->txt += "\n";
// Re-type and display the split line
setlinetype(currline);
@ -1318,10 +1225,9 @@ void IEclass::CopyAboveChar() {
char _ch = ' ';
if(currline->prev) {
char* _ptr = currline->prev->text;
uint _len = strlen(_ptr);
uint _len = currline->prev->txt.length();
if(_len and _len > col)
_ch = _ptr[col];
_ch = currline->prev->txt[col];
if(_ch == '\n')
_ch = ' ';
}
@ -1339,7 +1245,7 @@ void IEclass::DupLine() {
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->color = currline->color;
_nextline->kludge = currline->kludge;
@ -1411,7 +1317,7 @@ void IEclass::GoPgUp() {
GoTopMsg();
}
if((col+1) > strlen(currline->text))
if(col+1 > currline->txt.length())
GoEOL();
GFTRK(NULL);
@ -1469,7 +1375,7 @@ void IEclass::GoPgDn() {
GoBotMsg();
}
if((col+1) > strlen(currline->text))
if(col+1 > currline->txt.length())
GoEOL();
GFTRK(NULL);
@ -1488,7 +1394,7 @@ void IEclass::Tab() {
do {
if(insert)
insertchar(' ');
else if(currline->text[col] != '\n')
else if(currline->txt[col] != '\n')
GoRight();
else
break;
@ -1528,17 +1434,14 @@ void IEclass::DeleteEOL() {
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);
currline->text[col] = NUL;
THROW_CHECKPTR(currline->text);
currline->txt.erase(col);
if(_has_linefeed) {
strcat(currline->text, "\n");
THROW_CHECKPTR(currline->text);
}
if(_has_linefeed)
currline->txt += "\n";
clreol();
@ -1557,7 +1460,7 @@ void IEclass::deleteline(bool zapquotesbelow) {
do {
// Break if need to zap quotes, but the current line is not quote and is not empty
if(zapquotesbelow and not ((currline->type & GLINE_QUOT) or strblank(currline->text)))
if(zapquotesbelow and not ((currline->type & GLINE_QUOT) or strblank(currline->txt.c_str())))
break;
// 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(currline->next == NULL) {
if(currline->text[0] == NUL)
if(currline->txt.empty())
break;
insertlinebelow(currline, "", batch_mode);
batch_mode = BATCH_MODE;
@ -1612,7 +1515,7 @@ void IEclass::deleteline(bool zapquotesbelow) {
Edit__killbuf->next = NULL;
// Move the cursor to EOL if necessary
if((col+1) > strlen(currline->text))
if(col+1 > currline->txt.length())
GoEOL();
if(not zapquotesbelow)
@ -1666,7 +1569,7 @@ void IEclass::UnDelete(bool before) {
Undo->PushItem(EDIT_UNDO_POP_LINE);
// Move the cursor to EOL if necessary
if((col+1) > strlen(currline->text))
if(col+1 > currline->txt.length())
GoEOL();
if(down)
@ -1762,7 +1665,7 @@ void IEclass::savefile(int __status) {
// Copy the line to a buffer
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
char* _lfptr = strchr(_buf, '\n');
@ -1820,7 +1723,7 @@ int IEclass::isempty(Line* __line) {
if(__line == NULL)
__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
uint _qlen2;
char _qstr2[100];
GetQuotestr(currline->next->text, _qstr2, &_qlen2);
GetQuotestr(currline->next->txt.c_str(), _qstr2, &_qlen2);
if(not strieql(__qstr, _qstr2))
return false;
@ -1870,14 +1773,14 @@ void IEclass::Reflow() {
// Get the first quotestring
uint _qlen1;
char _qstr1[100];
GetQuotestr(currline->text, _qstr1, &_qlen1);
char* _qlenptr = currline->text + _qlen1;
GetQuotestr(currline->txt.c_str(), _qstr1, &_qlen1);
const char* _qlenptr = currline->txt.c_str() + _qlen1;
// Strip leading spaces from the first line
char* ptr = strskip_wht(_qlenptr);
const char* ptr = strskip_wht(_qlenptr);
if(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
@ -1944,7 +1847,7 @@ void IEclass::ToUpper() {
GFTRK("EditToUpper");
Undo->PushItem(EDIT_UNDO_OVR_CHAR);
currline->text[col] = toupper(currline->text[col]);
currline->txt[col] = toupper(currline->txt[col]);
GFTRK(NULL);
}
@ -1957,7 +1860,7 @@ void IEclass::ToLower() {
GFTRK("EditToLower");
Undo->PushItem(EDIT_UNDO_OVR_CHAR);
currline->text[col] = tolower(currline->text[col]);
currline->txt[col] = tolower(currline->txt[col]);
GFTRK(NULL);
}
@ -1970,10 +1873,10 @@ void IEclass::ToggleCase() {
GFTRK("EditToggleCase");
Undo->PushItem(EDIT_UNDO_OVR_CHAR);
if(toupper(currline->text[col]) == currline->text[col])
currline->text[col] = tolower(currline->text[col]);
if(toupper(currline->txt[col]) == currline->txt[col])
currline->txt[col] = tolower(currline->txt[col]);
else
currline->text[col] = toupper(currline->text[col]);
currline->txt[col] = toupper(currline->txt[col]);
GFTRK(NULL);
}
@ -1985,7 +1888,7 @@ void IEclass::LookupCursor() {
GFTRK("EditLookupCursor");
LookupNode(msgptr, currline->text+col, LOOK_NAME);
LookupNode(msgptr, currline->txt.c_str()+col, LOOK_NAME);
GFTRK(NULL);
}
@ -2033,7 +1936,7 @@ void IEclass::statusline() {
const char* trig = EDIT->Completion.Trigger();
uint tlen = strlen(trig);
if(col >= tlen) {
if(strneql(trig, currline->text+col-tlen, tlen)) {
if(strneql(trig, currline->txt.c_str()+col-tlen, tlen)) {
uint n;
for(n=0; n<tlen; n++)
DelLeft();
@ -2057,7 +1960,7 @@ void IEclass::statusline() {
const char* trig = EDIT->Comment.Trigger();
uint tlen = strlen(trig);
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());
break;
}
@ -2235,8 +2138,8 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
whelppcat(H_Editor);
if(currline == NULL) {
currline = (Line*)throw_xcalloc(1, sizeof(Line));
currline->text = throw_strdup("\n");
currline = new Line("\n");
throw_xnew(currline);
}
// Check if there is an unfinished backup message
@ -2294,7 +2197,7 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
int backattr = 0;
if(blockcol == -1) {
backattr = dispchar(currline->text[col], C_READC);
backattr = dispchar(currline->txt[col], C_READC);
gotorowcol(col, row);
}
@ -2334,7 +2237,7 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
}
if(blockcol == -1)
dispchar(currline->text[col], backattr);
dispchar(currline->txt[col], backattr);
chartyped = false;
if((_ch < KK_Commands) and (_ch & 0xFF) and not ismacro) {
@ -2377,14 +2280,12 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
}
}
else {
throw_release(__line->text);
if(__line->prev) {
__line = __line->prev;
throw_xrelease(__line->next);
}
else {
throw_xrelease(__line);
throw_xdelete(__line->next);
}
else
throw_xdelete(__line);
}
}
}
@ -2425,12 +2326,10 @@ UndoStack::~UndoStack() {
switch(last_item->action & EDIT_UNDO_ACTION) {
case EDIT_UNDO_DEL_TEXT:
case EDIT_UNDO_WRAP_TEXT:
delete last_item->data.text_ptr;
throw_delete(last_item->data.text_ptr);
break;
case EDIT_UNDO_DEL_LINE:
if(last_item->data.line_ptr->isallocated())
throw_release(last_item->data.line_ptr->text);
throw_xfree(last_item->data.line_ptr);
throw_xdelete(last_item->data.line_ptr);
}
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_OVR_CHAR:
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;
case EDIT_UNDO_DEL_TEXT:
last_item->line = __line;
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));
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;
case EDIT_UNDO_CUT_TEXT:
last_item->line = __line;
@ -2543,7 +2442,7 @@ void UndoStack::PlayItem() {
// Let user to see the position before performing Undo, unless it's a
// 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,
// then refresh window if the line is invisible.
@ -2569,7 +2468,7 @@ void UndoStack::PlayItem() {
} while(curr_row_num != thisrow);
}
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 _prow = item->prow;
@ -2597,13 +2496,15 @@ void UndoStack::PlayItem() {
case EDIT_UNDO_CHAR:
switch(undo_action) {
case EDIT_UNDO_INS_CHAR:
editor->strdelchr(currline->text, last_item->col.num);
currline->txt.erase(last_item->col.num,1);
break;
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;
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;
}
editor->setlinetype(currline);
@ -2611,27 +2512,22 @@ void UndoStack::PlayItem() {
case EDIT_UNDO_TEXT: {
text_item* text_data = last_item->data.text_ptr;
char *dest_ptr, *from_ptr, *thistext = currline->text;
string& txt = currline->txt;
switch(undo_action) {
case EDIT_UNDO_DEL_TEXT:
thistext = currline->text = (char*)throw_realloc(thistext, strlen(thistext) + text_data->len + 1);
memmove(thistext + text_data->col + text_data->len, thistext + text_data->col, strlen(thistext + text_data->col) + 1);
memcpy(thistext + text_data->col, text_data->text, text_data->len);
delete text_data;
txt.insert(text_data->col, text_data->text, text_data->len);
throw_delete(text_data);
break;
case EDIT_UNDO_CUT_TEXT:
thistext[last_item->col.num] = NUL;
txt.erase(last_item->col.num);
break;
case EDIT_UNDO_WRAP_TEXT:
thistext = currline->text = (char*)throw_realloc(thistext, strlen(thistext) + text_data->len + 1);
strncat(thistext, currline->next->text + text_data->col, text_data->len);
thistext = currline->next->text;
txt.append(currline->next->txt.c_str()+text_data->col, text_data->len);
txt = currline->next->txt;
// fall through...
case EDIT_UNDO_INS_TEXT:
dest_ptr = thistext + text_data->col;
from_ptr = dest_ptr + text_data->len;
memmove(dest_ptr, from_ptr, strlen(from_ptr) + 1);
delete text_data;
txt.erase(text_data->col, text_data->len);
throw_delete(text_data);
break;
}
editor->setlinetype(currline);
@ -2650,16 +2546,13 @@ void UndoStack::PlayItem() {
}
else
currline = thisline->next;
throw_release(thisline->text);
throw_xfree(thisline);
throw_xdelete(thisline);
break;
case EDIT_UNDO_ORPHAN_LINE:
if(last_item->action & LAST_LINE) {
thisline->prev = currline;
thisline->next = currline ? currline->next : NULL;
/*if(row == maxrow)
down = true;
else*/ if((row < maxrow) and currline)
if((row < maxrow) and currline)
row++;
}
else {
@ -2730,7 +2623,7 @@ void UndoStack::PlayItem() {
}
}
// Move the cursor to EOL if necessary
else if((col+1) > strlen(currline->text))
else if(col+1 > currline->txt.length())
editor->GoEOL();
undo_ready = YES;
}

View File

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

View File

@ -60,22 +60,10 @@ void IEclass::Clip2Buf() {
}
// Copy the paragraph to the new line and retype it
Line* _newline = __line = insertlinebelow(__line, buf);
__line = insertlinebelow(__line, buf);
if(Edit__pastebuf == NULL)
Edit__pastebuf = _newline;
setlinetype(_newline);
// 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;
Edit__pastebuf = __line;
setlinetype(__line);
}
Undo->undo_enabled = YES;
throw_free(buf);
@ -86,25 +74,15 @@ void IEclass::Clip2Buf() {
void IEclass::Buf2Clip() {
gclipbrd clipbrd;
int buflen = 0;
Line *_bufline;
string clipdata;
for(_bufline = Edit__pastebuf; _bufline; _bufline = _bufline->next)
buflen += strlen(_bufline->text) + 1;
char *clipdata = (char *)throw_malloc(buflen);
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");
if(not _bufline->txt.empty()) {
clipdata += _bufline->txt;
if(*(clipdata.end()-1) == '\n')
clipdata.replace(clipdata.end()-1, clipdata.end(), "\r\n");
}
curptr += strlen(curptr);
}
clipbrd.writeclipbrd(clipdata);
throw_free(clipdata);
clipbrd.writeclipbrd(clipdata.c_str());
}

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)
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) {
if(not *filesize) {
// is a file-size given?
char* p = ptr;
const char* p = ptr;
while(strchr(".,0123456789bBkKmMgG", *p))
p++;
@ -669,10 +669,10 @@ void FileRequest(GMsg* msg) {
if(AA->Msgn.Count() and msg->line and msg->lines) {
char buf[256];
char* ptr;
char* ptr1;
char* ptr2;
char* txtptr;
const char* ptr;
const char* ptr1 = NULL;
const char* ptr2;
const char* txtptr;
char** freqfile = NULL;
int gotticket = false;
int getnextdesc = false;
@ -697,7 +697,7 @@ void FileRequest(GMsg* msg) {
if(lin[n]->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))
continue;
ptr = txtptr = lin[n]->text;
ptr = txtptr = lin[n]->txt.c_str();
// Skip past whitespace and highbit junk
while(((*ptr < '!') or (*ptr > '\x7F')) and *ptr)
@ -727,8 +727,9 @@ void FileRequest(GMsg* msg) {
else
ptr1 = ptr2;
ptr2 = strskip_txt(ptr1);
*ptr2 = NUL;
frqgetfile(file, desc, filesize, ptr1);
__extension__ char tmpbuf[ptr2-ptr1+1];
strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
frqgetfile(file, desc, filesize, tmpbuf);
*desc = NUL; // Description never comes before filename
continue;
}
@ -764,8 +765,9 @@ void FileRequest(GMsg* msg) {
if(txtptr[16] == '/' and txtptr[19] == '/' and txtptr[24] == '(' /*)*/) {
ptr1 = strskip_wht(txtptr);
ptr2 = strskip_txt(ptr1);
*ptr2 = NUL;
frqgetfile(file, desc, filesize, ptr1);
__extension__ char tmpbuf[ptr2-ptr1+1];
strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
frqgetfile(file, desc, filesize, tmpbuf);
*desc = NUL; // Description never comes before filename
gotticket = true;
continue;
@ -802,7 +804,7 @@ void FileRequest(GMsg* msg) {
for(e = CFG->frqext.begin(); e != CFG->frqext.end(); e++) {
if(strnicmpw(e->c_str(), ptr2, MinV(e->length(), strlen(ptr2))) == 0) {
// Find beginning of filename
char* ptr3 = ptr2-1;
const char* ptr3 = ptr2-1;
while((ptr3 > ptr) and not invalidfilechar(*ptr3))
ptr3--;
if(invalidfilechar(*ptr3))
@ -895,13 +897,14 @@ void FileRequest(GMsg* msg) {
msg->attr.frq1();
ptr = freqfile[n]+1; // 01234567890123456
ptr2 = strskip_txt(ptr);
*ptr2++ = NUL;
__extension__ char tmpbuf[ptr2-ptr1+1];
strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
ptr2 = strskip_wht(ptr2);
if((strlen(msg->re) + strlen(ptr)) < sizeof(ISub)) { // We can only fill one subject line in this version...
strcat(msg->re, ptr);
if((strlen(msg->re) + strlen(tmpbuf)) < sizeof(ISub)) { // We can only fill one subject line in this version...
strcat(msg->re, tmpbuf);
strcat(msg->re, " ");
if(fh != -1) {
sprintf(buf, "%-12s %s\n", ptr, ptr2);
sprintf(buf, "%-12s %s\n", tmpbuf, ptr2);
write(fh, buf, strlen(buf));
}
freqs++;
@ -913,13 +916,14 @@ void FileRequest(GMsg* msg) {
msg->attr.frq1();
ptr = freqfile[crsr]+1; // 01234567890123456
ptr2 = strskip_txt(ptr);
*ptr2++ = NUL;
__extension__ char tmpbuf[ptr2-ptr1+1];
strxcpy(tmpbuf, ptr1, ptr2-ptr1+1);
ptr2 = strskip_wht(ptr2);
if((strlen(msg->re) + strlen(ptr)) < sizeof(ISub)) { // We can only fill one subject line in this version...
strcat(msg->re, ptr);
if((strlen(msg->re) + strlen(tmpbuf)) < sizeof(ISub)) { // We can only fill one subject line in this version...
strcat(msg->re, tmpbuf);
strcat(msg->re, " ");
if(fh != -1) {
sprintf(buf, "%-12s %s\n", ptr, ptr2);
sprintf(buf, "%-12s %s\n", tmpbuf, ptr2);
write(fh, buf, strlen(buf));
}
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);
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];
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);
}
@ -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);
}
@ -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));
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));
}
@ -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];
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);
}
@ -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);
}
@ -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));
@ -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[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);
}
@ -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;
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;
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* 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* 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;
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);
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);
}
@ -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
//
@ -722,10 +722,7 @@ void KludgeDATE(GMsg* msg, char* ptr) {
// Setting timezone
ptr = strskip_wht(strskip_digits(ptr));
if(*ptr) {
if(*ptr == '(' /*)*/ ) {
char* p;
if((p = strskip_to(++ptr, /*(*/ ')')) != NULL) *p = 0;
}
if(*ptr == '(' /*)*/ ) ++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];
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);
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);
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));
}
@ -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));
}
@ -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));
}
@ -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);
}
@ -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));
}
@ -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);
}
@ -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));
}
@ -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));
}
@ -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));
}
@ -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) {
uint len = strlen(ptr);
char* uptr = throw_strdup(ptr);
while(line and (line->type & GLINE_WRAP)) {
if(line->next) {
uint nextlen = strlen(line->next->text);
uint nextlen = line->next->txt.length();
uptr = (char*)throw_realloc(uptr, len+nextlen+2);
if(addspace and len and (uptr[len-1] != ' ')) {
strcat(uptr, " ");
len++;
}
strcpy(uptr+len, line->next->text);
strcpy(uptr+len, line->next->txt.c_str());
len += nextlen;
}
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) {
@ -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) {
@ -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
int kludgenum = 0;
// Pointer to kludge id
char* kludge = ptr;
const char* kludge1 = ptr;
// Skip past "RFC" string, if any
if(strnieql(kludge, "RFC", 3) and (kludge[3] != ':')) {
kludge += 3;
if(not isalpha(*kludge))
kludge++;
if(strnieql(kludge1, "RFC", 3) and (kludge1[3] != ':')) {
kludge1 += 3;
if(not isalpha(*kludge1))
kludge1++;
}
// Keep copy of id terminating char
while((*ptr != ' ') and (*ptr != ':') and *ptr)
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
if(*kludge) {
@ -1362,7 +1361,6 @@ int ScanLine(GMsg* msg, Line* line, char* ptr, int getvalue, int mask) {
}
// Restore terminating char
*ptr = endchar;
if(*ptr != ' ')
ptr++;
@ -1402,7 +1400,7 @@ Line* next_non_empty(Line *line) {
Line* nl = line;
while(nl) {
if(nl->text and not *nl->text)
if(nl->txt.empty())
nl = nl->next;
else
break;
@ -1414,7 +1412,7 @@ Line* next_non_empty(Line *line) {
void ScanKludges(GMsg* msg, int getvalue) {
char* ptr;
const char* ptr;
int tearlineno = INT_MAX;
int originlineno = INT_MAX;
int gotorig=NO, gottear=NO, gottag=NO;
@ -1430,7 +1428,7 @@ void ScanKludges(GMsg* msg, int getvalue) {
Line* line = LastLine(msg->lin);
do {
ptr = line->text;
ptr = line->txt.c_str();
if(*ptr == CTRL_A) {
// Set kludge/hidden color
@ -1444,11 +1442,11 @@ void ScanKludges(GMsg* msg, int getvalue) {
}
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->kludge = GKLUD_AREA;
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);
Area* ap = AL.AreaEchoToPtr(areakludgeptr);
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)) {
// Found Origin line
bool cnd = line->next and line->next->text;
bool cnd = line->next != NULL;
Line* nnel = next_non_empty(line->next);
bool nextkl = cnd ? not nnel or nnel->type & GLINE_KLUDGE : false;
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) {
gotorig = YES;
originlineno = lineno;
line->type |= GLINE_ORIG;
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
strcat(msg->origin, line->next->text);
strcat(msg->origin, line->next->txt.c_str());
line->next->color = C_READO;
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;
if(q != line)
q->type |= GLINE_HARD;
if(q->text and strneql("----", q->text, 4))
if(strneql("----", q->txt.c_str(), 4))
break;
}
}
@ -1577,9 +1575,9 @@ void ScanKludges(GMsg* msg, int getvalue) {
for(line = msg->lin; line; line = line->next)
if(line->type & GLINE_KLUDGE)
continue;
else if(line->text) {
if(strnieql(line->text, "From:", 5)) {
char* ptr = line->text + 5;
else {
if(strnieql(line->txt.c_str(), "From:", 5)) {
const char* ptr = line->txt.c_str() + 5;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeFROM(msg, tmp ? tmp : ptr);
@ -1588,8 +1586,8 @@ void ScanKludges(GMsg* msg, int getvalue) {
if(not AA->isinternet())
*msg->ifrom = NUL;
}
else if(strnieql(line->text, "To:", 3)) {
char* ptr = line->text + 3;
else if(strnieql(line->txt.c_str(), "To:", 3)) {
const char* ptr = line->txt.c_str() + 3;
ptr = strskip_wht(ptr);
char* tmp = UnwrapLine(line, ptr);
KludgeTO(msg, tmp ? tmp : ptr);
@ -1601,8 +1599,6 @@ void ScanKludges(GMsg* msg, int getvalue) {
else
break;
}
else
break;
if(not gottag)
*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)
return stpcpy(dest, src);
@ -1650,7 +1646,7 @@ char* XlatStr(char* dest, char* src, int level, Chs* chrtbl, int qpencoded, bool
int translated;
char* tptr;
char* escp;
char* sptr = src;
const char* sptr = src;
char* dptr = dest;
char dochar;
ChsTab* chrs = chrtbl ? chrtbl->t : (ChsTab*)NULL;
@ -1880,8 +1876,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
line = msg->lin;
while(line) {
nextline = line->next;
throw_release(line->text);
throw_xfree(line);
throw_xdelete(line);
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);
@ -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(para != GLINE_QUOT) {
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;
break;
}
@ -2384,7 +2380,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
else
line->type |= GLINE_HARD;
*(bp+1) = NUL;
*(++bp/*+1*/) = NUL;
// Get line length
uint tmplinelength = (uint)((long)bp-(long)bptr);
@ -2396,32 +2392,28 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
}
// Store line
if(line->isallocated())
throw_free(line->text);
line->text = (char*)throw_malloc(tmplinelength+10);
line->type &= ~GLINE_NOAL;
memcpy(line->text, linetmp+1, tmplinelength+5);
prev_ptr[0] = line->text[0];
prev_ptr[1] = line->text[1];
line->txt = linetmp+1; // .assign(linetmp+1, tmplinelength+5);
prev_ptr[0] = line->txt.empty() ? 0xFF : line->txt[0];
prev_ptr[1] = line->txt.length() < 2 ? 0xFF : line->txt[1];
// 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;
if(line->type & GLINE_QUOT)
line->color = quotecolor(line->text);
line->color = quotecolor(line->txt.c_str());
else if(inheader)
line->color = C_READT;
else
line->color = C_READW;
// Scan msg body top for RFC headerlines
if((*line->text == NUL) and not firstemptyline) {
if(line->txt.empty() and not firstemptyline) {
firstemptyline = true;
if(AA->Internetrfcbody()) {
Line* linep = FirstLine(line);
int headerlines = 0;
while(linep) {
char* tptr = linep->text;
const char* tptr = linep->txt.c_str();
if(*tptr) {
if(*tptr != CTRL_A) {
int kludgetype = ScanLine(msg, linep, tptr, getvalue, MASK_RFC);
@ -2441,7 +2433,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
gotmime = true;
}
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)) {
gotmultipart = true;
gotmime = true;
@ -2492,13 +2484,13 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
else
linep->color = C_READK;
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)) {
linep = linep->next;
linep->type |= linep->prev->type;
linep->color = linep->prev->color;
if(linep->next)
lwsp = *linep->next->text;
lwsp = *linep->next->txt.c_str();
else
break;
}
@ -2526,16 +2518,15 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
}
prevline = line;
line = (Line*)throw_xcalloc(1, sizeof(Line));
line = new Line();
throw_xnew(line);
line->prev = prevline;
ptr = spanfeeds(ptr);
}
throw_release(linetmp);
if(line->isallocated())
throw_free(line->text);
throw_xfree(line);
throw_xdelete(line);
// Scan for kludge-, tear- and originlines
ScanKludges(msg, getvalue);
@ -2579,7 +2570,7 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
msg->lines++;
if(line->next) {
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)) {
line = AddLine(line, "");
msg->lines++;
@ -2587,10 +2578,12 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
}
}
else {
if(msg->attr.pos())
if(strischg(line->text, "@position", ""))
line->type |= GLINE_POSI;
if((line->next->type & GLINE_QUOT) and not strblank(line->text)) {
const char *posn, *posn2 = line->txt.c_str();
if(msg->attr.pos() and ((posn = striinc("@position", posn2)) != NULL)) {
line->txt.erase(posn - posn2, 9);
line->type |= GLINE_POSI;
}
if((line->next->type & GLINE_QUOT) and not strblank(line->txt.c_str())) {
if(CFG->switches.get(quotespacing)) {
line = AddLine(line, "");
msg->lines++;
@ -2632,15 +2625,15 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
}
else if(line->type & GLINE_QUOT) {
if(not viewquote) {
GetQuotestr(line->text, qbuf, &qlen);
GetQuotestr(line->txt.c_str(), qbuf, &qlen);
strtrim(qbuf);
if(strieql(qbuf0, qbuf)) {
if(strpbrk(line->text+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
if(strpbrk(line->txt.c_str()+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
qmatches++;
}
else {
strcpy(qbuf0, qbuf);
if(strpbrk(line->text+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
if(strpbrk(line->txt.c_str()+qlen, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
qmatches = 1;
else
qmatches = 0;
@ -2668,8 +2661,8 @@ void MsgLineReIndex(GMsg* msg, int viewhidden, int viewkludge, int viewquote) {
line = msg->lin;
while(line) {
if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) {
if(line->text) {
int n = strlen(line->text);
if(line->txt.c_str()) {
int n = line->txt.length();
nonquotes += n;
if(line->type & GLINE_QUOT)
quotes += n;
@ -2749,8 +2742,7 @@ Line* DeleteLine(Line* line) {
line->next->prev = line->prev;
nextline = line->next;
}
throw_release(line->text);
throw_xfree(line);
throw_xdelete(line);
}
return nextline;
@ -2807,13 +2799,10 @@ Line* LastLine(Line* line) {
Line* AddLine(Line* line, char* buf, int where) {
Line* newline;
newline = (Line*)throw_xcalloc(1, sizeof(Line));
Line* newline = new Line(buf);
throw_xnew(newline);
newline->type = GLINE_HARD;
newline->text = (char*)throw_malloc(strlen(buf)+10);
newline->color = C_READW;
strcpy(newline->text, buf);
return InsertLine(newline, line, where);
}
@ -2831,9 +2820,9 @@ Line* AddLine(Line* line, char* buf) {
Line* AddLineFast(Line* oldline, char* text) {
Line* newline = (Line*)throw_xcalloc(1, sizeof(Line));
newline->type = GLINE_HARD|GLINE_NOAL;
newline->text = text;
Line* newline = new Line(text);
throw_xnew(newline);
newline->type = GLINE_HARD;
newline->color = C_READW;
newline->prev = oldline;
newline->next = oldline->next;
@ -2848,14 +2837,10 @@ Line* AddLineFast(Line* oldline, char* text) {
Line* AddKludge(Line* line, char* buf, int where) {
Line* newline;
newline = (Line*)throw_xcalloc(1, sizeof(Line));
Line* newline = new Line(buf);
throw_xnew(newline);
newline->type = GLINE_HARD|GLINE_KLUD;
newline->text = (char*)throw_malloc(strlen(buf)+10);
newline->color = C_READK;
strcpy(newline->text, buf);
return InsertLine(newline, line, where);
}
@ -2996,9 +2981,9 @@ void InvalidateControlInfo(GMsg* msg) {
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
if(not CFG->invalidate.tearline.first.empty())
@ -3018,11 +3003,9 @@ void InvalidateControlInfo(GMsg* msg) {
else
doinvalidate(buf, "SEEN-BY: ", "SEEN+BY: ");
if(stricmp(buf, line->text)) {
if(stricmp(buf, line->txt.c_str())) {
line->type &= ~GLINE_KLUDGE;
throw_release(line->text);
line->text = (char*)throw_malloc(strlen(buf)+10);
strcpy(line->text, buf);
line->txt = buf;
}
}

View File

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

View File

@ -542,10 +542,9 @@ int GMenuEditfile::Run(GMsg* __msg) {
Line* _line = __msg->lin;
while(_line) {
if(_line->type & GLINE_TAGL) {
throw_release(_line->text);
sprintf(_buf, "%c%c%c %s ", AA->Taglinechar(), AA->Taglinechar(), AA->Taglinechar(), __msg->tagline);
_line->text = throw_strdup(_buf);
strtrim(_line->text);
strtrim(_buf);
_line->txt = _buf;
break;
}
_line = _line->next;
@ -565,10 +564,9 @@ int GMenuEditfile::Run(GMsg* __msg) {
Line* _line = __msg->lin;
while(_line) {
if(_line->type & GLINE_ORIG) {
throw_release(_line->text);
sprintf(_buf, " * Origin: %s ", __msg->origin);
_line->text = throw_strdup(_buf);
strtrim(_line->text);
strtrim(_buf);
_line->txt = _buf;
break;
}
_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) {
char c;
char* ptr;
int ptr;
int n;
Line* line;
static char rot13_table[256];
@ -375,9 +375,10 @@ void Rot13(GMsg* msg) {
line = msg->lin;
while(line) {
if(not (line->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))) {
ptr = line->text;
while((c = *ptr) != NUL)
*ptr++ = ROT13_DECODE(c);
for(ptr = 0; ptr != line->txt.length(); ptr++) {
c = line->txt[ptr];
line->txt[ptr] = ROT13_DECODE(c);
}
}
line = line->next;
}
@ -532,7 +533,7 @@ void GMsg::LinesToText() {
// Approximate the size of the text
while(_line) {
_alloc_size += strlen(_line->text);
_alloc_size += _line->txt.length();
_line = _line->next;
_lines++;
}
@ -553,10 +554,10 @@ void GMsg::LinesToText() {
char* _bptr;
bool _hterm = true;
if(_line->isheader()) {
_bptr = stpcpy(_buf, _line->text);
_bptr = stpcpy(_buf, _line->txt.c_str());
while(_line->next and _line->iswrapped()) {
_line = _line->next;
_bptr = stpcpy(_bptr, _line->text);
_bptr = stpcpy(_bptr, _line->txt.c_str());
if((_bptr-_buf) > (bufsize-256)) {
int bptrlen = (int)(_bptr - _buf);
bufsize += 4096;
@ -566,18 +567,16 @@ void GMsg::LinesToText() {
}
}
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(_line->next) {
if(_line->next->text) {
if((*(_bptr-1) != ' ') and (*_line->next->text != ' '))
if(_isezycom or not _hardterm)
*_bptr++ = ' ';
if(not _hardterm) {
if(_isezycom and not CFG->switches.get(dispsoftcr))
*_bptr++ = SOFTCR;
_hterm = false;
}
if((*(_bptr-1) != ' ') and (*_line->next->txt.c_str() != ' '))
if(_isezycom or not _hardterm)
*_bptr++ = ' ';
if(not _hardterm) {
if(_isezycom and not CFG->switches.get(dispsoftcr))
*_bptr++ = SOFTCR;
_hterm = false;
}
}
}

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
void LookupNode(GMsg* msg, char* name, int what) {
void LookupNode(GMsg* msg, const char* name, int what) {
Subj statuslinebak;
strcpy(statuslinebak, information);

View File

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

View File

@ -172,7 +172,7 @@ Line* InsertLine(Line* newline, Line* oldline, int pos);
Line* LastLine(Line* line);
void MakeLineIndex(GMsg* msg, int rmargin, bool header_recode = true);
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* strxmimecpy(char* dest, const char* source, int level, int size, bool detect = false);
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);
void LookupNode(GMsg* msg, char* name, int what);
void LookupNode(GMsg* msg, const char* name, int what);
void CheckNodelists();
@ -351,7 +351,7 @@ void CheckSemaphores();
// GESOUP prototypes
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 ExportSOUP();

View File

@ -417,7 +417,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
if(line->type & GLINE_KLUDGE) {
if(AA->isinternet()) {
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);
}
else if(line->type & GLINE_WRAP) {
@ -427,7 +427,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
}
else {
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);
}
}
@ -444,7 +444,7 @@ int ExportQwkMsg(GMsg* msg, gfile& fp, int confno, int& pktmsgno) {
line = msg->lin;
while(line) {
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);
}
line = line->next;

View File

@ -776,7 +776,7 @@ void make_pathreport(const char* reportfile) {
Line* line = msg->lin;
while(line) {
if(line->kludge == GKLUD_PATH)
path += line->text + 6;
path += line->txt.c_str() + 6;
line = line->next;
}
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);
char* bptr = msgidbuf + strlen(msgidbuf);
@ -639,7 +639,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
while(line) {
if(line->type & GLINE_KLUDGE) {
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");
}
else if(line->type & GLINE_WRAP) {
@ -657,7 +657,7 @@ int ExportSoupMsg(GMsg* msg, char* msgfile, gfile& fp, int ismail) {
line = msg->lin;
while(line) {
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;
if(qp and strlen(mptr) > 76) {
// 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))
search_this_line = true;
if(search_this_line) {
if(item->search(line->text)) {
if(item->search(line->txt.c_str())) {
line->type |= GLINE_HIGH;
if(type & (GLINE_TAGL|GLINE_TEAR|GLINE_ORIG|GLINE_SIGN|GLINE_KLUDGE)) {
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;
*buf = NUL;
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) {
// Invalidate tearline
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
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);
strbtrim(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) {
n = 0;
while(oldmsg->line[n]) {
if(oldmsg->line[n]->text) {
strcpy(buf, oldmsg->line[n]->text);
if(oldmsg->line[n]->txt.c_str()) {
strcpy(buf, oldmsg->line[n]->txt.c_str());
if(mode == MODE_FORWARD) {
// Invalidate tearline
if(not CFG->invalidate.tearline.first.empty())
@ -720,11 +720,9 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
}
else {
if(oldmsg->line[n+1]) {
if(oldmsg->line[n+1]->text) {
if(msg->txt[pos-1] != ' ' and *oldmsg->line[n+1]->text != ' ') {
msg->txt[pos++] = ' ';
size++;
}
if(msg->txt[pos-1] != ' ' and *oldmsg->line[n+1]->txt.c_str() != ' ') {
msg->txt[pos++] = ' ';
size++;
}
}
}

View File

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

View File

@ -370,7 +370,7 @@ void GMsgBodyView::Create() {
scrollbar_color
);
dummy_line.text = "";
dummy_line.txt = "";
dummy_line.type = 0;
dummy_line.color = window_color;
@ -432,7 +432,7 @@ void GMsgBodyView::PaintLine(int row, Line *line) {
// Calculate effective coordinates for vputs
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;
@ -440,22 +440,22 @@ void GMsgBodyView::PaintLine(int row, Line *line) {
// cases, but always when hex dump displayed.
if(llen > visible_width) {
llen = visible_width;
line->text[llen] = NUL;
line->txt.erase(llen);
}
// Print it
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: ");
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
StyleCodeHighlight(line->text, vrow, 0, not AA->attr().hex() and CFG->hidestylies, color);
int tlen = strlen(line->text);
StyleCodeHighlight(line->txt.c_str(), vrow, 0, not AA->attr().hex() and CFG->hidestylies, color);
int tlen = strlen(line->txt.c_str());
vputns(vrow, tlen, color, "", visible_width-tlen);
}
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(fake_clipboard)

View File

@ -58,7 +58,7 @@ public:
char* read(char* buffer, int maxlen);
void close();
bool writeclipbrd(char* buf);
bool writeclipbrd(const char* buf);
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)
return -1;

View File

@ -64,7 +64,7 @@ void g_set_osicon(void);
bool g_is_clip_available(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_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;
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;
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;
char buf[81];

View File

@ -143,10 +143,14 @@ public:
int color; // Line color
uint type; // GLINE_*
uint kludge; // GKLUD_*
char* text; // Pointer to the line text
string txt; // The line text
Line* prev; // Pointer to previous 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 isorigin() { return !!(type & GLINE_ORIG); }
int ishidden() { return !!(type & GLINE_HIDD); }