Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/gnucobol-3.x' into gcos4gnucob…
Browse files Browse the repository at this point in the history
…ol-3.x
  • Loading branch information
ddeclerck committed Jul 26, 2024
2 parents 4d51096 + 9f1a64c commit 00f6832
Show file tree
Hide file tree
Showing 12 changed files with 4,432 additions and 321 deletions.
3 changes: 3 additions & 0 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,9 @@ output_data (cb_tree x)
output (")->data");
}
break;
case CB_TAG_DIRECT:
output ("%s", CB_DIRECT (x)->line);
break;
/* LCOV_EXCL_START */
default:
CB_TREE_TAG_UNEXPECTED_ABORT (x);
Expand Down
21 changes: 21 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

2024-07-13 Chuck Haatvedt <[email protected]>

* move.c (indirect_move) fixed sanitizer warnings by moving
one line of code


2024-07-11 Chuck Haatvedt <[email protected]>

* screenio.c (cob_sys_scr_dump, cob_sys_scr_restore) fixed C90 warnings
Expand All @@ -20,6 +26,12 @@
(indirect_move): fixed bug when calculating scale of
the intermediate cob field

2024-07-09 Boris Eng <[email protected]>

* fileio.c (bdb_bt_compare, indexed_open): handle BDB keys of different
length with a flag USE_BDB_KEYDIFF (passed with preparser flag CPPFLAGS)
* common.c (cob_cmp_strings), coblocal.h (cob_cmp_strings):
extracted from (cob_cmp_alnum)

2024-07-02 Chuck Haatvedt <[email protected]>

Expand Down Expand Up @@ -78,6 +90,11 @@
* termio.c (pretty_display_numeric), mlio.c (get_num):
changed to use the attributes of the receiving field

2024-07-19 Simon Sobisch <[email protected]>

* coblocal.h (COB_TLS): add a new attribute for thread local static.
* common.h, common.c (cob_cleanup_thread): add a cleanup function for threads

2024-05-15 Simon Sobisch <[email protected]>

* profiling.c: fix compile warnings
Expand Down Expand Up @@ -117,6 +134,10 @@

* common.c: add missing include libxml/parser.h

2024-02-26 Boris Eng <[email protected]>
FR #488: using state structures instead of state vars for strings
* strings.c: moved static variables to structures

2024-01-25 David Declerck <[email protected]>

FR #459: support COLLATING SEQUENCE clause on SELECT / INDEXED files
Expand Down
18 changes: 17 additions & 1 deletion libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ Note: also defined together with __clang__ in both frontends:
#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 Expand Up @@ -324,7 +338,6 @@ typedef struct __cob_settings {
unsigned int cob_exit_wait; /* wait on program exit if no ACCEPT came after last DISPLAY */
const char *cob_exit_msg; /* message for cob_exit_wait */


/* reportio.c */
unsigned int cob_col_just_lrc; /* Justify data in column LEFT/RIGHT/CENTER */

Expand Down Expand Up @@ -494,6 +507,9 @@ COB_HIDDEN const char *cob_get_last_exception_name (void);
COB_HIDDEN void cob_parameter_check (const char *, const int);
COB_HIDDEN char* cob_get_strerror (void);

COB_HIDDEN int cob_cmp_strings (unsigned char*, unsigned char*,
size_t, size_t, const unsigned char*);

enum cob_case_modifier {
CCM_NONE,
CCM_LOWER,
Expand Down
35 changes: 26 additions & 9 deletions libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,16 +1975,14 @@ cob_cmp_all (cob_field *f1, cob_field *f2)
return ret;
}

/* compare content of field 'f1' to content of 'f2', space padded,
using the optional collating sequence of the program */
static int
cob_cmp_alnum (cob_field *f1, cob_field *f2)
/* compare string 'data1' to string 'data2', of size 'size1' and 'size2'
respectively, space padded, using a given collating sequence */
int
cob_cmp_strings (
unsigned char* data1, unsigned char* data2,
size_t size1, size_t size2,
const unsigned char *col)
{
const unsigned char *col = COB_MODULE_PTR->collating_sequence;
const unsigned char *data1 = COB_FIELD_DATA (f1);
const unsigned char *data2 = COB_FIELD_DATA (f2);
const size_t size1 = COB_FIELD_SIZE (f1);
const size_t size2 = COB_FIELD_SIZE (f2);
const size_t min = (size1 < size2) ? size1 : size2;
int ret;

Expand Down Expand Up @@ -2025,6 +2023,20 @@ cob_cmp_alnum (cob_field *f1, cob_field *f2)
return 0;
}

/* compare content of field 'f1' to content of 'f2', space padded,
using the optional collating sequence of the program */
static int
cob_cmp_alnum (cob_field *f1, cob_field *f2)
{
return cob_cmp_strings (
(unsigned char *)COB_FIELD_DATA (f1),
(unsigned char *)COB_FIELD_DATA (f2),
COB_FIELD_SIZE (f1),
COB_FIELD_SIZE (f2),
COB_MODULE_PTR->collating_sequence
);
}

/* comparision of all key fields for SORT (without explicit collation)
in records pointed to by 'data1' and 'data2' */
static int
Expand Down Expand Up @@ -11206,3 +11218,8 @@ init_statement_list (void)
#undef COB_STATEMENT
}
#endif

void cob_cleanup_thread ()
{
cob_exit_strings ();
}
2 changes: 2 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,8 @@ COB_EXPIMP void cob_runtime_hint (const char *, ...) COB_A_FORMAT12;
COB_EXPIMP void cob_runtime_error (const char *, ...) COB_A_FORMAT12;
COB_EXPIMP void cob_runtime_warning (const char *, ...) COB_A_FORMAT12;

COB_EXPIMP void cob_cleanup_thread ();

/* General functions */

COB_EXPIMP int cob_is_initialized (void);
Expand Down
12 changes: 11 additions & 1 deletion libcob/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,19 +921,24 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2
{
const unsigned char *col = (unsigned char *)DBT_GET_APP_DATA (k1);
COB_UNUSED (db);

#ifdef USE_BDB_KEYDIFF /* flag passed with CPPFLAGS */
return cob_cmp_strings (k1->data, k2->data, (size_t)k1->size, (size_t)k2->size, col);
#else
/* LCOV_EXCL_START */
if (col == NULL) {
cob_runtime_error ("bdb_bt_compare was set but no collating sequence was stored in DBT");
cob_hard_failure ();
}
if (k1->size != k2->size) {
cob_runtime_error ("bdb_bt_compare was given keys of different length");
cob_hard_failure ();
}
/* LCOV_EXCL_STOP */
#if DB_VERSION_MAJOR >= 6
locp = NULL; /* docs: must be set to NULL or corruption can occur ... */
#endif
return indexed_key_compare (k1->data, k2->data, k2->size, col);
#endif /* USE_BDB_KEYDIFF */
}

#endif /* WITH_DB */
Expand Down Expand Up @@ -4672,9 +4677,14 @@ indexed_open (cob_file *f, char *filename,
if (f->keys[i].tf_duplicates) {
p->db[i]->set_flags (p->db[i], DB_DUP);
}
/* TODO: add national compare function later */
#ifdef USE_BDB_KEYDIFF
p->db[i]->set_bt_compare(p->db[i], bdb_bt_compare);
#else
if (f->keys[i].collating_sequence) {
p->db[i]->set_bt_compare(p->db[i], bdb_bt_compare);
}
#endif
}
} else {
handle_created = 0;
Expand Down
2 changes: 1 addition & 1 deletion libcob/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -1458,9 +1458,9 @@ indirect_move (void (*func) (cob_field *src, cob_field *dst),
cob_field_attr attr;
size_t temp_size;
unsigned short digits;
unsigned char buff[COB_MAX_DIGITS + 1] = { 0 };

if (COB_FIELD_TYPE(dst) == COB_TYPE_NUMERIC_EDITED) {
unsigned char buff[COB_MAX_DIGITS + 1] = { 0 };
temp_size = COB_FIELD_DIGITS(dst) + 1;
digits = (unsigned short)temp_size - 1;
if (COB_FIELD_HAVE_SIGN(dst)) {
Expand Down
Loading

0 comments on commit 00f6832

Please sign in to comment.