various fixes

This commit is contained in:
Alexander S. Aganichev
2000-11-27 06:15:29 +00:00
parent 8ef102eff3
commit 2bce072dd1
18 changed files with 116 additions and 179 deletions

View File

@@ -2146,8 +2146,6 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
if(marginquotes > margintext)
marginquotes = margintext;
whelppcat(H_Editor);
if(currline == NULL) {
currline = new Line("\n");
throw_xnew(currline);
@@ -2266,7 +2264,6 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
msgptr->lin = findfirstline();
savefile(quitnow ? MODE_UPDATE : MODE_SAVE);
whelpop();
// Prune killbuffer
if(Edit__killbuf) {
@@ -2336,6 +2333,7 @@ UndoStack::~UndoStack() {
while(last_item) {
switch(last_item->action & EDIT_UNDO_ACTION) {
case EDIT_UNDO_DEL_TEXT:
case EDIT_UNDO_INS_TEXT:
case EDIT_UNDO_WRAP_TEXT:
throw_delete(last_item->data.text_ptr);
break;

View File

@@ -92,6 +92,7 @@ void IEclass::windowopen() {
gwin.style = STYLE_NOCLEAR;
editwin.open(win_minrow, win_mincol, win_maxrow, win_maxcol, 5, C_READB, C_READW, C_READPB);
gwin.style = _tmp;
whelppcat(H_Editor);
}
@@ -99,6 +100,7 @@ void IEclass::windowopen() {
void IEclass::windowclose() {
whelpop();
// Close editor window without removing the window itself
editwin.unlink();
}
@@ -629,13 +631,15 @@ void IEclass::BlockDel(Line* anchor) {
// The firstcutline and lastcutline pointers
// are now pointing where they should
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol);
if(firstcutline != lastcutline) {
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol);
firstcutline->txt.erase(firstcol);
firstcutline->txt += lastcutline->txt.c_str()+lastcol;
}
else
else {
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol, lastcol-firstcol);
firstcutline->txt.erase(firstcol, lastcol-firstcol);
}
setlinetype(firstcutline);
firstcutline->type &= ~GLINE_BLOK;
blockcol = -1;
@@ -901,10 +905,10 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
ImportMode = MenuImportTxt.Run();
}
Path filenamebuf, tmpfile;
string filenamebuf;
Path tmpfile;
bool isPipe = NO;
char* _filenameptr = filenamebuf;
char* _selectedfile = NULL;
bool fileselected = false;
// Should the imported text be quoted or uuencoded?
#define quoteit (ImportMode == 1)
@@ -918,79 +922,71 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
AA->SetInputfile(CFG->inputfile);
// Pointer to the filename string
_filenameptr = strcpy(filenamebuf, AA->Inputfile());
filenamebuf = AA->Inputfile();
if(_filenameptr[0] == '|'){
if(filenamebuf.c_str()[0] == '|'){
Path cmdline;
isPipe = YES;
mktemp(strcpy(tmpfile, AddPath(CFG->goldpath, "GIXXXXXX")));
strxmerge(cmdline, sizeof(Path), _filenameptr+1, " > ", tmpfile, NULL);
mktemp(strxcpy(tmpfile, AddPath(CFG->goldpath, "GIXXXXXX"), sizeof(Path)));
strxmerge(cmdline, sizeof(Path), filenamebuf.c_str()+1, " > ", tmpfile, NULL);
ShellToDos(cmdline, "", NO, NO);
_selectedfile = _filenameptr = tmpfile;
filenamebuf = tmpfile;
fileselected = true;
} else {
// Check for wildcards
// Is the filename a directory?
if(is_dir(_filenameptr)) {
if(is_dir(filenamebuf)) {
// Does the filename contain wildcards?
if(not strpbrk(_filenameptr, "*?")) {
if(not strpbrk(filenamebuf.c_str(), "*?")) {
// Add match-all wildcards
strcat(AddBackslash(_filenameptr), "*");
AddBackslash(filenamebuf);
filenamebuf += "*";
}
}
// Pointer to selected filename or NULL if no file is selected
_selectedfile = _filenameptr;
fileselected = true;
// Does the filename contain wildcards?
if(strpbrk(_filenameptr, "*?")) {
if(strpbrk(filenamebuf.c_str(), "*?")) {
// Set selection window title and statusline
set_title(LNG->ImportTitle, TCENTER, C_MENUT);
update_statuslinef(LNG->ImportStatus, _filenameptr);
// Copy filename with wildcards to a temp buffer
Path _filenamebuf;
strcpy(_filenamebuf, _filenameptr);
update_statuslinef(LNG->ImportStatus, filenamebuf.c_str());
// Start the file picker
_selectedfile = wpickfile(
win_minrow,
win_mincol,
win_maxrow,
win_maxcol,
W_BMENU,
C_MENUB,
C_MENUW,
C_MENUS,
NO,
_filenamebuf,
_filenameptr,
maketitle
);
// If a file was selected, copy the filename
if(_selectedfile)
strcpy(_filenameptr, _selectedfile);
fileselected = wpickfile(win_minrow, win_mincol, win_maxrow, win_maxcol, W_BMENU, C_MENUB, C_MENUW, C_MENUS, NO, filenamebuf, maketitle);
}
}
}
if(_selectedfile or getclip) {
if(fileselected or getclip) {
// Open the file/clipboard
FILE* fp = NULL;
gclipbrd clipbrd;
if(getclip)
_filenameptr = strcpy(filenamebuf, CLIP_NAME);
filenamebuf = CLIP_NAME;
if(getclip ? clipbrd.openread() :
(fp = fsopen(_filenameptr, binary ? "rb" : "rt", CFG->sharemode))!=NULL) {
(fp = fsopen(filenamebuf.c_str(), binary ? "rb" : "rt", CFG->sharemode))!=NULL) {
update_statuslinef(LNG->ImportStatus, _filenameptr);
if (isPipe)
filenamebuf = AA->Inputfile();
const char *imp_filename = (getclip or isPipe) ? filenamebuf.c_str() : CleanFilename(filenamebuf.c_str());
// we need to truncate filename to prevent unpredictable results
int delta = strlen(imp_filename) - margintext;
if(delta > 0) {
filenamebuf.erase(filenamebuf.length()-delta);
imp_filename = (getclip or isPipe) ? filenamebuf.c_str() : CleanFilename(filenamebuf.c_str());
}
update_statuslinef(LNG->ImportStatus, filenamebuf.c_str());
// Allocate paragraph read buffer
char* _parabuf = (char*)throw_malloc(EDIT_PARABUFLEN);
@@ -1004,15 +1000,18 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Add import begin text, if any
if(*CFG->importbegin) {
sprintf(_parabuf, "%s\n", CFG->importbegin);
strischg(_parabuf, "@file", getclip ? _filenameptr : isPipe ? AA->Inputfile() : CleanFilename(_filenameptr));
strischg(_parabuf, "@file", imp_filename);
_parabuf[margintext] = NUL;
_parabuf[margintext-1] = '\n';
__line = insertlinebelow(__line, _parabuf);
setlinetype(__line);
}
if(uuencode) {
sprintf(_parabuf, "begin 644 %s\n", CleanFilename(_filenameptr));
sprintf(_parabuf, "begin 644 %s\n", imp_filename);
_parabuf[margintext] = NUL;
_parabuf[margintext-1] = '\n';
__line = insertlinebelow(__line, _parabuf);
setlinetype(__line);
@@ -1046,7 +1045,8 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
base64_engine b64;
sprintf(_parabuf, "Content-type: application/octet-stream; name=\"%s\"\n", CleanFilename(_filenameptr));
sprintf(_parabuf, "Content-type: application/octet-stream; name=\"%s\"\n", imp_filename);
strcpy(_parabuf+margintext-2, "\"\n");
__line = insertlinebelow(__line, _parabuf);
setlinetype(__line);
sprintf(_parabuf, "Content-transfer-encoding: base64\n");
@@ -1162,8 +1162,9 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Add import end text, if any
if(*CFG->importend or *CFG->importbegin) {
sprintf(_parabuf, "%s\n", *CFG->importend ? CFG->importend : CFG->importbegin);
strischg(_parabuf, "@file", getclip ? _filenameptr : isPipe ? AA->Inputfile() : CleanFilename(_filenameptr));
strischg(_parabuf, "@file", imp_filename);
_parabuf[margintext] = NUL;
_parabuf[margintext-1] = '\n';
__line = insertlinebelow(__line, _parabuf);
setlinetype(__line);
}
@@ -1176,7 +1177,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
fclose(fp);
}
else {
w_infof(LNG->CouldNotOpen, _filenameptr);
w_infof(LNG->CouldNotOpen, filenamebuf.c_str());
waitkeyt(10000);
w_info(NULL);
}

View File

@@ -32,10 +32,10 @@
// ------------------------------------------------------------------
char CFG__frqinvfilechars[40] = { "\"()+,.\\/:;<=>[]| \xff@" };
char CFG__frqinvfilechars[40] = { "\"()+,.\\/:;<=>[]| @" };
char CFG__frqskipwordchars[40] = { "0123456789-[" };
inline char* invalidfilechar(char ch) { return strchr(CFG__frqinvfilechars, ch); }
inline bool invalidfilechar(char ch) { return not isascii(ch&0xff) or strchr(CFG__frqinvfilechars, ch); }
// ------------------------------------------------------------------
@@ -574,18 +574,15 @@ static int frqchkdesc(char* desc) {
if(*desc == NUL)
strcpy(desc, " ");
else {
while(*ptr) {
if(isalnum(*ptr))
break;
while(*ptr and not isxalnum(*ptr))
ptr++;
}
if(*ptr == NUL) {
*desc = NUL;
return true;
}
}
ptr = desc + strlen(desc) - 1;
while(((*ptr < '!') or (*ptr > '\x7F')) and (ptr>desc))
while(not isascii(*ptr&0xff) and not isxalnum(*ptr) and (ptr>desc))
*ptr-- = NUL;
return false;
@@ -607,11 +604,11 @@ static int frqgetfile(char* file, char* desc, char* filesize, const char* txt) {
if(not invalidfilechar(*ptr) and ((ptr - txt) > 1)) {
// Find end of extension
while(*ptr and (*ptr != ' '))
while(*ptr and ((*ptr == '.') or not invalidfilechar(*ptr)))
ptr++;
// Strip invalid chars from the end of the extension
while(invalidfilechar(*(ptr-1)))
// Strip dots from the end of the extension
while(*(ptr-1) == '.')
ptr--;
// Copy the filename

View File

@@ -428,7 +428,7 @@ int EditHeaderinfo(int mode, GMsgHeaderView &view) {
ChgAttrs(false, msg);
whelpcat(help);
// whelppcat(help);
if(not hedit.dropped and not gkbd.quitall) {

View File

@@ -529,6 +529,7 @@ int SelectFromFile(const char* file, char* selection, const char* title, const c
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, 0, title_shadow);
if(n != -1) {
strcpy(selection, Listi[n]);
strtrim(selection);
retval = true;
}
for(n=0; n<lines; n++)

View File

@@ -997,9 +997,6 @@ int GMenuNavigate::Run() {
TAG_UTIL_LIST = (int)KK_ReadMessageList,
TAG_UTIL_WRITE = (int)KK_ReadWriteMsg,
TAG_UTIL_FREQ = (int)KK_ReadFileRequest,
TAG_HELP = 104,
TAG_HELP_GENERAL,
TAG_HELP_ABOUT,
TAG_SEPARATOR,
TAG_END
};
@@ -1047,12 +1044,6 @@ int GMenuNavigate::Run() {
Item(TAG_UTIL_WRITE, "W Write to disk/printer ");
Item(TAG_UTIL_FREQ, "F File request ");
End();
Item(TAG_UTIL, "H Help ");
BeginPullDown();
Item(TAG_HELP_GENERAL, "G General ");
Item(TAG_SEPARATOR, "----------", M_NOSEL);
Item(TAG_HELP_ABOUT, "A About ");
End();
End();
Start();
if((finaltag >= TAG_MAIN) and (finaltag < (TAG_END*10)))

View File

@@ -107,7 +107,7 @@ void CheckSubject(GMsg* msg, char* subj) {
fspec = (FileSpec*)throw_realloc(fspec, (fspecs+1)*sizeof(FileSpec));
memset(fspec+fspecs, 0, sizeof(FileSpec));
fspec[fspecs].files = 1;
strcpy(fspec[fspecs].path, ptr);
strxcpy(fspec[fspecs].path, ptr, sizeof(Path));
specfiles++;
fspecs++;
}
@@ -120,9 +120,9 @@ void CheckSubject(GMsg* msg, char* subj) {
ISub buf;
if(strblank(subj)) {
if(*CFG->attachpath)
strcpy(subj, CFG->attachpath);
strxcpy(subj, CFG->attachpath, sizeof(ISub));
else
strcpy(subj, CFG->goldpath);
strxcpy(subj, CFG->goldpath, sizeof(ISub));
}
strcpy(buf, subj);
char* ptr = strtok(buf, " ");
@@ -133,7 +133,7 @@ void CheckSubject(GMsg* msg, char* subj) {
fspec[fspecs].delsent = YES;
ptr++;
}
strcpy(fspec[fspecs].path, ptr);
strxcpy(fspec[fspecs].path, ptr, sizeof(Path));
FileSelect(msg, LNG->AttachFiles, &fspec[fspecs]);
specfiles += fspec[fspecs].files;
if(fspec[fspecs].files)
@@ -156,7 +156,7 @@ void CheckSubject(GMsg* msg, char* subj) {
else {
fspec = (FileSpec*)throw_realloc(fspec, (fspecs+1)*sizeof(FileSpec));
memset(fspec+fspecs, 0, sizeof(FileSpec));
strcpy(fspec[fspecs].path, ptr);
strxcpy(fspec[fspecs].path, ptr, sizeof(Path));
FileSelect(msg, LNG->UpdreqFiles, &fspec[fspecs]);
specfiles += fspec[fspecs].files;
if(fspec[fspecs].files)

View File

@@ -45,11 +45,10 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
if(FiletimeCmp(__file, idxfile) > 0)
idxexist = false;
FILE* fpi = fsopen(idxfile, idxexist ? "rb" : "wb+", CFG->sharemode);
if(fpi) {
// Create index if one was missing
if(not idxexist) {
// Create index if one was missing
if(not idxexist) {
FILE* fpi = fsopen(idxfile, "wb+", CFG->sharemode);
if(fpi) {
setvbuf(fp, NULL, _IOFBF, 32000);
setvbuf(fpi, NULL, _IOFBF, 16000);
long fpos = 0;
@@ -58,7 +57,12 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
fwrite(&fpos, sizeof(long), 1, fpi);
fpos += strlen(buf);
}
fclose(fpi);
}
}
FILE* fpi = fsopen(idxfile, "rb", CFG->sharemode);
if(fpi) {
// Get random line if there is at least one
int _lines = (int)(fsize(fpi)/sizeof(long));

View File

@@ -635,7 +635,7 @@ void UUDecode(GMsg* msg) {
w_progress(MODE_UPDATE, C_INFOW, n+1, AA->Mark.Count(), LNG->Preparing);
AA->LoadMsg(msg, AA->Mark[n], 79);
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, infile, msg);
}
}
if(AA->Mark.Count())
w_progress(MODE_QUIT, 0, 0, 0, NULL);
}

View File

@@ -270,6 +270,7 @@ void addressbook_form::LoadForm() {
voicephone= entry.voicephone;
faxphone = entry.faxphone;
dataphone = entry.dataphone;
group = entry.group;
snail1 = entry.snail1;
snail2 = entry.snail2;
snail3 = entry.snail3;
@@ -295,6 +296,7 @@ void addressbook_form::SaveForm() {
strcpy(entry.voicephone, voicephone.c_str());
strcpy(entry.faxphone, faxphone.c_str());
strcpy(entry.dataphone, dataphone.c_str());
entry.group = group.c_str()[0];
strcpy(entry.snail1, snail1.c_str());
strcpy(entry.snail2, snail2.c_str());
strcpy(entry.snail3, snail3.c_str());
@@ -373,10 +375,11 @@ bool guserbase::edit_entry(uint idx) {
form.add_field(addressbook_form::id_voicephone, 5, 13, 20, form.voicephone, sizeof(entry.voicephone));
form.add_field(addressbook_form::id_faxphone, 6, 13, 20, form.faxphone, sizeof(entry.faxphone));
form.add_field(addressbook_form::id_dataphone, 7, 13, 20, form.dataphone, sizeof(entry.dataphone));
form.add_field(addressbook_form::id_group, 8, 13, 20, form.group, sizeof(entry.group)+1);
form.add_field(addressbook_form::id_snail1, 5, 46, 26, form.snail1, sizeof(entry.snail1));
form.add_field(addressbook_form::id_snail2, 6, 46, 26, form.snail2, sizeof(entry.snail2));
form.add_field(addressbook_form::id_snail2, 6, 46, 26, form.snail2, sizeof(entry.snail2));
form.add_field(addressbook_form::id_snail3, 7, 46, 26, form.snail3, sizeof(entry.snail3));
form.add_field(addressbook_form::id_homepage , 8, 46, 26, form.homepage, sizeof(entry.homepage));
form.add_field(addressbook_form::id_homepage, 8, 46, 26, form.homepage, sizeof(entry.homepage));
form.add_field(addressbook_form::id_comment1, 9, 13, 59, form.comment1, sizeof(entry.comment1));
form.add_field(addressbook_form::id_comment2, 10, 13, 59, form.comment2, sizeof(entry.comment2));
form.add_field(addressbook_form::id_comment3, 11, 13, 59, form.comment3, sizeof(entry.comment3));

View File

@@ -98,6 +98,7 @@ class addressbook_form : public gwinput2 {
string voicephone;
string faxphone;
string homepage;
string group;
string comment1;
string comment2;
string comment3;

View File

@@ -117,11 +117,12 @@ void update_statusline(const char* info) {
void update_statuslinef(const char* format, ...) {
char winfobuf[350];
va_list argptr;
va_start(argptr, format);
vsprintf(information, format, argptr);
vsprintf(winfobuf, format, argptr);
va_end(argptr);
update_statuslines();
update_statusline(winfobuf);
}