[BACK]Return to test-strndup.c CVS log [TXT][DIR] 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, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_6, VERSION_1_14_5, VERSION_1_14_4, HEAD

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;
}