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

Make the compile work on a Mac #2

Merged
merged 6 commits into from
Dec 3, 2024
Merged

Conversation

ballanty
Copy link
Contributor

This change:

  • sed as used required the addition of a small change to have it work on the Mac. The Makefile was altered to detect the platform and conditionally use sed in different ways in one case.
  • it looks like "packets" was once a buffer size measure and it was changed to bytes at some point. Fix what appears to be a leftover reference to packets.
  • parsing of quantities ("2days" for example) seemed to differ by platform (Mac (didn't work) vs Linux (did)). Replaced parsing approach with one using regular expressions to make it more robust to platform differences between the way std::..stream operator>> parsed.

Copy link
Member

@lorenzosaino lorenzosaino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this feature. I made a few comments about minor nits, but the core change looks good.

src/quantity.cpp Outdated
Comment on lines 25 to 36
std::string regexpstr = "([0-9]+)(\\.[0-9]*)? *([^ \t]*)";
std::regex reg(regexpstr);
std::smatch match;
std::regex_search(str, match, reg);

if ( !match.empty() ) {
this->value = std::stod(match[1].str() + match[2].str());
this->unit = match[3];
} else {
this->value = 0.0;
this->unit = "";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: this block uses spaces for indentation, while the rest of the code uses tabs. I'd suggest we use tabs here too for consistency

src/quantity.cpp Outdated
std::smatch match;
std::regex_search(str, match, reg);

if ( !match.empty() ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: in the rest of the code, there are not spaces between parentheses and conditions (see for example at L38 below). I would use the same convention for consistency

test/test.cpp Outdated
Quantity t2(1, "h", Units::Time);
Quantity t3("60min", Units::Time);
Quantity t4("3601 sec", Units::Time);
t1.fromString("2days");
//t1.fromString("2days");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is commenting this out intended? Without this we are no longer testing anywhere the fromString method

Makefile Outdated
Comment on lines 170 to 171
rm $1; \
exit 1; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: not sure if intended but by adding space in front of these two lines makes them no longer aligned with the echo "OK"; \ instruction above. Was this change intended?

test/test.cpp Outdated
@@ -302,6 +302,8 @@ void testEdge() {
cout<<"Edge test: ";

Edge e;

e.setBufferSize(Quantity("1kB", Units::Data));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit like my comment above about using tabs instead of spaces

- fixed spaces to tabs in a few spots (tabs project default)
- fixed spacing conventions around if conditions.
- fixed spaces in shell script - not the same length as surrounding code
- reenabled a test after I commented it out to get changes working
@ballanty
Copy link
Contributor Author

ballanty commented Dec 3, 2024

Good catches all. I'm sorry I made you go through the detailed review. I'll remember the project conventions going forward!

Copy link
Member

@lorenzosaino lorenzosaino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@lorenzosaino lorenzosaino merged commit 0690cba into fnss:master Dec 3, 2024
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