Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for newlines inside "NAME" token #111

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sMezaOrellana
Copy link
Contributor

The following file is parsable by the gcc & clang compiler.

#define __SOCKADDR_COMMON_SIZE (sizeof(unsigned short))
typedef uint32_t in_addr_t;

#define __SOCKADDR_COMMON(sa_prefix) sa_family_t sa_prefix##family

typedef unsigned short sa_family_t;
struct in_addr {
  in_addr_t s_addr;
};

typedef uint16_t in_port_t;

struct sockaddr {
  sa_family_t sa_family;

  char sa_data[14]; /* Address data.  */
};

struct sockaddr_in {
  sa_family_t sin_family;
  in_port_t sin_port;      /* Port number.  */
  struct in_addr sin_addr; /* Internet address.  */

  /* Pad to size of `struct sockaddr'.  */
  unsigned char sin_zero[sizeof(struct sockaddr) - __SOCKADDR_COMMON_SIZE -
                        sizeof(in_port_t) - sizeof(struct in_addr)];
};

however this part of the code was giving issues when parsing with cstruct

  /* Pad to size of `struct sockaddr'.  */
  unsigned char sin_zero[sizeof(struct sockaddr) - __SOCKADDR_COMMON_SIZE -
                        sizeof(in_port_t) - sizeof(struct in_addr)];
};

I modified the "NAME" token regex to allow for newline character. This however means that the new newline needs to be handled by the ExpressionTokenizer. Which was also added.

A test case was also added to test the functionality.

Copy link

codecov bot commented Dec 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.46%. Comparing base (ed1daf2) to head (6b22ff4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #111   +/-   ##
=======================================
  Coverage   92.46%   92.46%           
=======================================
  Files          20       20           
  Lines        2176     2176           
=======================================
  Hits         2012     2012           
  Misses        164      164           
Flag Coverage Δ
unittests 92.46% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Horofic Horofic requested a review from Schamper December 4, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants