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.

drh 2018-01-07 23:45 trunk
Commit 24c2b99df2f659140a1bedaef3a9a44dfeb1c1ba7929c5bd8ec39de3d15dba44
1 file changed +8 -8
+8 -8
--- src/linenoise.c
+++ src/linenoise.c
@@ -556,24 +556,24 @@
556556
557557
/* First step: clear all the lines used before. To do so start by
558558
* going to the last row. */
559559
abInit(&ab);
560560
if (old_rows-rpos > 0) {
561
- lndebug("go down %d", old_rows-rpos);
561
+ /* lndebug("go down %d", old_rows-rpos); */
562562
snprintf(seq,64,"\x1b[%dB", old_rows-rpos);
563563
abAppend(&ab,seq,strlen(seq));
564564
}
565565
566566
/* Now for every row clear it, go up. */
567567
for (j = 0; j < old_rows-1; j++) {
568
- lndebug("clear+up");
568
+ /* lndebug("clear+up"); */
569569
snprintf(seq,64,"\r\x1b[0K\x1b[1A");
570570
abAppend(&ab,seq,strlen(seq));
571571
}
572572
573573
/* Clean the top line. */
574
- lndebug("clear");
574
+ /* lndebug("clear"); */
575575
snprintf(seq,64,"\r\x1b[0K");
576576
abAppend(&ab,seq,strlen(seq));
577577
578578
/* Write the prompt and the current buffer content */
579579
abAppend(&ab,l->prompt,strlen(l->prompt));
@@ -586,39 +586,39 @@
586586
* emit a newline and move the prompt to the first column. */
587587
if (l->pos &&
588588
l->pos == l->len &&
589589
(l->pos+plen) % l->cols == 0)
590590
{
591
- lndebug("<newline>");
591
+ /* lndebug("<newline>"); */
592592
abAppend(&ab,"\n",1);
593593
snprintf(seq,64,"\r");
594594
abAppend(&ab,seq,strlen(seq));
595595
rows++;
596596
if (rows > (int)l->maxrows) l->maxrows = rows;
597597
}
598598
599599
/* Move cursor to right position. */
600600
rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */
601
- lndebug("rpos2 %d", rpos2);
601
+ /* lndebug("rpos2 %d", rpos2); */
602602
603603
/* Go up till we reach the expected positon. */
604604
if (rows-rpos2 > 0) {
605
- lndebug("go-up %d", rows-rpos2);
605
+ /* lndebug("go-up %d", rows-rpos2); */
606606
snprintf(seq,64,"\x1b[%dA", rows-rpos2);
607607
abAppend(&ab,seq,strlen(seq));
608608
}
609609
610610
/* Set column. */
611611
col = (plen+(int)l->pos) % (int)l->cols;
612
- lndebug("set col %d", 1+col);
612
+ /* lndebug("set col %d", 1+col); */
613613
if (col)
614614
snprintf(seq,64,"\r\x1b[%dC", col);
615615
else
616616
snprintf(seq,64,"\r");
617617
abAppend(&ab,seq,strlen(seq));
618618
619
- lndebug("\n");
619
+ /* lndebug("\n"); */
620620
l->oldpos = l->pos;
621621
622622
if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */
623623
abFree(&ab);
624624
}
625625
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button