antirez / antirez/kilo

SUBJECT: Inquiry regarding inconsistent sizing in `editorSyntax` struct

Đang mở
#124 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C
Star
9.1k
Fork
997
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello,
I am relatively new to C programming so forgive me if I am mistaken. However, I noticed while looking at the struct, that there was a sizing inconsistency. Here is the definition of the struct:
```
struct editorSyntax {
char **filematch;
char **keywords;
char singleline_comment_start[2];
char multiline_comment_start[3];
char multiline_comment_end[3];
int flags;
};
```
I noticed that `singleline_comment_start` is initialised with 2 characters for '//' defined later on, which cuts the null terminator off, and not making it a C string. However, in the multiline comment ending and starting, it leaves space for the null terminator as it is 3 bytes, and the start and ending of the multiline comment is 2 bytes. So 2 bytes for the comment sign and 1 byte for the null terminator.

Was dropping the null terminator `singleline_comment_start` a trick to save memory (which is what I thought it was)? If so, why is the multiline comment also not stored like that?
Your help woudl be appreciated.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start by locating the `editorSyntax` struct definition and the later initialization of `singleline_comment_start`, `multiline_comment_start`, and `multiline_comment_end`. Compare how those fields are used, then clarify in the issue why their sizes differ; no specific file or test is named, so completion is a documented explanation rather than a code change.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c
Lĩnh vực
tooling
Loại issue
Tài liệu
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.