| 252 | } |
| 253 | |
| 254 | static int name_is_array(char *name, int *dim1, int *dim2) |
| 255 | { |
| 256 | int len = strlen(name); |
| 257 | /*fprintf(stderr,"[%s]",name);*/ |
| 258 | /*if (len >= 1) { |
| 259 | if (name[len-1] != ']') |
| 260 | return 1; |
| 261 | } |
| 262 | return 0;*/ |
| 263 | char *bp; |
| 264 | int num; |
| 265 | if (dim1) |
| 266 | { |
| 267 | *dim1 = 1; |
| 268 | } |
| 269 | if (dim2) |
| 270 | { |
| 271 | *dim2 = 1; |
| 272 | } |
| 273 | bp = strchr(name, '['); |
| 274 | if (!bp) |
| 275 | { |
| 276 | return 0; |
| 277 | } |
| 278 | num = 0; |
| 279 | while (++bp < name + len - 1) |
| 280 | { |
| 281 | const char c = *bp; |
| 282 | if (c == ']') |
| 283 | { |
| 284 | break; |
| 285 | } |
| 286 | if (c <= '9' && c >= '0') |
| 287 | { |
| 288 | num *= 10; |
| 289 | num += (c - '0'); |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | printf("array parse error.\n"); |
| 294 | return 0; |
| 295 | } |
| 296 | } |
| 297 | if (dim2) |
| 298 | { |
| 299 | *dim2 = num; |
| 300 | } |
| 301 | |
| 302 | /* find second dim, if any. */ |
| 303 | bp = strchr(bp, '['); |
| 304 | if (!bp) |
| 305 | { |
| 306 | return 1; /* at least we got the first dim. */ |
| 307 | } |
| 308 | num = 0; |
| 309 | while (++bp < name + len - 1) |
| 310 | { |
| 311 | const char c = *bp; |