return p;
}
+static __isl_give isl_printer *file_flush(__isl_take isl_printer *p)
+{
+ fflush(p->file);
+ return p;
+}
+
static __isl_give isl_printer *file_print_str(__isl_take isl_printer *p,
const char *s)
{
return p;
}
+static __isl_give isl_printer *str_flush(__isl_take isl_printer *p)
+{
+ p->buf_n = 0;
+ return p;
+}
+
static __isl_give isl_printer *str_print_str(__isl_take isl_printer *p,
const char *s)
{
int len;
isl_int_print_gmp_free_t gmp_free;
- s = mpz_get_str(0, 10, i);
+ s = isl_int_get_str(i);
len = strlen(s);
if (len < p->width)
p = str_print_indent(p, p->width - len);
isl_int i);
__isl_give isl_printer *(*print_str)(__isl_take isl_printer *p,
const char *s);
+ __isl_give isl_printer *(*flush)(__isl_take isl_printer *p);
};
static struct isl_printer_ops file_ops = {
file_end_line,
file_print_int,
file_print_isl_int,
- file_print_str
+ file_print_str,
+ file_flush
};
static struct isl_printer_ops str_ops = {
str_end_line,
str_print_int,
str_print_isl_int,
- str_print_str
+ str_print_str,
+ str_flush
};
__isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx, FILE *file)
if (!p->buf)
goto error;
p->buf_n = 0;
+ p->buf[0] = '\0';
p->buf_size = 256;
p->indent = 0;
p->output_format = ISL_FORMAT_ISL;
free(p);
}
+isl_ctx *isl_printer_get_ctx(__isl_keep isl_printer *printer)
+{
+ return printer ? printer->ctx : NULL;
+}
+
__isl_give isl_printer *isl_printer_set_isl_int_width(__isl_take isl_printer *p,
int width)
{
return p;
}
+__isl_give isl_printer *isl_printer_indent(__isl_take isl_printer *p,
+ int indent)
+{
+ if (!p)
+ return NULL;
+
+ p->indent += indent;
+ if (p->indent < 0)
+ p->indent = 0;
+
+ return p;
+}
+
__isl_give isl_printer *isl_printer_set_prefix(__isl_take isl_printer *p,
const char *prefix)
{
__isl_give isl_printer *isl_printer_print_str(__isl_take isl_printer *p,
const char *s)
{
+ if (!p)
+ return NULL;
+
return p->ops->print_str(p, s);
}
__isl_give isl_printer *isl_printer_print_int(__isl_take isl_printer *p, int i)
{
+ if (!p)
+ return NULL;
+
return p->ops->print_int(p, i);
}
__isl_give isl_printer *isl_printer_print_isl_int(__isl_take isl_printer *p,
isl_int i)
{
+ if (!p)
+ return NULL;
+
return p->ops->print_isl_int(p, i);
}
__isl_give isl_printer *isl_printer_start_line(__isl_take isl_printer *p)
{
+ if (!p)
+ return NULL;
+
return p->ops->start_line(p);
}
__isl_give isl_printer *isl_printer_end_line(__isl_take isl_printer *p)
{
+ if (!p)
+ return NULL;
+
return p->ops->end_line(p);
}
return NULL;
return strdup(printer->buf);
}
+
+__isl_give isl_printer *isl_printer_flush(__isl_take isl_printer *p)
+{
+ if (!p)
+ return NULL;
+
+ return p->ops->flush(p);
+}