122{
123 const char *toksep = " ";
124 const char kvsep = '=';
125 const char q2 = '"';
126 const char q1 = '\'';
127 const char notspace = 0x1F;
128
129 char *key, *val;
130 int in_str = 0;
131 size_t i = 0, sz, input_sz;
132 char *ptr = input;
133
134 if (!input)
135 lwerror(
"Option string is null");
136 input_sz = strlen(input);
137
138
139 while(*ptr) {
140 if (*ptr == q2 || *ptr == q1)
141 in_str = !in_str;
142 else if (in_str && *ptr == ' ')
143 *ptr = notspace;
144
145 ptr++;
146 }
147
148
149 for (key = strtok(input, toksep); key; key = strtok(NULL, toksep)) {
151 olist[i++] = key;
152 }
153
154
155 sz = i;
156 for (i = 0; i < sz; ++i) {
158 key = olist[i];
159
160 val = strchr(key, kvsep);
161 if (!val) {
162 lwerror(
"Option string entry '%s' lacks separator '%c'", key, kvsep);
163 return;
164 }
165 }
166
167
168 for (i = 0; i <= input_sz; ++i) {
169 if (input[i] == notspace)
170 input[i] = ' ';
171 }
172}
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.