GnuCOBOL  2.0
A free COBOL compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
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 "libcob.h"
#include "libcob/cobgetopt.h"
#include "libcob/exception.def"
#include "flag.def"
#include "warning.def"
Include dependency graph for cobc.c:

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 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)
 memory allocation for use when compiling More...
 
void cobc_free (void *mptr)
 deallocation of compile time memory More...
 
void * cobc_strdup (const char *dupstr)
 safely duplicate a character array More...
 
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 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 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 (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 = NULL
 
char * cb_oc_build_stamp = NULL
 
const char * demangle_name = NULL
 
const char * cb_storage_file_name = NULL
 
struct cb_text_listcb_include_list = NULL
 
struct cb_text_listcb_intrinsic_list = NULL
 
struct cb_text_listcb_extension_list = NULL
 
struct cb_text_listcb_static_call_list = NULL
 
struct cb_text_listcb_early_exit_list = NULL
 
char ** cb_saveargv = NULL
 
const char * cob_config_dir = NULL
 
FILE * cb_storage_file = NULL
 
FILE * cb_listing_file = NULL
 
struct noreservecobc_nores_base = NULL
 
int cb_source_format = CB_FORMAT_FIXED
 
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 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 = NULL
 
static struct cobc_mem_structcobc_mainmem_base = NULL
 
static struct cobc_mem_structcobc_parsemem_base = NULL
 
static struct cobc_mem_structcobc_plexmem_base = NULL
 
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 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 [] = "hVivECScbmxOPgwo:I:L:l:D:K:k:"
 
static struct option long_options []
 

Macro Definition Documentation

#define CB_COPT_1   " -O"

Referenced by main(), and process_command_line().

#define CB_COPT_2   " -O2"

Referenced by process_command_line().

#define CB_COPT_S   " -Os"

Referenced by process_command_line().

#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    int var = 0;
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)
Value:
{"f"name, CB_NO_ARG, &var, 1}, \
{"fno-"name, CB_NO_ARG, &var, 0},
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    cobc_print_flag (name, doc, pdok, 0);
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)    {"f"name, CB_RQ_ARG, NULL, opt},
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)    cobc_print_flag (name, doc, pdok, 1);
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    int var = def;
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    {"f"name, CB_RQ_ARG, NULL, opt},
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    cobc_print_flag (name, doc, pdok, 1);
#define CB_IMSG_SIZE   24

Referenced by cobc_var_print().

#define CB_IVAL_SIZE   (74 - CB_IMSG_SIZE - 4)

Referenced by cobc_var_print().

#define CB_LEVEL_COMPILE   3

Referenced by main(), and process_command_line().

#define CB_LEVEL_EXECUTABLE   7

Referenced by main().

#define CB_LEVEL_LIBRARY   6

Referenced by main(), and process_assemble().

#define CB_LEVEL_MODULE   5

Referenced by main(), and process_assemble().

#define CB_LEVEL_PREPROCESS   1
#define CB_LEVEL_TRANSLATE   2
#define CB_NO_ARG   no_argument
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    int var = 0;
#define CB_NOWARNDEF (   var,
  name,
  doc 
)
Value:
{"W"name, CB_NO_ARG, &var, 1}, \
{"Wno-"name, CB_NO_ARG, &var, 0},
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    cobc_print_warn (name, doc, 0);
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    var = 0;
#define CB_NOWARNDEF (   var,
  name,
  doc 
)
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    var = 1;
#define CB_OP_ARG   optional_argument
#define CB_RQ_ARG   required_argument
#define CB_TEXT_LIST_ADD (   y,
 
)    y = cb_text_list_add (y, z)
#define CB_TEXT_LIST_CHK (   y,
 
)    y = cb_text_list_chk (y, z)

Referenced by main(), and process_env_copy_path().

#define CB_WARNDEF (   var,
  name,
  doc 
)    int var = 0;
#define CB_WARNDEF (   var,
  name,
  doc 
)
Value:
{"W"name, CB_NO_ARG, &var, 1}, \
{"Wno-"name, CB_NO_ARG, &var, 0},
#define CB_WARNDEF (   var,
  name,
  doc 
)    cobc_print_warn (name, doc, 1);
#define CB_WARNDEF (   var,
  name,
  doc 
)    var = 0;
#define CB_WARNDEF (   var,
  name,
  doc 
)    var = 1;
#define CB_WARNDEF (   var,
  name,
  doc 
)    var = 1;
#define COB_EXCEPTION (   code,
  tag,
  name,
  critical 
)    {name, 0x##code, 0},
#define COB_NUM_CSYNS   sizeof(cob_csyns) / sizeof(char *)

Referenced by cobc_check_valid_name().

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

Referenced by main(), and process_command_line().

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

Referenced by process_command_line().

#define OC_C_VERSION   "unknown"

Referenced by cobc_print_version().

#define OC_C_VERSION_PRF   ""

Referenced by cobc_print_version().

Function Documentation

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

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, p, and PLEX_DEF_NONE.

Referenced by process_command_line().

1236 {
1237  struct cb_define_struct *p;
1238  struct cb_define_struct *l;
1239  char *s;
1240  char *x;
1241 
1242  x = cobc_strdup (text);
1243  s = strtok (x, "=");
1244 
1245  /* Check duplicate */
1246  for (l = list; l; l = l->next) {
1247  if (!strcasecmp (s, l->name)) {
1248  cobc_abort_pr (_("Duplicate define '%s' - Ignoring"), s);
1249  cobc_free (x);
1250  return list;
1251  }
1252  }
1253 
1254  p = cobc_main_malloc (sizeof (struct cb_define_struct));
1255  p->next = NULL;
1256  p->name = cobc_check_string (s);
1257  p->deftype = PLEX_DEF_NONE;
1258  s = strtok (NULL, "");
1259  if (cobc_set_value (p, s)) {
1260  cobc_free (x);
1261  return NULL;
1262  }
1263 
1264  cobc_free (x);
1265 
1266  if (!list) {
1267  p->last = p;
1268  return p;
1269  }
1270  list->last->next = p;
1271  list->last = p;
1272  return list;
1273 }
static struct cb_text_list* cb_text_list_add ( struct cb_text_list list,
const char *  text 
)
staticread

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

Referenced by cb_text_list_chk().

965 {
966  struct cb_text_list *p;
967 
968  p = cobc_main_malloc (sizeof (struct cb_text_list));
969  p->text = cobc_main_strdup (text);
970  if (!list) {
971  p->last = p;
972  return p;
973  }
974  list->last->next = p;
975  list->last = p;
976  return list;
977 }
static struct cb_text_list* cb_text_list_chk ( struct cb_text_list list,
const char *  text 
)
staticread

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

981 {
982  struct cb_text_list *p;
983 
984  for (p = list; p; p = p->next) {
985  if (!strcmp (text, p->text)) {
986  return list;
987  }
988  }
989  return cb_text_list_add (list, text);
990 }
DECLNORET void cobc_abort ( const char *  filename,
const int  linenum 
)

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 }
static void cobc_add_str ( char **  var,
size_t *  cursize,
const char *  s1,
const char *  s2,
const char *  s3 
)
static

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

1311 {
1312  size_t calcsize;
1313 
1314  if (!s1) {
1315  return;
1316  }
1317 
1318  calcsize = strlen (*var);
1319  calcsize += strlen (s1);
1320  if (s2) {
1321  calcsize += strlen (s2);
1322  }
1323  if (s3) {
1324  calcsize += strlen (s3);
1325  }
1326  if (calcsize >= 131072) {
1327  /* Arbitrary limit */
1328  cobc_err_exit (_("Parameter buffer size exceeded"));
1329  }
1330  if (calcsize >= *cursize) {
1331  while (*cursize <= calcsize) {
1332  *cursize *= 2;
1333  }
1334  *var = cobc_main_realloc (*var, *cursize);
1335  }
1336  strcat (*var, s1);
1337  if (s2) {
1338  strcat (*var, s2);
1339  }
1340  if (s3) {
1341  strcat (*var, s3);
1342  }
1343 }
static int cobc_bcompare ( const void *  p1,
const void *  p2 
)
static

Referenced by cobc_check_valid_name().

1077 {
1078  const void **tptr;
1079 
1080  tptr = (const void **)p2;
1081  return strcmp (p1, *tptr);
1082 }
static void cobc_check_action ( const char *  name)
static

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().

1347 {
1348  if (!name || access (name, F_OK)) {
1349  return;
1350  }
1351  if (!save_temps) {
1352  (void)unlink (name);
1353  return;
1354  }
1355  if (save_temps_dir) {
1356  char temp_buff[COB_MEDIUM_BUFF];
1357 
1358  snprintf (temp_buff, (size_t)COB_MEDIUM_MAX,
1359  "%s%s%s", save_temps_dir, SLASH_STR, name);
1360  /* Remove possible target file - ignore return */
1361  (void)unlink (temp_buff);
1362  if (rename (name, temp_buff)) {
1363  cobc_abort_pr (_("Warning - Could not move temporary file to %s"),
1364  temp_buff);
1365  }
1366  }
1367 }
void * cobc_check_string ( const char *  dupstr)

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_build_program_id(), cb_define_list_add(), and cb_encode_program_id().

942 {
943  struct strcache *s;
944 
945 #ifdef COB_TREE_DEBUG
946  if (unlikely(!dupstr)) {
947  cobc_abort_pr (_("Call to cobc_check_string with NULL pointer"));
949  }
950 #endif
951  for (s = base_string; s; s = s->next) {
952  if (!strcmp (dupstr, (const char *)s->val)) {
953  return s->val;
954  }
955  }
956  s = cobc_main_malloc (sizeof(struct strcache));
957  s->next = base_string;
958  s->val = cobc_main_strdup (dupstr);
959  base_string = s;
960  return s->val;
961 }
size_t cobc_check_valid_name ( const char *  name,
const unsigned int  prechk 
)

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

Referenced by cb_build_program_id(), and process_filename().

1133 {
1134  const char *p;
1135  size_t len;
1136 
1137  for (p = name, len = 0; *p; p++, len++) {
1138  if (*p == '/' || *p == '\\') {
1139  cobc_error_name (name, prechk, 5U);
1140  return 1;
1141  }
1142  }
1143  if (len < 1) {
1144  cobc_error_name (name, prechk, 1U);
1145  return 1;
1146  }
1147  if (!cb_relaxed_syntax_check && len > 31) {
1148  cobc_error_name (name, prechk, 1U);
1149  return 1;
1150  }
1151  if (*name == '_' || *name == ' ') {
1152  cobc_error_name (name, prechk, 2U);
1153  return 1;
1154  }
1155  if (prechk && len > 3 &&
1156  (!memcmp (name, "cob_", (size_t)4) ||
1157  !memcmp (name, "COB_", (size_t)4))) {
1158  cobc_error_name (name, prechk, 3U);
1159  return 1;
1160  }
1161  if (bsearch (name, cob_csyns, COB_NUM_CSYNS,
1162  sizeof (char *), cobc_bcompare)) {
1163  cobc_error_name (name, prechk, 4U);
1164  return 1;
1165  }
1166  return 0;
1167 }
static void cobc_chk_buff_size ( const size_t  bufflen)
static
static void cobc_clean_up ( const int  status)
static

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_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().

1371 {
1372  struct filename *fn;
1373  struct local_filename *lf;
1374  cob_u32_t i;
1375 
1376  if (cb_listing_file) {
1377  fclose (cb_listing_file);
1379  }
1380  if (cb_storage_file) {
1381  fclose (cb_storage_file);
1383  }
1384  if (ppin) {
1385  fclose (ppin);
1386  ppin = NULL;
1387  }
1388 
1389  if (ppout) {
1390  fclose (ppout);
1391  ppout = NULL;
1392  }
1393  if (yyin) {
1394  fclose (yyin);
1395  yyin = NULL;
1396  }
1397 
1398  if (yyout) {
1399  fclose (yyout);
1400  yyout = NULL;
1401  }
1402 
1403  for (fn = file_list; fn; fn = fn->next) {
1404  for (lf = fn->localfile; lf; lf = lf->next) {
1405  if (unlikely(lf->local_fp)) {
1406  fclose (lf->local_fp);
1407  lf->local_fp = NULL;
1408  }
1409  }
1410  if (fn->need_assemble &&
1411  (status || cb_compile_level > CB_LEVEL_ASSEMBLE ||
1413  cobc_check_action (fn->object);
1414  }
1415  if (save_all_src) {
1416  continue;
1417  }
1418  if (fn->need_preprocess &&
1419  (status || cb_compile_level > CB_LEVEL_PREPROCESS ||
1422  }
1423  if (save_c_src) {
1424  continue;
1425  }
1426  if (fn->need_translate &&
1427  (status || cb_compile_level > CB_LEVEL_TRANSLATE ||
1431  if (fn->localfile) {
1432  for (lf = fn->localfile; lf; lf = lf->next) {
1434  }
1435  } else if (fn->translate) {
1436  /* If we get syntax errors, we do not
1437  know the number of local include files */
1438  sprintf (cobc_buffer, "%s.l.h", fn->translate);
1439  for (i = 0; i < 30U; ++i) {
1440  if (i) {
1441  sprintf (cobc_buffer, "%s.l%u.h",
1442  fn->translate, i);
1443  }
1444  if (!access (cobc_buffer, F_OK)) {
1445  unlink (cobc_buffer);
1446  } else if (i) {
1447  break;
1448  }
1449  }
1450  }
1451  }
1452  }
1453  cobc_free_mem ();
1454  file_list = NULL;
1455 }
static void cobc_cmd_print ( const char *  cmd)
static

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

Referenced by preprocess(), and process().

1547 {
1548  char *p;
1549  char *token;
1550  size_t n;
1551  size_t toklen;
1552 
1553  fputs (_("Executing:"), stderr);
1554  /* Check if it fits in 80 characters */
1555  if (strlen (cmd) < 64) {
1556  fprintf (stderr, "\t%s\n", (char *)cmd);
1557  fflush (stderr);
1558  return;
1559  }
1560  putc ('\t', stderr);
1561  p = cobc_strdup (cmd);
1562  n = 0;
1563  token = strtok (p, " ");
1564  for (; token; token = strtok (NULL, " ")) {
1565  toklen = strlen (token) + 1;
1566  if ((n + toklen) > 63) {
1567  fprintf(stderr, "\n\t\t");
1568  n = 0;
1569  }
1570  fprintf (stderr, "%s%s", (n ? " " : ""), token);
1571  n += toklen;
1572  }
1573  cobc_free (p);
1574  putc ('\n', stderr);
1575  fflush (stderr);
1576 }
static void cobc_deciph_funcs ( const char *  opt)
static

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

Referenced by process_command_line().

1860 {
1861  char *p;
1862  char *q;
1863 
1864  if (!strcasecmp (opt, "ALL")) {
1866  return;
1867  }
1868 
1869  p = cobc_strdup (opt);
1870  q = strtok (p, ",");
1871  while (q) {
1872  if (!lookup_intrinsic (q, 0, 1)) {
1873  cobc_err_exit (_("'%s' is not an intrinsic function"), q);
1874  }
1876  q = strtok (NULL, ",");
1877  }
1878  cobc_free (p);
1879 }
static int cobc_deciph_optarg ( const char *  p,
const int  allow_quote 
)
static

Referenced by process_command_line().

1182 {
1183  const unsigned char *s;
1184  size_t len;
1185  size_t i;
1186  int n;
1187 
1188  len = strlen (p);
1189  if (!len) {
1190  return -1;
1191  }
1192  s = (const unsigned char *)p;
1193  if (allow_quote) {
1194  if (*s == '"' || *s == '\'') {
1195  if (len != 3 || *(s + 2) != *s) {
1196  return -1;
1197  }
1198  return (int)(*(s + 1));
1199  }
1200  if (*s < '0' || *s > '9') {
1201  if (len != 1) {
1202  return -1;
1203  }
1204  return (int)*s;
1205  }
1206  }
1207  n = 0;
1208  for (i = 0; i < len; ++i) {
1209  if (s[i] < '0' || s[i] > '9') {
1210  return -1;
1211  }
1212  n *= 10;
1213  n += (s[i] & 0x0F);
1214  }
1215  return n;
1216 }
DECLNORET void cobc_dumb_abort ( const char *  filename,
const int  linenum 
)

References cobc_abort().

614 {
615  cobc_abort (filename, linenum);
616 }
static const char* cobc_enum_explain ( const enum cb_tag  tag)
static

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 }
static void COB_A_NORETURN cobc_err_exit ( const char *  fmt,
  ... 
)
static

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().

1220 {
1221  va_list ap;
1222 
1223  fputs ("cobc: ", stderr);
1224  fputs (_("Error: "), stderr);
1225  va_start (ap, fmt);
1226  vfprintf (stderr, fmt, ap);
1227  va_end (ap);
1228  putc ('\n', stderr);
1229  fflush (stderr);
1230  cobc_free_mem ();
1231  exit (1);
1232 }
static void cobc_error_name ( const char *  name,
const unsigned int  source,
const unsigned int  reason 
)
static

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

Referenced by cobc_check_valid_name().

1087 {
1088  const char *s;
1089 
1090  s = "";
1091  switch (reason) {
1092  case 1:
1093  s = _(" - Length is < 1 or > 31");
1094  break;
1095  case 2:
1096  s = _(" - Name cannot begin with space or underscore");
1097  break;
1098  case 3:
1099  s = _(" - Name cannot begin with 'cob_' or 'COB_'");
1100  break;
1101  case 4:
1102  s = _(" - Name duplicates a 'C' keyword");
1103  break;
1104  case 5:
1105  s = _(" - Name cannot contain a directory separator");
1106  break;
1107  default:
1108  break;
1109  }
1110  switch (source) {
1111  case 0:
1112  /* basename */
1113  cobc_abort_pr (_("Invalid file base name '%s'%s"),
1114  name, s);
1115  break;
1116  case 1:
1117  /* ENTRY */
1118  cb_error (_("Invalid ENTRY '%s'%s"), name, s);
1119  break;
1120  case 2:
1121  /* PROGRAM-ID */
1122  cb_error (_("Invalid PROGRAM-ID '%s'%s"), name, s);
1123  break;
1124  default:
1125  cobc_abort_pr (_("Unknown name error '%s'%s"),
1126  name, s);
1127  break;
1128  }
1129 }
void cobc_free ( void *  mptr)

deallocation of compile time memory

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(), preprocess(), process(), process_env_copy_path(), scan_define_options(), while(), and ylex_clear_all().

658 {
659 #ifdef COB_TREE_DEBUG
660  if (unlikely(!mptr)) {
661  cobc_abort_pr (_("Call to cobc_free with NULL pointer"));
663  }
664 #endif
665  free(mptr);
666 }
static void cobc_free_mem ( void  )
static

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* cobc_getenv ( const char *  env)
static

References cobc_main_strdup(), NULL, and p.

Referenced by main().

1298 {
1299  char *p;
1300 
1301  p = getenv (env);
1302  if (!p || *p == 0 || *p == ' ') {
1303  return NULL;
1304  }
1305  return cobc_main_strdup (p);
1306 }
void cobc_main_free ( void *  prevptr)

References cobc_free(), cobc_mem_struct::memptr, cobc_mem_struct::next, and NULL.

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 (!curr) {
791  return;
792  }
793  if (prev) {
794  prev->next = curr->next;
795  } else {
796  /* At mainmem_base */
797  cobc_mainmem_base = curr->next;
798  }
799  cobc_free (curr);
800 }
void * cobc_main_malloc ( const size_t  size)
void * cobc_main_realloc ( void *  prevptr,
const size_t  size 
)

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_main_strdup ( const char *  dupstr)

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_main_malloc(), p, 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 cobc_main_strdup with NULL pointer"));
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_malloc ( const size_t  size)

memory allocation for use when compiling

Allocate size bytes of memory, cleared to zeros. Aborts compile if memory unavailable.

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 }
static void cobc_options_error_build ( void  )
static

References _, and cobc_err_exit().

Referenced by process_command_line().

1854 {
1855  cobc_err_exit (_("Only one of options 'm', 'x', 'b' may be specified"));
1856 }
static void cobc_options_error_nonfinal ( void  )
static

References _, and cobc_err_exit().

Referenced by process_command_line().

1848 {
1849  cobc_err_exit (_("Only one of options 'E', 'S', 'C', 'c' may be specified"));
1850 }
void cobc_parse_free ( void *  prevptr)

References cobc_free(), cobc_mem_struct::memptr, cobc_mem_struct::next, and NULL.

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

881 {
882  struct cobc_mem_struct *curr;
883  struct cobc_mem_struct *prev;
884 
885  prev = NULL;
886  for (curr = cobc_parsemem_base; curr; curr = curr->next) {
887  if (curr->memptr == prevptr) {
888  break;
889  }
890  prev = curr;
891  }
892  if (!curr) {
893  return;
894  }
895  if (prev) {
896  prev->next = curr->next;
897  } else {
898  /* At parsemem_base */
899  cobc_parsemem_base = curr->next;
900  }
901  cobc_free (curr);
902 }
void * cobc_parse_realloc ( void *  prevptr,
const size_t  size 
)

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

841 {
842  struct cobc_mem_struct *m;
843  struct cobc_mem_struct *curr;
844  struct cobc_mem_struct *prev;
845 
846  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
847  if (unlikely(!m)) {
848  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
849  (int)size);
851  }
852  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
853  m->memlen = size;
854 
855  prev = NULL;
856  for (curr = cobc_parsemem_base; curr; curr = curr->next) {
857  if (curr->memptr == prevptr) {
858  break;
859  }
860  prev = curr;
861  }
862  if (unlikely(!curr)) {
863  cobc_abort_pr (_("Attempt to reallocate non-allocated memory - Aborting"));
865  }
866  m->next = curr->next;
867  if (prev) {
868  prev->next = m;
869  } else {
870  /* At parsemem_base */
871  cobc_parsemem_base = m;
872  }
873  memcpy (m->memptr, curr->memptr, curr->memlen);
874  cobc_free (curr);
875 
876  return m->memptr;
877 }
void * cobc_parse_strdup ( const char *  dupstr)

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

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

823 {
824  void *p;
825  size_t n;
826 
827 #ifdef COB_TREE_DEBUG
828  if (unlikely(!dupstr)) {
829  cobc_abort_pr (_("Call to cobc_parse_strdup with NULL pointer"));
831  }
832 #endif
833  n = strlen (dupstr);
834  p = cobc_parse_malloc (n + 1);
835  memcpy (p, dupstr, n);
836  return p;
837 }
void * cobc_plex_malloc ( const size_t  size)

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(), and ppp_replace_list_add().

907 {
908  struct cobc_mem_struct *m;
909 
910  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
911  if (unlikely(!m)) {
912  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
913  (int)size);
915  }
916  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
917  m->next = cobc_plexmem_base;
918  cobc_plexmem_base = m;
919  return m->memptr;
920 }
void * cobc_plex_strdup ( const char *  dupstr)

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

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

924 {
925  void *p;
926  size_t n;
927 
928 #ifdef COB_TREE_DEBUG
929  if (unlikely(!dupstr)) {
930  cobc_abort_pr (_("Call to cobc_plex_strdup with NULL pointer"));
932  }
933 #endif
934  n = strlen (dupstr);
935  p = cobc_plex_malloc (n + 1);
936  memcpy (p, dupstr, n);
937  return p;
938 }
static void cobc_print_flag ( const char *  name,
const char *  doc,
const int  pdok,
const int  exten 
)
static
1739 {
1740  const char *bptr;
1741  char buff[32];
1742 
1743  if (!pdok) {
1744  return;
1745  }
1746  if (!exten) {
1747  bptr = name;
1748  } else {
1749  snprintf (buff, sizeof(buff), "%s=<value>", name);
1750  bptr = buff;
1751  }
1752  printf (" -f%-19s %s\n", bptr, doc);
1753 }
static void cobc_print_info ( void  )
static

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, and WITH_VARSEQ.

Referenced by process_command_line().

1619 {
1620  char buff[16];
1621  char *s;
1622 
1623  cobc_print_version ();
1624  putchar ('\n');
1625  puts (_("Build information"));
1626  cobc_var_print (_("Build environment"), COB_BLD_BUILD, 0);
1627  cobc_var_print ("CC", COB_BLD_CC, 0);
1628  cobc_var_print ("CPPFLAGS", COB_BLD_CPPFLAGS, 0);
1629  cobc_var_print ("CFLAGS", COB_BLD_CFLAGS, 0);
1630  cobc_var_print ("LD", COB_BLD_LD, 0);
1631  cobc_var_print ("LDFLAGS", COB_BLD_LDFLAGS, 0);
1632  putchar ('\n');
1633  puts (_("GNU Cobol information"));
1634  cobc_var_print ("COB_CC", COB_CC, 0);
1635  if ((s = getenv ("COB_CC")) != NULL) {
1636  cobc_var_print ("COB_CC", s, 1);
1637  }
1638  cobc_var_print ("COB_CFLAGS", COB_CFLAGS, 0);
1639  if ((s = getenv ("COB_CFLAGS")) != NULL) {
1640  cobc_var_print ("COB_CFLAGS", s, 1);
1641  }
1642  cobc_var_print ("COB_LDFLAGS", COB_LDFLAGS, 0);
1643  if ((s = getenv ("COB_LDFLAGS")) != NULL) {
1644  cobc_var_print ("COB_LDFLAGS", s, 1);
1645  }
1646  cobc_var_print ("COB_LIBS", COB_LIBS, 0);
1647  if ((s = getenv ("COB_LIBS")) != NULL) {
1648  cobc_var_print ("COB_LIBS", s, 1);
1649  }
1650  cobc_var_print ("COB_CONFIG_DIR", COB_CONFIG_DIR, 0);
1651  if ((s = getenv ("COB_CONFIG_DIR")) != NULL) {
1652  cobc_var_print ("COB_CONFIG_DIR", s, 1);
1653  }
1654  cobc_var_print ("COB_COPY_DIR", COB_COPY_DIR, 0);
1655  if ((s = getenv ("COB_COPY_DIR")) != NULL) {
1656  cobc_var_print ("COB_COPY_DIR", s, 1);
1657  }
1658  if ((s = getenv ("COBCPY")) != NULL) {
1659  cobc_var_print ("COBCPY", s, 1);
1660  }
1661  if (cb_msg_style == CB_MSG_STYLE_MSC) {
1662  cobc_var_print ("COB_MSG_FORMAT", "MSC", 0);
1663  } else {
1664  cobc_var_print ("COB_MSG_FORMAT", "GCC", 0);
1665  }
1666  if ((s = getenv ("COB_MSG_FORMAT")) != NULL) {
1667  cobc_var_print ("COB_MSG_FORMAT", s, 1);
1668  }
1669 #if 0 /* Simon: only relevant for libcob */
1670  if ((s = getenv ("COB_LIBRARY_PATH")) != NULL) {
1671  cobc_var_print ("COB_LIBRARY_PATH", s, 1);
1672  }
1673 #endif
1674  cobc_var_print ("COB_MODULE_EXT", COB_MODULE_EXT, 0);
1675  cobc_var_print ("COB_EXEEXT", COB_EXEEXT, 0);
1676 
1677 #if 0 /* Simon: only relevant for libcob */
1678 #if defined(USE_LIBDL) || defined(_WIN32)
1679  cobc_var_print (_("Dynamic loading"), _("System"), 0);
1680 #else
1681  cobc_var_print (_("Dynamic loading"), _("Libtool"), 0);
1682 #endif
1683 
1684 #ifdef COB_PARAM_CHECK
1685  cobc_var_print ("\"CBL_\" param check", _("Enabled"), 0);
1686 #else
1687  cobc_var_print ("\"CBL_\" param check", _("Disabled"), 0);
1688 #endif
1689 #endif
1690 
1691  snprintf (buff, sizeof(buff), "%d", WITH_VARSEQ);
1692  cobc_var_print (_("Variable format"), buff, 0);
1693  if ((s = getenv ("COB_VARSEQ_FORMAT")) != NULL) {
1694  cobc_var_print ("COB_VARSEQ_FORMAT", s, 1);
1695  }
1696 
1697 #ifdef COB_LI_IS_LL
1698  cobc_var_print ("BINARY-C-LONG", _("8 bytes"), 0);
1699 #else
1700  cobc_var_print ("BINARY-C-LONG", _("4 bytes"), 0);
1701 #endif
1702 
1703 #ifdef WITH_SEQRA_EXTFH
1704  cobc_var_print (_("Sequential handler"), _("External"), 0);
1705 #else
1706  cobc_var_print (_("Sequential handler"), _("Internal"), 0);
1707 #endif
1708 #ifdef WITH_INDEX_EXTFH
1709  cobc_var_print (_("ISAM handler"), _("External"), 0);
1710 #endif
1711 #ifdef WITH_DB
1712  cobc_var_print (_("ISAM handler"), _("BDB"), 0);
1713 #endif
1714 #ifdef WITH_CISAM
1715  cobc_var_print (_("ISAM handler"), _("C-ISAM (Experimental)"), 0);
1716 #endif
1717 #ifdef WITH_DISAM
1718  cobc_var_print (_("ISAM handler"), _("D-ISAM (Experimental)"), 0);
1719 #endif
1720 #ifdef WITH_VBISAM
1721  cobc_var_print (_("ISAM handler"), _("VBISAM (Experimental)"), 0);
1722 #endif
1723 }
static void cobc_print_usage ( char *  prog)
static

References _, and PACKAGE_NAME.

Referenced by process_command_line().

1757 {
1758  printf (_("Usage: %s [options]... file..."), prog);
1759  putchar ('\n');
1760  putchar ('\n');
1761  printf (_("%s compiler for most COBOL dialects with lots of extensions"), PACKAGE_NAME);
1762  putchar ('\n');
1763  putchar ('\n');
1764  puts (_("Options:"));
1765  puts (_(" -h, -help Display this help and exit"));
1766  puts (_(" -V, -version Display compiler version"));
1767  puts (_(" -i, -info Display compiler information (build/environment)"));
1768  puts (_(" -v Display the commands invoked by the compiler"));
1769  puts (_(" -x Build an executable program"));
1770  puts (_(" -m Build a dynamically loadable module (default)"));
1771  puts (_(" -std=<dialect> Warnings/features for a specific dialect:"));
1772  puts (_(" cobol2002 Cobol 2002"));
1773  puts (_(" cobol85 Cobol 85"));
1774  puts (_(" ibm IBM Compatible"));
1775  puts (_(" mvs MVS Compatible"));
1776  puts (_(" bs2000 BS2000 Compatible"));
1777  puts (_(" mf Micro Focus Compatible"));
1778  puts (_(" acu ACUCOBOL-GT Compatible"));
1779  puts (_(" default When not specified"));
1780  puts (_(" See config/default.conf and config/*.conf"));
1781  puts (_(" -free Use free source format"));
1782  puts (_(" -fixed Use fixed source format (default)"));
1783  puts (_(" -O, -O2, -Os Enable optimization"));
1784  puts (_(" -g Enable C compiler debug / stack check / trace"));
1785  puts (_(" -debug Enable all run-time error checking"));
1786  puts (_(" -o <file> Place the output into <file>"));
1787  puts (_(" -b Combine all input files into a single"));
1788  puts (_(" dynamically loadable module"));
1789  puts (_(" -E Preprocess only; do not compile or link"));
1790  puts (_(" -C Translation only; convert COBOL to C"));
1791  puts (_(" -S Compile only; output assembly file"));
1792  puts (_(" -c Compile and assemble, but do not link"));
1793  puts (_(" -P(=<dir or file>) Generate preprocessed program listing (.lst)"));
1794  puts (_(" -Xref Generate cross reference through 'cobxref'"));
1795  puts (_(" (V. Coen's 'cobxref' must be in path)"));
1796  puts (_(" -I <directory> Add <directory> to copy/include search path"));
1797  puts (_(" -L <directory> Add <directory> to library search path"));
1798  puts (_(" -l <lib> Link the library <lib>"));
1799  puts (_(" -A <options> Add <options> to the C compile phase"));
1800  puts (_(" -Q <options> Add <options> to the C link phase"));
1801  puts (_(" -D <define> DEFINE <define> to the COBOL compiler"));
1802  puts (_(" -K <entry> Generate CALL to <entry> as static"));
1803  puts (_(" -conf=<file> User defined dialect configuration - See -std="));
1804  puts (_(" -cb_conf=tag:value Override configuration entry"));
1805  puts (_(" -list-reserved Display reserved words"));
1806  puts (_(" -list-intrinsics Display intrinsic functions"));
1807  puts (_(" -list-mnemonics Display mnemonic names"));
1808  puts (_(" -list-system Display system routines"));
1809  puts (_(" -save-temps(=<dir>) Save intermediate files"));
1810  puts (_(" - Default : current directory"));
1811  puts (_(" -ext <extension> Add default file extension"));
1812 
1813  putchar ('\n');
1814 
1815  puts (_(" -W Enable ALL warnings"));
1816  puts (_(" -Wall Enable all warnings except as noted below"));
1817 #undef CB_WARNDEF
1818 #undef CB_NOWARNDEF
1819 #define CB_WARNDEF(var,name,doc) \
1820  cobc_print_warn (name, doc, 1);
1821 #define CB_NOWARNDEF(var,name,doc) \
1822  cobc_print_warn (name, doc, 0);
1823 #include "warning.def"
1824 #undef CB_WARNDEF
1825 #undef CB_NOWARNDEF
1826 
1827  putchar ('\n');
1828 
1829 #undef CB_FLAG
1830 #undef CB_FLAG_RQ
1831 #undef CB_FLAG_NQ
1832 #define CB_FLAG(var,pdok,name,doc) \
1833  cobc_print_flag (name, doc, pdok, 0);
1834 #define CB_FLAG_RQ(var,pdok,name,def,opt,doc) \
1835  cobc_print_flag (name, doc, pdok, 1);
1836 #define CB_FLAG_NQ(pdok,name,opt,doc) \
1837  cobc_print_flag (name, doc, pdok, 1);
1838 #include "flag.def"
1839 #undef CB_FLAG
1840 #undef CB_FLAG_RQ
1841 #undef CB_FLAG_NQ
1842 
1843  putchar ('\n');
1844 }
static void cobc_print_version ( void  )
static

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().

1529 {
1530  printf ("cobc (%s) %s.%d\n",
1532  puts ("Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida");
1533  puts ("Copyright (C) 2006-2012 Roger While");
1534  puts ("Copyright (C) 2009,2010,2012,2014 Simon Sobisch");
1535  puts (_("This is free software; see the source for copying conditions. There is NO\n\
1536 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."));
1537  printf (_("Built %s"), cb_oc_build_stamp);
1538  putchar ('\n');
1539  printf (_("Packaged %s"), COB_TAR_DATE);
1540  putchar ('\n');
1541  printf (_("C version %s%s"), OC_C_VERSION_PRF, OC_C_VERSION);
1542  putchar ('\n');
1543 }
static void cobc_print_warn ( const char *  name,
const char *  doc,
const int  wall 
)
static

References _.

1727 {
1728  printf (" -W%-19s %s", name, doc);
1729  if (!wall) {
1730  fputs ("\n\t\t\t", stdout);
1731  fputs (_("- NOT set with -Wall"), stdout);
1732  }
1733  putchar ('\n');
1734 }
void * cobc_realloc ( void *  prevptr,
const size_t  size 
)

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 }
static unsigned int cobc_set_value ( struct cb_define_struct p,
const char *  value 
)
static

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, cb_define_struct::value, and value.

Referenced by cb_define_list_add().

994 {
995  const char *s;
996  size_t size;
997  unsigned int dot_seen;
998  unsigned int sign_seen;
999 
1000  if (!value) {
1001  p->deftype = PLEX_DEF_NONE;
1002  p->value = NULL;
1003  p->sign = 0;
1004  p->int_part = 0;
1005  p->dec_part = 0;
1006  return 0;
1007  }
1008 
1009  /* Quoted value */
1010  if (*value == '"' || *value == '\'') {
1011  size = strlen (value) - 1U;
1012  if (value[0] != value[size]) {
1013  p->value = NULL;
1014  p->deftype = PLEX_DEF_NONE;
1015  return 1;
1016  }
1017  p->value = cobc_main_strdup (value);
1018 
1019  p->deftype = PLEX_DEF_LIT;
1020  p->sign = 0;
1021  p->int_part = 0;
1022  p->dec_part = 0;
1023  return 0;
1024  }
1025 
1026  /* Non-quoted value - Check if possible numeric */
1027  dot_seen = 0;
1028  sign_seen = 0;
1029  size = 0;
1030  s = value;
1031  if (*s == '+' || *s == '-') {
1032  sign_seen = 1;
1033  size++;
1034  s++;
1035  }
1036  for (; *s; ++s) {
1037  if (*s == '.') {
1038  if (dot_seen) {
1039  break;
1040  }
1041  dot_seen = 1;
1042  size++;
1043  continue;
1044  }
1045  if (*s > '9' || *s < '0') {
1046  break;
1047  }
1048  size++;
1049  }
1050 
1051  if (*s || size <= (dot_seen + sign_seen)) {
1052  /* Not numeric */
1053 #if 0 /* RXWRXW - Lit warn */
1054  cobc_abort_pr (_("Warning - Assuming literal for unquoted '%s'"),
1055  value);
1056 #endif
1057  size = strlen (value);
1058  p->value = cobc_main_malloc (size + 4U);
1059  sprintf (p->value, "'%s'", value);
1060  p->deftype = PLEX_DEF_LIT;
1061  p->sign = 0;
1062  p->int_part = 0;
1063  p->dec_part = 0;
1064  return 0;
1065  }
1066 
1067  p->value = cobc_main_strdup (value);
1068  p->deftype = PLEX_DEF_NUM;
1069  p->sign = 0;
1070  p->int_part = 0;
1071  p->dec_part = 0;
1072  return 0;
1073 }
static char* cobc_stradd_dup ( const char *  str1,
const char *  str2 
)
static

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

Referenced by process_filename().

1277 {
1278  char *p;
1279  size_t m;
1280  size_t n;
1281 
1282 #ifdef COB_TREE_DEBUG
1283  if (unlikely(!str1 || !str2)) {
1284  cobc_abort_pr (_("Call to cobc_stradd_dup with NULL pointer"));
1286  }
1287 #endif
1288  m = strlen (str1);
1289  n = strlen (str2);
1290  p = cobc_main_malloc (m + n + 1);
1291  memcpy (p, str1, m);
1292  memcpy (p + m, str2, n);
1293  return p;
1294 }
void * cobc_strdup ( const char *  dupstr)

safely duplicate a character array

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

Referenced by 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 while().

670 {
671  void *p;
672  size_t n;
673 
674 #ifdef COB_TREE_DEBUG
675  if (unlikely(!dupstr)) {
676  cobc_abort_pr (_("Call to cobc_strdup with NULL pointer"));
678  }
679 #endif
680  n = strlen (dupstr);
681  p = cobc_malloc (n + 1);
682  memcpy (p, dupstr, n);
683  return p;
684 }
static void COB_A_NORETURN cobc_terminate ( const char *  str)
static

References cobc_clean_up().

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

1459 {
1460  int save_errno;
1461 
1462  save_errno = errno;
1463  fprintf (stderr, "cobc: ");
1464  fflush (stderr);
1465  errno = save_errno;
1466  perror (str);
1467  fflush (stderr);
1468  cobc_clean_up (1);
1469  exit (1);
1470 }
DECLNORET void cobc_too_many_errors ( void  )

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_tree_cast_error ( const cb_tree  x,
const char *  filename,
const int  linenum,
const enum cb_tag  tagnum 
)

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 void cobc_var_print ( const char *  msg,
const char *  val,
const unsigned int  env 
)
static

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

Referenced by cobc_print_info().

1580 {
1581  char *p;
1582  char *token;
1583  size_t n;
1584  size_t lablen;
1585  size_t toklen;
1586 
1587  if (!env) {
1588  printf ("%-*.*s : ", CB_IMSG_SIZE, CB_IMSG_SIZE, msg);
1589  } else {
1590  printf (" %s: ", _("env"));
1591  lablen = CB_IMSG_SIZE - 2 - strlen(_("env")) - 2;
1592  printf ("%-*.*s : ", lablen, lablen, msg);
1593  }
1594  if (strlen(val) <= CB_IVAL_SIZE) {
1595  printf("%s\n", val);
1596  return;
1597  }
1598  p = cobc_strdup (val);
1599  n = 0;
1600  token = strtok (p, " ");
1601  for (; token; token = strtok (NULL, " ")) {
1602  toklen = strlen (token) + 1;
1603  if ((n + toklen) > CB_IVAL_SIZE) {
1604  if (n) {
1605  printf ("\n%*.*s", CB_IMSG_SIZE + 3,
1606  CB_IMSG_SIZE + 3, " ");
1607  }
1608  n = 0;
1609  }
1610  printf ("%s%s", (n ? " " : ""), token);
1611  n += toklen;
1612  }
1613  putchar ('\n');
1614  cobc_free (p);
1615 }
static char* file_basename ( const char *  filename)
static

References basename_buffer, basename_len, cobc_main_realloc(), NULL, and p.

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

2483 {
2484  const char *p;
2485  const char *startp;
2486  const char *endp;
2487  size_t len;
2488 
2489  /* Remove directory name */
2490  startp = NULL;
2491  for (p = filename; *p; p++) {
2492  if (*p == '/' || *p == '\\') {
2493  startp = p;
2494  }
2495  }
2496  if (startp) {
2497  startp++;
2498  } else {
2499  startp = filename;
2500  }
2501 
2502  /* Remove extension */
2503  endp = strrchr (filename, '.');
2504  if (endp > startp) {
2505  len = endp - startp;
2506  } else {
2507  len = strlen (startp);
2508  }
2509 
2510  if (len >= basename_len) {
2511  basename_len = len + 16;
2513  }
2514  /* Copy base name */
2515  memcpy (basename_buffer, startp, len);
2516  basename_buffer[len] = 0;
2517  return basename_buffer;
2518 }
static const char* file_extension ( const char *  filename)
static

References p.

Referenced by process_filename().

2522 {
2523  const char *p;
2524 
2525  p = strrchr (filename, '.');
2526  if (p) {
2527  return p + 1;
2528  }
2529  return "";
2530 }
int main ( int  argc,
char **  argv 
)

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, p, 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.

3879 {
3880  struct filename *fn;
3881  char *p;
3882  struct cobc_mem_struct *mptr;
3883  struct cobc_mem_struct *mptrt;
3884  unsigned int iparams;
3885  unsigned int local_level;
3886  int status;
3887  int year;
3888  int day;
3889  int i;
3890  char month[32];
3891 
3892 #if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGACTION)
3893  struct sigaction sa;
3894  struct sigaction osa;
3895 #endif
3896 
3897  file_list = NULL;
3899  ppin = NULL;
3900  ppout = NULL;
3901  yyin = NULL;
3902  yyout = NULL;
3903 
3904 #ifdef HAVE_SIGNAL_H
3905 
3906 #ifdef HAVE_SIGACTION
3907  memset (&sa, 0, sizeof(sa));
3908  sa.sa_handler = cobc_sig_handler;
3909 #ifdef SA_RESETHAND
3910  sa.sa_flags = SA_RESETHAND;
3911 #else
3912  sa.sa_flags = 0;
3913 #endif
3914 #ifdef SA_NOCLDSTOP
3915  sa.sa_flags |= SA_NOCLDSTOP;
3916 #endif
3917 #ifdef SIGINT
3918  (void)sigaction (SIGINT, NULL, &osa);
3919  if (osa.sa_handler != SIG_IGN) {
3920  (void)sigemptyset (&sa.sa_mask);
3921  (void)sigaction (SIGINT, &sa, NULL);
3922  }
3923 #endif
3924 #ifdef SIGHUP
3925  (void)sigaction (SIGHUP, NULL, &osa);
3926  if (osa.sa_handler != SIG_IGN) {
3927  (void)sigemptyset (&sa.sa_mask);
3928  (void)sigaction (SIGHUP, &sa, NULL);
3929  }
3930 #endif
3931 #ifdef SIGQUIT
3932  (void)sigaction (SIGQUIT, NULL, &osa);
3933  if (osa.sa_handler != SIG_IGN) {
3934  (void)sigemptyset (&sa.sa_mask);
3935  (void)sigaction (SIGQUIT, &sa, NULL);
3936  }
3937 #endif
3938 #ifdef SIGTERM
3939  (void)sigaction (SIGTERM, NULL, &osa);
3940  if (osa.sa_handler != SIG_IGN) {
3941  (void)sigemptyset (&sa.sa_mask);
3942  (void)sigaction (SIGTERM, &sa, NULL);
3943  }
3944 #endif
3945 #ifdef SIGPIPE
3946  (void)sigaction (SIGPIPE, NULL, &osa);
3947  if (osa.sa_handler != SIG_IGN) {
3948  (void)sigemptyset (&sa.sa_mask);
3949  (void)sigaction (SIGPIPE, &sa, NULL);
3950  }
3951 #endif
3952 #ifdef SIGSEGV
3953  /* Take direct control of segementation violation */
3954  (void)sigemptyset (&sa.sa_mask);
3955  (void)sigaction (SIGSEGV, &sa, NULL);
3956 #endif
3957 
3958 #else
3959 
3960 #ifdef SIGINT
3961  if (signal (SIGINT, SIG_IGN) != SIG_IGN) {
3962  (void)signal (SIGINT, cobc_sig_handler);
3963  }
3964 #endif
3965 #ifdef SIGHUP
3966  if (signal (SIGHUP, SIG_IGN) != SIG_IGN) {
3967  (void)signal (SIGHUP, cobc_sig_handler);
3968  }
3969 #endif
3970 #ifdef SIGQUIT
3971  if (signal (SIGQUIT, SIG_IGN) != SIG_IGN) {
3972  (void)signal (SIGQUIT, cobc_sig_handler);
3973  }
3974 #endif
3975 #ifdef SIGTERM
3976  if (signal (SIGTERM, SIG_IGN) != SIG_IGN) {
3977  (void)signal (SIGTERM, cobc_sig_handler);
3978  }
3979 #endif
3980 #ifdef SIGPIPE
3981  if (signal (SIGPIPE, SIG_IGN) != SIG_IGN) {
3982  (void)signal (SIGPIPE, cobc_sig_handler);
3983  }
3984 #endif
3985  /* Take direct control of segmentation violation */
3986 #ifdef SIGSEGV
3987  (void)signal (SIGSEGV, cobc_sig_handler);
3988 #endif
3989 #endif
3990 
3991 #endif
3992 
3993  cb_saveargc = argc;
3994  cb_saveargv = argv;
3995 
3996  /* General buffers */
3997  cobc_buffer = cobc_main_malloc ((size_t)COB_LARGE_BUFF);
3999  basename_buffer = cobc_main_malloc ((size_t)COB_MINI_BUFF);
4000  basename_len = COB_MINI_MAX - 16;
4001 
4002  cobc_libs = cobc_main_malloc ((size_t)COB_SMALL_BUFF);
4003  cobc_lib_paths = cobc_main_malloc ((size_t)COB_SMALL_BUFF);
4004  cobc_cflags = cobc_main_malloc ((size_t)COB_MINI_BUFF);
4005  cobc_ldflags = cobc_main_malloc ((size_t)COB_MINI_BUFF);
4006  cobc_include = cobc_main_malloc ((size_t)COB_MINI_BUFF);
4007 
4013 
4014  cb_source_file = NULL;
4015  save_temps_dir = NULL;
4016  base_string = NULL;
4017  cobc_objects_len = 0;
4018  cb_id = 1;
4019  cb_attr_id = 1;
4020  cb_literal_id = 1;
4021  cb_field_id = 1;
4022 #ifdef COB_EBCDIC_MACHINE
4023  cb_ebcdic_sign = 1;
4024 #else
4025  cb_ebcdic_sign = 0;
4026 #endif
4027 
4028 #ifdef _WIN32
4029  /* Allows running tests under Win */
4030  p = getenv ("COB_UNIX_LF");
4031  if (p && (*p == 'Y' || *p == 'y' || *p == '1')) {
4032  _setmode (_fileno (stdin), _O_BINARY);
4033  _setmode (_fileno (stdout), _O_BINARY);
4034  _setmode (_fileno (stderr), _O_BINARY);
4035  }
4036 #endif
4037 
4038 #ifdef HAVE_SETLOCALE
4039  setlocale (LC_ALL, "");
4040  setlocale (LC_NUMERIC, "C");
4041 #endif
4042 
4043 #ifdef ENABLE_NLS
4045  textdomain (PACKAGE);
4046 #endif
4047 
4048  /* Initialize variables */
4049 
4050  /* Set up build time stamp */
4051  memset (month, 0, sizeof(month));
4052  day = 0;
4053  year = 0;
4054  sscanf (__DATE__, "%s %d %d", month, &day, &year);
4055  if (day && year) {
4056  snprintf (cobc_buffer, (size_t)COB_MINI_MAX,
4057  "%s %2.2d %4.4d %s", month, day, year, __TIME__);
4058  } else {
4059  snprintf (cobc_buffer, (size_t)COB_MINI_MAX,
4060  "%s %s", __DATE__, __TIME__);
4061  }
4063 
4064  output_name = NULL;
4065 
4066  cobc_cc = cobc_getenv ("COB_CC");
4067  if (cobc_cc == NULL) {
4068  cobc_cc = COB_CC;
4069  }
4070 
4071  cob_config_dir = cobc_getenv ("COB_CONFIG_DIR");
4072  if (cob_config_dir == NULL) {
4074  }
4075 
4076  p = cobc_getenv ("COB_CFLAGS");
4077  if (p) {
4079  } else {
4081  }
4082 
4083  p = cobc_getenv ("COB_LDFLAGS");
4084  if (p) {
4086  } else {
4088  }
4089 
4090  p = cobc_getenv ("COB_LIBS");
4091  if (p) {
4093  } else {
4095  }
4096 
4097  p = cobc_getenv ("COB_LDADD");
4098  if (p) {
4099  COBC_ADD_STR (cobc_libs, " ", p, NULL);
4100  }
4101 
4102  p = cobc_getenv ("COB_LIB_PATHS");
4103  if (p) {
4105  } else {
4107  }
4108 
4109  /* Different styles for warning/error messages */
4110  p = cobc_getenv ("COB_MSG_FORMAT");
4111 #if defined (_MSC_VER)
4112  if (p && strcasecmp(p, "GCC") == 0) {
4114  } else {
4116  }
4117 #else
4118  if (p && strcasecmp(p, "MSC") == 0) {
4120  } else {
4122  }
4123 #endif
4124 
4125  /* Set default computed goto usage if appropriate */
4126 #if defined(__GNUC__) && !defined(__clang__)
4127  cb_flag_computed_goto = 1;
4128 #elif defined(__SUNPRO_C) && __SUNPRO_C >= 0x570
4129  cb_flag_computed_goto = 1;
4130 #elif defined(__xlc__) && defined(__IBMC__) && __IBMC__ >= 700
4131  cb_flag_computed_goto = 1;
4132  COBC_ADD_STR (cobc_cflags, " -qlanglvl=extended",
4133  NULL, NULL);
4134 #endif
4135 
4136  /* Compiler special options */
4137 
4138 #ifdef __WATCOMC__
4139  /* -s = no overflow checks, otherwise need to code/link a CHK routine */
4140  COBC_ADD_STR (cobc_cflags, " -s -wcd=118", NULL, NULL);
4141 #endif
4142 
4143 #ifdef __INTEL_COMPILER
4144  COBC_ADD_STR (cobc_cflags, " -vec-report0 -opt-report 0",
4145  NULL, NULL);
4146 #elif defined(__GNUC__)
4147 #if 0 /* RXWRXW - gcse */
4148  COBC_ADD_STR (cobc_cflags, " -Wno-unused -fsigned-char -fno-gcse",
4149  NULL, NULL);
4150 #else
4151  COBC_ADD_STR (cobc_cflags, " -Wno-unused -fsigned-char",
4152  NULL, NULL);
4153 #endif
4154  /* --param max-goto-duplication-insns=100000 */
4155 #ifdef HAVE_PSIGN_OPT
4156  COBC_ADD_STR (cobc_cflags, " -Wno-pointer-sign", NULL, NULL);
4157 #endif
4158 
4159 #elif defined(__xlc__)
4160  COBC_ADD_STR (cobc_cflags, " -qro -qroconst",
4161  NULL, NULL);
4162 #endif
4163 
4164  /* Enable default I/O exceptions */
4166 
4167  /* Compiler initialization I */
4168 #ifndef HAVE_DESIGNATED_INITS
4169  cobc_init_reserved ();
4170 #endif
4171 
4172  /* Process command line arguments */
4173  iargs = process_command_line (argc, argv);
4174 
4175  /* Check the filename */
4176  if (iargs == argc) {
4177  cobc_err_exit (_("No input files"));
4178  }
4179 
4180  /* Windows stuff reliant upon verbose option */
4181 #ifdef _MSC_VER
4182  if (!verbose_output) {
4183  COBC_ADD_STR (cobc_cflags, " /nologo", NULL, NULL);
4184  }
4185 #if _MSC_VER >= 1400
4186  if (!verbose_output) {
4187  manicmd = "mt /nologo";
4188  manilink = "/link /nologo /manifest";
4189  } else {
4190  manicmd = "mt";
4191  manilink = "/link /manifest";
4192  }
4193 #else
4194  if (!verbose_output) {
4195  manilink = "/link /nologo";
4196  } else {
4197  manilink = "/link";
4198  }
4199 #endif
4200  manilink_len = strlen (manilink);
4201 #endif
4202 
4203 #ifdef __WATCOMC__
4204  if (!verbose_output) {
4205  COBC_ADD_STR (cobc_cflags, " -q", NULL, NULL);
4206  }
4207 #endif
4208 
4209 #if 0 /* gcc opts */
4210 
4211 #if defined(__GNUC__) && !defined (__INTEL_COMPILER)
4212  if (!gflag_set && !cobc_wants_debug && !aflag_set) {
4213  COBC_ADD_STR (cobc_cflags, " -fomit-frame-pointer",
4214  " -fno-asynchronous-unwind-tables",
4215  " -U_FORTIFY_SOURCE");
4216 #if 0 /* RXWRXW - Default opt */
4217  if (!cob_optimize) {
4219  }
4220 #endif
4221 #ifdef HAVE_UNWIND_OPT
4222 #endif
4223  }
4224 #endif
4225 
4226 #endif
4227 
4228  /* Append default extensions */
4236 
4237  /* Process COB_COPY_DIR and COBCPY environment variables */
4238  process_env_copy_path (getenv ("COB_COPY_DIR"));
4239  process_env_copy_path (getenv ("COBCPY"));
4240 
4241  /* Add default COB_COPY_DIR directory */
4243 
4244  /* Defaults are set here */
4245  if (!cb_flag_syntax_only) {
4246  if (!wants_nonfinal) {
4247  if (cobc_flag_main) {
4249  } else if (cobc_flag_module) {
4251  } else if (cobc_flag_library) {
4253  } else if (cb_compile_level == 0) {
4255  cobc_flag_module = 1;
4256  }
4257  }
4260  cobc_flag_module = 1;
4261  }
4262  } else {
4264  cobc_flag_main = 0;
4265  cobc_flag_module = 0;
4266  cobc_flag_library = 0;
4267  }
4268 
4270  (argc - iargs) > 1) {
4271  cobc_err_exit (_("-o option invalid in this combination"));
4272  }
4273 
4274  if (cb_flag_notrunc) {
4275  cb_binary_truncate = 0;
4276  cb_pretty_display = 0;
4277  }
4278 
4279  /* Compiler initialization II */
4280 #ifndef HAVE_DESIGNATED_INITS
4281  cobc_init_scanner ();
4282  cobc_init_typeck ();
4283 #endif
4284 
4285  /* If -P=file specified, all lists go to this file */
4286  if (cobc_list_file) {
4287  cb_listing_file = fopen (cobc_list_file, "w");
4288  if (!cb_listing_file) {
4290  }
4291  }
4292 
4293  if (verbose_output) {
4294  fputs (_("Command line:"), stderr);
4295  putc ('\t', stderr);
4296  for (i = 0; i < argc; ++i) {
4297  fprintf (stderr, "%s ", argv[i]);
4298  }
4299  putc ('\n', stderr);
4300  fflush (stderr);
4301  }
4302 
4303  cobc_cc_len = strlen (cobc_cc);
4304  cobc_cflags_len = strlen (cobc_cflags);
4305  cobc_libs_len = strlen (cobc_libs);
4307  cobc_include_len = strlen (cobc_include);
4308  cobc_ldflags_len = strlen (cobc_ldflags);
4311  cobc_pic_flags_len = strlen (COB_PIC_FLAGS);
4312 
4313  /* Process input files */
4314  status = 0;
4315  iparams = 0;
4316  local_level = 0;
4317  while (iargs < argc) {
4318  /* Set up file parameters */
4319  fn = process_filename (argv[iargs++]);
4320  if (!fn) {
4321  cobc_clean_up (1);
4322  return 1;
4323  }
4324  cb_id = 1;
4325  cb_attr_id = 1;
4326  cb_literal_id = 1;
4327  cb_field_id = 1;
4329  memset (optimize_defs, 0, sizeof(optimize_defs));
4330  iparams++;
4331  if (iparams > 1 && cb_compile_level == CB_LEVEL_EXECUTABLE) {
4332  local_level = cb_compile_level;
4334  cobc_flag_main = 0;
4335  }
4336 
4338  fn->need_preprocess) {
4339  /* Preprocess */
4340  fn->has_error = preprocess (fn);
4341  status |= fn->has_error;
4342  }
4343  if (cobc_list_file) {
4344  putc ('\n', cb_listing_file);
4345  }
4346 
4347  if (cb_compile_level < CB_LEVEL_TRANSLATE || fn->has_error) {
4348  continue;
4349  }
4350  if (fn->need_translate) {
4351  /* Parse / Translate (to C code) */
4352  fn->has_error = process_translate (fn);
4353  status |= fn->has_error;
4354  /* Free parse memory */
4355  for (mptr = cobc_parsemem_base; mptr; ) {
4356  mptrt = mptr;
4357  mptr = mptr->next;
4358  cobc_free (mptrt);
4359  }
4361  }
4363  cb_flag_syntax_only || fn->has_error) {
4364  continue;
4365  }
4367  /* Compile to assembler code */
4368  fn->has_error = process_compile (fn);
4369  status |= fn->has_error;
4370  continue;
4371  }
4372 
4374  /* Build module direct */
4375  fn->has_error = process_module_direct (fn);
4376  status |= fn->has_error;
4377  } else {
4378  /* Compile to object code */
4380  fn->need_assemble) {
4381  fn->has_error = process_assemble (fn);
4382  status |= fn->has_error;
4383  }
4384  if (fn->has_error) {
4385  continue;
4386  }
4387 
4388  /* Build module */
4390  fn->has_error = process_module (fn);
4391  status |= fn->has_error;
4392  }
4393  }
4394  }
4395 
4396  if (cobc_list_file) {
4397  fclose (cb_listing_file);
4399  }
4400 
4401  /* Clear rest of preprocess stuff */
4402  plex_clear_all ();
4403 
4404  /* Clear rest of parser stuff */
4405  ylex_clear_all ();
4406 
4407  if (local_level == CB_LEVEL_EXECUTABLE) {
4409  }
4410 
4412  status || cb_flag_syntax_only) {
4413  /* Finished */
4414  cobc_clean_up (status);
4415  return status;
4416  }
4417 
4418  /* Allocate objects buffer */
4420 
4421  /* Link */
4423  /* Multi-program module */
4424  status = process_library (file_list);
4425  } else {
4426  /* Executable */
4427  status = process_link (file_list);
4428  }
4429 
4430  /* We have completed */
4431  cobc_clean_up (status);
4432 
4433  return status;
4434 }
static int preprocess ( struct filename fn)
static

References _, cb_listing_file, cb_source_format, cobc_buffer, cobc_cmd_print(), cobc_free(), cobc_free_mem(), cobc_gen_listing, cobc_list_file, cobc_terminate(), errorcount, 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().

3099 {
3100  struct cobc_mem_struct *m;
3101  struct cobc_mem_struct *ml;
3102  int save_source_format;
3103  int save_fold_copy;
3104  int save_fold_call;
3105  int ret;
3106 
3107  errorcount = 0;
3108 
3109  ppout = fopen (fn->preprocess, "w");
3110  if (!ppout) {
3111  cobc_terminate (fn->preprocess);
3112  }
3113 
3114  if (ppopen (fn->source, NULL) != 0) {
3115  fclose (ppout);
3116  ppout = NULL;
3117  if (fn->preprocess) {
3118  (void)unlink (fn->preprocess);
3119  }
3120  cobc_free_mem ();
3121  exit (1);
3122  }
3123 
3124  if (verbose_output) {
3125  fputs (_("Preprocessing:"), stderr);
3126  fprintf (stderr, "\t%s -> %s\n",
3127  fn->source, fn->preprocess);
3128  fflush (stderr);
3129  }
3130 
3131  if (cobc_gen_listing && !cobc_list_file) {
3132  cb_listing_file = fopen (fn->listing_file, "w");
3133  if (!cb_listing_file) {
3135  }
3136  }
3137 
3138  /* Reset pplex/ppparse variables */
3139  plex_clear_vars ();
3141 
3142  /* Save default flags in case program directives change them */
3143  save_source_format = cb_source_format;
3144  save_fold_copy = cb_fold_copy;
3145  save_fold_call = cb_fold_call;
3146 
3147  /* Preprocess */
3148  ppparse ();
3149 
3150  /* Restore default flags */
3151  cb_source_format = save_source_format;
3152  cb_fold_copy = save_fold_copy;
3153  cb_fold_call = save_fold_call;
3154 
3155  if (ppin) {
3156  fclose (ppin);
3157  ppin = NULL;
3158  }
3159 
3160  if (ppout) {
3161  if (unlikely(fclose(ppout) != 0)) {
3163  }
3164  ppout = NULL;
3165  }
3166 
3167  /* Release flex buffers - After file close */
3168  plex_call_destroy ();
3169 
3170  for (m = cobc_plexmem_base; m; ) {
3171  ml = m;
3172  m = m->next;
3173  cobc_free (ml);
3174  }
3176 
3177  if (cobc_gen_listing && !cobc_list_file) {
3178  if (unlikely(fclose (cb_listing_file) != 0)) {
3180  }
3181  if (cobc_gen_listing > 1) {
3182  sprintf (cobc_buffer, "cobxref %s -R", fn->listing_file);
3183  if (verbose_output) {
3185  }
3186  ret = system (cobc_buffer);
3187  if (verbose_output) {
3188  fputs (_("Return status:"), stderr);
3189  fprintf (stderr, "\t%d\n", ret);
3190  fflush (stderr);
3191  }
3192  if (ret) {
3193  fputs (_("'cobxref' execution unsuccessful"),
3194  stderr);
3195  putc ('\n', stderr);
3196 #ifdef _WIN32
3197  fputs (_("Check that 'cobxref' is in %%PATH%%"),
3198  stderr);
3199 #else
3200  fputs (_("Check that 'cobxref' is in $PATH"),
3201  stderr);
3202 #endif
3203  putc ('\n', stderr);
3204  fputs (_("No listing produced"),
3205  stderr);
3206  putc ('\n', stderr);
3207  fflush (stderr);
3208  }
3209  unlink (fn->listing_file);
3210  }
3212  }
3213 
3214  if (verbose_output) {
3215  fputs (_("Return status:"), stderr);
3216  fprintf (stderr, "\t%d\n", errorcount);
3217  fflush (stderr);
3218  }
3219  return !!errorcount;
3220 }
static int process ( const char *  cmd)
static

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

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

3038 {
3039  char *p;
3040  char *buffptr;
3041  size_t clen;
3042  int ret;
3043 
3044  if (likely(strchr (cmd, '$') == NULL)) {
3045  buffptr = (char *)cmd;
3046  } else {
3047  clen = strlen (cmd) + 64U;
3048  clen = clen + 6U;
3049  buffptr = (char *)cobc_malloc (clen);
3050  p = buffptr;
3051  /* Quote '$' */
3052  for (; *cmd; ++cmd) {
3053  if (*cmd == '$') {
3054  p += sprintf (p, "\\$");
3055  } else {
3056  *p++ = *cmd;
3057  }
3058  }
3059  *p = 0;
3060  }
3061 
3062  if (verbose_output) {
3063  cobc_cmd_print (buffptr);
3064  }
3065 
3066  ret = system (buffptr);
3067 
3068  if (unlikely(buffptr != cmd)) {
3069  cobc_free (buffptr);
3070  }
3071 
3072 #ifdef WIFSIGNALED
3073  if (WIFSIGNALED(ret)) {
3074 #ifdef SIGINT
3075  if (WTERMSIG(ret) == SIGINT) {
3076  cobc_sig_handler (SIGINT);
3077  }
3078 #endif
3079 #ifdef SIGQUIT
3080  if (WTERMSIG(ret) == SIGQUIT) {
3081  cobc_sig_handler (SIGQUIT);
3082  }
3083 #endif
3084  }
3085 #endif
3086  if (verbose_output) {
3087  fputs (_("Return status:"), stderr);
3088  fprintf (stderr, "\t%d\n", ret);
3089  fflush (stderr);
3090  }
3091  return !!ret;
3092 }
static int process_assemble ( struct filename fn)
static

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_include, cobc_include_len, cobc_main_malloc(), cobc_pic_flags_len, gflag_set, if(), filename::object, filename::object_len, p, process(), filename::translate, and filename::translate_len.

Referenced by main().

3433 {
3434  size_t bufflen;
3435 #ifdef __OS400__
3436  char *name;
3437 #endif
3438 
3439  bufflen = cobc_cc_len + cobc_cflags_len + fn->object_len
3441  + cobc_pic_flags_len + 64U;
3442 
3443  cobc_chk_buff_size (bufflen);
3444 
3445 #ifdef _MSC_VER
3446  sprintf (cobc_buffer, gflag_set ?
3447  "%s /c %s %s /Od /MDd /Zi /FR /Fo\"%s\" \"%s\"" :
3448  "%s /c %s %s /MD /Fo\"%s\" \"%s\"",
3450  fn->object, fn->translate);
3451  return process (cobc_buffer, fn);
3452 #elif defined(__OS400__)
3453  name = (char *) fn->translate;
3454  if (name[0] != '/') {
3455  char *p;
3456 
3457  p = cobc_main_malloc (COB_LARGE_BUFF);
3458  getcwd (p, COB_LARGE_BUFF);
3459  strcat (p, "/");
3460  strcat (p, name);
3461  name = p;
3462  }
3463  file_stripext ((char *) fn->object);
3464  sprintf (cobc_buffer, "%s -c %s %s -o %s %s",
3466  fn->object, name);
3467  return process (cobc_buffer);
3468 #elif defined(__WATCOMC__)
3471  sprintf (cobc_buffer, "%s -c %s %s %s -fe=\"%s\" \"%s\"",
3473  COB_PIC_FLAGS, fn->object, fn->translate);
3474  } else {
3475  sprintf (cobc_buffer, "%s -c %s %s -fe=\"%s\" \"%s\"",
3477  fn->object, fn->translate);
3478  }
3479  return process (cobc_buffer);
3480 #else
3484  sprintf (cobc_buffer, "%s -c %s %s %s -o \"%s\" \"%s\"",
3486  COB_PIC_FLAGS, fn->object, fn->translate);
3487  } else {
3488  // Only for CB_LEVEL_EXECUTABLE
3489  sprintf (cobc_buffer, "%s -c %s %s -o \"%s\" \"%s\"",
3491  fn->object, fn->translate);
3492  }
3493  return process(cobc_buffer);
3494 #endif
3495 
3496 }
static int process_command_line ( const int  argc,
char **  argv 
)
static

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_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_TEXT_LIST_ADD, 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_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, configuration_error(), exit_option, gflag_set, cb_text_list::next, no_physical_cancel, NULL, output_name, output_name_buff, p, save_all_src, save_c_src, save_temps, save_temps_dir, short_options, strip_output, cb_text_list::text, verbose_output, wants_nonfinal, and warningopt.

Referenced by main().

1883 {
1884  struct cb_define_struct *p;
1885  size_t osize;
1886  int c;
1887  int idx;
1888  int n;
1889 #ifdef _WIN32
1890  int argnum;
1891 #endif
1892  enum cob_exception_id i;
1893  struct stat st;
1894  char ext[COB_MINI_BUFF];
1895  struct cb_text_list *cb_conf_override_list = NULL;
1896  struct cb_text_list *covl;
1897 
1898  int ret = 0;
1899  int sub_ret;
1900 
1901 #ifdef _WIN32
1902  /* Translate command line arguments from WIN to UNIX style */
1903  argnum = 1;
1904  while (++argnum <= argc) {
1905  if (strrchr(argv[argnum - 1], '/') == argv[argnum - 1]) {
1906  argv[argnum - 1][0] = '-';
1907  }
1908  }
1909 #endif
1910 
1911  while ((c = cob_getopt_long_long (argc, argv, short_options,
1912  long_options, &idx, 1)) >= 0) {
1913  switch (c) {
1914  case 0:
1915  /* Defined flag */
1916  break;
1917 
1918  case '?':
1919  /* Unknown option or ambiguous */
1920  cobc_free_mem ();
1921  exit (1);
1922 
1923  case 'h':
1924  /* --help */
1925  cobc_print_usage (argv[0]);
1926  cobc_free_mem ();
1927  exit (0);
1928 
1929  case 'V':
1930  /* --version */
1931  cobc_print_version ();
1932  exit_option = 1;
1933  break;
1934 
1935  case 'i':
1936  /* --info */
1937  cobc_print_info ();
1938  exit_option = 1;
1939  break;
1940 
1941  case '5':
1942  /* --list-reserved */
1943  cb_list_reserved ();
1944  exit_option = 1;
1945  break;
1946 
1947  case '6':
1948  /* --list-intrinsics */
1949  cb_list_intrinsics ();
1950  exit_option = 1;
1951  break;
1952 
1953  case '7':
1954  /* --list-mnemonics */
1955  cb_list_mnemonics ();
1956  exit_option = 1;
1957  break;
1958 
1959  case '8':
1960  /* --list-system */
1961  cb_list_system ();
1962  exit_option = 1;
1963  break;
1964 
1965  case 'E':
1966  /* -E : Preprocess */
1967  if (wants_nonfinal) {
1969  }
1970  wants_nonfinal = 1;
1972  break;
1973 
1974  case 'C':
1975  /* -C : Generate C code */
1976  if (wants_nonfinal) {
1978  }
1979  save_c_src = 1;
1980  wants_nonfinal = 1;
1982  break;
1983 
1984  case 'S':
1985  /* -S : Generate assembler code */
1986  if (wants_nonfinal) {
1988  }
1989  wants_nonfinal = 1;
1991  break;
1992 
1993  case 'c':
1994  /* -c : Generate C object code */
1995  if (wants_nonfinal) {
1997  }
1998  wants_nonfinal = 1;
2000  break;
2001 
2002  case 'b':
2003  /* -b : Generate combined library module */
2006  }
2007  cobc_flag_library = 1;
2008  no_physical_cancel = 1;
2009  cb_flag_implicit_init = 1;
2010  break;
2011 
2012  case 'm':
2013  /* -m : Generate loadable module (default) */
2016  }
2017  cobc_flag_module = 1;
2018  break;
2019 
2020  case 'x':
2021  /* -x : Generate executable */
2024  }
2025  cobc_flag_main = 1;
2026  cb_flag_main = 1;
2027  no_physical_cancel = 1;
2028  break;
2029 
2030  case 'v':
2031  /* -v : Verbose reporting */
2032  verbose_output = 1;
2033  break;
2034 
2035  case 'o':
2036  /* -o : Output file */
2037  osize = strlen (cob_optarg);
2038  if (osize > COB_SMALL_MAX) {
2039  cobc_err_exit (_("Invalid output file name"));
2040  }
2042  /* Allocate buffer plus extension reserve */
2043  output_name_buff = cobc_main_malloc (osize + 32U);
2044  break;
2045 
2046  case 'O':
2047  /* -O : Optimize */
2048  cob_optimize = 1;
2050  break;
2051 
2052  case '9':
2053  /* -O2 : Optimize */
2054  cob_optimize = 1;
2055  strip_output = 1;
2057  break;
2058 
2059  case 's':
2060  /* -Os : Optimize */
2061  cob_optimize = 1;
2062  strip_output = 1;
2064  break;
2065 
2066  case 'g':
2067  /* -g : Generate C debug code */
2068  save_all_src = 1;
2069  gflag_set = 1;
2070  cb_flag_stack_check = 1;
2071  cb_flag_source_location = 1;
2072 #ifndef _MSC_VER
2073  COBC_ADD_STR (cobc_cflags, " -g", NULL, NULL);
2074 #endif
2075  break;
2076 
2077  case '$':
2078  /* -std=<xx> : Specify dialect */
2079  snprintf (ext, (size_t)COB_MINI_MAX, "%s.conf", cob_optarg);
2080  if (cb_load_std (ext) != 0) {
2081  cobc_err_exit (_("Invalid option -std=%s"),
2082  cob_optarg);
2083  }
2084  break;
2085 
2086  case '&':
2087  /* -conf=<xx> : Specify dialect configuration file */
2088  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2089  cobc_err_exit (COBC_INV_PAR , "-conf");
2090  }
2091  sub_ret = cb_load_conf (cob_optarg, 1, 0);
2092  if (sub_ret != 0) ret = sub_ret;
2093  break;
2094 
2095  case '%':
2096  /* -cb_conf=<xx:yy> : Override configuration entry */
2097  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2098  cobc_err_exit (COBC_INV_PAR , "-cb_conf");
2099  }
2100  /* postponed as we need full configuration loaded before */
2101  CB_TEXT_LIST_ADD (cb_conf_override_list, cob_optarg);
2102  break;
2103 
2104  case 'd':
2105  /* -debug : Turn on OC debugging */
2106  /* Turn on all exception conditions */
2107  for (i = (enum cob_exception_id)1; i < COB_EC_MAX; ++i) {
2108  CB_EXCEPTION_ENABLE (i) = 1;
2109  }
2110  cb_flag_source_location = 1;
2111  cb_flag_trace = 1;
2112  cb_flag_stack_check = 1;
2113  cobc_wants_debug = 1;
2114  break;
2115 
2116  case '_':
2117  /* --save-temps : Save intermediary files */
2118  save_temps = 1;
2119  if (cob_optarg) {
2120  if (stat (cob_optarg, &st) != 0 ||
2121  !(S_ISDIR (st.st_mode))) {
2122  cobc_abort_pr (_("Warning - '%s' is not a directory, defaulting to current directory"), cob_optarg);
2123  } else {
2125  }
2126  }
2127  break;
2128 
2129  case 'P':
2130  /* -P : Generate listing */
2131  if (cob_optarg) {
2132  if (!stat (cob_optarg, &st) && S_ISDIR (st.st_mode)) {
2134  } else {
2136  }
2137  }
2138  if (!cobc_gen_listing) {
2139  cobc_gen_listing = 1;
2140  }
2141  break;
2142 
2143  case 'X':
2144  /* -Xref : Generate listing through 'cobxref' */
2145  cobc_gen_listing = 2;
2146  break;
2147 
2148  case 'D':
2149  /* -D xx(=yy) : Define variables */
2150  if (strlen (cob_optarg) > 64U) {
2151  cobc_err_exit (COBC_INV_PAR, "-D");
2152  }
2153  if (!strcasecmp (cob_optarg, "ebug")) {
2154  cobc_abort_pr (_("Warning - assuming '%s' is a DEFINE - did you intend to use -debug?"),
2155  cob_optarg);
2156  }
2158  if (!p) {
2159  cobc_err_exit (COBC_INV_PAR, "-D");
2160  }
2161  cb_define_list = p;
2162  break;
2163 
2164  case 'I':
2165  /* -I <xx> : Include/copy directory */
2166  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2167  cobc_err_exit (COBC_INV_PAR, "-I");
2168  }
2169  if (stat (cob_optarg, &st) != 0 ||
2170  !(S_ISDIR (st.st_mode))) {
2171  break;
2172  }
2173 #ifdef _MSC_VER
2174  COBC_ADD_STR (cobc_include, " /I \"", cob_optarg, "\"");
2175 #elif defined (__WATCOMC__)
2176  COBC_ADD_STR (cobc_include, " -i\"", cob_optarg, "\"");
2177 #else
2178  COBC_ADD_STR (cobc_include, " -I\"", cob_optarg, "\"");
2179 #endif
2181  break;
2182 
2183  case 'L':
2184  /* -L <xx> : Directory for library search */
2185  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2186  cobc_err_exit (COBC_INV_PAR, "-L");
2187  }
2188  if (stat (cob_optarg, &st) != 0 ||
2189  !(S_ISDIR (st.st_mode))) {
2190  break;
2191  }
2192 #ifdef _MSC_VER
2193  COBC_ADD_STR (cobc_lib_paths, " /LIBPATH:\"", cob_optarg, "\"");
2194 #else
2195  COBC_ADD_STR (cobc_lib_paths, " -L\"", cob_optarg, "\"");
2196 #endif
2197  break;
2198 
2199  case 'l':
2200  /* -l <xx> : Add library to link phase */
2201  if (strlen (cob_optarg) > COB_SMALL_MAX) {
2202  cobc_err_exit (COBC_INV_PAR, "-l");
2203  }
2204 #ifdef _MSC_VER
2205  COBC_ADD_STR (cobc_libs, " \"", cob_optarg, ".lib\"");
2206 #else
2207  COBC_ADD_STR (cobc_libs, " -l\"", cob_optarg, "\"");
2208 #endif
2209  break;
2210 
2211  case 'e':
2212  /* -e <xx> : Add an extension suffix */
2213  if (strlen (cob_optarg) > 15U) {
2214  cobc_err_exit (COBC_INV_PAR, "--ext");
2215  }
2216  snprintf (ext, (size_t)COB_MINI_MAX, ".%s", cob_optarg);
2218  break;
2219 
2220  case 'K':
2221  /* -K <xx> : Define literal CALL to xx as static */
2222  if (strlen (cob_optarg) > 32U) {
2223  cobc_err_exit (COBC_INV_PAR, "-K");
2224  }
2226  break;
2227 
2228  case 'k':
2229  /* -k <xx> : Check for exit after CALL to xx */
2230  /* This is to cater for legacy German DIN standard */
2231  /* Check after CALL if an exit program required */
2232  /* Not in --help as subject to change and highly specific */
2233  if (strlen (cob_optarg) > 32U) {
2234  cobc_err_exit (COBC_INV_PAR, "-k");
2235  }
2237  break;
2238 
2239  case 1:
2240  /* -fstack-size=<xx> : Specify stack (perform) size */
2241  n = cobc_deciph_optarg (cob_optarg, 0);
2242  if (n < 16 || n > 512) {
2243  cobc_err_exit (COBC_INV_PAR, "-fstack-size");
2244  }
2245  cb_stack_size = n;
2246  break;
2247 
2248  case 2:
2249  /* -fif-cutoff=<xx> : Specify IF cutoff level */
2250  n = cobc_deciph_optarg (cob_optarg, 0);
2251  if (n < 1 || n > 512) {
2252  cobc_err_exit (COBC_INV_PAR, "-fif-cutoff");
2253  }
2254  cb_if_cutoff = n;
2255  break;
2256 
2257  case 3:
2258  /* -fsign=<ASCII/EBCDIC> : Specify display sign */
2259  if (!strcasecmp (cob_optarg, "EBCDIC")) {
2260  cb_ebcdic_sign = 1;
2261  } else if (!strcasecmp (cob_optarg, "ASCII")) {
2262  cb_ebcdic_sign = 0;
2263  } else {
2264  cobc_err_exit (COBC_INV_PAR, "-fsign");
2265  }
2266  break;
2267 
2268  case 4:
2269  /* -ffold-copy=<UPPER/LOWER> : COPY fold case */
2270  if (!strcasecmp (cob_optarg, "UPPER")) {
2271  cb_fold_copy = COB_FOLD_UPPER;
2272  } else if (!strcasecmp (cob_optarg, "LOWER")) {
2273  cb_fold_copy = COB_FOLD_LOWER;
2274  } else {
2275  cobc_err_exit (COBC_INV_PAR, "-ffold-copy");
2276  }
2277  break;
2278 
2279  case 5:
2280  /* -ffold-call=<UPPER/LOWER> : CALL/PROG-ID fold case */
2281  if (!strcasecmp (cob_optarg, "UPPER")) {
2282  cb_fold_call = COB_FOLD_UPPER;
2283  } else if (!strcasecmp (cob_optarg, "LOWER")) {
2284  cb_fold_call = COB_FOLD_LOWER;
2285  } else {
2286  cobc_err_exit (COBC_INV_PAR, "-ffold-call");
2287  }
2288  break;
2289 
2290  case 6:
2291  /* -fdefaultbyte=<xx> : Default initialization byte */
2292  n = cobc_deciph_optarg (cob_optarg, 1);
2293  if (n < 0 || n > 255) {
2294  cobc_err_exit (COBC_INV_PAR, "-fdefaultbyte");
2295  }
2296  cb_default_byte = n;
2297  break;
2298 
2299  case 10:
2300  /* -fintrinsics=<xx> : Intrinsic name or ALL */
2302  break;
2303 
2304  case 'A':
2305  /* -A <xx> : Add options to C compile phase */
2307  aflag_set = 1;
2308  break;
2309 
2310  case 'Q':
2311  /* -Q <xx> : Add options to C link phase */
2313  break;
2314 
2315  case 'w':
2316  /* -w(xx) : Turn off warnings */
2317 #undef CB_WARNDEF
2318 #undef CB_NOWARNDEF
2319 #define CB_WARNDEF(var,name,doc) var = 0;
2320 #define CB_NOWARNDEF(var,name,doc) var = 0;
2321 #include "warning.def"
2322 #undef CB_WARNDEF
2323 #undef CB_NOWARNDEF
2324  break;
2325 
2326  case 'W':
2327  /* -W : Turn on warnings */
2328  warningopt = 1;
2329 #undef CB_WARNDEF
2330 #undef CB_NOWARNDEF
2331 #define CB_WARNDEF(var,name,doc) var = 1;
2332 #define CB_NOWARNDEF(var,name,doc)
2333 #include "warning.def"
2334 #undef CB_WARNDEF
2335 #undef CB_NOWARNDEF
2336  break;
2337 
2338  case 'Z':
2339  /* -W : Turn on all warnings */
2340  warningopt = 1;
2341 #undef CB_WARNDEF
2342 #undef CB_NOWARNDEF
2343 #define CB_WARNDEF(var,name,doc) var = 1;
2344 #define CB_NOWARNDEF(var,name,doc) var = 1;
2345 #include "warning.def"
2346 #undef CB_WARNDEF
2347 #undef CB_NOWARNDEF
2348  break;
2349 
2350  default:
2351  cobc_err_exit (_("Invalid option detected"));
2352  }
2353  }
2354 
2355  /* Exit if list options specified */
2356  if (exit_option) {
2357  cobc_free_mem ();
2358  exit (0);
2359  }
2360 
2361  /* Load default configuration file if necessary */
2362  if (cb_config_name == NULL) {
2363  sub_ret = cb_load_std ("default.conf");
2364  if (sub_ret != 0) {
2365 #if 0 /* Simon: likely too verbose */
2366  configuration_error ("default.conf", 0, _("Failed to load the initial config file"));
2367 #endif
2368  ret = sub_ret;
2369  }
2370  }
2371  /* Do postponed override of configuration entries here */
2372  if (cb_conf_override_list) {
2373  for (covl = cb_conf_override_list; covl; covl = covl->next) {
2374  sub_ret = cb_config_entry ((char *)covl->text, NULL, 0);
2375  if (sub_ret != 0) ret = sub_ret;
2376  }
2377  /* Todo: free list */
2378  }
2379  /* Exit for configuration errors */
2380  if (ret != 0) {
2381  cobc_free_mem ();
2382  exit (1);
2383  }
2384 
2385  /* Check valid tab width */
2386  if (cb_tab_width < 1 || cb_tab_width > 8) {
2387  cobc_err_exit (_("Invalid tab-width value - %d"),
2388  cb_tab_width);
2389  }
2390 
2391  /* Check valid text columns value */
2392  if (cb_text_column < 72 || cb_text_column > 255) {
2393  cobc_err_exit (_("Invalid text-column value - %d"),
2394  cb_text_column);
2395  }
2396 
2397  /* Set relaxed syntax parameters */
2398  if (cb_flag_relaxed_syntax) {
2399  cb_relaxed_syntax_check = 1;
2400  cb_larger_redefines_ok = 1;
2401  cb_relax_level_hierarchy = 1;
2402  cb_top_level_occurs_clause = 1;
2403  }
2404 
2405  /* If C debug, do not strip output */
2406  if (gflag_set) {
2407  strip_output = 0;
2408  }
2409 
2410  if (cb_flag_traceall) {
2411  cb_flag_trace = 1;
2412  cb_flag_source_location = 1;
2413  }
2414 
2415  return cob_optind;
2416 }
static int process_compile ( struct filename fn)
static

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, and filename::translate_len.

Referenced by main().

3386 {
3387  char *name;
3388  size_t bufflen;
3389  size_t size;
3390 
3391  if (output_name) {
3392  name = output_name;
3393  } else {
3394  name = file_basename (fn->source);
3395 #ifndef _MSC_VER
3396  strcat (name, ".s");
3397 #endif
3398  }
3399  size = strlen (name);
3400 #ifdef _MSC_VER
3401  size *= 2U;
3402 #endif
3403 
3404  bufflen = cobc_cc_len + cobc_cflags_len
3405  + size + fn->translate_len
3406  + cobc_include_len + 64U;
3407 
3408  cobc_chk_buff_size (bufflen);
3409 
3410 #ifdef _MSC_VER
3411  sprintf (cobc_buffer, gflag_set ?
3412  "%s /c %s %s /Od /MDd /Zi /FR /c /Fa\"%s\" /Fo\"%s\" \"%s\"" :
3413  "%s /c %s %s /MD /c /Fa\"%s\" /Fo\"%s\" \"%s\"",
3415  name, fn->translate);
3416  return process (cobc_buffer, fn);
3417 #elif defined(__WATCOMC__)
3418  sprintf (cobc_buffer, "%s -fe=\"%s\" -s %s %s %s", cobc_cc, name,
3420  return process (cobc_buffer);
3421 #else
3422  sprintf (cobc_buffer, "%s -S -o \"%s\" %s %s %s", cobc_cc, name,
3424  return process(cobc_buffer);
3425 #endif
3426 
3427 }
static void process_env_copy_path ( const char *  p)
static

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

Referenced by main().

2437 {
2438  char *value;
2439  char *token;
2440  struct stat st;
2441 
2442  if (p == NULL || !*p || *p == ' ') {
2443  return;
2444  }
2445 
2446  /* Clone value for destructive strtok */
2447  value = cobc_strdup (p);
2448 
2449  /* Tokenize for path sep. */
2450  token = strtok (value, PATHSEPS);
2451  while (token) {
2452  if (!stat (token, &st) && (S_ISDIR (st.st_mode))) {
2454  }
2455  token = strtok (NULL, PATHSEPS);
2456  }
2457 
2458  cobc_free (value);
2459  return;
2460 }
static struct filename* process_filename ( const char *  filename)
staticread

References _, cb_compile_level, cb_encode_program_id(), CB_LEVEL_ASSEMBLE, CB_LEVEL_PREPROCESS, CB_LEVEL_TRANSLATE, 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_stradd_dup(), cobc_terminate(), filename::demangle_source, extension, file_basename(), file_extension(), 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_STR, filename::source, filename::translate, filename::translate_len, and filename::trstorage.

Referenced by main().

2534 {
2535  const char *extension;
2536  struct filename *fn;
2537  struct filename *ffn;
2538  char *fbasename;
2539  char *listptr;
2540  size_t fsize;
2541 
2542  fsize = strlen (filename);
2543  if (fsize > COB_NORMAL_MAX) {
2544  cobc_abort_pr (_("Invalid file name parameter"));
2545  return NULL;
2546  }
2547 
2548 #ifdef __OS400__
2549  if (strchr (filename, '.') != NULL) {
2550 #endif
2551 
2552  if (access (filename, R_OK) != 0) {
2554  }
2555 
2556 #ifdef __OS400__
2557  }
2558 #endif
2559 
2560  fbasename = file_basename (filename);
2561  extension = file_extension (filename);
2562  if (strcmp(extension, "lib") && strcmp(extension, "a")) {
2563  if (cobc_check_valid_name (fbasename, 0)) {
2564  return NULL;
2565  }
2566  }
2567  fn = cobc_main_malloc (sizeof (struct filename));
2568  fn->need_preprocess = 1;
2569  fn->need_translate = 1;
2570  fn->need_assemble = 1;
2571  fn->next = NULL;
2572 
2573  if (!file_list) {
2574  file_list = fn;
2575  } else {
2576  for (ffn = file_list; ffn->next; ffn = ffn->next)
2577  ;
2578  ffn->next = fn;
2579  }
2580 
2581  fn->demangle_source = cb_encode_program_id (fbasename);
2582 
2583  /* Check input file type */
2584  if (strcmp (extension, "i") == 0) {
2585  /* Already preprocessed */
2586  fn->need_preprocess = 0;
2587  } else if (strcmp (extension, "c") == 0 ||
2588  strcmp (extension, "s") == 0) {
2589  /* Already compiled */
2590  fn->need_preprocess = 0;
2591  fn->need_translate = 0;
2592  }
2593  else if (
2594 #if defined(__OS400__)
2595  extension[0] == 0
2596 #else
2597  strcmp (extension, COB_OBJECT_EXT) == 0
2598 #if defined(_WIN32)
2599  || strcmp(extension, "lib") == 0
2600 #endif
2601 #if !defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__)
2602  || strcmp(extension, "a") == 0
2603  || strcmp(extension, "so") == 0
2604  || strcmp(extension, "dylib") == 0
2605  || strcmp(extension, "sl") == 0
2606 #endif
2607 #endif
2608  ) {
2609  /* Already assembled */
2610  fn->need_preprocess = 0;
2611  fn->need_translate = 0;
2612  fn->need_assemble = 0;
2613  }
2614 
2615  /* Set source filename */
2617 
2618  /* Set preprocess filename */
2619  if (!fn->need_preprocess) {
2620  fn->preprocess = cobc_main_strdup (fn->source);
2623  } else if (save_all_src || save_temps ||
2625  fn->preprocess = cobc_stradd_dup (fbasename, ".i");
2626  } else {
2627  fn->preprocess = cobc_main_malloc(COB_FILE_MAX);
2628  cob_temp_name ((char *)fn->preprocess, ".cob");
2629  }
2630 
2631  /* Set translate filename */
2632  if (!fn->need_translate) {
2633  fn->translate = cobc_main_strdup (fn->source);
2634  } else if (output_name && cb_compile_level == CB_LEVEL_TRANSLATE) {
2636  } else if (save_all_src || save_temps || save_c_src ||
2638  fn->translate = cobc_stradd_dup (fbasename, ".c");
2639  } else {
2640  fn->translate = cobc_main_malloc(COB_FILE_MAX);
2641  cob_temp_name ((char *)fn->translate, ".c");
2642  }
2643  fn->translate_len = strlen (fn->translate);
2644 
2645  /* Set storage filename */
2646  if (fn->need_translate) {
2647  fn->trstorage = cobc_stradd_dup (fn->translate, ".h");
2648  }
2649 
2650  /* Set object filename */
2651  if (!fn->need_assemble) {
2652  fn->object = cobc_main_strdup (fn->source);
2653  } else if (output_name && cb_compile_level == CB_LEVEL_ASSEMBLE) {
2655  } else if (save_temps || cb_compile_level == CB_LEVEL_ASSEMBLE) {
2656  fn->object = cobc_stradd_dup(fbasename, "." COB_OBJECT_EXT);
2657  } else {
2658  fn->object = cobc_main_malloc(COB_FILE_MAX);
2659  cob_temp_name ((char *)fn->object, "." COB_OBJECT_EXT);
2660  }
2661  fn->object_len = strlen (fn->object);
2662  cobc_objects_len += fn->object_len + 8U;
2663 
2664  /* Set listing filename */
2665  if (cobc_gen_listing == 1) {
2666  if (cobc_list_file) {
2668  } else if (cobc_list_dir) {
2669  fsize = strlen (cobc_list_dir) + strlen (fbasename) + 8U;
2670  listptr = cobc_main_malloc (fsize);
2671  snprintf (listptr, fsize, "%s%s%s.lst",
2672  cobc_list_dir, SLASH_STR, fbasename);
2673  fn->listing_file = listptr;
2674  } else {
2675  fn->listing_file = cobc_stradd_dup (fbasename, ".lst");
2676  }
2677  } else if (cobc_gen_listing > 1) {
2678  fn->listing_file = cobc_stradd_dup (fbasename, ".xrf");
2679  }
2680 
2682  return fn;
2683 }
static int process_library ( struct filename l)
static

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_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, file_basename(), gflag_set, filename::next, NULL, filename::object, output_name, output_name_buff, process(), filename::source, and strip_output.

Referenced by main().

3692 {
3693  struct filename *f;
3694  char *name;
3695  size_t bufflen;
3696  size_t size;
3697  int ret;
3698 
3699  for (f = l; f; f = f->next) {
3700  strcat (cobc_objects_buffer, "\"");
3701  strcat (cobc_objects_buffer, f->object);
3702  strcat (cobc_objects_buffer, "\" ");
3703  }
3704 
3705  if (output_name) {
3706  name = output_name_buff;
3707  strcpy (name, output_name);
3708 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3709  file_stripext (name);
3710 #else
3711  if (strchr (output_name, '.') == NULL) {
3712  strcat (name, ".");
3713  strcat (name, COB_MODULE_EXT);
3714  }
3715 #endif
3716  } else {
3717  name = file_basename (l->source);
3718 #if !defined(_MSC_VER) && !defined(__OS400__) && !defined(__WATCOMC__) && !defined(__BORLANDC__)
3719  strcat (name, ".");
3720  strcat (name, COB_MODULE_EXT);
3721 #endif
3722  }
3723 
3724  size = strlen (name);
3725  bufflen = cobc_cc_len + cobc_ldflags_len
3727  + size + cobc_objects_len + cobc_libs_len
3728 #ifdef _MSC_VER
3729  + manilink_len
3730 #endif
3732 
3733  cobc_chk_buff_size (bufflen);
3734 
3735 #ifdef _MSC_VER
3736  sprintf (cobc_buffer, gflag_set ?
3737  "%s /Od /MDd /LDd /Zi /FR /Fe\"%s\" %s %s %s %s %s" :
3738  "%s /MD /LD /Fe\"%s\" %s %s %s %s %s",
3740  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3741  ret = process (cobc_buffer, l);
3742 #if _MSC_VER >= 1400
3743  /* Embedding manifest */
3744  if (ret == 0) {
3745  sprintf (cobc_buffer,
3746  "%s /manifest \"%s.dll.manifest\" /outputresource:\"%s.dll\";#2",
3747  manicmd, name, name);
3748  ret = process (cobc_buffer, l);
3749  sprintf (cobc_buffer, "%s.dll.manifest", name);
3751  }
3752 #endif
3753  sprintf (cobc_buffer, "%s.exp", name);
3755  sprintf (cobc_buffer, "%s.lib", name);
3757 #else /* _MSC_VER */
3758 #ifdef __WATCOMC__
3759  sprintf (cobc_buffer, "%s %s %s %s -fe=\"%s\" %s %s %s %s",
3763 #else
3764  sprintf (cobc_buffer, "%s %s %s %s -o \"%s\" %s %s %s %s",
3768 #endif
3769  ret = process (cobc_buffer);
3770 #ifdef COB_STRIP_CMD
3771  if (strip_output && ret == 0) {
3772  sprintf (cobc_buffer, "%s \"%s\"", COB_STRIP_CMD, name);
3773  ret = process (cobc_buffer);
3774  }
3775 #endif
3776 #endif /* _MSC_VER */
3777  return ret;
3778 }
static int process_link ( struct filename l)
static

References COB_EXEEXT, COB_EXPORT_DYN, COB_STRIP_CMD, cobc_buffer, cobc_cc, cobc_cc_len, cobc_check_action(), cobc_chk_buff_size(), cobc_export_dyn_len, 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, file_basename(), gflag_set, filename::next, filename::object, output_name, process(), filename::source, and strip_output.

Referenced by main().

3784 {
3785  struct filename *f;
3786  char *name;
3787  size_t bufflen;
3788  size_t size;
3789  int ret;
3790 
3791  for (f = l; f; f = f->next) {
3792 #ifdef __OS400__
3793  file_stripext ((char *) f->object);
3794  strcat (cobc_objects_buffer, f->object);
3795  strcat (cobc_objects_buffer, " ");
3796 #else
3797  strcat (cobc_objects_buffer, "\"");
3798  strcat (cobc_objects_buffer, f->object);
3799  strcat (cobc_objects_buffer, "\" ");
3800 #endif
3801  }
3802 
3803  if (output_name) {
3804 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3805  name = cobc_main_strdup (output_name);
3806  file_stripext (name);
3807 #else
3808  name = output_name;
3809 #endif
3810  } else {
3811  name = file_basename (l->source);
3812  }
3813 
3814  size = strlen (name);
3815  bufflen = cobc_cc_len + cobc_ldflags_len
3816  + cobc_export_dyn_len + size
3818 #ifdef _MSC_VER
3819  + manilink_len
3820 #endif
3821  + cobc_lib_paths_len + 64U;
3822 
3823  cobc_chk_buff_size (bufflen);
3824 
3825 #ifdef _MSC_VER
3826  sprintf (cobc_buffer, gflag_set ?
3827  "%s /Od /MDd /Zi /FR /Fe\"%s\" %s %s %s %s %s" :
3828  "%s /MD /Fe\"%s\" %s %s %s %s %s",
3830  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3831  ret = process (cobc_buffer, l);
3832 #if _MSC_VER >= 1400
3833  /* Embedding manifest */
3834  if (ret == 0) {
3835  sprintf (cobc_buffer,
3836  "%s /manifest \"%s.exe.manifest\" /outputresource:\"%s.exe\";#1",
3837  manicmd, name, name);
3838  ret = process (cobc_buffer, l);
3839  sprintf (cobc_buffer, "%s.exe.manifest", name);
3841  }
3842 #endif
3843 #else /* _MSC_VER */
3844 #ifdef __WATCOMC__
3845  sprintf (cobc_buffer, "%s %s -fe=\"%s\" %s %s %s %s",
3848 #else
3849  sprintf (cobc_buffer, "%s %s -o \"%s\" %s %s %s %s",
3852 #endif
3853 
3854  ret = process (cobc_buffer);
3855 
3856 #ifdef __hpux
3857  if (ret == 0) {
3858  sprintf (cobc_buffer, "chatr -s +s enable \"%s%s\" 1>/dev/null 2>&1",
3859  name, COB_EXEEXT);
3860  process (cobc_buffer);
3861  }
3862 #endif
3863 
3864 #ifdef COB_STRIP_CMD
3865  if (strip_output && ret == 0) {
3866  sprintf (cobc_buffer, "%s \"%s%s\"",
3867  COB_STRIP_CMD, name, COB_EXEEXT);
3868  ret = process (cobc_buffer);
3869  }
3870 #endif
3871 
3872 #endif /* _MSC_VER */
3873  return ret;
3874 }
static int process_module ( struct filename fn)
static

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_ldflags, cobc_ldflags_len, cobc_lib_paths, cobc_lib_paths_len, cobc_libs, cobc_libs_len, cobc_pic_flags_len, cobc_shared_opt_len, file_basename(), gflag_set, NULL, filename::object, filename::object_len, output_name, output_name_buff, process(), filename::source, and strip_output.

Referenced by main().

3607 {
3608  char *name;
3609  size_t bufflen;
3610  size_t size;
3611  int ret;
3612 
3613  if (output_name) {
3614  name = output_name_buff;
3615  strcpy (name, output_name);
3616 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3617  file_stripext (name);
3618 #else
3619  if (strchr (output_name, '.') == NULL) {
3620  strcat (name, ".");
3621  strcat (name, COB_MODULE_EXT);
3622  }
3623 #endif
3624  } else {
3625  name = file_basename (fn->source);
3626 #if !defined(_MSC_VER) && !defined(__OS400__) && !defined(__WATCOMC__) &&! defined(__BORLANDC__)
3627  strcat (name, ".");
3628  strcat (name, COB_MODULE_EXT);
3629 #endif
3630  }
3631 
3632  size = strlen (name);
3633  bufflen = cobc_cc_len + cobc_ldflags_len
3635  + size + fn->object_len + cobc_libs_len
3636 #ifdef _MSC_VER
3637  + manilink_len
3638 #endif
3640 
3641  cobc_chk_buff_size (bufflen);
3642 
3643 #ifdef _MSC_VER
3644  sprintf (cobc_buffer, gflag_set ?
3645  "%s /Od /MDd /LDd /Zi /FR /Fe\"%s\" \"%s\" %s %s %s %s" :
3646  "%s /MD /LD /Fe\"%s\" \"%s\" %s %s %s %s",
3647  cobc_cc, name, fn->object,
3648  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3649  ret = process (cobc_buffer, fn);
3650 #if _MSC_VER >= 1400
3651  /* Embedding manifest */
3652  if (ret == 0) {
3653  sprintf (cobc_buffer,
3654  "%s /manifest \"%s.dll.manifest\" /outputresource:\"%s.dll\";#2",
3655  manicmd, name, name);
3656  ret = process (cobc_buffer, fn);
3657  sprintf (cobc_buffer, "%s.dll.manifest", name);
3659  }
3660 #endif
3661  sprintf (cobc_buffer, "%s.exp", name);
3663  sprintf (cobc_buffer, "%s.lib", name);
3665  sprintf (cobc_buffer, "%s.obj", name);
3666  if(strstr(fn->source, cobc_buffer) == NULL) cobc_check_action (cobc_buffer);
3667 #else /* _MSC_VER */
3668 #ifdef __WATCOMC__
3669  sprintf (cobc_buffer, "%s %s %s %s -fe=\"%s\" \"%s\" %s %s %s",
3672 #else
3673  sprintf (cobc_buffer, "%s %s %s %s -o \"%s\" \"%s\" %s %s %s",
3676 #endif
3677  ret = process (cobc_buffer);
3678 #ifdef COB_STRIP_CMD
3679  if (strip_output && ret == 0) {
3680  sprintf (cobc_buffer, "%s %s", COB_STRIP_CMD, name);
3681  ret = process (cobc_buffer);
3682  }
3683 #endif
3684 #endif /* _MSC_VER */
3685  return ret;
3686 }
static int process_module_direct ( struct filename fn)
static

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_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, file_basename(), gflag_set, NULL, output_name, output_name_buff, p, process(), filename::source, strip_output, filename::translate, and filename::translate_len.

Referenced by main().

3502 {
3503  char *name;
3504  size_t bufflen;
3505  size_t size;
3506  int ret;
3507 
3508  if (output_name) {
3509  name = output_name_buff;
3510  strcpy (name, output_name);
3511 #if defined(_MSC_VER) || defined(__OS400__) || defined(__WATCOMC__) || defined(__BORLANDC__)
3512  file_stripext (name);
3513 #else
3514  if (strchr (output_name, '.') == NULL) {
3515  strcat (name, ".");
3516  strcat (name, COB_MODULE_EXT);
3517  }
3518 #endif
3519  } else {
3520  name = file_basename (fn->source);
3521 #if !defined(_MSC_VER) && !defined(__OS400__) && !defined(__WATCOMC__) && !defined(__BORLANDC__)
3522  strcat (name, ".");
3523  strcat (name, COB_MODULE_EXT);
3524 #endif
3525  }
3526 
3527  size = strlen (name);
3528 #ifdef _MSC_VER
3529  size *= 2U;
3530 #endif
3531 
3532  bufflen = cobc_cc_len + cobc_cflags_len
3534  + size + fn->translate_len
3536 #ifdef _MSC_VER
3537  + manilink_len
3538 #endif
3540 
3541  cobc_chk_buff_size (bufflen);
3542 
3543 #ifdef _MSC_VER
3544  sprintf (cobc_buffer, gflag_set ?
3545  "%s %s %s /Od /MDd /LDd /Zi /FR /Fe\"%s\" /Fo\"%s\" \"%s\" %s %s %s %s" :
3546  "%s %s %s /MD /LD /Fe\"%s\" /Fo\"%s\" \"%s\" %s %s %s %s",
3547  cobc_cc, cobc_cflags, cobc_include, name, name,
3548  fn->translate,
3549  manilink, cobc_ldflags, cobc_libs, cobc_lib_paths);
3550  ret = process (cobc_buffer, fn);
3551 #if _MSC_VER >= 1400
3552  /* Embedding manifest */
3553  if (ret == 0) {
3554  sprintf (cobc_buffer,
3555  "%s /manifest \"%s.dll.manifest\" /outputresource:\"%s.dll\";#2",
3556  manicmd, name, name);
3557  ret = process (cobc_buffer, fn);
3558  sprintf (cobc_buffer, "%s.dll.manifest", name);
3560  }
3561 #endif
3562  sprintf (cobc_buffer, "%s.exp", name);
3564  sprintf (cobc_buffer, "%s.lib", name);
3566  sprintf (cobc_buffer, "%s.%s", name, COB_OBJECT_EXT);
3567  if(strstr(fn->source, cobc_buffer) == NULL) cobc_check_action (cobc_buffer);
3568 #else /* _MSC_VER */
3569 #ifdef __OS400__
3570  if (fn->translate[0] != '/') {
3571  char *p;
3572 
3573  p = cobc_main_malloc (COB_LARGE_BUFF);
3574  getcwd (p, COB_LARGE_BUFF);
3575  strcat (p, "/");
3576  strcat (p, fn->translate);
3577  fn->translate = p;
3578  fn->translate_len = strlen (p);
3579  }
3580 #endif
3581 #ifdef __WATCOMC__
3582  sprintf (cobc_buffer, "%s %s %s %s %s %s -fe=\"%s\" \"%s\" %s %s %s",
3586 #else
3587  sprintf (cobc_buffer, "%s %s %s %s %s %s -o \"%s\" \"%s\" %s %s %s",
3591 #endif
3592  ret = process (cobc_buffer);
3593 #ifdef COB_STRIP_CMD
3594  if (strip_output && ret == 0) {
3595  sprintf (cobc_buffer, "%s \"%s\"", COB_STRIP_CMD, name);
3596  ret = process (cobc_buffer);
3597  }
3598 #endif
3599 #endif /* _MSC_VER */
3600  return ret;
3601 }
static int process_translate ( struct filename fn)
static

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, p, 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().

3226 {
3227  struct cb_program *p;
3228  struct cb_program *q;
3229  struct cb_program *r;
3230  struct nested_list *nlp;
3231  struct handler_struct *hstr1;
3232  struct handler_struct *hstr2;
3233  struct local_filename *lf;
3234  int ret;
3235  int i;
3236 
3237  /* Initialize */
3238  cb_source_file = NULL;
3239  cb_source_line = 0;
3240  errorcount = 0;
3241 
3242  /* Open the input file */
3243  yyin = fopen (fn->preprocess, "r");
3244  if (!yyin) {
3245  cobc_terminate (fn->preprocess);
3246  }
3247 
3248  if (verbose_output) {
3249  fputs (_("Parsing:"), stderr);
3250  fprintf (stderr, "\t%s (%s)\n", fn->preprocess, fn->source);
3251  fflush (stderr);
3252  }
3253 
3255  cb_init_constants ();
3256 
3257  /* Parse */
3258  ret = yyparse ();
3259 
3260  fclose (yyin);
3261  yyin = NULL;
3262 
3263  /* Release flex buffers - After file close */
3264  ylex_call_destroy ();
3265 
3266  if (verbose_output) {
3267  fputs (_("Return status:"), stderr);
3268  fprintf (stderr, "\t%d\n", ret);
3269  fflush (stderr);
3270  }
3271 
3272  if (ret || cb_flag_syntax_only) {
3273  return !!ret;
3274  }
3276  return 0;
3277  }
3278 
3279  /* Set up USE GLOBAL handlers */
3280  p = current_program;
3281  for (q = p; q; q = q->next_program) {
3283  if (q->nested_level) {
3284  for (r = q->next_program; r; r = r->next_program) {
3285  if (r->nested_level >= q->nested_level) {
3286  continue;
3287  }
3288  for (i = COB_OPEN_INPUT; i <= COB_OPEN_EXTEND; ++i) {
3289  hstr1 = &q->global_handler[i];
3290  hstr2 = &r->global_handler[i];
3291  if (!hstr1->handler_label &&
3292  hstr2->handler_label &&
3293  hstr2->handler_label->flag_global) {
3294  hstr1->handler_label = hstr2->handler_label;
3295  hstr1->handler_prog = r;
3296  }
3297  }
3298  if (!r->nested_level) {
3299  break;
3300  }
3301  }
3302  }
3303  }
3304 
3305  if (verbose_output) {
3306  fputs (_("Translating:"), stderr);
3307  fprintf (stderr, "\t%s -> %s (%s)\n",
3308  fn->preprocess, fn->translate, fn->source);
3309  fflush (stderr);
3310  }
3311 
3312  /* Open the output file */
3313  yyout = fopen (fn->translate, "w");
3314  if (!yyout) {
3315  cobc_terminate (fn->translate);
3316  }
3317 
3318  /* Open the common storage file */
3320  cb_storage_file = fopen (cb_storage_file_name, "w");
3321  if (!cb_storage_file) {
3323  }
3324 
3326 
3327  /* Set up local storage files */
3328  lf = NULL;
3329  ret = 1;
3330  for (q = p; q; q = q->next_program, ret++) {
3331  lf = cobc_main_malloc (sizeof(struct local_filename));
3332  lf->local_name = cobc_main_malloc (fn->translate_len + 12U);
3333  if (q == p && !q->next_program) {
3334  sprintf (lf->local_name, "%s.l.h", fn->translate);
3335  } else {
3336  sprintf (lf->local_name, "%s.l%d.h", fn->translate, ret);
3337  }
3338  lf->local_fp = fopen (lf->local_name, "w");
3339  if (!lf->local_fp) {
3340  cobc_terminate (lf->local_name);
3341  }
3342  q->local_include = lf;
3343  lf->next = fn->localfile;
3344  fn->localfile = lf;
3345  }
3346 
3347  /* Entries for COMMON programs */
3348  for (q = p; q; q = q->next_program) {
3349  i = q->nested_level;
3350  for (nlp = q->common_prog_list; nlp; nlp = nlp->next) {
3351  for (r = q->next_program; r; r = r->next_program) {
3352  if (r->nested_level <= i) {
3353  break;
3354  }
3356  }
3357  }
3358  }
3359 
3360  errorcount = 0;
3361  /* Translate to C */
3362  codegen (p, 0);
3363 
3364  /* Close files */
3365  if(unlikely(fclose (cb_storage_file) != 0)) {
3367  }
3369  if(unlikely(fclose (yyout) != 0)) {
3370  cobc_terminate (fn->translate);
3371  }
3372  yyout = NULL;
3373  for (q = p; q; q = q->next_program) {
3374  if(unlikely(fclose (q->local_include->local_fp) != 0)) {
3376  }
3377  q->local_include->local_fp = NULL;
3378  }
3379  return !!errorcount;
3380 }
static struct cb_program* program_list_reverse ( struct cb_program p)
staticread

References next, cb_program::next_program, NULL, and p.

Referenced by process_translate().

2422 {
2423  struct cb_program *next;
2424  struct cb_program *last;
2425 
2426  last = NULL;
2427  for (; p; p = next) {
2428  next = p->next_program;
2429  p->next_program = last;
2430  last = p;
2431  }
2432  return last;
2433 }

Variable Documentation

size_t aflag_set = 0
static

Referenced by main(), and process_command_line().

struct strcache* base_string
static

Referenced by cobc_check_string().

char* basename_buffer
static

Referenced by file_basename(), and main().

size_t basename_len
static

Referenced by file_basename(), and main().

int cb_attr_id = 0

Referenced by lookup_attr(), and main().

unsigned int cb_compile_level = 0
static
struct cb_define_struct* cb_define_list = NULL
static
struct cb_text_list * cb_early_exit_list = NULL

Referenced by output_call().

struct cb_exception cb_exception_table
struct cb_text_list * cb_extension_list = NULL

Referenced by ppcopy().

int cb_field_id = 0

Referenced by cb_build_field(), and main().

int cb_flag_functions_all = 0
int cb_flag_main = 0

Referenced by process_command_line().

struct cb_text_list * cb_include_list = NULL

Referenced by ppcopy().

struct cb_text_list * cb_intrinsic_list = NULL

Referenced by while().

FILE * cb_listing_file = NULL
int cb_literal_id = 0

Referenced by lookup_literal(), and main().

char * cb_oc_build_stamp = NULL
int cb_saveargc = 0

Referenced by main(), and output_header().

char ** cb_saveargv = NULL

Referenced by main(), and output_header().

int cb_source_format = CB_FORMAT_FIXED
struct cb_text_list * cb_static_call_list = NULL

Referenced by output_call().

FILE * cb_storage_file = NULL
const char * cb_storage_file_name = NULL

Referenced by codegen(), and process_translate().

const char * cob_config_dir = NULL

Referenced by cb_load_conf(), and main().

const char* const cob_csyns[]
static

Referenced by cobc_check_valid_name().

size_t cob_optimize = 0
static

Referenced by main(), and process_command_line().

size_t cobc_buffer_size
static

Referenced by cobc_chk_buff_size(), and main().

size_t cobc_cflags_len
static
size_t cobc_cflags_size
static

Referenced by main().

size_t cobc_export_dyn_len
static
size_t cobc_flag_library = 0
static

Referenced by main(), and process_command_line().

size_t cobc_flag_module = 0
static

Referenced by main(), and process_command_line().

unsigned int cobc_gen_listing = 0
size_t cobc_include_len
static
size_t cobc_include_size
static

Referenced by main().

size_t cobc_ldflags_len
static
size_t cobc_ldflags_size
static

Referenced by main().

size_t cobc_lib_paths_len
static
size_t cobc_lib_paths_size
static

Referenced by main().

size_t cobc_libs_len
static
size_t cobc_libs_size
static

Referenced by main().

char* cobc_list_dir
static
char* cobc_list_file
static
struct cobc_mem_struct* cobc_mainmem_base = NULL
static

Referenced by cobc_main_malloc().

struct noreserve * cobc_nores_base = NULL
char* cobc_objects_buffer
static

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

size_t cobc_objects_len
static
struct cobc_mem_struct* cobc_parsemem_base = NULL
static

Referenced by cobc_parse_malloc().

size_t cobc_pic_flags_len
static
struct cobc_mem_struct* cobc_plexmem_base = NULL
static

Referenced by cobc_plex_malloc().

size_t cobc_shared_opt_len
static
int cobc_wants_debug = 0

Referenced by main(), and process_command_line().

const char * demangle_name = NULL

Referenced by main().

int exit_option = 0

Referenced by process_command_line().

struct filename* file_list
static
int iargs
static

Referenced by main().

struct option long_options[]
static
int no_physical_cancel = 0
char* output_name_buff
static
size_t save_all_src = 0
static
size_t save_c_src = 0
static
size_t save_temps = 0
static
char* save_temps_dir
static
const char short_options[] = "hVivECScbmxOPgwo:I:L:l:D:K:k:"
static

Referenced by process_command_line().

size_t verbose_output = 0
static
size_t wants_nonfinal = 0
static

Referenced by main(), and process_command_line().

int warningcount = 0