Fossil SCM
Adjust the "lndebug()" macro in linenoise so that it works on older compilers that do not support varargs macros.
Commit
acab077c4cbcba28f8788d80c9335ce0e403c857
Parent
c510b74dd8ecd07…
1 file changed
+7
-7
+7
-7
| --- src/linenoise.c | ||
| +++ src/linenoise.c | ||
| @@ -176,24 +176,24 @@ | ||
| 176 | 176 | static void refreshLine(struct linenoiseState *l); |
| 177 | 177 | |
| 178 | 178 | /* Debugging macro. */ |
| 179 | 179 | #if 0 |
| 180 | 180 | FILE *lndebug_fp = NULL; |
| 181 | -#define lndebug(...) \ | |
| 181 | +#define lndebug(fmt, arg1) \ | |
| 182 | 182 | do { \ |
| 183 | 183 | if (lndebug_fp == NULL) { \ |
| 184 | 184 | lndebug_fp = fopen("/tmp/lndebug.txt","a"); \ |
| 185 | 185 | fprintf(lndebug_fp, \ |
| 186 | 186 | "[%d %d %d] p: %d, rows: %d, rpos: %d, max: %d, oldmax: %d\n", \ |
| 187 | 187 | (int)l->len,(int)l->pos,(int)l->oldpos,plen,rows,rpos, \ |
| 188 | 188 | (int)l->maxrows,old_rows); \ |
| 189 | 189 | } \ |
| 190 | - fprintf(lndebug_fp, ", " __VA_ARGS__); \ | |
| 190 | + fprintf(lndebug_fp, ", " fmt, arg1); \ | |
| 191 | 191 | fflush(lndebug_fp); \ |
| 192 | 192 | } while (0) |
| 193 | 193 | #else |
| 194 | -#define lndebug(fmt, ...) | |
| 194 | +#define lndebug(fmt, arg1) | |
| 195 | 195 | #endif |
| 196 | 196 | |
| 197 | 197 | /* ======================= Low level terminal handling ====================== */ |
| 198 | 198 | |
| 199 | 199 | /* Set if to use or not the multi line mode. */ |
| @@ -526,17 +526,17 @@ | ||
| 526 | 526 | abAppend(&ab,seq,strlen(seq)); |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | /* Now for every row clear it, go up. */ |
| 530 | 530 | for (j = 0; j < old_rows-1; j++) { |
| 531 | - lndebug("clear+up"); | |
| 531 | + lndebug("clear+up", 0); | |
| 532 | 532 | snprintf(seq,64,"\r\x1b[0K\x1b[1A"); |
| 533 | 533 | abAppend(&ab,seq,strlen(seq)); |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /* Clean the top line. */ |
| 537 | - lndebug("clear"); | |
| 537 | + lndebug("clear", 0); | |
| 538 | 538 | snprintf(seq,64,"\r\x1b[0K"); |
| 539 | 539 | abAppend(&ab,seq,strlen(seq)); |
| 540 | 540 | |
| 541 | 541 | /* Write the prompt and the current buffer content */ |
| 542 | 542 | abAppend(&ab,l->prompt,strlen(l->prompt)); |
| @@ -546,11 +546,11 @@ | ||
| 546 | 546 | * emit a newline and move the prompt to the first column. */ |
| 547 | 547 | if (l->pos && |
| 548 | 548 | l->pos == l->len && |
| 549 | 549 | (l->pos+plen) % l->cols == 0) |
| 550 | 550 | { |
| 551 | - lndebug("<newline>"); | |
| 551 | + lndebug("<newline>", 0); | |
| 552 | 552 | abAppend(&ab,"\n",1); |
| 553 | 553 | snprintf(seq,64,"\r"); |
| 554 | 554 | abAppend(&ab,seq,strlen(seq)); |
| 555 | 555 | rows++; |
| 556 | 556 | if (rows > (int)l->maxrows) l->maxrows = rows; |
| @@ -574,11 +574,11 @@ | ||
| 574 | 574 | snprintf(seq,64,"\r\x1b[%dC", col); |
| 575 | 575 | else |
| 576 | 576 | snprintf(seq,64,"\r"); |
| 577 | 577 | abAppend(&ab,seq,strlen(seq)); |
| 578 | 578 | |
| 579 | - lndebug("\n"); | |
| 579 | + lndebug("\n", 0); | |
| 580 | 580 | l->oldpos = l->pos; |
| 581 | 581 | |
| 582 | 582 | if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ |
| 583 | 583 | abFree(&ab); |
| 584 | 584 | } |
| 585 | 585 |
| --- src/linenoise.c | |
| +++ src/linenoise.c | |
| @@ -176,24 +176,24 @@ | |
| 176 | static void refreshLine(struct linenoiseState *l); |
| 177 | |
| 178 | /* Debugging macro. */ |
| 179 | #if 0 |
| 180 | FILE *lndebug_fp = NULL; |
| 181 | #define lndebug(...) \ |
| 182 | do { \ |
| 183 | if (lndebug_fp == NULL) { \ |
| 184 | lndebug_fp = fopen("/tmp/lndebug.txt","a"); \ |
| 185 | fprintf(lndebug_fp, \ |
| 186 | "[%d %d %d] p: %d, rows: %d, rpos: %d, max: %d, oldmax: %d\n", \ |
| 187 | (int)l->len,(int)l->pos,(int)l->oldpos,plen,rows,rpos, \ |
| 188 | (int)l->maxrows,old_rows); \ |
| 189 | } \ |
| 190 | fprintf(lndebug_fp, ", " __VA_ARGS__); \ |
| 191 | fflush(lndebug_fp); \ |
| 192 | } while (0) |
| 193 | #else |
| 194 | #define lndebug(fmt, ...) |
| 195 | #endif |
| 196 | |
| 197 | /* ======================= Low level terminal handling ====================== */ |
| 198 | |
| 199 | /* Set if to use or not the multi line mode. */ |
| @@ -526,17 +526,17 @@ | |
| 526 | abAppend(&ab,seq,strlen(seq)); |
| 527 | } |
| 528 | |
| 529 | /* Now for every row clear it, go up. */ |
| 530 | for (j = 0; j < old_rows-1; j++) { |
| 531 | lndebug("clear+up"); |
| 532 | snprintf(seq,64,"\r\x1b[0K\x1b[1A"); |
| 533 | abAppend(&ab,seq,strlen(seq)); |
| 534 | } |
| 535 | |
| 536 | /* Clean the top line. */ |
| 537 | lndebug("clear"); |
| 538 | snprintf(seq,64,"\r\x1b[0K"); |
| 539 | abAppend(&ab,seq,strlen(seq)); |
| 540 | |
| 541 | /* Write the prompt and the current buffer content */ |
| 542 | abAppend(&ab,l->prompt,strlen(l->prompt)); |
| @@ -546,11 +546,11 @@ | |
| 546 | * emit a newline and move the prompt to the first column. */ |
| 547 | if (l->pos && |
| 548 | l->pos == l->len && |
| 549 | (l->pos+plen) % l->cols == 0) |
| 550 | { |
| 551 | lndebug("<newline>"); |
| 552 | abAppend(&ab,"\n",1); |
| 553 | snprintf(seq,64,"\r"); |
| 554 | abAppend(&ab,seq,strlen(seq)); |
| 555 | rows++; |
| 556 | if (rows > (int)l->maxrows) l->maxrows = rows; |
| @@ -574,11 +574,11 @@ | |
| 574 | snprintf(seq,64,"\r\x1b[%dC", col); |
| 575 | else |
| 576 | snprintf(seq,64,"\r"); |
| 577 | abAppend(&ab,seq,strlen(seq)); |
| 578 | |
| 579 | lndebug("\n"); |
| 580 | l->oldpos = l->pos; |
| 581 | |
| 582 | if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ |
| 583 | abFree(&ab); |
| 584 | } |
| 585 |
| --- src/linenoise.c | |
| +++ src/linenoise.c | |
| @@ -176,24 +176,24 @@ | |
| 176 | static void refreshLine(struct linenoiseState *l); |
| 177 | |
| 178 | /* Debugging macro. */ |
| 179 | #if 0 |
| 180 | FILE *lndebug_fp = NULL; |
| 181 | #define lndebug(fmt, arg1) \ |
| 182 | do { \ |
| 183 | if (lndebug_fp == NULL) { \ |
| 184 | lndebug_fp = fopen("/tmp/lndebug.txt","a"); \ |
| 185 | fprintf(lndebug_fp, \ |
| 186 | "[%d %d %d] p: %d, rows: %d, rpos: %d, max: %d, oldmax: %d\n", \ |
| 187 | (int)l->len,(int)l->pos,(int)l->oldpos,plen,rows,rpos, \ |
| 188 | (int)l->maxrows,old_rows); \ |
| 189 | } \ |
| 190 | fprintf(lndebug_fp, ", " fmt, arg1); \ |
| 191 | fflush(lndebug_fp); \ |
| 192 | } while (0) |
| 193 | #else |
| 194 | #define lndebug(fmt, arg1) |
| 195 | #endif |
| 196 | |
| 197 | /* ======================= Low level terminal handling ====================== */ |
| 198 | |
| 199 | /* Set if to use or not the multi line mode. */ |
| @@ -526,17 +526,17 @@ | |
| 526 | abAppend(&ab,seq,strlen(seq)); |
| 527 | } |
| 528 | |
| 529 | /* Now for every row clear it, go up. */ |
| 530 | for (j = 0; j < old_rows-1; j++) { |
| 531 | lndebug("clear+up", 0); |
| 532 | snprintf(seq,64,"\r\x1b[0K\x1b[1A"); |
| 533 | abAppend(&ab,seq,strlen(seq)); |
| 534 | } |
| 535 | |
| 536 | /* Clean the top line. */ |
| 537 | lndebug("clear", 0); |
| 538 | snprintf(seq,64,"\r\x1b[0K"); |
| 539 | abAppend(&ab,seq,strlen(seq)); |
| 540 | |
| 541 | /* Write the prompt and the current buffer content */ |
| 542 | abAppend(&ab,l->prompt,strlen(l->prompt)); |
| @@ -546,11 +546,11 @@ | |
| 546 | * emit a newline and move the prompt to the first column. */ |
| 547 | if (l->pos && |
| 548 | l->pos == l->len && |
| 549 | (l->pos+plen) % l->cols == 0) |
| 550 | { |
| 551 | lndebug("<newline>", 0); |
| 552 | abAppend(&ab,"\n",1); |
| 553 | snprintf(seq,64,"\r"); |
| 554 | abAppend(&ab,seq,strlen(seq)); |
| 555 | rows++; |
| 556 | if (rows > (int)l->maxrows) l->maxrows = rows; |
| @@ -574,11 +574,11 @@ | |
| 574 | snprintf(seq,64,"\r\x1b[%dC", col); |
| 575 | else |
| 576 | snprintf(seq,64,"\r"); |
| 577 | abAppend(&ab,seq,strlen(seq)); |
| 578 | |
| 579 | lndebug("\n", 0); |
| 580 | l->oldpos = l->pos; |
| 581 | |
| 582 | if (write(fd,ab.b,ab.len) == -1) {} /* Can't recover from write error. */ |
| 583 | abFree(&ab); |
| 584 | } |
| 585 |