From: Peter Johnson Date: Thu, 28 Jun 2001 08:50:09 +0000 (-0000) Subject: Use autoconf to determine when to include our implementation of strdup, so X-Git-Tag: v0.1.0~449 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80c2b676beea457f91a44d2b52a54c79da122371;p=yasm Use autoconf to determine when to include our implementation of strdup, so remove util.c and create strdup.c. Make util.h, strdup.c, and several source files use config.h defines. svn path=/trunk/yasm/; revision=62 --- diff --git a/libyasm/xstrdup.c b/libyasm/xstrdup.c new file mode 100644 index 00000000..3390367c --- /dev/null +++ b/libyasm/xstrdup.c @@ -0,0 +1,52 @@ +/* $Id: xstrdup.c,v 1.1 2001/06/28 08:50:09 peter Exp $ + * strdup() implementation for systems that don't have it. + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef STDC_HEADERS +# include +# include +#else +void *malloc(size_t); +size_t strlen(const char *); +# ifndef HAVE_MEMCPY +void bcopy(const void *, void *, size_t); +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# else +void memcpy(void *, const void *, size_t); +# endif +#endif + +#include "util.h" + +char *strdup(const char *str) +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if((copy = malloc(len)) == NULL) + return (char *)NULL; + memcpy(copy, str, len); + return copy; +} diff --git a/src/strdup.c b/src/strdup.c new file mode 100644 index 00000000..7b5051bf --- /dev/null +++ b/src/strdup.c @@ -0,0 +1,52 @@ +/* $Id: strdup.c,v 1.1 2001/06/28 08:50:09 peter Exp $ + * strdup() implementation for systems that don't have it. + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef STDC_HEADERS +# include +# include +#else +void *malloc(size_t); +size_t strlen(const char *); +# ifndef HAVE_MEMCPY +void bcopy(const void *, void *, size_t); +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# else +void memcpy(void *, const void *, size_t); +# endif +#endif + +#include "util.h" + +char *strdup(const char *str) +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if((copy = malloc(len)) == NULL) + return (char *)NULL; + memcpy(copy, str, len); + return copy; +} diff --git a/src/xstrdup.c b/src/xstrdup.c new file mode 100644 index 00000000..3390367c --- /dev/null +++ b/src/xstrdup.c @@ -0,0 +1,52 @@ +/* $Id: xstrdup.c,v 1.1 2001/06/28 08:50:09 peter Exp $ + * strdup() implementation for systems that don't have it. + * + * Copyright (C) 2001 Peter Johnson + * + * This file is part of YASM. + * + * YASM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * YASM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef STDC_HEADERS +# include +# include +#else +void *malloc(size_t); +size_t strlen(const char *); +# ifndef HAVE_MEMCPY +void bcopy(const void *, void *, size_t); +# define memcpy(d, s, n) bcopy((s), (d), (n)) +# else +void memcpy(void *, const void *, size_t); +# endif +#endif + +#include "util.h" + +char *strdup(const char *str) +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if((copy = malloc(len)) == NULL) + return (char *)NULL; + memcpy(copy, str, len); + return copy; +}