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