|
OpenCOBOL 1.1pre-rel
|
#include <stdio.h>#include <libcob.h>#include "lib/gettext.h"#include "flag.def"#include "warning.def"#include "config.def"

Go to the source code of this file.
| #define CB_CONFIG_SUPPORT | ( | var, | |
| name | |||
| ) | extern enum cb_support var; |
| #define CB_EXCEPTION_CODE | ( | id | ) | cb_exception_table[id].code |
| #define CB_EXCEPTION_ENABLE | ( | id | ) | cb_exception_table[id].enable |
| #define CB_EXCEPTION_NAME | ( | id | ) | cb_exception_table[id].name |
| enum cb_assign_clause |
Definition at line 158 of file cobc.h.
{
CB_ASSIGN_COBOL2002, /* COBOL 2002 standard */
CB_ASSIGN_MF, /* Micro Focus COBOL compatibility */
CB_ASSIGN_IBM /* IBM COBOL compatibility */
};
| enum cb_binary_byteorder |
| enum cb_binary_size |
Definition at line 169 of file cobc.h.
{
CB_BINARY_SIZE_2_4_8, /* 2,4,8 bytes */
CB_BINARY_SIZE_1_2_4_8, /* 1,2,4,8 bytes */
CB_BINARY_SIZE_1__8 /* 1,2,3,4,5,6,7,8 bytes */
};
| enum cb_operation_type |
| enum cb_support |
Definition at line 181 of file cobc.h.
{
CB_OK,
CB_WARNING,
CB_ARCHAIC,
CB_OBSOLETE,
CB_SKIP,
CB_IGNORE,
CB_ERROR,
CB_UNCONFORMABLE
};
| void cb_error | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 85 of file error.c.
{
va_list ap;
va_start (ap, fmt);
print_error (NULL, 0, "Error: ", fmt, ap);
va_end (ap);
errorcount++;
}


| int cb_load_conf | ( | const char * | fname, |
| const int | check_nodef, | ||
| const int | prefix_dir | ||
| ) |
Definition at line 112 of file config.c.
{
char *s;
char *e;
const char *name;
const char *val;
void *var;
FILE *fp;
char *nores;
struct noreserve *noresptr;
int i;
int j;
int ret;
int saveret;
int line;
char buff[COB_SMALL_BUFF];
/* initialize the config table */
if (check_nodef) {
for (i = 0; config_table[i].name; i++) {
config_table[i].val = NULL;
}
}
if (prefix_dir) {
snprintf (buff, COB_SMALL_MAX, "%s/%s", cob_config_dir, fname);
name = buff;
} else {
name = fname;
}
/* open the config file */
fp = fopen (name, "r");
if (fp == NULL) {
perror (name);
return -1;
}
/* read the config file */
ret = 0;
line = 0;
while (fgets (buff, COB_SMALL_BUFF, fp)) {
line++;
/* skip comments */
if (buff[0] == '#') {
continue;
}
/* skip blank lines */
for (s = buff; *s; s++) {
if (isgraph (*s)) {
break;
}
}
if (!*s) {
continue;
}
/* get the tag */
s = strpbrk (buff, " \t:=");
if (!s) {
fprintf (stderr, "%s:%d: invalid line\n", fname, line);
ret = -1;
continue;
}
*s = 0;
/* find the entry */
for (i = 0; config_table[i].name; i++) {
if (strcmp (buff, config_table[i].name) == 0) {
break;
}
}
if (!config_table[i].name) {
fprintf (stderr, "%s:%d: unknown tag '%s'\n", fname, line, buff);
ret = -1;
continue;
}
/* get the value */
for (s++; *s && strchr (" \t:=", *s); s++) {
;
}
e = s + strlen (s) - 1;
for (; e >= s && strchr (" \t\r\n", *e); e--) {
;
}
e[1] = 0;
config_table[i].val = s;
/* set the value */
name = config_table[i].name;
var = config_table[i].var;
val = config_table[i].val;
switch (config_table[i].type) {
case ANY:
if (strcmp (name, "assign-clause") == 0) {
if (strcmp (val, "cobol2002") == 0) {
unsupported_value (fname, line, val);
ret = -1;
} else if (strcmp (val, "mf") == 0) {
cb_assign_clause = CB_ASSIGN_MF;
} else if (strcmp (val, "ibm") == 0) {
cb_assign_clause = CB_ASSIGN_IBM;
} else {
invalid_value (fname, line, name);
ret = -1;
}
} else if (strcmp (name, "binary-size") == 0) {
if (strcmp (val, "2-4-8") == 0) {
cb_binary_size = CB_BINARY_SIZE_2_4_8;
} else if (strcmp (val, "1-2-4-8") == 0) {
cb_binary_size = CB_BINARY_SIZE_1_2_4_8;
} else if (strcmp (val, "1--8") == 0) {
cb_binary_size = CB_BINARY_SIZE_1__8;
} else {
invalid_value (fname, line, name);
ret = -1;
}
} else if (strcmp (name, "binary-byteorder") == 0) {
if (strcmp (val, "native") == 0) {
cb_binary_byteorder = CB_BYTEORDER_NATIVE;
} else if (strcmp (val, "big-endian") == 0) {
cb_binary_byteorder = CB_BYTEORDER_BIG_ENDIAN;
} else {
invalid_value (fname, line, name);
ret = -1;
}
}
break;
case INT:
for (j = 0; val[j]; j++) {
if (!isdigit (val[j])) {
invalid_value (fname, line, name);
ret = -1;
break;
}
}
*((int *)var) = atoi (val);
break;
case STRING:
val = read_string (val);
if (strcmp (name, "include") == 0) {
/* include another conf file */
saveret = ret;
if (cb_load_conf (val, 0, 1) != 0) {
return -1;
}
ret = saveret;
} else if (strcmp (name, "not-reserved") == 0) {
nores = read_string (val);
noresptr = cobc_malloc (sizeof (struct noreserve));
noresptr->noresword = cobc_malloc (strlen (nores) + 1);
strcpy (noresptr->noresword, nores);
noresptr->next = norestab;
norestab = noresptr;
} else {
*((const char **)var) = val;
}
break;
case BOOLEAN:
if (strcmp (val, "yes") == 0) {
*((int *)var) = 1;
} else if (strcmp (val, "no") == 0) {
*((int *)var) = 0;
} else {
invalid_value (fname, line, name);
ret = -1;
}
break;
case SUPPORT:
if (strcmp (val, "ok") == 0) {
*((enum cb_support *)var) = CB_OK;
} else if (strcmp (val, "warning") == 0) {
*((enum cb_support *)var) = CB_WARNING;
} else if (strcmp (val, "archaic") == 0) {
*((enum cb_support *)var) = CB_ARCHAIC;
} else if (strcmp (val, "obsolete") == 0) {
*((enum cb_support *)var) = CB_OBSOLETE;
} else if (strcmp (val, "skip") == 0) {
*((enum cb_support *)var) = CB_SKIP;
} else if (strcmp (val, "ignore") == 0) {
*((enum cb_support *)var) = CB_IGNORE;
} else if (strcmp (val, "error") == 0) {
*((enum cb_support *)var) = CB_ERROR;
} else if (strcmp (val, "unconformable") == 0) {
*((enum cb_support *)var) = CB_UNCONFORMABLE;
} else {
invalid_value (fname, line, name);
ret = -1;
}
break;
default:
fprintf (stderr, _("%s:%d: invalid type for '%s'\n"),
fname, line, name);
ret = -1;
break;
}
}
fclose (fp);
/* checks for no definition */
if (check_nodef) {
for (i = 2; config_table[i].name; i++) {
if (config_table[i].val == NULL) {
fprintf (stderr, "%s: no definition of '%s'\n",
fname, config_table[i].name);
ret = -1;
}
}
}
return ret;
}


| int cb_load_std | ( | const char * | name | ) |
Definition at line 106 of file config.c.
{
return cb_load_conf (name, 1, 1);
}


| struct cb_text_list* cb_text_list_add | ( | struct cb_text_list * | list, |
| const char * | name | ||
| ) | [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;
}
}


| int cb_verify | ( | const enum cb_support | tag, |
| const char * | feature | ||
| ) |
Definition at line 122 of file error.c.
{
switch (tag) {
case CB_OK:
return 1;
case CB_WARNING:
return 1;
case CB_ARCHAIC:
if (cb_warn_archaic) {
cb_warning (_("%s is archaic in %s"), feature, cb_config_name);
}
return 1;
case CB_OBSOLETE:
if (cb_warn_obsolete) {
cb_warning (_("%s is obsolete in %s"), feature, cb_config_name);
}
return 1;
case CB_SKIP:
return 0;
case CB_IGNORE:
cb_warning (_("%s ignored"), feature);
return 0;
case CB_ERROR:
return 0;
case CB_UNCONFORMABLE:
cb_error (_("%s does not conform to %s"), feature, cb_config_name);
return 0;
}
return 0;
}


| void cb_warning | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 73 of file error.c.
{
va_list ap;
va_start (ap, fmt);
print_error (NULL, 0, "Warning: ", fmt, ap);
va_end (ap);
warningcount++;
}


| void cobc_abort | ( | const char * | filename, |
| const int | linenum | ||
| ) |
Definition at line 310 of file cobc.c.
{
fprintf (stderr, "%s:%d: Internal compiler error\n", filename, linenum);
(void)longjmp (cob_jmpbuf, 1);
}
| 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 | ) |
Definition at line 327 of file cobc.c.
{
void *mptr;
mptr = calloc (1, size);
if (!mptr) {
fprintf (stderr, "Cannot allocate %d bytes of memory - Aborting\n", (int)size);
fflush (stderr);
(void)longjmp (cob_jmpbuf, 1);
}
return mptr;
}

| void* cobc_realloc | ( | void * | prevptr, |
| const size_t | size | ||
| ) |
Definition at line 341 of file cobc.c.
{
void *mptr;
mptr = realloc (prevptr, size);
if (!mptr) {
fprintf (stderr, "Cannot reallocate %d bytes of memory - Aborting\n", (int)size);
fflush (stderr);
(void)longjmp (cob_jmpbuf, 1);
}
return mptr;
}

| void pp_set_replace_list | ( | struct cb_replace_list * | replace_list | ) |
| int ppcopy | ( | const char * | name, |
| const char * | lib, | ||
| struct cb_replace_list * | replace_list | ||
| ) |
| int pplex | ( | void | ) |
| int ppopen | ( | const char * | name, |
| struct cb_replace_list * | replace_list | ||
| ) |

| int ppparse | ( | void | ) |

| int yylex | ( | void | ) |
| int yyparse | ( | void | ) |
| int alt_ebcdic |
| int cb_attr_id |
| FILE* cb_depend_file |
| struct cb_text_list* cb_depend_list |
| char* cb_depend_target |
| int cb_display_sign |
| struct cb_exception cb_exception_table[] |
| struct cb_text_list* cb_extension_list |
| int cb_field_id |
| int cb_flag_main |
| struct cb_text_list* cb_include_list |
| FILE* cb_listing_file |
| int cb_literal_id |
| char* cb_oc_build_stamp |
| int cb_saveargc |
| char** cb_saveargv |
| char* cb_source_file |
| int cb_source_format |
| int cb_source_line |
| FILE* cb_storage_file |
| char* cb_storage_file_name |
| int cb_storage_id |
| const char* cob_config_dir |
| struct cb_label* current_paragraph |
| struct cb_program* current_program |
| struct cb_label* current_section |
| struct cb_statement* current_statement |
| char* demangle_name |
| int errorcount |
| size_t functions_are_all |
| int has_external |
| int optimize_flag |
| FILE* ppin |
| FILE* ppout |
| size_t sending_id |
| char* source_name |
| size_t suppress_warn |
| int warningcount |
| FILE* yyin |
| FILE* yyout |
1.7.4