Git Product home page Git Product logo

opensourcecobol / opensource-cobol Goto Github PK

View Code? Open in Web Editor NEW
68.0 25.0 27.0 12.53 MB

"opensource COBOL" is open-source COBOL compiler, an extension of the Japan-specific features. "opensource COBOL" translates COBOL program to C code and compiles it using GCC or CL.

Home Page: https://www.osscons.jp/osscobol/

License: GNU General Public License v2.0

Shell 38.84% C 45.34% COBOL 0.38% Perl 6 0.16% Makefile 5.67% Yacc 2.71% M4 6.69% C++ 0.21%
c cobol

opensource-cobol's Issues

English commit-messages / missing Changelog entries

For understanding what is going on here it would be very helpful to have the commit messages in English.
They actually could contain both Japanese and English messages if this would be helpful for the Japanese users.

The old messages can be changed, too - see https://help.github.com/articles/changing-a-commit-message/

In general there is are two things missing:

a) "user viewable changes" - NEWS file - you actually did a quite good job to provide the messages in https://github.com/opensourcecobol/opensource-cobol/releases - they only are missing from the NEWS file - please copy them over and commit the file.
Afterwards it is fine to change the NEWS file when preparing a new release.

b) Changelog entries - not every minor change needs them but it is good to have entries for most changes. I assume the commit messages can be used as a first "source" for them, you may see missing stuff when copying them (translated to English) into the Changelogs.
Afterwards Changelog entries are ideally always done during a change and committed along the actual change.

Thank you for responding.

Duplicate definitions of the same variable

An error occurs where the same variable is defined multiple times.
This error has been occurring since v1.0.19.

COBOL code:

      ****************************************************************
      *                                                              *
      *         ローン返済額計算(元利均等返済)                        *
      *                                                              *
      ****************************************************************
       IDENTIFICATION          DIVISION.
      ****************************************************************
       PROGRAM-ID.             LOANSAMPLE.
       AUTHOR.                 TOKYO-SYSTEM-HOUSE.
       DATE-WRITTEN.           2016/01/14.
       ENVIRONMENT             DIVISION.
       CONFIGURATION           SECTION.
       SOURCE-COMPUTER.        OPEN-COBOL.
       OBJECT-COMPUTER.        OPEN-COBOL.
      ****************************************************************
       DATA                    DIVISION.
      ****************************************************************
       WORKING-STORAGE         SECTION.
      * 01  WK-AREA.
       01  WK-INTEREST-RATE  PIC 9(02)V9(03).
       01  WK-INTEREST-YEAR  PIC 9(02)V9(09).
       01  WK-INTEREST-MONTH PIC 9(02)V9(09).
       01  WK-PERIODS        PIC 999.
       01 WK-PAYMENT        PIC 9(09).*>V9(09).
       01  WK-LOAN           PIC 9(09)V9(09).
       01  WK-LOAN-LEFT      PIC 9(09)V9(09).
       01  WK-PRINCIPAL      PIC 9(09).*>V9(09).
       01  WK-INTEREST       PIC 9(09).*>V9(09).
       01  WK-PERIODS-CNT    PIC 999.
       01  WK-DATE.
           05  WK-YEAR         PIC 9999.
           05  WK-MONTH        PIC 99.
           05  WK-DAY          PIC 99.
       01  WK-KAKUNIN          PIC X.
       *01  DSP-AREA.
       01  DSP-PAYMENT       PIC ZZZ,ZZZ,ZZ9.*>.99.
       01  DSP-PRINCIPAL     PIC ZZZ,ZZZ,ZZ9.*>.99.
       01  DSP-INTEREST      PIC ZZZ,ZZZ,ZZ9.*>.99.
       01  DSP-LOAN-LEFT     PIC ZZZ,ZZZ,ZZ9.*>.99.
       01  DSP-PERIODS-CNT   PIC ZZ9.  
       01  DSP-YEAR          PIC 9999.
       01  DSP-MONTH         PIC 99.      
       COPY "NUM-IO".
      ****************************************************************
       PROCEDURE               DIVISION.
      ****************************************************************
       HAJIME.
       MAIN-000.
           DISPLAY "***  ローン返済額計算  ***" .
           DISPLAY "借入金額: " NO ADVANCING.
           COPY "NUM-ACP" REPLACING =='#1'==  BY ==WK-LOAN==..
           DISPLAY "年利 (%): " NO ADVANCING.        
           COPY "NUM-ACP" REPLACING =='#1'==  BY ==WK-INTEREST-RATE==..
           DISPLAY "ローン期間(月): " NO ADVANCING.
           COPY "NUM-ACP" REPLACING =='#1'==  BY ==WK-PERIODS==..
       MAIN-100.
           COMPUTE WK-INTEREST-YEAR  = WK-INTEREST-RATE / 100.
           COMPUTE WK-INTEREST-MONTH = WK-INTEREST-YEAR / 12.
           COMPUTE WK-PAYMENT ROUNDED
                 = (WK-LOAN * WK-INTEREST-MONTH *
                    ((1 + WK-INTEREST-MONTH) ** (WK-PERIODS)))
                 / ((1 + WK-INTEREST-MONTH) ** (WK-PERIODS) - 1).            
       MAIN-100.
           DISPLAY "返済額(月) = " NO ADVANCING.
           MOVE WK-PAYMENT TO DSP-PAYMENT.
           DISPLAY DSP-PAYMENT.
           DISPLAY "印刷しますか?(Y/N)".
           ACCEPT WK-KAKUNIN.
           IF WK-KAKUNIN NOT = "Y"
               GO TO OWARI.
       MAIN-200.
           MOVE  WK-LOAN TO WK-LOAN-LEFT.
           MOVE  1       TO WK-PERIODS-CNT.
           ACCEPT WK-DATE FROM DATE YYYYMMDD.
      *            "ZZ9 9999/99  ZZZ,ZZZ,ZZ9 ZZZ,ZZZ,ZZ9 ZZZ,ZZZ,ZZ9 ZZZ,ZZZ,ZZ9"     
           DISPLAY "NO  年月     支払        原本        利息   "        
      -            "     残元金".
           DISPLAY "--- ------- ----------- ----------- ----------- ----
      -            "-------".
       MAIN-210.
           COMPUTE WK-INTEREST  ROUNDED
                   = WK-LOAN-LEFT * WK-INTEREST-MONTH.
           COMPUTE WK-PRINCIPAL = WK-PAYMENT - WK-INTEREST.
           COMPUTE WK-LOAN-LEFT = WK-LOAN-LEFT - WK-PRINCIPAL.
           IF WK-PERIODS-CNT = WK-PERIODS
              ADD  WK-LOAN-LEFT  TO WK-PRINCIPAL
                                    WK-PAYMENT
              MOVE ZERO          TO WK-LOAN-LEFT.
           MOVE    WK-PERIODS-CNT TO DSP-PERIODS-CNT.
           MOVE    WK-PAYMENT    TO DSP-PAYMENT.
           MOVE    WK-INTEREST   TO DSP-INTEREST.
           MOVE    WK-PRINCIPAL  TO DSP-PRINCIPAL.
           MOVE    WK-LOAN-LEFT  TO DSP-LOAN-LEFT.
           DISPLAY WK-PERIODS-CNT " " WK-YEAR "/" WK-MONTH " "
                   DSP-PAYMENT " "
                   DSP-PRINCIPAL " " DSP-INTEREST " "
                   DSP-LOAN-LEFT.
           COMPUTE WK-PERIODS-CNT = WK-PERIODS-CNT + 1.
           IF WK-MONTH = 12
              MOVE 1 TO WK-MONTH
              ADD  1 TO WK-YEAR
           ELSE
              ADD  1 TO WK-MONTH.     
           IF WK-PERIODS-CNT > WK-PERIODS
              GO TO OWARI.
           GO TO MAIN-210.
       OWARI.
           STOP RUN.
      *--------------------<< END OF PROGRAM >>-----------------------*

java code:

/* Sections and Labels */
  private final static int l_LOANSAMPLE = 1;
  private final static int l_MAIN_SECTION = 2;
  private final static int l_MAIN_SECTION__HAJIME = 3;
  private final static int l_MAIN_SECTION__MAIN_000 = 4;
  private final static int l_MAIN_SECTION__MAIN_100 = 5;
  private final static int l_MAIN_SECTION__MAIN_100 = 6;
  private final static int l_MAIN_SECTION__MAIN_200 = 7;
  private final static int l_MAIN_SECTION__MAIN_210 = 8;
  private final static int l_MAIN_SECTION__OWARI = 9;
  private final static int l_Default_Error_Handler = 10;

error message:
./LOANSAMPLE.java:718: error: variable l_MAIN_SECTION__MAIN_100 is already defined in class LOANSAMPLE private final static int l_MAIN_SECTION__MAIN_100 = 6; ^ 1 error

test

テストです。

Java変換プロジェクト

opensource COBOL開発者各位

お疲れ様です。
現在、我々のチームでopenosurce COBOLでのCOBOLのコンバート先として、C言語だけでなく、Javaコードを出力できるようにすることを考えています。

目的として、以下2点があります。

  • 昨今増えてきているJavaのシステムとの親和性を向上し、クラウド、マイクロサービスへの適用を考える
  • 日本国内ではCOBOLからJavaへの移行の需要が増えており、その中で利用できるようにしたい

開発内容について、opensourcecobol内に別途リポジトリを作成して共有したいと考えています。
ご意見有りましたら、コメントお願いいたします。

--
We would like to update opensource COBOL to generate Java code not only C code

because,

  • I want to improve the affinity with the Java system
  • I want to help migration, migrate from COBOL to Java

I'm thinking of create new repositoy and publish development.

what's your opinion.

Memory leaks in `Hello World` program

I used valgrind memory check against 'Hello World' program and found memory leaks.

       IDENTIFICATION              DIVISION.
       PROGRAM-ID.                 hello.
       DATA                        DIVISION.
       WORKING-STORAGE             SECTION.
       PROCEDURE                   DIVISION.
           DISPLAY "Hello".
           STOP RUN.
$ cobc -g -x hello.cbl
$ valgrind --leak-check=full --show-leak-kinds=all --tool=memcheck ./hello
==3009== Memcheck, a memory error detector
==3009== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3009== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==3009== Command: ./hello
==3009==
Hello
==3009==
==3009== HEAP SUMMARY:
==3009==     in use at exit: 35,883 bytes in 171 blocks
==3009==   total heap usage: 211 allocs, 40 frees, 45,470 bytes allocated
==3009==
==3009== 2 bytes in 1 blocks are definitely lost in loss record 1 of 38
==3009==    at 0x4C360A5: malloc (vg_replace_malloc.c:380)
==3009==    by 0x5D1480D: strdup (in /usr/lib64/libc-2.28.so)
==3009==    by 0x4E5253C: cob_init (in /usr/lib/libcob.so.1.0.0)
==3009==    by 0x400B55: main (hello.c:31)
==3009==
==3009== LEAK SUMMARY:
==3009==    definitely lost: 2 bytes in 1 blocks
==3009==    indirectly lost: 0 bytes in 0 blocks
==3009==      possibly lost: 0 bytes in 0 blocks
==3009==    still reachable: 35,881 bytes in 170 blocks
==3009==         suppressed: 0 bytes in 0 blocks
==3009== Reachable blocks (those to which a pointer was found) are not shown.
==3009== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3009==
==3009== For lists of detected and suppressed errors, rerun with: -s
==3009== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

機能開発時のブランチ名について

お世話になります。井坂です。

v1.4.0J作成時は、別サイトで管理していましたチケットIDをブランチ名として利用していました。
(チケット100ならブランチ名[iss100])

今後の開発はgithub上ですべて行えるように、ブランチ名については簡単な機能名などを付けていったほうがいいかと考えています。
※あまり名前付けは得意ではないので、何か規則があるとうれしいです

皆様のご意見はありますでしょうか。

プレリリース用のブランチ作成について

お世話になります。井坂です。

こちら側の都合となってしまい恐縮ですが、各機能を開発するにあたって、未リリースの状態でも機能をマージした環境が欲しいなと考えています。

いきなりマスターに入れてしまうのも運用上、あまりよくないと思いますので、開発中リポジトリを用意するのはどうでしょうか。

※ついでに開発時の運用ルールとかもある程度相談できればと思います。

Update automake files

While developing #41 , While developing # 41, I got many errors when trying to add an option to configure.

Opensource COBOL's Automake related files are created for older versions, and running new Automake and Autoconf will result in an error.
 
I'm thinking of updating these files, but what about that?
Or, please let me know if you already have the updated file.

Currently I am installing and fixing an older version of Automake.

make error while trying to generate/install opensource COBOL on Linux

I installed GNU MP (libgmp) successfully in Ubuntu 18. To generate/install opensource COBOL on Linux, I then ran ./configure and ran successfully. Then I ran make. I got some errors. I wanted to restart make, so I ran make clean and afterwards ran make.

The make command did not run successfully. I got errors and the first error was the following error. Attached is the full log of the last time I ran make.

rm -f ja.gmo && : -c --statistics -o ja.gmo ja.po
Makefile:123: recipe for target 'ja.gmo' failed

make.log

Could anybody help?

コーディングスタイルについて

以前に部会にて「オリジナルのOpenCOBOLとコーディングスタイルを合わせる」方針について検討した際に作成しました指針について挙げます。
ご意見、ご指摘、間違い等ありましたら返信願います。

1.関数呼び出しを行う際に関数名と"("の間に半角スペースを入れる。

2.","の後ろには半角スペースを入れる。

3.文字列の際に、型と変数名の間にタブを2つ入れる。INT型の宣言は半角スペースを入れる。

4.memcpyを呼び出す場合、引数として渡す式の演算子の前後にはスペースを入れない。

5.FOR文の各演算子の前後、";"の後ろには半角スペースを入れる。

6.通常の式では演算子の前後に半角スペースを入れる。

7."sizeof"と"("の間には半角スペースを入れる。(4の場合であってもsizeofは例外)

8.IF文の条件句の")"と"{"の間には半角スペースを入れる。改行は入れない。

9.各行の後ろや空白行などで、無駄なスペースを入れない。

10.SWITCH文の内部のCASEについては、インデントを下げない。

11.CASE文の中の演算(1行にまとまるもの)については演算子、";"などの前後にスペースを入れない。

12.IF文の条件式等、複数行にわたって記述する際には、各行の条件文の先頭の"文字"をそろえる。

13.コメントの後に空白行をいれない。

14.#defineによる宣言では区切りにタブを使う

15.グローバル宣言の文字列(char *)の宣言では、"char * 変数名"と半角スペースで区切る。(3の例外)

16.関数の宣言では、返り値と関数名の間は改行を行う。

17.変数宣言後、処理記述の間には空白行を入れる。

18.ELSE IFで対応できるものはつなげていく

19.typedef struct後の構造体名宣言では"}"と名前の間に半角スペースを入れる。

20.EXTERNの関数宣言では以下の形式
 →extern[_]void[_]関数名[タブ*1またはタブ*2](引数)
 →extern[_]int[_][_]関数名[タブ*1またはタブ*2](引数)

#INCLUDE problem in libcob/call.c

This is not a particularly important issue.
When building opensource-cobol, make command displays the following warning message.

 gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -O2 -finline-functions -fsigned-char -Wall -Wwrite-strings -Wmissing-prototypes -Wno-format-y2k -MT libcob_la-call.lo -MD -MP -MF .deps/libcob_la-call.Tpo -c call.c  -fPIC -DPIC -o .libs/libcob_la-call.o
call.c: In function 'cob_init_call':
call.c:595:7: warning: implicit declaration of function 'strcasecmp' [-Wimplicit-function-declaration]
  595 |   if (strcasecmp (s, "LOWER") == 0) {
      | 

The function strcasecmp is defined in strings.h of C standard libraries.
Even if #include<strings.h> is added to libcob/call.c, the warning will not be resolved.
The cause of the above warning message is that #include <strings.h> refers to libcob/strings.h instead of strings.h of C standard libraries. (gcc finds libcob/strings.h first because of -I. option)
I think it is necessary to update Makefile.am in order to fix the problem.
Once I learn more about Automake and Autoconf, I will fix the warning message.

JSON support

I tried to implement the JSON function.
This function like a environment function with jansson.

DISPLAY JSON-NAME : Specify the name of JSON structure.
DISPLAY JSON-KEY : Register period separated key names.
ACCEPT JSON-VALUE: Gets the value specified by JSON-KEY from JSON-NAME data.

Look at this branch: feature/JSON_support

COBOL sample:

      ******************************************************************
      *  opensource COBOL JSON support
      ******************************************************************
       IDENTIFICATION              DIVISION.
      ******************************************************************
       PROGRAM-ID.                 JSON.
       AUTHOR.                     n-isaka.
       DATE-WRITTEN.               2019-06-13.
      ******************************************************************
       ENVIRONMENT                 DIVISION.
      ******************************************************************
       CONFIGURATION               SECTION.
       SPECIAL-NAMES.
      ******************************************************************
       INPUT-OUTPUT                SECTION.
       FILE-CONTROL.
      ******************************************************************
       DATA                        DIVISION.
      ******************************************************************
       FILE                        SECTION.
      ******************************************************************
       WORKING-STORAGE             SECTION.
       01  JSON-STR                PIC  X(255).
       01  J-KEY                   PIC  X(255).
       01  J-VALUE                 PIC  X(255).
      ******************************************************************
       PROCEDURE                   DIVISION.
      ******************************************************************
       MAIN-RTN.

      *    *** 1つ目のJSONを登録
           STRING '{'                             DELIMITED BY SIZE
                     '"key1" : "value1",'         DELIMITED BY SIZE
                     '"key2" : 2,'                DELIMITED BY SIZE
                     '"key3" : {'                 DELIMITED BY SIZE
                        '"key3-1" : "value3-1",'  DELIMITED BY SIZE
                        '"key3-2" : "value3-2"'   DELIMITED BY SIZE
                     '},'                         DELIMITED BY SIZE
                     '"key4" : ['                 DELIMITED BY SIZE
                        '"value4-1",'             DELIMITED BY SIZE
                        '"value4-2",'             DELIMITED BY SIZE
                        '"value4-3"'              DELIMITED BY SIZE
                     ']'                          DELIMITED BY SIZE
                  '}'                             DELIMITED BY SIZE
                  INTO JSON-STR.

           DISPLAY "JSON"          UPON JSON-NAME.
           DISPLAY JSON-STR        UPON JSON-VALUE.

      *    *** 2つ目のJSONを登録
           MOVE SPACE              TO JSON-STR.
           STRING '{'                             DELIMITED BY SIZE
                     '"key10" : "value10"'        DELIMITED BY SIZE
                  '}'                             DELIMITED BY SIZE
                  INTO JSON-STR.

           DISPLAY "JSON2"         UPON JSON-NAME.
           DISPLAY JSON-STR        UPON JSON-VALUE.

      *    *** 1つ目のJSONを選択
           DISPLAY "JSON"          UPON JSON-NAME.

      *    *** 1つ目のJSONからKEYでデータを取得
      *    *** 配列は対応
           MOVE "key4[1]"          TO J-KEY.
           MOVE SPACE              TO J-VALUE.
           DISPLAY J-KEY           UPON JSON-KEY.
           ACCEPT  J-VALUE         FROM JSON-VALUE.
           DISPLAY J-KEY ":" J-VALUE.
      *    key4[1] : value4-2

      *    *** 数値型も対応
           MOVE "key2"             TO J-KEY.
           MOVE SPACE              TO J-VALUE.
           DISPLAY J-KEY           UPON JSON-KEY.
           ACCEPT  J-VALUE         FROM JSON-VALUE.
           DISPLAY J-KEY ":" J-VALUE.
      *    key2 : 2

      *    *** 入れ子も対応
           MOVE "key3.key3-2"      TO J-KEY.
           MOVE SPACE              TO J-VALUE.
           DISPLAY J-KEY           UPON JSON-KEY.
           ACCEPT  J-VALUE         FROM JSON-VALUE.
           DISPLAY J-KEY ":" J-VALUE.
      *    key3.key3-2 : value3-2

      *    *** 2つ目のJSONを選択
           DISPLAY "JSON2"         UPON JSON-NAME.

      *    *** 2つ目のJSONから値を取得
           MOVE "key10"            TO J-KEY.
           MOVE SPACE              TO J-VALUE.
           DISPLAY J-KEY           UPON JSON-KEY.
           ACCEPT  J-VALUE         FROM JSON-VALUE.
           DISPLAY J-KEY ":" J-VALUE.
      *    key10 : value10

      *    *** この時1個目のJSONからは値がとれない
           MOVE "key3.key3-2"      TO J-KEY.
           MOVE SPACE              TO J-VALUE.
           DISPLAY J-KEY           UPON JSON-KEY.
           ACCEPT  J-VALUE         FROM JSON-VALUE.
           DISPLAY J-KEY ":" J-VALUE.
      *    key3.key3-2 : 

       MAIN-EXT.
           STOP RUN.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.