From 6f7d52c8c6284a9e2eb66026354ccf0e4c3b54cd Mon Sep 17 00:00:00 2001 From: Emilien Lemaire Date: Wed, 11 Dec 2024 15:31:17 +0100 Subject: [PATCH] Use global var for bdb_app_data --- libcob/fileio.c | 10 ++-- tests/testsuite.src/run_file.at | 97 +++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 5 deletions(-) diff --git a/libcob/fileio.c b/libcob/fileio.c index 50962345..82e53fa1 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -690,15 +690,15 @@ static unsigned int bdb_lock_id = 0; key.data = fld->data; \ key.size = (cob_dbtsize_t) fld->size -#if (DB_VERSION_MAJOR > 4) || ((DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR > 0)) -#define DBT_SET_APP_DATA(key,data) ((key)->app_data = (data)) -#define DBT_GET_APP_DATA(key) ((key)->app_data) -#else +// #if (DB_VERSION_MAJOR > 4) || ((DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR > 0)) +// #define DBT_SET_APP_DATA(key,data) ((key)->app_data = (data)) +// #define DBT_GET_APP_DATA(key) ((key)->app_data) +// #else /* Workaround for older BDB versions that do not have app_data in DBT */ static void *bdb_app_data = NULL; #define DBT_SET_APP_DATA(key,data) ((void)(key), bdb_app_data = (data)) #define DBT_GET_APP_DATA(key) ((void)(key), bdb_app_data) -#endif +// #endif struct indexed_file { DB **db; /* Database handlers */ diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index f7fbbfe8..c083c99e 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -14653,3 +14653,100 @@ AT_CHECK([$COBCRUN_DIRECT ./prog2 > prog2.txt]) AT_CHECK([diff expected.txt prog2.txt]) AT_CLEANUP + +AT_SETUP([DELETE WITH COLLATING SEQUENCE]) +AT_KEYWORDS([runfile WRITE DELETE READ EBCDIC]) + +AT_SKIP_IF([test "$COB_HAS_ISAM" != "db"]) +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. READDEL. + ENVIRONMENT DIVISION. + CONFIGURATION SECTION. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + + SELECT READDEL ASSIGN EXTERNAL READDEL + ORGANIZATION INDEXED + ACCESS MODE DYNAMIC + RECORD KEY READDEL-KEY + FILE STATUS STA-READDEL. + + DATA DIVISION. + FILE SECTION. + + FD READDEL. + 01 READDEL-REC. + 02 READDEL-KEY. + 05 READDEL-KEY-NUM PIC S9(15). + 02 READDEL-VALUE. + 05 READDEL-STRING PIC X(10). + 05 READDEL-NUM PIC S9(27) OCCURS 10 TIMES. + *> + + *>----------------------* + WORKING-STORAGE SECTION. + *>----------------------* + + 01 STA-READDEL PIC X(2). + 01 END-READDEL PIC 9(1). + 01 WS-COUNT PIC S9(2) VALUE 0. + + *>------------------* + PROCEDURE DIVISION. + *>------------------* + MOVE 0 TO END-READDEL. + OPEN OUTPUT READDEL. + PERFORM 20 TIMES + MOVE WS-COUNT TO READDEL-KEY-NUM + MOVE "READDELNUM" TO READDEL-STRING + MOVE WS-COUNT TO READDEL-NUM(1) + MOVE WS-COUNT TO READDEL-NUM(2) + MOVE WS-COUNT TO READDEL-NUM(3) + MOVE WS-COUNT TO READDEL-NUM(4) + MOVE WS-COUNT TO READDEL-NUM(5) + MOVE WS-COUNT TO READDEL-NUM(6) + MOVE WS-COUNT TO READDEL-NUM(7) + MOVE WS-COUNT TO READDEL-NUM(8) + MOVE WS-COUNT TO READDEL-NUM(9) + MOVE WS-COUNT TO READDEL-NUM(10) + WRITE READDEL-REC + INVALID KEY + DISPLAY "INVALID KEY " READDEL-KEY + STOP RUN + END-WRITE + ADD 1 TO WS-COUNT + END-PERFORM. + CLOSE READDEL. + MOVE LOW-VALUE TO READDEL-KEY. + OPEN I-O READDEL. + START READDEL KEY IS > READDEL-KEY + INVALID KEY + DISPLAY "ERR START READDEL=" STA-READDEL + MOVE 1 TO END-READDEL + END-START. + PERFORM UNTIL END-READDEL = 1 + READ READDEL NEXT RECORD + AT END + MOVE 1 TO END-READDEL + NOT AT END + DISPLAY "READ KEY=" READDEL-KEY + DELETE READDEL + INVALID KEY + DISPLAY "ERR DELETE KEY=" READDEL-KEY + " / STATUS=" STA-READDEL + NOT INVALID + DISPLAY "DELETE OK KEY=" READDEL-KEY + END-DELETE + END-READ + END-PERFORM. + CLOSE READDEL. + STOP RUN. + + +]) + +AT_CHECK([$COMPILE -fdefault-file-colseq=EBCDIC prog.cob]) +AT_CHECK([timeout 10 $COBCRUN_DIRECT ./prog]) + +AT_CLEANUP