Skip to content
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

IN_STR method missing on array #25

Closed
mario-tux opened this issue Aug 23, 2018 · 5 comments
Closed

IN_STR method missing on array #25

mario-tux opened this issue Aug 23, 2018 · 5 comments
Assignees

Comments

@mario-tux
Copy link

As specified by documentation and confirmed by a quick look at the code in m-array.h, the container should provide the IN_STR method if the elements support it. This doesn't work in my tests.

ARRAY_DEF(my_list, string_t)
#define MY_LIST_OPLIST ARRAY_OPLIST(my_list, STRING_OPLIST)
#define M_OPL_my_list_t() MY_LIST_OPLIST

int main() {
    M_LET(list, list2, my_list_t)
    M_LET(string, string_t) {
        string_set_str(string, "hello");
        my_list_push_back(list, string);
        my_list_push_back(list, string);
        FILE *file = fopen("/tmp/test.data", "w+");
        assert(file);
        my_list_out_str(stdout, list);
        my_list_out_str(file, list);
        rewind(file);
        my_list_in_str(file, list2); /* <= not available :-( */
        my_list_out_str(stdout, list2);
        fclose(file);
    }
}

The same happens if I define an array of C native types like int. I didn't check with other types of container.

Sorry to bother you with these reports. Heavily using it into an extensive project such defects come up.

@mario-tux
Copy link
Author

I'm noting that the documentation usually reports wrong prototypes for the _in_str methods: the destination container is sometimes reported as second element (maybe a copy&paste from _out_str) and, other times, with the const specification.

@P-p-H-d P-p-H-d self-assigned this Aug 23, 2018
@P-p-H-d
Copy link
Owner

P-p-H-d commented Aug 23, 2018

I see a bug in your example. You shall write:
my_list_in_str(list2, file);
once I fix this, your example compiles & runs fine.
All functions have the out parameter first. The documentation is wrong; it shall be:
void name_in_str(name_t array, FILE *file)

C native types do not support generic IN_STR method yet!

@mario-tux
Copy link
Author

mario-tux commented Aug 23, 2018

Ok, documentation fooled me me on first glance. You can keep this report as request for C native types support and for documentation fix.

@P-p-H-d
Copy link
Owner

P-p-H-d commented Aug 23, 2018

Both have been taken in master.

Good luck for your project!

@mario-tux
Copy link
Author

On some early tests it looks that the _get_str methods for C native types work well. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants