libft-unit-test icon indicating copy to clipboard operation
libft-unit-test copied to clipboard

isalnum, tolower, toupper, calloc different behavior on Linux

Open m0d1nst4ll3r opened this issue 4 years ago • 3 comments

isalnum returns 8 (instead of 0) on 262, 266, 272, 274, 280 etc... for some reason and since tests include non-unsigned char values, they fail when it shouldn't matter and there's no way to get it right

The same happens for tolower and toupper. Toupper returns the int cast as unsigned char for int values between -128 and -2 (yes, -1 is excluded, it returns -1). Unlike isalnum, it's possible to OK it with a simple condition, but it makes no sense catering to this odd behavior.

As for calloc, I haven't gone through it entirely yet, but the manual is different on linux and mac. The linux manual claims calloc protects against 0 values and size_t overflows whereas the mac manual claims nothing like this.

m0d1nst4ll3r avatar Nov 23 '21 14:11 m0d1nst4ll3r

Waiting for merging or declining this pull request https://github.com/alelievr/libft-unit-test/pull/111 concerning ft_is* functions. On ft_calloc function: could you possibly provide some screenshots illustrating your point?

stankudrow avatar Nov 27 '21 15:11 stankudrow

For calloc, the linux manual says: If nmemb or size is 0, then calloc() returns either NULL, or a unique pointer value that can later be successfully passed to free() The tester counts NULL returns (in case of 0) as a fail. I'm not sure the moulinette will fail this behavior. Maybe a yellow KO?

The manual also says: If the multiplication of nmemb and size would result in integer overflow, then calloc() returns an error The mac manual doesn't, however, so it's unclear what the moulinette tests and what the correct behavior should be.

m0d1nst4ll3r avatar Nov 27 '21 22:11 m0d1nst4ll3r

Hello! Thanks for contributing to the libft unit test.

Note that this repository is not maintained by the owner anymore, instead there is a bot that will automatically merge any reviewed pull requests. If you feel like it, here are some links that can help you submiting a change in the code base::

github-actions[bot] avatar Sep 03 '22 19:09 github-actions[bot]