projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve comment.
[pintos-anon]
/
src
/
lib
/
string.c
diff --git
a/src/lib/string.c
b/src/lib/string.c
index bec4444670b025768485cb143edb0329de3cb60c..d223c89f48493793c52dc45dbcf288328776fd6f 100644
(file)
--- a/
src/lib/string.c
+++ b/
src/lib/string.c
@@
-190,7
+190,7
@@
strstr (const char *haystack, const char *needle)
{
size_t i;
{
size_t i;
- for (i = 0; i < haystack_len - needle_len; i++)
+ for (i = 0; i <
=
haystack_len - needle_len; i++)
if (!memcmp (haystack + i, needle, needle_len))
return (char *) haystack + i;
}
if (!memcmp (haystack + i, needle, needle_len))
return (char *) haystack + i;
}
@@
-212,7
+212,9
@@
strstr (const char *haystack, const char *needle)
single string.
strtok_r() modifies the string S, changing delimiters to null
single string.
strtok_r() modifies the string S, changing delimiters to null
- bytes. Thus, S must be a modifiable string.
+ bytes. Thus, S must be a modifiable string. String literals,
+ in particular, are *not* modifiable in C, even though for
+ backward compatibility they are not `const'.
Example usage:
Example usage:
@@
-333,7
+335,7
@@
strlcpy (char *dst, const char *src, size_t size)
{
size_t dst_len = size - 1;
if (src_len < dst_len)
{
size_t dst_len = size - 1;
if (src_len < dst_len)
-
src_len = dst
_len;
+
dst_len = src
_len;
memcpy (dst, src, dst_len);
dst[dst_len] = '\0';
}
memcpy (dst, src, dst_len);
dst[dst_len] = '\0';
}