Fix compilation warning: Use macro for seq_buffer_max_length (#14815)
Some checks are pending
CI / test-ubuntu-latest (push) Waiting to run
CI / test-sanitizer-address (push) Waiting to run
CI / build-debian-old (push) Waiting to run
CI / build-macos-latest (push) Waiting to run
CI / build-32bit (push) Waiting to run
CI / build-libc-malloc (push) Waiting to run
CI / build-centos-jemalloc (push) Waiting to run
CI / build-old-chain-jemalloc (push) Waiting to run
Codecov / code-coverage (push) Waiting to run
External Server Tests / test-external-standalone (push) Waiting to run
External Server Tests / test-external-cluster (push) Waiting to run
External Server Tests / test-external-nodebug (push) Waiting to run
Spellcheck / Spellcheck (push) Waiting to run

## Description

This PR fixes a compilation warning in `deps/linenoise/linenoise.c` by
converting the local constant variable `seq_buffer_max_length` to an
enum constant `SEQ_BUFFER_MAX_LENGTH`.

### Changes Made
- Replaced the local `const int seq_buffer_max_length = 8;` declaration
with a macro constant.
This commit is contained in:
Vitah Lin 2026-02-27 09:31:10 +08:00 committed by GitHub
parent 50f1469961
commit 33319b80a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,6 +120,7 @@
#include <assert.h>
#include "linenoise.h"
#define SEQ_BUFFER_MAX_LENGTH 8
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
#define LINENOISE_MAX_LINE 4096
static char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
@ -1060,15 +1061,14 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen,
if (seq[1] >= '0' && seq[1] <= '9') {
/* Extended escape, read additional bytes.
* Examples: ESC [1;5C ESC [3~ */
const int seq_buffer_max_length = 8;
char seq_buffer[seq_buffer_max_length];
char seq_buffer[SEQ_BUFFER_MAX_LENGTH];
int i = 0;
seq_buffer[i++] = seq[1];
/* Read more bytes until we see a CSI final byte (range @..~).
* Use seq_buffer_max_length-1 to reserve one position for '\0'. */
* Use SEQ_BUFFER_MAX_LENGTH-1 to reserve one position for '\0'. */
char seq_char;
while (i < seq_buffer_max_length-1 && read(l.ifd, &seq_char, 1) == 1) {
while (i < SEQ_BUFFER_MAX_LENGTH - 1 && read(l.ifd, &seq_char, 1) == 1) {
seq_buffer[i++] = seq_char;
if (seq_char >= '@' && seq_char <= '~') break; /* CSI final byte */
}