Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
6 changes: 4 additions & 2 deletions Flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class _FLASH_STRING : public _Printable
{ return static_cast<char>(pgm_read_byte(_arr + index)); }

void print(Print &stream) const;


unsigned int strncmp(const char *s2, size_t n);

private:
const prog_char *_arr;
};
Expand Down Expand Up @@ -230,4 +232,4 @@ inline Print &operator <<(Print &stream, const _FLASH_TABLE<T> &printable)
inline Print &operator <<(Print &stream, const _FLASH_STRING_ARRAY &printable)
{ printable.print(stream); return stream; }

#endif // def __FLASH_H__
#endif // def __FLASH_H__