1 /* $NetBSD: substring.c,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $ */ 2 3 /* substring.c -- extract substring. 4 Id: substring.c,v 1.2 2004/04/11 17:56:46 karl Exp 5 6 Copyright (C) 1999, 2004 Free Software Foundation, Inc. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2, or (at your option) 11 any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License along 19 with this program; if not, write to the Free Software Foundation, Inc., 20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 22 #include "system.h" 23 24 char * 25 substring (const char *start, const char *end) 26 { 27 char *result = xmalloc (end - start + 1); 28 char *scan_result = result; 29 const char *scan = start; 30 31 while (scan < end) 32 *scan_result++ = *scan++; 33 34 *scan_result = 0; 35 return result; 36 } 37 38