| 544 | } |
| 545 | |
| 546 | static char *read_line() |
| 547 | { |
| 548 | static char *line = NULL; |
| 549 | |
| 550 | if (istty) { |
| 551 | if (line) { |
| 552 | free(line); |
| 553 | line = NULL; |
| 554 | } |
| 555 | if ((line = readline(prompt)) != NULL && line[0] != 0 && |
| 556 | !skip_history(line)) |
| 557 | add_history(line); |
| 558 | return line; |
| 559 | } |
| 560 | int total_len = 0; |
| 561 | int n = -1; |
| 562 | static size_t sz = 0; |
| 563 | static char *getline = NULL; |
| 564 | while ((n = getdelim(&getline, &sz, delimstr[delim_len - 1], stdin)) != |
| 565 | -1) { |
| 566 | if (n > 0) { |
| 567 | total_len += n; |
| 568 | line = (char *)realloc(line, total_len + 1); |
| 569 | strcpy(line + total_len - n, getline); |
| 570 | if (has_delimiter(line, total_len, delimstr, delim_len) == true) { |
| 571 | line[total_len - delim_len] = 0; |
| 572 | return line; |
| 573 | } |
| 574 | } |
| 575 | } |
| 576 | if (n == -1 && total_len == 0) { |
| 577 | if (line) { |
| 578 | free(line); |
| 579 | line = NULL; |
| 580 | } |
| 581 | if (getline) { |
| 582 | free(getline); |
| 583 | getline = NULL; |
| 584 | } |
| 585 | return NULL; |
| 586 | } |
| 587 | return line; |
| 588 | } |
| 589 | |
| 590 | #define checkfortype(str, STRTYPE, ret) \ |
| 591 | do { \ |
no test coverage detected