Skip to content

Commit

Permalink
Merge SVN 5398
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Feb 14, 2025
1 parent 285117a commit e266614
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 4 deletions.
1 change: 0 additions & 1 deletion config/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

* mf-strict.conf: set missing-statement to ok (according to MF tests)


2023-09-19 Simon Sobisch <[email protected]>

* rm-strict.conf (perform-osvs): enabled as noted in MF docs
Expand Down
5 changes: 5 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
first, close the file descriptor only if the stream is NULL
(fixes assertions under MSVC debug)

2024-12-11 Emilien Lemaire <[email protected]>

* fileio.c->fbdb.c: fixed Bug #1032 by always using global thread-static variable
bdb_app_data pointer to access the collating sequence function

2024-11-06 David Declerck <[email protected]>

Reverted change 2022-02-21 to integrate change
Expand Down
14 changes: 14 additions & 0 deletions libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@
#define COB_MOUSE_INTERVAL cobsetptr->cob_mouse_interval
#define COB_USE_ESC cobsetptr->cob_use_esc

#if defined(COB_TLS)
/* already defined, for example as static to explicit disable TLS */
#elif defined(_WIN32)
#define COB_TLS __declspec(thread)
#elif defined(__GNUC__) && (__GNUC__ >= 4) || defined(__clang__) || \
defined(__hpux) || defined(_AIX) || defined(__sun)
#define COB_TLS static __thread
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include <threads.h>
#define COB_TLS thread_local
#else
#define COB_TLS static /* fallback definition */
#endif

/* Global settings structure */

typedef struct __cob_settings {
Expand Down
8 changes: 5 additions & 3 deletions libcob/fbdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ static int bdb_join = 1;
key.size = (cob_dbtsize_t) fld->size
#define COB_MAX_BDB_LOCKS 32

#if (DB_VERSION_MAJOR > 4) || ((DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR > 0))
#if 0 /* while the fields are part of DBT since 4.1, and were made part of the
public API with 6.0 (DB_VERSION_FAMILY 12) this field is not always
copied when passed to custom compare functions, see bug 1032 */
#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;
/* Used to save the collating sequence function */
COB_TLS 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
Expand Down
95 changes: 95 additions & 0 deletions tests/testsuite.src/run_file.at
Original file line number Diff line number Diff line change
Expand Up @@ -28535,3 +28535,98 @@ 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
DELETE READDEL
INVALID KEY
DISPLAY "ERR DELETE KEY=" READDEL-KEY
" / STATUS=" STA-READDEL
END-DELETE
END-READ
END-PERFORM.
CLOSE READDEL.
STOP RUN.


])

AT_CHECK([$COMPILE -fdefault-file-colseq=EBCDIC prog.cob])
AT_CHECK([$COBCRUN_DIRECT ./prog])

AT_CLEANUP

0 comments on commit e266614

Please sign in to comment.