Skip to content

Commit b76a6af

Browse files
committed
chore: better style for clang-format
1 parent b12ba4b commit b76a6af

File tree

5 files changed

+38
-41
lines changed

5 files changed

+38
-41
lines changed

.clang-format

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ AlwaysBreakAfterReturnType: None
1212
AlwaysBreakBeforeMultilineStrings: 'false'
1313
BinPackArguments: 'true'
1414
BinPackParameters: 'true'
15-
ColumnLimit: '1000'
15+
ColumnLimit: 1000
1616
IndentCaseLabels: 'true'
1717
IndentPPDirectives: AfterHash
18-
IndentWidth: '2'
19-
MaxEmptyLinesToKeep: '1'
18+
IndentWidth: 2
19+
MaxEmptyLinesToKeep: 1
2020
PointerAlignment: Right
2121
SortIncludes: 'false'
2222
SpaceBeforeAssignmentOperators: 'true'
2323
SpaceBeforeParens: ControlStatements
2424
SpaceInEmptyParentheses: 'false'
2525
SpacesBeforeTrailingComments: 1
26-
TabWidth: '4'
26+
TabWidth: 2
27+
BracedInitializerIndentWidth: 2
2728
UseTab: Never

src/build.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ static int plmustache_get_variable(void *userdata, const char *name, struct must
5858
return MUSTACH_OK;
5959
}
6060

61-
struct mustach_itf plmustache_mustach_itf = {.enter = plmustache_section_enter, .next = plmustache_section_next, .leave = plmustache_section_leave, .get = plmustache_get_variable};
61+
struct mustach_itf plmustache_mustach_itf = {
62+
63+
.enter = plmustache_section_enter,
64+
.next = plmustache_section_next,
65+
.leave = plmustache_section_leave,
66+
.get = plmustache_get_variable
67+
68+
};
6269

6370
static char *datum_to_cstring(Datum datum, Oid typeoid, plmustache_obs_handler observer) {
6471
HeapTuple typetuple = SearchSysCache(TYPEOID, ObjectIdGetDatum(typeoid), 0, 0, 0);

src/observation.c

+19-28
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,27 @@
33

44
#include <mustach/mustach.h>
55

6-
static const char *mustach_strerror(int mustach_code) {
7-
switch (mustach_code) {
8-
case MUSTACH_ERROR_SYSTEM:
9-
return "system error";
10-
case MUSTACH_ERROR_UNEXPECTED_END:
11-
return "unexpected end";
12-
case MUSTACH_ERROR_EMPTY_TAG:
13-
return "empty tag";
14-
case MUSTACH_ERROR_TAG_TOO_LONG:
15-
return "tag is too long";
16-
case MUSTACH_ERROR_BAD_SEPARATORS:
17-
return "bad separators";
18-
case MUSTACH_ERROR_TOO_DEEP:
19-
return "too deep";
20-
case MUSTACH_ERROR_CLOSING:
21-
return "closing";
22-
case MUSTACH_ERROR_BAD_UNESCAPE_TAG:
23-
return "bad unescape tag";
24-
case MUSTACH_ERROR_INVALID_ITF:
25-
return "invalid itf";
26-
case MUSTACH_ERROR_ITEM_NOT_FOUND:
27-
return "item not found";
28-
case MUSTACH_ERROR_PARTIAL_NOT_FOUND:
29-
return "partial not found";
30-
case MUSTACH_ERROR_UNDEFINED_TAG:
31-
return "undefined tag";
32-
default:
33-
return "unknown";
6+
// clang-format off
7+
static const char *mustach_strerror(int mustach_code){
8+
switch(mustach_code){
9+
10+
case MUSTACH_ERROR_SYSTEM : return "system error";
11+
case MUSTACH_ERROR_UNEXPECTED_END : return "unexpected end";
12+
case MUSTACH_ERROR_EMPTY_TAG : return "empty tag";
13+
case MUSTACH_ERROR_TAG_TOO_LONG : return "tag is too long";
14+
case MUSTACH_ERROR_BAD_SEPARATORS : return "bad separators";
15+
case MUSTACH_ERROR_TOO_DEEP : return "too deep";
16+
case MUSTACH_ERROR_CLOSING : return "closing";
17+
case MUSTACH_ERROR_BAD_UNESCAPE_TAG : return "bad unescape tag";
18+
case MUSTACH_ERROR_INVALID_ITF : return "invalid itf";
19+
case MUSTACH_ERROR_ITEM_NOT_FOUND : return "item not found";
20+
case MUSTACH_ERROR_PARTIAL_NOT_FOUND: return "partial not found";
21+
case MUSTACH_ERROR_UNDEFINED_TAG : return "undefined tag";
22+
default : return "unknown";
23+
3424
}
3525
}
26+
// clang-format on
3627

3728
void ereporter(plmustache_observation o) {
3829
switch (o.obs_type) {

src/observation.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
#define OBSERVATION_H
33

44
typedef enum {
5+
56
ERROR_NO_OID = 1,
67
ERROR_NO_RETTYPE,
78
ERROR_NO_SRC,
89
ERROR_NOT_ONLY_IN_PARAMS,
910
ERROR_NO_TEXT_RET,
1011
ERROR_UNNAMED_PARAMS,
11-
ERROR_PARAM_IMPLICIT_ITERATOR
12-
13-
,
12+
ERROR_PARAM_IMPLICIT_ITERATOR,
1413
ERROR_NO_DO_BLOCKS,
1514
ERROR_NO_TYPE_OID,
1615
ERROR_MUSTACH
16+
1717
} plmustache_observation_type;
1818

1919
typedef struct {

src/plmustache.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ PG_FUNCTION_INFO_V1(plmustache_handler);
1010
Datum plmustache_handler(PG_FUNCTION_ARGS) {
1111
Oid function_oid = fcinfo->flinfo->fn_oid;
1212

13-
char *mustache_result;
14-
int mustach_code;
15-
size_t mustache_result_size;
16-
1713
plmustache_call_info call_info = build_call_info(function_oid, fcinfo, ereporter);
1814

1915
plmustache_ctx ctx = build_mustache_ctx(call_info, fcinfo->args);
2016

21-
mustach_code = mustach_mem(ctx.template, 0, &plmustache_mustach_itf, &ctx, 0, &mustache_result, &mustache_result_size);
17+
char *mustache_result;
18+
size_t mustache_result_size;
19+
int mustach_code = mustach_mem(ctx.template, 0, &plmustache_mustach_itf, &ctx, 0, &mustache_result, &mustache_result_size);
2220

2321
if (mustach_code < 0) {
2422
ereporter((plmustache_observation){ERROR_MUSTACH, .error_mustach_code = mustach_code});

0 commit comments

Comments
 (0)