Debian Codegraph @

src/compat/strsep.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2002 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"
19 #ifndef HAVE_STRSEP
20 #include "strsep.h"
21
22 #include <cstring>
23
24 #include "common/setup_after.h"
25
26
27 namespace pvpgn
28 {
29
30 extern char * strsep(char * * str, char const * delims)
31 {
32 char * begin;
33
34 begin = *str;
35
36 if (!begin)
37 return NULL; /* already returned last token */
38
39 /* FIXME: optimiz case of 1 char delims (maybe not worth the effort) */
40 for (; **str != '\0'; (*str)++)
41 if (std::strchr(delims, **str))
42 {
43 **str = '\0'; /* terminate token */
44 (*str)++; /* remember the position of the next char */
45 return begin;
46 }
47
48 *str = NULL;
49 return begin; /* return the whole input string */
50 }
51
52 }
53
54 #else
55 typedef int filenotempty; /* make ISO standard happy */
56 #endif