test: format C test files and fix clang-tidy warnings

It's probably not worth adding the C test files to regular formatting as
they're pretty much never touched, but ensuring the files are formatted
according to our standards and getting rid of warnings is a cheap
one-time fix.
This commit is contained in:
dundargoc
2024-12-21 13:03:17 +01:00
committed by dundargoc
parent 130b5fd85f
commit fd05c7f19d
8 changed files with 122 additions and 119 deletions

View File

@@ -1,6 +1,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#ifdef _MSC_VER
# include <Windows.h>
# define usleep(usecs) Sleep(usecs/1000)
@@ -107,7 +108,7 @@ int main(int argc, char **argv)
char cmd[100];
int arg;
while (1) {
while (true) {
fprintf(stderr, "interact $ ");
if (fgets(input, sizeof(input), stdin) == NULL) {

View File

@@ -1,6 +1,5 @@
/// Helper program to exit and keep stdout open (like "xclip -i -loops 1").
#include <stdio.h>
#include <uv.h>
int main(int argc, char **argv)

View File

@@ -1,8 +1,9 @@
#include <string.h>
#include <stdlib.h>
#include "nvim/event/multiqueue.h"
#include <string.h>
#include "multiqueue.h"
#include "nvim/event/multiqueue.h"
void ut_multiqueue_put(MultiQueue *self, const char *str)
{

View File

@@ -1,4 +1,4 @@
#include "nvim/event/multiqueue.h"
void ut_multiqueue_put(MultiQueue *queue, const char *str);
const char *ut_multiqueue_get(MultiQueue *queue);
void ut_multiqueue_put(MultiQueue *self, const char *str);
const char *ut_multiqueue_get(MultiQueue *self);

View File

@@ -1,8 +1,8 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
enum {
kPOSIXErrnoEINTR = EINTR,

View File

@@ -1,7 +1,7 @@
#include "vterm_test.h"
#include <stdio.h>
#include "vterm_test.h"
int parser_text(const char bytes[], size_t len, void *user)
{
FILE *f = fopen(VTERM_TEST_FILE, "a");
@@ -27,7 +27,8 @@ static void printchars(const char *s, size_t len, FILE *f)
}
}
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user)
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed,
char command, void *user)
{
FILE *f = fopen(VTERM_TEST_FILE, "a");
fprintf(f, "csi %02x", command);
@@ -283,11 +284,9 @@ void print_color(const VTermColor *col)
FILE *f = fopen(VTERM_TEST_FILE, "a");
if (VTERM_COLOR_IS_RGB(col)) {
fprintf(f, "rgb(%d,%d,%d", col->rgb.red, col->rgb.green, col->rgb.blue);
}
else if (VTERM_COLOR_IS_INDEXED(col)) {
} else if (VTERM_COLOR_IS_INDEXED(col)) {
fprintf(f, "idx(%d", col->indexed.idx);
}
else {
} else {
fprintf(f, "invalid(%d", col->type);
}
if (VTERM_COLOR_IS_DEFAULT_FG(col)) {
@@ -322,7 +321,8 @@ int state_settermprop(VTermProp prop, VTermValue *val, void *user)
goto end;
case VTERM_VALUETYPE_STRING:
fprintf(f, "settermprop %d %s\"%.*s\"%s\n", prop,
val->string.initial ? "[" : "", (int)val->string.len, val->string.str, val->string.final ? "]" : "");
val->string.initial ? "[" : "", (int)val->string.len, val->string.str,
val->string.final ? "]" : "");
errcode = 0;
goto end;
case VTERM_VALUETYPE_COLOR:
@@ -422,7 +422,8 @@ int state_setpenattr(VTermAttr attr, VTermValue *val, void *user)
}
bool want_state_scrollback;
int state_sb_clear(void *user) {
int state_sb_clear(void *user)
{
if (!want_state_scrollback) {
return 1;
}

View File

@@ -5,7 +5,8 @@
#include "vterm/vterm.h"
int parser_text(const char bytes[], size_t len, void *user);
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user);
int parser_csi(const char *leader, const long args[], int argcount, const char *intermed,
char command, void *user);
int parser_osc(int command, VTermStringFragment frag, void *user);
int parser_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user);
int parser_apc(VTermStringFragment frag, void *user);