From e284c47e8917d913723e8c884f389caee887705e Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 9 Sep 2022 10:27:42 +0200 Subject: [PATCH 1/9] Add base for GnuCobol version --- COBOL/Gnu/.gitignore | 3 ++ COBOL/Gnu/GildedRose.cbl | 76 ++++++++++++++++++++++++++++++++++++++++ COBOL/Gnu/build.sh | 1 + COBOL/Gnu/run.sh | 2 ++ 4 files changed, 82 insertions(+) create mode 100644 COBOL/Gnu/.gitignore create mode 100644 COBOL/Gnu/GildedRose.cbl create mode 100755 COBOL/Gnu/build.sh create mode 100755 COBOL/Gnu/run.sh diff --git a/COBOL/Gnu/.gitignore b/COBOL/Gnu/.gitignore new file mode 100644 index 00000000..da658a72 --- /dev/null +++ b/COBOL/Gnu/.gitignore @@ -0,0 +1,3 @@ +in-items +items +GildedRose.so diff --git a/COBOL/Gnu/GildedRose.cbl b/COBOL/Gnu/GildedRose.cbl new file mode 100644 index 00000000..47e5c117 --- /dev/null +++ b/COBOL/Gnu/GildedRose.cbl @@ -0,0 +1,76 @@ +program-id. GildedRose as "GildedRose". + +environment division. + +input-output section. + +file-control. + select in-items assign 'in-items'. + select items assign 'items'. + +data division. +file section. + fd in-items. + 01 in-item pic x(58). + fd items. + 01 item. + 02 sell-in pic 9(4). + 02 quality pic 9(4). + 02 name pic x(50). + +working-storage section. +procedure division. + open input in-items output items. +start-lable. + read in-items end go to end-lable. + move in-item to item. + if name not equal "Aged Brie" and name not equal "Backstage passes to a TAFKAL80ETC concert" + if quality > 0 + if name not equal to "Sulfuras, Hand of Ragnaros" + compute quality = quality - 1 + end-if + end-if + else + if quality < 50 + compute quality = quality + 1 + if name equals "Backstage passes to a TAFKAL80ETC concert" + if sell-in < 11 + if quality < 50 + compute quality = quality + 1 + end-if + end-if + if sell-in < 6 + if quality < 50 + compute quality = quality + 1 + end-if + end-if + end-if + end-if + end-if + if name not equal "Sulfuras, Hand of Ragnaros" + compute sell-in = sell-in - 1 + end-if + if sell-in < 0 + if name is not equal to "Aged Brie" + if name is not equal to "Backstage passes to a TAFKAL80ETC concert" + if quality > 0 + if name is equal to "Sulfuras, Hand of Ragnaros" + compute quality = quality - 1 + end-if + end-if + else + compute quality = quality - quality + end-if + else + if quality < 50 + compute quality = quality + 1 + end-if + end-if + end-if + write item. + go to start-lable. +end-lable. + close items. +goback. + +end program GildedRose. diff --git a/COBOL/Gnu/build.sh b/COBOL/Gnu/build.sh new file mode 100755 index 00000000..1632b7c3 --- /dev/null +++ b/COBOL/Gnu/build.sh @@ -0,0 +1 @@ +cobc --free --std=mf -O GildedRose.cbl diff --git a/COBOL/Gnu/run.sh b/COBOL/Gnu/run.sh new file mode 100755 index 00000000..3201dadf --- /dev/null +++ b/COBOL/Gnu/run.sh @@ -0,0 +1,2 @@ +touch in-items +cobcrun GildedRose From cfb27bf23c9b3ab8d5e10cf5126d448ee84919fc Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 9 Sep 2022 10:35:28 +0200 Subject: [PATCH 2/9] Add test script --- COBOL/Gnu/test.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 COBOL/Gnu/test.sh diff --git a/COBOL/Gnu/test.sh b/COBOL/Gnu/test.sh new file mode 100755 index 00000000..de74c645 --- /dev/null +++ b/COBOL/Gnu/test.sh @@ -0,0 +1,2 @@ +./build.sh +./run.sh From 07c3edcb487bae020d9f22c1856e5fe73e476c0b Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 9 Sep 2022 10:35:41 +0200 Subject: [PATCH 3/9] Fix warning --- COBOL/Gnu/GildedRose.cbl | 1 + 1 file changed, 1 insertion(+) diff --git a/COBOL/Gnu/GildedRose.cbl b/COBOL/Gnu/GildedRose.cbl index 47e5c117..7ded4149 100644 --- a/COBOL/Gnu/GildedRose.cbl +++ b/COBOL/Gnu/GildedRose.cbl @@ -71,6 +71,7 @@ start-lable. go to start-lable. end-lable. close items. + close in-items. goback. end program GildedRose. From 3720febc884430533706c326a9af84f9a0be4315 Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 16 Sep 2022 15:36:26 +0200 Subject: [PATCH 4/9] Reduce the size of sell in and quality --- COBOL/Gnu/.gitignore | 2 +- COBOL/Gnu/GildedRose.cbl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/COBOL/Gnu/.gitignore b/COBOL/Gnu/.gitignore index da658a72..a2e99edb 100644 --- a/COBOL/Gnu/.gitignore +++ b/COBOL/Gnu/.gitignore @@ -1,3 +1,3 @@ in-items items -GildedRose.so +*.so diff --git a/COBOL/Gnu/GildedRose.cbl b/COBOL/Gnu/GildedRose.cbl index 7ded4149..5a234473 100644 --- a/COBOL/Gnu/GildedRose.cbl +++ b/COBOL/Gnu/GildedRose.cbl @@ -11,11 +11,11 @@ file-control. data division. file section. fd in-items. - 01 in-item pic x(58). + 01 in-item pic x(54). fd items. 01 item. - 02 sell-in pic 9(4). - 02 quality pic 9(4). + 02 sell-in pic s9(2). + 02 quality pic s9(2). 02 name pic x(50). working-storage section. From 9f208d7947d0cbcdf81b74690bca0c6fb1722064 Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 16 Sep 2022 15:38:18 +0200 Subject: [PATCH 5/9] Build all cbl files --- COBOL/Gnu/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COBOL/Gnu/build.sh b/COBOL/Gnu/build.sh index 1632b7c3..2e4a3e7d 100755 --- a/COBOL/Gnu/build.sh +++ b/COBOL/Gnu/build.sh @@ -1 +1 @@ -cobc --free --std=mf -O GildedRose.cbl +cobc --free --std=mf -O *.cbl From 38da2b91ce851ed66639445007eaa732670e5ffd Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 16 Sep 2022 15:39:14 +0200 Subject: [PATCH 6/9] Don't touch in-items file --- COBOL/Gnu/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/COBOL/Gnu/run.sh b/COBOL/Gnu/run.sh index 3201dadf..c86e9224 100755 --- a/COBOL/Gnu/run.sh +++ b/COBOL/Gnu/run.sh @@ -1,2 +1 @@ -touch in-items cobcrun GildedRose From cae6ee8d5d02066f435aaff00cef5e50b504c61c Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 16 Sep 2022 15:43:39 +0200 Subject: [PATCH 7/9] Add add programm to add item to the in-items file --- COBOL/Gnu/Add.cbl | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 COBOL/Gnu/Add.cbl diff --git a/COBOL/Gnu/Add.cbl b/COBOL/Gnu/Add.cbl new file mode 100644 index 00000000..46436285 --- /dev/null +++ b/COBOL/Gnu/Add.cbl @@ -0,0 +1,38 @@ +program-id. Add as "Add". + +environment division. + +input-output section. + +file-control. + select in-items assign 'in-items'. + +data division. +file section. + fd in-items. + 01 item. + 02 sell-in pic s9(2). + 02 quality pic s9(2). + 02 name pic x(50). + +working-storage section. + 01 accept-item. + 02 sell-in pic s9(2). + 02 quality pic s9(2). + 02 name pic x(50). + + +procedure division. + open extend in-items. + display "name" + accept name in accept-item. + display "sell-in" + accept sell-in in accept-item. + display "quality" + accept quality in accept-item. + move accept-item to item. + write item. + close in-items. +goback. + +end program Add. From f97344859baf1ded1efd1f1947b7eab2c01bf53d Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Fri, 16 Sep 2022 15:44:23 +0200 Subject: [PATCH 8/9] Dont ignore the items files --- COBOL/Gnu/.gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/COBOL/Gnu/.gitignore b/COBOL/Gnu/.gitignore index a2e99edb..140f8cf8 100644 --- a/COBOL/Gnu/.gitignore +++ b/COBOL/Gnu/.gitignore @@ -1,3 +1 @@ -in-items -items *.so From 0dfaefa14791cc1c5069456c796670d1f6155de5 Mon Sep 17 00:00:00 2001 From: Samuel Ytterbrink Date: Mon, 26 Sep 2022 15:20:26 +0200 Subject: [PATCH 9/9] Add add script that helps you add items --- COBOL/Gnu/add.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 COBOL/Gnu/add.sh diff --git a/COBOL/Gnu/add.sh b/COBOL/Gnu/add.sh new file mode 100755 index 00000000..a75d0f68 --- /dev/null +++ b/COBOL/Gnu/add.sh @@ -0,0 +1,2 @@ +touch in-items +cobcrun Add \ No newline at end of file