Skip to content

Commit 9b756ac

Browse files
Bugfix about SEARCH with DEPENDING in OCCURS (#545)
1 parent 5fdd7cb commit 9b756ac

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

cobj/codegen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,7 @@ static void joutput_search_all(cb_tree table, cb_tree stmt, cb_tree cond,
26672667
joutput_prefix();
26682668
joutput("int tail = ");
26692669
if (p->occurs_depending) {
2670+
joutput("(int)");
26702671
joutput_integer(p->occurs_depending);
26712672
joutput(" + 1;\n");
26722673
} else {

cobj/pplex.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ typedef unsigned int flex_uint32_t;
379379
* to BEGIN to return to the state. The YYSTATE alias is for lex
380380
* compatibility.
381381
*/
382-
#define YY_START (((yy_start)-1) / 2)
382+
#define YY_START (((yy_start) - 1) / 2)
383383
#define YYSTATE YY_START
384384
/* Action number for EOF rule of a given start state. */
385385
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
@@ -2632,8 +2632,8 @@ YY_DECL {
26322632
default:
26332633
YY_FATAL_ERROR("fatal flex scanner internal error--no action found");
26342634
} /* end of action switch */
2635-
} /* end of scanning one token */
2636-
} /* end of user's declarations */
2635+
} /* end of scanning one token */
2636+
} /* end of user's declarations */
26372637
} /* end of yylex */
26382638

26392639
/* yy_get_next_buffer - try to read in a new buffer

tests/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ misc_DEPENDENCIES = \
221221
misc.src/evaluate-switch.at \
222222
misc.src/fserial-variable.at \
223223
misc.src/file-handler-japanese.at \
224-
misc.src/perform-until-div.at
224+
misc.src/perform-until-div.at \
225+
misc.src/search-occurs-depending.at
225226

226227
EXTRA_DIST = $(srcdir)/package.m4 \
227228
$(TESTS) \

tests/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ misc_DEPENDENCIES = \
760760
misc.src/evaluate-switch.at \
761761
misc.src/fserial-variable.at \
762762
misc.src/file-handler-japanese.at \
763-
misc.src/perform-until-div.at
763+
misc.src/perform-until-div.at \
764+
misc.src/search-occurs-depending.at
764765

765766
EXTRA_DIST = $(srcdir)/package.m4 \
766767
$(TESTS) \

tests/misc.at

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ m4_include([evaluate-switch.at])
5151
m4_include([fserial-variable.at])
5252
m4_include([file-handler-japanese.at])
5353
m4_include([perform-until-div.at])
54+
m4_include([search-occurs-depending.at])
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AT_SETUP([SEARCH OCCURS DEPENDING])
2+
3+
AT_DATA([prog.cbl], [
4+
IDENTIFICATION DIVISION.
5+
PROGRAM-ID. prog.
6+
DATA DIVISION.
7+
WORKING-STORAGE SECTION.
8+
01 AAA.
9+
02 AAA1 PIC X(04) VALUE "HOGE".
10+
02 FILLER PIC X(18) VALUE SPACE.
11+
02 AAA2 PIC S9(4) COMP.
12+
01 BBB.
13+
02 AAA-1 OCCURS 1 TO 11 DEPENDING ON AAA2
14+
ASCENDING KEY KEY-A INDEXED BY K1.
15+
03 KEY-A PIC X(05).
16+
03 BBB1 PIC X(05).
17+
03 FILLER PIC X(02).
18+
01 CCC PIC X(05).
19+
PROCEDURE DIVISION.
20+
SEARCH ALL AAA-1
21+
AT END
22+
MOVE "ERROR" TO CCC
23+
WHEN KEY-A (K1) = "00001"
24+
MOVE BBB1 (K1) TO CCC
25+
END-SEARCH.
26+
DISPLAY CCC.
27+
STOP RUN.
28+
])
29+
30+
AT_CHECK([${COBJ} prog.cbl], [0])
31+
32+
AT_CLEANUP

0 commit comments

Comments
 (0)