11cc83814Sespie /* substring.c -- extract substring.
2*a1acfa9bSespie $Id: substring.c,v 1.1.1.2 2006/07/17 16:03:41 espie Exp $
31cc83814Sespie
4*a1acfa9bSespie Copyright (C) 1999, 2004 Free Software Foundation, Inc.
51cc83814Sespie
61cc83814Sespie This program is free software; you can redistribute it and/or modify
71cc83814Sespie it under the terms of the GNU General Public License as published by
81cc83814Sespie the Free Software Foundation; either version 2, or (at your option)
91cc83814Sespie any later version.
101cc83814Sespie
111cc83814Sespie This program is distributed in the hope that it will be useful,
121cc83814Sespie but WITHOUT ANY WARRANTY; without even the implied warranty of
131cc83814Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
141cc83814Sespie GNU General Public License for more details.
151cc83814Sespie
161cc83814Sespie You should have received a copy of the GNU General Public License along
171cc83814Sespie with this program; if not, write to the Free Software Foundation, Inc.,
181cc83814Sespie 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
191cc83814Sespie
201cc83814Sespie #include "system.h"
211cc83814Sespie
221cc83814Sespie char *
substring(const char * start,const char * end)23*a1acfa9bSespie substring (const char *start, const char *end)
241cc83814Sespie {
251cc83814Sespie char *result = xmalloc (end - start + 1);
261cc83814Sespie char *scan_result = result;
27*a1acfa9bSespie const char *scan = start;
281cc83814Sespie
291cc83814Sespie while (scan < end)
301cc83814Sespie *scan_result++ = *scan++;
311cc83814Sespie
321cc83814Sespie *scan_result = 0;
331cc83814Sespie return result;
341cc83814Sespie }
351cc83814Sespie
36