Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
970 B
Referenced Files
None
Subscribers
None
diff --git a/calendar.cpp b/calendar.cpp
index ae06e10..6c553b0 100644
--- a/calendar.cpp
+++ b/calendar.cpp
@@ -1,16 +1,25 @@
#include "calendar.h"
+#define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0]))
+
std::string getHoliday(int month, int day)
{
- for (int i=0;i<59;i++)
+ for (size_t i=0;i<ARRAY_LEN(PAGAN_HOLIDAYS);i++)
{
- if (month==std::stoi(PAGAN_HOLIDAYS[i][0]))
+ try
{
- if (day==std::stoi(PAGAN_HOLIDAYS[i][1]))
+ if (month==std::stoi(PAGAN_HOLIDAYS[i][0]))
{
- return PAGAN_HOLIDAYS[i][2];
+ if (day==std::stoi(PAGAN_HOLIDAYS[i][1]))
+ {
+ return PAGAN_HOLIDAYS[i][2];
+ }
}
+ } catch (...)
+ {
+ std::cerr << "Failed to convert " << PAGAN_HOLIDAYS[i][0] << " and " << PAGAN_HOLIDAYS[i][1] << " into ints\n";
+ continue;
}
}
return "";
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 16, 12:09 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
70624
Default Alt Text
(970 B)

Event Timeline