Skip to content

Commit

Permalink
Merge branch 'gnucobol-3.x' into gcos4gnucobol-3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Jul 9, 2023
2 parents a4abf11 + 4e7a61d commit 2a101a4
Show file tree
Hide file tree
Showing 32 changed files with 1,747 additions and 555 deletions.
12 changes: 11 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ NEWS - user visible changes -*- outline -*-
callee modules that use BY VALUE must be compiled with the same version of
GnuCOBOL, either prior this release, or since.

** cobc now uses a two-pass preprocessing algorithm, where replacements for
COPY-REPLACING are done in a first pass, and the replacements for
REPLACE are done in a second pass. Note that, however, both
statements are parsed before the first replacement pass, so
COPY-REPLACING cannot impact a REPLACE statement itself.

* Changes to the COBOL compiler (cobc) options:

** new -fformat dialect option, and extended SOURCE FORMAT directives,
Expand Down Expand Up @@ -321,7 +327,9 @@ NEWS - user visible changes -*- outline -*-
and fatality `cobc --list-exceptions`

** new compiler command line option -ftcmd to enable printing of the command
line in the source listing
line in the source listing, -fno-timestamp to suppress printing of the time
and -ftittle to set a title instead of GnuCOBOL and version (_ chars are
replaced by spaces in the title)

** new compiler command line option --coverage to instrument binaries
for coverage checks
Expand Down Expand Up @@ -349,6 +357,8 @@ NEWS - user visible changes -*- outline -*-
the option -fdiagnostics-plain-output was added to request that diagnostic
output look as plain as possible and stay more stable over time

** the -P flag accepts - as argument for stdout

* Important Bugfixes:

** for dialects other than the GnuCOBOL default different reserved "alias" words
Expand Down
5 changes: 5 additions & 0 deletions build_windows/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2023-07-07 Simon Sobisch <[email protected]>

* general for cobc: include new replace.c
* version_cobc.rc: updated date + rev

2023-06-30 Simon Sobisch <[email protected]>

* config.h.in: updated for OrangeC 6.0.70.2
Expand Down
1 change: 1 addition & 0 deletions build_windows/ocide/cobc.exe.cpj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<FILE NAME="..\..\cobc\parser.y" TITLE="parser.y" CLEAN="0"/>
<FILE NAME="..\..\cobc\ppparse.y" TITLE="ppparse.y" CLEAN="0"/>
<FILE NAME="..\..\cobc\reserved.c" TITLE="reserved.c" CLEAN="0"/>
<FILE NAME="..\..\cobc\replace.c" TITLE="replace.c" CLEAN="0"/>
<FILE NAME="..\..\cobc\tree.c" TITLE="tree.c" CLEAN="0"/>
<FILE NAME="..\..\cobc\typeck.c" TITLE="typeck.c" CLEAN="0"/>
</FOLDER>
Expand Down
4 changes: 2 additions & 2 deletions build_windows/version_cobc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "config.h"

#include "../libcob/version.h"
#define VCS_REF 5055
#define VCS_REF 5112

#define STRINGIZE_DETAIL_(v) #v
#define STRINGIZE(v) STRINGIZE_DETAIL_(v)
Expand Down Expand Up @@ -55,7 +55,7 @@ VS_VERSION_INFO VERSIONINFO
VALUE "SpecialBuild", ""

/* Non-Standard entries */
VALUE "Build", "May 2023"
VALUE "Build", "July 2023"
VALUE "Developer", "Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart and many others (see AUTHORS and THANKS)"
VALUE "Support", "https://www.gnu.org/software/gnucobol/"
VALUE "Users", "Unlimited."
Expand Down
4 changes: 4 additions & 0 deletions build_windows/vs2005/cobc.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\cobc\replace.c"
>
</File>
<File
RelativePath="..\..\cobc\reserved.c"
>
Expand Down
4 changes: 4 additions & 0 deletions build_windows/vs2008/cobc.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\cobc\replace.c"
>
</File>
<File
RelativePath="..\..\cobc\reserved.c"
>
Expand Down
1 change: 1 addition & 0 deletions build_windows/vs2010/cobc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
<ClCompile Include="..\..\cobc\error.c" />
<ClCompile Include="..\..\cobc\field.c" />
<ClCompile Include="..\..\cobc\help.c" />
<ClCompile Include="..\..\cobc\replace.c" />
<ClCompile Include="..\..\cobc\reserved.c" />
<ClCompile Include="..\..\cobc\tree.c" />
<ClCompile Include="..\..\cobc\typeck.c" />
Expand Down
3 changes: 3 additions & 0 deletions build_windows/vs2010/cobc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="..\..\cobc\field.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\replace.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\reserved.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions build_windows/vs2012/cobc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<ClCompile Include="..\..\cobc\error.c" />
<ClCompile Include="..\..\cobc\field.c" />
<ClCompile Include="..\..\cobc\help.c" />
<ClCompile Include="..\..\cobc\replace.c" />
<ClCompile Include="..\..\cobc\reserved.c" />
<ClCompile Include="..\..\cobc\tree.c" />
<ClCompile Include="..\..\cobc\typeck.c" />
Expand Down
3 changes: 3 additions & 0 deletions build_windows/vs2012/cobc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="..\..\cobc\field.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\replace.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\reserved.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions build_windows/vs2013/cobc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<ClCompile Include="..\..\cobc\error.c" />
<ClCompile Include="..\..\cobc\field.c" />
<ClCompile Include="..\..\cobc\help.c" />
<ClCompile Include="..\..\cobc\replace.c" />
<ClCompile Include="..\..\cobc\reserved.c" />
<ClCompile Include="..\..\cobc\tree.c" />
<ClCompile Include="..\..\cobc\typeck.c" />
Expand Down
3 changes: 3 additions & 0 deletions build_windows/vs2013/cobc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="..\..\cobc\field.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\replace.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\reserved.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions build_windows/vs2015/cobc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<ClCompile Include="..\..\cobc\error.c" />
<ClCompile Include="..\..\cobc\field.c" />
<ClCompile Include="..\..\cobc\help.c" />
<ClCompile Include="..\..\cobc\replace.c" />
<ClCompile Include="..\..\cobc\reserved.c" />
<ClCompile Include="..\..\cobc\tree.c" />
<ClCompile Include="..\..\cobc\typeck.c" />
Expand Down
3 changes: 3 additions & 0 deletions build_windows/vs2015/cobc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="..\..\cobc\field.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\replace.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\reserved.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions build_windows/vs2017/cobc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<ClCompile Include="..\..\cobc\error.c" />
<ClCompile Include="..\..\cobc\field.c" />
<ClCompile Include="..\..\cobc\help.c" />
<ClCompile Include="..\..\cobc\replace.c" />
<ClCompile Include="..\..\cobc\reserved.c" />
<ClCompile Include="..\..\cobc\tree.c" />
<ClCompile Include="..\..\cobc\typeck.c" />
Expand Down
3 changes: 3 additions & 0 deletions build_windows/vs2017/cobc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="..\..\cobc\field.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\replace.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\reserved.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions build_windows/vs2019/cobc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<ClCompile Include="..\..\cobc\error.c" />
<ClCompile Include="..\..\cobc\field.c" />
<ClCompile Include="..\..\cobc\help.c" />
<ClCompile Include="..\..\cobc\replace.c" />
<ClCompile Include="..\..\cobc\reserved.c" />
<ClCompile Include="..\..\cobc\tree.c" />
<ClCompile Include="..\..\cobc\typeck.c" />
Expand Down
3 changes: 3 additions & 0 deletions build_windows/vs2019/cobc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClCompile Include="..\..\cobc\field.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\replace.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cobc\reserved.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
49 changes: 49 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@

2023-07-07 Simon Sobisch <[email protected]>

common preparser cleanup
* ppparse.y: error recovery for COPY and REPLACE (consume until DOT
instead of until EOF)
* ppparse.y: renamed "TOKEN" from "Identifier" to "Word", adjust
some terminals prefixing it with leading underscore as optional
Bug #890 wrong reference in COPY diagnostic
* ppparse.y: switch to new buffer after parsing DOT, not before
Bug #23 several replacement values create parser errors
* pplex.l: split REPLACE_STATE and REPLACING_STATE from COPY_STATE
to limit their reserved word list to the applicable ones and to
improve error handling
* ppparse.y: explicit parse IN and OF as single replacement words

2023-07-06 Fabrice Le Fessant <[email protected]>

* replace.c: rewrite the code for preprocessing with a two-phase
algorithm. The first phase performs COPY REPLACING on the stream
of tokens, while the second phase perform REPLACE on the resulting
stream of tokens. This rewriting is closer to the COBOL standard
and fixes bug #831 partially.
* cobc.c: flag -P now accepts - as argument to mean stdout

2023-07-05 Fabrice Le Fessant <[email protected]>

* flag.def/cobc.c: new flags -fno-ttimestamp to suppress timestamp
Expand All @@ -9,6 +33,13 @@
CB_FLAG_GETOPT_. Remove unused 'case 6:' for -fdefaultbyte that is
now handled in config.c

2023-07-02 Fabrice Le Fessant <[email protected]>

* pplex.l (ppecho, ppecho_direct): replace alt_space by passing a
second equivalent token
* pplex.l, replace.c: move the preprocessing code performing
COPY REPLACING and REPLACE from pplex.l to replace.c

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

* codegen.c (output_char): extracted usage of disabled code for
Expand Down Expand Up @@ -325,18 +356,36 @@

* typeck.c (cb_build_move_field): generate optimized code for
reference-modification with same ref-mod length
* parser.y: fix several possible bad uses of "ALLOCATE identifier",
including "no identifier at all" and use of subscripting / ref-mod
which previously were all silently ignored

2023-03-08 Emilien Lemaire <[email protected]>

* reserved.c (get_user_specified_reserved_word): add check for
context sensitivity in aliases
* parser.y (begin_statement_internal): extracted from begin_statement and
begin_statement_from_backup_pos
* parser.y: explicit creation of "comment note" tokens to store the start
position for tokens used later, either direct for diagnostics or by
assigning it with the new function copy_pos instead of using a global
"backup position" or using the current position
* parser.y: explicit check for missing imperative statements in several
places that need one to generate a clean error
* parser.y (emit_entry): removed unused parameter override_source_line
* typeck.c (cb_emit_call), tree.h, parser.y: remove passing the CALL's
original line number as extra parameter, instead use the statement's
(now correct) position

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

* 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
* parser.y (check_non_area_a_of): new function used to do the area check
for all terminators and during error recovery
* parser.y: check area A for END FUNCTION

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

Expand Down
3 changes: 2 additions & 1 deletion cobc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
bin_PROGRAMS = cobc
cobc_SOURCES = cobc.c cobc.h ppparse.y pplex.c parser.y scanner.c config.c \
reserved.c error.c tree.c tree.h field.c typeck.c codegen.c help.c \
config.def flag.def warning.def codeoptim.def ppparse.def codeoptim.c
config.def flag.def warning.def codeoptim.def ppparse.def \
codeoptim.c replace.c

#cobc_SOURCES = cobc.c cobc.h ppparse.y pplex.l parser.y scanner.l config.c

Expand Down
54 changes: 52 additions & 2 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static const char *const cob_csyns[] = {

#define COB_NUM_CSYNS sizeof(cob_csyns) / sizeof(cob_csyns[0])

static const char short_options[] = "hVivqECScbmxjdFOPgwo:t:T:I:L:l:D:K:k:";
static const char short_options[] = "hVivqECScbmxjdFOgwo:P:t:T:I:L:l:D:K:k:";

#define CB_NO_ARG no_argument
#define CB_RQ_ARG required_argument
Expand Down Expand Up @@ -1337,6 +1337,50 @@ cobc_plex_strdup (const char *dupstr)
return p;
}

/* Return a newly allocated zero-terminated string with only the first
* len chars of the first argument */
void *
cobc_plex_strsub (const char *s, const int len)
{
void *p;
int n;

n = strlen (s);

#ifdef COB_TREE_DEBUG
/* LCOV_EXCL_START */
if ( len>n ) {
cobc_err_msg ("call to %s with bad argument len=%d>%d=strlen(s)",
"cobc_plex_strsub", len, n);
cobc_abort_terminate (1);
}
/* LCOV_EXCL_STOP */
#endif

p = cobc_plex_malloc (len + 1);
memcpy (p, s, len);
return p;
}

/* Returns a newly allocated zero-terminated string containing the
* concatenation of str1 and str2. str1 and str2 may be freed
* afterwards.
*/
char *
cobc_plex_stradd (const char *str1, const char *str2)
{
char *p;
size_t m, n;

m = strlen (str1);
n = strlen (str2);
p = cobc_plex_malloc (m + n + 1);
memcpy (p, str1, m);
memcpy (p + m, str2, n);
return p;
}


/* variant of strcpy which copies max 'max_size' bytes from 'src' to 'dest',
if the size of 'src' is too long only its last/last bytes are copied and an
eliding "..." is placed in front or at end depending on 'elide_at_end' */
Expand Down Expand Up @@ -9140,6 +9184,9 @@ main (int argc, char **argv)
memset (cb_listing_header, 0, sizeof (cb_listing_header));
/* If -P=file specified, all lists go to this file */
if (cobc_list_file) {
if (strcmp (cobc_list_file, COB_DASH) == 0) {
cb_listing_file = stdout;
} else
if (cb_unix_lf) {
cb_listing_file = fopen (cobc_list_file, "wb");
} else {
Expand Down Expand Up @@ -9225,7 +9272,10 @@ main (int argc, char **argv)
}

if (cobc_list_file) {
fclose (cb_listing_file);
if (cb_listing_file != stdout)
fclose (cb_listing_file);
else
fflush (stdout);
cb_listing_file = NULL;
}

Expand Down
2 changes: 2 additions & 0 deletions cobc/cobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ extern void cobc_parse_free (void *);

extern void *cobc_plex_malloc (const size_t);
extern void *cobc_plex_strdup (const char *);
extern void *cobc_plex_strsub (const char *, const int len);
extern char *cobc_plex_stradd (const char *str1, const char *str2);

extern void *cobc_check_string (const char *);
extern void cobc_err_msg (const char *, ...) COB_A_FORMAT12;
Expand Down
Loading

0 comments on commit 2a101a4

Please sign in to comment.