2011-10-23 19:02:01 +02:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
*
|
|
|
|
* i3 - an improved dynamic tiling window manager
|
2015-04-04 02:17:56 +02:00
|
|
|
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
|
2011-10-23 19:02:01 +02:00
|
|
|
*
|
|
|
|
*/
|
2016-10-11 09:13:35 +02:00
|
|
|
#include "libi3.h"
|
|
|
|
|
2011-10-23 19:02:01 +02:00
|
|
|
#include <string.h>
|
2020-04-19 09:43:48 +02:00
|
|
|
#include <sys/types.h>
|
2011-10-23 19:02:01 +02:00
|
|
|
|
2019-10-13 12:12:14 +02:00
|
|
|
#ifndef HAVE_strndup
|
2011-10-23 19:02:01 +02:00
|
|
|
/*
|
|
|
|
* Taken from FreeBSD
|
|
|
|
* Returns a pointer to a new string which is a duplicate of the
|
|
|
|
* string, but only copies at most n characters.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
char *strndup(const char *str, size_t n) {
|
|
|
|
size_t len;
|
|
|
|
char *copy;
|
|
|
|
|
|
|
|
for (len = 0; len < n && str[len]; len++)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
copy = smalloc(len + 1);
|
|
|
|
memcpy(copy, str, len);
|
|
|
|
copy[len] = '\0';
|
|
|
|
return (copy);
|
|
|
|
}
|
|
|
|
#endif
|