Naive fix for quoted words with execvp.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9128 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-10-25 14:21:42 +00:00
parent f6a49ae0f7
commit 292c3210f6
2 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2004-10-25 Angus Leeming <leeming@lyx.org>
* forkedcall.C (generateChild): strip quotes from each argument
of argv.
2004-09-26 Lars Gullik Bjonnes <larsbj@gullik.net> 2004-09-26 Lars Gullik Bjonnes <larsbj@gullik.net>
* pch.h: use proper signal include * pch.h: use proper signal include

View File

@ -270,6 +270,29 @@ int Forkedcall::generateChild()
argv.push_back(&*vit); argv.push_back(&*vit);
prev = *vit; prev = *vit;
} }
// Strip quotes. Does so naively, assuming that the word begins
// and ends in quotes.
vector<char *>::iterator ait = argv.begin();
vector<char *>::iterator const aend = argv.end();
for (; ait != aend; ++ait) {
char * word = *ait;
std::size_t const len = strlen(word);
if (len >= 2) {
char & first = word[0];
char & last = word[len-1];
if (first == last &&
(first == '\'' || first == '"')) {
first = '\0';
last = '\0';
*ait += 1;
}
}
}
ait = argv.begin();
for (; ait != aend; ++ait)
std::cout << *ait << std::endl;
argv.push_back(0); argv.push_back(0);
#ifndef __EMX__ #ifndef __EMX__