Macaulay2 Engine
Loading...
Searching...
No Matches

◆ read_poly_0()

TowerPolynomial DPoly::read_poly_0 ( char *& str)
staticprivate

Definition at line 341 of file dpoly.cpp.

342{
343 int len = 0;
344 long *elems = newarray_atomic(long, 100);
345 long this_elem = 0;
346 if (*str != '[')
347 {
348 fprintf(stderr, "expected '[', got %s\n", str);
349 exit(1);
350 }
351 str++;
352 // Now loop
353 while (*str != ']')
354 {
355 while (isspace(*str)) str++;
356 if (*str == ',')
357 {
358 str++;
359 }
360 else if (isdigit(*str))
361 {
362 char *end;
363 this_elem = strtol(str, &end, 10);
364 str = end;
365 while (isspace(*str)) str++;
366 if (*str == ',') str++;
367 }
368 else
369 {
370 fprintf(stderr, "expected , or [, but got %s\n", str);
371 exit(1);
372 }
373 elems[len++] = this_elem;
374 this_elem = 0;
375 }
376 // the only way to get here is if *str == ']'. Eat that char.
377 str++;
378 TowerPolynomial result = DPoly::alloc_poly_0(len - 1, elems);
379 freemem(elems);
380 return result;
381}
static TowerPolynomial alloc_poly_0(int deg, long *elems=nullptr)
Definition dpoly.cpp:279
void freemem(void *s)
Definition m2-mem.cpp:103
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define newarray_atomic(T, len)
Definition newdelete.hpp:91
TermIterator< Nterm > end(Nterm *)
Definition ringelem.cpp:5

References alloc_poly_0(), end(), freemem(), newarray_atomic, and result().

Referenced by read_poly().