Skip to content

Commit

Permalink
Allow decimal point "." for size units except bytes.
Browse files Browse the repository at this point in the history
Fixes part of issue HaikuArchives#74.
  • Loading branch information
owenca committed Jul 20, 2017
1 parent 4ba60a3 commit 035129f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions sources/RuleRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,11 @@ IsSizeMatch(const BMessage& test, const entry_ref& ref)
file.GetSize(&fileSize);
file.Unset();

off_t size = atoll(value.String());
double sz = strtod(value.String(), NULL);
for (int32 i = 0; i < unit; i++)
size <<= 10;
sz *= 1024;

off_t size = static_cast<off_t>(round(sz));

bool result;

Expand Down
12 changes: 11 additions & 1 deletion sources/TestView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ TestView::TestView(const char* name, BMessage* test, const int32& flags)
}

SetMode();
SetUnit();
SetTest();
}

Expand Down Expand Up @@ -363,10 +362,13 @@ TestView::SetTest()

if (fDataType == TEST_TYPE_NUMBER) {
fValueBox->OnlyAllowDigits(true);
SetUnit();

if (fUnitField->IsHidden())
fUnitField->Show();
} else {
fValueBox->OnlyAllowDigits(false);

if (!fUnitField->IsHidden())
fUnitField->Hide();
}
Expand All @@ -384,6 +386,14 @@ void
TestView::SetUnit()
{
fUnitField->MenuItem()->SetLabel(sSizeUnits[fUnit]);

const char dot = '.';
BTextView* view = fValueBox->TextView();

if (fUnit > 0)
view->AllowChar(dot);
else
view->DisallowChar(dot);
}


Expand Down

0 comments on commit 035129f

Please sign in to comment.