Debian Codegraph @

src/common/token.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2001 Rob Crittenden ([email protected])
3 * Copyright (C) 2001 Ross Combs ([email protected])
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 //#define PREFS_INTERNAL_ACCESS
20 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
21 #include "token.h"cxx . . $ `<file>/src/common/token.h`/
22
23 #include <cctype>
24
25 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
26 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
27
28 namespace pvpgncxx . . $ pvpgn/
29 {
30
31 /*
32 * Given a string and an integer pointer skip past pos characters and return
33 * the next white-space delimited string, setting pos to the new position.
34 */
35 extern char * next_tokencxx . . $ pvpgn/next_token(e8f487e1fe81a093).(char * ptr, unsigned int * pos)
36 {
37 unsigned int i;
38 unsigned int start;
39 int quoted;
40
41 if (!ptr || !pos)
42 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
43
44 /* skip leading whitespace */
45 for (i = *pos; stdcxx . . $ std/::isspacecxx . . $ std/isspace(a1851578aea3f541).((int)ptr[i]); i++);
46
47 if (ptr[i] == '\0')
48 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; /* if after whitespace, we're done */
49
50 if (ptr[i] == '"')
51 {
52 quoted = 1;
53 i++;
54 }
55 else
56 quoted = 0;
57
58 start = i;
59 for (;;)
60 {
61 if (ptr[i] == '\0')
62 break;
63 if (quoted) /* FIXME: add handling of escape chars so quotes can be in tokens */
64 {
65 if (ptr[i] == '"')
66 break;
67 }
68 else
69 if (stdcxx . . $ std/::isspacecxx . . $ std/isspace(a1851578aea3f541).((int)ptr[i]))
70 break;
71 i++;
72 }
73
74 if (ptr[i] != '\0')
75 {
76 ptr[i] = '\0'; /* terminate the string */
77 *pos = i + 1; /* remember the position of the next char */
78 }
79 else
80 *pos = i; /* this was the last token, just remember the NUL */
81
82 return &ptr[start];
83 }
84
85 }