#74 Record length variable set in FD does not work on write

unclassified
accepted
None
1
2014-07-28
2014-05-27
No

Create an FD where the record is varying in size depending on variable. Set the length to some value whereby trailing spaces are in the record to be written. Write out the record. Attached is a small sample program demonstrating the bug and a patch.

1 Attachments

Discussion

  • stephen connolly

    sample program

     
  • Simon Sobisch

    Simon Sobisch - 2014-06-05

    Good catch. I've had a look and found additional problems:

    • missing Status 44 (see new patch for libcob\fileio.c below)
    • missing support "RECORD clause invalid" for RECORD IS VARYING FROM number-1 CHARACTERS DEPENDING ON data-name (without TO number-2) and not correct behavior if [FROM number-1] isn't given. Needs changes in parser.y and tree.c.

    I'll finish my changes and commit them along with missing test cases.

        /* Determine the size to be written */
    -   if (unlikely(cob_ls_fixed != 0)) {
    +   if (f->variable_record) {
    +       size = (size_t)cob_get_int (f->variable_record);
    +       if (unlikely((size > f->record_max) || size < f->record_min)) {
    +           return COB_STATUS_44_RECORD_OVERFLOW;
    +       }
    +   } else if (unlikely(cob_ls_fixed != 0)) {
            size = f->record->size;
    

    Simon

     
    Last edit: Simon Sobisch 2014-06-05
  • Simon Sobisch

    Simon Sobisch - 2014-06-05

    Ticket moved from /p/open-cobol/patches/8/

     
  • Simon Sobisch

    Simon Sobisch - 2014-06-10
    • status: open --> accepted
    • assigned_to: Simon Sobisch
    • Group: Test --> open
     

Log in to post a comment.