New set of patches from Sir Raorn: quote and pipe.

This commit is contained in:
Jacobo Tarrío 2000-09-19 14:23:47 +00:00
parent 273c7029e9
commit e3360e463b

View File

@ -780,6 +780,8 @@ void IEclass::LoadFile() {
FILE* _fp = fsopen(AddPath(CFG->goldpath, EDIT->File()), "rb", CFG->sharemode); FILE* _fp = fsopen(AddPath(CFG->goldpath, EDIT->File()), "rb", CFG->sharemode);
if(_fp) { if(_fp) {
XlatName __oldxlatimport;
// Pop up a wait window // Pop up a wait window
cursoroff(); cursoroff();
w_info(LNG->Wait); w_info(LNG->Wait);
@ -813,10 +815,17 @@ void IEclass::LoadFile() {
fread(msgptr->txt, 1, (uint)fsize(_fp), _fp); fread(msgptr->txt, 1, (uint)fsize(_fp), _fp);
fclose(_fp); fclose(_fp);
// Save current charset
strcpy(__oldxlatimport, AA->Xlatimport());
AA->SetXlatimport(CFG->xlatlocalset);
// Index message text // Index message text
msgptr->TextToLines(margintext-1); msgptr->TextToLines(margintext-1);
_line = currline = msgptr->lin; _line = currline = msgptr->lin;
// Restore charset
AA->SetXlatimport(__oldxlatimport);
// Change lines to internal editor format // Change lines to internal editor format
while(_line) { while(_line) {
strtrim(_line->txt); strtrim(_line->txt);
@ -892,7 +901,8 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
ImportMode = MenuImportTxt.Run(); ImportMode = MenuImportTxt.Run();
} }
Path filenamebuf; Path filenamebuf, tmpfile;
bool isPipe = NO;
char* _filenameptr = filenamebuf; char* _filenameptr = filenamebuf;
char* _selectedfile = NULL; char* _selectedfile = NULL;
@ -910,6 +920,15 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Pointer to the filename string // Pointer to the filename string
_filenameptr = strcpy(filenamebuf, AA->Inputfile()); _filenameptr = strcpy(filenamebuf, AA->Inputfile());
if(_filenameptr[0] == '|'){
Path cmdline;
isPipe = YES;
mktemp(strcpy(tmpfile, AddPath(CFG->goldpath, "GIXXXXXX")));
strxmerge(cmdline, sizeof(Path), _filenameptr+1, " > ", tmpfile, NULL);
ShellToDos(cmdline, "", NO, NO);
_selectedfile = _filenameptr = tmpfile;
} else {
// Check for wildcards // Check for wildcards
// Is the filename a directory? // Is the filename a directory?
if(is_dir(_filenameptr)) { if(is_dir(_filenameptr)) {
@ -957,6 +976,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
strcpy(_filenameptr, _selectedfile); strcpy(_filenameptr, _selectedfile);
} }
} }
}
if(_selectedfile or getclip) { if(_selectedfile or getclip) {
@ -984,7 +1004,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Add import begin text, if any // Add import begin text, if any
if(*CFG->importbegin) { if(*CFG->importbegin) {
sprintf(_parabuf, "%s\n", CFG->importbegin); sprintf(_parabuf, "%s\n", CFG->importbegin);
strischg(_parabuf, "@file", getclip ? _filenameptr : CleanFilename(_filenameptr)); strischg(_parabuf, "@file", getclip ? _filenameptr : isPipe ? AA->Inputfile() : CleanFilename(_filenameptr));
_parabuf[margintext] = NUL; _parabuf[margintext] = NUL;
__line = insertlinebelow(__line, _parabuf); __line = insertlinebelow(__line, _parabuf);
setlinetype(__line); setlinetype(__line);
@ -1142,7 +1162,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Add import end text, if any // Add import end text, if any
if(*CFG->importend or *CFG->importbegin) { if(*CFG->importend or *CFG->importbegin) {
sprintf(_parabuf, "%s\n", *CFG->importend ? CFG->importend : CFG->importbegin); sprintf(_parabuf, "%s\n", *CFG->importend ? CFG->importend : CFG->importbegin);
strischg(_parabuf, "@file", getclip ? _filenameptr : CleanFilename(_filenameptr)); strischg(_parabuf, "@file", getclip ? _filenameptr : isPipe ? AA->Inputfile() : CleanFilename(_filenameptr));
_parabuf[margintext] = NUL; _parabuf[margintext] = NUL;
__line = insertlinebelow(__line, _parabuf); __line = insertlinebelow(__line, _parabuf);
setlinetype(__line); setlinetype(__line);
@ -1160,6 +1180,9 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
waitkeyt(10000); waitkeyt(10000);
w_info(NULL); w_info(NULL);
} }
if(isPipe)
unlink(tmpfile);
} }
AA->SetXlatimport(__oldxlatimport); AA->SetXlatimport(__oldxlatimport);