-tarval_Z_from_str (const char *s, size_t len, int base)
-{
- tarval *tv;
- char *buf;
-
- assert (!BUILDING);
-
- buf = alloca (len+1);
- stripcpy (buf, s, len);
-
- tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
- tv->mode = mode_Z;
-#if _TARVAL_GMP_
- if (mpz_init_set_str (&tv->u.Z, buf, base)) assert (0);
-#else
- assert(0 && "no support for Z in tv!");
-#endif
-
- return tarval_identify (tv);
-}
-
-
-tarval *
-tarval_B_from_str (const char *s, size_t len)
-{
- tarval *tv;
- size_t n; /* size of B */
- const char *r; /* read ptr */
- unsigned x; /* bit store */
- int b; /* bits in x */
- int shift; /* base shift */
-
- assert (!BUILDING);
- assert (len >= 3);
-
- tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
- tv->mode = mode_B;
-
- assert (s[0] == '0');
- switch (s[1]) {
- case 'o':
- case 'O': shift = 3; break;
- case 'x':
- case 'X': shift = 4; break;
- default: assert(0);
- }
-
- r = s+len; /* set r past input */
- s += 2; /* skip header */
- x = 0; b = 0; n = 0;
- while (--r >= s) {
- int d; /* digit */
-
- if (*r == '_') continue; /* skip _ styropor */
- if (('0' <= *r) && (*r <= '9')) {
- d = *r - '0';
- } else if (('a' <= *r) && (*r <= 'f')) {
- d = *r - 'a' + 10;
- } else { assert (('A' <= *r) && (*r <= 'F'));
- d = *r - 'A' + 10;
- }
-
- x |= d << b; /* insert d into x above the b present bits */
- b += shift; /* x now contains shift more bits */
-
- if (b >= 8) { /* we've accumulated at least a byte */
- char c = x & 0xFF; /* extract the lower 8 bits from x */
- obstack_grow (&tv_obst, &c, 1); /* and stuff them into B */
- x >>= 8; /* remove the lower 8 bits from x */
- b -= 8; /* x now contains 8 bits fewer */
- ++n; /* B grew a byte */
- }
- }
-
- if (b >= 0) { /* flush the rest of the bits */
- char c = x; /* extract them */
- obstack_grow (&tv_obst, &c, 1); /* and stuff them into B */
- ++n; /* B grew a byte */
- }
-
- { unsigned char *p = obstack_finish (&tv_obst);
- unsigned char *q = p + n;
-
- tv->u.B.p = p;
- tv->u.B.n = n;
- /* reverse p in place */
- while (p < q) { char c = *p; *p++ = *q; *q-- = c; }
- }
-
- return tarval_identify (tv);
-}
-
-
-tarval *
-tarval_f_from_str (const char *s, size_t len)