|
OpenCOBOL 1.1pre-rel
|
#include "config.h"#include "defaults.h"#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <setjmp.h>#include <sys/types.h>#include <unistd.h>#include <time.h>#include <sys/stat.h>#include <signal.h>#include <getopt.h>#include <locale.h>#include <tarstamp.h>#include "cobc.h"#include "tree.h"#include <libcob/exception.def>#include "flag.def"#include "warning.def"
Go to the source code of this file.
Defines | |
| #define | COB_EXCEPTION(code, tag, name, critical) {name, 0x##code, 0}, |
| #define | CB_FLAG(var, name, doc) int var = 0; |
| #define | CB_WARNDEF(var, name, wall, doc) int var = 0; |
| #define | PATHSEPS ":" |
| #define | COB_NUM_CSYNS sizeof(cob_csyns) / sizeof(char *) |
| #define | CB_FLAG(var, name, doc) |
| #define | CB_WARNDEF(var, name, wall, doc) |
| #define | CB_WARNDEF(var, name, wall, doc) |
| #define | CB_FLAG(var, name, doc) |
| #define | CB_WARNDEF(var, name, wall, doc) var = 0; |
| #define | CB_WARNDEF(var, name, wall, doc) if (wall) var = 1; |
| #define | CB_WARNDEF(var, name, wall, doc) var = 1; |
Typedefs | |
| typedef void(* | cob_sighandler_t )(int) |
Enumerations | |
| enum | cb_compile_level { CB_LEVEL_PREPROCESS = 1, CB_LEVEL_TRANSLATE, CB_LEVEL_COMPILE, CB_LEVEL_ASSEMBLE, CB_LEVEL_MODULE, CB_LEVEL_LIBRARY, CB_LEVEL_EXECUTABLE } |
Functions | |
| void | cobc_abort (const char *filename, const int linenum) |
| void | cobc_tree_cast_error (cb_tree x, const char *filen, const int linenum, const int tagnum) |
| void * | cobc_malloc (const size_t size) |
| void * | cobc_realloc (void *prevptr, const size_t size) |
| struct cb_text_list * | cb_text_list_add (struct cb_text_list *list, const char *text) |
| size_t | cobc_check_valid_name (char *name) |
| int | main (int argc, char *argv[]) |
Variables | |
| int | cb_source_format = CB_FORMAT_FIXED |
| int | cb_display_sign = COB_DISPLAY_SIGN_ASCII |
| struct cb_exception | cb_exception_table [] |
| int | cb_id = 1 |
| int | cb_attr_id = 1 |
| int | cb_literal_id = 1 |
| int | cb_field_id = 1 |
| int | cb_storage_id = 1 |
| int | cb_flag_main = 0 |
| int | errorcount = 0 |
| int | warningcount = 0 |
| int | alt_ebcdic = 0 |
| int | optimize_flag = 0 |
| char * | cb_source_file = NULL |
| char * | cb_oc_build_stamp = NULL |
| char * | source_name |
| char * | demangle_name |
| int | cb_source_line = 0 |
| FILE * | cb_storage_file |
| char * | cb_storage_file_name |
| FILE * | cb_listing_file = NULL |
| FILE * | cb_depend_file = NULL |
| char * | cb_depend_target = NULL |
| struct cb_text_list * | cb_depend_list = NULL |
| struct cb_text_list * | cb_include_list = NULL |
| struct cb_text_list * | cb_extension_list = NULL |
| int | cb_saveargc |
| char ** | cb_saveargv |
| const char * | cob_config_dir |
{"f"name, no_argument, &var, 1}, \
{"fno-"name, no_argument, &var, 0},
{"W"name, no_argument, &var, 1}, \
{"Wno-"name, no_argument, &var, 0},
| typedef void(* cob_sighandler_t)(int) |
| enum cb_compile_level |
| struct cb_text_list* cb_text_list_add | ( | struct cb_text_list * | list, |
| const char * | text | ||
| ) | [read] |
Definition at line 355 of file cobc.c.
{
struct cb_text_list *p;
struct cb_text_list *l;
p = cobc_malloc (sizeof (struct cb_text_list));
p->text = strdup (text);
p->next = NULL;
if (!list) {
return p;
} else {
for (l = list; l->next; l = l->next) { ; }
l->next = p;
return list;
}
}


| void cobc_abort | ( | const char * | filename, |
| const int | linenum | ||
| ) |
| size_t cobc_check_valid_name | ( | char * | name | ) |
Definition at line 373 of file cobc.c.
{
size_t n;
for (n = 0; n < COB_NUM_CSYNS; ++n) {
if (!strcmp (name, cob_csyns[n])) {
return 1;
}
}
return 0;
}

| void* cobc_malloc | ( | const size_t | size | ) |
| void* cobc_realloc | ( | void * | prevptr, |
| const size_t | size | ||
| ) |
| void cobc_tree_cast_error | ( | cb_tree | x, |
| const char * | filen, | ||
| const int | linenum, | ||
| const int | tagnum | ||
| ) |
Definition at line 317 of file cobc.c.
{
fprintf (stderr, "%s:%d: Invalid type cast from '%s'\n",
filen, linenum, x ? cb_name (x) : "null");
fprintf (stderr, "Tag 1 %d Tag 2 %d\n", x ? CB_TREE_TAG(x) : 0,
tagnum);
(void)longjmp (cob_jmpbuf, 1);
}

| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 1686 of file cobc.c.
{
struct filename *fn;
char *p;
int status = 1;
int year;
int day;
char month[32];
char buff[COB_SMALL_BUFF];
#ifdef HAVE_SIGNAL_H
if ((intsig = signal (SIGINT, cobc_sig_handler)) == SIG_IGN) {
(void)signal (SIGINT, SIG_IGN);
}
#ifdef SIGHUP
if ((hupsig = signal (SIGHUP, cobc_sig_handler)) == SIG_IGN) {
(void)signal (SIGHUP, SIG_IGN);
}
#endif
#ifdef SIGQUIT
if ((qutsig = signal (SIGQUIT, cobc_sig_handler)) == SIG_IGN) {
(void)signal (SIGQUIT, SIG_IGN);
}
#endif
#endif
cb_saveargc = argc;
cb_saveargv = argv;
#ifdef HAVE_SETLOCALE
setlocale (LC_ALL, "");
#endif
#ifdef ENABLE_NLS
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
#endif
#ifndef _WIN32
cob_process_id = getpid ();
#endif
/* Initialize global variables */
memset (buff, 0, sizeof(buff));
memset (month, 0, sizeof(month));
day = 0;
year = 0;
sscanf (__DATE__, "%s %d %d", month, &day, &year);
if (day && year) {
sprintf (buff, "%s %2.2d %4.4d %s", month, day, year, __TIME__);
} else {
sprintf (buff, "%s %s", __DATE__, __TIME__);
}
cb_oc_build_stamp = cobc_malloc (strlen (buff) + 1);
strcpy (cb_oc_build_stamp, buff);
output_name = NULL;
if ((p = getenv ("TMPDIR")) != NULL) {
cob_tmpdir = p;
} else if ((p = getenv ("TMP")) != NULL) {
cob_tmpdir = p;
sprintf (buff, "TMPDIR=%s", p);
p = strdup (buff);
putenv (p);
} else {
cob_tmpdir = "/tmp";
putenv ((char *)"TMPDIR=/tmp");
}
cob_cc = getenv ("COB_CC");
if (cob_cc == NULL) {
cob_cc = COB_CC;
}
cobc_init_var (cob_cflags, "COB_CFLAGS", COB_CFLAGS);
cobc_init_var (cob_libs, "COB_LIBS", COB_LIBS);
cob_ldflags = getenv ("COB_LDFLAGS");
if (cob_ldflags == NULL) {
cob_ldflags = COB_LDFLAGS;
}
cob_config_dir = getenv ("COB_CONFIG_DIR");
if (cob_config_dir == NULL) {
cob_config_dir = COB_CONFIG_DIR;
}
cob_copy_dir = getenv ("COB_COPY_DIR");
if (cob_copy_dir == NULL) {
cob_copy_dir = COB_COPY_DIR;
}
memset (cob_define_flags, 0, sizeof (cob_define_flags));
p = getenv ("COB_LDADD");
if (p) {
strcat (cob_libs, " ");
strcat (cob_libs, p);
}
p = getenv ("COB_EBCDIC");
if (p && (*p == 'F' || *p == 'f')) {
alt_ebcdic = 1;
}
/* Process command line arguments */
iargs = process_command_line (argc, argv);
/* Check the filename */
if (iargs == argc) {
fprintf (stderr, "cobc: No input files\n");
exit (1);
}
/* processes COBCPY environment variable */
process_env_copy_path ();
cb_include_list = cb_text_list_add (cb_include_list, cob_copy_dir);
file_list = NULL;
if (setjmp (cob_jmpbuf) != 0) {
fprintf (stderr, "Aborting compile of %s at line %d\n",
cb_source_file, cb_source_line);
fflush (stderr);
if (yyout) {
fflush (yyout);
}
if (cb_storage_file) {
fflush (cb_storage_file);
}
status = 1;
cobc_clean_up (status);
return status;
}
/* Defaults are set here */
if (!cb_flag_syntax_only) {
if (!wants_nonfinal) {
if (cb_flag_main) {
cb_compile_level = CB_LEVEL_EXECUTABLE;
}
if (cb_flag_module) {
cb_compile_level = CB_LEVEL_MODULE;
}
if (cb_flag_library) {
cb_compile_level = CB_LEVEL_LIBRARY;
}
}
if (cb_compile_level == 0 && !wants_nonfinal) {
cb_compile_level = CB_LEVEL_MODULE;
cb_flag_module = 1;
}
if (wants_nonfinal && cb_compile_level != CB_LEVEL_PREPROCESS &&
!cb_flag_main && !cb_flag_module && !cb_flag_library) {
cb_flag_module = 1;
}
} else {
cb_compile_level = CB_LEVEL_TRANSLATE;
}
if (output_name && cb_compile_level < CB_LEVEL_LIBRARY &&
(argc - iargs) > 1) {
fprintf (stderr, "cobc: -o option invalid in this combination\n");
exit (1);
}
if (cb_flag_sign_ascii && cb_flag_sign_ebcdic) {
fprintf (stderr, "Only one of -fsign-ascii or -fsign-ebcdic may be specified\n");
exit (1);
}
if (cb_flag_sign_ascii) {
cb_display_sign = COB_DISPLAY_SIGN_ASCII;
}
if (cb_flag_sign_ebcdic) {
cb_display_sign = COB_DISPLAY_SIGN_EBCDIC;
}
if (cb_flag_notrunc) {
cb_binary_truncate = 0;
cb_pretty_display = 0;
}
while (iargs < argc) {
fn = process_filename (argv[iargs++]);
if (!fn) {
status = 1;
cobc_clean_up (status);
return status;
}
/* Preprocess */
if (cb_compile_level >= CB_LEVEL_PREPROCESS && fn->need_preprocess) {
if (preprocess (fn) != 0) {
cobc_clean_up (status);
return status;
}
}
}
for (fn = file_list; fn; fn = fn->next) {
cb_id = 1;
cb_attr_id = 1;
cb_literal_id = 1;
cb_field_id = 1;
cb_storage_id = 1;
iparams++;
demangle_name = fn->demangle_source;
if (iparams > 1 && cb_compile_level == CB_LEVEL_EXECUTABLE &&
!cb_flag_syntax_only) {
local_level = cb_compile_level;
cb_flag_main = 0;
cb_compile_level = CB_LEVEL_ASSEMBLE;
}
/* Translate */
if (cb_compile_level >= CB_LEVEL_TRANSLATE && fn->need_translate) {
if (process_translate (fn) != 0) {
cobc_clean_up (status);
return status;
}
}
if (cb_flag_syntax_only) {
continue;
}
/* Compile */
if (cb_compile_level == CB_LEVEL_COMPILE) {
if (process_compile (fn) != 0) {
cobc_clean_up (status);
return status;
}
}
/* Build module */
if (cb_compile_level == CB_LEVEL_MODULE && fn->need_assemble) {
if (process_module_direct (fn) != 0) {
cobc_clean_up (status);
return status;
}
} else {
/* Assemble */
if (cb_compile_level >= CB_LEVEL_ASSEMBLE && fn->need_assemble) {
if (process_assemble (fn) != 0) {
cobc_clean_up (status);
return status;
}
}
/* Build module */
if (cb_compile_level == CB_LEVEL_MODULE) {
if (process_module (fn) != 0) {
cobc_clean_up (status);
return status;
}
}
}
}
if (!cb_flag_syntax_only) {
/* Link */
if (local_level == CB_LEVEL_EXECUTABLE) {
cb_compile_level = CB_LEVEL_EXECUTABLE;
cb_flag_main = 1;
}
if (cb_compile_level == CB_LEVEL_LIBRARY) {
if (process_library (file_list) != 0) {
cobc_clean_up (status);
return status;
}
} else if (cb_compile_level == CB_LEVEL_EXECUTABLE) {
if (process_link (file_list) != 0) {
cobc_clean_up (status);
return status;
}
}
}
/* We have successfully completed */
status = 0;
cobc_clean_up (status);
return status;
}

| int alt_ebcdic = 0 |
| int cb_attr_id = 1 |
| FILE* cb_depend_file = NULL |
| struct cb_text_list* cb_depend_list = NULL |
| char* cb_depend_target = NULL |
| int cb_display_sign = COB_DISPLAY_SIGN_ASCII |
| struct cb_exception cb_exception_table[] |
| struct cb_text_list* cb_extension_list = NULL |
| int cb_field_id = 1 |
| int cb_flag_main = 0 |
| struct cb_text_list* cb_include_list = NULL |
| FILE* cb_listing_file = NULL |
| int cb_literal_id = 1 |
| char* cb_oc_build_stamp = NULL |
| int cb_saveargc |
| char** cb_saveargv |
| char* cb_source_file = NULL |
| int cb_source_format = CB_FORMAT_FIXED |
| int cb_source_line = 0 |
| FILE* cb_storage_file |
| char* cb_storage_file_name |
| int cb_storage_id = 1 |
| const char* cob_config_dir |
| char* demangle_name |
| int errorcount = 0 |
| int optimize_flag = 0 |
| char* source_name |
| int warningcount = 0 |
1.7.4