comparison src/shape_path.c @ 10:7cfecdce94cc

Remove warning messages
author Thinker K.F. Li <thinker@branda.to>
date Sat, 26 Jul 2008 05:32:31 +0800
parents 6eecdd331fe7
children 128af06c876c
comparison
equal deleted inserted replaced
9:6eecdd331fe7 10:7cfecdce94cc
16 int cmd_len; 16 int cmd_len;
17 int arg_len; 17 int arg_len;
18 char *user_data; 18 char *user_data;
19 char *dev_data; /* device space data */ 19 char *dev_data; /* device space data */
20 } sh_path_t; 20 } sh_path_t;
21 #define RESERVED_AIXS sizeof(co_aix[2])
21 22
22 #define ASSERT(x) 23 #define ASSERT(x)
23 #define SKIP_SPACE(x) while(*(x) && isspace(*(x))) { (x)++; } 24 #define SKIP_SPACE(x) while(*(x) && isspace(*(x))) { (x)++; }
24 #define SKIP_NUM(x) \ 25 #define SKIP_NUM(x) \
25 while(*(x) && \ 26 while(*(x) && \
179 *cmd_cntp = cmd_cnt; 180 *cmd_cntp = cmd_cnt;
180 *arg_cntp = arg_cnt; 181 *arg_cntp = arg_cnt;
181 return OK; 182 return OK;
182 } 183 }
183 184
185 #define TO_ABS islower(cmd)? *(args - 2) + atof(old): atof(old)
186
184 static int sh_path_cmd_arg_fill(char *data, sh_path_t *path) { 187 static int sh_path_cmd_arg_fill(char *data, sh_path_t *path) {
185 char *p, *old; 188 char *p, *old;
186 char *cmds; 189 char *cmds;
187 char cmd; 190 char cmd;
188 co_aix *args; 191 co_aix *args;
203 SKIP_SPACE(p); 206 SKIP_SPACE(p);
204 old = p; 207 old = p;
205 SKIP_NUM(p); 208 SKIP_NUM(p);
206 if(p == old) 209 if(p == old)
207 break; 210 break;
208 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 211 *args = TO_ABS;
209 212 args++;
210 SKIP_SPACE(p); 213
211 old = p; 214 SKIP_SPACE(p);
212 SKIP_NUM(p); 215 old = p;
213 if(p == old) 216 SKIP_NUM(p);
214 return ERR; 217 if(p == old)
215 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 218 return ERR;
216 219 *args = TO_ABS;
217 SKIP_SPACE(p); 220 args++;
218 old = p; 221
219 SKIP_NUM(p); 222 SKIP_SPACE(p);
220 if(p == old) 223 old = p;
221 return ERR; 224 SKIP_NUM(p);
222 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 225 if(p == old)
223 226 return ERR;
224 SKIP_SPACE(p); 227 *args = TO_ABS;
225 old = p; 228 args++;
226 SKIP_NUM(p); 229
227 if(p == old) 230 SKIP_SPACE(p);
228 return ERR; 231 old = p;
229 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 232 SKIP_NUM(p);
230 SKIP_SPACE(p); 233 if(p == old)
231 old = p; 234 return ERR;
232 SKIP_NUM(p); 235 *args = TO_ABS;
233 if(p == old) 236 args++;
234 return ERR; 237 SKIP_SPACE(p);
235 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 238 old = p;
236 239 SKIP_NUM(p);
237 SKIP_SPACE(p); 240 if(p == old)
238 old = p; 241 return ERR;
239 SKIP_NUM(p); 242 *args = TO_ABS;
240 if(p == old) 243 args++;
241 return ERR; 244
242 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 245 SKIP_SPACE(p);
246 old = p;
247 SKIP_NUM(p);
248 if(p == old)
249 return ERR;
250 *args = TO_ABS;
251 args++;
243 } 252 }
244 break; 253 break;
245 case 's': 254 case 's':
246 case 'S': 255 case 'S':
247 case 'q': 256 case 'q':
251 SKIP_SPACE(p); 260 SKIP_SPACE(p);
252 old = p; 261 old = p;
253 SKIP_NUM(p); 262 SKIP_NUM(p);
254 if(p == old) 263 if(p == old)
255 break; 264 break;
256 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 265 *args = TO_ABS;
257 266 args++;
258 SKIP_SPACE(p); 267
259 old = p; 268 SKIP_SPACE(p);
260 SKIP_NUM(p); 269 old = p;
261 if(p == old) 270 SKIP_NUM(p);
262 return ERR; 271 if(p == old)
263 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 272 return ERR;
264 273 *args = TO_ABS;
265 SKIP_SPACE(p); 274 args++;
266 old = p; 275
267 SKIP_NUM(p); 276 SKIP_SPACE(p);
268 if(p == old) 277 old = p;
269 return ERR; 278 SKIP_NUM(p);
270 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 279 if(p == old)
271 280 return ERR;
272 SKIP_SPACE(p); 281 *args = TO_ABS;
273 old = p; 282 args++;
274 SKIP_NUM(p); 283
275 if(p == old) 284 SKIP_SPACE(p);
276 return ERR; 285 old = p;
277 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 286 SKIP_NUM(p);
287 if(p == old)
288 return ERR;
289 *args = TO_ABS;
290 args++;
278 } 291 }
279 break; 292 break;
280 case 'm': 293 case 'm':
281 case 'M': 294 case 'M':
282 case 'l': 295 case 'l':
288 SKIP_SPACE(p); 301 SKIP_SPACE(p);
289 old = p; 302 old = p;
290 SKIP_NUM(p); 303 SKIP_NUM(p);
291 if(p == old) 304 if(p == old)
292 break; 305 break;
293 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 306 *args = TO_ABS;
294 307 args++;
295 SKIP_SPACE(p); 308
296 old = p; 309 SKIP_SPACE(p);
297 SKIP_NUM(p); 310 old = p;
298 if(p == old) 311 SKIP_NUM(p);
299 return ERR; 312 if(p == old)
300 *args++ = islower(cmd)? *(args - 2) + atof(old): atof(old); 313 return ERR;
314 *args = TO_ABS;
315 args++;
301 } 316 }
302 break; 317 break;
303 case 'h': 318 case 'h':
304 case 'H': 319 case 'H':
305 case 'v': 320 case 'v':
330 345
331 /* Align at 4's boundary and keep 2 unused co_aix space 346 /* Align at 4's boundary and keep 2 unused co_aix space
332 * to make logic of transformation from relative to absolute 347 * to make logic of transformation from relative to absolute
333 * simple. 348 * simple.
334 */ 349 */
335 cmd_cnt += sizeof(co_aix) * 2; 350 cmd_cnt += RESERVED_AIXS;
336 cmd_cnt = (cmd_cnt + 3) & ~0x3; 351 cmd_cnt = (cmd_cnt + 3) & ~0x3;
337 352
338 path = (sh_path_t *)malloc(sizeof(sh_path_t)); 353 path = (sh_path_t *)malloc(sizeof(sh_path_t));
339 path->shape.sh_type = SHT_PATH; 354 path->shape.sh_type = SHT_PATH;
340 path->cmd_len = cmd_cnt; 355 path->cmd_len = cmd_cnt;
519 sh_path_t *path; 534 sh_path_t *path;
520 co_aix *args; 535 co_aix *args;
521 536
522 path = (sh_path_t *)sh_path_new("M 33 25l33 55C 33 87 44 22 55 99L33 77z"); 537 path = (sh_path_t *)sh_path_new("M 33 25l33 55C 33 87 44 22 55 99L33 77z");
523 CU_ASSERT(path != NULL); 538 CU_ASSERT(path != NULL);
524 CU_ASSERT(path->cmd_len == ((5 + sizeof(co_aix) * 2 + 3) & ~0x3)); 539 CU_ASSERT(path->cmd_len == ((5 + RESERVED_AIXS + 3) & ~0x3));
525 CU_ASSERT(path->arg_len == 12); 540 CU_ASSERT(path->arg_len == 12);
526 CU_ASSERT(strcmp(path->user_data, "MLCLZ") == 0); 541 CU_ASSERT(strcmp(path->user_data, "MLCLZ") == 0);
527 CU_ASSERT(strcmp(path->dev_data, "MLCLZ") == 0); 542 CU_ASSERT(strcmp(path->dev_data, "MLCLZ") == 0);
528 543
529 args = (co_aix *)(path->user_data + path->cmd_len); 544 args = (co_aix *)(path->user_data + path->cmd_len);
547 co_aix *args; 562 co_aix *args;
548 coord_t coord; 563 coord_t coord;
549 564
550 path = (sh_path_t *)sh_path_new("M 33 25l33 55C 33 87 44 22 55 99L33 77z"); 565 path = (sh_path_t *)sh_path_new("M 33 25l33 55C 33 87 44 22 55 99L33 77z");
551 CU_ASSERT(path != NULL); 566 CU_ASSERT(path != NULL);
552 CU_ASSERT(path->cmd_len == ((5 + sizeof(co_aix) * 2 + 3) & ~0x3)); 567 CU_ASSERT(path->cmd_len == ((5 + RESERVED_AIXS + 3) & ~0x3));
553 CU_ASSERT(path->arg_len == 12); 568 CU_ASSERT(path->arg_len == 12);
554 CU_ASSERT(strcmp(path->user_data, "MLCLZ") == 0); 569 CU_ASSERT(strcmp(path->user_data, "MLCLZ") == 0);
555 CU_ASSERT(strcmp(path->dev_data, "MLCLZ") == 0); 570 CU_ASSERT(strcmp(path->dev_data, "MLCLZ") == 0);
556 571
557 coord.aggr_matrix[0] = 1; 572 coord.aggr_matrix[0] = 1;