Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
98e58343
Commit
98e58343
authored
Jul 02, 2020
by
Thorsten von Eicken
Committed by
Damien George
Jul 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/libc: Add implementation of strncpy.
parent
9aa21407
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
lib/libc/string0.c
lib/libc/string0.c
+17
-0
No files found.
lib/libc/string0.c
View file @
98e58343
...
...
@@ -169,6 +169,23 @@ char *strcpy(char *dest, const char *src) {
return
dest
;
}
// Public Domain implementation of strncpy from:
// http://en.wikibooks.org/wiki/C_Programming/Strings#The_strncpy_function
char
*
strncpy
(
char
*
s1
,
const
char
*
s2
,
size_t
n
)
{
char
*
dst
=
s1
;
const
char
*
src
=
s2
;
/* Copy bytes, one at a time. */
while
(
n
>
0
)
{
n
--
;
if
((
*
dst
++
=
*
src
++
)
==
'\0'
)
{
/* If we get here, we found a null character at the end of s2 */
*
dst
=
'\0'
;
break
;
}
}
return
s1
;
}
// needed because gcc optimises strcpy + strcat to this
char
*
stpcpy
(
char
*
dest
,
const
char
*
src
)
{
while
(
*
src
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment