Debian Codegraph @

src/parameters.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/parameters.c`/include <cgreen/vector.h>cxx . . $ `<file>/include/cgreen/vector.h`/
2 #include <stdlib.h>
3 #include <stdbool.h>
4 #include <string.h>
5 #include <ctype.h>
6
7 #include "parameters.h"cxx . . $ `<file>/src/parameters.h`/
8
9 static char *tokenise_by_commas_and_whitespacecxx . . $ tokenise_by_commas_and_whitespace(7a9722d75b371431).(char *list);
10 static char *skip_nulls_untilcxx . . $ skip_nulls_until(5bd1a890f71b1efd).(char *pointer, char *pointer_end);
11 static char *end_of_tokencxx . . $ end_of_token(7a9722d75b371431).(char *token);
12 static char *strip_function_fromcxx . . $ strip_function_from(b7b3a83273496486).(char *token, const char *function_name);
13 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! begins_withcxx . . $ begins_with(9efbdc942cde3d3d).(char *token, const char *beginning);
14
15 static char *stringdupcxx . . $ stringdup(a8b8e32347182212).(const char *string) {
16 return strcpycxx . . $ strcpy(b7b3a83273496486).((char *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(string)+1), string);
17 }
18
19 CgreenVectorcxx . . $ CgreenVector# *create_vector_of_namescxx . . $ create_vector_of_names(d5a3278d3d52ae11).(const char *parameters) {
20 char *parameters_to_tokenize;
21 char *parameters_end;
22 char *tokens;
23 char *token;
24 CgreenVectorcxx . . $ CgreenVector# *names = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(&freecxx . . $ free(5d22bdacc48458e8).);
25 if ((parameters == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) || (strlencxx . . $ strlen(751346f8406fd082).(parameters) == 0)) {
26 return names;
27 }
28
29 parameters_to_tokenize = stringdupcxx . . $ stringdup(a8b8e32347182212).(parameters);
30 if (parameters_to_tokenize == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) {
31 return names;
32 }
33
34 parameters_end = parameters_to_tokenize + strlencxx . . $ strlen(751346f8406fd082).(parameters_to_tokenize);
35 tokens = tokenise_by_commas_and_whitespacecxx . . $ tokenise_by_commas_and_whitespace(7a9722d75b371431).(parameters_to_tokenize);
36 token = tokens;
37 while (token < tokens + strlencxx . . $ strlen(751346f8406fd082).(parameters)) {
38 token = skip_nulls_untilcxx . . $ skip_nulls_until(5bd1a890f71b1efd).(token, parameters_end);
39 int length_of_token = strlencxx . . $ strlen(751346f8406fd082).(token);
40 token = strip_function_fromcxx . . $ strip_function_from(b7b3a83273496486).(token, "box_double");
41 token = strip_function_fromcxx . . $ strip_function_from(b7b3a83273496486).(token, "d");
42 cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(names, (void*)stringdupcxx . . $ stringdup(a8b8e32347182212).(token));
43 token += length_of_token;
44 }
45
46 freecxx . . $ free(5d22bdacc48458e8).(tokens);
47 return names;
48 }
49
50 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! *pointer_to_boolcxx . . $ pointer_to_bool(d6f0041866c6a7de).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! value) {
51 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! *ptr = (boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(value));
52 *ptr = value;
53 return ptr;
54 }
55
56 /* TODO: Much duplication ahead. This should probably be folded into
57 the 'create_vector_of_names()' above */
58 CgreenVectorcxx . . $ CgreenVector# *create_vector_of_double_markers_forcxx . . $ create_vector_of_double_markers_for(d5a3278d3d52ae11).(const char *parameters) {
59 char *parameters_to_tokenize;
60 char *parameters_end;
61 char *tokens;
62 char *token;
63 CgreenVectorcxx . . $ CgreenVector# *markers = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(&freecxx . . $ free(5d22bdacc48458e8).);
64 if ((parameters == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) || (strlencxx . . $ strlen(751346f8406fd082).(parameters) == 0)) {
65 return markers;
66 }
67
68 parameters_to_tokenize = stringdupcxx . . $ stringdup(a8b8e32347182212).(parameters);
69 if (parameters_to_tokenize == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) {
70 return markers;
71 }
72
73 parameters_end = parameters_to_tokenize + strlencxx . . $ strlen(751346f8406fd082).(parameters_to_tokenize);
74 tokens = tokenise_by_commas_and_whitespacecxx . . $ tokenise_by_commas_and_whitespace(7a9722d75b371431).(parameters_to_tokenize);
75 token = tokens;
76 while (token < tokens + strlencxx . . $ strlen(751346f8406fd082).(parameters)) {
77 token = skip_nulls_untilcxx . . $ skip_nulls_until(5bd1a890f71b1efd).(token, parameters_end);
78 int length_of_token = strlencxx . . $ strlen(751346f8406fd082).(token);
79 if (begins_withcxx . . $ begins_with(9efbdc942cde3d3d).(token, "box_double"))
80 cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(markers, pointer_to_boolcxx . . $ pointer_to_bool(d6f0041866c6a7de).(truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!));
81 else
82 cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(markers, pointer_to_boolcxx . . $ pointer_to_bool(d6f0041866c6a7de).(falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!));
83 token = strip_function_fromcxx . . $ strip_function_from(b7b3a83273496486).(token, "box_double");
84 token = strip_function_fromcxx . . $ strip_function_from(b7b3a83273496486).(token, "d");
85 token += length_of_token;
86 }
87
88 freecxx . . $ free(5d22bdacc48458e8).(tokens);
89 return markers;
90 }
91
92 static char *tokenise_by_commas_and_whitespacecxx . . $ tokenise_by_commas_and_whitespace(7a9722d75b371431).(char *list) {
93 size_t i, length;
94
95 for (i = 0, length = strlencxx . . $ strlen(751346f8406fd082).(list); i < length; i++) {
96 if (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!((int)list[i]) || list[i] == ',') {
97 list[i] = '\0';
98 }
99 }
100
101 return list;
102 }
103
104 static char *skip_nulls_untilcxx . . $ skip_nulls_until(5bd1a890f71b1efd).(char *pointer, char *pointer_end) {
105 while (*pointer == '\0' && pointer < pointer_end) {
106 pointer++;
107 }
108
109 return pointer;
110 }
111
112 static char *end_of_tokencxx . . $ end_of_token(7a9722d75b371431).(char *token) {
113 return token + strlencxx . . $ strlen(751346f8406fd082).(token);
114 }
115
116 static char last_char_ofcxx . . $ last_char_of(7b84b878a74105eb).(char *token) {
117 return *(end_of_tokencxx . . $ end_of_token(7a9722d75b371431).(token) - 1);
118 }
119
120 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! begins_withcxx . . $ begins_with(9efbdc942cde3d3d).(char *token, const char *beginning) {
121 return strncmpcxx . . $ strncmp(fd278af2f295fa2e).(beginning, token, strlencxx . . $ strlen(751346f8406fd082).(beginning)) == 0;
122 }
123
124 static void move_parameter_to_beginning_ofcxx . . $ move_parameter_to_beginning_of(3366d352079c3ed6).(char *token, const char *function_name, int parameter_length) {
125 memmovecxx . . $ memmove(cc817cb175f282d).(token, token + strlencxx . . $ strlen(751346f8406fd082).(function_name) + strlencxx . . $ strlen(751346f8406fd082).("("), parameter_length+strlencxx . . $ strlen(751346f8406fd082).(")")+1);
126 *(end_of_tokencxx . . $ end_of_token(7a9722d75b371431).(token) - 1) = '\0';
127 }
128
129 static char *strip_function_fromcxx . . $ strip_function_from(b7b3a83273496486).(char *token, const char *function_name) {
130 if (begins_withcxx . . $ begins_with(9efbdc942cde3d3d).(token, function_name) && token[strlencxx . . $ strlen(751346f8406fd082).(function_name)] == '(' && last_char_ofcxx . . $ last_char_of(7b84b878a74105eb).(token) == ')') {
131 int parameter_length = strlencxx . . $ strlen(751346f8406fd082).(token) - strlencxx . . $ strlen(751346f8406fd082).(function_name) - strlencxx . . $ strlen(751346f8406fd082).("()");
132 move_parameter_to_beginning_ofcxx . . $ move_parameter_to_beginning_of(3366d352079c3ed6).(token, function_name, parameter_length);
133 }
134
135 return token;
136 }
137
138 /* vim: set ts=4 sw=4 et cindent: */