GnuCOBOL  2.0
A free COBOL compiler
cobc.c File Reference
#include "config.h"
#include "defaults.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include "tarstamp.h"
#include "cobc.h"
#include "tree.h"
#include "lib/gettext.h"
#include "libcob.h"
#include "libcob/cobgetopt.h"
#include "libcob/exception.def"
#include "flag.def"
#include "warning.def"
Include dependency graph for cobc.c:

Go to the source code of this file.

Data Structures

struct  strcache
 

Macros

#define CB_LEVEL_PREPROCESS   1
 
#define CB_LEVEL_TRANSLATE   2
 
#define CB_LEVEL_COMPILE   3
 
#define CB_LEVEL_ASSEMBLE   4
 
#define CB_LEVEL_MODULE   5
 
#define CB_LEVEL_LIBRARY   6
 
#define CB_LEVEL_EXECUTABLE   7
 
#define CB_IMSG_SIZE   24
 
#define CB_IVAL_SIZE   (74 - CB_IMSG_SIZE - 4)
 
#define COBC_ADD_STR(v, x, y, z)   cobc_add_str (&v, &v##_size, x, y, z);
 
#define COBC_INV_PAR   _("Invalid %s parameter")
 
#define OC_C_VERSION_PRF   ""
 
#define OC_C_VERSION   "unknown"
 
#define CB_TEXT_LIST_ADD(y, z)   y = cb_text_list_add (y, z)
 
#define CB_TEXT_LIST_CHK(y, z)   y = cb_text_list_chk (y, z)
 
#define CB_COPT_1   " -O"
 
#define CB_COPT_2   " -O2"
 
#define CB_COPT_S   " -Os"
 
#define COB_EXCEPTION(code, tag, name, critical)   {name, 0x##code, 0},
 
#define CB_FLAG(var, pdok, name, doc)   int var = 0;
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   int var = def;
 
#define CB_FLAG_NQ(pdok, name, opt, doc)
 
#define CB_WARNDEF(var, name, doc)   int var = 0;
 
#define CB_NOWARNDEF(var, name, doc)   int var = 0;
 
#define COB_NUM_CSYNS   sizeof(cob_csyns) / sizeof(char *)
 
#define CB_NO_ARG   no_argument
 
#define CB_RQ_ARG   required_argument
 
#define CB_OP_ARG   optional_argument
 
#define CB_FLAG(var, pdok, name, doc)
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   {"f"name, CB_RQ_ARG, NULL, opt},
 
#define CB_FLAG_NQ(pdok, name, opt, doc)   {"f"name, CB_RQ_ARG, NULL, opt},
 
#define CB_WARNDEF(var, name, doc)
 
#define CB_NOWARNDEF(var, name, doc)
 
#define CB_WARNDEF(var, name, doc)   cobc_print_warn (name, doc, 1);
 
#define CB_NOWARNDEF(var, name, doc)   cobc_print_warn (name, doc, 0);
 
#define CB_FLAG(var, pdok, name, doc)   cobc_print_flag (name, doc, pdok, 0);
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   cobc_print_flag (name, doc, pdok, 1);
 
#define CB_FLAG_NQ(pdok, name, opt, doc)   cobc_print_flag (name, doc, pdok, 1);
 
#define CB_WARNDEF(var, name, doc)   var = 0;
 
#define CB_NOWARNDEF(var, name, doc)   var = 0;
 
#define CB_WARNDEF(var, name, doc)   var = 1;
 
#define CB_NOWARNDEF(var, name, doc)
 
#define CB_WARNDEF(var, name, doc)   var = 1;
 
#define CB_NOWARNDEF(var, name, doc)   var = 1;
 

Functions

static DECLNORET void COB_A_NORETURN cobc_abort_terminate (void)
 
static void cobc_free_mem (void)
 
static const char * cobc_enum_explain (const enum cb_tag tag)
 
void cobc_abort_pr (const char *fmt,...)
 
void cobc_too_many_errors (void)
 
void cobc_abort (const char *filename, const int linenum)
 
void cobc_dumb_abort (const char *filename, const int linenum)
 
void cobc_tree_cast_error (const cb_tree x, const char *filename, const int linenum, const enum cb_tag tagnum)
 
void * cobc_malloc (const size_t size)
 
void cobc_free (void *mptr)
 
void * cobc_strdup (const char *dupstr)
 
void * cobc_realloc (void *prevptr, const size_t size)
 
void * cobc_main_malloc (const size_t size)
 
void * cobc_main_strdup (const char *dupstr)
 
void * cobc_main_realloc (void *prevptr, const size_t size)
 
void cobc_main_free (void *prevptr)
 
void * cobc_parse_malloc (const size_t size)
 
void * cobc_parse_strdup (const char *dupstr)
 
void * cobc_parse_realloc (void *prevptr, const size_t size)
 
void cobc_parse_free (void *prevptr)
 
void * cobc_plex_malloc (const size_t size)
 
void * cobc_plex_strdup (const char *dupstr)
 
void * cobc_check_string (const char *dupstr)
 
static struct cb_text_listcb_text_list_add (struct cb_text_list *list, const char *text)
 
static struct cb_text_listcb_text_list_chk (struct cb_text_list *list, const char *text)
 
static unsigned int cobc_set_value (struct cb_define_struct *p, const char *value)
 
static int cobc_bcompare (const void *p1, const void *p2)
 
static void cobc_error_name (const char *name, const unsigned int source, const unsigned int reason)
 
size_t cobc_check_valid_name (const char *name, const unsigned int prechk)
 
static void cobc_chk_buff_size (const size_t bufflen)
 
static int cobc_deciph_optarg (const char *p, const int allow_quote)
 
static DECLNORET void COB_A_NORETURN cobc_err_exit (const char *fmt,...)
 
static struct cb_define_structcb_define_list_add (struct cb_define_struct *list, const char *text)
 
static char * cobc_stradd_dup (const char *str1, const char *str2)
 
static char * cobc_getenv (const char *env)
 
static void cobc_add_str (char **var, size_t *cursize, const char *s1, const char *s2, const char *s3)
 
static void cobc_check_action (const char *name)
 
static void cobc_clean_up (const int status)
 
static DECLNORET void COB_A_NORETURN cobc_terminate (const char *str)
 
static void cobc_print_version (void)
 
static void cobc_cmd_print (const char *cmd)
 
static void cobc_var_print (const char *msg, const char *val, const unsigned int env)
 
static void cobc_print_info (void)
 
static void cobc_print_warn (const char *name, const char *doc, const int wall)
 
static void cobc_print_flag (const char *name, const char *doc, const int pdok, const int exten)
 
static void cobc_print_usage (char *prog)
 
static void cobc_options_error_nonfinal (void)
 
static void cobc_options_error_build (void)
 
static void cobc_deciph_funcs (const char *opt)
 
static int process_command_line (const int argc, char **argv)
 
static struct cb_programprogram_list_reverse (struct cb_program *p)
 
static void process_env_copy_path (const char *p)
 
static char * file_basename (const char *filename)
 
static const char * file_extension (const char *filename)
 
static struct filenameprocess_filename (const char *filename)
 
static int process_run (const char *name)
 -j run job after build More...
 
static int process (const char *cmd)
 
static int preprocess (struct filename *fn)
 
static int process_translate (struct filename *fn)
 
static int process_compile (struct filename *fn)
 
static int process_assemble (struct filename *fn)
 
static int process_module_direct (struct filename *fn)
 
static int process_module (struct filename *fn)
 
static int process_library (struct filename *l)
 
static int process_link (struct filename *l)
 
int main (int argc, char **argv)
 

Variables

const char * cb_source_file = ((void*)0)
 
char * cb_oc_build_stamp = ((void*)0)
 
const char * demangle_name = ((void*)0)
 
const char * cb_storage_file_name = ((void*)0)
 
struct cb_text_listcb_include_list = ((void*)0)
 
struct cb_text_listcb_intrinsic_list = ((void*)0)
 
struct cb_text_listcb_extension_list = ((void*)0)
 
struct cb_text_listcb_static_call_list = ((void*)0)
 
struct cb_text_listcb_early_exit_list = ((void*)0)
 
char ** cb_saveargv = ((void*)0)
 
const char * cob_config_dir = ((void*)0)
 
FILE * cb_storage_file = ((void*)0)
 
FILE * cb_listing_file = ((void*)0)
 
int cb_source_format = 0
 
int cb_id = 0
 
int cb_attr_id = 0
 
int cb_literal_id = 0
 
int cb_field_id = 0
 
int cobc_flag_main = 0
 
int cb_flag_main = 0
 
int cobc_wants_debug = 0
 
int cb_flag_functions_all = 0
 
int cobc_seen_stdin = 0
 
int errorcount = 0
 
int warningcount = 0
 
int exit_option = 0
 
int warningopt = 0
 
int no_physical_cancel = 0
 
int cb_source_line = 0
 
int cb_saveargc = 0
 
unsigned int cobc_gen_listing = 0
 
cob_u32_t optimize_defs [COB_OPTIM_MAX] = { 0 }
 
struct cb_exception cb_exception_table []
 
static struct cb_define_structcb_define_list = ((void*)0)
 
static struct cobc_mem_structcobc_mainmem_base = ((void*)0)
 
static struct cobc_mem_structcobc_parsemem_base = ((void*)0)
 
static struct cobc_mem_structcobc_plexmem_base = ((void*)0)
 
static const char * cobc_cc
 
static char * cobc_cflags
 
static char * cobc_libs
 
static char * cobc_lib_paths
 
static char * cobc_include
 
static char * cobc_ldflags
 
static size_t cobc_cflags_size
 
static size_t cobc_libs_size
 
static size_t cobc_lib_paths_size
 
static size_t cobc_include_size
 
static size_t cobc_ldflags_size
 
static size_t cobc_cc_len
 
static size_t cobc_cflags_len
 
static size_t cobc_libs_len
 
static size_t cobc_lib_paths_len
 
static size_t cobc_include_len
 
static size_t cobc_ldflags_len
 
static size_t cobc_export_dyn_len
 
static size_t cobc_shared_opt_len
 
static size_t cobc_pic_flags_len
 
static char * save_temps_dir
 
static struct strcachebase_string
 
static char * cobc_list_dir
 
static char * cobc_list_file
 
static char * output_name
 
static char * cobc_buffer
 
static char * cobc_objects_buffer
 
static char * output_name_buff
 
static char * basename_buffer
 
static size_t cobc_objects_len
 
static size_t basename_len
 
static size_t cobc_buffer_size
 
static struct filenamefile_list
 
static unsigned int cb_compile_level = 0
 
static int iargs
 
static size_t wants_nonfinal = 0
 
static size_t cobc_flag_module = 0
 
static size_t cobc_flag_library = 0
 
static size_t cobc_flag_run = 0
 
static size_t save_temps = 0
 
static size_t save_all_src = 0
 
static size_t save_c_src = 0
 
static size_t verbose_output = 0
 
static size_t cob_optimize = 0
 
static size_t strip_output = 0
 
static size_t gflag_set = 0
 
static size_t aflag_set = 0
 
static const char *const cob_csyns []
 
static const char short_options [] = "hVivECScbmxjdFOPgwo:I:L:l:D:K:k:"
 
static const struct option long_options []
 
int yydebug
 

Macro Definition Documentation

#define CB_COPT_1   " -O"

Definition at line 138 of file cobc.c.

Referenced by main(), and process_command_line().

#define CB_COPT_2   " -O2"

Definition at line 139 of file cobc.c.

Referenced by process_command_line().

#define CB_COPT_S   " -Os"

Definition at line 140 of file cobc.c.

Referenced by process_command_line().

#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    int var = 0;

Definition at line 196 of file cobc.c.

#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)
Value:
{"f"name, CB_NO_ARG, &var, 1}, \
{"fno-"name, CB_NO_ARG, &var, 0},
#define CB_NO_ARG
Definition: cobc.c:392

Definition at line 196 of file cobc.c.

#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    cobc_print_flag (name, doc, pdok, 0);

Definition at line 196 of file cobc.c.

#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)

Definition at line 198 of file cobc.c.

#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)    {"f"name, CB_RQ_ARG, NULL, opt},

Definition at line 198 of file cobc.c.

#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)    cobc_print_flag (name, doc, pdok, 1);

Definition at line 198 of file cobc.c.

#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    int var = def;

Definition at line 197 of file cobc.c.

#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    {"f"name, CB_RQ_ARG, NULL, opt},

Definition at line 197 of file cobc.c.

#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    cobc_print_flag (name, doc, pdok, 1);

Definition at line 197 of file cobc.c.

#define CB_IMSG_SIZE   24

Definition at line 80 of file cobc.c.

Referenced by cobc_var_print().

#define CB_IVAL_SIZE   (74 - CB_IMSG_SIZE - 4)

Definition at line 81 of file cobc.c.

Referenced by cobc_var_print().

#define CB_LEVEL_ASSEMBLE   4

Definition at line 74 of file cobc.c.

Referenced by cobc_clean_up(), main(), process_assemble(), process_command_line(), and process_filename().

#define CB_LEVEL_COMPILE   3

Definition at line 73 of file cobc.c.

Referenced by main(), and process_command_line().

#define CB_LEVEL_EXECUTABLE   7

Definition at line 77 of file cobc.c.

Referenced by main().

#define CB_LEVEL_LIBRARY   6

Definition at line 76 of file cobc.c.

Referenced by main(), process_assemble(), and process_run().

#define CB_LEVEL_MODULE   5

Definition at line 75 of file cobc.c.

Referenced by main(), process_assemble(), and process_run().

#define CB_LEVEL_PREPROCESS   1

Definition at line 71 of file cobc.c.

Referenced by cobc_clean_up(), main(), process_command_line(), and process_filename().

#define CB_LEVEL_TRANSLATE   2

Definition at line 72 of file cobc.c.

Referenced by cobc_clean_up(), main(), process_command_line(), and process_filename().

#define CB_NO_ARG   no_argument

Definition at line 392 of file cobc.c.

#define CB_NOWARNDEF (   var,
  name,
  doc 
)    int var = 0;

Definition at line 207 of file cobc.c.

#define CB_NOWARNDEF (   var,
  name,
  doc 
)
Value:
{"W"name, CB_NO_ARG, &var, 1}, \
{"Wno-"name, CB_NO_ARG, &var, 0},
#define CB_NO_ARG
Definition: cobc.c:392

Definition at line 207 of file cobc.c.

#define CB_NOWARNDEF (   var,
  name,
  doc 
)    cobc_print_warn (name, doc, 0);

Definition at line 207 of file cobc.c.

#define CB_NOWARNDEF (   var,
  name,
  doc 
)    var = 0;

Definition at line 207 of file cobc.c.

#define CB_NOWARNDEF (   var,
  name,
  doc 
)

Definition at line 207 of file cobc.c.

#define CB_NOWARNDEF (   var,
  name,
  doc 
)    var = 1;

Definition at line 207 of file cobc.c.

#define CB_OP_ARG   optional_argument

Definition at line 394 of file cobc.c.

#define CB_RQ_ARG   required_argument

Definition at line 393 of file cobc.c.

#define CB_TEXT_LIST_ADD (   y,
 
)    y = cb_text_list_add (y, z)

Definition at line 110 of file cobc.c.

Referenced by cobc_deciph_funcs(), main(), and process_command_line().

#define CB_TEXT_LIST_CHK (   y,
 
)    y = cb_text_list_chk (y, z)

Definition at line 111 of file cobc.c.

Referenced by main(), and process_env_copy_path().

#define CB_WARNDEF (   var,
  name,
  doc 
)    int var = 0;

Definition at line 206 of file cobc.c.

#define CB_WARNDEF (   var,
  name,
  doc 
)
Value:
{"W"name, CB_NO_ARG, &var, 1}, \
{"Wno-"name, CB_NO_ARG, &var, 0},
#define CB_NO_ARG
Definition: cobc.c:392

Definition at line 206 of file cobc.c.

#define CB_WARNDEF (   var,
  name,
  doc 
)    cobc_print_warn (name, doc, 1);

Definition at line 206 of file cobc.c.

#define CB_WARNDEF (   var,
  name,
  doc 
)    var = 0;

Definition at line 206 of file cobc.c.

#define CB_WARNDEF (   var,
  name,
  doc 
)    var = 1;

Definition at line 206 of file cobc.c.

#define CB_WARNDEF (   var,
  name,
  doc 
)    var = 1;

Definition at line 206 of file cobc.c.

#define COB_EXCEPTION (   code,
  tag,
  name,
  critical 
)    {name, 0x##code, 0},

Definition at line 185 of file cobc.c.

#define COB_NUM_CSYNS   sizeof(cob_csyns) / sizeof(char *)

Definition at line 388 of file cobc.c.

Referenced by cobc_check_valid_name().

#define COBC_ADD_STR (   v,
  x,
  y,
 
)    cobc_add_str (&v, &v##_size, x, y, z);

Definition at line 83 of file cobc.c.

Referenced by main(), and process_command_line().

#define COBC_INV_PAR   _("Invalid %s parameter")

Definition at line 84 of file cobc.c.

Referenced by process_command_line().

#define OC_C_VERSION   "unknown"

Definition at line 107 of file cobc.c.

Referenced by cobc_print_version().

#define OC_C_VERSION_PRF   ""

Definition at line 106 of file cobc.c.

Referenced by cobc_print_version().

Function Documentation

static struct cb_define_struct* cb_define_list_add ( struct cb_define_struct list,
const char *  text 
)
static

Definition at line 1245 of file cobc.c.

References _, cobc_abort_pr(), cobc_check_string(), cobc_free(), cobc_main_malloc(), cobc_set_value(), cobc_strdup(), cb_define_struct::deftype, cb_define_struct::last, cb_define_struct::name, cb_define_struct::next, NULL, and PLEX_DEF_NONE.

Referenced by process_command_line().

1246 {
1247  struct cb_define_struct *p;
1248  struct cb_define_struct *l;
1249  char *s;
1250  char *x;
1251 
1252  x = cobc_strdup (text);
1253  s = strtok (x, "=");
1254 
1255  /* Check duplicate */
1256  for (l = list; l; l = l->next) {
1257  if (!strcasecmp (s, l->name)) {
1258  cobc_abort_pr (_("Duplicate define '%s' - Ignoring"), s);
1259  cobc_free (x);
1260  return list;
1261  }
1262  }
1263 
1264  p = cobc_main_malloc (sizeof (struct cb_define_struct));
1265  p->next = NULL;
1266  p->name = cobc_check_string (s);
1267  p->deftype = PLEX_DEF_NONE;
1268  s = strtok (NULL, "");
1269  if (cobc_set_value (p, s)) {
1270  cobc_free (x);
1271  return NULL;
1272  }
1273 
1274  cobc_free (x);
1275 
1276  if (!list) {
1277  p->last = p;
1278  return p;
1279  }
1280  list->last->next = p;
1281  list->last = p;
1282  return list;
1283 }
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
struct cb_define_struct * next
Definition: cobc.h:177
#define PLEX_DEF_NONE
Definition: cobc.h:97
void cobc_free(void *mptr)
Definition: cobc.c:657
void * cobc_check_string(const char *dupstr)
Definition: cobc.c:951
char * name
Definition: cobc.h:179
#define _(s)
Definition: cobcrun.c:59
unsigned int deftype
Definition: cobc.h:181
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct cb_define_struct * last
Definition: cobc.h:178
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669
static unsigned int cobc_set_value(struct cb_define_struct *p, const char *value)
Definition: cobc.c:1003

Here is the call graph for this function:

Here is the caller graph for this function:

static struct cb_text_list* cb_text_list_add ( struct cb_text_list list,
const char *  text 
)
static

Definition at line 974 of file cobc.c.

References cobc_main_malloc(), cobc_main_strdup(), cb_text_list::last, cb_text_list::next, and cb_text_list::text.

Referenced by cb_text_list_chk().

975 {
976  struct cb_text_list *p;
977 
978  p = cobc_main_malloc (sizeof (struct cb_text_list));
979  p->text = cobc_main_strdup (text);
980  if (!list) {
981  p->last = p;
982  return p;
983  }
984  list->last->next = p;
985  list->last = p;
986  return list;
987 }
struct cb_text_list * next
Definition: cobc.h:160
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
const char * text
Definition: cobc.h:162
struct cb_text_list * last
Definition: cobc.h:161
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720

Here is the call graph for this function:

Here is the caller graph for this function:

static struct cb_text_list* cb_text_list_chk ( struct cb_text_list list,
const char *  text 
)
static

Definition at line 990 of file cobc.c.

References cb_text_list_add(), cb_text_list::next, and cb_text_list::text.

991 {
992  struct cb_text_list *p;
993 
994  for (p = list; p; p = p->next) {
995  if (!strcmp (text, p->text)) {
996  return list;
997  }
998  }
999  return cb_text_list_add (list, text);
1000 }
struct cb_text_list * next
Definition: cobc.h:160
const char * text
Definition: cobc.h:162
static struct cb_text_list * cb_text_list_add(struct cb_text_list *list, const char *text)
Definition: cobc.c:974

Here is the call graph for this function:

void cobc_abort ( const char *  filename,
const int  linenum 
)

Definition at line 606 of file cobc.c.

References _, cobc_abort_pr(), and cobc_abort_terminate().

Referenced by cobc_dumb_abort().

607 {
608  cobc_abort_pr (_("%s:%d Internal compiler error"), filename, linenum);
610 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
Definition: cobc.h:195

Here is the call graph for this function:

Here is the caller graph for this function:

static DECLNORET void COB_A_NORETURN cobc_abort_terminate ( void  )
static

Definition at line 1486 of file cobc.c.

References _, cb_source_file, cb_source_line, cobc_abort_pr(), and cobc_clean_up().

Referenced by cobc_abort(), cobc_check_string(), cobc_free(), cobc_main_free(), cobc_main_malloc(), cobc_main_realloc(), cobc_main_strdup(), cobc_malloc(), cobc_parse_free(), cobc_parse_malloc(), cobc_parse_realloc(), cobc_parse_strdup(), cobc_plex_malloc(), cobc_plex_strdup(), cobc_realloc(), cobc_stradd_dup(), cobc_strdup(), cobc_too_many_errors(), and cobc_tree_cast_error().

1487 {
1488  if (cb_source_file) {
1489  cobc_abort_pr (_("Aborting compile of %s at line %d"),
1491  }
1492  cobc_clean_up (99);
1493  exit (99);
1494 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
const char * cb_source_file
Definition: cobc.c:145
#define _(s)
Definition: cobcrun.c:59
int cb_source_line
Definition: cobc.c:178
static void cobc_clean_up(const int status)
Definition: cobc.c:1380

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_add_str ( char **  var,
size_t *  cursize,
const char *  s1,
const char *  s2,
const char *  s3 
)
static

Definition at line 1318 of file cobc.c.

References _, cobc_err_exit(), and cobc_main_realloc().

1320 {
1321  size_t calcsize;
1322 
1323  if (!s1) {
1324  return;
1325  }
1326 
1327  calcsize = strlen (*var);
1328  calcsize += strlen (s1);
1329  if (s2) {
1330  calcsize += strlen (s2);
1331  }
1332  if (s3) {
1333  calcsize += strlen (s3);
1334  }
1335  if (calcsize >= 131072) {
1336  /* Arbitrary limit */
1337  cobc_err_exit (_("Parameter buffer size exceeded"));
1338  }
1339  if (calcsize >= *cursize) {
1340  while (*cursize <= calcsize) {
1341  *cursize *= 2;
1342  }
1343  *var = cobc_main_realloc (*var, *cursize);
1344  }
1345  strcat (*var, s1);
1346  if (s2) {
1347  strcat (*var, s2);
1348  }
1349  if (s3) {
1350  strcat (*var, s3);
1351  }
1352 }
static DECLNORET void COB_A_NORETURN cobc_err_exit(const char *fmt,...)
Definition: cobc.c:1229
void * cobc_main_realloc(void *prevptr, const size_t size)
Definition: cobc.c:738
#define _(s)
Definition: cobcrun.c:59

Here is the call graph for this function:

static int cobc_bcompare ( const void *  p1,
const void *  p2 
)
static

Definition at line 1086 of file cobc.c.

Referenced by cobc_check_valid_name().

1087 {
1088  const void **tptr;
1089 
1090  tptr = (const void **)p2;
1091  return strcmp (p1, *tptr);
1092 }

Here is the caller graph for this function:

static void cobc_check_action ( const char *  name)
static

Definition at line 1355 of file cobc.c.

References _, COB_MEDIUM_BUFF, COB_MEDIUM_MAX, cobc_abort_pr(), F_OK, save_temps, save_temps_dir, and SLASH_STR.

Referenced by cobc_clean_up(), process_library(), process_link(), process_module(), and process_module_direct().

1356 {
1357  if (!name || access (name, F_OK)) {
1358  return;
1359  }
1360  if (!save_temps) {
1361  (void)unlink (name);
1362  return;
1363  }
1364  if (save_temps_dir) {
1365  char temp_buff[COB_MEDIUM_BUFF];
1366 
1367  snprintf (temp_buff, (size_t)COB_MEDIUM_MAX,
1368  "%s%s%s", save_temps_dir, SLASH_STR, name);
1369  temp_buff[COB_MEDIUM_MAX] = 0;
1370  /* Remove possible target file - ignore return */
1371  (void)unlink (temp_buff);
1372  if (rename (name, temp_buff)) {
1373  cobc_abort_pr (_("Warning - Could not move temporary file to %s"),
1374  temp_buff);
1375  }
1376  }
1377 }
static char * save_temps_dir
Definition: cobc.c:247
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define SLASH_STR
Definition: common.h:506
#define COB_MEDIUM_BUFF
Definition: common.h:543
#define _(s)
Definition: cobcrun.c:59
#define F_OK
Definition: cobc.h:46
static size_t save_temps
Definition: cobc.c:273
#define COB_MEDIUM_MAX
Definition: common.h:549

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_check_string ( const char *  dupstr)

Definition at line 951 of file cobc.c.

References _, base_string, cobc_abort_pr(), cobc_abort_terminate(), cobc_main_malloc(), cobc_main_strdup(), strcache::next, unlikely, and strcache::val.

Referenced by cb_build_binary_picture(), cb_build_picture(), cb_define_list_add(), and cb_encode_program_id().

952 {
953  struct strcache *s;
954 
955 #ifdef COB_TREE_DEBUG
956  if (unlikely(!dupstr)) {
957  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_check_string");
959  }
960 #endif
961  for (s = base_string; s; s = s->next) {
962  if (!strcmp (dupstr, (const char *)s->val)) {
963  return s->val;
964  }
965  }
966  s = cobc_main_malloc (sizeof(struct strcache));
967  s->next = base_string;
968  s->val = cobc_main_strdup (dupstr);
969  base_string = s;
970  return s->val;
971 }
Definition: cobc.c:65
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static struct strcache * base_string
Definition: cobc.c:248
struct strcache * next
Definition: cobc.c:66
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720
void * val
Definition: cobc.c:67
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

size_t cobc_check_valid_name ( const char *  name,
const unsigned int  prechk 
)

Definition at line 1142 of file cobc.c.

References cob_csyns, COB_NUM_CSYNS, cobc_bcompare(), and cobc_error_name().

Referenced by cb_build_program_id(), process_filename(), and yyparse().

1143 {
1144  const char *p;
1145  size_t len;
1146 
1147  for (p = name, len = 0; *p; p++, len++) {
1148  if (*p == '/' || *p == '\\') {
1149  cobc_error_name (name, prechk, 5U);
1150  return 1;
1151  }
1152  }
1153  if (len < 1) {
1154  cobc_error_name (name, prechk, 1U);
1155  return 1;
1156  }
1157  if (!cb_relaxed_syntax_check && len > 31) {
1158  cobc_error_name (name, prechk, 1U);
1159  return 1;
1160  }
1161  if (*name == '_' || *name == ' ') {
1162  cobc_error_name (name, prechk, 2U);
1163  return 1;
1164  }
1165  if (prechk && len > 3 &&
1166  (!memcmp (name, "cob_", (size_t)4) ||
1167  !memcmp (name, "COB_", (size_t)4))) {
1168  cobc_error_name (name, prechk, 3U);
1169  return 1;
1170  }
1171  if (bsearch (name, cob_csyns, COB_NUM_CSYNS,
1172  sizeof (char *), cobc_bcompare)) {
1173  cobc_error_name (name, prechk, 4U);
1174  return 1;
1175  }
1176  return 0;
1177 }
#define COB_NUM_CSYNS
Definition: cobc.c:388
static void cobc_error_name(const char *name, const unsigned int source, const unsigned int reason)
Definition: cobc.c:1095
static int cobc_bcompare(const void *p1, const void *p2)
Definition: cobc.c:1086
static const char *const cob_csyns[]
Definition: cobc.c:292

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_chk_buff_size ( const size_t  bufflen)
static

Definition at line 1182 of file cobc.c.

References cobc_buffer, cobc_buffer_size, and cobc_main_realloc().

Referenced by process_assemble(), process_compile(), process_library(), process_link(), process_module(), and process_module_direct().

1183 {
1184  if (bufflen >= cobc_buffer_size) {
1185  cobc_buffer_size = bufflen + 32;
1187  }
1188 }
void * cobc_main_realloc(void *prevptr, const size_t size)
Definition: cobc.c:738
static char * cobc_buffer
Definition: cobc.c:254
static size_t cobc_buffer_size
Definition: cobc.c:261

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_clean_up ( const int  status)
static

Definition at line 1380 of file cobc.c.

References cb_compile_level, CB_LEVEL_ASSEMBLE, CB_LEVEL_PREPROCESS, CB_LEVEL_TRANSLATE, cb_listing_file, cb_storage_file, cob_u32_t, cobc_buffer, cobc_buffer_size, cobc_check_action(), cobc_free_mem(), F_OK, local_filename::local_fp, local_filename::local_name, filename::localfile, filename::need_assemble, filename::need_preprocess, filename::need_translate, local_filename::next, filename::next, NULL, filename::object, ppin, ppout, filename::preprocess, save_all_src, save_c_src, save_temps, filename::translate, filename::trstorage, unlikely, yyin, and yyout.

Referenced by cobc_abort_terminate(), cobc_terminate(), and main().

1381 {
1382  struct filename *fn;
1383  struct local_filename *lf;
1384  cob_u32_t i;
1385 
1386  if (cb_listing_file) {
1387  fclose (cb_listing_file);
1389  }
1390  if (cb_storage_file) {
1391  fclose (cb_storage_file);
1393  }
1394  if (ppin) {
1395  fclose (ppin);
1396  ppin = NULL;
1397  }
1398 
1399  if (ppout) {
1400  fclose (ppout);
1401  ppout = NULL;
1402  }
1403  if (yyin) {
1404  fclose (yyin);
1405  yyin = NULL;
1406  }
1407 
1408  if (yyout) {
1409  fclose (yyout);
1410  yyout = NULL;
1411  }
1412 
1413  for (fn = file_list; fn; fn = fn->next) {
1414  for (lf = fn->localfile; lf; lf = lf->next) {
1415  if (unlikely(lf->local_fp)) {
1416  fclose (lf->local_fp);
1417  lf->local_fp = NULL;
1418  }
1419  }
1420  if (fn->need_assemble &&
1421  (status || cb_compile_level > CB_LEVEL_ASSEMBLE ||
1423  cobc_check_action (fn->object);
1424  }
1425  if (save_all_src) {
1426  continue;
1427  }
1428  if (fn->need_preprocess &&
1429  (status || cb_compile_level > CB_LEVEL_PREPROCESS ||
1432  }
1433  if (save_c_src) {
1434  continue;
1435  }
1436  if (fn->need_translate &&
1437  (status || cb_compile_level > CB_LEVEL_TRANSLATE ||
1441  if (fn->localfile) {
1442  for (lf = fn->localfile; lf; lf = lf->next) {
1444  }
1445  } else if (fn->translate) {
1446  /* If we get syntax errors, we do not
1447  know the number of local include files */
1448  snprintf (cobc_buffer, cobc_buffer_size,
1449  "%s.l.h", fn->translate);
1451  for (i = 0; i < 30U; ++i) {
1452  if (i) {
1453  snprintf (cobc_buffer, cobc_buffer_size,
1454  "%s.l%u.h", fn->translate, i);
1456  }
1457  if (!access (cobc_buffer, F_OK)) {
1458  unlink (cobc_buffer);
1459  } else if (i) {
1460  break;
1461  }
1462  }
1463  }
1464  }
1465  }
1466  cobc_free_mem ();
1467  file_list = NULL;
1468 }
static size_t save_all_src
Definition: cobc.c:274
#define cob_u32_t
Definition: common.h:31
FILE * cb_storage_file
Definition: cobc.c:156
static void cobc_free_mem(void)
Definition: cobc.c:465
unsigned int need_assemble
Definition: cobc.h:209
#define CB_LEVEL_ASSEMBLE
Definition: cobc.c:74
const char * preprocess
Definition: cobc.h:198
FILE * cb_listing_file
Definition: cobc.c:157
unsigned int need_translate
Definition: cobc.h:208
static char * cobc_buffer
Definition: cobc.c:254
#define CB_LEVEL_TRANSLATE
Definition: cobc.c:72
#define yyout
Definition: pplex.c:20
const char * trstorage
Definition: cobc.h:200
struct local_filename * localfile
Definition: cobc.h:204
FILE * ppin
Definition: pplex.c:367
#define unlikely(x)
Definition: common.h:437
#define F_OK
Definition: cobc.h:46
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
FILE * ppout
Definition: pplex.c:367
static void cobc_check_action(const char *name)
Definition: cobc.c:1355
static size_t save_c_src
Definition: cobc.c:275
struct filename * next
Definition: cobc.h:196
#define CB_LEVEL_PREPROCESS
Definition: cobc.c:71
#define yyin
Definition: pplex.c:16
static size_t save_temps
Definition: cobc.c:273
unsigned int need_preprocess
Definition: cobc.h:207
Definition: cobc.h:195
struct local_filename * next
Definition: cobc.h:189
const char * translate
Definition: cobc.h:199
const char * object
Definition: cobc.h:201
FILE * local_fp
Definition: cobc.h:191
static size_t cobc_buffer_size
Definition: cobc.c:261
char * local_name
Definition: cobc.h:190
static unsigned int cb_compile_level
Definition: cobc.c:265

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_cmd_print ( const char *  cmd)
static

Definition at line 1558 of file cobc.c.

References _, cobc_free(), cobc_strdup(), and NULL.

Referenced by preprocess(), process(), and process_run().

1559 {
1560  char *p;
1561  char *token;
1562  size_t n;
1563  size_t toklen;
1564 
1565  fputs (_("Executing:"), stderr);
1566  /* Check if it fits in 80 characters */
1567  if (strlen (cmd) < 64) {
1568  fprintf (stderr, "\t%s\n", (char *)cmd);
1569  fflush (stderr);
1570  return;
1571  }
1572  putc ('\t', stderr);
1573  p = cobc_strdup (cmd);
1574  n = 0;
1575  token = strtok (p, " ");
1576  for (; token; token = strtok (NULL, " ")) {
1577  toklen = strlen (token) + 1;
1578  if ((n + toklen) > 63) {
1579  fprintf(stderr, "\n\t\t");
1580  n = 0;
1581  }
1582  fprintf (stderr, "%s%s", (n ? " " : ""), token);
1583  n += toklen;
1584  }
1585  cobc_free (p);
1586  putc ('\n', stderr);
1587  fflush (stderr);
1588 }
void cobc_free(void *mptr)
Definition: cobc.c:657
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_deciph_funcs ( const char *  opt)
static

Definition at line 1888 of file cobc.c.

References _, cb_flag_functions_all, CB_TEXT_LIST_ADD, cobc_err_exit(), cobc_free(), cobc_strdup(), lookup_intrinsic(), and NULL.

Referenced by process_command_line().

1889 {
1890  char *p;
1891  char *q;
1892 
1893  if (!strcasecmp (opt, "ALL")) {
1895  return;
1896  }
1897 
1898  p = cobc_strdup (opt);
1899  q = strtok (p, ",");
1900  while (q) {
1901  if (!lookup_intrinsic (q, 0, 1)) {
1902  cobc_err_exit (_("'%s' is not an intrinsic function"), q);
1903  }
1905  q = strtok (NULL, ",");
1906  }
1907  cobc_free (p);
1908 }
struct cb_text_list * cb_intrinsic_list
Definition: cobc.c:150
void cobc_free(void *mptr)
Definition: cobc.c:657
struct cb_intrinsic_table * lookup_intrinsic(const char *name, const int checkres, const int checkimpl)
Definition: reserved.c:2976
#define CB_TEXT_LIST_ADD(y, z)
Definition: cobc.c:110
static DECLNORET void COB_A_NORETURN cobc_err_exit(const char *fmt,...)
Definition: cobc.c:1229
int cb_flag_functions_all
Definition: cobc.c:170
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669

Here is the call graph for this function:

Here is the caller graph for this function:

static int cobc_deciph_optarg ( const char *  p,
const int  allow_quote 
)
static

Definition at line 1191 of file cobc.c.

Referenced by process_command_line().

1192 {
1193  const unsigned char *s;
1194  size_t len;
1195  size_t i;
1196  int n;
1197 
1198  len = strlen (p);
1199  if (!len) {
1200  return -1;
1201  }
1202  s = (const unsigned char *)p;
1203  if (allow_quote) {
1204  if (*s == '"' || *s == '\'') {
1205  if (len != 3 || *(s + 2) != *s) {
1206  return -1;
1207  }
1208  return (int)(*(s + 1));
1209  }
1210  if (*s < '0' || *s > '9') {
1211  if (len != 1) {
1212  return -1;
1213  }
1214  return (int)*s;
1215  }
1216  }
1217  n = 0;
1218  for (i = 0; i < len; ++i) {
1219  if (s[i] < '0' || s[i] > '9') {
1220  return -1;
1221  }
1222  n *= 10;
1223  n += (s[i] & 0x0F);
1224  }
1225  return n;
1226 }

Here is the caller graph for this function:

void cobc_dumb_abort ( const char *  filename,
const int  linenum 
)

Definition at line 613 of file cobc.c.

References cobc_abort().

614 {
615  cobc_abort (filename, linenum);
616 }
void cobc_abort(const char *filename, const int linenum)
Definition: cobc.c:606
Definition: cobc.h:195

Here is the call graph for this function:

static const char* cobc_enum_explain ( const enum cb_tag  tag)
static

Definition at line 503 of file cobc.c.

References CB_TAG_ALPHABET_NAME, CB_TAG_ALTER, CB_TAG_ASSIGN, CB_TAG_BINARY_OP, CB_TAG_CALL, CB_TAG_CANCEL, CB_TAG_CAST, CB_TAG_CLASS_NAME, CB_TAG_CONST, CB_TAG_CONTINUE, CB_TAG_DEBUG, CB_TAG_DEBUG_CALL, CB_TAG_DECIMAL, CB_TAG_DIRECT, CB_TAG_FIELD, CB_TAG_FILE, CB_TAG_FUNCALL, CB_TAG_GOTO, CB_TAG_IF, CB_TAG_INITIALIZE, CB_TAG_INTEGER, CB_TAG_INTRINSIC, CB_TAG_LABEL, CB_TAG_LIST, CB_TAG_LITERAL, CB_TAG_LOCALE_NAME, CB_TAG_PERFORM, CB_TAG_PERFORM_VARYING, CB_TAG_PICTURE, CB_TAG_REFERENCE, CB_TAG_REPORT, CB_TAG_SEARCH, CB_TAG_SET_ATTR, CB_TAG_STATEMENT, CB_TAG_STRING, and CB_TAG_SYSTEM_NAME.

Referenced by cobc_tree_cast_error().

504 {
505  switch (tag) {
506  case CB_TAG_CONST:
507  return "CONSTANT";
508  case CB_TAG_INTEGER:
509  return "INTEGER";
510  case CB_TAG_STRING:
511  return "STRING";
513  return "ALPHABET";
514  case CB_TAG_CLASS_NAME:
515  return "CLASS";
516  case CB_TAG_LOCALE_NAME:
517  return "LOCALE";
518  case CB_TAG_SYSTEM_NAME:
519  return "SYSTEM";
520  case CB_TAG_LITERAL:
521  return "LITERAL";
522  case CB_TAG_DECIMAL:
523  return "DECIMAL";
524  case CB_TAG_FIELD:
525  return "FIELD";
526  case CB_TAG_FILE:
527  return "FILE";
528  case CB_TAG_REPORT:
529  return "REPORT";
530  case CB_TAG_REFERENCE:
531  return "REFERENCE";
532  case CB_TAG_BINARY_OP:
533  return "BINARY OP";
534  case CB_TAG_FUNCALL:
535  return "FUNCTION CALL";
536  case CB_TAG_CAST:
537  return "CAST";
538  case CB_TAG_INTRINSIC:
539  return "INTRINSIC";
540  case CB_TAG_LABEL:
541  return "LABEL";
542  case CB_TAG_ASSIGN:
543  return "ASSIGN";
544  case CB_TAG_INITIALIZE:
545  return "INITIALIZE";
546  case CB_TAG_SEARCH:
547  return "SEARCH";
548  case CB_TAG_CALL:
549  return "CALL";
550  case CB_TAG_GOTO:
551  return "GO TO";
552  case CB_TAG_IF:
553  return "IF";
554  case CB_TAG_PERFORM:
555  return "PERFORM";
556  case CB_TAG_STATEMENT:
557  return "STATEMENT";
558  case CB_TAG_CONTINUE:
559  return "CONTINUE";
560  case CB_TAG_CANCEL:
561  return "CANCEL";
562  case CB_TAG_ALTER:
563  return "ALTER";
564  case CB_TAG_SET_ATTR:
565  return "SET ATTRIBUTE";
567  return "PERFORM";
568  case CB_TAG_PICTURE:
569  return "PICTURE";
570  case CB_TAG_LIST:
571  return "LIST";
572  case CB_TAG_DIRECT:
573  return "DIRECT";
574  case CB_TAG_DEBUG:
575  return "DEBUG";
576  case CB_TAG_DEBUG_CALL:
577  return "DEBUG CALL";
578  default:
579  break;
580  }
581  return "UNKNOWN";
582 }
Definition: tree.h:88

Here is the caller graph for this function:

static DECLNORET void COB_A_NORETURN cobc_err_exit ( const char *  fmt,
  ... 
)
static

Definition at line 1229 of file cobc.c.

References _, and cobc_free_mem().

Referenced by cobc_add_str(), cobc_deciph_funcs(), cobc_options_error_build(), cobc_options_error_nonfinal(), main(), and process_command_line().

1230 {
1231  va_list ap;
1232 
1233  fputs ("cobc: ", stderr);
1234  fputs (_("Error: "), stderr);
1235  va_start (ap, fmt);
1236  vfprintf (stderr, fmt, ap);
1237  va_end (ap);
1238  putc ('\n', stderr);
1239  fflush (stderr);
1240  cobc_free_mem ();
1241  exit (1);
1242 }
static void cobc_free_mem(void)
Definition: cobc.c:465
#define _(s)
Definition: cobcrun.c:59

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_error_name ( const char *  name,
const unsigned int  source,
const unsigned int  reason 
)
static

Definition at line 1095 of file cobc.c.

References _, cb_error(), and cobc_abort_pr().

Referenced by cobc_check_valid_name().

1097 {
1098  const char *s;
1099 
1100  s = "";
1101  switch (reason) {
1102  case 1:
1103  s = _(" - Length is < 1 or > 31");
1104  break;
1105  case 2:
1106  s = _(" - Name cannot begin with space or underscore");
1107  break;
1108  case 3:
1109  s = _(" - Name cannot begin with 'cob_' or 'COB_'");
1110  break;
1111  case 4:
1112  s = _(" - Name duplicates a 'C' keyword");
1113  break;
1114  case 5:
1115  s = _(" - Name cannot contain a directory separator");
1116  break;
1117  default:
1118  break;
1119  }
1120  switch (source) {
1121  case 0:
1122  /* basename */
1123  cobc_abort_pr (_("Invalid file base name '%s'%s"),
1124  name, s);
1125  break;
1126  case 1:
1127  /* ENTRY */
1128  cb_error (_("Invalid ENTRY '%s'%s"), name, s);
1129  break;
1130  case 2:
1131  /* PROGRAM-ID */
1132  cb_error (_("Invalid PROGRAM-ID '%s'%s"), name, s);
1133  break;
1134  default:
1135  cobc_abort_pr (_("Unknown name error '%s'%s"),
1136  name, s);
1137  break;
1138  }
1139 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
void cb_error(const char *,...) COB_A_FORMAT12
Definition: error.c:98

Here is the call graph for this function:

Here is the caller graph for this function:

void cobc_free ( void *  mptr)

Definition at line 657 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), and unlikely.

Referenced by cb_define_list_add(), cb_reset_78(), cb_reset_global_78(), clear_initial_values(), cobc_cmd_print(), cobc_deciph_funcs(), cobc_free_mem(), cobc_main_free(), cobc_main_realloc(), cobc_parse_free(), cobc_parse_realloc(), cobc_var_print(), main(), plex_clear_all(), ppecho(), pplex(), preprocess(), process(), process_env_copy_path(), scan_define_options(), ylex_clear_all(), and yylex().

658 {
659 #ifdef COB_TREE_DEBUG
660  if (unlikely(!mptr)) {
661  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_free");
663  }
664 #endif
665  free(mptr);
666 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_free_mem ( void  )
static

Definition at line 465 of file cobc.c.

References cobc_free(), cobc_list_dir, cobc_list_file, cobc_mem_struct::next, NULL, and save_temps_dir.

Referenced by cobc_clean_up(), cobc_err_exit(), preprocess(), and process_command_line().

466 {
467  struct cobc_mem_struct *reps;
468  struct cobc_mem_struct *repsl;
469 
470  if (save_temps_dir) {
473  }
474  if (cobc_list_dir) {
477  }
478  if (cobc_list_file) {
481  }
482  for (reps = cobc_plexmem_base; reps; ) {
483  repsl = reps;
484  reps = reps->next;
485  cobc_free (repsl);
486  }
488  for (reps = cobc_parsemem_base; reps; ) {
489  repsl = reps;
490  reps = reps->next;
491  cobc_free (repsl);
492  }
494  for (reps = cobc_mainmem_base; reps; ) {
495  repsl = reps;
496  reps = reps->next;
497  cobc_free (repsl);
498  }
500 }
static char * save_temps_dir
Definition: cobc.c:247
static struct cobc_mem_struct * cobc_plexmem_base
Definition: cobc.c:222
void cobc_free(void *mptr)
Definition: cobc.c:657
static char * cobc_list_file
Definition: cobc.c:251
static struct cobc_mem_struct * cobc_mainmem_base
Definition: cobc.c:220
static char * cobc_list_dir
Definition: cobc.c:250
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static struct cobc_mem_struct * cobc_parsemem_base
Definition: cobc.c:221
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

static char* cobc_getenv ( const char *  env)
static

Definition at line 1306 of file cobc.c.

References cobc_main_strdup(), and NULL.

Referenced by main().

1307 {
1308  char *p;
1309 
1310  p = getenv (env);
1311  if (!p || *p == 0 || *p == ' ') {
1312  return NULL;
1313  }
1314  return cobc_main_strdup (p);
1315 }
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720

Here is the call graph for this function:

Here is the caller graph for this function:

void cobc_main_free ( void *  prevptr)

Definition at line 778 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_free(), cobc_mem_struct::memptr, cobc_mem_struct::next, NULL, and unlikely.

Referenced by delete_reserved_word_from_list().

779 {
780  struct cobc_mem_struct *curr;
781  struct cobc_mem_struct *prev;
782 
783  prev = NULL;
784  for (curr = cobc_mainmem_base; curr; curr = curr->next) {
785  if (curr->memptr == prevptr) {
786  break;
787  }
788  prev = curr;
789  }
790  if (unlikely(!curr)) {
791 #ifdef COB_TREE_DEBUG
792  cobc_abort_pr (_("Call to %s with invalid pointer, as it is missing in list"), "cobc_main_free");
794 #else
795  return;
796 #endif
797  }
798  if (prev) {
799  prev->next = curr->next;
800  } else {
801  /* At mainmem_base */
802  cobc_mainmem_base = curr->next;
803  }
804  cobc_free (curr);
805 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * memptr
Definition: cobc.h:232
void cobc_free(void *mptr)
Definition: cobc.c:657
static struct cobc_mem_struct * cobc_mainmem_base
Definition: cobc.c:220
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_main_malloc ( const size_t  size)

Definition at line 702 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_mainmem_base, cobc_mem_struct::memlen, cobc_mem_struct::memptr, cobc_mem_struct::next, and unlikely.

Referenced by add_reserved_word_without_init(), allocate_str_removing_asterisk(), ambiguous_error(), cb_build_class_name(), cb_build_picture(), cb_define_list_add(), cb_expr_init(), cb_int(), cb_text_list_add(), cobc_check_string(), cobc_main_strdup(), cobc_set_value(), cobc_stradd_dup(), codegen(), finalize_file(), get_reserved_words_from_user_list(), main(), output_initialize_one(), process_assemble(), process_command_line(), process_filename(), process_module_direct(), process_translate(), and undefined_error().

703 {
704  struct cobc_mem_struct *m;
705 
706  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
707  if (unlikely(!m)) {
708  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
709  (int)size);
711  }
712  m->next = cobc_mainmem_base;
713  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
714  m->memlen = size;
715  cobc_mainmem_base = m;
716  return m->memptr;
717 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * memptr
Definition: cobc.h:232
static struct cobc_mem_struct * cobc_mainmem_base
Definition: cobc.c:220
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
size_t memlen
Definition: cobc.h:233
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_main_realloc ( void *  prevptr,
const size_t  size 
)

Definition at line 738 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_free(), cobc_mem_struct::memlen, cobc_mem_struct::memptr, cobc_mem_struct::next, NULL, and unlikely.

Referenced by cb_expr_shift(), cobc_add_str(), cobc_chk_buff_size(), file_basename(), and output_initialize_one().

739 {
740  struct cobc_mem_struct *m;
741  struct cobc_mem_struct *curr;
742  struct cobc_mem_struct *prev;
743 
744  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
745  if (unlikely(!m)) {
746  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
747  (int)size);
749  }
750  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
751  m->memlen = size;
752 
753  prev = NULL;
754  for (curr = cobc_mainmem_base; curr; curr = curr->next) {
755  if (curr->memptr == prevptr) {
756  break;
757  }
758  prev = curr;
759  }
760  if (unlikely(!curr)) {
761  cobc_abort_pr (_("Attempt to reallocate non-allocated memory - Aborting"));
763  }
764  m->next = curr->next;
765  if (prev) {
766  prev->next = m;
767  } else {
768  /* At mainmem_base */
769  cobc_mainmem_base = m;
770  }
771  memcpy (m->memptr, curr->memptr, curr->memlen);
772  cobc_free (curr);
773 
774  return m->memptr;
775 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * memptr
Definition: cobc.h:232
void cobc_free(void *mptr)
Definition: cobc.c:657
static struct cobc_mem_struct * cobc_mainmem_base
Definition: cobc.c:220
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
size_t memlen
Definition: cobc.h:233
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_main_strdup ( const char *  dupstr)

Definition at line 720 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_main_malloc(), and unlikely.

Referenced by cb_text_list_add(), cobc_check_string(), cobc_getenv(), cobc_set_value(), main(), process_command_line(), process_filename(), process_link(), and read_string().

721 {
722  void *p;
723  size_t n;
724 
725 #ifdef COB_TREE_DEBUG
726  if (unlikely(!dupstr)) {
727  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_main_strdup");
729  }
730 #endif
731  n = strlen (dupstr);
732  p = cobc_main_malloc (n + 1);
733  memcpy (p, dupstr, n);
734  return p;
735 }
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_malloc ( const size_t  size)

Definition at line 643 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), and unlikely.

Referenced by cb_add_78(), cb_add_const_var(), cobc_strdup(), ppopen(), and process().

644 {
645  void *mptr;
646 
647  mptr = calloc ((size_t)1, size);
648  if (unlikely(!mptr)) {
649  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
650  (int)size);
652  }
653  return mptr;
654 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_options_error_build ( void  )
static

Definition at line 1882 of file cobc.c.

References _, and cobc_err_exit().

Referenced by process_command_line().

1883 {
1884  cobc_err_exit (_("Only one of options 'm', 'x', 'b' may be specified"));
1885 }
static DECLNORET void COB_A_NORETURN cobc_err_exit(const char *fmt,...)
Definition: cobc.c:1229
#define _(s)
Definition: cobcrun.c:59

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_options_error_nonfinal ( void  )
static

Definition at line 1876 of file cobc.c.

References _, and cobc_err_exit().

Referenced by process_command_line().

1877 {
1878  cobc_err_exit (_("Only one of options 'E', 'S', 'C', 'c' may be specified"));
1879 }
static DECLNORET void COB_A_NORETURN cobc_err_exit(const char *fmt,...)
Definition: cobc.c:1229
#define _(s)
Definition: cobcrun.c:59

Here is the call graph for this function:

Here is the caller graph for this function:

void cobc_parse_free ( void *  prevptr)

Definition at line 885 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_free(), cobc_mem_struct::memptr, cobc_mem_struct::next, NULL, and unlikely.

Referenced by cb_build_move_literal(), remove_program_name(), terminator_clear(), terminator_error(), terminator_warning(), and yyparse().

886 {
887  struct cobc_mem_struct *curr;
888  struct cobc_mem_struct *prev;
889 
890  prev = NULL;
891  for (curr = cobc_parsemem_base; curr; curr = curr->next) {
892  if (curr->memptr == prevptr) {
893  break;
894  }
895  prev = curr;
896  }
897  if (unlikely(!curr)) {
898 #ifdef COB_TREE_DEBUG
899  cobc_abort_pr (_("Call to %s with invalid pointer, as it is missing in list"), "cobc_parse_free");
901 #else
902  return;
903 #endif
904  }
905  if (prev) {
906  prev->next = curr->next;
907  } else {
908  /* At parsemem_base */
909  cobc_parsemem_base = curr->next;
910  }
911  cobc_free (curr);
912 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * memptr
Definition: cobc.h:232
void cobc_free(void *mptr)
Definition: cobc.c:657
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
static struct cobc_mem_struct * cobc_parsemem_base
Definition: cobc.c:221
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_parse_malloc ( const size_t  size)

Definition at line 809 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_parsemem_base, cobc_mem_struct::memlen, cobc_mem_struct::memptr, cobc_mem_struct::next, and unlikely.

Referenced by add_contained_prog(), attach_attrib_to_cur_stmt(), build_literal(), cb_build_label(), cb_build_move(), cb_build_move_literal(), cb_build_picture(), cb_build_program(), cb_name(), cb_validate_program_body(), cobc_parse_strdup(), concat_literals(), lookup_attr(), lookup_call(), lookup_func_call(), lookup_literal(), lookup_string(), lookup_word(), make_tree(), output_base(), output_internal_function(), output_param(), output_perform_call(), set_up_use_file(), validate_field_1(), and yyparse().

810 {
811  struct cobc_mem_struct *m;
812 
813  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
814  if (unlikely(!m)) {
815  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
816  (int)size);
818  }
820  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
821  m->memlen = size;
822  cobc_parsemem_base = m;
823  return m->memptr;
824 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * memptr
Definition: cobc.h:232
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
size_t memlen
Definition: cobc.h:233
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
static struct cobc_mem_struct * cobc_parsemem_base
Definition: cobc.c:221
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_parse_realloc ( void *  prevptr,
const size_t  size 
)

Definition at line 845 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_free(), cobc_mem_struct::memlen, cobc_mem_struct::memptr, cobc_mem_struct::next, NULL, and unlikely.

846 {
847  struct cobc_mem_struct *m;
848  struct cobc_mem_struct *curr;
849  struct cobc_mem_struct *prev;
850 
851  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
852  if (unlikely(!m)) {
853  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
854  (int)size);
856  }
857  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
858  m->memlen = size;
859 
860  prev = NULL;
861  for (curr = cobc_parsemem_base; curr; curr = curr->next) {
862  if (curr->memptr == prevptr) {
863  break;
864  }
865  prev = curr;
866  }
867  if (unlikely(!curr)) {
868  cobc_abort_pr (_("Attempt to reallocate non-allocated memory - Aborting"));
870  }
871  m->next = curr->next;
872  if (prev) {
873  prev->next = m;
874  } else {
875  /* At parsemem_base */
876  cobc_parsemem_base = m;
877  }
878  memcpy (m->memptr, curr->memptr, curr->memlen);
879  cobc_free (curr);
880 
881  return m->memptr;
882 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * memptr
Definition: cobc.h:232
void cobc_free(void *mptr)
Definition: cobc.c:657
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
size_t memlen
Definition: cobc.h:233
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
static struct cobc_mem_struct * cobc_parsemem_base
Definition: cobc.c:221
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

void* cobc_parse_strdup ( const char *  dupstr)

Definition at line 827 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_parse_malloc(), and unlikely.

Referenced by cb_build_class_name(), cb_build_debug(), cb_emit_evaluate(), cb_to_cname(), lookup_string(), lookup_word(), and yylex().

828 {
829  void *p;
830  size_t n;
831 
832 #ifdef COB_TREE_DEBUG
833  if (unlikely(!dupstr)) {
834  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_parse_strdup");
836  }
837 #endif
838  n = strlen (dupstr);
839  p = cobc_parse_malloc (n + 1);
840  memcpy (p, dupstr, n);
841  return p;
842 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
void * cobc_parse_malloc(const size_t size)
Definition: cobc.c:809
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_plex_malloc ( const size_t  size)

Definition at line 916 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_plexmem_base, cobc_mem_struct::memptr, cobc_mem_struct::next, and unlikely.

Referenced by cobc_plex_strdup(), pp_text_list_add(), ppp_define_add(), ppp_list_add(), ppp_replace_list_add(), and ppparse().

917 {
918  struct cobc_mem_struct *m;
919 
920  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
921  if (unlikely(!m)) {
922  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
923  (int)size);
925  }
926  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
927  m->next = cobc_plexmem_base;
928  cobc_plexmem_base = m;
929  return m->memptr;
930 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static struct cobc_mem_struct * cobc_plexmem_base
Definition: cobc.c:222
void * memptr
Definition: cobc.h:232
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_plex_strdup ( const char *  dupstr)

Definition at line 933 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_plex_malloc(), and unlikely.

Referenced by pplex(), ppp_define_add(), ppp_list_add(), ppp_set_value(), and switch_to_buffer().

934 {
935  void *p;
936  size_t n;
937 
938 #ifdef COB_TREE_DEBUG
939  if (unlikely(!dupstr)) {
940  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_plex_strdup");
942  }
943 #endif
944  n = strlen (dupstr);
945  p = cobc_plex_malloc (n + 1);
946  memcpy (p, dupstr, n);
947  return p;
948 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
void * cobc_plex_malloc(const size_t size)
Definition: cobc.c:916
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_print_flag ( const char *  name,
const char *  doc,
const int  pdok,
const int  exten 
)
static

Definition at line 1767 of file cobc.c.

1769 {
1770  const char *bptr;
1771  char buff[32];
1772 
1773  if (!pdok) {
1774  return;
1775  }
1776  if (!exten) {
1777  bptr = name;
1778  } else {
1779  snprintf (buff, sizeof(buff), "%s=<value>", name);
1780  bptr = buff;
1781  }
1782  printf (" -f%-19s %s\n", bptr, doc);
1783 }
static void cobc_print_info ( void  )
static

Definition at line 1630 of file cobc.c.

References _, cb_msg_style, CB_MSG_STYLE_MSC, COB_BLD_BUILD, COB_BLD_CC, COB_BLD_CFLAGS, COB_BLD_CPPFLAGS, COB_BLD_LD, COB_BLD_LDFLAGS, COB_CC, COB_CFLAGS, COB_CONFIG_DIR, COB_COPY_DIR, COB_EXEEXT, COB_LDFLAGS, COB_LIBS, COB_MODULE_EXT, cobc_print_version(), cobc_var_print(), NULL, WITH_CURSES, and WITH_VARSEQ.

Referenced by process_command_line().

1631 {
1632  char buff[16];
1633  char *s;
1634 
1635  cobc_print_version ();
1636  putchar ('\n');
1637  puts (_("build information"));
1638  cobc_var_print (_("build environment"), COB_BLD_BUILD, 0);
1639  cobc_var_print ("CC", COB_BLD_CC, 0);
1640  cobc_var_print ("CPPFLAGS", COB_BLD_CPPFLAGS, 0);
1641  cobc_var_print ("CFLAGS", COB_BLD_CFLAGS, 0);
1642  cobc_var_print ("LD", COB_BLD_LD, 0);
1643  cobc_var_print ("LDFLAGS", COB_BLD_LDFLAGS, 0);
1644  putchar ('\n');
1645  puts (_("GnuCOBOL information"));
1646  cobc_var_print ("COB_CC", COB_CC, 0);
1647  if ((s = getenv ("COB_CC")) != NULL) {
1648  cobc_var_print ("COB_CC", s, 1);
1649  }
1650  cobc_var_print ("COB_CFLAGS", COB_CFLAGS, 0);
1651  if ((s = getenv ("COB_CFLAGS")) != NULL) {
1652  cobc_var_print ("COB_CFLAGS", s, 1);
1653  }
1654  cobc_var_print ("COB_LDFLAGS", COB_LDFLAGS, 0);
1655  if ((s = getenv ("COB_LDFLAGS")) != NULL) {
1656  cobc_var_print ("COB_LDFLAGS", s, 1);
1657  }
1658  cobc_var_print ("COB_LIBS", COB_LIBS, 0);
1659  if ((s = getenv ("COB_LIBS")) != NULL) {
1660  cobc_var_print ("COB_LIBS", s, 1);
1661  }
1662  cobc_var_print ("COB_CONFIG_DIR", COB_CONFIG_DIR, 0);
1663  if ((s = getenv ("COB_CONFIG_DIR")) != NULL) {
1664  cobc_var_print ("COB_CONFIG_DIR", s, 1);
1665  }
1666  cobc_var_print ("COB_COPY_DIR", COB_COPY_DIR, 0);
1667  if ((s = getenv ("COB_COPY_DIR")) != NULL) {
1668  cobc_var_print ("COB_COPY_DIR", s, 1);
1669  }
1670  if ((s = getenv ("COBCPY")) != NULL) {
1671  cobc_var_print ("COBCPY", s, 1);
1672  }
1673  if (cb_msg_style == CB_MSG_STYLE_MSC) {
1674  cobc_var_print ("COB_MSG_FORMAT", "MSC", 0);
1675  } else {
1676  cobc_var_print ("COB_MSG_FORMAT", "GCC", 0);
1677  }
1678  if ((s = getenv ("COB_MSG_FORMAT")) != NULL) {
1679  cobc_var_print ("COB_MSG_FORMAT", s, 1);
1680  }
1681 #if 0 /* Simon: only relevant for libcob */
1682  if ((s = getenv ("COB_LIBRARY_PATH")) != NULL) {
1683  cobc_var_print ("COB_LIBRARY_PATH", s, 1);
1684  }
1685 #endif
1686  cobc_var_print ("COB_MODULE_EXT", COB_MODULE_EXT, 0);
1687  cobc_var_print ("COB_EXEEXT", COB_EXEEXT, 0);
1688 
1689 #if 0 /* Simon: only relevant for libcob */
1690 #if defined(USE_LIBDL) || defined(_WIN32)
1691  cobc_var_print (_("Dynamic loading"), _("System"), 0);
1692 #else
1693  cobc_var_print (_("Dynamic loading"), _("Libtool"), 0);
1694 #endif
1695 
1696 #ifdef COB_PARAM_CHECK
1697  cobc_var_print ("\"CBL_\" param check", _("Enabled"), 0);
1698 #else
1699  cobc_var_print ("\"CBL_\" param check", _("Disabled"), 0);
1700 #endif
1701 #endif
1702 
1703  if (sizeof (void *) > 4U) {
1704  cobc_var_print ("64bit-mode", _("yes"), 0);
1705  } else {
1706  cobc_var_print ("64bit-mode", _("no"), 0);
1707  }
1708 
1709 #ifdef COB_LI_IS_LL
1710  cobc_var_print ("BINARY-C-LONG", _("8 bytes"), 0);
1711 #else
1712  cobc_var_print ("BINARY-C-LONG", _("4 bytes"), 0);
1713 #endif
1714 
1715  cobc_var_print (_("Extended screen I/O"), WITH_CURSES, 0);
1716 
1717  snprintf (buff, sizeof(buff), "%d", WITH_VARSEQ);
1718  cobc_var_print (_("Variable format"), buff, 0);
1719  if ((s = getenv ("COB_VARSEQ_FORMAT")) != NULL) {
1720  cobc_var_print ("COB_VARSEQ_FORMAT", s, 1);
1721  }
1722 
1723 #ifdef WITH_SEQRA_EXTFH
1724  cobc_var_print (_("Sequential handler"), _("External"), 0);
1725 #else
1726  cobc_var_print (_("Sequential handler"), _("Internal"), 0);
1727 #endif
1728 
1729 #if defined (WITH_INDEX_EXTFH)
1730  cobc_var_print (_("ISAM handler"), _("External"), 0);
1731 #elif defined (WITH_DB)
1732  cobc_var_print (_("ISAM handler"), "BDB", 0);
1733 #elif defined (WITH_CISAM)
1734  cobc_var_print (_("ISAM handler"), "C-ISAM", 0);
1735 #elif defined (WITH_DISAM)
1736  cobc_var_print (_("ISAM handler"), "D-ISAM", 0);
1737 #elif defined (WITH_VBISAM)
1738  cobc_var_print (_("ISAM handler"), "VBISAM", 0);
1739 #else
1740  cobc_var_print (_("ISAM handler"), _("Not available"), 0);
1741 #endif
1742 
1743 #ifdef WITH_INDEX_EXTFH
1744 #endif
1745 #ifdef WITH_DB
1746 #endif
1747 #ifdef WITH_CISAM
1748 #endif
1749 #ifdef WITH_DISAM
1750 #endif
1751 #ifdef WITH_VBISAM
1752 #endif
1753 }
#define COB_LDFLAGS
Definition: defaults.h:4
#define WITH_VARSEQ
Definition: config.h:370
static void cobc_var_print(const char *msg, const char *val, const unsigned int env)
Definition: cobc.c:1591
#define COB_BLD_CPPFLAGS
Definition: defaults.h:12
#define COB_MODULE_EXT
Definition: defaults.h:9
#define COB_BLD_LDFLAGS
Definition: defaults.h:15
#define COB_BLD_CC
Definition: defaults.h:11
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define CB_MSG_STYLE_MSC
Definition: cobc.h:436
size_t cb_msg_style
Definition: error.c:43
#define WITH_CURSES
Definition: config.h:355
#define COB_LIBS
Definition: defaults.h:5
#define COB_BLD_LD
Definition: defaults.h:14
#define COB_CONFIG_DIR
Definition: defaults.h:6
#define COB_BLD_CFLAGS
Definition: defaults.h:13
#define COB_BLD_BUILD
Definition: defaults.h:16
#define COB_EXEEXT
Definition: config.h:8
#define COB_CFLAGS
Definition: defaults.h:3
static void cobc_print_version(void)
Definition: cobc.c:1541
#define COB_CC
Definition: defaults.h:2
#define COB_COPY_DIR
Definition: defaults.h:7

Here is the call graph for this function:

Here is the caller graph for this function:

static void cobc_print_usage ( char *  prog)
static

Definition at line 1786 of file cobc.c.

References _.

Referenced by process_command_line().

1787 {
1788  puts (_("GnuCOBOL compiler for most COBOL dialects with lots of extensions"));
1789  putchar ('\n');
1790  printf (_("usage: %s [options]... file..."), prog);
1791  putchar ('\n');
1792  putchar ('\n');
1793  puts (_("options:"));
1794  puts (_(" -h, -help display this help and exit"));
1795  puts (_(" -V, -version display compiler version and exit"));
1796  puts (_(" -i, -info display compiler information (build/environment)"));
1797  puts (_(" -v, -verbose display the commands invoked by the compiler"));
1798  puts (_(" -vv display compiler version and the commands\n" \
1799  " invoked by the compiler"));
1800  puts (_(" -x build an executable program"));
1801  puts (_(" -m build a dynamically loadable module (default)"));
1802  puts (_(" -j run job, after build"));
1803  puts (_(" -std=<dialect> warnings/features for a specific dialect\n"
1804  " <dialect> can be one of:\n"
1805  " cobol2014, cobol2002, cobol85, default,\n"
1806  " ibm, mvs, bs2000, mf, acu;\n"
1807  " see configuration files in directory config"));
1808  puts (_(" -F, -free use free source format"));
1809  puts (_(" -free use free source format"));
1810  puts (_(" -fixed use fixed source format (default)"));
1811  puts (_(" -O, -O2, -Os enable optimization"));
1812  puts (_(" -g enable C compiler debug / stack check / trace"));
1813  puts (_(" -d, -debug enable all run-time error checking"));
1814  puts (_(" -o <file> place the output into <file>"));
1815  puts (_(" -b combine all input files into a single\n"
1816  " dynamically loadable module"));
1817  puts (_(" -E preprocess only; do not compile or link"));
1818  puts (_(" -C translation only; convert COBOL to C"));
1819  puts (_(" -S compile only; output assembly file"));
1820  puts (_(" -c compile and assemble, but do not link"));
1821  puts (_(" -P(=<dir or file>) generate preprocessed program listing (.lst)"));
1822  puts (_(" -Xref generate cross reference through 'cobxref'\n"
1823  " (V. Coen's 'cobxref' must be in path)"));
1824  puts (_(" -I <directory> add <directory> to copy/include search path"));
1825  puts (_(" -L <directory> add <directory> to library search path"));
1826  puts (_(" -l <lib> link the library <lib>"));
1827  puts (_(" -A <options> add <options> to the C compile phase"));
1828  puts (_(" -Q <options> add <options> to the C link phase"));
1829  puts (_(" -D <define> define <define> for COBOL compilation"));
1830  puts (_(" -K <entry> generate CALL to <entry> as static"));
1831  puts (_(" -conf=<file> user defined dialect configuration - See -std="));
1832  puts (_(" -cb_conf=<tag:value> override configuration entry"));
1833  puts (_(" -list-reserved display reserved words"));
1834  puts (_(" -list-intrinsics display intrinsic functions"));
1835  puts (_(" -list-mnemonics display mnemonic names"));
1836  puts (_(" -list-system display system routines"));
1837  puts (_(" -save-temps(=<dir>) save intermediate files\n"
1838  " - default: current directory"));
1839  puts (_(" -ext <extension> add default file extension"));
1840 
1841  putchar ('\n');
1842 
1843  puts (_(" -W enable ALL warnings"));
1844  puts (_(" -Wall enable all warnings except as noted below"));
1845  puts (_(" -Wno-<feature> disable warning enabled by -W or -Wall"));
1846 #undef CB_WARNDEF
1847 #undef CB_NOWARNDEF
1848 #define CB_WARNDEF(var,name,doc) \
1849  cobc_print_warn (name, doc, 1);
1850 #define CB_NOWARNDEF(var,name,doc) \
1851  cobc_print_warn (name, doc, 0);
1852 #include "warning.def"
1853 #undef CB_WARNDEF
1854 #undef CB_NOWARNDEF
1855 
1856  putchar ('\n');
1857 
1858 #undef CB_FLAG
1859 #undef CB_FLAG_RQ
1860 #undef CB_FLAG_NQ
1861 #define CB_FLAG(var,pdok,name,doc) \
1862  cobc_print_flag (name, doc, pdok, 0);
1863 #define CB_FLAG_RQ(var,pdok,name,def,opt,doc) \
1864  cobc_print_flag (name, doc, pdok, 1);
1865 #define CB_FLAG_NQ(pdok,name,opt,doc) \
1866  cobc_print_flag (name, doc, pdok, 1);
1867 #include "flag.def"
1868 #undef CB_FLAG
1869 #undef CB_FLAG_RQ
1870 #undef CB_FLAG_NQ
1871 
1872  putchar ('\n');
1873 }
#define _(s)
Definition: cobcrun.c:59

Here is the caller graph for this function:

static void cobc_print_version ( void  )
static

Definition at line 1541 of file cobc.c.

References _, cb_oc_build_stamp, COB_TAR_DATE, OC_C_VERSION, OC_C_VERSION_PRF, PACKAGE_NAME, PACKAGE_VERSION, and PATCH_LEVEL.

Referenced by cobc_print_info(), and process_command_line().

1542 {
1543  printf ("cobc (%s) %s.%d\n",
1545  puts ("Copyright (C) 2001-2016 Free Software Foundation, Inc.");
1546  printf (_("Written by %s\n"), "Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch");
1547  puts (_("This is free software; see the source for copying conditions. There is NO\n"
1548  "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."));
1549  printf (_("Built %s"), cb_oc_build_stamp);
1550  putchar ('\n');
1551  printf (_("Packaged %s"), COB_TAR_DATE);
1552  putchar ('\n');
1553  printf (_("C version %s%s"), OC_C_VERSION_PRF, OC_C_VERSION);
1554  putchar ('\n');
1555 }
char * cb_oc_build_stamp
Definition: cobc.c:146
#define OC_C_VERSION
Definition: cobc.c:107
#define PACKAGE_NAME
Definition: config.h:300
#define _(s)
Definition: cobcrun.c:59
#define OC_C_VERSION_PRF
Definition: cobc.c:106
#define COB_TAR_DATE
Definition: tarstamp.h:1
#define PACKAGE_VERSION
Definition: config.h:312
#define PATCH_LEVEL
Definition: config.h:315

Here is the caller graph for this function:

static void cobc_print_warn ( const char *  name,
const char *  doc,
const int  wall 
)
static

Definition at line 1756 of file cobc.c.

References _.

1757 {
1758  printf (" -W%-19s %s", name, doc);
1759  if (!wall) {
1760  fputs ("\n\t\t\t", stdout);
1761  fputs (_("- NOT set with -Wall"), stdout);
1762  }
1763  putchar ('\n');
1764 }
#define _(s)
Definition: cobcrun.c:59
void* cobc_realloc ( void *  prevptr,
const size_t  size 
)

Definition at line 687 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), and unlikely.

Referenced by read_literal(), scan_x(), and scan_z().

688 {
689  void *mptr;
690 
691  mptr = realloc (prevptr, size);
692  if (unlikely(!mptr)) {
693  cobc_abort_pr (_("Cannot reallocate %d bytes of memory - Aborting"),
694  (int)size);
696  }
697  return mptr;
698 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned int cobc_set_value ( struct cb_define_struct p,
const char *  value 
)
static

Definition at line 1003 of file cobc.c.

References _, cobc_abort_pr(), cobc_main_malloc(), cobc_main_strdup(), cb_define_struct::dec_part, cb_define_struct::deftype, cb_define_struct::int_part, NULL, PLEX_DEF_LIT, PLEX_DEF_NONE, PLEX_DEF_NUM, cb_define_struct::sign, value, and cb_define_struct::value.

Referenced by cb_define_list_add().

1004 {
1005  const char *s;
1006  size_t size;
1007  unsigned int dot_seen;
1008  unsigned int sign_seen;
1009 
1010  if (!value) {
1011  p->deftype = PLEX_DEF_NONE;
1012  p->value = NULL;
1013  p->sign = 0;
1014  p->int_part = 0;
1015  p->dec_part = 0;
1016  return 0;
1017  }
1018 
1019  /* Quoted value */
1020  if (*value == '"' || *value == '\'') {
1021  size = strlen (value) - 1U;
1022  if (value[0] != value[size]) {
1023  p->value = NULL;
1024  p->deftype = PLEX_DEF_NONE;
1025  return 1;
1026  }
1027  p->value = cobc_main_strdup (value);
1028 
1029  p->deftype = PLEX_DEF_LIT;
1030  p->sign = 0;
1031  p->int_part = 0;
1032  p->dec_part = 0;
1033  return 0;
1034  }
1035 
1036  /* Non-quoted value - Check if possible numeric */
1037  dot_seen = 0;
1038  sign_seen = 0;
1039  size = 0;
1040  s = value;
1041  if (*s == '+' || *s == '-') {
1042  sign_seen = 1;
1043  size++;
1044  s++;
1045  }
1046  for (; *s; ++s) {
1047  if (*s == '.') {
1048  if (dot_seen) {
1049  break;
1050  }
1051  dot_seen = 1;
1052  size++;
1053  continue;
1054  }
1055  if (*s > '9' || *s < '0') {
1056  break;
1057  }
1058  size++;
1059  }
1060 
1061  if (*s || size <= (dot_seen + sign_seen)) {
1062  /* Not numeric */
1063 #if 0 /* RXWRXW - Lit warn */
1064  cobc_abort_pr (_("Warning - Assuming literal for unquoted '%s'"),
1065  value);
1066 #endif
1067  size = strlen (value);
1068  p->value = cobc_main_malloc (size + 4U);
1069  sprintf (p->value, "'%s'", value);
1070  p->deftype = PLEX_DEF_LIT;
1071  p->sign = 0;
1072  p->int_part = 0;
1073  p->dec_part = 0;
1074  return 0;
1075  }
1076 
1077  p->value = cobc_main_strdup (value);
1078  p->deftype = PLEX_DEF_NUM;
1079  p->sign = 0;
1080  p->int_part = 0;
1081  p->dec_part = 0;
1082  return 0;
1083 }
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
int int_part
Definition: cobc.h:183
#define PLEX_DEF_NONE
Definition: cobc.h:97
int dec_part
Definition: cobc.h:184
strict implicit external value
Definition: warning.def:54
#define _(s)
Definition: cobcrun.c:59
unsigned int deftype
Definition: cobc.h:181
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define PLEX_DEF_NUM
Definition: cobc.h:99
#define PLEX_DEF_LIT
Definition: cobc.h:98
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720
char * value
Definition: cobc.h:180

Here is the call graph for this function:

Here is the caller graph for this function:

static char* cobc_stradd_dup ( const char *  str1,
const char *  str2 
)
static

Definition at line 1286 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_main_malloc(), and unlikely.

Referenced by process_filename(), process_library(), process_link(), process_module(), and process_module_direct().

1287 {
1288  char *p;
1289  size_t m, n;
1290 
1291 #ifdef COB_TREE_DEBUG
1292  if (unlikely(!str1 || !str2)) {
1293  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_stradd_dup");
1295  }
1296 #endif
1297  m = strlen (str1);
1298  n = strlen (str2);
1299  p = cobc_main_malloc (m + n + 1);
1300  memcpy (p, str1, m);
1301  memcpy (p + m, str2, n);
1302  return p;
1303 }
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

void* cobc_strdup ( const char *  dupstr)

Definition at line 669 of file cobc.c.

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_malloc(), and unlikely.

Referenced by cb_build_program_id(), cb_define_list_add(), cobc_cmd_print(), cobc_deciph_funcs(), cobc_var_print(), ppecho(), ppopen(), process_command_line(), process_env_copy_path(), scan_define_options(), and yylex().

670 {
671  void *p;
672  size_t n;
673 
674 #ifdef COB_TREE_DEBUG
675  if (unlikely(!dupstr)) {
676  cobc_abort_pr (_("Call to %s with NULL pointer"), "cobc_strdup");
678  }
679 #endif
680  n = strlen (dupstr);
681  p = cobc_malloc (n + 1);
682  memcpy (p, dupstr, n);
683  return p;
684 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
void * cobc_malloc(const size_t size)
Definition: cobc.c:643
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

static DECLNORET void COB_A_NORETURN cobc_terminate ( const char *  str)
static

Definition at line 1471 of file cobc.c.

References cobc_clean_up().

Referenced by main(), preprocess(), process_filename(), and process_translate().

1472 {
1473  int save_errno;
1474 
1475  save_errno = errno;
1476  fprintf (stderr, "cobc: ");
1477  fflush (stderr);
1478  errno = save_errno;
1479  perror (str);
1480  fflush (stderr);
1481  cobc_clean_up (1);
1482  exit (1);
1483 }
static void cobc_clean_up(const int status)
Definition: cobc.c:1380

Here is the call graph for this function:

Here is the caller graph for this function:

void cobc_too_many_errors ( void  )

Definition at line 599 of file cobc.c.

References _, cobc_abort_pr(), and cobc_abort_terminate().

Referenced by cb_error(), cb_error_x(), and cb_plex_error().

600 {
601  cobc_abort_pr (_("Too many errors - Aborting compilation"));
603 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
#define _(s)
Definition: cobcrun.c:59
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486

Here is the call graph for this function:

Here is the caller graph for this function:

void cobc_tree_cast_error ( const cb_tree  x,
const char *  filename,
const int  linenum,
const enum cb_tag  tagnum 
)

Definition at line 619 of file cobc.c.

References _, cb_name(), CB_TREE_TAG, cobc_abort_pr(), cobc_abort_terminate(), and cobc_enum_explain().

621 {
622  cobc_abort_pr (_("%s:%d Invalid cast from '%s' type %s to type %s"),
623  filename, linenum,
624  x ? cb_name (x) : "NULL",
625  x ? cobc_enum_explain (CB_TREE_TAG(x)) : "None",
626  cobc_enum_explain (tagnum));
628 }
static const char * cobc_enum_explain(const enum cb_tag tag)
Definition: cobc.c:503
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
char * cb_name(cb_tree x)
Definition: tree.c:735
#define _(s)
Definition: cobcrun.c:59
#define CB_TREE_TAG(x)
Definition: tree.h:441
static DECLNORET void COB_A_NORETURN cobc_abort_terminate(void)
Definition: cobc.c:1486
Definition: cobc.h:195

Here is the call graph for this function:

static void cobc_var_print ( const char *  msg,
const char *  val,
const unsigned int  env 
)
static

Definition at line 1591 of file cobc.c.

References _, CB_IMSG_SIZE, CB_IVAL_SIZE, cobc_free(), cobc_strdup(), and NULL.

Referenced by cobc_print_info().

1592 {
1593  char *p;
1594  char *token;
1595  size_t n;
1596  int lablen;
1597  size_t toklen;
1598 
1599  if (!env) {
1600  printf ("%-*.*s : ", CB_IMSG_SIZE, CB_IMSG_SIZE, msg);
1601  } else {
1602  printf (" %s: ", _("env"));
1603  lablen = CB_IMSG_SIZE - 2 - (int)strlen(_("env")) - 2;
1604  printf ("%-*.*s : ", lablen, lablen, msg);
1605  }
1606  if (strlen(val) <= CB_IVAL_SIZE) {
1607  printf("%s\n", val);
1608  return;
1609  }
1610  p = cobc_strdup (val);
1611  n = 0;
1612  token = strtok (p, " ");
1613  for (; token; token = strtok (NULL, " ")) {
1614  toklen = (int)strlen (token) + 1;
1615  if ((n + toklen) > CB_IVAL_SIZE) {
1616  if (n) {
1617  printf ("\n%*.*s", CB_IMSG_SIZE + 3,
1618  CB_IMSG_SIZE + 3, " ");
1619  }
1620  n = 0;
1621  }
1622  printf ("%s%s", (n ? " " : ""), token);
1623  n += toklen;
1624  }
1625  putchar ('\n');
1626  cobc_free (p);
1627 }
void cobc_free(void *mptr)
Definition: cobc.c:657
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669
#define CB_IMSG_SIZE
Definition: cobc.c:80
#define CB_IVAL_SIZE
Definition: cobc.c:81

Here is the call graph for this function:

Here is the caller graph for this function:

static char* file_basename ( const char *  filename)
static

Definition at line 2573 of file cobc.c.

References _, basename_buffer, basename_len, COBC_ABORT, cobc_abort_pr(), cobc_main_realloc(), and NULL.

Referenced by process_compile(), process_filename(), process_library(), process_link(), process_module(), process_module_direct(), and process_run().

2574 {
2575  const char *p;
2576  const char *startp;
2577  const char *endp;
2578  size_t len;
2579 
2580  if (!filename) {
2581  cobc_abort_pr (_("Call to '%s' with invalid parameter '%s'"),
2582  "file_basename", "filename");
2583  COBC_ABORT ();
2584  }
2585 
2586  /* Remove directory name */
2587  startp = NULL;
2588  for (p = filename; *p; p++) {
2589  if (*p == '/' || *p == '\\') {
2590  startp = p;
2591  }
2592  }
2593  if (startp) {
2594  startp++;
2595  } else {
2596  startp = filename;
2597  }
2598 
2599  /* Remove extension */
2600  endp = strrchr (filename, '.');
2601  if (endp > startp) {
2602  len = endp - startp;
2603  } else {
2604  len = strlen (startp);
2605  }
2606 
2607  if (len >= basename_len) {
2608  basename_len = len + 16;
2610  }
2611  /* Copy base name */
2612  memcpy (basename_buffer, startp, len);
2613  basename_buffer[len] = 0;
2614  return basename_buffer;
2615 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static size_t basename_len
Definition: cobc.c:260
void * cobc_main_realloc(void *prevptr, const size_t size)
Definition: cobc.c:738
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define COBC_ABORT()
Definition: cobc.h:61
Definition: cobc.h:195
static char * basename_buffer
Definition: cobc.c:257

Here is the call graph for this function:

Here is the caller graph for this function:

static const char* file_extension ( const char *  filename)
static

Definition at line 2618 of file cobc.c.

Referenced by process_filename().

2619 {
2620  const char *p;
2621 
2622  p = strrchr (filename, '.');
2623  if (p) {
2624  return p + 1;
2625  }
2626  return "";
2627 }
Definition: cobc.h:195

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 4152 of file cobc.c.

References _, aflag_set, basename_buffer, basename_len, bindtextdomain, cb_attr_id, cb_compile_level, CB_COPT_1, CB_EXCEPTION_ENABLE, cb_field_id, cb_id, CB_LEVEL_ASSEMBLE, CB_LEVEL_COMPILE, CB_LEVEL_EXECUTABLE, CB_LEVEL_LIBRARY, CB_LEVEL_MODULE, CB_LEVEL_PREPROCESS, CB_LEVEL_TRANSLATE, cb_listing_file, cb_literal_id, cb_msg_style, CB_MSG_STYLE_GCC, CB_MSG_STYLE_MSC, cb_oc_build_stamp, cb_saveargc, cb_saveargv, cb_source_file, CB_TEXT_LIST_ADD, CB_TEXT_LIST_CHK, COB_CC, COB_CFLAGS, COB_CONFIG_DIR, cob_config_dir, COB_COPY_DIR, COB_EC_I_O, COB_EXPORT_DYN, COB_LARGE_BUFF, COB_LARGE_MAX, COB_LDFLAGS, COB_LIBS, COB_MINI_BUFF, COB_MINI_MAX, cob_optimize, COB_PIC_FLAGS, COB_SHARED_OPT, COB_SMALL_BUFF, COB_SMALL_MAX, COBC_ADD_STR, cobc_buffer, cobc_buffer_size, cobc_cc, cobc_cc_len, cobc_cflags, cobc_cflags_len, cobc_cflags_size, cobc_clean_up(), cobc_err_exit(), cobc_export_dyn_len, cobc_flag_library, cobc_flag_main, cobc_flag_module, cobc_free(), cobc_getenv(), cobc_include, cobc_include_len, cobc_include_size, cobc_init_reserved(), cobc_init_scanner(), cobc_init_typeck(), cobc_ldflags, cobc_ldflags_len, cobc_ldflags_size, cobc_lib_paths, cobc_lib_paths_len, cobc_lib_paths_size, cobc_libs, cobc_libs_len, cobc_libs_size, cobc_list_file, cobc_main_malloc(), cobc_main_strdup(), cobc_objects_buffer, cobc_objects_len, cobc_pic_flags_len, cobc_shared_opt_len, cobc_terminate(), cobc_wants_debug, demangle_name, filename::demangle_source, gflag_set, filename::has_error, iargs, LOCALEDIR, filename::need_assemble, filename::need_preprocess, filename::need_translate, cobc_mem_struct::next, NULL, optimize_defs, output_name, PACKAGE, plex_clear_all(), ppin, ppout, preprocess(), process_assemble(), process_command_line(), process_compile(), process_env_copy_path(), process_filename(), process_library(), process_link(), process_module(), process_module_direct(), process_translate(), save_temps_dir, textdomain, verbose_output, wants_nonfinal, ylex_clear_all(), yyin, and yyout.

4153 {
4154  struct filename *fn;
4155  char *p;
4156  struct cobc_mem_struct *mptr;
4157  struct cobc_mem_struct *mptrt;
4158  unsigned int iparams;
4159  unsigned int local_level;
4160  int status;
4161  int year;
4162  int day;
4163  int i;
4164  char month[32];
4165 
4166 #if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGACTION)
4167  struct sigaction sa;
4168  struct sigaction osa;
4169 #endif
4170 #ifdef ENABLE_NLS
4171  struct stat localest;
4172  const char* localedir;
4173 #endif
4174 
4175  yydebug = 0;
4176  file_list = NULL;
4178  ppin = NULL;
4179  ppout = NULL;
4180  yyin = NULL;
4181  yyout = NULL;
4182 
4183 #ifdef HAVE_SIGNAL_H
4184 
4185 #ifdef HAVE_SIGACTION
4186  memset (&sa, 0, sizeof(sa));
4187  sa.sa_handler = cobc_sig_handler;
4188 #ifdef SA_RESETHAND
4189  sa.sa_flags = SA_RESETHAND;
4190 #else
4191  sa.sa_flags = 0;
4192 #endif
4193 #ifdef SA_NOCLDSTOP
4194  sa.sa_flags |= SA_NOCLDSTOP;
4195 #endif
4196 #ifdef SIGINT
4197  (void)sigaction (SIGINT, NULL, &osa);
4198  if (osa.sa_handler != SIG_IGN) {
4199  (void)sigemptyset (&sa.sa_mask);
4200  (void)sigaction (SIGINT, &sa, NULL);
4201  }
4202 #endif
4203 #ifdef SIGHUP
4204  (void)sigaction (SIGHUP, NULL, &osa);
4205  if (osa.sa_handler != SIG_IGN) {
4206  (void)sigemptyset (&sa.sa_mask);
4207  (void)sigaction (SIGHUP, &sa, NULL);
4208  }
4209 #endif
4210 #ifdef SIGQUIT
4211  (void)sigaction (SIGQUIT, NULL, &osa);
4212  if (osa.sa_handler != SIG_IGN) {
4213  (void)sigemptyset (&sa.sa_mask);
4214  (void)sigaction (SIGQUIT, &sa, NULL);
4215  }
4216 #endif
4217 #ifdef SIGTERM
4218  (void)sigaction (SIGTERM, NULL, &osa);
4219  if (osa.sa_handler != SIG_IGN) {
4220  (void)sigemptyset (&sa.sa_mask);
4221  (void)sigaction (SIGTERM, &sa, NULL);
4222  }
4223 #endif
4224 #ifdef SIGPIPE
4225  (void)sigaction (SIGPIPE, NULL, &osa);
4226  if (osa.sa_handler != SIG_IGN) {
4227  (void)sigemptyset (&sa.sa_mask);
4228  (void)sigaction (SIGPIPE, &sa, NULL);
4229  }
4230 #endif
4231 #ifdef SIGSEGV
4232  /* Take direct control of segementation violation */
4233  (void)sigemptyset (&sa.sa_mask);
4234  (void)sigaction (SIGSEGV, &sa, NULL);
4235 #endif
4236 
4237 #else
4238 
4239 #ifdef SIGINT
4240  if (signal (SIGINT, SIG_IGN) != SIG_IGN) {
4241  (void)signal (SIGINT, cobc_sig_handler);
4242  }
4243 #endif
4244 #ifdef SIGHUP
4245  if (signal (SIGHUP, SIG_IGN) != SIG_IGN) {
4246  (void)signal (SIGHUP, cobc_sig_handler);
4247  }
4248 #endif
4249 #ifdef SIGQUIT
4250  if (signal (SIGQUIT, SIG_IGN) != SIG_IGN) {
4251  (void)signal (SIGQUIT, cobc_sig_handler);
4252  }
4253 #endif
4254 #ifdef SIGTERM
4255  if (signal (SIGTERM, SIG_IGN) != SIG_IGN) {
4256  (void)signal (SIGTERM, cobc_sig_handler);
4257  }
4258 #endif
4259 #ifdef SIGPIPE
4260  if (signal (SIGPIPE, SIG_IGN) != SIG_IGN) {
4261  (void)signal (SIGPIPE, cobc_sig_handler);
4262  }
4263 #endif
4264  /* Take direct control of segmentation violation */
4265 #ifdef SIGSEGV
4266  (void)signal (SIGSEGV, cobc_sig_handler);
4267 #endif
4268 #endif
4269 
4270 #endif
4271 
4272  cb_saveargc = argc;
4273  cb_saveargv = argv;
4274 
4275  /* General buffers */
4279  basename_len = COB_MINI_MAX - 16;
4280 
4286 
4292 
4293  cb_source_file = NULL;
4294  save_temps_dir = NULL;
4295  base_string = NULL;
4296  cobc_objects_len = 0;
4297  cb_id = 1;
4298  cb_attr_id = 1;
4299  cb_literal_id = 1;
4300  cb_field_id = 1;
4301 #ifdef COB_EBCDIC_MACHINE
4302  cb_ebcdic_sign = 1;
4303 #else
4304  cb_ebcdic_sign = 0;
4305 #endif
4306 
4307 #ifdef _WIN32
4308  /* Allows running tests under Win */
4309  p = getenv ("COB_UNIX_LF");
4310  if (p && (*p == 'Y' || *p == 'y' || *p == '1')) {
4311  (void)_setmode (_fileno (stdin), _O_BINARY);
4312  (void)_setmode (_fileno (stdout), _O_BINARY);
4313  (void)_setmode (_fileno (stderr), _O_BINARY);
4314  }
4315 #endif
4316 
4317 #ifdef HAVE_SETLOCALE
4318  setlocale (LC_ALL, "");
4319  setlocale (LC_NUMERIC, "C");
4320 #endif
4321 
4322 #ifdef ENABLE_NLS
4323  localedir = getenv("LOCALEDIR");
4324  if (localedir != NULL
4325  && !stat (localedir, &localest)
4326  && (S_ISDIR (localest.st_mode))) {
4327  bindtextdomain (PACKAGE, localedir);
4328  } else {
4330  }
4331  textdomain (PACKAGE);
4332 #endif
4333 
4334  /* Initialize variables */
4335 
4336  /* Set up build time stamp */
4337  memset (month, 0, sizeof(month));
4338  day = 0;
4339  year = 0;
4340  status = sscanf (__DATE__, "%s %d %d", month, &day, &year);
4341  if (status == 3) {
4342  snprintf (cobc_buffer, (size_t)COB_MINI_MAX,
4343  "%s %2.2d %4.4d %s", month, day, year, __TIME__);
4344  } else {
4345  snprintf (cobc_buffer, (size_t)COB_MINI_MAX,
4346  "%s %s", __DATE__, __TIME__);
4347  }
4349 
4350  output_name = NULL;
4351 
4352  cobc_cc = cobc_getenv ("COB_CC");
4353  if (cobc_cc == NULL) {
4354  cobc_cc = COB_CC;
4355  }
4356 
4357  cob_config_dir = cobc_getenv ("COB_CONFIG_DIR");
4358  if (cob_config_dir == NULL) {
4360  }
4361 
4362  p = cobc_getenv ("COB_CFLAGS");
4363  if (p) {
4365  } else {
4367  }
4368 
4369  p = cobc_getenv ("COB_LDFLAGS");
4370  if (p) {
4372  } else {
4374  }
4375 
4376  p = cobc_getenv ("COB_LIBS");
4377  if (p) {
4379  } else {
4381  }
4382 
4383  p = cobc_getenv ("COB_LDADD");
4384  if (p) {
4385  COBC_ADD_STR (cobc_libs, " ", p, NULL);
4386  }
4387 
4388  p = cobc_getenv ("COB_LIB_PATHS");
4389  if (p) {
4391  } else {
4393  }
4394 
4395  /* Different styles for warning/error messages */
4396  p = cobc_getenv ("COB_MSG_FORMAT");
4397 #if defined (_MSC_VER)
4398  if (p && strcasecmp(p, "GCC") == 0) {
4400  } else {
4402  }
4403 #else
4404  if (p && strcasecmp(p, "MSC") == 0) {
4406  } else {
4408  }
4409 #endif
4410 
4411  /* Set default computed goto usage if appropriate */
4412 #if defined(__GNUC__) && !defined(__clang__)
4413  cb_flag_computed_goto = 1;
4414 #elif defined(__SUNPRO_C) && __SUNPRO_C >= 0x570
4415  cb_flag_computed_goto = 1;
4416 #elif defined(__xlc__) && defined(__IBMC__) && __IBMC__ >= 700
4417  cb_flag_computed_goto = 1;
4418  COBC_ADD_STR (cobc_cflags, " -qlanglvl=extended",
4419  NULL, NULL);
4420 #endif
4421 
4422  /* Compiler special options */
4423 
4424 #ifdef __WATCOMC__
4425  /* -s = no overflow checks, otherwise need to code/link a CHK routine */
4426  COBC_ADD_STR (cobc_cflags, " -s -wcd=118", NULL, NULL);
4427 #endif
4428 
4429 #ifdef __INTEL_COMPILER
4430  COBC_ADD_STR (cobc_cflags, " -vec-report0 -opt-report 0",
4431  NULL, NULL);
4432 #elif defined(__GNUC__)
4433 #if 0 /* RXWRXW - gcse */
4434  COBC_ADD_STR (cobc_cflags, " -Wno-unused -fsigned-char -fno-gcse",
4435  NULL, NULL);
4436 #else
4437  COBC_ADD_STR (cobc_cflags, " -Wno-unused -fsigned-char",
4438  NULL, NULL);
4439 #endif
4440  /* --param max-goto-duplication-insns=100000 */
4441 #ifdef HAVE_PSIGN_OPT
4442  COBC_ADD_STR (cobc_cflags, " -Wno-pointer-sign", NULL, NULL);
4443 #endif
4444 
4445 #elif defined(__xlc__)
4446  COBC_ADD_STR (cobc_cflags, " -qro -qroconst",
4447  NULL, NULL);
4448 #endif
4449 
4450  /* Enable default I/O exceptions */
4452 
4453  /* Compiler initialization I */
4454 #ifndef HAVE_DESIGNATED_INITS
4455  cobc_init_reserved ();
4456 #endif
4457 
4458  /* Process command line arguments */
4459  iargs = process_command_line (argc, argv);
4460 
4461  /* Check the filename */
4462  if (iargs == argc) {
4463  cobc_err_exit (_("No input files"));
4464  }
4465 
4466  /* Windows stuff reliant upon verbose option */
4467 #ifdef _MSC_VER
4468  if (!verbose_output) {
4469  COBC_ADD_STR (cobc_cflags, " /nologo", NULL, NULL);
4470  }
4471 #if defined(_MSC_VER) && COB_USE_VC2005_OR_GREATER
4472  if (!verbose_output) {
4473  manicmd = "mt /nologo";
4474  manilink = "/link /nologo /manifest";
4475  } else {
4476  manicmd = "mt";
4477  manilink = "/link /manifest";
4478  }
4479 #else
4480  if (!verbose_output) {
4481  manilink = "/link /nologo";
4482  } else {
4483  manilink = "/link";
4484  }
4485 #endif
4486  manilink_len = strlen (manilink);
4487 #endif
4488 
4489 #ifdef __WATCOMC__
4490  if (!verbose_output) {
4491  COBC_ADD_STR (cobc_cflags, " -q", NULL, NULL);
4492  }
4493 #endif
4494 
4495 #if 0 /* gcc opts */
4496 
4497 #if defined(__GNUC__) && !defined (__INTEL_COMPILER)
4498  if (!gflag_set && !cobc_wants_debug && !aflag_set) {
4499  COBC_ADD_STR (cobc_cflags, " -fomit-frame-pointer",
4500  " -fno-asynchronous-unwind-tables",
4501  " -U_FORTIFY_SOURCE");
4502 #if 0 /* RXWRXW - Default opt */
4503  if (!cob_optimize) {
4505  }
4506 #endif
4507 #ifdef HAVE_UNWIND_OPT
4508 #endif
4509  }
4510 #endif
4511 
4512 #endif
4513 
4514  /* Append default extensions */
4522 
4523  /* Process COB_COPY_DIR and COBCPY environment variables */
4524  process_env_copy_path (getenv ("COB_COPY_DIR"));
4525  process_env_copy_path (getenv ("COBCPY"));
4526 
4527  /* Add default COB_COPY_DIR directory */
4529 
4530  /* Defaults are set here */
4531  if (!cb_flag_syntax_only) {
4532  if (!wants_nonfinal) {
4533  if (cobc_flag_main) {
4535  } else if (cobc_flag_module) {
4537  } else if (cobc_flag_library) {
4539  } else if (cb_compile_level == 0) {
4541  cobc_flag_module = 1;
4542  }
4543  }
4546  cobc_flag_module = 1;
4547  }
4548  } else {
4550  cobc_flag_main = 0;
4551  cobc_flag_module = 0;
4552  cobc_flag_library = 0;
4553  }
4554 
4556  (argc - iargs) > 1) {
4557  cobc_err_exit (_("%s option invalid in this combination"), "-o");
4558  }
4559 
4560  if (cb_flag_notrunc) {
4561  cb_binary_truncate = 0;
4562  cb_pretty_display = 0;
4563  }
4564 
4565  /* Compiler initialization II */
4566 #ifndef HAVE_DESIGNATED_INITS
4567  cobc_init_scanner ();
4568  cobc_init_typeck ();
4569 #endif
4570 
4571  /* If -P=file specified, all lists go to this file */
4572  if (cobc_list_file) {
4573  cb_listing_file = fopen (cobc_list_file, "w");
4574  if (!cb_listing_file) {
4576  }
4577  }
4578 
4579  if (verbose_output) {
4580  fputs (_("Command line:"), stderr);
4581  putc ('\t', stderr);
4582  for (i = 0; i < argc; ++i) {
4583  fprintf (stderr, "%s ", argv[i]);
4584  }
4585  putc ('\n', stderr);
4586  fflush (stderr);
4587  }
4588 
4589  cobc_cc_len = strlen (cobc_cc);
4590  cobc_cflags_len = strlen (cobc_cflags);
4591  cobc_libs_len = strlen (cobc_libs);
4593  cobc_include_len = strlen (cobc_include);
4594  cobc_ldflags_len = strlen (cobc_ldflags);
4597  cobc_pic_flags_len = strlen (COB_PIC_FLAGS);
4598 
4599  /* Process input files */
4600  status = 0;
4601  iparams = 0;
4602  local_level = 0;
4603 
4604  while (iargs < argc) {
4605  /* Set up file parameters */
4606  fn = process_filename (argv[iargs++]);
4607  if (!fn) {
4608  cobc_clean_up (1);
4609  return 1;
4610  }
4611  cb_id = 1;
4612  cb_attr_id = 1;
4613  cb_literal_id = 1;
4614  cb_field_id = 1;
4616  memset (optimize_defs, 0, sizeof(optimize_defs));
4617  iparams++;
4618  if (iparams > 1 && cb_compile_level == CB_LEVEL_EXECUTABLE) {
4619  local_level = cb_compile_level;
4621  cobc_flag_main = 0;
4622  }
4623 
4625  fn->need_preprocess) {
4626  /* Preprocess */
4627  fn->has_error = preprocess (fn);
4628  status |= fn->has_error;
4629  }
4630  if (cobc_list_file) {
4631  putc ('\n', cb_listing_file);
4632  }
4633 
4634  if (cb_compile_level < CB_LEVEL_TRANSLATE || fn->has_error) {
4635  continue;
4636  }
4637  if (fn->need_translate) {
4638  /* Parse / Translate (to C code) */
4639  fn->has_error = process_translate (fn);
4640  status |= fn->has_error;
4641  /* Free parse memory */
4642  for (mptr = cobc_parsemem_base; mptr; ) {
4643  mptrt = mptr;
4644  mptr = mptr->next;
4645  cobc_free (mptrt);
4646  }
4648  }
4650  cb_flag_syntax_only || fn->has_error) {
4651  continue;
4652  }
4654  /* Compile to assembler code */
4655  fn->has_error = process_compile (fn);
4656  status |= fn->has_error;
4657  continue;
4658  }
4659 
4661  /* Build module direct */
4662  fn->has_error = process_module_direct (fn);
4663  status |= fn->has_error;
4664  } else {
4665  /* Compile to object code */
4667  fn->need_assemble) {
4668  fn->has_error = process_assemble (fn);
4669  status |= fn->has_error;
4670  }
4671  if (fn->has_error) {
4672  continue;
4673  }
4674 
4675  /* Build module */
4677  fn->has_error = process_module (fn);
4678  status |= fn->has_error;
4679  }
4680  }
4681  }
4682 
4683  if (cobc_list_file) {
4684  fclose (cb_listing_file);
4686  }
4687 
4688  /* Clear rest of preprocess stuff */
4689  plex_clear_all ();
4690 
4691  /* Clear rest of parser stuff */
4692  ylex_clear_all ();
4693 
4694  if (local_level == CB_LEVEL_EXECUTABLE) {
4696  }
4697 
4699  status || cb_flag_syntax_only) {
4700  /* Finished */
4701  cobc_clean_up (status);
4702  return status;
4703  }
4704 
4705  /* Allocate objects buffer */
4707 
4708  if (file_list) {
4709  /* Link */
4711  /* Multi-program module */
4712  status = process_library (file_list);
4713  } else {
4714  /* Executable */
4715  status = process_link (file_list);
4716  }
4717  }
4718 
4719  /* We have completed */
4720  cobc_clean_up (status);
4721 
4722  return status;
4723 }
#define CB_LEVEL_LIBRARY
Definition: cobc.c:76
const char * cob_config_dir
Definition: cobc.c:155
static char * save_temps_dir
Definition: cobc.c:247
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
#define CB_TEXT_LIST_CHK(y, z)
Definition: cobc.c:111
static size_t cobc_include_size
Definition: cobc.c:234
static size_t cobc_objects_len
Definition: cobc.c:259
static size_t cobc_ldflags_size
Definition: cobc.c:235
static struct strcache * base_string
Definition: cobc.c:248
const char * cb_source_file
Definition: cobc.c:145
struct cb_text_list * cb_extension_list
Definition: cobc.c:151
#define CB_COPT_1
Definition: cobc.c:138
static size_t cobc_cflags_len
Definition: cobc.c:238
struct cb_text_list * cb_include_list
Definition: cobc.c:149
static char * cobc_include
Definition: cobc.c:228
static size_t gflag_set
Definition: cobc.c:289
#define COB_LDFLAGS
Definition: defaults.h:4
static char * cobc_libs
Definition: cobc.c:226
unsigned int need_assemble
Definition: cobc.h:209
int cb_id
Definition: cobc.c:163
#define COBC_ADD_STR(v, x, y, z)
Definition: cobc.c:83
static size_t basename_len
Definition: cobc.c:260
void cobc_free(void *mptr)
Definition: cobc.c:657
static char * cobc_objects_buffer
Definition: cobc.c:255
static int process_link(struct filename *l)
Definition: cobc.c:4031
static DECLNORET void COB_A_NORETURN cobc_terminate(const char *str)
Definition: cobc.c:1471
#define CB_LEVEL_ASSEMBLE
Definition: cobc.c:74
static size_t cobc_lib_paths_size
Definition: cobc.c:233
#define COB_SMALL_BUFF
Definition: common.h:540
static void process_env_copy_path(const char *p)
Definition: cobc.c:2527
FILE * cb_listing_file
Definition: cobc.c:157
#define COB_MINI_BUFF
Definition: common.h:539
#define CB_TEXT_LIST_ADD(y, z)
Definition: cobc.c:110
static size_t cobc_cflags_size
Definition: cobc.c:231
#define bindtextdomain(Domainname, Dirname)
Definition: gettext.h:86
static size_t cobc_cc_len
Definition: cobc.c:237
static char * cobc_list_file
Definition: cobc.c:251
static size_t wants_nonfinal
Definition: cobc.c:269
void plex_clear_all(void)
Definition: pplex.c:4570
static DECLNORET void COB_A_NORETURN cobc_err_exit(const char *fmt,...)
Definition: cobc.c:1229
#define COB_SMALL_MAX
Definition: common.h:546
void ylex_clear_all(void)
Definition: scanner.c:4736
const char * demangle_source
Definition: cobc.h:202
#define COB_LARGE_BUFF
Definition: common.h:544
char * cb_oc_build_stamp
Definition: cobc.c:146
#define COB_PIC_FLAGS
Definition: config.h:32
static int process_module(struct filename *fn)
Definition: cobc.c:3814
unsigned int need_translate
Definition: cobc.h:208
static char * cobc_ldflags
Definition: cobc.c:229
static char * cobc_buffer
Definition: cobc.c:254
static int process_module_direct(struct filename *fn)
Definition: cobc.c:3696
#define CB_LEVEL_TRANSLATE
Definition: cobc.c:72
#define textdomain(Domainname)
Definition: gettext.h:84
#define yyout
Definition: pplex.c:20
static int process_compile(struct filename *fn)
Definition: cobc.c:3560
static size_t cobc_include_len
Definition: cobc.c:241
static size_t cobc_flag_module
Definition: cobc.c:270
static int iargs
Definition: cobc.c:267
int cobc_wants_debug
Definition: cobc.c:169
FILE * ppin
Definition: pplex.c:367
static size_t cobc_libs_size
Definition: cobc.c:232
#define CB_LEVEL_EXECUTABLE
Definition: cobc.c:77
#define _(s)
Definition: cobcrun.c:59
static const char * cobc_cc
Definition: cobc.c:224
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
void cobc_init_scanner(void)
Definition: scanner.c:4922
static size_t verbose_output
Definition: cobc.c:276
#define CB_MSG_STYLE_MSC
Definition: cobc.h:436
#define CB_LEVEL_COMPILE
Definition: cobc.c:73
static char * cobc_lib_paths
Definition: cobc.c:227
static int preprocess(struct filename *fn)
Definition: cobc.c:3262
FILE * ppout
Definition: pplex.c:367
static size_t cobc_libs_len
Definition: cobc.c:239
char ** cb_saveargv
Definition: cobc.c:154
static int process_translate(struct filename *fn)
Definition: cobc.c:3397
int cb_saveargc
Definition: cobc.c:179
static int process_command_line(const int argc, char **argv)
Definition: cobc.c:1911
size_t cb_msg_style
Definition: error.c:43
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720
static char * cobc_getenv(const char *env)
Definition: cobc.c:1306
static size_t cob_optimize
Definition: cobc.c:277
int cb_field_id
Definition: cobc.c:166
static char * output_name
Definition: cobc.c:253
int has_error
Definition: cobc.h:210
#define COB_LIBS
Definition: defaults.h:5
#define COB_LARGE_MAX
Definition: common.h:550
static struct filename * process_filename(const char *filename)
Definition: cobc.c:2630
int cb_literal_id
Definition: cobc.c:165
#define CB_EXCEPTION_ENABLE(id)
Definition: cobc.h:243
#define CB_LEVEL_PREPROCESS
Definition: cobc.c:71
#define COB_CONFIG_DIR
Definition: defaults.h:6
#define yyin
Definition: pplex.c:16
const char * demangle_name
Definition: cobc.c:147
static char * cobc_cflags
Definition: cobc.c:225
int cb_attr_id
Definition: cobc.c:164
static size_t cobc_export_dyn_len
Definition: cobc.c:243
static int process_assemble(struct filename *fn)
Definition: cobc.c:3611
#define COB_CFLAGS
Definition: defaults.h:3
cob_u32_t optimize_defs[COB_OPTIM_MAX]
Definition: cobc.c:182
#define CB_LEVEL_MODULE
Definition: cobc.c:75
unsigned int need_preprocess
Definition: cobc.h:207
Definition: cobc.h:195
static char * basename_buffer
Definition: cobc.c:257
static size_t cobc_lib_paths_len
Definition: cobc.c:240
#define PACKAGE
Definition: config.h:294
static size_t cobc_shared_opt_len
Definition: cobc.c:244
#define COB_EXPORT_DYN
Definition: config.h:14
#define CB_MSG_STYLE_GCC
Definition: cobc.h:435
#define LOCALEDIR
Definition: defaults.h:17
int cobc_flag_main
Definition: cobc.c:167
static int process_library(struct filename *l)
Definition: cobc.c:3913
static struct cobc_mem_struct * cobc_parsemem_base
Definition: cobc.c:221
void cobc_init_typeck(void)
Definition: typeck.c:8747
static void cobc_clean_up(const int status)
Definition: cobc.c:1380
static size_t cobc_buffer_size
Definition: cobc.c:261
#define COB_SHARED_OPT
Definition: config.h:35
static unsigned int cb_compile_level
Definition: cobc.c:265
static size_t cobc_flag_library
Definition: cobc.c:271
#define COB_CC
Definition: defaults.h:2
static size_t aflag_set
Definition: cobc.c:290
#define COB_COPY_DIR
Definition: defaults.h:7
void cobc_init_reserved(void)
Definition: reserved.c:3133
#define COB_MINI_MAX
Definition: common.h:545
static size_t cobc_ldflags_len
Definition: cobc.c:242
struct cobc_mem_struct * next
Definition: cobc.h:231
int yydebug
static size_t cobc_pic_flags_len
Definition: cobc.c:245

Here is the call graph for this function:

static int preprocess ( struct filename fn)
static

Definition at line 3262 of file cobc.c.

References _, cb_listing_file, cb_source_format, COB_DASH, cobc_buffer, cobc_buffer_size, cobc_cmd_print(), cobc_free(), cobc_free_mem(), cobc_gen_listing, cobc_list_file, cobc_terminate(), errorcount, filename::file_is_stdin, filename::listing_file, cobc_mem_struct::next, NULL, plex_call_destroy(), plex_clear_vars(), ppin, ppopen(), ppout, ppparse(), ppparse_clear_vars(), filename::preprocess, filename::source, unlikely, and verbose_output.

Referenced by main().

3263 {
3264  struct cobc_mem_struct *m;
3265  struct cobc_mem_struct *ml;
3266  const char *sourcename;
3267  int save_source_format;
3268  int save_fold_copy;
3269  int save_fold_call;
3270  int ret;
3271 
3272  errorcount = 0;
3273 
3274  ppout = fopen (fn->preprocess, "w");
3275  if (!ppout) {
3276  cobc_terminate (fn->preprocess);
3277  }
3278 
3279  if (fn->file_is_stdin) {
3280  sourcename = COB_DASH;
3281  } else {
3282  sourcename = fn->source;
3283  }
3284  if (ppopen (sourcename, NULL) != 0) {
3285  fclose (ppout);
3286  ppout = NULL;
3287  if (fn->preprocess) {
3288  (void)unlink (fn->preprocess);
3289  }
3290  cobc_free_mem ();
3291  exit (1);
3292  }
3293 
3294  if (verbose_output) {
3295  fputs (_("Preprocessing:"), stderr);
3296  fprintf (stderr, "\t%s -> %s\n",
3297  sourcename, fn->preprocess);
3298  fflush (stderr);
3299  }
3300 
3301  if (cobc_gen_listing && !cobc_list_file) {
3302  cb_listing_file = fopen (fn->listing_file, "w");
3303  if (!cb_listing_file) {
3305  }
3306  }
3307 
3308  /* Reset pplex/ppparse variables */
3309  plex_clear_vars ();
3311 
3312  /* Save default flags in case program directives change them */
3313  save_source_format = cb_source_format;
3314  save_fold_copy = cb_fold_copy;
3315  save_fold_call = cb_fold_call;
3316 
3317  /* Preprocess */
3318  ppparse ();
3319 
3320  /* Restore default flags */
3321  cb_source_format = save_source_format;
3322  cb_fold_copy = save_fold_copy;
3323  cb_fold_call = save_fold_call;
3324 
3325  if (ppin) {
3326  fclose (ppin);
3327  ppin = NULL;
3328  }
3329 
3330  if (ppout) {
3331  if (unlikely(fclose(ppout) != 0)) {
3333  }
3334  ppout = NULL;
3335  }
3336 
3337  /* Release flex buffers - After file close */
3338  plex_call_destroy ();
3339 
3340  for (m = cobc_plexmem_base; m; ) {
3341  ml = m;
3342  m = m->next;
3343  cobc_free (ml);
3344  }
3346 
3347  if (cobc_gen_listing && !cobc_list_file) {
3348  if (unlikely(fclose (cb_listing_file) != 0)) {
3350  }
3351  if (cobc_gen_listing > 1) {
3352  snprintf (cobc_buffer, cobc_buffer_size,
3353  "cobxref %s -R", fn->listing_file);
3355  if (verbose_output) {
3357  }
3358  ret = system (cobc_buffer);
3359  if (verbose_output) {
3360  fputs (_("Return status:"), stderr);
3361  fprintf (stderr, "\t%d\n", ret);
3362  fflush (stderr);
3363  }
3364  if (ret) {
3365  fputs (_("'cobxref' execution unsuccessful"),
3366  stderr);
3367  putc ('\n', stderr);
3368 #ifdef _WIN32
3369  fprintf (stderr, _("Check that 'cobxref' is in %s"),
3370  "%%PATH%%");
3371 #else
3372  fprintf (stderr, _("Check that 'cobxref' is in %s"),
3373  "$PATH");
3374 #endif
3375  putc ('\n', stderr);
3376  fputs (_("No listing produced"),
3377  stderr);
3378  putc ('\n', stderr);
3379  fflush (stderr);
3380  }
3381  unlink (fn->listing_file);
3382  }
3384  }
3385 
3386  if (verbose_output) {
3387  fputs (_("Return status:"), stderr);
3388  fprintf (stderr, "\t%d\n", errorcount);
3389  fflush (stderr);
3390  }
3391  return !!errorcount;
3392 }
void plex_call_destroy(void)
Definition: pplex.c:4583
static struct cobc_mem_struct * cobc_plexmem_base
Definition: cobc.c:222
static void cobc_free_mem(void)
Definition: cobc.c:465
void cobc_free(void *mptr)
Definition: cobc.c:657
const char * listing_file
Definition: cobc.h:203
static DECLNORET void COB_A_NORETURN cobc_terminate(const char *str)
Definition: cobc.c:1471
const char * preprocess
Definition: cobc.h:198
void ppparse_clear_vars(const struct cb_define_struct *)
Definition: ppparse.c:490
FILE * cb_listing_file
Definition: cobc.c:157
int cb_source_format
Definition: cobc.c:162
static char * cobc_list_file
Definition: cobc.c:251
static char * cobc_buffer
Definition: cobc.c:254
unsigned int cobc_gen_listing
Definition: cobc.c:180
FILE * ppin
Definition: pplex.c:367
const char * source
Definition: cobc.h:197
#define _(s)
Definition: cobcrun.c:59
#define COB_DASH
Definition: cobc.h:121
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
void plex_clear_vars(void)
Definition: pplex.c:4559
int ppparse(void)
Definition: ppparse.c:1656
int ppopen(const char *, struct cb_replace_list *)
Definition: pplex.c:4420
FILE * ppout
Definition: pplex.c:367
static void cobc_cmd_print(const char *cmd)
Definition: cobc.c:1558
int file_is_stdin
Definition: cobc.h:211
static struct cb_define_struct * cb_define_list
Definition: cobc.c:218
static size_t cobc_buffer_size
Definition: cobc.c:261
int errorcount
Definition: cobc.c:173
struct cobc_mem_struct * next
Definition: cobc.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

static int process ( const char *  cmd)
static

Definition at line 3201 of file cobc.c.

References _, cobc_cmd_print(), cobc_free(), cobc_malloc(), likely, NULL, unlikely, and verbose_output.

Referenced by process_assemble(), process_compile(), process_library(), process_link(), process_module(), and process_module_direct().

3202 {
3203  char *p;
3204  char *buffptr;
3205  size_t clen;
3206  int ret;
3207 
3208  if (likely(strchr (cmd, '$') == NULL)) {
3209  buffptr = (char *)cmd;
3210  } else {
3211  clen = strlen (cmd) + 64U;
3212  clen = clen + 6U;
3213  buffptr = (char *)cobc_malloc (clen);
3214  p = buffptr;
3215  /* Quote '$' */
3216  for (; *cmd; ++cmd) {
3217  if (*cmd == '$') {
3218  p += sprintf (p, "\\$");
3219  } else {
3220  *p++ = *cmd;
3221  }
3222  }
3223  *p = 0;
3224  }
3225 
3226  if (verbose_output) {
3227  cobc_cmd_print (buffptr);
3228  }
3229 
3230  ret = system (buffptr);
3231 
3232  if (unlikely(buffptr != cmd)) {
3233  cobc_free (buffptr);
3234  }
3235 
3236 #ifdef WIFSIGNALED
3237  if (WIFSIGNALED(ret)) {
3238 #ifdef SIGINT
3239  if (WTERMSIG(ret) == SIGINT) {
3240  cobc_sig_handler (SIGINT);
3241  }
3242 #endif
3243 #ifdef SIGQUIT
3244  if (WTERMSIG(ret) == SIGQUIT) {
3245  cobc_sig_handler (SIGQUIT);
3246  }
3247 #endif
3248  }
3249 #endif
3250  if (verbose_output) {
3251  fputs (_("Return status:"), stderr);
3252  fprintf (stderr, "\t%d\n", ret);
3253  fflush (stderr);
3254  }
3255  return !!ret;
3256 }
void cobc_free(void *mptr)
Definition: cobc.c:657
#define _(s)
Definition: cobcrun.c:59
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
static void cobc_cmd_print(const char *cmd)
Definition: cobc.c:1558
void * cobc_malloc(const size_t size)
Definition: cobc.c:643
#define likely(x)
Definition: common.h:436

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_assemble ( struct filename fn)
static

Definition at line 3611 of file cobc.c.

References cb_compile_level, CB_LEVEL_ASSEMBLE, CB_LEVEL_LIBRARY, CB_LEVEL_MODULE, COB_LARGE_BUFF, COB_PIC_FLAGS, cobc_buffer, cobc_cc, cobc_cc_len, cobc_cflags, cobc_cflags_len, cobc_chk_buff_size(), cobc_flag_run, cobc_include, cobc_include_len, cobc_main_malloc(), cobc_pic_flags_len, gflag_set, filename::object, filename::object_len, process(), process_run(), filename::translate, filename::translate_len, and verbose_output.

Referenced by main().

3612 {
3613 #ifndef _MSC_VER
3614  int ret;
3615 #endif
3616  size_t bufflen;
3617 #ifdef __OS400__
3618  char *name;
3619 #endif
3620 
3621  bufflen = cobc_cc_len + cobc_cflags_len + fn->object_len
3623  + cobc_pic_flags_len + 64U;
3624 
3625  cobc_chk_buff_size (bufflen);
3626 
3627 #ifdef _MSC_VER
3628  sprintf (cobc_buffer, gflag_set ?
3629  "%s /c %s %s /Od /MDd /Zi /FR /Fo\"%s\" \"%s\"" :
3630  "%s /c %s %s /MD /Fo\"%s\" \"%s\"",
3632  fn->object, fn->translate);
3633  if (verbose_output) {
3634  return process (cobc_buffer);
3635  } else {
3636  return process_filtered (cobc_buffer, fn);
3637  }
3638 #elif defined(__OS400__)
3639  name = (char *) fn->translate;
3640  if (name[0] != '/') {
3641  char *p;
3642 
3644  getcwd (p, COB_LARGE_BUFF);
3645  strcat (p, "/");
3646  strcat (p, name);
3647  name = p;
3648  }
3649  file_stripext ((char *) fn->object);
3650  sprintf (cobc_buffer, "%s -c %s %s -o %s %s",
3652  fn->object, name);
3653  ret = process (cobc_buffer);
3654  if ((ret == 0) && cobc_flag_run) {
3655  ret = process_run (name);
3656  }
3657  return ret;
3658 #elif defined(__WATCOMC__)
3661  sprintf (cobc_buffer, "%s -c %s %s %s -fe=\"%s\" \"%s\"",
3663  COB_PIC_FLAGS, fn->object, fn->translate);
3664  } else {
3665  sprintf (cobc_buffer, "%s -c %s %s -fe=\"%s\" \"%s\"",
3667  fn->object, fn->translate);
3668  }
3669  ret = process (cobc_buffer);
3670  if ((ret == 0) && cobc_flag_run) {
3671  ret = process_run (fn->object);
3672  }
3673  return ret;
3674 #else
3678  sprintf (cobc_buffer, "%s -c %s %s %s -o \"%s\" \"%s\"",
3680  COB_PIC_FLAGS, fn->object, fn->translate);
3681  } else {
3682  // Only for CB_LEVEL_EXECUTABLE
3683  sprintf (cobc_buffer, "%s -c %s %s -o \"%s\" \"%s\"",
3685  fn->object, fn->translate);
3686  }
3687  ret = process (cobc_buffer);
3688  return ret;
3689 #endif
3690 
3691 }
#define CB_LEVEL_LIBRARY
Definition: cobc.c:76
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
static size_t cobc_cflags_len
Definition: cobc.c:238
static char * cobc_include
Definition: cobc.c:228
static size_t gflag_set
Definition: cobc.c:289
#define CB_LEVEL_ASSEMBLE
Definition: cobc.c:74
static int process_run(const char *name)
-j run job after build
Definition: cobc.c:2836
static size_t cobc_cc_len
Definition: cobc.c:237
#define COB_LARGE_BUFF
Definition: common.h:544
#define COB_PIC_FLAGS
Definition: config.h:32
static char * cobc_buffer
Definition: cobc.c:254
static size_t cobc_include_len
Definition: cobc.c:241
static int process(const char *cmd)
Definition: cobc.c:3201
size_t object_len
Definition: cobc.h:206
static const char * cobc_cc
Definition: cobc.c:224
static size_t verbose_output
Definition: cobc.c:276
size_t translate_len
Definition: cobc.h:205
static size_t cobc_flag_run
Definition: cobc.c:272
static char * cobc_cflags
Definition: cobc.c:225
#define CB_LEVEL_MODULE
Definition: cobc.c:75
const char * translate
Definition: cobc.h:199
const char * object
Definition: cobc.h:201
static unsigned int cb_compile_level
Definition: cobc.c:265
static void cobc_chk_buff_size(const size_t bufflen)
Definition: cobc.c:1182
static size_t cobc_pic_flags_len
Definition: cobc.c:245

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_command_line ( const int  argc,
char **  argv 
)
static

Definition at line 1911 of file cobc.c.

References _, aflag_set, cb_compile_level, cb_config_entry(), CB_COPT_1, CB_COPT_2, CB_COPT_S, cb_define_list_add(), CB_EXCEPTION_ENABLE, cb_flag_main, CB_FORMAT_FREE, CB_LEVEL_ASSEMBLE, CB_LEVEL_COMPILE, CB_LEVEL_PREPROCESS, CB_LEVEL_TRANSLATE, cb_list_intrinsics(), cb_list_mnemonics(), cb_list_reserved(), cb_list_system(), cb_load_conf(), cb_load_std(), CB_OK, cb_source_format, CB_TEXT_LIST_ADD, COB_EC_MAX, COB_FOLD_LOWER, COB_FOLD_UPPER, cob_getopt_long_long(), COB_MINI_BUFF, COB_MINI_MAX, cob_optarg, cob_optimize, cob_optind, COB_SMALL_MAX, cobc_abort_pr(), COBC_ADD_STR, cobc_cflags, cobc_deciph_funcs(), cobc_deciph_optarg(), cobc_err_exit(), cobc_flag_library, cobc_flag_main, cobc_flag_module, cobc_flag_run, cobc_free_mem(), cobc_gen_listing, cobc_include, COBC_INV_PAR, cobc_ldflags, cobc_lib_paths, cobc_libs, cobc_list_dir, cobc_list_file, cobc_main_malloc(), cobc_main_strdup(), cobc_options_error_build(), cobc_options_error_nonfinal(), cobc_print_info(), cobc_print_usage(), cobc_print_version(), cobc_strdup(), cobc_wants_debug, exit_option, gflag_set, no_physical_cancel, NULL, output_name, output_name_buff, save_all_src, save_c_src, save_temps, save_temps_dir, short_options, strip_output, verbose_output, wants_nonfinal, and warningopt.

Referenced by main().

1912 {
1913  struct cb_define_struct *p;
1914  size_t osize;
1915  int c;
1916  int idx;
1917  int n;
1918  int list_reserved = 0;
1919 #ifdef _WIN32
1920  int argnum;
1921 #endif
1922  enum cob_exception_id i;
1923  struct stat st;
1924  char ext[COB_MINI_BUFF];
1925 
1926  int conf_ret = 0;
1927  int sub_ret;
1928 
1929 #ifdef _WIN32
1930  /* Translate command line arguments from WIN to UNIX style */
1931  argnum = 1;
1932  while (++argnum <= argc) {
1933  if (strrchr(argv[argnum - 1], '/') == argv[argnum - 1]) {
1934  argv[argnum - 1][0] = '-';
1935  }
1936  }
1937 #endif
1938 
1939  /* First run of getopt: handle std/conf and all listing options
1940  We need to postpone single configuration flags as we need
1941  a full configuration to be loaded before */
1942  cob_optind = 1;
1943  while ((c = cob_getopt_long_long (argc, argv, short_options,
1944  long_options, &idx, 1)) >= 0) {
1945  switch (c) {
1946 
1947  case '?':
1948  /* Unknown option or ambiguous */
1949  cobc_free_mem ();
1950  exit (1);
1951 
1952  case 'h':
1953  /* --help */
1954  cobc_print_usage (argv[0]);
1955  cobc_free_mem ();
1956  exit (0);
1957 
1958  case 'V':
1959  /* --version */
1960  cobc_print_version ();
1961  exit (0);
1962 
1963  case 'i':
1964  /* --info */
1965  cobc_print_info ();
1966  exit_option = 1;
1967  break;
1968 
1969  case '5':
1970  /* --list-reserved */
1971  /*
1972  This must be postponed until after the configuration
1973  is loaded.
1974  */
1975  list_reserved = 1;
1976  break;
1977 
1978  case '6':
1979  /* --list-intrinsics */
1980  cb_list_intrinsics ();
1981  exit_option = 1;
1982  break;
1983 
1984  case '7':
1985  /* --list-mnemonics */
1986  cb_list_mnemonics ();
1987  exit_option = 1;
1988  break;
1989 
1990  case '8':
1991  /* --list-system */
1992  cb_list_system ();
1993  exit_option = 1;
1994  break;
1995 
1996  case 'v':
1997  /* --verbose : Verbose reporting */
1998  /* VERY special case as we set different level by mutliple calls */
1999  /* Output version information when running very verbose */
2000  if (++verbose_output == 2) {
2001  cobc_print_version ();
2002  }
2003  break;
2004 
2005  case '$':
2006  /* -std=<xx> : Specify dialect */
2007  if (!exit_option) {
2008  snprintf (ext, (size_t)COB_MINI_MAX, "%s.conf", cob_optarg);
2009  if (cb_load_std (ext) != 0) {
2010  cobc_err_exit (_("Invalid option -std=%s"),
2011  cob_optarg);
2012  }
2013  }
2014  break;
2015 
2016  case '&':
2017  /* -conf=<xx> : Specify dialect configuration file */
2018  if (!exit_option) {
2019  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2020  cobc_err_exit (COBC_INV_PAR, "-conf");
2021  }
2022  sub_ret = cb_load_conf (cob_optarg, 0);
2023  if (sub_ret != 0) conf_ret = sub_ret;
2024  }
2025  break;
2026 
2027  default:
2028  /* as we postpone most options simply skip everything other here */
2029  break;
2030  }
2031  }
2032 
2033  /* Exit if list options were specified */
2034  if (exit_option) {
2035  cobc_free_mem ();
2036  exit (0);
2037  }
2038 
2039  /* Load default configuration file if necessary */
2040  if (cb_config_name == NULL) {
2041  if (verbose_output) {
2042  fputs (_("Loading standard configuration file 'default.conf'"), stderr);
2043  fputc ('\n', stderr);
2044  }
2045  sub_ret = cb_load_std ("default.conf");
2046  if (sub_ret != 0) conf_ret = sub_ret;
2047  }
2048 
2049  /* Exit for configuration errors resulting from -std/-conf/default.conf */
2050  if (conf_ret != 0) {
2051  cobc_free_mem ();
2052  exit (1);
2053  }
2054 
2055  /* Set relaxed syntax configuration options if requested */
2056  if (cb_flag_relaxed_syntax) {
2057  cb_relaxed_syntax_check = 1;
2058  cb_larger_redefines_ok = 1;
2059  cb_relax_level_hierarchy = 1;
2060  cb_top_level_occurs_clause = CB_OK;
2061  }
2062 
2063  cob_optind = 1;
2064  while ((c = cob_getopt_long_long (argc, argv, short_options,
2065  long_options, &idx, 1)) >= 0) {
2066  switch (c) {
2067  case 0:
2068  /* Defined flag */
2069  break;
2070 
2071  case 'h':
2072  /* --help */
2073  case 'V':
2074  /* --version */
2075  case 'i':
2076  /* --info */
2077  case '5':
2078  /* --list-reserved */
2079  case '6':
2080  /* --list-intrinsics */
2081  case '7':
2082  /* --list-mnemonics */
2083  case '8':
2084  /* --list-system */
2085  /* These options were all processed in the first getopt-run */
2086  break;
2087 
2088  case 'E':
2089  /* -E : Preprocess */
2090  if (wants_nonfinal) {
2092  }
2093  wants_nonfinal = 1;
2095  break;
2096 
2097  case 'C':
2098  /* -C : Generate C code */
2099  if (wants_nonfinal) {
2101  }
2102  save_c_src = 1;
2103  wants_nonfinal = 1;
2105  break;
2106 
2107  case 'S':
2108  /* -S : Generate assembler code */
2109  if (wants_nonfinal) {
2111  }
2112  wants_nonfinal = 1;
2114  break;
2115 
2116  case 'c':
2117  /* -c : Generate C object code */
2118  if (wants_nonfinal) {
2120  }
2121  wants_nonfinal = 1;
2123  break;
2124 
2125  case 'b':
2126  /* -b : Generate combined library module */
2129  }
2130  cobc_flag_library = 1;
2131  no_physical_cancel = 1;
2132  cb_flag_implicit_init = 1;
2133  break;
2134 
2135  case 'm':
2136  /* -m : Generate loadable module (default) */
2139  }
2140  cobc_flag_module = 1;
2141  break;
2142 
2143  case 'x':
2144  /* -x : Generate executable */
2147  }
2148  cobc_flag_main = 1;
2149  cb_flag_main = 1;
2150  no_physical_cancel = 1;
2151  break;
2152 
2153  case 'j':
2154  /* -j : Run job; compile, link and go, either by ./ or cobcrun */
2155  cobc_flag_run = 1;
2156  break;
2157 
2158  case 'F':
2159  /* -F : short option for -free */
2161  break;
2162 
2163  case 'v':
2164  /* --verbose : Verbose reporting */
2165  /* This option was processed in the first getopt-run */
2166  break;
2167 
2168  case 'o':
2169  /* -o : Output file */
2170  osize = strlen (cob_optarg);
2171  if (osize > COB_SMALL_MAX) {
2172  cobc_err_exit (_("Invalid output file name"));
2173  }
2175  /* Allocate buffer plus extension reserve */
2176  output_name_buff = cobc_main_malloc (osize + 32U);
2177  break;
2178 
2179  case 'O':
2180  /* -O : Optimize */
2181  cob_optimize = 1;
2183  break;
2184 
2185  case '9':
2186  /* -O2 : Optimize */
2187  cob_optimize = 1;
2188  strip_output = 1;
2190  break;
2191 
2192  case 's':
2193  /* -Os : Optimize */
2194  cob_optimize = 1;
2195  strip_output = 1;
2197  break;
2198 
2199  case 'g':
2200  /* -g : Generate C debug code */
2201  save_all_src = 1;
2202  gflag_set = 1;
2203  cb_flag_stack_check = 1;
2204  cb_flag_source_location = 1;
2205 #ifndef _MSC_VER
2206  COBC_ADD_STR (cobc_cflags, " -g", NULL, NULL);
2207 #endif
2208  break;
2209 
2210  case '$':
2211  /* -std=<xx> : Specify dialect */
2212  case '&':
2213  /* -conf=<xx> : Specify dialect configuration file */
2214  /* These options were all processed in the first getopt-run */
2215  break;
2216 
2217  case '%':
2218  /* -cb_conf=<xx:yy> : Override configuration entry */
2219  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2220  cobc_err_exit (COBC_INV_PAR , "-cb_conf");
2221  }
2222  sub_ret = cb_config_entry (cob_optarg, NULL, 0);
2223  if (sub_ret != 0) conf_ret = sub_ret;
2224  break;
2225 
2226  case 'd':
2227  /* -debug : Turn on OC debugging */
2228  cb_flag_source_location = 1;
2229  cb_flag_trace = 1;
2230  cb_flag_stack_check = 1;
2231  cobc_wants_debug = 1;
2232  break;
2233 
2234  case '_':
2235  /* --save-temps : Save intermediary files */
2236  save_temps = 1;
2237  if (cob_optarg) {
2238  if (stat (cob_optarg, &st) != 0 ||
2239  !(S_ISDIR (st.st_mode))) {
2240  cobc_abort_pr (_("Warning - '%s' is not a directory, defaulting to current directory"),
2241  cob_optarg);
2242  } else {
2244  }
2245  }
2246  break;
2247 
2248  case 'P':
2249  /* -P : Generate listing */
2250  if (cob_optarg) {
2251  if (!stat (cob_optarg, &st) && S_ISDIR (st.st_mode)) {
2253  } else {
2255  }
2256  }
2257  if (!cobc_gen_listing) {
2258  cobc_gen_listing = 1;
2259  }
2260  break;
2261 
2262  case 'X':
2263  /* -Xref : Generate listing through 'cobxref' */
2264  cobc_gen_listing = 2;
2265  break;
2266 
2267  case 'D':
2268  /* -D xx(=yy) : Define variables */
2269  if (strlen (cob_optarg) > 64U) {
2270  cobc_err_exit (COBC_INV_PAR, "-D");
2271  }
2272  if (!strcasecmp (cob_optarg, "ebug")) {
2273  cobc_abort_pr (_("Warning - assuming '%s' is a DEFINE - did you intend to use -debug?"),
2274  cob_optarg);
2275  }
2277  if (!p) {
2278  cobc_err_exit (COBC_INV_PAR, "-D");
2279  }
2280  cb_define_list = p;
2281  break;
2282 
2283  case 'I':
2284  /* -I <xx> : Include/copy directory */
2285  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2286  cobc_err_exit (COBC_INV_PAR, "-I");
2287  }
2288  if (stat (cob_optarg, &st) != 0 ||
2289  !(S_ISDIR (st.st_mode))) {
2290  break;
2291  }
2292 #ifdef _MSC_VER
2293  COBC_ADD_STR (cobc_include, " /I \"", cob_optarg, "\"");
2294 #elif defined (__WATCOMC__)
2295  COBC_ADD_STR (cobc_include, " -i\"", cob_optarg, "\"");
2296 #else
2297  COBC_ADD_STR (cobc_include, " -I\"", cob_optarg, "\"");
2298 #endif
2300  break;
2301 
2302  case 'L':
2303  /* -L <xx> : Directory for library search */
2304  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2305  cobc_err_exit (COBC_INV_PAR, "-L");
2306  }
2307  if (stat (cob_optarg, &st) != 0 ||
2308  !(S_ISDIR (st.st_mode))) {
2309  break;
2310  }
2311 #ifdef _MSC_VER
2312  COBC_ADD_STR (cobc_lib_paths, " /LIBPATH:\"", cob_optarg, "\"");
2313 #else
2314  COBC_ADD_STR (cobc_lib_paths, " -L\"", cob_optarg, "\"");
2315 #endif
2316  break;
2317 
2318  case 'l':
2319  /* -l <xx> : Add library to link phase */
2320  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2321  cobc_err_exit (COBC_INV_PAR, "-l");
2322  }
2323 #ifdef _MSC_VER
2324  COBC_ADD_STR (cobc_libs, " \"", cob_optarg, ".lib\"");
2325 #else
2326  COBC_ADD_STR (cobc_libs, " -l\"", cob_optarg, "\"");
2327 #endif
2328  break;
2329 
2330  case 'e':
2331  /* -e <xx> : Add an extension suffix */
2332  if (strlen (cob_optarg) > 15U) {
2333  cobc_err_exit (COBC_INV_PAR, "--ext");
2334  }
2335  snprintf (ext, (size_t)COB_MINI_MAX, ".%s", cob_optarg);
2337  break;
2338 
2339  case 'K':
2340  /* -K <xx> : Define literal CALL to xx as static */
2341  if (strlen (cob_optarg) > 32U) {
2342  cobc_err_exit (COBC_INV_PAR, "-K");
2343  }
2345  break;
2346 
2347  case 'k':
2348  /* -k <xx> : Check for exit after CALL to xx */
2349  /* This is to cater for legacy German DIN standard */
2350  /* Check after CALL if an exit program required */
2351  /* Not in --help as subject to change and highly specific */
2352  if (strlen (cob_optarg) > 32U) {
2353  cobc_err_exit (COBC_INV_PAR, "-k");
2354  }
2356  break;
2357 
2358  case 1:
2359  /* -fstack-size=<xx> : Specify stack (perform) size */
2360  n = cobc_deciph_optarg (cob_optarg, 0);
2361  if (n < 16 || n > 512) {
2362  cobc_err_exit (COBC_INV_PAR, "-fstack-size");
2363  }
2364  cb_stack_size = n;
2365  break;
2366 
2367  case 2:
2368  /* -fif-cutoff=<xx> : Specify IF cutoff level */
2369  n = cobc_deciph_optarg (cob_optarg, 0);
2370  if (n < 1 || n > 512) {
2371  cobc_err_exit (COBC_INV_PAR, "-fif-cutoff");
2372  }
2373  cb_if_cutoff = n;
2374  break;
2375 
2376  case 3:
2377  /* -fsign=<ASCII/EBCDIC> : Specify display sign */
2378  if (!strcasecmp (cob_optarg, "EBCDIC")) {
2379  cb_ebcdic_sign = 1;
2380  } else if (!strcasecmp (cob_optarg, "ASCII")) {
2381  cb_ebcdic_sign = 0;
2382  } else {
2383  cobc_err_exit (COBC_INV_PAR, "-fsign");
2384  }
2385  break;
2386 
2387  case 4:
2388  /* -ffold-copy=<UPPER/LOWER> : COPY fold case */
2389  if (!strcasecmp (cob_optarg, "UPPER")) {
2390  cb_fold_copy = COB_FOLD_UPPER;
2391  } else if (!strcasecmp (cob_optarg, "LOWER")) {
2392  cb_fold_copy = COB_FOLD_LOWER;
2393  } else {
2394  cobc_err_exit (COBC_INV_PAR, "-ffold-copy");
2395  }
2396  break;
2397 
2398  case 5:
2399  /* -ffold-call=<UPPER/LOWER> : CALL/PROG-ID fold case */
2400  if (!strcasecmp (cob_optarg, "UPPER")) {
2401  cb_fold_call = COB_FOLD_UPPER;
2402  } else if (!strcasecmp (cob_optarg, "LOWER")) {
2403  cb_fold_call = COB_FOLD_LOWER;
2404  } else {
2405  cobc_err_exit (COBC_INV_PAR, "-ffold-call");
2406  }
2407  break;
2408 
2409  case 6:
2410  /* -fdefaultbyte=<xx> : Default initialization byte */
2411  n = cobc_deciph_optarg (cob_optarg, 1);
2412  if (n < 0 || n > 255) {
2413  cobc_err_exit (COBC_INV_PAR, "-fdefaultbyte");
2414  }
2415  cb_default_byte = n;
2416  break;
2417 
2418  case 10:
2419  /* -fintrinsics=<xx> : Intrinsic name or ALL */
2421  break;
2422 
2423  case 'A':
2424  /* -A <xx> : Add options to C compile phase */
2426  aflag_set = 1;
2427  break;
2428 
2429  case 'Q':
2430  /* -Q <xx> : Add options to C link phase */
2432  break;
2433 
2434  case 'w':
2435  /* -w(xx) : Turn off warnings */
2436 #undef CB_WARNDEF
2437 #undef CB_NOWARNDEF
2438 #define CB_WARNDEF(var,name,doc) var = 0;
2439 #define CB_NOWARNDEF(var,name,doc) var = 0;
2440 #include "warning.def"
2441 #undef CB_WARNDEF
2442 #undef CB_NOWARNDEF
2443  break;
2444 
2445  case 'W':
2446  /* -W : Turn on warnings */
2447  warningopt = 1;
2448 #undef CB_WARNDEF
2449 #undef CB_NOWARNDEF
2450 #define CB_WARNDEF(var,name,doc) var = 1;
2451 #define CB_NOWARNDEF(var,name,doc)
2452 #include "warning.def"
2453 #undef CB_WARNDEF
2454 #undef CB_NOWARNDEF
2455  break;
2456 
2457  case 'Z':
2458  /* -W : Turn on all warnings */
2459  warningopt = 1;
2460 #undef CB_WARNDEF
2461 #undef CB_NOWARNDEF
2462 #define CB_WARNDEF(var,name,doc) var = 1;
2463 #define CB_NOWARNDEF(var,name,doc) var = 1;
2464 #include "warning.def"
2465 #undef CB_WARNDEF
2466 #undef CB_NOWARNDEF
2467  break;
2468 
2469  default:
2470  cobc_err_exit (_("Invalid option detected"));
2471  }
2472  }
2473 
2474  /* Exit for configuration errors resulting from -cb_conf */
2475  if (conf_ret != 0) {
2476  cobc_free_mem ();
2477  exit (1);
2478  }
2479 
2480  if (list_reserved) {
2481  cb_list_reserved ();
2482  cobc_free_mem ();
2483  exit (0);
2484  }
2485 
2486  /* debug: Turn on all exception conditions */
2487  if (cobc_wants_debug) {
2488  for (i = (enum cob_exception_id)1; i < COB_EC_MAX; ++i) {
2489  CB_EXCEPTION_ENABLE (i) = 1;
2490  }
2491  if (verbose_output > 1) {
2492  fputs (_("All runtime checks are enabled"), stderr);
2493  fputc ('\n', stderr);
2494  }
2495  }
2496 
2497  /* If C debug, do not strip output */
2498  if (gflag_set) {
2499  strip_output = 0;
2500  }
2501 
2502  if (cb_flag_traceall) {
2503  cb_flag_trace = 1;
2504  cb_flag_source_location = 1;
2505  }
2506 
2507  return cob_optind;
2508 }
static size_t save_all_src
Definition: cobc.c:274
static char * save_temps_dir
Definition: cobc.c:247
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
int cob_getopt_long_long(const int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, const int long_only)
Definition: cobgetopt.c:321
struct cb_text_list * cb_extension_list
Definition: cobc.c:151
#define CB_COPT_1
Definition: cobc.c:138
struct cb_text_list * cb_include_list
Definition: cobc.c:149
static char * cobc_include
Definition: cobc.c:228
static int cobc_deciph_optarg(const char *p, const int allow_quote)
Definition: cobc.c:1191
static size_t gflag_set
Definition: cobc.c:289
static void cobc_free_mem(void)
Definition: cobc.c:465
int cb_flag_main
Definition: cobc.c:168
static char * cobc_libs
Definition: cobc.c:226
int warningopt
Definition: cobc.c:176
#define COBC_ADD_STR(v, x, y, z)
Definition: cobc.c:83
int cb_load_conf(const char *, const int)
Definition: config.c:476
void cb_list_intrinsics(void)
Definition: reserved.c:3052
#define CB_LEVEL_ASSEMBLE
Definition: cobc.c:74
void cb_list_mnemonics(void)
Definition: reserved.c:3101
#define COB_MINI_BUFF
Definition: common.h:539
#define CB_TEXT_LIST_ADD(y, z)
Definition: cobc.c:110
int cb_source_format
Definition: cobc.c:162
static char * cobc_list_file
Definition: cobc.c:251
static size_t wants_nonfinal
Definition: cobc.c:269
static DECLNORET void COB_A_NORETURN cobc_err_exit(const char *fmt,...)
Definition: cobc.c:1229
#define CB_COPT_S
Definition: cobc.c:140
#define COB_SMALL_MAX
Definition: common.h:546
int cob_optind
Definition: cobgetopt.c:92
#define CB_COPT_2
Definition: cobc.c:139
static char * cobc_ldflags
Definition: cobc.c:229
int no_physical_cancel
Definition: cobc.c:177
Definition: cobc.h:135
unsigned int cobc_gen_listing
Definition: cobc.c:180
#define CB_LEVEL_TRANSLATE
Definition: cobc.c:72
static char * cobc_list_dir
Definition: cobc.c:250
static size_t cobc_flag_module
Definition: cobc.c:270
static struct cb_define_struct * cb_define_list_add(struct cb_define_struct *list, const char *text)
Definition: cobc.c:1245
static void cobc_deciph_funcs(const char *opt)
Definition: cobc.c:1888
static const struct option long_options[]
Definition: cobc.c:396
int cobc_wants_debug
Definition: cobc.c:169
struct cb_text_list * cb_early_exit_list
Definition: cobc.c:153
int exit_option
Definition: cobc.c:175
#define _(s)
Definition: cobcrun.c:59
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
#define CB_LEVEL_COMPILE
Definition: cobc.c:73
static char * cobc_lib_paths
Definition: cobc.c:227
void cb_list_reserved(void)
Definition: reserved.c:2989
void cb_list_system(void)
Definition: typeck.c:833
static void cobc_options_error_build(void)
Definition: cobc.c:1882
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720
static void cobc_print_info(void)
Definition: cobc.c:1630
#define COB_FOLD_LOWER
Definition: common.h:587
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669
static size_t cob_optimize
Definition: cobc.c:277
static size_t save_c_src
Definition: cobc.c:275
static char * output_name
Definition: cobc.c:253
static void cobc_options_error_nonfinal(void)
Definition: cobc.c:1876
static struct cb_define_struct * cb_define_list
Definition: cobc.c:218
static size_t cobc_flag_run
Definition: cobc.c:272
#define CB_EXCEPTION_ENABLE(id)
Definition: cobc.h:243
int cb_load_std(const char *)
Definition: config.c:147
#define CB_LEVEL_PREPROCESS
Definition: cobc.c:71
cob_exception_id
Definition: common.h:710
static char * cobc_cflags
Definition: cobc.c:225
static size_t strip_output
Definition: cobc.c:288
#define CB_FORMAT_FREE
Definition: cobc.h:66
static size_t save_temps
Definition: cobc.c:273
static void cobc_print_version(void)
Definition: cobc.c:1541
#define COB_FOLD_UPPER
Definition: common.h:586
static const char short_options[]
Definition: cobc.c:390
int cobc_flag_main
Definition: cobc.c:167
static char * output_name_buff
Definition: cobc.c:256
#define COBC_INV_PAR
Definition: cobc.c:84
static void cobc_print_usage(char *prog)
Definition: cobc.c:1786
int cb_config_entry(char *, const char *, const int)
Definition: config.c:153
static unsigned int cb_compile_level
Definition: cobc.c:265
static size_t cobc_flag_library
Definition: cobc.c:271
struct cb_text_list * cb_static_call_list
Definition: cobc.c:152
char * cob_optarg
Definition: cobgetopt.c:77
static size_t aflag_set
Definition: cobc.c:290
#define COB_MINI_MAX
Definition: common.h:545

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_compile ( struct filename fn)
static

Definition at line 3560 of file cobc.c.

References cobc_buffer, cobc_cc, cobc_cc_len, cobc_cflags, cobc_cflags_len, cobc_chk_buff_size(), cobc_include, cobc_include_len, file_basename(), gflag_set, output_name, process(), filename::source, filename::translate, filename::translate_len, and verbose_output.

Referenced by main().

3561 {
3562  char *name;
3563  size_t bufflen;
3564  size_t size;
3565 
3566  if (output_name) {
3567  name = output_name;
3568  } else {
3569  name = file_basename (fn->source);
3570 #ifndef _MSC_VER
3571  strcat (name, ".s");
3572 #endif
3573  }
3574  size = strlen (name);
3575 #ifdef _MSC_VER
3576  size *= 2U;
3577 #endif
3578 
3579  bufflen = cobc_cc_len + cobc_cflags_len
3580  + size + fn->translate_len
3581  + cobc_include_len + 64U;
3582 
3583  cobc_chk_buff_size (bufflen);
3584 
3585 #ifdef _MSC_VER
3586  sprintf (cobc_buffer, gflag_set ?
3587  "%s /c %s %s /Od /MDd /Zi /FR /c /Fa\"%s\" /Fo\"%s\" \"%s\"" :
3588  "%s /c %s %s /MD /c /Fa\"%s\" /Fo\"%s\" \"%s\"",
3590  name, fn->translate);
3591  if (verbose_output) {
3592  return process (cobc_buffer);
3593  } else {
3594  return process_filtered (cobc_buffer, fn);
3595  }
3596 #elif defined(__WATCOMC__)
3597  sprintf (cobc_buffer, "%s -fe=\"%s\" -s %s %s %s", cobc_cc, name,
3599  return process (cobc_buffer);
3600 #else
3601  sprintf (cobc_buffer, "%s -S -o \"%s\" %s %s %s", cobc_cc, name,
3603  return process(cobc_buffer);
3604 #endif
3605 
3606 }
static size_t cobc_cflags_len
Definition: cobc.c:238
static char * cobc_include
Definition: cobc.c:228
static size_t gflag_set
Definition: cobc.c:289
static size_t cobc_cc_len
Definition: cobc.c:237
static char * cobc_buffer
Definition: cobc.c:254
static size_t cobc_include_len
Definition: cobc.c:241
static int process(const char *cmd)
Definition: cobc.c:3201
const char * source
Definition: cobc.h:197
static const char * cobc_cc
Definition: cobc.c:224
static size_t verbose_output
Definition: cobc.c:276
size_t translate_len
Definition: cobc.h:205
static char * file_basename(const char *filename)
Definition: cobc.c:2573
static char * output_name
Definition: cobc.c:253
static char * cobc_cflags
Definition: cobc.c:225
const char * translate
Definition: cobc.h:199
static void cobc_chk_buff_size(const size_t bufflen)
Definition: cobc.c:1182

Here is the call graph for this function:

Here is the caller graph for this function:

static void process_env_copy_path ( const char *  p)
static

Definition at line 2527 of file cobc.c.

References CB_TEXT_LIST_CHK, cobc_free(), cobc_strdup(), NULL, PATHSEP_STR, and value.

Referenced by main().

2528 {
2529  char *value;
2530  char *token;
2531  struct stat st;
2532 
2533  if (p == NULL || !*p || *p == ' ') {
2534  return;
2535  }
2536 
2537  /* Clone value for destructive strtok */
2538  value = cobc_strdup (p);
2539 
2540  /* Tokenize for path sep. */
2541  token = strtok (value, PATHSEP_STR);
2542  while (token) {
2543  if (!stat (token, &st) && (S_ISDIR (st.st_mode))) {
2545  }
2546  token = strtok (NULL, PATHSEP_STR);
2547  }
2548 
2549  cobc_free (value);
2550  return;
2551 }
#define CB_TEXT_LIST_CHK(y, z)
Definition: cobc.c:111
struct cb_text_list * cb_include_list
Definition: cobc.c:149
void cobc_free(void *mptr)
Definition: cobc.c:657
strict implicit external value
Definition: warning.def:54
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
#define PATHSEP_STR
Definition: common.h:501
void * cobc_strdup(const char *dupstr)
Definition: cobc.c:669

Here is the call graph for this function:

Here is the caller graph for this function:

static struct filename* process_filename ( const char *  filename)
static

Definition at line 2630 of file cobc.c.

References _, cb_compile_level, cb_encode_program_id(), CB_LEVEL_ASSEMBLE, CB_LEVEL_PREPROCESS, CB_LEVEL_TRANSLATE, COB_DASH, COB_DASH_NAME, COB_FILE_MAX, cob_incr_temp_iteration(), COB_NORMAL_MAX, COB_OBJECT_EXT, cob_temp_name(), cobc_abort_pr(), cobc_check_valid_name(), cobc_gen_listing, cobc_list_dir, cobc_list_file, cobc_main_malloc(), cobc_main_strdup(), cobc_objects_len, cobc_seen_stdin, cobc_stradd_dup(), cobc_terminate(), filename::demangle_source, extension, file_basename(), file_extension(), filename::file_is_stdin, filename::listing_file, filename::need_assemble, filename::need_preprocess, filename::need_translate, filename::next, NULL, filename::object, filename::object_len, output_name, filename::preprocess, R_OK, save_all_src, save_c_src, save_temps, SLASH_CHAR, filename::source, filename::translate, filename::translate_len, and filename::trstorage.

Referenced by main().

2631 {
2632  const char *extension;
2633  struct filename *fn;
2634  struct filename *ffn;
2635  char *fbasename;
2636  char *listptr;
2637  size_t fsize;
2638  int file_is_stdin;
2639 
2640  if (strcmp(filename, COB_DASH) == 0) {
2641  if (cobc_seen_stdin == 0) {
2642  cobc_seen_stdin = 1;
2643  file_is_stdin = 1;
2645  } else {
2646  cobc_abort_pr (_("Only one stdin input allowed"));
2647  return NULL;
2648  }
2649  } else {
2650  file_is_stdin = 0;
2651  }
2652 
2653  fsize = strlen (filename);
2654  if (fsize > COB_NORMAL_MAX) {
2655  cobc_abort_pr (_("Invalid file name parameter"));
2656  return NULL;
2657  }
2658 
2659 #ifdef __OS400__
2660  if (strchr (filename, '.') != NULL) {
2661 #endif
2662 
2663  if (!file_is_stdin && access (filename, R_OK) != 0) {
2665  }
2666 
2667 #ifdef __OS400__
2668  }
2669 #endif
2670 
2671  fbasename = file_basename (filename);
2672  extension = file_extension (filename);
2673  if (strcmp(extension, "lib") && strcmp(extension, "a") &&
2674  strcmp(extension, COB_OBJECT_EXT)) {
2675  if (cobc_check_valid_name (fbasename, 0)) {
2676  return NULL;
2677  }
2678  }
2679  fn = cobc_main_malloc (sizeof (struct filename));
2680  fn->need_preprocess = 1;
2681  fn->need_translate = 1;
2682  fn->need_assemble = 1;
2684  fn->next = NULL;
2685 
2686  if (!file_list) {
2687  file_list = fn;
2688  } else {
2689  for (ffn = file_list; ffn->next; ffn = ffn->next)
2690  ;
2691  ffn->next = fn;
2692  }
2693 
2694  fn->demangle_source = cb_encode_program_id (fbasename);
2695 
2696  /* Check input file type */
2697  if (strcmp (extension, "i") == 0) {
2698  /* Already preprocessed */
2699  fn->need_preprocess = 0;
2700  } else if (strcmp (extension, "c") == 0 ||
2701  strcmp (extension, "s") == 0) {
2702  /* Already compiled */
2703  fn->need_preprocess = 0;
2704  fn->need_translate = 0;
2705  }
2706  else if (
2707 #if defined(__OS400__)
2708  extension[0] == 0
2709 #else
2710  strcmp (extension, COB_OBJECT_EXT) == 0
2711 #if defined(_WIN32)
2712  || strcmp(extension, "lib") == 0
2713 #endif
2714 #if !defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__)
2715  || strcmp(extension, "a") == 0
2716  || strcmp(extension, "so") == 0
2717  || strcmp(extension, "dylib") == 0
2718  || strcmp(extension, "sl") == 0
2719 #endif
2720 #endif
2721  ) {
2722  /* Already assembled */
2723  fn->need_preprocess = 0;
2724  fn->need_translate = 0;
2725  fn->need_assemble = 0;
2726  }
2727 
2728  /* Set source filename */
2730 
2731  /* Set preprocess filename */
2732  if (!fn->need_preprocess) {
2733  fn->preprocess = cobc_main_strdup (fn->source);
2736  } else if (save_all_src || save_temps ||
2738  fn->preprocess = cobc_stradd_dup (fbasename, ".i");
2739  } else {
2741  cob_temp_name ((char *)fn->preprocess, ".cob");
2742  }
2743 
2744  /* Set translate filename */
2745  if (!fn->need_translate) {
2746  fn->translate = cobc_main_strdup (fn->source);
2747  } else if (output_name && cb_compile_level == CB_LEVEL_TRANSLATE) {
2749  } else if (save_all_src || save_temps || save_c_src ||
2751  fn->translate = cobc_stradd_dup (fbasename, ".c");
2752  } else {
2754  cob_temp_name ((char *)fn->translate, ".c");
2755  }
2756  fn->translate_len = strlen (fn->translate);
2757 
2758  /* Set storage filename */
2759  if (fn->need_translate) {
2760  fn->trstorage = cobc_stradd_dup (fn->translate, ".h");
2761  }
2762 
2763  /* Set object filename */
2764  if (!fn->need_assemble) {
2765  fn->object = cobc_main_strdup (fn->source);
2766  } else if (output_name && cb_compile_level == CB_LEVEL_ASSEMBLE) {
2768  } else if (save_temps || cb_compile_level == CB_LEVEL_ASSEMBLE) {
2769  fn->object = cobc_stradd_dup(fbasename, "." COB_OBJECT_EXT);
2770  } else {
2772  cob_temp_name ((char *)fn->object, "." COB_OBJECT_EXT);
2773  }
2774  fn->object_len = strlen (fn->object);
2775  cobc_objects_len += fn->object_len + 8U;
2776 
2777  /* Set listing filename */
2778  if (cobc_gen_listing == 1) {
2779  if (cobc_list_file) {
2781  } else if (cobc_list_dir) {
2782  fsize = strlen (cobc_list_dir) + strlen (fbasename) + 8U;
2783  listptr = cobc_main_malloc (fsize);
2784  snprintf (listptr, fsize, "%s%c%s.lst",
2785  cobc_list_dir, SLASH_CHAR, fbasename);
2786  fn->listing_file = listptr;
2787  } else {
2788  fn->listing_file = cobc_stradd_dup (fbasename, ".lst");
2789  }
2790  } else if (cobc_gen_listing > 1) {
2791  fn->listing_file = cobc_stradd_dup (fbasename, ".xrf");
2792  }
2793 
2795  return fn;
2796 }
static size_t save_all_src
Definition: cobc.c:274
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static size_t cobc_objects_len
Definition: cobc.c:259
static char * cobc_stradd_dup(const char *str1, const char *str2)
Definition: cobc.c:1286
int cobc_seen_stdin
Definition: cobc.c:171
unsigned int need_assemble
Definition: cobc.h:209
const char * listing_file
Definition: cobc.h:203
static DECLNORET void COB_A_NORETURN cobc_terminate(const char *str)
Definition: cobc.c:1471
#define CB_LEVEL_ASSEMBLE
Definition: cobc.c:74
const char * preprocess
Definition: cobc.h:198
static char * cobc_list_file
Definition: cobc.c:251
if fold fold static computed alternate extra correct stack on syntax debugging source implicit stack syntax extension
Definition: flag.def:102
const char * demangle_source
Definition: cobc.h:202
unsigned int need_translate
Definition: cobc.h:208
unsigned int cobc_gen_listing
Definition: cobc.c:180
#define CB_LEVEL_TRANSLATE
Definition: cobc.c:72
static char * cobc_list_dir
Definition: cobc.c:250
const char * trstorage
Definition: cobc.h:200
static const char * file_extension(const char *filename)
Definition: cobc.c:2618
const char * source
Definition: cobc.h:197
#define _(s)
Definition: cobcrun.c:59
size_t object_len
Definition: cobc.h:206
#define COB_DASH
Definition: cobc.h:121
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
size_t translate_len
Definition: cobc.h:205
static char * file_basename(const char *filename)
Definition: cobc.c:2573
#define SLASH_CHAR
Definition: common.h:505
#define COB_DASH_NAME
Definition: cobc.h:122
#define COB_NORMAL_MAX
Definition: common.h:547
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720
static size_t save_c_src
Definition: cobc.c:275
static char * output_name
Definition: cobc.c:253
char * cb_encode_program_id(const char *)
Definition: typeck.c:1132
int file_is_stdin
Definition: cobc.h:211
struct filename * next
Definition: cobc.h:196
void cob_incr_temp_iteration(void)
Definition: common.c:3266
#define CB_LEVEL_PREPROCESS
Definition: cobc.c:71
static size_t save_temps
Definition: cobc.c:273
#define R_OK
Definition: cobc.h:58
size_t cobc_check_valid_name(const char *name, const unsigned int prechk)
Definition: cobc.c:1142
unsigned int need_preprocess
Definition: cobc.h:207
Definition: cobc.h:195
const char * translate
Definition: cobc.h:199
#define COB_FILE_MAX
Definition: common.h:548
const char * object
Definition: cobc.h:201
static unsigned int cb_compile_level
Definition: cobc.c:265
#define COB_OBJECT_EXT
Definition: defaults.h:10
void cob_temp_name(char *filename, const char *ext)
Definition: common.c:3253

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_library ( struct filename l)
static

Definition at line 3913 of file cobc.c.

References _, COB_EXPORT_DYN, COB_MODULE_EXT, COB_PIC_FLAGS, COB_SHARED_OPT, COB_STRIP_CMD, COBC_ABORT, cobc_abort_pr(), cobc_buffer, cobc_cc, cobc_cc_len, cobc_check_action(), cobc_chk_buff_size(), cobc_export_dyn_len, cobc_flag_run, cobc_ldflags, cobc_ldflags_len, cobc_lib_paths, cobc_lib_paths_len, cobc_libs, cobc_libs_len, cobc_objects_buffer, cobc_objects_len, cobc_pic_flags_len, cobc_shared_opt_len, cobc_stradd_dup(), file_basename(), gflag_set, filename::next, NULL, filename::object, output_name, output_name_buff, process(), process_run(), filename::source, strip_output, and verbose_output.

Referenced by main().

3914 {
3915  struct filename *f;
3916  char *name;
3917 #ifdef _MSC_VER
3918  char *exename;
3919 #endif
3920  size_t bufflen;
3921  size_t size;
3922  int ret;
3923 
3924  if (!l) {
3925  cobc_abort_pr (_("Call to '%s' with invalid parameter '%s'"),
3926  "process_library", "l");
3927  COBC_ABORT ();
3928  }
3929 
3930  for (f = l; f; f = f->next) {
3931  strcat (cobc_objects_buffer, "\"");
3932  strcat (cobc_objects_buffer, f->object);
3933  strcat (cobc_objects_buffer, "\" ");
3934  }
3935 
3936  if (output_name) {
3937  name = output_name_buff;
3938  strcpy (name, output_name);
3939 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3940  file_stripext (name);
3941 #else
3942  if (strchr (output_name, '.') == NULL) {
3943  strcat (name, ".");
3944  strcat (name, COB_MODULE_EXT);
3945  }
3946 #endif
3947  } else {
3948  name = file_basename (l->source);
3949 #if !defined(_MSC_VER) && !defined(__OS400__) && !defined(__WATCOMC__) && !defined(__BORLANDC__)
3950  strcat (name, ".");
3951  strcat (name, COB_MODULE_EXT);
3952 #endif
3953  }
3954 #ifdef _MSC_VER
3955  exename = cobc_stradd_dup (name, ".dll");
3956 #endif
3957 
3958  size = strlen (name);
3959  bufflen = cobc_cc_len + cobc_ldflags_len
3961  + size + cobc_objects_len + cobc_libs_len
3962 #ifdef _MSC_VER
3963  + manilink_len
3964 #endif
3966 
3967  cobc_chk_buff_size (bufflen);
3968 
3969 #ifdef _MSC_VER
3970  sprintf (cobc_buffer, gflag_set ?
3971  "%s /Od /MDd /LDd /Zi /FR /Fe\"%s\" %s %s %s %s %s" :
3972  "%s /MD /LD /Fe\"%s\" %s %s %s %s %s",
3973  cobc_cc, exename, cobc_objects_buffer,
3974  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3975  if (verbose_output) {
3976  ret = process (cobc_buffer);
3977  } else {
3978  ret = process_filtered (cobc_buffer, l);
3979  }
3980 #if defined(_MSC_VER) && COB_USE_VC2005_OR_GREATER
3981  /* Embedding manifest */
3982  if (ret == 0) {
3983  sprintf (cobc_buffer,
3984  "%s /manifest \"%s.manifest\" /outputresource:\"%s\";#2",
3985  manicmd, exename, exename);
3986  ret = process (cobc_buffer);
3987  sprintf (cobc_buffer, "%s.manifest", exename);
3989  }
3990 #endif
3991  sprintf (cobc_buffer, "%s.exp", name);
3993  sprintf (cobc_buffer, "%s.lib", name);
3994 
3995  for (f = l; f; f = f->next) {
3996  if (strstr (f->source, cobc_buffer) != NULL) {
3997  break;
3998  }
3999  }
4000  if (!f) cobc_check_action (cobc_buffer);
4001 #else /* _MSC_VER */
4002 #ifdef __WATCOMC__
4003  sprintf (cobc_buffer, "%s %s %s %s -fe=\"%s\" %s %s %s %s",
4007 #else
4008  sprintf (cobc_buffer, "%s %s %s %s -o \"%s\" %s %s %s %s",
4012 #endif
4013  ret = process (cobc_buffer);
4014 #ifdef COB_STRIP_CMD
4015  if (strip_output && ret == 0) {
4016  sprintf (cobc_buffer, "%s \"%s\"", COB_STRIP_CMD, name);
4017  ret = process (cobc_buffer);
4018  }
4019 #endif
4020 #endif /* _MSC_VER */
4021  /* cobcrun job? */
4022  if ((ret == 0) && cobc_flag_run) {
4023  ret = process_run (name);
4024  }
4025  return ret;
4026 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static size_t cobc_objects_len
Definition: cobc.c:259
static char * cobc_stradd_dup(const char *str1, const char *str2)
Definition: cobc.c:1286
static size_t gflag_set
Definition: cobc.c:289
static char * cobc_libs
Definition: cobc.c:226
static char * cobc_objects_buffer
Definition: cobc.c:255
static int process_run(const char *name)
-j run job after build
Definition: cobc.c:2836
static size_t cobc_cc_len
Definition: cobc.c:237
#define COB_MODULE_EXT
Definition: defaults.h:9
#define COB_PIC_FLAGS
Definition: config.h:32
static char * cobc_ldflags
Definition: cobc.c:229
static char * cobc_buffer
Definition: cobc.c:254
static int process(const char *cmd)
Definition: cobc.c:3201
const char * source
Definition: cobc.h:197
#define _(s)
Definition: cobcrun.c:59
static const char * cobc_cc
Definition: cobc.c:224
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
#define COBC_ABORT()
Definition: cobc.h:61
static char * file_basename(const char *filename)
Definition: cobc.c:2573
static char * cobc_lib_paths
Definition: cobc.c:227
static size_t cobc_libs_len
Definition: cobc.c:239
static void cobc_check_action(const char *name)
Definition: cobc.c:1355
static char * output_name
Definition: cobc.c:253
static size_t cobc_flag_run
Definition: cobc.c:272
struct filename * next
Definition: cobc.h:196
static size_t strip_output
Definition: cobc.c:288
static size_t cobc_export_dyn_len
Definition: cobc.c:243
Definition: cobc.h:195
static size_t cobc_lib_paths_len
Definition: cobc.c:240
static size_t cobc_shared_opt_len
Definition: cobc.c:244
#define COB_EXPORT_DYN
Definition: config.h:14
#define COB_STRIP_CMD
Definition: config.h:41
const char * object
Definition: cobc.h:201
static char * output_name_buff
Definition: cobc.c:256
#define COB_SHARED_OPT
Definition: config.h:35
static size_t cobc_ldflags_len
Definition: cobc.c:242
static void cobc_chk_buff_size(const size_t bufflen)
Definition: cobc.c:1182
static size_t cobc_pic_flags_len
Definition: cobc.c:245

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_link ( struct filename l)
static

Definition at line 4031 of file cobc.c.

References _, COB_DASH_OUT, COB_EXEEXT, COB_EXPORT_DYN, COB_STRIP_CMD, COBC_ABORT, cobc_abort_pr(), cobc_buffer, cobc_cc, cobc_cc_len, cobc_check_action(), cobc_chk_buff_size(), cobc_export_dyn_len, cobc_flag_run, cobc_ldflags, cobc_ldflags_len, cobc_lib_paths, cobc_lib_paths_len, cobc_libs, cobc_libs_len, cobc_main_strdup(), cobc_objects_buffer, cobc_objects_len, cobc_stradd_dup(), file_basename(), filename::file_is_stdin, gflag_set, filename::next, filename::object, output_name, process(), process_run(), filename::source, strip_output, and verbose_output.

Referenced by main().

4032 {
4033  struct filename *f;
4034  const char *name;
4035 #ifdef _MSC_VER
4036  const char *exename;
4037 #endif
4038  size_t bufflen;
4039  size_t size;
4040  int ret;
4041 
4042  if (!l) {
4043  cobc_abort_pr (_("Call to '%s' with invalid parameter '%s'"),
4044  "process_link", "l");
4045  COBC_ABORT ();
4046  }
4047 
4048  for (f = l; f; f = f->next) {
4049 #ifdef __OS400__
4050  file_stripext ((char *) f->object);
4051  strcat (cobc_objects_buffer, f->object);
4052  strcat (cobc_objects_buffer, " ");
4053 #else
4054  strcat (cobc_objects_buffer, "\"");
4055  strcat (cobc_objects_buffer, f->object);
4056  strcat (cobc_objects_buffer, "\" ");
4057 #endif
4058  }
4059 
4060  if (output_name) {
4061 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
4062  name = cobc_main_strdup (output_name);
4063  file_stripext ((char *)name);
4064 #else
4065  name = output_name;
4066 #endif
4067  } else {
4068  if (l->file_is_stdin) {
4069  name = COB_DASH_OUT;
4070  } else {
4071  name = file_basename (l->source);
4072  }
4073  }
4074 #ifdef _MSC_VER
4075  exename = cobc_stradd_dup (name, ".exe");
4076 #endif
4077 
4078  size = strlen (name);
4079  bufflen = cobc_cc_len + cobc_ldflags_len
4080  + cobc_export_dyn_len + size
4082 #ifdef _MSC_VER
4083  + manilink_len
4084 #endif
4085  + cobc_lib_paths_len + 64U;
4086 
4087  cobc_chk_buff_size (bufflen);
4088 
4089 #ifdef _MSC_VER
4090  sprintf (cobc_buffer, gflag_set ?
4091  "%s /Od /MDd /Zi /FR /Fe\"%s\" %s %s %s %s %s" :
4092  "%s /MD /Fe\"%s\" %s %s %s %s %s",
4093  cobc_cc, exename, cobc_objects_buffer,
4094  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
4095  if (verbose_output) {
4096  ret = process (cobc_buffer);
4097  } else {
4098  ret = process_filtered (cobc_buffer, l);
4099  }
4100 #if defined(_MSC_VER) && COB_USE_VC2005_OR_GREATER
4101  /* Embedding manifest */
4102  if (ret == 0) {
4103  sprintf (cobc_buffer,
4104  "%s /manifest \"%s.manifest\" /outputresource:\"%s\";#1",
4105  manicmd, exename, exename);
4106  ret = process (cobc_buffer);
4107  sprintf (cobc_buffer, "%s.manifest", exename);
4109  }
4110 #endif
4111 #else /* _MSC_VER */
4112 #ifdef __WATCOMC__
4113  sprintf (cobc_buffer, "%s %s -fe=\"%s\" %s %s %s %s",
4116 #else
4117  sprintf (cobc_buffer, "%s %s -o \"%s\" %s %s %s %s",
4120 #endif
4121 
4122  ret = process (cobc_buffer);
4123 
4124 #ifdef __hpux
4125  if (ret == 0) {
4126  sprintf (cobc_buffer, "chatr -s +s enable \"%s%s\" 1>/dev/null 2>&1",
4127  name, COB_EXEEXT);
4128  process (cobc_buffer);
4129  }
4130 #endif
4131 
4132 #ifdef COB_STRIP_CMD
4133  if (strip_output && ret == 0) {
4134  sprintf (cobc_buffer, "%s \"%s%s\"",
4135  COB_STRIP_CMD, name, COB_EXEEXT);
4136  ret = process (cobc_buffer);
4137  }
4138 #endif
4139 
4140 #endif /* _MSC_VER */
4141 
4142  /* run job? */
4143  if ((ret == 0) && cobc_flag_run) {
4144  ret = process_run (name);
4145  }
4146  return ret;
4147 }
void cobc_abort_pr(const char *fmt,...)
Definition: cobc.c:587
static size_t cobc_objects_len
Definition: cobc.c:259
static char * cobc_stradd_dup(const char *str1, const char *str2)
Definition: cobc.c:1286
static size_t gflag_set
Definition: cobc.c:289
static char * cobc_libs
Definition: cobc.c:226
static char * cobc_objects_buffer
Definition: cobc.c:255
static int process_run(const char *name)
-j run job after build
Definition: cobc.c:2836
static size_t cobc_cc_len
Definition: cobc.c:237
static char * cobc_ldflags
Definition: cobc.c:229
static char * cobc_buffer
Definition: cobc.c:254
static int process(const char *cmd)
Definition: cobc.c:3201
const char * source
Definition: cobc.h:197
#define _(s)
Definition: cobcrun.c:59
static const char * cobc_cc
Definition: cobc.c:224
static size_t verbose_output
Definition: cobc.c:276
#define COBC_ABORT()
Definition: cobc.h:61
static char * file_basename(const char *filename)
Definition: cobc.c:2573
static char * cobc_lib_paths
Definition: cobc.c:227
static size_t cobc_libs_len
Definition: cobc.c:239
void * cobc_main_strdup(const char *dupstr)
Definition: cobc.c:720
static void cobc_check_action(const char *name)
Definition: cobc.c:1355
static char * output_name
Definition: cobc.c:253
int file_is_stdin
Definition: cobc.h:211
static size_t cobc_flag_run
Definition: cobc.c:272
struct filename * next
Definition: cobc.h:196
static size_t strip_output
Definition: cobc.c:288
#define COB_DASH_OUT
Definition: cobc.h:123
#define COB_EXEEXT
Definition: config.h:8
static size_t cobc_export_dyn_len
Definition: cobc.c:243
Definition: cobc.h:195
static size_t cobc_lib_paths_len
Definition: cobc.c:240
#define COB_EXPORT_DYN
Definition: config.h:14
#define COB_STRIP_CMD
Definition: config.h:41
const char * object
Definition: cobc.h:201
static size_t cobc_ldflags_len
Definition: cobc.c:242
static void cobc_chk_buff_size(const size_t bufflen)
Definition: cobc.c:1182

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_module ( struct filename fn)
static

Definition at line 3814 of file cobc.c.

References COB_EXPORT_DYN, COB_MODULE_EXT, COB_PIC_FLAGS, COB_SHARED_OPT, COB_STRIP_CMD, cobc_buffer, cobc_cc, cobc_cc_len, cobc_check_action(), cobc_chk_buff_size(), cobc_export_dyn_len, cobc_flag_run, cobc_ldflags, cobc_ldflags_len, cobc_lib_paths, cobc_lib_paths_len, cobc_libs, cobc_libs_len, cobc_pic_flags_len, cobc_shared_opt_len, cobc_stradd_dup(), file_basename(), gflag_set, NULL, filename::object, filename::object_len, output_name, output_name_buff, process(), process_run(), filename::source, strip_output, and verbose_output.

Referenced by main().

3815 {
3816  char *name;
3817 #ifdef _MSC_VER
3818  char *exename;
3819 #endif
3820  size_t bufflen;
3821  size_t size;
3822  int ret;
3823 
3824  if (output_name) {
3825  name = output_name_buff;
3826  strcpy (name, output_name);
3827 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3828  file_stripext (name);
3829 #else
3830  if (strchr (output_name, '.') == NULL) {
3831  strcat (name, ".");
3832  strcat (name, COB_MODULE_EXT);
3833  }
3834 #endif
3835  } else {
3836  name = file_basename (fn->source);
3837 #if !defined(_MSC_VER) && !defined(__OS400__) && !defined(__WATCOMC__) &&! defined(__BORLANDC__)
3838  strcat (name, ".");
3839  strcat (name, COB_MODULE_EXT);
3840 #endif
3841  }
3842 #ifdef _MSC_VER
3843  exename = cobc_stradd_dup (name, ".dll");
3844 #endif
3845 
3846  size = strlen (name);
3847  bufflen = cobc_cc_len + cobc_ldflags_len
3849  + size + fn->object_len + cobc_libs_len
3850 #ifdef _MSC_VER
3851  + manilink_len
3852 #endif
3854 
3855  cobc_chk_buff_size (bufflen);
3856 
3857 #ifdef _MSC_VER
3858  sprintf (cobc_buffer, gflag_set ?
3859  "%s /Od /MDd /LDd /Zi /FR /Fe\"%s\" \"%s\" %s %s %s %s" :
3860  "%s /MD /LD /Fe\"%s\" \"%s\" %s %s %s %s",
3861  cobc_cc, exename, fn->object,
3862  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3863  if (verbose_output) {
3864  ret = process (cobc_buffer);
3865  } else {
3866  ret = process_filtered (cobc_buffer, fn);
3867  }
3868 #if defined(_MSC_VER) && COB_USE_VC2005_OR_GREATER
3869  /* Embedding manifest */
3870  if (ret == 0) {
3871  sprintf (cobc_buffer,
3872  "%s /manifest \"%s.manifest\" /outputresource:\"%s\";#2",
3873  manicmd, exename, exename);
3874  ret = process (cobc_buffer);
3875  sprintf (cobc_buffer, "%s.manifest", exename);
3877  }
3878 #endif
3879  sprintf (cobc_buffer, "%s.exp", name);
3881  sprintf (cobc_buffer, "%s.lib", name);
3882  if (strstr(fn->source, cobc_buffer) == NULL) cobc_check_action (cobc_buffer);
3883  sprintf (cobc_buffer, "%s.obj", name);
3884  if (strstr(fn->source, cobc_buffer) == NULL) cobc_check_action (cobc_buffer);
3885 #else /* _MSC_VER */
3886 #ifdef __WATCOMC__
3887  sprintf (cobc_buffer, "%s %s %s %s -fe=\"%s\" \"%s\" %s %s %s",
3890 #else
3891  sprintf (cobc_buffer, "%s %s %s %s -o \"%s\" \"%s\" %s %s %s",
3894 #endif
3895  ret = process (cobc_buffer);
3896 #ifdef COB_STRIP_CMD
3897  if (strip_output && ret == 0) {
3898  sprintf (cobc_buffer, "%s %s", COB_STRIP_CMD, name);
3899  ret = process (cobc_buffer);
3900  }
3901 #endif
3902 #endif /* _MSC_VER */
3903  /* cobcrun job? */
3904  if ((ret == 0) && cobc_flag_run) {
3905  ret = process_run (name);
3906  }
3907  return ret;
3908 }
static char * cobc_stradd_dup(const char *str1, const char *str2)
Definition: cobc.c:1286
static size_t gflag_set
Definition: cobc.c:289
static char * cobc_libs
Definition: cobc.c:226
static int process_run(const char *name)
-j run job after build
Definition: cobc.c:2836
static size_t cobc_cc_len
Definition: cobc.c:237
#define COB_MODULE_EXT
Definition: defaults.h:9
#define COB_PIC_FLAGS
Definition: config.h:32
static char * cobc_ldflags
Definition: cobc.c:229
static char * cobc_buffer
Definition: cobc.c:254
static int process(const char *cmd)
Definition: cobc.c:3201
const char * source
Definition: cobc.h:197
size_t object_len
Definition: cobc.h:206
static const char * cobc_cc
Definition: cobc.c:224
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
static char * file_basename(const char *filename)
Definition: cobc.c:2573
static char * cobc_lib_paths
Definition: cobc.c:227
static size_t cobc_libs_len
Definition: cobc.c:239
static void cobc_check_action(const char *name)
Definition: cobc.c:1355
static char * output_name
Definition: cobc.c:253
static size_t cobc_flag_run
Definition: cobc.c:272
static size_t strip_output
Definition: cobc.c:288
static size_t cobc_export_dyn_len
Definition: cobc.c:243
static size_t cobc_lib_paths_len
Definition: cobc.c:240
static size_t cobc_shared_opt_len
Definition: cobc.c:244
#define COB_EXPORT_DYN
Definition: config.h:14
#define COB_STRIP_CMD
Definition: config.h:41
const char * object
Definition: cobc.h:201
static char * output_name_buff
Definition: cobc.c:256
#define COB_SHARED_OPT
Definition: config.h:35
static size_t cobc_ldflags_len
Definition: cobc.c:242
static void cobc_chk_buff_size(const size_t bufflen)
Definition: cobc.c:1182
static size_t cobc_pic_flags_len
Definition: cobc.c:245

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_module_direct ( struct filename fn)
static

Definition at line 3696 of file cobc.c.

References COB_EXPORT_DYN, COB_LARGE_BUFF, COB_MODULE_EXT, COB_OBJECT_EXT, COB_PIC_FLAGS, COB_SHARED_OPT, COB_STRIP_CMD, cobc_buffer, cobc_cc, cobc_cc_len, cobc_cflags, cobc_cflags_len, cobc_check_action(), cobc_chk_buff_size(), cobc_export_dyn_len, cobc_flag_run, cobc_include, cobc_include_len, cobc_ldflags, cobc_ldflags_len, cobc_lib_paths, cobc_lib_paths_len, cobc_libs, cobc_libs_len, cobc_main_malloc(), cobc_pic_flags_len, cobc_shared_opt_len, cobc_stradd_dup(), file_basename(), gflag_set, NULL, output_name, output_name_buff, process(), process_run(), filename::source, strip_output, filename::translate, filename::translate_len, and verbose_output.

Referenced by main().

3697 {
3698  char *name;
3699 #ifdef _MSC_VER
3700  char *exename;
3701 #endif
3702  size_t bufflen;
3703  size_t size;
3704  int ret;
3705 
3706  if (output_name) {
3707  name = output_name_buff;
3708  strcpy (name, output_name);
3709 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3710  file_stripext (name);
3711 #else
3712  if (strchr (output_name, '.') == NULL) {
3713  strcat (name, ".");
3714  strcat (name, COB_MODULE_EXT);
3715  }
3716 #endif
3717  } else {
3718  name = file_basename (fn->source);
3719 #if !defined(_MSC_VER) && !defined(__OS400__) && !defined(__WATCOMC__) && !defined(__BORLANDC__)
3720  strcat (name, ".");
3721  strcat (name, COB_MODULE_EXT);
3722 #endif
3723  }
3724 #ifdef _MSC_VER
3725  exename = cobc_stradd_dup (name, ".dll");
3726 #endif
3727 
3728  size = strlen (name);
3729 #ifdef _MSC_VER
3730  size *= 2U;
3731 #endif
3732 
3733  bufflen = cobc_cc_len + cobc_cflags_len
3735  + size + fn->translate_len
3737 #ifdef _MSC_VER
3738  + manilink_len
3739 #endif
3741 
3742  cobc_chk_buff_size (bufflen);
3743 
3744 #ifdef _MSC_VER
3745  sprintf (cobc_buffer, gflag_set ?
3746  "%s %s %s /Od /MDd /LDd /Zi /FR /Fe\"%s\" /Fo\"%s\" \"%s\" %s %s %s %s" :
3747  "%s %s %s /MD /LD /Fe\"%s\" /Fo\"%s\" \"%s\" %s %s %s %s",
3748  cobc_cc, cobc_cflags, cobc_include, exename, name,
3749  fn->translate,
3750  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3751  if (verbose_output) {
3752  ret = process (cobc_buffer);
3753  } else {
3754  ret = process_filtered (cobc_buffer, fn);
3755  }
3756 #if defined(_MSC_VER) && COB_USE_VC2005_OR_GREATER
3757  /* Embedding manifest */
3758  if (ret == 0) {
3759  sprintf (cobc_buffer,
3760  "%s /manifest \"%s.manifest\" /outputresource:\"%s\";#2",
3761  manicmd, exename, exename);
3762  ret = process (cobc_buffer);
3763  sprintf (cobc_buffer, "%s.manifest", exename);
3765  }
3766 #endif
3767  sprintf (cobc_buffer, "%s.exp", name);
3769  sprintf (cobc_buffer, "%s.lib", name);
3770  if (strstr(fn->source, cobc_buffer) == NULL) cobc_check_action (cobc_buffer);
3771  sprintf (cobc_buffer, "%s.%s", name, COB_OBJECT_EXT);
3772  if (strstr(fn->source, cobc_buffer) == NULL) cobc_check_action (cobc_buffer);
3773 #else /* _MSC_VER */
3774 #ifdef __OS400__
3775  if (fn->translate[0] != '/') {
3776  char *p;
3777 
3779  getcwd (p, COB_LARGE_BUFF);
3780  strcat (p, "/");
3781  strcat (p, fn->translate);
3782  fn->translate = p;
3783  fn->translate_len = strlen (p);
3784  }
3785 #endif
3786 #ifdef __WATCOMC__
3787  sprintf (cobc_buffer, "%s %s %s %s %s %s -fe=\"%s\" \"%s\" %s %s %s",
3791 #else
3792  sprintf (cobc_buffer, "%s %s %s %s %s %s -o \"%s\" \"%s\" %s %s %s",
3796 #endif
3797  ret = process (cobc_buffer);
3798 #ifdef COB_STRIP_CMD
3799  if (strip_output && ret == 0) {
3800  sprintf (cobc_buffer, "%s \"%s\"", COB_STRIP_CMD, name);
3801  ret = process (cobc_buffer);
3802  }
3803 #endif
3804 #endif /* _MSC_VER */
3805  if ((ret == 0) && cobc_flag_run) {
3806  ret = process_run (name);
3807  }
3808  return ret;
3809 }
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
static char * cobc_stradd_dup(const char *str1, const char *str2)
Definition: cobc.c:1286
static size_t cobc_cflags_len
Definition: cobc.c:238
static char * cobc_include
Definition: cobc.c:228
static size_t gflag_set
Definition: cobc.c:289
static char * cobc_libs
Definition: cobc.c:226
static int process_run(const char *name)
-j run job after build
Definition: cobc.c:2836
static size_t cobc_cc_len
Definition: cobc.c:237
#define COB_MODULE_EXT
Definition: defaults.h:9
#define COB_LARGE_BUFF
Definition: common.h:544
#define COB_PIC_FLAGS
Definition: config.h:32
static char * cobc_ldflags
Definition: cobc.c:229
static char * cobc_buffer
Definition: cobc.c:254
static size_t cobc_include_len
Definition: cobc.c:241
static int process(const char *cmd)
Definition: cobc.c:3201
const char * source
Definition: cobc.h:197
static const char * cobc_cc
Definition: cobc.c:224
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
size_t translate_len
Definition: cobc.h:205
static char * file_basename(const char *filename)
Definition: cobc.c:2573
static char * cobc_lib_paths
Definition: cobc.c:227
static size_t cobc_libs_len
Definition: cobc.c:239
static void cobc_check_action(const char *name)
Definition: cobc.c:1355
static char * output_name
Definition: cobc.c:253
static size_t cobc_flag_run
Definition: cobc.c:272
static char * cobc_cflags
Definition: cobc.c:225
static size_t strip_output
Definition: cobc.c:288
static size_t cobc_export_dyn_len
Definition: cobc.c:243
const char * translate
Definition: cobc.h:199
static size_t cobc_lib_paths_len
Definition: cobc.c:240
static size_t cobc_shared_opt_len
Definition: cobc.c:244
#define COB_EXPORT_DYN
Definition: config.h:14
#define COB_STRIP_CMD
Definition: config.h:41
static char * output_name_buff
Definition: cobc.c:256
#define COB_SHARED_OPT
Definition: config.h:35
#define COB_OBJECT_EXT
Definition: defaults.h:10
static size_t cobc_ldflags_len
Definition: cobc.c:242
static void cobc_chk_buff_size(const size_t bufflen)
Definition: cobc.c:1182
static size_t cobc_pic_flags_len
Definition: cobc.c:245

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_run ( const char *  name)
static

-j run job after build

Definition at line 2836 of file cobc.c.

References _, cb_compile_level, CB_LEVEL_LIBRARY, CB_LEVEL_MODULE, cobc_buffer, cobc_buffer_size, cobc_cmd_print(), file_basename(), SLASH_CHAR, and verbose_output.

Referenced by process_assemble(), process_library(), process_link(), process_module(), and process_module_direct().

2836  {
2837  int ret;
2838 
2840  fputs (_("Nothing for -j to run"), stderr);
2841  fflush (stderr);
2842  return 0;
2843  }
2844 
2847  snprintf (cobc_buffer, cobc_buffer_size, "cobcrun %s",
2848  file_basename(name));
2849  } else { /* executable */
2850  snprintf (cobc_buffer, cobc_buffer_size, ".%c%s",
2851  SLASH_CHAR, name);
2852  }
2854  if (verbose_output) {
2856  }
2857  ret = system (cobc_buffer);
2858  if (verbose_output) {
2859  fputs (_("Return status:"), stderr);
2860  fprintf (stderr, "\t%d\n", ret);
2861  fflush (stderr);
2862  }
2863  return ret;
2864 }
#define CB_LEVEL_LIBRARY
Definition: cobc.c:76
static char * cobc_buffer
Definition: cobc.c:254
#define _(s)
Definition: cobcrun.c:59
static size_t verbose_output
Definition: cobc.c:276
static char * file_basename(const char *filename)
Definition: cobc.c:2573
#define SLASH_CHAR
Definition: common.h:505
static void cobc_cmd_print(const char *cmd)
Definition: cobc.c:1558
#define CB_LEVEL_MODULE
Definition: cobc.c:75
static size_t cobc_buffer_size
Definition: cobc.c:261
static unsigned int cb_compile_level
Definition: cobc.c:265

Here is the call graph for this function:

Here is the caller graph for this function:

static int process_translate ( struct filename fn)
static

Definition at line 3397 of file cobc.c.

References _, cb_init_constants(), cb_insert_common_prog(), cb_list_reverse(), cb_source_file, cb_source_line, cb_storage_file, cb_storage_file_name, COB_OPEN_EXTEND, COB_OPEN_INPUT, cobc_main_malloc(), cobc_terminate(), codegen(), cb_program::common_prog_list, current_program, cb_program::entry_list, errorcount, cb_label::flag_global, cb_program::global_file_list, cb_program::global_handler, handler_struct::handler_label, handler_struct::handler_prog, local_filename::local_fp, cb_program::local_include, local_filename::local_name, filename::localfile, cb_program::nested_level, nested_list::nested_prog, local_filename::next, nested_list::next, cb_program::next_program, NULL, filename::preprocess, program_list_reverse(), filename::source, filename::translate, filename::translate_len, filename::trstorage, unlikely, verbose_output, ylex_call_destroy(), yyin, yyout, and yyparse.

Referenced by main().

3398 {
3399  struct cb_program *p;
3400  struct cb_program *q;
3401  struct cb_program *r;
3402  struct nested_list *nlp;
3403  struct handler_struct *hstr1;
3404  struct handler_struct *hstr2;
3405  struct local_filename *lf;
3406  int ret;
3407  int i;
3408 
3409  /* Initialize */
3410  cb_source_file = NULL;
3411  cb_source_line = 0;
3412  errorcount = 0;
3413 
3414  /* Open the input file */
3415  yyin = fopen (fn->preprocess, "r");
3416  if (!yyin) {
3417  cobc_terminate (fn->preprocess);
3418  }
3419 
3420  if (verbose_output) {
3421  fputs (_("Parsing:"), stderr);
3422  fprintf (stderr, "\t%s (%s)\n", fn->preprocess, fn->source);
3423  fflush (stderr);
3424  }
3425 
3427  cb_init_constants ();
3428 
3429  /* Parse */
3430  ret = yyparse ();
3431 
3432  fclose (yyin);
3433  yyin = NULL;
3434 
3435  /* Release flex buffers - After file close */
3436  ylex_call_destroy ();
3437 
3438  if (verbose_output) {
3439  fputs (_("Return status:"), stderr);
3440  fprintf (stderr, "\t%d\n", ret);
3441  fflush (stderr);
3442  }
3443 
3444  if (ret || cb_flag_syntax_only) {
3445  return !!ret;
3446  }
3448  return 0;
3449  }
3450 
3451  /* Set up USE GLOBAL handlers */
3452  p = current_program;
3453  for (q = p; q; q = q->next_program) {
3455  if (q->nested_level) {
3456  for (r = q->next_program; r; r = r->next_program) {
3457  if (r->nested_level >= q->nested_level) {
3458  continue;
3459  }
3460  for (i = COB_OPEN_INPUT; i <= COB_OPEN_EXTEND; ++i) {
3461  hstr1 = &q->global_handler[i];
3462  hstr2 = &r->global_handler[i];
3463  if (!hstr1->handler_label &&
3464  hstr2->handler_label &&
3465  hstr2->handler_label->flag_global) {
3466  hstr1->handler_label = hstr2->handler_label;
3467  hstr1->handler_prog = r;
3468  }
3469  }
3470  if (!r->nested_level) {
3471  break;
3472  }
3473  }
3474  }
3475  }
3476 
3477  if (verbose_output) {
3478  fputs (_("Translating:"), stderr);
3479  fprintf (stderr, "\t%s -> %s (%s)\n",
3480  fn->preprocess, fn->translate, fn->source);
3481  fflush (stderr);
3482  }
3483 
3484  /* Open the output file */
3485  yyout = fopen (fn->translate, "w");
3486  if (!yyout) {
3487  cobc_terminate (fn->translate);
3488  }
3489 
3490  /* Open the common storage file */
3492  cb_storage_file = fopen (cb_storage_file_name, "w");
3493  if (!cb_storage_file) {
3495  }
3496 
3498 
3499  /* Set up local storage files */
3500  lf = NULL;
3501  ret = 1;
3502  for (q = p; q; q = q->next_program, ret++) {
3503  lf = cobc_main_malloc (sizeof(struct local_filename));
3504  lf->local_name = cobc_main_malloc (fn->translate_len + 12U);
3505  if (q == p && !q->next_program) {
3506  sprintf (lf->local_name, "%s.l.h", fn->translate);
3507  } else {
3508  sprintf (lf->local_name, "%s.l%d.h", fn->translate, ret);
3509  }
3510  lf->local_fp = fopen (lf->local_name, "w");
3511  if (!lf->local_fp) {
3512  cobc_terminate (lf->local_name);
3513  }
3514  q->local_include = lf;
3515  lf->next = fn->localfile;
3516  fn->localfile = lf;
3517  }
3518 
3519  /* Entries for COMMON programs */
3520  for (q = p; q; q = q->next_program) {
3521  i = q->nested_level;
3522  for (nlp = q->common_prog_list; nlp; nlp = nlp->next) {
3523  for (r = q->next_program; r; r = r->next_program) {
3524  if (r->nested_level <= i) {
3525  break;
3526  }
3528  }
3529  }
3530  }
3531 
3532  errorcount = 0;
3533  /* Translate to C */
3534  codegen (p, 0);
3535 
3536  /* Close files */
3537  if(unlikely(fclose (cb_storage_file) != 0)) {
3539  }
3541  if(unlikely(fclose (yyout) != 0)) {
3542  cobc_terminate (fn->translate);
3543  }
3544  yyout = NULL;
3545  for (q = p; q; q = q->next_program) {
3546  if (unlikely(!q->local_include->local_fp)) {
3547  continue;
3548  }
3549  if (unlikely(fclose (q->local_include->local_fp) != 0)) {
3551  }
3552  q->local_include->local_fp = NULL;
3553  }
3554  return !!errorcount;
3555 }
struct cb_label * handler_label
Definition: tree.h:805
void ylex_call_destroy(void)
Definition: scanner.c:4757
void * cobc_main_malloc(const size_t size)
Definition: cobc.c:702
const char * cb_source_file
Definition: cobc.c:145
FILE * cb_storage_file
Definition: cobc.c:156
void codegen(struct cb_program *prog, const int nested)
Definition: codegen.c:7448
unsigned int flag_global
Definition: tree.h:782
cb_tree global_file_list
Definition: tree.h:1282
const char * cb_storage_file_name
Definition: cobc.c:148
static DECLNORET void COB_A_NORETURN cobc_terminate(const char *str)
Definition: cobc.c:1471
const char * preprocess
Definition: cobc.h:198
int nested_level
Definition: tree.h:1295
struct nested_list * next
Definition: tree.h:1234
struct local_filename * local_include
Definition: tree.h:1248
#define yyout
Definition: pplex.c:20
const char * trstorage
Definition: cobc.h:200
struct local_filename * localfile
Definition: cobc.h:204
struct cb_program * nested_prog
Definition: tree.h:1235
const char * source
Definition: cobc.h:197
#define _(s)
Definition: cobcrun.c:59
#define COB_OPEN_EXTEND
Definition: common.h:787
#define COB_OPEN_INPUT
Definition: common.h:784
#define unlikely(x)
Definition: common.h:437
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static size_t verbose_output
Definition: cobc.c:276
size_t translate_len
Definition: cobc.h:205
struct cb_program * next_program
Definition: tree.h:1242
struct cb_program * handler_prog
Definition: tree.h:806
void cb_insert_common_prog(struct cb_program *prog, struct cb_program *comprog)
Definition: tree.c:1479
cb_tree entry_list
Definition: tree.h:1251
static struct cb_program * program_list_reverse(struct cb_program *p)
Definition: cobc.c:2512
struct cb_program * current_program
Definition: parser.c:168
struct nested_list * common_prog_list
Definition: tree.h:1250
struct handler_struct global_handler[5]
Definition: tree.h:1283
void cb_init_constants(void)
Definition: tree.c:1259
#define yyin
Definition: pplex.c:16
int cb_source_line
Definition: cobc.c:178
struct local_filename * next
Definition: cobc.h:189
cb_tree cb_list_reverse(cb_tree l)
Definition: tree.c:1327
const char * translate
Definition: cobc.h:199
FILE * local_fp
Definition: cobc.h:191
char * local_name
Definition: cobc.h:190
#define yyparse
Definition: ppparse.c:63
int errorcount
Definition: cobc.c:173

Here is the call graph for this function:

Here is the caller graph for this function:

static struct cb_program* program_list_reverse ( struct cb_program p)
static

Definition at line 2512 of file cobc.c.

References cb_program::next_program, and NULL.

Referenced by process_translate().

2513 {
2514  struct cb_program *next;
2515  struct cb_program *last;
2516 
2517  last = NULL;
2518  for (; p; p = next) {
2519  next = p->next_program;
2520  p->next_program = last;
2521  last = p;
2522  }
2523  return last;
2524 }
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct cb_program * next_program
Definition: tree.h:1242

Here is the caller graph for this function:

Variable Documentation

size_t aflag_set = 0
static

Definition at line 290 of file cobc.c.

Referenced by main(), and process_command_line().

struct strcache* base_string
static

Definition at line 248 of file cobc.c.

Referenced by cobc_check_string().

char* basename_buffer
static

Definition at line 257 of file cobc.c.

Referenced by file_basename(), and main().

size_t basename_len
static

Definition at line 260 of file cobc.c.

Referenced by file_basename(), and main().

int cb_attr_id = 0

Definition at line 164 of file cobc.c.

Referenced by lookup_attr(), and main().

unsigned int cb_compile_level = 0
static
struct cb_define_struct* cb_define_list = ((void*)0)
static

Definition at line 218 of file cobc.c.

struct cb_text_list* cb_early_exit_list = ((void*)0)

Definition at line 153 of file cobc.c.

Referenced by output_call().

struct cb_exception cb_exception_table[]

Definition at line 186 of file cobc.c.

struct cb_text_list* cb_extension_list = ((void*)0)

Definition at line 151 of file cobc.c.

Referenced by ppcopy().

int cb_field_id = 0

Definition at line 166 of file cobc.c.

Referenced by cb_build_field(), and main().

int cb_flag_functions_all = 0

Definition at line 170 of file cobc.c.

Referenced by cb_build_program(), and cobc_deciph_funcs().

int cb_flag_main = 0

Definition at line 168 of file cobc.c.

Referenced by process_command_line().

int cb_id = 0
struct cb_text_list* cb_include_list = ((void*)0)

Definition at line 149 of file cobc.c.

Referenced by ppcopy().

struct cb_text_list* cb_intrinsic_list = ((void*)0)

Definition at line 150 of file cobc.c.

Referenced by yylex().

FILE* cb_listing_file = ((void*)0)

Definition at line 157 of file cobc.c.

Referenced by check_listing(), cobc_clean_up(), main(), ppecho(), and preprocess().

int cb_literal_id = 0

Definition at line 165 of file cobc.c.

Referenced by lookup_literal(), and main().

char* cb_oc_build_stamp = ((void*)0)

Definition at line 146 of file cobc.c.

Referenced by cobc_print_version(), main(), and output_header().

int cb_saveargc = 0

Definition at line 179 of file cobc.c.

Referenced by main(), and output_header().

char** cb_saveargv = ((void*)0)

Definition at line 154 of file cobc.c.

Referenced by main(), and output_header().

int cb_source_format = 0

Definition at line 162 of file cobc.c.

Referenced by check_listing(), ppinput(), pplex(), ppopen(), ppparse(), preprocess(), and process_command_line().

struct cb_text_list* cb_static_call_list = ((void*)0)

Definition at line 152 of file cobc.c.

Referenced by output_call().

FILE* cb_storage_file = ((void*)0)

Definition at line 156 of file cobc.c.

Referenced by cobc_clean_up(), codegen(), output_storage(), and process_translate().

const char* cb_storage_file_name = ((void*)0)

Definition at line 148 of file cobc.c.

Referenced by codegen(), and process_translate().

const char* cob_config_dir = ((void*)0)

Definition at line 155 of file cobc.c.

Referenced by cb_load_conf(), cb_load_conf_file(), and main().

const char* const cob_csyns[]
static

Definition at line 292 of file cobc.c.

Referenced by cobc_check_valid_name().

size_t cob_optimize = 0
static

Definition at line 277 of file cobc.c.

Referenced by main(), and process_command_line().

size_t cobc_buffer_size
static

Definition at line 261 of file cobc.c.

Referenced by cobc_chk_buff_size(), cobc_clean_up(), main(), preprocess(), and process_run().

const char* cobc_cc
static
size_t cobc_cc_len
static
char* cobc_cflags
static
size_t cobc_cflags_len
static

Definition at line 238 of file cobc.c.

Referenced by main(), process_assemble(), process_compile(), and process_module_direct().

size_t cobc_cflags_size
static

Definition at line 231 of file cobc.c.

Referenced by main().

size_t cobc_export_dyn_len
static

Definition at line 243 of file cobc.c.

Referenced by main(), process_library(), process_link(), process_module(), and process_module_direct().

size_t cobc_flag_library = 0
static

Definition at line 271 of file cobc.c.

Referenced by main(), and process_command_line().

int cobc_flag_main = 0
size_t cobc_flag_module = 0
static

Definition at line 270 of file cobc.c.

Referenced by main(), and process_command_line().

size_t cobc_flag_run = 0
static
unsigned int cobc_gen_listing = 0

Definition at line 180 of file cobc.c.

Referenced by check_listing(), preprocess(), process_command_line(), and process_filename().

char* cobc_include
static
size_t cobc_include_len
static

Definition at line 241 of file cobc.c.

Referenced by main(), process_assemble(), process_compile(), and process_module_direct().

size_t cobc_include_size
static

Definition at line 234 of file cobc.c.

Referenced by main().

char* cobc_ldflags
static
size_t cobc_ldflags_len
static

Definition at line 242 of file cobc.c.

Referenced by main(), process_library(), process_link(), process_module(), and process_module_direct().

size_t cobc_ldflags_size
static

Definition at line 235 of file cobc.c.

Referenced by main().

char* cobc_lib_paths
static
size_t cobc_lib_paths_len
static

Definition at line 240 of file cobc.c.

Referenced by main(), process_library(), process_link(), process_module(), and process_module_direct().

size_t cobc_lib_paths_size
static

Definition at line 233 of file cobc.c.

Referenced by main().

char* cobc_libs
static
size_t cobc_libs_len
static

Definition at line 239 of file cobc.c.

Referenced by main(), process_library(), process_link(), process_module(), and process_module_direct().

size_t cobc_libs_size
static

Definition at line 232 of file cobc.c.

Referenced by main().

char* cobc_list_dir
static

Definition at line 250 of file cobc.c.

Referenced by cobc_free_mem(), process_command_line(), and process_filename().

char* cobc_list_file
static

Definition at line 251 of file cobc.c.

Referenced by cobc_free_mem(), main(), preprocess(), process_command_line(), and process_filename().

struct cobc_mem_struct* cobc_mainmem_base = ((void*)0)
static

Definition at line 220 of file cobc.c.

Referenced by cobc_main_malloc().

char* cobc_objects_buffer
static

Definition at line 255 of file cobc.c.

Referenced by main(), process_library(), and process_link().

size_t cobc_objects_len
static

Definition at line 259 of file cobc.c.

Referenced by main(), process_filename(), process_library(), and process_link().

struct cobc_mem_struct* cobc_parsemem_base = ((void*)0)
static

Definition at line 221 of file cobc.c.

Referenced by cobc_parse_malloc().

size_t cobc_pic_flags_len
static
struct cobc_mem_struct* cobc_plexmem_base = ((void*)0)
static

Definition at line 222 of file cobc.c.

Referenced by cobc_plex_malloc().

int cobc_seen_stdin = 0

Definition at line 171 of file cobc.c.

Referenced by process_filename().

size_t cobc_shared_opt_len
static

Definition at line 244 of file cobc.c.

Referenced by main(), process_library(), process_module(), and process_module_direct().

int cobc_wants_debug = 0

Definition at line 169 of file cobc.c.

Referenced by main(), and process_command_line().

const char* demangle_name = ((void*)0)

Definition at line 147 of file cobc.c.

Referenced by main(), and yyparse().

int errorcount = 0

Definition at line 173 of file cobc.c.

Referenced by cb_error(), cb_error_x(), cb_plex_error(), ppopen(), preprocess(), process_translate(), and yyparse().

int exit_option = 0

Definition at line 175 of file cobc.c.

Referenced by process_command_line().

struct filename* file_list
static

Definition at line 263 of file cobc.c.

int iargs
static

Definition at line 267 of file cobc.c.

Referenced by main().

const struct option long_options[]
static

Definition at line 396 of file cobc.c.

int no_physical_cancel = 0

Definition at line 177 of file cobc.c.

Referenced by output_module_init(), and process_command_line().

char* output_name_buff
static
size_t save_all_src = 0
static

Definition at line 274 of file cobc.c.

Referenced by cobc_clean_up(), process_command_line(), and process_filename().

size_t save_c_src = 0
static

Definition at line 275 of file cobc.c.

Referenced by cobc_clean_up(), process_command_line(), and process_filename().

size_t save_temps = 0
static

Definition at line 273 of file cobc.c.

Referenced by cobc_check_action(), cobc_clean_up(), process_command_line(), and process_filename().

char* save_temps_dir
static

Definition at line 247 of file cobc.c.

Referenced by cobc_check_action(), cobc_free_mem(), main(), and process_command_line().

const char short_options[] = "hVivECScbmxjdFOPgwo:I:L:l:D:K:k:"
static

Definition at line 390 of file cobc.c.

Referenced by process_command_line().

size_t strip_output = 0
static
size_t wants_nonfinal = 0
static

Definition at line 269 of file cobc.c.

Referenced by main(), and process_command_line().

int warningcount = 0

Definition at line 174 of file cobc.c.

Referenced by cb_plex_warning(), cb_warning(), and cb_warning_x().

int yydebug