Skip to content

Commit

Permalink
Merge SVN 5024
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Oct 2, 2024
1 parent e22046b commit d967b65
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 219 deletions.
30 changes: 30 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@
* typeck.c (cb_emit_sort_init): generate call to cob_file_sort_options
* help.c (cobc_print_usage_dialect): extended -fregister help

2023-04-17 Simon Sobisch <[email protected]>

* scanner.l: dropped last_token_is_dot and integer_is_label by checking
last_token instead
* scanner.l, parser.y, reserved.c, tree.h: dropped cobc_force_literal by
introducing second_last_token and checking the tokens instead
* scanner.l: early consume spaces after comma and semicolon
* scanner.l: simplify check for redundant periods by splitting its rule
* cobc.c (file_basename): directly use filename,
only handle backslash on win32
* codegen.c: minor refactoring to drop global string_buffer
* codegen.c: generate COB_EXT_IMPORT and COB_EXT_EXPORT instead of extern
* codegen.c (codegen): minor refactoring
* parser.y (setup_registers): extracted
* parser.y: minor refactoring

2023-04-14 Simon Sobisch <[email protected]>

* pplex.l (ppopen_get_file): extracted from ppopen and minor refactor
* pplex.l (ppecho): disabled performance-dropping fflush until found
necessary

2023-03-29 Simon Sobisch <[email protected]>

* typeck.c (count_pic_edited): renamed from count_pic_alphanumeric_edited
Expand Down Expand Up @@ -78,6 +100,8 @@

* typeck.c (cb_build_cond_fields): optimize comparison between field and
ZEROES up to COB_ZEROES_ALPHABETIC_BYTE_LENGTH
* pplex.l (ppopen): fixes for auto-detection of reference-format FR #45
handling tabs, dos eol and empty lines correctly

2023-02-28 Simon Sobisch <[email protected]>

Expand Down Expand Up @@ -207,6 +231,7 @@

2023-01-28 Fabrice Le Fessant <[email protected]>

FR #45: auto-detection of reference-format
* cobc.c (main): initialize cb_config_text_column to 72 to avoid a
race condition in config files.
* pplex.l (ppopen): try to autodetect the format of a file after
Expand All @@ -229,6 +254,10 @@
* cobc.c, flag.def, cobc.h: handle external table for "ebcdic-table"
* codegen.c: generate code using the external table

2023-01-20 Ron Norman <[email protected]>

* codeoptim.c: fix cob_check_subscript_inline for min subscript value

2023-01-20 Simon Sobisch <[email protected]>

fixed bug #704: ANY LENGTH cannot have ref-mod, POS not context-sensitive
Expand Down Expand Up @@ -1269,6 +1298,7 @@

2022-01-25 Nicolas Berthier <[email protected]>

FR #137: relax syntax for partial replace
* pplex.l, ppparse.y, config.h: support COPY and REPLACE
statements with partial REPLACING operands specified using
literals
Expand Down
15 changes: 9 additions & 6 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,6 @@ file_stripext (char *buff)
static char *
file_basename (const char *filename, const char *strip_ext)
{
const char *p;
const char *startp;
const char *endp;
size_t len;
Expand All @@ -2775,19 +2774,23 @@ file_basename (const char *filename, const char *strip_ext)
/* LCOV_EXCL_STOP */

/* Remove directory name */
startp = NULL;
for (p = filename; *p; p++) {
if (*p == '/' || *p == '\\') {
startp = p;
startp = strrchr (filename, '/');
#if defined(_WIN32) || defined(__CYGWIN__)
{
const char *slash = strrchr (filename, '\\');
if (slash
&& (!startp || startp < slash)) {
startp = slash;
}
}
#endif
if (startp) {
startp++;
} else {
startp = filename;
}

/* Remove extension */
/* Remove extension (= after last '.') */
if (!strip_ext || strcmp (strip_ext, COB_BASENAME_KEEP_EXT)) {
endp = strrchr (filename, '.');
} else {
Expand Down
68 changes: 29 additions & 39 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ static struct base_list *globext_cache = NULL;
static struct base_list *local_base_cache = NULL;
static struct string_list *string_cache = NULL;
static struct string_list *source_cache = NULL;
static char *string_buffer = NULL;
static struct label_list *label_cache = NULL;
static struct ml_tree_list *ml_tree_cache = NULL;

Expand Down Expand Up @@ -581,7 +580,6 @@ clear_local_codegen_vars (void)
local_base_cache = NULL;
local_field_cache = NULL;
static_call_cache = NULL;
string_buffer = NULL;
string_cache = NULL;
ml_tree_cache = NULL;

Expand Down Expand Up @@ -13395,6 +13393,7 @@ output_internal_function (struct cb_program *prog, cb_tree parameter_list)
for (l = prog->file_list; l; l = CB_CHAIN (l)) {
f = CB_FILE (CB_VALUE (l))->record;
if (f->flag_external) {
char string_buffer[COB_MINI_BUFF];
strcpy (string_buffer, f->name);
for (p = string_buffer; *p; p++) {
if (*p == '-' || *p == ' ') {
Expand Down Expand Up @@ -13891,9 +13890,9 @@ static void
output_entry_function (struct cb_program *prog, cb_tree entry,
cb_tree parameter_list, const int gencode)
{
const char *entry_name;
cb_tree using_list;
cb_tree l;
const char *entry_name = CB_LABEL (CB_PURPOSE (entry))->name;
cb_tree using_list = CB_VALUE (CB_VALUE (entry));
cb_tree l = CB_PURPOSE (CB_VALUE (entry)); /* entry convention */
cb_tree l1;
cb_tree l2;
struct cb_field *f;
Expand All @@ -13909,18 +13908,14 @@ output_entry_function (struct cb_program *prog, cb_tree entry,
int sticky_nonp[MAX_CALL_FIELD_PARAMS] = { 0 };
int entry_convention = 0;

entry_name = CB_LABEL (CB_PURPOSE (entry))->name;
using_list = CB_VALUE (CB_VALUE (entry));

/* entry convention */
l = CB_PURPOSE (CB_VALUE (entry));
/* LCOV_EXCL_START */
if (!l || !(CB_INTEGER_P (l) || CB_NUMERIC_LITERAL_P (l))) {
/* not translated as it is a highly unlikely internal abort */
cobc_err_msg ("Missing/wrong internal entry convention!");
COBC_ABORT ();
}
/* LCOV_EXCL_STOP */

if (CB_INTEGER_P (l)) {
entry_convention = CB_INTEGER (l)->val;
} else if (CB_NUMERIC_LITERAL_P (l)) {
Expand All @@ -13930,18 +13925,16 @@ output_entry_function (struct cb_program *prog, cb_tree entry,
if (gencode) {
output_line ("/* ENTRY '%s' */", entry_name);
output_newline ();
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(__clang__)
} else {
if (!prog->nested_level) {
output ("__declspec(dllexport) ");
output ("COB_EXT_EXPORT ");
}
#endif
}

/* Output return type. */
if ((prog->nested_level && !prog->flag_void)
|| (prog->flag_main && !prog->flag_recursive
&& !strcmp(prog->program_id, entry_name))) {
if ( (prog->nested_level && !prog->flag_void)
|| (prog->flag_main && !prog->flag_recursive
&& !strcmp (prog->program_id, entry_name))) {
output ("static ");
}
if (prog->flag_void) {
Expand Down Expand Up @@ -14271,7 +14264,7 @@ output_function_prototypes (struct cb_program *prog)
may use the same but not-default function */
if (strcmp (prog->extfh, extfh_value) != 0
&& strcmp ("EXTFH", extfh_value) != 0) {
output_line ("extern int %s (unsigned char *opcode, FCD3 *fcd);",
output_line ("COB_EXT_IMPORT int %s (unsigned char *opcode, FCD3 *fcd);",
extfh_value);
}
}
Expand All @@ -14292,7 +14285,7 @@ output_function_prototypes (struct cb_program *prog)
/* prototype for general EXTFH function */
if (prog->file_list && prog->extfh
&& strcmp ("EXTFH", prog->extfh) != 0) {
output ("extern int %s (unsigned char *opcode, FCD3 *fcd);", prog->extfh);
output ("COB_EXT_IMPORT int %s (unsigned char *opcode, FCD3 *fcd);", prog->extfh);
output_newline ();
}

Expand Down Expand Up @@ -14382,38 +14375,39 @@ emit_base_symbols (struct cb_program *prog)
void
codegen (struct cb_program *prog, const char *translate_name)
{
const int set_xref = cb_listing_xref;
int subsequent_call = 0;

codegen_init (prog, translate_name);

/* Temporarily disable cross-reference during C generation */
cb_listing_xref = 0;

for (;;) {
/* Temporarily disable cross-reference during C generation */
if (cb_listing_xref) {
cb_listing_xref = 0;
codegen_internal (current_program, subsequent_call);
cb_listing_xref = 1;
} else {
codegen_internal (current_program, subsequent_call);
}
codegen_internal (current_program, subsequent_call);
if (!current_program->next_program) {
break;
}
if (current_program->flag_file_global && current_program->next_program->nested_level) {
subsequent_call = 1;
if (current_program->flag_file_global
&& current_program->next_program->nested_level) {
has_global_file = 1;
} else {
has_global_file = 0;
}
current_program = current_program->next_program;
subsequent_call = 1;
}
current_program = prog;
cb_listing_xref = set_xref;

codegen_finalize ();
}

void
codegen_init (struct cb_program *prog, const char *translate_name)
{
char timestamp_buffer[COB_MINI_BUFF];

current_program = prog;
current_section = NULL;
current_paragraph = NULL;
Expand All @@ -14422,6 +14416,7 @@ codegen_init (struct cb_program *prog, const char *translate_name)

output_line_number = 1;
output_name = (char*)translate_name;
/* escape output name for C string */
if (strchr (output_name, '\\')) {
char buff[COB_MEDIUM_BUFF];
int pos = 0;
Expand Down Expand Up @@ -14456,32 +14451,27 @@ codegen_init (struct cb_program *prog, const char *translate_name)
}
}

if (!string_buffer) {
string_buffer = cobc_main_malloc ((size_t)COB_MINI_BUFF);
}

strftime (string_buffer, (size_t)COB_MINI_MAX,
strftime (timestamp_buffer, (size_t)COB_MINI_MAX,
"%b %d %Y %H:%M:%S", &current_compile_tm);

output_target = yyout;
output_header (string_buffer, NULL);
output_header (timestamp_buffer, NULL);
output_target = cb_storage_file;
output_header (string_buffer, NULL);
output_header (timestamp_buffer, NULL);
{
struct cb_program* cp;
struct cb_program *cp;
for (cp = prog; cp; cp = cp->next_program) {
if (cp->flag_prototype) {
continue;
}
output_target = cp->local_include->local_fp;
output_header (string_buffer, cp);
output_header (timestamp_buffer, cp);
}
}
output_target = yyout;

output_standard_includes (prog);
/* string_buffer has formatted date from above */
output_gnucobol_defines (string_buffer);
output_gnucobol_defines (timestamp_buffer);

output_newline ();
#if defined(HAVE_SIGACTION) && !defined(_WIN32)
Expand Down
Loading

0 comments on commit d967b65

Please sign in to comment.