[PATCH] test: run uncrustify
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Jun 25 10:55:45 PDT 2019
This is the result of running:
$ uncrustify --replace --config ../devel/uncrustify.cfg *.cc *.c *.h
in the test directory.
Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
test/arg-test.c | 72 +++++++++++++++++++++--------------------
test/ghost-report.cc | 10 +++---
test/hex-xcode.c | 20 ++++++------
test/make-db-version.cc | 3 +-
test/notmuch-test.h | 8 ++---
test/parse-time.c | 58 ++++++++++++++++-----------------
test/random-corpus.c | 2 +-
test/smtp-dummy.c | 2 +-
test/symbol-test.cc | 5 +--
9 files changed, 93 insertions(+), 87 deletions(-)
diff --git a/test/arg-test.c b/test/arg-test.c
index a218f967..44477730 100644
--- a/test/arg-test.c
+++ b/test/arg-test.c
@@ -2,27 +2,29 @@
#include "command-line-arguments.h"
-int main(int argc, char **argv){
-
- int opt_index=1;
-
- int kw_val=0;
- int kwb_val=0;
- int fl_val=0;
- int int_val=0;
- const char *pos_arg1=NULL;
- const char *pos_arg2=NULL;
- const char *string_val=NULL;
+int
+main (int argc, char **argv)
+{
+
+ int opt_index = 1;
+
+ int kw_val = 0;
+ int kwb_val = 0;
+ int fl_val = 0;
+ int int_val = 0;
+ const char *pos_arg1 = NULL;
+ const char *pos_arg2 = NULL;
+ const char *string_val = NULL;
bool bool_val = false;
bool fl_set = false, int_set = false, bool_set = false, kwb_set = false,
- kw_set = false, string_set = false, pos1_set = false, pos2_set = false;
+ kw_set = false, string_set = false, pos1_set = false, pos2_set = false;
notmuch_opt_desc_t parent_options[] = {
{ .opt_flags = &fl_val, .name = "flag", .present = &fl_set, .keywords =
- (notmuch_keyword_t []){ { "one", 1 << 0},
- { "two", 1 << 1 },
- { "three", 1 << 2 },
- { 0, 0 } } },
+ (notmuch_keyword_t []){ { "one", 1 << 0 },
+ { "two", 1 << 1 },
+ { "three", 1 << 2 },
+ { 0, 0 } } },
{ .opt_int = &int_val, .name = "int", .present = &int_set },
{ }
};
@@ -30,16 +32,16 @@ int main(int argc, char **argv){
notmuch_opt_desc_t options[] = {
{ .opt_bool = &bool_val, .name = "boolean", .present = &bool_set },
{ .opt_keyword = &kw_val, .name = "keyword", .present = &kw_set, .keywords =
- (notmuch_keyword_t []){ { "zero", 0 },
- { "one", 1 },
- { "two", 2 },
- { 0, 0 } } },
+ (notmuch_keyword_t []){ { "zero", 0 },
+ { "one", 1 },
+ { "two", 2 },
+ { 0, 0 } } },
{ .opt_keyword = &kwb_val, .name = "boolkeyword", .present = &kwb_set,
.keyword_no_arg_value = "true", .keywords =
- (notmuch_keyword_t []){ { "false", 0 },
- { "true", 1 },
- { "auto", 2 },
- { 0, 0 } } },
+ (notmuch_keyword_t []){ { "false", 0 },
+ { "true", 1 },
+ { "auto", 2 },
+ { 0, 0 } } },
{ .opt_inherit = parent_options },
{ .opt_string = &string_val, .name = "string", .present = &string_set },
{ .opt_position = &pos_arg1, .present = &pos1_set },
@@ -47,38 +49,38 @@ int main(int argc, char **argv){
{ }
};
- opt_index = parse_arguments(argc, argv, options, 1);
+ opt_index = parse_arguments (argc, argv, options, 1);
if (opt_index < 0)
return 1;
if (bool_set)
- printf("boolean %d\n", bool_val);
+ printf ("boolean %d\n", bool_val);
if (kw_set)
- printf("keyword %d\n", kw_val);
+ printf ("keyword %d\n", kw_val);
if (kwb_set)
- printf("boolkeyword %d\n", kwb_val);
+ printf ("boolkeyword %d\n", kwb_val);
if (fl_set)
- printf("flags %d\n", fl_val);
+ printf ("flags %d\n", fl_val);
if (int_set)
- printf("int %d\n", int_val);
+ printf ("int %d\n", int_val);
if (string_set)
- printf("string %s\n", string_val);
+ printf ("string %s\n", string_val);
if (pos1_set)
- printf("positional arg 1 %s\n", pos_arg1);
+ printf ("positional arg 1 %s\n", pos_arg1);
if (pos2_set)
- printf("positional arg 2 %s\n", pos_arg2);
+ printf ("positional arg 2 %s\n", pos_arg2);
- for ( ; opt_index < argc ; opt_index ++) {
- printf("non parsed arg %d = %s\n", opt_index, argv[opt_index]);
+ for (; opt_index < argc; opt_index++) {
+ printf ("non parsed arg %d = %s\n", opt_index, argv[opt_index]);
}
return 0;
diff --git a/test/ghost-report.cc b/test/ghost-report.cc
index 3e1b07c6..fad9a71d 100644
--- a/test/ghost-report.cc
+++ b/test/ghost-report.cc
@@ -2,13 +2,15 @@
#include <cstdlib>
#include <xapian.h>
-int main(int argc, char **argv) {
+int
+main (int argc, char **argv)
+{
if (argc < 2) {
std::cerr << "usage: ghost-report xapian-dir" << std::endl;
- exit(1);
+ exit (1);
}
- Xapian::Database db(argv[1]);
- std::cout << db.get_termfreq("Tghost") << std::endl;
+ Xapian::Database db (argv[1]);
+ std::cout << db.get_termfreq ("Tghost") << std::endl;
}
diff --git a/test/hex-xcode.c b/test/hex-xcode.c
index 33046e9a..2e70f737 100644
--- a/test/hex-xcode.c
+++ b/test/hex-xcode.c
@@ -26,13 +26,13 @@ xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
if (dir == ENCODE)
status = hex_encode (ctx, in, buf_p, size_p);
else
- if (inplace) {
- status = hex_decode_inplace (in);
- *buf_p = in;
- *size_p = strlen(in);
- } else {
- status = hex_decode (ctx, in, buf_p, size_p);
- }
+ if (inplace) {
+ status = hex_decode_inplace (in);
+ *buf_p = in;
+ *size_p = strlen (in);
+ } else {
+ status = hex_decode (ctx, in, buf_p, size_p);
+ }
if (status == HEX_SUCCESS)
fputs (*buf_p, stdout);
@@ -49,9 +49,9 @@ main (int argc, char **argv)
notmuch_opt_desc_t options[] = {
{ .opt_keyword = &dir, .name = "direction", .keywords =
- (notmuch_keyword_t []){ { "encode", ENCODE },
- { "decode", DECODE },
- { 0, 0 } } },
+ (notmuch_keyword_t []){ { "encode", ENCODE },
+ { "decode", DECODE },
+ { 0, 0 } } },
{ .opt_bool = &omit_newline, .name = "omit-newline" },
{ .opt_bool = &inplace, .name = "in-place" },
{ }
diff --git a/test/make-db-version.cc b/test/make-db-version.cc
index fa80cac9..78feaf72 100644
--- a/test/make-db-version.cc
+++ b/test/make-db-version.cc
@@ -8,7 +8,8 @@
#include <xapian.h>
-int main(int argc, char **argv)
+int
+main (int argc, char **argv)
{
if (argc != 4) {
fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]);
diff --git a/test/notmuch-test.h b/test/notmuch-test.h
index 45d03d67..df852da9 100644
--- a/test/notmuch-test.h
+++ b/test/notmuch-test.h
@@ -4,13 +4,13 @@
#include <notmuch.h>
inline static void
-expect0(int line, notmuch_status_t ret)
+expect0 (int line, notmuch_status_t ret)
{
- if (ret) {
+ if (ret) {
fprintf (stderr, "line %d: %d\n", line, ret);
exit (1);
- }
+ }
}
-#define EXPECT0(v) expect0(__LINE__, v);
+#define EXPECT0(v) expect0 (__LINE__, v);
#endif
diff --git a/test/parse-time.c b/test/parse-time.c
index 694761cf..6aac89b9 100644
--- a/test/parse-time.c
+++ b/test/parse-time.c
@@ -30,16 +30,16 @@
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
static const char *parse_time_error_strings[] = {
- [PARSE_TIME_OK] = "OK",
- [PARSE_TIME_ERR] = "ERR",
- [PARSE_TIME_ERR_LIB] = "LIB",
- [PARSE_TIME_ERR_ALREADYSET] = "ALREADYSET",
- [PARSE_TIME_ERR_FORMAT] = "FORMAT",
- [PARSE_TIME_ERR_DATEFORMAT] = "DATEFORMAT",
- [PARSE_TIME_ERR_TIMEFORMAT] = "TIMEFORMAT",
- [PARSE_TIME_ERR_INVALIDDATE] = "INVALIDDATE",
- [PARSE_TIME_ERR_INVALIDTIME] = "INVALIDTIME",
- [PARSE_TIME_ERR_KEYWORD] = "KEYWORD",
+ [PARSE_TIME_OK] = "OK",
+ [PARSE_TIME_ERR] = "ERR",
+ [PARSE_TIME_ERR_LIB] = "LIB",
+ [PARSE_TIME_ERR_ALREADYSET] = "ALREADYSET",
+ [PARSE_TIME_ERR_FORMAT] = "FORMAT",
+ [PARSE_TIME_ERR_DATEFORMAT] = "DATEFORMAT",
+ [PARSE_TIME_ERR_TIMEFORMAT] = "TIMEFORMAT",
+ [PARSE_TIME_ERR_INVALIDDATE] = "INVALIDDATE",
+ [PARSE_TIME_ERR_INVALIDTIME] = "INVALIDTIME",
+ [PARSE_TIME_ERR_KEYWORD] = "KEYWORD",
};
static const char *
@@ -66,7 +66,7 @@ concat_args (int start, int end, char *argv[])
len += strlen (argv[i]) + 1;
p = malloc (len);
- if (!p)
+ if (! p)
return NULL;
*p = 0;
@@ -111,10 +111,10 @@ struct {
const char *operator;
int round;
} operators[] = {
- { "==>", PARSE_TIME_NO_ROUND },
- { "==_>", PARSE_TIME_ROUND_DOWN },
- { "==^>", PARSE_TIME_ROUND_UP_INCLUSIVE },
- { "==^^>", PARSE_TIME_ROUND_UP },
+ { "==>", PARSE_TIME_NO_ROUND },
+ { "==_>", PARSE_TIME_ROUND_DOWN },
+ { "==^>", PARSE_TIME_ROUND_UP_INCLUSIVE },
+ { "==^^>", PARSE_TIME_ROUND_UP },
};
static const char *
@@ -145,7 +145,7 @@ get_operator (int round)
const char *oper = NULL;
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(operators); i++) {
+ for (i = 0; i < ARRAY_SIZE (operators); i++) {
if (round == operators[i].round) {
oper = operators[i].operator;
break;
@@ -172,10 +172,10 @@ parse_stdin (FILE *infile, time_t *ref, int round, const char *format)
/* trail is trailing whitespace and (optional) comment */
trail = strchr (input, '#');
- if (!trail)
+ if (! trail)
trail = input + len;
- while (trail > input && isspace ((unsigned char) *(trail-1)))
+ while (trail > input && isspace ((unsigned char) *(trail - 1)))
trail--;
if (trail == input) {
@@ -184,7 +184,7 @@ parse_stdin (FILE *infile, time_t *ref, int round, const char *format)
}
tmp = strdup (trail);
- if (!tmp) {
+ if (! tmp) {
fprintf (stderr, "strdup() failed\n");
continue;
}
@@ -201,8 +201,8 @@ parse_stdin (FILE *infile, time_t *ref, int round, const char *format)
}
r = parse_time_string (input, &t, ref, round);
- if (!r) {
- if (!localtime_r (&t, &tm)) {
+ if (! r) {
+ if (! localtime_r (&t, &tm)) {
fprintf (stderr, "localtime_r() failed\n");
free (trail);
continue;
@@ -239,12 +239,12 @@ main (int argc, char *argv[])
char buf[1024];
const char *format = DEFAULT_FORMAT;
struct option options[] = {
- { "help", no_argument, NULL, 'h' },
- { "^", no_argument, NULL, 'u' },
- { "^^", no_argument, NULL, 'U' },
- { "_", no_argument, NULL, 'd' },
- { "format", required_argument, NULL, 'f' },
- { "ref", required_argument, NULL, 'r' },
+ { "help", no_argument, NULL, 'h' },
+ { "^", no_argument, NULL, 'u' },
+ { "^^", no_argument, NULL, 'U' },
+ { "_", no_argument, NULL, 'd' },
+ { "format", required_argument, NULL, 'f' },
+ { "ref", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 },
};
@@ -287,7 +287,7 @@ main (int argc, char *argv[])
return parse_stdin (stdin, nowp, round, format);
argstr = concat_args (optind, argc, argv);
- if (!argstr)
+ if (! argstr)
return 1;
r = parse_time_string (argstr, &result, nowp, round);
@@ -304,7 +304,7 @@ main (int argc, char *argv[])
return r;
}
- if (!localtime_r (&result, &tm))
+ if (! localtime_r (&result, &tm))
return 1;
strftime (buf, sizeof (buf), format, &tm);
diff --git a/test/random-corpus.c b/test/random-corpus.c
index 9272afda..8ed7ff76 100644
--- a/test/random-corpus.c
+++ b/test/random-corpus.c
@@ -116,7 +116,7 @@ random_utf8_string (void *ctx, size_t char_count)
/* stubs since we cannot link with notmuch.o */
const notmuch_opt_desc_t notmuch_shared_options[] = {
- { }
+ { }
};
const char *notmuch_requested_db_uuid = NULL;
diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c
index a7c1fe4f..1c89e9af 100644
--- a/test/smtp-dummy.c
+++ b/test/smtp-dummy.c
@@ -275,7 +275,7 @@ main (int argc, char *argv[])
do_smtp_to_file (peer_file, output);
- DONE:
+ DONE:
if (output)
fclose (output);
if (peer_file)
diff --git a/test/symbol-test.cc b/test/symbol-test.cc
index 7454838b..9d73a571 100644
--- a/test/symbol-test.cc
+++ b/test/symbol-test.cc
@@ -3,7 +3,8 @@
#include <xapian.h>
#include <notmuch.h>
-int main (int argc, char** argv)
+int
+main (int argc, char **argv)
{
notmuch_database_t *notmuch;
char *message = NULL;
@@ -22,7 +23,7 @@ int main (int argc, char** argv)
try {
(void) new Xapian::WritableDatabase (argv[2], Xapian::DB_OPEN);
} catch (const Xapian::Error &error) {
- printf("caught %s\n", error.get_msg().c_str());
+ printf ("caught %s\n", error.get_msg ().c_str ());
return 0;
}
--
2.20.1
More information about the notmuch
mailing list