util: readline: replace tab indent by four spaces to fix checkpatch errors
Replace tab indent by four spaces to fix errors issued by checkpatch.pl tool "ERROR: code indent should never use tabs" within "util/readline.c" file. Signed-off-by: Jules Irenge <jbi.octave@gmail.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-id: 20190401024406.10819-3-jbi.octave@gmail.com Message-Id: <20190401024406.10819-3-jbi.octave@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
2467f95ab3
commit
c95d4a29c3
|
@ -179,20 +179,20 @@ static void readline_up_char(ReadLineState *rs)
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (rs->hist_entry == 0)
|
if (rs->hist_entry == 0)
|
||||||
return;
|
return;
|
||||||
if (rs->hist_entry == -1) {
|
if (rs->hist_entry == -1) {
|
||||||
/* Find latest entry */
|
/* Find latest entry */
|
||||||
for (idx = 0; idx < READLINE_MAX_CMDS; idx++) {
|
for (idx = 0; idx < READLINE_MAX_CMDS; idx++) {
|
||||||
if (rs->history[idx] == NULL)
|
if (rs->history[idx] == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rs->hist_entry = idx;
|
rs->hist_entry = idx;
|
||||||
}
|
}
|
||||||
rs->hist_entry--;
|
rs->hist_entry--;
|
||||||
if (rs->hist_entry >= 0) {
|
if (rs->hist_entry >= 0) {
|
||||||
pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf),
|
pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf),
|
||||||
rs->history[rs->hist_entry]);
|
rs->history[rs->hist_entry]);
|
||||||
rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf);
|
rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,11 +202,11 @@ static void readline_down_char(ReadLineState *rs)
|
||||||
return;
|
return;
|
||||||
if (rs->hist_entry < READLINE_MAX_CMDS - 1 &&
|
if (rs->hist_entry < READLINE_MAX_CMDS - 1 &&
|
||||||
rs->history[++rs->hist_entry] != NULL) {
|
rs->history[++rs->hist_entry] != NULL) {
|
||||||
pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf),
|
pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf),
|
||||||
rs->history[rs->hist_entry]);
|
rs->history[rs->hist_entry]);
|
||||||
} else {
|
} else {
|
||||||
rs->cmd_buf[0] = 0;
|
rs->cmd_buf[0] = 0;
|
||||||
rs->hist_entry = -1;
|
rs->hist_entry = -1;
|
||||||
}
|
}
|
||||||
rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf);
|
rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf);
|
||||||
}
|
}
|
||||||
|
@ -217,42 +217,42 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
if (cmdline[0] == '\0')
|
if (cmdline[0] == '\0')
|
||||||
return;
|
return;
|
||||||
new_entry = NULL;
|
new_entry = NULL;
|
||||||
if (rs->hist_entry != -1) {
|
if (rs->hist_entry != -1) {
|
||||||
/* We were editing an existing history entry: replace it */
|
/* We were editing an existing history entry: replace it */
|
||||||
hist_entry = rs->history[rs->hist_entry];
|
hist_entry = rs->history[rs->hist_entry];
|
||||||
idx = rs->hist_entry;
|
idx = rs->hist_entry;
|
||||||
if (strcmp(hist_entry, cmdline) == 0) {
|
if (strcmp(hist_entry, cmdline) == 0) {
|
||||||
goto same_entry;
|
goto same_entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Search cmdline in history buffers */
|
/* Search cmdline in history buffers */
|
||||||
for (idx = 0; idx < READLINE_MAX_CMDS; idx++) {
|
for (idx = 0; idx < READLINE_MAX_CMDS; idx++) {
|
||||||
hist_entry = rs->history[idx];
|
hist_entry = rs->history[idx];
|
||||||
if (hist_entry == NULL)
|
if (hist_entry == NULL)
|
||||||
break;
|
break;
|
||||||
if (strcmp(hist_entry, cmdline) == 0) {
|
if (strcmp(hist_entry, cmdline) == 0) {
|
||||||
same_entry:
|
same_entry:
|
||||||
new_entry = hist_entry;
|
new_entry = hist_entry;
|
||||||
/* Put this entry at the end of history */
|
/* Put this entry at the end of history */
|
||||||
memmove(&rs->history[idx], &rs->history[idx + 1],
|
memmove(&rs->history[idx], &rs->history[idx + 1],
|
||||||
(READLINE_MAX_CMDS - (idx + 1)) * sizeof(char *));
|
(READLINE_MAX_CMDS - (idx + 1)) * sizeof(char *));
|
||||||
rs->history[READLINE_MAX_CMDS - 1] = NULL;
|
rs->history[READLINE_MAX_CMDS - 1] = NULL;
|
||||||
for (; idx < READLINE_MAX_CMDS; idx++) {
|
for (; idx < READLINE_MAX_CMDS; idx++) {
|
||||||
if (rs->history[idx] == NULL)
|
if (rs->history[idx] == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (idx == READLINE_MAX_CMDS) {
|
if (idx == READLINE_MAX_CMDS) {
|
||||||
/* Need to get one free slot */
|
/* Need to get one free slot */
|
||||||
g_free(rs->history[0]);
|
g_free(rs->history[0]);
|
||||||
memmove(rs->history, &rs->history[1],
|
memmove(rs->history, &rs->history[1],
|
||||||
(READLINE_MAX_CMDS - 1) * sizeof(char *));
|
(READLINE_MAX_CMDS - 1) * sizeof(char *));
|
||||||
rs->history[READLINE_MAX_CMDS - 1] = NULL;
|
rs->history[READLINE_MAX_CMDS - 1] = NULL;
|
||||||
idx = READLINE_MAX_CMDS - 1;
|
idx = READLINE_MAX_CMDS - 1;
|
||||||
}
|
}
|
||||||
if (new_entry == NULL)
|
if (new_entry == NULL)
|
||||||
new_entry = g_strdup(cmdline);
|
new_entry = g_strdup(cmdline);
|
||||||
|
@ -403,9 +403,9 @@ void readline_handle_byte(ReadLineState *rs, int ch)
|
||||||
case 8:
|
case 8:
|
||||||
readline_backspace(rs);
|
readline_backspace(rs);
|
||||||
break;
|
break;
|
||||||
case 155:
|
case 155:
|
||||||
rs->esc_state = IS_CSI;
|
rs->esc_state = IS_CSI;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (ch >= 32) {
|
if (ch >= 32) {
|
||||||
readline_insert_char(rs, ch);
|
readline_insert_char(rs, ch);
|
||||||
|
@ -426,14 +426,14 @@ void readline_handle_byte(ReadLineState *rs, int ch)
|
||||||
break;
|
break;
|
||||||
case IS_CSI:
|
case IS_CSI:
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'F':
|
case 'F':
|
||||||
readline_up_char(rs);
|
readline_up_char(rs);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
case 'E':
|
case 'E':
|
||||||
readline_down_char(rs);
|
readline_down_char(rs);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
readline_backward_char(rs);
|
readline_backward_char(rs);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue