Skip to content

Commit

Permalink
Use clang-format, llvm style, for formatting.
Browse files Browse the repository at this point in the history
* Reformatted all source files.
* Added 'format' target to Makefile.
* Removed 'astyle' target.
* Updated .editorconfig.
  • Loading branch information
jgm committed Jul 28, 2015
1 parent aca7161 commit 62cb38b
Show file tree
Hide file tree
Showing 35 changed files with 33,323 additions and 27,175 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Expand Up @@ -9,8 +9,8 @@ insert_final_newline = true

[*.{c,h}]
trim_trailing_whitespace = true
indent_style = tab
indent_size = 8
indent_style = space
indent_size = 2

[Makefile]
trim_trailing_whitespace = true
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Expand Up @@ -20,7 +20,7 @@ RELEASE?=CommonMark-$(VERSION)
INSTALL_PREFIX?=/usr/local
CLANG_CHECK?=clang-check

.PHONY: all cmake_build spec leakcheck clean fuzztest dingus upload test update-site upload-site debug ubsan asan mingw archive bench astyle update-spec afl clang-check
.PHONY: all cmake_build spec leakcheck clean fuzztest dingus upload test update-site upload-site debug ubsan asan mingw archive bench format update-spec afl clang-check

all: cmake_build man/man3/cmark.3

Expand Down Expand Up @@ -115,6 +115,7 @@ $(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re
esac
re2c --case-insensitive -b -i --no-generation-date -8 \
--encoding-policy substitute -o $@ $<
clang-format -style llvm -i $@

# We include entities.inc in the repository, so normally this
# doesn't need to be regenerated:
Expand Down Expand Up @@ -167,9 +168,8 @@ bench: $(BENCHFILE)
done \
} 2>&1 | grep 'real' | awk '{print $$2}' | python3 'bench/stats.py'

astyle:
astyle --style=linux -t -p -r 'src/*.c' --exclude=scanners.c
astyle --style=linux -t -p -r 'src/*.h' --exclude=html_unescape.h
format:
clang-format -style llvm -i src/*.c src/*.h

operf: $(CMARK)
operf $< < $(BENCHINP) > /dev/null
Expand Down
32 changes: 16 additions & 16 deletions man/man3/cmark.3
@@ -1,4 +1,4 @@
.TH cmark 3 "July 13, 2015" "LOCAL" "Library Functions Manual"
.TH cmark 3 "July 27, 2015" "LOCAL" "Library Functions Manual"
.SH
NAME
.PP
Expand All @@ -24,7 +24,7 @@ Node Structure
Creating and Destroying Nodes

.PP
\fIcmark_node*\f[] \fBcmark_node_new\f[](\fIcmark_node_type type\f[])
\fIcmark_node *\f[] \fBcmark_node_new\f[](\fIcmark_node_type type\f[])

.PP
Creates a new node of type \f[I]type\f[]. Note that the node may have
Expand All @@ -41,34 +41,34 @@ Frees the memory allocated for a node.
Tree Traversal

.PP
\fIcmark_node*\f[] \fBcmark_node_next\f[](\fIcmark_node *node\f[])
\fIcmark_node *\f[] \fBcmark_node_next\f[](\fIcmark_node *node\f[])

.PP
Returns the next node in the sequence after \f[I]node\f[], or NULL if
there is none.

.PP
\fIcmark_node*\f[] \fBcmark_node_previous\f[](\fIcmark_node *node\f[])
\fIcmark_node *\f[] \fBcmark_node_previous\f[](\fIcmark_node *node\f[])

.PP
Returns the previous node in the sequence after \f[I]node\f[], or NULL
if there is none.

.PP
\fIcmark_node*\f[] \fBcmark_node_parent\f[](\fIcmark_node *node\f[])
\fIcmark_node *\f[] \fBcmark_node_parent\f[](\fIcmark_node *node\f[])

.PP
Returns the parent of \f[I]node\f[], or NULL if there is none.

.PP
\fIcmark_node*\f[] \fBcmark_node_first_child\f[](\fIcmark_node *node\f[])
\fIcmark_node *\f[] \fBcmark_node_first_child\f[](\fIcmark_node *node\f[])

.PP
Returns the first child of \f[I]node\f[], or NULL if \f[I]node\f[] has
no children.

.PP
\fIcmark_node*\f[] \fBcmark_node_last_child\f[](\fIcmark_node *node\f[])
\fIcmark_node *\f[] \fBcmark_node_last_child\f[](\fIcmark_node *node\f[])

.PP
Returns the last child of \f[I]node\f[], or NULL if \f[I]node\f[] has no
Expand Down Expand Up @@ -130,7 +130,7 @@ Nodes must only be modified after an \f[C]EXIT\f[] event, or an
\f[C]ENTER\f[] event for leaf nodes.

.PP
\fIcmark_iter*\f[] \fBcmark_iter_new\f[](\fIcmark_node *root\f[])
\fIcmark_iter *\f[] \fBcmark_iter_new\f[](\fIcmark_node *root\f[])

.PP
Creates a new iterator starting at \f[I]root\f[]. The current node and
Expand All @@ -152,7 +152,7 @@ Advances to the next node and returns the event type
\f[C]CMARK_EVENT_DONE\f[]).

.PP
\fIcmark_node*\f[] \fBcmark_iter_get_node\f[](\fIcmark_iter *iter\f[])
\fIcmark_node *\f[] \fBcmark_iter_get_node\f[](\fIcmark_iter *iter\f[])

.PP
Returns the current node.
Expand All @@ -164,7 +164,7 @@ Returns the current node.
Returns the current event type.

.PP
\fIcmark_node*\f[] \fBcmark_iter_get_root\f[](\fIcmark_iter *iter\f[])
\fIcmark_node *\f[] \fBcmark_iter_get_root\f[](\fIcmark_iter *iter\f[])

.PP
Returns the root node.
Expand All @@ -181,7 +181,7 @@ descendant of the root node or the root node itself.
Accessors

.PP
\fIvoid*\f[] \fBcmark_node_get_user_data\f[](\fIcmark_node *node\f[])
\fIvoid *\f[] \fBcmark_node_get_user_data\f[](\fIcmark_node *node\f[])

.PP
Returns the user data of \f[I]node\f[].
Expand All @@ -200,14 +200,14 @@ failure.
Returns the type of \f[I]node\f[], or \f[C]CMARK_NODE_NONE\f[] on error.

.PP
\fIconst char*\f[] \fBcmark_node_get_type_string\f[](\fIcmark_node *node\f[])
\fIconst char *\f[] \fBcmark_node_get_type_string\f[](\fIcmark_node *node\f[])

.PP
Like \f[I]cmark_node_get_type\f[], but returns a string representation
of the type, or \f[C]"<unknown>"\f[].

.PP
\fIconst char*\f[] \fBcmark_node_get_literal\f[](\fIcmark_node *node\f[])
\fIconst char *\f[] \fBcmark_node_get_literal\f[](\fIcmark_node *node\f[])

.PP
Returns the string contents of \f[I]node\f[], or NULL if none.
Expand Down Expand Up @@ -288,7 +288,7 @@ Returns 1 if \f[I]node\f[] is a tight list, 0 otherwise.
Sets the "tightness" of a list. Returns 1 on success, 0 on failure.

.PP
\fIconst char*\f[] \fBcmark_node_get_fence_info\f[](\fIcmark_node *node\f[])
\fIconst char *\f[] \fBcmark_node_get_fence_info\f[](\fIcmark_node *node\f[])

.PP
Returns the info string from a fenced code block, or NULL if none.
Expand All @@ -301,7 +301,7 @@ Sets the info string in a fenced code block, returning 1 on success and
0 on failure.

.PP
\fIconst char*\f[] \fBcmark_node_get_url\f[](\fIcmark_node *node\f[])
\fIconst char *\f[] \fBcmark_node_get_url\f[](\fIcmark_node *node\f[])

.PP
Gets the URL of a link or image \f[I]node\f[], or NULL if none.
Expand All @@ -314,7 +314,7 @@ Sets the URL of a link or image \f[I]node\f[]. Returns 1 on success, 0
on failure.

.PP
\fIconst char*\f[] \fBcmark_node_get_title\f[](\fIcmark_node *node\f[])
\fIconst char *\f[] \fBcmark_node_get_title\f[](\fIcmark_node *node\f[])

.PP
Gets the title of a link or image \f[I]node\f[], or NULL if none.
Expand Down
16 changes: 8 additions & 8 deletions src/bench.h
Expand Up @@ -9,15 +9,15 @@ float _cmark_start_time;
float _cmark_end_time;
float _cmark_save_time;

#define start_timer() \
_cmark_save_time = _cmark_start_time; \
_cmark_start_time = (float)clock()/CLOCKS_PER_SEC
#define start_timer() \
_cmark_save_time = _cmark_start_time; \
_cmark_start_time = (float)clock() / CLOCKS_PER_SEC

#define end_timer(M) \
_cmark_end_time = (float)clock()/CLOCKS_PER_SEC; \
fprintf(stderr, "[TIME] (%s:%d) %4.f ns " M "\n", __FILE__, \
__LINE__, (_cmark_end_time - _cmark_start_time) * 1000000); \
_cmark_start_time = _cmark_save_time;
#define end_timer(M) \
_cmark_end_time = (float)clock() / CLOCKS_PER_SEC; \
fprintf(stderr, "[TIME] (%s:%d) %4.f ns " M "\n", __FILE__, __LINE__, \
(_cmark_end_time - _cmark_start_time) * 1000000); \
_cmark_start_time = _cmark_save_time;

#else
#define start_timer()
Expand Down

0 comments on commit 62cb38b

Please sign in to comment.