Fossil SCM
Remove varargs C-preprocessor macros from linenoise.c, since some older C compilers (ex: gcc on a circa-2000 iBook) are unable to deal with them.
Commit
24c2b99df2f659140a1bedaef3a9a44dfeb1c1ba7929c5bd8ec39de3d15dba44
Parent
2aa7a23b8f3d6c8…
1 file changed
+8
-8
+8
-8
| --- src/linenoise.c | ||
| +++ src/linenoise.c | ||
| @@ -556,24 +556,24 @@ | ||
| 556 | 556 | |
| 557 | 557 | /* First step: clear all the lines used before. To do so start by |
| 558 | 558 | * going to the last row. */ |
| 559 | 559 | abInit(&ab); |
| 560 | 560 | if (old_rows-rpos > 0) { |
| 561 | - lndebug("go down %d", old_rows-rpos); | |
| 561 | + /* lndebug("go down %d", old_rows-rpos); */ | |
| 562 | 562 | snprintf(seq,64,"\x1b[%dB", old_rows-rpos); |
| 563 | 563 | abAppend(&ab,seq,strlen(seq)); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /* Now for every row clear it, go up. */ |
| 567 | 567 | for (j = 0; j < old_rows-1; j++) { |
| 568 | - lndebug("clear+up"); | |
| 568 | + /* lndebug("clear+up"); */ | |
| 569 | 569 | snprintf(seq,64,"\r\x1b[0K\x1b[1A"); |
| 570 | 570 | abAppend(&ab,seq,strlen(seq)); |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /* Clean the top line. */ |
| 574 | - lndebug("clear"); | |
| 574 | + /* lndebug("clear"); */ | |
| 575 | 575 | snprintf(seq,64,"\r\x1b[0K"); |
| 576 | 576 | abAppend(&ab,seq,strlen(seq)); |
| 577 | 577 | |
| 578 | 578 | /* Write the prompt and the current buffer content */ |
| 579 | 579 | abAppend(&ab,l->prompt,strlen(l->prompt)); |
| @@ -586,39 +586,39 @@ | ||
| 586 | 586 | * emit a newline and move the prompt to the first column. */ |
| 587 | 587 | if (l->pos && |
| 588 | 588 | l->pos == l->len && |
| 589 | 589 | (l->pos+plen) % l->cols == 0) |
| 590 | 590 | { |
| 591 | - lndebug("<newline>"); | |
| 591 | + /* lndebug("<newline>"); */ | |
| 592 | 592 | abAppend(&ab,"\n",1); |
| 593 | 593 | snprintf(seq,64,"\r"); |
| 594 | 594 | abAppend(&ab,seq,strlen(seq)); |
| 595 | 595 | rows++; |
| 596 | 596 | if (rows > (int)l->maxrows) l->maxrows = rows; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /* Move cursor to right position. */ |
| 600 | 600 | rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */ |
| 601 | - lndebug("rpos2 %d", rpos2); | |
| 601 | + /* lndebug("rpos2 %d", rpos2); */ | |
| 602 | 602 | |
| 603 | 603 | /* Go up till we reach the expected positon. */ |
| 604 | 604 | if (rows-rpos2 > 0) { |
| 605 | - lndebug("go-up %d", rows-rpos2); | |
| 605 | + /* lndebug("go-up %d", rows-rpos2); */ | |
| 606 | 606 | snprintf(seq,64,"\x1b[%dA", rows-rpos2); |
| 607 | 607 | abAppend(&ab,seq,strlen(seq)); |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /* Set column. */ |
| 611 | 611 | col = (plen+(int)l->pos) % (int)l->cols; |
| 612 | - lndebug("set col %d", 1+col); | |
| 612 | + /* lndebug("set col %d", 1+col); */ | |
| 613 | 613 | if (col) |
| 614 | 614 | snprintf(seq,64,"\r\x1b[%dC", col); |
| 615 | 615 | else |
| 616 | 616 | snprintf(seq,64,"\r"); |
| 617 | 617 | abAppend(&ab,seq,strlen(seq)); |
| 618 | 618 | |
| 619 | - lndebug("\n"); | |
| 619 | + /* lndebug("\n"); */ | |
| 620 | 620 | l->oldpos = l->pos; |
| 621 | 621 | |
| 622 | 622 | if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ |
| 623 | 623 | abFree(&ab); |
| 624 | 624 | } |
| 625 | 625 |
| --- src/linenoise.c | |
| +++ src/linenoise.c | |
| @@ -556,24 +556,24 @@ | |
| 556 | |
| 557 | /* First step: clear all the lines used before. To do so start by |
| 558 | * going to the last row. */ |
| 559 | abInit(&ab); |
| 560 | if (old_rows-rpos > 0) { |
| 561 | lndebug("go down %d", old_rows-rpos); |
| 562 | snprintf(seq,64,"\x1b[%dB", old_rows-rpos); |
| 563 | abAppend(&ab,seq,strlen(seq)); |
| 564 | } |
| 565 | |
| 566 | /* Now for every row clear it, go up. */ |
| 567 | for (j = 0; j < old_rows-1; j++) { |
| 568 | lndebug("clear+up"); |
| 569 | snprintf(seq,64,"\r\x1b[0K\x1b[1A"); |
| 570 | abAppend(&ab,seq,strlen(seq)); |
| 571 | } |
| 572 | |
| 573 | /* Clean the top line. */ |
| 574 | lndebug("clear"); |
| 575 | snprintf(seq,64,"\r\x1b[0K"); |
| 576 | abAppend(&ab,seq,strlen(seq)); |
| 577 | |
| 578 | /* Write the prompt and the current buffer content */ |
| 579 | abAppend(&ab,l->prompt,strlen(l->prompt)); |
| @@ -586,39 +586,39 @@ | |
| 586 | * emit a newline and move the prompt to the first column. */ |
| 587 | if (l->pos && |
| 588 | l->pos == l->len && |
| 589 | (l->pos+plen) % l->cols == 0) |
| 590 | { |
| 591 | lndebug("<newline>"); |
| 592 | abAppend(&ab,"\n",1); |
| 593 | snprintf(seq,64,"\r"); |
| 594 | abAppend(&ab,seq,strlen(seq)); |
| 595 | rows++; |
| 596 | if (rows > (int)l->maxrows) l->maxrows = rows; |
| 597 | } |
| 598 | |
| 599 | /* Move cursor to right position. */ |
| 600 | rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */ |
| 601 | lndebug("rpos2 %d", rpos2); |
| 602 | |
| 603 | /* Go up till we reach the expected positon. */ |
| 604 | if (rows-rpos2 > 0) { |
| 605 | lndebug("go-up %d", rows-rpos2); |
| 606 | snprintf(seq,64,"\x1b[%dA", rows-rpos2); |
| 607 | abAppend(&ab,seq,strlen(seq)); |
| 608 | } |
| 609 | |
| 610 | /* Set column. */ |
| 611 | col = (plen+(int)l->pos) % (int)l->cols; |
| 612 | lndebug("set col %d", 1+col); |
| 613 | if (col) |
| 614 | snprintf(seq,64,"\r\x1b[%dC", col); |
| 615 | else |
| 616 | snprintf(seq,64,"\r"); |
| 617 | abAppend(&ab,seq,strlen(seq)); |
| 618 | |
| 619 | lndebug("\n"); |
| 620 | l->oldpos = l->pos; |
| 621 | |
| 622 | if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ |
| 623 | abFree(&ab); |
| 624 | } |
| 625 |
| --- src/linenoise.c | |
| +++ src/linenoise.c | |
| @@ -556,24 +556,24 @@ | |
| 556 | |
| 557 | /* First step: clear all the lines used before. To do so start by |
| 558 | * going to the last row. */ |
| 559 | abInit(&ab); |
| 560 | if (old_rows-rpos > 0) { |
| 561 | /* lndebug("go down %d", old_rows-rpos); */ |
| 562 | snprintf(seq,64,"\x1b[%dB", old_rows-rpos); |
| 563 | abAppend(&ab,seq,strlen(seq)); |
| 564 | } |
| 565 | |
| 566 | /* Now for every row clear it, go up. */ |
| 567 | for (j = 0; j < old_rows-1; j++) { |
| 568 | /* lndebug("clear+up"); */ |
| 569 | snprintf(seq,64,"\r\x1b[0K\x1b[1A"); |
| 570 | abAppend(&ab,seq,strlen(seq)); |
| 571 | } |
| 572 | |
| 573 | /* Clean the top line. */ |
| 574 | /* lndebug("clear"); */ |
| 575 | snprintf(seq,64,"\r\x1b[0K"); |
| 576 | abAppend(&ab,seq,strlen(seq)); |
| 577 | |
| 578 | /* Write the prompt and the current buffer content */ |
| 579 | abAppend(&ab,l->prompt,strlen(l->prompt)); |
| @@ -586,39 +586,39 @@ | |
| 586 | * emit a newline and move the prompt to the first column. */ |
| 587 | if (l->pos && |
| 588 | l->pos == l->len && |
| 589 | (l->pos+plen) % l->cols == 0) |
| 590 | { |
| 591 | /* lndebug("<newline>"); */ |
| 592 | abAppend(&ab,"\n",1); |
| 593 | snprintf(seq,64,"\r"); |
| 594 | abAppend(&ab,seq,strlen(seq)); |
| 595 | rows++; |
| 596 | if (rows > (int)l->maxrows) l->maxrows = rows; |
| 597 | } |
| 598 | |
| 599 | /* Move cursor to right position. */ |
| 600 | rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */ |
| 601 | /* lndebug("rpos2 %d", rpos2); */ |
| 602 | |
| 603 | /* Go up till we reach the expected positon. */ |
| 604 | if (rows-rpos2 > 0) { |
| 605 | /* lndebug("go-up %d", rows-rpos2); */ |
| 606 | snprintf(seq,64,"\x1b[%dA", rows-rpos2); |
| 607 | abAppend(&ab,seq,strlen(seq)); |
| 608 | } |
| 609 | |
| 610 | /* Set column. */ |
| 611 | col = (plen+(int)l->pos) % (int)l->cols; |
| 612 | /* lndebug("set col %d", 1+col); */ |
| 613 | if (col) |
| 614 | snprintf(seq,64,"\r\x1b[%dC", col); |
| 615 | else |
| 616 | snprintf(seq,64,"\r"); |
| 617 | abAppend(&ab,seq,strlen(seq)); |
| 618 | |
| 619 | /* lndebug("\n"); */ |
| 620 | l->oldpos = l->pos; |
| 621 | |
| 622 | if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ |
| 623 | abFree(&ab); |
| 624 | } |
| 625 |