2424#include < cstdlib>
2525#include < string>
2626#include < ctime>
27+ #include < cstring>
2728
2829#include < boost/date_time.hpp>
2930#include < boost/algorithm/string.hpp>
@@ -51,6 +52,10 @@ namespace detail {
5152# endif
5253#endif
5354
55+ #ifdef _MSC_VER
56+ # define strcasecmp stricmp
57+ #endif
58+
5459inline bool headers_equal (const std::string& a, const std::string& b)
5560{
5661 if (a.length () != b.length ())
@@ -638,23 +643,7 @@ typedef struct {
638643 int tm_mday;
639644 int tm_mon;
640645 int tm_year;
641- } short_tm;
642-
643- inline int str_raw_equal (const char *first, const char *second)
644- {
645- while (*first && *second)
646- {
647- // get out of the loop as soon as they don't match.
648- if (std::toupper (*first) != std::toupper (*second))
649- break ;
650- first++;
651- second++;
652- }
653- // we do the comparison here (possibly again), just to make sure that if the
654- // loop above is skipped because one of the strings reached zero, we must not
655- // return this as a successful match
656- return (std::toupper (*first) == std::toupper (*second));
657- }
646+ } short_tm;
658647
659648inline int checkday (const char *check, size_t len)
660649{
@@ -668,7 +657,7 @@ inline int checkday(const char *check, size_t len)
668657 what = &wkday[0 ];
669658 for (i = 0 ; i < 7 ; i++)
670659 {
671- if (str_raw_equal (check, what[0 ]))
660+ if (strcasecmp (check, what[0 ]) == 0 )
672661 {
673662 found = true ;
674663 break ;
@@ -687,7 +676,7 @@ inline int checkmonth(const char *check)
687676 what = &month[0 ];
688677 for (i = 0 ; i < 12 ; i++)
689678 {
690- if (str_raw_equal (check, what[0 ]))
679+ if (strcasecmp (check, what[0 ]) == 0 )
691680 {
692681 found = true ;
693682 break ;
@@ -710,7 +699,7 @@ inline int checktz(const char *check)
710699 what = tz;
711700 for (i = 0 ; i < sizeof (tz) / sizeof (tz[0 ]); i++)
712701 {
713- if (str_raw_equal (check, what->name ))
702+ if (strcasecmp (check, what->name ) == 0 )
714703 {
715704 found = true ;
716705 break ;
@@ -800,8 +789,8 @@ inline bool parse(const char* date, time_t* output)
800789 // a name coming up
801790 char buf[32 ] = " " ;
802791 size_t len;
803- sscanf (date, " %31[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] " ,
804- buf);
792+
793+ sscanf (date, " %31[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] " , buf);
805794 len = strlen (buf);
806795
807796 if (wdaynum == -1 )
@@ -810,6 +799,7 @@ inline bool parse(const char* date, time_t* output)
810799 if (wdaynum != -1 )
811800 found = true ;
812801 }
802+
813803 if (!found && (monnum == -1 ))
814804 {
815805 monnum = checkmonth (buf);
0 commit comments