-
Notifications
You must be signed in to change notification settings - Fork 41
Bug fix for BIN and changes to return values of POLYCENT and POLYAREA #173
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
Conversation
src/common/blib_math.c
Outdated
|
|
||
| qsort(e, count, sizeof(var_num_t), median_compare); | ||
|
|
||
| if (count % 2 == 0) |
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.
could you please add curley braces around the single lines?
also indent with 2 spaces :)
src/common/blib_math.c
Outdated
| // | ||
| // compare function for median calculation | ||
| // | ||
| int median_compare (const void * a, const void * b) { |
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.
please remove the space between the function name and "("
src/common/blib_func.c
Outdated
| IF_ERR_RETURN; | ||
|
|
||
| if (l == 0) { | ||
| r->v.p.ptr = (char *)malloc(2); |
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.
these lines should be replaced with a call to v_createstr(r, "0")
src/common/blib_func.c
Outdated
|
|
||
| tb = malloc(33); | ||
| memset(tb, 0, 33); | ||
| memset(tb, 0, 33); |
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.
could you please replace 33 with a constant (#define is okay) ?
src/common/blib_func.c
Outdated
| } | ||
|
|
||
| r->v.p.ptr = tb; | ||
| r->v.p.ptr = (char *)malloc(strlen(p) + 1); |
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.
this should be replaced with a call to v_createstr
| BCS:catsanddogs | ||
| BGETC: | ||
| BIN:00000000000000000000000000001100 | ||
| BIN:1100 |
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.
It would be good to add some more testing for BIN. Something like this could be added to strings.bas
bin_test=[[,], [0, "0"], [7, "111"], [14, "1110"], [15, "1111"]]
for t in bin_test
if (t[1] != bin(t[0])) then throw "err:" + str(t) + " <> " + bin(t[0])
next
|
Hi Chris, I made a new commit with the changes you suggested. Best regards, Joerg |
| p++; | ||
| } | ||
|
|
||
| v_createstr(r, p); |
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.
Need to call free(tb); before the break; line to avoid a memory leak
src/common/blib_math.c
Outdated
|
|
||
| if (count % 2 == 0) { | ||
| return (e[count/2] + e[count/2 - 1]) / 2; | ||
| } |
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.
sorry to be a pain, but could you pls reformat the else line to be on the same line as the closing brace, ie:
} else {
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.
Cool stuff - thanks for the changes
|
No problem. Here the changes. Most probably my last action this year. I wish you a happy new year. |
|
No worries - happy new year! |
Hi Chris,
four small things:
Best regards, Joerg