summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/util.cc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-04-19 23:59:33 +0000
committerKarl Berry <karl@freefriends.org>2010-04-19 23:59:33 +0000
commitdddce3148a2bc785603576b18ffcf72d39adbe47 (patch)
tree14f4c79ef11bcf0820a8d4ff2ab0c5ac009c365c /Build/source/utils/asymptote/util.cc
parenta01e51b01f5819b6091af48cdca581e9f2a9282e (diff)
asy 1.93
git-svn-id: svn://tug.org/texlive/trunk@17934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/util.cc')
-rw-r--r--Build/source/utils/asymptote/util.cc36
1 files changed, 21 insertions, 15 deletions
diff --git a/Build/source/utils/asymptote/util.cc b/Build/source/utils/asymptote/util.cc
index b9c7db35155..9e307a20800 100644
--- a/Build/source/utils/asymptote/util.cc
+++ b/Build/source/utils/asymptote/util.cc
@@ -103,12 +103,14 @@ string stripFile(string name)
p=name.rfind('\\');
if(p < string::npos) {
dir=true;
+ while(p > 0 && name[p-1] == '\\') --p;
name.erase(p+1);
}
#endif
p=name.rfind('/');
if(p < string::npos) {
dir=true;
+ while(p > 0 && name[p-1] == '/') --p;
name.erase(p+1);
}
@@ -150,26 +152,30 @@ string Getenv(const char *name, bool msdos)
void writeDisabled()
{
- camp::reportError("Write/cd to other directories disabled; override with option -globalwrite");
+ camp::reportError("Write to other directories disabled; override with option -globalwrite");
}
-void checkLocal(string name)
+string cleanpath(string name)
{
- if(globalwrite()) return;
-#ifdef __CYGWIN__
- if(name.rfind('\\') < string::npos) writeDisabled();
-#endif
- if(name.rfind('/') < string::npos) writeDisabled();
- return;
+ string dir=stripFile(name);
+ name=stripDir(name);
+ spaceToUnderscore(name);
+ return dir+name;
+}
+
+string outpath(string name)
+{
+ bool global=globalwrite();
+ string dir=stripFile(name);
+ if(global && !dir.empty()) return name;
+ string outdir=stripFile(outname());
+ if(!(global || dir.empty() || dir == outdir)) writeDisabled();
+ return outdir+stripDir(name);
}
string buildname(string name, string suffix, string aux)
{
- string dir=stripFile(outname());
- name=globalwrite() ? dir+name : dir+stripDir(name);
-
- name=stripExt(name,defaultformat());
- name += aux;
+ name=stripExt(outpath(name),defaultformat())+aux;
if(!suffix.empty()) name += "."+suffix;
return name;
}
@@ -286,7 +292,7 @@ int System(const mem::vector<string> &command, int quiet, bool wait,
if(quiet < 2) {
ostringstream msg;
msg << "Command failed: ";
- for(size_t i=0; i < command.size(); ++i) msg << command[i];
+ for(size_t i=0; i < command.size(); ++i) msg << command[i] << " ";
camp::reportError(msg);
}
}
@@ -305,7 +311,7 @@ int System(const mem::vector<string> &command, int quiet, bool wait,
if(quiet < 2) {
ostringstream msg;
msg << "Command exited abnormally: ";
- for(size_t i=0; i < command.size(); ++i) msg << command[i];
+ for(size_t i=0; i < command.size(); ++i) msg << command[i] << " ";
camp::reportError(msg);
}
}