/usr/share/ecere/extras/types/Currency.ec is in ecere-extras 0.44.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #ifdef ECERE_STATIC
public import static "ecere"
#else
public import "ecere"
#endif
default:
__attribute__((unused)) static void _WorkAround()
{
int a;
a.OnGetDataFromString(null);
}
extern int __ecereVMethodID_class_OnGetDataFromString;
private:
public class Currency : double
{
const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
{
char number[256];
int len;
int c = 0;
int pos = 2;
bool firstGroup = true;
sprintf(number, "%.2f", this);
len = strlen(number);
sprintf(tempString, "$ ");
if(number[c] == '-')
{
c++;
tempString[pos++] = '-';
}
while(true)
{
int numDigits = len - c - 3;
if(numDigits > 3)
{
if(firstGroup)
{
numDigits = (len - c - 3) % 3;
if(!numDigits) numDigits = 3;
firstGroup = false;
}
else
numDigits = 3;
}
memcpy(tempString + pos, number + c, numDigits);
c += numDigits;
pos += numDigits;
if(c == len - 3)
break;
tempString[pos++] = ',';
}
strcpy(tempString + pos, number + c);
return tempString;
}
bool OnGetDataFromString(const char * string)
{
int c;
char ch;
char number[256] = "";
int len = 0;
bool gotDot = false;
int numDecimals = 0;
for(c = 0; (ch = string[c]) && !isdigit(ch) && ch != '.' && ch != '-'; c++);
for(; (ch = string[c]) && (isdigit(ch) || ch == '.' || ch == ',' || ch == ' ' || ch == '-'); c++)
{
if(ch != ',' && ch != ' ' && !(len && ch == '-'))
{
if(ch == '.') gotDot = true;
else if(gotDot)
numDecimals++;
number[len++] = ch;
if(numDecimals == 2)
break;
}
}
number[len] = 0;
return ((bool (*)(void *, void *, const char *))(void *)class(double)._vTbl[__ecereVMethodID_class_OnGetDataFromString])(class(double), &this, number);
}
}
|