diff --git a/Flash.cpp b/Flash.cpp index 195de5b..f1a9181 100644 --- a/Flash.cpp +++ b/Flash.cpp @@ -32,3 +32,23 @@ void _FLASH_STRING::print(Print &stream) const stream.print(c); // print in char form } } + +unsigned int _FLASH_STRING::strncmp(const char *s2, size_t n) { + size_t i; + size_t s2_len = strlen(s2); + + if (s2_len < n) { + // s2 too short + return 1; + } + + for (i = 0; i < n; i++) { + char c = (*this)[i]; + if (0 == c || c != s2[i]) { + return 1; + } + } + + return 0; + +} diff --git a/Flash.h b/Flash.h index 1f9aa5e..a1e697d 100644 --- a/Flash.h +++ b/Flash.h @@ -88,7 +88,9 @@ class _FLASH_STRING : public _Printable { return static_cast(pgm_read_byte(_arr + index)); } void print(Print &stream) const; - + + unsigned int strncmp(const char *s2, size_t n); + private: const prog_char *_arr; }; @@ -230,4 +232,4 @@ inline Print &operator <<(Print &stream, const _FLASH_TABLE &printable) inline Print &operator <<(Print &stream, const _FLASH_STRING_ARRAY &printable) { printable.print(stream); return stream; } -#endif // def __FLASH_H__ \ No newline at end of file +#endif // def __FLASH_H__