bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #64546] rec_parse_rset: Comments on Records Are Separate Records


From: anonymous
Subject: [bug #64546] rec_parse_rset: Comments on Records Are Separate Records
Date: Fri, 11 Aug 2023 15:32:52 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?64546>

                 Summary: rec_parse_rset: Comments on Records Are Separate
Records
                   Group: GNU recutils
               Submitter: None
               Submitted: Fri 11 Aug 2023 07:32:50 PM UTC
                Category: librec
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Fri 11 Aug 2023 07:32:50 PM UTC By: Anonymous
I could be ignorant of some details, it appears if the comment for a record is
placed above the first field, and there is more than one record in a record
set, the comment is added as a separate record.

Below (and attached) will output:
Record Set: Test
Record Count: 3

This is unvaried if instead a comment is prepended to the second record, or it
will count 4 if prepended to both.

Potentially caused by
[https://git.savannah.gnu.org/cgit/recutils.git/tree/src/rec-parser.c#n919
rec-parser.c#920].

test.rec:

%rec: Test

#If first line is a comment, and there are 2+ records... This is its own
record.
Line: This should be record 1, but it's 2.

Line: This should be record 2, but it's 3.


main.c:

#include <rec.h>
#include <stdio.h>

int main(void) {
    FILE *file;
    rec_parser_t parser;
    rec_rset_t rset;

    file = fopen("test.rec", "r");
    parser = rec_parser_new(file, "test.rec");

    while (rec_parse_rset(parser, &rset)) {
        printf("Record Set: %s\n", rec_rset_type(rset));
        printf("Record Count: %d\n", rec_rset_num_elems(rset));
    }

    rec_rset_destroy(rset);
    rec_parser_destroy(parser);
    fclose(file);
    return 0;
}






    _______________________________________________________
File Attachments:


-------------------------------------------------------
Date: Fri 11 Aug 2023 07:32:50 PM UTC  Name: main.c  Size: 466B   By: None
Attached test files for convenience.
<http://savannah.gnu.org/bugs/download.php?file_id=55026>
-------------------------------------------------------
Date: Fri 11 Aug 2023 07:32:50 PM UTC  Name: test.rec  Size: 180B   By: None
Attached test files for convenience.
<http://savannah.gnu.org/bugs/download.php?file_id=55027>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64546>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]