summaryrefslogtreecommitdiff
path: root/graphics/asymptote/runstring.in
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/asymptote/runstring.in')
-rw-r--r--graphics/asymptote/runstring.in72
1 files changed, 36 insertions, 36 deletions
diff --git a/graphics/asymptote/runstring.in b/graphics/asymptote/runstring.in
index a8b0e68bce..915811c7ff 100644
--- a/graphics/asymptote/runstring.in
+++ b/graphics/asymptote/runstring.in
@@ -35,16 +35,16 @@ static const string defaulttimeformat=string("%a %b %d %T %Z %Y");
#ifdef HAVE_STRFTIME
static const size_t nTime=256;
static char Time[nTime];
-#endif
+#endif
-void checkformat(const char *ptr, bool intformat)
+void checkformat(const char *ptr, bool intformat)
{
while(*ptr != '\0') {
if(*ptr != '%') /* While we have regular characters, print them. */
ptr++;
else { /* We've got a format specifier. */
ptr++;
-
+
while(*ptr && strchr ("-+ #0'I", *ptr)) /* Move past flags. */
ptr++;
@@ -52,7 +52,7 @@ void checkformat(const char *ptr, bool intformat)
ptr++;
else while(isdigit(*ptr)) /* Handle explicit numeric value. */
ptr++;
-
+
if(*ptr == '.') {
ptr++; /* Go past the period. */
if(*ptr == '*') {
@@ -63,7 +63,7 @@ void checkformat(const char *ptr, bool intformat)
}
while(*ptr && strchr ("hlL", *ptr))
ptr++;
-
+
if(*ptr == '%') {++ptr; continue;}
else if(*ptr != '\0') {
if(intformat) {
@@ -78,7 +78,7 @@ void checkformat(const char *ptr, bool intformat)
break;
default:
ostringstream buf;
- buf << "Invalid format '" << *ptr << "' for type "
+ buf << "Invalid format '" << *ptr << "' for type "
<< types::names[types::ty_Int];
error(buf);
break;
@@ -105,7 +105,7 @@ void checkformat(const char *ptr, bool intformat)
} /* End of else statement */
}
}
-
+
// Autogenerated routines:
@@ -157,7 +157,7 @@ string erase(string s, Int pos, Int n)
{
if ((size_t) pos < s.length())
return s.erase(pos,n);
- return s;
+ return s;
}
string downcase(string s)
@@ -187,7 +187,7 @@ string replace(string *S, stringarray2 *translate)
for(size_t i=0; i < size;) {
array *a=read<array*>(translate,i);
size_t size2=checkArray(a);
- if(size2 != 2)
+ if(size2 != 2)
error("translation table entry must be an array of length 2");
string* from=read<string*>(a,0);
size_t len=from->length();
@@ -202,12 +202,12 @@ string replace(string *S, stringarray2 *translate)
return buf.str();
}
-string format(string *format, Int x, string locale=emptystring)
+string format(string *format, Int x, string locale=emptystring)
{
ostringstream out;
const char *p0=format->c_str();
checkformat(p0,true);
-
+
const char *p=p0;
const char *start=NULL;
while(*p != 0) {
@@ -218,16 +218,16 @@ string format(string *format, Int x, string locale=emptystring)
}
out << *(p++);
}
-
+
if(!start) return out.str();
-
- // Allow at most 1 argument
+
+ // Allow at most 1 argument
while(*p != 0) {
if(*p == '*' || *p == '$') return out.str();
if(isupper(*p) || islower(*p)) {p++; break;}
p++;
}
-
+
string f=format->substr(start-p0,p-start);
const char *oldlocale=NULL;
@@ -247,7 +247,7 @@ string format(string *format, Int x, string locale=emptystring)
out << p;
delete[] buf;
-
+
if(oldlocale) {
setlocale(LC_ALL,oldlocale);
delete[] oldlocale;
@@ -260,16 +260,16 @@ string format(string *format, bool forcemath=false, string separator, real x,
string locale=emptystring)
{
if(*format == "%") return ""; // Temporary workaround for github Issue #29.
-
+
bool tex=getSetting<string>("tex") != "none";
bool texify=forcemath;
ostringstream out;
-
+
const char *p0=format->c_str();
checkformat(p0,false);
const char *phantom="\\phantom{+}";
-
+
const char *p=p0;
const char *start=NULL;
char prev=0;
@@ -283,16 +283,16 @@ string format(string *format, bool forcemath=false, string separator, real x,
}
out << *(p++);
}
-
+
if(!start) return out.str();
-
- // Allow at most 1 argument
+
+ // Allow at most 1 argument
while(*p != 0) {
if(*p == '*' || *p == '$') return out.str();
if(isupper(*p) || islower(*p)) {p++; break;}
p++;
}
-
+
const char *tail=p;
string f=format->substr(start-p0,tail-start);
@@ -311,14 +311,14 @@ string format(string *format, bool forcemath=false, string separator, real x,
bool trailingzero=f.find("#") < string::npos;
bool plus=f.find("+") < string::npos;
bool space=f.find(" ") < string::npos;
-
+
char *q=buf; // beginning of formatted number
if(*q == ' ' && texify) {
out << phantom;
q++;
}
-
+
const char decimal=*(localeconv()->decimal_point);
// Remove any spurious sign
@@ -335,11 +335,11 @@ string format(string *format, bool forcemath=false, string separator, real x,
if((plus || space) && texify) out << phantom;
}
}
-
+
const char *r=p=q;
bool dp=false;
while(*r != 0 && (isspace(*r) || isdigit(*r) || *r == decimal \
- || *r == '+' || *r == '-')) {
+ || *r == '+' || *r == '-')) {
if(*r == decimal) dp=true;
r++;
}
@@ -351,12 +351,12 @@ string format(string *format, bool forcemath=false, string separator, real x,
while(q <= r) out << *(q++);
if(!trailingzero) q += n;
}
-
+
bool zero=(r == p && *r == '0') && !trailingzero;
-
+
// Translate "E+/E-/e+/e-" exponential notation to TeX
while(*q != 0) {
- if(texify && (*q == 'E' || *q == 'e') &&
+ if(texify && (*q == 'E' || *q == 'e') &&
(*(q+1) == '+' || *(q+1) == '-')) {
if(!zero) out << separator << "10^{";
bool plus=(*(q+1) == '+');
@@ -371,17 +371,17 @@ string format(string *format, bool forcemath=false, string separator, real x,
}
out << *(q++);
}
-
- while(*tail != 0)
+
+ while(*tail != 0)
out << *(tail++);
-
+
delete[] buf;
if(oldlocale) {
setlocale(LC_ALL,oldlocale);
delete[] oldlocale;
}
-
+
return out.str();
}
@@ -424,7 +424,7 @@ string time(string format=defaulttimeformat)
return Time;
#else
return format;
-#endif
+#endif
}
string time(Int seconds, string format=defaulttimeformat)
@@ -449,5 +449,5 @@ Int seconds(string t=emptystring, string format=emptystring)
return (Int) mktime(&tm);
#else
return -1;
-#endif
+#endif
}