Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cobj/cobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ static const struct option long_options[] = {
{"free", no_argument, &cb_source_format, CB_FORMAT_FREE},
{"free_1col_aster", no_argument, &cb_source_format,
CB_FORMAT_FREE_1COL_ASTER},
{"variable", no_argument, &cb_source_format, CB_FORMAT_VARIABLE},
{"fixed", no_argument, &cb_source_format, CB_FORMAT_FIXED},
{"static", no_argument, &cb_flag_static_call, 1},
{"dynamic", no_argument, &cb_flag_static_call, 0},
Expand Down Expand Up @@ -802,6 +803,8 @@ static void cobc_print_usage(void) {
puts(_(" -free Use free source format"));
puts(_(" -free_1col_aster Use free(1col_aster) source "
"format"));
puts(_(" -variable Allow codes after 72 digits not "
"to be ignored"));
puts(_(" -g Enable Java compiler debug"));
puts(_(" -debug Enable all run-time error "
"checking"));
Expand Down
1 change: 1 addition & 0 deletions cobj/cobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define CB_FORMAT_FIXED 0
#define CB_FORMAT_FREE 1
#define CB_FORMAT_FREE_1COL_ASTER 2
#define CB_FORMAT_VARIABLE 3

extern int cb_source_format;
extern int cb_source_format1;
Expand Down
15 changes: 12 additions & 3 deletions cobj/pplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,9 @@ static void check_directive(char *buff, int *line_size) {
cb_source_format1 = 1;
return;
}
if (!strcasecmp(sbuff[2], "VARIABLE")) {
cb_source_format = CB_FORMAT_VARIABLE;
}
break;
default:
if (strcasecmp(sbuff[1], "FORMAT")) {
Expand All @@ -3728,6 +3731,9 @@ static void check_directive(char *buff, int *line_size) {
cb_source_format1 = 1;
return;
}
if (!strcasecmp(sbuff[3], "VARIABLE")) {
cb_source_format = CB_FORMAT_VARIABLE;
}
break;
}
cb_warning(_("Invalid directive - ignored"));
Expand Down Expand Up @@ -3905,6 +3911,8 @@ static void check_dollar_directive(char *buff, int *line_size) {
cb_source_format = CB_FORMAT_FREE_1COL_ASTER;
cb_source_format1 = 1;
return;
} else if (strcasecmp(sbuff[1], "SOURCEFORMAT(VARIABLE)") == 0) {
cb_source_format = CB_FORMAT_VARIABLE;
} else {
cb_compile_status = CB_COMPILE_STATUS_ERROR;
cb_error(_("Invalid $SET"));
Expand Down Expand Up @@ -3968,7 +3976,7 @@ static int ppinput(char *buff, int max_size) {
return strlen(buff);
}
if (n == 0 && cb_source_format != CB_FORMAT_FIXED &&
cb_source_format1 != 1) {
cb_source_format1 != 1 && cb_source_format != CB_FORMAT_VARIABLE) {
if (ipchar != ' ' && ipchar != '\n') {
buff[n++] = ' ';
}
Expand Down Expand Up @@ -4029,7 +4037,8 @@ static int ppinput(char *buff, int max_size) {
}

/* nothing more to do with free format */
if (cb_source_format != CB_FORMAT_FIXED) {
if (cb_source_format != CB_FORMAT_FIXED &&
cb_source_format != CB_FORMAT_VARIABLE) {
return n;
}

Expand Down Expand Up @@ -4117,7 +4126,7 @@ static int ppinput(char *buff, int max_size) {
}

/* check the text that is longer than cb_text_column */
if (n > cb_text_column + 1) {
if (n > cb_text_column + 1 && cb_source_format != CB_FORMAT_VARIABLE) {

/* show warning if it is not whitespaces */
if (cb_warn_column_overflow && last_line_2 < cb_source_line - 1) {
Expand Down
15 changes: 12 additions & 3 deletions cobj/pplex.l
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ check_directive (char *buff, int *line_size)
cb_source_format1 = 1;
return;
}
if (!strcasecmp (sbuff[2], "VARIABLE")){
cb_source_format = CB_FORMAT_VARIABLE;
}
break;
default:
if (strcasecmp (sbuff[1], "FORMAT")) {
Expand All @@ -743,6 +746,9 @@ check_directive (char *buff, int *line_size)
cb_source_format1 = 1;
return;
}
if (!strcasecmp (sbuff[3], "VARIABLE")){
cb_source_format = CB_FORMAT_VARIABLE;
}
break;
}
cb_warning (_("Invalid directive - ignored"));
Expand Down Expand Up @@ -908,6 +914,8 @@ check_dollar_directive (char *buff, int *line_size)
cb_source_format = CB_FORMAT_FREE_1COL_ASTER;
cb_source_format1 = 1;
return;
} else if (strcasecmp (sbuff[1], "SOURCEFORMAT(VARIABLE)") == 0){
cb_source_format = CB_FORMAT_VARIABLE;
} else {
cb_compile_status = CB_COMPILE_STATUS_ERROR;
cb_error (_("Invalid $SET"));
Expand Down Expand Up @@ -972,7 +980,8 @@ start:
newline_count = 0;
return strlen (buff);
}
if (n == 0 && cb_source_format != CB_FORMAT_FIXED && cb_source_format1 != 1) {
if (n == 0 && cb_source_format != CB_FORMAT_FIXED && cb_source_format1 != 1
&& cb_source_format != CB_FORMAT_VARIABLE) {
if (ipchar != ' ' && ipchar != '\n') {
buff[n++] = ' ';
}
Expand Down Expand Up @@ -1033,7 +1042,7 @@ start:
}

/* nothing more to do with free format */
if (cb_source_format != CB_FORMAT_FIXED) {
if (cb_source_format != CB_FORMAT_FIXED && cb_source_format != CB_FORMAT_VARIABLE) {
return n;
}

Expand Down Expand Up @@ -1121,7 +1130,7 @@ start:
}

/* check the text that is longer than cb_text_column */
if (n > cb_text_column + 1) {
if (n > cb_text_column + 1 && cb_source_format != CB_FORMAT_VARIABLE) {

/* show warning if it is not whitespaces */
if (cb_warn_column_overflow && last_line_2 < cb_source_line - 1) {
Expand Down
15 changes: 12 additions & 3 deletions cobj/pplex.l.m4
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,9 @@ check_directive (char *buff, int *line_size)
cb_source_format1 = 1;
return;
}
if (!strcasecmp (sbuff[2], "VARIABLE")){
cb_source_format = CB_FORMAT_VARIABLE;
}
break;
default:
if (strcasecmp (sbuff[1], "FORMAT")) {
Expand All @@ -758,6 +761,9 @@ check_directive (char *buff, int *line_size)
cb_source_format1 = 1;
return;
}
if (!strcasecmp (sbuff[3], "VARIABLE")){
cb_source_format = CB_FORMAT_VARIABLE;
}
break;
}
cb_warning (_("Invalid directive - ignored"));
Expand Down Expand Up @@ -923,6 +929,8 @@ check_dollar_directive (char *buff, int *line_size)
cb_source_format = CB_FORMAT_FREE_1COL_ASTER;
cb_source_format1 = 1;
return;
} else if (strcasecmp (sbuff[1], "SOURCEFORMAT(VARIABLE)") == 0){
cb_source_format = CB_FORMAT_VARIABLE;
} else {
cb_compile_status = CB_COMPILE_STATUS_ERROR;
cb_error (_("Invalid $SET"));
Expand Down Expand Up @@ -987,7 +995,8 @@ start:
newline_count = 0;
return strlen (buff);
}
if (n == 0 && cb_source_format != CB_FORMAT_FIXED && cb_source_format1 != 1) {
if (n == 0 && cb_source_format != CB_FORMAT_FIXED && cb_source_format1 != 1
&& cb_source_format != CB_FORMAT_VARIABLE) {
if (ipchar != ' ' && ipchar != '\n') {
buff[n++] = ' ';
}
Expand Down Expand Up @@ -1048,7 +1057,7 @@ start:
}

/* nothing more to do with free format */
if (cb_source_format != CB_FORMAT_FIXED) {
if (cb_source_format != CB_FORMAT_FIXED && cb_source_format != CB_FORMAT_VARIABLE) {
return n;
}

Expand Down Expand Up @@ -1136,7 +1145,7 @@ start:
}

/* check the text that is longer than cb_text_column */
if (n > cb_text_column + 1) {
if (n > cb_text_column + 1 && cb_source_format != CB_FORMAT_VARIABLE) {

/* show warning if it is not whitespaces */
if (cb_warn_column_overflow && last_line_2 < cb_source_line - 1) {
Expand Down
53 changes: 53 additions & 0 deletions tests/command-line-options.src/free.at
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,57 @@ HELLO
WORLD
])

AT_CLEANUP

AT_SETUP([-variable])

AT_DATA([prog.cbl], [
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. prog.
000003 DATA DIVISION.
000004 WORKING-STORAGE SECTION.
000005 PROCEDURE DIVISION.
000006 DISPLAY "HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO".
])

AT_CHECK([${COBJ} -variable prog.cbl])
AT_CHECK([${RUN_MODULE} prog], [0],
[HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO
])

AT_DATA([prog2.cbl], [
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. prog2.
000003 DATA DIVISION.
000004 WORKING-STORAGE SECTION.
000005PROCEDURE DIVISION.
000006 STOP RUN.
])

AT_CHECK([${COBJ} -variable prog2.cbl], [1], [],
[prog2.cbl:5: Error: Invalid indicator 'P' at column 7
])

AT_DATA([prog3.cbl], [
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. prog3.
000003 DATA DIVISION.
000004 WORKING-STORAGE SECTION.
000005 COPY inc.
000006 PROCEDURE DIVISION.
000007 DISPLAY AFTER-72.
000008 DISPLAY "HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO".
000009 STOP RUN.
])

AT_DATA([inc.cpy], [
000001 01 AFTER-72 PIC X(119) VALUE "HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO".
])

AT_CHECK([${COBJ} -variable prog3.cbl])
AT_CHECK([${RUN_MODULE} prog3], [0],
[HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO
HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO HELLO
])

AT_CLEANUP