Mercurial > hg > toybox
comparison lib/xwrap.c @ 1105:1bca28705a87 draft
Give xstrncpy() a more informative error message.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 02 Nov 2013 14:24:54 -0500 |
parents | 501fd74c028e |
children | c644f85444d0 |
comparison
equal
deleted
inserted
replaced
1104:e11684e3bbc5 | 1105:1bca28705a87 |
---|---|
10 #include "toys.h" | 10 #include "toys.h" |
11 | 11 |
12 // Strcpy with size checking: exit if there's not enough space for the string. | 12 // Strcpy with size checking: exit if there's not enough space for the string. |
13 void xstrncpy(char *dest, char *src, size_t size) | 13 void xstrncpy(char *dest, char *src, size_t size) |
14 { | 14 { |
15 if (strlen(src)+1 > size) error_exit("xstrcpy"); | 15 if (strlen(src)+1 > size) error_exit("'%s' > %ld bytes", src, (long)size); |
16 strcpy(dest, src); | 16 strcpy(dest, src); |
17 } | 17 } |
18 | 18 |
19 void xexit(void) | 19 void xexit(void) |
20 { | 20 { |