Hi, I failed in selecting my preferred set of options for indent. These options are missing or I didn't saw them:
1) No space between function pointer name and parameter. Example:
int foo(double (*bar)(int));
instead of
int foo(double (*bar) (int));
2) No space between the pointer star and the name. Example:
static char *format_size_base10(const prefix_t *units);
instead of
static char *format_size_base10(const prefix_t * units);
3) One space between code and one-line comment. Example:
} else { // size >= 1000
instead of
} else { // size >= 1000
4) No space around braces for initial array values. Example:
static const char *prefix[PREFIX_TYPES] = {"base10", "base2",
"historic"};
instead of
static const char *prefix[PREFIX_TYPES] = { "base10", "base2",
"historic" };
5) I found a bug: indent with the -l80 did not wrap this line correctly:
int kibi_n_format_transfer_rate(char *dest, size_t n, filesize_t
transfer_rate) {
Here's how you can reproduce all above:
bzr branch lp:libkibi
cd libkibi
INDENT_PARAM="-kr --no-tabs --braces-on-func-def-line
--no-space-after-for \
--no-space-after-if --no-space-after-while --no-space-after-casts \
-l80 -cp0"
indent -v $INDENT_PARAM kibi/kibi.h kibi/kibi.c test/test.c
bzr diff
bzr diff shouldn't show a difference (with the correct indent
parameters). Attached the diffs it produces.
--
Benjamin Drung
Debian & Ubuntu Developer
=== modified file 'kibi/kibi.c'
--- kibi/kibi.c 2011-01-13 22:32:06 +0000
+++ kibi/kibi.c 2011-01-13 22:33:40 +0000
@@ -52,10 +52,10 @@
#define PREFIX_COUNT 7
typedef struct prefix_s {
- char *(*format_size)(const struct prefix_s*, filesize_t, const char*);
- int (*format_n)(const struct prefix_s*, char*, size_t, filesize_t,
- const char*);
- double (*get_factor)(unsigned int level);
+ char *(*format_size) (const struct prefix_s *, filesize_t, const char *);
+ int (*format_n) (const struct prefix_s *, char *, size_t, filesize_t,
+ const char *);
+ double (*get_factor) (unsigned int level);
char *prefix[PREFIX_COUNT];
char *size[PREFIX_COUNT];
char *transfer_rate[PREFIX_COUNT];
@@ -64,7 +64,7 @@
static const prefix_t *selected_prefix = NULL;
static const struct lconv *locale = NULL;
-static char *format_size_base10(const prefix_t *units, filesize_t size,
+static char *format_size_base10(const prefix_t * units, filesize_t size,
const char *suffix) {
char *formatted_size = NULL;
filesize_t rounded_size;
@@ -80,7 +80,7 @@
return NULL;
}
snprintf(formatted_size, length, "%llu %s", size, suffix);
- } else { // size >= 1000
+ } else { // size >= 1000
i = 1;
// 999950 will be rounded to 1,000,000
while(size >= 999950) {
@@ -99,7 +99,7 @@
snprintf(formatted_size, length, "%llu%s%02llu %s%s",
rounded_size / 100, locale->decimal_point,
rounded_size % 100, units->prefix[i], suffix);
- } else { // size >= 9995 (which will be rounded to 10,000)
+ } else { // size >= 9995 (which will be rounded to 10,000)
rounded_size = (size + 50) / 100;
// strlen("999.9") = 5
length = 5 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1;
@@ -117,7 +117,7 @@
return formatted_size;
}
-static char *format_size_base2(const prefix_t *units, filesize_t size,
+static char *format_size_base2(const prefix_t * units, filesize_t size,
const char *suffix) {
char *formatted_size = NULL;
filesize_t carry_10 = 0;
@@ -146,7 +146,7 @@
}
rounded_size = (size * 100 + carry_100 + 512) >> 10;
- if(rounded_size < 1000) { // rounded_size < 10.00
+ if(rounded_size < 1000) { // rounded_size < 10.00
// strlen("9.99") = 4
length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1;
formatted_size = malloc(length);
@@ -157,9 +157,9 @@
snprintf(formatted_size, length, "%llu%s%02llu %s%s",
rounded_size / 100, locale->decimal_point,
rounded_size % 100, units->prefix[i], suffix);
- } else { // rounded_size >= 10.00
+ } else { // rounded_size >= 10.00
rounded_size = (size * 10 + carry_10 + 512) >> 10;
- if(likely(rounded_size < 10000)) { // rounded_size < 1,000.0
+ if(likely(rounded_size < 10000)) { // rounded_size < 1,000.0
// strlen("999.9") = 5
length = 5 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1;
formatted_size = malloc(length);
@@ -170,7 +170,7 @@
snprintf(formatted_size, length, "%llu%s%01llu %s%s",
rounded_size / 10, locale->decimal_point,
rounded_size % 10, units->prefix[i], suffix);
- } else { // rounded_size >= 1,000.0
+ } else { // rounded_size >= 1,000.0
rounded_size = (size + 512) >> 10;
// strlen("1023") = 4
length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1;
@@ -188,7 +188,7 @@
return formatted_size;
}
-static int format_n_base10(const prefix_t *units, char *dest, size_t n,
+static int format_n_base10(const prefix_t * units, char *dest, size_t n,
filesize_t size, const char *suffix) {
filesize_t rounded_size;
int i;
@@ -196,7 +196,7 @@
if(unlikely(size < 1000)) {
length = snprintf(dest, n, "%llu %s", size, suffix);
- } else { // size >= 1000
+ } else { // size >= 1000
i = 1;
// 999950 will be rounded to 1,000,000
while(size >= 999950) {
@@ -208,7 +208,7 @@
length = snprintf(dest, n, "%llu%s%02llu %s%s", rounded_size / 100,
locale->decimal_point, rounded_size % 100,
units->prefix[i], suffix);
- } else { // size >= 9995 (which will be rounded to 10,000)
+ } else { // size >= 9995 (which will be rounded to 10,000)
rounded_size = (size + 50) / 100;
length = snprintf(dest, n, "%llu%s%01llu %s%s", rounded_size / 10,
locale->decimal_point, rounded_size % 10,
@@ -219,7 +219,7 @@
return length;
}
-static int format_n_base2(const prefix_t *units, char *dest, size_t n,
+static int format_n_base2(const prefix_t * units, char *dest, size_t n,
filesize_t size, const char *suffix) {
filesize_t carry_10 = 0;
filesize_t carry_100 = 0;
@@ -240,17 +240,17 @@
}
rounded_size = (size * 100 + carry_100 + 512) >> 10;
- if(rounded_size < 1000) { // rounded_size < 10.00
+ if(rounded_size < 1000) { // rounded_size < 10.00
length = snprintf(dest, n, "%llu%s%02llu %s%s", rounded_size / 100,
locale->decimal_point, rounded_size % 100,
units->prefix[i], suffix);
- } else { // rounded_size >= 10.00
+ } else { // rounded_size >= 10.00
rounded_size = (size * 10 + carry_10 + 512) >> 10;
- if(likely(rounded_size < 10000)) { // rounded_size < 1,000.0
+ if(likely(rounded_size < 10000)) { // rounded_size < 1,000.0
length = snprintf(dest, n, "%llu%s%01llu %s%s",
rounded_size / 10, locale->decimal_point,
rounded_size % 10, units->prefix[i], suffix);
- } else { // rounded_size >= 1,000.0
+ } else { // rounded_size >= 1,000.0
rounded_size = (size + 512) >> 10;
length = snprintf(dest, n, "%llu %s%s", rounded_size,
units->prefix[i], suffix);
@@ -319,7 +319,7 @@
return NULL;
}
strncpy(result, xdg_config_home, length);
- } else { // xdg_config_home == NULL || strlen(xdg_config_home) == 0
+ } else { // xdg_config_home == NULL || strlen(xdg_config_home) == 0
// Use $HOME/.config if XDG_CONFIG_HOME is not defined.
home = getenv("HOME");
length = strlen(home) + 1 + strlen(config_dir) + 1;
@@ -423,12 +423,12 @@
if(!access(user_config_file, R_OK)) {
debug("found %s\n", user_config_file);
found_config = read_config_file(user_config_file);
- } else { // access(user_config_file, R_OK)
+ } else { // access(user_config_file, R_OK)
if(!access(user_config_file, F_OK)) {
fprintf(stderr,
"\nlibkibi: Warning: Can't read config file %s\n",
user_config_file);
- } else { // access(user_config_file, F_OK)
+ } else { // access(user_config_file, F_OK)
debug("not found %s\n", user_config_file);
}
}
@@ -439,12 +439,12 @@
if(!access(SYSTEM_CONFIG_FILE, R_OK)) {
debug("found %s\n", SYSTEM_CONFIG_FILE);
found_config = read_config_file(SYSTEM_CONFIG_FILE);
- } else { // access(SYSTEM_CONFIG_FILE, R_OK)
+ } else { // access(SYSTEM_CONFIG_FILE, R_OK)
if(!access(SYSTEM_CONFIG_FILE, F_OK)) {
fprintf(stderr,
"\nlibkibi: Warning: Can't read config file %s\n",
SYSTEM_CONFIG_FILE);
- } else { // access(SYSTEM_CONFIG_FILE, F_OK)
+ } else { // access(SYSTEM_CONFIG_FILE, F_OK)
debug("not found %s\n", SYSTEM_CONFIG_FILE);
}
}
@@ -479,7 +479,7 @@
if(selected_prefix == &historic) {
formatted_size = historic.format_size(&historic, memory_size, "B");
- } else { // selected_prefix != &historic
+ } else { // selected_prefix != &historic
formatted_size = base2.format_size(&base2, memory_size, "B");
}
@@ -518,12 +518,12 @@
}
if(selected_prefix == &base10) {
snprintf(formatted_size, length, "%s/%s", base10_size, base2_size);
- } else { // selected_prefix == &base2
+ } else { // selected_prefix == &base2
snprintf(formatted_size, length, "%s/%s", base2_size, base10_size);
}
free(base2_size);
free(base10_size);
- } else { // size < 1024 || selected_prefix == &historic
+ } else { // size < 1024 || selected_prefix == &historic
formatted_size = selected_prefix->format_size(selected_prefix, size,
"B");
}
@@ -582,7 +582,7 @@
level = PREFIX_COUNT - 1;
}
- return (filesize_t)(size * selected_prefix->get_factor(level) + 0.5);
+ return (filesize_t) (size * selected_prefix->get_factor(level) + 0.5);
}
int kibi_n_format_memory_size(char *dest, size_t n, filesize_t memory_size) {
@@ -594,7 +594,7 @@
if(selected_prefix == &historic) {
length = historic.format_n(&historic, dest, n, memory_size, "B");
- } else { // selected_prefix != &historic
+ } else { // selected_prefix != &historic
length = base2.format_n(&base2, dest, n, memory_size, "B");
}
@@ -623,18 +623,17 @@
base10.format_n(&base10, base10_size, BASE10_SIZE_LENGTH, size, "B");
if(selected_prefix == &base10) {
length = snprintf(dest, n, "%s/%s", base10_size, base2_size);
- } else { // selected_prefix == &base2
+ } else { // selected_prefix == &base2
length = snprintf(dest, n, "%s/%s", base2_size, base10_size);
}
- } else { // size < 1024 || selected_prefix == &historic
+ } else { // size < 1024 || selected_prefix == &historic
length = selected_prefix->format_n(selected_prefix, dest, n, size, "B");
}
return length;
}
-int kibi_n_format_transfer_rate(char *dest, size_t n,
- filesize_t transfer_rate) {
+int kibi_n_format_transfer_rate(char *dest, size_t n, filesize_t transfer_rate) {
if(unlikely(selected_prefix == NULL)) {
kibi_init();
}
=== modified file 'test/test.c'
--- test/test.c 2011-01-12 11:03:29 +0000
+++ test/test.c 2011-01-13 22:33:40 +0000
@@ -66,24 +66,24 @@
typedef struct {
char *name;
- char *(*function)(filesize_t);
+ char *(*function) (filesize_t);
const testcase_t *testcases;
} function_test_t;
typedef struct {
char *name;
- const char *(*function)(unsigned int);
+ const char *(*function) (unsigned int);
const testcase_t *testcases;
} const_function_test_t;
typedef struct {
char *name;
- int (*function)(char*, size_t, filesize_t);
+ int (*function) (char *, size_t, filesize_t);
const testcase_t *testcases;
const testcase_n_t *testcases_n;
} function_n_test_t;
-static const char *prefix[PREFIX_TYPES] = {"base10", "base2", "historic"};
+static const char *prefix[PREFIX_TYPES] = { "base10", "base2", "historic" };
static const testcase_divide_t testcases_divide_size[] = {
{0, 4, {0, 0, 0}},
@@ -329,8 +329,8 @@
}
static int check_divide(char *name,
- double (*function)(filesize_t, unsigned int),
- const testcase_divide_t *testcases, int format) {
+ double (*function) (filesize_t, unsigned int),
+ const testcase_divide_t * testcases, int format) {
double result;
int failures = 0;
const testcase_divide_t *testcase;
@@ -353,8 +353,8 @@
return failures;
}
-static int check_function(char *name, char *(*function)(filesize_t),
- const testcase_t *testcases, int format) {
+static int check_function(char *name, char *(*function) (filesize_t),
+ const testcase_t * testcases, int format) {
char *result;
int failures = 0;
const testcase_t *testcase;
@@ -378,8 +378,8 @@
}
static int check_function2(char *name,
- char *(*function)(filesize_t, const char*),
- const testcase2_t *testcases, int format) {
+ char *(*function) (filesize_t, const char *),
+ const testcase2_t * testcases, int format) {
char *result;
int failures = 0;
const testcase2_t *testcase;
@@ -404,8 +404,8 @@
}
static int check_const_function(char *name,
- const char *(*function)(unsigned int),
- const testcase_t *testcases, int format) {
+ const char *(*function) (unsigned int),
+ const testcase_t * testcases, int format) {
const char *result;
unsigned int level;
int failures = 0;
@@ -430,9 +430,9 @@
}
static int check_function_n(char *name,
- int (*function)(char*, size_t, filesize_t),
- const testcase_t *testcases,
- const testcase_n_t *testcases_n, int format) {
+ int (*function) (char *, size_t, filesize_t),
+ const testcase_t * testcases,
+ const testcase_n_t * testcases_n, int format) {
bool strings_equal;
char fix_formatted_size[DEST_BUFFER_LENGTH];
char *formatted_size;
@@ -502,10 +502,10 @@
}
static int check_function2_n(char *name,
- int (*function)(char*, size_t, filesize_t,
- const char*),
- const testcase2_t *testcases,
- const testcase2_n_t *testcases_n, int format) {
+ int (*function) (char *, size_t, filesize_t,
+ const char *),
+ const testcase2_t * testcases,
+ const testcase2_n_t * testcases_n, int format) {
bool strings_equal;
char fix_formatted_size[DEST_BUFFER_LENGTH];
char *formatted_size;
@@ -576,8 +576,8 @@
}
static int check_multiply(char *name,
- filesize_t (*function)(double, unsigned int),
- const testcase_multiply_t *testcases, int format) {
+ filesize_t(*function) (double, unsigned int),
+ const testcase_multiply_t * testcases, int format) {
filesize_t result;
int failures = 0;
const testcase_multiply_t *testcase;
signature.asc
Description: This is a digitally signed message part
_______________________________________________ bug-indent mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-indent
