Browse Source

Formatting fixes

Serj Kalichev 4 years ago
parent
commit
a22ee5775c
7 changed files with 41 additions and 39 deletions
  1. 2 2
      .clang-format
  2. 8 8
      faux/conv/conv.c
  3. 2 2
      faux/ctype/ctype.c
  4. 14 11
      faux/ini/ini.c
  5. 6 6
      faux/list/list.c
  6. 8 9
      faux/str/str.c
  7. 1 1
      faux/sysdb/sysdb.c

+ 2 - 2
.clang-format

@@ -8,7 +8,7 @@ AlignEscapedNewlines: false
 AlignOperands: false
 AlignTrailingComments: false
 #AllowAllArgumentsOnNextLine: true
-AllowAllParametersOfDeclarationOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
 AllowShortBlocksOnASingleLine: false
 AllowShortCaseLabelsOnASingleLine: false
 AllowShortFunctionsOnASingleLine: None
@@ -32,7 +32,7 @@ BreakBeforeBinaryOperators: None
 BreakBeforeBraces: Attach
 BreakBeforeTernaryOperators: false
 BreakStringLiterals: false
-ColumnLimit: 0
+ColumnLimit: 80
 IncludeBlocks: Preserve
 #IndentCaseBlocks: false
 IndentCaseLabels: false

+ 8 - 8
faux/conv/conv.c

@@ -192,8 +192,8 @@ int faux_conv_atoui(const char *str, unsigned int *val, int base) {
  * @param [in] base Base to convert.
  * @return 0 - success, < 0 - error
  */
-int faux_conv_atos(const char *str, short *val, int base)
-{
+int faux_conv_atos(const char *str, short *val, int base) {
+
 	long int tmp = 0;
 
 	if (faux_conv_atol(str, &tmp, base) < 0)
@@ -217,8 +217,8 @@ int faux_conv_atos(const char *str, short *val, int base)
  * @param [in] base Base to convert.
  * @return 0 - success, < 0 - error
  */
-int faux_conv_atous(const char *str, unsigned short *val, int base)
-{
+int faux_conv_atous(const char *str, unsigned short *val, int base) {
+
 	unsigned long int tmp = 0;
 
 	if (faux_conv_atoul(str, &tmp, base) < 0)
@@ -242,8 +242,8 @@ int faux_conv_atous(const char *str, unsigned short *val, int base)
  * @param [in] base Base to convert.
  * @return 0 - success, < 0 - error
  */
-int faux_conv_atoc(const char *str, char *val, int base)
-{
+int faux_conv_atoc(const char *str, char *val, int base) {
+
 	long int tmp = 0;
 
 	if (faux_conv_atol(str, &tmp, base) < 0)
@@ -267,8 +267,8 @@ int faux_conv_atoc(const char *str, char *val, int base)
  * @param [in] base Base to convert.
  * @return 0 - success, < 0 - error
  */
-int faux_conv_atouc(const char *str, unsigned char *val, int base)
-{
+int faux_conv_atouc(const char *str, unsigned char *val, int base) {
+
 	unsigned long int tmp = 0;
 
 	if (faux_conv_atoul(str, &tmp, base) < 0)

+ 2 - 2
faux/ctype/ctype.c

@@ -64,8 +64,8 @@ char faux_ctype_tolower(char c) {
  * @param [in] c Character to convert.
  * @return Converted character.
  */
-char faux_ctype_toupper(char c)
-{
+char faux_ctype_toupper(char c) {
+
 	// toupper() man says that argument must be unsigned char
 	return toupper((unsigned char)c);
 }

+ 14 - 11
faux/ini/ini.c

@@ -69,7 +69,8 @@ void faux_ini_free(faux_ini_t *ini) {
  * NULL if entry was removed (value == NULL)
  * NULL on error
  */
-const faux_pair_t *faux_ini_set(faux_ini_t *ini, const char *name, const char *value) {
+const faux_pair_t *faux_ini_set(
+	faux_ini_t *ini, const char *name, const char *value) {
 
 	faux_pair_t *pair = NULL;
 	faux_list_node_t *node = NULL;
@@ -103,7 +104,8 @@ const faux_pair_t *faux_ini_set(faux_ini_t *ini, const char *name, const char *v
 	found_pair = faux_list_data(node);
 	if (found_pair != pair) { // Item already exists so use existent
 		faux_pair_free(pair);
-		faux_pair_set_value(found_pair, value); // Replace value by new one
+		faux_pair_set_value(
+			found_pair, value); // Replace value by new one
 		return found_pair;
 	}
 
@@ -230,8 +232,7 @@ const faux_pair_t *faux_ini_each(faux_ini_node_t **iter) {
  * @param [in] str String to find word in it.
  * @return Purified copy of word or NULL.
  */
-static char *faux_ini_purify_word(const char *str)
-{
+static char *faux_ini_purify_word(const char *str) {
 	const char *word;
 	const char *string = str;
 	bool_t quoted = BOOL_FALSE;
@@ -310,8 +311,8 @@ int faux_ini_parse_str(faux_ini_t *ini, const char *string) {
 
 	buffer = faux_str_dup(string);
 	// Now loop though each line
-	for (line = strtok_r(buffer, "\n\r", &saveptr);
-		line; line = strtok_r(NULL, "\n\r", &saveptr)) {
+	for (line = strtok_r(buffer, "\n\r", &saveptr); line;
+		line = strtok_r(NULL, "\n\r", &saveptr)) {
 
 		// Now 'line' contain one 'name/value' pair. Single line.
 		char *str = NULL;
@@ -401,11 +402,11 @@ int faux_ini_parse_file(faux_ini_t *ini, const char *fn) {
 	while (fgets(buf + bytes_readed, size - bytes_readed, fd)) {
 
 		// Not enough space in buffer. Make it larger.
-		if (feof(fd) == 0 &&
-			!strchr(buf + bytes_readed, '\n') &&
+		if (feof(fd) == 0 && !strchr(buf + bytes_readed, '\n') &&
 			!strchr(buf + bytes_readed, '\r')) {
 			char *tmp = NULL;
-			bytes_readed = size - 1; // fgets() put '\0' to last byte
+			bytes_readed =
+				size - 1; // fgets() put '\0' to last byte
 			size += chunk_size;
 			tmp = realloc(buf, size);
 			if (!tmp) // Memory problems
@@ -462,11 +463,13 @@ int faux_ini_write_file(const faux_ini_t *ini, const char *fn) {
 		const char *value = faux_pair_value(pair);
 
 		// Print name field
-		quote = strchr(name, ' ') ? "" : "\""; // Word with spaces needs quotes
+		// Word with spaces needs quotes
+		quote = strchr(name, ' ') ? "" : "\"";
 		fprintf(fd, "%s%s%s=", quote, name, quote);
 
 		// Print value field
-		quote = strchr(value, ' ') ? "" : "\""; // Word with spaces needs quotes
+		// Word with spaces needs quotes
+		quote = strchr(value, ' ') ? "" : "\"";
 		fprintf(fd, "%s%s%s\n", quote, value, quote);
 	}
 

+ 6 - 6
faux/list/list.c

@@ -153,8 +153,8 @@ void *faux_list_each(faux_list_node_t **iter) {
  * @param [in] freeFn Callback function to free user data.
  * @return Newly created bidirectional list or NULL on error.
  */
-faux_list_t *faux_list_new(faux_list_compare_fn compareFn,
-	faux_list_free_fn freeFn) {
+faux_list_t *faux_list_new(
+	faux_list_compare_fn compareFn, faux_list_free_fn freeFn) {
 
 	faux_list_t *list = NULL;
 
@@ -253,8 +253,8 @@ size_t faux_list_len(const faux_list_t *list) {
  * identical entry. Or NULL if find is false.
  * @return Newly added list node.
  */
-static faux_list_node_t *faux_list_add_generic(faux_list_t *list, void *data,
-	bool_t uniq, bool_t find) {
+static faux_list_node_t *faux_list_add_generic(
+	faux_list_t *list, void *data, bool_t uniq, bool_t find) {
 
 	faux_list_node_t *node = NULL;
 	faux_list_node_t *iter = NULL;
@@ -494,8 +494,8 @@ faux_list_node_t *faux_list_match_node(const faux_list_t *list,
 void *faux_list_match(const faux_list_t *list, faux_list_match_fn matchFn,
 	const void *userkey, faux_list_node_t **saveptr) {
 
-	faux_list_node_t *res = faux_list_match_node(list, matchFn,
-		userkey, saveptr);
+	faux_list_node_t *res =
+		faux_list_match_node(list, matchFn, userkey, saveptr);
 	if (!res)
 		return NULL;
 

+ 8 - 9
faux/str/str.c

@@ -235,8 +235,8 @@ int faux_str_casecmpn(const char *str1, const char *str2, size_t n) {
 	size_t num = n;
 
 	while (*p1 != '\0' && *p2 != '\0' && num != 0) {
-		int res = faux_str_cmp_chars(faux_ctype_tolower(*p1),
-			faux_ctype_tolower(*p2));
+		int res = faux_str_cmp_chars(
+			faux_ctype_tolower(*p1), faux_ctype_tolower(*p2));
 		if (res != 0)
 			return res;
 		p1++;
@@ -247,8 +247,8 @@ int faux_str_casecmpn(const char *str1, const char *str2, size_t n) {
 	if (0 == n) // It means n first characters are equal.
 		return 0;
 
-	return faux_str_cmp_chars(faux_ctype_tolower(*p1),
-		faux_ctype_tolower(*p2));
+	return faux_str_cmp_chars(
+		faux_ctype_tolower(*p1), faux_ctype_tolower(*p2));
 }
 
 
@@ -268,16 +268,16 @@ int faux_str_casecmp(const char *str1, const char *str2) {
 	const char *p2 = str2;
 
 	while (*p1 != '\0' && *p2 != '\0') {
-		int res = faux_str_cmp_chars(faux_ctype_tolower(*p1),
-			faux_ctype_tolower(*p2));
+		int res = faux_str_cmp_chars(
+			faux_ctype_tolower(*p1), faux_ctype_tolower(*p2));
 		if (res != 0)
 			return res;
 		p1++;
 		p2++;
 	}
 
-	return faux_str_cmp_chars(faux_ctype_tolower(*p1),
-		faux_ctype_tolower(*p2));
+	return faux_str_cmp_chars(
+		faux_ctype_tolower(*p1), faux_ctype_tolower(*p2));
 }
 
 
@@ -534,7 +534,6 @@ char *lub_string_encode(const char *string, const char *escape_chars)
 */
 
 
-
 // TODO: Is it needed?
 /*--------------------------------------------------------- */
 /*

+ 1 - 1
faux/sysdb/sysdb.c

@@ -111,7 +111,7 @@ struct group *faux_sysdb_getgrnam(const char *name) {
 
 	long int size;
 	char *buf;
-	struct group *grbuf; 
+	struct group *grbuf;
 	struct group *gr = NULL;
 	int res = 0;