MCPcopy Create free account
hub / github.com/apache/nuttx / parse_line

Function parse_line

tools/cfgparser.c:115–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 */
114
115static void parse_line(char *ptr, char **varname, char **varval)
116{
117 /* Skip over any leading spaces */
118
119 ptr = skip_space(ptr);
120
121 /* The first no-space is the beginning of the variable name */
122
123 *varname = skip_space(ptr);
124 *varval = NULL;
125
126 /* Parse to the end of the variable name */
127
128 ptr = find_name_end(ptr);
129
130 /* An equal sign is expected next, perhaps after some white space */
131
132 if (*ptr && *ptr != '=')
133 {
134 /* Some else follows the variable name. Terminate the variable
135 * name and skip over any spaces.
136 */
137
138 *ptr = '\0';
139 ptr = skip_space(ptr + 1);
140 }
141
142 /* Verify that the equal sign is present */
143
144 if (*ptr == '=')
145 {
146 /* Make sure that the variable name is terminated (this was already
147 * done if the name was followed by white space.
148 */
149
150 *ptr = '\0';
151
152 /* The variable value should follow =, perhaps separated by some
153 * white space.
154 */
155
156 ptr = skip_space(ptr + 1);
157 if (*ptr)
158 {
159 /* Yes.. a variable follows. Save the pointer to the start
160 * of the variable string.
161 */
162
163 *varval = ptr;
164
165 /* Find the end of the variable string and make sure that it
166 * is terminated.
167 */
168
169 ptr = find_value_end(ptr);
170 *ptr = '\0';
171 }
172 }

Callers 1

parse_fileFunction · 0.70

Calls 3

skip_spaceFunction · 0.70
find_name_endFunction · 0.70
find_value_endFunction · 0.70

Tested by

no test coverage detected