test: run uncrustify

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@fifthhorseman.net>
This commit is contained in:
Daniel Kahn Gillmor 2019-06-25 13:55:45 -04:00 committed by David Bremner
parent 1959a95d25
commit bdc87f0d3e
9 changed files with 91 additions and 85 deletions

View file

@ -2,27 +2,29 @@
#include "command-line-arguments.h" #include "command-line-arguments.h"
int main(int argc, char **argv){ int
main (int argc, char **argv)
{
int opt_index=1; int opt_index = 1;
int kw_val=0; int kw_val = 0;
int kwb_val=0; int kwb_val = 0;
int fl_val=0; int fl_val = 0;
int int_val=0; int int_val = 0;
const char *pos_arg1=NULL; const char *pos_arg1 = NULL;
const char *pos_arg2=NULL; const char *pos_arg2 = NULL;
const char *string_val=NULL; const char *string_val = NULL;
bool bool_val = false; bool bool_val = false;
bool fl_set = false, int_set = false, bool_set = false, kwb_set = 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[] = { notmuch_opt_desc_t parent_options[] = {
{ .opt_flags = &fl_val, .name = "flag", .present = &fl_set, .keywords = { .opt_flags = &fl_val, .name = "flag", .present = &fl_set, .keywords =
(notmuch_keyword_t []){ { "one", 1 << 0}, (notmuch_keyword_t []){ { "one", 1 << 0 },
{ "two", 1 << 1 }, { "two", 1 << 1 },
{ "three", 1 << 2 }, { "three", 1 << 2 },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_int = &int_val, .name = "int", .present = &int_set }, { .opt_int = &int_val, .name = "int", .present = &int_set },
{ } { }
}; };
@ -30,16 +32,16 @@ int main(int argc, char **argv){
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_bool = &bool_val, .name = "boolean", .present = &bool_set }, { .opt_bool = &bool_val, .name = "boolean", .present = &bool_set },
{ .opt_keyword = &kw_val, .name = "keyword", .present = &kw_set, .keywords = { .opt_keyword = &kw_val, .name = "keyword", .present = &kw_set, .keywords =
(notmuch_keyword_t []){ { "zero", 0 }, (notmuch_keyword_t []){ { "zero", 0 },
{ "one", 1 }, { "one", 1 },
{ "two", 2 }, { "two", 2 },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_keyword = &kwb_val, .name = "boolkeyword", .present = &kwb_set, { .opt_keyword = &kwb_val, .name = "boolkeyword", .present = &kwb_set,
.keyword_no_arg_value = "true", .keywords = .keyword_no_arg_value = "true", .keywords =
(notmuch_keyword_t []){ { "false", 0 }, (notmuch_keyword_t []){ { "false", 0 },
{ "true", 1 }, { "true", 1 },
{ "auto", 2 }, { "auto", 2 },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_inherit = parent_options }, { .opt_inherit = parent_options },
{ .opt_string = &string_val, .name = "string", .present = &string_set }, { .opt_string = &string_val, .name = "string", .present = &string_set },
{ .opt_position = &pos_arg1, .present = &pos1_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) if (opt_index < 0)
return 1; return 1;
if (bool_set) if (bool_set)
printf("boolean %d\n", bool_val); printf ("boolean %d\n", bool_val);
if (kw_set) if (kw_set)
printf("keyword %d\n", kw_val); printf ("keyword %d\n", kw_val);
if (kwb_set) if (kwb_set)
printf("boolkeyword %d\n", kwb_val); printf ("boolkeyword %d\n", kwb_val);
if (fl_set) if (fl_set)
printf("flags %d\n", fl_val); printf ("flags %d\n", fl_val);
if (int_set) if (int_set)
printf("int %d\n", int_val); printf ("int %d\n", int_val);
if (string_set) if (string_set)
printf("string %s\n", string_val); printf ("string %s\n", string_val);
if (pos1_set) if (pos1_set)
printf("positional arg 1 %s\n", pos_arg1); printf ("positional arg 1 %s\n", pos_arg1);
if (pos2_set) 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 ++) { for (; opt_index < argc; opt_index++) {
printf("non parsed arg %d = %s\n", opt_index, argv[opt_index]); printf ("non parsed arg %d = %s\n", opt_index, argv[opt_index]);
} }
return 0; return 0;

View file

@ -2,13 +2,15 @@
#include <cstdlib> #include <cstdlib>
#include <xapian.h> #include <xapian.h>
int main(int argc, char **argv) { int
main (int argc, char **argv)
{
if (argc < 2) { if (argc < 2) {
std::cerr << "usage: ghost-report xapian-dir" << std::endl; std::cerr << "usage: ghost-report xapian-dir" << std::endl;
exit(1); exit (1);
} }
Xapian::Database db(argv[1]); Xapian::Database db (argv[1]);
std::cout << db.get_termfreq("Tghost") << std::endl; std::cout << db.get_termfreq ("Tghost") << std::endl;
} }

View file

@ -26,13 +26,13 @@ xcode (void *ctx, enum direction dir, char *in, char **buf_p, size_t *size_p)
if (dir == ENCODE) if (dir == ENCODE)
status = hex_encode (ctx, in, buf_p, size_p); status = hex_encode (ctx, in, buf_p, size_p);
else else
if (inplace) { if (inplace) {
status = hex_decode_inplace (in); status = hex_decode_inplace (in);
*buf_p = in; *buf_p = in;
*size_p = strlen(in); *size_p = strlen (in);
} else { } else {
status = hex_decode (ctx, in, buf_p, size_p); status = hex_decode (ctx, in, buf_p, size_p);
} }
if (status == HEX_SUCCESS) if (status == HEX_SUCCESS)
fputs (*buf_p, stdout); fputs (*buf_p, stdout);
@ -49,9 +49,9 @@ main (int argc, char **argv)
notmuch_opt_desc_t options[] = { notmuch_opt_desc_t options[] = {
{ .opt_keyword = &dir, .name = "direction", .keywords = { .opt_keyword = &dir, .name = "direction", .keywords =
(notmuch_keyword_t []){ { "encode", ENCODE }, (notmuch_keyword_t []){ { "encode", ENCODE },
{ "decode", DECODE }, { "decode", DECODE },
{ 0, 0 } } }, { 0, 0 } } },
{ .opt_bool = &omit_newline, .name = "omit-newline" }, { .opt_bool = &omit_newline, .name = "omit-newline" },
{ .opt_bool = &inplace, .name = "in-place" }, { .opt_bool = &inplace, .name = "in-place" },
{ } { }

View file

@ -8,7 +8,8 @@
#include <xapian.h> #include <xapian.h>
int main(int argc, char **argv) int
main (int argc, char **argv)
{ {
if (argc != 4) { if (argc != 4) {
fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]); fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]);

View file

@ -4,13 +4,13 @@
#include <notmuch.h> #include <notmuch.h>
inline static void 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); fprintf (stderr, "line %d: %d\n", line, ret);
exit (1); exit (1);
} }
} }
#define EXPECT0(v) expect0(__LINE__, v); #define EXPECT0(v) expect0 (__LINE__, v);
#endif #endif

View file

@ -30,16 +30,16 @@
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
static const char *parse_time_error_strings[] = { static const char *parse_time_error_strings[] = {
[PARSE_TIME_OK] = "OK", [PARSE_TIME_OK] = "OK",
[PARSE_TIME_ERR] = "ERR", [PARSE_TIME_ERR] = "ERR",
[PARSE_TIME_ERR_LIB] = "LIB", [PARSE_TIME_ERR_LIB] = "LIB",
[PARSE_TIME_ERR_ALREADYSET] = "ALREADYSET", [PARSE_TIME_ERR_ALREADYSET] = "ALREADYSET",
[PARSE_TIME_ERR_FORMAT] = "FORMAT", [PARSE_TIME_ERR_FORMAT] = "FORMAT",
[PARSE_TIME_ERR_DATEFORMAT] = "DATEFORMAT", [PARSE_TIME_ERR_DATEFORMAT] = "DATEFORMAT",
[PARSE_TIME_ERR_TIMEFORMAT] = "TIMEFORMAT", [PARSE_TIME_ERR_TIMEFORMAT] = "TIMEFORMAT",
[PARSE_TIME_ERR_INVALIDDATE] = "INVALIDDATE", [PARSE_TIME_ERR_INVALIDDATE] = "INVALIDDATE",
[PARSE_TIME_ERR_INVALIDTIME] = "INVALIDTIME", [PARSE_TIME_ERR_INVALIDTIME] = "INVALIDTIME",
[PARSE_TIME_ERR_KEYWORD] = "KEYWORD", [PARSE_TIME_ERR_KEYWORD] = "KEYWORD",
}; };
static const char * static const char *
@ -66,7 +66,7 @@ concat_args (int start, int end, char *argv[])
len += strlen (argv[i]) + 1; len += strlen (argv[i]) + 1;
p = malloc (len); p = malloc (len);
if (!p) if (! p)
return NULL; return NULL;
*p = 0; *p = 0;
@ -111,10 +111,10 @@ struct {
const char *operator; const char *operator;
int round; int round;
} operators[] = { } operators[] = {
{ "==>", PARSE_TIME_NO_ROUND }, { "==>", PARSE_TIME_NO_ROUND },
{ "==_>", PARSE_TIME_ROUND_DOWN }, { "==_>", PARSE_TIME_ROUND_DOWN },
{ "==^>", PARSE_TIME_ROUND_UP_INCLUSIVE }, { "==^>", PARSE_TIME_ROUND_UP_INCLUSIVE },
{ "==^^>", PARSE_TIME_ROUND_UP }, { "==^^>", PARSE_TIME_ROUND_UP },
}; };
static const char * static const char *
@ -145,7 +145,7 @@ get_operator (int round)
const char *oper = NULL; const char *oper = NULL;
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(operators); i++) { for (i = 0; i < ARRAY_SIZE (operators); i++) {
if (round == operators[i].round) { if (round == operators[i].round) {
oper = operators[i].operator; oper = operators[i].operator;
break; 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 is trailing whitespace and (optional) comment */
trail = strchr (input, '#'); trail = strchr (input, '#');
if (!trail) if (! trail)
trail = input + len; trail = input + len;
while (trail > input && isspace ((unsigned char) *(trail-1))) while (trail > input && isspace ((unsigned char) *(trail - 1)))
trail--; trail--;
if (trail == input) { if (trail == input) {
@ -184,7 +184,7 @@ parse_stdin (FILE *infile, time_t *ref, int round, const char *format)
} }
tmp = strdup (trail); tmp = strdup (trail);
if (!tmp) { if (! tmp) {
fprintf (stderr, "strdup() failed\n"); fprintf (stderr, "strdup() failed\n");
continue; 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); r = parse_time_string (input, &t, ref, round);
if (!r) { if (! r) {
if (!localtime_r (&t, &tm)) { if (! localtime_r (&t, &tm)) {
fprintf (stderr, "localtime_r() failed\n"); fprintf (stderr, "localtime_r() failed\n");
free (trail); free (trail);
continue; continue;
@ -239,12 +239,12 @@ main (int argc, char *argv[])
char buf[1024]; char buf[1024];
const char *format = DEFAULT_FORMAT; const char *format = DEFAULT_FORMAT;
struct option options[] = { struct option options[] = {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "^", no_argument, NULL, 'u' }, { "^", no_argument, NULL, 'u' },
{ "^^", no_argument, NULL, 'U' }, { "^^", no_argument, NULL, 'U' },
{ "_", no_argument, NULL, 'd' }, { "_", no_argument, NULL, 'd' },
{ "format", required_argument, NULL, 'f' }, { "format", required_argument, NULL, 'f' },
{ "ref", required_argument, NULL, 'r' }, { "ref", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 }, { NULL, 0, NULL, 0 },
}; };
@ -287,7 +287,7 @@ main (int argc, char *argv[])
return parse_stdin (stdin, nowp, round, format); return parse_stdin (stdin, nowp, round, format);
argstr = concat_args (optind, argc, argv); argstr = concat_args (optind, argc, argv);
if (!argstr) if (! argstr)
return 1; return 1;
r = parse_time_string (argstr, &result, nowp, round); r = parse_time_string (argstr, &result, nowp, round);
@ -304,7 +304,7 @@ main (int argc, char *argv[])
return r; return r;
} }
if (!localtime_r (&result, &tm)) if (! localtime_r (&result, &tm))
return 1; return 1;
strftime (buf, sizeof (buf), format, &tm); strftime (buf, sizeof (buf), format, &tm);

View file

@ -116,7 +116,7 @@ random_utf8_string (void *ctx, size_t char_count)
/* stubs since we cannot link with notmuch.o */ /* stubs since we cannot link with notmuch.o */
const notmuch_opt_desc_t notmuch_shared_options[] = { const notmuch_opt_desc_t notmuch_shared_options[] = {
{ } { }
}; };
const char *notmuch_requested_db_uuid = NULL; const char *notmuch_requested_db_uuid = NULL;

View file

@ -275,7 +275,7 @@ main (int argc, char *argv[])
do_smtp_to_file (peer_file, output); do_smtp_to_file (peer_file, output);
DONE: DONE:
if (output) if (output)
fclose (output); fclose (output);
if (peer_file) if (peer_file)

View file

@ -3,7 +3,8 @@
#include <xapian.h> #include <xapian.h>
#include <notmuch.h> #include <notmuch.h>
int main (int argc, char** argv) int
main (int argc, char **argv)
{ {
notmuch_database_t *notmuch; notmuch_database_t *notmuch;
char *message = NULL; char *message = NULL;
@ -22,7 +23,7 @@ int main (int argc, char** argv)
try { try {
(void) new Xapian::WritableDatabase (argv[2], Xapian::DB_OPEN); (void) new Xapian::WritableDatabase (argv[2], Xapian::DB_OPEN);
} catch (const Xapian::Error &error) { } 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; return 0;
} }