minor string_eq fix
This commit is contained in:
parent
b025e301bb
commit
4b2691fa57
2
TODO
2
TODO
|
@ -1,4 +1,4 @@
|
|||
- [ ] Fix string_eq
|
||||
- [x] Fix string_eq
|
||||
- [ ] Move function signatures to the *.h file
|
||||
- [ ] Sorting stuff
|
||||
- [x] Random Libraries
|
||||
|
|
|
@ -19,12 +19,25 @@ String from_c_str(char* ptr) {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
// String equality tests for length/contents
|
||||
// If the contents and length are the same then it is true else its false
|
||||
bool string_eq(String lhs, String rhs) {
|
||||
bool same_contents = false;
|
||||
bool same_ptr = false;
|
||||
bool same_len = false;
|
||||
|
||||
if (lhs.ptr == rhs.ptr) {
|
||||
if (lhs.len == rhs.len) {
|
||||
return true;
|
||||
}
|
||||
same_ptr = true;
|
||||
}
|
||||
|
||||
if (lhs.len == rhs.len) {
|
||||
same_len = true;
|
||||
}
|
||||
if (same_len && same_ptr){
|
||||
return true;
|
||||
} else {
|
||||
// TODO: still check the contents instead of just unconditionally falsing
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
Loading…
Reference in a new issue