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)
{
static __isl_give isl_printer *str_start_line(__isl_take isl_printer *p)
{
p = str_print_indent(p, p->indent);
- p = str_print(p, p->prefix, strlen(p->prefix));
+ if (p->prefix)
+ p = str_print(p, p->prefix, strlen(p->prefix));
return p;
}
static __isl_give isl_printer *str_end_line(__isl_take isl_printer *p)
{
- p = str_print(p, p->suffix, strlen(p->suffix));
+ if (p->suffix)
+ p = str_print(p, p->suffix, strlen(p->suffix));
p = str_print(p, "\n", strlen("\n"));
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)
__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);
+}