-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
src/gr_mat/write.c
Outdated
gr_mat_write(gr_stream_t out, const gr_mat_t mat, gr_ctx_t ctx) | ||
{ | ||
return _gr_mat_write(out, mat, 1, ctx); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does your editor not end files with a newline?
src/test/t-io.c
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_stream
methods and havegr_stream_t
record 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.c
and 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_printf
actually 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.