-
Notifications
You must be signed in to change notification settings - Fork 24
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
Handle BDB keys of different length #156
Handle BDB keys of different length #156
Conversation
libcob/fileio.c
Outdated
@@ -919,20 +919,34 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 | |||
) | |||
{ | |||
const unsigned char *col = (unsigned char *)DBT_GET_APP_DATA (k1); | |||
#ifdef USE_BDB_KEYDIFF /* flag passed with CPPFLAGS */ | |||
COB_MODULE_PTR->collating_sequence = col; |
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 changes the current module's collating sequence; we don't want that.
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.
agreed, we also don't want cob_fields to be used here - so extract the logic that only operates on data + size + col from cob_cmp_alnum and locally export it, then calling this here
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.
That's still open... just drop that line
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.
the main open point is the previously unclear registration:
when USE_BDB_KEYDIFF
is used then bdb_bt_compare
needs to be always registered (it currently is only registered if there is a col in use)
For your example: parameters should be passed as arguments to configure, instead of being set inline/exported (if you are interested why: the autotools manual has an entry on that, but the biggest part is that passed arguments are checked to be identical between runs).
libcob/fileio.c
Outdated
@@ -919,20 +919,34 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 | |||
) | |||
{ | |||
const unsigned char *col = (unsigned char *)DBT_GET_APP_DATA (k1); | |||
#ifdef USE_BDB_KEYDIFF /* flag passed with CPPFLAGS */ | |||
COB_MODULE_PTR->collating_sequence = col; |
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.
agreed, we also don't want cob_fields to be used here - so extract the logic that only operates on data + size + col from cob_cmp_alnum and locally export it, then calling this here
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 adjust as noted in the fix-commit (I've screwed up and commented there instead of on the PR).
In any case you want to further add to the ChangeLog.
One thing I do wonder: should cob_cmp_strings()
have a parameter int national
and do a different compare for the spaces in this case? cob_cmp_alnum()
would pass zero, bdb_bt_compare()
would pass depending on the national flag in k1.
In any case this can be done in a later refactoring on as well.
2408d79
to
986ffd8
Compare
It sounds right to me. I've looked at the DBT structure and in particular its |
That's not inside of the DBT->flags (those really belong to BDB), but instead it is inside the cob_field, which only is used to set the DBT->data+size (see |
It might be wiser for us to leave that for a later refactoring as there is a need from one of our customers and I'm not very familiar with character sets and national yet (I currently don't know what this |
I agree, let's finish this PR just leaving a note at the place where we register the compare function, possibly something like |
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.
some finalization, then ready to check-in upstream
libcob/common.c
Outdated
return cob_cmp_strings ((unsigned char *)data1, (unsigned char *)data2, | ||
size1, size2, col); |
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.
Is there a reason to not pass the arguments directly without intermediate variables?
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.
@engboris you've marked that as solved but the question is unanswered?
libcob/fileio.c
Outdated
@@ -919,20 +919,34 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 | |||
) | |||
{ | |||
const unsigned char *col = (unsigned char *)DBT_GET_APP_DATA (k1); | |||
#ifdef USE_BDB_KEYDIFF /* flag passed with CPPFLAGS */ | |||
COB_MODULE_PTR->collating_sequence = col; |
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.
That's still open... just drop that line
libcob/fileio.c
Outdated
unsigned char *data1 = k1->data; | ||
unsigned char *data2 = k2->data; | ||
size_t size1 = (size_t)k1->size; | ||
size_t size2 = (size_t)k2->size; | ||
return cob_cmp_strings (data1, data2, size1, size2, col); |
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.
Is there a reason for intermediate variables here?
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.
There is no reason. It was temporary and they were meant to be removed.
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.
you've removed those here, but left them in line 2031++ https://github.com/OCamlPro/gnucobol/pull/156/files#diff-16de7d2ecd4918cd696dff002aebea147395b0d09288c2e8e0310155dc943da1R2031-R2037
42bb2de
to
373e465
Compare
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.
Apart from the unanswered answer (and the doc comment) that's finished; would you like to commit that upstream then?
[note: upstream 3.x is currently failing CI, you may want to wait until @chuck-haatvedt did his final fix-commit tomorrow
libcob/common.c
Outdated
return cob_cmp_strings ((unsigned char *)data1, (unsigned char *)data2, | ||
size1, size2, col); |
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.
@engboris you've marked that as solved but the question is unanswered?
59f5c22
to
62f1253
Compare
It should be good now! |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## gcos4gnucobol-3.x #156 +/- ##
=====================================================
+ Coverage 65.78% 66.11% +0.32%
=====================================================
Files 32 33 +1
Lines 59416 60044 +628
Branches 15694 15802 +108
=====================================================
+ Hits 39087 39698 +611
+ Misses 14311 14295 -16
- Partials 6018 6051 +33 ☔ View full report in Codecov by Sentry. |
6c83450
to
4430207
Compare
My final fix-commit is done now.
This fixes the issue with a build without curses. It also fixes
warnings in libcob related to C90 ==>
declaration-after-statement.
sorry about the delay...
@page { margin: 0.79in }
p { margin-bottom: 0.08in }
Chuck
Haatvedt
***@***.***
On 7/11/2024 3:13 AM, Simon Sobisch
wrote:
@GitMensch requested changes on this pull request.
Apart from the unanswered answer (and the doc
comment) that's finished; would you like to commit that upstream
then?
[note: upstream 3.x is currently failing CI, you may want to
wait until @chuck-haatvedt did his final
fix-commit tomorrow
In libcob/common.c:
-/* compare content of field 'f1' to content of 'f2', space padded,
- using the optional collating sequence of the program */
let's include the old doc comment, adjusted to
"strings, space padded, using an optional collating sequence"
here so this "local exported" function has a doc comment
In libcob/common.c:
+ return cob_cmp_strings ((unsigned char *)data1, (unsigned char *)data2,
+ size1, size2, col);
@engboris
you've marked that as solved but the question is unanswered?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message
ID: ***@***.***>
[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#156 (review)",
"url": "#156 (review)",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
|
4430207
to
aa3fc1a
Compare
Merged in SVN @ 5296. |
Fix for issue #154
Problem
The function
libcob/fileio.c:bdb_bt_compare
fails on keys of different length passed in arguments. This is necessary since valid BDB files containing additional data interpreted as keys of different length may be used with GnuCOBOL (example given from one of our customers). Such files may be produced by external tools but still meant to be readable.Solution
Use the already implemented
libcob/common.c:cob_cmp_alnum
function (now made external) to compare keys as alphanumeric fields of possibly different length (padded with spaces).This PR introduces a new preparser flag
USE_BDB_KEYDIFF
with may be passed in the following way when compiling GnuCOBOL sources:This flag allows such BDB keys of different length as an option since it has an overhead cost.
Notes
I have also been suggested to
Which is something I do not currently understand.