Return to test-strndup.c CVS log | Up to [cvsweb.bsd.lv] / mandoc |
File: [cvsweb.bsd.lv] / mandoc / test-strndup.c (download)
Revision 1.1, Tue Feb 27 11:16:23 2018 UTC (6 years, 6 months ago) by schwarze
Add strndup(3) compat implementation. Jan Stary reports that MacOS X Snow Leopard and older lacks it. |
#include <string.h> int main(void) { char *s; s = strndup("123", 2); return s[0] != '1' ? 1 : s[1] != '2' ? 2 : s[2] != '\0' ? 3 : 0; }