Skip to content

Commit

Permalink
Fix save-temps with object targets
Browse files Browse the repository at this point in the history
* Do not move object files if they were specified as an explicit
  target on the command line (typically cobc -c --save-temps=DIR -o
  foo.o foo.cob should keep foo.o in the current directory)
  • Loading branch information
lefessan committed Nov 29, 2023
1 parent c0d64ad commit ebc4024
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

2023-11-29 Fabrice Le Fessant <[email protected]>

* cobc.c (cobc_clean_up): do not move object files if they were
specified as an explicit target on the command line
* parser.y: add "emit_statement_before", "drop_last_statement"
and "replace_last_statement" function for later eventual use.
They are commented using a macro.

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

* typeck.c (search_set_keys): improving SEARCH ALL syntax checks
Expand Down
6 changes: 5 additions & 1 deletion cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,11 @@ cobc_clean_up (const int status)
if (fn->need_assemble
&& (status
|| cb_compile_level > CB_LEVEL_ASSEMBLE
|| (cb_compile_level == CB_LEVEL_ASSEMBLE && save_temps))) {
|| (cb_compile_level == CB_LEVEL_ASSEMBLE
&& save_temps
/* do not move object if a name was
* specified on the command line */
&& !output_name))) {
cobc_check_action (fn->object);
}
clean_up_intermediates (fn, status);
Expand Down
7 changes: 7 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

2023-11-29 Fabrice Le Fessant <[email protected]>

* common.h: export "cob_get_strerror" as a public function
* common.c: (cob_expand_env_string): use "getpid" instead
of "cob_sys_getpid" to use the correct PID in case of "fork"
* coblocal.h: include "config.h"

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

* screenio.c, common.c: replace use of NCURSES_MOUSE_VERSION by
Expand Down
2 changes: 2 additions & 0 deletions libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef COB_LOCAL_H
#define COB_LOCAL_H

#include "config.h"

/* We use this file to define/prototype things that should not be
exported to user space
*/
Expand Down
4 changes: 2 additions & 2 deletions libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ cob_get_source_line ()
}

/* reentrant version of strerror */
static char *
char *
cob_get_strerror (void)
{
size_t size;
Expand Down Expand Up @@ -7801,7 +7801,7 @@ cob_expand_env_string (char *strval)
k--;
} else if (strval[k] == '$'
&& strval[k+1] == '$') { /* Replace $$ with process-id */
j += sprintf (&env[j], "%d", cob_sys_getpid());
j += sprintf (&env[j], "%d", getpid());
k++;
/* CHECME: possibly add $f /$b as basename of executable [or, when passed to cob_init the first name]
along with $d date as yyyymmdd and $t as hhmmss */
Expand Down
1 change: 1 addition & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,7 @@ COB_EXPIMP int cob_last_exception_is (const int);

COB_EXPIMP int cob_last_exit_code (void);
COB_EXPIMP const char* cob_last_runtime_error (void);
COB_EXPIMP char* cob_get_strerror (void);

COB_EXPIMP void cob_runtime_hint (const char *, ...) COB_A_FORMAT12;
COB_EXPIMP void cob_runtime_error (const char *, ...) COB_A_FORMAT12;
Expand Down

0 comments on commit ebc4024

Please sign in to comment.