Support gr objects in flint_printf - #2226
Conversation
|
I don't understand why clang doesn't like this. It seems to misread the passed length for the |
It doesn't have error handling, it assumes that the correct type is used and that the objects have valid representations. |
Seems to be OS-specific since macOS passes. |
| gr_mat_write(gr_stream_t out, const gr_mat_t mat, gr_ctx_t ctx) | ||
| { | ||
| return _gr_mat_write(out, mat, 1, ctx); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Does your editor not end files with a newline?
| gr_ctx_t xgr_ctx; | ||
| gr_ctx_init_fmpzi(xgr_ctx); | ||
| gr_ptr xgr = gr_heap_init(xgr_ctx); | ||
| gr_ptr xgr_vec = gr_heap_init_vec(GR_VEC_LEN, xgr_ctx); | ||
| gr_poly_t xgr_poly; | ||
| gr_mat_t xgr_mat; | ||
| GR_IGNORE(gr_set_ui(xgr, 5, xgr_ctx)); | ||
| GR_IGNORE(gr_set_ui(GR_ENTRY(xgr_vec, 0, xgr_ctx->sizeof_elem), 1, xgr_ctx)); | ||
| GR_IGNORE(gr_set_ui(GR_ENTRY(xgr_vec, 1, xgr_ctx->sizeof_elem), 2, xgr_ctx)); | ||
| GR_IGNORE(gr_set_str(GR_ENTRY(xgr_vec, 2, xgr_ctx->sizeof_elem), "I", xgr_ctx)); | ||
| gr_poly_init(xgr_poly, xgr_ctx); | ||
| GR_IGNORE(gr_poly_set_coeff_si(xgr_poly, 1, -1, xgr_ctx)); | ||
| gr_mat_init(xgr_mat, 1, 2, xgr_ctx); | ||
| GR_IGNORE(gr_set_ui(gr_mat_entry_ptr(xgr_mat, 0, 0, xgr_ctx), 4, xgr_ctx)); | ||
| GR_IGNORE(gr_set_ui(gr_mat_entry_ptr(xgr_mat, 0, 1, xgr_ctx), 3, xgr_ctx)); |
There was a problem hiding this comment.
Before any merging, please initialize, set and clear as done with all other variables.
I mean error handling for the case where IO fails, eg because you've run out of disk space. |
Support
%{gr_ctx},%{gr},%{gr*},%{gr_poly}and%{gr_mat}.To make this possible we add error handling to the internal
gr_streammethods and havegr_stream_trecord the number of written characters so that we can extract this for the return value offlint_printf.With this it should be possible to get rid of the ad-hoc generics in
generic_files/io.cand instead just wrapgr; mainly we just need to consolidate the printing styles first.BTW am I reading the code wrong or is the error handling in
flint_printfactually broken? It doesn't seem to actually check if a subroutine call returns a negative length (indicating error), it just appends it to he total length.