diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-05-06 16:56:32 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-06-02 11:18:47 +0200 |
| commit | 8174a918ea3b7cb216bf7ea98cfdc10661b5c37d (patch) | |
| tree | 0747ec3ccb9f8d7eeccfac35977fc17855ca3bbb /src/benchmarks/cfrac/ptoa.c | |
| parent | 8f52e8fc02dd235582f5961941bcd564e9a681cd (diff) | |
| download | allocbench-8174a918ea3b7cb216bf7ea98cfdc10661b5c37d.tar.gz allocbench-8174a918ea3b7cb216bf7ea98cfdc10661b5c37d.zip | |
make the whole project more python idiomatic
* rename src directory to allocbench
* make global variable names UPPERCASE
* format a lot of code using yapf
* use lowercase ld_preload and ld_library_path as Allocator members
* name expected Errors 'err' and don't raise a new Exception
* disable some pylint messages
Diffstat (limited to 'src/benchmarks/cfrac/ptoa.c')
| -rw-r--r-- | src/benchmarks/cfrac/ptoa.c | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/src/benchmarks/cfrac/ptoa.c b/src/benchmarks/cfrac/ptoa.c deleted file mode 100644 index a928ea2..0000000 --- a/src/benchmarks/cfrac/ptoa.c +++ /dev/null @@ -1,71 +0,0 @@ -#include <string.h> -#include "pdefs.h" -#include "pcvt.h" -#include "precision.h" - -/* - * Return the character string decimal value of a Precision - */ -#if (BASE > 10) -#define CONDIGIT(d) ((d) < 10 ? (d) + '0' : (d) + 'a'-10) -#else -#define CONDIGIT(d) ((d) + '0') -#endif - -char *ptoa(u) - precision u; -{ - register accumulator temp; - register char *dPtr; - char *d; - int i = 0; - unsigned int consize; - precision r, v, pbase; - register int j; - - (void) pparm(u); - r = pUndef; - v = pUndef; - pbase = pUndef; - - consize = (unsigned int) u->size; - if (consize > MAXINT / aDigits) { - consize = (consize / pDigits) * aDigits; - } else { - consize = (consize * aDigits) / pDigits; - } - - consize += aDigitLog + 2; /* leading 0's, sign, & '\0' */ - d = (char *) allocate((unsigned int) consize); - if (d == (char *) 0) return d; - - pset(&v, pabs(u)); - pset(&pbase, utop(aDigit)); - - dPtr = d + consize; - *--dPtr = '\0'; /* null terminate string */ - i = u->sign; /* save sign */ - do { - pdivmod(v, pbase, &v, &r); - temp = ptou(r); /* Assumes unsigned and accumulator same! */ - j = aDigitLog; - do { - *--dPtr = CONDIGIT(temp % aBase); /* remainder */ - temp = temp / aBase; - } while (--j > 0); - } while (pnez(v)); - - while (*dPtr == '0') dPtr++; /* toss leading zero's */ - if (*dPtr == '\0') --dPtr; /* but don't waste zero! */ - if (i) *--dPtr = '-'; - if (dPtr > d) { /* ASSUME copied from lower to higher! */ - (void) memcpy(d, dPtr, consize - (dPtr - d)); - } - - pdestroy(pbase); - pdestroy(v); - pdestroy(r); - - pdestroy(u); - return d; -} |
