From fe25b6d06401b0a523e15a896831720c488bd5ce Mon Sep 17 00:00:00 2001 From: Ben Gardner Date: Sat, 17 Oct 2009 13:13:55 -0500 Subject: [PATCH] Import r1644 from subversion --- .gitignore | 21 + AUTHORS | 1 + BUGS | 67 + COPYING | 340 + HELP | 56 + INSTALL | 229 + Makefile.am | 18 + Makefile.in | 716 ++ NEWS | 2 + README | 56 + aclocal.m4 | 908 ++ autogen.sh | 4 + config.guess | 1400 +++ config.sub | 1469 ++++ configure | 7519 +++++++++++++++++ configure.in | 50 + do-c.sh | 3 + do-d.sh | 3 + documentation/align-thresholds.txt | 218 + documentation/example.c | 117 + documentation/goals.txt | 24 + documentation/htdocs/ChangeLog | 745 ++ documentation/htdocs/ben.cfg.txt | 114 + documentation/htdocs/config.txt | 915 ++ documentation/htdocs/configuration.txt | 69 + documentation/htdocs/default.cfg | 1276 +++ documentation/htdocs/examples/c-1.in.c | 1234 +++ documentation/htdocs/examples/c-1.out.c | 1245 +++ documentation/htdocs/examples/example.c | 117 + documentation/htdocs/images/linuxlinks.gif | Bin 0 -> 462 bytes documentation/htdocs/index.html | 172 + documentation/htdocs/linux.cfg.txt | 94 + documentation/htdocs/project-support.jpg | Bin 0 -> 3788 bytes documentation/htdocs/uncrustify.css | 63 + documentation/htdocs/uncrustify.html | 29 + documentation/overview.odt | Bin 0 -> 16651 bytes documentation/paren_stack.txt | 219 + documentation/theory.txt | 129 + etc/amxmodx.cfg | 209 + etc/ben.cfg | 1222 +++ etc/ben2.cfg | 85 + etc/d.cfg | 85 + etc/defaults.cfg | 1276 +++ etc/dofiles.sh | 19 + etc/gnu-indent.cfg | 84 + etc/klaus.cfg | 501 ++ etc/kr-indent.cfg | 84 + etc/linux-indent.cfg | 92 + etc/linux.cfg | 122 + etc/mono.cfg | 88 + etc/objc.cfg | 135 + etc/types.txt | 26 + etc/uncrust-files.sh | 19 + etc/xsupplicant.cfg | 84 + extras.vpj | 137 + install-sh | 519 ++ make_token_names.sh | 35 + man/Makefile.am | 8 + man/Makefile.in | 512 ++ man/uncrustify.1 | 154 + missing | 367 + release-steps.txt | 74 + run_tests.sh | 8 + scripts/check_options.py | 60 + scripts/cmpcfg.pl | 101 + scripts/punc.py | 110 + scripts/tokenize.py | 315 + scripts/update-defaults.sh | 4 + src/ChunkStack.cpp | 174 + src/ChunkStack.h | 80 + src/ListManager.h | 203 + src/Makefile.am | 32 + src/Makefile.in | 658 ++ src/align.cpp | 1801 ++++ src/align_stack.cpp | 467 + src/align_stack.h | 61 + src/args.cpp | 270 + src/args.h | 115 + src/backup.cpp | 161 + src/backup.h | 56 + src/base_types.h | 60 + src/brace_cleanup.cpp | 1007 +++ src/braces.cpp | 1061 +++ src/char_table.h | 68 + src/chunk_list.cpp | 649 ++ src/chunk_list.h | 275 + src/combine.cpp | 3744 ++++++++ src/config.h | 109 + src/config.h.in | 108 + src/d.tokenize.cpp | 122 + src/defines.cpp | 416 + src/detect.cpp | 486 ++ src/indent.cpp | 1727 ++++ src/keywords.cpp | 558 ++ src/lang_pawn.cpp | 504 ++ src/log_levels.h | 93 + src/logger.cpp | 374 + src/logger.h | 153 + src/logmask.cpp | 152 + src/logmask.h | 90 + src/md5.cpp | 326 + src/md5.h | 39 + src/newlines.cpp | 2425 ++++++ src/options.cpp | 1742 ++++ src/options.h | 591 ++ src/output.cpp | 1479 ++++ src/parens.cpp | 179 + src/parse_frame.cpp | 287 + src/prototypes.h | 323 + src/punctuators.cpp | 154 + src/punctuators.h | 78 + src/semicolons.cpp | 117 + src/sorting.cpp | 169 + src/space.cpp | 1547 ++++ src/token_enum.h | 283 + src/token_names.h | 237 + src/tokenize.cpp | 1202 +++ src/tokenize_cleanup.cpp | 744 ++ src/unc_ctype.h | 79 + src/uncrustify.cpp | 1686 ++++ src/uncrustify_types.h | 343 + src/uncrustify_version.h | 14 + src/universalindentgui.cpp | 256 + src/width.cpp | 561 ++ tests/c-sharp.test | 26 + tests/c.test | 258 + tests/config/1liner-no-split.cfg | 523 ++ tests/config/1liner-split.cfg | 523 ++ .../config/add_long_closebrace_comment_1.cfg | 3 + tests/config/al.cfg | 924 ++ tests/config/align-1.cfg | 94 + tests/config/align-2.cfg | 94 + tests/config/align-3.cfg | 94 + tests/config/align_attr.cfg | 4 + tests/config/align_fcall-2.cfg | 5 + tests/config/align_fcall.cfg | 4 + tests/config/align_right_cmt_gap-1.cfg | 5 + tests/config/align_right_cmt_gap-2.cfg | 5 + tests/config/align_typedef_func-0.cfg | 6 + tests/config/align_typedef_func-1.cfg | 6 + tests/config/align_typedef_func-2.cfg | 8 + tests/config/amxmodx.cfg | 214 + tests/config/avalon.cfg | 382 + tests/config/avalon2.cfg | 385 + tests/config/avalon3.cfg | 506 ++ tests/config/avalon4.cfg | 676 ++ tests/config/ben.cfg | 214 + tests/config/blc-1.cfg | 21 + tests/config/bool-pos-eol.cfg | 18 + tests/config/bool-pos-sol.cfg | 18 + tests/config/brace-allman.cfg | 27 + tests/config/brace-banner.cfg | 40 + tests/config/brace-gnu.cfg | 42 + tests/config/brace-kr-br.cfg | 43 + tests/config/brace-kr.cfg | 40 + tests/config/brace-remove-2.cfg | 12 + tests/config/brace-remove-all.cfg | 13 + tests/config/brace-ws.cfg | 29 + tests/config/brace-ws2.cfg | 30 + tests/config/byref-center.cfg | 13 + tests/config/byref-left.cfg | 13 + tests/config/byref-right.cfg | 13 + tests/config/case-1.cfg | 17 + tests/config/case-2.cfg | 19 + tests/config/case-3.cfg | 17 + tests/config/cast-sp-a.cfg | 194 + tests/config/cast-sp-r.cfg | 194 + tests/config/cast-type.cfg | 198 + tests/config/cast-types.txt | 28 + tests/config/cgal.cfg | 213 + tests/config/clark.cfg | 506 ++ tests/config/class-colon-pos-eol-add.cfg | 21 + tests/config/class-colon-pos-eol.cfg | 18 + tests/config/class-colon-pos-sol-add.cfg | 22 + tests/config/class-colon-pos-sol.cfg | 18 + tests/config/class-header.h | 4 + tests/config/class-nl_func-add.cfg | 23 + tests/config/class-nl_func-del.cfg | 24 + tests/config/cmt_indent-1.cfg | 6 + tests/config/cmt_indent-2.cfg | 7 + tests/config/cmt_indent-3.cfg | 8 + tests/config/cmt_multi-1.cfg | 3 + tests/config/cmt_multi-2.cfg | 3 + tests/config/cmt_nl_end.cfg | 7 + tests/config/cmt_right.cfg | 2 + tests/config/comment-align.cfg | 4 + tests/config/cond-1.cfg | 5 + tests/config/cond-2.cfg | 5 + tests/config/const_throw.cfg | 8 + tests/config/cpp_to_c-1.cfg | 20 + tests/config/cpp_to_c-2.cfg | 18 + tests/config/cpp_to_c-3.cfg | 20 + tests/config/cs_generics.cfg | 6 + tests/config/cu.cfg | 180 + tests/config/custom-open.cfg | 25 + tests/config/custom-open2.cfg | 25 + tests/config/custom_types_ssl.cfg | 126 + tests/config/d-tst2.cfg | 103 + tests/config/d.cfg | 98 + tests/config/d2.cfg | 111 + tests/config/d3.cfg | 95 + tests/config/d3a.cfg | 100 + tests/config/del_semicolon.cfg | 8 + tests/config/delete.cfg | 3 + tests/config/else-if-1.cfg | 5 + tests/config/else-if-2.cfg | 5 + tests/config/empty_body.cfg | 15 + tests/config/endif.cfg | 88 + tests/config/file-header.h | 6 + tests/config/file_footer.txt | 6 + tests/config/file_header.txt | 7 + tests/config/func-def-1.cfg | 21 + tests/config/func-def-2.cfg | 21 + tests/config/func-def-3.cfg | 22 + tests/config/func-header.h | 5 + tests/config/func-header2.h | 6 + tests/config/func_call_user.cfg | 927 ++ tests/config/func_wrap1.cfg | 3 + tests/config/func_wrap2.cfg | 3 + tests/config/function_header.txt | 9 + tests/config/ger.cfg | 360 + tests/config/getset.cfg | 92 + tests/config/if_chain.cfg | 116 + tests/config/indent-1.cfg | 12 + tests/config/indent.cfg | 14 + tests/config/indent_func_call_param.cfg | 10 + tests/config/indent_func_def_param.cfg | 10 + tests/config/indent_func_param.cfg | 8 + tests/config/indent_func_proto_param.cfg | 8 + tests/config/indent_namespace-f.cfg | 6 + tests/config/indent_namespace-t.cfg | 6 + tests/config/indent_paren_close-0.cfg | 8 + tests/config/indent_paren_close-1.cfg | 17 + tests/config/indent_paren_close-2.cfg | 8 + tests/config/indent_var_def.cfg | 1111 +++ tests/config/kw_subst.cfg | 9 + tests/config/kw_subst2.cfg | 5 + tests/config/kw_subst3.cfg | 972 +++ tests/config/long_namespace.cfg | 2 + tests/config/misc6.cfg | 4 + tests/config/mod-paren.cfg | 517 ++ tests/config/mod-paren2.cfg | 517 ++ tests/config/mod_case_brace_add.cfg | 1179 +++ tests/config/mod_case_brace_rm.cfg | 1179 +++ tests/config/mono.cfg | 89 + tests/config/multi.cfg | 3 + tests/config/newline_after_endif.cfg | 160 + tests/config/nl-comment.cfg | 105 + tests/config/nl_access_spec.cfg | 8 + tests/config/nl_after_func_body-2.cfg | 16 + tests/config/nl_after_func_body.cfg | 13 + tests/config/nl_assign1.cfg | 9 + tests/config/nl_assign2.cfg | 9 + tests/config/nl_brace_brace-a.cfg | 3 + tests/config/nl_brace_test.cfg | 1137 +++ tests/config/nl_class-a.cfg | 7 + tests/config/nl_class-r.cfg | 7 + tests/config/nl_create_one_liner.cfg | 8 + tests/config/nl_ds_struct_enum-1.cfg | 7 + tests/config/nl_ds_struct_enum-2.cfg | 8 + tests/config/nl_endif.cfg | 160 + tests/config/nl_func_decl_1.cfg | 11 + tests/config/nl_func_decl_2.cfg | 13 + tests/config/nl_func_scope_name.cfg | 7 + tests/config/nl_func_type_name_class.cfg | 8 + tests/config/nl_func_type_name_force.cfg | 8 + tests/config/nl_func_type_name_remove.cfg | 8 + tests/config/nl_namespace-a.cfg | 7 + tests/config/nl_namespace-r.cfg | 7 + tests/config/nl_semicolon.cfg | 101 + tests/config/nl_template_class-force.cfg | 25 + tests/config/nl_template_class-remove.cfg | 27 + tests/config/nl_try-a.cfg | 9 + tests/config/obj-c.cfg | 213 + tests/config/oc-split.cfg | 2 + tests/config/op-space-force.cfg | 19 + tests/config/op-space-remove.cfg | 18 + tests/config/pascal_ptr.cfg | 15 + tests/config/pawn-escape.cfg | 50 + tests/config/pawn.cfg | 50 + tests/config/pos_compare-eol.cfg | 2 + tests/config/pos_compare-sol.cfg | 2 + tests/config/pos_conditional-eol.cfg | 2 + tests/config/pos_conditional-sol.cfg | 2 + tests/config/pp-indent-1.cfg | 14 + tests/config/pp-indent-2.cfg | 15 + tests/config/pp-indent-3.cfg | 14 + tests/config/pp-space.cfg | 7 + tests/config/pp_define_at_level-1.cfg | 7 + tests/config/pp_if_indent-0.cfg | 7 + tests/config/pp_if_indent-1.cfg | 7 + tests/config/pp_if_indent-2.cfg | 7 + tests/config/pp_if_indent-3.cfg | 7 + tests/config/pp_ret.cfg | 757 ++ tests/config/preproc-cleanup.cfg | 123 + tests/config/ptr_star-1.cfg | 10 + tests/config/ptr_star-2.cfg | 10 + tests/config/ptr_star-3.cfg | 10 + tests/config/region-0.cfg | 7 + tests/config/region-1.cfg | 7 + tests/config/region-2.cfg | 7 + tests/config/region-3.cfg | 7 + tests/config/return-1.cfg | 11 + tests/config/return-2.cfg | 11 + tests/config/return-3.cfg | 11 + tests/config/return-4.cfg | 11 + tests/config/sef.cfg | 253 + tests/config/sim.cfg | 680 ++ tests/config/sort_imports.cfg | 5 + tests/config/sp-for-semi.cfg | 8 + tests/config/sp_after_cast.cfg | 194 + tests/config/sp_after_oc_at_sel_add.cfg | 5 + tests/config/sp_after_oc_at_sel_force.cfg | 5 + tests/config/sp_after_oc_at_sel_remove.cfg | 5 + tests/config/sp_after_oc_return_type_add.cfg | 5 + .../config/sp_after_oc_return_type_force.cfg | 5 + .../config/sp_after_oc_return_type_remove.cfg | 5 + tests/config/sp_before_ellipsis-f.cfg | 3 + tests/config/sp_cmt_cpp_start_add.cfg | 3 + tests/config/sp_cmt_cpp_start_force.cfg | 3 + tests/config/sp_cmt_cpp_start_remove.cfg | 3 + tests/config/sp_throw_paren-f.cfg | 3 + tests/config/sp_throw_paren-r.cfg | 3 + tests/config/star_pos-0.cfg | 28 + tests/config/star_pos-1.cfg | 28 + tests/config/star_pos-2.cfg | 28 + tests/config/tcf.cfg | 5 + tests/config/template4.cfg | 2 + tests/config/template_sp-force.cfg | 27 + tests/config/template_sp-remove.cfg | 27 + tests/config/type_wrap.cfg | 8 + tests/config/var_def_gap.cfg | 19 + tests/config/wessex.cfg | 676 ++ tests/config/width-2.cfg | 39 + tests/config/width-3.cfg | 33 + tests/config/width.cfg | 33 + tests/config/xml-str.cfg | 98 + tests/cpp.test | 153 + tests/d.test | 33 + tests/difftest.sh | 53 + tests/ecma.test | 9 + tests/embed.c | 45 + tests/fixtest.sh | 40 + tests/input/align_fcall.cpp | 7 + tests/input/c/add_long_comment.c | 36 + tests/input/c/align-equ.c | 31 + tests/input/c/align-proto-vars.c | 12 + tests/input/c/align-proto.c | 4 + tests/input/c/align-string.c | 14 + tests/input/c/align-struct-init.c | 48 + tests/input/c/align-typedef.c | 11 + tests/input/c/align-var.c | 46 + tests/input/c/align_attr.c | 4 + tests/input/c/beautifier-off.c | 32 + tests/input/c/bits.c | 7 + tests/input/c/bool-pos.c | 52 + tests/input/c/brace-remove.c | 65 + tests/input/c/brace-remove2.c | 52 + tests/input/c/brace.c | 13 + tests/input/c/braces-2.c | 14 + tests/input/c/braces-3.c | 9 + tests/input/c/braces-4.c | 12 + tests/input/c/braces-5.c | 20 + tests/input/c/braces.c | 79 + tests/input/c/bsnl.c | 5 + tests/input/c/bugs-1.c | 52 + tests/input/c/bugs-2.c | 22 + tests/input/c/bugs-3.c | 48 + tests/input/c/bugs-4.c | 26 + tests/input/c/bugs-5.c | 13 + tests/input/c/bugs-6.c | 19 + tests/input/c/bugs-7.c | 25 + tests/input/c/bugs-8.c | 7 + tests/input/c/bugs.c | 35 + tests/input/c/case.c | 69 + tests/input/c/casts.c | 89 + tests/input/c/cmt-align.c | 20 + tests/input/c/cmt_multi.c | 17 + tests/input/c/cmt_nl_end.c | 12 + tests/input/c/cmt_right_align.c | 47 + tests/input/c/code_width.c | 42 + tests/input/c/colon-asm.c | 19 + tests/input/c/comment-convert.c | 27 + tests/input/c/comment-indent.c | 40 + tests/input/c/cond.c | 10 + tests/input/c/custom_types_ssl.c | 134 + tests/input/c/define-if-indent.c | 9 + tests/input/c/deref.c | 14 + tests/input/c/directfb.h | 2994 +++++++ tests/input/c/dos.c | 33 + tests/input/c/else-if.c | 29 + tests/input/c/empty-for.c | 6 + tests/input/c/endif.c | 30 + tests/input/c/enum-struct-init.c | 31 + tests/input/c/fcn_indent.c | 26 + tests/input/c/fcn_type.c | 36 + tests/input/c/for-space.c | 17 + tests/input/c/func_call_user.c | 7 + tests/input/c/func_param.c | 12 + tests/input/c/func_wrap.c | 3 + tests/input/c/funcfunc.c | 5 + tests/input/c/function-def.c | 24 + tests/input/c/global-vars.c | 7 + tests/input/c/hello.c | 13 + tests/input/c/i2c-core.c | 1234 +++ tests/input/c/if_chain.c | 70 + tests/input/c/ifdef-indent.c | 35 + tests/input/c/ifdef-nest.c | 15 + tests/input/c/include_define.h | 5 + tests/input/c/indent-assign.c | 13 + tests/input/c/indent.cpp | 1084 +++ tests/input/c/kw_subst.c | 22 + tests/input/c/mac.c | 1 + tests/input/c/minus-minus.c | 33 + tests/input/c/misc.c | 32 + tests/input/c/mod-paren.c | 58 + tests/input/c/mod_case_brace.c | 57 + tests/input/c/multi.h | 12 + tests/input/c/newline_after_endif.c | 53 + tests/input/c/nl-comment.c | 32 + tests/input/c/nl-cont.c | 16 + tests/input/c/nl-cont2.c | 16 + tests/input/c/nl-semicolon.c | 21 + tests/input/c/nl-ver-def.c | 9 + tests/input/c/nl_assign.c | 19 + tests/input/c/nl_create_one_liner.c | 17 + tests/input/c/nl_ds_struct_enum.c | 21 + tests/input/c/nl_endif.c | 13 + tests/input/c/nl_proto_endif.c | 10 + tests/input/c/nl_return_expr.c | 23 + tests/input/c/one-liner-init.c | 16 + tests/input/c/output.cpp | 657 ++ tests/input/c/paren-indent.c | 46 + tests/input/c/paren_indent.c | 12 + tests/input/c/pascal_ptr.c | 13 + tests/input/c/pos_compare.c | 11 + tests/input/c/pos_conditional.c | 14 + tests/input/c/pp-nest.c | 15 + tests/input/c/pp-space.c | 30 + tests/input/c/pp_concat_asn1.h | 296 + tests/input/c/pp_ret.c | 14 + tests/input/c/pragma.c | 13 + tests/input/c/preproc-if.c | 35 + tests/input/c/return-multi.c | 46 + tests/input/c/semicolons.c | 75 + tests/input/c/sort_include.c | 11 + tests/input/c/sp_cmt_cpp_start.c | 7 + tests/input/c/sp_embed_comment.c | 8 + tests/input/c/struct-brace.c | 17 + tests/input/c/switch-case.c | 117 + tests/input/c/switch.c | 29 + tests/input/c/t3.in.c | 10 + tests/input/c/type-cast.c | 14 + tests/input/c/type_wrap.c | 4 + tests/input/c/vb-do.c | 22 + tests/input/c/vb-pp.c | 35 + tests/input/c/vb-while.c | 41 + tests/input/c/xml.c | 9 + tests/input/cpp/Example.h | 10 + tests/input/cpp/Timestamp.h | 169 + tests/input/cpp/al.cpp | 28 + tests/input/cpp/align-func-params.cpp | 35 + tests/input/cpp/align-star-amp-pos.cpp | 47 + tests/input/cpp/align_constr.cpp | 16 + tests/input/cpp/align_fcall.cpp | 10 + tests/input/cpp/alt_tokens.cpp | 5 + tests/input/cpp/av.h | 49 + tests/input/cpp/bool.cpp | 11 + tests/input/cpp/byref.cpp | 41 + tests/input/cpp/class-addr.h | 11 + tests/input/cpp/class-init.cpp | 58 + tests/input/cpp/class.h | 52 + tests/input/cpp/cmt-reflow.cpp | 34 + tests/input/cpp/cmt_indent.cpp | 32 + tests/input/cpp/cmt_right.cpp | 26 + tests/input/cpp/comment-align.cpp | 34 + tests/input/cpp/const_throw.cpp | 8 + tests/input/cpp/constructor.cpp | 31 + tests/input/cpp/cout.cpp | 17 + tests/input/cpp/ctor-var.cpp | 4 + tests/input/cpp/custom-open-2.cpp | 46 + tests/input/cpp/custom-open.cpp | 26 + tests/input/cpp/delete.cpp | 10 + tests/input/cpp/deref.cpp | 15 + tests/input/cpp/exception.cpp | 33 + tests/input/cpp/extern_c.h | 35 + tests/input/cpp/for_long.cpp | 8 + tests/input/cpp/function-def.cpp | 64 + tests/input/cpp/goto.cpp | 11 + tests/input/cpp/indent-off.cpp | 21 + tests/input/cpp/indent_namespace.h | 32 + tests/input/cpp/indent_var_def.cpp | 7 + tests/input/cpp/init_align.h | 22 + tests/input/cpp/kw_subst.cpp | 29 + tests/input/cpp/kw_subst2.cpp | 33 + tests/input/cpp/long_namespace.cpp | 15 + tests/input/cpp/misc.cpp | 51 + tests/input/cpp/misc2.cpp | 59 + tests/input/cpp/misc3.cpp | 25 + tests/input/cpp/misc4.cpp | 28 + tests/input/cpp/misc5.cpp | 13 + tests/input/cpp/misc6.cpp | 3 + tests/input/cpp/nl-class.h | 59 + tests/input/cpp/nl-namespace.h | 15 + tests/input/cpp/nl_brace_brace.cpp | 18 + tests/input/cpp/nl_func.cpp | 23 + tests/input/cpp/nl_func_decl.cpp | 22 + tests/input/cpp/nl_func_scope_name.cpp | 2 + tests/input/cpp/nl_func_type_name.cpp | 42 + tests/input/cpp/operator.cpp | 71 + tests/input/cpp/pp-define-indent.cpp | 35 + tests/input/cpp/ptr-star.cpp | 34 + tests/input/cpp/qt-1.cpp | 18 + tests/input/cpp/region.cpp | 20 + tests/input/cpp/sef.cpp | 4 + tests/input/cpp/semicolons.cpp | 95 + tests/input/cpp/sim.h | 50 + tests/input/cpp/sp_throw_paren.cpp | 7 + tests/input/cpp/strings.cpp | 7 + tests/input/cpp/templ_class.h | 16 + tests/input/cpp/templates.cpp | 147 + tests/input/cpp/templates2.cpp | 54 + tests/input/cpp/templates3.cpp | 18 + tests/input/cpp/templates4.cpp | 17 + tests/input/cpp/try-catch-nl.cpp | 10 + tests/input/cpp/var_def_gap.cpp | 27 + tests/input/cpp/variadic-template.h | 10 + tests/input/cpp/wacky-template.cpp | 12 + tests/input/cs/generics.cs | 11 + tests/input/cs/getset.cs | 14 + tests/input/cs/gs.cs | 30 + tests/input/cs/region.cs | 20 + tests/input/cs/simple.cs | 114 + tests/input/cs/sort_using.cs | 18 + tests/input/cs/strings.cs | 8 + tests/input/cs/tcf.cs | 32 + tests/input/cs/unsafe.cs | 7 + tests/input/cs/var-member.cs | 24 + tests/input/d/HashMap.d | 1059 +++ tests/input/d/Lexer.d | 2335 +++++ tests/input/d/bug-indent.d | 17 + tests/input/d/casts.d | 13 + tests/input/d/delegate.d | 20 + tests/input/d/funcfunc.d | 5 + tests/input/d/imports.d | 8 + tests/input/d/numbers.d | 45 + tests/input/d/sort_import.d | 19 + tests/input/d/strings.d | 32 + tests/input/d/template.d | 25 + tests/input/d/tst01.d | 23 + tests/input/d/tst02.d | 30 + tests/input/d/tst03.d | 145 + tests/input/d/volatile-1.d | 10 + tests/input/d/volatile-2.d | 8 + tests/input/d/volatile-3.d | 7 + tests/input/d/volatile.d | 27 + tests/input/ecma/example-1.es | 10 + tests/input/oc/Declarations.h | 22 + tests/input/oc/Fraction.h | 14 + tests/input/oc/Fraction.m | 24 + tests/input/oc/exceptions.m | 15 + tests/input/oc/main.m | 21 + tests/input/oc/misc.m | 19 + tests/input/oc/oc-split.m | 10 + tests/input/oc/return_type.m | 36 + tests/input/oc/selector.m | 3 + tests/input/oc/sort_import.m | 11 + tests/input/oc/string.m | 11 + tests/input/pawn/comment.p | 38 + tests/input/pawn/crusty_ex-1.sma | 26 + tests/input/pawn/enum.pawn | 82 + tests/input/pawn/functions.pawn | 23 + tests/input/pawn/rpn_calc.pawn | 71 + tests/input/pawn/str-escape.p | 6 + tests/input/pawn/switch-vsemi.sma | 16 + tests/input/pawn/tags.pawn | 63 + tests/input/pawn/test1.pawn | 59 + tests/input/pawn/traffic.p | 28 + tests/input/pawn/unbraced.p | 10 + tests/input/sql/mysql.sqc | 43 + tests/input/sql/sta-select.sqc | 74 + tests/input/vala/advanced.vala | 26 + tests/input/vala/list.vala | 20 + tests/java.test | 8 + tests/objective-c.test | 26 + tests/output/c/00000-comment-indent.c | 40 + tests/output/c/00001-comment-indent.c | 40 + tests/output/c/00002-comment-indent.c | 40 + tests/output/c/00003-comment-indent.c | 47 + tests/output/c/00004-switch.c | 29 + tests/output/c/00005-cmt-align.c | 20 + tests/output/c/00006-comment-convert.c | 27 + tests/output/c/00007-comment-convert.c | 27 + tests/output/c/00008-comment-convert.c | 27 + tests/output/c/00009-comment-convert.c | 35 + tests/output/c/00010-braces.c | 101 + tests/output/c/00011-braces.c | 87 + tests/output/c/00012-braces.c | 73 + tests/output/c/00013-braces.c | 88 + tests/output/c/00014-braces.c | 75 + tests/output/c/00015-braces.c | 88 + tests/output/c/00016-braces.c | 88 + tests/output/c/00020-define-if-indent.c | 9 + tests/output/c/00050-brace-remove.c | 56 + tests/output/c/00051-brace-remove.c | 52 + tests/output/c/00052-brace-remove2.c | 43 + tests/output/c/00053-brace.c | 18 + tests/output/c/00054-if_chain.c | 70 + tests/output/c/00055-braces-2.c | 16 + tests/output/c/00060-braces-2.c | 16 + tests/output/c/00061-braces-3.c | 12 + tests/output/c/00062-braces-4.c | 16 + tests/output/c/00065-braces-5.c | 23 + tests/output/c/00066-vb-while.c | 52 + tests/output/c/00067-vb-do.c | 29 + tests/output/c/00068-bsnl.c | 5 + tests/output/c/00069-vb-pp.c | 49 + tests/output/c/00070-return-multi.c | 47 + tests/output/c/00071-include_define.h | 5 + tests/output/c/00072-align-proto.c | 4 + tests/output/c/00073-nl_proto_endif.c | 10 + tests/output/c/00081-else-if.c | 28 + tests/output/c/00082-else-if.c | 29 + tests/output/c/00091-cond.c | 10 + tests/output/c/00092-cond.c | 10 + tests/output/c/00101-bugs-1.c | 69 + tests/output/c/00102-bugs-2.c | 22 + tests/output/c/00103-bugs-3.c | 49 + tests/output/c/00104-bugs-4.c | 26 + tests/output/c/00105-bugs-5.c | 12 + tests/output/c/00106-bugs-6.c | 19 + tests/output/c/00107-bugs-7.c | 25 + tests/output/c/00108-bugs-8.c | 7 + tests/output/c/00110-misc.c | 42 + tests/output/c/00111-misc.c | 38 + tests/output/c/00120-sp_cmt_cpp_start.c | 7 + tests/output/c/00121-sp_cmt_cpp_start.c | 7 + tests/output/c/00122-sp_cmt_cpp_start.c | 7 + tests/output/c/00130-minus-minus.c | 33 + tests/output/c/00140-global-vars.c | 7 + tests/output/c/00141-deref.c | 13 + tests/output/c/00142-type-cast.c | 15 + tests/output/c/00143-t3.in.c | 10 + tests/output/c/00144-align-proto-vars.c | 12 + tests/output/c/00150-casts.c | 89 + tests/output/c/00151-casts.c | 89 + tests/output/c/00152-casts.c | 89 + tests/output/c/00153-casts.c | 89 + tests/output/c/00154-casts.c | 89 + tests/output/c/00160-fcn_indent.c | 26 + tests/output/c/00161-fcn_indent.c | 27 + tests/output/c/00162-fcn_indent.c | 28 + tests/output/c/00163-fcn_indent.c | 26 + tests/output/c/00170-beautifier-off.c | 32 + tests/output/c/00201-case.c | 73 + tests/output/c/00202-case.c | 73 + tests/output/c/00203-case.c | 73 + tests/output/c/00301-align-struct-init.c | 52 + tests/output/c/00302-one-liner-init.c | 29 + tests/output/c/00303-one-liner-init.c | 30 + tests/output/c/00304-one-liner-init.c | 14 + tests/output/c/00310-sp_embed_comment.c | 8 + tests/output/c/00401-align-equ.c | 31 + tests/output/c/00402-align-var.c | 47 + tests/output/c/00403-align-var.c | 47 + tests/output/c/00404-align-var.c | 47 + tests/output/c/00405-bits.c | 8 + tests/output/c/00411-align-typedef.c | 11 + tests/output/c/00412-align-typedef.c | 11 + tests/output/c/00413-align-typedef.c | 11 + tests/output/c/00414-align-typedef.c | 11 + tests/output/c/00421-nl_ds_struct_enum.c | 24 + tests/output/c/00422-nl_ds_struct_enum.c | 26 + tests/output/c/00430-paren-indent.c | 46 + tests/output/c/00431-paren-indent.c | 46 + tests/output/c/00432-paren-indent.c | 46 + tests/output/c/00501-bool-pos.c | 52 + tests/output/c/00502-bool-pos.c | 52 + tests/output/c/00503-pos_compare.c | 11 + tests/output/c/00504-pos_compare.c | 11 + tests/output/c/00505-pos_conditional.c | 14 + tests/output/c/00506-pos_conditional.c | 14 + tests/output/c/00600-dos.c | 33 + tests/output/c/00601-mac.c | 1 + tests/output/c/00611-pp-space.c | 30 + tests/output/c/00612-pp-space.c | 30 + tests/output/c/00613-pp-space.c | 30 + tests/output/c/00614-pp-space.c | 30 + tests/output/c/00615-pp-nest.c | 15 + tests/output/c/00620-indent-assign.c | 14 + tests/output/c/00621-nl_endif.c | 12 + tests/output/c/00631-nl_assign.c | 21 + tests/output/c/00632-nl_assign.c | 21 + tests/output/c/00701-function-def.c | 51 + tests/output/c/00702-function-def.c | 23 + tests/output/c/00703-function-def.c | 18 + tests/output/c/00710-add_long_comment.c | 36 + tests/output/c/00721-nl-semicolon.c | 33 + tests/output/c/00801-fcn_type.c | 40 + tests/output/c/00802-funcfunc.c | 5 + tests/output/c/00901-code_width.c | 74 + tests/output/c/00902-code_width.c | 63 + tests/output/c/00903-code_width.c | 66 + tests/output/c/00910-pascal_ptr.c | 13 + tests/output/c/00911-pascal_ptr.c | 12 + tests/output/c/01000-mod-paren.c | 58 + tests/output/c/01001-nl-comment.c | 43 + tests/output/c/01002-mod-paren.c | 58 + tests/output/c/01005-mod_case_brace.c | 71 + tests/output/c/01006-mod_case_brace.c | 54 + tests/output/c/01011-semicolons.c | 74 + tests/output/c/01012-semicolons.c | 89 + tests/output/c/01015-paren_indent.c | 12 + tests/output/c/01016-align_attr.c | 4 + tests/output/c/01020-kw_subst.c | 51 + tests/output/c/01021-hello.c | 49 + tests/output/c/01022-kw_subst.c | 76 + tests/output/c/01030-multi.h | 12 + tests/output/c/01035-func_wrap.c | 3 + tests/output/c/01036-func_wrap.c | 3 + tests/output/c/01037-type_wrap.c | 4 + tests/output/c/01040-newline_after_endif.c | 53 + tests/output/c/01050-func_call_user.c | 6 + tests/output/c/20000-i2c-core.c | 1457 ++++ tests/output/c/20001-directfb.h | 3063 +++++++ tests/output/c/20100-i2c-core.c | 1398 +++ tests/output/c/20101-comment-indent.c | 37 + tests/output/c/20102-indent.cpp | 1023 +++ tests/output/c/20103-output.cpp | 625 ++ tests/output/c/20200-xml.c | 9 + tests/output/c/20201-align-string.c | 14 + tests/output/c/20300-preproc-if.c | 36 + tests/output/c/20301-preproc-if.c | 36 + tests/output/c/20302-nl-cont.c | 18 + tests/output/c/20303-nl-cont2.c | 18 + tests/output/c/20310-empty-for.c | 6 + tests/output/c/20311-pragma.c | 13 + tests/output/c/20315-pp_ret.c | 13 + tests/output/c/20320-nl_create_one_liner.c | 13 + tests/output/c/20325-sort_include.c | 11 + tests/output/c/21010-ifdef-indent.c | 35 + tests/output/c/21011-ifdef-indent.c | 35 + tests/output/c/21012-ifdef-indent.c | 35 + tests/output/c/21013-ifdef-indent.c | 35 + tests/output/c/21015-endif.c | 29 + tests/output/c/21016-cmt_nl_end.c | 13 + tests/output/c/21021-cmt_multi.c | 17 + tests/output/c/21022-cmt_multi.c | 17 + tests/output/c/21031-cmt_right_align.c | 47 + tests/output/c/21032-cmt_right_align.c | 47 + tests/output/c/21051-nl_return_expr.c | 21 + tests/output/c/21052-nl_return_expr.c | 21 + tests/output/c/21053-nl_return_expr.c | 25 + tests/output/c/21054-nl_return_expr.c | 25 + tests/output/c/66601-custom_types_ssl.c | 137 + tests/output/c/66602-custom_types_ssl.c | 134 + tests/output/c/66603-pp_concat_asn1.h | 298 + tests/output/cpp/30000-cout.cpp | 17 + tests/output/cpp/30001-alt_tokens.cpp | 5 + tests/output/cpp/30002-constructor.cpp | 31 + tests/output/cpp/30003-strings.cpp | 7 + tests/output/cpp/30010-class.h | 52 + tests/output/cpp/30011-misc.cpp | 51 + tests/output/cpp/30012-misc2.cpp | 58 + tests/output/cpp/30013-sim.h | 48 + tests/output/cpp/30014-ctor-var.cpp | 4 + tests/output/cpp/30015-exception.cpp | 40 + tests/output/cpp/30016-custom-open.cpp | 26 + tests/output/cpp/30017-custom-open.cpp | 26 + tests/output/cpp/30018-class-addr.h | 11 + tests/output/cpp/30019-wacky-template.cpp | 12 + tests/output/cpp/30020-bool.cpp | 11 + tests/output/cpp/30021-byref.cpp | 43 + tests/output/cpp/30022-extern_c.h | 35 + tests/output/cpp/30023-templates.cpp | 153 + tests/output/cpp/30024-class-init.cpp | 68 + tests/output/cpp/30025-class-init.cpp | 61 + tests/output/cpp/30026-byref.cpp | 41 + tests/output/cpp/30027-byref.cpp | 41 + tests/output/cpp/30028-byref.cpp | 41 + tests/output/cpp/30029-init_align.h | 22 + tests/output/cpp/30030-Timestamp.h | 165 + tests/output/cpp/30031-operator.cpp | 69 + tests/output/cpp/30032-operator.cpp | 71 + tests/output/cpp/30033-operator.cpp | 71 + tests/output/cpp/30040-nl-class.h | 57 + tests/output/cpp/30041-nl-class.h | 61 + tests/output/cpp/30045-nl_func_decl.cpp | 16 + tests/output/cpp/30046-nl_func_decl.cpp | 28 + tests/output/cpp/30050-nl-namespace.h | 14 + tests/output/cpp/30051-nl-namespace.h | 16 + tests/output/cpp/30052-try-catch-nl.cpp | 24 + tests/output/cpp/30055-nl_func.cpp | 32 + tests/output/cpp/30056-nl_func.cpp | 30 + tests/output/cpp/30061-class-init.cpp | 58 + tests/output/cpp/30062-class-init.cpp | 58 + tests/output/cpp/30063-class-init.cpp | 68 + tests/output/cpp/30064-class-init.cpp | 68 + tests/output/cpp/30065-Example.h | 11 + tests/output/cpp/30070-nl_func_scope_name.cpp | 4 + tests/output/cpp/30075-goto.cpp | 11 + tests/output/cpp/30080-nl_brace_brace.cpp | 20 + tests/output/cpp/30100-templates.cpp | 158 + tests/output/cpp/30101-templates.cpp | 144 + tests/output/cpp/30102-templates.cpp | 149 + tests/output/cpp/30103-templates.cpp | 149 + tests/output/cpp/30104-templ_class.h | 14 + tests/output/cpp/30105-av.h | 52 + tests/output/cpp/30106-templates2.cpp | 54 + tests/output/cpp/30107-templates2.cpp | 50 + tests/output/cpp/30108-templates3.cpp | 15 + tests/output/cpp/30109-templates4.cpp | 17 + tests/output/cpp/30201-cmt_indent.cpp | 32 + tests/output/cpp/30202-cmt_indent.cpp | 32 + tests/output/cpp/30203-cmt_indent.cpp | 32 + tests/output/cpp/30204-comment-align.cpp | 34 + tests/output/cpp/30205-cmt_right.cpp | 28 + tests/output/cpp/30250-align_fcall.cpp | 10 + tests/output/cpp/30251-align_fcall.cpp | 10 + tests/output/cpp/30255-align_constr.cpp | 16 + tests/output/cpp/30260-var_def_gap.cpp | 27 + tests/output/cpp/30270-const_throw.cpp | 12 + tests/output/cpp/30271-sp_throw_paren.cpp | 7 + tests/output/cpp/30272-sp_throw_paren.cpp | 7 + tests/output/cpp/30701-function-def.cpp | 99 + tests/output/cpp/30702-function-def.cpp | 67 + tests/output/cpp/30703-function-def.cpp | 57 + tests/output/cpp/30711-semicolons.cpp | 98 + tests/output/cpp/30720-custom-open-2.cpp | 45 + tests/output/cpp/30730-qt-1.cpp | 26 + tests/output/cpp/30731-qt-1.cpp | 35 + tests/output/cpp/30740-sef.cpp | 15 + tests/output/cpp/30741-al.cpp | 40 + tests/output/cpp/30742-delete.cpp | 10 + tests/output/cpp/30800-align-star-amp-pos.cpp | 47 + tests/output/cpp/30801-align-star-amp-pos.cpp | 47 + tests/output/cpp/30802-align-star-amp-pos.cpp | 47 + tests/output/cpp/30805-ptr-star.cpp | 34 + tests/output/cpp/30806-ptr-star.cpp | 34 + tests/output/cpp/30807-ptr-star.cpp | 34 + tests/output/cpp/30810-ptr-star.cpp | 36 + tests/output/cpp/30811-misc3.cpp | 21 + tests/output/cpp/30812-misc4.cpp | 36 + tests/output/cpp/30813-misc5.cpp | 13 + tests/output/cpp/30814-misc6.cpp | 3 + tests/output/cpp/30815-cmt-reflow.cpp | 41 + tests/output/cpp/30816-for_long.cpp | 12 + tests/output/cpp/30820-pp-define-indent.cpp | 35 + tests/output/cpp/30830-kw_subst.cpp | 70 + tests/output/cpp/30831-kw_subst2.cpp | 70 + tests/output/cpp/30840-nl_func_type_name.cpp | 45 + tests/output/cpp/30841-nl_func_type_name.cpp | 55 + tests/output/cpp/30842-nl_func_type_name.cpp | 51 + tests/output/cpp/30845-deref.cpp | 15 + tests/output/cpp/30900-region.cpp | 20 + tests/output/cpp/30901-region.cpp | 20 + tests/output/cpp/30902-region.cpp | 20 + tests/output/cpp/30903-region.cpp | 20 + tests/output/cpp/30910-indent_namespace.h | 32 + tests/output/cpp/30911-indent_namespace.h | 32 + tests/output/cpp/30912-long_namespace.cpp | 15 + tests/output/cpp/30920-indent-off.cpp | 23 + tests/output/cpp/30921-variadic-template.h | 10 + tests/output/cpp/30922-variadic-template.h | 10 + tests/output/cpp/30930-indent_var_def.cpp | 9 + tests/output/cs/10000-simple.cs | 118 + tests/output/cs/10001-getset.cs | 17 + tests/output/cs/10002-simple.cs | 131 + tests/output/cs/10003-region.cs | 18 + tests/output/cs/10010-var-member.cs | 23 + tests/output/cs/10011-strings.cs | 8 + tests/output/cs/10020-region.cs | 20 + tests/output/cs/10021-region.cs | 20 + tests/output/cs/10022-region.cs | 20 + tests/output/cs/10023-region.cs | 20 + tests/output/cs/10030-sort_using.cs | 18 + tests/output/cs/10040-tcf.cs | 38 + tests/output/cs/10041-gs.cs | 37 + tests/output/cs/10050-generics.cs | 11 + tests/output/cs/10060-unsafe.cs | 7 + tests/output/d/40000-HashMap.d | 1088 +++ tests/output/d/40001-imports.d | 8 + tests/output/d/40002-volatile.d | 27 + tests/output/d/40003-volatile-1.d | 10 + tests/output/d/40004-volatile-2.d | 8 + tests/output/d/40005-volatile-3.d | 7 + tests/output/d/40006-Lexer.d | 2464 ++++++ tests/output/d/40007-Lexer.d | 2412 ++++++ tests/output/d/40010-template.d | 27 + tests/output/d/40020-funcfunc.d | 5 + tests/output/d/40021-tst01.d | 25 + tests/output/d/40022-tst02.d | 30 + tests/output/d/40023-bug-indent.d | 20 + tests/output/d/40024-tst03.d | 148 + tests/output/d/40025-tst03.d | 153 + tests/output/d/40030-delegate.d | 22 + tests/output/d/40040-sort_import.d | 19 + tests/output/d/40050-strings.d | 32 + tests/output/d/40051-numbers.d | 46 + tests/output/d/40052-numbers.d | 43 + tests/output/ecma/90000-example-1.es | 12 + tests/output/oc/50001-Fraction.h | 14 + tests/output/oc/50002-Fraction.m | 29 + tests/output/oc/50003-main.m | 22 + tests/output/oc/50004-string.m | 11 + tests/output/oc/50005-Declarations.h | 22 + tests/output/oc/50006-exceptions.m | 19 + tests/output/oc/50007-misc.m | 18 + tests/output/oc/50010-oc-split.m | 10 + tests/output/oc/50010-return_type.m | 36 + tests/output/oc/50011-return_type.m | 36 + tests/output/oc/50012-return_type.m | 36 + tests/output/oc/50020-selector.m | 3 + tests/output/oc/50021-selector.m | 3 + tests/output/oc/50022-selector.m | 3 + tests/output/oc/50030-sort_import.m | 11 + tests/output/pawn/60000-functions.pawn | 32 + tests/output/pawn/60001-comment.p | 46 + tests/output/pawn/60002-traffic.p | 52 + tests/output/pawn/60003-tags.pawn | 69 + tests/output/pawn/60004-enum.pawn | 91 + tests/output/pawn/60005-unbraced.p | 15 + tests/output/pawn/60010-str-escape.p | 6 + tests/output/pawn/60020-switch-vsemi.sma | 16 + tests/output/pawn/60030-crusty_ex-1.sma | 29 + tests/output/sql/21000-mysql.sqc | 45 + tests/output/sql/21001-sta-select.sqc | 76 + tests/output/vala/70000-list.vala | 22 + tests/output/vala/70001-advanced.vala | 31 + tests/pawn.test | 19 + tests/run_tests.py | 181 + tests/tests.vpj | 350 + tests/vala.test | 9 + todo.txt | 217 + uncrustify.vpj | 120 + uncrustify.vpw | 8 + uncrustify.xcodeproj/project.pbxproj | 2465 ++++++ update-default-cfg.sh | 4 + win32/Uncrustify_Win32.dsp | 306 + win32/Uncrustify_Win32.dsw | 29 + win32/Uncrustify_Win32.sln | 20 + win32/Uncrustify_Win32.vcproj | 978 +++ win32/Uncrustify_Win32_2005.sln | 32 + win32/Uncrustify_Win32_2005.vcproj | 921 ++ win32/windows_compat.h | 72 + 945 files changed, 125891 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 BUGS create mode 100644 COPYING create mode 100644 HELP create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 README create mode 100644 aclocal.m4 create mode 100755 autogen.sh create mode 100755 config.guess create mode 100755 config.sub create mode 100755 configure create mode 100644 configure.in create mode 100644 do-c.sh create mode 100644 do-d.sh create mode 100644 documentation/align-thresholds.txt create mode 100644 documentation/example.c create mode 100644 documentation/goals.txt create mode 100644 documentation/htdocs/ChangeLog create mode 100644 documentation/htdocs/ben.cfg.txt create mode 100644 documentation/htdocs/config.txt create mode 100644 documentation/htdocs/configuration.txt create mode 100644 documentation/htdocs/default.cfg create mode 100644 documentation/htdocs/examples/c-1.in.c create mode 100644 documentation/htdocs/examples/c-1.out.c create mode 100644 documentation/htdocs/examples/example.c create mode 100644 documentation/htdocs/images/linuxlinks.gif create mode 100644 documentation/htdocs/index.html create mode 100644 documentation/htdocs/linux.cfg.txt create mode 100644 documentation/htdocs/project-support.jpg create mode 100644 documentation/htdocs/uncrustify.css create mode 100644 documentation/htdocs/uncrustify.html create mode 100644 documentation/overview.odt create mode 100644 documentation/paren_stack.txt create mode 100644 documentation/theory.txt create mode 100644 etc/amxmodx.cfg create mode 100644 etc/ben.cfg create mode 100644 etc/ben2.cfg create mode 100644 etc/d.cfg create mode 100644 etc/defaults.cfg create mode 100644 etc/dofiles.sh create mode 100644 etc/gnu-indent.cfg create mode 100644 etc/klaus.cfg create mode 100644 etc/kr-indent.cfg create mode 100644 etc/linux-indent.cfg create mode 100644 etc/linux.cfg create mode 100644 etc/mono.cfg create mode 100644 etc/objc.cfg create mode 100644 etc/types.txt create mode 100644 etc/uncrust-files.sh create mode 100644 etc/xsupplicant.cfg create mode 100644 extras.vpj create mode 100755 install-sh create mode 100755 make_token_names.sh create mode 100644 man/Makefile.am create mode 100644 man/Makefile.in create mode 100644 man/uncrustify.1 create mode 100755 missing create mode 100644 release-steps.txt create mode 100755 run_tests.sh create mode 100644 scripts/check_options.py create mode 100755 scripts/cmpcfg.pl create mode 100755 scripts/punc.py create mode 100755 scripts/tokenize.py create mode 100755 scripts/update-defaults.sh create mode 100644 src/ChunkStack.cpp create mode 100644 src/ChunkStack.h create mode 100644 src/ListManager.h create mode 100644 src/Makefile.am create mode 100644 src/Makefile.in create mode 100644 src/align.cpp create mode 100644 src/align_stack.cpp create mode 100644 src/align_stack.h create mode 100644 src/args.cpp create mode 100644 src/args.h create mode 100644 src/backup.cpp create mode 100644 src/backup.h create mode 100644 src/base_types.h create mode 100644 src/brace_cleanup.cpp create mode 100644 src/braces.cpp create mode 100644 src/char_table.h create mode 100644 src/chunk_list.cpp create mode 100644 src/chunk_list.h create mode 100644 src/combine.cpp create mode 100644 src/config.h create mode 100644 src/config.h.in create mode 100644 src/d.tokenize.cpp create mode 100644 src/defines.cpp create mode 100644 src/detect.cpp create mode 100644 src/indent.cpp create mode 100644 src/keywords.cpp create mode 100644 src/lang_pawn.cpp create mode 100644 src/log_levels.h create mode 100644 src/logger.cpp create mode 100644 src/logger.h create mode 100644 src/logmask.cpp create mode 100644 src/logmask.h create mode 100644 src/md5.cpp create mode 100644 src/md5.h create mode 100644 src/newlines.cpp create mode 100644 src/options.cpp create mode 100644 src/options.h create mode 100644 src/output.cpp create mode 100644 src/parens.cpp create mode 100644 src/parse_frame.cpp create mode 100644 src/prototypes.h create mode 100644 src/punctuators.cpp create mode 100644 src/punctuators.h create mode 100644 src/semicolons.cpp create mode 100644 src/sorting.cpp create mode 100644 src/space.cpp create mode 100644 src/token_enum.h create mode 100644 src/token_names.h create mode 100644 src/tokenize.cpp create mode 100644 src/tokenize_cleanup.cpp create mode 100644 src/unc_ctype.h create mode 100644 src/uncrustify.cpp create mode 100644 src/uncrustify_types.h create mode 100644 src/uncrustify_version.h create mode 100644 src/universalindentgui.cpp create mode 100644 src/width.cpp create mode 100644 tests/c-sharp.test create mode 100644 tests/c.test create mode 100644 tests/config/1liner-no-split.cfg create mode 100644 tests/config/1liner-split.cfg create mode 100644 tests/config/add_long_closebrace_comment_1.cfg create mode 100644 tests/config/al.cfg create mode 100644 tests/config/align-1.cfg create mode 100644 tests/config/align-2.cfg create mode 100644 tests/config/align-3.cfg create mode 100644 tests/config/align_attr.cfg create mode 100644 tests/config/align_fcall-2.cfg create mode 100644 tests/config/align_fcall.cfg create mode 100644 tests/config/align_right_cmt_gap-1.cfg create mode 100644 tests/config/align_right_cmt_gap-2.cfg create mode 100644 tests/config/align_typedef_func-0.cfg create mode 100644 tests/config/align_typedef_func-1.cfg create mode 100644 tests/config/align_typedef_func-2.cfg create mode 100644 tests/config/amxmodx.cfg create mode 100644 tests/config/avalon.cfg create mode 100644 tests/config/avalon2.cfg create mode 100644 tests/config/avalon3.cfg create mode 100644 tests/config/avalon4.cfg create mode 100644 tests/config/ben.cfg create mode 100644 tests/config/blc-1.cfg create mode 100644 tests/config/bool-pos-eol.cfg create mode 100644 tests/config/bool-pos-sol.cfg create mode 100644 tests/config/brace-allman.cfg create mode 100644 tests/config/brace-banner.cfg create mode 100644 tests/config/brace-gnu.cfg create mode 100644 tests/config/brace-kr-br.cfg create mode 100644 tests/config/brace-kr.cfg create mode 100644 tests/config/brace-remove-2.cfg create mode 100644 tests/config/brace-remove-all.cfg create mode 100644 tests/config/brace-ws.cfg create mode 100644 tests/config/brace-ws2.cfg create mode 100644 tests/config/byref-center.cfg create mode 100644 tests/config/byref-left.cfg create mode 100644 tests/config/byref-right.cfg create mode 100644 tests/config/case-1.cfg create mode 100644 tests/config/case-2.cfg create mode 100644 tests/config/case-3.cfg create mode 100644 tests/config/cast-sp-a.cfg create mode 100644 tests/config/cast-sp-r.cfg create mode 100644 tests/config/cast-type.cfg create mode 100644 tests/config/cast-types.txt create mode 100644 tests/config/cgal.cfg create mode 100644 tests/config/clark.cfg create mode 100644 tests/config/class-colon-pos-eol-add.cfg create mode 100644 tests/config/class-colon-pos-eol.cfg create mode 100644 tests/config/class-colon-pos-sol-add.cfg create mode 100644 tests/config/class-colon-pos-sol.cfg create mode 100644 tests/config/class-header.h create mode 100644 tests/config/class-nl_func-add.cfg create mode 100644 tests/config/class-nl_func-del.cfg create mode 100644 tests/config/cmt_indent-1.cfg create mode 100644 tests/config/cmt_indent-2.cfg create mode 100644 tests/config/cmt_indent-3.cfg create mode 100644 tests/config/cmt_multi-1.cfg create mode 100644 tests/config/cmt_multi-2.cfg create mode 100644 tests/config/cmt_nl_end.cfg create mode 100644 tests/config/cmt_right.cfg create mode 100644 tests/config/comment-align.cfg create mode 100644 tests/config/cond-1.cfg create mode 100644 tests/config/cond-2.cfg create mode 100644 tests/config/const_throw.cfg create mode 100644 tests/config/cpp_to_c-1.cfg create mode 100644 tests/config/cpp_to_c-2.cfg create mode 100644 tests/config/cpp_to_c-3.cfg create mode 100644 tests/config/cs_generics.cfg create mode 100644 tests/config/cu.cfg create mode 100644 tests/config/custom-open.cfg create mode 100644 tests/config/custom-open2.cfg create mode 100644 tests/config/custom_types_ssl.cfg create mode 100644 tests/config/d-tst2.cfg create mode 100644 tests/config/d.cfg create mode 100644 tests/config/d2.cfg create mode 100644 tests/config/d3.cfg create mode 100644 tests/config/d3a.cfg create mode 100644 tests/config/del_semicolon.cfg create mode 100644 tests/config/delete.cfg create mode 100644 tests/config/else-if-1.cfg create mode 100644 tests/config/else-if-2.cfg create mode 100644 tests/config/empty_body.cfg create mode 100644 tests/config/endif.cfg create mode 100644 tests/config/file-header.h create mode 100644 tests/config/file_footer.txt create mode 100644 tests/config/file_header.txt create mode 100644 tests/config/func-def-1.cfg create mode 100644 tests/config/func-def-2.cfg create mode 100644 tests/config/func-def-3.cfg create mode 100644 tests/config/func-header.h create mode 100644 tests/config/func-header2.h create mode 100644 tests/config/func_call_user.cfg create mode 100644 tests/config/func_wrap1.cfg create mode 100644 tests/config/func_wrap2.cfg create mode 100644 tests/config/function_header.txt create mode 100644 tests/config/ger.cfg create mode 100644 tests/config/getset.cfg create mode 100644 tests/config/if_chain.cfg create mode 100644 tests/config/indent-1.cfg create mode 100644 tests/config/indent.cfg create mode 100644 tests/config/indent_func_call_param.cfg create mode 100644 tests/config/indent_func_def_param.cfg create mode 100644 tests/config/indent_func_param.cfg create mode 100644 tests/config/indent_func_proto_param.cfg create mode 100644 tests/config/indent_namespace-f.cfg create mode 100644 tests/config/indent_namespace-t.cfg create mode 100644 tests/config/indent_paren_close-0.cfg create mode 100644 tests/config/indent_paren_close-1.cfg create mode 100644 tests/config/indent_paren_close-2.cfg create mode 100644 tests/config/indent_var_def.cfg create mode 100644 tests/config/kw_subst.cfg create mode 100644 tests/config/kw_subst2.cfg create mode 100644 tests/config/kw_subst3.cfg create mode 100644 tests/config/long_namespace.cfg create mode 100644 tests/config/misc6.cfg create mode 100644 tests/config/mod-paren.cfg create mode 100644 tests/config/mod-paren2.cfg create mode 100644 tests/config/mod_case_brace_add.cfg create mode 100644 tests/config/mod_case_brace_rm.cfg create mode 100644 tests/config/mono.cfg create mode 100644 tests/config/multi.cfg create mode 100644 tests/config/newline_after_endif.cfg create mode 100644 tests/config/nl-comment.cfg create mode 100644 tests/config/nl_access_spec.cfg create mode 100644 tests/config/nl_after_func_body-2.cfg create mode 100644 tests/config/nl_after_func_body.cfg create mode 100644 tests/config/nl_assign1.cfg create mode 100644 tests/config/nl_assign2.cfg create mode 100644 tests/config/nl_brace_brace-a.cfg create mode 100644 tests/config/nl_brace_test.cfg create mode 100644 tests/config/nl_class-a.cfg create mode 100644 tests/config/nl_class-r.cfg create mode 100644 tests/config/nl_create_one_liner.cfg create mode 100644 tests/config/nl_ds_struct_enum-1.cfg create mode 100644 tests/config/nl_ds_struct_enum-2.cfg create mode 100644 tests/config/nl_endif.cfg create mode 100644 tests/config/nl_func_decl_1.cfg create mode 100644 tests/config/nl_func_decl_2.cfg create mode 100644 tests/config/nl_func_scope_name.cfg create mode 100644 tests/config/nl_func_type_name_class.cfg create mode 100644 tests/config/nl_func_type_name_force.cfg create mode 100644 tests/config/nl_func_type_name_remove.cfg create mode 100644 tests/config/nl_namespace-a.cfg create mode 100644 tests/config/nl_namespace-r.cfg create mode 100644 tests/config/nl_semicolon.cfg create mode 100644 tests/config/nl_template_class-force.cfg create mode 100644 tests/config/nl_template_class-remove.cfg create mode 100644 tests/config/nl_try-a.cfg create mode 100644 tests/config/obj-c.cfg create mode 100644 tests/config/oc-split.cfg create mode 100644 tests/config/op-space-force.cfg create mode 100644 tests/config/op-space-remove.cfg create mode 100644 tests/config/pascal_ptr.cfg create mode 100644 tests/config/pawn-escape.cfg create mode 100644 tests/config/pawn.cfg create mode 100644 tests/config/pos_compare-eol.cfg create mode 100644 tests/config/pos_compare-sol.cfg create mode 100644 tests/config/pos_conditional-eol.cfg create mode 100644 tests/config/pos_conditional-sol.cfg create mode 100644 tests/config/pp-indent-1.cfg create mode 100644 tests/config/pp-indent-2.cfg create mode 100644 tests/config/pp-indent-3.cfg create mode 100644 tests/config/pp-space.cfg create mode 100644 tests/config/pp_define_at_level-1.cfg create mode 100644 tests/config/pp_if_indent-0.cfg create mode 100644 tests/config/pp_if_indent-1.cfg create mode 100644 tests/config/pp_if_indent-2.cfg create mode 100644 tests/config/pp_if_indent-3.cfg create mode 100644 tests/config/pp_ret.cfg create mode 100644 tests/config/preproc-cleanup.cfg create mode 100644 tests/config/ptr_star-1.cfg create mode 100644 tests/config/ptr_star-2.cfg create mode 100644 tests/config/ptr_star-3.cfg create mode 100644 tests/config/region-0.cfg create mode 100644 tests/config/region-1.cfg create mode 100644 tests/config/region-2.cfg create mode 100644 tests/config/region-3.cfg create mode 100644 tests/config/return-1.cfg create mode 100644 tests/config/return-2.cfg create mode 100644 tests/config/return-3.cfg create mode 100644 tests/config/return-4.cfg create mode 100644 tests/config/sef.cfg create mode 100644 tests/config/sim.cfg create mode 100644 tests/config/sort_imports.cfg create mode 100644 tests/config/sp-for-semi.cfg create mode 100644 tests/config/sp_after_cast.cfg create mode 100644 tests/config/sp_after_oc_at_sel_add.cfg create mode 100644 tests/config/sp_after_oc_at_sel_force.cfg create mode 100644 tests/config/sp_after_oc_at_sel_remove.cfg create mode 100644 tests/config/sp_after_oc_return_type_add.cfg create mode 100644 tests/config/sp_after_oc_return_type_force.cfg create mode 100644 tests/config/sp_after_oc_return_type_remove.cfg create mode 100644 tests/config/sp_before_ellipsis-f.cfg create mode 100644 tests/config/sp_cmt_cpp_start_add.cfg create mode 100644 tests/config/sp_cmt_cpp_start_force.cfg create mode 100644 tests/config/sp_cmt_cpp_start_remove.cfg create mode 100644 tests/config/sp_throw_paren-f.cfg create mode 100644 tests/config/sp_throw_paren-r.cfg create mode 100644 tests/config/star_pos-0.cfg create mode 100644 tests/config/star_pos-1.cfg create mode 100644 tests/config/star_pos-2.cfg create mode 100644 tests/config/tcf.cfg create mode 100644 tests/config/template4.cfg create mode 100644 tests/config/template_sp-force.cfg create mode 100644 tests/config/template_sp-remove.cfg create mode 100644 tests/config/type_wrap.cfg create mode 100644 tests/config/var_def_gap.cfg create mode 100644 tests/config/wessex.cfg create mode 100644 tests/config/width-2.cfg create mode 100644 tests/config/width-3.cfg create mode 100644 tests/config/width.cfg create mode 100644 tests/config/xml-str.cfg create mode 100644 tests/cpp.test create mode 100644 tests/d.test create mode 100755 tests/difftest.sh create mode 100644 tests/ecma.test create mode 100644 tests/embed.c create mode 100755 tests/fixtest.sh create mode 100644 tests/input/align_fcall.cpp create mode 100644 tests/input/c/add_long_comment.c create mode 100644 tests/input/c/align-equ.c create mode 100644 tests/input/c/align-proto-vars.c create mode 100644 tests/input/c/align-proto.c create mode 100644 tests/input/c/align-string.c create mode 100644 tests/input/c/align-struct-init.c create mode 100644 tests/input/c/align-typedef.c create mode 100644 tests/input/c/align-var.c create mode 100644 tests/input/c/align_attr.c create mode 100644 tests/input/c/beautifier-off.c create mode 100644 tests/input/c/bits.c create mode 100644 tests/input/c/bool-pos.c create mode 100644 tests/input/c/brace-remove.c create mode 100644 tests/input/c/brace-remove2.c create mode 100644 tests/input/c/brace.c create mode 100644 tests/input/c/braces-2.c create mode 100644 tests/input/c/braces-3.c create mode 100644 tests/input/c/braces-4.c create mode 100644 tests/input/c/braces-5.c create mode 100644 tests/input/c/braces.c create mode 100644 tests/input/c/bsnl.c create mode 100644 tests/input/c/bugs-1.c create mode 100644 tests/input/c/bugs-2.c create mode 100644 tests/input/c/bugs-3.c create mode 100644 tests/input/c/bugs-4.c create mode 100644 tests/input/c/bugs-5.c create mode 100644 tests/input/c/bugs-6.c create mode 100644 tests/input/c/bugs-7.c create mode 100644 tests/input/c/bugs-8.c create mode 100644 tests/input/c/bugs.c create mode 100644 tests/input/c/case.c create mode 100644 tests/input/c/casts.c create mode 100644 tests/input/c/cmt-align.c create mode 100644 tests/input/c/cmt_multi.c create mode 100644 tests/input/c/cmt_nl_end.c create mode 100644 tests/input/c/cmt_right_align.c create mode 100644 tests/input/c/code_width.c create mode 100644 tests/input/c/colon-asm.c create mode 100644 tests/input/c/comment-convert.c create mode 100644 tests/input/c/comment-indent.c create mode 100644 tests/input/c/cond.c create mode 100644 tests/input/c/custom_types_ssl.c create mode 100644 tests/input/c/define-if-indent.c create mode 100644 tests/input/c/deref.c create mode 100644 tests/input/c/directfb.h create mode 100644 tests/input/c/dos.c create mode 100644 tests/input/c/else-if.c create mode 100644 tests/input/c/empty-for.c create mode 100644 tests/input/c/endif.c create mode 100644 tests/input/c/enum-struct-init.c create mode 100644 tests/input/c/fcn_indent.c create mode 100644 tests/input/c/fcn_type.c create mode 100644 tests/input/c/for-space.c create mode 100644 tests/input/c/func_call_user.c create mode 100644 tests/input/c/func_param.c create mode 100644 tests/input/c/func_wrap.c create mode 100644 tests/input/c/funcfunc.c create mode 100644 tests/input/c/function-def.c create mode 100644 tests/input/c/global-vars.c create mode 100644 tests/input/c/hello.c create mode 100644 tests/input/c/i2c-core.c create mode 100644 tests/input/c/if_chain.c create mode 100644 tests/input/c/ifdef-indent.c create mode 100644 tests/input/c/ifdef-nest.c create mode 100644 tests/input/c/include_define.h create mode 100644 tests/input/c/indent-assign.c create mode 100644 tests/input/c/indent.cpp create mode 100644 tests/input/c/kw_subst.c create mode 100644 tests/input/c/mac.c create mode 100644 tests/input/c/minus-minus.c create mode 100644 tests/input/c/misc.c create mode 100644 tests/input/c/mod-paren.c create mode 100644 tests/input/c/mod_case_brace.c create mode 100644 tests/input/c/multi.h create mode 100644 tests/input/c/newline_after_endif.c create mode 100644 tests/input/c/nl-comment.c create mode 100644 tests/input/c/nl-cont.c create mode 100644 tests/input/c/nl-cont2.c create mode 100644 tests/input/c/nl-semicolon.c create mode 100644 tests/input/c/nl-ver-def.c create mode 100644 tests/input/c/nl_assign.c create mode 100644 tests/input/c/nl_create_one_liner.c create mode 100644 tests/input/c/nl_ds_struct_enum.c create mode 100644 tests/input/c/nl_endif.c create mode 100644 tests/input/c/nl_proto_endif.c create mode 100644 tests/input/c/nl_return_expr.c create mode 100644 tests/input/c/one-liner-init.c create mode 100644 tests/input/c/output.cpp create mode 100644 tests/input/c/paren-indent.c create mode 100644 tests/input/c/paren_indent.c create mode 100644 tests/input/c/pascal_ptr.c create mode 100644 tests/input/c/pos_compare.c create mode 100644 tests/input/c/pos_conditional.c create mode 100644 tests/input/c/pp-nest.c create mode 100644 tests/input/c/pp-space.c create mode 100644 tests/input/c/pp_concat_asn1.h create mode 100644 tests/input/c/pp_ret.c create mode 100644 tests/input/c/pragma.c create mode 100644 tests/input/c/preproc-if.c create mode 100644 tests/input/c/return-multi.c create mode 100644 tests/input/c/semicolons.c create mode 100644 tests/input/c/sort_include.c create mode 100644 tests/input/c/sp_cmt_cpp_start.c create mode 100644 tests/input/c/sp_embed_comment.c create mode 100644 tests/input/c/struct-brace.c create mode 100644 tests/input/c/switch-case.c create mode 100644 tests/input/c/switch.c create mode 100644 tests/input/c/t3.in.c create mode 100644 tests/input/c/type-cast.c create mode 100644 tests/input/c/type_wrap.c create mode 100644 tests/input/c/vb-do.c create mode 100644 tests/input/c/vb-pp.c create mode 100644 tests/input/c/vb-while.c create mode 100644 tests/input/c/xml.c create mode 100644 tests/input/cpp/Example.h create mode 100644 tests/input/cpp/Timestamp.h create mode 100644 tests/input/cpp/al.cpp create mode 100644 tests/input/cpp/align-func-params.cpp create mode 100644 tests/input/cpp/align-star-amp-pos.cpp create mode 100644 tests/input/cpp/align_constr.cpp create mode 100644 tests/input/cpp/align_fcall.cpp create mode 100644 tests/input/cpp/alt_tokens.cpp create mode 100644 tests/input/cpp/av.h create mode 100644 tests/input/cpp/bool.cpp create mode 100644 tests/input/cpp/byref.cpp create mode 100644 tests/input/cpp/class-addr.h create mode 100644 tests/input/cpp/class-init.cpp create mode 100644 tests/input/cpp/class.h create mode 100644 tests/input/cpp/cmt-reflow.cpp create mode 100644 tests/input/cpp/cmt_indent.cpp create mode 100644 tests/input/cpp/cmt_right.cpp create mode 100644 tests/input/cpp/comment-align.cpp create mode 100644 tests/input/cpp/const_throw.cpp create mode 100644 tests/input/cpp/constructor.cpp create mode 100644 tests/input/cpp/cout.cpp create mode 100644 tests/input/cpp/ctor-var.cpp create mode 100644 tests/input/cpp/custom-open-2.cpp create mode 100644 tests/input/cpp/custom-open.cpp create mode 100644 tests/input/cpp/delete.cpp create mode 100644 tests/input/cpp/deref.cpp create mode 100644 tests/input/cpp/exception.cpp create mode 100644 tests/input/cpp/extern_c.h create mode 100644 tests/input/cpp/for_long.cpp create mode 100644 tests/input/cpp/function-def.cpp create mode 100644 tests/input/cpp/goto.cpp create mode 100644 tests/input/cpp/indent-off.cpp create mode 100644 tests/input/cpp/indent_namespace.h create mode 100644 tests/input/cpp/indent_var_def.cpp create mode 100644 tests/input/cpp/init_align.h create mode 100644 tests/input/cpp/kw_subst.cpp create mode 100644 tests/input/cpp/kw_subst2.cpp create mode 100644 tests/input/cpp/long_namespace.cpp create mode 100644 tests/input/cpp/misc.cpp create mode 100644 tests/input/cpp/misc2.cpp create mode 100644 tests/input/cpp/misc3.cpp create mode 100644 tests/input/cpp/misc4.cpp create mode 100644 tests/input/cpp/misc5.cpp create mode 100644 tests/input/cpp/misc6.cpp create mode 100644 tests/input/cpp/nl-class.h create mode 100644 tests/input/cpp/nl-namespace.h create mode 100644 tests/input/cpp/nl_brace_brace.cpp create mode 100644 tests/input/cpp/nl_func.cpp create mode 100644 tests/input/cpp/nl_func_decl.cpp create mode 100644 tests/input/cpp/nl_func_scope_name.cpp create mode 100644 tests/input/cpp/nl_func_type_name.cpp create mode 100644 tests/input/cpp/operator.cpp create mode 100644 tests/input/cpp/pp-define-indent.cpp create mode 100644 tests/input/cpp/ptr-star.cpp create mode 100644 tests/input/cpp/qt-1.cpp create mode 100644 tests/input/cpp/region.cpp create mode 100644 tests/input/cpp/sef.cpp create mode 100644 tests/input/cpp/semicolons.cpp create mode 100644 tests/input/cpp/sim.h create mode 100644 tests/input/cpp/sp_throw_paren.cpp create mode 100644 tests/input/cpp/strings.cpp create mode 100644 tests/input/cpp/templ_class.h create mode 100644 tests/input/cpp/templates.cpp create mode 100644 tests/input/cpp/templates2.cpp create mode 100644 tests/input/cpp/templates3.cpp create mode 100644 tests/input/cpp/templates4.cpp create mode 100644 tests/input/cpp/try-catch-nl.cpp create mode 100644 tests/input/cpp/var_def_gap.cpp create mode 100644 tests/input/cpp/variadic-template.h create mode 100644 tests/input/cpp/wacky-template.cpp create mode 100644 tests/input/cs/generics.cs create mode 100644 tests/input/cs/getset.cs create mode 100644 tests/input/cs/gs.cs create mode 100644 tests/input/cs/region.cs create mode 100644 tests/input/cs/simple.cs create mode 100644 tests/input/cs/sort_using.cs create mode 100644 tests/input/cs/strings.cs create mode 100644 tests/input/cs/tcf.cs create mode 100644 tests/input/cs/unsafe.cs create mode 100644 tests/input/cs/var-member.cs create mode 100644 tests/input/d/HashMap.d create mode 100644 tests/input/d/Lexer.d create mode 100644 tests/input/d/bug-indent.d create mode 100644 tests/input/d/casts.d create mode 100644 tests/input/d/delegate.d create mode 100644 tests/input/d/funcfunc.d create mode 100644 tests/input/d/imports.d create mode 100644 tests/input/d/numbers.d create mode 100644 tests/input/d/sort_import.d create mode 100644 tests/input/d/strings.d create mode 100644 tests/input/d/template.d create mode 100644 tests/input/d/tst01.d create mode 100644 tests/input/d/tst02.d create mode 100644 tests/input/d/tst03.d create mode 100644 tests/input/d/volatile-1.d create mode 100644 tests/input/d/volatile-2.d create mode 100644 tests/input/d/volatile-3.d create mode 100644 tests/input/d/volatile.d create mode 100644 tests/input/ecma/example-1.es create mode 100644 tests/input/oc/Declarations.h create mode 100644 tests/input/oc/Fraction.h create mode 100644 tests/input/oc/Fraction.m create mode 100644 tests/input/oc/exceptions.m create mode 100644 tests/input/oc/main.m create mode 100644 tests/input/oc/misc.m create mode 100644 tests/input/oc/oc-split.m create mode 100644 tests/input/oc/return_type.m create mode 100644 tests/input/oc/selector.m create mode 100644 tests/input/oc/sort_import.m create mode 100644 tests/input/oc/string.m create mode 100644 tests/input/pawn/comment.p create mode 100755 tests/input/pawn/crusty_ex-1.sma create mode 100644 tests/input/pawn/enum.pawn create mode 100644 tests/input/pawn/functions.pawn create mode 100644 tests/input/pawn/rpn_calc.pawn create mode 100644 tests/input/pawn/str-escape.p create mode 100644 tests/input/pawn/switch-vsemi.sma create mode 100644 tests/input/pawn/tags.pawn create mode 100644 tests/input/pawn/test1.pawn create mode 100644 tests/input/pawn/traffic.p create mode 100644 tests/input/pawn/unbraced.p create mode 100644 tests/input/sql/mysql.sqc create mode 100644 tests/input/sql/sta-select.sqc create mode 100644 tests/input/vala/advanced.vala create mode 100644 tests/input/vala/list.vala create mode 100644 tests/java.test create mode 100644 tests/objective-c.test create mode 100644 tests/output/c/00000-comment-indent.c create mode 100644 tests/output/c/00001-comment-indent.c create mode 100644 tests/output/c/00002-comment-indent.c create mode 100644 tests/output/c/00003-comment-indent.c create mode 100644 tests/output/c/00004-switch.c create mode 100644 tests/output/c/00005-cmt-align.c create mode 100644 tests/output/c/00006-comment-convert.c create mode 100644 tests/output/c/00007-comment-convert.c create mode 100644 tests/output/c/00008-comment-convert.c create mode 100644 tests/output/c/00009-comment-convert.c create mode 100644 tests/output/c/00010-braces.c create mode 100644 tests/output/c/00011-braces.c create mode 100644 tests/output/c/00012-braces.c create mode 100644 tests/output/c/00013-braces.c create mode 100644 tests/output/c/00014-braces.c create mode 100644 tests/output/c/00015-braces.c create mode 100644 tests/output/c/00016-braces.c create mode 100644 tests/output/c/00020-define-if-indent.c create mode 100644 tests/output/c/00050-brace-remove.c create mode 100644 tests/output/c/00051-brace-remove.c create mode 100644 tests/output/c/00052-brace-remove2.c create mode 100644 tests/output/c/00053-brace.c create mode 100644 tests/output/c/00054-if_chain.c create mode 100644 tests/output/c/00055-braces-2.c create mode 100644 tests/output/c/00060-braces-2.c create mode 100644 tests/output/c/00061-braces-3.c create mode 100644 tests/output/c/00062-braces-4.c create mode 100644 tests/output/c/00065-braces-5.c create mode 100644 tests/output/c/00066-vb-while.c create mode 100644 tests/output/c/00067-vb-do.c create mode 100644 tests/output/c/00068-bsnl.c create mode 100644 tests/output/c/00069-vb-pp.c create mode 100644 tests/output/c/00070-return-multi.c create mode 100644 tests/output/c/00071-include_define.h create mode 100644 tests/output/c/00072-align-proto.c create mode 100644 tests/output/c/00073-nl_proto_endif.c create mode 100644 tests/output/c/00081-else-if.c create mode 100644 tests/output/c/00082-else-if.c create mode 100644 tests/output/c/00091-cond.c create mode 100644 tests/output/c/00092-cond.c create mode 100644 tests/output/c/00101-bugs-1.c create mode 100644 tests/output/c/00102-bugs-2.c create mode 100644 tests/output/c/00103-bugs-3.c create mode 100644 tests/output/c/00104-bugs-4.c create mode 100644 tests/output/c/00105-bugs-5.c create mode 100644 tests/output/c/00106-bugs-6.c create mode 100644 tests/output/c/00107-bugs-7.c create mode 100644 tests/output/c/00108-bugs-8.c create mode 100644 tests/output/c/00110-misc.c create mode 100644 tests/output/c/00111-misc.c create mode 100644 tests/output/c/00120-sp_cmt_cpp_start.c create mode 100644 tests/output/c/00121-sp_cmt_cpp_start.c create mode 100644 tests/output/c/00122-sp_cmt_cpp_start.c create mode 100644 tests/output/c/00130-minus-minus.c create mode 100644 tests/output/c/00140-global-vars.c create mode 100644 tests/output/c/00141-deref.c create mode 100644 tests/output/c/00142-type-cast.c create mode 100644 tests/output/c/00143-t3.in.c create mode 100644 tests/output/c/00144-align-proto-vars.c create mode 100644 tests/output/c/00150-casts.c create mode 100644 tests/output/c/00151-casts.c create mode 100644 tests/output/c/00152-casts.c create mode 100644 tests/output/c/00153-casts.c create mode 100644 tests/output/c/00154-casts.c create mode 100644 tests/output/c/00160-fcn_indent.c create mode 100644 tests/output/c/00161-fcn_indent.c create mode 100644 tests/output/c/00162-fcn_indent.c create mode 100644 tests/output/c/00163-fcn_indent.c create mode 100644 tests/output/c/00170-beautifier-off.c create mode 100644 tests/output/c/00201-case.c create mode 100644 tests/output/c/00202-case.c create mode 100644 tests/output/c/00203-case.c create mode 100644 tests/output/c/00301-align-struct-init.c create mode 100644 tests/output/c/00302-one-liner-init.c create mode 100644 tests/output/c/00303-one-liner-init.c create mode 100644 tests/output/c/00304-one-liner-init.c create mode 100644 tests/output/c/00310-sp_embed_comment.c create mode 100644 tests/output/c/00401-align-equ.c create mode 100644 tests/output/c/00402-align-var.c create mode 100644 tests/output/c/00403-align-var.c create mode 100644 tests/output/c/00404-align-var.c create mode 100644 tests/output/c/00405-bits.c create mode 100644 tests/output/c/00411-align-typedef.c create mode 100644 tests/output/c/00412-align-typedef.c create mode 100644 tests/output/c/00413-align-typedef.c create mode 100644 tests/output/c/00414-align-typedef.c create mode 100644 tests/output/c/00421-nl_ds_struct_enum.c create mode 100644 tests/output/c/00422-nl_ds_struct_enum.c create mode 100644 tests/output/c/00430-paren-indent.c create mode 100644 tests/output/c/00431-paren-indent.c create mode 100644 tests/output/c/00432-paren-indent.c create mode 100644 tests/output/c/00501-bool-pos.c create mode 100644 tests/output/c/00502-bool-pos.c create mode 100644 tests/output/c/00503-pos_compare.c create mode 100644 tests/output/c/00504-pos_compare.c create mode 100644 tests/output/c/00505-pos_conditional.c create mode 100644 tests/output/c/00506-pos_conditional.c create mode 100644 tests/output/c/00600-dos.c create mode 100644 tests/output/c/00601-mac.c create mode 100644 tests/output/c/00611-pp-space.c create mode 100644 tests/output/c/00612-pp-space.c create mode 100644 tests/output/c/00613-pp-space.c create mode 100644 tests/output/c/00614-pp-space.c create mode 100644 tests/output/c/00615-pp-nest.c create mode 100644 tests/output/c/00620-indent-assign.c create mode 100644 tests/output/c/00621-nl_endif.c create mode 100644 tests/output/c/00631-nl_assign.c create mode 100644 tests/output/c/00632-nl_assign.c create mode 100644 tests/output/c/00701-function-def.c create mode 100644 tests/output/c/00702-function-def.c create mode 100644 tests/output/c/00703-function-def.c create mode 100644 tests/output/c/00710-add_long_comment.c create mode 100644 tests/output/c/00721-nl-semicolon.c create mode 100644 tests/output/c/00801-fcn_type.c create mode 100644 tests/output/c/00802-funcfunc.c create mode 100644 tests/output/c/00901-code_width.c create mode 100644 tests/output/c/00902-code_width.c create mode 100644 tests/output/c/00903-code_width.c create mode 100644 tests/output/c/00910-pascal_ptr.c create mode 100644 tests/output/c/00911-pascal_ptr.c create mode 100644 tests/output/c/01000-mod-paren.c create mode 100644 tests/output/c/01001-nl-comment.c create mode 100644 tests/output/c/01002-mod-paren.c create mode 100644 tests/output/c/01005-mod_case_brace.c create mode 100644 tests/output/c/01006-mod_case_brace.c create mode 100644 tests/output/c/01011-semicolons.c create mode 100644 tests/output/c/01012-semicolons.c create mode 100644 tests/output/c/01015-paren_indent.c create mode 100644 tests/output/c/01016-align_attr.c create mode 100644 tests/output/c/01020-kw_subst.c create mode 100644 tests/output/c/01021-hello.c create mode 100644 tests/output/c/01022-kw_subst.c create mode 100644 tests/output/c/01030-multi.h create mode 100644 tests/output/c/01035-func_wrap.c create mode 100644 tests/output/c/01036-func_wrap.c create mode 100644 tests/output/c/01037-type_wrap.c create mode 100644 tests/output/c/01040-newline_after_endif.c create mode 100644 tests/output/c/01050-func_call_user.c create mode 100644 tests/output/c/20000-i2c-core.c create mode 100644 tests/output/c/20001-directfb.h create mode 100644 tests/output/c/20100-i2c-core.c create mode 100644 tests/output/c/20101-comment-indent.c create mode 100644 tests/output/c/20102-indent.cpp create mode 100644 tests/output/c/20103-output.cpp create mode 100644 tests/output/c/20200-xml.c create mode 100644 tests/output/c/20201-align-string.c create mode 100644 tests/output/c/20300-preproc-if.c create mode 100644 tests/output/c/20301-preproc-if.c create mode 100644 tests/output/c/20302-nl-cont.c create mode 100644 tests/output/c/20303-nl-cont2.c create mode 100644 tests/output/c/20310-empty-for.c create mode 100644 tests/output/c/20311-pragma.c create mode 100644 tests/output/c/20315-pp_ret.c create mode 100644 tests/output/c/20320-nl_create_one_liner.c create mode 100644 tests/output/c/20325-sort_include.c create mode 100644 tests/output/c/21010-ifdef-indent.c create mode 100644 tests/output/c/21011-ifdef-indent.c create mode 100644 tests/output/c/21012-ifdef-indent.c create mode 100644 tests/output/c/21013-ifdef-indent.c create mode 100644 tests/output/c/21015-endif.c create mode 100644 tests/output/c/21016-cmt_nl_end.c create mode 100644 tests/output/c/21021-cmt_multi.c create mode 100644 tests/output/c/21022-cmt_multi.c create mode 100644 tests/output/c/21031-cmt_right_align.c create mode 100644 tests/output/c/21032-cmt_right_align.c create mode 100644 tests/output/c/21051-nl_return_expr.c create mode 100644 tests/output/c/21052-nl_return_expr.c create mode 100644 tests/output/c/21053-nl_return_expr.c create mode 100644 tests/output/c/21054-nl_return_expr.c create mode 100644 tests/output/c/66601-custom_types_ssl.c create mode 100644 tests/output/c/66602-custom_types_ssl.c create mode 100644 tests/output/c/66603-pp_concat_asn1.h create mode 100644 tests/output/cpp/30000-cout.cpp create mode 100644 tests/output/cpp/30001-alt_tokens.cpp create mode 100644 tests/output/cpp/30002-constructor.cpp create mode 100644 tests/output/cpp/30003-strings.cpp create mode 100644 tests/output/cpp/30010-class.h create mode 100644 tests/output/cpp/30011-misc.cpp create mode 100644 tests/output/cpp/30012-misc2.cpp create mode 100644 tests/output/cpp/30013-sim.h create mode 100644 tests/output/cpp/30014-ctor-var.cpp create mode 100644 tests/output/cpp/30015-exception.cpp create mode 100644 tests/output/cpp/30016-custom-open.cpp create mode 100644 tests/output/cpp/30017-custom-open.cpp create mode 100644 tests/output/cpp/30018-class-addr.h create mode 100644 tests/output/cpp/30019-wacky-template.cpp create mode 100644 tests/output/cpp/30020-bool.cpp create mode 100644 tests/output/cpp/30021-byref.cpp create mode 100644 tests/output/cpp/30022-extern_c.h create mode 100644 tests/output/cpp/30023-templates.cpp create mode 100644 tests/output/cpp/30024-class-init.cpp create mode 100644 tests/output/cpp/30025-class-init.cpp create mode 100644 tests/output/cpp/30026-byref.cpp create mode 100644 tests/output/cpp/30027-byref.cpp create mode 100644 tests/output/cpp/30028-byref.cpp create mode 100644 tests/output/cpp/30029-init_align.h create mode 100644 tests/output/cpp/30030-Timestamp.h create mode 100644 tests/output/cpp/30031-operator.cpp create mode 100644 tests/output/cpp/30032-operator.cpp create mode 100644 tests/output/cpp/30033-operator.cpp create mode 100644 tests/output/cpp/30040-nl-class.h create mode 100644 tests/output/cpp/30041-nl-class.h create mode 100644 tests/output/cpp/30045-nl_func_decl.cpp create mode 100644 tests/output/cpp/30046-nl_func_decl.cpp create mode 100644 tests/output/cpp/30050-nl-namespace.h create mode 100644 tests/output/cpp/30051-nl-namespace.h create mode 100644 tests/output/cpp/30052-try-catch-nl.cpp create mode 100644 tests/output/cpp/30055-nl_func.cpp create mode 100644 tests/output/cpp/30056-nl_func.cpp create mode 100644 tests/output/cpp/30061-class-init.cpp create mode 100644 tests/output/cpp/30062-class-init.cpp create mode 100644 tests/output/cpp/30063-class-init.cpp create mode 100644 tests/output/cpp/30064-class-init.cpp create mode 100644 tests/output/cpp/30065-Example.h create mode 100644 tests/output/cpp/30070-nl_func_scope_name.cpp create mode 100644 tests/output/cpp/30075-goto.cpp create mode 100644 tests/output/cpp/30080-nl_brace_brace.cpp create mode 100644 tests/output/cpp/30100-templates.cpp create mode 100644 tests/output/cpp/30101-templates.cpp create mode 100644 tests/output/cpp/30102-templates.cpp create mode 100644 tests/output/cpp/30103-templates.cpp create mode 100644 tests/output/cpp/30104-templ_class.h create mode 100644 tests/output/cpp/30105-av.h create mode 100644 tests/output/cpp/30106-templates2.cpp create mode 100644 tests/output/cpp/30107-templates2.cpp create mode 100644 tests/output/cpp/30108-templates3.cpp create mode 100644 tests/output/cpp/30109-templates4.cpp create mode 100644 tests/output/cpp/30201-cmt_indent.cpp create mode 100644 tests/output/cpp/30202-cmt_indent.cpp create mode 100644 tests/output/cpp/30203-cmt_indent.cpp create mode 100644 tests/output/cpp/30204-comment-align.cpp create mode 100644 tests/output/cpp/30205-cmt_right.cpp create mode 100644 tests/output/cpp/30250-align_fcall.cpp create mode 100644 tests/output/cpp/30251-align_fcall.cpp create mode 100644 tests/output/cpp/30255-align_constr.cpp create mode 100644 tests/output/cpp/30260-var_def_gap.cpp create mode 100644 tests/output/cpp/30270-const_throw.cpp create mode 100644 tests/output/cpp/30271-sp_throw_paren.cpp create mode 100644 tests/output/cpp/30272-sp_throw_paren.cpp create mode 100644 tests/output/cpp/30701-function-def.cpp create mode 100644 tests/output/cpp/30702-function-def.cpp create mode 100644 tests/output/cpp/30703-function-def.cpp create mode 100644 tests/output/cpp/30711-semicolons.cpp create mode 100644 tests/output/cpp/30720-custom-open-2.cpp create mode 100644 tests/output/cpp/30730-qt-1.cpp create mode 100644 tests/output/cpp/30731-qt-1.cpp create mode 100644 tests/output/cpp/30740-sef.cpp create mode 100644 tests/output/cpp/30741-al.cpp create mode 100644 tests/output/cpp/30742-delete.cpp create mode 100644 tests/output/cpp/30800-align-star-amp-pos.cpp create mode 100644 tests/output/cpp/30801-align-star-amp-pos.cpp create mode 100644 tests/output/cpp/30802-align-star-amp-pos.cpp create mode 100644 tests/output/cpp/30805-ptr-star.cpp create mode 100644 tests/output/cpp/30806-ptr-star.cpp create mode 100644 tests/output/cpp/30807-ptr-star.cpp create mode 100644 tests/output/cpp/30810-ptr-star.cpp create mode 100644 tests/output/cpp/30811-misc3.cpp create mode 100644 tests/output/cpp/30812-misc4.cpp create mode 100644 tests/output/cpp/30813-misc5.cpp create mode 100644 tests/output/cpp/30814-misc6.cpp create mode 100644 tests/output/cpp/30815-cmt-reflow.cpp create mode 100644 tests/output/cpp/30816-for_long.cpp create mode 100644 tests/output/cpp/30820-pp-define-indent.cpp create mode 100644 tests/output/cpp/30830-kw_subst.cpp create mode 100644 tests/output/cpp/30831-kw_subst2.cpp create mode 100644 tests/output/cpp/30840-nl_func_type_name.cpp create mode 100644 tests/output/cpp/30841-nl_func_type_name.cpp create mode 100644 tests/output/cpp/30842-nl_func_type_name.cpp create mode 100644 tests/output/cpp/30845-deref.cpp create mode 100644 tests/output/cpp/30900-region.cpp create mode 100644 tests/output/cpp/30901-region.cpp create mode 100644 tests/output/cpp/30902-region.cpp create mode 100644 tests/output/cpp/30903-region.cpp create mode 100644 tests/output/cpp/30910-indent_namespace.h create mode 100644 tests/output/cpp/30911-indent_namespace.h create mode 100644 tests/output/cpp/30912-long_namespace.cpp create mode 100644 tests/output/cpp/30920-indent-off.cpp create mode 100644 tests/output/cpp/30921-variadic-template.h create mode 100644 tests/output/cpp/30922-variadic-template.h create mode 100644 tests/output/cpp/30930-indent_var_def.cpp create mode 100644 tests/output/cs/10000-simple.cs create mode 100644 tests/output/cs/10001-getset.cs create mode 100644 tests/output/cs/10002-simple.cs create mode 100644 tests/output/cs/10003-region.cs create mode 100644 tests/output/cs/10010-var-member.cs create mode 100644 tests/output/cs/10011-strings.cs create mode 100644 tests/output/cs/10020-region.cs create mode 100644 tests/output/cs/10021-region.cs create mode 100644 tests/output/cs/10022-region.cs create mode 100644 tests/output/cs/10023-region.cs create mode 100644 tests/output/cs/10030-sort_using.cs create mode 100644 tests/output/cs/10040-tcf.cs create mode 100644 tests/output/cs/10041-gs.cs create mode 100644 tests/output/cs/10050-generics.cs create mode 100644 tests/output/cs/10060-unsafe.cs create mode 100644 tests/output/d/40000-HashMap.d create mode 100644 tests/output/d/40001-imports.d create mode 100644 tests/output/d/40002-volatile.d create mode 100644 tests/output/d/40003-volatile-1.d create mode 100644 tests/output/d/40004-volatile-2.d create mode 100644 tests/output/d/40005-volatile-3.d create mode 100644 tests/output/d/40006-Lexer.d create mode 100644 tests/output/d/40007-Lexer.d create mode 100644 tests/output/d/40010-template.d create mode 100644 tests/output/d/40020-funcfunc.d create mode 100644 tests/output/d/40021-tst01.d create mode 100644 tests/output/d/40022-tst02.d create mode 100644 tests/output/d/40023-bug-indent.d create mode 100644 tests/output/d/40024-tst03.d create mode 100644 tests/output/d/40025-tst03.d create mode 100644 tests/output/d/40030-delegate.d create mode 100644 tests/output/d/40040-sort_import.d create mode 100644 tests/output/d/40050-strings.d create mode 100644 tests/output/d/40051-numbers.d create mode 100644 tests/output/d/40052-numbers.d create mode 100644 tests/output/ecma/90000-example-1.es create mode 100644 tests/output/oc/50001-Fraction.h create mode 100644 tests/output/oc/50002-Fraction.m create mode 100644 tests/output/oc/50003-main.m create mode 100644 tests/output/oc/50004-string.m create mode 100644 tests/output/oc/50005-Declarations.h create mode 100644 tests/output/oc/50006-exceptions.m create mode 100644 tests/output/oc/50007-misc.m create mode 100644 tests/output/oc/50010-oc-split.m create mode 100644 tests/output/oc/50010-return_type.m create mode 100644 tests/output/oc/50011-return_type.m create mode 100644 tests/output/oc/50012-return_type.m create mode 100644 tests/output/oc/50020-selector.m create mode 100644 tests/output/oc/50021-selector.m create mode 100644 tests/output/oc/50022-selector.m create mode 100644 tests/output/oc/50030-sort_import.m create mode 100644 tests/output/pawn/60000-functions.pawn create mode 100644 tests/output/pawn/60001-comment.p create mode 100644 tests/output/pawn/60002-traffic.p create mode 100644 tests/output/pawn/60003-tags.pawn create mode 100644 tests/output/pawn/60004-enum.pawn create mode 100644 tests/output/pawn/60005-unbraced.p create mode 100644 tests/output/pawn/60010-str-escape.p create mode 100644 tests/output/pawn/60020-switch-vsemi.sma create mode 100644 tests/output/pawn/60030-crusty_ex-1.sma create mode 100644 tests/output/sql/21000-mysql.sqc create mode 100644 tests/output/sql/21001-sta-select.sqc create mode 100644 tests/output/vala/70000-list.vala create mode 100644 tests/output/vala/70001-advanced.vala create mode 100644 tests/pawn.test create mode 100755 tests/run_tests.py create mode 100644 tests/tests.vpj create mode 100644 tests/vala.test create mode 100644 todo.txt create mode 100644 uncrustify.vpj create mode 100644 uncrustify.vpw create mode 100644 uncrustify.xcodeproj/project.pbxproj create mode 100755 update-default-cfg.sh create mode 100644 win32/Uncrustify_Win32.dsp create mode 100644 win32/Uncrustify_Win32.dsw create mode 100644 win32/Uncrustify_Win32.sln create mode 100644 win32/Uncrustify_Win32.vcproj create mode 100644 win32/Uncrustify_Win32_2005.sln create mode 100644 win32/Uncrustify_Win32_2005.vcproj create mode 100644 win32/windows_compat.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..ae200086a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +.svn +*.o +src/uncrustify +Makefile +man/Makefile +src/Makefile +src/stamp-h1 +*~ +config.log +config.status +*.vtg +*.vpwh* +tests/results +.waf* +.lock* +build +waf* +win32/Release +win32/Debug +*.obj +autom4te.cache diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000..f256cb178f --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +2005 - .... : Ben Gardner diff --git a/BUGS b/BUGS new file mode 100644 index 0000000000..05f2690d24 --- /dev/null +++ b/BUGS @@ -0,0 +1,67 @@ +------------------------------------------------------------------------------- +BUGS: + +Post any bugs to the issue tracker found on the project's Sourceforge page: + http://sourceforge.net/projects/uncrustify + +Before you do so, try running with the latest code from subversion. +The bug might have already been fixed. + +If it hasn't already been reported, then you'll need to file a bug report. + +First, reduce your input file to the minimum that still causes the problem. +This is important, as a 1000-line input file is much more difficult to diagnose +than a 5-line file. + +Next, rename your functions, change your strings, comments, etc, to protect +any trade secrets or whatnot. +If you attach an input file with a bug, it will most likely appear as a future +test case. + +Finally, create a bug report. + +Here's what I like to see in a bug report. + +1. The type of problem (crash or bad formatting) +2. The version of uncrustify you tested with (ie, rev 850) +3. The operating system +4. The input file or code snippet +5. The configuration file you used. + If it isn't one of the 'standard' ones, then attach it. +6. The expected output (not needed for crash bugs) + + +If you are the code writing type (and you are, since you are using a code +formatting tool), I'd like you to take a quick look and see if you can pinpoint +the source of the problem. + +Here is what I do when I get a bug report. + +1. Check for options that control the desired behavior. + About half the time a user missed an option. + +2. Run with the supplied input and config to verify the problem. + $ uncrustify -c bug.cfg -f bug.c + +2a. For a crash-bug, I create a core dump to quickly find the offending code. + $ ulimit -c unlimited + $ uncrustify -c bug.cfg -f bug.c + $ gdb uncrustify core + +3. Formatting bugs usually land in one of three catagories. + a. Incorrectly labeled chunks + b. Bad formatting logic or unexpected input + c. Missing options + +Debugging help: + +I run with the "-p" option to get a dump of the chunks. +$ uncrustify -c bug.cfg -f bug.c -p parsed.txt + +This tells me the configuration and how each chunk is labeled, indented, and +otherwise processed. + +I also selectively turn on log levels (the -L command line option) to aid +debugging of specific areas of interest. +Don't turn on all log levels -- the result is excessive and not at all helpful. + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/HELP b/HELP new file mode 100644 index 0000000000..fb3b2c8c42 --- /dev/null +++ b/HELP @@ -0,0 +1,56 @@ +------------------------------------------------------------------------------- +HELP: + +Are you looking to help with uncrustify development? Great! + +Here are some tasks that need to be done: + +1. New features + +Look at the feature requests on the Sourceforge project site. +Do any interest you? +Most are easily done, but I haven't had the 'itch' to implement them. + + +2. Test Coverage + +The test coverage right now is hardly adequate. +I would appreciate it if someone could make sure that every option is +tested and add tests as needed. +Automated testing is good. Without it, we can't detect regressions. +Any option that doesn't have an associated test isn't really supported. + + +3. Code cleanup + +I don't have much time to work on uncrustify. +When I do, it is usually a short span - only an hour or two. +This leads to unreachable code and doing the same thing in multiple places. + +Trace through the code and find these "problems". +I found one the other day in do_space(). A new feature didn't work because +several lines of code were not reachable. + + +4. Code redesign + +Code gets ugly over time when new features are added willy-nilly. +The problem is that the requirements are not known before the design is done. + +There are a few areas in particular that could benefit from a redesign. + +4a. brace_cleanup + +The code in brace_cleanup is ugly. It works, but it is ugly. +It was written with the assumption that there is no 'next' chunk. +I had planned to merge that code in with the tokenizer. +That didn't happen. +So we are left with code that is more complicated than it needs to be. +I haven't had the time or energy to revisit that code; I probably never will. +If you'd like to take a stab at it... the would be wonderful. + +4b. indent_text + +I think this function could be reworked to better take advantage of the +paren stack. + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000000..a4b34144dc --- /dev/null +++ b/INSTALL @@ -0,0 +1,229 @@ +Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000000..f84789ebbc --- /dev/null +++ b/Makefile.am @@ -0,0 +1,18 @@ +## Process this file with automake to produce Makefile.in + +AUTOMAKE_OPTIONS=foreign no-dependencies + +SUBDIRS = src man + +pkgdata_DATA = etc/ben.cfg etc/d.cfg etc/gnu-indent.cfg etc/kr-indent.cfg etc/linux-indent.cfg etc/linux.cfg etc/mono.cfg etc/xsupplicant.cfg + +# INCLUDES = @INCLUDES@ + +testdir = tests +TESTS = run_tests.sh + +check-local: + +DISTCLEANFILES = +CLEANFILES = *~ *.bak +MAINTAINERCLEANFILES = aclocal.m4 Makefile.in diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000000..c5587a8dd1 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,716 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ + INSTALL NEWS config.guess config.sub install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(pkgdatadir)" +pkgdataDATA_INSTALL = $(INSTALL_DATA) +DATA = $(pkgdata_DATA) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign no-dependencies +SUBDIRS = src man +pkgdata_DATA = etc/ben.cfg etc/d.cfg etc/gnu-indent.cfg etc/kr-indent.cfg etc/linux-indent.cfg etc/linux.cfg etc/mono.cfg etc/xsupplicant.cfg + +# INCLUDES = @INCLUDES@ +testdir = tests +TESTS = run_tests.sh +DISTCLEANFILES = +CLEANFILES = *~ *.bak +MAINTAINERCLEANFILES = aclocal.m4 Makefile.in +all: all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +install-pkgdataDATA: $(pkgdata_DATA) + @$(NORMAL_INSTALL) + test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)" + @list='$(pkgdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pkgdataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgdatadir)/$$f'"; \ + $(pkgdataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgdatadir)/$$f"; \ + done + +uninstall-pkgdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgdata_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d $(distdir) || mkdir $(distdir) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local +check: check-recursive +all-am: Makefile $(DATA) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(pkgdatadir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-pkgdataDATA + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-pkgdataDATA + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-TESTS check-am check-local \ + clean clean-generic ctags ctags-recursive dist dist-all \ + dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ dist-zip \ + distcheck distclean distclean-generic distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pkgdataDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-pkgdataDATA + + +check-local: +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000000..8b6344a058 --- /dev/null +++ b/NEWS @@ -0,0 +1,2 @@ +No news is good news! + diff --git a/README b/README new file mode 100644 index 0000000000..d01f6d1b42 --- /dev/null +++ b/README @@ -0,0 +1,56 @@ +README for Uncrustify +===================== + + +Building the program +-------------------- + +Quick start: + $ ./configure + $ make + +The executable is src/uncrustify. +Copy that to your ~/bin/ folder or wherever you want. + + +Configuring the program +----------------------- + +Examine the example config files in etc and/or read +documentation/htdocs/configuration.txt. +Copy the existing config file that closely matches your style and put in +~/.uncrustify/. Modify to your liking. + + +Running the program (and refining your style) +--------------------------------------------- + +As of the current release, I don't particularly trust this program to not make +mistakes and screw up my whitespace formatting. + +Here's how to run it: +$ uncrustify -c ~/.uncrustify/mystyle.cfg -f somefile.c > somefile.c.unc + +The -c option selects the configuration file. +The -f option specifies the input file. +The output is sent to stdout. Error messages are sent to stderr. + +Use a quality side-by-side diff tool to determine if the program did what you +wanted. +Repeat until your style is refined. + + +Running the program (once you've found your style) +-------------------------------------------------- + +Write a script to automate the above. +Check out etc/dofiles.sh for an example. +That script is used as follows: +1. navigate one level above your project +2. make a list of file to process + $ find myproj -name "*.[ch]" > files.txt +3. sh etc/dofiles.sh files.txt +4. Use your favorite diff/merge program to merge in the changes + $ xxdiff out/myproj myproj + + diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000000..fe20d44b47 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,908 @@ +# generated automatically by aclocal 1.10.2 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],, +[m4_warning([this file was generated for autoconf 2.63. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.10' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.10.2], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.10.2])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 5 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 13 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.60])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +AC_DEFUN([AM_MAINTAINER_MODE], +[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode is disabled by default + AC_ARG_ENABLE(maintainer-mode, +[ --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + USE_MAINTAINER_MODE=$enableval, + USE_MAINTAINER_MODE=no) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST(MAINT)dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000000..041027eb13 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,4 @@ +#! /bin/sh + +autoreconf --force --install + diff --git a/config.guess b/config.guess new file mode 100755 index 0000000000..9b1384be4b --- /dev/null +++ b/config.guess @@ -0,0 +1,1400 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002 Free Software Foundation, Inc. + +timestamp='2002-11-30' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# This shell variable is my proudest work .. or something. --bje + +set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ; +(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old) + || (echo "$me: cannot create $tmpdir" >&2 && exit 1) ; +dummy=$tmpdir/dummy ; +files="$dummy.c $dummy.o $dummy.rel $dummy" ; +trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $files ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; +unset files' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + eval $set_cc_for_build + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + $CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null + if test "$?" = 0 ; then + case `$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; + 3-1307) + UNAME_MACHINE="alphaev7" + ;; + esac + fi + rm -f $dummy.s $dummy && rmdir $tmpdir + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 + rm -f $dummy.c $dummy && rmdir $tmpdir + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 + rm -f $dummy.c $dummy && rmdir $tmpdir + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy && rmdir $tmpdir + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 + rm -f $dummy.c $dummy && rmdir $tmpdir + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + rm -f $dummy.c && rmdir $tmpdir + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:3*) + echo i586-pc-interix3 + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + rm -f $dummy.c && rmdir $tmpdir + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + rm -f $dummy.c && rmdir $tmpdir + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + rm -f $dummy.c && rmdir $tmpdir + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 +rm -f $dummy.c $dummy && rmdir $tmpdir + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.sub b/config.sub new file mode 100755 index 0000000000..f0675aa6b7 --- /dev/null +++ b/config.sub @@ -0,0 +1,1469 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002 Free Software Foundation, Inc. + +timestamp='2002-11-30' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* \ + | m32r-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39 | mipstx39el \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3d) + basic_machine=alpha-cray + os=-unicos + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic4x | c4x*) + basic_machine=tic4x-unknown + os=-coff + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 0000000000..d39d50a211 --- /dev/null +++ b/configure @@ -0,0 +1,7519 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.63 for uncrustify 0.54. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell bug-autoconf@gnu.org about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without shell functions. +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='uncrustify' +PACKAGE_TARNAME='uncrustify' +PACKAGE_VERSION='0.54' +PACKAGE_STRING='uncrustify 0.54' +PACKAGE_BUGREPORT='' + +ac_unique_file="src/uncrustify.cpp" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +EGREP +GREP +CPP +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +ac_ct_CC +CFLAGS +CC +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CXX +CPPFLAGS +LDFLAGS +CXXFLAGS +CXX +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_maintainer_mode +enable_dependency_tracking +' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { $as_echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { $as_echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 + { (exit 1); exit 1; }; } ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { $as_echo "$as_me: error: working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures uncrustify 0.54 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/uncrustify] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of uncrustify 0.54:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Some influential environment variables: + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CC C compiler command + CFLAGS C compiler flags + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +uncrustify configure 0.54 +generated by GNU Autoconf 2.63 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by uncrustify $as_me 0.54, which was +generated by GNU Autoconf 2.63. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test -r "$ac_site_file"; then + { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +am__api_version='1.10' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + +done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +$as_echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:$LINENO: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='uncrustify' + VERSION='0.54' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + +{ $as_echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + +ac_config_headers="$ac_config_headers src/config.h" + + +# Checks for programs. +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:$LINENO: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C++ compiler cannot create executables +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C++ compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + fi + fi +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +# Provide some information about the compiler. +$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:$LINENO: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:$LINENO: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +# Checks for libraries. + +# Checks for header files. + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in inttypes.h stdint.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in utime.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ $as_echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 +$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } +if test "${ac_cv_header_stdbool_h+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#ifndef bool + "error: bool is not defined" +#endif +#ifndef false + "error: false is not defined" +#endif +#if false + "error: false is not 0" +#endif +#ifndef true + "error: true is not defined" +#endif +#if true != 1 + "error: true is not 1" +#endif +#ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" +#endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +# if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a runtime + test, and that would make cross-compilation harder. + Let us hope that IBM fixes the xlc bug, and also adds + support for this kind of constant expression. In the + meantime, this test will reject xlc, which is OK, since + our stdbool.h substitute should suffice. We also test + this with GCC, where it should work, to detect more + quickly whether someone messes up the test in the + future. */ + char digs[] = "0123456789"; + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); +# endif + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdbool_h=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdbool_h=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 +$as_echo "$ac_cv_header_stdbool_h" >&6; } +{ $as_echo "$as_me:$LINENO: checking for _Bool" >&5 +$as_echo_n "checking for _Bool... " >&6; } +if test "${ac_cv_type__Bool+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_type__Bool=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if (sizeof (_Bool)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if (sizeof ((_Bool))) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type__Bool=yes +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 +$as_echo "$ac_cv_type__Bool" >&6; } +if test "x$ac_cv_type__Bool" = x""yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + +if test $ac_cv_header_stdbool_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STDBOOL_H 1 +_ACEOF + +fi + +{ $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if test "${ac_cv_c_const+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const /**/ +_ACEOF + +fi + +{ $as_echo "$as_me:$LINENO: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if test "${ac_cv_c_inline+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_inline=$ac_kw +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + + +# Checks for library functions. + +for ac_header in stdlib.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 +$as_echo_n "checking for GNU libc compatible malloc... " >&6; } +if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_malloc_0_nonnull=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif + +int +main () +{ +return ! malloc (0); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_malloc_0_nonnull=yes +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_malloc_0_nonnull=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } +if test $ac_cv_func_malloc_0_nonnull = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MALLOC 1 +_ACEOF + +else + cat >>confdefs.h <<\_ACEOF +#define HAVE_MALLOC 0 +_ACEOF + + case " $LIBOBJS " in + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<\_ACEOF +#define malloc rpl_malloc +_ACEOF + +fi + + + +{ $as_echo "$as_me:$LINENO: checking for working memcmp" >&5 +$as_echo_n "checking for working memcmp... " >&6; } +if test "${ac_cv_func_memcmp_working+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_memcmp_working=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Some versions of memcmp are not 8-bit clean. */ + char c0 = '\100', c1 = '\200', c2 = '\201'; + if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) + return 1; + + /* The Next x86 OpenStep bug shows up only when comparing 16 bytes + or more and with at least one buffer not starting on a 4-byte boundary. + William Lewis provided this test program. */ + { + char foo[21]; + char bar[21]; + int i; + for (i = 0; i < 4; i++) + { + char *a = foo + i; + char *b = bar + i; + strcpy (a, "--------01111111"); + strcpy (b, "--------10000000"); + if (memcmp (a, b, 16) >= 0) + return 1; + } + return 0; + } + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_memcmp_working=yes +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_memcmp_working=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5 +$as_echo "$ac_cv_func_memcmp_working" >&6; } +test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in + *" memcmp.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" + ;; +esac + + + +for ac_header in stdlib.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 +$as_echo_n "checking for GNU libc compatible realloc... " >&6; } +if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_realloc_0_nonnull=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *realloc (); +#endif + +int +main () +{ +return ! realloc (0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_realloc_0_nonnull=yes +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_realloc_0_nonnull=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } +if test $ac_cv_func_realloc_0_nonnull = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_REALLOC 1 +_ACEOF + +else + cat >>confdefs.h <<\_ACEOF +#define HAVE_REALLOC 0 +_ACEOF + + case " $LIBOBJS " in + *" realloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS realloc.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<\_ACEOF +#define realloc rpl_realloc +_ACEOF + +fi + + + + + + + + + + +for ac_func in memset strcasecmp strchr strdup strerror strtol strtoul +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +{ $as_echo "$as_me:$LINENO: checking whether our compiler supports __func__" >&5 +$as_echo_n "checking whether our compiler supports __func__... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +const char *cp = __func__ + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:$LINENO: checking whether our compiler supports __FUNCTION__" >&5 +$as_echo_n "checking whether our compiler supports __FUNCTION__... " >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +const char *cp = __FUNCTION__ + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define __func__ __FUNCTION__ +_ACEOF + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define __func__ __FILE__ +_ACEOF + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +ac_config_files="$ac_config_files Makefile src/Makefile man/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by uncrustify $as_me 0.54, which was +generated by GNU Autoconf 2.63. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTION]... [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_version="\\ +uncrustify config.status 0.54 +configured by $0, generated by GNU Autoconf 2.63, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { $as_echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { $as_echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; + + *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + $as_echo "$as_me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=' ' +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 +$as_echo "$as_me: error: could not setup config files machinery" >&2;} + { (exit 1); exit 1; }; } +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 +$as_echo "$as_me: error: could not setup config headers machinery" >&2;} + { (exit 1); exit 1; }; } +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 +$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + ac_file_inputs="$ac_file_inputs '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 +$as_echo "$as_me: error: could not create -" >&2;} + { (exit 1); exit 1; }; } + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000000..b660d56a16 --- /dev/null +++ b/configure.in @@ -0,0 +1,50 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59) +AC_INIT(uncrustify, 0.54) +AM_INIT_AUTOMAKE([-Wall]) +AM_MAINTAINER_MODE +AC_CONFIG_SRCDIR([src/uncrustify.cpp]) +AC_CONFIG_HEADER([src/config.h]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +# Checks for libraries. + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([inttypes.h stdint.h]) + +AC_CHECK_HEADERS([utime.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST +AC_C_INLINE + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_MEMCMP +AC_FUNC_REALLOC +AC_CHECK_FUNCS([memset strcasecmp strchr strdup strerror strtol strtoul]) + +AC_MSG_CHECKING([whether our compiler supports __func__]) +AC_TRY_COMPILE([], + [const char *cp = __func__], + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([whether our compiler supports __FUNCTION__]) + AC_TRY_COMPILE([], + [const char *cp = __FUNCTION__], + AC_MSG_RESULT([yes]) + AC_DEFINE(__func__, __FUNCTION__, + [Define to appropriate substitue if compiler doesnt have __func__]), + AC_MSG_RESULT([no]) + AC_DEFINE(__func__, __FILE__, + [Define to appropriate substitue if compiler doesnt have __func__]))) + +AC_CONFIG_FILES([Makefile src/Makefile man/Makefile]) +AC_OUTPUT diff --git a/do-c.sh b/do-c.sh new file mode 100644 index 0000000000..ad7221427b --- /dev/null +++ b/do-c.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +src/uncrustify -c etc/ben.cfg -p parsed.txt -f $1 $2 $3 $4 > out.c 2> out.err.txt diff --git a/do-d.sh b/do-d.sh new file mode 100644 index 0000000000..5bb3907a8d --- /dev/null +++ b/do-d.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +src/uncrustify -c etc/d.cfg -f $1 -p parsed.txt > out.d 2> out.err.txt diff --git a/documentation/align-thresholds.txt b/documentation/align-thresholds.txt new file mode 100644 index 0000000000..e0075adcb9 --- /dev/null +++ b/documentation/align-thresholds.txt @@ -0,0 +1,218 @@ +------------------------------------------------------------------------------- +Alignment thresholds: + +Alignment threshold are used to prevent aligning of certain text. + +Consider this example when aligning assignments: + + a = 2; + gld.settings[somevariable] = 5; + +Without thresholds, this would result in: + + a = 2; + gld.settings[somevariable] = 5; + +However, this is likely not desired. + +So to handle this, we set a limit on the number of columns that a alignment +may move a token. If we set the threshold to, say, 3 characters, then +the two would not be aligned together because 'a = 2' would have to be moved +by 25 columns. + +Here's a more complicated case: + + a = 1; + bb = 2; + ccc = 3; + dddd = 4; + eeeee = 5; + ffffff = 6; + +In this case, we may want this output: + + a = 1; + bb = 2; + ccc = 3; + dddd = 4; + eeeee = 5; + ffffff = 6; + +But, with a threshold of 3, 'a' and 'ffffff' cannot be aligned together. + +So how should these thresholds be implemented? + +One approach is to use the threshold as the maximum difference between the +current maximum and the new maximum. Using this approach, all 6 lines above +are aligned, because the change for each is 1 column. + +Consider this with a line-span of 3 and a column-threshold of 3. +Note that we'll now need to keep track of the last line processed. +(line and column numbers added for clarity) + + 111111 + 123456789012345 + --------------- +1 | a = 1; +2 | eeeee = 5; +3 | ffffff = 6; + +On line 1, the maxcol is set to 3. +On line 2, the maxcol would be set to 7, except that exceeds the threshold. +On line 3, the maxcol would be set to 8, except that exceeds the threshold. + +So, it ends up with one item in the align stack - line 1. +Then we pick up from where we left off - on line 2. +On line 2, the maxcol is set to 7. +On line 3, the maxcol is set to 8. + +End result: + 111111 + 123456789012345 + --------------- +1 | a = 1; +2 | eeeee = 5; +3 | ffffff = 6; + + +Now lets get tricky. + + 111111 + 123456789012345 + --------------- +1 | a = 1; +2 | eeeee = 5; +3 | ccc = 3; +4 | ffffff = 6; + +How should this be aligned? +I think we need to add another list - a 'skipped' list, that runs in parallel +with the 'aligned' list. + +On line 1, the maxcol is set to 3, added to the aligned list. +On line 2, col exceeds the threshold, so it is added to the skipped list. +On line 3, the maxcol is set to 5, added to the aligned list. +Now, after an item is added to the aligned list, the skipped list must be re-scanned. +We now see that line 2 is only 2 columns different, so it is added and maxcol = 7. +The skipped list is now empty. +On line 4, the maxcol is set to 8, added to the aligned list. + +So the output is: + + 111111 + 123456789012345 + --------------- +1 | a = 1; +2 | eeeee = 5; +3 | ccc = 3; +4 | ffffff = 6; + + +Now for a case where the skipped list is not absorbed: + + 111111 + 123456789012345 + --------------- +1 | a = 1; +2 | iiiiiiiiiiiiieeeee = 5; +3 | ccc = 3; +4 | ffffff = 6; + +On line 1, the maxcol is set to 3, added to the aligned list. +On line 2, col exceeds the threshold, so it is added to the skipped list. +On line 3, the maxcol is set to 5, added to the aligned list. +Skipped list is scanned, nothing moved from the skipped list to the aligned list. +On line 4, the maxcol is set to 8, added to the aligned list. + +So the output is: + + 111111 + 123456789012345 + --------------- +1 | a = 1; +2 | iiiiiiiiiiiiieeeee = 5; +3 | ccc = 3; +4 | ffffff = 6; + +As a reminder, the old system would have produced: + +1 | a = 1; +2 | iiiiiiiiiiiiieeeee = 5; +3 | ccc = 3; +4 | ffffff = 6; + +Which is probably not wanted. + + + + +--===---===---===---===-- +How to do this generically in the code... + +Easy case - one item per line. + +Here's the functions and what each do: +align_start(line_span, col_thresh) +align_add(pc) +align_flush() +align_newline(count) +align_end() + +For each entry, a sequence number is kept. + +align_start(line_span, col_thresh) + - initializes the align and skipped lists + - zero max_column + - zero cur_seqnum + - zero nl_count + +align_add(pc) + - update cur_seqnum, assign to item + - if item column is within threshold + - zero nl_count + - add to the aligned list + - if item column is > max_col + - update max_col + - re-adds all items on the skipped list + - if item column is not within threshold, add to skipped list + +align_newline(count) + - adds count to nl_count + - if nl_count > line_span, call align_flush() + +align_flush() + - step through all the items in aligned list and align the items to max_column + - keep the seq_num of the last aligned item + - zero max_column + - remove all items with a seq_num < last aligned seq_num + - call align_add on all remaining items in the skipped list + +align_end() + - call align_flush + - clear the lists + - free resources, etc + +Example usage: Aligning trailing comments + +void align_trailing_comments(void) +{ + chunk_t *pc; + + align_start(cpd.settings[UO_align_right_cmt_span], + cpd.settings[UO_align_right_cmt_thresh]); + + for(pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if ((pc->flags & PCF_RIGHT_COMMENT) != 0) + { + align_add(pc); + } + else if (chunk_is_newline(pc)) + { + align_newline(pc->nl_count); + } + } + + align_end(); +} + diff --git a/documentation/example.c b/documentation/example.c new file mode 100644 index 0000000000..7c8edf79c4 --- /dev/null +++ b/documentation/example.c @@ -0,0 +1,117 @@ + +const char *token_names[] = +{ + [CT_POUND] = "POUND", + [CT_PREPROC] = "PREPROC", + [CT_PREPROC_BODY] = "PREPROC_BODY", + [CT_PP] = "PP", +}; + + +int main(int argc, char *argv[]) +{ + struct junk a[] = + { + { "version", 0, 0, 0 }, + { "file", 1, 150, 'f' }, + { "config", 1, 0, 'c' }, + { "parsed", 25, 0, 'p' }, + { NULL, 0, 0, 0 } + }; +} + + +color_t colors[] = +{ + { "red", { 255, 0, 0 } }, { "blue", { 0, 255, 0 } }, + { "green", { 0, 0, 255 } }, { "purple", { 255, 255, 0 } }, +}; + + +struct foo_t bar = +{ + .name = "bar", + .age = 21 +}; + + +struct foo_t bars[] = +{ + [0] = { .name = "bar", + .age = 21 }, + [1] = { .name = "barley", + .age = 55 }, +}; + +void foo(void) +{ + int i; + char *name; + + i = 5; + name = "bob"; +} + +/** + * This is your typical header comment + */ +int foo(int bar) +{ + int idx; + int res = 0; // trailing comment + // that spans two lines + for (idx = 1; idx < bar; idx++) + /* comment in virtual braces */ + res += idx; + + res *= idx; // some comment + + // almost continued, but a NL in between + +// col1 comment in level 1 + return(res); +} + +// col1 comment in level 0 + + +#define foobar(x) \ + { \ + for (i = 0; i < x; i++) \ + { \ + junk(i, x); \ + } \ + } + + +void foo(void) +{ + switch(ch) + { + case 'a': + { + handle_a(); + break; + } + + case 'b': + handle_b(); + break; + + case 'c': + case 'd': + handle_cd(); + break; + + case 'e': + { + handle_a(); + } + break; + + default: + handle_default(); + break; + } +} + diff --git a/documentation/goals.txt b/documentation/goals.txt new file mode 100644 index 0000000000..610ec1213b --- /dev/null +++ b/documentation/goals.txt @@ -0,0 +1,24 @@ +------------------------------------------------------------------------------- +Goal: + +Do as little or as much reformatting as desired - everything should be configurable + +Features: + +Whitespace modifications + + Indent code (tabs, tabs + spaces, spaces) + - brace indenting + - paren continuation + - '=' continuation + - broken string continuation + - comment indenting + + Add/Remove spaces before/after/between symbols + + position braces (same line, cuddle else/while, etc) + +Non-whitespace modifications + + Put a '*' on the left in multi-line C comments + + Add/Remove outter-most parens on return expressions + + Add braces for 'fully braced' format + +(TODO: update the list to include more available features) + diff --git a/documentation/htdocs/ChangeLog b/documentation/htdocs/ChangeLog new file mode 100644 index 0000000000..8863db0406 --- /dev/null +++ b/documentation/htdocs/ChangeLog @@ -0,0 +1,745 @@ + + +Changes in uncrustify-0.54 (16 Oct 2009) +------------------------------------------------------------------------------- + - Add mod_case_brace + - Add sp_after_semi_for and sp_after_semi + - Add align_oc_msg_colon + - ObjC: Do not set the parent of everything in a message at OC_MSG (was breaking casts) + - ObjC: sp_before_square does not apply in "if (i < [a count])" + - Fix crash bug in chunk_get_prev() at the start of the file + - Fix issue with #if COND followed by a cast on the next line + - Add nl_func_decl_empty + - Add nl_func_type_name_class + - Add cmt_reflow_mode (Ger Hobbelt) + - A case statement starts an expression. Fixes "case -1:" + - Improve semicolon removal test + - fix marking of brace/paren pairs that have a preproc inside + - fix nl_func_type_name where the return type contains a template + - Add mod_full_brace_if_chain + - fix detection of deref in a macro function + - fix detection of "std::vector functions;" + - Remove extra semicolons on an 'else if' + - Add sp_before_ellipsis + - treat a constructor the same as a function regarding nl_func_decl_* + - Add nl_brace_brace + - Allow any number of spaces between multi-line comments when combining them + - Add pos_compare + - Add pos_conditional + - Fix indent_relative_single_line_comments + - Add sp_after_oc_return_type and sp_after_oc_at_sel (Andre Berg) + - Add indent_namespace_level (James LewisMoss) + - Add indent_namespace_limit (Maciej Libera) + + +Changes in uncrustify-0.53 (16 May 2009) +------------------------------------------------------------------------------- + - Fix sp_inside_braces* options, which were broken by the fix to issue #2629652 + - Fix sp_after_cast, which was broken by a previous fix + - Be a little more agressive in removing unecessary semicolons + - Fix one case where the parser leaves a preprocessor #define + - Fix indent of line starting with '(' after a function name + - Add align_var_def_attribute + - Fix nl_func_type_name for function without a return type (ie, cast operator) + - Reset up state variables after processing a file + - Fix a case where a semicolon was incorrectly removed + - Fix a case where braces were incorrectly removed + - Fix handling of 'force' setting for many newline options + - Add func_wrap type for use with 'set func_wrap FSUB' + - Add type_wrap type for use with 'set type_wrap STACK_OF' + - Make file replacement more atomic - write to a temp file then rename + - With the 'replace' option, only replace if the file content changes + - Handle C# wide literal string prefix S"foo" + - Handle the ObjC '@protocol' the same as '@interface' + - Add 'make check' and 'make clean' (Ger Hobbelt) + - Add align_right_cmt_at_col (Ger Hobbelt) + - Add sp_pp_concat and sp_pp_stringify (Ger Hobbelt) + - Add mod_add_long_ifdef_{else,endif}_comment (Ger Hobbelt) + - Objective C improvements (Etienne Samson) + - Only mess with escaped newlines in a comment if inside a preprocessor + - Fix pos_xxx options when a preprocessor is near + - Apply Debian patch to man file + - Fix '<<' indenting/aligning (moved from indent.cpp to align.cpp) + - Rework the sp_before_nl_cont option + - Fix a few other bugs + + +Changes in uncrustify-0.52 (28 Feb 2009) +------------------------------------------------------------------------------- + - Add sp_before_assign and sp_after_assign + - Add sp_enum_before_assign and sp_enum_after_assign + - Add indent_var_def_blk + - Add sp_inside_sparen_close for the 'CGAL' style + - First pass at supporting ECMAScript (.es) files + - Add support for the C# '??' operator + - Fix conflict between nl_after_func_proto_group and nl_squeeze_ifdef + - Add sp_cmt_cpp_start + - Add align_on_operator + - Fix nl_func_type_name for operators + - Allow '$' to be part of identifiers (global change) + - Fix detection of the '*' in 'int a = b[0] * c;' + - Fix and improve the description of nl_multi_line_cond + - Fix handling of global namespace type such as '::sockaddr' + - Add nl_after_brace_close + - Add nl_func_scope_name + - Add cmt_insert_file_footer + + +Changes in uncrustify-0.51 (27 Nov 2008) +------------------------------------------------------------------------------- + - Prefer to split at ',' and then '=' in for() statements if at paren level + - Fix a NULL deref crash + - Fix nl_namespace_brace when something trails the open brace + - Get sp_after_sparen and sp_sparen_brace to play well together + - Ignore trailing comments when inserting the function header comment + - Combine two C comments when they have no space between them "/***//***/" + - Add cmt_insert_before_preproc + - Add mod_remove_empty_return + - Add nl_comment_func_def + - Fix aligning of anonymous bit fields + - Add indent_align_assign + - Add sp_before_case_colon + - Fix D 'invariant' handling + - Add sp_invariant_after_paren and sp_invariant_paren + - Fix handling of the C# [assembly: xxx] construct + - Fix handling of the C# 'base()' construct + - Add sp_range for the D '..' range operator as in [start .. end] + - Update $(fclass) and $(function) to handle operators + - Improve handling of inserted comments + - Enable 'finally' blocks for C# + - Add nl_after_try_catch_finally + - Add nl_between_get_set and nl_around_cs_property + + +Changes in uncrustify-0.50 (25-Oct-2008) +------------------------------------------------------------------------------- + - Fix sp_before_unnamed_ptr_star in 'char ** n' + - Fix crash when a open brace is at the end of a file + - ObjC class definitions do not need { } + - Fix ObjC msg detection + - Add sp_after_ptr_star_func, sp_before_ptr_star_func + - Add sp_after_byref_func, sp_before_byref_func + - Treat an ObjC msg decl more like a function def + - Add indent_func_const, indent_func_throw (Thanks, Ron) + - Fix detection of prototype inside extern or namespace braces + - Add align_left_shift to handle aligning of '<<' + - Add sp_cpp_cast_paren + - Add support for ObjC '@property' statements + - Add sp_brace_typedef and sp_case_label + - Merge in the lastest UniversalIndent support (Thanks, Thomas!) + - Fix extra '\r' in multi-line comments and strings + - Add sp_throw_paren + - Assume a '<' in a preprocessor can't be part of a template + - Don't align a constructor with class variables + - Fix ending column error when tokenizing strings + + +Changes in uncrustify-0.49 (22-Aug-2008) +------------------------------------------------------------------------------- + - Allow the MSVC++ '64' suffix on numbers + - Initialize align_stack class members for the MSVC++ compiler + - Indent a line that starts with '=' + - Add pos_arith and pos_assign (Thanks, Ron!) + - Fix pos_bool & code_width interaction (Thanks, Ron!) + - Fix cmt_width, which was going one word over the limit. (Thanks, Ron!) + - Major rework of the aligning code to better handle the gap options + - Indent comments before 'case' at the same level as 'case' + - mod_add_long_*_closebrace_comment adds the right comment type. (Thanks, Ron!) + - Relax number parsing even further to accept stuff like "3A" + - Add sp_after_oc_colon (Thanks, Kevin!) + - Add better detection and labeling of Objective C messages + - Add sp_after_send_oc_colon and sp_before_send_oc_colon (Thanks, Kevin!) + - Fix detection of '*' in "return n * f();" + - Add the 'set' config option which lets you create arbitrary keywords + - Add sp_func_call_user_paren and the 'func_call_user' keyword type + + +Changes in uncrustify-0.48 (18-Jul-2008) +------------------------------------------------------------------------------- + - Fix classification of '(' in '#if defined (FOO)' + - Add sp_defined_paren + - Fix handling of negative in '#if X < -1' + - Revert a change that broke indent continuation in an assignment + - Fix interaction between nl_squeeze_ifdef and nl_after_{if,for,while,switch,do} + - Preprocessor indents are indents, so indent_with_tabs=1 should do tabs + - Add pp_indent_count + - Handle C++ style casts, such as 'int(42.0)' a bit better + - Another rework of template detection + - Add sp_before_nl_cont, defaults to 'add' + - If a statement starts with 'operator', it is a function call + - Change sp_angle_word to be more generic + - Add sp_after_operator_sym for "operator ++(" vs "operator ++ (" + - Add sp_template_angle for "template<" vs "template <" + - Add support for " *INDENT-OFF* " and " *INDENT-ON* " + - Shuffle around spacing priorities + - Add handling for '...' in variadic templates + - Extend nl_template_class to handle anything after 'template <...>' + - Treat the template '<' the same as '(' for indenting + - Add indent_template_param + - Split internal CT_CAST into CT_C_CAST, CT_CPP_CAST and CT_D_CAST + - Swap priority of sp_after_angle and sp_before_ptr_star + - Change cmt_multi_indent=false to disable all reformatting (needs more work) + - Fix align_var_def_span - it wasn't counting newlines when it recursed + - Add nl_else_if + - mod_full_brace_if: Don't remove braces around certain 'else' statements + - Tweak template detection a bit more + - Rework and simplify multi-line comment indenting + - Add indent_else_if + - Improve right-comment aligning + - Fix detection of functions with a 'const' return type + - Add sp_cond_colon and sp_cond_question + - Fine-tune the right comment align stuff + - Add cmt_multi_check_last + - Add align_right_cmt_gap + - Add nl_return_expr + - Indent FPAREN_OPEN if after a newline but not before a newline + - Give sp_after_operator_sym priority over sp_func_call_paren + - Add align_same_func_call_params + + +Changes in uncrustify-0.47 (06-Jun-2008) +------------------------------------------------------------------------------- + - Fix inifinite loop bug in reindent_line + - Fix prototype detection with template parameter types + - Fix off-by-1 error on positive values for indent_access_spec and indent_label + - Add indent_extern to control indent extern-type namespaces + - Add initial support for Objective C++ (extension '.mm') + - Add nl_before_throw and indent 'throw' if after a prototype + - Extend line numbers to 32 bits (used for logging) + - Remove alternate token support for '<%', '%>', '<:', ':>', '%:', and '%:%:' + - Fix recently-broken mixing of right-comment aligning (PP_ENDIF/PP_ELSE issue) + - Indent a 'break' that follows a fully-braced 'case' at the level of the + close brace + - Add mod_move_case_break + - Fix '&' and '*' after 'delete' + - Escape opening '/*' when converting C++ comments to C comments + - Add sp_inside_braces_empty + - Fix cmt_sp_after_star_cont + - Fix cmt_sp_before_star_cont + - Explicitly disallow a tab after a space + - Improve multi-line comment indenting a bit + - Add sp_before_unnamed_byref and sp_before_unnamed_ptr_star + + +Changes in uncrustify-0.46 (22-Apr-2008) +------------------------------------------------------------------------------- + - Load the config file, if available, before handling '--universalindent' + - Add align_var_def_gap, align_var_def_colon_gap, align_var_struct_gap, + align_func_proto_gap, align_mix_var_proto, align_single_line_brace_gap + - (internal) Eliminate the 'trailer' stuff, simplify aligning + + +Changes in uncrustify-0.45 (7-Mar-2008) +------------------------------------------------------------------------------- + - Fix buffer overflow in logger code + - Add sp_enum_assign + - For elipses handling in the GCC extension "case 1 ... 5:" + - Add sp_after_class_colon, sp_before_class_colon, and sp_after_type + - Send usage text to stdout instead of stderr + - Fix mod_add_long_function_closebrace_comment if the file doesn't end in a newline + - Redo alignments after splitting long lines + - Add indent_relative_single_line_comments + - Add indent_access_spec_body + - Fix indent_func_proto_param to work on constructors + - Add cmt_indent_multi + - Add align_single_line_brace and align_single_line_func + - Fix interaction of virtual braces and #pragma + - Fix indenting problem with an assignment the last part of a for() + - Fix the order of opening files so that '-f' and '-o' can be used together + - Added a man file + - Many improvements thanks to Stas Grabois + - Fix a D problem due the lack of semicolons after struct/enum definitions + - Improve the way aligning is done + + +Changes in uncrustify-0.44 (12-Feb-2008) +------------------------------------------------------------------------------- + - Fix issue with #else and unmatched braces (issue 1868493) + - Update UnivarsalIndentGUI config output + - Add the version to generated config files + - Add nl_multi_line_define + - Minimize distance between code and the backslash-newline in macros + - Properly handle stuff like '#define MYHEADER ' + - Fix detection of 'int foo(int);' in C++ (func proto, not class variable) + - Improve handling of multi-line comments in a macro + - Fix crash bug with some ctype implementations + - Fix incorrect indenting of nested #endif with pp_if_indent_code + - Fix problem with nl_after_if and nl_before_if w/ trailing comments + + +Changes in uncrustify-0.43 (08-Jan-2008) +------------------------------------------------------------------------------- + - Add align_right_cmt_mix to control aligning of comments after '}' and '#endif' + - Allow a line split after an assignment + - Fix infinite loop bug + - Add sp_sign and sp_incdec + - Fix vbrace conversion where some are converted and some aren't + - Add a vbrace before a #pragma instead of after + - Improve Objective C support + - Add sp_before_oc_colon, sp_after_oc_scope, and sp_after_oc_type for ObjC + - Add align_oc_msg_spec_span for ObjC + - Add sp_member for spacing around '->' and '.' + - More template handling improvements + - Fix a NULL dereference related to __attribute__ + + +Changes in uncrustify-0.42 (30-Nov-2007) +------------------------------------------------------------------------------- + - Fix bug that would remove a newline after a C++ comment + - Add "--mtime" command line option to preserve the mtime + - Remove extra semicolons before inserting newlines after semicolons + - Fix broken struct initializer alignment + - Fix problem with pos_class_comma in a #define + - Fix problem with an incomplete statement in a #define and virtual braces + - Add indent_func_proto_param and indent_func_def_param + - Add nl_func_proto_type_name, split from nl_func_type_name + - Add mod_add_long_switch_closebrace_comment, mod_add_long_function_closebrace_comment + - Add mod_sort_import to sort import statements (Java/D) + - Add mod_sort_using to sort using statements (C#) + - Add mod_sort_include to sort #include (C/C++) and #import (ObjC) statements + - Add indent_func_class_param, indent_func_ctor_var_param, and + indent_func_param_double + - Fix inserting a newline before a preprocessor + - Don't split empty function parens for code_width stuff + + +Changes in uncrustify-0.41 (07-Nov-2007) +------------------------------------------------------------------------------- + - Add cmt_insert_func_header, cmt_insert_file_header, and cmt_insert_class_header + - Fix detection of prototypes without named parameters + - sp_after_byref and sp_after_ptr_star only are applied if before a word + - internal rework + - Add pp_define_at_level + - Fix detection of deref in "sizeof *x" + - Fix broken output of backslash-newline in certain situations + - Fix pp_indent_if stuff + - Add nl_after_brace_open_cmt + - Properly handle anonymous namespaces + - Add pp_space_count + + +Changes in uncrustify-0.40 (12-Oct-2007) +------------------------------------------------------------------------------- + - Simplify preprocessor indenting + - Add pp_indent_region and pp_region_indent_code + - Add pp_indent_at_level + - Add pp_indent_if and pp_if_indent_code + - Add initial VALA support + - Fix a problem with mod_full_paren_if_bool and functions + - Add nl_func_paren + - Fix function type parameter marking (broken in the last few releases) + - Don't remove newline chunks before/after a preprocessor + + +Changes in uncrustify-0.39 (25-Sep-2007) +------------------------------------------------------------------------------- + - Improve conversion operators + - Prevent undesired chunk combining ("~ ~" vs "~~" in D) + - Add nl_after_multiline_comment + - Fix handling of try/catch/finally blocks in virtual braces + - Add sp_inv, sp_not, sp_addr, sp_deref (default to remove) + - Fix nl_class_brace + - Fix indent_func_call_param + - Add nl_create_if_one_liner, nl_create_for_one_liner, nl_create_while_one_liner + - Add indent_preserve_sql + - Fix one-liner detection with multiple statements on one line + - Add nl_func_leave_one_liners and nl_if_leave_one_liners + - More template improvements + + +Changes in uncrustify-0.38 (04-Sep-2007) +------------------------------------------------------------------------------- + - Fix line splitting WRT the CT_SPACE token + - Improve function call/prototype/definition detection + - Fix some spacing issues + - More template improvements + - Allow for a C++ struct constructor + - Add nl_before_access_spec and nl_after_access_spec + - Add cmt_width, cmt_c_group, cmt_c_nl_start, cmt_c_nl_end + - Handle conversion operators + + +Changes in uncrustify-0.37 (16-Aug-2007) +------------------------------------------------------------------------------- + - A bunch of D language improvements + - Add sp_d_array_colon, nl_assign_square, nl_after_square_assign + - Fix static keyword sort order + - Improve typedef detection and aligning + - Split nl_ds_struct_enum_close_brace out of nl_ds_struct_enum_cmt + - Add indent_paren_close + - Add indent_comma_paren and indent_bool_paren + + +Changes in uncrustify-0.36 (04-Aug-2007) +------------------------------------------------------------------------------- + - Add nl_after_vbrace_open + - Improve option descriptions + - Fix seg faults (check for NULL) + - Fix spacing for operators () and [] + - Add sp_before_dc and sp_after_dc to control spacing around '::' + - Split pos_class_comma from pos_comma + - Improve line splitting a little - no longer break at '::' or '->' or '.' + - Add nl_enum_leave_one_liners and nl_getset_leave_one_liners + - Add mod_remove_extra_semicolon + - Fix handling of macro-open and macro-close + - Add align_var_struct_thresh + - Improve handling of comments after braces + - Add support for Qt slots and signals + - Add align_typedef_amp_style and align_var_def_amp_style + - Add sp_attribute_paren and handling of the '__attribute__' macro + - Add align_typedef_func, improve aligning of typedefs + - Add sp_after_semi_for_empty + + +Changes in uncrustify-0.35 (14-Jul-2007) +------------------------------------------------------------------------------- + - Fix bug with nl_func_type_name and empty param list: int foo() { ... } + - Don't parse pragma bodies + - Properly indent multiline #error and #warning + - Change nl_after_func_body to force the newline count (was a minimum) + - Fix handling of CT_PTR_STAR when all options are AV_IGNORE + - Fix problem when the first token in the file isn't in column 1 + - Properly mark catch clauses that contain parameters, ie catch (Exception *e) + - Add a newline after the open brace for nl_catch_brace, nl_do_brace, + nl_else_brace, nl_try_brace, nl_getset_brace, nl_finally_brace + - Add nl_multi_line_cond + - Fix a bug with mod_full_paren_if_bool + - Fix handling of templated variables: Buffer* buf + - Fix handling of dynamic_cast(obj) stuff + - Fix detection of templates in for() statements: + for (std::map::iterator it = map.begin(); ... + - Add --no-backup command-line option to replace w/o a backup file + - Fix nl_class_leave_one_liners when set to false + - Add nl_class_colon, which split the functionality of nl_class_init_args + - Improve detection of reference variable declarations (A& B) + + +Changes in uncrustify-0.34 (11-May-2007) +------------------------------------------------------------------------------- + - Add sp_angle_paren and sp_angle_word + - Properly handle multi-line CPP comments + - Add sp_inside_paren_cast + - improve indent_class_colon + - fix indenting on open parens + - Add sp_before_semi_for_empty + - Fix detection of while if the do is in a preprocessor chunk (1675673) + - (pawn) Don't add vsemi after case/switch brace close (1684840) + - Add nl_assign_leave_one_liners to allow "foo_t foo = { 0, 1 };" + - Change handling of #region stuff so that it is indented at brace level + - Fix handling of missing semicolon after while-of-do. + - Fix crash-bug in handling bad code: "if (a && );" + - Add pos_comma + + +Changes in uncrustify-0.33 (05-Mar-2007) +------------------------------------------------------------------------------- + - Fix converting C++ comments with embedded C comments + - Fix nl_func_var_def_blk with class variables + - Fix some output issues with the 1st line and C++ comments + - Eliminate indent_case_body, which wasn't used + - Change rules for indenting case braces and the use of indent_case_brace + - Fix variable declaration detection at the start of a code block + - Add support for custom open/close indenting macros + MACRO_OPEN, MACRO_ELSE, MACRO_CLOSE + - Fix the config updating routines to NOT lose custom types and stuff + - Add nl_after_func_body_one_liner + - Fix nl_class_init_args + - Add --universalindent option to output an ini file for UniversalIndentGUI + + +Changes in uncrustify-0.32 (20-Feb-2007) +------------------------------------------------------------------------------- + - Enable align_proto_var_def for constructors + - Fix while-of-do handling inside virtual braces + - Fix problem with comments between a close brace and else + - Add sp_before_comma + - Change align_var_def_star to align_var_def_star_style + - Change align_proto_var_def to align_func_params + - Add ls_func_split_full and ls_for_split_full + - Rework code width code a bit + - Start Objective C support + - Add cmt_sp_before_star_cont and cmt_sp_after_star_cont + - Fix spacing between (( and )) + - Add nl_try_brace, nl_catch_brace, nl_finally_brace, nl_brace_catch, + nl_brace_finally, sp_catch_brace, sp_brace_catch, sp_finally_brace, + sp_brace_finally, sp_try_brace + - Treat typedef functions the same as other function for param aligning + - Turn any word after a enum/struct/union into a type + - Add sp_getset_brace and nl_getset_brace + - Add mod_full_paren_if_bool + - Add nl_before_c_comment and nl_before_cpp_comment + - Fix nl_class_leave_one_liners + - Add nl_ds_struct_enum_cmt + - Add sp_balance_nested_parens + + +Changes in uncrustify-0.31 (24-Jan-2007) +------------------------------------------------------------------------------- + - Improve mixed tab indent / space align + - Try to fix spacing around embedded comments + - Add indent_access_spec + - Add __func__ and __FUNCTION__ detection for non-C99 compilers + - General code cleanup (Thanks Tom!) + - Add indent_xml_string + - Add align_proto_var_def to align variables in prototypes + + +Changes in uncrustify-0.30 (24-Nov-2006) +------------------------------------------------------------------------------- + - Use environment variable UNCRUSTIFY_CONFIG if no '-c' option (non-WIN32) + - Default to ~/.uncrustify.cfg if no '-c' option and no env var (non-WIN32) + - Add '-q' option to the usage info + - Added initial embedded SQL support + - Many bug fixes + - New options: indent_braces_no_func, indent_sing_line_comments, nl_before_if, + nl_before_for, nl_after_for, nl_before_while, nl_after_while, + nl_before_switch, nl_after_switch, nl_before_do, nl_after_do + + +Changes in uncrustify-0.29 (26-Oct-2006) +------------------------------------------------------------------------------- + - Add support for the 'Klaus' style + - Fix a bunch of c++ template bugs + - Add option nl_class_leave_one_liners + + +Changes in uncrustify-0.28 (06-Oct-2006) +------------------------------------------------------------------------------- + - Fix D range array detection a[1..4] => a[1 .. 4] + - Fix D delegate variable aligning + - More documentation updates (thanks Dirk!) + - New options: nl_after_semicolon and nl_after_open_brace + + +Changes in uncrustify-0.27 (23-Sep-2006) +------------------------------------------------------------------------------- + - Improve template detection again (allow CT_TYPE in a template) + - Fix bad formatting in "[ABC * 123]" and "[0xf & *val]" + - Add --replace option to convert files in-place + - Use a map for the options + - Major configuration/option cleanup + - add -o option to write to a file instead of stdout + + +Changes in uncrustify-0.26 (09-Sep-2006) (removed a number from the version) +------------------------------------------------------------------------------- + - Fix preprocessor labeling WRT comments + - Fix an indenting problem + - Add sp_after_byref + - Fix alignment of global variable definitions + - Fix detection of deref inside squares: a[*p] + - Fix a weird indenting bug + - Fix D template ! spacing + - Add sp_after_operator + - Add nl_template_class + - Add start to detailed docs inside the program + - Add --prefix and --suffix command line args + - Add align_enum_equ_thresh and fix align_enum_equ_span + - Fix formatting of function typedefs + - Add indent_member + - Simplify the indenting code a bit + - Improve type_cast stuff (ie, dynamic_cast<> or static_cast<>) and templates + + +Changes in uncrustify-0.0.25 (26-Aug-2006) +------------------------------------------------------------------------------- + - Add sp_after_ptr_star, sp_before_ptr_star, sp_between_ptr_star + - Fix D tokenizing for numbers and strings + - Fix a bug with cast detection and with nl_after_func_proto + - Improve template detection + - Rename nl_bool_pos to pos_bool + - Add pos_class_colon + - Add indent_class_colon + - Add nl_class_init_args + - Add nl_collapse_empty_body + - Add indent_square_nl + + +Changes in uncrustify-0.0.24 (05-Aug-2006) +------------------------------------------------------------------------------- + - Add initial PAWN support (thanks to Derek Evan Mart for testing and motivation!) + - Fix parsing of numbers like 10.0 + - Fix double negative (- -x) vs (--x) + - Add ability to convert C++ (//) comments into C (/* */) comments + - Fix usage of indent_columns; output_tab_size is only needed if using tabs + - Add first small step in code width handling + - New options: sp_fparen_brace, sp_macro, sp_marco_func, + nl_elseif_brace, mod_pawn_semicolon, cmt_cpp_to_c, cmt_cpp_group, + cmt_cpp_nl_start, cmt_cpp_nl_end, sp_after_tag + + +Changes in uncrustify-0.0.23 (22-Jul-2006) +------------------------------------------------------------------------------- + - Fix some crash bugs and some formatting problems + - Fix Windows CRLF issues (binary vs text mode) + - Add indent_class and indent_namespace + - Add nl_class_brace and nl_namespace_brace + - Add handling of operator stuff in CPP + - Improve the test script a bit + - Add sp_inside_fparens + - Add ability to define types in the config file + - Started work on improving #ifdef handling by evaluating the preprocessor + + +Changes in uncrustify-0.0.22 (15-Jul-2006) +------------------------------------------------------------------------------- + - Implement nl_max, nl_before_block_comment, nl_after_func_body, + nl_after_func_proto, nl_after_func_proto_group + - Improve detection of function prototypes + - Improve marking of function prototype-related tokens + - Improve variable definition aligning + - fix align_var_def threshold + - Improve handling of "private:" style stuff + - Handle types with "::" in them + - Add preprocessor spacing and indenting + - Fix tab indenting style 1 (tab indent, space align) + - Improve multi-line comment formatting + + +Changes in uncrustify-0.0.21 (01-Jul-2006) +------------------------------------------------------------------------------- + - Clean up some memory leaks & uninitialized variables + - Add option to process multiple files at once + - Change the newlines values from [UNIX, DOS, MAC] to [LF, CRLF, CR] + - Properly mark the parens for functions + - Implement control over the format of the function prototypes and definitions + - Update configuration.txt + + +Changes in uncrustify-0.0.20 (10-Jun-2006) +------------------------------------------------------------------------------- + - Fix cast on a sizeof: (INT32)sizeof(x) + - Fix this: "#define SOME_JUNK /*lint -e123 */(const mytype_t *)-1" + - Don't align function typedefs (fixed again) + - Finally fix the DOS and MAC line-ending support + - Add line-ending autodetection + - Add Windows build support + + +Changes in uncrustify-0.0.19 (27-May-2006) +------------------------------------------------------------------------------- + - Fix C/C++/C# casts + - Improve D casts + + +Changes in uncrustify-0.0.18 (12-May-2006) +------------------------------------------------------------------------------- + - Add nl_bool_pos to move boolean ops between eol and sol + - Improve C99 array initializer aligning/formatting + - Replace nl_eat_start, nl_eat_end, and nl_eof_min with nl_start_of_file, + nl_start_of_file_min, nl_end_of_file, and nl_end_of_file_min + + +Changes in uncrustify-0.0.17 (03-May-2006) +------------------------------------------------------------------------------- + - Add nl_eat_start to remove newlines at the start of the file + - Add nl_eat_end to remove newlines at the end of the file + - Add nl_eof_min to set the minimum number of newlines at the end of file + - Add newlines setting to configure the newline output + - Add '-q' command line option to turn off logging + - Fix bug in nl_func_var_def_blk handling + + +Changes in uncrustify-0.0.16 (21-Apr-2006) +------------------------------------------------------------------------------- + - Add a stack alignment helper class + - Improve typedef formatting + - Add aligning thresholds for typedefs and assignments + - update the automake/autoconf stuff + + +Changes in uncrustify-0.0.15 (14-Apr-2006) +------------------------------------------------------------------------------- + - Switch to C++ + - Improve C++ template formatting + - Improve C++ class handling + + +Changes in uncrustify-0.0.14 (09-Apr-2006) +------------------------------------------------------------------------------- + - Read from stdin if no file is specified + - Build on OS X + + +Changes in uncrustify-0.0.13 (07-Apr-2006) +------------------------------------------------------------------------------- + - Rewrite the indent code + - Fix a bunch of small problems with C casts + - Rename a few files + - Add more tests + + +Changes in uncrustify-0.0.12 (30-Mar-2006) +------------------------------------------------------------------------------- + - Add support for D template format "Foo!(int,char)" + - Fix a format bug in a log + - Fix elipsis spacing (remove space before elipsis) + - Don't use getopt as it isn't all that portable (at least for QNX) + - Rename some files + - Bugfix: don't add virtual braces on the same line as a preprocessor + - Bugfix: clean up indexed array aligning + + +Changes in uncrustify-0.0.11 (27-Mar-2006) +------------------------------------------------------------------------------- + - fix brace analysis on else statement + - allow options to depend on other options + - set the parent for case braces + - handle/indent the C++ class colon thingy + - handle C++ constructors and function defs + - special handling for '::' operator + - implement case indenting + - handle cout '<<' indenting + - handle DOS and MAC line endings in multiline comments + - rename some indent options + - fix ifndef handling + - fix volatile handling + - fix private/public/protected 'label' handling + - alternate punctuators are also part of C++ + - handle C++ wide L"strings" + - improve C# get/set handling + - fix spacing bug "a++;" vs "a ++;" due to statement start misdetect + - add nl_assign_brace + - fix parent of vbrace close + - more test enhancements + + +Changes in uncrustify-0.0.10 (22-Mar-2006) +------------------------------------------------------------------------------- + - Complete rewrite of tokenizer and brace parser + - Added support for D nested comments + - Fixed some virtual brace bugs + - Added some documentation for the brace parsing stuff + - Add more tests to improve coverage (still lacking) + + +Changes in uncrustify-0.0.9 (18-Mar-2006) +------------------------------------------------------------------------------- + - Major enhancements for D + - Add handling for special "[]" sequence for C#/D + - add some more tests + + +Changes in uncrustify-0.0.8 (13-Mar-2006) +------------------------------------------------------------------------------- + - update TODO list + - add a threshold for brace removal + - improve brace removal + - keep track of whether a token follows a tab + - add option to preserve non-indenting tabs + - major keyword and operator cleanup for C++, C#, D, and Java + - add 'string' variants for ARITH, COMPARE, etc + - add C# get/set detection + - add template detection + - add colon handling for class stuff and anonymous bitfields + - pop the whole indent stack when leaving a preprocessor + - fix embedded return handling in C#, ie: [ this should return negative ] + - fix a problem with the ifdef frame stack (still a problem lurking...) + - handle literal strings (C#) + - handle non-keyword words (C#) -- example: @if @switch + - set the parent on 'do' braces + - handle C# #region preprocessor stuff + - partially implement align on tabstop + - fix virtual brace spacing (no more "else return;" => "elsereturn;") + - add some more tests + diff --git a/documentation/htdocs/ben.cfg.txt b/documentation/htdocs/ben.cfg.txt new file mode 100644 index 0000000000..81ed71f44c --- /dev/null +++ b/documentation/htdocs/ben.cfg.txt @@ -0,0 +1,114 @@ +# +# My favorite format +# +# $Id: ben.cfg 408 2006-08-11 02:08:30Z bengardner $ +# + +newlines = LF # AUTO (default), CRLF, CR, or LF + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +# indent_label = 0 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_class = true + +nl_start_of_file = remove +# nl_start_of_file_min = 0 +nl_end_of_file = force +nl_end_of_file_min = 1 +nl_max = 4 +nl_before_block_comment = 2 +nl_after_func_body = 2 +nl_after_func_proto_group = 2 + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +pos_bool = trail # BOOL ops on trailing end + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_func_class_paren = remove +sp_before_angle = force +sp_after_angle = force +sp_inside_angle = remove +sp_sparen_brace = add +sp_fparen_brace = add +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 1 +align_var_def_thresh = 12 +align_var_def_inline = TRUE +align_var_def_star = TRUE +align_var_def_colon = TRUE +align_assign_span = 1 +align_assign_thresh = 12 +align_struct_init_span = 3 +align_var_struct_span = 99 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + diff --git a/documentation/htdocs/config.txt b/documentation/htdocs/config.txt new file mode 100644 index 0000000000..44555c012e --- /dev/null +++ b/documentation/htdocs/config.txt @@ -0,0 +1,915 @@ +# Uncrustify 0.43+svn +# +# General options +# + +newlines { Auto, LF, CR, CRLF } + The type of line endings + +input_tab_size Number + The original size of tabs in the input + +output_tab_size Number + The size of tabs in the output (only used if align_with_tabs=true) + +string_escape_char Number + The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) + +string_escape_char2 Number + Alternate string escape char for Pawn. Only works right before the quote char. + +# +# Indenting +# + +indent_columns Number + The number of columns to indent per level. + Usually 2, 3, 4, or 8. + +indent_with_tabs Number + How to use tabs when indenting code + 0=spaces only + 1=indent with tabs, align with spaces + 2=indent and align with tabs + +indent_align_string { False, True } + Whether to indent strings broken by '\' so that they line up + +indent_xml_string Number + The number of spaces to indent multi-line XML strings. + Requires indent_align_string=True + +indent_brace Number + Spaces to indent '{' from level + +indent_braces { False, True } + Whether braces are indented to the body level + +indent_braces_no_func { False, True } + Disabled indenting function braces if indent_braces is true + +indent_brace_parent { False, True } + Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. + +indent_namespace { False, True } + Whether the 'namespace' body is indented + +indent_class { False, True } + Whether the 'class' body is indented + +indent_class_colon { False, True } + Whether to indent the stuff after a leading class colon + +indent_func_call_param { False, True } + True: indent continued function call parameters one indent level + False: align parameters under the open paren + +indent_func_def_param { False, True } + Same as indent_func_call_param, but for function defs + +indent_func_proto_param { False, True } + Same as indent_func_call_param, but for function protos + +indent_func_class_param { False, True } + Same as indent_func_call_param, but for class declarations + +indent_func_ctor_var_param { False, True } + Same as indent_func_call_param, but for class variable constructors + +indent_func_param_double { False, True } + Double the indent for indent_func_xxx_param options + +indent_member Number + The number of spaces to indent a continued '->' or '.' + Usually set to 0, 1, or indent_columns. + +indent_sing_line_comments Number + Spaces to indent single line ('//') comments on lines before code + +indent_switch_case Number + Spaces to indent 'case' from 'switch' + Usually 0 or indent_columns. + +indent_case_shift Number + Spaces to shift the 'case' line, without affecting any other lines + Usually 0. + +indent_case_brace Number + Spaces to indent '{' from 'case'. + By default, the brace will appear under the 'c' in case. + Usually set to 0 or indent_columns. + +indent_col1_comment { False, True } + Whether to indent comments found in first column + +indent_label Number + How to indent goto labels + >0 : absolute column where 1 is the leftmost column + <=0 : subtract from brace indent + +indent_access_spec Number + Same as indent_label, but for access specifiers that are followed by a colon + +indent_paren_nl { False, True } + If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) + +indent_paren_close Number + Controls the indent of a close paren after a newline. + 0: Indent to body level + 1: Align under the open paren + 2: Indent to the brace level + +indent_comma_paren { False, True } + Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren + +indent_bool_paren { False, True } + Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren + +indent_square_nl { False, True } + If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) + +indent_preserve_sql { False, True } + Don't change the relative indent of ESQL/C 'EXEC SQL' bodies + +# +# Spacing options +# + +sp_arith { Ignore, Add, Remove, Force } + Add or remove space around arithmetic operator '+', '-', '/', '*', etc + +sp_assign { Ignore, Add, Remove, Force } + Add or remove space around assignment operator '=', '+=', etc + +sp_bool { Ignore, Add, Remove, Force } + Add or remove space around boolean operators '&&' and '||' + +sp_compare { Ignore, Add, Remove, Force } + Add or remove space around compare operator '<', '>', '==', etc + +sp_inside_paren { Ignore, Add, Remove, Force } + Add or remove space inside '(' and ')' + +sp_paren_paren { Ignore, Add, Remove, Force } + Add or remove space between nested parens + +sp_balance_nested_parens { False, True } + Whether to balance spaces inside nested parens + +sp_paren_brace { Ignore, Add, Remove, Force } + Add or remove space between ')' and '{' + +sp_before_ptr_star { Ignore, Add, Remove, Force } + Add or remove space before pointer star '*' + +sp_between_ptr_star { Ignore, Add, Remove, Force } + Add or remove space between pointer stars '*' + +sp_after_ptr_star { Ignore, Add, Remove, Force } + Add or remove space after pointer star '*', if followed by a word. + +sp_before_byref { Ignore, Add, Remove, Force } + Add or remove space before reference sign '&' + +sp_after_byref { Ignore, Add, Remove, Force } + Add or remove space after reference sign '&', if followed by a word. + +sp_before_angle { Ignore, Add, Remove, Force } + Add or remove space before '<>' + +sp_after_angle { Ignore, Add, Remove, Force } + Add or remove space after '<>' + +sp_angle_paren { Ignore, Add, Remove, Force } + Add or remove space between '<>' and '(' as found in 'new List();' + +sp_angle_word { Ignore, Add, Remove, Force } + Add or remove space between '<>' and a word as in 'List m;' + +sp_before_sparen { Ignore, Add, Remove, Force } + Add or remove space before '(' of 'if', 'for', 'switch', and 'while' + +sp_inside_sparen { Ignore, Add, Remove, Force } + Add or remove space inside if-condition '(' and ')' + +sp_after_sparen { Ignore, Add, Remove, Force } + Add or remove space after ')' of 'if', 'for', 'switch', and 'while' + +sp_sparen_brace { Ignore, Add, Remove, Force } + Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' + +sp_special_semi { Ignore, Add, Remove, Force } + Add or remove space before empty statement ';' on 'if', 'for' and 'while' + +sp_before_semi { Ignore, Add, Remove, Force } + Add or remove space before ';' + +sp_before_semi_for { Ignore, Add, Remove, Force } + Add or remove space before ';' in non-empty 'for' statements + +sp_before_semi_for_empty { Ignore, Add, Remove, Force } + Add or remove space before a semicolon of an empty part of a for statment. + +sp_after_semi_for_empty { Ignore, Add, Remove, Force } + Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). + +sp_before_square { Ignore, Add, Remove, Force } + Add or remove space before '[' (except '[]') + +sp_before_squares { Ignore, Add, Remove, Force } + Add or remove space before '[]' + +sp_inside_square { Ignore, Add, Remove, Force } + Add or remove space inside '[' and ']' + +sp_after_comma { Ignore, Add, Remove, Force } + Add or remove space after ',' + +sp_before_comma { Ignore, Add, Remove, Force } + Add or remove space before ',' + +sp_after_operator { Ignore, Add, Remove, Force } + Add or remove space between 'operator' and operator sign + +sp_after_cast { Ignore, Add, Remove, Force } + Add or remove space after cast + +sp_inside_paren_cast { Ignore, Add, Remove, Force } + Add or remove spaces inside cast parens + +sp_sizeof_paren { Ignore, Add, Remove, Force } + Add or remove space between 'sizeof' and '(' + +sp_after_tag { Ignore, Add, Remove, Force } + Add or remove space after the tag keyword (Pawn) + +sp_inside_braces_enum { Ignore, Add, Remove, Force } + Add or remove space inside enum '{' and '}' + +sp_inside_braces_struct { Ignore, Add, Remove, Force } + Add or remove space inside struct/union '{' and '}' + +sp_inside_braces { Ignore, Add, Remove, Force } + Add or remove space inside '{' and '}' + +sp_inside_angle { Ignore, Add, Remove, Force } + Add or remove space inside '<' and '>' + +sp_type_func { Ignore, Add, Remove, Force } + Add or remove space between return type and function name + A minimum of 1 is forced except for pointer return types. + +sp_func_proto_paren { Ignore, Add, Remove, Force } + Add or remove space between function name and '(' on function declaration + +sp_func_def_paren { Ignore, Add, Remove, Force } + Add or remove space between function name and '(' on function definition + +sp_inside_fparens { Ignore, Add, Remove, Force } + Add or remove space inside empty function '()' + +sp_inside_fparen { Ignore, Add, Remove, Force } + Add or remove space inside function '(' and ')' + +sp_square_fparen { Ignore, Add, Remove, Force } + Add or remove space between ']' and '(' when part of a function call. + +sp_fparen_brace { Ignore, Add, Remove, Force } + Add or remove space between ')' and '{' of function + +sp_func_call_paren { Ignore, Add, Remove, Force } + Add or remove space between function name and '(' on function calls + +sp_func_class_paren { Ignore, Add, Remove, Force } + Add or remove space between a constructor/destructor and the open paren + +sp_return_paren { Ignore, Add, Remove, Force } + Add or remove space between 'return' and '(' + +sp_attribute_paren { Ignore, Add, Remove, Force } + Add or remove space between '__attribute__' and '(' + +sp_macro { Ignore, Add, Remove, Force } + Add or remove space between macro and value + +sp_macro_func { Ignore, Add, Remove, Force } + Add or remove space between macro function ')' and value + +sp_else_brace { Ignore, Add, Remove, Force } + Add or remove space between 'else' and '{' if on the same line + +sp_brace_else { Ignore, Add, Remove, Force } + Add or remove space between '}' and 'else' if on the same line + +sp_catch_brace { Ignore, Add, Remove, Force } + Add or remove space between 'catch' and '{' if on the same line + +sp_brace_catch { Ignore, Add, Remove, Force } + Add or remove space between '}' and 'catch' if on the same line + +sp_finally_brace { Ignore, Add, Remove, Force } + Add or remove space between 'finally' and '{' if on the same line + +sp_brace_finally { Ignore, Add, Remove, Force } + Add or remove space between '}' and 'finally' if on the same line + +sp_try_brace { Ignore, Add, Remove, Force } + Add or remove space between 'try' and '{' if on the same line + +sp_getset_brace { Ignore, Add, Remove, Force } + Add or remove space between get/set and '{' if on the same line + +sp_before_dc { Ignore, Add, Remove, Force } + Add or remove space before the '::' operator + +sp_after_dc { Ignore, Add, Remove, Force } + Add or remove space after the '::' operator + +sp_d_array_colon { Ignore, Add, Remove, Force } + Add or remove around the D named array initializer ':' operator + +sp_not { Ignore, Add, Remove, Force } + Add or remove space after the '!' (not) operator. + +sp_inv { Ignore, Add, Remove, Force } + Add or remove space after the '~' (invert) operator. + +sp_addr { Ignore, Add, Remove, Force } + Add or remove space after the '&' (address-of) operator. + This does not affect the spacing after a '&' that is part of a type. + +sp_member { Ignore, Add, Remove, Force } + Add or remove space around the '.' or '->' operators + + +sp_deref { Ignore, Add, Remove, Force } + Add or remove space after the '*' (dereference) operator. + This does not affect the spacing after a '*' that is part of a type. + +sp_sign { Ignore, Add, Remove, Force } + Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' + +sp_incdec { Ignore, Add, Remove, Force } + Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' + +sp_after_oc_scope { Ignore, Add, Remove, Force } + Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' + +sp_before_oc_colon { Ignore, Add, Remove, Force } + Add or remove space after the colon in message specs + '-(int) f: (int) x;' vs '+(int) f : (int) x;' + +sp_after_oc_type { Ignore, Add, Remove, Force } + Add or remove space after the (type) in message specs + '-(int) f: (int) x;' vs '+(int)f : (int)x;' + +# +# Code alignment (not left column spaces/tabs) +# + +align_keep_tabs { False, True } + Whether to keep non-indenting tabs + +align_with_tabs { False, True } + Whether to use tabs for alinging + +align_on_tabstop { False, True } + Whether to bump out to the next tab when aligning + +align_number_left { False, True } + Whether to left-align numbers + +align_func_params { False, True } + Align variable definitions in prototypes and functions + +align_var_def_span Number + The span for aligning variable definitions (0=don't align) + +align_var_def_star_style Number + How to align the star in variable definitions. + 0=Part of the type + 1=Part of the variable + 2=Dangling + +align_var_def_amp_style Number + How to align the '&' in variable definitions. + 0=Part of the type + 1=Part of the variable + 2=Dangling + +align_var_def_thresh Number + The threshold for aligning variable definitions (0=no limit) + +align_var_def_colon { False, True } + Whether to align the colon in struct bit fields + +align_var_def_inline { False, True } + Whether to align inline struct/enum/union variable definitions + +align_assign_span Number + The span for aligning on '=' in assignments (0=don't align) + +align_assign_thresh Number + The threshold for aligning on '=' in assignments (0=no limit) + +align_enum_equ_span Number + The span for aligning on '=' in enums (0=don't align) + +align_enum_equ_thresh Number + The threshold for aligning on '=' in enums (0=no limit) + +align_var_struct_span Number + The span for aligning struct/union (0=don't align) + +align_var_struct_thresh Number + The threshold for aligning struct/union member definitions (0=no limit) + +align_struct_init_span Number + The span for aligning struct initializer values (0=don't align) + +align_typedef_gap Number + The minimum space between the type and the synonym of a typedef + +align_typedef_span Number + The span for aligning single-line typedefs (0=don't align) + +align_typedef_func Number + How to align typedef'd functions with other typedefs + 0: Don't mix them at all + 1: align the open paren with the types + 2: align the function type name with the other type names + +align_typedef_star_style Number + Controls the positioning of the '*' in typedefs. Just try it. + 0: Align on typdef type, ignore '*' + 1: The '*' is part of type name: typedef int *pint; + 2: The '*' is part of the type, but dangling: typedef int *pint; + +align_typedef_amp_style Number + Controls the positioning of the '&' in typedefs. Just try it. + 0: Align on typdef type, ignore '&' + 1: The '&' is part of type name: typedef int &pint; + 2: The '&' is part of the type, but dangling: typedef int &pint; + +align_right_cmt_span Number + The span for aligning comments that end lines (0=don't align) + +align_right_cmt_mix { False, True } + If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment + +align_func_proto_span Number + The span for aligning function prototypes (0=don't align) + +align_oc_msg_spec_span Number + The span for aligning function prototypes (0=don't align) + +align_nl_cont { False, True } + Whether to align macros wrapped with a backslash and a newline. + This will not work right if the macro contains a multi-line comment. + +align_pp_define_gap Number + The minimum space between label and value of a preprocessor define + +align_pp_define_span Number + The span for aligning on '#define' bodies (0=don't align) + +# +# Newline adding and removing options +# + +nl_collapse_empty_body { False, True } + Whether to collapse empty blocks between '{' and '}' + +nl_assign_leave_one_liners { False, True } + Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' + +nl_class_leave_one_liners { False, True } + Don't split one-line braced statements inside a class xx { } body + +nl_enum_leave_one_liners { False, True } + Don't split one-line enums: 'enum foo { BAR = 15 };' + +nl_getset_leave_one_liners { False, True } + Don't split one-line get or set functions + +nl_func_leave_one_liners { False, True } + Don't split one-line function definitions - 'int foo() { return 0; }' + +nl_if_leave_one_liners { False, True } + Don't split one-line if/else statements - 'if(a) b++;' + +nl_start_of_file { Ignore, Add, Remove, Force } + Add or remove newlines at the start of the file + +nl_start_of_file_min Number + The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' + +nl_end_of_file { Ignore, Add, Remove, Force } + Add or remove newline at the end of the file + +nl_end_of_file_min Number + The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') + +nl_assign_brace { Ignore, Add, Remove, Force } + Add or remove newline between '=' and '{' + +nl_assign_square { Ignore, Add, Remove, Force } + Add or remove newline between '=' and '[' (D only) + +nl_after_square_assign { Ignore, Add, Remove, Force } + Add or remove newline after '= [' (D only). Will also affect the newline before the ']' + +nl_func_var_def_blk Number + The number of newlines after a block of variable definitions + +nl_fcall_brace { Ignore, Add, Remove, Force } + Add or remove newline between a function call's ')' and '{', as in: + list_for_each(item, &list) { } + +nl_enum_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'enum' and '{' + +nl_struct_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'struct and '{' + +nl_union_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'union' and '{' + +nl_if_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'if' and '{' + +nl_brace_else { Ignore, Add, Remove, Force } + Add or remove newline between '}' and 'else' + +nl_elseif_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'else if' and '{' + If set to ignore, nl_if_brace is used instead + +nl_else_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'else' and '{' + +nl_brace_finally { Ignore, Add, Remove, Force } + Add or remove newline between '}' and 'finally' + +nl_finally_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'finally' and '{' + +nl_try_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'try' and '{' + +nl_getset_brace { Ignore, Add, Remove, Force } + Add or remove newline between get/set and '{' + +nl_for_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'for' and '{' + +nl_catch_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'catch' and '{' + +nl_brace_catch { Ignore, Add, Remove, Force } + Add or remove newline between '}' and 'catch' + +nl_while_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'while' and '{' + +nl_do_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'do' and '{' + +nl_brace_while { Ignore, Add, Remove, Force } + Add or remove newline between '}' and 'while' of 'do' statement + +nl_switch_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'switch' and '{' + +nl_multi_line_cond { False, True } + Add or remove newline when condition spans two or more lines + +nl_multi_line_define { False, True } + Force a newline in a define after the macro name for multi-line defines. + +nl_before_case { False, True } + Whether to put a newline before 'case' statement + +nl_after_case { False, True } + Whether to put a newline after 'case' statement + +nl_namespace_brace { Ignore, Add, Remove, Force } + Newline between namespace and { + +nl_template_class { Ignore, Add, Remove, Force } + Add or remove newline between 'template<>' and 'class' + +nl_class_brace { Ignore, Add, Remove, Force } + Add or remove newline between 'class' and '{' + +nl_class_init_args { Ignore, Add, Remove, Force } + Add or remove newline after each ',' in the constructor member initialization + +nl_func_type_name { Ignore, Add, Remove, Force } + Add or remove newline between return type and function name in definition + +nl_func_proto_type_name { Ignore, Add, Remove, Force } + Add or remove newline between return type and function name in a prototype + +nl_func_paren { Ignore, Add, Remove, Force } + Add or remove newline between a function name and the opening '(' + +nl_func_decl_start { Ignore, Add, Remove, Force } + Add or remove newline after '(' in a function declaration + +nl_func_decl_args { Ignore, Add, Remove, Force } + Add or remove newline after each ',' in a function declaration + +nl_func_decl_end { Ignore, Add, Remove, Force } + Add or remove newline before the ')' in a function declaration + +nl_fdef_brace { Ignore, Add, Remove, Force } + Add or remove newline between function signature and '{' + +nl_after_return { False, True } + Whether to put a newline after 'return' statement + +nl_after_semicolon { False, True } + Whether to put a newline after semicolons, except in 'for' statements + +nl_after_brace_open { False, True } + Whether to put a newline after brace open. + This also adds a newline before the matching brace close. + +nl_after_brace_open_cmt { False, True } + If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is + placed between the open brace and a trailing single-line comment. + +nl_after_vbrace_open { False, True } + Whether to put a newline after a virtual brace open. + These occur in un-braced if/while/do/for statement bodies. + +nl_define_macro { False, True } + Whether to alter newlines in '#define' macros + +nl_squeeze_ifdef { False, True } + Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' + +nl_before_if { Ignore, Add, Remove, Force } + Add or remove newline before 'if' + +nl_after_if { Ignore, Add, Remove, Force } + Add or remove newline after 'if' + +nl_before_for { Ignore, Add, Remove, Force } + Add or remove newline before 'for' + +nl_after_for { Ignore, Add, Remove, Force } + Add or remove newline after 'for' + +nl_before_while { Ignore, Add, Remove, Force } + Add or remove newline before 'while' + +nl_after_while { Ignore, Add, Remove, Force } + Add or remove newline after 'while' + +nl_before_switch { Ignore, Add, Remove, Force } + Add or remove newline before 'switch' + +nl_after_switch { Ignore, Add, Remove, Force } + Add or remove newline after 'switch' + +nl_before_do { Ignore, Add, Remove, Force } + Add or remove newline before 'do' + +nl_after_do { Ignore, Add, Remove, Force } + Add or remove newline after 'do' + +nl_ds_struct_enum_cmt { False, True } + Whether to double-space commented-entries in struct/enum + +nl_ds_struct_enum_close_brace { False, True } + Whether to double-space before the close brace of a struct/union/enum + +nl_class_colon { Ignore, Add, Remove, Force } + Add or remove a newline around a class colon. + Related to pos_class_colon, nl_class_init_args, and pos_comma. + +nl_create_if_one_liner { False, True } + Change simple unbraced if statements into a one-liner + 'if(b)\n i++;' => 'if(b) i++;' + +nl_create_for_one_liner { False, True } + Change simple unbraced for statements into a one-liner + 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' + +nl_create_while_one_liner { False, True } + Change simple unbraced while statements into a one-liner + 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' + +# +# Positioning options +# + +pos_bool { Ignore, Lead, Trail } + The position of boolean operators in wrapped expressions + +pos_comma { Ignore, Lead, Trail } + The position of the comma in wrapped expressions + +pos_class_comma { Ignore, Lead, Trail } + The position of the comma in the constructor initialization list + +pos_class_colon { Ignore, Lead, Trail } + The position of colons between constructor and member initialization + +# +# Line Splitting options +# + +code_width Number + Try to limit code width to N number of columns + +ls_for_split_full { False, True } + Whether to fully split long 'for' statements at semi-colons + +ls_func_split_full { False, True } + Whether to fully split long function protos/calls at commas + +# +# Blank line options +# + +nl_max Number + The maximum consecutive newlines + +nl_after_func_proto Number + The number of newlines after a function prototype, if followed by another function prototype + +nl_after_func_proto_group Number + The number of newlines after a function prototype, if not followed by another function prototype + +nl_after_func_body Number + The number of newlines after '}' of a multi-line function body + +nl_after_func_body_one_liner Number + The number of newlines after '}' of a single line function body + +nl_before_block_comment Number + The minimum number of newlines before a multi-line comment. + Doesn't apply if after a brace open or another multi-line comment. + +nl_before_c_comment Number + The minimum number of newlines before a single-line C comment. + Doesn't apply if after a brace open or other single-line C comments. + +nl_before_cpp_comment Number + The minimum number of newlines before a CPP comment. + Doesn't apply if after a brace open or other CPP comments. + +nl_after_multiline_comment { False, True } + Whether to force a newline after a mulit-line comment. + +nl_before_access_spec Number + The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. + Will not change the newline count if after a brace open. + 0 = No change. + +nl_after_access_spec Number + The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. + 0 = No change. + +eat_blanks_after_open_brace { False, True } + Whether to remove blank lines after '{' + +eat_blanks_before_close_brace { False, True } + Whether to remove blank lines before '}' + +# +# Code modifying options (non-whitespace) +# + +mod_full_brace_do { Ignore, Add, Remove, Force } + Add or remove braces on single-line 'do' statement + +mod_full_brace_for { Ignore, Add, Remove, Force } + Add or remove braces on single-line 'for' statement + +mod_full_brace_function { Ignore, Add, Remove, Force } + Add or remove braces on single-line function defintions. (Pawn) + +mod_full_brace_if { Ignore, Add, Remove, Force } + Add or remove braces on single-line 'if' statement + +mod_full_brace_nl Number + Don't remove braces around statements that span N newlines + +mod_full_brace_while { Ignore, Add, Remove, Force } + Add or remove braces on single-line 'while' statement + +mod_paren_on_return { Ignore, Add, Remove, Force } + Add or remove unnecessary paren on 'return' statement + +mod_pawn_semicolon { False, True } + Whether to change optional semicolons to real semicolons + +mod_full_paren_if_bool { False, True } + Add parens on 'while' and 'if' statement around bools + +mod_remove_extra_semicolon { False, True } + Whether to remove superfluous semicolons + +mod_add_long_function_closebrace_comment Number + If a function body exceeds the specified number of newlines and doesn't have a comment after + the close brace, a comment will be added. + +mod_add_long_switch_closebrace_comment Number + If a switch body exceeds the specified number of newlines and doesn't have a comment after + the close brace, a comment will be added. + +mod_sort_import { False, True } + If TRUE, will sort consecutive single-line 'import' statements [Java, D] + +mod_sort_using { False, True } + If TRUE, will sort consecutive single-line 'using' statements [C#] + +mod_sort_include { False, True } + If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] + This is generally a bad idea, as it may break your code. + +# +# Comment modifications +# + +cmt_width Number + Try to wrap comments at cmt_witdth columns + +cmt_c_group { False, True } + Whether to group c-comments that look like they are in a block + +cmt_c_nl_start { False, True } + Whether to put an empty '/*' on the first line of the combined c-comment + +cmt_c_nl_end { False, True } + Whether to put a newline before the closing '*/' of the combined c-comment + +cmt_cpp_group { False, True } + Whether to group cpp-comments that look like they are in a block + +cmt_cpp_nl_start { False, True } + Whether to put an empty '/*' on the first line of the combined cpp-comment + +cmt_cpp_nl_end { False, True } + Whether to put a newline before the closing '*/' of the combined cpp-comment + +cmt_cpp_to_c { False, True } + Whether to change cpp-comments into c-comments + +cmt_star_cont { False, True } + Whether to put a star on subsequent comment lines + +cmt_sp_before_star_cont Number + The number of spaces to insert at the start of subsequent comment lines + +cmt_sp_after_star_cont Number + The number of spaces to insert after the star on subsequent comment lines + +cmt_insert_file_header + The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. + Will substitue $(filename) with the current file's name. + +cmt_insert_func_header + The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. + Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. + Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } + +cmt_insert_class_header + The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. + Will substitue $(class) with the class name. + +# +# Preprocessor options +# + +pp_indent { Ignore, Add, Remove, Force } + Control indent of preprocessors inside #if blocks at brace level 0 + +pp_indent_at_level { False, True } + Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) + +pp_space { Ignore, Add, Remove, Force } + Add or remove space after # based on pp_level of #if blocks + +pp_space_count Number + Sets the number of spaces added with pp_space + +pp_indent_region Number + The indent for #region and #endregion in C# and '#pragma region' in C/C++ + +pp_region_indent_code { False, True } + Whether to indent the code between #region and #endregion + +pp_indent_if Number + If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level + +pp_if_indent_code { False, True } + Control whether to indent the code between #if, #else and #endif when not at file-level + +pp_define_at_level { False, True } + Whether to indent '#define' at the brace level (true) or from column 1 (false) + diff --git a/documentation/htdocs/configuration.txt b/documentation/htdocs/configuration.txt new file mode 100644 index 0000000000..1691e30669 --- /dev/null +++ b/documentation/htdocs/configuration.txt @@ -0,0 +1,69 @@ +Quick documentation (probably out of date - see options.h) + +$Id: configuration.txt 858 2007-08-10 23:45:33Z bengardner $ + +There are five type of arguments: + - boolean (true/false) + - numeric + - ignore/add/remove/force + - LF/CRLF/CR/AUTO + - ignore/lead/trail + +"Ignore" means do not change it. +"Add" in the context of spaces means make sure there is at least 1. +"Add" elsewhere means make sure one is present. +"Remove" mean remove the space/brace/newline/etc. +"Force" in the context of spaces means ensure that there is exactly 1. +"Force" in other contexts means the same as "add". + +Configuration items may reference previously defined configuration items. +Numeric items may be prefixed with a '-' to invert the number. +Boolean items may be prefixed with a '-' or '~' to invert the value. +For example, the following is valid: + output_tab_size = 4 + indent_columns = output_tab_size + + +All items default to false/0/ignore except: + - newlines = auto + - input_tab_size = 8 + - output_tab_size = 8 + - indent_columns = 8 + - indent_with_tabs = 1 + - indent_label = 1 + - indent_access_spec = 1 + - sp_before_comma = remove + - string_escape_char = 92 # '\' + + Refer to set_option_defaults() + +Terminology: + There are three types of parenthesis: sparen, fparen, paren. + sparen are found with if/for/switch/while statements. + fparen are found with function prototypes, calls and implementations. + paren are everything else, such as those found with arithmetic ops. + + A 'span' is the maximum number of lines that a aligning feature will be + considered. This is done to limit the scope of the aligning. + So, if a span is set to 3 and more than 3 lines do not contain the item + that is to be aligned, then the aligning set is closed. + + A 'gap' is the minimum spacing for aligned items. + So, if it is set to 3 for typedefs, then there are a minimum of three + spaces between the type and the typedef name. + + A 'threshold' is the maximum number of columns that a aligning feature + will be considered. This is done to limit the scope of the aligning. + This prevents really longs lines from being aligned with short lines. + + +A list of all the options with documentation can be acquired by running +uncrustify with the following options: + +$ uncrustify --show-config + + +To get a valid configuration file with all defaults, run this: + +$ uncrustify -c /dev/null --update-config-with-doc + diff --git a/documentation/htdocs/default.cfg b/documentation/htdocs/default.cfg new file mode 100644 index 0000000000..4f37b8d1b0 --- /dev/null +++ b/documentation/htdocs/default.cfg @@ -0,0 +1,1276 @@ +# Uncrustify 0.54 + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 8 # number + +# The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 8 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 1 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# The number of spaces to indent a namespace block +indent_namespace_level = 0 # number + +# If the body of the namespace is longer than this number, it won't be indented. +# Requires indent_namespace=true. Default=0 (no limit) +indent_namespace_limit = 0 # number + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = false # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute +indent_var_def_blk = 0 # number + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = true # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = ignore # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around preprocessor '##' concatenation operator. Default=Add +sp_pp_concat = add # ignore/add/remove/force + +# Add or remove space after preprocessor '#' stringify operator. Default=Add +sp_pp_stringify = add # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = ignore # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = ignore # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word. Default=Force +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = ignore # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = ignore # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = ignore # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = ignore # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';'. Default=Remove +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statement. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space after ';', except when followed by a comment. Default=Add +sp_after_semi = add # ignore/add/remove/force + +# Add or remove space after ';' in non-empty 'for' statements. Default=Force +sp_after_semi_for = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = ignore # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = ignore # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space before the variadic '...' +sp_before_ellipsis = ignore # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':'. Default=Remove +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = ignore # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = ignore # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = ignore # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = ignore # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = ignore # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = ignore # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = ignore # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = ignore # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = ignore # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. Default=Remove +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. Default=Remove +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. Default=Remove +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators. Default=Remove +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. Default=Remove +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line. Default=Add +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int)f: (int) x;' vs '-(int)f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space after the first (type) in message specs +# '-(int) f:(int)x;' vs '-(int)f:(int)x;' +sp_after_oc_return_type = ignore # ignore/add/remove/force + +# Add or remove space between '@selector' and '(' +# '@selector(msgName).' vs '@selector (msgName)' +sp_after_oc_at_sel = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = ignore # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A' +sp_cmt_cpp_start = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for aligning +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = false # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 0 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align any attribute after the variable name +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typedef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typedef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 0 # number + +# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) +align_right_cmt_at_col = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Align function protos on the 'operator' keyword instead of what follows +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# Align parameters in an Obj-C message on the ':' +align_oc_msg_colon = false # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 0 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 0 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = ignore # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = ignore # ignore/add/remove/force + +# Add or remove newline between two open or close braces. +# Due to general newline/brace handling, REMOVE may not work. +nl_brace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = ignore # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = ignore # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a function definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name inside a class {} +# Uses nl_func_type_name or nl_func_proto_type_name if set to ignore. +nl_func_type_name_class = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name in a definition +# Controls the newline after '::' in 'void A::f() { }' +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between '()' in a function declaration. +nl_func_decl_empty = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = ignore # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = false # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = false # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = false # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of comparison operators in wrapped expressions +pos_compare = ignore # ignore/lead/trail + +# The position of conditional (b ? t : f) operators in wrapped expressions +pos_conditional = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 0 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 0 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 0 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 0 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = ignore # ignore/add/remove/force + +# Add or remove braces on single-line function definitions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = ignore # ignore/add/remove/force + +# Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if. +# If any must be braced, they are all braced. If all can be unbraced, then the braces are removed. +mod_full_brace_if_chain = false # false/true + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = ignore # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = ignore # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = false # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after +# the #else, a comment will be added. +mod_add_long_ifdef_endif_comment = 0 # number + +# If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after +# the #endif, a comment will be added. +mod_add_long_ifdef_else_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# Will add or remove the braces around a fully braced case statement. +# Will only remove the braces if there are no variable declarations in the block. +mod_case_brace = ignore # ignore/add/remove/force + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# Set the comment reflow mode (default: 0) +# 0: no reflowing (apart from the line wrapping due to cmt_width) +# 1: no touching at all +# 2: full reflow +cmt_reflow_mode = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment. +# Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment. +# Will substitute $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = ignore # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ +# +# The full syntax description of all custom definition config entries +# is shown below: +# +# define custom tokens as: +# - embed whitespace in token using '' escape character, or +# put token in quotes +# - these: ' " and ` are recognized as quote delimiters +# +# type token1 token2 token3 ... +# ^ optionally specify multiple tokens on a single line +# define def_token output_token +# ^ output_token is optional, then NULL is assumed +# macro-open token +# macro-close token +# macro-else token +# set id token1 token2 ... +# ^ optionally specify multiple tokens on a single line +# ^ id is one of the names in token_enum.h sans the CT_ prefix, +# e.g. PP_PRAGMA +# +# all tokens are separated by any mix of ',' commas, '=' equal signs +# and whitespace (space, tab) +# diff --git a/documentation/htdocs/examples/c-1.in.c b/documentation/htdocs/examples/c-1.in.c new file mode 100644 index 0000000000..c1a53476d4 --- /dev/null +++ b/documentation/htdocs/examples/c-1.in.c @@ -0,0 +1,1234 @@ +/* i2c-core.c - a device driver for the iic-bus interface */ +/* ------------------------------------------------------------------------- */ +/* Copyright (C) 1995-99 Simon G. Vogl + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* ------------------------------------------------------------------------- */ + +/* With some changes from Kyösti Mälkki . + All SMBus-related things are written by Frodo Looijaard + SMBus 2.0 support by Mark Studebaker */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static LIST_HEAD(adapters); +static LIST_HEAD(drivers); +static DECLARE_MUTEX(core_lists); +static DEFINE_IDR(i2c_adapter_idr); + +static int i2c_device_match(struct device *dev, struct device_driver *drv) +{ + return 1; +} + +static int i2c_bus_suspend(struct device * dev, pm_message_t state) +{ + int rc = 0; + + if (dev->driver && dev->driver->suspend) + rc = dev->driver->suspend(dev,state,0); + return rc; +} + +static int i2c_bus_resume(struct device * dev) +{ + int rc = 0; + + if (dev->driver && dev->driver->resume) + rc = dev->driver->resume(dev,0); + return rc; +} + +struct bus_type i2c_bus_type = { + .name = "i2c", + .match = i2c_device_match, + .suspend = i2c_bus_suspend, + .resume = i2c_bus_resume, +}; + +static int i2c_device_probe(struct device *dev) +{ + return -ENODEV; +} + +static int i2c_device_remove(struct device *dev) +{ + return 0; +} + +void i2c_adapter_dev_release(struct device *dev) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + complete(&adap->dev_released); +} + +struct device_driver i2c_adapter_driver = { + .name = "i2c_adapter", + .bus = &i2c_bus_type, + .probe = i2c_device_probe, + .remove = i2c_device_remove, +}; + +static void i2c_adapter_class_dev_release(struct class_device *dev) +{ + struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); + complete(&adap->class_dev_released); +} + +struct class i2c_adapter_class = { + .name = "i2c-adapter", + .release =&i2c_adapter_class_dev_release, +}; + +static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + return sprintf(buf, "%s\n", adap->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); + + +static void i2c_client_release(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + complete(&client->released); +} + +static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + return sprintf(buf, "%s\n", client->name); +} + +/* + * We can't use the DEVICE_ATTR() macro here as we want the same filename for a + * different type of a device. So beware if the DEVICE_ATTR() macro ever + * changes, this definition will also have to change. + */ +static struct device_attribute dev_attr_client_name = { + .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, + .show = &show_client_name, +}; + + +/* --------------------------------------------------- + * registering functions + * --------------------------------------------------- + */ + +/* ----- + * i2c_add_adapter is called from within the algorithm layer, + * when a new hw adapter registers. A new device is register to be + * available for clients. + */ +int i2c_add_adapter(struct i2c_adapter *adap) +{ + int id, res = 0; + struct list_head *item; + struct i2c_driver *driver; + + down(&core_lists); + + if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { + res = -ENOMEM; + goto out_unlock; + } + + res = idr_get_new(&i2c_adapter_idr, adap, &id); + if (res < 0) { + if (res == -EAGAIN) + res = -ENOMEM; + goto out_unlock; + } + + adap->nr = id & MAX_ID_MASK; + init_MUTEX(&adap->bus_lock); + init_MUTEX(&adap->clist_lock); + list_add_tail(&adap->list,&adapters); + INIT_LIST_HEAD(&adap->clients); + + /* Add the adapter to the driver core. + * If the parent pointer is not set up, + * we add this adapter to the host bus. + */ + if (adap->dev.parent == NULL) + adap->dev.parent = &platform_bus; + sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); + adap->dev.driver = &i2c_adapter_driver; + adap->dev.release = &i2c_adapter_dev_release; + device_register(&adap->dev); + device_create_file(&adap->dev, &dev_attr_name); + + /* Add this adapter to the i2c_adapter class */ + memset(&adap->class_dev, 0x00, sizeof(struct class_device)); + adap->class_dev.dev = &adap->dev; + adap->class_dev.class = &i2c_adapter_class; + strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); + class_device_register(&adap->class_dev); + + dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); + + /* inform drivers of new adapters */ + list_for_each(item,&drivers) { + driver = list_entry(item, struct i2c_driver, list); + if (driver->flags & I2C_DF_NOTIFY) + /* We ignore the return code; if it fails, too bad */ + driver->attach_adapter(adap); + } + +out_unlock: + up(&core_lists); + return res; +} + + +int i2c_del_adapter(struct i2c_adapter *adap) +{ + struct list_head *item, *_n; + struct i2c_adapter *adap_from_list; + struct i2c_driver *driver; + struct i2c_client *client; + int res = 0; + + down(&core_lists); + + /* First make sure that this adapter was ever added */ + list_for_each_entry(adap_from_list, &adapters, list) { + if (adap_from_list == adap) + break; + } + if (adap_from_list != adap) { + pr_debug("i2c-core: attempting to delete unregistered " + "adapter [%s]\n", adap->name); + res = -EINVAL; + goto out_unlock; + } + + list_for_each(item,&drivers) { + driver = list_entry(item, struct i2c_driver, list); + if (driver->detach_adapter) + if ((res = driver->detach_adapter(adap))) { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } + + /* detach any active clients. This must be done first, because + * it can fail; in which case we give up. */ + list_for_each_safe(item, _n, &adap->clients) { + client = list_entry(item, struct i2c_client, list); + + /* detaching devices is unconditional of the set notify + * flag, as _all_ clients that reside on the adapter + * must be deleted, as this would cause invalid states. + */ + if ((res=client->driver->detach_client(client))) { + dev_err(&adap->dev, "detach_client failed for client " + "[%s] at address 0x%02x\n", client->name, + client->addr); + goto out_unlock; + } + } + + /* clean up the sysfs representation */ + init_completion(&adap->dev_released); + init_completion(&adap->class_dev_released); + class_device_unregister(&adap->class_dev); + device_remove_file(&adap->dev, &dev_attr_name); + device_unregister(&adap->dev); + list_del(&adap->list); + + /* wait for sysfs to drop all references */ + wait_for_completion(&adap->dev_released); + wait_for_completion(&adap->class_dev_released); + + /* free dynamically allocated bus id */ + idr_remove(&i2c_adapter_idr, adap->nr); + + dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); + + out_unlock: + up(&core_lists); + return res; +} + + +/* ----- + * What follows is the "upwards" interface: commands for talking to clients, + * which implement the functions to access the physical information of the + * chips. + */ + +int i2c_add_driver(struct i2c_driver *driver) +{ + struct list_head *item; + struct i2c_adapter *adapter; + int res = 0; + + down(&core_lists); + + /* add the driver to the list of i2c drivers in the driver core */ + driver->driver.name = driver->name; + driver->driver.bus = &i2c_bus_type; + driver->driver.probe = i2c_device_probe; + driver->driver.remove = i2c_device_remove; + + res = driver_register(&driver->driver); + if (res) + goto out_unlock; + + list_add_tail(&driver->list,&drivers); + pr_debug("i2c-core: driver [%s] registered\n", driver->name); + + /* now look for instances of driver on our adapters */ + if (driver->flags & I2C_DF_NOTIFY) { + list_for_each(item,&adapters) { + adapter = list_entry(item, struct i2c_adapter, list); + driver->attach_adapter(adapter); + } + } + + out_unlock: + up(&core_lists); + return res; +} + +int i2c_del_driver(struct i2c_driver *driver) +{ + struct list_head *item1, *item2, *_n; + struct i2c_client *client; + struct i2c_adapter *adap; + + int res = 0; + + down(&core_lists); + + /* Have a look at each adapter, if clients of this driver are still + * attached. If so, detach them to be able to kill the driver + * afterwards. + * + * Removing clients does not depend on the notify flag, else + * invalid operation might (will!) result, when using stale client + * pointers. + */ + list_for_each(item1,&adapters) { + adap = list_entry(item1, struct i2c_adapter, list); + if (driver->detach_adapter) { + if ((res = driver->detach_adapter(adap))) { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } else { + list_for_each_safe(item2, _n, &adap->clients) { + client = list_entry(item2, struct i2c_client, list); + if (client->driver != driver) + continue; + dev_dbg(&adap->dev, "detaching client [%s] " + "at 0x%02x\n", client->name, + client->addr); + if ((res = driver->detach_client(client))) { + dev_err(&adap->dev, "detach_client " + "failed for client [%s] at " + "0x%02x\n", client->name, + client->addr); + goto out_unlock; + } + } + } + } + + driver_unregister(&driver->driver); + list_del(&driver->list); + pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); + + out_unlock: + up(&core_lists); + return 0; +} + +static int __i2c_check_addr(struct i2c_adapter *adapter, unsigned int addr) +{ + struct list_head *item; + struct i2c_client *client; + + list_for_each(item,&adapter->clients) { + client = list_entry(item, struct i2c_client, list); + if (client->addr == addr) + return -EBUSY; + } + return 0; +} + +int i2c_check_addr(struct i2c_adapter *adapter, int addr) +{ + int rval; + + down(&adapter->clist_lock); + rval = __i2c_check_addr(adapter, addr); + up(&adapter->clist_lock); + + return rval; +} + +int i2c_attach_client(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + + down(&adapter->clist_lock); + if (__i2c_check_addr(client->adapter, client->addr)) { + up(&adapter->clist_lock); + return -EBUSY; + } + list_add_tail(&client->list,&adapter->clients); + up(&adapter->clist_lock); + + if (adapter->client_register) { + if (adapter->client_register(client)) { + dev_dbg(&adapter->dev, "client_register " + "failed for client [%s] at 0x%02x\n", + client->name, client->addr); + } + } + + if (client->flags & I2C_CLIENT_ALLOW_USE) + client->usage_count = 0; + + client->dev.parent = &client->adapter->dev; + client->dev.driver = &client->driver->driver; + client->dev.bus = &i2c_bus_type; + client->dev.release = &i2c_client_release; + + snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), + "%d-%04x", i2c_adapter_id(adapter), client->addr); + dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", + client->name, client->dev.bus_id); + device_register(&client->dev); + device_create_file(&client->dev, &dev_attr_client_name); + + return 0; +} + + +int i2c_detach_client(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + int res = 0; + + if ((client->flags & I2C_CLIENT_ALLOW_USE) + && (client->usage_count > 0)) { + dev_warn(&client->dev, "Client [%s] still busy, " + "can't detach\n", client->name); + return -EBUSY; + } + + if (adapter->client_unregister) { + res = adapter->client_unregister(client); + if (res) { + dev_err(&client->dev, + "client_unregister [%s] failed, " + "client not detached\n", client->name); + goto out; + } + } + + down(&adapter->clist_lock); + list_del(&client->list); + init_completion(&client->released); + device_remove_file(&client->dev, &dev_attr_client_name); + device_unregister(&client->dev); + up(&adapter->clist_lock); + wait_for_completion(&client->released); + + out: + return res; +} + +static int i2c_inc_use_client(struct i2c_client *client) +{ + + if (!try_module_get(client->driver->owner)) + return -ENODEV; + if (!try_module_get(client->adapter->owner)) { + module_put(client->driver->owner); + return -ENODEV; + } + + return 0; +} + +static void i2c_dec_use_client(struct i2c_client *client) +{ + module_put(client->driver->owner); + module_put(client->adapter->owner); +} + +int i2c_use_client(struct i2c_client *client) +{ + int ret; + + ret = i2c_inc_use_client(client); + if (ret) + return ret; + + if (client->flags & I2C_CLIENT_ALLOW_USE) { + if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + client->usage_count++; + else if (client->usage_count > 0) + goto busy; + else + client->usage_count++; + } + + return 0; + busy: + i2c_dec_use_client(client); + return -EBUSY; +} + +int i2c_release_client(struct i2c_client *client) +{ + if(client->flags & I2C_CLIENT_ALLOW_USE) { + if(client->usage_count>0) + client->usage_count--; + else { + pr_debug("i2c-core: %s used one too many times\n", + __FUNCTION__); + return -EPERM; + } + } + + i2c_dec_use_client(client); + + return 0; +} + +void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) +{ + struct list_head *item; + struct i2c_client *client; + + down(&adap->clist_lock); + list_for_each(item,&adap->clients) { + client = list_entry(item, struct i2c_client, list); + if (!try_module_get(client->driver->owner)) + continue; + if (NULL != client->driver->command) { + up(&adap->clist_lock); + client->driver->command(client,cmd,arg); + down(&adap->clist_lock); + } + module_put(client->driver->owner); + } + up(&adap->clist_lock); +} + +static int __init i2c_init(void) +{ + int retval; + + retval = bus_register(&i2c_bus_type); + if (retval) + return retval; + retval = driver_register(&i2c_adapter_driver); + if (retval) + return retval; + return class_register(&i2c_adapter_class); +} + +static void __exit i2c_exit(void) +{ + class_unregister(&i2c_adapter_class); + driver_unregister(&i2c_adapter_driver); + bus_unregister(&i2c_bus_type); +} + +subsys_initcall(i2c_init); +module_exit(i2c_exit); + +/* ---------------------------------------------------- + * the functional interface to the i2c busses. + * ---------------------------------------------------- + */ + +int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) +{ + int ret; + + if (adap->algo->master_xfer) { +#ifdef DEBUG + for (ret = 0; ret < num; ret++) { + dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, " + "len=%d\n", ret, msgs[ret].flags & I2C_M_RD ? + 'R' : 'W', msgs[ret].addr, msgs[ret].len); + } +#endif + + down(&adap->bus_lock); + ret = adap->algo->master_xfer(adap,msgs,num); + up(&adap->bus_lock); + + return ret; + } else { + dev_dbg(&adap->dev, "I2C level transfers not supported\n"); + return -ENOSYS; + } +} + +int i2c_master_send(struct i2c_client *client,const char *buf ,int count) +{ + int ret; + struct i2c_adapter *adap=client->adapter; + struct i2c_msg msg; + + msg.addr = client->addr; + msg.flags = client->flags & I2C_M_TEN; + msg.len = count; + msg.buf = (char *)buf; + + ret = i2c_transfer(adap, &msg, 1); + + /* If everything went ok (i.e. 1 msg transmitted), return #bytes + transmitted, else error code. */ + return (ret == 1) ? count : ret; +} + +int i2c_master_recv(struct i2c_client *client, char *buf ,int count) +{ + struct i2c_adapter *adap=client->adapter; + struct i2c_msg msg; + int ret; + + msg.addr = client->addr; + msg.flags = client->flags & I2C_M_TEN; + msg.flags |= I2C_M_RD; + msg.len = count; + msg.buf = buf; + + ret = i2c_transfer(adap, &msg, 1); + + /* If everything went ok (i.e. 1 msg transmitted), return #bytes + transmitted, else error code. */ + return (ret == 1) ? count : ret; +} + + +int i2c_control(struct i2c_client *client, + unsigned int cmd, unsigned long arg) +{ + int ret = 0; + struct i2c_adapter *adap = client->adapter; + + dev_dbg(&client->adapter->dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg); + switch (cmd) { + case I2C_RETRIES: + adap->retries = arg; + break; + case I2C_TIMEOUT: + adap->timeout = arg; + break; + default: + if (adap->algo->algo_control!=NULL) + ret = adap->algo->algo_control(adap,cmd,arg); + } + return ret; +} + +/* ---------------------------------------------------- + * the i2c address scanning function + * Will not work for 10-bit addresses! + * ---------------------------------------------------- + */ +static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind, + int (*found_proc) (struct i2c_adapter *, int, int)) +{ + int err; + + /* Make sure the address is valid */ + if (addr < 0x03 || addr > 0x77) { + dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n", + addr); + return -EINVAL; + } + + /* Skip if already in use */ + if (i2c_check_addr(adapter, addr)) + return 0; + + /* Make sure there is something at this address, unless forced */ + if (kind < 0) { + if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL) < 0) + return 0; + + /* prevent 24RF08 corruption */ + if ((addr & ~0x0f) == 0x50) + i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL); + } + + /* Finally call the custom detection function */ + err = found_proc(adapter, addr, kind); + + /* -ENODEV can be returned if there is a chip at the given address + but it isn't supported by this chip driver. We catch it here as + this isn't an error. */ + return (err == -ENODEV) ? 0 : err; +} + +int i2c_probe(struct i2c_adapter *adapter, + struct i2c_client_address_data *address_data, + int (*found_proc) (struct i2c_adapter *, int, int)) +{ + int i, err; + int adap_id = i2c_adapter_id(adapter); + + /* Forget it if we can't probe using SMBUS_QUICK */ + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) + return -1; + + /* Force entries are done first, and are not affected by ignore + entries */ + if (address_data->forces) { + unsigned short **forces = address_data->forces; + int kind; + + for (kind = 0; forces[kind]; kind++) { + for (i = 0; forces[kind][i] != I2C_CLIENT_END; + i += 2) { + if (forces[kind][i] == adap_id + || forces[kind][i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found force " + "parameter for adapter %d, " + "addr 0x%02x, kind %d\n", + adap_id, forces[kind][i + 1], + kind); + err = i2c_probe_address(adapter, + forces[kind][i + 1], + kind, found_proc); + if (err) + return err; + } + } + } + } + + /* Probe entries are done second, and are not affected by ignore + entries either */ + for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { + if (address_data->probe[i] == adap_id + || address_data->probe[i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found probe parameter for " + "adapter %d, addr 0x%02x\n", adap_id, + address_data->probe[i + 1]); + err = i2c_probe_address(adapter, + address_data->probe[i + 1], + -1, found_proc); + if (err) + return err; + } + } + + /* Normal entries are done last, unless shadowed by an ignore entry */ + for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { + int j, ignore; + + ignore = 0; + for (j = 0; address_data->ignore[j] != I2C_CLIENT_END; + j += 2) { + if ((address_data->ignore[j] == adap_id || + address_data->ignore[j] == ANY_I2C_BUS) + && address_data->ignore[j + 1] + == address_data->normal_i2c[i]) { + dev_dbg(&adapter->dev, "found ignore " + "parameter for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->ignore[j + 1]); + } + ignore = 1; + break; + } + if (ignore) + continue; + + dev_dbg(&adapter->dev, "found normal entry for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->normal_i2c[i]); + err = i2c_probe_address(adapter, address_data->normal_i2c[i], + -1, found_proc); + if (err) + return err; + } + + return 0; +} + +struct i2c_adapter* i2c_get_adapter(int id) +{ + struct i2c_adapter *adapter; + + down(&core_lists); + adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); + if (adapter && !try_module_get(adapter->owner)) + adapter = NULL; + + up(&core_lists); + return adapter; +} + +void i2c_put_adapter(struct i2c_adapter *adap) +{ + module_put(adap->owner); +} + +/* The SMBus parts */ + +#define POLY (0x1070U << 3) +static u8 +crc8(u16 data) +{ + int i; + + for(i = 0; i < 8; i++) { + if (data & 0x8000) + data = data ^ POLY; + data = data << 1; + } + return (u8)(data >> 8); +} + +/* CRC over count bytes in the first array plus the bytes in the rest + array if it is non-null. rest[0] is the (length of rest) - 1 + and is included. */ +static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest) +{ + int i; + + for(i = 0; i < count; i++) + crc = crc8((crc ^ first[i]) << 8); + if(rest != NULL) + for(i = 0; i <= rest[0]; i++) + crc = crc8((crc ^ rest[i]) << 8); + return crc; +} + +static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) +{ + return i2c_smbus_partial_pec(0, count, first, rest); +} + +/* Returns new "size" (transaction type) + Note that we convert byte to byte_data and byte_data to word_data + rather than invent new xxx_PEC transactions. */ +static int i2c_smbus_add_pec(u16 addr, u8 command, int size, + union i2c_smbus_data *data) +{ + u8 buf[3]; + + buf[0] = addr << 1; + buf[1] = command; + switch(size) { + case I2C_SMBUS_BYTE: + data->byte = i2c_smbus_pec(2, buf, NULL); + size = I2C_SMBUS_BYTE_DATA; + break; + case I2C_SMBUS_BYTE_DATA: + buf[2] = data->byte; + data->word = buf[2] || + (i2c_smbus_pec(3, buf, NULL) << 8); + size = I2C_SMBUS_WORD_DATA; + break; + case I2C_SMBUS_WORD_DATA: + /* unsupported */ + break; + case I2C_SMBUS_BLOCK_DATA: + data->block[data->block[0] + 1] = + i2c_smbus_pec(2, buf, data->block); + size = I2C_SMBUS_BLOCK_DATA_PEC; + break; + } + return size; +} + +static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, + union i2c_smbus_data *data) +{ + u8 buf[3], rpec, cpec; + + buf[1] = command; + switch(size) { + case I2C_SMBUS_BYTE_DATA: + buf[0] = (addr << 1) | 1; + cpec = i2c_smbus_pec(2, buf, NULL); + rpec = data->byte; + break; + case I2C_SMBUS_WORD_DATA: + buf[0] = (addr << 1) | 1; + buf[2] = data->word & 0xff; + cpec = i2c_smbus_pec(3, buf, NULL); + rpec = data->word >> 8; + break; + case I2C_SMBUS_WORD_DATA_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_PROC_CALL_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_BLOCK_DATA_PEC: + buf[0] = (addr << 1); + buf[2] = (addr << 1) | 1; + cpec = i2c_smbus_pec(3, buf, data->block); + rpec = data->block[data->block[0] + 1]; + break; + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + buf[0] = (addr << 1) | 1; + rpec = i2c_smbus_partial_pec(partial, 1, + buf, data->block); + cpec = data->block[data->block[0] + 1]; + break; + default: + cpec = rpec = 0; + break; + } + if (rpec != cpec) { + pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", + rpec, cpec); + return -1; + } + return 0; +} + +s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) +{ + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + value,0,I2C_SMBUS_QUICK,NULL); +} + +s32 i2c_smbus_read_byte(struct i2c_client *client) +{ + union i2c_smbus_data data; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data)) + return -1; + else + return 0x0FF & data.byte; +} + +s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) +{ + union i2c_smbus_data data; /* only for PEC */ + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,&data); +} + +s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) +{ + union i2c_smbus_data data; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data)) + return -1; + else + return 0x0FF & data.byte; +} + +s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) +{ + union i2c_smbus_data data; + data.byte = value; + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,command, + I2C_SMBUS_BYTE_DATA,&data); +} + +s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) +{ + union i2c_smbus_data data; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA, &data)) + return -1; + else + return 0x0FFFF & data.word; +} + +s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) +{ + union i2c_smbus_data data; + data.word = value; + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,command, + I2C_SMBUS_WORD_DATA,&data); +} + +s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, + u8 length, u8 *values) +{ + union i2c_smbus_data data; + int i; + if (length > I2C_SMBUS_BLOCK_MAX) + length = I2C_SMBUS_BLOCK_MAX; + for (i = 1; i <= length; i++) + data.block[i] = values[i-1]; + data.block[0] = length; + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,command, + I2C_SMBUS_BLOCK_DATA,&data); +} + +/* Returns the number of read bytes */ +s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) +{ + union i2c_smbus_data data; + int i; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, + I2C_SMBUS_I2C_BLOCK_DATA,&data)) + return -1; + else { + for (i = 1; i <= data.block[0]; i++) + values[i-1] = data.block[i]; + return data.block[0]; + } +} + +/* Simulate a SMBus command using the i2c protocol + No checking of parameters is done! */ +static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, + unsigned short flags, + char read_write, u8 command, int size, + union i2c_smbus_data * data) +{ + /* So we need to generate a series of msgs. In the case of writing, we + need to use only one message; when reading, we need two. We initialize + most things with sane defaults, to keep the code below somewhat + simpler. */ + unsigned char msgbuf0[34]; + unsigned char msgbuf1[34]; + int num = read_write == I2C_SMBUS_READ?2:1; + struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, + { addr, flags | I2C_M_RD, 0, msgbuf1 } + }; + int i; + + msgbuf0[0] = command; + switch(size) { + case I2C_SMBUS_QUICK: + msg[0].len = 0; + /* Special case: The read/write field is used as data */ + msg[0].flags = flags | (read_write==I2C_SMBUS_READ)?I2C_M_RD:0; + num = 1; + break; + case I2C_SMBUS_BYTE: + if (read_write == I2C_SMBUS_READ) { + /* Special case: only a read! */ + msg[0].flags = I2C_M_RD | flags; + num = 1; + } + break; + case I2C_SMBUS_BYTE_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = 1; + else { + msg[0].len = 2; + msgbuf0[1] = data->byte; + } + break; + case I2C_SMBUS_WORD_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = 2; + else { + msg[0].len=3; + msgbuf0[1] = data->word & 0xff; + msgbuf0[2] = (data->word >> 8) & 0xff; + } + break; + case I2C_SMBUS_PROC_CALL: + num = 2; /* Special case */ + read_write = I2C_SMBUS_READ; + msg[0].len = 3; + msg[1].len = 2; + msgbuf0[1] = data->word & 0xff; + msgbuf0[2] = (data->word >> 8) & 0xff; + break; + case I2C_SMBUS_BLOCK_DATA: + case I2C_SMBUS_BLOCK_DATA_PEC: + if (read_write == I2C_SMBUS_READ) { + dev_err(&adapter->dev, "Block read not supported " + "under I2C emulation!\n"); + return -1; + } else { + msg[0].len = data->block[0] + 2; + if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) { + dev_err(&adapter->dev, "smbus_access called with " + "invalid block write size (%d)\n", + data->block[0]); + return -1; + } + if(size == I2C_SMBUS_BLOCK_DATA_PEC) + (msg[0].len)++; + for (i = 1; i <= msg[0].len; i++) + msgbuf0[i] = data->block[i-1]; + } + break; + case I2C_SMBUS_BLOCK_PROC_CALL: + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + dev_dbg(&adapter->dev, "Block process call not supported " + "under I2C emulation!\n"); + return -1; + case I2C_SMBUS_I2C_BLOCK_DATA: + if (read_write == I2C_SMBUS_READ) { + msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; + } else { + msg[0].len = data->block[0] + 1; + if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { + dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " + "invalid block write size (%d)\n", + data->block[0]); + return -1; + } + for (i = 1; i <= data->block[0]; i++) + msgbuf0[i] = data->block[i]; + } + break; + default: + dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n", + size); + return -1; + } + + if (i2c_transfer(adapter, msg, num) < 0) + return -1; + + if (read_write == I2C_SMBUS_READ) + switch(size) { + case I2C_SMBUS_BYTE: + data->byte = msgbuf0[0]; + break; + case I2C_SMBUS_BYTE_DATA: + data->byte = msgbuf1[0]; + break; + case I2C_SMBUS_WORD_DATA: + case I2C_SMBUS_PROC_CALL: + data->word = msgbuf1[0] | (msgbuf1[1] << 8); + break; + case I2C_SMBUS_I2C_BLOCK_DATA: + /* fixed at 32 for now */ + data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; + for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) + data->block[i+1] = msgbuf1[i]; + break; + } + return 0; +} + + +s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, + char read_write, u8 command, int size, + union i2c_smbus_data * data) +{ + s32 res; + int swpec = 0; + u8 partial = 0; + + flags &= I2C_M_TEN | I2C_CLIENT_PEC; + if((flags & I2C_CLIENT_PEC) && + !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) { + swpec = 1; + if(read_write == I2C_SMBUS_READ && + size == I2C_SMBUS_BLOCK_DATA) + size = I2C_SMBUS_BLOCK_DATA_PEC; + else if(size == I2C_SMBUS_PROC_CALL) + size = I2C_SMBUS_PROC_CALL_PEC; + else if(size == I2C_SMBUS_BLOCK_PROC_CALL) { + i2c_smbus_add_pec(addr, command, + I2C_SMBUS_BLOCK_DATA, data); + partial = data->block[data->block[0] + 1]; + size = I2C_SMBUS_BLOCK_PROC_CALL_PEC; + } else if(read_write == I2C_SMBUS_WRITE && + size != I2C_SMBUS_QUICK && + size != I2C_SMBUS_I2C_BLOCK_DATA) + size = i2c_smbus_add_pec(addr, command, size, data); + } + + if (adapter->algo->smbus_xfer) { + down(&adapter->bus_lock); + res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, + command,size,data); + up(&adapter->bus_lock); + } else + res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, + command,size,data); + + if(res >= 0 && swpec && + size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA && + (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC || + size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) { + if(i2c_smbus_check_pec(addr, command, size, partial, data)) + return -1; + } + return res; +} + + +/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL_GPL(i2c_adapter_dev_release); +EXPORT_SYMBOL_GPL(i2c_adapter_driver); +EXPORT_SYMBOL_GPL(i2c_adapter_class); +EXPORT_SYMBOL_GPL(i2c_bus_type); + +EXPORT_SYMBOL(i2c_add_adapter); +EXPORT_SYMBOL(i2c_del_adapter); +EXPORT_SYMBOL(i2c_add_driver); +EXPORT_SYMBOL(i2c_del_driver); +EXPORT_SYMBOL(i2c_attach_client); +EXPORT_SYMBOL(i2c_detach_client); +EXPORT_SYMBOL(i2c_use_client); +EXPORT_SYMBOL(i2c_release_client); +EXPORT_SYMBOL(i2c_clients_command); +EXPORT_SYMBOL(i2c_check_addr); + +EXPORT_SYMBOL(i2c_master_send); +EXPORT_SYMBOL(i2c_master_recv); +EXPORT_SYMBOL(i2c_control); +EXPORT_SYMBOL(i2c_transfer); +EXPORT_SYMBOL(i2c_get_adapter); +EXPORT_SYMBOL(i2c_put_adapter); +EXPORT_SYMBOL(i2c_probe); + +EXPORT_SYMBOL(i2c_smbus_xfer); +EXPORT_SYMBOL(i2c_smbus_write_quick); +EXPORT_SYMBOL(i2c_smbus_read_byte); +EXPORT_SYMBOL(i2c_smbus_write_byte); +EXPORT_SYMBOL(i2c_smbus_read_byte_data); +EXPORT_SYMBOL(i2c_smbus_write_byte_data); +EXPORT_SYMBOL(i2c_smbus_read_word_data); +EXPORT_SYMBOL(i2c_smbus_write_word_data); +EXPORT_SYMBOL(i2c_smbus_write_block_data); +EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data); + +MODULE_AUTHOR("Simon G. Vogl "); +MODULE_DESCRIPTION("I2C-Bus main module"); +MODULE_LICENSE("GPL"); diff --git a/documentation/htdocs/examples/c-1.out.c b/documentation/htdocs/examples/c-1.out.c new file mode 100644 index 0000000000..ceb484c62a --- /dev/null +++ b/documentation/htdocs/examples/c-1.out.c @@ -0,0 +1,1245 @@ +/* i2c-core.c - a device driver for the iic-bus interface */ +/* ------------------------------------------------------------------------- */ +/* Copyright (C) 1995-99 Simon G. Vogl + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* ------------------------------------------------------------------------- */ + +/* With some changes from Kyösti Mälkki . + All SMBus-related things are written by Frodo Looijaard + SMBus 2.0 support by Mark Studebaker */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static LIST_HEAD(adapters); +static LIST_HEAD(drivers); +static DECLARE_MUTEX(core_lists); +static DEFINE_IDR(i2c_adapter_idr); + +static int i2c_device_match(struct device *dev, struct device_driver *drv) +{ + return 1; +} + +static int i2c_bus_suspend(struct device *dev, pm_message_t state) +{ + int rc = 0; + + if (dev->driver && dev->driver->suspend) + rc = dev->driver->suspend(dev, state, 0); + return rc; +} + +static int i2c_bus_resume(struct device *dev) +{ + int rc = 0; + + if (dev->driver && dev->driver->resume) + rc = dev->driver->resume(dev, 0); + return rc; +} + +struct bus_type i2c_bus_type = { + .name = "i2c", + .match = i2c_device_match, + .suspend = i2c_bus_suspend, + .resume = i2c_bus_resume, +}; + +static int i2c_device_probe(struct device *dev) +{ + return -ENODEV; +} + +static int i2c_device_remove(struct device *dev) +{ + return 0; +} + +void i2c_adapter_dev_release(struct device *dev) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + + complete(&adap->dev_released); +} + +struct device_driver i2c_adapter_driver = { + .name = "i2c_adapter", + .bus = &i2c_bus_type, + .probe = i2c_device_probe, + .remove = i2c_device_remove, +}; + +static void i2c_adapter_class_dev_release(struct class_device *dev) +{ + struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); + + complete(&adap->class_dev_released); +} + +struct class i2c_adapter_class = { + .name = "i2c-adapter", + .release = &i2c_adapter_class_dev_release, +}; + +static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + + return sprintf(buf, "%s\n", adap->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); + + +static void i2c_client_release(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + + complete(&client->released); +} + +static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + + return sprintf(buf, "%s\n", client->name); +} + +/* + * We can't use the DEVICE_ATTR() macro here as we want the same filename for a + * different type of a device. So beware if the DEVICE_ATTR() macro ever + * changes, this definition will also have to change. + */ +static struct device_attribute dev_attr_client_name = { + .attr = { .name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, + .show = &show_client_name, +}; + + +/* --------------------------------------------------- + * registering functions + * --------------------------------------------------- + */ + +/* ----- + * i2c_add_adapter is called from within the algorithm layer, + * when a new hw adapter registers. A new device is register to be + * available for clients. + */ +int i2c_add_adapter(struct i2c_adapter *adap) +{ + int id, res = 0; + struct list_head *item; + struct i2c_driver *driver; + + down(&core_lists); + + if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { + res = -ENOMEM; + goto out_unlock; + } + + res = idr_get_new(&i2c_adapter_idr, adap, &id); + if (res < 0) { + if (res == -EAGAIN) + res = -ENOMEM; + goto out_unlock; + } + + adap->nr = id & MAX_ID_MASK; + init_MUTEX(&adap->bus_lock); + init_MUTEX(&adap->clist_lock); + list_add_tail(&adap->list, &adapters); + INIT_LIST_HEAD(&adap->clients); + + /* Add the adapter to the driver core. + * If the parent pointer is not set up, + * we add this adapter to the host bus. + */ + if (adap->dev.parent == NULL) + adap->dev.parent = &platform_bus; + sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); + adap->dev.driver = &i2c_adapter_driver; + adap->dev.release = &i2c_adapter_dev_release; + device_register(&adap->dev); + device_create_file(&adap->dev, &dev_attr_name); + + /* Add this adapter to the i2c_adapter class */ + memset(&adap->class_dev, 0x00, sizeof(struct class_device)); + adap->class_dev.dev = &adap->dev; + adap->class_dev.class = &i2c_adapter_class; + strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); + class_device_register(&adap->class_dev); + + dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); + + /* inform drivers of new adapters */ + list_for_each(item, &drivers) { + driver = list_entry(item, struct i2c_driver, list); + if (driver->flags & I2C_DF_NOTIFY) + /* We ignore the return code; if it fails, too bad */ + driver->attach_adapter(adap); + } + + out_unlock: + up(&core_lists); + return res; +} + + +int i2c_del_adapter(struct i2c_adapter *adap) +{ + struct list_head *item, *_n; + struct i2c_adapter *adap_from_list; + struct i2c_driver *driver; + struct i2c_client *client; + int res = 0; + + down(&core_lists); + + /* First make sure that this adapter was ever added */ + list_for_each_entry(adap_from_list, &adapters, list) { + if (adap_from_list == adap) + break; + } + if (adap_from_list != adap) { + pr_debug("i2c-core: attempting to delete unregistered " + "adapter [%s]\n", adap->name); + res = -EINVAL; + goto out_unlock; + } + + list_for_each(item, &drivers) { + driver = list_entry(item, struct i2c_driver, list); + if (driver->detach_adapter) + if ((res = driver->detach_adapter(adap))) { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } + + /* detach any active clients. This must be done first, because + * it can fail; in which case we give up. */ + list_for_each_safe(item, _n, &adap->clients) { + client = list_entry(item, struct i2c_client, list); + + /* detaching devices is unconditional of the set notify + * flag, as _all_ clients that reside on the adapter + * must be deleted, as this would cause invalid states. + */ + if ((res = client->driver->detach_client(client))) { + dev_err(&adap->dev, "detach_client failed for client " + "[%s] at address 0x%02x\n", client->name, + client->addr); + goto out_unlock; + } + } + + /* clean up the sysfs representation */ + init_completion(&adap->dev_released); + init_completion(&adap->class_dev_released); + class_device_unregister(&adap->class_dev); + device_remove_file(&adap->dev, &dev_attr_name); + device_unregister(&adap->dev); + list_del(&adap->list); + + /* wait for sysfs to drop all references */ + wait_for_completion(&adap->dev_released); + wait_for_completion(&adap->class_dev_released); + + /* free dynamically allocated bus id */ + idr_remove(&i2c_adapter_idr, adap->nr); + + dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); + + out_unlock: + up(&core_lists); + return res; +} + + +/* ----- + * What follows is the "upwards" interface: commands for talking to clients, + * which implement the functions to access the physical information of the + * chips. + */ + +int i2c_add_driver(struct i2c_driver *driver) +{ + struct list_head *item; + struct i2c_adapter *adapter; + int res = 0; + + down(&core_lists); + + /* add the driver to the list of i2c drivers in the driver core */ + driver->driver.name = driver->name; + driver->driver.bus = &i2c_bus_type; + driver->driver.probe = i2c_device_probe; + driver->driver.remove = i2c_device_remove; + + res = driver_register(&driver->driver); + if (res) + goto out_unlock; + + list_add_tail(&driver->list, &drivers); + pr_debug("i2c-core: driver [%s] registered\n", driver->name); + + /* now look for instances of driver on our adapters */ + if (driver->flags & I2C_DF_NOTIFY) { + list_for_each(item, &adapters) { + adapter = list_entry(item, struct i2c_adapter, list); + driver->attach_adapter(adapter); + } + } + + out_unlock: + up(&core_lists); + return res; +} + +int i2c_del_driver(struct i2c_driver *driver) +{ + struct list_head *item1, *item2, *_n; + struct i2c_client *client; + struct i2c_adapter *adap; + + int res = 0; + + down(&core_lists); + + /* Have a look at each adapter, if clients of this driver are still + * attached. If so, detach them to be able to kill the driver + * afterwards. + * + * Removing clients does not depend on the notify flag, else + * invalid operation might (will!) result, when using stale client + * pointers. + */ + list_for_each(item1, &adapters) { + adap = list_entry(item1, struct i2c_adapter, list); + if (driver->detach_adapter) { + if ((res = driver->detach_adapter(adap))) { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } else { + list_for_each_safe(item2, _n, &adap->clients) { + client = list_entry(item2, struct i2c_client, list); + if (client->driver != driver) + continue; + dev_dbg(&adap->dev, "detaching client [%s] " + "at 0x%02x\n", client->name, + client->addr); + if ((res = driver->detach_client(client))) { + dev_err(&adap->dev, "detach_client " + "failed for client [%s] at " + "0x%02x\n", client->name, + client->addr); + goto out_unlock; + } + } + } + } + + driver_unregister(&driver->driver); + list_del(&driver->list); + pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); + + out_unlock: + up(&core_lists); + return 0; +} + +static int __i2c_check_addr(struct i2c_adapter *adapter, unsigned int addr) +{ + struct list_head *item; + struct i2c_client *client; + + list_for_each(item, &adapter->clients) { + client = list_entry(item, struct i2c_client, list); + if (client->addr == addr) + return -EBUSY; + } + return 0; +} + +int i2c_check_addr(struct i2c_adapter *adapter, int addr) +{ + int rval; + + down(&adapter->clist_lock); + rval = __i2c_check_addr(adapter, addr); + up(&adapter->clist_lock); + + return rval; +} + +int i2c_attach_client(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + + down(&adapter->clist_lock); + if (__i2c_check_addr(client->adapter, client->addr)) { + up(&adapter->clist_lock); + return -EBUSY; + } + list_add_tail(&client->list, &adapter->clients); + up(&adapter->clist_lock); + + if (adapter->client_register) { + if (adapter->client_register(client)) { + dev_dbg(&adapter->dev, "client_register " + "failed for client [%s] at 0x%02x\n", + client->name, client->addr); + } + } + + if (client->flags & I2C_CLIENT_ALLOW_USE) + client->usage_count = 0; + + client->dev.parent = &client->adapter->dev; + client->dev.driver = &client->driver->driver; + client->dev.bus = &i2c_bus_type; + client->dev.release = &i2c_client_release; + + snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), + "%d-%04x", i2c_adapter_id(adapter), client->addr); + dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", + client->name, client->dev.bus_id); + device_register(&client->dev); + device_create_file(&client->dev, &dev_attr_client_name); + + return 0; +} + + +int i2c_detach_client(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + int res = 0; + + if ((client->flags & I2C_CLIENT_ALLOW_USE) + && (client->usage_count > 0)) { + dev_warn(&client->dev, "Client [%s] still busy, " + "can't detach\n", client->name); + return -EBUSY; + } + + if (adapter->client_unregister) { + res = adapter->client_unregister(client); + if (res) { + dev_err(&client->dev, + "client_unregister [%s] failed, " + "client not detached\n", client->name); + goto out; + } + } + + down(&adapter->clist_lock); + list_del(&client->list); + init_completion(&client->released); + device_remove_file(&client->dev, &dev_attr_client_name); + device_unregister(&client->dev); + up(&adapter->clist_lock); + wait_for_completion(&client->released); + + out: + return res; +} + +static int i2c_inc_use_client(struct i2c_client *client) +{ + + if (!try_module_get(client->driver->owner)) + return -ENODEV; + if (!try_module_get(client->adapter->owner)) { + module_put(client->driver->owner); + return -ENODEV; + } + + return 0; +} + +static void i2c_dec_use_client(struct i2c_client *client) +{ + module_put(client->driver->owner); + module_put(client->adapter->owner); +} + +int i2c_use_client(struct i2c_client *client) +{ + int ret; + + ret = i2c_inc_use_client(client); + if (ret) + return ret; + + if (client->flags & I2C_CLIENT_ALLOW_USE) { + if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + client->usage_count++; + else if (client->usage_count > 0) + goto busy; + else + client->usage_count++; + } + + return 0; + busy: + i2c_dec_use_client(client); + return -EBUSY; +} + +int i2c_release_client(struct i2c_client *client) +{ + if (client->flags & I2C_CLIENT_ALLOW_USE) { + if (client->usage_count > 0) + client->usage_count--; + else { + pr_debug("i2c-core: %s used one too many times\n", + __FUNCTION__); + return -EPERM; + } + } + + i2c_dec_use_client(client); + + return 0; +} + +void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) +{ + struct list_head *item; + struct i2c_client *client; + + down(&adap->clist_lock); + list_for_each(item, &adap->clients) { + client = list_entry(item, struct i2c_client, list); + if (!try_module_get(client->driver->owner)) + continue; + if (NULL != client->driver->command) { + up(&adap->clist_lock); + client->driver->command(client, cmd, arg); + down(&adap->clist_lock); + } + module_put(client->driver->owner); + } + up(&adap->clist_lock); +} + +static int __init i2c_init(void) +{ + int retval; + + retval = bus_register(&i2c_bus_type); + if (retval) + return retval; + retval = driver_register(&i2c_adapter_driver); + if (retval) + return retval; + return class_register(&i2c_adapter_class); +} + +static void __exit i2c_exit(void) +{ + class_unregister(&i2c_adapter_class); + driver_unregister(&i2c_adapter_driver); + bus_unregister(&i2c_bus_type); +} + +subsys_initcall(i2c_init); +module_exit(i2c_exit); + +/* ---------------------------------------------------- + * the functional interface to the i2c busses. + * ---------------------------------------------------- + */ + +int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +{ + int ret; + + if (adap->algo->master_xfer) { +#ifdef DEBUG + for (ret = 0; ret < num; ret++) { + dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, " + "len=%d\n", ret, msgs[ret].flags & I2C_M_RD ? + 'R' : 'W', msgs[ret].addr, msgs[ret].len); + } +#endif + + down(&adap->bus_lock); + ret = adap->algo->master_xfer(adap, msgs, num); + up(&adap->bus_lock); + + return ret; + } else { + dev_dbg(&adap->dev, "I2C level transfers not supported\n"); + return -ENOSYS; + } +} + +int i2c_master_send(struct i2c_client *client, const char *buf, int count) +{ + int ret; + struct i2c_adapter *adap = client->adapter; + struct i2c_msg msg; + + msg.addr = client->addr; + msg.flags = client->flags & I2C_M_TEN; + msg.len = count; + msg.buf = (char *)buf; + + ret = i2c_transfer(adap, &msg, 1); + + /* If everything went ok (i.e. 1 msg transmitted), return #bytes + transmitted, else error code. */ + return (ret == 1) ? count : ret; +} + +int i2c_master_recv(struct i2c_client *client, char *buf, int count) +{ + struct i2c_adapter *adap = client->adapter; + struct i2c_msg msg; + int ret; + + msg.addr = client->addr; + msg.flags = client->flags & I2C_M_TEN; + msg.flags |= I2C_M_RD; + msg.len = count; + msg.buf = buf; + + ret = i2c_transfer(adap, &msg, 1); + + /* If everything went ok (i.e. 1 msg transmitted), return #bytes + transmitted, else error code. */ + return (ret == 1) ? count : ret; +} + + +int i2c_control(struct i2c_client *client, + unsigned int cmd, unsigned long arg) +{ + int ret = 0; + struct i2c_adapter *adap = client->adapter; + + dev_dbg(&client->adapter->dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg); + switch (cmd) { + case I2C_RETRIES: + adap->retries = arg; + break; + case I2C_TIMEOUT: + adap->timeout = arg; + break; + default: + if (adap->algo->algo_control != NULL) + ret = adap->algo->algo_control(adap, cmd, arg); + } + return ret; +} + +/* ---------------------------------------------------- + * the i2c address scanning function + * Will not work for 10-bit addresses! + * ---------------------------------------------------- + */ +static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind, + int (*found_proc)(struct i2c_adapter *, int, int)) +{ + int err; + + /* Make sure the address is valid */ + if (addr < 0x03 || addr > 0x77) { + dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n", + addr); + return -EINVAL; + } + + /* Skip if already in use */ + if (i2c_check_addr(adapter, addr)) + return 0; + + /* Make sure there is something at this address, unless forced */ + if (kind < 0) { + if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL) < 0) + return 0; + + /* prevent 24RF08 corruption */ + if ((addr & ~0x0f) == 0x50) + i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL); + } + + /* Finally call the custom detection function */ + err = found_proc(adapter, addr, kind); + + /* -ENODEV can be returned if there is a chip at the given address + but it isn't supported by this chip driver. We catch it here as + this isn't an error. */ + return (err == -ENODEV) ? 0 : err; +} + +int i2c_probe(struct i2c_adapter *adapter, + struct i2c_client_address_data *address_data, + int (*found_proc)(struct i2c_adapter *, int, int)) +{ + int i, err; + int adap_id = i2c_adapter_id(adapter); + + /* Forget it if we can't probe using SMBUS_QUICK */ + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) + return -1; + + /* Force entries are done first, and are not affected by ignore + entries */ + if (address_data->forces) { + unsigned short **forces = address_data->forces; + int kind; + + for (kind = 0; forces[kind]; kind++) { + for (i = 0; forces[kind][i] != I2C_CLIENT_END; + i += 2) { + if (forces[kind][i] == adap_id + || forces[kind][i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found force " + "parameter for adapter %d, " + "addr 0x%02x, kind %d\n", + adap_id, forces[kind][i + 1], + kind); + err = i2c_probe_address(adapter, + forces[kind][i + 1], + kind, found_proc); + if (err) + return err; + } + } + } + } + + /* Probe entries are done second, and are not affected by ignore + entries either */ + for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { + if (address_data->probe[i] == adap_id + || address_data->probe[i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found probe parameter for " + "adapter %d, addr 0x%02x\n", adap_id, + address_data->probe[i + 1]); + err = i2c_probe_address(adapter, + address_data->probe[i + 1], + -1, found_proc); + if (err) + return err; + } + } + + /* Normal entries are done last, unless shadowed by an ignore entry */ + for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { + int j, ignore; + + ignore = 0; + for (j = 0; address_data->ignore[j] != I2C_CLIENT_END; + j += 2) { + if ((address_data->ignore[j] == adap_id || + address_data->ignore[j] == ANY_I2C_BUS) + && address_data->ignore[j + 1] + == address_data->normal_i2c[i]) { + dev_dbg(&adapter->dev, "found ignore " + "parameter for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->ignore[j + 1]); + } + ignore = 1; + break; + } + if (ignore) + continue; + + dev_dbg(&adapter->dev, "found normal entry for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->normal_i2c[i]); + err = i2c_probe_address(adapter, address_data->normal_i2c[i], + -1, found_proc); + if (err) + return err; + } + + return 0; +} + +struct i2c_adapter * i2c_get_adapter(int id) +{ + struct i2c_adapter *adapter; + + down(&core_lists); + adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); + if (adapter && !try_module_get(adapter->owner)) + adapter = NULL; + + up(&core_lists); + return adapter; +} + +void i2c_put_adapter(struct i2c_adapter *adap) +{ + module_put(adap->owner); +} + +/* The SMBus parts */ + +#define POLY (0x1070U << 3) +static u8 +crc8(u16 data) +{ + int i; + + for (i = 0; i < 8; i++) { + if (data & 0x8000) + data = data ^ POLY; + data = data << 1; + } + return (u8)(data >> 8); +} + +/* CRC over count bytes in the first array plus the bytes in the rest + array if it is non-null. rest[0] is the (length of rest) - 1 + and is included. */ +static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest) +{ + int i; + + for (i = 0; i < count; i++) + crc = crc8((crc ^ first[i]) << 8); + if (rest != NULL) + for (i = 0; i <= rest[0]; i++) + crc = crc8((crc ^ rest[i]) << 8); + return crc; +} + +static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) +{ + return i2c_smbus_partial_pec(0, count, first, rest); +} + +/* Returns new "size" (transaction type) + Note that we convert byte to byte_data and byte_data to word_data + rather than invent new xxx_PEC transactions. */ +static int i2c_smbus_add_pec(u16 addr, u8 command, int size, + union i2c_smbus_data *data) +{ + u8 buf[3]; + + buf[0] = addr << 1; + buf[1] = command; + switch (size) { + case I2C_SMBUS_BYTE: + data->byte = i2c_smbus_pec(2, buf, NULL); + size = I2C_SMBUS_BYTE_DATA; + break; + case I2C_SMBUS_BYTE_DATA: + buf[2] = data->byte; + data->word = buf[2] || + (i2c_smbus_pec(3, buf, NULL) << 8); + size = I2C_SMBUS_WORD_DATA; + break; + case I2C_SMBUS_WORD_DATA: + /* unsupported */ + break; + case I2C_SMBUS_BLOCK_DATA: + data->block[data->block[0] + 1] = + i2c_smbus_pec(2, buf, data->block); + size = I2C_SMBUS_BLOCK_DATA_PEC; + break; + } + return size; +} + +static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, + union i2c_smbus_data *data) +{ + u8 buf[3], rpec, cpec; + + buf[1] = command; + switch (size) { + case I2C_SMBUS_BYTE_DATA: + buf[0] = (addr << 1) | 1; + cpec = i2c_smbus_pec(2, buf, NULL); + rpec = data->byte; + break; + case I2C_SMBUS_WORD_DATA: + buf[0] = (addr << 1) | 1; + buf[2] = data->word & 0xff; + cpec = i2c_smbus_pec(3, buf, NULL); + rpec = data->word >> 8; + break; + case I2C_SMBUS_WORD_DATA_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_PROC_CALL_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_BLOCK_DATA_PEC: + buf[0] = (addr << 1); + buf[2] = (addr << 1) | 1; + cpec = i2c_smbus_pec(3, buf, data->block); + rpec = data->block[data->block[0] + 1]; + break; + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + buf[0] = (addr << 1) | 1; + rpec = i2c_smbus_partial_pec(partial, 1, + buf, data->block); + cpec = data->block[data->block[0] + 1]; + break; + default: + cpec = rpec = 0; + break; + } + if (rpec != cpec) { + pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", + rpec, cpec); + return -1; + } + return 0; +} + +s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) +{ + return i2c_smbus_xfer(client->adapter, client->addr, client->flags, + value, 0, I2C_SMBUS_QUICK, NULL); +} + +s32 i2c_smbus_read_byte(struct i2c_client *client) +{ + union i2c_smbus_data data; + + if (i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data)) + return -1; + else + return 0x0FF & data.byte; +} + +s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) +{ + union i2c_smbus_data data; /* only for PEC */ + + return i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, &data); +} + +s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) +{ + union i2c_smbus_data data; + + if (i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_READ, command, I2C_SMBUS_BYTE_DATA, &data)) + return -1; + else + return 0x0FF & data.byte; +} + +s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) +{ + union i2c_smbus_data data; + + data.byte = value; + return i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_WRITE, command, + I2C_SMBUS_BYTE_DATA, &data); +} + +s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) +{ + union i2c_smbus_data data; + + if (i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_READ, command, I2C_SMBUS_WORD_DATA, &data)) + return -1; + else + return 0x0FFFF & data.word; +} + +s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) +{ + union i2c_smbus_data data; + + data.word = value; + return i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_WRITE, command, + I2C_SMBUS_WORD_DATA, &data); +} + +s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, + u8 length, u8 *values) +{ + union i2c_smbus_data data; + int i; + + if (length > I2C_SMBUS_BLOCK_MAX) + length = I2C_SMBUS_BLOCK_MAX; + for (i = 1; i <= length; i++) + data.block[i] = values[i - 1]; + data.block[0] = length; + return i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_WRITE, command, + I2C_SMBUS_BLOCK_DATA, &data); +} + +/* Returns the number of read bytes */ +s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) +{ + union i2c_smbus_data data; + int i; + + if (i2c_smbus_xfer(client->adapter, client->addr, client->flags, + I2C_SMBUS_READ, command, + I2C_SMBUS_I2C_BLOCK_DATA, &data)) + return -1; + else { + for (i = 1; i <= data.block[0]; i++) + values[i - 1] = data.block[i]; + return data.block[0]; + } +} + +/* Simulate a SMBus command using the i2c protocol + No checking of parameters is done! */ +static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, + unsigned short flags, + char read_write, u8 command, int size, + union i2c_smbus_data *data) +{ + /* So we need to generate a series of msgs. In the case of writing, we + need to use only one message; when reading, we need two. We initialize + most things with sane defaults, to keep the code below somewhat + simpler. */ + unsigned char msgbuf0[34]; + unsigned char msgbuf1[34]; + int num = read_write == I2C_SMBUS_READ ? 2 : 1; + struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, + { addr, flags | I2C_M_RD, 0, msgbuf1 } }; + int i; + + msgbuf0[0] = command; + switch (size) { + case I2C_SMBUS_QUICK: + msg[0].len = 0; + /* Special case: The read/write field is used as data */ + msg[0].flags = flags | (read_write == I2C_SMBUS_READ) ? I2C_M_RD : 0; + num = 1; + break; + case I2C_SMBUS_BYTE: + if (read_write == I2C_SMBUS_READ) { + /* Special case: only a read! */ + msg[0].flags = I2C_M_RD | flags; + num = 1; + } + break; + case I2C_SMBUS_BYTE_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = 1; + else { + msg[0].len = 2; + msgbuf0[1] = data->byte; + } + break; + case I2C_SMBUS_WORD_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = 2; + else { + msg[0].len = 3; + msgbuf0[1] = data->word & 0xff; + msgbuf0[2] = (data->word >> 8) & 0xff; + } + break; + case I2C_SMBUS_PROC_CALL: + num = 2; /* Special case */ + read_write = I2C_SMBUS_READ; + msg[0].len = 3; + msg[1].len = 2; + msgbuf0[1] = data->word & 0xff; + msgbuf0[2] = (data->word >> 8) & 0xff; + break; + case I2C_SMBUS_BLOCK_DATA: + case I2C_SMBUS_BLOCK_DATA_PEC: + if (read_write == I2C_SMBUS_READ) { + dev_err(&adapter->dev, "Block read not supported " + "under I2C emulation!\n"); + return -1; + } else { + msg[0].len = data->block[0] + 2; + if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) { + dev_err(&adapter->dev, "smbus_access called with " + "invalid block write size (%d)\n", + data->block[0]); + return -1; + } + if (size == I2C_SMBUS_BLOCK_DATA_PEC) + (msg[0].len)++; + for (i = 1; i <= msg[0].len; i++) + msgbuf0[i] = data->block[i - 1]; + } + break; + case I2C_SMBUS_BLOCK_PROC_CALL: + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + dev_dbg(&adapter->dev, "Block process call not supported " + "under I2C emulation!\n"); + return -1; + case I2C_SMBUS_I2C_BLOCK_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; + else { + msg[0].len = data->block[0] + 1; + if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { + dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " + "invalid block write size (%d)\n", + data->block[0]); + return -1; + } + for (i = 1; i <= data->block[0]; i++) + msgbuf0[i] = data->block[i]; + } + break; + default: + dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n", + size); + return -1; + } + + if (i2c_transfer(adapter, msg, num) < 0) + return -1; + + if (read_write == I2C_SMBUS_READ) + switch (size) { + case I2C_SMBUS_BYTE: + data->byte = msgbuf0[0]; + break; + case I2C_SMBUS_BYTE_DATA: + data->byte = msgbuf1[0]; + break; + case I2C_SMBUS_WORD_DATA: + case I2C_SMBUS_PROC_CALL: + data->word = msgbuf1[0] | (msgbuf1[1] << 8); + break; + case I2C_SMBUS_I2C_BLOCK_DATA: + /* fixed at 32 for now */ + data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; + for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) + data->block[i + 1] = msgbuf1[i]; + break; + } + return 0; +} + + +s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, + char read_write, u8 command, int size, + union i2c_smbus_data *data) +{ + s32 res; + int swpec = 0; + u8 partial = 0; + + flags &= I2C_M_TEN | I2C_CLIENT_PEC; + if ((flags & I2C_CLIENT_PEC) && + !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) { + swpec = 1; + if (read_write == I2C_SMBUS_READ && + size == I2C_SMBUS_BLOCK_DATA) + size = I2C_SMBUS_BLOCK_DATA_PEC; + else if (size == I2C_SMBUS_PROC_CALL) + size = I2C_SMBUS_PROC_CALL_PEC; + else if (size == I2C_SMBUS_BLOCK_PROC_CALL) { + i2c_smbus_add_pec(addr, command, + I2C_SMBUS_BLOCK_DATA, data); + partial = data->block[data->block[0] + 1]; + size = I2C_SMBUS_BLOCK_PROC_CALL_PEC; + } else if (read_write == I2C_SMBUS_WRITE && + size != I2C_SMBUS_QUICK && + size != I2C_SMBUS_I2C_BLOCK_DATA) + size = i2c_smbus_add_pec(addr, command, size, data); + } + + if (adapter->algo->smbus_xfer) { + down(&adapter->bus_lock); + res = adapter->algo->smbus_xfer(adapter, addr, flags, read_write, + command, size, data); + up(&adapter->bus_lock); + } else + res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, + command, size, data); + + if (res >= 0 && swpec && + size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA && + (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC || + size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) + if (i2c_smbus_check_pec(addr, command, size, partial, data)) + return -1; + return res; +} + + +/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL_GPL(i2c_adapter_dev_release); +EXPORT_SYMBOL_GPL(i2c_adapter_driver); +EXPORT_SYMBOL_GPL(i2c_adapter_class); +EXPORT_SYMBOL_GPL(i2c_bus_type); + +EXPORT_SYMBOL(i2c_add_adapter); +EXPORT_SYMBOL(i2c_del_adapter); +EXPORT_SYMBOL(i2c_add_driver); +EXPORT_SYMBOL(i2c_del_driver); +EXPORT_SYMBOL(i2c_attach_client); +EXPORT_SYMBOL(i2c_detach_client); +EXPORT_SYMBOL(i2c_use_client); +EXPORT_SYMBOL(i2c_release_client); +EXPORT_SYMBOL(i2c_clients_command); +EXPORT_SYMBOL(i2c_check_addr); + +EXPORT_SYMBOL(i2c_master_send); +EXPORT_SYMBOL(i2c_master_recv); +EXPORT_SYMBOL(i2c_control); +EXPORT_SYMBOL(i2c_transfer); +EXPORT_SYMBOL(i2c_get_adapter); +EXPORT_SYMBOL(i2c_put_adapter); +EXPORT_SYMBOL(i2c_probe); + +EXPORT_SYMBOL(i2c_smbus_xfer); +EXPORT_SYMBOL(i2c_smbus_write_quick); +EXPORT_SYMBOL(i2c_smbus_read_byte); +EXPORT_SYMBOL(i2c_smbus_write_byte); +EXPORT_SYMBOL(i2c_smbus_read_byte_data); +EXPORT_SYMBOL(i2c_smbus_write_byte_data); +EXPORT_SYMBOL(i2c_smbus_read_word_data); +EXPORT_SYMBOL(i2c_smbus_write_word_data); +EXPORT_SYMBOL(i2c_smbus_write_block_data); +EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data); + +MODULE_AUTHOR("Simon G. Vogl "); +MODULE_DESCRIPTION("I2C-Bus main module"); +MODULE_LICENSE("GPL"); diff --git a/documentation/htdocs/examples/example.c b/documentation/htdocs/examples/example.c new file mode 100644 index 0000000000..7c8edf79c4 --- /dev/null +++ b/documentation/htdocs/examples/example.c @@ -0,0 +1,117 @@ + +const char *token_names[] = +{ + [CT_POUND] = "POUND", + [CT_PREPROC] = "PREPROC", + [CT_PREPROC_BODY] = "PREPROC_BODY", + [CT_PP] = "PP", +}; + + +int main(int argc, char *argv[]) +{ + struct junk a[] = + { + { "version", 0, 0, 0 }, + { "file", 1, 150, 'f' }, + { "config", 1, 0, 'c' }, + { "parsed", 25, 0, 'p' }, + { NULL, 0, 0, 0 } + }; +} + + +color_t colors[] = +{ + { "red", { 255, 0, 0 } }, { "blue", { 0, 255, 0 } }, + { "green", { 0, 0, 255 } }, { "purple", { 255, 255, 0 } }, +}; + + +struct foo_t bar = +{ + .name = "bar", + .age = 21 +}; + + +struct foo_t bars[] = +{ + [0] = { .name = "bar", + .age = 21 }, + [1] = { .name = "barley", + .age = 55 }, +}; + +void foo(void) +{ + int i; + char *name; + + i = 5; + name = "bob"; +} + +/** + * This is your typical header comment + */ +int foo(int bar) +{ + int idx; + int res = 0; // trailing comment + // that spans two lines + for (idx = 1; idx < bar; idx++) + /* comment in virtual braces */ + res += idx; + + res *= idx; // some comment + + // almost continued, but a NL in between + +// col1 comment in level 1 + return(res); +} + +// col1 comment in level 0 + + +#define foobar(x) \ + { \ + for (i = 0; i < x; i++) \ + { \ + junk(i, x); \ + } \ + } + + +void foo(void) +{ + switch(ch) + { + case 'a': + { + handle_a(); + break; + } + + case 'b': + handle_b(); + break; + + case 'c': + case 'd': + handle_cd(); + break; + + case 'e': + { + handle_a(); + } + break; + + default: + handle_default(); + break; + } +} + diff --git a/documentation/htdocs/images/linuxlinks.gif b/documentation/htdocs/images/linuxlinks.gif new file mode 100644 index 0000000000000000000000000000000000000000..d3adec5c38785594e486ee067e96dcce47258a9b GIT binary patch literal 462 zcmZ?wbhEHb3}cXCIKsg2|NsBb@4r94|Ni#*=jZp|KfM0>_W9>m_aC2MzrUfOVRHWV z_W1SH{>$_2=cgIZ443cs=5KdkXkZ{3DE?$&5n=expaaqYvXg=Jzk)(vO6I(bRqJwI z?<>$bUy^&jVqL%I`~L?P6nN-JRqtL>bTY?k{)H7KUb&h|jVlfZ>MANNcUG3p&~Zs^ z$|z);!q2c#>7E9IRPP4~hl~S1s~K|gD#{pn1O@rnA~oXG`;|J`CS{dZPU2AF6=32k zo<1R=Mo@rxiE>4gKp6uMFAED-jON6+#SC47Qv|22nwh~bIAfvOM3$~)Css!DGb!^3 z@N#f0-?~F(+g|qFduJaJoRuw@dvv?f2}W*#J1Ye{rette2+X~%8hI;=t#jJN^Q=mL z3>hAJ?}^WFk&)i25V*=FJW6sy%b7_lTqLf(5I)$e#L~mRNnvxdhc9!Fgs694lp52; z!_x#z>U>zZjy6PCaN6wlbX(5BXy<-p)3M{~=N4H;e`I0Ua`Dn4rM#$~t1G&%u8!E8 cb@$ZP?5WBLhr4)RZ(Vb9bH-&aPDTc60O?Pyi2wiq literal 0 HcmV?d00001 diff --git a/documentation/htdocs/index.html b/documentation/htdocs/index.html new file mode 100644 index 0000000000..e1a60a036a --- /dev/null +++ b/documentation/htdocs/index.html @@ -0,0 +1,172 @@ + + + + + Uncrustify - Source Code Beautifier for C-like languages + + + + + +
+ + + + +
+
+
+

Uncrustify

+

Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA

+
+ +

Introduction

+

The goals of this project are simple: +Create a highly configurable, easily modifiable source code beautifier.

+ +
+ +

Features

+
    +
  • Ident code, aligning on parens, assignments, etc
  • +
  • Align on '=' and variable definitions
  • +
  • Align structure initializers
  • +
  • Align #define stuff
  • +
  • Align backslash-newline stuff
  • +
  • Reformat comments (a little bit)
  • +
  • Fix inter-character spacing
  • +
  • Add or remove parens on return statements
  • +
  • Add or remove braces on single-statement if/do/while/for statements
  • +
  • Supports embedded SQL 'EXEC SQL' stuff
  • +
  • Highly configurable - 366 configurable options as of version 0.54
  • +
+ +

+ See some example output. +

+ +
+ +

Where to get Uncrustify

+ + + +

+

Project Websites

+Sourceforge project web site
+Freshmeat Project
+

+ +

+

Source Code

+Download Uncrustify 0.54 source
+The change log is here +

+ +

+

Prebuilt binaries

+Windows (i386) : +Sourceforge
+ +SPARC/Solaris 2.5-10 and x86/Solaris 8-10 : +sunfreeware.com
+ +

+ +

+

Universal Indent GUI

+Universal Indent GUI is a +cross-platform graphical configuration file editor for many code beautifiers, including Uncrustify. +

+ + +
+ +

Want to help?

+

+The most helpful way is to try it out and give feedback. +Documentation and examples are available in the source tree, so check it out. +

+

+You can find the output from 'uncrustify --show-config' here.
+Here is the default config file. +And one I set up for Linux.
+And here is a before and after C source example.
+That should give you a pretty good idea of what Uncrustify can do.
+

+ +

+If you find a bug, please do the following: +

+
    +
  • Reduce the input source file to the minimum that still has the problem
  • +
  • Use the sourceforget.net bug tracker
  • +
  • Attach the input source file, the configuration file, and a file that contains the expected output
  • +
+ +

+If you want to add a feature, fix a bug, or implement missing functionality, feel free to do so! Patches are welcome!
+Here are some areas that need attention: +

+
    +
  • Test Java support and provide feedback (or patches!)
  • +
  • Test Objective C support and provide feedback (or patches!)
  • +
  • Test Embedded SQL to see what works
  • +
  • This web page need a (re)design
  • +
  • A logo of some sort
  • +
  • Examples that can be put on this website to show off what Uncrustify can do
  • +
  • Anything else that you want to do to make it better?
  • +
+ +

Project Mailing list

+There is one mailing list for Uncrustify.
+uncrustify-developer@lists.sourceforge.net
+Despite the name, it is for both users and developers. + + +
+ +

Portability

+

+I'm pretty sure that I'm not using anything that is OS-specific.
+The software has been tested on the following operating systems: +

+
    +
  • Linux (Ubuntu)
  • +
  • QNX (6.2.1)
  • +
  • OS X
  • +
  • OpenBSD 3.4
  • +
  • NetBSD 1.6.1
  • +
  • Sun Solaris 9
  • +
  • Windows XP (binary available)
  • +
+ +
+ +

Links

+ +

Distributions that package Uncrustify

+ +
+
+
+
+
+Support This Project + +
+ + + + diff --git a/documentation/htdocs/linux.cfg.txt b/documentation/htdocs/linux.cfg.txt new file mode 100644 index 0000000000..ebabfa6bb2 --- /dev/null +++ b/documentation/htdocs/linux.cfg.txt @@ -0,0 +1,94 @@ +# +# uncrustify config file for the linux kernel +# +# $Id: linux.cfg,v 1.6 2006/02/15 03:24:38 bengardner Exp $ +# + +indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +indent_label = 1 # pos: absolute col, neg: relative column + + +# +# inter-symbol newlines +# + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_brace_while = remove # "} while" vs "} \n while" - cuddle while +nl_brace_else = remove # "} else" vs "} \n else" - cuddle else +nl_func_var_def_blk = 1 +nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE; +# nl_before_case = 1 + + +# +# Source code modifications +# + +mod_paren_on_return = remove # "return 1;" vs "return (1);" +mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = remove # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" +mod_full_brace_nl = 3 # don't remove if more than 3 newlines + + +# +# inter-character spacing options +# + +# sp_return_paren = force # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = add # "{ 1 }" vs "{1}" +sp_inside_braces_struct = add # "{ 1 }" vs "{1}" +sp_inside_braces_enum = add # "{ 1 }" vs "{1}" +sp_assign = add +sp_arith = add +sp_bool = add +sp_compare = add +sp_assign = add +sp_after_comma = add +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + + +# +# Aligning stuff +# + +align_with_tabs = TRUE # use tabs to align +align_on_tabstop = TRUE # align on tabstops +# align_keep_tabs = true +align_enum_equ_span = 4 # '=' in enum definition +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = FALSE +# align_var_def_colon = TRUE +# align_assign_span = 1 +align_struct_init_span = 3 # align stuff in a structure init '= { }' +align_right_cmt_span = 3 +# align_pp_define_span = 8; +# align_pp_define_gap = 4; + +# cmt_star_cont = FALSE + +# indent_brace = 0 + diff --git a/documentation/htdocs/project-support.jpg b/documentation/htdocs/project-support.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5d15550f7f88b87e2bfecce06a014f2e2f2774ad GIT binary patch literal 3788 zcmbW3RaDdsyT$)Qr;={tbfX|Kl#-ItAl)q}H4?(h zP|}C@oVC8S&h58v_iyk0Tt0UTcRv9#Wd)c50J;}9h#LUzZh^;g?p9`=R+h|2J5O6? zZCfj5MVOk#-7+Bezu3R%f2)5>{@d(-a(A5oIRU^7=wX9c0W5M5HaY077hnJYEG%pg z2>6fi2=EC3EFxT-d-oX`0K&aDL0EYA)V~NG7B&tpK8S#VkQ|_-qJG5kn3V?1As}`S z(|~~gR|EjqIC!}Kj&PF$*Z>v?2ZRj}|KASizJ{Cvz@=otqhb}H1`7(w$Z49HyCvT( z0VLR<`}?rT0coJsh4hBKBO@r|Qva{vO*?opKz(anE*{6>8U5I44#weHm1!Zo zI;bLNKF*GU@PMZv*})^=7uWs)S}Eytq#Ttjyr`XcN_VM>8z^3duVP!fChcIN{Q?}r z^xWBEn@_a$qs4Y3#wbB3-@a+WeQDQyNLH8LIf-8FhQ}#xuLPV(*YABf2BIY$_x(0! zt*1C``1_JRU4iM_)QLK;uXs}rL8#Z;bZ1Np1K(2y;f6OwViBhtnk1g%@%4Xrp#W%xpXwYgH z*`LPvYD6F#la;+WyZcew{dMSsJZ@Q`8wY30_0`6Yf{vbzW@OoTg@wXc1$lg=YOg|{ zQH-!w*re%@ubT`t>7S8laQ*?F`H#cpTZxOXJoNc0--wByqEEg@`)*4b8lp>i6PU7E zdfSKmxi%UA*J9Q4{mEKsChsAE-Z)T9)Kr2wi__C%NN#A1l(LrQBGg6&qp;t5P813{ zuf|r|ZdNMis=ljpyzy+JY%UDHy{*8q4dlRo$YHQ-hwPR+kCi1W$+<9qzsf}G$?8lY z7An$aS!~_r=OPRaw?CzcZTv~%L-l%;i^I(2NKfOjSp<5C@#PaeRwNK+=|1HP5Rz89 z0w+TGyx&gFQISyM#=$TFQaRC=51{!w7TR9kTY1OM{`_-^tc~)qG8DP{!-%8Vp;1q% zIUNLitv=!EWh)6y{UvIoQ8isH`gyaThG5oYXO@Z9(>;BT{{Ax4fd99f>OS1lphEtP*m8v9Tbena$`Q&Hyr zmb{<&BshcBPb`rr$wz)KRnVRDcqTQcAz!5nuGtvPJPu+`4}@V<#i!9C!DUJ5gYA?j z*Pi6|(5--Gy2^qrLWm!sEsTwi|YoP+E099%Swjv#vRpbNr-0N;1$0 zO*KR@=3c7NaI=6G?-N=7VM>=!NLEPdACgc6+R?49sO|EouEtfm52bN`EQNCriJPij^@^A4@lzNiMARz06idp5eyG z*;Wh@Zrx04Q*@EJzIBR13URdBZ{ogKYDMOBQ-eJm!osqGK#y(HXELaY1Ifz^Qs1@V z+F5G)F&Defn+NXC`H}1+JI-E;?ynM>$c@XbAOAs0l(eMKq29!WaGOAdYtHd8T6aL} zOYg39hk(;<7=~Fe*53~y+gcMsDAH*^Dg-HM9eRt0s=m_VDoz&OWn!UkY{>L1@ctbx z#}+t#c4!%6|4ufa5!EJ{Rk(<&9w|M-V99sh8x_x>P-i&U+1q#SrWtxflAUkIKr~7}Z<4YibV=TbDbTw} zo#rfO8WwTAgu=ON0?C-&XIx9!yxYD#d@c~D%sw5tARSkvkrbfpY z5?n}yap6|s=Y0WP#q5j_|KMeemu!E^4fTUnzL++OwnCWqW*+iaaFxS+1wMI5)B98E zDC9HlU{k42I%aZ$q>Lb!<;g6~y_o``rX}I6P%t(rS$=g>oQxgVTy#mNJb;Kd=1oqO zi~eUuq#Ss>KXox%X{?PgVo^k$0s+Ghek&by+wQ2AwIymPWUVnO=qo6IVAl`PP=eyT z)4T;&qXG`mr~=iS=N;+%ChdhJ&BNDsz$RG98Y84BWHGc$=cvswX2ol-7C5)H%~lKB zl~dk$q$`ZnWql*>#q^fC7;8C&V41^Dx8P43U+C+T)xYv+4i$lI<>cJWivuNGZ*JI! zjLnO|m$V#6GfwG2qw&*jQ+Z-7d(mF%U)IIX>&<`u0&uZdChPq+T!SS8ZQ9tkYVdrS zpMJ9`=a}paXb6c~v+goR>@ctnkyOgQ|7qW+xnhsYSS6XOuZd>e?fw#lVTDqk|3yEV zx7A&Kf{4D|7AkMz<7Ofpk!K9jdtmgP1cnL|F?12SE*moBJ>zM%F_$WqjUQ__eieyU zFw<(;Wor;GIAR)Dfwn;qwW`FLQPy1v>0U%!ZGu$m0|OTs5s zjDnwk3ZgU$sy{y1Z2(7&z9*JL6YMK;by?YnOn;ZLUladQNFgQJOl%!lzR^t<|G+8+RafLyS;x0U5KBq?a z`_sqtI6Nna#Ww_2DH$wXY?1Kl$iB*16%$cvFY3d@Qqx6~7XExu9NYvQ<{CH_{c$uV^>$DR`?n+dKxoy1Etq$13gl zpkoVByCB9uhLnc;3Cj``qb#qK^H4=tgMbLw3vQH?f)7e|*H%^Jq+^Z@8WH^gC@C@P zMk&5WdbNoR>+I|s;&rG<2kv9QOJ}+sVRP0UsaPeMe`rk|vX~a9JW8;V0y#dYs*1&l zUQ~TBY530GUX@sxBa#k}E3Kc`GU#o-_Te<=k*EW0gnIH8ok)Uy`XQK3Rgu4|ODPG z&Wk})4aQGj>L@2hIM#CVC&q~e5+AF z%tFg%y;V0CIXrG4ULqB2YMx>86t>z)6v*f`k}Hv8>7klJ>l(5ix)d3Ip~r{mfm^*q z*E`{sJyqH({F?7X$hh)ZCSl5+xqg#r_4pPye@AgT-Jq&$V^Al;KxVws^xwRdAjSRm>^MPxP^gZl~}!V+)kpvBBh_e&-TFz z!osZ9%q>|1QbKW(M4nLJFk#dDV%u}CNCT?GAf^(teonhQQ*>5!xP!fL>|{D}N3$*B zz)i~ZV`vn$dbN8MF609?8!H3aYJNN%mS;>0Ctuvk=D)rydt|m$g5-BmB5E)bVSR_7 zSjpc1sdHjv)pQ5wcfY(H{tID5rfW_f%jWDki>|T>1IFm`Ml*m&vraB^{fxMLmj>Si&!fws%_CnB#oq&Tt5 z#j#6l)Vin;74X?FOzc#S&4l;V+M-Noi@xWGyT@W8q*^@`0+NJmy=V;_BehsX63=|Z zZ#Mowb_Xywr6r?7Ki7>QgF(ehYWpYHtLY=*yRqPkqYxqmh3Ck4DImS|ZYDAT+zcf7WdcXCqFeG$oI*ZcL;=i{hD z?d~G4^bb5^MHu!0C+>>XJ3s_&I)CdabmP%>#nBJ8yPa!-t_{onT@%N+87sq6k2;WL z>OZ~>%c*U2CkxwD=*^bs28?4xkzJa7rXjEKTl@BB`m0alfCHUzHIKaOh~XRVN6cgc z4vj2Bc_D#*^IAHcGV>TonZ%5sF?31%wNL8#;YFCY(t2t~&DI^z;Bh#1zl?0Zy?+v$ z{~E@hYSc0p5z)C1sXz^r9WGJ3zqPWG1wHrZ%3VM7#xgcQ=GRgnXZlVhNe!neSJy!h zUEhMpt$6>pR-CT%mSxxO#8ro;c~34T9a7@4${qSuW!}`Iz|=2*olHi`y_?g!#s2{| C3-&_* literal 0 HcmV?d00001 diff --git a/documentation/htdocs/uncrustify.css b/documentation/htdocs/uncrustify.css new file mode 100644 index 0000000000..240171e939 --- /dev/null +++ b/documentation/htdocs/uncrustify.css @@ -0,0 +1,63 @@ +html, body { + background-color: #5a5f52; + color: #ffffff; +} + +div.node1 { + margin: 0em; + width: 70%; +} +div.node2 { + margin: 0em; + width: 90%; +} + +h1, h2, h3, h4 { + font-family: Verdana, sans-serif; + color: #d1c121; +} +h1 { + font-size: 18pt; +} +h2 { + font-size: 14pt; +} +h3 { + font-size: 11pt; +} +h4 { + font-size: 10pt; +} + +pre { + font-family: Verdana, sans-serif; + font-size: 11pt; + background-color: #6b6f63; +} + +a { + font-family: Verdana, sans-serif; + font-size: 11pt; + color: #d1c121; +} + +p, small, li { + font-family: Verdana, sans-serif; + color: #ffffff; +} + +p { + font-size: 11pt; +} + +small { + font-size: 7pt; +} + +li { + list-style-type: disc; + font-size: 11pt; + font-style: italic; +} + + diff --git a/documentation/htdocs/uncrustify.html b/documentation/htdocs/uncrustify.html new file mode 100644 index 0000000000..48c93bf133 --- /dev/null +++ b/documentation/htdocs/uncrustify.html @@ -0,0 +1,29 @@ + + + + + + +

Uncrustify +your C code

+Project +web site +

Download +Uncrustify 0.0.3

+What it does: +
    +
  • Ident code +
  • Align code on '=' and variable definitions +
  • Align #define stuff +
  • Align backslash-newline stuff +
  • Reformat comments (a little bit) +
  • Fix inter-character spacing +
+What it doesn't do (yet): +
    +
  • Split long lines +
  • Handle format changing #if/#else stuff +
+ + + diff --git a/documentation/overview.odt b/documentation/overview.odt new file mode 100644 index 0000000000000000000000000000000000000000..e14e3285b143be3a16d9748525019edcfa39c4a7 GIT binary patch literal 16651 zcma)k1yo&0(=8exxVyW%ySoKRRRYidFBV$tnmf+2s&zh00pmyLyuiIcmXiGiJ+wS|#^lZ7pS z-UVPxXKUbS;Yep|X96&`HFCBw0XWe)nYcMA{7u;l{*Q$9k`uNCm|B=QJN#7R$VBhx zWZ>lNXlUR-{~HeSrOQ_%{s6sXUJdyt&cMjX#MF>32^>>5dVh5`Ip}89Bj=T zOdS6*{C`9Ko1L$n{W)p>SCo^jt@Zy#;s1-37B&WECXVz%7EU$>c8>pJonT(T)&}mj z&Q7#O21e#4M#lQa6bNSe`jG3!`ud8Yj68lYKi5Ze{_QjBi!k=f_20`5{nBb=3vl{< zX^(MrY_S{9TH6B@{JI*=X{D>u)j1zxI6konIB>GGHKU0lDl}`q-_vo3-quuwhq!Eo z_qNj0%xo`h&tWEUt-Y_RtwW)P*y)VDWn@mn97T66q;GGMLw4x>xce@RZSesDwo8P9 znC?yfhZ8zoh%qd^^ru~E%zhr@R*4YzuR%~klrWF-`gP;HbDoO>3Hy>ojo+bCm{yn# zelhZC~A>kx$RcVvDD5KP= zcOfJLYHyZG4XwYz=p^vrXpu^8TYN4|&=7`Ak1uM&Dk(u!3nVRp3RNyG!FD;VaciD9 z*gO`SX{2QBCS`J;^?*pf9&4^g)=~IY)L?gnQY_S4o$%?KnA)B+rSv=dfThgD<|dpC*ritPp&bVk^|S}g`5eYJwT+)ZNQ%Q&d?#6voWLvzY~ z{x;7CLY%6Pa&In{ARx5Og~1*AQfnx=JybDd`|Vb!unie91Z9NLL}+9#7e2||4ViAX zWh2OAz=21RTZPNln?lX1&-D z?0id$aWfM&DbrXA{XCOSv7(FH!61=@cT;ms?44Ee*L#-~Z1v;~1O1JUP1etHwCf;( zb<$oLc8Bk(P*aKT5>q8-@_gamXjxe$E|prb+~3291hp64#r~cVe6ih#?)M$r@KCWln636r)Sx zp6B1^J0$QPU;IQR1OfX20z$r#K$DDzC>rjlJ%z-jPP8a}OspvV_>-lpR?gyzpK|j< zXg_;I?UK94V@;WQGd7AevOU>W4{;$gbIJ;RpJ9^^x}U zY})K_IFykPQ3w|OCaZQZ!0ZX8XbPVT9ADiK>PKWVG`~C3^;&)~2@LdRO#a=)Q#TxQ zKky3i3bL>;^Di17z=t(fRnUM0v%?C)!wI40ra)I+$R-9ravVbpcqN+IiFjL}-xUW^ z6gaAtjn{uImhT?&k82DY$B|H|5LBaV1amZz#Ip%03}t7!a$}Z= z1_*gD+9K#jF9*r*Qq{a`>G01T=}2d#Z4olufZDd`zgQYT^CjDsi@id-IX4ynNj7~K zV-SJa<7~*i?F!yHj;@~~*}0yWqe7qzS#zO87Z7xvMZQVrF2X!3CLgrDDk1=T&b1_~ z>)JfXy$m>ys!MIzIwm{$<`REn{Zh36IA4T-7t+i1M3tY?IIy^Pk7Hmyv^bh868EwQ z%@TL2<=4@v9oERD9%Q(@j~Q0J zaCP5qH`sL^m@8!E>-ERHU&;&Jw#}on%-^;*ZnXCtD`YX4_%F*2dD85QFq>RmvmWT2 z)`GuljpXa>w?VJ`RuJnoI&WXt;5<#+LyGWK1~@8Z5O<4@-3 zO(#DgGhU0oi@%g@wx@n-e-T&8^0fM<0@RjGpKX5!p07sNr9j!%m^=CPNIj&HPB-{6 zT_Z6vFwBAv0eF>M(Oqe>GW6*qGh<`Ae%k~i^(L3}K1WQWWP`r{Ckw)N{n6}_aaP%W z7?fy61;9sN8YDM-6xO#|{aYN^5oCi}VywE|kAKt+6qYWwagLAH3_8w$92$~p*)SCfS1~ExwI0mWI==NJ--t6fP(SVZBz(RZO^})r&Yp65BxRSN&awaQ;+c+YbcLOM@C2B3vJ}3Il5n zx~DkYveFGJ{b}mLreAS$-iWh4A5%g)xb!sJ=4n6x<3ac%!al^R1Gp&$251MqJftOU zk9r_T;jJI^IJB}mHH<5E7nUN449sxMQPx^^7BDNk3El7(rHKYHU;0h@eHqj)yl{x6 zfrT>&w*UR&5E|qMdtMaVX7#PNkJx|?{7x|n4A_)|x@sMa1!+q3!FehOwg&^%_}N_C za%8S?rX zyLTJTs3qT!!a8X?yxpsw%WOGHAu7oO|GpI(84f;W3h+HuJ3>XI8Rn!0L1&RIFA-!Q zwh+eBxmvg;B6^t9lTwBnXY8o8QJHQtvn*;SG5@yzgs!@u03{V=O27cQk~n574?xb5 z90f7Hw&=!u?1R16udu7P47&4ZI3v{tF9kf41E`J&H8T}N(Gjqaw z13b{S$Q&71^<@2~r92+-13G=UHQcHy&&Do5bc4cXnGZs|1?fZPv(d?HjXeN1&JYH* zwCaIiDgThcAk+NqaA_8kEkXWnpte6-wC)4K}>7MteqvRJGJY=4gAEO69N;d#^h&~9m7=12k?H{vJyn||84!1DdfU@{P zN>LhybW(WkFFWGAQHpoQVR)t-ZhdimLB{EO-b0GB7j4Oz2`xzk)xoG&nTtdzR6!6H z+jKzizEebF3@k)`-mW6*l!?!8V6n zSz$jdDp#}kobj?g=ArL(7 zR9dXfJT6nR1MtSbI$b_PecM3DK&>}T)T+x)c5R<>*M>zl$95z~eUKhmvT zV?*bdbXM5HxY*VcJ^N&D_NZRZL7|jGCRaI&f)0(F z%E9n+o{FU+4h><D0V=$20DSkO-~J_F_) zoE3$XGOi!rZk~b5K>EUTY9$T|EGodNvS2hBiLxB3KRKz$Ynu>}`c!4fTSAAOCL?t# zsUi{y1ns{soW|>m3`ZuEycLj$%ri&XaL+d^3}Wc!tIhJyHSI}CN^>Zkd(VFyYa4!% z#a%U;pFTcCRXC@VFZanh5<6p7No@O*5g#5gci{IT9+L*Y=x`QZaASdLsAe+kj+AZ> zpEZ+WYIMJ5>G*y?>Gs5`%1PGJ6gR&v1OgZ{4dX4$)95#oo2mRy@E@7*cvkIH?$Oba z`Nq!|vGrEPI?LagXvzz2&DjZ@T3otUuiIBYQh{G6aN7&AS~=67o+G;h10{uq81E7u zk@SB~TCT85+`#2;FRc5a0oah8KYGXSdHj z8xHa03^Re_MW*(*dR-6o(b^dBZehDre6$%m4R0))1IdXdcZx*qNf|2hYBLZaEL9vA zfwc$Q)gSNo38O!h;r&?br#uU-w^ofF^O)ssNG_ApwjVjuj)yxB?s3sbS%>11`_T{k;j4Ct-j46P3we|lVA zcm{rbxl(iZH6;ih2ngW&zka;Gefjb3=;Ur~;`sVnW<*mfevu8u=cHVJ*10m@j_MX2ZO1PJjQR*Blyyrx4kc1KIdkm4}%+A zGKTd{=?7U1BMGrbcjia?hFq*4Ps!WPd&nBL$f#=@Cw)~I5DxE!3@TK|+B8zIYciHV zsLY}0Hl*Al9b&8%lK$jbSkFYQxu9S_awH|)@<})t)m9j-G~}ctS?60&_KJc*FEpET z@0@kPscz0jN-*P)1BoPbFCXdUp;1Kwlb#$|^9rD)8I!p!StO#@@Jk`;dc)=rbcSUa zNya)#@kkE|mN@cIs=@n^O{Eq(5=~?3VTjZ>l1|$yXH}Rui1ev&Q$1Qe5d9&hfTkNV z%5hc2u~9A0o$4%-oy3fBZ4*yTdF9|{R~6W!^ABYF|$cg1tr&4~L> zC}dp8j=}*&SRA@OGTzn>=p)wm{krG}(X98pEeZv14tY1PENEdrcG;@3U7gfu0VIb;_ld^L8mfoGEh5udoyA2*1r=*nR5<>F_CG1JPuu9VQ!cJ zX&am1gK6Wm73G&y5F33crB;OM04X@dvu};|NTldOdxFzapXw-4)v-)av@{Ec#EYDZ z>M}OHLubPerj|%%^Q?>~Vy26%aWCJ%CYgB-)F*XebeSi80ekCMFhK#cz7eS`j)9@& zE@-5I5zI{>>=;xn9F_*hhs|OjL;zj5Xw227GyMHv+Pu#U4z2WJGl0OsYp?jS`~zd| z%X$@CJ=Oacu$O%)^gTR5D+h2GXdx^z_SuI(&Rm4S)+`_@>4w=v?4S;2o(KR;q$;t= zcEf87wR_vbsS5@WNGQJshcC_na2)EaY~ZL%X&%Gv@uccH9g4pbPz}l190Alvf>{K4 zptvIZo%O(6;3Ip$qLUdB8p_>+Z1hiGUTK9sev<2r}?^onl{v7EjMJGv& z8lwFpii)tWUS`45BTT{EBq+HQ`wrSetP?BrwaqR`)^+P%4Hu*GhVrr zTp-8LyG{+2YgyW`+Wglv;>W`l8tKPJ)}Sy_T^jO8a2OL1xmq_dEAjGyytnMjy*FzU zz9NSY{Dx;YM6#7~1{XdHvB4oW)0>520M{fg&b5Z<+>rtGOBr@t`4T{kTQ4>K4P`+R z+TJkhSjl=NodNy|+6+V524*A7CykK{7B2^wBmGNR&ycJAeXcs|>Z{UkZ?sptWe654 z2UCg$gsyNw1jS3`iamrW7vat#3&>+p6_#(p239GX*zh5(T+%B5WyrI~&RtE-a_Tp8 zP=^~_1|#LjvzuH7qEq-$#gY!4@5n0s=!E8smF%9}IEo+*I44Um;}7cLU6tWzcZ$&ByGBArKc1pO`sVP|WU zGgwV=dRi0WF1rvb^0d?CWo?V-;jE>bkzH_Mo$FG8yS&Be&zw0q6xq!hGO&JIb6)4Vx(grA}|3M z*&15_%y@}Zl*MQ{i1_*5^4OZ1S{Rvd{qpP3zBqsk2wtE7N3P$Rc!``H09-#kKwJO= z8xuz^CnK)Ex`Md=D$Vt?qu*-WtStamyhP?sPIg@M^scV1bgs;Fwhm_WjGUaD^gmmP ze(%cI=npwNX9w$_QpQH~FMgj_XOkm6BON3CFWFZM|F1^9%Kp_PTU*;dI(i+$Z$tdq z9TNis3;l0pB7)y%_+hS z2E7+Ykfn){6FnOT1BsBcg|#s)Cj%oR5B)#X{ifc?!Q`j+jMn(YRmJyWAsa0NGc6Ol zG9xD!GdtHGxWCKs7#nf@6Trm4#mdaZ%Em+gtMOIJ+5lkY{NnQAGXc=5DE(~vqv|&c zOpGm@UUm$vk-O2$10LTWJ^rKq@508vJN@_+lo=%$*<@KbUv&Q*;4j!862AeR9Zei) zjZI7~04Bx+KLuZR8ZVI~z|@w2k%<2H+5VqmO#e4A=Kq@*%O7HYd^2ACmllpr7Dm5W z=wx7MZ9;2g>kM$>C1NJ}t@5V>?N{Z?H}2by<9gKffvT-u~UTb9j0x){qrzR z6uR2ss1%wMorDsx??^gpCBmDRMtr}gKWvP6UbvXL@;{oos*c_rb3Q1_i+_Op42KU2 z8Ym&GBZ|KQk!3|l$JT`V5YZgyF9t;EjuBv62Gk1yMhoAjh#igJ25G) zES-N70;7cLCDTWVv0H@a1bGX3g=W4iW%g9@Rc}Z)EiO zH13Yk`gw6Wt954 z!&q#b)(K%#o;PSJKIUaSdNFGMI2&CbLq{}OYh7SpTrk99hV0R@$iXUCq znkY_i&@nYmX5&TjcY6*skA{g9?ozgaT0rL?#(n-~VN$RXs*_w9{xx)Z*wbaD{>KH=WpUZSruPkkD{lSetc z@=2A%M@{h0#I{t$mTogJVw+T)pl!)DZVMQ*4-`-MOFl#67tJdyW)G!=ZK@vXZ!`K; zS7bG!`X!U+FUB7(WXw;drh|p%zVE;daO&B3GJZ^&7|vCE4i_ykV|d?)#+ry;eqS;O zh{0IEgh6x_w2Oeyad)1--eO;fHjeZ$Rr#T>A7gnv)%|7oOunth03NP-NqK*z6053D zsPA;8xo9U-$;NM~#O@L>*Dad>1Uye*$Y6>yR5VD6OS#!NUXp%e@UGj0B6wOHBGb+=j;@g+?l>ihwo+tzBAJ8%hyRRp&m7GS7}*ig3%uqnZ&tRUW|L@#-UTUGp?>FW)8YnRRQEO@K(7Cyn7qQ zB9O^DNzbxf-fdv1VRW=DldieU^I=NN>n_iGH(zVYJ7hY!j?68D`(lb&i5p`5{Z~Hf z&!xkk7SyU}F4w`U-LM7HGKACW=k;ywNbMV)*4$1ve;Qv%wcWWRXZ3rirljmpMtBCt zO=zm+WUn2CKDG{L!pq=5g=hg>OsRR$3%z6o zBRK^&O-po~kcW(V-*PvufeeblJ|C_lHxPH7Zwt5~lKC?6_@ANZ2ZoJx)(v##=Zqm7 zpS7AyP!B0fKV|RW%bRi);2WnHW(^r#-}PFOxO=kYE^(A__&T$2VqCS$g^ECMZj3q@CWLTi|?__@(&#_g(zJUEHF91D5uCr zba@wc7IRN2cm=oS-{aT7+=DXM=yF%LH5nYM8h1;AX(y2c3))*qCgicwL0|X_;aXG{ zv9Qy2s~4tCJR+ zpKwEQuQ`?;Kq#?!J`eg@rrqb4_=Kn49+HLy1Txm==mf4gwW{+aWiO7{Jf|vRB ziU?a!#GG#Zct4)}o~u9Tc=#A^3R6i_>A^a0MUk}_t#sN7s(zsh&0uHfv;`;jTjlZA zpsh^ed?Jl(pzp_rSQ%ypwNf8@x4pZyAGcA`vs2F6ZA6Qo;K)R?_hz)g1^J9NBl6AZ zdd6X?;+d6|HkFVrwyz5iZ{0H+U8EYfuE_C$D#`L^OMtHIeo%kp?IyAT&FV|!4?{zN zlZ{k$p@GKBs54M5s3zcBuexKV|j7 z&eL~eFBhsr0JxVMnT2J=JFSS?)k{b(M-2Z*C_R*v;^45n^FlRxXm3i0@My75A%9zz z00gZFy))BNX(+J|`J1h5SHAZG?75Zh6T4;<+zV2JYBpRD(%+}uRY-9vgP1ncM8fV7 zaX!v!31=2$iJa_5jvDUClxhszTrI-z`logt??yy{COl4!@l6(#P$?pv*}+?uo=u5Y zW}5cBP5%De2aS3Hq4J#MP8^gAfQfDA4p4iT*BX~Wk}eC`d9!1D>khUyUoNN=SH6f{F5KgNb4|`mO07q{Sad4u+O%| z{ijUNhQHu>n@NgVm`(suey#+=kIgHu>arP6VSrdh!VHE0$#QAk$`RGhXJ#s7n;T`8 zbb{MOI9+H{myg5G4t(C4wkF#gjC*c^VDQzwr{MVbR4{AF9EUrwB*N05(t~vJ!;8d7 zsrBwgDD7qAIEPjIQ7ekS4B3aD zYW>JSoaZ5(?44H0%K6%s({=cu8ZpuD>(r;4L;9s?D3qU-T_}uN2yJ35zjGAw7Zy?I9#H`M_ zK1I@gOM!av)2E`YlyZTjK7Nuaesp&_IsayM;ERw0Ese>pWL~B7?AX)SWzNd z@!C6!ch zZ^e477~3=1o<|nlYsnV(@YSW9VRd3g&&@gGQkF6$-t>c-^ei|1`BpZV{DSMz&0Z>& zqlVnmNGyzAHz~i&A$+0Tv-PcMT%JP?mi*Nb$itF=9w;?4Bw11|5|` z9?a~uz&VtTN2NV=l6O4HK^}U{OA2!~1uMS^<8p53eA=lsln0bRQTotE;cKtm8VDdb zO>SPJ>s1yU=v;odAk(8IC*08^_3;t=4*%5Mgh)b3i8it-xVcz;YAdL+8WE)uPpcU= zzyGd*23Gn4_<-7sRv~STV}qm>DU{OBL_sJ&d4TT<0!o)bvumdwOBo~@lYx%0IC4^% zm459iXV|*Q7)1gKH*3wg|FRRKgmd%b*@I+F$W$WVl;sySIcPx951J)(`+J?IB(|e? zlH?@dK2!_#Travwzd@$%mxl}(uO|}!M&r08QrW8{THw6`f>2_n))&9AK6;CNBqq&N zUMdxF%+=dzo?XvvB}EL9zWk1wP80nbPg~uhBJImtMsyao4gK?>R6;ehWxKZ-F zlxo9Ox6cy`WkVVIxM3v^=Onb>W6pr=%b0R)JSyQZMG`?Y#ks`erM#yh5_muuP`1GX zxjsh$eX~yWleELUMrEzq?}<8Mw?(pV74P=vp@)|k0qgSZe4@~)MLBAEYkW{Vd={-D zcwJM?c=-k;mWE@ZPF*-56sCSgQ#B6eXNBU&Hpi0Zjp8y2!bEdU{rD(&pJz0-LNQy4kkjbP@ z?5sRlayh~3%w%}k%Xmi_P1}bW5;f<0PC~T6{FCtp7KiyQ)^Rq~x{*ar5@k6xush$XW`@zp z^m&APi~WTU3vSBmdK-K=nzAM#muAJ_HNTcQNagW)WXxs$qQ?!x__@)F zeL3@1B*Tc61E{-%R;)^5TLLAH$UPUJaGA`2S}czvebL$4D@FR)X>K6Ye}B;6*B!y{ z;}B{&Ox8U1(YBf&vmvXq41{9`-RCix-(0-Ls~W@_^veDqLtds-LicBWMa!t5%d)SCQle7@ zZMc|hw1h^TZpn~@P#W@XI|81S*JJkZTaK_g(N^A+Xr+-?cn4UpAK-u!$95`QLU0Px zIn70xji4GC920}>Ca#W+DJ#x+(TW z2QVy^Fd3_RM8%syrNXmq0+CE4YFI2Sif*-@$1W#vmn;Z%`36(`4Qs=;XRPq3 z4YswblPZzfnUGSvob4uaaPY@7Lcw~*xDpkS-I zM|>h>hRuyzS?;<~iL^pg>tV<*zHR0IxQ4HG@Eu?)xqlI&f0PQc?w|hYOj@ zt(q12;n=kSwYadd;yX25L{%WtS3$s)5F5sN1t`s}8}N73E`%?={Gr)m9Cc!T&0ph` za*@nSIUzA}Ra$uzb1hS4?leA|HD^nR{pAcJDa)fbbr(-dgZW8V9bauqo(Du|(yBBk zeJA-|^+z$%aF8`t;0V<*_%KzO!0z!kt9HiE;X!lbge}4Baxqq%{yrMwZ@+UImrM+( zfU)i0^z2BP@7L^ja0gn~avGecu(%$-t&#IS-R{N3N$bO955MAEh`JJp)}ck5aQ2N= z`te0MVL3S6SWqzp(*_$mLg5T4zSABe@I!y~)kJ)*2bC6`_bM?6zuCe!RW5=b1#rvn zi0G-Kzmrv+?7y!Rlcc`=@Qrr!n`m-rl&Wo@*gfT^4lT)phs=03$cgiSWnL)WEa68e(!z_@JNFVh%ngz)8|m=N<&2?LnRWE832uEPZ6 zF!DX|q)Q!#iea@aW$@y7^J>T<(+TYr)oGD>+a6-YT3Xt8k5UxrNz5YdmV4||yx0(MdeX;@x5-C)V3%gDh`FLY28jWYNZ6K!M%)T`T+sR zA5%s>{cMFul~ErkU#vE#L`7s$OA`k@(y1GC;p?D*!w5b|oktuF(c)I)DUYpVW=WGf z=zv8?3zKxR)F;(i?tpBr2Pa@AUnDV|w@>LVly-X?n*Y@~dCU|u!_6C-XXTzZI@NlR z1-WWwl;1Y2u%}eTQMBM~?>UM<_jy(-Nb0&`(Wy=9+3G{V?ntyQ>EZm$1IA-y ze!6P-9&Dztg{yWJcobr;{jd@O!LCUQUA5D0oUx+Ea@2 z6EQhxi}+wU@uV9T;(4_GdI_||yn%89lmjINo)_~@#n!WrdG(a)-qFifH$U$=rGiY9Xhihu*%?5{*)Vq`_u25ljCrsdfDmy6CWvFQp}wTt<{>&Z&c;JO3u#*k;xPxJhjPNPmI*| z;#t~%*)IVr$D}S?k2bWz_X-UG@yphhZ+WjfFBNd z1r5d^3)1cbvIUP2>r-~|$&^V!%WTl10r1T@#4e)*GVpi1KA+T+rGXX&hQ=QpmD;7l zVXsV#gqA$?ImML1)~-EwMe@Pu>ng+&0XKPvauA}nV0q_w!Z}SlHMf!OMG|T{NVu{9 z8DNCXwWqxfheJwGmNloPerK7_EQhwf{8LXf7xB1IjEwmUb{w(B{(jqr6|7#?zCaFb zMiMhF1=}Gte!C0W4QKB?-6up^Au}60P*Z^3cHPq`;>E>rs5AnF1=)mtyOhe#rmLEj z@`3W72MRleHp1LkYh%H`d~4fZK|9QemYgTH&wk=2{a!#1EJlb8sAhE_djtn*XWB|J z_?S;u-JHzIQ7DDW;;En+C!K)sY5(yo()-Yyg+^i!(s5~;y)g=XJ&Ya@Z(sIuFaI9F z+j$d({XtO6PCIZVS<|SWXDzZ_=IB6MRDOBi^O3fojoUuSu4>SrMqXx=6zOzWXiIJx zU29;qf(3Pdqr&G}3A+2XmV5un&ebMGrjxjnoIOtlM4*QD6G-98#ll=;5qUD3m!&se z5qfA`{}JVM8-^bWY_8~KGEJ$FHd{n`c-R02u>+%LgH+;7jRk8Ghl=Wq-Ca~3z zhW&-cR2ZN>x)~ckk9;Pk;SL{oR+K|MDiu6p%!IIe6~ ztHjoWxIVRnQf6%j2H@#0-jz|T>3e)Ol3}P6!QIfLjFEb&s!a*8C<@JueLFyS$3k4j zfetT!x~bu~Y=2)WNyh6CJs$K4_A+3rG-4G;l%iSQ%XHC|7;5R$YKkM>wKbIN!t=@J zo9D6qN8ivB38aYGJ}BO7YQ}Lv39qzM#TTzb(98ATZi!dYk)w&z zt3T>zs8Owkj^iR1f_Hm+z!~=ju?jEJ-QDteVxP!} zlu50oP6-{o0xeaoShk|%>i3X)iajs;qC%%jEv2wq%KX`ur z>tWodP1g2XWo8gY>ByO5qYCk2ds9_xm%G9J#tz1NG>8wg4X3JL*aXN563#n8w!#=L zIAk$x_e`*&UfBkva?VPNZtmjqHshv_YB9J%G}u?!R-bfk1(wfH9G+<;1$3KSz&;#k zL|0ZwQ$pi9EN{AH==D~n9SomCG31~uK3hpE-=$j%J`A%LR2f*|JA%Mpf`Q$>326HQ z!D-03wXxK}bM1kBxByB~o|f@`5~9*Dj*k>G(%#$s-+;nJm(|Zg|sf>>C z)o4hlmyMGlb-ekguwd zSR;r9v~e@USsM)#Da?+8$+Ub{7&Qns6?#IVDHZDUeddVGp7( zU3_laM*8U9^Bd5g65H&FSCK0;$Cy}cM|5B!yDp_dYJoN&jQal&+gq7P8?>kKMkW{B z4CoJ_Cy8}6WWdVaZD&>zxG~Hf&`Q)&B|q8&Gupuq@>&eapu*4m4u5#r-m_orOo)J_ zH3F)jq@GIN`z01<=GY#xphHF!iLOiq1hK#YZSzjWv51q*L$vB}_n0+#k(iF>Y zmxcj^wI(<$1uk;?q^c~u+43Gerla^o;%9Pzuh`=v+sMv=Ap6EBA@CVM)&FD0@)_hc?t;~--cau)vI6~u zzxdw=(<{MIR#aJ#R#Hxk-o^l6VQS*|lcQRjAPeXwKoGm(4DMacJ1(l)6tT?BAmHr) zi^e5^3B&wyd)*s*KE+m)GJ7Nta1+w`L%j?>kn$Qsf_o{f|3DDMJi)5=82hZvo%(aH zN3A-XzH?~Lm4!l%cjD-jSdYFHL{4EH1Hnv*<=#Y{TrV)~+~>Kuc#B#Jx^+2hnyD@Z zG<3{5EGax*Hjox}P2ha4oz=RT2^Ae`sy@(&q3?89N*?Pv#5pmpg8(Jn^kXOd?n+3H zxSo#KI)w9eK}wdSJUR(f;iRafrlgew(Q!6k2tjSl)(u71IWt)%A7k6McF+4R@j}V?dtI z(EueUzTLjlJEpxkK`;`98)Hysy>zr$QJV=X$p=eq`_Q;?!G@MRmFfvNe&^%qpoagt zB7rvnY4X58K&3CyFbdMZASgipO=o^tmcOK5Uk1Ob3H2uke{=aHz`WG#Ka-#oR%PTAT&vg1PTK+$d z^l!?3?Sj7&o?jnW{!Fwlo8zyX>0e9z3;EY*>sLbbpULY5Y4j&O`k%nR28X={WB-{r zk^UN*{R{Wn{>pX#XXx0UxNgjs{{`?8I`SGw_6zmP%)dUX{e9)2@%}q( VBrace +'++' [ELSE - BRACE2] [VBRACE OPEN] +';' <- VBrace close inserted after semicolon + ELSE removed after statement close + +Nested virtual brace example: (EOF represents the end of the file) + if ( x ) + if (y) + y--; + else + z++; + EOF + +'if' [IF - PAREN1] +'(' [IF - PAREN1] [PAREN OPEN] +'x' [IF - PAREN1] [PAREN OPEN] +')' [IF - BRACE2] +'if' [IF - BRACE2] [VBRACE OPEN] [IF - PAREN1] <- VBrace on BRACE2, IF opened +'(' [IF - BRACE2] [VBRACE OPEN] [IF - PAREN1] [SPAREN OPEN] +'y' [IF - BRACE2] [VBRACE OPEN] [IF - PAREN1] [SPAREN OPEN] +')' [IF - BRACE2] [VBRACE OPEN] [IF - BRACE2] +'y' [IF - BRACE2] [VBRACE OPEN] [IF - BRACE2] [VBRACE OPEN] +'--' [IF - BRACE2] [VBRACE OPEN] [IF - BRACE2] [VBRACE OPEN] +';' [IF - BRACE2] [VBRACE OPEN] [IF - ELSE] +'else' [IF - BRACE2] [VBRACE OPEN] [ELSE - ELSEIF] +'z' [IF - BRACE2] [VBRACE OPEN] [ELSE - BRACE2] [VBRACE OPEN] +'++' [IF - BRACE2] [VBRACE OPEN] [ELSE - BRACE2] [VBRACE OPEN] +';' [IF - BRACE2] [VBRACE OPEN] [ELSE - BRACE2] - step1 + [IF - BRACE2] [VBRACE OPEN] - step2 + [IF - ELSE] - step3 +EOF + +-- this last semi is more complicated - first it terminates the VBRACE and then + the else, which then, since it is the end of a statement, terminates the + VBRACE. That bumps the IF stage to ELSE. + The EOF kills that off (since it is not an else) + +Order of operation: +1) if TOS=VBRACE && PC=SEMI, insert VBRACE close, PC=>VBRACE close +2) if PC=VBRACE close or PC=BRACE close, and TOS is complex (if/else/etc) + then advance complex stage. If statement ends, pop and advance + + +Stages for each complex statement: +if +IF-PAREN1, IF-BRACE2, IF-ELSE + +if/else +IF-PAREN1, IF-BRACE2, IF-ELSE, ELSE-ELSEIF, ELSE-BRACE2 + +if/else if/else +IF-PAREN1, IF-BRACE2, IF-ELSE, ELSE-ELSEIF, IF-PAREN1, IF-BRACE2, IF-ELSE, ELSE-ELSEIF, ELSE-BRACE2 + +for +FOR-PAREN1, FOR-BRACE2 + +while +WHILE-PAREN1, WHILE-BRACE2 + +switch +SWITCH-PAREN1, SWITCH-BRACE2 + +do/while +DO-BRACE_DO, DO-WHILE, WHILE-PAREN2 + + +Another less-interesting example: + +{ + if (x) + volatile + { + y++; + } + return y; +} + +'{' [BRACE OPEN] +'if' [BRACE OPEN] [IF - PAREN1] +'(' [BRACE OPEN] [IF - PAREN1] [PAREN OPEN] +'x' [BRACE OPEN] [IF - PAREN1] [PAREN OPEN] +')' [BRACE OPEN] [IF - BRACE2] +'volatile' [BRACE OPEN] [IF - BRACE2] [VBRACE OPEN] [VOLATILE - BRACE2] +'{' [BRACE OPEN] [IF - BRACE2] [VBRACE OPEN] [VOLATILE - BRACE2] [BRACE OPEN] +'y' [BRACE OPEN] [IF - BRACE2] [VBRACE OPEN] [VOLATILE - BRACE2] [BRACE OPEN] +'++' [BRACE OPEN] [IF - BRACE2] [VBRACE OPEN] [VOLATILE - BRACE2] [BRACE OPEN] +';' [BRACE OPEN] [IF - BRACE2] [VBRACE OPEN] [VOLATILE - BRACE2] [BRACE OPEN] +'}' [BRACE OPEN] [IF - ELSE] <- the brace close ends brace-open, + volatile-brace2 and vbrace-open +'return' [BRACE OPEN] <- not else +'y' [BRACE OPEN] +';' [BRACE OPEN] +'}' <- empties the stack + + +=-----------------------------------------------------------------------------= +* * +* Parse Frames * +* * +=-----------------------------------------------------------------------------= + +The pse stack is kept on a frame stack. +The frame stack is need for languages that support preprocessors (C, C++, C#) +that can arbitrarily change code flow. It also isolates #define macros so +that they are indented independently and do not affect the rest of the program. + +When an #if is hit, a copy of the current frame is push on the frame stack. +When an #else/#elif is hit, a copy of the current stack is pushed under the +#if frame and the original (pre-#if) frame is copied to the current frame. +When #endif is hit, the top frame is popped. +This has the following effects: + - a simple #if / #endif does not affect program flow + - #if / #else /#endif - continues from the #if clause + +When a #define is entered, the current frame is pushed and cleared. +When a #define is exited, the frame is popped. + + +Take this example, which isn't very exciting, as both the #if and #else parts +end up with the same paren stack. This is the usual case. + +{ + foo(param1, +#ifdef DEBUG + "debug"); +#else + "release"); +#endif +} + +Right before the #ifdef, we have this for the paren stack: + Top> [BRACE OPEN] [PAREN OPEN] + +The #ifdef pushes a copy of the current stack, so we have this: + Top> [BRACE OPEN] [PAREN OPEN] + [BRACE OPEN] [PAREN OPEN] + +The close paren after "debug" closes out the PAREN-OPEN on the top of the stack. + Top> [BRACE OPEN] + [BRACE OPEN] [PAREN OPEN] + +The #else swaps the top two frames. + Top> [BRACE OPEN] [PAREN OPEN] + [BRACE OPEN] + +Right after the #else, we hit another close paren after the "release". + Top> [BRACE OPEN] + [BRACE OPEN] + +At the #endif, the top of stack is thrown out, which restores us to the #if path. + Top> [BRACE OPEN] + + diff --git a/documentation/theory.txt b/documentation/theory.txt new file mode 100644 index 0000000000..deb1ab7759 --- /dev/null +++ b/documentation/theory.txt @@ -0,0 +1,129 @@ +$Id: theory.txt 858 2007-08-10 23:45:33Z bengardner $ +------------------------------------------------------------------------------- +This document is too incomplete to be of much use. +Patches are welcome! + + +Theory of operation +------------------- + +Uncrustify goes through several steps to reformat code. +The first step, parsing, is the most complex and important. + + +Step 1 - Tokenize +----------------- +C code must be understood to some degree to be able to be properly indented. +The parsing step reads in a text buffer and breaks it into chunks and puts +those chunks in a list. + +When a chunk is parsed, the original column and line are recorded. + +These are the chunks that are parsed: + - punctuators + - numbers + - words (keywords, variables, etc) + - comments + - strings + - whitespace + - preprocessors + +See token_enum.h for a complete list. +See punctuators.cpp and keywords.cpp for examples of how they are used. + +In the code, chunk types are prefixed with 'CT_'. +The CT_WORD token is changed into a more specific token using the lookup table +in keywords.cpp + + +Step 2 - Tokenize Cleanup +------------------------- + +The second step is to change the token type for certain constructs that need +to be adjusted early on. +For example, the '<' token can be either a CT_COMPARE or CT_ANGLE_OPEN. +Both are handled very differently. +If a CT_WORD follows CT_ENUM/CT_STRUCT/CT_UNION, then it is marked as a CT_TYPE. +Basically, anything that doesn't depend on the nesting level can be done at this +stage. + + +Step 3 - Brace Cleanup +------------------------- + +This is possibly the most difficult step. +do/if/else/for/switch/while bodies are examined and virtual braces are added. +Brace parent types are set. +Statement start and expression starts are labeled. +And #ifdef constructs are handled. + +This step determines the levels (brace_level, level, & pp_level). + +REVISIT: + The code in brace_cleanup.cpp needs to be reworked to take advantage of being + able to scan forward and backward. The original code was going to be merged + into tokenize.cpp, but that was WAY too complex. + + +Step 4 - Fix Symbols (combine.cpp) +---------------------------------- + +This step is no longer properly named. +In the original design, neighboring chunks were to be combined into longer +chunks. This proved to be a silly idea. But the name of the file stuck. + +This is where most of the interesting identification stuff goes on. +Colons type are detected, variables are marked, functions are labeled, etc. +Also, all the punctuators are classified. Ie, CT_MINUS become CT_NEG or CT_ARITH. + + - Types are marked. + - Functions are marked. + - Parenthesis and braces are marked where appropriate. + - finds and marks casts + - finds and marks variable definitions (for aligning) + - finds and marks assignments that may be aligned + - changes CT_INCDEC_AFTER to CT_INCDEC_BEFORE + - changes CT_STAR to either CT_PTR_TYPE, CT_DEREF or CT_ARITH + - changes CT_MINUS to either CT_NEG or CT_ARITH + - changes CT_PLUS and CT_ADDR to CT_ARITH, if needed + - other stuff? + + +Casts +----- +Casts are detected as follows: + - paren pair not part of if/for/etc nor part of a function + - contains only CT_QUALIFIER, CT_TYPE, '*', and no more than one CT_WORD + - is not followed by CT_ARITH + +Tough cases: +(foo) * bar; + +If uncertain about a cast like this: (foo_t), some simple rules are applied. +If the word ends in '_t', it is a cast, unless followed by '+'. +If the word is all caps (FOO), it is a cast. +If you use custom types (very likely) that aren't detected properly (unlikely), +the add them to the config file like so: (example Using C-Sharp types) +type UInt32 UInt16 UInt8 Byte +type Int32 Int16 Int8 + + +Step 6+ Everything else +------------------------- + +From this point on, many filters are run on the chunk list to change the +token columns. + +indent.cpp sets the left-most column. +align.cpp set the column for individual chunks. +space.cpp sets the spacing between chunks. +Others insert newlines, change token position, etc. + + +Last Step - Output +------------------------- + +At the final step the list is printed to the output. +Everything except comments are printed as-is. +Comments are reformatted in the output stage. + diff --git a/etc/amxmodx.cfg b/etc/amxmodx.cfg new file mode 100644 index 0000000000..91dc04490f --- /dev/null +++ b/etc/amxmodx.cfg @@ -0,0 +1,209 @@ +# +# AMX Mod X style for Pawn (or as close as possible) +# +# $Id: amxmodx.cfg 313 2006-07-29 02:13:00 EST marticus $ +# + +####################### +# Basic Indenting Stuff + +# (a/i/r) comment notation for add/ignore/remove which is the actual setting +input_tab_size = 1 # tab size on input file: usually 8 +output_tab_size = 8 # tab size for output: usually 8 +indent_columns = 8 # ie 3 or 8 +indent_with_tabs = 2 # 1=only to the 'level' indent, 2=use tab indenting +#indent_paren_nl = 1 # indent-align under paren for open followed by nl + +pp_indent = remove # indent preproc 1 space per level (a/i/r) +pp_space = remove # spaces between # and word (add/ignore/remove) + +#indent_switch_case = 1 # spaces to indent case from switch +#indent_case_brace = 0 # spaces to indent '{' from case + # (usually 0 or indent_columns) + +#indent_brace = 0 # spaces to indent '{' from level (usually 0) +indent_braces = 0 # whether to indent the braces or not +#indent_label = 0 # 0=left >0=col from left (absolute column), + # <0=sub from brace indent (relative column) + +indent_align_string = false # True/False - indent align broken strings +indent_col1_comment = false # indent comments in column 1 +indent_func_call_param = false # indent continued function calls to indent_columns otherwise index_columns + spaces to align with open paren. + +indent_namespace = true # indent stuff inside namespace braces +indent_class = true # indent stuff inside class braces + + +############################ +# Misc Inter-element Spacing +# Force,Ignore,Add,Remove + +# ignored by nl_*_brace = true +sp_paren_brace = force # space between ')' and '{' +sp_fparen_brace = force # space between ')' and '{' of function +sp_sparen_brace = force # space between ')' and '{' of if, while, etc + +sp_after_cast = force # space after cast - "(int) a" vs "(int)a" + +sp_before_byref = force # space before '&' of 'fcn(int& idx)' + +sp_inside_fparen = force # space inside 'foo( xxx )' vs 'foo(xxx)' +sp_inside_fparens = remove # space inside 'foo( )' vs 'foo()' +sp_inside_paren = remove # space inside '+ ( xxx )' vs '+ (xxx)' +sp_inside_square = remove # space inside 'byte[ 5 ]' vs 'byte[5]' +sp_inside_sparen = force # space inside 'if( xxx )' vs 'if(xxx)' +sp_inside_angle = ignore # space inside '<>', as in '' + +sp_before_sparen = force # space before '(' of 'if/for/while/switch' +sp_after_sparen = force # space after ')' of 'if/for/while/switch' + # the do-while does not get set here + +sp_before_angle = ignore # space before '<>', as in '' +sp_after_angle = ignore # space after '<>', as in '' + +sp_before_square = ignore # space before single '[' +sp_before_squares = remove # space before '[]', as in 'byte []' + +sp_paren_paren = force # space between nested parens - '( (' vs '((' + +sp_return_paren = remove # space between 'return' and '(' +sp_sizeof_paren = remove # space between 'sizeof' and '(' + +sp_after_comma = force # space after ',' + +sp_arith = force # space around + - / * etc +sp_bool = force # space around || && +sp_compare = force # space around < > ==, etc +sp_assign = force # space around =, +=, etc + +sp_func_def_paren = remove # space between 'func' and '(' - "foo (" vs "foo(" +sp_func_call_paren = remove # space between 'func' and '(' - "foo (" vs "foo(" +sp_func_proto_paren = remove # space between 'func' and '(' - "foo (" vs "foo(" +sp_func_class_paren = remove # space between ctor/dtor and '(' + +#sp_type_func = 1 # space between return type and 'func' + # a minimum of 1 is forced except for '*' + + +sp_special_semi = remove # space empty stmt ';' on while, if, for + # example "while (*p++ = ' ') ;" +sp_before_semi = remove # space before all ';' +sp_inside_braces = force # space inside '{' and '}' - "{ 1, 2, 3 }" +sp_inside_braces_enum = force # space inside enum '{' and '}' - "{ a, b, c }" +sp_inside_braces_struct = force # space inside struct/union '{' and '}' + +sp_macro = force # space between macro and value, ie '#define a 6' +sp_macro_func = force # space between macro and value, ie '#define a 6' + +sp_square_fparen = remove # weird pawn stuff: native yark[rect](a[rect]) +sp_after_tag = remove # pawn: space after a tag colon + + +################################ +# Code Alignment +# (not left column spaces/tabs) + +align_with_tabs = true # use tabs for aligning (0/1) +align_keep_tabs = false # keep non-indenting tabs +align_on_tabstop = true # always align on tabstops +align_nl_cont = false # align the back-slash \n combo (macros) +align_enum_equ_span = 1 # align the '=' in enums +align_assign_span = 1 # align on '='. 0=don't align +align_assign_thresh = 0 # threshold for aligning on '='. 0=no limit +align_right_cmt_span = 8 # align comment that end lines. 0=don't align +align_var_def_span = 1 # align variable defs on variable (span for regular stuff) +align_var_def_thresh = 0 # align variable defs threshold +align_var_def_inline = true # also align inline struct/enum/union var defs +align_var_def_star_style = 1 # the star is part of the variable name +align_var_def_colon = false # align the colon in struct bit fields +align_var_struct_span = 1 # span for struct/union (0=don't align) +align_pp_define_span = 1 # align bodies in #define statments +align_pp_define_gap = 1 # min space between define label and value "#define a <---> 16" + +align_struct_init_span = 1 # align structure initializer values +align_func_proto_span = 1 # align function prototypes +align_number_left = false # left-align numbers (not fully supported, yet) +align_typedef_span = 1 # align single-line typedefs +align_typedef_gap = 1 # minimum spacing +align_typedef_star_style = 1 # Start aligning style + # 0: '*' not part of type + # 1: '*' part of the type - no space + # 2: '*' part of type, dangling + + +##################################### +# Newline Adding and Removing Options +# Add/Remove/Ignore + +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_func_decl_start = ignore # newline after the '(' in a function decl +nl_func_decl_args = ignore # newline after each ',' in a function decl +nl_func_decl_end = ignore # newline before the ')' in a function decl +nl_func_type_name = ignore # newline between return type and func name in def +nl_func_var_def_blk = 0 # newline after a block of variable defs +nl_before_case = false # newline before 'case' statement +nl_after_return = false # newline after return statement +nl_after_case = false # disallow nested "case 1: a=3;" +nl_fcall_brace = add # newline between function call and open brace +nl_squeeze_ifdef = false # no blanks after #ifxx, #elxx, or before #endif TRUE/F +nl_enum_brace = ignore # nl between enum and brace +nl_struct_brace = ignore # nl between struct and brace +nl_union_brace = ignore # nl between union and brace +nl_assign_brace = ignore # nl between '=' and brace +nl_class_brace = ignore # nl between class name and brace +nl_namespace_brace = ignore # nl between namespace name and brace + +nl_do_brace = add # nl between do and { +nl_if_brace = add # nl between if and { +nl_for_brace = add # nl between for and { +nl_else_brace = remove # nl between else and { +nl_while_brace = add # nl between while and { +nl_switch_brace = add # nl between switch and { +nl_brace_else = remove # nl between } and else +nl_brace_while = add # nl between } and while of do stmt + +nl_elseif_brace = add # nl between close paren and open brace in 'else if () {' + +nl_define_macro = 0 # alter newlines in #define macros +nl_start_of_file = ignore # alter newlines at the start of file +nl_start_of_file_min = 0 # min number of newlines at the start of the file +nl_end_of_file = ignore # alter newlines at the end of file +nl_end_of_file_min = 0 # min number of newlines at the end of the file + +pos_bool = start # end=move &&/|| to EOL ignore=gnore, start=move to SOL + +##################### +# Blank Line Options + +nl_before_block_comment = 3 # before a block comment (stand-alone + # comment-multi), except after brace open +nl_after_func_body = 3 # after the closing brace of a function body +nl_after_func_proto = 3 # after each prototype +nl_after_func_proto_group = 3 # after a block of prototypes +nl_max = 3 # maximum consecutive newlines (3=2 lines) + +eat_blanks_after_open_brace = true # remove blank lines after { +eat_blanks_before_close_brace = true # remove blank lines before } + +######################## +# Code Modifying Options +# (non-whitespace) + +mod_paren_on_return = force # add or remove paren on return +mod_full_brace_nl = 1 # max number of newlines to span w/o braces +mod_full_brace_if = ignore # add or remove braces on if +mod_full_brace_for = ignore # add or remove braces on for +mod_full_brace_do = ignore # add or remove braces on do +mod_full_brace_while = ignore # add or remove braces on while +mod_pawn_semicolon = True # add optional semicolons +mod_full_brace_function = add # add optional braces on Pawn functions + + +####################### +# Comment Modifications + +cmt_star_cont = true # put a star on subsequent comment lines +cmt_cpp_to_c = true # convert CPP comments to C comments +cmt_cpp_group = true # if UO_cmt_cpp_to_c, try to group in one big C comment +cmt_cpp_nl_start = true # put a blank /* at the start of a converted group +cmt_cpp_nl_end = true # put a nl before the */ in a converted group diff --git a/etc/ben.cfg b/etc/ben.cfg new file mode 100644 index 0000000000..94d3f04fe9 --- /dev/null +++ b/etc/ben.cfg @@ -0,0 +1,1222 @@ +# Uncrustify 0.53 + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute +indent_var_def_blk = 0 # number + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 3 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 3 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = true # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around preprocessor '##' concatenation operator +sp_pp_concat = add # ignore/add/remove/force + +# Add or remove space after preprocessor '#' stringify operator +sp_pp_stringify = add # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':' +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, ie 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '-(int) f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = remove # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A' +sp_cmt_cpp_start = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 1 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 16 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align any attribute after the variable name +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 0 # number + +# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) +align_right_cmt_at_col = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Align function protos on the 'operator' keyword instead of what follows +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = true # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = force # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = force # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = force # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = force # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = true # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name in a definition +# Controls the newline after '::' in 'void A::f() { }' +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 3 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 1 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = true # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after +# the #else, a comment will be added. +mod_add_long_ifdef_endif_comment = 0 # number + +# If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after +# the #endif, a comment will be added. +mod_add_long_ifdef_else_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# Will add or remove the braces around a fully braced case statement. +# Will only remove the braces if there are no variable declarations in the block. +mod_case_brace = remove # ignore/add/remove/force + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = true # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = remove # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ +# +# The full syntax description of all custom definition config entries +# is shown below: +# +# define custom tokens as: +# - embed whitespace in token using '' escape character, or +# put token in quotes +# - these: ' " and ` are recognized as quote delimiters +# +# type token1 token2 token3 ... +# ^ optionally specify multiple tokens on a single line +# define def_token output_token +# ^ output_token is optional, then NULL is assumed +# macro-open token +# macro-close token +# macro-else token +# set id token1 token2 ... +# ^ optionally specify multiple tokens on a single line +# ^ id is one of the names in token_enum.h sans the CT_ prefix, +# e.g. PP_PRAGMA +# +# all tokens are separated by any mix of ',' commas, '=' equal signs +# and whitespace (space, tab) +# diff --git a/etc/ben2.cfg b/etc/ben2.cfg new file mode 100644 index 0000000000..e9924f6653 --- /dev/null +++ b/etc/ben2.cfg @@ -0,0 +1,85 @@ +# +# My favorite format +# +# $Id: ben2.cfg 686 2007-02-24 20:06:09Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent with tabs, 2=indent to level only +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 + +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/etc/d.cfg b/etc/d.cfg new file mode 100644 index 0000000000..aa5f6c6d26 --- /dev/null +++ b/etc/d.cfg @@ -0,0 +1,85 @@ +# +# My favorite format +# +# $Id: d.cfg 686 2007-02-24 20:06:09Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 + +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +# nl_func_var_def_blk = 1 +# nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = add # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/etc/defaults.cfg b/etc/defaults.cfg new file mode 100644 index 0000000000..4f37b8d1b0 --- /dev/null +++ b/etc/defaults.cfg @@ -0,0 +1,1276 @@ +# Uncrustify 0.54 + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 8 # number + +# The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 8 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 1 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# The number of spaces to indent a namespace block +indent_namespace_level = 0 # number + +# If the body of the namespace is longer than this number, it won't be indented. +# Requires indent_namespace=true. Default=0 (no limit) +indent_namespace_limit = 0 # number + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = false # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute +indent_var_def_blk = 0 # number + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = true # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = ignore # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around preprocessor '##' concatenation operator. Default=Add +sp_pp_concat = add # ignore/add/remove/force + +# Add or remove space after preprocessor '#' stringify operator. Default=Add +sp_pp_stringify = add # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = ignore # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = ignore # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word. Default=Force +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = ignore # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = ignore # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = ignore # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = ignore # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';'. Default=Remove +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statement. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space after ';', except when followed by a comment. Default=Add +sp_after_semi = add # ignore/add/remove/force + +# Add or remove space after ';' in non-empty 'for' statements. Default=Force +sp_after_semi_for = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = ignore # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = ignore # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space before the variadic '...' +sp_before_ellipsis = ignore # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':'. Default=Remove +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = ignore # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = ignore # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = ignore # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = ignore # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = ignore # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = ignore # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = ignore # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = ignore # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = ignore # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. Default=Remove +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. Default=Remove +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. Default=Remove +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators. Default=Remove +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. Default=Remove +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line. Default=Add +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int)f: (int) x;' vs '-(int)f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space after the first (type) in message specs +# '-(int) f:(int)x;' vs '-(int)f:(int)x;' +sp_after_oc_return_type = ignore # ignore/add/remove/force + +# Add or remove space between '@selector' and '(' +# '@selector(msgName).' vs '@selector (msgName)' +sp_after_oc_at_sel = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = ignore # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A' +sp_cmt_cpp_start = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for aligning +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = false # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 0 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align any attribute after the variable name +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typedef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typedef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 0 # number + +# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) +align_right_cmt_at_col = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Align function protos on the 'operator' keyword instead of what follows +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# Align parameters in an Obj-C message on the ':' +align_oc_msg_colon = false # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 0 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 0 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = ignore # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = ignore # ignore/add/remove/force + +# Add or remove newline between two open or close braces. +# Due to general newline/brace handling, REMOVE may not work. +nl_brace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = ignore # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = ignore # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a function definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name inside a class {} +# Uses nl_func_type_name or nl_func_proto_type_name if set to ignore. +nl_func_type_name_class = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name in a definition +# Controls the newline after '::' in 'void A::f() { }' +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between '()' in a function declaration. +nl_func_decl_empty = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = ignore # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = false # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = false # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = false # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of comparison operators in wrapped expressions +pos_compare = ignore # ignore/lead/trail + +# The position of conditional (b ? t : f) operators in wrapped expressions +pos_conditional = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 0 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 0 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 0 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 0 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = ignore # ignore/add/remove/force + +# Add or remove braces on single-line function definitions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = ignore # ignore/add/remove/force + +# Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if. +# If any must be braced, they are all braced. If all can be unbraced, then the braces are removed. +mod_full_brace_if_chain = false # false/true + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = ignore # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = ignore # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = false # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after +# the #else, a comment will be added. +mod_add_long_ifdef_endif_comment = 0 # number + +# If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after +# the #endif, a comment will be added. +mod_add_long_ifdef_else_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# Will add or remove the braces around a fully braced case statement. +# Will only remove the braces if there are no variable declarations in the block. +mod_case_brace = ignore # ignore/add/remove/force + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# Set the comment reflow mode (default: 0) +# 0: no reflowing (apart from the line wrapping due to cmt_width) +# 1: no touching at all +# 2: full reflow +cmt_reflow_mode = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment. +# Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment. +# Will substitute $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = ignore # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ +# +# The full syntax description of all custom definition config entries +# is shown below: +# +# define custom tokens as: +# - embed whitespace in token using '' escape character, or +# put token in quotes +# - these: ' " and ` are recognized as quote delimiters +# +# type token1 token2 token3 ... +# ^ optionally specify multiple tokens on a single line +# define def_token output_token +# ^ output_token is optional, then NULL is assumed +# macro-open token +# macro-close token +# macro-else token +# set id token1 token2 ... +# ^ optionally specify multiple tokens on a single line +# ^ id is one of the names in token_enum.h sans the CT_ prefix, +# e.g. PP_PRAGMA +# +# all tokens are separated by any mix of ',' commas, '=' equal signs +# and whitespace (space, tab) +# diff --git a/etc/dofiles.sh b/etc/dofiles.sh new file mode 100644 index 0000000000..e08fd6f749 --- /dev/null +++ b/etc/dofiles.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +if [ -z "$1" ]; then + echo "specify the file that contains a list of files" + exit +fi + +files=$(cat $1) + +mkdir -p out + +for item in $files ; do + + dn=$(dirname $item) + mkdir -p out/$dn + src/uncrustify -f $item -c etc/ben.cfg > out/$item + +done + diff --git a/etc/gnu-indent.cfg b/etc/gnu-indent.cfg new file mode 100644 index 0000000000..eeedc8e67e --- /dev/null +++ b/etc/gnu-indent.cfg @@ -0,0 +1,84 @@ +# +# GNU format (sorta) +# +# $Id: gnu-indent.cfg 488 2006-09-09 12:44:38Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = 2 +# indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 2 + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = ignore # "return 1;" vs "return (1);" +# mod_full_brace_if = ignore # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = ignore # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = ignore # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = ignore # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +# align_with_tabs = FALSE # use tabs to align +# align_on_tabstop = FALSE # align on tabstops +# align_enum_equ_span = 4 +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = TRUE +# align_var_def_colon = TRUE +# align_assign_span = 1 +# align_struct_init_span = 3 +# align_var_struct_span = 3 +# align_right_cmt_span = 3 +# align_pp_define_span = 3 +# align_pp_define_gap = 4 +# align_number_left = TRUE +# align_typedef_span = 5 +# align_typedef_gap = 3 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/etc/klaus.cfg b/etc/klaus.cfg new file mode 100644 index 0000000000..235771d578 --- /dev/null +++ b/etc/klaus.cfg @@ -0,0 +1,501 @@ + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = true # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 3 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 0 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = remove # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = remove # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = remove # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = remove # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 1 + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 12 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = force # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = remove # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force diff --git a/etc/kr-indent.cfg b/etc/kr-indent.cfg new file mode 100644 index 0000000000..7bf0b669e1 --- /dev/null +++ b/etc/kr-indent.cfg @@ -0,0 +1,84 @@ +# +# K&R (sort-of) +# +# $Id: kr-indent.cfg 488 2006-09-09 12:44:38Z bengardner $ +# + +indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +# indent_align_string = False # align broken strings +# indent_brace = 0 + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +# nl_func_var_def_blk = 1 +# nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = remove +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove # "( 1 )" vs "(1)" +sp_inside_fparen = remove # "( 1 )" vs "(1)" - functions +sp_inside_sparen = remove # "( 1 )" vs "(1)" - if/for/etc +# sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +# align_with_tabs = FALSE # use tabs to align +# align_on_tabstop = FALSE # align on tabstops +# align_enum_equ_span = 4 +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = TRUE +# align_var_def_colon = TRUE +# align_assign_span = 1 +# align_struct_init_span = 3 +# align_var_struct_span = 3 +# align_right_cmt_span = 3 +# align_pp_define_span = 3 +# align_pp_define_gap = 4 +# align_number_left = TRUE +# align_typedef_span = 5 +# align_typedef_gap = 3 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/etc/linux-indent.cfg b/etc/linux-indent.cfg new file mode 100644 index 0000000000..7eb7518c65 --- /dev/null +++ b/etc/linux-indent.cfg @@ -0,0 +1,92 @@ +# +# uncrustify config file for the linux kernel +# +# $Id: linux-indent.cfg 488 2006-09-09 12:44:38Z bengardner $ +# + +indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs +align_with_tabs = TRUE # use tabs to align +align_on_tabstop = TRUE # align on tabstops +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +indent_label = 2 # pos: absolute col, neg: relative column + + +# +# inter-symbol newlines +# + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_brace_while = remove # "} while" vs "} \n while" - cuddle while +nl_brace_else = remove # "} else" vs "} \n else" - cuddle else +nl_func_var_def_blk = 1 +nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE; +# nl_before_case = 1 + + +# +# Source code modifications +# + +# mod_paren_on_return = remove # "return 1;" vs "return (1);" +# mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = remove # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" + + +# +# inter-character spacing options +# + +# sp_return_paren = force # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = add # "{ 1 }" vs "{1}" +sp_inside_braces_struct = add # "{ 1 }" vs "{1}" +sp_inside_braces_enum = add # "{ 1 }" vs "{1}" +sp_assign = add +sp_arith = add +sp_bool = add +sp_compare = add +sp_assign = add +sp_after_comma = add +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + + +# +# Aligning stuff +# + +align_enum_equ_span = 4 # '=' in enum definition +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = FALSE +# align_var_def_colon = TRUE +# align_assign_span = 1 +align_struct_init_span = 3 # align stuff in a structure init '= { }' +align_right_cmt_span = 3 +# align_pp_define_span = 8; +# align_pp_define_gap = 4; + +# cmt_star_cont = FALSE + +# indent_brace = 0 + diff --git a/etc/linux.cfg b/etc/linux.cfg new file mode 100644 index 0000000000..ae92337faa --- /dev/null +++ b/etc/linux.cfg @@ -0,0 +1,122 @@ +# +# uncrustify config file for the linux kernel +# +# $Id: linux.cfg 1604 2009-08-09 14:34:54Z bengardner $ +# + +indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +indent_label = 1 # pos: absolute col, neg: relative column + + +# +# inter-symbol newlines +# + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_brace_while = remove # "} while" vs "} \n while" - cuddle while +nl_brace_else = remove # "} else" vs "} \n else" - cuddle else +sp_brace_else = force +sp_else_brace = force +nl_func_var_def_blk = 1 +nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE; +# nl_before_case = 1 + + +# +# Source code modifications +# + +mod_paren_on_return = remove # "return 1;" vs "return (1);" +#mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_if_chain = true +mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = remove # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" +mod_full_brace_nl = 3 # don't remove if more than 3 newlines + + +# +# inter-character spacing options +# + +sp_return_paren = force # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + + +# +# Aligning stuff +# + +align_with_tabs = TRUE # use tabs to align +align_on_tabstop = TRUE # align on tabstops +# align_keep_tabs = true +align_enum_equ_span = 4 # '=' in enum definition +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = FALSE +# align_var_def_colon = TRUE +# align_assign_span = 1 +align_struct_init_span = 3 # align stuff in a structure init '= { }' +align_right_cmt_span = 3 +# align_pp_define_span = 8; +# align_pp_define_gap = 4; + +cmt_star_cont = true + +# indent_brace = 0 + +nl_func_paren = remove +nl_func_decl_start = remove +nl_func_decl_empty = remove +nl_func_decl_args = remove +nl_func_decl_end = remove +sp_inside_paren = remove +sp_inside_square = remove +sp_inside_paren_cast = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_paren_paren = remove +sp_before_ptr_star = force +sp_after_ptr_star = remove +sp_between_ptr_star = remove +align_func_params = true +align_var_struct_span = 6 + +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +pp_indent = remove + +nl_start_of_file = remove +nl_end_of_file = force +nl_end_of_file_min = 1 +nl_comment_func_def = 1 diff --git a/etc/mono.cfg b/etc/mono.cfg new file mode 100644 index 0000000000..9f6f726b25 --- /dev/null +++ b/etc/mono.cfg @@ -0,0 +1,88 @@ +# +# Mono library format +# +# $Id: mono.cfg 488 2006-09-09 12:44:38Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +# indent_align_string = False # align broken strings +# indent_brace = 0 +indent_func_call_param = true # use indent tabstop + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = remove # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +sp_before_square = add +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = force # "int foo (){" vs "int foo(){" +sp_func_call_paren = force # "foo (" vs "foo(" +sp_func_proto_paren = force # "int foo ();" vs "int foo();" + +# align_with_tabs = FALSE # use tabs to align +# align_on_tabstop = FALSE # align on tabstops +# align_enum_equ_span = 4 +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = TRUE +# align_var_def_colon = TRUE +# align_assign_span = 1 +# align_struct_init_span = 3 +# align_var_struct_span = 3 +# align_right_cmt_span = 3 +# align_pp_define_span = 3 +# align_pp_define_gap = 4 +# align_number_left = TRUE +# align_typedef_span = 5 +# align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/etc/objc.cfg b/etc/objc.cfg new file mode 100644 index 0000000000..c5015895f9 --- /dev/null +++ b/etc/objc.cfg @@ -0,0 +1,135 @@ +# +# uncrustify config file for objective-c and objective-c++ +# +# $Id: objc.cfg 488 2009-10-08 12:44:38Z andreberg $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_assign = FALSE + +# +# Indenting +# + +# indent_brace = 0 + +# +# Inter-symbol newlines +# + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_brace_while = remove # "} while" vs "} \n while" - cuddle while +nl_brace_else = remove # "} else" vs "} \n else" - cuddle else +nl_func_var_def_blk = 1 +nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{" +nl_fdef_brace = remove # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE; +# nl_before_case = 1 + + +# +# Source code modifications +# + +mod_paren_on_return = ignore # "return 1;" vs "return (1);" +mod_full_brace_if = ignore # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = ignore # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" +mod_full_brace_nl = 3 # don't remove if more than 3 newlines +mod_add_long_ifdef_endif_comment = 20 +mod_add_long_ifdef_else_comment = mod_add_long_ifdef_else_comment +mod_add_long_switch_closebrace_comment = mod_add_long_ifdef_else_comment +mod_add_long_function_closebrace_comment = mod_add_long_ifdef_else_comment + +# +# Inter-character spacing options +# + +# sp_return_paren = force # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = add # "{ 1 }" vs "{1}" +sp_inside_braces_struct = add # "{ 1 }" vs "{1}" +sp_inside_braces_enum = add # "{ 1 }" vs "{1}" +sp_inside_fparen = remove # "func( param )" vs "func(param)" +sp_paren_brace = force +sp_assign = add +sp_arith = add +sp_bool = add +sp_compare = add +sp_assign = add +sp_after_comma = add +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_before_ptr_star = force +sp_after_ptr_star = force +sp_before_unnamed_ptr_star = ignore +sp_between_ptr_star = remove +sp_after_ptr_star_func = force +sp_before_ptr_star_func = force +sp_cmt_cpp_start = force +sp_cond_question = force +sp_cond_colon = force +sp_else_brace = force +sp_brace_else = force +sp_after_class_colon = force +sp_before_class_colon = force +sp_before_case_colon = remove +# Objective-C specifics +sp_before_oc_colon = remove +sp_after_oc_colon = remove +sp_after_oc_scope = force +sp_after_oc_type = remove +sp_after_oc_return_type = force +sp_before_send_oc_colon = remove +sp_after_send_oc_colon = remove +sp_after_oc_at_sel = remove + +# +# Aligning stuff +# + +align_with_tabs = False # use tabs to align +align_on_tabstop = False # align on tabstops +# align_keep_tabs = True +align_enum_equ_span = 4 # '=' in enum definition +# align_nl_cont = True +# align_var_def_span = 2 +# align_var_def_inline = True +# align_var_def_star = False +# align_var_def_colon = True +# align_assign_span = 1 +align_struct_init_span = 4 # align stuff in a structure init '= { }' +align_right_cmt_span = 4 +align_pp_define_span = 8 +#align_pp_define_gap = 8 + +# +# Line Splitting options +# + +# ls_func_split_full = True # Whether to fully split long function protos/calls at commas + +# +# Comment modifications +# + +cmt_star_cont = True # Whether to put a star on subsequent comment lines + + + diff --git a/etc/types.txt b/etc/types.txt new file mode 100644 index 0000000000..0df27c78bd --- /dev/null +++ b/etc/types.txt @@ -0,0 +1,26 @@ +# +# a simple list of stuff that should be detected as a CT_TYPE +# this usually isn't necessary because types are detected from the context. +# +# In the future, I may allow arbitrary CT_xxx stuff to be specified, as +# well as a language +# + +INT8 +UINT8 +INT16 +UINT16 +INT32 +UINT32 +INT64 +UINT64 +FLOAT +CHAR +DOUBLE +TRUE +FALSE +BOOL +FILE +DIR +bat + diff --git a/etc/uncrust-files.sh b/etc/uncrust-files.sh new file mode 100644 index 0000000000..3e1d09b393 --- /dev/null +++ b/etc/uncrust-files.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +if [ -z "$1" ]; then + echo "specify the file that contains a list of files" + exit +fi + +files=$(cat $1) + +mkdir -p out + +for item in $files ; do + + dn=$(dirname $item) + mkdir -p out/$dn + ~/bin/uncrustify -f $item -c ~/.uncrustify/xsupplicant.cfg > out/$item + +done + diff --git a/etc/xsupplicant.cfg b/etc/xsupplicant.cfg new file mode 100644 index 0000000000..25974bfa6e --- /dev/null +++ b/etc/xsupplicant.cfg @@ -0,0 +1,84 @@ +# +# GNU-like format +# +# $Id: xsupplicant.cfg 488 2006-09-09 12:44:38Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 2 # new tab size +indent_columns = 2 # should usually match output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 2 + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = ignore # "return 1;" vs "return (1);" +# mod_full_brace_if = ignore # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = ignore # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = ignore # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = ignore # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +# align_with_tabs = FALSE # use tabs to align +# align_on_tabstop = FALSE # align on tabstops +# align_enum_equ_span = 4 +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = TRUE +# align_var_def_colon = TRUE +# align_assign_span = 1 +# align_struct_init_span = 3 +# align_var_struct_span = 3 +# align_right_cmt_span = 3 +# align_pp_define_span = 3 +# align_pp_define_gap = 4 +# align_number_left = TRUE +# align_typedef_span = 5 +# align_typedef_gap = 3 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/extras.vpj b/extras.vpj new file mode 100644 index 0000000000..3427ab3c77 --- /dev/null +++ b/extras.vpj @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/install-sh b/install-sh new file mode 100755 index 0000000000..a5897de6ea --- /dev/null +++ b/install-sh @@ -0,0 +1,519 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2006-12-25.00 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/make_token_names.sh b/make_token_names.sh new file mode 100755 index 0000000000..93f689d081 --- /dev/null +++ b/make_token_names.sh @@ -0,0 +1,35 @@ +#! /bin/sh +# +# Scans src/token_enum.h and creates token_names.h +# + +infile="token_enum.h" +outfile="token_names.h" + +if [ -d src ] ; then + infile="src/"${infile} + outfile="src/"${outfile} +fi + +cat > $outfile <>$outfile + +cat >> $outfile </dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(MANS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: install-man1 + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-man + +uninstall-man: uninstall-man1 + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic ctags \ + ctags-recursive distclean distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-man1 install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-man uninstall-man1 + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/man/uncrustify.1 b/man/uncrustify.1 new file mode 100644 index 0000000000..4f79ae9f9e --- /dev/null +++ b/man/uncrustify.1 @@ -0,0 +1,154 @@ +.TH UNCRUSTIFY "1" "Oct 2009" "uncrustify 0.54" "User Commands" +.SH NAME +uncrustify \- C, C++, C#, D, Java and Pawn source code beautifier + +.SH SYNOPSIS +.B uncrustify \fR[\fIOPTIONS\fR] [\fIFILES\fR] + +.SH DESCRIPTION + +If no input files are specified, the input is read from stdin. +.br +If reading from stdin, you should specify the language using \-l. + +If \-F is used or files are specified on the command line, the output filename is +\fIPFX\fR + "/" + filename + \fISFX\fR. +.br +Unless, of course, the options \fB\-\-replace\fR or \fB\-\-no\-backup\fR are used. + +When reading from stdin or doing a single file via the '\-f' option, +the output is dumped to stdout, unless redirected with \-o FILE. + +Errors are always dumped to stderr + +.SH OPTIONS +.SS "Basic Options:" +.TP +\fB\-c\fI CFG +Use the config file \fICFG\fR. +.br +If not specified, uncrustify will use \fB$UNCRUSTIFY_CONFIG\fR or \fB$HOME\\.uncrustify.cfg\fR. +.TP +\fB\-f\fI FILE +Process the single file \fIFILE\fR, sending output to stdout or the file specified with \fB\-o\fR. +.TP +\fB\-o\fI FILE +Redirect output to \fIFILE\fR. +.br +Use with \fB\-f\fR, \fB\-\-update\-config\fR, \fB\-\-update\-config\-with\-doc\fR, +\fB\-\-universalindent\fR. +.TP +\fB\-F\fI FILE +Read files to process from \fIFILE\fR, one filename per line. +.br +You can create this file using something like \'\fBfind . \-name "*.c" > list.txt\fR\'. +.br +This cannot be combined with \fB\-f\fR. +.TP +\fB\-\-prefix\fI PFX +Prepend \fIPFX\fR to the output filename path. +.br +This cannot be combined with \fB\-f\fR, \fB\-\-replace\fR, or \fB\-\-no\-backup\fR. +.TP +\fB\-\-suffix\fI SFX +Append \fISFX\fR to the output filename. +.br +The default is '.uncrustify' if neither \fISFX\fR or \fIPFX\fR are specified. +.br +This cannot be combined with \fB\-f\fR, \fB\-\-replace\fR, or \fB\-\-no\-backup\fR. +.TP +\fB\-\-replace\fR +Replace source files (creates a backup). +.br +This cannot be combined with \fB\-f\fR, \fB\-\-prefix\fR, or \fB\-\-suffix\fR. +.TP +\fB\-\-no\-backup\fR +Replace files, no backup. Useful if files are under source control +.br +This cannot be combined with \fB\-f\fR, \fB\-\-prefix\fR, or \fB\-\-suffix\fR. +.TP +\fB\-\-mtime\fR +Preserve mtime on replaced files. +.TP +\fB\-l\fR +Language override: C, CPP, D, CS, JAVA, PAWN, VALA, OC, OC+ +.TP +\fB\-t\fR +Load a file with types (usually not needed) +.TP +\fB\-q\fR +Quiet mode \- no output on stderr (\fB\-L\fR will override) +.SS "Config/Help Options:" +.TP +\fB\-h\fR \-? \fB\-\-help\fR \fB\-\-usage\fR +Print this message and exit +.TP +\fB\-\-version\fR +Print the version and exit +.TP +\fB\-\-show\-config\fR +Print out option documentation and exit +.TP +\fB\-\-update\-config\fR +Output a new config file. +.TP +\fB\-\-update\-config\-with\-doc\fR +Output a new config file with embedded usage comments. +.TP +\fB\-\-universalindent\fR +Output a config file for Universal Indent GUI. +.TP +\fB\-\-detect\fR +Detects the config from a source file. Use with '\-f FILE'. +Detection is currently fairly limited. + +.SS "Debug Options:" +.TP +\fB\-p\fI FILE +Dump debug info to a file +.TP +\fB\-L\fI SEV +Set the log severity (see log_levels.h) +.TP +\fB\-s\fR +Show the log severity in the logs +.TP +\fB\-\-decode\fI FLAG +Print \fIFLAG\fR as text and exit + +.SH EXAMPLES +.TP +Read a D file from stdin, output to stdout. +cat foo.d | uncrustify \-q \-c my.cfg \-l d +.TP +Process a file, output to stdout. +uncrustify \-c my.cfg \-d foo.d +.TP +Process a source tree, output to a different tree. +find src \-name "*.[ch]" > files.txt +.br +uncrustify \-c my.cfg \-F files.txt \-\-prefix out +.TP +Process a source tree in\(hyplace. +uncrustify \-c my.cfg \-\-no\-backup $(find src \-name "*.[ch]") + +.SH NOTES +Use comments containing ' *INDENT\-OFF*' and ' *INDENT\-ON*' to disable +processing of parts of the source file. + +.SH AUTHOR +Written by Ben Gardner + +.SH REPORTING BUGS +Use the issue tracker at + +.SH COPYRIGHT +Copyright (C) 2006\(hy2009 Ben Gardner + +.SH LICENSE +GNU GPL version 2 or later + +This is free software; see the source for copying conditions. +There is NO warranty; not even for MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. + diff --git a/missing b/missing new file mode 100755 index 0000000000..1c8ff7049d --- /dev/null +++ b/missing @@ -0,0 +1,367 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2006-05-10.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case $1 in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $1 in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/release-steps.txt b/release-steps.txt new file mode 100644 index 0000000000..ac70e246ae --- /dev/null +++ b/release-steps.txt @@ -0,0 +1,74 @@ + +Release steps. +Just in case I don't do a release for a while and forget what to do... =) + +0. Update the following two lines and paste into a terminal: + +UNC_URL=https://uncrustify.svn.sourceforge.net/svnroot/uncrustify +UNC_REL=0.54 + +1. Make sure all tests pass + + Run all tests (requires python): + + cd tests + ./run_tests.py + +2. Make sure it builds on Windows + +3. Update the version number. +Replace the old version with the new version everywhere except in ChangeLog. +Specific files to update: + configure.in + documentation/htdocs/index.html + man/uncrustify.1 (man file) + src/uncrustify_version.h +Run "sh autogen.sh" and then "./configure". + +3a. Rebuild from scratch (make clean && make) + +4. Update the config files +$ scripts/update-defaults.sh + +4a. Update the man file, if any command-line options have changed. + +5. Update the ChangeLog to indicate the release date + +6. Make sure there are no modified files in the workspace. + Check in all the changes you just made. + +7. Copy the trunk to a tag +$ svn cp $UNC_URL/trunk/uncrustify $UNC_URL/tags/uncrustify-$UNC_REL -m "uncrustify-$UNC_REL" + +8. Export to the release folder +$ cd ../releases +$ svn export $UNC_URL/tags/uncrustify-$UNC_REL + +9. Tar up the files +$ tar czf uncrustify-$UNC_REL.tgz uncrustify-$UNC_REL + +REVISIT: consider splitting the tests out from the source + +10. Update and build on windows +Copy the exe, ChangeLog, index.html, and all the .cfg files in etc into a +folder named "uncrustify-$UNC_REL-win32". +Zip up that folder using the folder name + ".zip" +Copy to the release folder on Linux + +11. Copy the files to sourceforge +$ sftp USER,uncrustify@frs.sourceforge.net +sftp> cd /home/pfs/project/u/un/uncrustify/uncrustify/uncrustify-0.XX +sftp> put uncrustify-0.XX.tgz +sftp> put uncrustify-0.XX-win32.tgz +sftp> exit + +12. Update the web page files +$ cd uncrustify-$UNC_REL/documentation/htdocs +$ scp -r * USER,uncrustify@web.sourceforge.net:htdocs/ + +13. Use the web interface to create the release and attach the files + +14. (optional) Create a news item + +15. (optional) Update freshmeat.net project + diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000000..584f3b2a0e --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +cd tests + +./run_tests.py $@ + +exit $? + diff --git a/scripts/check_options.py b/scripts/check_options.py new file mode 100644 index 0000000000..eecc1ac9ba --- /dev/null +++ b/scripts/check_options.py @@ -0,0 +1,60 @@ +#! /usr/bin/env python +# +# Check the option usage. +# Make sure the union member matches the option type. +# +import sys, os, fnmatch + +# just use the first letter of the member name - should be unique +opt_suffix = { + 'b' : 'AT_BOOL', + 'a' : 'AT_IARF', + 'n' : 'AT_NUM', + 'l' : 'AT_LINE', + 't' : 'AT_POS' + } +opts = { } + +def check_file (fn): + problems = 0 + fd = open(fn, 'r') + line_no = 0 + for line in fd: + line_no = line_no + 1 + cpd = line.find('cpd.settings[UO_') + if cpd > 0: + sb = line[cpd:].find(']') + opt = line[cpd + 13 : cpd + sb] + mem = line[cpd + sb + 2] + if opt in opts and mem in opt_suffix: + if opts[opt] != opt_suffix[mem]: + print fn + '[%d]' % (line_no) , opt, 'should use', opts[opt], 'not', opt_suffix[mem] + problems += 1 + return problems + +def main (argv): + # Read in all the options + of = open(os.path.join('src', 'options.cpp'), 'r'); + for line in of: + if line.find('unc_add_option') > 0 and line.find('UO_') > 0: + ps = line.split(',') + if len(ps) >= 3: + opts[ps[1].strip()] = ps[2].strip() + of.close() + + # Get a list of all the source files + ld = os.listdir('src') + src_files = fnmatch.filter(ld, '*.cpp') + src_files.extend(fnmatch.filter(ld, '*.h')) + + + # Check each source file + problems = 0 + for fn in src_files: + problems += check_file(os.path.join('src', fn)) + if problems == 0: + print 'No problems found' + +if __name__ == '__main__': + main(sys.argv) + diff --git a/scripts/cmpcfg.pl b/scripts/cmpcfg.pl new file mode 100755 index 0000000000..df119dc186 --- /dev/null +++ b/scripts/cmpcfg.pl @@ -0,0 +1,101 @@ +#!/usr/bin/perl +# +# Copyright (c) 2006 David Thompson +# da.thompson@yahoo.com +# Fri Nov 17 20:41:23 PST 2006 +# License: GPL + +# Purpose of this script is to process config files and +# produce a comparision chart of values. The input files +# are simple series of parameter definitions, of the form +# 'name=value' pairs, whitespace and comments are correctly +# ignored. Invoke on multiple config files to compare +# parameter values for all files, try this, +# cd /usr/local/share/uncrustify +# cmpcfg.pl *.cfg + +# first build hashes from all input files +# 1. %name is a master hash of all parameter names found +# across all files, we use a hash to remember the keys, +# we don't compare about the values stored for each key +# 2. %table is a per file 2 dimensional hash array indexed +# by the current filename and parameter; ie, this hash +# stores the 'name=value' pairs on per file basis +foreach my $file (@ARGV) { + open FH, "<$file" + or die "Can't open file: $file"; + while () { + chomp; + next if (/^[ \t]*$/); # ignore blank lines + next if (/^[ \t]*#/); # ignore comment lines + s/#.*$//; # strip trailing comments + s/^[ \t]*//; # strip leading whitespace + s/[ \t]*$//; # strip trailing whitespace + s/[ \t]*=[ \t]*/=/; # remove whitespace around '=' + $_ = lc; # lowercase everything + ($name, $value) = split /=/; # extract name and value + $names{$name} = $name; # master hash of all names + $table{$file}{$name} = $value; # per file hash of names + } + close FH; +} + +# find longest parameter name +# we'll use this later for report printing +foreach $name (sort keys %names) { + if (length($name) > $maxlen) { + $maxlen = length($name); + } +} +$maxlen += 4; # add extra padding + +# return string centered in specified width +sub center { + ($wid, $str) = @_; + $flg = 0; + while (length($str) < $wid) { + if ($flg) { + $flg = 0; + $str = " " . $str; + } else { + $flg = 1; + $str = $str . " "; + } + } + return $str; +} + +# print legend for filenames +$cnt = 0; +foreach $file (@ARGV) { + $cnt++; + print " <$cnt> $file\n"; +} + +# blank line separates legend & header +print "\n"; + +# print header line +print " " x $maxlen . " "; +$cnt = 0; +foreach (@ARGV) { + $cnt++; + $fmt = "<$cnt>"; + print " ".¢er(6, $fmt); +} +print "\n"; + +# print body of report, one line per parameter name +foreach $name (sort keys %names) { + printf "%-*s ", $maxlen, $name; + foreach $file (@ARGV) { + if (defined($table{$file}{$name})) { + print " ".¢er(6, $table{$file}{$name}); + } else { + # parameter not defined for this file + print " ".¢er(6, "*"); + } + } + print "\n"; +} + diff --git a/scripts/punc.py b/scripts/punc.py new file mode 100755 index 0000000000..3a00fc74ff --- /dev/null +++ b/scripts/punc.py @@ -0,0 +1,110 @@ +#! /usr/bin/env python +# +# Creates a possibly faster lookup table for tokens, etc. +# +# @author Ben Gardner +# @license GPL v2+ +# + +def scan_file (filename): + fh = open(filename, 'r') + lines = fh.readlines() + cur_token = '' + token_idx = 0 + args = [] + for line in lines: + line = line.strip() + if line.startswith('static const chunk_tag_t'): + idx = line.find('[') + if idx > 0: + cur_token = line[25:idx].strip() + token_idx = 0 + else: + if len(cur_token) > 0: + idx1 = line.find('{') + idx2 = line.find('CT_') + if idx1 >= 0 and idx2 > idx1: + tok = line[idx1 + 1:idx2].strip() + tok = tok[1:-2] # strip off open quotes and commas + args.append([tok, "%s[%d]" % (cur_token, token_idx)]) + token_idx += 1 + return args + +def build_table (db, prev, arr): + start_idx = len(arr) + + # do the current level first + k = db.keys(); + if len(k) <= 0: + return + + k.sort() + num_left = len(k) + for i in k: + did_one = 1 + en = db[i] + # [ char, full-string, left-in-group, next_index, table-entry ] + num_left -= 1 + arr.append([en[0], prev + en[0], num_left, 0, en[2]]) + + # update the one-up level index + if len(prev) > 0: + for idx in range(0, len(arr)): + if arr[idx][1] == prev: + arr[idx][3] = start_idx + break + + # Now do each sub level + for i in k: + en = db[i] + build_table(en[3], prev + en[0], arr) + +def add_to_db(entry, db_top): + """ + find or create the entry for the first char + """ + str = entry[0] + db_cur = db_top + for idx in range(0, len(str)): + if not str[idx] in db_cur: + db_cur[str[idx]] = [ str[idx], 0, None, {} ] + dbe = db_cur[str[idx]] + if idx == len(str) - 1: + dbe[2] = entry + else: + db_cur = dbe[3] + +if __name__ == '__main__': + pl = scan_file('src/punctuators.cpp') + pl.sort() + + db = {} + for a in pl: + add_to_db(a, db) + + arr = [] + build_table(db, '', arr) + idx = 0 + print "/**" + print " * @file punctuators.h" + print " * Automatically generated" + print " */" + print "static const lookup_entry_t punc_table[] =" + print "{" + max_len = 0 + for i in arr: + rec = i[4] + if rec != None and len(rec[1]) > max_len: + max_len = len(rec[1]) + + for i in arr: + rec = i[4] + if len(i[0]) == 0: + print " { 0, 0, 0, NULL %s }, // %3d:" % ((max_len - 4) * ' ', idx) + elif rec == None: + print " { '%s', %2d, %2d, NULL %s }, // %3d: '%s'" % (i[0], i[2], i[3], (max_len - 4) * ' ', idx, i[1]) + else: + print " { '%s', %2d, %2d, &%s%s }, // %3d: '%s'" % (i[0], i[2], i[3], rec[1], (max_len - len(rec[1])) * ' ', idx, i[1]) + idx += 1 + print '};' + diff --git a/scripts/tokenize.py b/scripts/tokenize.py new file mode 100755 index 0000000000..822761a199 --- /dev/null +++ b/scripts/tokenize.py @@ -0,0 +1,315 @@ +#! /usr/bin/env python +# tokenize.py +# +# Parses a C/C++/C#/D/Java/Pawn/whatever file in an array of +# tuples (string, type) +# + +# punctuator lookup table +punc_table = [ + [ '!', 25, 26, '!' ], # 0: '!' + [ '#', 24, 35, '#' ], # 1: '#' + [ '$', 23, 0, '$' ], # 2: '$' + [ '%', 22, 36, '%' ], # 3: '%' + [ '&', 21, 41, '&' ], # 4: '&' + [ '(', 20, 0, '(' ], # 5: '(' + [ ')', 19, 0, ')' ], # 6: ')' + [ '*', 18, 43, '*' ], # 7: '*' + [ '+', 17, 44, '+' ], # 8: '+' + [ ',', 16, 0, ',' ], # 9: ',' + [ '-', 15, 46, '-' ], # 10: '-' + [ '.', 14, 50, '.' ], # 11: '.' + [ '/', 13, 53, '/' ], # 12: '/' + [ ':', 12, 54, ':' ], # 13: ':' + [ ';', 11, 0, ';' ], # 14: ';' + [ '<', 10, 56, '<' ], # 15: '<' + [ '=', 9, 63, '=' ], # 16: '=' + [ '>', 8, 65, '>' ], # 17: '>' + [ '?', 7, 0, '?' ], # 18: '?' + [ '[', 6, 70, '[' ], # 19: '[' + [ ']', 5, 0, ']' ], # 20: ']' + [ '^', 4, 71, '^' ], # 21: '^' + [ '{', 3, 0, '{' ], # 22: '{' + [ '|', 2, 72, '|' ], # 23: '|' + [ '}', 1, 0, '}' ], # 24: '}' + [ '~', 0, 74, '~' ], # 25: '~' + [ '<', 3, 30, '!<' ], # 26: '!<' + [ '=', 2, 33, '!=' ], # 27: '!=' + [ '>', 1, 34, '!>' ], # 28: '!>' + [ '~', 0, 0, '!~' ], # 29: '!~' + [ '=', 1, 0, '!<=' ], # 30: '!<=' + [ '>', 0, 32, '!<>' ], # 31: '!<>' + [ '=', 0, 0, '!<>='], # 32: '!<>=' + [ '=', 0, 0, '!==' ], # 33: '!==' + [ '=', 0, 0, '!>=' ], # 34: '!>=' + [ '#', 0, 0, '##' ], # 35: '##' + [ ':', 2, 39, '%:' ], # 36: '%:' + [ '=', 1, 0, '%=' ], # 37: '%=' + [ '>', 0, 0, '%>' ], # 38: '%>' + [ '%', 0, 40, None ], # 39: '%:%' + [ ':', 0, 0, '%:%:'], # 40: '%:%:' + [ '&', 1, 0, '&&' ], # 41: '&&' + [ '=', 0, 0, '&=' ], # 42: '&=' + [ '=', 0, 0, '*=' ], # 43: '*=' + [ '+', 1, 0, '++' ], # 44: '++' + [ '=', 0, 0, '+=' ], # 45: '+=' + [ '-', 2, 0, '--' ], # 46: '--' + [ '=', 1, 0, '-=' ], # 47: '-=' + [ '>', 0, 49, '->' ], # 48: '->' + [ '*', 0, 0, '->*' ], # 49: '->*' + [ '*', 1, 0, '.*' ], # 50: '.*' + [ '.', 0, 52, '..' ], # 51: '..' + [ '.', 0, 0, '...' ], # 52: '...' + [ '=', 0, 0, '/=' ], # 53: '/=' + [ ':', 1, 0, '::' ], # 54: '::' + [ '>', 0, 0, ':>' ], # 55: ':>' + [ '%', 4, 0, '<%' ], # 56: '<%' + [ ':', 3, 0, '<:' ], # 57: '<:' + [ '<', 2, 61, '<<' ], # 58: '<<' + [ '=', 1, 0, '<=' ], # 59: '<=' + [ '>', 0, 62, '<>' ], # 60: '<>' + [ '=', 0, 0, '<<=' ], # 61: '<<=' + [ '=', 0, 0, '<>=' ], # 62: '<>=' + [ '=', 0, 64, '==' ], # 63: '==' + [ '=', 0, 0, '===' ], # 64: '===' + [ '=', 1, 0, '>=' ], # 65: '>=' + [ '>', 0, 67, '>>' ], # 66: '>>' + [ '=', 1, 0, '>>=' ], # 67: '>>=' + [ '>', 0, 69, '>>>' ], # 68: '>>>' + [ '=', 0, 0, '>>>='], # 69: '>>>=' + [ ']', 0, 0, '[]' ], # 70: '[]' + [ '=', 0, 0, '^=' ], # 71: '^=' + [ '=', 1, 0, '|=' ], # 72: '|=' + [ '|', 0, 0, '||' ], # 73: '||' + [ '=', 1, 0, '~=' ], # 74: '~=' + [ '~', 0, 0, '~~' ], # 75: '~~' +] + +# +# Token types: +# 0 = newline +# 1 = punctuator +# 2 = integer +# 3 = float +# 4 = string +# 5 = identifier +# + +class tokenizer: + def __init__(self): + self.tokens = [] + self.text = '' + self.text_idx = 0 + + def tokenize_text (self, in_text): + self.tokens = [] + self.text = in_text + self.text_idx = 0 + + print in_text + try: + while self.text_idx < len(self.text): + if self.parse_whitespace(): + continue + elif self.text[self.text_idx] == '\\' and self.text[self.text_idx + 1] == '\n': + self.text_idx += 2 + continue + elif self.parse_comment(): + continue + elif self.parse_number(): + continue + elif self.parse_identifier(): + continue + elif self.parse_string(): + continue + elif self.parse_punctuator(): + continue + else: + print 'confused:', self.text[self.text_idx:] + break + except: + print 'bombed' + raise + + def parse_whitespace(self): + start_idx = self.text_idx + hit_newline = False + while self.text_idx < len(self.text): + if self.text[self.text_idx] in '\n\r': + hit_newline = True + elif not self.text[self.text_idx] in ' \t': + break + self.text_idx += 1 + + if hit_newline: + self.tokens.append(('\n', 0)) + return start_idx != self.text_idx + + def parse_comment(self): + if not self.text[self.text_idx] == '/' or not self.text[self.text_idx + 1] in '/*': + return False + if self.text[self.text_idx + 1] == '/': + while self.text_idx < len(self.text): + if self.text[self.text_idx] in '\n\r': + break; + self.text_idx += 1 + else: + while self.text_idx < len(self.text) - 1: + if self.text[self.text_idx] == '*' and self.text[self.text_idx + 1] == '/': + self.text_idx += 2 + break; + self.text_idx += 1 + return True + + def parse_identifier(self): + if not self.text[self.text_idx].upper() in '@_ABCDEFGHIJKLMNOPQRSTUVWXYZ': + return False + start_idx = self.text_idx + while self.text_idx < len(self.text) and self.text[self.text_idx].upper() in '@_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890': + self.text_idx += 1 + self.tokens.append((self.text[start_idx : self.text_idx], 5)) + return True + + def parse_string(self): + starter = 0 + start_ch = self.text[self.text_idx] + if start_ch == 'L': + starter = 1 + start_ch = self.text[self.text_idx + 1] + if not start_ch in '"\'': + return False + start_idx = self.text_idx + self.text_idx += starter + 1 + escaped = False + while self.text_idx < len(self.text): + if escaped: + escaped = False + else: + if self.text[self.text_idx] == '\\': + escaped = True + elif self.text[self.text_idx] == start_ch: + self.text_idx += 1 + break; + self.text_idx += 1 + + self.tokens.append((self.text[start_idx : self.text_idx], 4)) + return True + + # Checks for punctuators + # Returns whether a punctuator was consumed (True or False) + def parse_punctuator(self): + tab_idx = 0 + punc_len = 0 + saved_punc = None + while 1: + pte = punc_table[tab_idx] + if pte[0] == self.text[self.text_idx]: + if pte[3] != None: + saved_punc = pte[3] + self.text_idx += 1 + tab_idx = pte[2] + if tab_idx == 0: + break + elif pte[1] == 0: + break + else: + tab_idx += 1 + if saved_punc != None: + self.tokens.append((saved_punc, 1)) + return True + return False + + def parse_number(self): + # A number must start with a digit or a dot followed by a digit + ch = self.text[self.text_idx] + if not ch.isdigit() and (ch != '.' or not self.text[self.text_idx + 1].isdigit()): + return False; + token_type = 2 # integer + if (ch == '.'): + token_type = 3 # float + did_hex = False; + start_idx = self.text_idx + + # Check for Hex, Octal, or Binary + # Note that only D and Pawn support binary, but who cares? + # + if ch == '0': + self.text_idx += 1 + ch = self.text[self.text_idx].upper() + if ch == 'X': # hex + did_hex = True + self.text_idx += 1 + while self.text[self.text_idx] in '_0123456789abcdefABCDEF': + self.text_idx += 1 + elif ch == 'B': # binary + self.text_idx += 1 + while self.text[self.text_idx] in '_01': + self.text_idx += 1 + elif ch >= '0' and ch <= 7: # octal (but allow decimal) + self.text_idx += 1 + while self.text[self.text_idx] in '_0123456789': + self.text_idx += 1 + else: + # either just 0 or 0.1 or 0UL, etc + pass + else: + # Regular int or float + while self.text[self.text_idx] in '_0123456789': + self.text_idx += 1 + + # Check if we stopped on a decimal point + if self.text[self.text_idx] == '.': + self.text_idx += 1 + token_type = 3 # float + if did_hex: + while self.text[self.text_idx] in '_0123456789abcdefABCDEF': + self.text_idx += 1 + else: + while self.text[self.text_idx] in '_0123456789': + self.text_idx += 1 + + # Check exponent + # Valid exponents per language (not that it matters): + # C/C++/D/Java: eEpP + # C#/Pawn: eE + if self.text[self.text_idx] in 'eEpP': + token_type = 3 # float + self.text_idx += 1 + if self.text[self.text_idx] in '+-': + self.text_idx += 1 + while self.text[self.text_idx] in '_0123456789': + self.text_idx += 1 + + # Check the suffixes + # Valid suffixes per language (not that it matters): + # Integer Float + # C/C++: uUlL lLfF + # C#: uUlL fFdDMm + # D: uUL ifFL + # Java: lL fFdD + # Pawn: (none) (none) + # + # Note that i, f, d, and m only appear in floats. + while 1: + if self.text[self.text_idx] in 'tTfFdDmM': + token_type = 3 # float + elif not self.text[self.text_idx] in 'lLuU': + break; + self.text_idx += 1 + + self.tokens.append((self.text[start_idx : self.text_idx], token_type)) + return True + +text = """ +1.23+4-3*16%2 *sin(1.e-3 + .5p32) "hello" and "hello\\"there" +123 // some comment +a = b + c; +#define abc \\ + 5 +d = 5 /* hello */ + 3; +""" + +t=tokenizer() +t.tokenize_text(text) +print t.tokens + diff --git a/scripts/update-defaults.sh b/scripts/update-defaults.sh new file mode 100755 index 0000000000..7338005d3e --- /dev/null +++ b/scripts/update-defaults.sh @@ -0,0 +1,4 @@ +#! /bin/sh +src/uncrustify -c /dev/null --update-config-with-doc > etc/defaults.cfg +cp etc/defaults.cfg documentation/htdocs/default.cfg + diff --git a/src/ChunkStack.cpp b/src/ChunkStack.cpp new file mode 100644 index 0000000000..c650b4d67b --- /dev/null +++ b/src/ChunkStack.cpp @@ -0,0 +1,174 @@ +/** + * @file ChunkStack.cpp + * Manages a chunk stack + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "ChunkStack.h" +#include +#include + +ChunkStack::ChunkStack(const ChunkStack& cs) +{ + Set(cs); +} + + +ChunkStack::~ChunkStack() +{ + if (m_cse != NULL) + { + free(m_cse); + m_cse = NULL; + m_size = m_len = 0; + } +} + + +void ChunkStack::Set(const ChunkStack& cs) +{ + Init(); + Resize(cs.m_len); + for (int idx = 0; idx < cs.m_len; idx++) + { + Push(cs.m_cse[idx].m_pc, cs.m_cse[idx].m_seqnum); + } + m_seqnum = cs.m_seqnum; +} + + +const ChunkStack::Entry *ChunkStack::Top() const +{ + if (m_len > 0) + { + return(&m_cse[m_len - 1]); + } + return(NULL); +} + + +const ChunkStack::Entry *ChunkStack::Get(int idx) const +{ + if ((idx < m_len) && (idx >= 0)) + { + return(&m_cse[idx]); + } + return(NULL); +} + + +chunk_t *ChunkStack::GetChunk(int idx) const +{ + if ((idx < m_len) && (idx >= 0)) + { + return(m_cse[idx].m_pc); + } + return(NULL); +} + + +chunk_t *ChunkStack::Pop() +{ + if (m_len > 0) + { + m_len--; + return(m_cse[m_len].m_pc); + } + return(NULL); +} + + +void ChunkStack::Push(chunk_t *pc, int seqnum) +{ + if (m_len >= m_size) + { + Resize(m_len + 64); + } + m_cse[m_len].m_pc = pc; + m_cse[m_len].m_seqnum = seqnum; + m_len++; + if (m_seqnum < seqnum) + { + m_seqnum = seqnum; + } +} + + +void ChunkStack::Init() +{ + m_cse = NULL; + m_size = 0; + m_len = 0; + m_seqnum = 0; +} + + +void ChunkStack::Resize(int newsize) +{ + if (m_size < newsize) + { + m_size = newsize; + m_cse = (Entry *)realloc(m_cse, m_size * sizeof(ChunkStack::Entry)); + assert(m_cse != NULL); + /*TODO: check for out-of-memory? */ + } +} + + +/** + * Mark an entry to be removed by Collapse() + * + * @param idx The item to remove + */ +void ChunkStack::Zap(int idx) +{ + if ((idx < m_len) && (idx >= 0)) + { + assert(m_cse != NULL); + m_cse[idx].m_pc = NULL; + } +} + + +/** + * Compresses down the stack by removing dead entries + */ +void ChunkStack::Collapse() +{ + int oldlen = m_len; + + m_len = 0; + + for (int idx = 0; idx < oldlen; idx++) + { + assert(m_cse != NULL); + if (m_cse[idx].m_pc != NULL) + { + m_cse[m_len].m_pc = m_cse[idx].m_pc; + m_cse[m_len].m_seqnum = m_cse[idx].m_seqnum; + m_len++; + } + } +} + + +// +//int main(int argc, char **argv) +//{ +// ChunkStack cs; +// +// cs.Push((chunk_t *)1); +// cs.Push((chunk_t *)2); +// cs.Push((chunk_t *)3); +// cs.Push((chunk_t *)4); +// +// while (!cs.Empty()) +// { +// chunk_t *pc = cs.Pop(); +// printf("pc = %p\n", pc); +// } +// +// return (0); +//} +// diff --git a/src/ChunkStack.h b/src/ChunkStack.h new file mode 100644 index 0000000000..24f4867d47 --- /dev/null +++ b/src/ChunkStack.h @@ -0,0 +1,80 @@ +/** + * @file ChunkStack.h + * Manages a simple stack of chunks + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef CHUNKSTACK_H_INCLUDED +#define CHUNKSTACK_H_INCLUDED + +#include "uncrustify_types.h" + +class ChunkStack +{ +public: + struct Entry + { + int m_seqnum; + chunk_t *m_pc; + }; + +protected: + Entry *m_cse; // the array of entries + int m_size; // entries allocated + int m_len; // entries used + int m_seqnum; // current seq num + +public: + ChunkStack() + { + Init(); + } + + + ChunkStack(const ChunkStack& cs); + + ~ChunkStack(); + + void Set(const ChunkStack& cs); + + void Push(chunk_t *pc) + { + Push(pc, ++m_seqnum); + } + + + bool Empty() const + { + return(m_len == 0); + } + + + int Len() const + { + return(m_len); + } + + + const Entry *Top() const; + const Entry *Get(int idx) const; + chunk_t *GetChunk(int idx) const; + + chunk_t *Pop(); + void Push(chunk_t *pc, int seqnum); + + void Reset() + { + m_len = 0; + } + + + void Zap(int idx); + void Collapse(); + +protected: + void Init(); + void Resize(int newsize); +}; + +#endif /* CHUNKSTACK_H_INCLUDED */ diff --git a/src/ListManager.h b/src/ListManager.h new file mode 100644 index 0000000000..c6e35dcc18 --- /dev/null +++ b/src/ListManager.h @@ -0,0 +1,203 @@ +/** + * @file ListManager.h + * Template class that manages items in a double-linked list. + * If C++ could do it, this would just be a class that worked on an interface. + * + * @author Ben Gardner + * @license GPL v2+ + */ + +/** + * A simple list manager for a double-linked list. + * Class T must define 'next' and 'prev', which must be pointers to type T. + */ + +template class ListManager +{ +protected: + + /* Pointers to the head and tail. + * They are either both NULL or both non-NULL. + */ + T *first; + T *last; + +private: + /* Hide copy constructor */ + ListManager(const ListManager& ref) + { + first = NULL; + last = NULL; + } + + +public: + ListManager() + { + first = NULL; + last = NULL; + } + + + T *GetHead() + { + return(first); + } + + + T *GetTail() + { + return(last); + } + + + T *GetNext(T *ref) + { + return((ref != NULL) ? ref->next : NULL); + } + + + T *GetPrev(T *ref) + { + return((ref != NULL) ? ref->prev : NULL); + } + + + void InitEntry(T *obj) const + { + if (obj != NULL) + { + obj->next = NULL; + obj->prev = NULL; + } + } + + + void Pop(T *obj) + { + if (obj != NULL) + { + if (first == obj) + { + first = obj->next; + } + if (last == obj) + { + last = obj->prev; + } + if (obj->next != NULL) + { + obj->next->prev = obj->prev; + } + if (obj->prev != NULL) + { + obj->prev->next = obj->next; + } + obj->next = NULL; + obj->prev = NULL; + } + } + + + void Swap(T *obj1, T *obj2) + { + if ((obj1 != NULL) && (obj2 != NULL)) + { + if (obj1->prev == obj2) + { + Pop(obj1); + AddBefore(obj1, obj2); + } + else if (obj2->prev == obj1) + { + Pop(obj2); + AddBefore(obj2, obj1); + } + else + { + T *prev1 = obj1->prev; + Pop(obj1); + + T *prev2 = obj2->prev; + Pop(obj2); + + AddAfter(obj1, prev2); + AddAfter(obj2, prev1); + } + } + } + + + void AddAfter(T *obj, T *ref) + { + if ((obj != NULL) && (ref != NULL)) + { + Pop(obj); + obj->next = ref->next; + obj->prev = ref; + if (ref->next != NULL) + { + ref->next->prev = obj; + } + else + { + last = obj; + } + ref->next = obj; + } + } + + + void AddBefore(T *obj, T *ref) + { + if ((obj != NULL) && (ref != NULL)) + { + Pop(obj); + obj->next = ref; + obj->prev = ref->prev; + if (ref->prev != NULL) + { + ref->prev->next = obj; + } + else + { + first = obj; + } + ref->prev = obj; + } + } + + + void AddTail(T *obj) + { + obj->next = NULL; + obj->prev = last; + if (last == NULL) + { + last = obj; + first = obj; + } + else + { + last->next = obj; + } + last = obj; + } + + + void AddHead(T *obj) + { + obj->next = first; + obj->prev = NULL; + if (first == NULL) + { + last = obj; + first = obj; + } + else + { + first->prev = obj; + } + first = obj; + } +}; diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000000..9a2eefa514 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,32 @@ +AUTOMAKE_OPTIONS = foreign no-dependencies nostdinc + +DISTCLEANFILES = +CLEANFILES = *.o *~ *.bak +MAINTAINERCLEANFILES = Makefile.in + +bin_PROGRAMS = uncrustify + +BUILT_SOURCES = token_names.h + +uncrustify_SOURCES = uncrustify.cpp chunk_list.cpp indent.cpp align.cpp combine.cpp \ + tokenize.cpp tokenize_cleanup.cpp space.cpp newlines.cpp output.cpp \ + args.cpp options.cpp keywords.cpp punctuators.cpp parse_frame.cpp \ + logmask.cpp logger.cpp ChunkStack.cpp braces.cpp brace_cleanup.cpp \ + align_stack.cpp defines.cpp width.cpp lang_pawn.cpp md5.cpp \ + backup.cpp parens.cpp universalindentgui.cpp semicolons.cpp \ + sorting.cpp detect.cpp + +noinst_HEADERS = chunk_list.h options.h char_table.h chunk_list.h \ + uncrustify_types.h prototypes.h logmask.h logger.h \ + ChunkStack.h args.h token_names.h token_enum.h ListManager.h md5.h \ + align_stack.h backup.h base_types.h log_levels.h \ + punctuators.h \ + uncrustify_version.h \ + unc_ctype.h \ + d.tokenize.cpp + +token_names.h: token_enum.h ../make_token_names.sh + @echo "Rebuilding token_names.h" + @sh ../make_token_names.sh + +uncrustify_CPPFLAGS = -Wall diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000000..d92ed54a8d --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,658 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = uncrustify$(EXEEXT) +subdir = src +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_uncrustify_OBJECTS = uncrustify-uncrustify.$(OBJEXT) \ + uncrustify-chunk_list.$(OBJEXT) uncrustify-indent.$(OBJEXT) \ + uncrustify-align.$(OBJEXT) uncrustify-combine.$(OBJEXT) \ + uncrustify-tokenize.$(OBJEXT) \ + uncrustify-tokenize_cleanup.$(OBJEXT) \ + uncrustify-space.$(OBJEXT) uncrustify-newlines.$(OBJEXT) \ + uncrustify-output.$(OBJEXT) uncrustify-args.$(OBJEXT) \ + uncrustify-options.$(OBJEXT) uncrustify-keywords.$(OBJEXT) \ + uncrustify-punctuators.$(OBJEXT) \ + uncrustify-parse_frame.$(OBJEXT) uncrustify-logmask.$(OBJEXT) \ + uncrustify-logger.$(OBJEXT) uncrustify-ChunkStack.$(OBJEXT) \ + uncrustify-braces.$(OBJEXT) uncrustify-brace_cleanup.$(OBJEXT) \ + uncrustify-align_stack.$(OBJEXT) uncrustify-defines.$(OBJEXT) \ + uncrustify-width.$(OBJEXT) uncrustify-lang_pawn.$(OBJEXT) \ + uncrustify-md5.$(OBJEXT) uncrustify-backup.$(OBJEXT) \ + uncrustify-parens.$(OBJEXT) \ + uncrustify-universalindentgui.$(OBJEXT) \ + uncrustify-semicolons.$(OBJEXT) uncrustify-sorting.$(OBJEXT) \ + uncrustify-detect.$(OBJEXT) +uncrustify_OBJECTS = $(am_uncrustify_OBJECTS) +uncrustify_LDADD = $(LDADD) +DEFAULT_INCLUDES = +depcomp = +am__depfiles_maybe = +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(uncrustify_SOURCES) +DIST_SOURCES = $(uncrustify_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign no-dependencies nostdinc +DISTCLEANFILES = +CLEANFILES = *.o *~ *.bak +MAINTAINERCLEANFILES = Makefile.in +BUILT_SOURCES = token_names.h +uncrustify_SOURCES = uncrustify.cpp chunk_list.cpp indent.cpp align.cpp combine.cpp \ + tokenize.cpp tokenize_cleanup.cpp space.cpp newlines.cpp output.cpp \ + args.cpp options.cpp keywords.cpp punctuators.cpp parse_frame.cpp \ + logmask.cpp logger.cpp ChunkStack.cpp braces.cpp brace_cleanup.cpp \ + align_stack.cpp defines.cpp width.cpp lang_pawn.cpp md5.cpp \ + backup.cpp parens.cpp universalindentgui.cpp semicolons.cpp \ + sorting.cpp detect.cpp + +noinst_HEADERS = chunk_list.h options.h char_table.h chunk_list.h \ + uncrustify_types.h prototypes.h logmask.h logger.h \ + ChunkStack.h args.h token_names.h token_enum.h ListManager.h md5.h \ + align_stack.h backup.h base_types.h log_levels.h \ + punctuators.h \ + uncrustify_version.h \ + unc_ctype.h \ + d.tokenize.cpp + +uncrustify_CPPFLAGS = -Wall +all: $(BUILT_SOURCES) config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status src/config.h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +uncrustify$(EXEEXT): $(uncrustify_OBJECTS) $(uncrustify_DEPENDENCIES) + @rm -f uncrustify$(EXEEXT) + $(CXXLINK) $(uncrustify_OBJECTS) $(uncrustify_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.cpp.o: + $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: + $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +uncrustify-uncrustify.o: uncrustify.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-uncrustify.o `test -f 'uncrustify.cpp' || echo '$(srcdir)/'`uncrustify.cpp + +uncrustify-uncrustify.obj: uncrustify.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-uncrustify.obj `if test -f 'uncrustify.cpp'; then $(CYGPATH_W) 'uncrustify.cpp'; else $(CYGPATH_W) '$(srcdir)/uncrustify.cpp'; fi` + +uncrustify-chunk_list.o: chunk_list.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-chunk_list.o `test -f 'chunk_list.cpp' || echo '$(srcdir)/'`chunk_list.cpp + +uncrustify-chunk_list.obj: chunk_list.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-chunk_list.obj `if test -f 'chunk_list.cpp'; then $(CYGPATH_W) 'chunk_list.cpp'; else $(CYGPATH_W) '$(srcdir)/chunk_list.cpp'; fi` + +uncrustify-indent.o: indent.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-indent.o `test -f 'indent.cpp' || echo '$(srcdir)/'`indent.cpp + +uncrustify-indent.obj: indent.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-indent.obj `if test -f 'indent.cpp'; then $(CYGPATH_W) 'indent.cpp'; else $(CYGPATH_W) '$(srcdir)/indent.cpp'; fi` + +uncrustify-align.o: align.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-align.o `test -f 'align.cpp' || echo '$(srcdir)/'`align.cpp + +uncrustify-align.obj: align.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-align.obj `if test -f 'align.cpp'; then $(CYGPATH_W) 'align.cpp'; else $(CYGPATH_W) '$(srcdir)/align.cpp'; fi` + +uncrustify-combine.o: combine.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-combine.o `test -f 'combine.cpp' || echo '$(srcdir)/'`combine.cpp + +uncrustify-combine.obj: combine.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-combine.obj `if test -f 'combine.cpp'; then $(CYGPATH_W) 'combine.cpp'; else $(CYGPATH_W) '$(srcdir)/combine.cpp'; fi` + +uncrustify-tokenize.o: tokenize.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-tokenize.o `test -f 'tokenize.cpp' || echo '$(srcdir)/'`tokenize.cpp + +uncrustify-tokenize.obj: tokenize.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-tokenize.obj `if test -f 'tokenize.cpp'; then $(CYGPATH_W) 'tokenize.cpp'; else $(CYGPATH_W) '$(srcdir)/tokenize.cpp'; fi` + +uncrustify-tokenize_cleanup.o: tokenize_cleanup.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-tokenize_cleanup.o `test -f 'tokenize_cleanup.cpp' || echo '$(srcdir)/'`tokenize_cleanup.cpp + +uncrustify-tokenize_cleanup.obj: tokenize_cleanup.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-tokenize_cleanup.obj `if test -f 'tokenize_cleanup.cpp'; then $(CYGPATH_W) 'tokenize_cleanup.cpp'; else $(CYGPATH_W) '$(srcdir)/tokenize_cleanup.cpp'; fi` + +uncrustify-space.o: space.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-space.o `test -f 'space.cpp' || echo '$(srcdir)/'`space.cpp + +uncrustify-space.obj: space.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-space.obj `if test -f 'space.cpp'; then $(CYGPATH_W) 'space.cpp'; else $(CYGPATH_W) '$(srcdir)/space.cpp'; fi` + +uncrustify-newlines.o: newlines.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-newlines.o `test -f 'newlines.cpp' || echo '$(srcdir)/'`newlines.cpp + +uncrustify-newlines.obj: newlines.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-newlines.obj `if test -f 'newlines.cpp'; then $(CYGPATH_W) 'newlines.cpp'; else $(CYGPATH_W) '$(srcdir)/newlines.cpp'; fi` + +uncrustify-output.o: output.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-output.o `test -f 'output.cpp' || echo '$(srcdir)/'`output.cpp + +uncrustify-output.obj: output.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-output.obj `if test -f 'output.cpp'; then $(CYGPATH_W) 'output.cpp'; else $(CYGPATH_W) '$(srcdir)/output.cpp'; fi` + +uncrustify-args.o: args.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-args.o `test -f 'args.cpp' || echo '$(srcdir)/'`args.cpp + +uncrustify-args.obj: args.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-args.obj `if test -f 'args.cpp'; then $(CYGPATH_W) 'args.cpp'; else $(CYGPATH_W) '$(srcdir)/args.cpp'; fi` + +uncrustify-options.o: options.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-options.o `test -f 'options.cpp' || echo '$(srcdir)/'`options.cpp + +uncrustify-options.obj: options.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-options.obj `if test -f 'options.cpp'; then $(CYGPATH_W) 'options.cpp'; else $(CYGPATH_W) '$(srcdir)/options.cpp'; fi` + +uncrustify-keywords.o: keywords.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-keywords.o `test -f 'keywords.cpp' || echo '$(srcdir)/'`keywords.cpp + +uncrustify-keywords.obj: keywords.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-keywords.obj `if test -f 'keywords.cpp'; then $(CYGPATH_W) 'keywords.cpp'; else $(CYGPATH_W) '$(srcdir)/keywords.cpp'; fi` + +uncrustify-punctuators.o: punctuators.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-punctuators.o `test -f 'punctuators.cpp' || echo '$(srcdir)/'`punctuators.cpp + +uncrustify-punctuators.obj: punctuators.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-punctuators.obj `if test -f 'punctuators.cpp'; then $(CYGPATH_W) 'punctuators.cpp'; else $(CYGPATH_W) '$(srcdir)/punctuators.cpp'; fi` + +uncrustify-parse_frame.o: parse_frame.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-parse_frame.o `test -f 'parse_frame.cpp' || echo '$(srcdir)/'`parse_frame.cpp + +uncrustify-parse_frame.obj: parse_frame.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-parse_frame.obj `if test -f 'parse_frame.cpp'; then $(CYGPATH_W) 'parse_frame.cpp'; else $(CYGPATH_W) '$(srcdir)/parse_frame.cpp'; fi` + +uncrustify-logmask.o: logmask.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-logmask.o `test -f 'logmask.cpp' || echo '$(srcdir)/'`logmask.cpp + +uncrustify-logmask.obj: logmask.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-logmask.obj `if test -f 'logmask.cpp'; then $(CYGPATH_W) 'logmask.cpp'; else $(CYGPATH_W) '$(srcdir)/logmask.cpp'; fi` + +uncrustify-logger.o: logger.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-logger.o `test -f 'logger.cpp' || echo '$(srcdir)/'`logger.cpp + +uncrustify-logger.obj: logger.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-logger.obj `if test -f 'logger.cpp'; then $(CYGPATH_W) 'logger.cpp'; else $(CYGPATH_W) '$(srcdir)/logger.cpp'; fi` + +uncrustify-ChunkStack.o: ChunkStack.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-ChunkStack.o `test -f 'ChunkStack.cpp' || echo '$(srcdir)/'`ChunkStack.cpp + +uncrustify-ChunkStack.obj: ChunkStack.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-ChunkStack.obj `if test -f 'ChunkStack.cpp'; then $(CYGPATH_W) 'ChunkStack.cpp'; else $(CYGPATH_W) '$(srcdir)/ChunkStack.cpp'; fi` + +uncrustify-braces.o: braces.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-braces.o `test -f 'braces.cpp' || echo '$(srcdir)/'`braces.cpp + +uncrustify-braces.obj: braces.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-braces.obj `if test -f 'braces.cpp'; then $(CYGPATH_W) 'braces.cpp'; else $(CYGPATH_W) '$(srcdir)/braces.cpp'; fi` + +uncrustify-brace_cleanup.o: brace_cleanup.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-brace_cleanup.o `test -f 'brace_cleanup.cpp' || echo '$(srcdir)/'`brace_cleanup.cpp + +uncrustify-brace_cleanup.obj: brace_cleanup.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-brace_cleanup.obj `if test -f 'brace_cleanup.cpp'; then $(CYGPATH_W) 'brace_cleanup.cpp'; else $(CYGPATH_W) '$(srcdir)/brace_cleanup.cpp'; fi` + +uncrustify-align_stack.o: align_stack.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-align_stack.o `test -f 'align_stack.cpp' || echo '$(srcdir)/'`align_stack.cpp + +uncrustify-align_stack.obj: align_stack.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-align_stack.obj `if test -f 'align_stack.cpp'; then $(CYGPATH_W) 'align_stack.cpp'; else $(CYGPATH_W) '$(srcdir)/align_stack.cpp'; fi` + +uncrustify-defines.o: defines.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-defines.o `test -f 'defines.cpp' || echo '$(srcdir)/'`defines.cpp + +uncrustify-defines.obj: defines.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-defines.obj `if test -f 'defines.cpp'; then $(CYGPATH_W) 'defines.cpp'; else $(CYGPATH_W) '$(srcdir)/defines.cpp'; fi` + +uncrustify-width.o: width.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-width.o `test -f 'width.cpp' || echo '$(srcdir)/'`width.cpp + +uncrustify-width.obj: width.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-width.obj `if test -f 'width.cpp'; then $(CYGPATH_W) 'width.cpp'; else $(CYGPATH_W) '$(srcdir)/width.cpp'; fi` + +uncrustify-lang_pawn.o: lang_pawn.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-lang_pawn.o `test -f 'lang_pawn.cpp' || echo '$(srcdir)/'`lang_pawn.cpp + +uncrustify-lang_pawn.obj: lang_pawn.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-lang_pawn.obj `if test -f 'lang_pawn.cpp'; then $(CYGPATH_W) 'lang_pawn.cpp'; else $(CYGPATH_W) '$(srcdir)/lang_pawn.cpp'; fi` + +uncrustify-md5.o: md5.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-md5.o `test -f 'md5.cpp' || echo '$(srcdir)/'`md5.cpp + +uncrustify-md5.obj: md5.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-md5.obj `if test -f 'md5.cpp'; then $(CYGPATH_W) 'md5.cpp'; else $(CYGPATH_W) '$(srcdir)/md5.cpp'; fi` + +uncrustify-backup.o: backup.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-backup.o `test -f 'backup.cpp' || echo '$(srcdir)/'`backup.cpp + +uncrustify-backup.obj: backup.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-backup.obj `if test -f 'backup.cpp'; then $(CYGPATH_W) 'backup.cpp'; else $(CYGPATH_W) '$(srcdir)/backup.cpp'; fi` + +uncrustify-parens.o: parens.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-parens.o `test -f 'parens.cpp' || echo '$(srcdir)/'`parens.cpp + +uncrustify-parens.obj: parens.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-parens.obj `if test -f 'parens.cpp'; then $(CYGPATH_W) 'parens.cpp'; else $(CYGPATH_W) '$(srcdir)/parens.cpp'; fi` + +uncrustify-universalindentgui.o: universalindentgui.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-universalindentgui.o `test -f 'universalindentgui.cpp' || echo '$(srcdir)/'`universalindentgui.cpp + +uncrustify-universalindentgui.obj: universalindentgui.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-universalindentgui.obj `if test -f 'universalindentgui.cpp'; then $(CYGPATH_W) 'universalindentgui.cpp'; else $(CYGPATH_W) '$(srcdir)/universalindentgui.cpp'; fi` + +uncrustify-semicolons.o: semicolons.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-semicolons.o `test -f 'semicolons.cpp' || echo '$(srcdir)/'`semicolons.cpp + +uncrustify-semicolons.obj: semicolons.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-semicolons.obj `if test -f 'semicolons.cpp'; then $(CYGPATH_W) 'semicolons.cpp'; else $(CYGPATH_W) '$(srcdir)/semicolons.cpp'; fi` + +uncrustify-sorting.o: sorting.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-sorting.o `test -f 'sorting.cpp' || echo '$(srcdir)/'`sorting.cpp + +uncrustify-sorting.obj: sorting.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-sorting.obj `if test -f 'sorting.cpp'; then $(CYGPATH_W) 'sorting.cpp'; else $(CYGPATH_W) '$(srcdir)/sorting.cpp'; fi` + +uncrustify-detect.o: detect.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-detect.o `test -f 'detect.cpp' || echo '$(srcdir)/'`detect.cpp + +uncrustify-detect.obj: detect.cpp + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uncrustify_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncrustify-detect.obj `if test -f 'detect.cpp'; then $(CYGPATH_W) 'detect.cpp'; else $(CYGPATH_W) '$(srcdir)/detect.cpp'; fi` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(HEADERS) config.h +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags distclean distclean-compile \ + distclean-generic distclean-hdr distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS + + +token_names.h: token_enum.h ../make_token_names.sh + @echo "Rebuilding token_names.h" + @sh ../make_token_names.sh +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/align.cpp b/src/align.cpp new file mode 100644 index 0000000000..72b28951b8 --- /dev/null +++ b/src/align.cpp @@ -0,0 +1,1801 @@ +/** + * @file align.cpp + * Does all the aligning stuff. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "ChunkStack.h" +#include "align_stack.h" +#include "prototypes.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +static chunk_t *align_var_def_brace(chunk_t *pc, int span, int *nl_count); +chunk_t *align_trailing_comments(chunk_t *start); +static void align_init_brace(chunk_t *start); +static void align_func_params(); +static void align_same_func_call_params(); +static void align_func_proto(int span); +static void align_oc_msg_spec(int span); +static void align_typedefs(int span); +static void align_left_shift(void); +static void align_oc_msg_colon(void); + + +/* + * Here are the items aligned: + * + * - enum value assignments + * enum { + * cat = 1, + * fred = 2, + * }; + * + * - struct/union variable & bit definitions + * struct foo { + * char cat; + * int id : 5; + * int name_len : 6; + * int heigth : 12; + * }; + * + * - variable definitions & assignments in normal code + * const char *cat = "feline"; + * int id = 4; + * a = 5; + * bat = 14; + * + * - simple array initializers + * int a[] = { + * 1, 2, 3, 4, 5, + * 6, 7, 8, 9, 10 + * }; + * + * - c99 array initializers + * const char *name[] = { + * [FRED] = "fred", + * [JOE] = "joe", + * [PETER] = "peter", + * }; + * struct foo b[] = { + * { .id = 1, .name = "text 1" }, + * { .id = 567, .name = "text 2" }, + * }; + * struct foo_t bars[] = + * { + * [0] = { .name = "bar", + * .age = 21 }, + * [1] = { .name = "barley", + * .age = 55 }, + * }; + * + * - compact array initializers + * struct foo b[] = { + * { 3, "dog" }, { 6, "spider" }, + * { 8, "elephant" }, { 3, "cat" }, + * }; + * + * - multiline array initializers (2nd line indented, not aligned) + * struct foo b[] = { + * { AD_NOT_ALLOWED, "Sorry, you failed to guess the password.", + * "Try again?", "Yes", "No" }, + * { AD_SW_ERROR, "A software error has occured.", "Bye!", NULL, NULL }, + * }; + * + * - Trailing comments + * + * - Back-slash newline groups + * + * - Function prototypes + * int foo(); + * void bar(); + * + * - Preprocessors + * #define FOO_VAL 15 + * #define MAX_TIMEOUT 60 + * #define FOO(x) ((x) * 65) + * + * - typedefs + * typedef uint8_t BYTE; + * typedef int32_t INT32; + * typedef uint32_t UINT32; + */ + +/** + * Aligns everything in the chunk stack to a particular column. + * The stack is empty after this function. + * + * @param col the column + * @param align_single align even if there is only one item on the stack + */ +static void align_stack(ChunkStack& cs, int col, bool align_single, log_sev_t sev) +{ + chunk_t *pc; + + if (cpd.settings[UO_align_on_tabstop].b) + { + int rem = (col - 1) % cpd.settings[UO_output_tab_size].n; + if (rem != 0) + { + LOG_FMT(sev, "%s: col=%d rem=%d", __func__, col, rem); + col += cpd.settings[UO_output_tab_size].n - rem; + } + } + + if ((cs.Len() > 1) || (align_single && (cs.Len() == 1))) + { + LOG_FMT(sev, "%s: max_col=%d\n", __func__, col); + while ((pc = cs.Pop()) != NULL) + { + if (cpd.settings[UO_align_right_cmt_at_col].n == 0) + { + indent_to_column(pc, col); + } + else + { + align_to_column(pc, col); + } + pc->flags |= PCF_WAS_ALIGNED; + + if (pc->type == CT_NL_CONT) + { + LOG_FMT(sev, "%s: indented [NL_CONT] on line %d to %d\n", + __func__, pc->orig_line, pc->column); + } + else + { + LOG_FMT(sev, "%s: indented [%.*s] on line %d to %d\n", + __func__, pc->len, pc->str, pc->orig_line, pc->column); + } + } + } + cs.Reset(); +} + + +/** + * Adds an item to the align stack and adjust the nl_count and max_col. + * Adjust max_col as needed + * + * @param pc the item to add + * @param max_col pointer to the column variable + * @param extra_pad extra padding + */ +static void align_add(ChunkStack& cs, chunk_t *pc, int& max_col, int min_pad, bool squeeze) +{ + chunk_t *prev; + int min_col; + + prev = chunk_get_prev(pc); + if ((prev == NULL) || chunk_is_newline(prev)) + { + min_col = squeeze ? 1 : pc->column; + LOG_FMT(LALADD, "%s: pc->col=%d max_col=%d min_pad=%d min_col=%d\n", + __func__, pc->column, max_col, min_pad, min_col); + } + else + { + if (prev->type == CT_COMMENT_MULTI) + { + min_col = prev->orig_col_end + min_pad; + } + else + { + min_col = prev->column + prev->len + min_pad; + } + if (!squeeze) + { + if (min_col < pc->column) + { + min_col = pc->column; + } + } + LOG_FMT(LALADD, "%s: pc->col=%d max_col=%d min_pad=%d min_col=%d multi:%s prev->col=%d prev->len=%d %s\n", + __func__, pc->column, max_col, min_pad, min_col, (prev->type == CT_COMMENT_MULTI) ? "Y" : "N", + (prev->type == CT_COMMENT_MULTI) ? prev->orig_col_end : prev->column, prev->len, get_token_name(prev->type)); + } + + if (cs.Empty()) + { + max_col = 0; + } + + cs.Push(pc); + if (min_col > max_col) + { + max_col = min_col; + } +} + + +void quick_align_again(void) +{ + chunk_t *pc; + chunk_t *tmp; + AlignStack as; + + LOG_FMT(LALAGAIN, "%s:\n", __func__); + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if ((pc->align.next != NULL) && (pc->flags & PCF_ALIGN_START)) + { + as.Start(100, 0); + as.m_right_align = pc->align.right_align; + as.m_star_style = (AlignStack::StarStyle)pc->align.star_style; + as.m_amp_style = (AlignStack::StarStyle)pc->align.amp_style; + as.m_gap = pc->align.gap; + + LOG_FMT(LALAGAIN, " [%.*s:%d]", pc->len, pc->str, pc->orig_line); + as.Add(pc->align.start); + for (tmp = pc->align.next; tmp != NULL; tmp = tmp->align.next) + { + as.Add(tmp->align.start); + LOG_FMT(LALAGAIN, " => [%.*s:%d]", tmp->len, tmp->str, tmp->orig_line); + } + LOG_FMT(LALAGAIN, "\n"); + as.End(); + } + } +} + + +void align_all(void) +{ + if (cpd.settings[UO_align_typedef_span].n > 0) + { + align_typedefs(cpd.settings[UO_align_typedef_span].n); + } + + if (cpd.settings[UO_align_left_shift].b) + { + align_left_shift(); + } + + if (cpd.settings[UO_align_oc_msg_colon].b) + { + align_oc_msg_colon(); + } + + /* Align variable definitions */ + if ((cpd.settings[UO_align_var_def_span].n > 0) || + (cpd.settings[UO_align_var_struct_span].n > 0)) + { + align_var_def_brace(chunk_get_head(), cpd.settings[UO_align_var_def_span].n, NULL); + } + + /* Align assignments */ + align_assign(chunk_get_head(), + cpd.settings[UO_align_assign_span].n, + cpd.settings[UO_align_assign_thresh].n); + + /* Align structure initializers */ + if (cpd.settings[UO_align_struct_init_span].n > 0) + { + align_struct_initializers(); + } + + /* Align function prototypes */ + if ((cpd.settings[UO_align_func_proto_span].n > 0) && + !cpd.settings[UO_align_mix_var_proto].b) + { + align_func_proto(cpd.settings[UO_align_func_proto_span].n); + } + + /* Align function prototypes */ + if (cpd.settings[UO_align_oc_msg_spec_span].n > 0) + { + align_oc_msg_spec(cpd.settings[UO_align_oc_msg_spec_span].n); + } + + /* Align variable defs in function prototypes */ + if (cpd.settings[UO_align_func_params].b) + { + align_func_params(); + } + + if (cpd.settings[UO_align_same_func_call_params].b) + { + align_same_func_call_params(); + } + /* Just in case something was aligned out of order... do it again */ + quick_align_again(); +} + + +/** + * Aligns all function prototypes in the file. + */ +static void align_oc_msg_spec(int span) +{ + chunk_t *pc; + AlignStack as; + + LOG_FMT(LALIGN, "%s\n", __func__); + as.Start(span, 0); + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (chunk_is_newline(pc)) + { + as.NewLines(pc->nl_count); + } + else if (pc->type == CT_OC_MSG_SPEC) + { + as.Add(pc); + } + } + as.End(); +} + + +/** + * Aligns all backslash-newline combos in the file. + * This should be done LAST. + */ +void align_backslash_newline(void) +{ + chunk_t *pc; + + pc = chunk_get_head(); + while (pc != NULL) + { + if (pc->type != CT_NL_CONT) + { + pc = chunk_get_next_type(pc, CT_NL_CONT, -1); + continue; + } + pc = align_nl_cont(pc); + } +} + + +void align_right_comments(void) +{ + chunk_t *pc; + chunk_t *prev; + bool skip; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if ((pc->type == CT_COMMENT) || (pc->type == CT_COMMENT_CPP)) + { + skip = false; + if (pc->parent_type == CT_COMMENT_END) + { + prev = chunk_get_prev(pc); + if (pc->orig_col <= (prev->orig_col_end + cpd.settings[UO_align_right_cmt_gap].n)) + { + LOG_FMT(LALTC, "NOT changing END comment on line %d (%d <= %d + %d)\n", + pc->orig_line, + pc->orig_col, prev->orig_col_end, cpd.settings[UO_align_right_cmt_gap].n); + skip = true; + } + if (!skip) + { + LOG_FMT(LALTC, "Changing END comment on line %d into a RIGHT-comment\n", + pc->orig_line); + pc->flags |= PCF_RIGHT_COMMENT; + } + } + + /* Change certain WHOLE comments into RIGHT-alignable comments */ + if (pc->parent_type == CT_COMMENT_WHOLE) + { + int tmp_col = 1 + (pc->brace_level * cpd.settings[UO_indent_columns].n); + + /* If the comment is further right than the brace level... */ + if (pc->column > (tmp_col + cpd.settings[UO_align_right_cmt_gap].n)) + { + LOG_FMT(LALTC, "Changing WHOLE comment on line %d into a RIGHT-comment\n", + pc->orig_line); + + pc->flags |= PCF_RIGHT_COMMENT; + } + } + } + } + + pc = chunk_get_head(); + while (pc != NULL) + { + if ((pc->flags & PCF_RIGHT_COMMENT) != 0) + { + pc = align_trailing_comments(pc); + } + else + { + pc = chunk_get_next(pc); + } + } +} + + +/** + * Aligns stuff inside a multi-line "= { ... }" sequence. + */ +void align_struct_initializers(void) +{ + chunk_t *pc; + chunk_t *prev; + + pc = chunk_get_head(); + while (pc != NULL) + { + prev = chunk_get_prev_ncnl(pc); + if ((prev != NULL) && (prev->type == CT_ASSIGN) && + ((pc->type == CT_BRACE_OPEN) || + ((cpd.lang_flags & LANG_D) && (pc->type == CT_SQUARE_OPEN)))) + { + align_init_brace(pc); + } + pc = chunk_get_next_type(pc, CT_BRACE_OPEN, -1); + } +} + + +/** + * Scans the whole file for #defines. Aligns all within X lines of each other + */ +void align_preprocessor(void) +{ + chunk_t *pc; + AlignStack as; // value macros + AlignStack asf; // function macros + AlignStack *cur_as = &as; + + as.Start(cpd.settings[UO_align_pp_define_span].n); + as.m_gap = cpd.settings[UO_align_pp_define_gap].n; + + asf.Start(cpd.settings[UO_align_pp_define_span].n); + asf.m_gap = cpd.settings[UO_align_pp_define_gap].n; + + pc = chunk_get_head(); + while (pc != NULL) + { + /* Note: not counting back-slash newline combos */ + if (pc->type == CT_NEWLINE) + { + as.NewLines(pc->nl_count); + asf.NewLines(pc->nl_count); + } + + /* If we aren't on a 'define', then skip to the next non-comment */ + if (pc->type != CT_PP_DEFINE) + { + pc = chunk_get_next_nc(pc); + continue; + } + + /* step past the 'define' */ + pc = chunk_get_next_nc(pc); + if (pc == NULL) + { + break; + } + + LOG_FMT(LALPP, "%s: define (%.*s) on line %d col %d\n", + __func__, pc->len, pc->str, pc->orig_line, pc->orig_col); + + cur_as = &as; + if (pc->type == CT_MACRO_FUNC) + { + cur_as = &asf; + + /* Skip to the close paren */ + pc = chunk_get_next_nc(pc); // point to open ( + pc = chunk_get_next_type(pc, CT_FPAREN_CLOSE, pc->level); + + LOG_FMT(LALPP, "%s: jumped to (%.*s) on line %d col %d\n", + __func__, pc->len, pc->str, pc->orig_line, pc->orig_col); + } + + /* step to the value past the close paren or the macro name */ + pc = chunk_get_next(pc); + if (pc == NULL) + { + break; + } + + /* don't align anything if the first line ends with a newline before + * a value is given */ + if (!chunk_is_newline(pc)) + { + LOG_FMT(LALPP, "%s: align on '%.*s', line %d col %d\n", + __func__, pc->len, pc->str, pc->orig_line, pc->orig_col); + + cur_as->Add(pc); + } + } + + as.End(); + asf.End(); +} + + +/** + * Aligns all assignment operators on the same level as first, starting with + * first. + * + * For variable definitions, only consider the '=' for the first variable. + * Otherwise, only look at the first '=' on the line. + */ +chunk_t *align_assign(chunk_t *first, int span, int thresh) +{ + int my_level; + chunk_t *pc; + int tmp; + int var_def_cnt = 0; + int equ_count = 0; + + if (first == NULL) + { + return(NULL); + } + my_level = first->level; + + if (span <= 0) + { + return(chunk_get_next(first)); + } + + LOG_FMT(LALASS, "%s[%d]: checking %.*s on line %d - span=%d thresh=%d\n", + __func__, my_level, first->len, first->str, first->orig_line, + span, thresh); + + AlignStack as; // regular assigns + AlignStack vdas; // variable def assigns + + as.Start(span, thresh); + as.m_right_align = true; + vdas.Start(span, thresh); + vdas.m_right_align = true; + + pc = first; + while ((pc != NULL) && ((pc->level >= my_level) || (pc->level == 0))) + { + /* Don't check inside PAREN or SQUARE groups */ + if ((pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SQUARE_OPEN) || + (pc->type == CT_PAREN_OPEN)) + { + tmp = pc->orig_line; + pc = chunk_skip_to_match(pc); + if (pc != NULL) + { + as.NewLines(pc->orig_line - tmp); + vdas.NewLines(pc->orig_line - tmp); + } + continue; + } + + /* Recurse if a brace set is found */ + if ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_VBRACE_OPEN)) + { + int myspan; + int mythresh; + + tmp = pc->orig_line; + + if (pc->parent_type == CT_ENUM) + { + myspan = cpd.settings[UO_align_enum_equ_span].n; + mythresh = cpd.settings[UO_align_enum_equ_thresh].n; + } + else + { + myspan = cpd.settings[UO_align_assign_span].n; + mythresh = cpd.settings[UO_align_assign_thresh].n; + } + + pc = align_assign(chunk_get_next_ncnl(pc), myspan, mythresh); + if (pc != NULL) + { + /* do a rough count of the number of lines just spanned */ + as.NewLines(pc->orig_line - tmp); + vdas.NewLines(pc->orig_line - tmp); + } + continue; + } + + if (chunk_is_newline(pc)) + { + as.NewLines(pc->nl_count); + vdas.NewLines(pc->nl_count); + + var_def_cnt = 0; + equ_count = 0; + } + else if ((pc->flags & PCF_VAR_DEF) != 0) + { + var_def_cnt++; + } + else if (var_def_cnt > 1) + { + /* we hit the second variable def - don't look for assigns */ + } + else if ((equ_count == 0) && (pc->type == CT_ASSIGN)) + { + //fprintf(stderr, "%s: ** %s level=%d line=%d col=%d prev=%d count=%d\n", + // __func__, pc->str, pc->level, pc->orig_line, pc->orig_col, prev_equ_type, + // equ_count); + + equ_count++; + if (var_def_cnt != 0) + { + vdas.Add(pc); + } + else + { + as.Add(pc); + } + } + + pc = chunk_get_next(pc); + } + + as.End(); + vdas.End(); + + if (pc != NULL) + { + LOG_FMT(LALASS, "%s: done on %.*s on line %d\n", + __func__, pc->len, pc->str, pc->orig_line); + } + else + { + LOG_FMT(LALASS, "%s: done on NULL\n", __func__); + } + + return(pc); +} + + +/** + * Counts how many '*' pointers are in a row, going backwards + * + * @param pc Pointer to the last '*' in the series + * @return The count, including the current one + */ +int count_prev_ptr_type(chunk_t *pc) +{ + int count = 0; + + while ((pc != NULL) && (pc->type == CT_PTR_TYPE)) + { + count++; + pc = chunk_get_prev_nc(pc); + } + return(count); +} + + +static chunk_t *align_func_param(chunk_t *start) +{ + AlignStack as; + chunk_t *pc = start; + + as.Start(2, 0); + + as.m_star_style = (AlignStack::StarStyle)cpd.settings[UO_align_var_def_star_style].n; + as.m_amp_style = (AlignStack::StarStyle)cpd.settings[UO_align_var_def_amp_style].n; + + bool did_this_line = false; + int comma_count = 0; + int chunk_count = 0; + + while ((pc = chunk_get_next(pc)) != NULL) + { + chunk_count++; + if (chunk_is_newline(pc)) + { + did_this_line = false; + comma_count = 0; + chunk_count = 0; + } + else if (pc->level <= start->level) + { + break; + } + else if (!did_this_line && (pc->flags & PCF_VAR_DEF)) + { + if (chunk_count > 1) + { + as.Add(pc); + } + did_this_line = true; + } + else if (comma_count > 0) + { + if (!chunk_is_comment(pc)) + { + comma_count = 2; + break; + } + } + else if (pc->type == CT_COMMA) + { + comma_count++; + } + } + + if (comma_count <= 1) + { + as.End(); + } + + return(pc); +} + + +static void align_func_params() +{ + chunk_t *pc; + + pc = chunk_get_head(); + while ((pc = chunk_get_next(pc)) != NULL) + { + if ((pc->type != CT_FPAREN_OPEN) || + ((pc->parent_type != CT_FUNC_PROTO) && + (pc->parent_type != CT_FUNC_DEF) && + (pc->parent_type != CT_FUNC_CLASS) && + (pc->parent_type != CT_TYPEDEF))) + { + continue; + } + + /* We're on a open paren of a prototype */ + pc = align_func_param(pc); + } +} + + +static int align_params(chunk_t *start, chunk_t *chunks[], int num_chunks) +{ + int count = 0; + chunk_t *pc = start; + bool hit_comma = true; + + pc = chunk_get_next_type(start, CT_FPAREN_OPEN, start->level); + + while ((pc = chunk_get_next(pc)) != NULL) + { + if (chunk_is_newline(pc) || + (count >= num_chunks) || + (pc->type == CT_SEMICOLON) || + ((pc->type == CT_FPAREN_CLOSE) && (pc->level == start->level))) + { + break; + } + + if (pc->level == (start->level + 1)) + { + if (hit_comma) + { + chunks[count++] = pc; + hit_comma = false; + } + else if (pc->type == CT_COMMA) + { + hit_comma = true; + } + } + } + return(count); +} + + +static void align_same_func_call_params() +{ + chunk_t *pc; + chunk_t *align_root = NULL; + chunk_t *align_cur = NULL; + int align_len = 0; + chunk_t *chunks[16]; + AlignStack as[16]; + AlignStack fcn_as; + int max_idx = -1; + int cur_as; + int idx; + const char *add_str = NULL; + + fcn_as.Start(3); + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type != CT_FUNC_CALL) + { + if (chunk_is_newline(pc)) + { + for (idx = 0; idx <= max_idx; idx++) + { + as[idx].NewLines(pc->nl_count); + } + fcn_as.NewLines(pc->nl_count); + } + continue; + } + + fcn_as.Add(pc); + add_str = NULL; + + if (align_root != NULL) + { + if ((pc->len == align_root->len) && + (memcmp(pc->str, align_root->str, pc->len) == 0)) + { + align_cur->align.next = pc; + align_cur = pc; + align_len++; + add_str = " Add"; + } + else + { + LOG_FMT(LASFCP, " ++ Ended with %d fcns\n", align_len); + + /* Flush it all! */ + fcn_as.Flush(); + for (idx = 0; idx <= max_idx; idx++) + { + as[idx].Flush(); + } + align_root = NULL; + } + } + if (align_root == NULL) + { + align_root = pc; + align_cur = pc; + align_len = 1; + add_str = "Start"; + } + + if (add_str != NULL) + { + LOG_FMT(LASFCP, "%s '%.*s' on line %d -", + add_str, pc->len, pc->str, pc->orig_line); + cur_as = align_params(pc, chunks, ARRAY_SIZE(chunks)); + LOG_FMT(LASFCP, " %d items:", cur_as); + + for (idx = 0; idx < cur_as; idx++) + { + LOG_FMT(LASFCP, " [%.*s]", chunks[idx]->len, chunks[idx]->str); + if (idx > max_idx) + { + as[idx].Start(3); + if (!cpd.settings[UO_align_number_left].b) + { + if ((chunks[idx]->type == CT_NUMBER_FP) || + (chunks[idx]->type == CT_NUMBER) || + (chunks[idx]->type == CT_POS) || + (chunks[idx]->type == CT_NEG)) + { + as[idx].m_right_align = true; + } + } + max_idx = idx; + } + as[idx].Add(chunks[idx]); + } + LOG_FMT(LASFCP, "\n"); + } + } + fcn_as.End(); + for (idx = 0; idx <= max_idx; idx++) + { + as[idx].End(); + } +} + + +/** + * Aligns all function prototypes in the file. + */ +static void align_func_proto(int span) +{ + chunk_t *pc; + bool look_bro = false; + AlignStack as; + AlignStack as_br; + + LOG_FMT(LALIGN, "%s\n", __func__); + as.Start(span, 0); + as.m_gap = cpd.settings[UO_align_func_proto_gap].n; + + as_br.Start(span, 0); + as_br.m_gap = cpd.settings[UO_align_single_line_brace_gap].n; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (chunk_is_newline(pc)) + { + look_bro = false; + as.NewLines(pc->nl_count); + as_br.NewLines(pc->nl_count); + } + else if ((pc->type == CT_FUNC_PROTO) || + ((pc->type == CT_FUNC_DEF) && + cpd.settings[UO_align_single_line_func].b)) + { + if ((pc->parent_type == CT_OPERATOR) && + cpd.settings[UO_align_on_operator].b) + { + as.Add(chunk_get_prev_ncnl(pc)); + } + else + { + as.Add(pc); + } + look_bro = (pc->type == CT_FUNC_DEF) && + cpd.settings[UO_align_single_line_brace].b; + } + else if (look_bro && + (pc->type == CT_BRACE_OPEN) && + (pc->flags & PCF_ONE_LINER)) + { + as_br.Add(pc); + look_bro = false; + } + } + as.End(); + as_br.End(); +} + + +/** + * Scan everything at the current level until the close brace and find the + * variable def align column. Also aligns bit-colons, but that assumes that + * bit-types are the same! But that should always be the case... + */ +static chunk_t *align_var_def_brace(chunk_t *start, int span, int *p_nl_count) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + int align_mask = PCF_IN_FCN_DEF | PCF_VAR_1ST; + int myspan = span; + int mythresh = 0; + int mygap = 0; + AlignStack as; /* var/proto/def */ + AlignStack as_bc; /* bit-colon */ + AlignStack as_at; /* attribute */ + AlignStack as_br; /* one-liner brace open */ + bool fp_active = cpd.settings[UO_align_mix_var_proto].b; + bool fp_look_bro = false; + + + if (start == NULL) + { + return(NULL); + } + + /* Override the span, if this is a struct/union */ + if ((start->parent_type == CT_STRUCT) || + (start->parent_type == CT_UNION)) + { + myspan = cpd.settings[UO_align_var_struct_span].n; + mythresh = cpd.settings[UO_align_var_struct_thresh].n; + mygap = cpd.settings[UO_align_var_struct_gap].n; + } + else + { + mythresh = cpd.settings[UO_align_var_def_thresh].n; + mygap = cpd.settings[UO_align_var_def_gap].n; + } + + /* can't be any variable definitions in a "= {" block */ + prev = chunk_get_prev_ncnl(start); + if ((prev != NULL) && (prev->type == CT_ASSIGN)) + { + LOG_FMT(LAVDB, "%s: start=%.*s [%s] on line %d (abort due to assign)\n", __func__, + start->len, start->str, get_token_name(start->type), start->orig_line); + + pc = chunk_get_next_type(start, CT_BRACE_CLOSE, start->level); + return(chunk_get_next_ncnl(pc)); + } + + LOG_FMT(LAVDB, "%s: start=%.*s [%s] on line %d\n", __func__, + start->len, start->str, get_token_name(start->type), start->orig_line); + + if (!cpd.settings[UO_align_var_def_inline].b) + { + align_mask |= PCF_VAR_INLINE; + } + + /* Set up the var/proto/def aligner */ + as.Start(myspan, mythresh); + as.m_gap = mygap; + as.m_star_style = (AlignStack::StarStyle)cpd.settings[UO_align_var_def_star_style].n; + as.m_amp_style = (AlignStack::StarStyle)cpd.settings[UO_align_var_def_amp_style].n; + + /* Set up the bit colon aligner */ + as_bc.Start(myspan, 0); + as_bc.m_gap = cpd.settings[UO_align_var_def_colon_gap].n; + + as_at.Start(myspan, 0); + + /* Set up the brace open aligner */ + as_br.Start(myspan, mythresh); + as_br.m_gap = cpd.settings[UO_align_single_line_brace_gap].n; + + bool did_this_line = false; + pc = chunk_get_next(start); + while ((pc != NULL) && ((pc->level >= start->level) || (pc->level == 0))) + { + if (chunk_is_comment(pc)) + { + if (pc->nl_count > 0) + { + as.NewLines(pc->nl_count); + as_bc.NewLines(pc->nl_count); + as_at.NewLines(pc->nl_count); + as_br.NewLines(pc->nl_count); + } + pc = chunk_get_next(pc); + continue; + } + + if (fp_active) + { + if ((pc->type == CT_FUNC_PROTO) || + ((pc->type == CT_FUNC_DEF) && + cpd.settings[UO_align_single_line_func].b)) + { + LOG_FMT(LAVDB, " add=[%.*s] line=%d col=%d level=%d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col, pc->level); + + as.Add(pc); + fp_look_bro = (pc->type == CT_FUNC_DEF) && + cpd.settings[UO_align_single_line_brace].b; + } + else if (fp_look_bro && + (pc->type == CT_BRACE_OPEN) && + (pc->flags & PCF_ONE_LINER)) + { + as_br.Add(pc); + fp_look_bro = false; + } + } + + /* process nested braces */ + if (pc->type == CT_BRACE_OPEN) + { + int sub_nl_count = 0; + + pc = align_var_def_brace(pc, span, &sub_nl_count); + if (sub_nl_count > 0) + { + fp_look_bro = false; + did_this_line = false; + as.NewLines(sub_nl_count); + as_bc.NewLines(sub_nl_count); + as_at.NewLines(sub_nl_count); + as_br.NewLines(sub_nl_count); + if (p_nl_count != NULL) + { + *p_nl_count += sub_nl_count; + } + } + continue; + } + + /* Done with this brace set? */ + if (pc->type == CT_BRACE_CLOSE) + { + pc = chunk_get_next(pc); + break; + } + + if (chunk_is_newline(pc)) + { + fp_look_bro = false; + did_this_line = false; + as.NewLines(pc->nl_count); + as_bc.NewLines(pc->nl_count); + as_at.NewLines(pc->nl_count); + as_br.NewLines(pc->nl_count); + if (p_nl_count != NULL) + { + *p_nl_count += pc->nl_count; + } + } + + /* don't align stuff inside parens/squares/angles */ + if (pc->level > pc->brace_level) + { + pc = chunk_get_next(pc); + continue; + } + + /* If this is a variable def, update the max_col */ + if ((pc->type != CT_FUNC_CLASS) && + ((pc->flags & align_mask) == PCF_VAR_1ST) && + ((pc->level == (start->level + 1)) || + (pc->level == 0))) + { + if (!did_this_line) + { + LOG_FMT(LAVDB, " add=[%.*s] line=%d col=%d level=%d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col, pc->level); + + as.Add(pc); + + if (cpd.settings[UO_align_var_def_colon].b) + { + next = chunk_get_next_nc(pc); + if (next->type == CT_BIT_COLON) + { + as_bc.Add(next); + } + } + if (cpd.settings[UO_align_var_def_attribute].b) + { + next = pc; + while ((next = chunk_get_next_nc(next)) != NULL) + { + if (next->type == CT_ATTRIBUTE) + { + as_at.Add(next); + break; + } + if ((next->type == CT_SEMICOLON) || chunk_is_newline(next)) + { + break; + } + } + } + } + did_this_line = true; + } + if (pc->type == CT_BIT_COLON) + { + if (!did_this_line) + { + as_bc.Add(pc); + did_this_line = true; + } + } + pc = chunk_get_next(pc); + } + + as.End(); + as_bc.End(); + as_at.End(); + as_br.End(); + + return(pc); +} + + +/** + * For a series of lines ending in backslash-newline, align them. + * The series ends when a newline or multi-line C comment is encountered. + * + * @param start Start point + * @return pointer the last item looked at (NULL/newline/comment) + */ +chunk_t *align_nl_cont(chunk_t *start) +{ + int max_col = 0; + chunk_t *pc = start; + chunk_t *tmp; + ChunkStack cs; + + LOG_FMT(LALNLC, "%s: start on [%s] on line %d\n", __func__, + get_token_name(start->type), start->orig_line); + + /* Find the max column */ + while ((pc != NULL) && + (pc->type != CT_NEWLINE) && + (pc->type != CT_COMMENT_MULTI)) + { + if (pc->type == CT_NL_CONT) + { + align_add(cs, pc, max_col, 1, true); + } + pc = chunk_get_next(pc); + } + + /* shift out to the next tabstop */ + max_col = align_tab_column(max_col); + + /* NL_CONT is always the last thing on a line */ + while ((tmp = cs.Pop()) != NULL) + { + tmp->flags |= PCF_WAS_ALIGNED; + tmp->column = max_col; + } + + return(pc); +} + + +enum CmtAlignType +{ + CAT_REGULAR, + CAT_BRACE, + CAT_ENDIF, +}; + +static CmtAlignType get_comment_align_type(chunk_t *cmt) +{ + chunk_t *prev; + CmtAlignType cmt_type = CAT_REGULAR; + + if (!cpd.settings[UO_align_right_cmt_mix].b && + ((prev = chunk_get_prev(cmt)) != NULL)) + { + if ((prev->type == CT_PP_ENDIF) || + (prev->type == CT_PP_ELSE) || + (prev->type == CT_BRACE_CLOSE)) + { + /* REVISIT: someone may want this configurable */ + if ((cmt->column - (prev->column + prev->len)) < 3) + { + cmt_type = (prev->type == CT_PP_ENDIF) ? CAT_ENDIF : CAT_BRACE; + } + } + } + return(cmt_type); +} + + +/** + * For a series of lines ending in a comment, align them. + * The series ends when more than align_right_cmt_span newlines are found. + * + * @param start Start point + * @return pointer the last item looked at + */ +chunk_t *align_trailing_comments(chunk_t *start) +{ + int max_col = 0; + chunk_t *pc = start; + int nl_count = 0; + ChunkStack cs; + CmtAlignType cmt_type_start, cmt_type_cur; + int col; + int intended_col = cpd.settings[UO_align_right_cmt_at_col].n; + + cmt_type_start = get_comment_align_type(pc); + + /* Find the max column */ + while ((pc != NULL) && (nl_count < cpd.settings[UO_align_right_cmt_span].n)) + { + if ((pc->flags & PCF_RIGHT_COMMENT) != 0) + { + cmt_type_cur = get_comment_align_type(pc); + + if (cmt_type_cur == cmt_type_start) + { + col = 1 + (pc->brace_level * cpd.settings[UO_indent_columns].n); + LOG_FMT(LALADD, "%s: col=%d max_col=%d pc->col=%d pc->len=%d %s\n", + __func__, col, max_col, pc->column, pc->len, get_token_name(pc->type)); + if (pc->column < col) + { + pc->column = col; + } + if (pc->column < intended_col) + { + pc->column = intended_col; + } + align_add(cs, pc, max_col, 1, (intended_col != 0)); + nl_count = 0; + } + } + if (chunk_is_newline(pc)) + { + nl_count += pc->nl_count; + } + pc = chunk_get_next(pc); + } + + align_stack(cs, max_col, (intended_col != 0), LALTC); + + return(chunk_get_next(pc)); +} + + +/** + * Shifts out all columns by a certain amount. + * + * @param idx The index to start shifting + * @param num The number of columns to shift + */ +void ib_shift_out(int idx, int num) +{ + while (idx < cpd.al_cnt) + { + cpd.al[idx].col += num; + idx++; + } +} + + +/** + * Scans a line for stuff to align on. + * + * We trigger on BRACE_OPEN, FPAREN_OPEN, ASSIGN, and COMMA. + * We want to align the NEXT item. + */ +static chunk_t *scan_ib_line(chunk_t *start, bool first_pass) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev_match = NULL; + int token_width; + int idx = 0; + bool last_was_comment = false; + + /* Skip past C99 "[xx] =" stuff */ + if (start->type == CT_SQUARE_OPEN) + { + start->parent_type = CT_TSQUARE; + start = chunk_get_next_type(start, CT_ASSIGN, start->level); + start = chunk_get_next_ncnl(start); + cpd.al_c99_array = true; + } + pc = start; + + if (pc != NULL) + { + LOG_FMT(LSIB, "%s: start=%s col %d/%d line %d\n", __func__, + get_token_name(pc->type), pc->column, pc->orig_col, pc->orig_line); + } + + while ((pc != NULL) && !chunk_is_newline(pc) && + (pc->level >= start->level)) + { + //LOG_FMT(LSIB, "%s: '%.*s' col %d/%d line %d\n", __func__, + // pc->len, pc->str, pc->column, pc->orig_col, pc->orig_line); + + next = chunk_get_next(pc); + if ((next == NULL) || chunk_is_comment(next)) + { + /* do nothing */ + } + else if ((pc->type == CT_ASSIGN) || + (pc->type == CT_BRACE_OPEN) || + (pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_COMMA)) + { + token_width = space_col_align(pc, next); + + /*TODO: need to handle missing structure defs? ie NULL vs { ... } ?? */ + + /* Is this a new entry? */ + if (idx >= cpd.al_cnt) + { + LOG_FMT(LSIB, " - New [%d] %.2d/%d - %10.10s\n", idx, + pc->column, token_width, get_token_name(pc->type)); + + cpd.al[cpd.al_cnt].type = pc->type; + cpd.al[cpd.al_cnt].col = pc->column; + cpd.al[cpd.al_cnt].len = token_width; + cpd.al_cnt++; + idx++; + last_was_comment = false; + } + else + { + /* expect to match stuff */ + if (cpd.al[idx].type == pc->type) + { + LOG_FMT(LSIB, " - Match [%d] %.2d/%d - %10.10s", idx, + pc->column, token_width, get_token_name(pc->type)); + + /* Shift out based on column */ + if (prev_match == NULL) + { + if (pc->column > cpd.al[idx].col) + { + LOG_FMT(LSIB, " [ pc->col(%d) > col(%d) ] ", + pc->column, cpd.al[idx].col); + + ib_shift_out(idx, pc->column - cpd.al[idx].col); + cpd.al[idx].col = pc->column; + } + } + else if (idx > 0) + { + int min_col_diff = pc->column - prev_match->column; + int cur_col_diff = cpd.al[idx].col - cpd.al[idx - 1].col; + if (cur_col_diff < min_col_diff) + { + LOG_FMT(LSIB, " [ min_col_diff(%d) > cur_col_diff(%d) ] ", + min_col_diff, cur_col_diff); + ib_shift_out(idx, min_col_diff - cur_col_diff); + } + } + LOG_FMT(LSIB, " - now col %d, len %d\n", cpd.al[idx].col, cpd.al[idx].len); + idx++; + } + } + prev_match = pc; + } + last_was_comment = chunk_is_comment(pc); + pc = chunk_get_next_nc(pc); + } + + //if (last_was_comment && (cpd.al[cpd.al_cnt - 1].type == CT_COMMA)) + //{ + // cpd.al_cnt--; + //} + return(pc); +} + + +static void align_log_al(log_sev_t sev, int line) +{ + int idx; + + if (log_sev_on(sev)) + { + log_fmt(sev, "%s: line %d, %d)", __func__, line, cpd.al_cnt); + for (idx = 0; idx < cpd.al_cnt; idx++) + { + log_fmt(sev, " %d/%d=%s", cpd.al[idx].col, cpd.al[idx].len, + get_token_name(cpd.al[idx].type)); + } + log_fmt(sev, "\n"); + } +} + + +/** + * Generically aligns on '=', '{', '(' and item after ',' + * It scans the first line and picks up the location of those tags. + * It then scans subsequent lines and adjusts the column. + * Finally it does a second pass to align everything. + * + * Aligns all the '=' signs in stucture assignments. + * a = { + * .a = 1; + * .type = fast; + * }; + * + * And aligns on '{', numbers, strings, words. + * colors[] = { + * {"red", {255, 0, 0}}, {"blue", { 0, 255, 0}}, + * {"green", { 0, 0, 255}}, {"purple", {255, 255, 0}}, + * }; + * + * For the C99 indexed array assignment, the leading []= is skipped (no aligning) + * struct foo_t bars[] = + * { + * [0] = { .name = "bar", + * .age = 21 }, + * [1] = { .name = "barley", + * .age = 55 }, + * }; + * + * NOTE: this assumes that spacing is at the minimum correct spacing (ie force) + * if it isn't, some extra spaces will be inserted. + * + * @param start Points to the open brace chunk + */ +static void align_init_brace(chunk_t *start) +{ + int idx; + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + chunk_t *num_token = NULL; + + cpd.al_cnt = 0; + cpd.al_c99_array = false; + + LOG_FMT(LALBR, "%s: line %d, col %d\n", __func__, start->orig_line, start->orig_col); + + pc = chunk_get_next_ncnl(start); + pc = scan_ib_line(pc, true); + if ((pc == NULL) || ((pc->type == CT_BRACE_CLOSE) && + (pc->parent_type == CT_ASSIGN))) + { + /* single line - nothing to do */ + return; + } + + do + { + pc = scan_ib_line(pc, false); + + /* debug dump the current frame */ + align_log_al(LALBR, pc->orig_line); + + while (chunk_is_newline(pc)) + { + pc = chunk_get_next(pc); + } + } while ((pc != NULL) && (pc->level > start->level)); + + /* debug dump the current frame */ + align_log_al(LALBR, start->orig_line); + + if (cpd.settings[UO_align_on_tabstop].b && (cpd.al_cnt >= 1) && + (cpd.al[0].type == CT_ASSIGN)) + { + int rem = (cpd.al[0].col - 1) % cpd.settings[UO_output_tab_size].n; + if (rem != 0) + { + LOG_FMT(LALBR, "%s: col=%d rem=%d", __func__, cpd.al[0].col, rem); + cpd.al[0].col += cpd.settings[UO_output_tab_size].n - rem; + } + } + + pc = chunk_get_next(start); + idx = 0; + do + { + if ((idx == 0) && (pc->type == CT_SQUARE_OPEN)) + { + pc = chunk_get_next_type(pc, CT_ASSIGN, pc->level); + pc = chunk_get_next(pc); + if (pc != NULL) + { + LOG_FMT(LALBR, " -%d- skipped '[] =' to %s\n", + pc->orig_line, get_token_name(pc->type)); + } + continue; + } + + next = pc; + if (idx < cpd.al_cnt) + { + LOG_FMT(LALBR, " (%d) check %s vs %s -- ", + idx, get_token_name(pc->type), get_token_name(cpd.al[idx].type)); + if (pc->type == cpd.al[idx].type) + { + if ((idx == 0) && cpd.al_c99_array) + { + prev = chunk_get_prev(pc); + if (chunk_is_newline(prev)) + { + pc->flags |= PCF_DONT_INDENT; + } + } + LOG_FMT(LALBR, " [%.*s] to col %d\n", pc->len, pc->str, cpd.al[idx].col); + + if (num_token != NULL) + { + int col_diff = pc->column - num_token->column; + + reindent_line(num_token, cpd.al[idx].col - col_diff); + //LOG_FMT(LSYS, "-= %d =- NUM indent [%.*s] col=%d diff=%d\n", + // num_token->orig_line, + // num_token->len, num_token->str, cpd.al[idx - 1].col, col_diff); + + num_token->flags |= PCF_WAS_ALIGNED; + num_token = NULL; + } + + /* Comma's need to 'fall back' to the previous token */ + if (pc->type == CT_COMMA) + { + next = chunk_get_next(pc); + if ((next != NULL) && !chunk_is_newline(next)) + { + //LOG_FMT(LSYS, "-= %d =- indent [%.*s] col=%d len=%d\n", + // next->orig_line, + // next->len, next->str, cpd.al[idx].col, cpd.al[idx].len); + + if ((idx < (cpd.al_cnt - 1)) && + cpd.settings[UO_align_number_left].b && + ((next->type == CT_NUMBER_FP) || + (next->type == CT_NUMBER) || + (next->type == CT_POS) || + (next->type == CT_NEG))) + { + /* Need to wait until the next match to indent numbers */ + num_token = next; + } + else + { + reindent_line(next, cpd.al[idx].col + cpd.al[idx].len); + next->flags |= PCF_WAS_ALIGNED; + } + } + } + else + { + /* first item on the line */ + reindent_line(pc, cpd.al[idx].col); + pc->flags |= PCF_WAS_ALIGNED; + + /* see if we need to right-align a number */ + if ((idx < (cpd.al_cnt - 1)) && + cpd.settings[UO_align_number_left].b) + { + next = chunk_get_next(pc); + if ((next != NULL) && !chunk_is_newline(next) && + ((next->type == CT_NUMBER_FP) || + (next->type == CT_NUMBER) || + (next->type == CT_POS) || + (next->type == CT_NEG))) + { + /* Need to wait until the next match to indent numbers */ + num_token = next; + } + } + } + idx++; + } + else + { + LOG_FMT(LALBR, " no match\n"); + } + } + if (chunk_is_newline(pc) || chunk_is_newline(next)) + { + idx = 0; + } + pc = chunk_get_next(pc); + } while ((pc != NULL) && (pc->level > start->level)); +} + + +/** + * Aligns simple typedefs that are contained on a single line each. + * This should be called after the typedef target is marked as a type. + * + * Won't align function typedefs. + * + * typedef int foo_t; + * typedef char bar_t; + * typedef const char cc_t; + */ +static void align_typedefs(int span) +{ + chunk_t *pc; + chunk_t *c_type = NULL; + chunk_t *c_typedef = NULL; + AlignStack as; + + as.Start(span); + as.m_gap = cpd.settings[UO_align_typedef_gap].n; + as.m_star_style = (AlignStack::StarStyle)cpd.settings[UO_align_typedef_star_style].n; + as.m_amp_style = (AlignStack::StarStyle)cpd.settings[UO_align_typedef_amp_style].n; + + pc = chunk_get_head(); + while (pc != NULL) + { + if (chunk_is_newline(pc)) + { + as.NewLines(pc->nl_count); + c_typedef = NULL; + } + else if (c_typedef != NULL) + { + if (pc->flags & PCF_ANCHOR) + { + as.Add(pc); + c_typedef = NULL; + } + } + else + { + if (pc->type == CT_TYPEDEF) + { + LOG_FMT(LALTD, "%s: line %d, col %d\n", + __func__, pc->orig_line, pc->orig_col); + c_typedef = pc; + c_type = NULL; + } + } + + pc = chunk_get_next(pc); + } + + as.End(); +} + +/** + * Align '<<' (CT_ARITH?) + */ +static void align_left_shift(void) +{ + chunk_t *pc; + AlignStack as; + bool skip_stmt = false; + + as.Start(2); + + pc = chunk_get_head(); + while (pc != NULL) + { + if (chunk_is_newline(pc)) + { + as.NewLines(pc->nl_count); + skip_stmt = as.m_aligned.Empty(); + } + else if (pc->flags & PCF_STMT_START) + { + as.Reset(); + skip_stmt = false; + } + else if (pc->type == CT_SEMICOLON) + { + as.Flush(); + } + else if (!skip_stmt && chunk_is_str(pc, "<<", 2)) + { + if (as.m_aligned.Empty()) + { + as.Add(pc); + } + else if (chunk_is_newline(chunk_get_prev(pc))) + { + as.Add(pc); + } + } + + pc = chunk_get_next(pc); + } + + if (skip_stmt) + { + as.Reset(); + } + else + { + as.End(); + } +} + +/** + * Aligns OC message + */ +static void align_oc_msg_colon(void) +{ + chunk_t *pc = chunk_get_head(); + chunk_t *tmp; + AlignStack cas; /* for the colons */ + AlignStack nas; /* for the parameter tag */ + int level; + bool did_line; + + while (pc != NULL) + { + if ((pc->type != CT_SQUARE_OPEN) || (pc->parent_type != CT_OC_MSG)) + { + pc = chunk_get_next(pc); + continue; + } + + cas.Reset(); + nas.Reset(); + nas.m_right_align = true; + + level = pc->level; + pc = chunk_get_next_ncnl(pc, CNAV_PREPROC); + did_line = false; + while ((pc != NULL) && (pc->level > level)) + { + if (chunk_is_newline(pc)) + { + did_line = false; + } + else if (!did_line && (pc->type == CT_OC_COLON)) + { + cas.Add(pc); + tmp = chunk_get_prev(pc); + if ((tmp != NULL) && ((tmp->type == CT_WORD) || (tmp->type == CT_TYPE))) + { + nas.Add(tmp); + } + did_line = true; + } + pc = chunk_get_next(pc, CNAV_PREPROC); + } + nas.End(); + cas.End(); + } +} diff --git a/src/align_stack.cpp b/src/align_stack.cpp new file mode 100644 index 0000000000..4bb927dbe5 --- /dev/null +++ b/src/align_stack.cpp @@ -0,0 +1,467 @@ +/** + * @file align_stack.cpp + * Manages a align stack, which is just a pair of chunk stacks. + * There can be at most 1 item per line in the stack. + * The seqnum is actually a line counter. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "align_stack.h" +#include "prototypes.h" +#include "chunk_list.h" + +/** + * Resets the two ChunkLists and zeroes local vars. + * + * @param span The row span limit + * @param thresh The column threshold + */ +void AlignStack::Start(int span, int thresh) +{ + LOG_FMT(LAS, "Start(%d, %d)\n", span, thresh); + + m_aligned.Reset(); + m_skipped.Reset(); + m_span = span; + m_thresh = thresh; + m_min_col = 9999; + m_max_col = 0; + m_nl_seqnum = 0; + m_seqnum = 0; + m_gap = 0; + m_right_align = false; + m_star_style = SS_IGNORE; + m_amp_style = SS_IGNORE; +} + + +/** + * Calls Add on all the skipped items + */ +void AlignStack::ReAddSkipped() +{ + if (!m_skipped.Empty()) + { + /* Make a copy of the ChunkStack and clear m_skipped */ + m_scratch.Set(m_skipped); + m_skipped.Reset(); + + const ChunkStack::Entry *ce; + + /* Need to add them in order so that m_nl_seqnum is correct */ + for (int idx = 0; idx < m_scratch.Len(); idx++) + { + ce = m_scratch.Get(idx); + LOG_FMT(LAS, "ReAddSkipped [%d] - ", ce->m_seqnum); + Add(ce->m_pc, ce->m_seqnum); + } + + /* Check to see if we need to flush right away */ + NewLines(0); + } +} + + +/** + * Adds an entry to the appropriate stack. + * + * @param pc The chunk + * @param seqnum Optional seqnum (0=assign one) + */ +void AlignStack::Add(chunk_t *start, int seqnum) +{ + /* Assign a seqnum if needed */ + if (seqnum == 0) + { + seqnum = m_seqnum; + } + + chunk_t *ali; + chunk_t *ref; + chunk_t *tmp; + chunk_t *prev; + chunk_t *next; + + int col_adj = 0; /* Amount the column is shifted for 'dangle' mode */ + int tmp_col; + int endcol; + int gap; + + m_last_added = 0; + + /* Check threshold limits */ + if ((m_max_col == 0) || (m_thresh == 0) || + (((start->column + m_gap) <= (m_max_col + m_thresh)) && + (((start->column + m_gap) >= (m_max_col - m_thresh)) || + (start->column >= m_min_col)))) + { + /* we are adding it, so update the newline seqnum */ + if (seqnum > m_nl_seqnum) + { + m_nl_seqnum = seqnum; + } + + /** + * SS_IGNORE: no special handling of '*' or '&', only 'foo' is aligned + * void foo; // gap=5, 'foo' is aligned + * char * foo; // gap=3, 'foo' is aligned + * foomatic foo; // gap=1, 'foo' is aligned + * The gap is the columns between 'foo' and the previous token. + * [void - foo], ['*' - foo], etc + * + * SS_INCLUDE: - space between variable and '*' or '&' is eaten + * void foo; // gap=5, 'foo' is aligned + * char *foo; // gap=5, '*' is aligned + * foomatic foo; // gap=1, 'foo' is aligned + * The gap is the columns between the first '*' or '&' before foo + * and the previous token. [void - foo], [char - '*'], etc + * + * SS_DANGLE: - space between variable and '*' or '&' is eaten + * void foo; // gap=5 + * char *bar; // gap=5, as the '*' doesn't count + * foomatic foo; // gap=1 + * The gap is the columns between 'foo' and the chunk before the first + * '*' or '&'. [void - foo], [char - bar], etc + * + * If the gap < m_gap, then the column is bumped out by the difference. + * So, if m_gap is 2, then the above would be: + * SS_IGNORE: + * void foo; // gap=6 + * char * foo; // gap=4 + * foomatic foo; // gap=2 + * SS_INCLUDE: + * void foo; // gap=6 + * char *foo; // gap=6 + * foomatic foo; // gap=2 + * SS_DANGLE: + * void foo; // gap=6 + * char *bar; // gap=6, as the '*' doesn't count + * foomatic foo; // gap=2 + * Right aligned numbers: + * #define A -1 + * #define B 631 + * #define C 3 + * Left aligned numbers: + * #define A -1 + * #define B 631 + * #define C 3 + * + * In the code below, pc is set to the item that is aligned. + * In the above examples, that is 'foo', '*', '-', or 63. + * + * Ref is set to the last part of the type. + * In the above examples, that is 'void', 'char', 'foomatic', 'A', or 'B'. + * + * The '*' and '&' can float between the two. + */ + + /* Find ref. Back up to the real item that is aligned. */ + prev = start; + while (((prev = chunk_get_prev(prev)) != NULL) && + (chunk_is_star(prev) || + chunk_is_addr(prev) || + (chunk_is_str(prev, "(", 1) && (prev->parent_type == CT_TYPEDEF)))) + { + /* do nothing - we want prev when this exits */ + } + ref = prev; + if (chunk_is_newline(ref)) + { + ref = chunk_get_next(ref); + } + + /* Find the item that we are going to align. */ + ali = start; + if (m_star_style != SS_IGNORE) + { + /* back up to the first '*' preceding the token */ + prev = chunk_get_prev(ali); + while (chunk_is_star(prev)) + { + ali = prev; + prev = chunk_get_prev(ali); + } + if (chunk_is_str(prev, "(", 1) && (prev->parent_type == CT_TYPEDEF)) + { + ali = prev; + prev = chunk_get_prev(ali); + } + } + if (m_amp_style != SS_IGNORE) + { + /* back up to the first '&' preceding the token */ + prev = chunk_get_prev(ali); + while (chunk_is_addr(prev)) + { + ali = prev; + prev = chunk_get_prev(ali); + } + } + + /* Tighten down the spacing between ref and start */ + tmp_col = ref->column; + tmp = ref; + while (tmp != start) + { + next = chunk_get_next(tmp); + tmp_col += space_col_align(tmp, next); + if (next->column != tmp_col) + { + align_to_column(next, tmp_col); + } + tmp = next; + } + + /* Set the column adjust and gap */ + col_adj = 0; + gap = 0; + if (ref != ali) + { + gap = ali->column - (ref->column + ref->len); + } + tmp = ali; + if (chunk_is_str(tmp, "(", 1) && (tmp->parent_type == CT_TYPEDEF)) + { + tmp = chunk_get_next(tmp); + } + if ((chunk_is_star(tmp) && (m_star_style == SS_DANGLE)) || + (chunk_is_addr(tmp) && (m_amp_style == SS_DANGLE))) + { + col_adj = start->column - ali->column; + gap = start->column - (ref->column + ref->len); + } + + /* See if this pushes out the max_col */ + endcol = ali->column + col_adj; + if (gap < m_gap) + { + endcol += m_gap - gap; + } + + // LOG_FMT(LSYS, "[%p] line %d pc='%.*s' [%s] col:%d ali='%.*s' [%s] col:%d ref='%.*s' [%s] col:%d col_adj=%d endcol=%d, ss=%d as=%d, gap=%d\n", + // this, + // start->orig_line, + // start->len, start->str, get_token_name(start->type), start->column, + // ali->len, ali->str, get_token_name(ali->type), ali->column, + // ref->len, ref->str, get_token_name(ref->type), ref->column, + // col_adj, endcol, m_star_style, m_amp_style, gap); + + ali->align.col_adj = col_adj; + ali->align.ref = ref; + ali->align.start = start; + m_aligned.Push(ali, seqnum); + m_last_added = 1; + + LOG_FMT(LAS, "Add-[%.*s]: line %d, col %d, adj %d : ref=[%.*s] endcol=%d\n", + ali->len, ali->str, ali->orig_line, ali->column, ali->align.col_adj, + ref->len, ref->str, endcol); + + if (m_min_col > endcol) + { + m_min_col = endcol; + } + + if (endcol > m_max_col) + { + LOG_FMT(LAS, "Add-aligned [%d/%d/%d]: line %d, col %d : max_col old %d, new %d - min_col %d\n", + seqnum, m_nl_seqnum, m_seqnum, + ali->orig_line, ali->column, m_max_col, endcol, m_min_col); + m_max_col = endcol; + + /** + * If there were any entries that were skipped, re-add them as they + * may now be within the threshold + */ + if (!m_skipped.Empty()) + { + ReAddSkipped(); + } + } + else + { + LOG_FMT(LAS, "Add-aligned [%d/%d/%d]: line %d, col %d : col %d <= %d - min_col %d\n", + seqnum, m_nl_seqnum, m_seqnum, + ali->orig_line, ali->column, endcol, m_max_col, m_min_col); + } + } + else + { + /* The threshold check failed, so add it to the skipped list */ + m_skipped.Push(start, seqnum); + m_last_added = 2; + + LOG_FMT(LAS, "Add-skipped [%d/%d/%d]: line %d, col %d <= %d + %d\n", + seqnum, m_nl_seqnum, m_seqnum, + start->orig_line, start->column, m_max_col, m_thresh); + } +} + + +/** + * Adds some newline and calls Flush() if needed + */ +void AlignStack::NewLines(int cnt) +{ + if (!m_aligned.Empty()) + { + m_seqnum += cnt; + if (m_seqnum > (m_nl_seqnum + m_span)) + { + LOG_FMT(LAS, "Newlines<%d>-", cnt); + Flush(); + } + else + { + LOG_FMT(LAS, "Newlines<%d>\n", cnt); + } + } +} + + +/** + * Aligns all the stuff in m_aligned. + * Re-adds 'newer' items in m_skipped. + */ +void AlignStack::Flush() +{ + int last_seqnum = 0; + int idx; + int tmp_col; + const ChunkStack::Entry *ce = NULL; + chunk_t *pc; + + LOG_FMT(LAS, "Flush (min=%d, max=%d)\n", m_min_col, m_max_col); + + m_last_added = 0; + m_max_col = 0; + + /* Recalculate the max_col - it may have shifted since the last Add() */ + for (idx = 0; idx < m_aligned.Len(); idx++) + { + pc = m_aligned.Get(idx)->m_pc; + + /* Set the column adjust and gap */ + int col_adj = 0; + int gap = 0; + if (pc != pc->align.ref) + { + gap = pc->column - (pc->align.ref->column + pc->align.ref->len); + } + chunk_t *tmp = pc; + if (chunk_is_str(tmp, "(", 1) && (tmp->parent_type == CT_TYPEDEF)) + { + tmp = chunk_get_next(tmp); + } + if ((chunk_is_star(tmp) && (m_star_style == SS_DANGLE)) || + (chunk_is_addr(tmp) && (m_amp_style == SS_DANGLE))) + { + col_adj = pc->align.start->column - pc->column; + gap = pc->align.start->column - (pc->align.ref->column + pc->align.ref->len); + } + if (m_right_align) + { + /* Adjust the width for signed numbers */ + int start_len = pc->align.start->len; + if (pc->align.start->type == CT_NEG) + { + tmp = chunk_get_next(pc->align.start); + if ((tmp != NULL) && (tmp->type == CT_NUMBER)) + { + start_len += tmp->len; + } + } + col_adj += start_len; + } + + pc->align.col_adj = col_adj; + + /* See if this pushes out the max_col */ + int endcol = pc->column + col_adj; + if (gap < m_gap) + { + endcol += m_gap - gap; + } + if (endcol > m_max_col) + { + m_max_col = endcol; + } + } + + for (idx = 0; idx < m_aligned.Len(); idx++) + { + ce = m_aligned.Get(idx); + pc = ce->m_pc; + if (idx == 0) + { + pc->flags |= PCF_ALIGN_START; + + pc->align.right_align = m_right_align; + pc->align.amp_style = (int)m_amp_style; + pc->align.star_style = (int)m_star_style; + pc->align.gap = m_gap; + } + pc->align.next = m_aligned.GetChunk(idx + 1); + + /* Indent the token, taking col_adj into account */ + tmp_col = m_max_col - pc->align.col_adj; + LOG_FMT(LAS, "%s: line %d: '%.*s' to col %d (adj=%d)\n", __func__, + pc->orig_line, pc->len, pc->str, tmp_col, pc->align.col_adj); + align_to_column(pc, tmp_col); + } + + if (ce != NULL) + { + last_seqnum = ce->m_seqnum; + m_aligned.Reset(); + } + m_min_col = 9999; + m_max_col = 0; + + if (m_skipped.Empty()) + { + /* Nothing was skipped, sync the seqnums */ + m_nl_seqnum = m_seqnum; + } + else + { + /* Remove all items with seqnum < last_seqnum */ + for (idx = 0; idx < m_skipped.Len(); idx++) + { + if (m_skipped.Get(idx)->m_seqnum < last_seqnum) + { + m_skipped.Zap(idx); + } + } + m_skipped.Collapse(); + + /* Add all items from the skipped list */ + ReAddSkipped(); + } +} + + +/** + * Resets the stack, discarding anything that was previously added + */ +void AlignStack::Reset() +{ + m_aligned.Reset(); + m_skipped.Reset(); +} + + +/** + * Aligns everything else and resets the lists. + */ +void AlignStack::End() +{ + if (!m_aligned.Empty()) + { + LOG_FMT(LAS, "End-"); + Flush(); + } + + m_aligned.Reset(); + m_skipped.Reset(); +} diff --git a/src/align_stack.h b/src/align_stack.h new file mode 100644 index 0000000000..458cf5d369 --- /dev/null +++ b/src/align_stack.h @@ -0,0 +1,61 @@ +/** + * @file align_stack.h + * Manages a align stack, which is just a pair of chunk stacks with a few + * fancy functions. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "ChunkStack.h" + +class AlignStack +{ +public: + enum StarStyle + { + SS_IGNORE, // don't look for prev stars + SS_INCLUDE, // include prev * before add + SS_DANGLE // include prev * after add + }; + + ChunkStack m_aligned; /* contains the token that is aligned */ + ChunkStack m_skipped; /* contains the tokens sent to Add() */ + int m_max_col; + int m_min_col; + int m_span; + int m_thresh; + int m_seqnum; + int m_nl_seqnum; + int m_gap; + bool m_right_align; + StarStyle m_star_style; + StarStyle m_amp_style; + + + AlignStack() : + m_max_col(0), m_min_col(0), m_span(0), m_thresh(0), m_seqnum(0), + m_nl_seqnum(0), m_gap(0), m_right_align(false), + m_star_style(SS_IGNORE), m_amp_style(SS_IGNORE), + m_last_added(0) + { + } + + + ~AlignStack() + { + } + + + void Start(int span, int threshold = 0); + void Add(chunk_t *pc, int seqnum = 0); + void NewLines(int cnt); + void Flush(); + void Reset(); + void End(); + +protected: + int m_last_added; /* 0=none, 1=aligned, 2=skipped */ + void ReAddSkipped(); + + ChunkStack m_scratch; /* used in ReAddSkipped() */ +}; diff --git a/src/args.cpp b/src/args.cpp new file mode 100644 index 0000000000..f88dbc9e1b --- /dev/null +++ b/src/args.cpp @@ -0,0 +1,270 @@ +/** + * @file args.cpp + * Parses command line arguments. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "args.h" +#include +#include "unc_ctype.h" + + +/** + * Store the values and allocate enough memory for the 'used' flags. + * + * @param argc The argc that was passed to main() + * @param argv The argv that was passed to main() + */ +Args::Args(int argc, char **argv) +{ + m_count = argc; + m_values = argv; + int len = (argc >> 3) + 1; + m_used = new UINT8[len]; + if (m_used != NULL) + { + memset(m_used, 0, len); + } +} + + +Args::~Args() +{ + if (m_used != NULL) + { + delete[] m_used; + m_used = NULL; + } + m_count = 0; +} + + +/** + * Check for an exact match + * + * @param token The token string to match + * @return true/false -- Whether the argument was present + */ +bool Args::Present(const char *token) +{ + int idx; + + if (token != NULL) + { + for (idx = 0; idx < m_count; idx++) + { + if (strcmp(token, m_values[idx]) == 0) + { + SetUsed(idx); + return(true); + } + } + } + + return(false); +} + + +/** + * Just call arg_params() with an index of 0. + * + * @param token The token string to match + * @return NULL or the pointer to the string + */ +const char *Args::Param(const char *token) +{ + int idx = 0; + + return(Params(token, idx)); +} + + +/** + * Scan for a match + * + * @param token The token string to match + * @return NULL or the pointer to the string + */ +const char *Args::Params(const char *token, int& index) +{ + int idx; + int token_len; + int arg_len; + + if (token == NULL) + { + return(NULL); + } + + token_len = (int)strlen(token); + + for (idx = index; idx < m_count; idx++) + { + arg_len = (int)strlen(m_values[idx]); + + if ((arg_len >= token_len) && + (memcmp(token, m_values[idx], token_len) == 0)) + { + SetUsed(idx); + if (arg_len > token_len) + { + if (m_values[idx][token_len] == '=') + { + token_len++; + } + index = idx + 1; + return(&m_values[idx][token_len]); + } + idx++; + index = idx + 1; + if (idx < m_count) + { + SetUsed(idx); + return(m_values[idx]); + } + return(""); + } + } + + return(NULL); +} + + +/** + * Gets whether an argument has been used, by index. + * + * @param idx The index of the argument + */ +bool Args::GetUsed(int idx) +{ + if ((m_used != NULL) && (idx >= 0) && (idx < m_count)) + { + return((m_used[idx >> 3] & (1 << (idx & 0x07))) != 0); + } + return(false); +} + + +/** + * Marks an argument as being used. + * + * @param idx The index of the argument + */ +void Args::SetUsed(int idx) +{ + if ((m_used != NULL) && (idx >= 0) && (idx < m_count)) + { + m_used[idx >> 3] |= (1 << (idx & 0x07)); + } +} + + +/** + * This function retrieves all unused parameters. + * You must set the index before the first call. + * Set the index to 1 to skip argv[0]. + * + * @param idx Pointer to the index + * @return NULL (done) or the pointer to the string + */ +const char *Args::Unused(int& index) +{ + int idx; + + if (m_used == NULL) + { + return(NULL); + } + + for (idx = index; idx < m_count; idx++) + { + if (!GetUsed(idx)) + { + index = idx + 1; + return(m_values[idx]); + } + } + index = m_count; + return(NULL); +} + + +/** + * Takes text and splits it into arguments. + * args is an array of char * pointers that will get populated. + * num_args is the maximum number of args split off. + * If there are more than num_args, the remaining text is ignored. + * Note that text is modified (zeroes are inserted) + * + * @param text The text to split (modified) + * @param args The char * array to populate + * @param num_args The number of items in args + * @return The number of arguments parsed (always <= num_args) + */ +int Args::SplitLine(char *text, char *args[], int num_args) +{ + char cur_quote = 0; + bool in_backslash = false; + bool in_arg = false; + int argc = 0; + char *dest = text; + + + while ((*text != 0) && (argc <= num_args)) + { + /* Detect the start of an arg */ + if (!in_arg && !unc_isspace(*text)) + { + in_arg = true; + args[argc] = dest; + argc++; + } + + if (in_arg) + { + if (in_backslash) + { + in_backslash = false; + *dest = *text; + dest++; + } + else if (*text == '\\') + { + in_backslash = true; + } + else if (*text == cur_quote) + { + cur_quote = 0; + } + else if ((*text == '\'') || (*text == '"') || (*text == '`')) + { + cur_quote = *text; + } + else if (cur_quote != 0) + { + *dest = *text; + dest++; + } + else if (unc_isspace(*text)) + { + *dest = 0; + dest++; + in_arg = false; + if (argc == num_args) + { + break; + } + } + else + { + *dest = *text; + dest++; + } + } + text++; + } + *dest = 0; + + return(argc); +} diff --git a/src/args.h b/src/args.h new file mode 100644 index 0000000000..dbaa5f0a17 --- /dev/null +++ b/src/args.h @@ -0,0 +1,115 @@ +/** + * @file args.h + * Parses command line arguments. + * + * This differs from the GNU/getopt way in that: + * - parameters cannot mixed "-e -f" is not the same as "-ef" + * - knowledge of the complete set of parameters is not required + * - this means you can handle args in multiple spots + * - it is more portable + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef ARGS_H_INCLUDED +#define ARGS_H_INCLUDED + +#include "base_types.h" + +class Args +{ +protected: + int m_count; + char **m_values; + UINT8 *m_used; /* array of bits */ + +public: + + /** + * Initializes the argument library. + * This keeps a reference to argv, so don't change it. + * + * @param argc The argc that was passed to main() + * @param argv The argv that was passed to main() + */ + Args(int argc, char **argv); + + /** Standard destructor */ + ~Args(); + + /** + * Checks to see if an arg w/o a value is present. + * Just scans the args looking for an exact match. + * + * "-c" matches "-c", but not "-call" or "-ec" + * + * @param token The token string to match + * @return true/false -- Whether the argument was present + */ + bool Present(const char *token); + + /** + * Check for an arg with a value. + * Returns only the first match. + * + * Assuming the token "-c"... + * "-call" returns "all" + * "-c=all" returns "all" + * "-c", "all" returns "all" + * "-c=", "all" returns "" + * + * @param token The token string to match + * @return NULL or the pointer to the string + */ + const char *Param(const char *token); + + /** + * Similiar to arg_param, but can iterate over all matches. + * Set index to 0 before the first call. + * + * @param token The token string to match + * @param idx Pointer to the index that you initialized to 0 + * @return NULL or the pointer to the string. + */ + const char *Params(const char *token, int& index); + + /** + * Marks an argument as being used. + * + * @param idx The index of the argument + */ + void SetUsed(int idx); + + /** + * Gets whether an argument has been used, by index. + * + * @param idx The index of the argument + */ + bool GetUsed(int idx); + + /** + * This function retrieves all unused parameters. + * You must set the index before the first call. + * Set the index to 1 to skip argv[0]. + * + * @param idx Pointer to the index + * @return NULL (done) or the pointer to the string + */ + const char *Unused(int& idx); + + /** + * Takes text and splits it into arguments. + * args is an array of char * pointers that will get populated. + * num_args is the maximum number of args split off. + * If there are more than num_args, the remaining text is ignored. + * Note that text is modified (zeroes are inserted) + * + * @param text The text to split (modified) + * @param args The char * array to populate + * @param num_args The number of items in args + * @return The number of arguments parsed (always <= num_args) + */ + static int SplitLine(char *text, char *args[], int num_args); +}; + +#endif /* ARGS_H_INCLUDED */ diff --git a/src/backup.cpp b/src/backup.cpp new file mode 100644 index 0000000000..462ca7f353 --- /dev/null +++ b/src/backup.cpp @@ -0,0 +1,161 @@ +/** + * @file backup.cpp + * Make a backup of a source file + * The current plans are to use two files. + * + * - A '.unc-backup~' file that contains the original contents + * - A '.unc-backup-md5~' file that contains the MD5 over the last output + * that uncrustify generated + * + * The logic goes like this: + * 1. If there isn't a .backup-md5 or the md5 over the input file doesn't + * match what is in .backup-md5, then copy the source file to .backup. + * + * 2. Create the output file. + * + * 3. Calculate the md5 over the output file. + * Create the .backup-md5 file. + * + * This will let you run uncrustify multiple times over the same file without + * losing the original file. If you edit the file, then a new backup is made. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "prototypes.h" +#include "backup.h" +#include "md5.h" +#include "logger.h" +#include +#include +#include "unc_ctype.h" +#include + +/** + * Check the backup-md5 file and copy the input file to a backup if needed. + */ +int backup_copy_file(const char *filename, const char *file_data, int file_len) +{ + char newpath[1024]; + char buffer[128]; + char md5_str_in[33]; + char md5_str[33]; + UINT8 dig[16]; + + md5_str_in[0] = 0; + + MD5::Calc(file_data, file_len, dig); + snprintf(md5_str, sizeof(md5_str), + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + dig[0], dig[1], dig[2], dig[3], + dig[4], dig[5], dig[6], dig[7], + dig[8], dig[9], dig[10], dig[11], + dig[12], dig[13], dig[14], dig[15]); + + /* Create the backup-md5 filename, open it and read the md5 */ + snprintf(newpath, sizeof(newpath), "%s%s", filename, UNC_BACKUP_MD5_SUFFIX); + + FILE *thefile = fopen(newpath, "rb"); + if (thefile != NULL) + { + if (fgets(buffer, sizeof(buffer), thefile) != NULL) + { + for (int i = 0; buffer[i] != 0; i++) + { + if (unc_isxdigit(buffer[i])) + { + md5_str_in[i] = unc_tolower(buffer[i]); + } + else + { + md5_str_in[i] = 0; + break; + } + } + } + fclose(thefile); + } + + /* if the MD5s match, then there is no need to back up the file */ + if (memcmp(md5_str, md5_str_in, 32) == 0) + { + LOG_FMT(LNOTE, "%s: MD5 match for %s\n", __func__, filename); + return(SUCCESS); + } + + LOG_FMT(LNOTE, "%s: MD5 mismatch - backing up %s\n", __func__, filename); + + /* Create the backup file */ + snprintf(newpath, sizeof(newpath), "%s%s", filename, UNC_BACKUP_SUFFIX); + + thefile = fopen(newpath, "wb"); + if (thefile != NULL) + { + int retval = fwrite(file_data, file_len, 1, thefile); + int my_errno = errno; + + fclose(thefile); + + if (retval == 1) + { + return(SUCCESS); + } + LOG_FMT(LERR, "fwrite(%s) failed: %s (%d)\n", + newpath, strerror(my_errno), my_errno); + } + else + { + LOG_FMT(LERR, "fopen(%s) failed: %s (%d)\n", + newpath, strerror(errno), errno); + } + return(FAILURE); +} + + +/** + * This should be called after the file was written to disk. + * It will be read back and an md5 will be calculated over it. + */ +void backup_create_md5_file(const char *filename) +{ + UINT8 dig[16]; + MD5 md5; + FILE *thefile; + UINT8 buf[4096]; + INT32 len; + char newpath[1024]; + + md5.Init(); + + thefile = fopen(filename, "rb"); + if (thefile == NULL) + { + LOG_FMT(LERR, "%s: fopen(%s) failed: %s (%d)\n", + __func__, filename, strerror(errno), errno); + return; + } + + while ((len = fread(buf, 1, sizeof(buf), thefile)) > 0) + { + md5.Update(buf, len); + } + + fclose(thefile); + md5.Final(dig); + + snprintf(newpath, sizeof(newpath), "%s%s", filename, UNC_BACKUP_MD5_SUFFIX); + + thefile = fopen(newpath, "wb"); + if (thefile != NULL) + { + fprintf(thefile, + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x %s\n", + dig[0], dig[1], dig[2], dig[3], + dig[4], dig[5], dig[6], dig[7], + dig[8], dig[9], dig[10], dig[11], + dig[12], dig[13], dig[14], dig[15], + path_basename(filename)); + + fclose(thefile); + } +} diff --git a/src/backup.h b/src/backup.h new file mode 100644 index 0000000000..1535ae802b --- /dev/null +++ b/src/backup.h @@ -0,0 +1,56 @@ +/** + * @file backup.h + * Handles backing up file data. + * + * It works like this: + * + * 1. Read in the file data + * + * 2. Call backup_copy_file() to create a backup of the input, if needed + * + * 3. Do the uncrustify magic and write the output file + * + * 4. Call backup_create_md5_file() + * + * This will let you run uncrustify multiple times over the same file without + * losing the original file. If you edit the file, then a new backup is made. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef BACKUP_H_INCLUDED +#define BACKUP_H_INCLUDED + +#define UNC_BACKUP_SUFFIX ".unc-backup~" +#define UNC_BACKUP_MD5_SUFFIX ".unc-backup.md5~" + + +/** + * If there isn't a FILENAME+UNC_BACKUP_MD5_SUFFIX or the md5 over the data + * doesn't match what is in FILENAME+UNC_BACKUP_MD5_SUFFIX, then write the + * data to FILENAME+UNC_BACKUP_SUFFIX. + * + * Note that if this fails, we shouldn't overwrite to original file with the + * output. + * + * @param filename The file that was read (full path) + * @param file_data The file data + * @param file_len The file length + * @return SUCCESS or FAILURE + */ +int backup_copy_file(const char *filename, const char *file_data, int file_len); + + +/** + * This calculates the MD5 over the file and writes the MD5 to + * FILENAME+UNC_BACKUP_MD5_SUFFIX.* + * This should be called after the file was written to disk. + * We really don't care if it fails, as the MD5 just prevents us from backing + * up a file that uncrustify created. + * + * @param filename The file that was written (full path) + */ +void backup_create_md5_file(const char *filename); + + +#endif /* BACKUP_H_INCLUDED */ diff --git a/src/base_types.h b/src/base_types.h new file mode 100644 index 0000000000..08ffadddcc --- /dev/null +++ b/src/base_types.h @@ -0,0 +1,60 @@ +/** + * @file base_types.h + * + * Defines some base types, includes config.h + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef BASE_TYPES_H_INCLUDED +#define BASE_TYPES_H_INCLUDED + +#ifdef WIN32 + +#include "windows_compat.h" + +#else /* not WIN32 */ + +#include "config.h" + +#define PATH_SEP '/' + +#if defined HAVE_STDINT_H +#include +#elif defined HAVE_INTTYPES_H +#include +#else +#error "Don't know where int8_t is defined" +#endif + + +/* some of my favorite aliases */ + +typedef char CHAR; + +typedef int8_t INT8; +typedef int16_t INT16; +typedef int32_t INT32; + +typedef uint8_t UINT8; +typedef uint16_t UINT16; +typedef uint32_t UINT32; + +#endif /* ifdef WIN32 */ + +/* and the good old SUCCESS/FAILURE */ + +#define SUCCESS 0 +#define FAILURE -1 + + +/* and a nice macro to keep SlickEdit happy */ + +#define static_inline static inline + +/* and the ever-so-important array size macro */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +#endif /* BASE_TYPES_H_INCLUDED */ diff --git a/src/brace_cleanup.cpp b/src/brace_cleanup.cpp new file mode 100644 index 0000000000..f8c7e75e1a --- /dev/null +++ b/src/brace_cleanup.cpp @@ -0,0 +1,1007 @@ +/** + * @file brace_cleanup.cpp + * Determines the brace level and paren level. + * Inserts virtual braces as needed. + * Handles all that preprocessor crap. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "char_table.h" +#include "prototypes.h" +#include "chunk_list.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +static chunk_t *insert_vbrace(chunk_t *pc, bool after, + struct parse_frame *frm); + +#define insert_vbrace_close_after(pc, frm) insert_vbrace(pc, true, frm) +#define insert_vbrace_open_before(pc, frm) insert_vbrace(pc, false, frm) + +static void parse_cleanup(struct parse_frame *frm, chunk_t *pc); + +static bool close_statement(struct parse_frame *frm, chunk_t *pc); + +static bool check_complex_statements(struct parse_frame *frm, chunk_t *pc); +static bool handle_complex_close(struct parse_frame *frm, chunk_t *pc); + + +static int preproc_start(struct parse_frame *frm, chunk_t *pc) +{ + chunk_t *next; + int pp_level = cpd.pp_level; + + /* Get the type of preprocessor and handle it */ + next = chunk_get_next_ncnl(pc); + if (next != NULL) + { + cpd.in_preproc = next->type; + + /** + * If we are in a define, push the frame stack. + */ + if (cpd.in_preproc == CT_PP_DEFINE) + { + pf_push(frm); + + /* a preproc body starts a new, blank frame */ + memset(frm, 0, sizeof(*frm)); + frm->level = 1; + frm->brace_level = 1; + + /*TODO: not sure about the next 3 lines */ + frm->pse_tos = 1; + frm->pse[frm->pse_tos].type = CT_PP_DEFINE; + frm->pse[frm->pse_tos].stage = BS_NONE; + } + else + { + /* Check for #if, #else, #endif, etc */ + pp_level = pf_check(frm, pc); + } + } + return(pp_level); +} + + +static void print_stack(int logsev, const char *str, + struct parse_frame *frm, chunk_t *pc) +{ + if (log_sev_on(logsev)) + { + int idx; + + log_fmt(logsev, "%8.8s", str); + + for (idx = 1; idx <= frm->pse_tos; idx++) + { + if (frm->pse[idx].stage != BS_NONE) + { + LOG_FMT(logsev, " [%s - %d]", get_token_name(frm->pse[idx].type), + frm->pse[idx].stage); + } + else + { + LOG_FMT(logsev, " [%s]", get_token_name(frm->pse[idx].type)); + } + } + log_fmt(logsev, "\n"); + } +} + + +/** + * Scans through the whole list and does stuff. + * It has to do some tricks to parse preprocessors. + * + * TODO: This can be cleaned up and simplified - we can look both forward and backward! + */ +void brace_cleanup(void) +{ + chunk_t *pc; + chunk_t vs_chunk; + struct parse_frame frm; + int pp_level; + + memset(&frm, 0, sizeof(frm)); + memset(&vs_chunk, 0, sizeof(vs_chunk)); + + cpd.in_preproc = CT_NONE; + cpd.pp_level = 0; + + pc = chunk_get_head(); + while (pc != NULL) + { + /* Check for leaving a #define body */ + if ((cpd.in_preproc != CT_NONE) && ((pc->flags & PCF_IN_PREPROC) == 0)) + { + if (cpd.in_preproc == CT_PP_DEFINE) + { + /* out of the #define body, restore the frame */ + pf_pop(&frm); + } + + cpd.in_preproc = CT_NONE; + } + + /* Check for a preprocessor start */ + pp_level = cpd.pp_level; + if (pc->type == CT_PREPROC) + { + pp_level = preproc_start(&frm, pc); + } + + /* Do before assigning stuff from the frame */ + if ((cpd.lang_flags & LANG_PAWN) != 0) + { + if ((frm.pse[frm.pse_tos].type == CT_VBRACE_OPEN) && + (pc->type == CT_NEWLINE)) + { + pc = pawn_check_vsemicolon(pc); + } + } + + /* Assume the level won't change */ + pc->level = frm.level; + pc->brace_level = frm.brace_level; + pc->pp_level = pp_level; + + + /** + * #define bodies get the full formatting treatment + * Also need to pass in the initial '#' to close out any virtual braces. + */ + if (!chunk_is_comment(pc) && !chunk_is_newline(pc) && + ((cpd.in_preproc == CT_PP_DEFINE) || + (cpd.in_preproc == CT_NONE))) + { + cpd.consumed = false; + parse_cleanup(&frm, pc); + print_stack(LBCSAFTER, (pc->type == CT_VBRACE_CLOSE) ? "Virt-}" : pc->str, &frm, pc); + } + pc = chunk_get_next(pc); + } +} + + +/** + * pc is a CT_WHILE. + * Scan backwards to see if we find a brace/vbrace with the parent set to CT_DO + */ +static bool maybe_while_of_do(chunk_t *pc) +{ + chunk_t *prev; + + prev = chunk_get_prev_ncnl(pc); + if ((prev == NULL) || !(prev->flags & PCF_IN_PREPROC)) + { + return(false); + } + + /* Find the chunk before the preprocessor */ + while ((prev != NULL) && (prev->flags & PCF_IN_PREPROC)) + { + prev = chunk_get_prev_ncnl(prev); + } + + if ((prev != NULL) && + (prev->parent_type == CT_DO) && + ((prev->type == CT_VBRACE_CLOSE) || + (prev->type == CT_BRACE_CLOSE))) + { + return(true); + } + return(false); +} + + +static void push_fmr_pse(struct parse_frame *frm, chunk_t *pc, + brstage_e stage, const char *logtext) +{ + if (frm->pse_tos < ((int)ARRAY_SIZE(frm->pse) - 1)) + { + frm->pse_tos++; + frm->pse[frm->pse_tos].type = pc->type; + frm->pse[frm->pse_tos].stage = stage; + frm->pse[frm->pse_tos].pc = pc; + + print_stack(LBCSPUSH, logtext, frm, pc); + } + else + { + LOG_FMT(LWARN, "%s:%d Error: Frame stack overflow, Unable to properly process this file.\n", + cpd.filename, cpd.line_number); + cpd.error_count++; + } +} + + +/** + * At the heart of this algorithm are two stacks. + * There is the Paren Stack (PS) and the Frame stack. + * + * The PS (pse in the code) keeps track of braces, parens, + * if/else/switch/do/while/etc items -- anything that is nestable. + * Complex statements go through stages. + * Take this simple if statment as an example: + * if ( x ) { x--; } + * + * The stack would change like so: 'token' stack afterwards + * 'if' [IF - 1] + * '(' [IF - 1] [PAREN OPEN] + * 'x' [IF - 1] [PAREN OPEN] + * ')' [IF - 2] <- note that the state was incremented + * '{' [IF - 2] [BRACE OPEN] + * 'x' [IF - 2] [BRACE OPEN] + * '--' [IF - 2] [BRACE OPEN] + * ';' [IF - 2] [BRACE OPEN] + * '}' [IF - 3] + * <- lack of else kills the IF, closes statement + * + * Virtual braces example: + * if ( x ) x--; else x++; + * + * 'if' [IF - 1] + * '(' [IF - 1] [PAREN OPEN] + * 'x' [IF - 1] [PAREN OPEN] + * ')' [IF - 2] + * 'x' [IF - 2] [VBRACE OPEN] <- VBrace open inserted before because '{' was not next + * '--' [IF - 2] [VBRACE OPEN] + * ';' [IF - 3] <- VBrace close inserted after semicolon + * 'else' [ELSE - 0] <- IF changed into ELSE + * 'x' [ELSE - 0] [VBRACE OPEN] <- lack of '{' -> VBrace + * '++' [ELSE - 0] [VBRACE OPEN] + * ';' [ELSE - 0] <- VBrace close inserted after semicolon + * <- ELSE removed after statment close + * + * The pse stack is kept on a frame stack. + * The frame stack is need for languages that support preprocessors (C, C++, C#) + * that can arbitrarily change code flow. It also isolates #define macros so + * that they are indented independently and do not affect the rest of the program. + * + * When an #if is hit, a copy of the current frame is push on the frame stack. + * When an #else/#elif is hit, a copy of the current stack is pushed under the + * #if frame and the original (pre-#if) frame is copied to the current frame. + * When #endif is hit, the top frame is popped. + * This has the following effects: + * - a simple #if / #endif does not affect program flow + * - #if / #else /#endif - continues from the #if clause + * + * When a #define is entered, the current frame is pushed and cleared. + * When a #define is exited, the frame is popped. + */ +static void parse_cleanup(struct parse_frame *frm, chunk_t *pc) +{ + c_token_t parent = CT_NONE; + chunk_t *prev; + + LOG_FMT(LTOK, "%s:%d] %16s - tos:%d/%16s stg:%d\n", + __func__, pc->orig_line, get_token_name(pc->type), + frm->pse_tos, get_token_name(frm->pse[frm->pse_tos].type), + frm->pse[frm->pse_tos].stage); + + /* Mark statement starts */ + if (((frm->stmt_count == 0) || (frm->expr_count == 0)) && + !chunk_is_semicolon(pc) && + (pc->type != CT_BRACE_CLOSE) && + (pc->type != CT_VBRACE_CLOSE)) + { + pc->flags |= PCF_EXPR_START; + pc->flags |= (frm->stmt_count == 0) ? PCF_STMT_START : 0; + LOG_FMT(LSTMT, "%d] 1.marked %.*s as stmt start st:%d ex:%d\n", + pc->orig_line, pc->len, pc->str, frm->stmt_count, frm->expr_count); + } + frm->stmt_count++; + frm->expr_count++; + + if (frm->sparen_count > 0) + { + int tmp; + + pc->flags |= PCF_IN_SPAREN; + + /* Mark everything in the a for statement */ + for (tmp = frm->pse_tos - 1; tmp >= 0; tmp--) + { + if (frm->pse[tmp].type == CT_FOR) + { + pc->flags |= PCF_IN_FOR; + break; + } + } + + /* Mark the parent on semicolons in for() stmts */ + if ((pc->type == CT_SEMICOLON) && + (frm->pse_tos > 1) && + (frm->pse[frm->pse_tos - 1].type == CT_FOR)) + { + pc->parent_type = CT_FOR; + } + } + + /* Check the progression of complex statements */ + if (frm->pse[frm->pse_tos].stage != BS_NONE) + { + if (check_complex_statements(frm, pc)) + { + return; + } + } + + /** + * Check for a virtual brace statement close due to a semicolon. + * The virtual brace will get handled the next time through. + * The semicolon isn't handled at all. + * TODO: may need to float VBRACE past comments until newline? + */ + if (frm->pse[frm->pse_tos].type == CT_VBRACE_OPEN) + { + if (chunk_is_semicolon(pc)) + { + cpd.consumed = true; + close_statement(frm, pc); + } + else if ((cpd.lang_flags & LANG_PAWN) != 0) + { + if (pc->type == CT_BRACE_CLOSE) + { + close_statement(frm, pc); + } + } + } + + /* Handle close paren, vbrace, brace, and square */ + if ((pc->type == CT_PAREN_CLOSE) || + (pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_VBRACE_CLOSE) || + (pc->type == CT_ANGLE_CLOSE) || + (pc->type == CT_MACRO_CLOSE) || + (pc->type == CT_SQUARE_CLOSE)) + { + /* Change CT_PAREN_CLOSE into CT_SPAREN_CLOSE or CT_FPAREN_CLOSE */ + if ((pc->type == CT_PAREN_CLOSE) && + ((frm->pse[frm->pse_tos].type == CT_FPAREN_OPEN) || + (frm->pse[frm->pse_tos].type == CT_SPAREN_OPEN))) + { + pc->type = (c_token_t)(frm->pse[frm->pse_tos].type + 1); + if (pc->type == CT_SPAREN_CLOSE) + { + frm->sparen_count--; + pc->flags &= ~PCF_IN_SPAREN; + } + } + + /* Make sure the open / close match */ + if (pc->type != (frm->pse[frm->pse_tos].type + 1)) + { + if ((frm->pse[frm->pse_tos].type != CT_NONE) && + (frm->pse[frm->pse_tos].type != CT_PP_DEFINE)) + { + LOG_FMT(LWARN, "%s:%d Error: Unexpected '%.*s' for '%s', which was on line %d\n", + cpd.filename, pc->orig_line, pc->len, pc->str, + get_token_name(frm->pse[frm->pse_tos].pc->type), + frm->pse[frm->pse_tos].pc->orig_line); + print_stack(LBCSPOP, "=Error ", frm, pc); + cpd.error_count++; + } + } + else + { + cpd.consumed = true; + + /* Copy the parent, update the paren/brace levels */ + pc->parent_type = frm->pse[frm->pse_tos].parent; + frm->level--; + if ((pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_VBRACE_CLOSE) || + (pc->type == CT_MACRO_CLOSE)) + { + frm->brace_level--; + } + pc->level = frm->level; + pc->brace_level = frm->brace_level; + + /* Pop the entry */ + frm->pse_tos--; + print_stack(LBCSPOP, "-Close ", frm, pc); + + /* See if we are in a complex statement */ + if (frm->pse[frm->pse_tos].stage != BS_NONE) + { + handle_complex_close(frm, pc); + } + } + } + + /* In this state, we expect a semicolon, but we'll also hit the closing + * sparen, so we need to check cpd.consumed to see if the close sparen was + * aleady handled. + */ + if (frm->pse[frm->pse_tos].stage == BS_WOD_SEMI) + { + chunk_t *tmp = pc; + + if (cpd.consumed) + { + /* If consumed, then we are on the close sparen. + * PAWN: Check the next chunk for a semicolon. If it isn't, then + * add a virtual semicolon, which will get handled on the next pass. + */ + if (cpd.lang_flags & LANG_PAWN) + { + tmp = chunk_get_next_ncnl(pc); + + if ((tmp->type != CT_SEMICOLON) && (tmp->type != CT_VSEMICOLON)) + { + pawn_add_vsemi_after(pc); + } + } + } + else + { + /* Complain if this ISN'T a semicolon, but close out WHILE_OF_DO anyway */ + if ((pc->type == CT_SEMICOLON) || (pc->type == CT_VSEMICOLON)) + { + cpd.consumed = true; + pc->parent_type = CT_WHILE_OF_DO; + } + else + { + LOG_FMT(LWARN, "%s:%d: Error: Expected a semicolon for WHILE_OF_DO, but got '%s'\n", + cpd.filename, pc->orig_line, get_token_name(pc->type)); + cpd.error_count++; + } + handle_complex_close(frm, pc); + } + } + + /* Get the parent type for brace and paren open */ + parent = pc->parent_type; + if ((pc->type == CT_PAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_BRACE_OPEN)) + { + prev = chunk_get_prev_ncnl(pc); + if (prev != NULL) + { + if ((pc->type == CT_PAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN)) + { + /* Set the parent for parens and change paren type */ + if (frm->pse[frm->pse_tos].stage != BS_NONE) + { + pc->type = CT_SPAREN_OPEN; + parent = frm->pse[frm->pse_tos].type; + frm->sparen_count++; + } + else if (prev->type == CT_FUNCTION) + { + pc->type = CT_FPAREN_OPEN; + parent = CT_FUNCTION; + } + else + { + /* no need to set parent */ + } + } + else /* must be CT_BRACE_OPEN */ + { + /* Set the parent for open braces */ + if (frm->pse[frm->pse_tos].stage != BS_NONE) + { + parent = frm->pse[frm->pse_tos].type; + } + else if ((prev->type == CT_ASSIGN) && (prev->str[0] == '=')) + { + parent = CT_ASSIGN; + } + else if (prev->type == CT_FPAREN_CLOSE) + { + parent = CT_FUNCTION; + } + else + { + /* no need to set parent */ + } + } + } + } + + /** + * Adjust the level for opens & create a stack entry + * Note that CT_VBRACE_OPEN has already been handled. + */ + if ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_PAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_ANGLE_OPEN) || + (pc->type == CT_MACRO_OPEN) || + (pc->type == CT_SQUARE_OPEN)) + { + frm->level++; + if ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_MACRO_OPEN)) + { + frm->brace_level++; + } + push_fmr_pse(frm, pc, BS_NONE, "+Open "); + frm->pse[frm->pse_tos].parent = parent; + pc->parent_type = parent; + } + + pattern_class patcls = get_token_pattern_class(pc->type); + + /** Create a stack entry for complex statments IF/DO/FOR/WHILE/SWITCH */ + if (patcls == PATCLS_BRACED) + { + push_fmr_pse(frm, pc, + (pc->type == CT_DO) ? BS_BRACE_DO : BS_BRACE2, + "+ComplexBraced"); + } + else if (patcls == PATCLS_PBRACED) + { + brstage_e bs = BS_PAREN1; + + if ((pc->type == CT_WHILE) && maybe_while_of_do(pc)) + { + pc->type = CT_WHILE_OF_DO; + bs = BS_WOD_PAREN; + } + push_fmr_pse(frm, pc, bs, "+ComplexParenBraced"); + } + else if (patcls == PATCLS_OPBRACED) + { + push_fmr_pse(frm, pc, BS_OP_PAREN1, "+ComplexOpParenBraced"); + } + else if (patcls == PATCLS_ELSE) + { + push_fmr_pse(frm, pc, BS_ELSEIF, "+ComplexElse"); + } + + /* Mark simple statement/expression starts + * - after { or } + * - after ';', but not if the paren stack top is a paren + * - after '(' that has a parent type of CT_FOR + */ + if ((pc->type == CT_SQUARE_OPEN) || + ((pc->type == CT_BRACE_OPEN) && (pc->parent_type != CT_ASSIGN)) || + (pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_VBRACE_CLOSE) || + ((pc->type == CT_SPAREN_OPEN) && (pc->parent_type == CT_FOR)) || + (chunk_is_semicolon(pc) && + (frm->pse[frm->pse_tos].type != CT_PAREN_OPEN) && + (frm->pse[frm->pse_tos].type != CT_FPAREN_OPEN) && + (frm->pse[frm->pse_tos].type != CT_SPAREN_OPEN))) + { + LOG_FMT(LSTMT, "%s: %d> reset stmt on %.*s\n", + __func__, pc->orig_line, pc->len, pc->str); + frm->stmt_count = 0; + frm->expr_count = 0; + } + + /* Mark expression starts */ + if ((pc->type == CT_ARITH) || + (pc->type == CT_ASSIGN) || + (pc->type == CT_CASE) || + (pc->type == CT_COMPARE) || + (pc->type == CT_STAR) || + (pc->type == CT_BOOL) || + (pc->type == CT_MINUS) || + (pc->type == CT_ANGLE_OPEN) || + (pc->type == CT_ANGLE_CLOSE) || + (pc->type == CT_RETURN) || + (pc->type == CT_GOTO) || + (pc->type == CT_CONTINUE) || + (pc->type == CT_PAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_BRACE_OPEN) || + chunk_is_semicolon(pc) || + (pc->type == CT_COMMA) || + (pc->type == CT_NOT) || + (pc->type == CT_INV) || + (pc->type == CT_COLON) || + (pc->type == CT_QUESTION)) + { + frm->expr_count = 0; + LOG_FMT(LSTMT, "%s: %d> reset expr on %.*s\n", + __func__, pc->orig_line, pc->len, pc->str); + } +} + + +/** + * Checks the progression of complex statements. + * - checks for else after if + * - checks for if after else + * - checks for while after do + * - checks for open brace in BRACE2 and BRACE_DO stages, inserts open VBRACE + * - checks for open paren in PAREN1 and PAREN2 stages, complains + * + * @param frm The parse frame + * @param pc The current chunk + * @return true - done with this chunk, false - keep processing + */ +static bool check_complex_statements(struct parse_frame *frm, chunk_t *pc) +{ + c_token_t parent; + chunk_t *vbrace; + + /* Turn an optional paren into either a real paren or a brace */ + if (frm->pse[frm->pse_tos].stage == BS_OP_PAREN1) + { + frm->pse[frm->pse_tos].stage = (pc->type != CT_PAREN_OPEN) ? BS_BRACE2 : BS_PAREN1; + } + + /* Check for CT_ELSE after CT_IF */ + while (frm->pse[frm->pse_tos].stage == BS_ELSE) + { + if (pc->type == CT_ELSE) + { + /* Replace CT_IF with CT_ELSE on the stack & we are done */ + frm->pse[frm->pse_tos].type = CT_ELSE; + frm->pse[frm->pse_tos].stage = BS_ELSEIF; + print_stack(LBCSSWAP, "=Swap ", frm, pc); + return(true); + } + + /* Remove the CT_IF and close the statement */ + frm->pse_tos--; + print_stack(LBCSPOP, "-IF-CCS ", frm, pc); + if (close_statement(frm, pc)) + { + return(true); + } + } + + /* Check for CT_IF after CT_ELSE */ + if (frm->pse[frm->pse_tos].stage == BS_ELSEIF) + { + if (pc->type == CT_IF) + { + if (!cpd.settings[UO_indent_else_if].b || + !chunk_is_newline(chunk_get_prev_nc(pc))) + { + /* Replace CT_ELSE with CT_IF */ + pc->type = CT_ELSEIF; + frm->pse[frm->pse_tos].type = CT_ELSEIF; + frm->pse[frm->pse_tos].stage = BS_PAREN1; + return(true); + } + } + + /* Jump to the 'expecting brace' stage */ + frm->pse[frm->pse_tos].stage = BS_BRACE2; + } + + /* Check for CT_CATCH or CT_FINALLY after CT_TRY or CT_CATCH */ + while (frm->pse[frm->pse_tos].stage == BS_CATCH) + { + if ((pc->type == CT_CATCH) || (pc->type == CT_FINALLY)) + { + /* Replace CT_TRY with CT_CATCH on the stack & we are done */ + frm->pse[frm->pse_tos].type = pc->type; + frm->pse[frm->pse_tos].stage = (pc->type == CT_CATCH) ? BS_OP_PAREN1 : BS_BRACE2; + print_stack(LBCSSWAP, "=Swap ", frm, pc); + return(true); + } + + /* Remove the CT_TRY and close the statement */ + frm->pse_tos--; + print_stack(LBCSPOP, "-TRY-CCS ", frm, pc); + if (close_statement(frm, pc)) + { + return(true); + } + } + + /* Check for CT_WHILE after the CT_DO */ + if (frm->pse[frm->pse_tos].stage == BS_WHILE) + { + if (pc->type == CT_WHILE) + { + pc->type = CT_WHILE_OF_DO; + frm->pse[frm->pse_tos].type = CT_WHILE_OF_DO; //CT_WHILE; + frm->pse[frm->pse_tos].stage = BS_WOD_PAREN; + return(true); + } + + LOG_FMT(LWARN, "%s:%d Error: Expected 'while', got '%.*s'\n", + cpd.filename, pc->orig_line, pc->len, pc->str); + frm->pse_tos--; + print_stack(LBCSPOP, "-Error ", frm, pc); + cpd.error_count++; + } + + /* Insert a CT_VBRACE_OPEN, if needed */ + if ((pc->type != CT_BRACE_OPEN) && + ((frm->pse[frm->pse_tos].stage == BS_BRACE2) || + (frm->pse[frm->pse_tos].stage == BS_BRACE_DO))) + { + parent = frm->pse[frm->pse_tos].type; + + vbrace = insert_vbrace_open_before(pc, frm); + vbrace->parent_type = parent; + + frm->level++; + frm->brace_level++; + + push_fmr_pse(frm, vbrace, BS_NONE, "+VBrace "); + frm->pse[frm->pse_tos].parent = parent; + + /* update the level of pc */ + pc->level = frm->level; + pc->brace_level = frm->brace_level; + + /* Mark as a start of a statement */ + frm->stmt_count = 0; + frm->expr_count = 0; + pc->flags |= PCF_STMT_START | PCF_EXPR_START; + frm->stmt_count = 1; + frm->expr_count = 1; + LOG_FMT(LSTMT, "%d] 2.marked %.*s as stmt start\n", pc->orig_line, pc->len, pc->str); + } + + /* Verify open paren in complex statement */ + if ((pc->type != CT_PAREN_OPEN) && + ((frm->pse[frm->pse_tos].stage == BS_PAREN1) || + (frm->pse[frm->pse_tos].stage == BS_WOD_PAREN))) + { + LOG_FMT(LWARN, "%s:%d Error: Expected '(', got '%.*s' for '%s'\n", + cpd.filename, pc->orig_line, pc->len, pc->str, + get_token_name(frm->pse[frm->pse_tos].type)); + + /* Throw out the complex statement */ + frm->pse_tos--; + print_stack(LBCSPOP, "-Error ", frm, pc); + cpd.error_count++; + } + + return(false); +} + + +/** + * Handles a close paren or brace - just progress the stage, if the end + * of the statement is hit, call close_statement() + * + * @param frm The parse frame + * @param pc The current chunk + * @return true - done with this chunk, false - keep processing + */ +static bool handle_complex_close(struct parse_frame *frm, chunk_t *pc) +{ + chunk_t *next; + + if (frm->pse[frm->pse_tos].stage == BS_PAREN1) + { + /* PAREN1 always => BRACE2 */ + frm->pse[frm->pse_tos].stage = BS_BRACE2; + } + else if (frm->pse[frm->pse_tos].stage == BS_BRACE2) + { + /* BRACE2: IF => ELSE, anyting else => close */ + if ((frm->pse[frm->pse_tos].type == CT_IF) || + (frm->pse[frm->pse_tos].type == CT_ELSEIF)) + { + frm->pse[frm->pse_tos].stage = BS_ELSE; + + /* If the next chunk isn't CT_ELSE, close the statement */ + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && (next->type != CT_ELSE)) + { + frm->pse_tos--; + print_stack(LBCSPOP, "-IF-HCS ", frm, pc); + if (close_statement(frm, pc)) + { + return(true); + } + } + } + else if ((frm->pse[frm->pse_tos].type == CT_TRY) || + (frm->pse[frm->pse_tos].type == CT_CATCH)) + { + frm->pse[frm->pse_tos].stage = BS_CATCH; + + /* If the next chunk isn't CT_CATCH or CT_FINALLY, close the statement */ + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && + (next->type != CT_CATCH) && + (next->type != CT_FINALLY)) + { + frm->pse_tos--; + print_stack(LBCSPOP, "-TRY-HCS ", frm, pc); + if (close_statement(frm, pc)) + { + return(true); + } + } + } + else + { + LOG_FMT(LNOTE, "%s: close_statement on %s BS_BRACE2\n", __func__, + get_token_name(frm->pse[frm->pse_tos].type)); + frm->pse_tos--; + print_stack(LBCSPOP, "-HCC B2 ", frm, pc); + if (close_statement(frm, pc)) + { + return(true); + } + } + } + else if (frm->pse[frm->pse_tos].stage == BS_BRACE_DO) + { + frm->pse[frm->pse_tos].stage = BS_WHILE; + } + else if (frm->pse[frm->pse_tos].stage == BS_WOD_PAREN) + { + LOG_FMT(LNOTE, "%s: close_statement on %s BS_WOD_PAREN\n", __func__, + get_token_name(frm->pse[frm->pse_tos].type)); + frm->pse[frm->pse_tos].stage = BS_WOD_SEMI; + print_stack(LBCSPOP, "-HCC WoDP ", frm, pc); + } + else if (frm->pse[frm->pse_tos].stage == BS_WOD_SEMI) + { + LOG_FMT(LNOTE, "%s: close_statement on %s BS_WOD_SEMI\n", __func__, + get_token_name(frm->pse[frm->pse_tos].type)); + frm->pse_tos--; + print_stack(LBCSPOP, "-HCC WoDS ", frm, pc); + + if (close_statement(frm, pc)) + { + return(true); + } + } + else + { + /* PROBLEM */ + LOG_FMT(LWARN, "%s:%d Error: TOS.type='%s' TOS.stage=%d\n", + cpd.filename, pc->orig_line, + get_token_name(frm->pse[frm->pse_tos].type), + frm->pse[frm->pse_tos].stage); + cpd.error_count++; + } + return(false); +} + + +static chunk_t *insert_vbrace(chunk_t *pc, bool after, + struct parse_frame *frm) +{ + chunk_t chunk; + chunk_t *rv; + chunk_t *ref; + + memset(&chunk, 0, sizeof(chunk)); + + chunk.orig_line = pc->orig_line; + chunk.parent_type = frm->pse[frm->pse_tos].type; + chunk.level = frm->level; + chunk.brace_level = frm->brace_level; + chunk.flags = pc->flags & PCF_COPY_FLAGS; + chunk.str = ""; + if (after) + { + chunk.type = CT_VBRACE_CLOSE; + rv = chunk_add_after(&chunk, pc); + } + else + { + ref = chunk_get_prev(pc); + if ((ref->flags & PCF_IN_PREPROC) == 0) + { + chunk.flags &= ~PCF_IN_PREPROC; + } + + while (chunk_is_newline(ref) || chunk_is_comment(ref)) + { + ref->level++; + ref->brace_level++; + ref = chunk_get_prev(ref); + } + + /* Don't back into a preprocessor */ + if (((pc->flags & PCF_IN_PREPROC) == 0) && + ((ref->flags & PCF_IN_PREPROC) != 0)) + { + if (ref->type == CT_PREPROC_BODY) + { + do + { + ref = chunk_get_prev(ref); + } while ((ref != NULL) && ((ref->flags & PCF_IN_PREPROC) != 0)); + } + else + { + ref = chunk_get_next(ref); + } + } + + chunk.orig_line = ref->orig_line; + chunk.column = ref->column + ref->len + 1; + chunk.type = CT_VBRACE_OPEN; + rv = chunk_add_after(&chunk, ref); + } + return(rv); +} + + +/** + * Called when a statement was just closed and the pse_tos was just + * decremented. + * + * - if the TOS is now VBRACE, insert a CT_VBRACE_CLOSE and recurse. + * - if the TOS is a complex statement, call handle_complex_close() + * + * @return true - done with this chunk, false - keep processing + */ +bool close_statement(struct parse_frame *frm, chunk_t *pc) +{ + chunk_t *vbc = pc; + + LOG_FMT(LTOK, "%s:%d] %s '%.*s' type %s stage %d\n", __func__, + pc->orig_line, + get_token_name(pc->type), pc->len, pc->str, + get_token_name(frm->pse[frm->pse_tos].type), + frm->pse[frm->pse_tos].stage); + + if (cpd.consumed) + { + frm->stmt_count = 0; + frm->expr_count = 0; + LOG_FMT(LSTMT, "%s: %d> reset stmt on %.*s\n", + __func__, pc->orig_line, pc->len, pc->str); + } + + /** + * If we are in a virtual brace and we are not ON a CT_VBRACE_CLOSE add one + */ + if (frm->pse[frm->pse_tos].type == CT_VBRACE_OPEN) + { + /* If the current token has already been consumed, then add after it */ + if (cpd.consumed) + { + insert_vbrace_close_after(pc, frm); + } + else + { + /* otherwise, add before it and consume the vbrace */ + vbc = chunk_get_prev_ncnl(pc); + vbc = insert_vbrace_close_after(vbc, frm); + vbc->parent_type = frm->pse[frm->pse_tos].parent; + + frm->level--; + frm->brace_level--; + frm->pse_tos--; + + /* Update the token level */ + pc->level = frm->level; + pc->brace_level = frm->brace_level; + + print_stack(LBCSPOP, "-CS VB ", frm, pc); + + /* And repeat the close */ + close_statement(frm, pc); + return(true); + } + } + + /* See if we are done with a complex statement */ + if (frm->pse[frm->pse_tos].stage != BS_NONE) + { + if (handle_complex_close(frm, vbc)) + { + return(true); + } + } + return(false); +} diff --git a/src/braces.cpp b/src/braces.cpp new file mode 100644 index 0000000000..f47a9addb6 --- /dev/null +++ b/src/braces.cpp @@ -0,0 +1,1061 @@ +/** + * @file braces.cpp + * Adds or removes braces. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +static void convert_brace(chunk_t *br); +static void convert_vbrace(chunk_t *br); +static void convert_vbrace_to_brace(void); +static void examine_braces(void); +static void examine_brace(chunk_t *bopen); +static void move_case_break(void); +static void mod_case_brace(void); +static void mod_full_brace_if_chain(void); +static bool can_remove_braces(chunk_t *bopen); +static bool should_add_braces(chunk_t *vbopen); + + +void do_braces(void) +{ + /* covert vbraces if needed */ + if (((cpd.settings[UO_mod_full_brace_if].a | + cpd.settings[UO_mod_full_brace_do].a | + cpd.settings[UO_mod_full_brace_for].a | + cpd.settings[UO_mod_full_brace_function].a | + cpd.settings[UO_mod_full_brace_while].a) & AV_ADD) != 0) + { + convert_vbrace_to_brace(); + } + + if (((cpd.settings[UO_mod_full_brace_if].a | + cpd.settings[UO_mod_full_brace_do].a | + cpd.settings[UO_mod_full_brace_for].a | + cpd.settings[UO_mod_full_brace_while].a) & AV_REMOVE) != 0) + { + examine_braces(); + } + + if (cpd.settings[UO_mod_full_brace_if_chain].b) + { + mod_full_brace_if_chain(); + } + + /* Mark one-liners */ + chunk_t *pc; + chunk_t *br_open; + chunk_t *tmp; + + pc = chunk_get_head(); + while ((pc = chunk_get_next_ncnl(pc)) != NULL) + { + if (pc->type != CT_BRACE_OPEN) + { + continue; + } + br_open = pc; + + /* Detect empty bodies */ + tmp = chunk_get_next_ncnl(pc); + if ((tmp != NULL) && (tmp->type == CT_BRACE_CLOSE)) + { + br_open->flags |= PCF_EMPTY_BODY; + tmp->flags |= PCF_EMPTY_BODY; + } + + /* Scan for the brace close or a newline */ + tmp = br_open; + while ((tmp = chunk_get_next_nc(tmp)) != NULL) + { + if (chunk_is_newline(tmp)) + { + break; + } + if ((tmp->type == CT_BRACE_CLOSE) && (br_open->level == tmp->level)) + { + br_open->flags |= PCF_ONE_LINER; + tmp->flags |= PCF_ONE_LINER; + break; + } + } + } + + if (cpd.settings[UO_mod_case_brace].a != AV_IGNORE) + { + mod_case_brace(); + } + if (cpd.settings[UO_mod_move_case_break].b) + { + move_case_break(); + } +} + + +/** + * Go backwards to honor brace newline removal limits + */ +static void examine_braces(void) +{ + chunk_t *pc; + chunk_t *prev; + + pc = chunk_get_tail(); + while (pc != NULL) + { + prev = chunk_get_prev_type(pc, CT_BRACE_OPEN, -1); + if ((pc->type == CT_BRACE_OPEN) && + ((pc->flags & PCF_IN_PREPROC) == 0)) + { + if ((((pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE) || + (pc->parent_type == CT_ELSEIF)) && + ((cpd.settings[UO_mod_full_brace_if].a & AV_REMOVE) != 0)) || + ((pc->parent_type == CT_DO) && + ((cpd.settings[UO_mod_full_brace_do].a & AV_REMOVE) != 0)) || + ((pc->parent_type == CT_FOR) && + ((cpd.settings[UO_mod_full_brace_for].a & AV_REMOVE) != 0)) || + ((pc->parent_type == CT_WHILE) && + ((cpd.settings[UO_mod_full_brace_while].a & AV_REMOVE) != 0))) + { + examine_brace(pc); + } + } + pc = prev; + } +} + +/** + * Checks to see if the virtual braces should be converted to real braces. + * - over a certain length + * + * @param vbopen Virtual Brace Open chunk + * @return true (convert to real braces) or false (leave alone) + */ +static bool should_add_braces(chunk_t *vbopen) +{ + chunk_t *pc; + int nl_max = cpd.settings[UO_mod_full_brace_nl].n; + int nl_count = 0; + + if (nl_max == 0) + { + return(false); + } + + LOG_FMT(LBRDEL, "%s: start on %d : ", __func__, vbopen->orig_line); + for (pc = chunk_get_next_nc(vbopen, CNAV_PREPROC); + (pc != NULL) && (pc->level > vbopen->level); + pc = chunk_get_next_nc(pc, CNAV_PREPROC)) + { + if (chunk_is_newline(pc)) + { + nl_count += pc->nl_count; + } + } + if ((pc != NULL) && (nl_count > nl_max) && (vbopen->pp_level == pc->pp_level)) + { + LOG_FMT(LBRDEL, " exceeded %d newlines\n", nl_max); + return(true); + } + return(false); +} + +/** + * Checks to see if the braces can be removed. + * - less than a certain length + * - doesn't mess up if/else stuff + */ +static bool can_remove_braces(chunk_t *bopen) +{ + chunk_t *pc; + chunk_t *prev = NULL; + int semi_count = 0; + int level = bopen->level + 1; + bool hit_semi = false; + bool was_fcn = false; + int nl_max = cpd.settings[UO_mod_full_brace_nl].n; + int nl_count = 0; + int if_count = 0; + int br_count = 0; + + /* Cannot remove braces inside a preprocessor */ + if (bopen->flags & PCF_IN_PREPROC) + { + return(false); + } + pc = chunk_get_next_ncnl(bopen, CNAV_PREPROC); + if ((pc != NULL) && (pc->type == CT_BRACE_CLOSE)) + { + /* Can't remove empty statement */ + return(false); + } + + LOG_FMT(LBRDEL, "%s: start on %d : ", __func__, bopen->orig_line); + + pc = chunk_get_next_nc(bopen, CNAV_PREPROC); + while ((pc != NULL) && (pc->level >= level)) + { + if (chunk_is_newline(pc)) + { + nl_count += pc->nl_count; + if ((nl_max > 0) && (nl_count > nl_max)) + { + LOG_FMT(LBRDEL, " exceeded %d newlines\n", nl_max); + return(false); + } + } + else + { + if (pc->type == CT_BRACE_OPEN) + { + br_count++; + } + else if (pc->type == CT_BRACE_CLOSE) + { + br_count--; + } + else if ((pc->type == CT_IF) || (pc->type == CT_ELSEIF)) + { + if (br_count == 0) + { + if_count++; + } + } + + if (pc->level == level) + { + if ((semi_count > 0) && hit_semi) + { + /* should have bailed due to close brace level drop */ + LOG_FMT(LBRDEL, " no close brace\n"); + return(false); + } + + LOG_FMT(LBRDEL, " [%.*s %d-%d]", pc->len, pc->str, pc->orig_line, semi_count); + + if (pc->type == CT_ELSE) + { + LOG_FMT(LBRDEL, " bailed on %.*s on line %d\n", + pc->len, pc->str, pc->orig_line); + return(false); + } + + was_fcn = (prev != NULL) && (prev->type == CT_FPAREN_CLOSE); + + if (chunk_is_semicolon(pc) || + (pc->type == CT_IF) || + (pc->type == CT_ELSEIF) || + (pc->type == CT_FOR) || + (pc->type == CT_DO) || + (pc->type == CT_WHILE) || + ((pc->type == CT_BRACE_OPEN) && was_fcn)) + { + hit_semi |= chunk_is_semicolon(pc); + if (++semi_count > 1) + { + LOG_FMT(LBRDEL, " bailed on %d because of %.*s on line %d\n", + bopen->orig_line, pc->len, pc->str, pc->orig_line); + return(false); + } + } + } + } + prev = pc; + pc = chunk_get_next_nc(pc, CNAV_PREPROC); + } + + if (pc == NULL) + { + LOG_FMT(LBRDEL, " NULL\n"); + return(false); + } + + LOG_FMT(LBRDEL, " - end on '%s' on line %d. if_count=%d semi_count=%d\n", + get_token_name(pc->type), pc->orig_line, if_count, semi_count); + + return((pc->type == CT_BRACE_CLOSE) && (pc->pp_level == bopen->pp_level)); +} + +/** + * Step forward and count the number of semi colons at the current level. + * Abort if more than 1 or if we enter a preprocessor + */ +static void examine_brace(chunk_t *bopen) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev = NULL; + int semi_count = 0; + int level = bopen->level + 1; + bool hit_semi = false; + bool was_fcn = false; + int nl_max = cpd.settings[UO_mod_full_brace_nl].n; + int nl_count = 0; + int if_count = 0; + int br_count = 0; + + LOG_FMT(LBRDEL, "%s: start on %d : ", __func__, bopen->orig_line); + + pc = chunk_get_next_nc(bopen); + while ((pc != NULL) && (pc->level >= level)) + { + if ((pc->flags & PCF_IN_PREPROC) != 0) + { + LOG_FMT(LBRDEL, " PREPROC\n"); + return; + } + + if (chunk_is_newline(pc)) + { + nl_count += pc->nl_count; + if ((nl_max > 0) && (nl_count > nl_max)) + { + LOG_FMT(LBRDEL, " exceeded %d newlines\n", nl_max); + return; + } + } + else + { + if (pc->type == CT_BRACE_OPEN) + { + br_count++; + } + else if (pc->type == CT_BRACE_CLOSE) + { + br_count--; + } + else if ((pc->type == CT_IF) || (pc->type == CT_ELSEIF)) + { + if (br_count == 0) + { + if_count++; + } + } + + if (pc->level == level) + { + if ((semi_count > 0) && hit_semi) + { + /* should have bailed due to close brace level drop */ + LOG_FMT(LBRDEL, " no close brace\n"); + return; + } + + LOG_FMT(LBRDEL, " [%.*s %d-%d]", pc->len, pc->str, pc->orig_line, semi_count); + + if (pc->type == CT_ELSE) + { + LOG_FMT(LBRDEL, " bailed on %.*s on line %d\n", + pc->len, pc->str, pc->orig_line); + return; + } + + was_fcn = (prev != NULL) && (prev->type == CT_FPAREN_CLOSE); + + if (chunk_is_semicolon(pc) || + (pc->type == CT_IF) || + (pc->type == CT_ELSEIF) || + (pc->type == CT_FOR) || + (pc->type == CT_DO) || + (pc->type == CT_WHILE) || + ((pc->type == CT_BRACE_OPEN) && was_fcn)) + { + hit_semi |= chunk_is_semicolon(pc); + if (++semi_count > 1) + { + LOG_FMT(LBRDEL, " bailed on %d because of %.*s on line %d\n", + bopen->orig_line, pc->len, pc->str, pc->orig_line); + return; + } + } + } + } + prev = pc; + pc = chunk_get_next_nc(pc); + } + + if (pc == NULL) + { + LOG_FMT(LBRDEL, " NULL\n"); + return; + } + + LOG_FMT(LBRDEL, " - end on '%s' on line %d. if_count=%d semi_count=%d\n", + get_token_name(pc->type), pc->orig_line, if_count, semi_count); + + if (pc->type == CT_BRACE_CLOSE) + { + next = chunk_get_next_ncnl(pc); + while ((next != NULL) && (next->type == CT_VBRACE_CLOSE)) + { + next = chunk_get_next_ncnl(next); + } + LOG_FMT(LBRDEL, " next is '%s'\n", get_token_name(next->type)); + if ((if_count > 0) && + ((next->type == CT_ELSE) || (next->type == CT_ELSEIF))) + { + LOG_FMT(LBRDEL, " bailed on because 'else' is next and %d ifs\n", if_count); + return; + } + + if (semi_count > 0) + { + if (bopen->parent_type == CT_ELSE) + { + next = chunk_get_next_ncnl(bopen); + if (next->type == CT_IF) + { + prev = chunk_get_prev_ncnl(bopen); + LOG_FMT(LBRDEL, " else-if removing braces on line %d and %d\n", + bopen->orig_line, pc->orig_line); + + chunk_del(bopen); + chunk_del(pc); + newline_del_between(prev, next); + if (cpd.settings[UO_nl_else_if].a & AV_ADD) + { + newline_add_between(prev, next); + } + return; + } + } + + /* we have a pair of braces with only 1 statement inside */ + convert_brace(bopen); + convert_brace(pc); + + LOG_FMT(LBRDEL, " removing braces on line %d and %d\n", + bopen->orig_line, pc->orig_line); + } + else + { + LOG_FMT(LBRDEL, " empty statement\n"); + } + } + else + { + LOG_FMT(LBRDEL, " not a close brace? - '%.*s'\n", pc->len, pc->str); + } +} + +/** + * Converts a single brace into a virtual brace + */ +static void convert_brace(chunk_t *br) +{ + chunk_t *tmp; + + if (br == NULL) + { + return; + } + else if (br->type == CT_BRACE_OPEN) + { + br->type = CT_VBRACE_OPEN; + br->len = 0; + br->str = ""; + tmp = chunk_get_prev(br); + } + else if (br->type == CT_BRACE_CLOSE) + { + br->type = CT_VBRACE_CLOSE; + br->len = 0; + br->str = ""; + tmp = chunk_get_next(br); + } + else + { + return; + } + + if (chunk_is_newline(tmp)) + { + if (tmp->nl_count > 1) + { + tmp->nl_count--; + } + else + { + if (chunk_safe_to_del_nl(tmp)) + { + chunk_del(tmp); + } + } + } +} + + +/** + * Converts a single virtual brace into a brace + */ +static void convert_vbrace(chunk_t *vbr) +{ + if (vbr == NULL) + { + return; + } + else if (vbr->type == CT_VBRACE_OPEN) + { + vbr->type = CT_BRACE_OPEN; + vbr->len = 1; + vbr->str = "{"; + + /* If the next chunk is a preprocessor, then move the open brace after the + * preprocessor. + */ + chunk_t *tmp = chunk_get_next(vbr); + if ((tmp != NULL) && (tmp->type == CT_PREPROC)) + { + tmp = chunk_get_next(vbr, CNAV_PREPROC); + chunk_move_after(vbr, tmp); + newline_add_after(vbr); + } + } + else if (vbr->type == CT_VBRACE_CLOSE) + { + vbr->type = CT_BRACE_CLOSE; + vbr->len = 1; + vbr->str = "}"; + + /* If the next chunk is a comment, followed by a newline, then + * move the brace after the newline and add another newline after + * the close brace. + */ + chunk_t *tmp = chunk_get_next(vbr); + if (chunk_is_comment(tmp)) + { + tmp = chunk_get_next(tmp); + if (chunk_is_newline(tmp)) + { + chunk_move_after(vbr, tmp); + newline_add_after(vbr); + } + } + } +} + +static void convert_vbrace_to_brace(void) +{ + chunk_t *pc; + chunk_t *tmp; + chunk_t *vbc; + bool in_preproc; + + /* Find every vbrace open */ + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if (pc->type != CT_VBRACE_OPEN) + { + continue; + } + + in_preproc = (pc->flags & PCF_IN_PREPROC) != 0; + + if ((((pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE) || + (pc->parent_type == CT_ELSEIF)) && + ((cpd.settings[UO_mod_full_brace_if].a & AV_ADD) != 0)) + || + ((pc->parent_type == CT_FOR) && + ((cpd.settings[UO_mod_full_brace_for].a & AV_ADD) != 0)) + || + ((pc->parent_type == CT_DO) && + ((cpd.settings[UO_mod_full_brace_do].a & AV_ADD) != 0)) + || + ((pc->parent_type == CT_WHILE) && + ((cpd.settings[UO_mod_full_brace_while].a & AV_ADD) != 0)) + || + ((pc->parent_type == CT_FUNC_DEF) && + ((cpd.settings[UO_mod_full_brace_function].a & AV_ADD) != 0))) + { + /* Find the matching vbrace close */ + vbc = NULL; + tmp = pc; + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if (in_preproc && ((tmp->flags & PCF_IN_PREPROC) == 0)) + { + /* Can't leave a preprocessor */ + break; + } + if ((pc->brace_level == tmp->brace_level) && + (tmp->type == CT_VBRACE_CLOSE) && + (pc->parent_type == tmp->parent_type) && + ((tmp->flags & PCF_IN_PREPROC) == (pc->flags & PCF_IN_PREPROC))) + { + vbc = tmp; + break; + } + } + if (vbc == NULL) + { + continue; + } + + convert_vbrace(pc); + convert_vbrace(vbc); + } + } +} + + +/** + * Adds a comment after the ref chunk + * Returns the added chunk or NULL + */ +chunk_t *insert_comment_after(chunk_t *ref, c_token_t cmt_type, + int cmt_len, const char *cmt_text) +{ + chunk_t new_cmt; + char *txt; + int txt_len; + + if (cmt_len <= 0) + { + cmt_len = strlen(cmt_text); + } + txt_len = cmt_len + 8; /* 8 is big enough for all types */ + + memcpy(&new_cmt, ref, sizeof(new_cmt)); /* [i_a] clone levels, etc. */ + new_cmt.prev = NULL; + new_cmt.next = NULL; + + new_cmt.flags = (ref->flags & PCF_COPY_FLAGS) | PCF_OWN_STR; + new_cmt.type = cmt_type; + + /* allocate memory for the string */ + txt = new char[txt_len]; + if (txt == NULL) + { + return(NULL); + } + + new_cmt.str = txt; + if (cmt_type == CT_COMMENT_CPP) + { + new_cmt.len = snprintf(txt, txt_len, "// %.*s", cmt_len, cmt_text); + } + else + { + new_cmt.len = snprintf(txt, txt_len, "/* %.*s */", cmt_len, cmt_text); + } + /* TODO: expand comment type to cover other comment styles? */ + + new_cmt.column = ref->column + ref->len + 1; + new_cmt.orig_col = new_cmt.column; + + return(chunk_add_after(&new_cmt, ref)); +} + + +/* + * See also it's preprocessor counterpart + * add_long_preprocessor_conditional_block_comment + * in defines.cpp + */ +void add_long_closebrace_comment(void) +{ + chunk_t *pc; + chunk_t *tmp; + chunk_t *br_open; + chunk_t *br_close; + chunk_t *fcn_pc = NULL; + chunk_t *sw_pc = NULL; + int nl_count; + + pc = chunk_get_head(); + while ((pc = chunk_get_next_ncnl(pc)) != NULL) + { + if ((pc->type == CT_FUNC_DEF) || + (pc->type == CT_OC_MSG_DECL)) + { + fcn_pc = pc; + } + else if (pc->type == CT_SWITCH) + { + /* kinda pointless, since it always has the text "switch" */ + sw_pc = pc; + } + if ((pc->type != CT_BRACE_OPEN) || ((pc->flags & PCF_IN_PREPROC) != 0)) + { + continue; + } + + br_open = pc; + nl_count = 0; + + tmp = pc; + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if (chunk_is_newline(tmp)) + { + nl_count += tmp->nl_count; + } + else if ((tmp->level == br_open->level) && + (tmp->type == CT_BRACE_CLOSE)) + { + br_close = tmp; + + //LOG_FMT(LSYS, "found brace pair on lines %d and %d, nl_count=%d\n", + // br_open->orig_line, br_close->orig_line, nl_count); + + /* Found the matching close brace - make sure a newline is next */ + tmp = chunk_get_next(tmp); + if ((tmp == NULL) || chunk_is_newline(tmp)) + { + int nl_min = 0; + chunk_t *tag_pc = NULL; + + if (br_open->parent_type == CT_SWITCH) + { + nl_min = cpd.settings[UO_mod_add_long_switch_closebrace_comment].n; + tag_pc = sw_pc; + } + else if ((br_open->parent_type == CT_FUNC_DEF) || + (br_open->parent_type == CT_OC_MSG_DECL)) + { + nl_min = cpd.settings[UO_mod_add_long_function_closebrace_comment].n; + tag_pc = fcn_pc; + } + + if ((nl_min > 0) && (nl_count >= nl_min) && (tag_pc != NULL)) + { + /* determine the added comment style */ + c_token_t style = (cpd.lang_flags & (LANG_CPP | LANG_CS)) ? + CT_COMMENT_CPP : CT_COMMENT; + + /* Add a comment after the close brace */ + insert_comment_after(br_close, style, + tag_pc->len, tag_pc->str); + } + } + break; + } + } + } +} + + +static void move_case_break(void) +{ + chunk_t *pc; + chunk_t *prev = NULL; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if ((pc->type == CT_BREAK) && + (prev != NULL) && + (prev->type == CT_BRACE_CLOSE) && + (prev->parent_type == CT_CASE)) + { + if (chunk_is_newline(chunk_get_prev(pc)) && + chunk_is_newline(chunk_get_prev(prev))) + { + chunk_swap_lines(prev, pc); + } + } + prev = pc; + } +} + +/** + * Remove the case brace, if allowable. + */ +static chunk_t *mod_case_brace_remove(chunk_t *br_open) +{ + chunk_t *pc; + chunk_t *br_close; + chunk_t *next = chunk_get_next_ncnl(br_open, CNAV_PREPROC); + + LOG_FMT(LMCB, "%s: line %d", __func__, br_open->orig_line); + + /* Find the matching brace close */ + br_close = chunk_get_next_type(br_open, CT_BRACE_CLOSE, br_open->level, CNAV_PREPROC); + if (br_close == NULL) + { + LOG_FMT(LMCB, " - no close\n"); + return(next); + } + + /* Make sure 'break', 'return', 'goto', 'case' or '}' is after the close brace */ + pc = chunk_get_next_ncnl(br_close, CNAV_PREPROC); + if ((pc == NULL) || + ((pc->type != CT_BREAK) && + (pc->type != CT_RETURN) && + (pc->type != CT_CASE) && + (pc->type != CT_GOTO) && + (pc->type != CT_BRACE_CLOSE))) + { + LOG_FMT(LMCB, " - after '%s'\n", + (pc == NULL) ? "" : get_token_name(pc->type)); + return(next); + } + + /* scan to make sure there are no definitions at brace level between braces */ + for (pc = br_open; pc != br_close; pc = chunk_get_next_ncnl(pc, CNAV_PREPROC)) + { + if ((pc->level == (br_open->level + 1)) && (pc->flags & PCF_VAR_DEF)) + { + LOG_FMT(LMCB, " - vardef on line %d: '%.*s'\n", pc->orig_line, pc->len, pc->str); + return(next); + } + } + LOG_FMT(LMCB, " - removing braces on lines %d and %d\n", + br_open->orig_line, br_close->orig_line); + + for (pc = br_open; pc != br_close; pc = chunk_get_next_ncnl(pc, CNAV_PREPROC)) + { + pc->brace_level--; + pc->level--; + } + next = chunk_get_prev(br_open, CNAV_PREPROC); + chunk_del(br_open); + chunk_del(br_close); + return(chunk_get_next(next, CNAV_PREPROC)); +} + +/** + * Add the case brace, if allowable. + */ +static chunk_t *mod_case_brace_add(chunk_t *cl_colon) +{ + chunk_t *pc = cl_colon; + chunk_t *last = NULL; + chunk_t *next = chunk_get_next_ncnl(cl_colon, CNAV_PREPROC); + chunk_t *br_open; + chunk_t *br_close; + chunk_t chunk; + + LOG_FMT(LMCB, "%s: line %d", __func__, pc->orig_line); + + while ((pc = chunk_get_next_ncnl(pc, CNAV_PREPROC)) != NULL) + { + if (pc->level < cl_colon->level) + { + LOG_FMT(LMCB, " - level drop\n"); + return(next); + } + + if ((pc->level == cl_colon->level) && + ((pc->type == CT_CASE) || + (pc->type == CT_BREAK))) + { + last = pc; + //if (pc->type == CT_BREAK) + //{ + // /* Step past the semicolon */ + // last = chunk_get_next_ncnl(chunk_get_next_ncnl(last)); + //} + break; + } + } + + if (last == NULL) + { + LOG_FMT(LMCB, " - NULL last\n"); + return(next); + } + + LOG_FMT(LMCB, " - adding before '%.*s' on line %d\n", last->len, last->str, last->orig_line); + + memset(&chunk, 0, sizeof(chunk)); + + chunk.type = CT_BRACE_OPEN; + chunk.orig_line = cl_colon->orig_line; + chunk.parent_type = CT_CASE; + chunk.level = cl_colon->level; + chunk.brace_level = cl_colon->brace_level; + chunk.flags = pc->flags & PCF_COPY_FLAGS; + chunk.str = "{"; + chunk.len = 1; + + br_open = chunk_add_after(&chunk, cl_colon); + + chunk.type = CT_BRACE_CLOSE; + chunk.orig_line = last->orig_line; + chunk.str = "}"; + + br_close = chunk_add_before(&chunk, last); + + for (pc = chunk_get_next(br_open, CNAV_PREPROC); + pc != br_close; + pc = chunk_get_next(pc, CNAV_PREPROC)) + { + pc->level++; + pc->brace_level++; + } + + return(br_open); +} + + +static void mod_case_brace(void) +{ + chunk_t *pc = chunk_get_head(); + chunk_t *next; + + while (pc != NULL) + { + next = chunk_get_next_ncnl(pc, CNAV_PREPROC); + if (next == NULL) + { + return; + } + + if ((cpd.settings[UO_mod_case_brace].a == AV_REMOVE) && + (pc->type == CT_BRACE_OPEN) && + (pc->parent_type == CT_CASE)) + { + pc = mod_case_brace_remove(pc); + } + else if ((cpd.settings[UO_mod_case_brace].a & AV_ADD) && + (pc->type == CT_CASE_COLON) && + (next->type != CT_BRACE_OPEN) && + (next->type != CT_BRACE_CLOSE) && + (next->type != CT_CASE)) + { + pc = mod_case_brace_add(pc); + } + else + { + pc = chunk_get_next_ncnl(pc, CNAV_PREPROC); + } + } +} + +/** + * Traverse the if chain and see if all can be removed + */ +static void process_if_chain(chunk_t *br_start) +{ + chunk_t *braces[256]; + chunk_t *br_close; + int br_cnt = 0; + chunk_t *pc; + bool must_have_braces = false; + bool tmp; + + pc = br_start; + + LOG_FMT(LBRCH, "%s: if starts on line %d\n", __func__, br_start->orig_line); + + while (pc != NULL) + { + if (pc->type == CT_BRACE_OPEN) + { + tmp = can_remove_braces(pc); + LOG_FMT(LBRCH, " [%d] line %d - can%s remove %s\n", + br_cnt, pc->orig_line, tmp ? "" : "not", + get_token_name(pc->type)); + if (!tmp) + { + must_have_braces = true; + } + } + else + { + tmp = should_add_braces(pc); + if (tmp) + { + must_have_braces = true; + } + LOG_FMT(LBRCH, " [%d] line %d - %s %s\n", + br_cnt, pc->orig_line, tmp ? "should add" : "ignore", + get_token_name(pc->type)); + } + + braces[br_cnt++] = pc; + br_close = chunk_get_next_type(pc, (c_token_t)(pc->type + 1), pc->level, CNAV_PREPROC); + if (br_close == NULL) + { + break; + } + braces[br_cnt++] = br_close; + + pc = chunk_get_next_ncnl(br_close, CNAV_PREPROC); + if ((pc == NULL) || (pc->type != CT_ELSE)) + { + break; + } + pc = chunk_get_next_ncnl(pc, CNAV_PREPROC); + if ((pc != NULL) && (pc->type == CT_ELSEIF)) + { + while ((pc != NULL) && (pc->type != CT_VBRACE_OPEN) && (pc->type != CT_BRACE_OPEN)) + { + pc = chunk_get_next_ncnl(pc, CNAV_PREPROC); + } + } + if (pc == NULL) + { + break; + } + if ((pc->type != CT_BRACE_OPEN) && (pc->type != CT_VBRACE_OPEN)) + { + break; + } + } + + if (must_have_braces) + { + LOG_FMT(LBRCH, "%s: add braces on lines[%d]:", __func__, br_cnt); + while (--br_cnt >= 0) + { + if ((braces[br_cnt]->type == CT_VBRACE_OPEN) || + (braces[br_cnt]->type == CT_VBRACE_CLOSE)) + { + LOG_FMT(LBRCH, " %d", braces[br_cnt]->orig_line); + convert_vbrace(braces[br_cnt]); + } + else + { + LOG_FMT(LBRCH, " {%d}", braces[br_cnt]->orig_line); + } + braces[br_cnt] = NULL; + } + LOG_FMT(LBRCH, "\n"); + } + else + { + LOG_FMT(LBRCH, "%s: remove braces on lines[%d]:", __func__, br_cnt); + while (--br_cnt >= 0) + { + if ((braces[br_cnt]->type == CT_BRACE_OPEN) || + (braces[br_cnt]->type == CT_BRACE_CLOSE)) + { + LOG_FMT(LBRCH, " {%d}", braces[br_cnt]->orig_line); + convert_brace(braces[br_cnt]); + } + else + { + LOG_FMT(LBRCH, " %d", braces[br_cnt]->orig_line); + } + braces[br_cnt] = NULL; + } + LOG_FMT(LBRCH, "\n"); + } +} + +static void mod_full_brace_if_chain(void) +{ + chunk_t *pc; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (((pc->type == CT_BRACE_OPEN) || (pc->type == CT_VBRACE_OPEN)) && + (pc->parent_type == CT_IF)) + { + process_if_chain(pc); + } + } +} diff --git a/src/char_table.h b/src/char_table.h new file mode 100644 index 0000000000..0a3c738023 --- /dev/null +++ b/src/char_table.h @@ -0,0 +1,68 @@ +/** + * @file char_table.h + * A simple table to help tokenize stuff. + * Used to parse strings (paired char) and words. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef CHAR_TABLE_H_INCLUDED +#define CHAR_TABLE_H_INCLUDED + + +/** + * bit0-7 = paired char + * bit8 = OK for keyword 1st char + * bit9 = OK for keyword 2+ char + */ +struct CharTable +{ + static int chars[128]; + + enum + { + KW1 = 0x0100, + KW2 = 0x0200, + }; + + static inline int Get(char ch) + { + return(chars[(int)ch & 0x7f]); + } + + + static inline bool IsKw1(char ch) + { + return((Get(ch) & KW1) != 0); + } + + + static inline bool IsKw2(char ch) + { + return((Get(ch) & KW2) != 0); + } +}; + +#ifdef DEFINE_CHAR_TABLE +int CharTable::chars[128] = +{ + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* [........] */ + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* [........] */ + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* [........] */ + 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* [........] */ + 0x000, 0x000, 0x022, 0x000, 0x300, 0x000, 0x000, 0x027, /* [ !"#$%&'] */ + 0x029, 0x028, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* [()*+,-./] */ + 0x200, 0x200, 0x200, 0x200, 0x200, 0x200, 0x200, 0x200, /* [01234567] */ + 0x200, 0x200, 0x000, 0x000, 0x03e, 0x000, 0x03c, 0x000, /* [89:;<=>?] */ + 0x200, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, /* [@ABCDEFG] */ + 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, /* [HIJKLMNO] */ + 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, /* [PQRSTUVW] */ + 0x300, 0x300, 0x300, 0x05d, 0x000, 0x05b, 0x000, 0x300, /* [XYZ[\]^_] */ + 0x060, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, /* [`abcdefg] */ + 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, /* [hijklmno] */ + 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, 0x300, /* [pqrstuvw] */ + 0x300, 0x300, 0x300, 0x07d, 0x000, 0x07b, 0x000, 0x000, /* [xyz{|}~.] */ +}; +#endif /* DEFINE_CHAR_TABLE */ + +#endif /* CHAR_TABLE_H_INCLUDED */ diff --git a/src/chunk_list.cpp b/src/chunk_list.cpp new file mode 100644 index 0000000000..a7b373ab40 --- /dev/null +++ b/src/chunk_list.cpp @@ -0,0 +1,649 @@ +/** + * @file chunk_list.cpp + * Manages and navigates the list of chunks. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "chunk_list.h" +#include +#include + +#include "ListManager.h" +#include "prototypes.h" + +typedef ListManager ChunkList; + +ChunkList g_cl; + +chunk_t *chunk_get_head(void) +{ + return(g_cl.GetHead()); +} + + +chunk_t *chunk_get_tail(void) +{ + return(g_cl.GetTail()); +} + + +chunk_t *chunk_get_next(chunk_t *cur, chunk_nav_t nav) +{ + if (cur == NULL) + { + return(NULL); + } + chunk_t *pc = g_cl.GetNext(cur); + if ((pc == NULL) || (nav == CNAV_ALL)) + { + return(pc); + } + if (cur->flags & PCF_IN_PREPROC) + { + /* If in a preproc, return NULL if trying to leave */ + if ((pc->flags & PCF_IN_PREPROC) == 0) + { + return(NULL); + } + return(pc); + } + /* Not in a preproc, skip any proproc */ + while ((pc != NULL) && (pc->flags & PCF_IN_PREPROC)) + { + pc = g_cl.GetNext(pc); + } + return(pc); +} + + +chunk_t *chunk_get_prev(chunk_t *cur, chunk_nav_t nav) +{ + if (cur == NULL) + { + return(NULL); + } + chunk_t *pc = g_cl.GetPrev(cur); + if ((pc == NULL) || (nav == CNAV_ALL)) + { + return(pc); + } + if (cur->flags & PCF_IN_PREPROC) + { + /* If in a preproc, return NULL if trying to leave */ + if ((pc->flags & PCF_IN_PREPROC) == 0) + { + return(NULL); + } + return(pc); + } + /* Not in a preproc, skip any proproc */ + while ((pc != NULL) && (pc->flags & PCF_IN_PREPROC)) + { + pc = g_cl.GetPrev(pc); + } + return(pc); +} + + +chunk_t *chunk_dup(const chunk_t *pc_in) +{ + chunk_t *pc; + + /* Allocate the entry */ + pc = new chunk_t; + if (pc == NULL) + { + exit(1); + } + + /* Copy all fields and then init the entry */ + *pc = *pc_in; + g_cl.InitEntry(pc); + + return(pc); +} + + +/** + * Add to the tail of the list + */ +chunk_t *chunk_add(const chunk_t *pc_in) +{ + chunk_t *pc; + + if ((pc = chunk_dup(pc_in)) != NULL) + { + g_cl.AddTail(pc); + } + return(pc); +} + + +/** + * Add a copy after the given chunk. + * If ref is NULL, add at the head. + */ +chunk_t *chunk_add_after(const chunk_t *pc_in, chunk_t *ref) +{ + chunk_t *pc; + + if ((pc = chunk_dup(pc_in)) != NULL) + { + if (ref != NULL) + { + g_cl.AddAfter(pc, ref); + } + else + { + g_cl.AddHead(pc); + } + } + return(pc); +} + + +/** + * Add a copy before the given chunk. + * If ref is NULL, add at the head. + */ +chunk_t *chunk_add_before(const chunk_t *pc_in, chunk_t *ref) +{ + chunk_t *pc; + + if ((pc = chunk_dup(pc_in)) != NULL) + { + if (ref != NULL) + { + g_cl.AddBefore(pc, ref); + } + else + { + g_cl.AddTail(pc); + } + } + return(pc); +} + + +void chunk_del(chunk_t *pc) +{ + g_cl.Pop(pc); + if ((pc->flags & PCF_OWN_STR) && (pc->str != NULL)) + { + delete[] (char *)pc->str; + pc->str = NULL; + } + delete pc; +} + + +void chunk_move_after(chunk_t *pc_in, chunk_t *ref) +{ + g_cl.Pop(pc_in); + g_cl.AddAfter(pc_in, ref); + + /* HACK: Adjust the original column */ + pc_in->column = ref->column + space_col_align(ref, pc_in); + pc_in->orig_col = pc_in->column; + pc_in->orig_col_end = pc_in->orig_col + pc_in->len; +} + + +/** + * Gets the next NEWLINE chunk + */ +chunk_t *chunk_get_next_nl(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + } while ((pc != NULL) && !chunk_is_newline(pc)); + return(pc); +} + + +/** + * Gets the prev NEWLINE chunk + */ +chunk_t *chunk_get_prev_nl(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && !chunk_is_newline(pc)); + return(pc); +} + + +/** + * Gets the next non-NEWLINE chunk + */ +chunk_t *chunk_get_next_nnl(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + } while (chunk_is_newline(pc)); + return(pc); +} + + +/** + * Gets the prev non-NEWLINE chunk + */ +chunk_t *chunk_get_prev_nnl(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && chunk_is_newline(pc)); + return(pc); +} + + +/** + * Gets the next non-NEWLINE and non-comment chunk + */ +chunk_t *chunk_get_next_ncnl(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + } while ((pc != NULL) && (chunk_is_comment(pc) || chunk_is_newline(pc))); + return(pc); +} + + +/** + * Gets the next non-NEWLINE and non-comment chunk, non-preprocessor chunk + */ +chunk_t *chunk_get_next_ncnlnp(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + if (chunk_is_preproc(cur)) + { + do + { + pc = chunk_get_next(pc, nav); + } while ((pc != NULL) && chunk_is_preproc(pc) && + (chunk_is_comment(pc) || chunk_is_newline(pc))); + } + else + { + do + { + pc = chunk_get_next(pc, nav); + } while ((pc != NULL) && (chunk_is_comment(pc) || + chunk_is_newline(pc) || + chunk_is_preproc(pc))); + } + return(pc); +} + + +/** + * Gets the prev non-NEWLINE and non-comment chunk, non-preprocessor chunk + */ +chunk_t *chunk_get_prev_ncnlnp(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + if (chunk_is_preproc(cur)) + { + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && chunk_is_preproc(pc) && + (chunk_is_comment(pc) || chunk_is_newline(pc))); + } + else + { + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && (chunk_is_comment(pc) || + chunk_is_newline(pc) || + chunk_is_preproc(pc))); + } + return(pc); +} + + +/** + * Gets the next non-blank chunk + */ +chunk_t *chunk_get_next_nblank(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + } while ((pc != NULL) && (chunk_is_comment(pc) || + chunk_is_newline(pc) || + chunk_is_blank(pc))); + return(pc); +} + + +/** + * Gets the prev non-blank chunk + */ +chunk_t *chunk_get_prev_nblank(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && (chunk_is_comment(pc) || chunk_is_newline(pc) || + chunk_is_blank(pc))); + return(pc); +} + + +/** + * Gets the next non-comment chunk + */ +chunk_t *chunk_get_next_nc(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + } while ((pc != NULL) && chunk_is_comment(pc)); + return(pc); +} + + +/** + * Gets the prev non-NEWLINE and non-comment chunk + */ +chunk_t *chunk_get_prev_ncnl(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && (chunk_is_comment(pc) || chunk_is_newline(pc))); + return(pc); +} + + +/** + * Gets the prev non-comment chunk + */ +chunk_t *chunk_get_prev_nc(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + } while ((pc != NULL) && chunk_is_comment(pc)); + return(pc); +} + + +/** + * Grabs the next chunk of the given type at the level. + * + * @param cur Starting chunk + * @param type The type to look for + * @param level -1 (any level) or the level to match + * @return NULL or the match + */ +chunk_t *chunk_get_next_type(chunk_t *cur, c_token_t type, + int level, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + if ((pc == NULL) || + ((pc->type == type) && ((pc->level == level) || (level < 0)))) + { + break; + } + } while (pc != NULL); + return(pc); +} + + +chunk_t *chunk_get_next_str(chunk_t *cur, const char *str, int len, int level, + chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + if ((pc == NULL) || + ((pc->len == len) && (memcmp(str, pc->str, len) == 0) && + ((pc->level == level) || (level < 0)))) + { + break; + } + } while (pc != NULL); + return(pc); +} + + +/** + * Grabs the prev chunk of the given type at the level. + * + * @param cur Starting chunk + * @param type The type to look for + * @param level -1 (any level) or the level to match + * @return NULL or the match + */ +chunk_t *chunk_get_prev_type(chunk_t *cur, c_token_t type, + int level, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + if ((pc == NULL) || + ((pc->type == type) && ((pc->level == level) || (level < 0)))) + { + break; + } + } while (pc != NULL); + return(pc); +} + + +chunk_t *chunk_get_prev_str(chunk_t *cur, const char *str, int len, int level, + chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + if ((pc == NULL) || + ((pc->len == len) && (memcmp(str, pc->str, len) == 0) && + ((pc->level == level) || (level < 0)))) + { + break; + } + } while (pc != NULL); + return(pc); +} + + +/** + * Check to see if there is a newline bewteen the two chunks + */ +bool chunk_is_newline_between(chunk_t *start, chunk_t *end) +{ + chunk_t *pc; + + for (pc = start; pc != end; pc = chunk_get_next(pc)) + { + if (chunk_is_newline(pc)) + { + return(true); + } + } + return(false); +} + + +/** + * Swaps the two chunks. + * + * @param pc1 The first chunk + * @param pc2 The second chunk + */ +void chunk_swap(chunk_t *pc1, chunk_t *pc2) +{ + g_cl.Swap(pc1, pc2); +} + + +/** + * Finds the first chunk on the line that pc is on. + * This just backs up until a newline or NULL is hit. + * + * given: [ a - b - c - n1 - d - e - n2 ] + * input: [ a | b | c | n1 ] => a + * input: [ d | e | n2 ] => d + */ +chunk_t *chunk_first_on_line(chunk_t *pc) +{ + chunk_t *first = pc; + + while (((pc = chunk_get_prev(pc)) != NULL) && !chunk_is_newline(pc)) + { + first = pc; + } + + return(first); +} + + +/** + * Swaps two lines that are started with the specified chunks. + * + * @param pc1 The first chunk of line 1 + * @param pc2 The first chunk of line 2 + */ +void chunk_swap_lines(chunk_t *pc1, chunk_t *pc2) +{ + chunk_t *ref2; + chunk_t *tmp; + + pc1 = chunk_first_on_line(pc1); + pc2 = chunk_first_on_line(pc2); + + if ((pc1 == NULL) || (pc2 == NULL) || (pc1 == pc2)) + { + return; + } + + /** + * Example start: + * ? - start1 - a1 - b1 - nl1 - ? - ref2 - start2 - a2 - b2 - nl2 - ? + * ^- pc1 ^- pc2 + */ + ref2 = chunk_get_prev(pc2); + + /* Move the line started at pc2 before pc1 */ + while ((pc2 != NULL) && !chunk_is_newline(pc2)) + { + tmp = chunk_get_next(pc2); + g_cl.Pop(pc2); + g_cl.AddBefore(pc2, pc1); + pc2 = tmp; + } + + /** + * Should now be: + * ? - start2 - a2 - b2 - start1 - a1 - b1 - nl1 - ? - ref2 - nl2 - ? + * ^- pc1 ^- pc2 + */ + + /* Now move the line started at pc1 after ref2 */ + while ((pc1 != NULL) && !chunk_is_newline(pc1)) + { + tmp = chunk_get_next(pc1); + g_cl.Pop(pc1); + if (ref2 != NULL) + { + g_cl.AddAfter(pc1, ref2); + } + else + { + g_cl.AddHead(pc1); + } + ref2 = pc1; + pc1 = tmp; + } + + /** + * Should now be: + * ? - start2 - a2 - b2 - nl1 - ? - ref2 - start1 - a1 - b1 - nl2 - ? + * ^- pc1 ^- pc2 + */ + + /* pc1 and pc2 should be the newlines for their lines. + * swap the chunks and the nl_count so that the spacing remains the same. + */ + if ((pc1 != NULL) && (pc2 != NULL)) + { + int nl_count = pc1->nl_count; + + pc1->nl_count = pc2->nl_count; + pc2->nl_count = nl_count; + + chunk_swap(pc1, pc2); + } +} + + +/** + * Gets the next non-vbrace chunk + */ +chunk_t *chunk_get_next_nvb(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_next(pc, nav); + } while (chunk_is_vbrace(pc)); + return(pc); +} + + +/** + * Gets the prev non-vbrace chunk + */ +chunk_t *chunk_get_prev_nvb(chunk_t *cur, chunk_nav_t nav) +{ + chunk_t *pc = cur; + + do + { + pc = chunk_get_prev(pc, nav); + } while (chunk_is_vbrace(pc)); + return(pc); +} diff --git a/src/chunk_list.h b/src/chunk_list.h new file mode 100644 index 0000000000..d2cd059dd2 --- /dev/null +++ b/src/chunk_list.h @@ -0,0 +1,275 @@ +/** + * @file chunk_list.c + * Manages and navigates the list of chunks. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef CHUNK_LIST_H_INCLUDED +#define CHUNK_LIST_H_INCLUDED + +#include "uncrustify_types.h" +#include "char_table.h" + + +/** + * Specifies how to handle proprocessors. + * CNAV_ALL (default) + * - return the true next/prev + * + * CNAV_PREPROC + * - If not in a preprocessor, skip over any encountered preprocessor stuff + * - If in a preprocessor, fail to leave (return NULL) + */ +enum chunk_nav_t +{ + CNAV_ALL, + CNAV_PREPROC, +}; + + +chunk_t *chunk_dup(const chunk_t *pc_in); + +chunk_t *chunk_add(const chunk_t *pc_in); +chunk_t *chunk_add_after(const chunk_t *pc_in, chunk_t *ref); +chunk_t *chunk_add_before(const chunk_t *pc_in, chunk_t *ref); + +void chunk_del(chunk_t *pc); +void chunk_move_after(chunk_t *pc_in, chunk_t *ref); + +chunk_t *chunk_get_head(void); +chunk_t *chunk_get_tail(void); +chunk_t *chunk_get_next(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); + +void chunk_swap(chunk_t *pc1, chunk_t *pc2); +void chunk_swap_lines(chunk_t *pc1, chunk_t *pc2); +chunk_t *chunk_first_on_line(chunk_t *pc); + +chunk_t *chunk_get_next_nl(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_next_nc(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_next_nnl(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_next_ncnl(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_next_ncnlnp(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); + +chunk_t *chunk_get_next_nblank(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_nblank(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); + +chunk_t *chunk_get_prev_nl(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_nc(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_nnl(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_ncnl(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_ncnlnp(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); + +chunk_t *chunk_get_next_type(chunk_t *cur, c_token_t type, int level, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_type(chunk_t *cur, c_token_t type, int level, chunk_nav_t nav = CNAV_ALL); + +chunk_t *chunk_get_next_str(chunk_t *cur, const char *str, int len, int level, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_str(chunk_t *cur, const char *str, int len, int level, chunk_nav_t nav = CNAV_ALL); + +chunk_t *chunk_get_next_nvb(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); +chunk_t *chunk_get_prev_nvb(chunk_t *cur, chunk_nav_t nav = CNAV_ALL); + +/** + * Skips to the closing match for the current paren/brace/square. + * + * @param cur The opening paren/brace/square + * @return NULL or the matching paren/brace/square + */ +static_inline +chunk_t *chunk_skip_to_match(chunk_t *cur, chunk_nav_t nav = CNAV_ALL) +{ + if ((cur != NULL) && + ((cur->type == CT_PAREN_OPEN) || + (cur->type == CT_SPAREN_OPEN) || + (cur->type == CT_FPAREN_OPEN) || + (cur->type == CT_BRACE_OPEN) || + (cur->type == CT_VBRACE_OPEN) || + (cur->type == CT_SQUARE_OPEN))) + { + return(chunk_get_next_type(cur, (c_token_t)(cur->type + 1), cur->level, nav)); + } + return(cur); +} + + +static_inline +bool chunk_is_comment(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_COMMENT) || + (pc->type == CT_COMMENT_MULTI) || + (pc->type == CT_COMMENT_CPP))); +} + + +static_inline +bool chunk_is_single_line_comment(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_COMMENT) || + (pc->type == CT_COMMENT_CPP))); +} + + +static_inline +bool chunk_is_newline(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_NEWLINE) || + (pc->type == CT_NL_CONT))); +} + + +static_inline +bool chunk_is_semicolon(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_SEMICOLON) || + (pc->type == CT_VSEMICOLON))); +} + + +static_inline +bool chunk_is_blank(chunk_t *pc) +{ + return((pc != NULL) && (pc->len == 0)); +} + + +static_inline +bool chunk_is_preproc(chunk_t *pc) +{ + return((pc != NULL) && ((pc->flags & PCF_IN_PREPROC) != 0)); +} + + +static_inline +bool chunk_is_type(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_TYPE) || + (pc->type == CT_PTR_TYPE) || + (pc->type == CT_BYREF) || + (pc->type == CT_DC_MEMBER) || + (pc->type == CT_QUALIFIER) || + (pc->type == CT_STRUCT) || + (pc->type == CT_ENUM) || + (pc->type == CT_UNION))); +} + + +static_inline +bool chunk_is_token(chunk_t *pc, c_token_t c_token) +{ + return((pc != NULL) && (pc->type == c_token)); +} + + +static_inline +bool chunk_is_str(chunk_t *pc, const char *str, int len) +{ + return((pc != NULL) && (pc->len == len) && (memcmp(pc->str, str, len) == 0)); +} + + +static_inline +bool chunk_is_str_case(chunk_t *pc, const char *str, int len) +{ + return((pc != NULL) && (pc->len == len) && (strncasecmp(pc->str, str, len) == 0)); +} + + +static_inline +bool chunk_is_word(chunk_t *pc) +{ + return((pc != NULL) && (pc->len >= 1) && CharTable::IsKw1(pc->str[0])); +} + + +static_inline +bool chunk_is_star(chunk_t *pc) +{ + return((pc != NULL) && (pc->len == 1) && (pc->str[0] == '*')); +} + + +static_inline +bool chunk_is_addr(chunk_t *pc) +{ + return((pc != NULL) && (pc->len == 1) && (pc->str[0] == '&')); +} + + +bool chunk_is_newline_between(chunk_t *start, chunk_t *end); + +static_inline +bool chunk_is_closing_brace(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_VBRACE_CLOSE))); +} + + +static_inline +bool chunk_is_opening_brace(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_VBRACE_OPEN))); +} + + +static_inline +bool chunk_is_vbrace(chunk_t *pc) +{ + return((pc != NULL) && ((pc->type == CT_VBRACE_CLOSE) || + (pc->type == CT_VBRACE_OPEN))); +} + + +static_inline +bool chunk_is_paren_open(chunk_t *pc) +{ + return((pc != NULL) && + ((pc->type == CT_PAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN))); +} + + +static_inline +bool chunk_is_paren_close(chunk_t *pc) +{ + return((pc != NULL) && + ((pc->type == CT_PAREN_CLOSE) || + (pc->type == CT_SPAREN_CLOSE) || + (pc->type == CT_FPAREN_CLOSE))); +} + + +/** + * Returns true if either chunk is null or both have the same preproc flags. + * If this is true, you can remove a newline/nl_cont between the two. + */ +static_inline +bool chunk_same_preproc(chunk_t *pc1, chunk_t *pc2) +{ + return((pc1 == NULL) || (pc2 == NULL) || + ((pc1->flags & PCF_IN_PREPROC) == (pc2->flags & PCF_IN_PREPROC))); +} + + +/** + * Returns true if it is safe to delete the newline token. + * The prev and next chunks must have the same PCF_IN_PREPROC flag AND + * the newline can't be after a C++ comment. + */ +static_inline +bool chunk_safe_to_del_nl(chunk_t *nl) +{ + chunk_t *tmp = chunk_get_prev(nl); + + if ((tmp != NULL) && (tmp->type == CT_COMMENT_CPP)) + { + return(false); + } + return(chunk_same_preproc(chunk_get_prev(nl), chunk_get_next(nl))); +} + + +#endif /* CHUNK_LIST_H_INCLUDED */ diff --git a/src/combine.cpp b/src/combine.cpp new file mode 100644 index 0000000000..eee1fa7c6f --- /dev/null +++ b/src/combine.cpp @@ -0,0 +1,3744 @@ +/** + * @file combine.cpp + * Labels the chunks as needed. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "ChunkStack.h" +#include "prototypes.h" + +#include +#include +#include +#include +#include "unc_ctype.h" +#include + +static void fix_fcn_def_params(chunk_t *pc); +static void fix_typedef(chunk_t *pc); +static void fix_enum_struct_union(chunk_t *pc); +static void fix_casts(chunk_t *pc); +static void fix_type_cast(chunk_t *pc); +static chunk_t *fix_var_def(chunk_t *pc); +static void mark_function(chunk_t *pc); +static void mark_struct_union_body(chunk_t *start); +static chunk_t *mark_variable_definition(chunk_t *start); + +static void mark_define_expressions(void); +static void process_returns(void); +static chunk_t *process_return(chunk_t *pc); +static void mark_class_ctor(chunk_t *pclass); +static void mark_namespace(chunk_t *pns); +static void mark_function_type(chunk_t *pc); +static void mark_cpp_constructor(chunk_t *pc); +static void mark_lvalue(chunk_t *pc); +static void mark_template_func(chunk_t *pc, chunk_t *pc_next); +static void mark_exec_sql(chunk_t *pc); +static void handle_oc_class(chunk_t *pc); +static void handle_oc_message_decl(chunk_t *pc); +static void handle_oc_message_send(chunk_t *pc); +static void handle_cs_square_stmt(chunk_t *pc); +static void handle_cs_property(chunk_t *pc); +static void handle_template(chunk_t *pc); +static void handle_wrap(chunk_t *pc); + +void make_type(chunk_t *pc) +{ + if (pc != NULL) + { + if (pc->type == CT_WORD) + { + pc->type = CT_TYPE; + } + else if (chunk_is_star(pc)) + { + pc->type = CT_PTR_TYPE; + } + else if (chunk_is_addr(pc)) + { + pc->type = CT_BYREF; + } + } +} + + +/** + * Flags everything from the open paren to the close paren. + * + * @param po Pointer to the open parenthesis + * @return The token after the close paren + */ +static chunk_t *flag_parens(chunk_t *po, UINT32 flags, + c_token_t opentype, c_token_t parenttype, + bool parent_all) +{ + chunk_t *paren_close; + chunk_t *pc; + + paren_close = chunk_skip_to_match(po, CNAV_PREPROC); + if (paren_close == NULL) + { + LOG_FMT(LERR, "%s: no match for [%.*s] at [%d:%d]\n", + __func__, po->len, po->str, po->orig_line, po->orig_col); + return(NULL); + } + + if ((paren_close != NULL) && (po != paren_close)) + { + if ((flags != 0) || + (parent_all && (parenttype != CT_NONE))) + { + for (pc = chunk_get_next(po, CNAV_PREPROC); + pc != paren_close; + pc = chunk_get_next(pc, CNAV_PREPROC)) + { + pc->flags |= flags; + if (parent_all) + { + pc->parent_type = parenttype; + } + } + } + + if (opentype != CT_NONE) + { + po->type = opentype; + paren_close->type = (c_token_t)(opentype + 1); + } + + if (parenttype != CT_NONE) + { + po->parent_type = parenttype; + paren_close->parent_type = parenttype; + } + } + return(chunk_get_next_ncnl(paren_close, CNAV_PREPROC)); +} + + +/** + * Sets the parent of the open paren/brace/square/angle and the closing. + * Note - it is assumed that pc really does point to an open item and the + * close must be open + 1. + * + * @param start The open paren + * @param parent The type to assign as the parent + * @reutrn The chunk after the close paren + */ +chunk_t *set_paren_parent(chunk_t *start, c_token_t parent) +{ + chunk_t *end; + + end = chunk_get_next_type(start, (c_token_t)(start->type + 1), start->level, CNAV_PREPROC); + if (end != NULL) + { + start->parent_type = parent; + end->parent_type = parent; + } + return(chunk_get_next_ncnl(end, CNAV_PREPROC)); +} + + +/* Scan backwards to see if we might be on a type declaration */ +static bool chunk_ends_type(chunk_t *pc) +{ + bool ret = false; + + for (/* nada */; pc != NULL; pc = chunk_get_prev_ncnl(pc)) + { + LOG_FMT(LFTYPE, "%s: [%s] %.*s flags %x on line %d, col %d\n", + __func__, get_token_name(pc->type), pc->len, pc->str, + pc->flags, pc->orig_line, pc->orig_col); + + if ((pc->type == CT_WORD) || + (pc->type == CT_TYPE) || + (pc->type == CT_STRUCT) || + (pc->type == CT_DC_MEMBER) || + (pc->type == CT_QUALIFIER)) + { + continue; + } + + if (chunk_is_semicolon(pc) || + (pc->type == CT_BRACE_OPEN) || + (pc->type == CT_BRACE_CLOSE)) + { + ret = true; + } + break; + } + + if (pc == NULL) + { + /* first token */ + ret = true; + } + + LOG_FMT(LFTYPE, "%s verdict: %s\n", __func__, ret ? "yes" : "no"); + + return(ret); +} + + +/** + * This is called on every chunk. + * First on all non-preprocessor chunks and then on each preprocessor chunk. + * It does all the detection and classifying. + */ +void do_symbol_check(chunk_t *prev, chunk_t *pc, chunk_t *next) +{ + chunk_t *tmp; + + // LOG_FMT(LSYS, " %3d > ['%.*s' %s] ['%.*s' %s] ['%.*s' %s]\n", + // pc->orig_line, + // prev->len, prev->str, get_token_name(prev->type), + // pc->len, pc->str, get_token_name(pc->type), + // next->len, next->str, get_token_name(next->type)); + + /* D stuff */ + if ((next->type == CT_PAREN_OPEN) && + ((pc->type == CT_D_CAST) || + (pc->type == CT_DELEGATE) || + (pc->type == CT_ALIGN))) + { + /* mark the parenthesis parent */ + tmp = set_paren_parent(next, pc->type); + + /* For a D cast - convert the next item */ + if ((pc->type == CT_D_CAST) && (tmp != NULL)) + { + if (tmp->type == CT_STAR) + { + tmp->type = CT_DEREF; + } + else if (tmp->type == CT_AMP) + { + tmp->type = CT_ADDR; + } + else if (tmp->type == CT_MINUS) + { + tmp->type = CT_NEG; + } + else if (tmp->type == CT_PLUS) + { + tmp->type = CT_POS; + } + } + + /* For a delegate, mark previous words as types and the item after the + * close paren as a variable def + */ + if (pc->type == CT_DELEGATE) + { + if (tmp != NULL) + { + tmp->parent_type = CT_DELEGATE; + if (tmp->level == tmp->brace_level) + { + tmp->flags |= PCF_VAR_1ST_DEF; + } + } + + for (tmp = chunk_get_prev_ncnl(pc); tmp != NULL; tmp = chunk_get_prev_ncnl(tmp)) + { + if (chunk_is_semicolon(tmp) || + (tmp->type == CT_BRACE_OPEN) || + (tmp->type == CT_VBRACE_OPEN)) + { + break; + } + make_type(tmp); + } + } + + if ((pc->type == CT_ALIGN) && (tmp != NULL)) + { + if (tmp->type == CT_BRACE_OPEN) + { + set_paren_parent(tmp, pc->type); + } + else if (tmp->type == CT_COLON) + { + tmp->parent_type = pc->type; + } + } + } /* paren open + cast/align/delegate */ + + if (pc->type == CT_INVARIANT) + { + if (next->type == CT_PAREN_OPEN) + { + next->parent_type = pc->type; + tmp = chunk_get_next(next); + while (tmp != NULL) + { + if (tmp->type == CT_PAREN_CLOSE) + { + tmp->parent_type = pc->type; + break; + } + make_type(tmp); + tmp = chunk_get_next(tmp); + } + } + else + { + pc->type = CT_QUALIFIER; + } + } + + /* Objective C stuff */ + if (cpd.lang_flags & LANG_OC) + { + /* Check for message declarations */ + if (pc->flags & PCF_STMT_START) + { + if ((chunk_is_str(pc, "-", 1) || chunk_is_str(pc, "+", 1)) && + chunk_is_str(next, "(", 1)) + { + handle_oc_message_decl(pc); + } + } + if (pc->flags & PCF_EXPR_START) + { + if (pc->type == CT_SQUARE_OPEN) + { + handle_oc_message_send(pc); + } + } + } + + /* C# stuff */ + if (cpd.lang_flags & LANG_CS) + { + /* '[assembly: xxx]' stuff */ + if ((pc->flags & PCF_EXPR_START) && + (pc->type == CT_SQUARE_OPEN)) + { + handle_cs_square_stmt(pc); + } + + if ((next != NULL) && (next->type == CT_BRACE_OPEN) && + (next->parent_type == CT_NONE) && + ((pc->type == CT_SQUARE_CLOSE) || + (pc->type == CT_WORD))) + { + handle_cs_property(next); + } + } + + if ((pc->type == CT_ASSIGN) && (next->type == CT_SQUARE_OPEN)) + { + set_paren_parent(next, CT_ASSIGN); + + /* Mark one-liner assignment */ + tmp = next; + while ((tmp = chunk_get_next_nc(tmp)) != NULL) + { + if (chunk_is_newline(tmp)) + { + break; + } + if ((tmp->type == CT_SQUARE_CLOSE) && (next->level == tmp->level)) + { + tmp->flags |= PCF_ONE_LINER; + next->flags |= PCF_ONE_LINER; + break; + } + } + } + + /* A [] in C# and D only follows a type */ + if ((pc->type == CT_TSQUARE) && + ((cpd.lang_flags & (LANG_D | LANG_CS | LANG_VALA)) != 0)) + { + if ((prev != NULL) && (prev->type == CT_WORD)) + { + prev->type = CT_TYPE; + } + if ((next != NULL) && (next->type == CT_WORD)) + { + next->flags |= PCF_VAR_1ST_DEF; + } + } + + if ((pc->type == CT_SQL_EXEC) || + (pc->type == CT_SQL_BEGIN) || + (pc->type == CT_SQL_END)) + { + mark_exec_sql(pc); + } + + if ((pc->type == CT_FUNC_WRAP) || + (pc->type == CT_TYPE_WRAP)) + { + handle_wrap(pc); + next = chunk_get_next_ncnl(pc); + } + + /* Handle the typedef */ + if (pc->type == CT_TYPEDEF) + { + fix_typedef(pc); + } + if ((pc->type == CT_ENUM) || + (pc->type == CT_STRUCT) || + (pc->type == CT_UNION)) + { + if (prev->type != CT_TYPEDEF) + { + fix_enum_struct_union(pc); + } + } + + if (pc->type == CT_EXTERN) + { + tmp = chunk_get_next_type(next, CT_BRACE_OPEN, next->level); + if (tmp != NULL) + { + set_paren_parent(tmp, CT_EXTERN); + } + } + + if (pc->type == CT_TEMPLATE) + { + handle_template(pc); + } + + if ((pc->type == CT_WORD) && + (next->type == CT_ANGLE_OPEN) && + (next->parent_type == CT_TEMPLATE)) + { + mark_template_func(pc, next); + } + + if ((pc->type == CT_SQUARE_CLOSE) && + (next->type == CT_PAREN_OPEN)) + { + flag_parens(next, 0, CT_FPAREN_OPEN, CT_NONE, false); + } + + if (pc->type == CT_TYPE_CAST) + { + fix_type_cast(pc); + } + + if (pc->type == CT_ASSIGN) + { + mark_lvalue(pc); + } + + if ((pc->parent_type == CT_ASSIGN) && + ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_SQUARE_OPEN))) + { + /* Mark everything in here as in assign */ + flag_parens(pc, PCF_IN_ARRAY_ASSIGN, pc->type, CT_NONE, false); + } + + if (pc->type == CT_D_TEMPLATE) + { + set_paren_parent(next, pc->type); + } + + /** + * A word before an open paren is a function call or definition. + * CT_WORD => CT_FUNC_CALL or CT_FUNC_DEF + */ + if (next->type == CT_PAREN_OPEN) + { + if (pc->type == CT_WORD) + { + pc->type = CT_FUNCTION; + } + else if (pc->type == CT_TYPE) + { + /** + * If we are on a type, then we are either on a C++ style cast, a + * function or we are on a function type. + * The only way to tell for sure is to find the close paren and see + * if it is followed by an open paren. + * "int(5.6)" + * "int()" + * "int(foo)(void)" + * + * FIXME: this check can be done better... + */ + tmp = chunk_get_next_type(next, CT_PAREN_CLOSE, next->level); + tmp = chunk_get_next(tmp); + if ((tmp != NULL) && (tmp->type == CT_PAREN_OPEN)) + { + /* we have "TYPE(...)(" */ + pc->type = CT_FUNCTION; + } + else + { + if ((pc->parent_type == CT_NONE) && + ((pc->flags & PCF_IN_TYPEDEF) == 0)) + { + tmp = chunk_get_next_ncnl(next); + if ((tmp != NULL) && (tmp->type == CT_PAREN_CLOSE)) + { + /* we have TYPE() */ + pc->type = CT_FUNCTION; + } + else + { + /* we have TYPE(...) */ + pc->type = CT_CPP_CAST; + set_paren_parent(next, CT_CPP_CAST); + } + } + } + } + else if (pc->type == CT_ATTRIBUTE) + { + flag_parens(next, 0, CT_FPAREN_OPEN, CT_ATTRIBUTE, false); + } + } + if ((cpd.lang_flags & LANG_PAWN) != 0) + { + if ((pc->type == CT_FUNCTION) && (pc->brace_level > 0)) + { + pc->type = CT_FUNC_CALL; + } + if ((pc->type == CT_STATE) && + (next != NULL) && + (next->type == CT_PAREN_OPEN)) + { + set_paren_parent(next, pc->type); + } + } + else + { + if (pc->type == CT_FUNCTION) + { + mark_function(pc); + } + } + + /* Detect C99 member stuff */ + if ((pc->type == CT_MEMBER) && + ((prev->type == CT_COMMA) || + (prev->type == CT_BRACE_OPEN))) + { + pc->type = CT_C99_MEMBER; + next->parent_type = CT_C99_MEMBER; + } + + /* Mark function parens and braces */ + if ((pc->type == CT_FUNC_DEF) || + (pc->type == CT_FUNC_CALL) || + (pc->type == CT_FUNC_CALL_USER) || + (pc->type == CT_FUNC_PROTO)) + { + tmp = next; + if (tmp->type == CT_SQUARE_OPEN) + { + tmp = set_paren_parent(tmp, pc->type); + } + else if ((tmp->type == CT_TSQUARE) || + (tmp->parent_type == CT_OPERATOR)) + { + tmp = chunk_get_next_ncnl(tmp); + } + + tmp = flag_parens(tmp, 0, CT_FPAREN_OPEN, pc->type, false); + if (tmp != NULL) + { + if (tmp->type == CT_BRACE_OPEN) + { + if ((pc->flags & PCF_IN_CONST_ARGS) == 0) + { + set_paren_parent(tmp, pc->type); + } + } + else if (chunk_is_semicolon(tmp) && (pc->type == CT_FUNC_PROTO)) + { + tmp->parent_type = pc->type; + } + } + } + + /* Mark the parameters in catch() */ + if ((pc->type == CT_CATCH) && (next->type == CT_SPAREN_OPEN)) + { + fix_fcn_def_params(next); + } + + if ((pc->type == CT_THROW) && (prev->type == CT_FPAREN_CLOSE)) + { + pc->parent_type = prev->parent_type; + if (next->type == CT_PAREN_OPEN) + { + set_paren_parent(next, CT_THROW); + } + } + + /* Mark the braces in: "for_each_entry(xxx) { }" */ + if ((pc->type == CT_BRACE_OPEN) && + (prev->type == CT_FPAREN_CLOSE) && + ((prev->parent_type == CT_FUNC_CALL) || + (prev->parent_type == CT_FUNC_CALL_USER)) && + ((pc->flags & PCF_IN_CONST_ARGS) == 0)) + { + set_paren_parent(pc, CT_FUNC_CALL); + } + + /* Check for a close paren followed by an open paren, which means that + * we are on a function type declaration (C/C++ only?). + * Note that typedefs are already taken care of. + */ + if ((next != NULL) && + ((pc->flags & (PCF_IN_TYPEDEF | PCF_IN_TEMPLATE)) == 0) && + (pc->parent_type != CT_CPP_CAST) && + (pc->parent_type != CT_C_CAST) && + ((pc->flags & PCF_IN_PREPROC) == 0) && + chunk_is_str(pc, ")", 1) && + chunk_is_str(next, "(", 1)) + { + if ((cpd.lang_flags & LANG_D) != 0) + { + flag_parens(next, 0, CT_FPAREN_OPEN, CT_FUNC_CALL, false); + } + else + { + mark_function_type(pc); + } + } + + if (((pc->type == CT_CLASS) || + (pc->type == CT_STRUCT)) && + (pc->level == pc->brace_level)) + { + if ((pc->type != CT_STRUCT) || ((cpd.lang_flags & LANG_C) == 0)) + { + mark_class_ctor(pc); + } + } + + if (pc->type == CT_OC_CLASS) + { + handle_oc_class(pc); + } + + if (pc->type == CT_NAMESPACE) + { + mark_namespace(pc); + } + + /*TODO: Check for stuff that can only occur at the start of an statement */ + + if ((cpd.lang_flags & LANG_D) == 0) + { + /** + * Check a paren pair to see if it is a cast. + * Note that SPAREN and FPAREN have already been marked. + */ + if ((pc->type == CT_PAREN_OPEN) && + ((pc->parent_type == CT_NONE) || (pc->parent_type == CT_OC_MSG)) && + ((next->type == CT_WORD) || + (next->type == CT_TYPE) || + (next->type == CT_STRUCT) || + (next->type == CT_QUALIFIER) || + (next->type == CT_MEMBER) || + (next->type == CT_DC_MEMBER) || + (next->type == CT_ENUM) || + (next->type == CT_UNION)) && + (prev->type != CT_SIZEOF) && + (prev->parent_type != CT_OPERATOR) && + ((pc->flags & PCF_IN_TYPEDEF) == 0)) + { + fix_casts(pc); + } + } + + /* Check for stuff that can only occur at the start of an expression */ + if ((pc->flags & PCF_EXPR_START) != 0) + { + /* Change STAR, MINUS, and PLUS in the easy cases */ + if (pc->type == CT_STAR) + { + pc->type = (prev->type == CT_ANGLE_CLOSE) ? CT_PTR_TYPE : CT_DEREF; + } + if (pc->type == CT_MINUS) + { + pc->type = CT_NEG; + } + if (pc->type == CT_PLUS) + { + pc->type = CT_POS; + } + if (pc->type == CT_INCDEC_AFTER) + { + pc->type = CT_INCDEC_BEFORE; + //fprintf(stderr, "%s: %d> changed INCDEC_AFTER to INCDEC_BEFORE\n", __func__, pc->orig_line); + } + if (pc->type == CT_AMP) + { + //fprintf(stderr, "Changed AMP to ADDR on line %d\n", pc->orig_line); + pc->type = CT_ADDR; + } + } + + /* Detect a variable definition that starts with struct/enum/union */ + if (((pc->flags & PCF_IN_TYPEDEF) == 0) && + (prev->parent_type != CT_CPP_CAST) && + ((prev->flags & PCF_IN_FCN_DEF) == 0) && + ((pc->type == CT_STRUCT) || + (pc->type == CT_UNION) || + (pc->type == CT_ENUM))) + { + tmp = next; + if (tmp->type == CT_TYPE) + { + tmp = chunk_get_next_ncnl(tmp); + } + if ((tmp != NULL) && (tmp->type == CT_BRACE_OPEN)) + { + tmp = chunk_skip_to_match(tmp); + tmp = chunk_get_next_ncnl(tmp); + } + if ((tmp != NULL) && (chunk_is_star(tmp) || (tmp->type == CT_WORD))) + { + mark_variable_definition(tmp); + } + } + + /** + * Change the paren pair after a function/macrofunc. + * CT_PAREN_OPEN => CT_FPAREN_OPEN + */ + if (pc->type == CT_MACRO_FUNC) + { + flag_parens(next, PCF_IN_FCN_CALL, CT_FPAREN_OPEN, CT_MACRO_FUNC, false); + } + + if ((pc->type == CT_MACRO_OPEN) || + (pc->type == CT_MACRO_ELSE) || + (pc->type == CT_MACRO_CLOSE)) + { + if (next->type == CT_PAREN_OPEN) + { + flag_parens(next, 0, CT_FPAREN_OPEN, pc->type, false); + } + } + + /* Change CT_STAR to CT_PTR_TYPE or CT_ARITH or SYM_DEREF */ + if (pc->type == CT_STAR) + { + if (chunk_is_paren_close(next)) + { + pc->type = CT_PTR_TYPE; + } + else if ((prev->type == CT_SIZEOF) || (prev->type == CT_DELETE)) + { + pc->type = CT_DEREF; + } + else if (((prev->type == CT_WORD) && chunk_ends_type(prev)) || + (prev->type == CT_DC_MEMBER)) + { + pc->type = CT_PTR_TYPE; + } + else + { + /* most PCF_PUNCTUATOR chunks except a paren close would make this + * a deref. A paren close may end a cast or may be part of a macro fcn. + */ + pc->type = ((prev->flags & PCF_PUNCTUATOR) && + (!chunk_is_paren_close(prev) || + (prev->parent_type == CT_MACRO_FUNC)) && + (prev->type != CT_SQUARE_CLOSE) && + (prev->type != CT_DC_MEMBER)) ? CT_DEREF : CT_ARITH; + } + } + + if (pc->type == CT_AMP) + { + if (prev->type == CT_DELETE) + { + pc->type = CT_DEREF; + } + else + { + pc->type = CT_ARITH; + if (prev->type == CT_WORD) + { + tmp = chunk_get_prev_ncnl(prev); + if ((tmp != NULL) && + (chunk_is_semicolon(tmp) || + (tmp->type == CT_BRACE_OPEN) || + (tmp->type == CT_QUALIFIER))) + { + prev->type = CT_TYPE; + pc->type = CT_ADDR; + next->flags |= PCF_VAR_1ST; + } + } + } + } + + if ((pc->type == CT_MINUS) || + (pc->type == CT_PLUS)) + { + if ((prev->type == CT_POS) || (prev->type == CT_NEG)) + { + pc->type = (pc->type == CT_MINUS) ? CT_NEG : CT_POS; + } + else if (prev->type == CT_OC_CLASS) + { + pc->type = CT_NEG; + } + else + { + pc->type = CT_ARITH; + } + } +} + + +/** + * Change CT_INCDEC_AFTER + WORD to CT_INCDEC_BEFORE + * Change number/word + CT_ADDR to CT_ARITH + * Change number/word + CT_STAR to CT_ARITH + * Change number/word + CT_NEG to CT_ARITH + * Change word + ( to a CT_FUNCTION + * Cahnge struct/union/enum + CT_WORD => CT_TYPE + * Force parens on return. + * + * TODO: This could be done earlier. + * + * Patterns detected: + * STRUCT/ENUM/UNION + WORD :: WORD => TYPE + * WORD + '(' :: WORD => FUNCTION + */ +void fix_symbols(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + chunk_t dummy; + + mark_define_expressions(); + + memset(&dummy, 0, sizeof(dummy)); + + pc = chunk_get_head(); + if (chunk_is_newline(pc) || chunk_is_comment(pc)) + { + pc = chunk_get_next_ncnl(pc); + } + while (pc != NULL) + { + prev = chunk_get_prev_ncnl(pc, CNAV_PREPROC); + if (prev == NULL) + { + prev = &dummy; + } + next = chunk_get_next_ncnl(pc, CNAV_PREPROC); + if (next == NULL) + { + next = &dummy; + } + do_symbol_check(prev, pc, next); + pc = chunk_get_next_ncnl(pc); + } + + pawn_add_virtual_semicolons(); + process_returns(); + + /** + * 2nd pass - handle variable definitions + * REVISIT: We need function params marked to do this (?) + */ + pc = chunk_get_head(); + int square_level = -1; + while (pc != NULL) + { + /* Can't have a variable definition inside [ ] */ + if (square_level < 0) + { + if (pc->type == CT_SQUARE_OPEN) + { + square_level = pc->level; + } + } + else + { + if (pc->level <= square_level) + { + square_level = -1; + } + } + + /** + * A variable definition is possible after at the start of a statement + * that starts with: QUALIFIER, TYPE, or WORD + */ + if ((square_level < 0) && + ((pc->flags & PCF_STMT_START) != 0) && + ((pc->type == CT_QUALIFIER) || + (pc->type == CT_TYPE) || + (pc->type == CT_WORD)) && + (pc->parent_type != CT_ENUM)) // TODO: why this check? + { + pc = fix_var_def(pc); + } + else + { + pc = chunk_get_next_ncnl(pc); + } + } +} + + +/* Just hit an assign. Go backwards until we hit an open brace/paren/square or + * semicolon (TODO: other limiter?) and mark as a LValue. + */ +static void mark_lvalue(chunk_t *pc) +{ + chunk_t *prev; + + if ((pc->flags & PCF_IN_PREPROC) != 0) + { + return; + } + + for (prev = chunk_get_prev_ncnl(pc); + prev != NULL; + prev = chunk_get_prev_ncnl(prev)) + { + if ((prev->level < pc->level) || + (prev->type == CT_ASSIGN) || + (prev->type == CT_COMMA) || + (prev->type == CT_BOOL) || + chunk_is_semicolon(prev) || + chunk_is_str(prev, "(", 1) || + chunk_is_str(prev, "{", 1) || + chunk_is_str(prev, "[", 1) || + (prev->flags & PCF_IN_PREPROC)) + { + break; + } + prev->flags |= PCF_LVALUE; + if ((prev->level == pc->level) && chunk_is_str(prev, "&", 1)) + { + make_type(prev); + } + } +} + + +/** + * Process a function type that is not in a typedef. + * pc points to the first close paren. + * + * void (*func)(params); + * + * @param pc Points to the closing paren + */ +static void mark_function_type(chunk_t *pc) +{ + chunk_t *tmp; + + LOG_FMT(LFTYPE, "%s: [%s] %.*s on line %d, col %d\n", + __func__, get_token_name(pc->type), pc->len, pc->str, + pc->orig_line, pc->orig_col); + + int star_count = 0; + int word_count = 0; + bool nogo = false; + + /* Scan backwards across the name, which can only be a word and single star */ + tmp = chunk_get_prev_ncnl(pc); + while ((tmp = chunk_get_prev_ncnl(tmp)) != NULL) + { + LOG_FMT(LFTYPE, " -- [%s] %.*s on line %d, col %d\n", + get_token_name(tmp->type), tmp->len, tmp->str, + tmp->orig_line, tmp->orig_col); + + if (chunk_is_star(tmp)) + { + star_count++; + } + else if ((tmp->type == CT_WORD) || (tmp->type == CT_TYPE)) + { + word_count++; + } + else if (tmp->type == CT_DC_MEMBER) + { + word_count = 0; + } + else if (chunk_is_str(tmp, "(", 1)) + { + break; + } + else + { + LOG_FMT(LFTYPE, "%s: unexpected token [%s] %.*s on line %d, col %d\n", + __func__, get_token_name(tmp->type), tmp->len, tmp->str, + tmp->orig_line, tmp->orig_col); + nogo = true; + } + } + + if (!nogo && ((star_count > 1) || + (word_count > 1) || + ((star_count + word_count) == 0))) + { + LOG_FMT(LFTYPE, "%s: bad counts word:%d, star:%d\n", __func__, + word_count, star_count); + nogo = true; + } + + if (nogo) + { + tmp = chunk_get_next_ncnl(pc); + flag_parens(tmp, 0, CT_FPAREN_OPEN, CT_FUNC_CALL, false); + return; + } + + pc->type = CT_PAREN_CLOSE; + pc->parent_type = CT_NONE; + + /* Step backwards to the previous open paren and mark everything a + */ + tmp = pc; + while ((tmp = chunk_get_prev_ncnl(tmp)) != NULL) + { + if (*tmp->str == '(') + { + tmp->flags |= PCF_VAR_1ST_DEF; + tmp->type = CT_PAREN_OPEN; + tmp->parent_type = CT_NONE; + + tmp = chunk_get_prev_ncnl(tmp); + if (tmp != NULL) + { + if ((tmp->type == CT_FUNCTION) || + (tmp->type == CT_FUNC_CALL) || + (tmp->type == CT_FUNC_CALL_USER) || + (tmp->type == CT_FUNC_DEF) || + (tmp->type == CT_FUNC_PROTO)) + { + tmp->type = CT_TYPE; + tmp->flags &= ~PCF_VAR_1ST_DEF; + } + } + break; + } + } +} + + +static void process_returns(void) +{ + chunk_t *pc; + + pc = chunk_get_head(); + while (pc != NULL) + { + if ((pc->type != CT_RETURN) || (pc->flags & PCF_IN_PREPROC)) + { + pc = chunk_get_next_type(pc, CT_RETURN, -1); + continue; + } + + pc = process_return(pc); + } +} + + +/** + * Processes a return statment, labeling the parens and marking the parent. + * May remove or add parens around the return statement + * + * @param pc Pointer to the return chunk + */ +static chunk_t *process_return(chunk_t *pc) +{ + chunk_t *next; + chunk_t *temp; + chunk_t *semi; + chunk_t *cpar; + chunk_t chunk; + + /* grab next and bail if it is a semicolon */ + next = chunk_get_next_ncnl(pc); + if ((next == NULL) || chunk_is_semicolon(next)) + { + return(next); + } + + if (cpd.settings[UO_nl_return_expr].a != AV_IGNORE) + { + newline_iarf(pc, cpd.settings[UO_nl_return_expr].a); + } + + if (next->type == CT_PAREN_OPEN) + { + /* See if the return is fully paren'd */ + cpar = chunk_get_next_type(next, CT_PAREN_CLOSE, next->level); + semi = chunk_get_next_ncnl(cpar); + if (chunk_is_semicolon(semi)) + { + if (cpd.settings[UO_mod_paren_on_return].a == AV_REMOVE) + { + LOG_FMT(LRETURN, "%s: removing parens on line %d\n", + __func__, pc->orig_line); + + /* lower the level of everything */ + for (temp = next; temp != cpar; temp = chunk_get_next(temp)) + { + temp->level--; + } + + /* delete the parens */ + chunk_del(next); + chunk_del(cpar); + + /* back up the semicolon */ + semi->column--; + semi->orig_col--; + semi->orig_col_end--; + } + else + { + LOG_FMT(LRETURN, "%s: keeping parens on line %d\n", + __func__, pc->orig_line); + + /* mark & keep them */ + next->parent_type = CT_RETURN; + cpar->parent_type = CT_RETURN; + } + return(semi); + } + } + + /* We don't have a fully paren'd return. Should we add some? */ + if ((cpd.settings[UO_mod_paren_on_return].a & AV_ADD) == 0) + { + return(next); + } + + /* find the next semicolon on the same level */ + semi = next; + while ((semi = chunk_get_next(semi)) != NULL) + { + if ((chunk_is_semicolon(semi) && (pc->level == semi->level)) || + (semi->level < pc->level)) + { + break; + } + } + if (chunk_is_semicolon(semi) && (pc->level == semi->level)) + { + /* add the parens */ + memset(&chunk, 0, sizeof(chunk)); + chunk.type = CT_PAREN_OPEN; + chunk.str = "("; + chunk.len = 1; + chunk.level = pc->level; + chunk.brace_level = pc->brace_level; + chunk.orig_line = pc->orig_line; + chunk.parent_type = CT_RETURN; + chunk.flags = pc->flags & PCF_COPY_FLAGS; + chunk_add_before(&chunk, next); + + chunk.type = CT_PAREN_CLOSE; + chunk.str = ")"; + chunk.orig_line = semi->orig_line; + cpar = chunk_add_before(&chunk, semi); + + LOG_FMT(LRETURN, "%s: added parens on line %d\n", + __func__, pc->orig_line); + + for (temp = next; temp != cpar; temp = chunk_get_next(temp)) + { + temp->level++; + } + } + return(semi); +} + + +static bool is_ucase_str(const char *str, int len) +{ + while (len-- > 0) + { + if (unc_toupper(*str) != *str) + { + return(false); + } + str++; + } + return(true); +} + + +/** + * Checks to see if the current paren is part of a cast. + * We already verified that this doesn't follow function, TYPE, IF, FOR, + * SWITCH, or WHILE and is followed by WORD, TYPE, STRUCT, ENUM, or UNION. + * + * @param start Pointer to the open paren + */ +static void fix_casts(chunk_t *start) +{ + chunk_t *pc; + chunk_t *prev; + chunk_t *first; + chunk_t *after; + chunk_t *last = NULL; + chunk_t *paren_close; + const char *verb = "likely"; + const char *detail = ""; + int count = 0; + int word_count = 0; + int word_consec = 0; + bool nope; + bool doubtful_cast = false; + + + LOG_FMT(LCASTS, "%s:line %d, col %d:", __func__, start->orig_line, start->orig_col); + + prev = chunk_get_prev_ncnl(start); + if ((prev != NULL) && (prev->type == CT_PP_DEFINED)) + { + LOG_FMT(LCASTS, " -- not a cast - after defined\n"); + return; + } + + /* Make sure there is only WORD, TYPE, and '*' before the close paren */ + pc = chunk_get_next_ncnl(start); + first = pc; + while ((pc != NULL) && (chunk_is_type(pc) || + (pc->type == CT_WORD) || + (pc->type == CT_QUALIFIER) || + (pc->type == CT_DC_MEMBER) || + (pc->type == CT_STAR))) + { + LOG_FMT(LCASTS, " [%s]", get_token_name(pc->type)); + + if (pc->type == CT_WORD) + { + word_count++; + word_consec++; + } + else if (pc->type == CT_DC_MEMBER) + { + word_count--; + } + else + { + word_consec = 0; + } + + last = pc; + pc = chunk_get_next_ncnl(pc); + count++; + } + + if ((pc == NULL) || (pc->type != CT_PAREN_CLOSE)) + { + LOG_FMT(LCASTS, " -- not a cast, hit [%s]\n", + pc == NULL ? "NULL" : get_token_name(pc->type)); + return; + } + + if (word_count > 1) + { + LOG_FMT(LCASTS, " -- too many words: %d\n", word_count); + return; + } + paren_close = pc; + + /* If last is a type or star, we have a cast for sure */ + if ((last->type == CT_STAR) || + (last->type == CT_PTR_TYPE) || + (last->type == CT_TYPE)) + { + verb = "for sure"; + } + else if (count == 1) + { + /** + * We are on a potential cast of the form "(word)". + * We don't know if the word is a type. So lets guess based on some + * simple rules: + * - if all caps, likely a type + * - if it ends in _t, likely a type + */ + verb = "guessed"; + if ((last->len > 3) && + (last->str[last->len - 2] == '_') && + (last->str[last->len - 1] == 't')) + { + detail = " -- '_t'"; + } + else if (is_ucase_str(last->str, last->len)) + { + detail = " -- upper case"; + } + else + { + /* If we can't tell for sure whether this is a cast, decide against it */ + detail = " -- mixed case"; + doubtful_cast = true; + } + + /** + * If the next item is a * or &, the next item after that can't be a + * number or string. + * + * If the next item is a +, the next item has to be a number. + * + * If the next item is a -, the next item can't be a string. + * + * For this to be a cast, the close paren must be followed by: + * - constant (number or string) + * - paren open + * - word + * + * Find the next non-open paren item. + */ + pc = chunk_get_next_ncnl(paren_close); + after = pc; + do + { + after = chunk_get_next_ncnl(after); + } while ((after != NULL) && (after->type == CT_PAREN_OPEN)); + + if (after == NULL) + { + LOG_FMT(LCASTS, " -- not a cast - hit NULL\n"); + return; + } + + nope = false; + if (chunk_is_star(pc) || chunk_is_addr(pc)) + { + /* star (*) and addr (&) are ambiguous */ + if ((after->type == CT_NUMBER_FP) || + (after->type == CT_NUMBER) || + (after->type == CT_STRING) || + doubtful_cast) + { + nope = true; + } + } + else if (pc->type == CT_MINUS) + { + /* (UINT8)-1 or (foo)-1 or (FOO)-'a' */ + if ((after->type == CT_STRING) || doubtful_cast) + { + nope = true; + } + } + else if (pc->type == CT_PLUS) + { + /* (UINT8)+1 or (foo)+1 */ + if (((after->type != CT_NUMBER) && + (after->type != CT_NUMBER_FP)) || doubtful_cast) + { + nope = true; + } + } + else if ((pc->type != CT_NUMBER_FP) && + (pc->type != CT_NUMBER) && + (pc->type != CT_WORD) && + (pc->type != CT_PAREN_OPEN) && + (pc->type != CT_STRING) && + (pc->type != CT_SIZEOF) && + (pc->type != CT_FUNC_CALL) && + (pc->type != CT_FUNC_CALL_USER) && + (pc->type != CT_FUNCTION)) + { + LOG_FMT(LCASTS, " -- not a cast - followed by '%.*s' %s\n", + pc->len, pc->str, get_token_name(pc->type)); + return; + } + + if (nope) + { + LOG_FMT(LCASTS, " -- not a cast - '%.*s' followed by %s\n", + pc->len, pc->str, get_token_name(after->type)); + return; + } + } + + start->parent_type = CT_C_CAST; + paren_close->parent_type = CT_C_CAST; + + LOG_FMT(LCASTS, " -- %s c-cast: (", verb); + + for (pc = first; pc != paren_close; pc = chunk_get_next_ncnl(pc)) + { + pc->parent_type = CT_C_CAST; + make_type(pc); + LOG_FMT(LCASTS, " %.*s", pc->len, pc->str); + } + LOG_FMT(LCASTS, " )%s\n", detail); + + /* Mark the next item as an expression start */ + pc = chunk_get_next_ncnl(paren_close); + if (pc != NULL) + { + pc->flags |= PCF_EXPR_START; + } +} + + +/** + * CT_TYPE_CAST follows this pattern: + * dynamic_cast<...>(...) + * + * Mark everything between the <> as a type and set the paren parent + */ +static void fix_type_cast(chunk_t *start) +{ + chunk_t *pc; + + pc = chunk_get_next_ncnl(start); + if ((pc == NULL) || (pc->type != CT_ANGLE_OPEN)) + { + return; + } + + while (((pc = chunk_get_next_ncnl(pc)) != NULL) && + (pc->level >= start->level)) + { + if ((pc->level == start->level) && (pc->type == CT_ANGLE_CLOSE)) + { + pc = chunk_get_next_ncnl(pc); + if (chunk_is_str(pc, "(", 1)) + { + set_paren_parent(pc, CT_TYPE_CAST); + } + return; + } + make_type(pc); + } +} + + +/** + * We are on an enum/struct/union tag that is NOT inside a typedef. + * If there is a {...} and words before the ';', then they are variables. + * + * tag { ... } [*] word [, [*]word] ; + * tag [word/type] { ... } [*] word [, [*]word] ; + * tag [word/type] [word]; -- this gets caught later. + * fcn(tag [word/type] [word]) + * a = (tag [word/type] [*])&b; + * + * REVISIT: should this be consolidated with the typedef code? + */ +static void fix_enum_struct_union(chunk_t *pc) +{ + chunk_t *next; + int flags = PCF_VAR_1ST_DEF; + int in_fcn_paren = pc->flags & PCF_IN_FCN_DEF; + + /* Make sure this wasn't a cast */ + if (pc->parent_type == CT_C_CAST) + { + return; + } + + /* the next item is either a type or open brace */ + next = chunk_get_next_ncnl(pc); + if (next->type == CT_TYPE) + { + next->parent_type = pc->type; + next = chunk_get_next_ncnl(next); + + if (((cpd.lang_flags & LANG_PAWN) != 0) && + (next->type == CT_PAREN_OPEN)) + { + next = set_paren_parent(next, CT_ENUM); + } + } + if (next->type == CT_BRACE_OPEN) + { + if ((pc->type == CT_UNION) || (pc->type == CT_STRUCT)) + { + mark_struct_union_body(next); + } + + flag_parens(next, PCF_IN_ENUM, CT_NONE, CT_NONE, false); + + /* Skip to the closing brace */ + next->parent_type = pc->type; + next = chunk_get_next_type(next, CT_BRACE_CLOSE, pc->level); + flags |= PCF_VAR_INLINE; + if (next != NULL) + { + next->parent_type = pc->type; + next = chunk_get_next_ncnl(next); + } + } + + if ((next == NULL) || (next->type == CT_PAREN_CLOSE)) + { + return; + } + + if ((cpd.lang_flags & LANG_D) && !chunk_is_semicolon(next)) + { + next = pawn_add_vsemi_after(chunk_get_prev_ncnl(next)); + } + + /* We are either pointing to a ';' or a variable */ + while ((next != NULL) && !chunk_is_semicolon(next) && + (next->type != CT_ASSIGN) && + ((in_fcn_paren ^ (next->flags & PCF_IN_FCN_DEF)) == 0)) + { + if (next->type == CT_WORD) + { + next->flags |= flags; + flags &= ~PCF_VAR_1ST; /* clear the first flag for the next items */ + } + + if (next->type == CT_STAR) + { + next->type = CT_PTR_TYPE; + } + + /* If we hit a comma in a function param, we are done */ + if (((next->type == CT_COMMA) || + (next->type == CT_FPAREN_CLOSE)) && + ((next->flags & (PCF_IN_FCN_DEF | PCF_IN_FCN_CALL)) != 0)) + { + return; + } + + next = chunk_get_next_ncnl(next); + } +} + + +/** + * We are on a typedef. + * If the next word is not enum/union/struct, then the last word before the + * next ',' or ';' or '__attribute__' is a type. + * + * typedef [type...] [*] type [, [*]type] ; + * typedef ([*]func)(params); + * typedef [type] [*] type [, [*]type] ; + * typedef [type] { ... } [*] type [, [*]type] ; + */ +static void fix_typedef(chunk_t *start) +{ + chunk_t *next; + chunk_t *prev; + chunk_t *the_type = NULL; + chunk_t *open_paren; + c_token_t tag; + + LOG_FMT(LTYPEDEF, "%s: looking at line %d\n", __func__, start->orig_line); + + /* Mark everything in the typedef and scan for ")(", which makes it a + * function type + */ + next = start; + while (((next = chunk_get_next_ncnl(next)) != NULL) && + (next->level >= start->level)) + { + next->flags |= PCF_IN_TYPEDEF; + if (start->level == next->level) + { + if (chunk_is_semicolon(next)) + { + next->parent_type = CT_TYPEDEF; + break; + } + if (next->type == CT_ATTRIBUTE) + { + break; + } + if ((cpd.lang_flags & LANG_D) && (next->type == CT_ASSIGN)) + { + next->parent_type = CT_TYPEDEF; + break; + } + make_type(next); + if (next->type == CT_TYPE) + { + the_type = next; + } + next->flags &= ~PCF_VAR_1ST_DEF; + if (*next->str == '(') + { + prev = chunk_get_prev_ncnl(next); + if (*prev->str != ')') + { + continue; + } + + prev->parent_type = CT_TYPEDEF; + open_paren = chunk_get_prev_type(prev, c_token_t(prev->type - 1), prev->level); + open_paren->parent_type = CT_TYPEDEF; + + flag_parens(next, 0, CT_FPAREN_OPEN, CT_TYPEDEF, false); + + fix_fcn_def_params(next); + + /* Grab the type name (right before the close paren */ + the_type = chunk_get_prev_ncnl(prev); + + LOG_FMT(LTYPEDEF, "%s: fcn typedef [%.*s] on line %d\n", __func__, + the_type->len, the_type->str, the_type->orig_line); + + /* If we are aligning on the open paren, grab that instead */ + if (cpd.settings[UO_align_typedef_func].n == 1) + { + the_type = open_paren; + } + if (cpd.settings[UO_align_typedef_func].n != 0) + { + the_type->flags |= PCF_ANCHOR; + } + + /* already did everything we need to do */ + return; + } + } + } + + /** + * Skip over enum/struct/union stuff, as we know it isn't a return type + * for a function type + */ + next = chunk_get_next_ncnl(start); + if ((next->type != CT_ENUM) && + (next->type != CT_STRUCT) && + (next->type != CT_UNION)) + { + /* We have just a regular typedef */ + LOG_FMT(LTYPEDEF, "%s: regular typedef [%.*s] on line %d\n", __func__, + the_type->len, the_type->str, the_type->orig_line); + the_type->flags |= PCF_ANCHOR; + return; + } + + /* We have a struct/union/enum type, set the parent */ + tag = next->type; + + /* the next item should be either a type or { */ + next = chunk_get_next_ncnl(next); + if (next->type == CT_TYPE) + { + next = chunk_get_next_ncnl(next); + } + if (next->type == CT_BRACE_OPEN) + { + next->parent_type = tag; + /* Skip to the closing brace */ + next = chunk_get_next_type(next, CT_BRACE_CLOSE, next->level); + if (next != NULL) + { + next->parent_type = tag; + } + } + + if (the_type != NULL) + { + LOG_FMT(LTYPEDEF, "%s: %s typedef [%.*s] on line %d\n", + __func__, get_token_name(tag), the_type->len, the_type->str, the_type->orig_line); + the_type->flags |= PCF_ANCHOR; + } +} + + +/** + * Examines the whole file and changes CT_COLON to + * CT_Q_COLON, CT_LABEL_COLON, or CT_CASE_COLON. + * It also changes the CT_WORD before CT_LABEL_COLON into CT_LABEL. + */ +void combine_labels(void) +{ + chunk_t *cur; + chunk_t *prev; + chunk_t *next; + chunk_t *tmp; + int question_count = 0; + bool hit_case = false; + bool hit_class = false; + + prev = chunk_get_head(); + cur = chunk_get_next_nc(prev); + next = chunk_get_next_nc(cur); + + /* unlikely that the file will start with a label... */ + while (next != NULL) + { + if ((next->type == CT_CLASS) || + (next->type == CT_OC_CLASS) || + (next->type == CT_TEMPLATE)) + { + hit_class = true; + } + if (chunk_is_semicolon(next) || (next->type == CT_BRACE_OPEN)) + { + hit_class = false; + } + if (next->type == CT_QUESTION) + { + question_count++; + } + else if (next->type == CT_CASE) + { + if (cur->type == CT_GOTO) + { + /* handle "goto case x;" */ + next->type = CT_QUALIFIER; + } + else + { + hit_case = true; + } + } + else if (next->type == CT_COLON) + { + if (cur->type == CT_DEFAULT) + { + cur->type = CT_CASE; + hit_case = true; + } + if (question_count > 0) + { + next->type = CT_COND_COLON; + question_count--; + } + else if (hit_case) + { + hit_case = false; + next->type = CT_CASE_COLON; + tmp = chunk_get_next_ncnl(next); + if ((tmp != NULL) && (tmp->type == CT_BRACE_OPEN)) + { + tmp->parent_type = CT_CASE; + tmp = chunk_get_next_type(tmp, CT_BRACE_CLOSE, tmp->level); + if (tmp != NULL) + { + tmp->parent_type = CT_CASE; + } + } + } + else + { + chunk_t *nextprev = chunk_get_prev_ncnl(next); + + if ((cpd.lang_flags & LANG_PAWN) != 0) + { + if ((cur->type == CT_WORD) || + (cur->type == CT_BRACE_CLOSE)) + { + c_token_t new_type = CT_TAG; + + tmp = chunk_get_next_nc(next); + if (chunk_is_newline(prev) && chunk_is_newline(tmp)) + { + new_type = CT_LABEL; + next->type = CT_LABEL_COLON; + } + else + { + next->type = CT_TAG_COLON; + } + if (cur->type == CT_WORD) + { + cur->type = new_type; + } + } + } + else if (next->flags & PCF_IN_ARRAY_ASSIGN) + { + next->type = CT_D_ARRAY_COLON; + } + else if (cur->type == CT_WORD) + { + if (chunk_is_newline(prev)) + { + cur->type = CT_LABEL; + next->type = CT_LABEL_COLON; + } + else + { + next->type = CT_BIT_COLON; + + tmp = chunk_get_next(next); + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if (tmp->type == CT_SEMICOLON) + { + break; + } + if (tmp->type == CT_COLON) + { + tmp->type = CT_BIT_COLON; + } + } + } + } + else if (nextprev->type == CT_FPAREN_CLOSE) + { + /* it's a class colon */ + next->type = CT_CLASS_COLON; + } + else if (next->level > next->brace_level) + { + /* ignore it, as it is inside a paren */ + } + else if ((cur->type == CT_TYPE) || + (cur->type == CT_ENUM) || + (cur->type == CT_PRIVATE) || + (cur->type == CT_QUALIFIER) || + (cur->parent_type == CT_ALIGN)) + { + /* ignore it - bit field, align or public/private, etc */ + } + else if ((cur->type == CT_ANGLE_CLOSE) || hit_class) + { + /* ignore it - template thingy */ + } + else if (cur->parent_type == CT_SQL_EXEC) + { + /* ignore it - SQL variable name */ + } + else + { + tmp = chunk_get_next_ncnl(next); + if ((tmp != NULL) && ((tmp->type == CT_BASE) || + (tmp->type == CT_THIS))) + { + /* ignore it, as it is a C# base thingy */ + } + else + { + LOG_FMT(LWARN, "%s:%d unexpected colon in col %d n-parent=%s c-parent=%s l=%d bl=%d\n", + cpd.filename, next->orig_line, next->orig_col, + get_token_name(next->parent_type), + get_token_name(cur->parent_type), + next->level, next->brace_level); + cpd.error_count++; + } + } + } + } + prev = cur; + cur = next; + next = chunk_get_next_nc(cur); + } +} + + +static void mark_variable_stack(ChunkStack& cs, log_sev_t sev) +{ + chunk_t *var_name; + chunk_t *word_type; + + /* throw out the last word and mark the rest */ + var_name = cs.Pop(); + if (var_name != NULL) + { + LOG_FMT(LFCNP, "%s: parameter on line %d :", + __func__, var_name->orig_line); + + while ((word_type = cs.Pop()) != NULL) + { + LOG_FMT(LFCNP, " <%.*s>", word_type->len, word_type->str); + word_type->type = CT_TYPE; + word_type->flags |= PCF_VAR_TYPE; + } + + LOG_FMT(LFCNP, " [%.*s]\n", var_name->len, var_name->str); + var_name->flags |= PCF_VAR_DEF; + } +} + + +/** + * Simply change any STAR to PTR_TYPE and WORD to TYPE + * + * @param start points to the open paren + */ +static void fix_fcn_def_params(chunk_t *start) +{ + LOG_FMT(LFCNP, "%s: %.*s [%s] on line %d, level %d\n", + __func__, start->len, start->str, get_token_name(start->type), start->orig_line, start->level); + + while ((start != NULL) && !chunk_is_paren_open(start)) + { + start = chunk_get_next_ncnl(start); + } + + assert((start->len == 1) && (*start->str == '(')); + + ChunkStack cs; + + int level = start->level + 1; + + chunk_t *pc = start; + while ((pc = chunk_get_next_ncnl(pc)) != NULL) + { + if (((start->len == 1) && (*start->str == ')')) || + (pc->level < level)) + { + LOG_FMT(LFCNP, "%s: bailed on %.*s on line %d\n", __func__, pc->len, pc->str, pc->orig_line); + break; + } + + LOG_FMT(LFCNP, "%s: %s %.*s on line %d, level %d\n", __func__, + (pc->level > level) ? "skipping" : "looking at", + pc->len, pc->str, pc->orig_line, pc->level); + + if (pc->level > level) + { + continue; + } + if (chunk_is_star(pc)) + { + pc->type = CT_PTR_TYPE; + } + else if (pc->type == CT_AMP) + { + pc->type = CT_BYREF; + } + else if ((pc->type == CT_WORD) || (pc->type == CT_TYPE)) + { + cs.Push(pc); + } + else if ((pc->type == CT_COMMA) || (pc->type == CT_ASSIGN)) + { + mark_variable_stack(cs, LFCNP); + } + } + mark_variable_stack(cs, LFCNP); +} + + +//#define DEBUG_FIX_VAR_DEF + +/** + * Skips to the start of the next statement. + */ +static chunk_t *skip_to_next_statement(chunk_t *pc) +{ + while ((pc != NULL) && !chunk_is_semicolon(pc) && + (pc->type != CT_BRACE_OPEN) && + (pc->type != CT_BRACE_CLOSE)) + { + pc = chunk_get_next_ncnl(pc); + } + return(pc); +} + + +/** + * We are on the start of a sequence that could be a var def + * - FPAREN_OPEN (parent == CT_FOR) + * - BRACE_OPEN + * - SEMICOLON + * + */ +static chunk_t *fix_var_def(chunk_t *start) +{ + chunk_t *pc = start; + chunk_t *end; + chunk_t *tmp_pc; + ChunkStack cs; + int idx, ref_idx; + + LOG_FMT(LFVD, "%s: top[%d]", __func__, pc->orig_line); + + /* Scan for words and types and stars oh my! */ + while ((pc != NULL) && + ((pc->type == CT_TYPE) || + (pc->type == CT_WORD) || + (pc->type == CT_QUALIFIER) || + (pc->type == CT_DC_MEMBER) || + (pc->type == CT_MEMBER) || + chunk_is_addr(pc) || + chunk_is_star(pc))) + { + LOG_FMT(LFVD, " %.*s[%s]", pc->len, pc->str, get_token_name(pc->type)); + cs.Push(pc); + pc = chunk_get_next_ncnl(pc); + + /* Skip templates and attributes */ + pc = skip_template_next(pc); + pc = skip_attribute_next(pc); + } + end = pc; + + LOG_FMT(LFVD, " end=[%s]\n", (end != NULL) ? get_token_name(end->type) : "NULL"); + + if (end == NULL) + { + return(NULL); + } + + /* Function defs are handled elsewhere */ + if ((cs.Len() <= 1) || + (end->type == CT_FUNC_DEF) || + (end->type == CT_FUNC_PROTO) || + (end->type == CT_FUNC_CLASS)) + { + return(skip_to_next_statement(end)); + } + + /* ref_idx points to the alignable part of the var def */ + ref_idx = cs.Len() - 1; + + /* Check for the '::' stuff: "char *Engine::name" */ + if ((cs.Len() >= 3) && + ((cs.Get(cs.Len() - 2)->m_pc->type == CT_MEMBER) || + (cs.Get(cs.Len() - 2)->m_pc->type == CT_DC_MEMBER))) + { + idx = cs.Len() - 2; + while (idx > 0) + { + tmp_pc = cs.Get(idx)->m_pc; + if ((tmp_pc->type != CT_DC_MEMBER) && + (tmp_pc->type != CT_MEMBER)) + { + break; + } + idx--; + tmp_pc = cs.Get(idx)->m_pc; + if ((tmp_pc->type != CT_WORD) && + (tmp_pc->type != CT_TYPE)) + { + break; + } + make_type(tmp_pc); + idx--; + } + ref_idx = idx + 1; + } + tmp_pc = cs.Get(ref_idx)->m_pc; + LOG_FMT(LFVD, " ref_idx(%d) => %.*s\n", ref_idx, tmp_pc->len, tmp_pc->str); + + /* No type part found! */ + if (ref_idx <= 0) + { + return(skip_to_next_statement(end)); + } + + LOG_FMT(LFVD2, "%s:%d TYPE : ", __func__, start->orig_line); + for (idx = 0; idx < cs.Len() - 1; idx++) + { + tmp_pc = cs.Get(idx)->m_pc; + make_type(tmp_pc); + tmp_pc->flags |= PCF_VAR_TYPE; + LOG_FMT(LFVD2, " %.*s[%s]", tmp_pc->len, tmp_pc->str, get_token_name(tmp_pc->type)); + } + LOG_FMT(LFVD2, "\n"); + + /** + * OK we have two or more items, mark types up to the end. + */ + mark_variable_definition(cs.Get(cs.Len() - 1)->m_pc); + if (end->type == CT_COMMA) + { + return(chunk_get_next_ncnl(end)); + } + return(skip_to_next_statement(end)); +} + + +/** + * Skips everything until a comma or semicolon at the same level. + * Returns the semicolon, comma, or close brace/paren or NULL. + */ +static chunk_t *skip_expression(chunk_t *start) +{ + chunk_t *pc = start; + + while ((pc != NULL) && (pc->level >= start->level)) + { + if ((pc->level == start->level) && + (chunk_is_semicolon(pc) || (pc->type == CT_COMMA))) + { + return(pc); + } + pc = chunk_get_next_ncnl(pc); + } + return(pc); +} + + +/** + * We are on the first word of a variable definition. + * Mark all the variable names with PCF_VAR_1ST and PCF_VAR_DEF as appropriate. + * Also mark any '*' encountered as a CT_PTR_TYPE. + * Skip over []. Go until a ';' is hit. + * + * Example input: + * int a = 3, b, c = 2; ## called with 'a' + * foo_t f = {1, 2, 3}, g = {5, 6, 7}; ## called with 'f' + * struct {...} *a, *b; ## called with 'a' or '*' + * myclass a(4); + */ +static chunk_t *mark_variable_definition(chunk_t *start) +{ + chunk_t *pc = start; + int flags = PCF_VAR_1ST_DEF; + + if (start == NULL) + { + return(NULL); + } + + LOG_FMT(LVARDEF, "%s: line %d, col %d '%.*s' type %s\n", + __func__, + pc->orig_line, pc->orig_col, pc->len, pc->str, + get_token_name(pc->type)); + + pc = start; + while ((pc != NULL) && !chunk_is_semicolon(pc) && + (pc->level == start->level)) + { + if ((pc->type == CT_WORD) || (pc->type == CT_FUNC_CTOR_VAR)) + { + pc->flags |= flags; + flags &= ~PCF_VAR_1ST; + + LOG_FMT(LVARDEF, "%s:%d marked '%.*s'[%s] in col %d\n", + __func__, pc->orig_line, pc->len, pc->str, + get_token_name(pc->type), pc->orig_col); + } + else if (chunk_is_star(pc)) + { + pc->type = CT_PTR_TYPE; + } + else if (chunk_is_addr(pc)) + { + pc->type = CT_BYREF; + } + else if ((pc->type == CT_SQUARE_OPEN) || (pc->type == CT_ASSIGN)) + { + pc = skip_expression(pc); + continue; + } + pc = chunk_get_next_ncnl(pc); + } + return(pc); +} + + +/** + * Checks to see if a series of chunks could be a C++ parameter + * FOO foo(5, &val); + * + * WORD means CT_WORD or CT_TYPE + * + * "WORD WORD" ==> true + * "QUALIFIER ??" ==> true + * "TYPE" ==> true + * "WORD" ==> true + * "WORD.WORD" ==> true + * "WORD::WORD" ==> true + * "WORD * WORD" ==> true + * "NUMBER" ==> false + * "STRING" ==> false + * "OPEN PAREN" ==> false + * + * @param start the first chunk to look at + * @param end the chunk after the last one to look at + */ +static bool can_be_full_param(chunk_t *start, chunk_t *end) +{ + chunk_t *pc; + chunk_t *last; + int word_cnt = 0; + int type_count = 0; + bool ret; + + LOG_FMT(LFPARAM, "%s:", __func__); + + for (pc = start; pc != end; pc = chunk_get_next_ncnl(pc)) + { + LOG_FMT(LFPARAM, " [%.*s]", pc->len, pc->str); + + if ((pc->type == CT_QUALIFIER) || + (pc->type == CT_STRUCT) || + (pc->type == CT_ENUM) || + (pc->type == CT_UNION)) + { + LOG_FMT(LFPARAM, " <== %s!\n", get_token_name(pc->type)); + return(true); + } + + if ((pc->type == CT_WORD) || + (pc->type == CT_TYPE)) + { + word_cnt++; + if (pc->type == CT_TYPE) + { + type_count++; + } + } + else if ((pc->type == CT_MEMBER) || + (pc->type == CT_DC_MEMBER)) + { + word_cnt--; + } + else if ((pc != start) && (chunk_is_star(pc) || + chunk_is_addr(pc))) + { + /* chunk is OK */ + } + else if (pc->type == CT_ASSIGN) + { + /* chunk is OK (default values) */ + break; + } + else if (pc->type == CT_ANGLE_OPEN) + { + LOG_FMT(LFPARAM, " <== template\n"); + return(true); + } + else if (pc->type == CT_ELLIPSIS) + { + LOG_FMT(LFPARAM, " <== elipses\n"); + return(true); + } + else + { + LOG_FMT(LFPARAM, " <== [%s] no way!\n", get_token_name(pc->type)); + return(false); + } + } + + last = chunk_get_prev_ncnl(pc); + if (chunk_is_star(last) || chunk_is_addr(last)) + { + LOG_FMT(LFPARAM, " <== [%s] sure!\n", get_token_name(pc->type)); + return(true); + } + + ret = ((word_cnt >= 2) || ((word_cnt == 1) && (type_count == 1))); + + LOG_FMT(LFPARAM, " <== [%s] %s!\n", + get_token_name(pc->type), ret ? "Yup" : "Unlikely"); + return(ret); +} + + +/** + * We are on a function word. we need to: + * - find out if this is a call or prototype or implementation + * - mark return type + * - mark parameter types + * - mark brace pair + * + * REVISIT: + * This whole function is a mess. + * It needs to be reworked to eliminate duplicate logic and determine the + * function type more directly. + * 1. Skip to the close paren and see what is after. + * a. semicolon - function call or function proto + * b. open brace - function call (ie, list_for_each) or function def + * c. open paren - function type or chained function call + * d. qualifier - function def or proto, continue to semicolon or open brace + * 2. Examine the 'parameters' to see if it can be a proto/def + * 3. Examine what is before the function name to see if it is a proto or call + * Constructor/destructor detection should have already been done when the + * 'class' token was encountered (see mark_class_ctor). + */ +static void mark_function(chunk_t *pc) +{ + chunk_t *prev; + chunk_t *next; + chunk_t *tmp; + chunk_t *semi = NULL; + chunk_t *paren_open; + chunk_t *paren_close; + chunk_t *pc_op = NULL; + + prev = chunk_get_prev_ncnlnp(pc); + next = chunk_get_next_ncnlnp(pc); + + /* Find out what is before the operator */ + if (pc->parent_type == CT_OPERATOR) + { + pc_op = chunk_get_prev_type(pc, CT_OPERATOR, pc->level); + if ((pc_op != NULL) && (pc_op->flags & PCF_EXPR_START)) + { + pc->type = CT_FUNC_CALL; + } + if (cpd.lang_flags & LANG_CPP) + { + tmp = pc; + while ((tmp = chunk_get_prev_ncnl(tmp)) != NULL) + { + if (tmp->type == CT_BRACE_CLOSE) + { + break; + } + if (tmp->type == CT_TEMPLATE) + { + pc->type = CT_FUNC_DEF; + break; + } + if (tmp->type == CT_BRACE_OPEN) + { + if (tmp->parent_type == CT_FUNC_DEF) + { + pc->type = CT_FUNC_CALL; + } + if ((tmp->parent_type == CT_CLASS) || + (tmp->parent_type == CT_STRUCT)) + { + pc->type = CT_FUNC_DEF; + } + break; + } + } + } + } + + if (chunk_is_star(next) || chunk_is_addr(next)) + { + next = chunk_get_next_ncnlnp(next); + } + + LOG_FMT(LFCN, "%s: %d] %.*s[%s] - parent=%s level=%d/%d, next=%.*s[%s] - level=%d\n", + __func__, + pc->orig_line, pc->len, pc->str, + get_token_name(pc->type), get_token_name(pc->parent_type), + pc->level, pc->brace_level, + next->len, next->str, get_token_name(next->type), next->level); + + if (pc->flags & PCF_IN_CONST_ARGS) + { + pc->type = CT_FUNC_CTOR_VAR; + LOG_FMT(LFCN, " 1) Marked [%.*s] as FUNC_CTOR_VAR on line %d col %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col); + next = skip_template_next(next); + flag_parens(next, 0, CT_FPAREN_OPEN, pc->type, true); + return; + } + + /* Skip over any template and attribute madness */ + next = skip_template_next(next); + next = skip_attribute_next(next); + + /* Find the open and close paren */ + paren_open = chunk_get_next_str(pc, "(", 1, pc->level); + paren_close = chunk_get_next_str(paren_open, ")", 1, pc->level); + + if ((paren_open == NULL) || (paren_close == NULL)) + { + LOG_FMT(LFCN, "No parens found for [%.*s] on line %d col %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col); + return; + } + + /** + * This part detects either chained function calls or a function ptr definition. + * MYTYPE (*func)(void); + * mWriter( "class Clst_"c )( somestr.getText() )( " : Cluster {"c ).newline; + * + * For it to be a function variable def, there must be a '*' followed by a + * single word. + * + * Otherwise, it must be chained function calls. + */ + tmp = chunk_get_next_ncnl(paren_close); + if (chunk_is_str(tmp, "(", 1)) + { + chunk_t *tmp1, *tmp2, *tmp3; + + tmp1 = next; + do + { + tmp1 = chunk_get_next_ncnl(tmp1); + } while ((tmp1 != NULL) && + ((tmp1->type == CT_WORD) || + (tmp1->type == CT_DC_MEMBER))); + + tmp2 = chunk_get_next_ncnl(tmp1); + if (chunk_is_str(tmp2, ")", 1)) + { + tmp3 = tmp2; + tmp2 = NULL; + } + else + { + tmp3 = chunk_get_next_ncnl(tmp2); + } + + if (chunk_is_str(tmp3, ")", 1) && + chunk_is_star(tmp1) && + ((tmp2 == NULL) || (tmp2->type == CT_WORD))) + { + if (tmp2 != NULL) + { + LOG_FMT(LFCN, "%s: [%d/%d] function variable [%.*s], changing [%.*s] into a type\n", + __func__, pc->orig_line, pc->orig_col, tmp2->len, tmp2->str, pc->len, pc->str); + } + else + { + LOG_FMT(LFCN, "%s: [%d/%d] function type, changing [%.*s] into a type\n", + __func__, pc->orig_line, pc->orig_col, pc->len, pc->str); + } + + pc->type = CT_TYPE; + tmp1->type = CT_PTR_TYPE; + pc->flags &= ~PCF_VAR_1ST_DEF; + if (tmp2 != NULL) + { + tmp2->flags |= PCF_VAR_1ST_DEF; + } + flag_parens(tmp, 0, CT_FPAREN_OPEN, CT_FUNC_PROTO, false); + fix_fcn_def_params(tmp); + return; + } + + LOG_FMT(LFCN, "%s: chained function calls? [%d.%d] [%.*s]\n", + __func__, pc->orig_line, pc->orig_col, pc->len, pc->str); + } + + /* Assume it is a function call if not already labeled */ + if (pc->type == CT_FUNCTION) + { + pc->type = (pc->parent_type == CT_OPERATOR) ? CT_FUNC_DEF : CT_FUNC_CALL; + } + + /* Check for C++ function def */ + if ((pc->type == CT_FUNC_CLASS) || + ((prev != NULL) && ((prev->type == CT_DC_MEMBER) || + (prev->type == CT_INV)))) + { + chunk_t *destr = NULL; + if (prev->type == CT_INV) + { + /* TODO: do we care that this is the destructor? */ + prev->type = CT_DESTRUCTOR; + pc->type = CT_FUNC_CLASS; + + destr = prev; + prev = chunk_get_prev_ncnlnp(prev); + } + + if ((prev != NULL) && (prev->type == CT_DC_MEMBER)) + { + prev = chunk_get_prev_ncnlnp(prev); + // LOG_FMT(LSYS, "%s: prev1 = %s (%.*s)\n", __func__, + // get_token_name(prev->type), prev->len, prev->str); + prev = skip_template_prev(prev); + prev = skip_attribute_prev(prev); + // LOG_FMT(LSYS, "%s: prev2 = %s [%d](%.*s) pc = %s [%d](%.*s)\n", __func__, + // get_token_name(prev->type), prev->len, prev->len, prev->str, + // get_token_name(pc->type), pc->len, pc->len, pc->str); + if ((prev != NULL) && ((prev->type == CT_WORD) || (prev->type == CT_TYPE))) + { + if ((pc->len == prev->len) && (memcmp(pc->str, prev->str, pc->len) == 0)) + { + pc->type = CT_FUNC_CLASS; + if (destr != NULL) + { + destr->type = CT_DESTRUCTOR; + } + LOG_FMT(LFCN, "FOUND %sSTRUCTOR for %.*s[%s]\n", + (destr != NULL) ? "DE" : "CON", + prev->len, prev->str, get_token_name(prev->type)); + + mark_cpp_constructor(pc); + return; + } + else + { + /* Point to the item previous to the class name */ + prev = chunk_get_prev_ncnlnp(prev); + } + } + } + } + + /* Determine if this is a function call or a function def/proto */ + if ((pc->type == CT_FUNC_CALL) && + (pc->level == pc->brace_level) && + ((pc->flags & PCF_IN_ARRAY_ASSIGN) == 0)) + { + bool isa_def = false; + bool hit_star = false; + LOG_FMT(LFCN, " Checking func call: prev=%s", (prev == NULL) ? "" : get_token_name(prev->type)); + + /** + * REVISIT: + * a function def can only occur at brace level, but not inside an + * assignment, structure, enum, or union. + * The close paren must be followed by an open brace, with an optional + * qualifier (const) in between. + * There can be all sorts of template crap and/or '[]' in the type. + * This hack mostly checks that. + * + * Examples: + * foo->bar(maid); -- fcn call + * FOO * bar(); -- fcn proto or class variable + * FOO foo(); -- fcn proto or class variable + * FOO foo(1); -- class variable + * a = FOO * bar(); -- fcn call + * a.y = foo() * bar(); -- fcn call + * static const char * const fizz(); -- fcn def + */ + while (prev != NULL) + { + if (prev->flags & PCF_IN_PREPROC) + { + prev = chunk_get_prev_ncnlnp(prev); + continue; + } + + /* Some code slips an attribute between the type and function */ + if ((prev->type == CT_FPAREN_CLOSE) && + (prev->parent_type == CT_ATTRIBUTE)) + { + prev = skip_attribute_prev(prev); + continue; + } + + /** Skip the word/type before the '.' or '::' */ + if ((prev->type == CT_DC_MEMBER) || + (prev->type == CT_MEMBER)) + { + prev = chunk_get_prev_ncnlnp(prev); + if ((prev == NULL) || + ((prev->type != CT_WORD) && + (prev->type != CT_TYPE))) + { + LOG_FMT(LFCN, " --? Skipped MEMBER and landed on %s\n", + (prev == NULL) ? "" : get_token_name(prev->type)); + break; + } + LOG_FMT(LFCN, " ", prev->len, prev->str); + prev = chunk_get_prev_ncnlnp(prev); + continue; + } + + /* If we are on a TYPE or WORD, then we must be on a proto or def */ + if ((prev->type == CT_TYPE) || + (prev->type == CT_WORD)) + { + if (!hit_star) + { + LOG_FMT(LFCN, " --> For sure a prototype or definition\n"); + isa_def = true; + break; + } + LOG_FMT(LFCN, " --> maybe a proto/def\n"); + isa_def = true; + } + + if (chunk_is_addr(prev) || + chunk_is_star(prev)) + { + hit_star = true; + } + + if ((prev->type != CT_OPERATOR) && + (prev->type != CT_TSQUARE) && + (prev->type != CT_ANGLE_CLOSE) && + (prev->type != CT_QUALIFIER) && + (prev->type != CT_TYPE) && + (prev->type != CT_WORD) && + !chunk_is_addr(prev) && + !chunk_is_star(prev)) + { + LOG_FMT(LFCN, " --> Stopping on %.*s [%s]\n", + prev->len, prev->str, get_token_name(prev->type)); + break; + } + + /* Skip over template and attribute stuff */ + if (prev->type == CT_ANGLE_CLOSE) + { + prev = skip_template_prev(prev); + } + else if ((prev->type == CT_FPAREN_CLOSE) && + (prev->parent_type == CT_ATTRIBUTE)) + { + prev = skip_attribute_prev(prev); + } + else + { + prev = chunk_get_prev_ncnlnp(prev); + } + } + + //LOG_FMT(LFCN, " -- stopped on %.*s [%s]\n", + // prev->len, prev->str, get_token_name(prev->type)); + + if (isa_def && (prev != NULL) && + (chunk_is_paren_close(prev) || + (prev->type == CT_ASSIGN) || + (prev->type == CT_RETURN))) + { + LOG_FMT(LFCN, " -- overriding DEF due to %.*s [%s]\n", + prev->len, prev->str, get_token_name(prev->type)); + isa_def = false; + } + if (isa_def) + { + pc->type = CT_FUNC_DEF; + LOG_FMT(LFCN, "%s: '%.*s' is FCN_DEF:", __func__, pc->len, pc->str); + if (prev == NULL) + { + prev = chunk_get_head(); + } + for (tmp = prev; tmp != pc; tmp = chunk_get_next_ncnl(tmp)) + { + LOG_FMT(LFCN, ", %.*s[%s]", + tmp->len, tmp->str, get_token_name(tmp->type)); + make_type(tmp); + } + LOG_FMT(LFCN, "\n"); + } + } + + if (pc->type != CT_FUNC_DEF) + { + LOG_FMT(LFCN, " Detected %s '%.*s' on line %d col %d\n", + get_token_name(pc->type), + pc->len, pc->str, pc->orig_line, pc->orig_col); + + flag_parens(next, PCF_IN_FCN_CALL, CT_FPAREN_OPEN, CT_NONE, false); + return; + } + + /* We have a function definition or prototype + * Look for a semicolon or a brace open after the close paren to figure + * out whether this is a prototype or definition + */ + + flag_parens(paren_open, PCF_IN_FCN_DEF, CT_FPAREN_OPEN, pc->parent_type, false); + + /* See if this is a prototype or implementation */ + + /* Scan tokens until we hit a brace open (def) or semicolon (proto) */ + tmp = paren_close; + while ((tmp = chunk_get_next_ncnl(tmp)) != NULL) + { + /* Only care about brace or semi on the same level */ + if (tmp->level < pc->level) + { + /* No semicolon - probably a function call? */ + pc->type = CT_FUNC_CALL; + break; + } + else if (tmp->level == pc->level) + { + if (tmp->type == CT_BRACE_OPEN) + { + /* its a function def for sure */ + break; + } + else if (chunk_is_semicolon(tmp)) + { + /* Set the parent for the semi for later */ + semi = tmp; + pc->type = CT_FUNC_PROTO; + break; + } + else if (pc->type == CT_COMMA) + { + pc->type = CT_FUNC_CTOR_VAR; + LOG_FMT(LFCN, " 2) Marked [%.*s] as FUNC_CTOR_VAR on line %d col %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col); + break; + } + else if (chunk_is_str(tmp, ":", 1)) + { + /* mark constuctor colon (?) */ + tmp->type = CT_CLASS_COLON; + } + } + } + + /** + * C++ syntax is wacky. We need to check to see if a prototype is really a + * variable definition with parameters passed into the constructor. + * Unfortunately, the only mostly reliable way to do so is to guess that + * it is a constructor variable if inside a function body and scan the + * 'parameter list' for items that are not allowed in a prototype. + * We search backwards and checking the parent of the containing open braces. + * If the parent is a class or namespace, then it probably is a prototype. + */ + if ((cpd.lang_flags & LANG_CPP) && + (pc->type == CT_FUNC_PROTO) && + (pc->parent_type != CT_OPERATOR)) + { + LOG_FMT(LFPARAM, "%s :: checking '%.*s' for constructor variable %s %s\n", + __func__, pc->len, pc->str, + get_token_name(paren_open->type), + get_token_name(paren_close->type)); + + /* Scan the parameters looking for: + * - constant strings + * - numbers + * - non-type fields + * - function calls + */ + chunk_t *ref = chunk_get_next_ncnl(paren_open); + chunk_t *tmp = ref; + chunk_t *tmp2; + bool is_param = true; + while (tmp != paren_close) + { + tmp2 = chunk_get_next_ncnl(tmp); + if ((tmp->type == CT_COMMA) && (tmp->level == (paren_open->level + 1))) + { + if (!can_be_full_param(ref, tmp)) + { + is_param = false; + break; + } + ref = tmp2; + } + tmp = tmp2; + } + if (is_param && (ref != tmp)) + { + if (!can_be_full_param(ref, tmp)) + { + is_param = false; + } + } + if (!is_param) + { + pc->type = CT_FUNC_CTOR_VAR; + LOG_FMT(LFCN, " 3) Marked [%.*s] as FUNC_CTOR_VAR on line %d col %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col); + } + else if (pc->brace_level > 0) + { + chunk_t *br_open = chunk_get_prev_type(pc, CT_BRACE_OPEN, pc->brace_level - 1); + + if ((br_open != NULL) && + (br_open->parent_type != CT_EXTERN) && + (br_open->parent_type != CT_NAMESPACE)) + { + /* Do a check to see if the level is right */ + prev = chunk_get_prev_ncnl(pc); + if (!chunk_is_str(prev, "*", 1) && !chunk_is_str(prev, "&", 1)) + { + chunk_t *p_op = chunk_get_prev_type(pc, CT_BRACE_OPEN, pc->brace_level - 1); + if ((p_op != NULL) && + (p_op->parent_type != CT_CLASS) && + (p_op->parent_type != CT_STRUCT) && + (p_op->parent_type != CT_NAMESPACE)) + { + pc->type = CT_FUNC_CTOR_VAR; + LOG_FMT(LFCN, " 4) Marked [%.*s] as FUNC_CTOR_VAR on line %d col %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col); + } + } + } + } + } + + if (semi != NULL) + { + tmp->parent_type = pc->type; + } + + if (pc->type == CT_FUNC_CTOR_VAR) + { + pc->flags |= PCF_VAR_1ST_DEF; + return; + } + + if (next->type == CT_TSQUARE) + { + next = chunk_get_next_ncnl(next); + } + + /* Mark parameters */ + fix_fcn_def_params(next); + + /* Step backwards from pc and mark the parent of the return type */ + tmp = pc; + while ((tmp = chunk_get_prev_ncnl(tmp)) != NULL) + { + if (!chunk_is_type(tmp) && + (tmp->type != CT_OPERATOR) && + (tmp->type != CT_WORD) && + (tmp->type != CT_ADDR)) + { + break; + } + tmp->parent_type = pc->type; + make_type(tmp); + } + + /* Find the brace pair and set the parent */ + if (pc->type == CT_FUNC_DEF) + { + bool on_first = true; + tmp = chunk_get_next_ncnl(paren_close); + while ((tmp != NULL) && + (tmp->type != CT_BRACE_OPEN)) + { + //LOG_FMT(LSYS, "%s: set parent to FUNC_DEF on line %d: [%.*s]\n", __func__, tmp->orig_line, tmp->len, tmp->str); + tmp->parent_type = CT_FUNC_DEF; + if (chunk_is_semicolon(tmp)) + { + on_first = true; + } + else + { + tmp->flags |= PCF_OLD_FCN_PARAMS; + on_first = false; + } + tmp = chunk_get_next_ncnl(tmp); + } + if ((tmp != NULL) && (tmp->type == CT_BRACE_OPEN)) + { + tmp->parent_type = CT_FUNC_DEF; + tmp = chunk_skip_to_match(tmp); + if (tmp != NULL) + { + tmp->parent_type = CT_FUNC_DEF; + } + } + } +} + + +static void mark_cpp_constructor(chunk_t *pc) +{ + chunk_t *paren_open; + chunk_t *tmp; + chunk_t *after; + + LOG_FMT(LFTOR, "FOUND CONSTRUCTOR for %.*s[%s] ", + pc->len, pc->str, get_token_name(pc->type)); + + paren_open = chunk_get_next_ncnl(pc); + if (!chunk_is_str(paren_open, "(", 1)) + { + LOG_FMT(LWARN, "%s:%d Expected '(', got: [%.*s]\n", + cpd.filename, paren_open->orig_line, + paren_open->len, paren_open->str); + return; + } + + /* Mark parameters */ + fix_fcn_def_params(paren_open); + after = flag_parens(paren_open, PCF_IN_FCN_CALL, CT_FPAREN_OPEN, CT_FUNC_CLASS, false); + + LOG_FMT(LFTOR, "[%.*s]\n", after->len, after->str); + + /* Scan until the brace open, mark everything */ + tmp = paren_open; + while ((tmp != NULL) && (tmp->type != CT_BRACE_OPEN) && + !chunk_is_semicolon(tmp)) + { + tmp->flags |= PCF_IN_CONST_ARGS; + tmp = chunk_get_next_ncnl(tmp); + if (chunk_is_str(tmp, ":", 1)) + { + tmp->type = CT_CLASS_COLON; + } + } + if ((tmp != NULL) && (tmp->type == CT_BRACE_OPEN)) + { + set_paren_parent(tmp, CT_FUNC_CLASS); + } +} + + +/** + * We're on a 'class' or 'struct'. + * Scan for CT_FUNCTION with a string that matches pclass->str + */ +static void mark_class_ctor(chunk_t *start) +{ + chunk_t *next; + chunk_t *pclass; + + pclass = chunk_get_next_ncnl(start, CNAV_PREPROC); + if ((pclass == NULL) || + ((pclass->type != CT_TYPE) && + (pclass->type != CT_WORD))) + { + return; + } + + chunk_t *pc = chunk_get_next_ncnl(pclass, CNAV_PREPROC); + int level = pclass->brace_level + 1; + + LOG_FMT(LFTOR, "%s: Called on %.*s on line %d (next='%.*s')\n", + __func__, pclass->len, pclass->str, pclass->orig_line, + pc->len, pc->str); + + pclass->parent_type = start->type; + + /* Find the open brace, abort on semicolon */ + while ((pc != NULL) && (pc->type != CT_BRACE_OPEN)) + { + LOG_FMT(LFTOR, " [%.*s]", pc->len, pc->str); + + if (chunk_is_str(pc, ":", 1)) + { + pc->type = CT_CLASS_COLON; + LOG_FMT(LFTOR, "%s: class colon on line %d\n", + __func__, pc->orig_line); + } + + if (chunk_is_semicolon(pc)) + { + LOG_FMT(LFTOR, "%s: bailed on semicolon on line %d\n", + __func__, pc->orig_line); + return; + } + pc = chunk_get_next_ncnl(pc, CNAV_PREPROC); + } + + if (pc == NULL) + { + LOG_FMT(LFTOR, "%s: bailed on NULL\n", __func__); + return; + } + + set_paren_parent(pc, start->type); + + pc = chunk_get_next_ncnl(pc, CNAV_PREPROC); + while (pc != NULL) + { + pc->flags |= PCF_IN_CLASS; + + if ((pc->brace_level > level) || ((pc->flags & PCF_IN_PREPROC) != 0)) + { + pc = chunk_get_next_ncnl(pc); + continue; + } + + if ((pc->type == CT_BRACE_CLOSE) && (pc->brace_level < level)) + { + LOG_FMT(LFTOR, "%s: %d] Hit brace close\n", __func__, pc->orig_line); + return; + } + + next = chunk_get_next_ncnl(pc, CNAV_PREPROC); + if ((next != NULL) && (next->len == 1) && (*next->str == '(') && + (pc->len == pclass->len) && + (memcmp(pc->str, pclass->str, pc->len) == 0)) + { + pc->type = CT_FUNC_CLASS; + LOG_FMT(LFTOR, "%d] Marked CTor/DTor %.*s\n", pc->orig_line, pc->len, pc->str); + mark_cpp_constructor(pc); + } + pc = next; + } +} + + +/** + * We're on a 'namespace' skip the word and then set the parent of the braces. + */ +static void mark_namespace(chunk_t *pns) +{ + chunk_t *pc; + chunk_t *br_close; + + pc = chunk_get_next_ncnl(pns); + if (pc != NULL) + { + if (pc->type != CT_BRACE_OPEN) + { + pc = chunk_get_next_ncnl(pc); + } + if ((pc != NULL) && (pc->type == CT_BRACE_OPEN)) + { + if ((cpd.settings[UO_indent_namespace_limit].n > 0) && + ((br_close = chunk_skip_to_match(pc)) != NULL)) + { + int diff = br_close->orig_line - pc->orig_line; + + if (diff > cpd.settings[UO_indent_namespace_limit].n) + { + pc->flags |= PCF_LONG_BLOCK; + br_close->flags |= PCF_LONG_BLOCK; + } + } + flag_parens(pc, PCF_IN_NAMESPACE, CT_NONE, CT_NAMESPACE, false); + } + } +} + + +/** + * Examines the stuff between braces { }. + * There should only be variable definitions. + */ +static void mark_struct_union_body(chunk_t *start) +{ + chunk_t *pc = start; + chunk_t *first; + chunk_t *last; + + // fprintf(stderr, "%s: line %d %s\n", + // __func__, start->orig_line, get_token_name(start->type)); + + while ((pc != NULL) && + (pc->level >= start->level) && + (pc->type != CT_BRACE_CLOSE)) + { + if (chunk_is_semicolon(pc)) + { + pc = chunk_get_next_ncnlnp(pc); + continue; + } + + if ((pc->type == CT_STRUCT) || (pc->type == CT_UNION)) + { + pc = chunk_get_next_ncnlnp(pc); + if ((pc != NULL) && (pc->type != CT_BRACE_OPEN)) + { + pc = chunk_get_next_ncnlnp(pc); + } + if ((pc != NULL) && (pc->type == CT_BRACE_OPEN)) + { + mark_struct_union_body(pc); + pc = chunk_skip_to_match(pc); + pc = chunk_get_next_ncnlnp(pc); + } + if (pc != NULL) + { + pc = mark_variable_definition(pc); + } + } + else + { + last = NULL; + first = pc; + while ((pc != NULL) && ((pc->type == CT_TYPE) || + (pc->type == CT_WORD) || + (pc->type == CT_QUALIFIER) || + (pc->type == CT_DC_MEMBER) || + (pc->type == CT_MEMBER) || + (pc->type == CT_ANGLE_OPEN) || + chunk_is_star(pc) || + chunk_is_addr(pc))) + { + last = pc; + if (pc->type == CT_ANGLE_OPEN) + { + pc = skip_template_next(pc); + } + else if (pc->type == CT_ATTRIBUTE) + { + pc = skip_attribute_next(pc); + } + else + { + pc = chunk_get_next_ncnlnp(pc); + } + } + if (last != NULL) + { + for (pc = first; pc != last; pc = chunk_get_next_ncnlnp(pc)) + { + make_type(pc); + } + pc = mark_variable_definition(last); + } + else + { + pc = chunk_get_next_ncnlnp(pc); + } + } + } +} + + +/** + * Sets the parent for comments. + */ +void mark_comments(void) +{ + chunk_t *cur; + chunk_t *next; + bool prev_nl = true; + bool next_nl; + + cur = chunk_get_head(); + + while (cur != NULL) + { + next = chunk_get_next(cur); + next_nl = (next == NULL) || chunk_is_newline(next); + + if (chunk_is_comment(cur)) + { + if (next_nl && prev_nl) + { + cur->parent_type = CT_COMMENT_WHOLE; + } + else if (next_nl) + { + cur->parent_type = CT_COMMENT_END; + } + else if (prev_nl) + { + cur->parent_type = CT_COMMENT_START; + } + else + { + cur->parent_type = CT_COMMENT_EMBED; + } + } + + prev_nl = chunk_is_newline(cur); + cur = next; + } +} + + +/** + * Marks statement starts in a macro body. + * REVISIT: this may already be done + */ +static void mark_define_expressions(void) +{ + chunk_t *pc; + chunk_t *prev; + bool in_define = false; + bool first = true; + + pc = chunk_get_head(); + prev = pc; + + while (pc != NULL) + { + if (!in_define) + { + if ((pc->type == CT_PP_DEFINE) || + (pc->type == CT_PP_IF) || + (pc->type == CT_PP_ELSE)) + { + in_define = true; + first = true; + } + } + else + { + if (((pc->flags & PCF_IN_PREPROC) == 0) || (pc->type == CT_PREPROC)) + { + in_define = false; + } + else + { + if ((pc->type != CT_MACRO) && + (first || + (prev->type == CT_PAREN_OPEN) || + (prev->type == CT_ARITH) || + (prev->type == CT_ASSIGN) || + (prev->type == CT_COMPARE) || + (prev->type == CT_RETURN) || + (prev->type == CT_GOTO) || + (prev->type == CT_CONTINUE) || + (prev->type == CT_PAREN_OPEN) || + (prev->type == CT_FPAREN_OPEN) || + (prev->type == CT_SPAREN_OPEN) || + (prev->type == CT_BRACE_OPEN) || + chunk_is_semicolon(prev) || + (prev->type == CT_COMMA) || + (prev->type == CT_COLON) || + (prev->type == CT_QUESTION))) + { + pc->flags |= PCF_EXPR_START; + first = false; + } + } + } + + prev = pc; + pc = chunk_get_next(pc); + } +} + + +/** + * We are on the 'template' C++ keyword. + * What follows should be the following: + * + * template function_declaration; + * template function_declaration; + * template class class_declaration; + * template class class_declaration; + * + * Change the 'class' inside the <> to CT_TYPE. + * Set the parent to the class after the <> to CT_TEMPLATE. + * Set the parent of the semicolon to CT_TEMPLATE. + */ +static void handle_template(chunk_t *pc) +{ + chunk_t *tmp; + int level; + + tmp = chunk_get_next_ncnl(pc); + if (tmp->type != CT_ANGLE_OPEN) + { + return; + } + tmp->parent_type = CT_TEMPLATE; + + level = tmp->level; + + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if ((tmp->type == CT_CLASS) || + (tmp->type == CT_STRUCT)) + { + tmp->type = CT_TYPE; + } + else if ((tmp->type == CT_ANGLE_CLOSE) && (tmp->level == level)) + { + tmp->parent_type = CT_TEMPLATE; + break; + } + } + if (tmp != NULL) + { + tmp = chunk_get_next_ncnl(tmp); + if ((tmp != NULL) && + ((tmp->type == CT_CLASS) || (tmp->type == CT_STRUCT))) + { + tmp->parent_type = CT_TEMPLATE; + + /* REVISTI: This may be a bit risky - might need to track the { }; */ + tmp = chunk_get_next_type(tmp, CT_SEMICOLON, tmp->level); + if (tmp != NULL) + { + tmp->parent_type = CT_TEMPLATE; + } + } + } +} + + +/** + * We are on a word followed by a angle open which is part of a template. + * If the angle close is followed by a open paren, then we are on a template + * function def or a template function call: + * Vector2(...) [: ...[, ...]] { ... } + * Or we could be on a variable def if it's followed by a word: + * Renderer rend; + */ +static void mark_template_func(chunk_t *pc, chunk_t *pc_next) +{ + chunk_t *angle_close; + chunk_t *after; + + /* We know angle_close must be there... */ + angle_close = chunk_get_next_type(pc_next, CT_ANGLE_CLOSE, pc->level); + + after = chunk_get_next_ncnl(angle_close); + if (after != NULL) + { + if (chunk_is_str(after, "(", 1)) + { + if (angle_close->flags & PCF_IN_FCN_CALL) + { + LOG_FMT(LTEMPFUNC, "%s: marking '%.*s' in line %d as a FUNC_CALL\n", + __func__, pc->len, pc->str, pc->orig_line); + pc->type = CT_FUNC_CALL; + flag_parens(after, PCF_IN_FCN_CALL, CT_FPAREN_OPEN, CT_FUNC_CALL, false); + } + else + { + /* Might be a function def. Must check what is before the template: + * Func call: + * BTree.Insert(std::pair(*it, double(*it) + 1.0)); + * a = Test(j); + * std::pair(*it, double(*it) + 1.0)); + */ + + LOG_FMT(LTEMPFUNC, "%s: marking '%.*s' in line %d as a FUNC_CALL\n", + __func__, pc->len, pc->str, pc->orig_line); + // its a function!!! + pc->type = CT_FUNC_CALL; + mark_function(pc); + } + } + else if (after->type == CT_WORD) + { + // its a type! + pc->type = CT_TYPE; + pc->flags |= PCF_VAR_TYPE; + after->flags |= PCF_VAR_DEF; + } + } +} + + +/** + * Just mark every CT_WORD until a semicolon as CT_SQL_WORD. + * Adjust the levels if pc is CT_SQL_BEGIN + */ +static void mark_exec_sql(chunk_t *pc) +{ + chunk_t *tmp; + + /* Change CT_WORD to CT_SQL_WORD */ + for (tmp = chunk_get_next(pc); tmp != NULL; tmp = chunk_get_next(tmp)) + { + tmp->parent_type = pc->type; + if (tmp->type == CT_WORD) + { + tmp->type = CT_SQL_WORD; + } + if (tmp->type == CT_SEMICOLON) + { + break; + } + } + + if ((pc->type != CT_SQL_BEGIN) || + (tmp == NULL) || (tmp->type != CT_SEMICOLON)) + { + return; + } + + for (tmp = chunk_get_next(tmp); + (tmp != NULL) && (tmp->type != CT_SQL_END); + tmp = chunk_get_next(tmp)) + { + tmp->level++; + } +} + + +/** + * Skips over the rest of the template if ang_open is indeed a CT_ANGLE_OPEN. + * Points to the chunk after the CT_ANGLE_CLOSE. + * If the chunk isn't an CT_ANGLE_OPEN, then it is returned. + */ +chunk_t *skip_template_next(chunk_t *ang_open) +{ + if ((ang_open != NULL) && (ang_open->type == CT_ANGLE_OPEN)) + { + chunk_t *pc; + pc = chunk_get_next_type(ang_open, CT_ANGLE_CLOSE, ang_open->level); + return(chunk_get_next_ncnl(pc)); + } + return(ang_open); +} + + +/** + * Skips over the rest of the template if ang_close is indeed a CT_ANGLE_CLOSE. + * Points to the chunk before the CT_ANGLE_OPEN + * If the chunk isn't an CT_ANGLE_CLOSE, then it is returned. + */ +chunk_t *skip_template_prev(chunk_t *ang_close) +{ + if ((ang_close != NULL) && (ang_close->type == CT_ANGLE_CLOSE)) + { + chunk_t *pc; + pc = chunk_get_prev_type(ang_close, CT_ANGLE_OPEN, ang_close->level); + return(chunk_get_prev_ncnl(pc)); + } + return(ang_close); +} + + +/** + * If attr is CT_ATTRIBUTE, then skip it and the parens and return the chunk + * after the CT_FPAREN_CLOSE. + * If the chunk isn't an CT_ATTRIBUTE, then it is returned. + */ +chunk_t *skip_attribute_next(chunk_t *attr) +{ + if ((attr != NULL) && (attr->type == CT_ATTRIBUTE)) + { + chunk_t *pc = chunk_get_next(attr); + if ((pc != NULL) && (pc->type == CT_FPAREN_OPEN)) + { + pc = chunk_get_next_type(attr, CT_FPAREN_CLOSE, attr->level); + return(chunk_get_next_ncnl(pc)); + } + return(pc); + } + return(attr); +} + + +/** + * If fp_close is a CT_FPAREN_CLOSE with a parent of CT_ATTRIBUTE, then skip it + * and the '__attribute__' thingy and return the chunk before CT_ATTRIBUTE. + * Otherwise return fp_close. + */ +chunk_t *skip_attribute_prev(chunk_t *fp_close) +{ + if ((fp_close != NULL) && + (fp_close->type == CT_FPAREN_CLOSE) && + (fp_close->parent_type == CT_ATTRIBUTE)) + { + chunk_t *pc; + pc = chunk_get_prev_type(fp_close, CT_ATTRIBUTE, fp_close->level); + return(chunk_get_prev_ncnl(pc)); + } + return(fp_close); +} + + +/** + * Process an ObjC 'class' + * pc is the chunk after '@implementation' or '@interface'. + * Change colons, etc. + */ +static void handle_oc_class(chunk_t *pc) +{ + chunk_t *tmp = pc; + + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if (tmp->type == CT_OC_END) + { + break; + } + if (tmp->type == CT_BRACE_OPEN) + { + tmp->parent_type = CT_OC_CLASS; + break; + } + else if (tmp->type == CT_COLON) + { + tmp->type = CT_CLASS_COLON; + tmp->parent_type = CT_OC_CLASS; + } + else if (chunk_is_str(tmp, "-", 1) || chunk_is_str(tmp, "+", 1)) + { + tmp->flags |= PCF_STMT_START; + break; + } + } + + if ((tmp != NULL) && (tmp->type == CT_BRACE_OPEN)) + { + tmp = chunk_get_next_type(tmp, CT_BRACE_CLOSE, tmp->level); + if (tmp != NULL) + { + tmp->parent_type = CT_OC_CLASS; + } + } +} + + +/** + * Process an ObjC message spec/dec + * + * Specs: + * -(void) foo ARGS; + * + * Decl: + * -(void) foo ARGS { } + * + * ARGS is ': (type) name [name]' + * -(void) foo: (int) arg: { } + */ +static void handle_oc_message_decl(chunk_t *pc) +{ + chunk_t *tmp; + bool in_paren = false; + int paren_cnt = 0; + int arg_cnt = 0; + c_token_t pt = CT_OC_MSG_SPEC; + + /* Figure out if this is a spec or decl */ + tmp = pc; + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if ((tmp->type == CT_SEMICOLON) || + (tmp->type == CT_BRACE_OPEN)) + { + pt = (tmp->type == CT_SEMICOLON) ? CT_OC_MSG_SPEC : CT_OC_MSG_DECL; + break; + } + } + if (tmp == NULL) + { + return; + } + pc->type = CT_OC_SCOPE; + pc->parent_type = pt; + + /* Mark everything */ + tmp = pc; + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if ((tmp->type == CT_SEMICOLON) || + (tmp->type == CT_BRACE_OPEN)) + { + tmp->parent_type = pt; + break; + } + + /* Mark first parens as return type */ + if ((arg_cnt == 0) && + ((tmp->type == CT_PAREN_OPEN) || + (tmp->type == CT_PAREN_CLOSE))) + { + tmp->parent_type = CT_OC_RTYPE; + in_paren = (tmp->type == CT_PAREN_OPEN); + if (!in_paren) + { + paren_cnt++; + arg_cnt++; + } + } + else if ((tmp->type == CT_PAREN_OPEN) || + (tmp->type == CT_PAREN_CLOSE)) + { + tmp->parent_type = pt; + in_paren = (tmp->type == CT_PAREN_OPEN); + if (!in_paren) + { + paren_cnt++; + } + } + else if (tmp->type == CT_WORD) + { + if (in_paren) + { + tmp->type = CT_TYPE; + } + else if (paren_cnt == 1) + { + tmp->type = pt; + } + else + { + tmp->flags |= PCF_VAR_DEF; + } + } + else if (tmp->type == CT_COLON) + { + tmp->type = CT_OC_COLON; + tmp->parent_type = pt; + } + } + + if ((tmp != NULL) && (tmp->type == CT_BRACE_OPEN)) + { + tmp = chunk_get_next_type(tmp, CT_BRACE_CLOSE, tmp->level); + if (tmp != NULL) + { + tmp->parent_type = pt; + } + } +} + + +/** + * Process an ObjC message send statement: + * [ server setStringValue : @"" ] ; + * + * Just find the matching ']' and ';' and mark the colon. + * + * @param os points to the open square '[' + */ +static void handle_oc_message_send(chunk_t *os) +{ + chunk_t *tmp; + chunk_t *cs = chunk_get_next(os); + + while ((cs != NULL) && (cs->level > os->level)) + { + cs = chunk_get_next(cs); + } + + if ((cs == NULL) || (cs->type != CT_SQUARE_CLOSE)) + { + return; + } + + tmp = chunk_get_next_ncnl(cs); + if (chunk_is_semicolon(tmp)) + { + tmp->parent_type = CT_OC_MSG; + } + + os->parent_type = CT_OC_MSG; + cs->parent_type = CT_OC_MSG; + + for (tmp = chunk_get_next(os); tmp != cs; tmp = chunk_get_next(tmp)) + { + tmp->parent_type = CT_OC_MSG; + if (tmp->type == CT_COLON) + { + tmp->type = CT_OC_COLON; + } + } +} + + +/** + * Process an C# [] thingy: + * [assembly: xxx] + * [AttributeUsage()] + * [@X] + * + * Set the next chunk to a statement start after the close ']' + * + * @param os points to the open square '[' + */ +static void handle_cs_square_stmt(chunk_t *os) +{ + chunk_t *tmp; + chunk_t *cs = chunk_get_next(os); + + while ((cs != NULL) && (cs->level > os->level)) + { + cs = chunk_get_next(cs); + } + + if ((cs == NULL) || (cs->type != CT_SQUARE_CLOSE)) + { + return; + } + + os->parent_type = CT_CS_SQ_STMT; + cs->parent_type = CT_CS_SQ_STMT; + + for (tmp = chunk_get_next(os); tmp != cs; tmp = chunk_get_next(tmp)) + { + tmp->parent_type = CT_CS_SQ_STMT; + if (tmp->type == CT_COLON) + { + tmp->type = CT_CS_SQ_COLON; + } + } + + tmp = chunk_get_next_ncnl(cs); + if (tmp != NULL) + { + tmp->flags |= PCF_STMT_START | PCF_EXPR_START; + } +} + + +/** + * We are on a brace open that is preceeded by a word or square close. + * Set the brace parent to CT_CS_PROPERTY and find the first item in the + * property and set its parent, too. + */ +static void handle_cs_property(chunk_t *bro) +{ + chunk_t *pc; + bool did_prop = false; + + set_paren_parent(bro, CT_CS_PROPERTY); + + pc = bro; + while ((pc = chunk_get_prev_ncnl(pc)) != NULL) + { + if (pc->level == bro->level) + { + if (!did_prop && ((pc->type == CT_WORD) || (pc->type == CT_THIS))) + { + pc->type = CT_CS_PROPERTY; + did_prop = true; + } + else + { + pc->parent_type = CT_CS_PROPERTY; + make_type(pc); + } + if (pc->flags & PCF_STMT_START) + { + break; + } + } + } +} + + +/** + * Remove 'return;' that appears as the last statement in a function + */ +void remove_extra_returns() +{ + chunk_t *pc; + chunk_t *semi; + chunk_t *cl_br; + + pc = chunk_get_head(); + while (pc != NULL) + { + if ((pc->type == CT_RETURN) && ((pc->flags & PCF_IN_PREPROC) == 0)) + { + semi = chunk_get_next_ncnl(pc); + cl_br = chunk_get_next_ncnl(semi); + + if ((semi != NULL) && (semi->type == CT_SEMICOLON) && + (cl_br != NULL) && (cl_br->type == CT_BRACE_CLOSE) && + ((cl_br->parent_type == CT_FUNC_DEF) || + (cl_br->parent_type == CT_FUNC_CLASS))) + { + LOG_FMT(LRMRETURN, "Removed 'return;' on line %d\n", pc->orig_line); + chunk_del(pc); + chunk_del(semi); + pc = cl_br; + } + } + + pc = chunk_get_next(pc); + } +} + + +/** + * A func wrap chunk and what follows should be treated as a function name. + * Create new text for the chunk and call it a CT_FUNCTION. + * + * A type wrap chunk and what follows should be treated as a simple type. + * Create new text for the chunk and call it a CT_TYPE. + */ +static void handle_wrap(chunk_t *pc) +{ + chunk_t *opp = chunk_get_next(pc); + chunk_t *name = chunk_get_next(opp); + chunk_t *clp = chunk_get_next(name); + char *new_name; + + argval_t av = (pc->type == CT_FUNC_WRAP) ? + cpd.settings[UO_sp_inside_fparen].a : + cpd.settings[UO_sp_inside_paren_cast].a; + + if ((clp != NULL) && + (opp->type == CT_PAREN_OPEN) && + ((name->type == CT_WORD) || (name->type == CT_TYPE)) && + (clp->type == CT_PAREN_CLOSE)) + { + new_name = new char[pc->len + 2 + name->len + 2]; + if (new_name != NULL) + { + const char *fsp = (av & AV_ADD) ? " " : ""; + + sprintf(new_name, "%.*s(%s%.*s%s)", + pc->len, pc->str, fsp, name->len, name->str, fsp); + pc->type = (pc->type == CT_FUNC_WRAP) ? CT_FUNCTION : CT_TYPE; + pc->str = new_name; + pc->len = strlen(new_name); + pc->flags |= PCF_OWN_STR; + + pc->orig_col_end = pc->orig_col + pc->len; + + chunk_del(opp); + chunk_del(name); + chunk_del(clp); + } + } +} diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000000..8ceb666d34 --- /dev/null +++ b/src/config.h @@ -0,0 +1,109 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#define HAVE_MALLOC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#define HAVE_REALLOC 1 + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Name of package */ +#define PACKAGE "uncrustify" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "uncrustify" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "uncrustify 0.54" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "uncrustify" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.54" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.54" + +/* Define to appropriate substitue if compiler doesnt have __func__ */ +/* #undef __func__ */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +/* #undef malloc */ + +/* Define to rpl_realloc if the replacement function should be used. */ +/* #undef realloc */ diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000000..3a4c89e07b --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,108 @@ +/* src/config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#undef HAVE_REALLOC + +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the `strtoul' function. */ +#undef HAVE_STRTOUL + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UTIME_H + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to appropriate substitue if compiler doesnt have __func__ */ +#undef __func__ + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to rpl_realloc if the replacement function should be used. */ +#undef realloc diff --git a/src/d.tokenize.cpp b/src/d.tokenize.cpp new file mode 100644 index 0000000000..36011a7c1a --- /dev/null +++ b/src/d.tokenize.cpp @@ -0,0 +1,122 @@ +/** + * @file d.tokenize.cpp + * This file gets included into tokenize.cpp. + * This is specific to the D language. + * + * @author Ben Gardner + * @license GPL v2+ + */ + + +/** + * Parses all legal D string constants. + * + * Quoted strings: + * r"Wysiwyg" # WYSIWYG string + * x"hexstring" # Hexadecimal array + * `Wysiwyg` # WYSIWYG string + * 'char' # single character + * "reg_string" # regular string + * + * Non-quoted strings: + * \x12 # 1-byte hex constant + * \u1234 # 2-byte hex constant + * \U12345678 # 4-byte hex constant + * \123 # octal constant + * \& # named entity + * \n # single character + * + * @param pc The structure to update, str is an input. + * @return Whether a string was parsed + */ +static bool d_parse_string(chunk_t *pc) +{ + if (pc->str[0] == '"') + { + return(parse_string(pc, 0, true)); + } + else if ((pc->str[0] == '\'') || + (pc->str[0] == '`')) + { + return(parse_string(pc, 0, true)); + } + else if (pc->str[0] == '\\') + { + pc->len = 0; + while (pc->str[pc->len] == '\\') + { + pc->len++; + /* Check for end of file */ + switch (pc->str[pc->len]) + { + case 'x': + /* \x HexDigit HexDigit */ + pc->len += 3; + break; + + case 'u': + /* \u HexDigit HexDigit HexDigit HexDigit */ + pc->len += 5; + break; + + case 'U': + /* \U HexDigit (x8) */ + pc->len += 9; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + /* handle up to 3 octal digits */ + pc->len++; + if ((pc->str[pc->len] >= '0') && (pc->str[pc->len] <= '7')) + { + pc->len++; + if ((pc->str[pc->len] >= '0') && (pc->str[pc->len] <= '7')) + { + pc->len++; + } + } + break; + + case '&': + /* \& NamedCharacterEntity ; */ + pc->len++; + while (isalpha(pc->str[pc->len])) + { + pc->len++; + } + if (pc->str[pc->len] == ';') + { + pc->len++; + } + break; + + default: + /* Everything else is a single character */ + pc->len++; + break; + } + } + + if (pc->len > 1) + { + pc->type = CT_STRING; + cpd.column += pc->len; + return(true); + } + } + else if (pc->str[1] == '"') + { + if ((pc->str[0] == 'r') || (pc->str[0] == 'x')) + { + return(parse_string(pc, 1, false)); + } + } + return(false); +} diff --git a/src/defines.cpp b/src/defines.cpp new file mode 100644 index 0000000000..b4c613f9a9 --- /dev/null +++ b/src/defines.cpp @@ -0,0 +1,416 @@ +/** + * @file defines.cpp + * Manages the table of keywords. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "char_table.h" +#include "args.h" +#include +#include +#include +#include "unc_ctype.h" +#include "chunk_list.h" +#include "prototypes.h" + +typedef struct +{ + define_tag_t *p_tags; + int total; /* number of items at p_tags */ + int active; /* number of valid entries */ +} define_list_t; +static define_list_t dl; + + +/** + * Compares two define_tag_t entries using strcmp on the name + * + * @param p1 The 'left' entry + * @param p2 The 'right' entry + */ +static int def_compare(const void *p1, const void *p2) +{ + const define_tag_t *t1 = (const define_tag_t *)p1; + const define_tag_t *t2 = (const define_tag_t *)p2; + + return(strcmp(t1->tag, t2->tag)); +} + + +/** + * Adds an entry to the define list + * + * @param tag The tag (string) must be zero terminated + * @param value NULL or the value of the define + */ +void add_define(const char *tag, const char *value) +{ + /* Update existing entry */ + if (dl.active > 0) + { + define_tag_t *p_ret; + + p_ret = (define_tag_t *)bsearch(&tag, dl.p_tags, dl.active, + sizeof(define_tag_t), def_compare); + if (p_ret != NULL) + { + if (*p_ret->value != 0) + { + free((void *)p_ret->value); + } + if ((value == NULL) || (*value == 0)) + { + dl.p_tags[dl.active].value = ""; + } + else + { + dl.p_tags[dl.active].value = strdup(value); + } + return; + } + } + + /* need to add it to the list: do we need to allocate more memory? */ + if ((dl.total == dl.active) || (dl.p_tags == NULL)) + { + dl.total += 16; + dl.p_tags = (define_tag_t *)realloc(dl.p_tags, sizeof(define_tag_t) * dl.total); + } + if (dl.p_tags != NULL) + { + /* add to the end of the list */ + dl.p_tags[dl.active].tag = strdup(tag); + if ((value == NULL) || (*value == 0)) + { + dl.p_tags[dl.active].value = ""; + } + else + { + dl.p_tags[dl.active].value = strdup(value); + } + dl.active++; + + /* Todo: add in sorted order instead of resorting the whole list? */ + qsort(dl.p_tags, dl.active, sizeof(define_tag_t), def_compare); + + LOG_FMT(LDEFVAL, "%s: added '%s' = '%s'\n", + __func__, tag, value ? value : "NULL"); + } +} + + +/** + * Search the define table for a match + * + * @param word Pointer to the text -- NOT zero terminated + * @param len The length of the text + * @return NULL (no match) or the define entry + */ +const define_tag_t *find_define(const char *word, int len) +{ + define_tag_t tag; + char buf[32]; + const define_tag_t *p_ret; + + if (len > (int)(sizeof(buf) - 1)) + { + LOG_FMT(LNOTE, "%s: define too long at %d char (%d max) : %.*s\n", + __func__, len, (int)sizeof(buf), len, word); + return(NULL); + } + memcpy(buf, word, len); + buf[len] = 0; + + tag.tag = buf; + + /* check the dynamic word list first */ + p_ret = (const define_tag_t *)bsearch(&tag, dl.p_tags, dl.active, + sizeof(define_tag_t), def_compare); + return(p_ret); +} + + +/** + * Loads the defines from a file + * + * @param filename The path to the file to load + * @return SUCCESS or FAILURE + */ +int load_define_file(const char *filename) +{ + FILE *pf; + char buf[160]; + char *ptr; + char *args[3]; + int argc; + int line_no = 0; + + pf = fopen(filename, "r"); + if (pf == NULL) + { + LOG_FMT(LERR, "%s: fopen(%s) failed: %s (%d)\n", + __func__, filename, strerror(errno), errno); + cpd.error_count++; + return(FAILURE); + } + + while (fgets(buf, sizeof(buf), pf) != NULL) + { + line_no++; + + /* remove comments */ + if ((ptr = strchr(buf, '#')) != NULL) + { + *ptr = 0; + } + + argc = Args::SplitLine(buf, args, ARRAY_SIZE(args) - 1); + args[argc] = 0; + + if (argc > 0) + { + if ((argc <= 2) && CharTable::IsKw1(*args[0])) + { + LOG_FMT(LDEFVAL, "%s: line %d - %s\n", filename, line_no, args[0]); + add_define(args[0], args[1]); + } + else + { + LOG_FMT(LWARN, "%s: line %d invalid (starts with '%s')\n", + filename, line_no, args[0]); + cpd.error_count++; + } + } + } + + fclose(pf); + return(SUCCESS); +} + + +void output_defines(FILE *pfile) +{ + int idx; + + if (dl.active > 0) + { + fprintf(pfile, "-== User Defines ==-\n"); + } + for (idx = 0; idx < dl.active; idx++) + { + if (*dl.p_tags[idx].value != 0) + { + fprintf(pfile, "%s = %s\n", dl.p_tags[idx].tag, dl.p_tags[idx].value); + } + else + { + fprintf(pfile, "%s\n", dl.p_tags[idx].tag); + } + } +} + + +const define_tag_t *get_define_idx(int& idx) +{ + const define_tag_t *dt = NULL; + + if ((idx >= 0) && (idx < dl.active)) + { + dt = &dl.p_tags[idx]; + } + idx++; + return(dt); +} + + +void clear_defines(void) +{ + if (dl.p_tags != NULL) + { + for (int idx = 0; idx < dl.active; idx++) + { + free((void *)dl.p_tags[idx].tag); + dl.p_tags[idx].tag = NULL; + if (dl.p_tags[idx].value != NULL) + { + free((void *)dl.p_tags[idx].value); + dl.p_tags[idx].value = NULL; + } + } + free(dl.p_tags); + dl.p_tags = NULL; + } + dl.total = 0; + dl.active = 0; +} + + +/** + * This renders the #if condition to a string buffer. + */ +static void generate_if_conditional_as_text(std::string& dst, chunk_t *ifdef) +{ + chunk_t *pc; + int column = -1; + + dst.erase(); + for (pc = ifdef; pc != NULL; pc = chunk_get_next(pc)) + { + if (column == -1) + { + column = pc->column; + } + if ((pc->type == CT_NEWLINE) || + (pc->type == CT_COMMENT_MULTI) || + (pc->type == CT_COMMENT_CPP)) + { + break; + } + else if (pc->type == CT_NL_CONT) + { + dst += ' '; + column = -1; + } + else if ((pc->type == CT_COMMENT) || + (pc->type == CT_COMMENT_EMBED)) + { + } + else // if (pc->type == CT_JUNK) || else + { + int spacing; + + for (spacing = pc->column - column; spacing > 0; spacing--) + { + dst += ' '; + column++; + } + dst.append(pc->str, pc->len); + column += pc->len; + } + } +} + + +/* + * See also it's preprocessor counterpart + * add_long_closebrace_comment + * in braces.cpp + * + * Note: since this concerns itself with the preprocessor -- which is line-oriented -- + * it turns out that just looking at pc->pp_level is NOT the right thing to do. + * See a --parsed dump if you don't believe this: an '#endif' will be one level + * UP from the corresponding #ifdef when you look at the tokens 'ifdef' versus 'endif', + * but it's a whole another story when you look at their CT_PREPROC ('#') tokens! + * + * Hence we need to track and seek matching CT_PREPROC pp_levels here, which complicates + * things a little bit, but not much. + */ +void add_long_preprocessor_conditional_block_comment(void) +{ + chunk_t *pc; + chunk_t *tmp; + chunk_t *br_open; + chunk_t *br_close; + chunk_t *pp_start = NULL; + chunk_t *pp_end = NULL; + int nl_count; + + for (pc = chunk_get_head(); pc; pc = chunk_get_next_ncnl(pc)) + { + /* just track the preproc level: */ + if (pc->type == CT_PREPROC) + { + pp_end = pp_start = pc; + } + + if (pc->type != CT_PP_IF) + { + continue; + } +#if 0 + if ((pc->flags & PCF_IN_PREPROC) != 0) + { + continue; + } +#endif + + br_open = pc; + nl_count = 0; + + tmp = pc; + while ((tmp = chunk_get_next(tmp)) != NULL) + { + /* just track the preproc level: */ + if (tmp->type == CT_PREPROC) + { + pp_end = tmp; + } + + if (chunk_is_newline(tmp)) + { + nl_count += tmp->nl_count; + } + else if ((pp_end->pp_level == pp_start->pp_level) && + ((tmp->type == CT_PP_ENDIF) || + (br_open->type == CT_PP_IF ? tmp->type == CT_PP_ELSE : 0))) + { + br_close = tmp; + + LOG_FMT(LPPIF, "found #if / %s section on lines %d and %d, nl_count=%d\n", + (tmp->type == CT_PP_ENDIF ? "#endif" : "#else"), + br_open->orig_line, br_close->orig_line, nl_count); + + /* Found the matching #else or #endif - make sure a newline is next */ + tmp = chunk_get_next(tmp); + + LOG_FMT(LPPIF, "next item type %d (is %s)\n", + (tmp ? tmp->type : -1), (tmp ? chunk_is_newline(tmp) ? "newline" + : chunk_is_comment(tmp) ? "comment" : "other" : "---")); + if ((tmp == NULL) || (tmp->type == CT_NEWLINE) /* chunk_is_newline(tmp) */) + { + int nl_min; + + if (br_close->type == CT_PP_ENDIF) + { + nl_min = cpd.settings[UO_mod_add_long_ifdef_endif_comment].n; + } + else + { + nl_min = cpd.settings[UO_mod_add_long_ifdef_else_comment].n; + } + + LOG_FMT(LPPIF, "#if / %s section candidate for augmenting when over NL threshold %d != 0 (nl_count=%d)\n", + (tmp->type == CT_PP_ENDIF ? "#endif" : "#else"), + nl_min, nl_count); + + if ((nl_min > 0) && (nl_count > nl_min)) /* nl_count is 1 too large at all times as #if line was counted too */ + { + /* determine the added comment style */ + c_token_t style = (cpd.lang_flags & (LANG_CPP | LANG_CS)) ? + CT_COMMENT_CPP : CT_COMMENT; + + std::string str; + generate_if_conditional_as_text(str, br_open); + + LOG_FMT(LPPIF, "#if / %s section over threshold %d (nl_count=%d) --> insert comment after the %s: %s\n", + (tmp->type == CT_PP_ENDIF ? "#endif" : "#else"), + nl_min, nl_count, + (tmp->type == CT_PP_ENDIF ? "#endif" : "#else"), + str.c_str()); + + /* Add a comment after the close brace */ + insert_comment_after(br_close, style, str.length(), str.c_str()); + } + } + + /* checks both the #else and #endif for a given level, only then look further in the main loop */ + if (br_close->type == CT_PP_ENDIF) + { + break; + } + } + } + } +} diff --git a/src/detect.cpp b/src/detect.cpp new file mode 100644 index 0000000000..7a6a523c70 --- /dev/null +++ b/src/detect.cpp @@ -0,0 +1,486 @@ +/** + * @file detect.cpp + * Scans the parsed file and tries to determine options. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "ChunkStack.h" +#include "align_stack.h" +#include "prototypes.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +class sp_votes +{ +protected: + int m_add; + int m_remove; + int m_force; + argval_t *m_av; + +public: + sp_votes(argval_t& av) + { + m_add = 0; + m_remove = 0; + m_force = 0; + m_av = &av; + } + + + ~sp_votes(); + + void vote(chunk_t *first, chunk_t *second); +}; + +void sp_votes::vote(chunk_t *first, chunk_t *second) +{ + if ((first == NULL) || chunk_is_newline(first) || + (second == NULL) || chunk_is_newline(second)) + { + return; + } + + int col_dif = second->column - (first->column + first->len); + if (col_dif == 0) + { + m_remove++; + } + else if (col_dif == 1) + { + m_force++; + } + else + { + m_add++; + } +} + + +/** + * Figure out the result of the vote and maybe update *m_av + */ +sp_votes::~sp_votes() +{ + /* no change if no items were added */ + if ((m_remove == 0) && (m_add == 0) && (m_force == 0)) + { + return; + } + + if (m_remove == 0) + { + *m_av = (m_force > m_add) ? AV_FORCE : AV_ADD; + } + else if ((m_force == 0) && (m_add == 0)) + { + *m_av = AV_REMOVE; + } + else + { + /* nothing conclusive. do not alter. */ + } +} + + +#define SP_VOTE_VAR(x) sp_votes vote_ ## x(cpd.settings[UO_ ## x].a) + +/** + * Detect spacing options + */ +static void detect_space_options() +{ + SP_VOTE_VAR(sp_arith); + SP_VOTE_VAR(sp_before_assign); + SP_VOTE_VAR(sp_after_assign); + SP_VOTE_VAR(sp_enum_before_assign); + SP_VOTE_VAR(sp_enum_after_assign); + SP_VOTE_VAR(sp_bool); + SP_VOTE_VAR(sp_compare); + SP_VOTE_VAR(sp_inside_paren); + SP_VOTE_VAR(sp_paren_paren); + SP_VOTE_VAR(sp_paren_brace); + SP_VOTE_VAR(sp_before_ptr_star); + SP_VOTE_VAR(sp_before_unnamed_ptr_star); + SP_VOTE_VAR(sp_between_ptr_star); + SP_VOTE_VAR(sp_after_ptr_star); + SP_VOTE_VAR(sp_after_byref); + SP_VOTE_VAR(sp_before_byref); + SP_VOTE_VAR(sp_before_unnamed_byref); + SP_VOTE_VAR(sp_after_type); + SP_VOTE_VAR(sp_template_angle); + SP_VOTE_VAR(sp_before_angle); + SP_VOTE_VAR(sp_inside_angle); + SP_VOTE_VAR(sp_after_angle); + SP_VOTE_VAR(sp_angle_paren); + SP_VOTE_VAR(sp_angle_word); + SP_VOTE_VAR(sp_before_square); + SP_VOTE_VAR(sp_before_squares); + SP_VOTE_VAR(sp_inside_square); + SP_VOTE_VAR(sp_before_sparen); + SP_VOTE_VAR(sp_inside_sparen); + SP_VOTE_VAR(sp_after_sparen); + SP_VOTE_VAR(sp_sparen_brace); + SP_VOTE_VAR(sp_special_semi); + SP_VOTE_VAR(sp_before_semi); + SP_VOTE_VAR(sp_before_semi_for); + SP_VOTE_VAR(sp_before_semi_for_empty); + SP_VOTE_VAR(sp_after_semi_for_empty); + SP_VOTE_VAR(sp_after_comma); + SP_VOTE_VAR(sp_before_comma); + SP_VOTE_VAR(sp_after_class_colon); + SP_VOTE_VAR(sp_before_class_colon); + SP_VOTE_VAR(sp_inside_braces); + SP_VOTE_VAR(sp_inside_braces_empty); + SP_VOTE_VAR(sp_else_brace); + SP_VOTE_VAR(sp_brace_else); + SP_VOTE_VAR(sp_catch_brace); + SP_VOTE_VAR(sp_brace_catch); + SP_VOTE_VAR(sp_finally_brace); + SP_VOTE_VAR(sp_brace_finally); + SP_VOTE_VAR(sp_try_brace); + SP_VOTE_VAR(sp_getset_brace); + + chunk_t *prev = chunk_get_head(); + chunk_t *pc = chunk_get_next(prev); + chunk_t *next; + + while (pc != NULL) + { + next = chunk_get_next(pc); + if (next == NULL) + { + break; + } + + if (pc->type == CT_ARITH) + { + vote_sp_arith.vote(pc, next); + vote_sp_arith.vote(prev, pc); + } + if (pc->type == CT_ASSIGN) + { + if ((pc->flags & PCF_IN_ENUM) == 0) + { + vote_sp_before_assign.vote(prev, pc); + vote_sp_after_assign.vote(pc, next); + } + else + { + vote_sp_enum_before_assign.vote(prev, pc); + vote_sp_enum_after_assign.vote(pc, next); + } + } + if (pc->type == CT_SQUARE_OPEN) + { + vote_sp_before_square.vote(prev, pc); + vote_sp_inside_square.vote(pc, next); + } + if (pc->type == CT_SQUARE_CLOSE) + { + vote_sp_inside_square.vote(prev, pc); + } + if (pc->type == CT_TSQUARE) + { + vote_sp_before_squares.vote(prev, pc); + } + if (pc->type == CT_BOOL) + { + vote_sp_bool.vote(prev, pc); + vote_sp_bool.vote(pc, next); + } + if (pc->type == CT_COMPARE) + { + vote_sp_compare.vote(prev, pc); + vote_sp_compare.vote(pc, next); + } + if (pc->type == CT_PAREN_CLOSE) + { + vote_sp_inside_paren.vote(prev, pc); + } + if (pc->type == CT_PAREN_OPEN) + { + vote_sp_inside_paren.vote(pc, next); + } + if ((chunk_is_paren_open(pc) && chunk_is_paren_open(next)) || + (chunk_is_paren_close(pc) && chunk_is_paren_close(next))) + { + vote_sp_paren_paren.vote(pc, next); + } + if (chunk_is_paren_close(pc) && (next->type == CT_BRACE_OPEN)) + { + vote_sp_paren_brace.vote(pc, next); + } + if (pc->type == CT_PTR_TYPE) + { + if (prev->type == CT_PTR_TYPE) + { + vote_sp_between_ptr_star.vote(prev, pc); + } + else if (next->type != CT_WORD) + { + vote_sp_before_unnamed_ptr_star.vote(prev, pc); + } + else + { + vote_sp_before_ptr_star.vote(prev, pc); + } + if (CharTable::IsKw1(next->str[0])) + { + vote_sp_after_ptr_star.vote(pc, next); + } + } + if (pc->type == CT_BYREF) + { + if (next->type != CT_WORD) + { + vote_sp_before_unnamed_byref.vote(prev, pc); + } + else + { + vote_sp_before_byref.vote(prev, pc); + } + vote_sp_after_byref.vote(pc, next); + } + if ((pc->type != CT_PTR_TYPE) && + ((prev->type == CT_QUALIFIER) || (prev->type == CT_TYPE))) + { + vote_sp_after_type.vote(prev, pc); + } + if (pc->type == CT_ANGLE_OPEN) + { + vote_sp_inside_angle.vote(pc, next); + if (prev->type == CT_TEMPLATE) + { + vote_sp_template_angle.vote(prev, pc); + } + else + { + vote_sp_before_angle.vote(prev, pc); + } + } + if (pc->type == CT_ANGLE_CLOSE) + { + vote_sp_inside_angle.vote(prev, pc); + if (chunk_is_paren_open(next)) + { + vote_sp_angle_paren.vote(prev, pc); + } + else if ((next->type == CT_WORD) || CharTable::IsKw1(next->str[0])) + { + vote_sp_angle_word.vote(prev, pc); + } + else + { + vote_sp_after_angle.vote(pc, next); + } + } + + if (pc->type == CT_SPAREN_OPEN) + { + vote_sp_before_sparen.vote(prev, pc); + vote_sp_inside_sparen.vote(pc, next); + } + if (pc->type == CT_SPAREN_CLOSE) + { + vote_sp_inside_sparen.vote(prev, pc); + if (next->type == CT_BRACE_OPEN) + { + vote_sp_sparen_brace.vote(pc, next); + } + else + { + vote_sp_after_sparen.vote(pc, next); + } + } + if (pc->type == CT_SEMICOLON) + { + if (pc->parent_type == CT_FOR) + { + if (prev->type == CT_SPAREN_OPEN) + { + /* emtpy, ie for (;;) */ + vote_sp_before_semi_for_empty.vote(prev, pc); + } + else if (next->type == CT_SPAREN_CLOSE) + { + /* emtpy, ie for (;;) */ + vote_sp_after_semi_for_empty.vote(pc, next); + } + else if (prev->type != CT_SEMICOLON) + { + vote_sp_before_semi_for.vote(prev, pc); + } + } + else if (prev->type == CT_VBRACE_OPEN) + { + vote_sp_special_semi.vote(chunk_get_prev(prev), pc); + } + else + { + vote_sp_before_semi.vote(prev, pc); + } + } + if (pc->type == CT_COMMA) + { + vote_sp_before_comma.vote(prev, pc); + vote_sp_after_comma.vote(pc, next); + } + if (pc->type == CT_CLASS_COLON) + { + vote_sp_before_class_colon.vote(prev, pc); + vote_sp_after_class_colon.vote(pc, next); + } + if (pc->type == CT_BRACE_OPEN) + { + if (prev->type == CT_ELSE) + { + vote_sp_else_brace.vote(prev, pc); + } + else if (prev->type == CT_CATCH) + { + vote_sp_catch_brace.vote(prev, pc); + } + else if (prev->type == CT_FINALLY) + { + vote_sp_catch_brace.vote(prev, pc); + } + else if (prev->type == CT_TRY) + { + vote_sp_catch_brace.vote(prev, pc); + } + else if (prev->type == CT_GETSET) + { + vote_sp_catch_brace.vote(prev, pc); + } + if (next->type == CT_BRACE_CLOSE) + { + vote_sp_inside_braces_empty.vote(pc, next); + } + else + { + vote_sp_inside_braces.vote(pc, next); + } + } + if (pc->type == CT_BRACE_CLOSE) + { + vote_sp_inside_braces.vote(prev, pc); + if (next->type == CT_ELSE) + { + vote_sp_brace_else.vote(pc, next); + } + else if (next->type == CT_CATCH) + { + vote_sp_brace_catch.vote(pc, next); + } + else if (next->type == CT_FINALLY) + { + vote_sp_brace_finally.vote(pc, next); + } + } + + prev = pc; + pc = next; + } +} + + +// unc_add_option("sp_after_operator", UO_sp_after_operator, AT_IARF, +// "Add or remove space between 'operator' and operator sign"); +// unc_add_option("sp_after_operator_sym", UO_sp_after_operator_sym, AT_IARF, +// "Add or remove space between the operator symbol and the open paren, as in 'operator ++('"); +// unc_add_option("sp_after_cast", UO_sp_after_cast, AT_IARF, +// "Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a'"); +// unc_add_option("sp_inside_paren_cast", UO_sp_inside_paren_cast, AT_IARF, +// "Add or remove spaces inside cast parens"); +// unc_add_option("sp_sizeof_paren", UO_sp_sizeof_paren, AT_IARF, +// "Add or remove space between 'sizeof' and '('"); +// unc_add_option("sp_after_tag", UO_sp_after_tag, AT_IARF, +// "Add or remove space after the tag keyword (Pawn)"); +// unc_add_option("sp_inside_braces_enum", UO_sp_inside_braces_enum, AT_IARF, +// "Add or remove space inside enum '{' and '}'"); +// unc_add_option("sp_inside_braces_struct", UO_sp_inside_braces_struct, AT_IARF, +// "Add or remove space inside struct/union '{' and '}'"); +// unc_add_option("sp_type_func", UO_sp_type_func, AT_IARF, +// "Add or remove space between return type and function name\n" +// "A minimum of 1 is forced except for pointer return types."); +// unc_add_option("sp_func_proto_paren", UO_sp_func_proto_paren, AT_IARF, +// "Add or remove space between function name and '(' on function declaration"); +// unc_add_option("sp_func_def_paren", UO_sp_func_def_paren, AT_IARF, +// "Add or remove space between function name and '(' on function definition"); +// unc_add_option("sp_inside_fparens", UO_sp_inside_fparens, AT_IARF, +// "Add or remove space inside empty function '()'"); +// unc_add_option("sp_inside_fparen", UO_sp_inside_fparen, AT_IARF, +// "Add or remove space inside function '(' and ')'"); +// unc_add_option("sp_square_fparen", UO_sp_square_fparen, AT_IARF, +// "Add or remove space between ']' and '(' when part of a function call."); +// unc_add_option("sp_fparen_brace", UO_sp_fparen_brace, AT_IARF, +// "Add or remove space between ')' and '{' of function"); +// unc_add_option("sp_func_call_paren", UO_sp_func_call_paren, AT_IARF, +// "Add or remove space between function name and '(' on function calls"); +// unc_add_option("sp_func_class_paren", UO_sp_func_class_paren, AT_IARF, +// "Add or remove space between a constructor/destructor and the open paren"); +// unc_add_option("sp_return_paren", UO_sp_return_paren, AT_IARF, +// "Add or remove space between 'return' and '('"); +// unc_add_option("sp_attribute_paren", UO_sp_attribute_paren, AT_IARF, +// "Add or remove space between '__attribute__' and '('"); +// unc_add_option("sp_defined_paren", UO_sp_defined_paren, AT_IARF, +// "Add or remove space between 'defined' and '(' in '#if defined (FOO)'"); +// unc_add_option("sp_macro", UO_sp_macro, AT_IARF, +// "Add or remove space between macro and value"); +// unc_add_option("sp_macro_func", UO_sp_macro_func, AT_IARF, +// "Add or remove space between macro function ')' and value"); +// unc_add_option("sp_before_dc", UO_sp_before_dc, AT_IARF, +// "Add or remove space before the '::' operator"); +// unc_add_option("sp_after_dc", UO_sp_after_dc, AT_IARF, +// "Add or remove space after the '::' operator"); +// unc_add_option("sp_d_array_colon", UO_sp_d_array_colon, AT_IARF, +// "Add or remove around the D named array initializer ':' operator"); +// unc_add_option("sp_not", UO_sp_not, AT_IARF, +// "Add or remove space after the '!' (not) operator."); +// unc_add_option("sp_inv", UO_sp_inv, AT_IARF, "Add or remove space after the '~' (invert) operator."); +// unc_add_option("sp_addr", UO_sp_addr, AT_IARF, +// "Add or remove space after the '&' (address-of) operator.\n" +// "This does not affect the spacing after a '&' that is part of a type."); +// unc_add_option("sp_member", UO_sp_member, AT_IARF, +// "Add or remove space around the '.' or '->' operators\n"); +// unc_add_option("sp_deref", UO_sp_deref, AT_IARF, +// "Add or remove space after the '*' (dereference) operator.\n" +// "This does not affect the spacing after a '*' that is part of a type."); +// unc_add_option("sp_sign", UO_sp_sign, AT_IARF, +// "Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'"); +// unc_add_option("sp_incdec", UO_sp_incdec, AT_IARF, +// "Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'"); +// +// unc_add_option("sp_before_nl_cont", UO_sp_before_nl_cont, AT_IARF, +// "Add or remove space before a backslash-newline at the end of a line"); +// +// unc_add_option("sp_after_oc_scope", UO_sp_after_oc_scope, AT_IARF, +// "Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;'"); +// unc_add_option("sp_before_oc_colon", UO_sp_before_oc_colon, AT_IARF, +// "Add or remove space after the colon in message specs\n" +// "'-(int) f: (int) x;' vs '+(int) f : (int) x;'"); +// unc_add_option("sp_after_oc_type", UO_sp_after_oc_type, AT_IARF, +// "Add or remove space after the (type) in message specs\n" +// "'-(int) f: (int) x;' vs '+(int)f : (int)x;'"); +// +// unc_add_option("sp_cond_colon", UO_sp_cond_colon, AT_IARF, +// "Add or remove space around the ':' in 'b ? t : f'"); +// unc_add_option("sp_cond_question", UO_sp_cond_question, AT_IARF, +// "Add or remove space around the '?' in 'b ? t : f'"); + + +/** + * Call all the detect_xxxx() functions + */ +void detect_options(const char *data, int data_len) +{ + detect_space_options(); +} diff --git a/src/indent.cpp b/src/indent.cpp new file mode 100644 index 0000000000..62a86e8620 --- /dev/null +++ b/src/indent.cpp @@ -0,0 +1,1727 @@ +/** + * @file indent.cpp + * Does all the indenting stuff. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +/** + * General indenting approach: + * Indenting levels are put into a stack. + * + * The stack entries contain: + * - opening type + * - brace column + * - continuation column + * + * Items that start a new stack item: + * - preprocessor (new parse frame) + * - Brace Open (Virtual brace also) + * - Paren, Square, Angle open + * - Assignments + * - C++ '<<' operator (ie, cout << "blah") + * - case + * - class colon + * - return + * - types + * - any other continued statement + * + * Note that the column of items marked 'PCF_WAS_ALIGNED' is not changed. + * + * For an open brace: + * - indent increases by indent_columns + * - if part of if/else/do/while/switch/etc, an extra indent may be applied + * - if in a paren, then cont-col is set to column + 1, ie "({ some code })" + * + * Open paren/square/angle: + * cont-col is set to the column of the item after the open paren, unless + * followed by a newline, then it is set to (brace-col + indent_columns). + * Examples: + * a_really_long_funcion_name( + * param1, param2); + * a_really_long_funcion_name(param1, + * param2); + * + * Assignments: + * Assignments are continued aligned with the first item after the assignment, + * unless the assign is followed by a newline. + * Examples: + * some.variable = asdf + asdf + + * asdf; + * some.variable = + * asdf + asdf + asdf; + * + * C++ << operator: + * Handled the same as assignment. + * Examples: + * cout << "this is test number: " + * << test_number; + * + * case: + * Started with case or default. + * Terminated with close brace at level or another case or default. + * Special indenting according to various rules. + * - indent of case label + * - indent of case body + * - how to handle optional braces + * Examples: + * { + * case x: { + * a++; + * break; + * } + * case y: + * b--; + * break; + * default: + * c++; + * break; + * } + * + * Class colon: + * Indent continuation by indent_columns: + * class my_class : + * baseclass1, + * baseclass2 + * { + * + * Return: same as assignemts + * If the return statement is not fully paren'd, then the indent continues at + * the column of the item after the return. If it is paren'd, then the paren + * rules apply. + * return somevalue + + * othervalue; + * + * Type: pretty much the same as assignments + * Examples: + * int foo, + * bar, + * baz; + * + * Any other continued item: + * There shouldn't be anything not covered by the above cases, but any other + * continued item is indented by indent_columns: + * Example: + * somereallycrazylongname.with[lotsoflongstuff]. + * thatreallyannoysme.whenIhavetomaintain[thecode] = 3; + */ + +static void indent_comment(chunk_t *pc, int col); + + +void indent_to_column(chunk_t *pc, int column) +{ + if (column < pc->column) + { + column = pc->column; + } + reindent_line(pc, column); +} + +enum align_mode +{ + ALMODE_SHIFT, /* shift relative to the current column */ + ALMODE_KEEP_ABS, /* try to keep the original absolute column */ + ALMODE_KEEP_REL, /* try to keep the original gap */ +}; + +/* Same as indent_to_column, except we can move both ways */ +void align_to_column(chunk_t *pc, int column) +{ + if (column == pc->column) + { + return; + } + + LOG_FMT(LINDLINE, "%s: %d] col %d on %.*s [%s] => %d\n", + __func__, pc->orig_line, pc->column, pc->len, pc->str, + get_token_name(pc->type), column); + + int col_delta = column - pc->column; + int min_col = column; + int min_delta; + + pc->column = column; + do + { + chunk_t *next = chunk_get_next(pc); + chunk_t *prev; + align_mode almod = ALMODE_SHIFT; + + if (next == NULL) + { + break; + } + min_delta = space_col_align(pc, next); + min_col += min_delta; + prev = pc; + pc = next; + + if (chunk_is_comment(pc) && (pc->parent_type != CT_COMMENT_EMBED)) + { + almod = (chunk_is_single_line_comment(pc) && + cpd.settings[UO_indent_relative_single_line_comments].b) ? + ALMODE_KEEP_REL : ALMODE_KEEP_ABS; + } + + if (almod == ALMODE_KEEP_ABS) + { + /* Keep same absolute column */ + pc->column = pc->orig_col; + if (pc->column < min_col) + { + pc->column = min_col; + } + } + else if (almod == ALMODE_KEEP_REL) + { + /* Keep same relative column */ + int orig_delta = pc->orig_col - prev->orig_col; + if (orig_delta < min_delta) + { + orig_delta = min_delta; + } + pc->column = prev->column + orig_delta; + } + else /* ALMODE_SHIFT */ + { + /* Shift by the same amount */ + pc->column += col_delta; + if (pc->column < min_col) + { + pc->column = min_col; + } + } + LOG_FMT(LINDLINED, " %s set column of %s on line %d to col %d (orig %d)\n", + (almod == ALMODE_KEEP_ABS) ? "abs" : + (almod == ALMODE_KEEP_REL) ? "rel" : "sft", + get_token_name(pc->type), pc->orig_line, pc->column, pc->orig_col); + } while ((pc != NULL) && (pc->nl_count == 0)); +} + + +/** + * Changes the initial indent for a line to the given column + * + * @param pc The chunk at the start of the line + * @param column The desired column + */ +void reindent_line2(chunk_t *pc, int column, const char *fcn_name, int lineno) +{ + LOG_FMT(LINDLINE, "%s: %d] col %d on %.*s [%s] => %d orig_line, pc->column, pc->len, pc->str, + get_token_name(pc->type), column, fcn_name, lineno); + + if (column == pc->column) + { + return; + } + + int col_delta = column - pc->column; + int min_col = column; + + pc->column = column; + do + { + chunk_t *next = chunk_get_next(pc); + + if (next == NULL) + { + break; + } + min_col += space_col_align(pc, next); + pc = next; + + bool is_comment = chunk_is_comment(pc); + bool keep = is_comment && chunk_is_single_line_comment(pc) && + cpd.settings[UO_indent_relative_single_line_comments].b; + + if (is_comment && (pc->parent_type != CT_COMMENT_EMBED) && !keep) + { + pc->column = pc->orig_col; + if (pc->column < min_col) + { + pc->column = min_col; // + 1; + } + LOG_FMT(LINDLINE, "%s: set comment on line %d to col %d (orig %d)\n", + __func__, pc->orig_line, pc->column, pc->orig_col); + } + else + { + pc->column += col_delta; + if (pc->column < min_col) + { + pc->column = min_col; + } + LOG_FMT(LINDLINED, " set column of '%.*s' to %d (orig %d)\n", + pc->len, pc->str, pc->column, pc->orig_col); + } + } while ((pc != NULL) && (pc->nl_count == 0)); +} + + +/** + * Starts a new entry + * + * @param frm The parse frame + * @param pc The chunk causing the push + */ +static void indent_pse_push(struct parse_frame& frm, chunk_t *pc) +{ + static int ref = 0; + + /* check the stack depth */ + if (frm.pse_tos < ((int)ARRAY_SIZE(frm.pse) - 1)) + { + /* Bump up the index and initialize it */ + frm.pse_tos++; + memset(&frm.pse[frm.pse_tos], 0, sizeof(frm.pse[frm.pse_tos])); + + LOG_FMT(LINDPSE, "%4d] (pp=%d) OPEN [%d,%s] level=%d\n", + pc->orig_line, cpd.pp_level, frm.pse_tos, get_token_name(pc->type), pc->level); + + frm.pse[frm.pse_tos].pc = pc; + frm.pse[frm.pse_tos].type = pc->type; + frm.pse[frm.pse_tos].level = pc->level; + frm.pse[frm.pse_tos].open_line = pc->orig_line; + frm.pse[frm.pse_tos].ref = ++ref; + frm.pse[frm.pse_tos].in_preproc = (pc->flags & PCF_IN_PREPROC) != 0; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos - 1].indent_tab; + frm.pse[frm.pse_tos].non_vardef = false; + } +} + + +/** + * Removes the top entry + * + * @param frm The parse frame + * @param pc The chunk causing the push + */ +static void indent_pse_pop(struct parse_frame& frm, chunk_t *pc) +{ + /* Bump up the index and initialize it */ + if (frm.pse_tos > 0) + { + if (pc != NULL) + { + LOG_FMT(LINDPSE, "%4d] (pp=%d) CLOSE [%d,%s] on %s, started on line %d, level=%d/%d\n", + pc->orig_line, cpd.pp_level, frm.pse_tos, + get_token_name(frm.pse[frm.pse_tos].type), + get_token_name(pc->type), + frm.pse[frm.pse_tos].open_line, + frm.pse[frm.pse_tos].level, + pc->level); + } + else + { + LOG_FMT(LINDPSE, " EOF] CLOSE [%d,%s], started on line %d\n", + frm.pse_tos, get_token_name(frm.pse[frm.pse_tos].type), + frm.pse[frm.pse_tos].open_line); + } + + /* Don't clear the stack entry because some code 'cheats' and uses the + * just-popped indent values + */ + frm.pse_tos--; + } +} + + +static int token_indent(c_token_t type) +{ + switch (type) + { + case CT_IF: + case CT_DO: + return(3); + + case CT_FOR: + case CT_ELSE: // wacky, but that's what is wanted + return(4); + + case CT_WHILE: + return(6); + + case CT_SWITCH: + return(7); + + case CT_ELSEIF: + return(8); + + default: + return(0); + } +} + + +#define indent_column_set(X) \ + do { \ + indent_column = (X); \ + LOG_FMT(LINDENT2, "[line %d] indent_column = %d\n", \ + __LINE__, indent_column); \ + } while (0) + +/** + * Change the top-level indentation only by changing the column member in + * the chunk structures. + * The level indicator must already be set. + */ +void indent_text(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev = NULL; + bool did_newline = true; + int idx; + int vardefcol = 0; + int indent_size = cpd.settings[UO_indent_columns].n; + int tmp; + struct parse_frame frm; + bool in_preproc = false, was_preproc = false; + int indent_column; + int parent_token_indent = 0; + int xml_indent = 0; + bool token_used; + int sql_col = 0; + int sql_orig_col = 0; + + memset(&frm, 0, sizeof(frm)); + + /* dummy top-level entry */ + frm.pse[0].indent = 1; + frm.pse[0].indent_tmp = 1; + frm.pse[0].indent_tab = 1; + frm.pse[0].type = CT_EOF; + + pc = chunk_get_head(); + while (pc != NULL) + { + /* Handle proprocessor transitions */ + was_preproc = in_preproc; + in_preproc = (pc->flags & PCF_IN_PREPROC) != 0; + + if (cpd.settings[UO_indent_brace_parent].b) + { + parent_token_indent = token_indent(pc->parent_type); + } + + /* Clean up after a #define, etc */ + if (!in_preproc) + { + while ((frm.pse_tos > 0) && frm.pse[frm.pse_tos].in_preproc) + { + c_token_t type = frm.pse[frm.pse_tos].type; + indent_pse_pop(frm, pc); + + /* If we just removed an #endregion, then check to see if a + * PP_REGION_INDENT entry is right below it + */ + if ((type == CT_PP_ENDREGION) && + (frm.pse[frm.pse_tos].type == CT_PP_REGION_INDENT)) + { + indent_pse_pop(frm, pc); + } + } + } + else if (pc->type == CT_PREPROC) + { + /* Close out PP_IF_INDENT before playing with the parse frames */ + if ((frm.pse[frm.pse_tos].type == CT_PP_IF_INDENT) && + ((pc->parent_type == CT_PP_ENDIF) || + (pc->parent_type == CT_PP_ELSE))) + { + indent_pse_pop(frm, pc); + } + + pf_check(&frm, pc); + + /* Indent the body of a #region here */ + if (cpd.settings[UO_pp_region_indent_code].b && + (pc->parent_type == CT_PP_REGION)) + { + next = chunk_get_next(pc); + /* Hack to get the logs to look right */ + next->type = CT_PP_REGION_INDENT; + indent_pse_push(frm, next); + next->type = CT_PP_REGION; + + /* Indent one level */ + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos - 1].indent_tab + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].in_preproc = false; + } + + /* Indent the body of a #if here */ + if (cpd.settings[UO_pp_if_indent_code].b && + ((pc->parent_type == CT_PP_IF) || + (pc->parent_type == CT_PP_ELSE))) + { + next = chunk_get_next(pc); + /* Hack to get the logs to look right */ + next->type = CT_PP_IF_INDENT; + indent_pse_push(frm, next); + next->type = CT_PP_IF; + + /* Indent one level */ + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos - 1].indent_tab + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].in_preproc = false; + } + + /* Transition into a preproc by creating a dummy indent */ + frm.level++; + indent_pse_push(frm, chunk_get_next(pc)); + + if (pc->parent_type == CT_PP_DEFINE) + { + frm.pse[frm.pse_tos].indent_tmp = cpd.settings[UO_pp_define_at_level].b ? + frm.pse[frm.pse_tos - 1].indent_tmp : 1; + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos].indent_tmp + indent_size; + } + else + { + if ((frm.pse[frm.pse_tos - 1].type == CT_PP_REGION_INDENT) || + ((frm.pse[frm.pse_tos - 1].type == CT_PP_IF_INDENT) && + (frm.pse[frm.pse_tos].type != CT_PP_ENDIF))) + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 2].indent; + } + else + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent; + } + if ((pc->parent_type == CT_PP_REGION) || + (pc->parent_type == CT_PP_ENDREGION)) + { + int val = cpd.settings[UO_pp_indent_region].n; + if (val > 0) + { + frm.pse[frm.pse_tos].indent = val; + } + else + { + frm.pse[frm.pse_tos].indent += val; + } + } + else if ((pc->parent_type == CT_PP_IF) || + (pc->parent_type == CT_PP_ELSE) || + (pc->parent_type == CT_PP_ENDIF)) + { + int val = cpd.settings[UO_pp_indent_if].n; + if (val > 0) + { + frm.pse[frm.pse_tos].indent = val; + } + else + { + frm.pse[frm.pse_tos].indent += val; + } + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + } + } + + /* Check for close XML tags " 0) + { + if (pc->type == CT_STRING) + { + if ((pc->len > 4) && + (xml_indent > 0) && + (pc->str[1] == '<') && + (pc->str[2] == '/')) + { + xml_indent -= cpd.settings[UO_indent_xml_string].n; + } + } + else + { + if (!chunk_is_comment(pc) && !chunk_is_newline(pc)) + { + xml_indent = 0; + } + } + } + + /** + * Handle non-brace closures + */ + + token_used = false; + int old_pse_tos; + do + { + old_pse_tos = frm.pse_tos; + + /* End anything that drops a level + * REVISIT: not sure about the preproc check + */ + if (!chunk_is_newline(pc) && + !chunk_is_comment(pc) && + ((pc->flags & PCF_IN_PREPROC) == 0) && + (frm.pse[frm.pse_tos].level > pc->level)) + { + indent_pse_pop(frm, pc); + } + + if (frm.pse[frm.pse_tos].level >= pc->level) + { + /* process virtual braces closes (no text output) */ + if ((pc->type == CT_VBRACE_CLOSE) && + (frm.pse[frm.pse_tos].type == CT_VBRACE_OPEN)) + { + indent_pse_pop(frm, pc); + frm.level--; + pc = chunk_get_next(pc); + } + + /* End any assign operations with a semicolon on the same level */ + if (((frm.pse[frm.pse_tos].type == CT_ASSIGN_NL) || + (frm.pse[frm.pse_tos].type == CT_ASSIGN)) && + (chunk_is_semicolon(pc) || + (pc->type == CT_COMMA) || + (pc->type == CT_BRACE_OPEN) || + (pc->type == CT_SPAREN_CLOSE) || + ((pc->type == CT_SQUARE_OPEN) && (pc->parent_type == CT_ASSIGN)))) + { + indent_pse_pop(frm, pc); + } + + /* End any assign operations with a semicolon on the same level */ + if (chunk_is_semicolon(pc) && + ((frm.pse[frm.pse_tos].type == CT_IMPORT) || + (frm.pse[frm.pse_tos].type == CT_THROW) || + (frm.pse[frm.pse_tos].type == CT_USING))) + { + indent_pse_pop(frm, pc); + } + + /* End any custom macro-based open/closes */ + if (!token_used && + (frm.pse[frm.pse_tos].type == CT_MACRO_OPEN) && + (pc->type == CT_MACRO_CLOSE)) + { + token_used = true; + indent_pse_pop(frm, pc); + } + + /* End any CPP/ObjC class colon stuff */ + if ((frm.pse[frm.pse_tos].type == CT_CLASS_COLON) && + ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_OC_END) || + (pc->type == CT_OC_SCOPE) || + chunk_is_semicolon(pc))) + { + indent_pse_pop(frm, pc); + } + + /* a case is ended with another case or a close brace */ + if ((frm.pse[frm.pse_tos].type == CT_CASE) && + ((pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_CASE))) + { + indent_pse_pop(frm, pc); + } + + /* a class scope is ended with another class scope or a close brace */ + if (cpd.settings[UO_indent_access_spec_body].b && + (frm.pse[frm.pse_tos].type == CT_PRIVATE) && + ((pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_PRIVATE))) + { + indent_pse_pop(frm, pc); + } + + /* a return is ended with a semicolon */ + if ((frm.pse[frm.pse_tos].type == CT_RETURN) && + chunk_is_semicolon(pc)) + { + indent_pse_pop(frm, pc); + } + + /* an SQL EXEC is ended with a semicolon */ + if ((frm.pse[frm.pse_tos].type == CT_SQL_EXEC) && + chunk_is_semicolon(pc)) + { + indent_pse_pop(frm, pc); + } + + /* Close out parens and squares */ + if ((frm.pse[frm.pse_tos].type == (pc->type - 1)) && + ((pc->type == CT_PAREN_CLOSE) || + (pc->type == CT_SPAREN_CLOSE) || + (pc->type == CT_FPAREN_CLOSE) || + (pc->type == CT_SQUARE_CLOSE) || + (pc->type == CT_ANGLE_CLOSE))) + { + indent_pse_pop(frm, pc); + frm.paren_count--; + } + } + } while (old_pse_tos > frm.pse_tos); + + /* Grab a copy of the current indent */ + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + + if (!chunk_is_newline(pc) && !chunk_is_comment(pc)) + { + LOG_FMT(LINDPC, " -=[ %.*s ]=- top=%d %s %d/%d\n", + pc->len, pc->str, + frm.pse_tos, + get_token_name(frm.pse[frm.pse_tos].type), + frm.pse[frm.pse_tos].indent_tmp, + frm.pse[frm.pse_tos].indent); + } + + /** + * Handle stuff that can affect the current indent: + * - brace close + * - vbrace open + * - brace open + * - case (immediate) + * - labels (immediate) + * - class colons (immediate) + * + * And some stuff that can't + * - open paren + * - open square + * - assignment + * - return + */ + + bool brace_indent = false; + if ((pc->type == CT_BRACE_CLOSE) || (pc->type == CT_BRACE_OPEN)) + { + brace_indent = (cpd.settings[UO_indent_braces].b && + (!cpd.settings[UO_indent_braces_no_func].b || + (pc->parent_type != CT_FUNC_DEF))); + } + + if (pc->type == CT_BRACE_CLOSE) + { + if (frm.pse[frm.pse_tos].type == CT_BRACE_OPEN) + { + /* Indent the brace to match the open brace */ + indent_column_set(frm.pse[frm.pse_tos].brace_indent); + + indent_pse_pop(frm, pc); + frm.level--; + } + } + else if (pc->type == CT_VBRACE_OPEN) + { + frm.level++; + indent_pse_push(frm, pc); + + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + + /* Always indent on virtual braces */ + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + } + else if (pc->type == CT_BRACE_OPEN) + { + frm.level++; + indent_pse_push(frm, pc); + + if (frm.paren_count != 0) + { + /* We are inside ({ ... }) -- indent one tab from the paren */ + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + } + else + { + /* Use the prev indent level + indent_size. */ + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + + /* If this brace is part of a statement, bump it out by indent_brace */ + if ((pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE) || + (pc->parent_type == CT_ELSEIF) || + (pc->parent_type == CT_TRY) || + (pc->parent_type == CT_CATCH) || + (pc->parent_type == CT_DO) || + (pc->parent_type == CT_WHILE) || + (pc->parent_type == CT_SWITCH) || + (pc->parent_type == CT_FOR)) + { + if (parent_token_indent != 0) + { + frm.pse[frm.pse_tos].indent += parent_token_indent - indent_size; + } + else + { + frm.pse[frm.pse_tos].indent += cpd.settings[UO_indent_brace].n; + indent_column_set(indent_column + cpd.settings[UO_indent_brace].n); + } + } + else if (pc->parent_type == CT_CASE) + { + /* An open brace with the parent of case does not indent by default + * UO_indent_case_brace can be used to indent the brace. + * So we need to take the CASE indent, subtract off the + * indent_size that was added above and then add indent_case_brace. + */ + indent_column_set(frm.pse[frm.pse_tos - 1].indent - indent_size + + cpd.settings[UO_indent_case_brace].n); + + /* Stuff inside the brace still needs to be indented */ + frm.pse[frm.pse_tos].indent = indent_column + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + } + else if ((pc->parent_type == CT_CLASS) && !cpd.settings[UO_indent_class].b) + { + frm.pse[frm.pse_tos].indent -= indent_size; + } + else if (pc->parent_type == CT_NAMESPACE) + { + if ((pc->flags & PCF_LONG_BLOCK) || + !cpd.settings[UO_indent_namespace].b) + { + /* don't indent long blocks */ + frm.pse[frm.pse_tos].indent -= indent_size; + } + else /* indenting 'short' namespace */ + { + if (cpd.settings[UO_indent_namespace_level].n > 0) + { + frm.pse[frm.pse_tos].indent -= indent_size; + frm.pse[frm.pse_tos].indent += + cpd.settings[UO_indent_namespace_level].n; + } + } + } + else if ((pc->parent_type == CT_EXTERN) && !cpd.settings[UO_indent_extern].b) + { + frm.pse[frm.pse_tos].indent -= indent_size; + } + + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + } + + if ((pc->flags & PCF_DONT_INDENT) != 0) + { + frm.pse[frm.pse_tos].indent = pc->column; + indent_column_set(pc->column); + } + else + { + /** + * If there isn't a newline between the open brace and the next + * item, just indent to wherever the next token is. + * This covers this sort of stuff: + * { a++; + * b--; }; + */ + next = chunk_get_next_ncnl(pc); + if (!chunk_is_newline_between(pc, next)) + { + frm.pse[frm.pse_tos].indent = next->column; + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].open_line = pc->orig_line; + + /* Update the indent_column if needed */ + if (brace_indent || (parent_token_indent != 0)) + { + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + } + } + + /* Save the brace indent */ + frm.pse[frm.pse_tos].brace_indent = indent_column; + } + else if (pc->type == CT_SQL_END) + { + if (frm.pse[frm.pse_tos].type == CT_SQL_BEGIN) + { + indent_pse_pop(frm, pc); + frm.level--; + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + } + } + else if (pc->type == CT_SQL_BEGIN) + { + frm.level++; + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + } + else if (pc->type == CT_SQL_EXEC) + { + frm.level++; + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + } + else if (pc->type == CT_MACRO_OPEN) + { + frm.level++; + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + } + else if (pc->type == CT_MACRO_ELSE) + { + if (frm.pse[frm.pse_tos].type == CT_MACRO_OPEN) + { + indent_column_set(frm.pse[frm.pse_tos - 1].indent); + } + } + else if (pc->type == CT_CASE) + { + /* Start a case - indent UO_indent_switch_case from the switch level */ + tmp = frm.pse[frm.pse_tos].indent + cpd.settings[UO_indent_switch_case].n; + + indent_pse_push(frm, pc); + + frm.pse[frm.pse_tos].indent = tmp; + frm.pse[frm.pse_tos].indent_tmp = tmp - indent_size + cpd.settings[UO_indent_case_shift].n; + frm.pse[frm.pse_tos].indent_tab = tmp; + + /* Always set on case statements */ + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + + /* comments before 'case' need to be aligned with the 'case' */ + chunk_t *pct = pc; + while (((pct = chunk_get_prev_nnl(pct)) != NULL) && + chunk_is_comment(pct)) + { + chunk_t *t2 = chunk_get_prev(pct); + if (chunk_is_newline(t2)) + { + pct->column = frm.pse[frm.pse_tos].indent_tmp; + pct->column_indent = pct->column; + } + } + } + else if (pc->type == CT_BREAK) + { + prev = chunk_get_prev_ncnl(pc); + if ((prev != NULL) && + (prev->type == CT_BRACE_CLOSE) && + (prev->parent_type == CT_CASE)) + { + /* This only affects the 'break', so no need for a stack entry */ + indent_column_set(prev->column); + } + } + else if (pc->type == CT_LABEL) + { + /* Labels get sent to the left or backed up */ + if (cpd.settings[UO_indent_label].n > 0) + { + indent_column_set(cpd.settings[UO_indent_label].n); + } + else + { + indent_column_set(frm.pse[frm.pse_tos].indent + + cpd.settings[UO_indent_label].n); + } + } + else if (pc->type == CT_PRIVATE) + { + if (cpd.settings[UO_indent_access_spec_body].b) + { + tmp = frm.pse[frm.pse_tos].indent + indent_size; + + indent_pse_push(frm, pc); + + frm.pse[frm.pse_tos].indent = tmp; + frm.pse[frm.pse_tos].indent_tmp = tmp - indent_size; + frm.pse[frm.pse_tos].indent_tab = tmp; + + /* If we are indenting the body, then we must leave the access spec + * indented at brace level + */ + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + } + else + { + /* Access spec labels get sent to the left or backed up */ + if (cpd.settings[UO_indent_access_spec].n > 0) + { + indent_column_set(cpd.settings[UO_indent_access_spec].n); + } + else + { + indent_column_set(frm.pse[frm.pse_tos].indent + + cpd.settings[UO_indent_access_spec].n); + } + } + } + else if (pc->type == CT_CLASS_COLON) + { + /* just indent one level */ + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + + if (cpd.settings[UO_indent_class_colon].b) + { + prev = chunk_get_prev(pc); + if (chunk_is_newline(prev)) + { + frm.pse[frm.pse_tos].indent += 2; + /* don't change indent of current line */ + } + else + { + next = chunk_get_next(pc); + if ((next != NULL) && !chunk_is_newline(next)) + { + frm.pse[frm.pse_tos].indent = next->column; + } + } + } + } + else if ((pc->type == CT_PAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SQUARE_OPEN) || + (pc->type == CT_ANGLE_OPEN)) + { + /* Open parens and squares - never update indent_column, unless right + * after a newline. + */ + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = pc->column + pc->len; + + if (((pc->type == CT_FPAREN_OPEN) || (pc->type == CT_ANGLE_OPEN)) && + ((cpd.settings[UO_indent_func_call_param].b && + ((pc->parent_type == CT_FUNC_CALL) || + (pc->parent_type == CT_FUNC_CALL_USER))) + || + (cpd.settings[UO_indent_func_proto_param].b && + ((pc->parent_type == CT_FUNC_PROTO) || + (pc->parent_type == CT_FUNC_CLASS))) + || + (cpd.settings[UO_indent_func_class_param].b && + (pc->parent_type == CT_FUNC_CLASS)) + || + (cpd.settings[UO_indent_template_param].b && + (pc->parent_type == CT_TEMPLATE)) + || + (cpd.settings[UO_indent_func_ctor_var_param].b && + (pc->parent_type == CT_FUNC_CTOR_VAR)) + || + (cpd.settings[UO_indent_func_def_param].b && + (pc->parent_type == CT_FUNC_DEF)))) + { + /* Skip any continuation indents */ + idx = frm.pse_tos - 1; + while ((idx > 0) && + (frm.pse[idx].type != CT_BRACE_OPEN) && + (frm.pse[idx].type != CT_VBRACE_OPEN) && + (frm.pse[idx].type != CT_PAREN_OPEN) && + (frm.pse[idx].type != CT_FPAREN_OPEN) && + (frm.pse[idx].type != CT_SPAREN_OPEN) && + (frm.pse[idx].type != CT_SQUARE_OPEN) && + (frm.pse[idx].type != CT_ANGLE_OPEN) && + (frm.pse[idx].type != CT_CLASS_COLON) && + (frm.pse[idx].type != CT_ASSIGN_NL)) + { + idx--; + } + frm.pse[frm.pse_tos].indent = frm.pse[idx].indent + indent_size; + if (cpd.settings[UO_indent_func_param_double].b) + { + frm.pse[frm.pse_tos].indent += indent_size; + } + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + } + + else if ((chunk_is_str(pc, "(", 1) && !cpd.settings[UO_indent_paren_nl].b) || + (chunk_is_str(pc, "<", 1) && !cpd.settings[UO_indent_paren_nl].b) || /* TODO: add indent_angle_nl? */ + (chunk_is_str(pc, "[", 1) && !cpd.settings[UO_indent_square_nl].b)) + { + next = chunk_get_next_nc(pc); + if (chunk_is_newline(next)) + { + int sub = 1; + if (frm.pse[frm.pse_tos - 1].type == CT_ASSIGN) + { + sub = 2; + } + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - sub].indent + indent_size; + } + else + { + if (!chunk_is_comment(next)) + { + frm.pse[frm.pse_tos].indent = next->column; + } + } + } + + if ((pc->type == CT_FPAREN_OPEN) && + chunk_is_newline(chunk_get_prev(pc)) && + !chunk_is_newline(chunk_get_next(pc))) + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + indent_column_set(frm.pse[frm.pse_tos].indent); + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.paren_count++; + } + else if ((pc->type == CT_ASSIGN) || + (pc->type == CT_IMPORT) || + (pc->type == CT_USING)) + { + /** + * if there is a newline after the '=' or the line starts with a '=', + * just indent one level, + * otherwise align on the '='. + */ + if ((pc->type == CT_ASSIGN) && chunk_is_newline(chunk_get_prev(pc))) + { + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent + indent_size; + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + LOG_FMT(LINDENT, "%s: %d] assign => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, frm.pse[frm.pse_tos].indent_tmp); + } + + next = chunk_get_next(pc); + if (next != NULL) + { + indent_pse_push(frm, pc); + if (chunk_is_newline(next) || !cpd.settings[UO_indent_align_assign].b) + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + if (pc->type == CT_ASSIGN) + { + frm.pse[frm.pse_tos].type = CT_ASSIGN_NL; + } + } + else + { + frm.pse[frm.pse_tos].indent = pc->column + pc->len + 1; + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + } + } + else if (pc->type == CT_RETURN) + { + /* don't count returns inside a () or [] */ + if (pc->level == pc->brace_level) + { + indent_pse_push(frm, pc); + if (chunk_is_newline(chunk_get_next(pc))) + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + } + else + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + pc->len + 1; + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos - 1].indent; + } + } + else if (pc->type == CT_THROW) + { + // Pick up what was just before this. + prev = chunk_get_prev(pc); + if (pc->parent_type == CT_FUNC_PROTO) + { + indent_pse_push(frm, pc); + + if ((cpd.settings[UO_indent_func_throw].n != 0) && + ((prev == NULL) || (prev->type == CT_NEWLINE))) + { + frm.pse[frm.pse_tos].indent = cpd.settings[UO_indent_func_throw].n; + } + else + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].indent_tab = frm.pse[frm.pse_tos].indent; + + indent_column_set(frm.pse[frm.pse_tos].indent_tmp); + } + else if (pc->parent_type == CT_FUNC_DEF) + { + if ((cpd.settings[UO_indent_func_throw].n != 0) && + ((prev == NULL) || (prev->type == CT_NEWLINE))) + { + indent_column_set(cpd.settings[UO_indent_func_throw].n); + LOG_FMT(LINDENT, "%s: %d] throw => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + } + } + else + { + /* anything else? */ + } + + /** + * Indent the line if needed + */ + if (did_newline && !chunk_is_newline(pc) && (pc->len != 0)) + { + pc->column_indent = frm.pse[frm.pse_tos].indent_tab; + + LOG_FMT(LINDENT2, "%s: %d] %d for %.*s\n", + __func__, pc->orig_line, pc->column_indent, pc->len, pc->str); + + /** + * Check for special continuations. + * Note that some of these could be done as a stack item like + * everything else + */ + + prev = chunk_get_prev_ncnl(pc); + next = chunk_get_next_ncnl(pc); + if ((pc->flags & PCF_DONT_INDENT) != 0) + { + /* no change */ + } + else if ((pc->parent_type == CT_SQL_EXEC) && + cpd.settings[UO_indent_preserve_sql].b) + { + reindent_line(pc, sql_col + (pc->orig_col - sql_orig_col)); + LOG_FMT(LINDENT, "Indent SQL: [%.*s] to %d (%d/%d)\n", + pc->len, pc->str, pc->column, sql_col, sql_orig_col); + } + else if (((pc->flags & PCF_STMT_START) == 0) && + ((pc->type == CT_MEMBER) || + (pc->type == CT_DC_MEMBER) || + ((prev != NULL) && + ((prev->type == CT_MEMBER) || + (prev->type == CT_DC_MEMBER))))) + { + tmp = cpd.settings[UO_indent_member].n + indent_column; + LOG_FMT(LINDENT, "%s: %d] member => %d\n", + __func__, pc->orig_line, tmp); + reindent_line(pc, tmp); + } + else if ((vardefcol > 0) && + (pc->level == pc->brace_level) && + (pc->type == CT_WORD) && + ((pc->flags & PCF_VAR_DEF) != 0) && + (prev != NULL) && (prev->type == CT_COMMA)) + { + LOG_FMT(LINDENT, "%s: %d] Vardefcol => %d\n", + __func__, pc->orig_line, vardefcol); + reindent_line(pc, vardefcol); + } + else if ((pc->type == CT_STRING) && (prev->type == CT_STRING) && + cpd.settings[UO_indent_align_string].b) + { + tmp = (xml_indent != 0) ? xml_indent : prev->column; + + LOG_FMT(LINDENT, "%s: %d] String => %d\n", + __func__, pc->orig_line, tmp); + reindent_line(pc, tmp); + } + else if (chunk_is_comment(pc)) + { + LOG_FMT(LINDENT, "%s: %d] comment => %d\n", + __func__, pc->orig_line, frm.pse[frm.pse_tos].indent_tmp); + indent_comment(pc, frm.pse[frm.pse_tos].indent_tmp); + } + else if (pc->type == CT_PREPROC) + { + LOG_FMT(LINDENT, "%s: %d] pp-indent => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + else if (chunk_is_paren_close(pc) || (pc->type == CT_ANGLE_CLOSE)) + { + /* This is a big hack. We assume that since we hit a paren close, + * that we just removed a paren open */ + if (frm.pse[frm.pse_tos + 1].type == c_token_t(pc->type - 1)) + { + chunk_t *ck1 = frm.pse[frm.pse_tos + 1].pc; + chunk_t *ck2 = chunk_get_prev(ck1); + + /* If the open paren was the first thing on the line or we are + * doing mode 1, then put the close paren in the same column */ + if (chunk_is_newline(ck2) || + (cpd.settings[UO_indent_paren_close].n == 1)) + { + indent_column_set(ck1->column); + } + else + { + if (cpd.settings[UO_indent_paren_close].n != 2) + { + indent_column_set(frm.pse[frm.pse_tos + 1].indent_tmp); + if (cpd.settings[UO_indent_paren_close].n == 1) + { + indent_column--; + } + } + } + } + LOG_FMT(LINDENT, "%s: %d] cl paren => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + else if (pc->type == CT_COMMA) + { + if (cpd.settings[UO_indent_comma_paren].b && + chunk_is_paren_open(frm.pse[frm.pse_tos].pc)) + { + indent_column_set(frm.pse[frm.pse_tos].pc->column); + } + LOG_FMT(LINDENT, "%s: %d] comma => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + else if (cpd.settings[UO_indent_func_const].n && + (pc->type == CT_QUALIFIER) && + (strncasecmp(pc->str, "const", pc->len) == 0) && + ((next == NULL) || + (next->type == CT_BRACED) || + (next->type == CT_BRACE_OPEN) || + (next->type == CT_NEWLINE) || + (next->type == CT_SEMICOLON) || + (next->type == CT_THROW) || + (next->type == CT_VBRACE_OPEN))) + { + // indent const - void GetFoo(void)\n const\n { return (m_Foo); } + indent_column_set(cpd.settings[UO_indent_func_const].n); + LOG_FMT(LINDENT, "%s: %d] const => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + else if (pc->type == CT_BOOL) + { + if (cpd.settings[UO_indent_bool_paren].b && + chunk_is_paren_open(frm.pse[frm.pse_tos].pc)) + { + indent_column_set(frm.pse[frm.pse_tos].pc->column); + } + LOG_FMT(LINDENT, "%s: %d] bool => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + else + { + if (pc->column != indent_column) + { + LOG_FMT(LINDENT, "%s: %d] indent => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + } + did_newline = false; + + if ((pc->type == CT_SQL_EXEC) || + (pc->type == CT_SQL_BEGIN) || + (pc->type == CT_SQL_END)) + { + sql_col = pc->column; + sql_orig_col = pc->orig_col; + } + + /* Handle indent for variable defs at the top of a block of code */ + if (pc->flags & PCF_VAR_TYPE) + { + if (!frm.pse[frm.pse_tos].non_vardef && + (frm.pse[frm.pse_tos].type == CT_BRACE_OPEN)) + { + int tmp = indent_column; + if (cpd.settings[UO_indent_var_def_blk].n > 0) + { + tmp = cpd.settings[UO_indent_var_def_blk].n; + } + else + { + tmp += cpd.settings[UO_indent_var_def_blk].n; + } + reindent_line(pc, tmp); + LOG_FMT(LINDENT, "%s: %d] var_type indent => %d [%.*s]\n", + __func__, pc->orig_line, tmp, pc->len, pc->str); + } + } + else + { + if (pc != frm.pse[frm.pse_tos].pc) + { + frm.pse[frm.pse_tos].non_vardef = true; + } + } + } + + /** + * Handle variable definition continuation indenting + */ + if ((pc->type == CT_WORD) && + ((pc->flags & PCF_IN_FCN_DEF) == 0) && + ((pc->flags & PCF_VAR_1ST_DEF) == PCF_VAR_1ST_DEF)) + { + vardefcol = pc->column; + } + if (chunk_is_semicolon(pc) || + ((pc->type == CT_BRACE_OPEN) && (pc->parent_type == CT_FUNCTION))) + { + vardefcol = 0; + } + + /* if we hit a newline, reset indent_tmp */ + if (chunk_is_newline(pc) || + (pc->type == CT_COMMENT_MULTI) || + (pc->type == CT_COMMENT_CPP)) + { + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + + /** + * Handle the case of a multi-line #define w/o anything on the + * first line (indent_tmp will be 1 or 0) + */ + if ((pc->type == CT_NL_CONT) && + (frm.pse[frm.pse_tos].indent_tmp <= indent_size)) + { + frm.pse[frm.pse_tos].indent_tmp = indent_size + 1; + } + + /* Get ready to indent the next item */ + did_newline = true; + } + + /* Check for open XML tags " 0) + { + if (pc->type == CT_STRING) + { + if ((pc->len > 4) && + (pc->str[1] == '<') && + (pc->str[2] != '/') && + (pc->str[pc->len - 3] != '/')) + { + if (xml_indent <= 0) + { + xml_indent = pc->column; + } + xml_indent += cpd.settings[UO_indent_xml_string].n; + } + } + } + + if (!chunk_is_comment(pc) && !chunk_is_newline(pc)) + { + prev = pc; + } + pc = chunk_get_next(pc); + } + + /* Throw out any stuff inside a preprocessor - no need to warn */ + while ((frm.pse_tos > 0) && frm.pse[frm.pse_tos].in_preproc) + { + indent_pse_pop(frm, pc); + } + + for (idx = 1; idx <= frm.pse_tos; idx++) + { + LOG_FMT(LWARN, "%s:%d Unmatched %s\n", + cpd.filename, frm.pse[idx].open_line, + get_token_name(frm.pse[idx].type)); + cpd.error_count++; + } + + quick_align_again(); +} + + +/** + * returns true if forward scan reveals only single newlines or comments + * stops when hits code + * false if next thing hit is a closing brace, also if 2 newlines in a row + */ +static bool single_line_comment_indent_rule_applies(chunk_t *start) +{ + chunk_t *pc = start; + int nl_count = 0; + + if (!chunk_is_single_line_comment(pc)) + { + return(false); + } + + /* scan forward, if only single newlines and comments before next line of + * code, we want to apply */ + while ((pc = chunk_get_next(pc)) != NULL) + { + if (chunk_is_newline(pc)) + { + if ((nl_count > 0) || (pc->nl_count > 1)) + { + return(false); + } + + nl_count++; + } + else + { + nl_count = 0; + if (!chunk_is_single_line_comment(pc)) + { + /* here we check for things to run into that we wouldn't want to + * indent the comment for. for example, non-single line comment, + * closing brace */ + if (chunk_is_comment(pc) || chunk_is_closing_brace(pc)) + { + return(false); + } + + return(true); + } + } + } + + return(false); +} + + +/** + * REVISIT: This needs to be re-checked, maybe cleaned up + * + * Indents comments in a (hopefully) smart manner. + * + * There are two type of comments that get indented: + * - stand alone (ie, no tokens on the line before the comment) + * - trailing comments (last token on the line apart from a linefeed) + * + note that a stand-alone comment is a special case of a trailing + * + * The stand alone comments will get indented in one of three ways: + * - column 1: + * + There is an empty line before the comment AND the indent level is 0 + * + The comment was originally in column 1 + * + * - Same column as trailing comment on previous line (ie, aligned) + * + if originally within TBD (3) columns of the previous comment + * + * - syntax indent level + * + doesn't fit in the previous categories + * + * Options modify this behavior: + * - keep original column (don't move the comment, if possible) + * - keep relative column (move out the same amount as first item on line) + * - fix trailing comment in column TBD + * + * @param pc The comment, which is the first item on a line + * @param col The column if this is to be put at indent level + */ +static void indent_comment(chunk_t *pc, int col) +{ + chunk_t *nl; + chunk_t *prev; + + LOG_FMT(LCMTIND, "%s: line %d, col %d, level %d: ", __func__, + pc->orig_line, pc->orig_col, pc->level); + + /* force column 1 comment to column 1 if not changing them */ + if ((pc->orig_col == 1) && !cpd.settings[UO_indent_col1_comment].b && + ((pc->flags & PCF_INSERTED) == 0)) + { + LOG_FMT(LCMTIND, "rule 1 - keep in col 1\n"); + reindent_line(pc, 1); + return; + } + + nl = chunk_get_prev(pc); + + /* outside of any expression or statement? */ + if (pc->level == 0) + { + if ((nl != NULL) && (nl->nl_count > 1)) + { + LOG_FMT(LCMTIND, "rule 2 - level 0, nl before\n"); + reindent_line(pc, 1); + return; + } + } + + prev = chunk_get_prev(nl); + if (chunk_is_comment(prev) && (nl->nl_count == 1)) + { + int coldiff = prev->orig_col - pc->orig_col; + + if ((coldiff <= 3) && (coldiff >= -3)) + { + reindent_line(pc, prev->column); + LOG_FMT(LCMTIND, "rule 3 - prev comment, coldiff = %d, now in %d\n", + coldiff, pc->column); + return; + } + } + + /* check if special single line comment rule applies */ + if ((cpd.settings[UO_indent_sing_line_comments].n > 0) && + single_line_comment_indent_rule_applies(pc)) + { + reindent_line(pc, col + cpd.settings[UO_indent_sing_line_comments].n); + LOG_FMT(LCMTIND, "rule 4 - single line comment indent, now in %d\n", pc->column); + return; + } + LOG_FMT(LCMTIND, "rule 5 - fall-through, stay in %d\n", col); + + reindent_line(pc, col); +} + + +/** + * Scan to see if the whole file is covered by one #ifdef + */ +static bool ifdef_over_whole_file() +{ + chunk_t *pc; + chunk_t *next; + + int stage = 0; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (chunk_is_comment(pc) || chunk_is_newline(pc)) + { + continue; + } + + if (stage == 0) + { + /* Check the first PP, make sure it is an #if type */ + if (pc->type != CT_PREPROC) + { + break; + } + next = chunk_get_next(pc); + if ((next == NULL) || (next->type != CT_PP_IF)) + { + break; + } + stage = 1; + } + else if (stage == 1) + { + /* Scan until a PP at level 0 is found - the close to the #if */ + if ((pc->type == CT_PREPROC) && + (pc->pp_level == 0)) + { + stage = 2; + } + continue; + } + else if (stage == 2) + { + /* We should only see the rest of the preprocessor */ + if ((pc->type == CT_PREPROC) || + ((pc->flags & PCF_IN_PREPROC) == 0)) + { + stage = 0; + break; + } + } + } + + if (stage == 2) + { + LOG_FMT(LINFO, "The whole file is covered by a #IF\n"); + return(true); + } + return(stage == 2); +} + + +/** + * Indent the preprocessor stuff from column 1. + * FIXME: This is broken if there is a comment or escaped newline + * between '#' and 'define'. + */ +void indent_preproc(void) +{ + chunk_t *pc; + chunk_t *next; + int pp_level; + int pp_level_sub = 0; + + /* Scan to see if the whole file is covered by one #ifdef */ + if (ifdef_over_whole_file()) + { + pp_level_sub = 1; + } + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type != CT_PREPROC) + { + continue; + } + + next = chunk_get_next_ncnl(pc); + + pp_level = pc->pp_level - pp_level_sub; + if (pp_level < 0) + { + pp_level = 0; + } + + /* Adjust the indent of the '#' */ + if ((cpd.settings[UO_pp_indent].a & AV_ADD) != 0) + { + reindent_line(pc, 1 + pp_level * cpd.settings[UO_pp_indent_count].n); + } + else if ((cpd.settings[UO_pp_indent].a & AV_REMOVE) != 0) + { + reindent_line(pc, 1); + } + + /* Add spacing by adjusting the length */ + if ((cpd.settings[UO_pp_space].a != AV_IGNORE) && (next != NULL)) + { + if ((cpd.settings[UO_pp_space].a & AV_ADD) != 0) + { + int mult = cpd.settings[UO_pp_space_count].n; + + if (mult < 1) + { + mult = 1; + } + reindent_line(next, pc->column + pc->len + (pp_level * mult)); + } + else if ((cpd.settings[UO_pp_space].a & AV_REMOVE) != 0) + { + reindent_line(next, pc->column + pc->len); + } + } + + /* Mark as already handled if not region stuff or in column 1 */ + if ((!cpd.settings[UO_pp_indent_at_level].b || + (pc->brace_level <= (pc->parent_type == CT_PP_DEFINE ? 1 : 0))) && + (pc->parent_type != CT_PP_REGION) && + (pc->parent_type != CT_PP_ENDREGION)) + { + if (!cpd.settings[UO_pp_define_at_level].b || + (pc->parent_type != CT_PP_DEFINE)) + { + pc->flags |= PCF_DONT_INDENT; + } + } + + LOG_FMT(LPPIS, "%s: Indent line %d to %d (len %d, next->col %d)\n", + __func__, pc->orig_line, 1 + pp_level, pc->len, next->column); + } +} diff --git a/src/keywords.cpp b/src/keywords.cpp new file mode 100644 index 0000000000..66f881f49a --- /dev/null +++ b/src/keywords.cpp @@ -0,0 +1,558 @@ +/** + * @file keywords.cpp + * Manages the table of keywords. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "char_table.h" +#include "args.h" +#include +#include +#include +#include "unc_ctype.h" + +typedef struct +{ + chunk_tag_t *p_tags; + int total; /* number of items at p_tags */ + int active; /* number of valid entries */ +} dynamic_word_list_t; + +/* A dynamic list of keywords - add via add_keyword() */ +static dynamic_word_list_t wl; + + +/** + * interesting static keywords - keep sorted. + * Table should include the Name, Type, and Language flags. + */ +static const chunk_tag_t keywords[] = +{ + { "@catch", CT_CATCH, LANG_OC | LANG_CPP | LANG_C }, + { "@dynamic", CT_OC_DYNAMIC, LANG_OC | LANG_CPP | LANG_C }, + { "@end", CT_OC_END, LANG_OC | LANG_CPP | LANG_C }, + { "@finally", CT_TRY, LANG_OC | LANG_CPP | LANG_C }, + { "@implementation", CT_OC_IMPL, LANG_OC | LANG_CPP | LANG_C }, + { "@interface", CT_OC_INTF, LANG_OC | LANG_CPP | LANG_C }, + { "@private", CT_PRIVATE, LANG_OC | LANG_CPP | LANG_C }, + { "@property", CT_OC_PROPERTY, LANG_OC | LANG_CPP | LANG_C }, + { "@protocol", CT_OC_INTF, LANG_OC | LANG_CPP | LANG_C }, + { "@synthesize", CT_OC_DYNAMIC, LANG_OC | LANG_CPP | LANG_C }, + { "@selector", CT_OC_SEL, LANG_OC | LANG_CPP | LANG_C }, + { "@try", CT_TRY, LANG_OC | LANG_CPP | LANG_C }, + { "_Bool", CT_TYPE, LANG_CPP }, + { "_Complex", CT_TYPE, LANG_CPP }, + { "_Imaginary", CT_TYPE, LANG_CPP }, + { "__attribute__", CT_ATTRIBUTE, LANG_C | LANG_CPP }, + { "__const__", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "__inline__", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "__restrict", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "__signed__", CT_TYPE, LANG_C | LANG_CPP }, + { "__traits", CT_QUALIFIER, LANG_D }, + { "__typeof__", CT_SIZEOF, LANG_C | LANG_CPP }, + { "__volatile__", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "abstract", CT_QUALIFIER, LANG_CS | LANG_D | LANG_JAVA | LANG_VALA | LANG_ECMA }, + { "add", CT_GETSET, LANG_CS }, + { "alias", CT_QUALIFIER, LANG_D }, + { "align", CT_ALIGN, LANG_D }, + { "alignof", CT_SIZEOF, LANG_C | LANG_CPP }, + { "and", CT_SBOOL, LANG_C | LANG_CPP }, + { "and_eq", CT_SASSIGN, LANG_C | LANG_CPP }, + { "as", CT_AS, LANG_CS }, + { "asm", CT_ASM, LANG_C | LANG_CPP | LANG_D }, + { "assert", CT_FUNCTION, LANG_D | LANG_PAWN }, // PAWN + { "assert", CT_PP_ASSERT, LANG_PAWN | FLAG_PP }, // PAWN + { "auto", CT_QUALIFIER, LANG_C | LANG_CPP | LANG_D }, + { "base", CT_BASE, LANG_CS | LANG_VALA }, + { "bit", CT_TYPE, LANG_D }, + { "bitand", CT_ARITH, LANG_C | LANG_CPP }, + { "bitor", CT_ARITH, LANG_C | LANG_CPP }, + { "body", CT_BODY, LANG_D }, + { "bool", CT_TYPE, LANG_CPP | LANG_CS | LANG_VALA }, + { "boolean", CT_TYPE, LANG_JAVA | LANG_ECMA }, + { "break", CT_BREAK, LANG_ALL }, // PAWN + { "byte", CT_TYPE, LANG_CS | LANG_D | LANG_JAVA | LANG_ECMA }, + { "callback", CT_QUALIFIER, LANG_VALA }, + { "case", CT_CASE, LANG_ALL }, // PAWN + { "cast", CT_D_CAST, LANG_D }, + { "catch", CT_CATCH, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_ECMA }, + { "cdouble", CT_TYPE, LANG_D }, + { "cent", CT_TYPE, LANG_D }, + { "cfloat", CT_TYPE, LANG_D }, + { "char", CT_CHAR, LANG_PAWN }, // PAWN + { "char", CT_TYPE, LANG_ALLC }, + { "checked", CT_QUALIFIER, LANG_CS }, + { "class", CT_CLASS, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_VALA | LANG_ECMA }, + { "compl", CT_ARITH, LANG_C | LANG_CPP }, + { "const", CT_QUALIFIER, LANG_ALL }, // PAWN + { "const_cast", CT_TYPE_CAST, LANG_CPP }, + { "construct", CT_CONSTRUCT, LANG_VALA }, + { "continue", CT_CONTINUE, LANG_ALL }, // PAWN + { "creal", CT_TYPE, LANG_D }, + { "dchar", CT_TYPE, LANG_D }, + { "debug", CT_DEBUG, LANG_D }, + { "debugger", CT_DEBUGGER, LANG_ECMA }, + { "default", CT_DEFAULT, LANG_ALL }, // PAWN + { "define", CT_PP_DEFINE, LANG_ALL | FLAG_PP }, // PAWN + { "defined", CT_DEFINED, LANG_PAWN }, // PAWN + { "defined", CT_PP_DEFINED, LANG_ALLC | FLAG_PP }, + { "delegate", CT_DELEGATE, LANG_CS | LANG_D }, + { "delete", CT_DELETE, LANG_CPP | LANG_D | LANG_ECMA }, + { "deprecated", CT_QUALIFIER, LANG_D }, + { "do", CT_DO, LANG_ALL }, // PAWN + { "double", CT_TYPE, LANG_ALLC }, + { "dynamic_cast", CT_TYPE_CAST, LANG_CPP }, + { "elif", CT_PP_ELSE, LANG_ALLC | FLAG_PP }, + { "else", CT_ELSE, LANG_ALL }, // PAWN + { "else", CT_PP_ELSE, LANG_ALL | FLAG_PP }, // PAWN + { "elseif", CT_PP_ELSE, LANG_PAWN | FLAG_PP }, // PAWN + { "emit", CT_PP_EMIT, LANG_PAWN | FLAG_PP }, // PAWN + { "endif", CT_PP_ENDIF, LANG_ALL | FLAG_PP }, // PAWN + { "endinput", CT_PP_ENDINPUT, LANG_PAWN | FLAG_PP }, // PAWN + { "endregion", CT_PP_ENDREGION, LANG_ALL | FLAG_PP }, + { "endscript", CT_PP_ENDINPUT, LANG_PAWN | FLAG_PP }, // PAWN + { "enum", CT_ENUM, LANG_ALL }, // PAWN + { "error", CT_PP_ERROR, LANG_PAWN | FLAG_PP }, // PAWN + { "event", CT_TYPE, LANG_CS }, + { "exit", CT_FUNCTION, LANG_PAWN }, // PAWN + { "explicit", CT_TYPE, LANG_C | LANG_CPP | LANG_CS }, + { "export", CT_EXPORT, LANG_C | LANG_CPP | LANG_D | LANG_ECMA }, + { "extends", CT_QUALIFIER, LANG_JAVA | LANG_ECMA }, + { "extern", CT_EXTERN, LANG_C | LANG_CPP | LANG_CS | LANG_D | LANG_VALA }, + { "false", CT_WORD, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_VALA }, + { "file", CT_PP_FILE, LANG_PAWN | FLAG_PP }, // PAWN + { "final", CT_QUALIFIER, LANG_D | LANG_ECMA }, + { "finally", CT_FINALLY, LANG_D | LANG_CS | LANG_ECMA }, + { "flags", CT_TYPE, LANG_VALA }, + { "float", CT_TYPE, LANG_ALLC }, + { "for", CT_FOR, LANG_ALL }, // PAWN + { "foreach", CT_FOR, LANG_CS | LANG_D | LANG_VALA }, + { "foreach_reverse", CT_FOR, LANG_D }, + { "forward", CT_FORWARD, LANG_PAWN }, // PAWN + { "friend", CT_FRIEND, LANG_CPP }, + { "function", CT_FUNCTION, LANG_D | LANG_ECMA }, + { "get", CT_GETSET, LANG_CS | LANG_VALA }, + { "goto", CT_GOTO, LANG_ALL }, // PAWN + { "idouble", CT_TYPE, LANG_D }, + { "if", CT_IF, LANG_ALL }, // PAWN + { "if", CT_PP_IF, LANG_ALL | FLAG_PP }, // PAWN + { "ifdef", CT_PP_IF, LANG_ALLC | FLAG_PP }, + { "ifloat", CT_TYPE, LANG_D }, + { "ifndef", CT_PP_IF, LANG_ALLC | FLAG_PP }, + { "implements", CT_QUALIFIER, LANG_JAVA | LANG_ECMA }, + { "implicit", CT_QUALIFIER, LANG_CS }, + { "import", CT_IMPORT, LANG_D | LANG_JAVA | LANG_ECMA }, // fudged to get indenting + { "import", CT_PP_INCLUDE, LANG_OC | FLAG_PP }, // ObjectiveC version of include + { "in", CT_IN, LANG_D | LANG_CS | LANG_VALA | LANG_ECMA }, + { "include", CT_PP_INCLUDE, LANG_C | LANG_CPP | LANG_PAWN | FLAG_PP }, // PAWN + { "inline", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "inout", CT_QUALIFIER, LANG_D }, + { "instanceof", CT_SIZEOF, LANG_JAVA | LANG_ECMA }, + { "int", CT_TYPE, LANG_ALLC }, + { "interface", CT_CLASS, LANG_CS | LANG_D | LANG_JAVA | LANG_VALA | LANG_ECMA }, + { "internal", CT_QUALIFIER, LANG_CS }, + { "invariant", CT_INVARIANT, LANG_D }, + { "ireal", CT_TYPE, LANG_D }, + { "is", CT_SCOMPARE, LANG_D | LANG_CS | LANG_VALA }, + { "lazy", CT_LAZY, LANG_D }, + { "line", CT_PP_LINE, LANG_PAWN | FLAG_PP }, // PAWN + { "lock", CT_LOCK, LANG_CS | LANG_VALA }, + { "long", CT_TYPE, LANG_ALLC }, + { "macro", CT_D_MACRO, LANG_D }, + { "mixin", CT_CLASS, LANG_D }, // may need special handling + { "module", CT_D_MODULE, LANG_D }, + { "mutable", CT_MUTABLE, LANG_C | LANG_CPP }, + { "namespace", CT_NAMESPACE, LANG_C | LANG_CPP | LANG_CS | LANG_VALA }, + { "native", CT_NATIVE, LANG_PAWN }, // PAWN + { "native", CT_QUALIFIER, LANG_JAVA | LANG_ECMA }, + { "new", CT_NEW, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_PAWN | LANG_VALA | LANG_ECMA }, // PAWN + { "not", CT_SARITH, LANG_C | LANG_CPP }, + { "not_eq", CT_SCOMPARE, LANG_C | LANG_CPP }, + { "null", CT_TYPE, LANG_CS | LANG_D | LANG_JAVA | LANG_VALA }, + { "object", CT_TYPE, LANG_CS }, + { "operator", CT_OPERATOR, LANG_CPP | LANG_CS | LANG_PAWN }, // PAWN + { "or", CT_SBOOL, LANG_C | LANG_CPP }, + { "or_eq", CT_SASSIGN, LANG_C | LANG_CPP }, + { "out", CT_QUALIFIER, LANG_CS | LANG_D | LANG_VALA }, + { "override", CT_QUALIFIER, LANG_CS | LANG_D | LANG_VALA }, + { "package", CT_NAMESPACE, LANG_D | LANG_JAVA | LANG_ECMA }, + { "params", CT_TYPE, LANG_CS }, + { "pragma", CT_PP_PRAGMA, LANG_ALL | FLAG_PP }, // PAWN + { "private", CT_PRIVATE, LANG_ALLC }, // not C + { "protected", CT_PRIVATE, LANG_ALLC }, // not C + { "public", CT_PRIVATE, LANG_ALL }, // PAWN // not C + { "readonly", CT_QUALIFIER, LANG_CS }, + { "real", CT_TYPE, LANG_D }, + { "ref", CT_QUALIFIER, LANG_CS | LANG_VALA }, + { "region", CT_PP_REGION, LANG_ALL | FLAG_PP }, + { "register", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "reinterpret_cast", CT_TYPE_CAST, LANG_C | LANG_CPP }, + { "remove", CT_GETSET, LANG_CS }, + { "restrict", CT_QUALIFIER, LANG_C | LANG_CPP }, + { "return", CT_RETURN, LANG_ALL }, // PAWN + { "sbyte", CT_TYPE, LANG_CS }, + { "scope", CT_SCOPE, LANG_D }, + { "sealed", CT_QUALIFIER, LANG_CS }, + { "section", CT_PP_SECTION, LANG_PAWN | FLAG_PP }, // PAWN + { "set", CT_GETSET, LANG_CS | LANG_VALA }, + { "short", CT_TYPE, LANG_ALLC }, + { "signal", CT_PRIVATE, LANG_VALA }, + { "signals", CT_PRIVATE, LANG_CPP }, + { "signed", CT_TYPE, LANG_C | LANG_CPP }, + { "sizeof", CT_SIZEOF, LANG_C | LANG_CPP | LANG_CS | LANG_PAWN }, // PAWN + { "sleep", CT_FUNCTION, LANG_C | LANG_CPP | LANG_CS | LANG_PAWN }, // PAWN + { "stackalloc", CT_NEW, LANG_CS }, + { "state", CT_STATE, LANG_PAWN }, // PAWN + { "static", CT_QUALIFIER, LANG_ALL }, // PAWN + { "static_cast", CT_TYPE_CAST, LANG_CPP }, + { "stock", CT_STOCK, LANG_PAWN }, // PAWN + { "strictfp", CT_QUALIFIER, LANG_JAVA }, + { "string", CT_TYPE, LANG_CS }, + { "struct", CT_STRUCT, LANG_C | LANG_CPP | LANG_CS | LANG_D | LANG_VALA }, + { "super", CT_SUPER, LANG_D | LANG_JAVA | LANG_ECMA }, + { "switch", CT_SWITCH, LANG_ALL }, // PAWN + { "synchronized", CT_QUALIFIER, LANG_D | LANG_JAVA | LANG_ECMA }, + { "tagof", CT_TAGOF, LANG_PAWN }, // PAWN + { "template", CT_TEMPLATE, LANG_CPP | LANG_D }, + { "this", CT_THIS, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_VALA | LANG_ECMA }, + { "throw", CT_THROW, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_ECMA }, + { "throws", CT_QUALIFIER, LANG_JAVA | LANG_ECMA }, + { "transient", CT_QUALIFIER, LANG_JAVA | LANG_ECMA }, + { "true", CT_WORD, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_VALA }, + { "try", CT_TRY, LANG_CPP | LANG_CS | LANG_D | LANG_JAVA | LANG_ECMA }, + { "tryinclude", CT_PP_INCLUDE, LANG_PAWN | FLAG_PP }, // PAWN + { "typedef", CT_TYPEDEF, LANG_C | LANG_CPP | LANG_D }, + { "typeid", CT_SIZEOF, LANG_C | LANG_CPP | LANG_D }, + { "typename", CT_TYPENAME, LANG_CPP }, + { "typeof", CT_SIZEOF, LANG_C | LANG_CPP | LANG_CS | LANG_D | LANG_VALA | LANG_ECMA }, + { "ubyte", CT_TYPE, LANG_D }, + { "ucent", CT_TYPE, LANG_D }, + { "uint", CT_TYPE, LANG_CS | LANG_D }, + { "ulong", CT_TYPE, LANG_CS | LANG_D }, + { "unchecked", CT_QUALIFIER, LANG_CS }, + { "undef", CT_PP_UNDEF, LANG_ALL | FLAG_PP }, // PAWN + { "union", CT_UNION, LANG_C | LANG_CPP | LANG_D }, + { "unittest", CT_UNITTEST, LANG_D }, + { "unsafe", CT_UNSAFE, LANG_CS }, + { "unsigned", CT_TYPE, LANG_C | LANG_CPP }, + { "ushort", CT_TYPE, LANG_CS | LANG_D }, + { "using", CT_USING, LANG_CPP | LANG_CS | LANG_VALA }, + { "var", CT_TYPE, LANG_VALA | LANG_ECMA }, + { "version", CT_VERSION, LANG_D }, + { "virtual", CT_QUALIFIER, LANG_CPP | LANG_CS | LANG_VALA }, + { "void", CT_TYPE, LANG_ALLC }, + { "volatile", CT_QUALIFIER, LANG_C | LANG_CPP | LANG_CS | LANG_JAVA | LANG_ECMA }, + { "volatile", CT_VOLATILE, LANG_D }, + { "wchar", CT_TYPE, LANG_D }, + { "wchar_t", CT_TYPE, LANG_C | LANG_CPP }, + { "weak", CT_QUALIFIER, LANG_VALA }, + { "while", CT_WHILE, LANG_ALL }, // PAWN + { "with", CT_D_WITH, LANG_D | LANG_ECMA }, + { "xor", CT_SARITH, LANG_C | LANG_CPP }, + { "xor_eq", CT_SASSIGN, LANG_C | LANG_CPP }, +}; + + +/** + * Compares two chunk_tag_t entries using strcmp on the strings + * + * @param p1 The 'left' entry + * @param p2 The 'right' entry + */ +static int kw_compare(const void *p1, const void *p2) +{ + const chunk_tag_t *t1 = (const chunk_tag_t *)p1; + const chunk_tag_t *t2 = (const chunk_tag_t *)p2; + + return(strcmp(t1->tag, t2->tag)); +} + + +bool keywords_are_sorted(void) +{ + int idx; + bool retval = true; + + for (idx = 1; idx < (int)ARRAY_SIZE(keywords); idx++) + { + if (kw_compare(&keywords[idx - 1], &keywords[idx]) > 0) + { + LOG_FMT(LERR, "%s: bad sort order at idx %d, words '%s' and '%s'\n", + __func__, idx - 1, keywords[idx - 1].tag, keywords[idx].tag); + retval = false; + } + } + return(retval); +} + + +/** + * Adds a keyword to the list of dynamic keywords + * + * @param tag The tag (string) must be zero terminated + * @param type The type, usually CT_TYPE + * @param lang_flags Language flags, typically LANG_ALL + */ +void add_keyword(const char *tag, c_token_t type, int lang_flags) +{ + /* Do we need to allocate more memory? */ + if ((wl.total == wl.active) || (wl.p_tags == NULL)) + { + wl.total += 16; + wl.p_tags = (chunk_tag_t *)realloc(wl.p_tags, sizeof(chunk_tag_t) * wl.total); + } + if (wl.p_tags != NULL) + { + wl.p_tags[wl.active].tag = strdup(tag); + wl.p_tags[wl.active].type = type; + wl.p_tags[wl.active].lang_flags = lang_flags; + wl.active++; + + /* Todo: add in sorted order instead of resorting the whole list? */ + qsort(wl.p_tags, wl.active, sizeof(chunk_tag_t), kw_compare); + + LOG_FMT(LDYNKW, "%s: added '%s'\n", __func__, tag); + } +} + + +/** + * Backs up to the first string match in keywords. + */ +static const chunk_tag_t *kw_static_first(const chunk_tag_t *tag) +{ + const chunk_tag_t *prev = tag - 1; + + while ((prev >= &keywords[0]) && (strcmp(prev->tag, tag->tag) == 0)) + { + tag = prev; + prev--; + } + //fprintf(stderr, "first:%s -", tag->tag); + return(tag); +} + + +static const chunk_tag_t *kw_static_match(const chunk_tag_t *tag) +{ + bool in_pp = ((cpd.in_preproc != CT_NONE) && (cpd.in_preproc != CT_PP_DEFINE)); + bool pp_iter; + const chunk_tag_t *iter; + + for (iter = kw_static_first(tag); + iter < &keywords[ARRAY_SIZE(keywords)]; + iter++) + { + //fprintf(stderr, " check:%s", iter->tag); + pp_iter = (iter->lang_flags & FLAG_PP) != 0; + if ((strcmp(iter->tag, tag->tag) == 0) && + ((cpd.lang_flags & iter->lang_flags) != 0) && + (in_pp == pp_iter)) + { + //fprintf(stderr, " match:%s", iter->tag); + return(iter); + } + } + return(NULL); +} + + +/** + * Search first the dynamic and then the static table for a matching keyword + * + * @param word Pointer to the text -- NOT zero terminated + * @param len The length of the text + * @return NULL (no match) or the keyword entry + */ +const chunk_tag_t *find_keyword(const char *word, int len) +{ + chunk_tag_t tag; + char buf[128]; + const chunk_tag_t *p_ret; + + if (len > (int)(sizeof(buf) - 1)) + { + LOG_FMT(LNOTE, "%s: keyword too long at %d char (%d max) : %.*s\n", + __func__, len, (int)sizeof(buf), len, word); + return(NULL); + } + memcpy(buf, word, len); + buf[len] = 0; + + tag.tag = buf; + + /* check the dynamic word list first */ + p_ret = NULL; + if (wl.p_tags) + { + p_ret = (const chunk_tag_t *)bsearch(&tag, wl.p_tags, wl.active, + sizeof(chunk_tag_t), kw_compare); + } + + if (p_ret == NULL) + { + /* check the static word list */ + p_ret = (const chunk_tag_t *)bsearch(&tag, keywords, ARRAY_SIZE(keywords), + sizeof(keywords[0]), kw_compare); + if (p_ret != NULL) + { + //fprintf(stderr, "%s: match %s -", __func__, p_ret->tag); + p_ret = kw_static_match(p_ret); + //fprintf(stderr, "\n"); + } + } + return(p_ret); +} + + +/** + * Loads the dynamic keywords from a file + * + * @param filename The path to the file to load + * @return SUCCESS or FAILURE + */ +int load_keyword_file(const char *filename) +{ + FILE *pf; + char buf[256]; + char *ptr; + char *args[3]; + int argc; + int line_no = 0; + + pf = fopen(filename, "r"); + if (pf == NULL) + { + LOG_FMT(LERR, "%s: fopen(%s) failed: %s (%d)\n", + __func__, filename, strerror(errno), errno); + cpd.error_count++; + return(FAILURE); + } + + while (fgets(buf, sizeof(buf), pf) != NULL) + { + line_no++; + + /* remove comments */ + if ((ptr = strchr(buf, '#')) != NULL) + { + *ptr = 0; + } + + argc = Args::SplitLine(buf, args, ARRAY_SIZE(args) - 1); + args[argc] = 0; + + if (argc > 0) + { + if ((argc == 1) && CharTable::IsKw1(*args[0])) + { + add_keyword(args[0], CT_TYPE, LANG_ALL); + } + else + { + LOG_FMT(LWARN, "%s:%d Invalid line (starts with '%s')\n", + filename, line_no, args[0]); + cpd.error_count++; + } + } + } + + fclose(pf); + return(SUCCESS); +} + + +void output_types(FILE *pfile) +{ + int idx; + + if (wl.active > 0) + { + fprintf(pfile, "-== User Types ==-\n"); + } + for (idx = 0; idx < wl.active; idx++) + { + fprintf(pfile, "%s\n", wl.p_tags[idx].tag); + } +} + + +const chunk_tag_t *get_custom_keyword_idx(int& idx) +{ + const chunk_tag_t *ct = NULL; + + if ((idx >= 0) && (idx < wl.active)) + { + ct = &wl.p_tags[idx]; + } + idx++; + return(ct); +} + + +void clear_keyword_file(void) +{ + if (wl.p_tags != NULL) + { + for (int idx = 0; idx < wl.active; idx++) + { + free((void *)wl.p_tags[idx].tag); + wl.p_tags[idx].tag = NULL; + } + free(wl.p_tags); + wl.p_tags = NULL; + } + wl.total = 0; + wl.active = 0; +} + + +/** + * Returns the pattern that the keyword needs based on the token + */ +pattern_class get_token_pattern_class(c_token_t tok) +{ + switch (tok) + { + case CT_IF: + case CT_ELSEIF: + case CT_SWITCH: + case CT_FOR: + case CT_WHILE: + case CT_LOCK: + case CT_D_WITH: + return(PATCLS_PBRACED); + + case CT_ELSE: + return(PATCLS_ELSE); + + case CT_DO: + case CT_TRY: + case CT_FINALLY: + case CT_BODY: + case CT_UNITTEST: + case CT_UNSAFE: + case CT_VOLATILE: + case CT_GETSET: + return(PATCLS_BRACED); + + case CT_CATCH: + case CT_VERSION: + case CT_DEBUG: + return(PATCLS_OPBRACED); + + case CT_NAMESPACE: + return(PATCLS_VBRACED); + + case CT_WHILE_OF_DO: + return(PATCLS_PAREN); + + case CT_INVARIANT: + return(PATCLS_OPPAREN); + + default: + return(PATCLS_NONE); + } +} diff --git a/src/lang_pawn.cpp b/src/lang_pawn.cpp new file mode 100644 index 0000000000..35806746b7 --- /dev/null +++ b/src/lang_pawn.cpp @@ -0,0 +1,504 @@ +/** + * @file lang_pawn.cpp + * Special functions for pawn stuff + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "ChunkStack.h" +#include "prototypes.h" + +static chunk_t *pawn_process_line(chunk_t *start); +static chunk_t *pawn_mark_function0(chunk_t *start, chunk_t *fcn); +static chunk_t *pawn_process_variable(chunk_t *start); +static chunk_t *pawn_process_func_def(chunk_t *pc); + +chunk_t *pawn_add_vsemi_after(chunk_t *pc) +{ + if ((pc->type == CT_VSEMICOLON) || + (pc->type == CT_SEMICOLON)) + { + return(pc); + } + + chunk_t *next = chunk_get_next_nc(pc); + if ((next != NULL) && + ((next->type == CT_VSEMICOLON) || + (next->type == CT_SEMICOLON))) + { + return(pc); + } + chunk_t chunk; + + chunk = *pc; + chunk.type = CT_VSEMICOLON; + chunk.len = cpd.settings[UO_mod_pawn_semicolon].b ? 1 : 0; + chunk.str = ";"; + chunk.column += pc->len; + chunk.parent_type = CT_NONE; + + LOG_FMT(LPVSEMI, "%s: Added VSEMI on line %d, prev='%.*s' [%s]\n", + __func__, pc->orig_line, pc->len, pc->str, + get_token_name(pc->type)); + + return(chunk_add_after(&chunk, pc)); +} + + +/** + * Turns certain virtual semicolons invisible. + * - after a close brace with a parent of switch, case, else, if + */ +void pawn_scrub_vsemi(void) +{ + if (!cpd.settings[UO_mod_pawn_semicolon].b) + { + return; + } + + chunk_t *pc; + chunk_t *prev; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type != CT_VSEMICOLON) + { + continue; + } + prev = chunk_get_prev_ncnl(pc); + if ((prev != NULL) && (prev->type == CT_BRACE_CLOSE)) + { + if ((prev->parent_type == CT_IF) || + (prev->parent_type == CT_ELSE) || + (prev->parent_type == CT_SWITCH) || + (prev->parent_type == CT_CASE) || + (prev->parent_type == CT_WHILE_OF_DO)) + { + pc->len = 0; + } + } + } +} + + +/** + * Checks to see if a token continues a statement to the next line. + * We need to check for 'open' braces/paren/etc because the level doesn't + * change until the token after the open. + */ +static bool pawn_continued(chunk_t *pc, int br_level) +{ + if (pc == NULL) + { + return(false); + } + if ((pc->level > br_level) || + (pc->type == CT_ARITH) || + (pc->type == CT_QUESTION) || + (pc->type == CT_BOOL) || + (pc->type == CT_ASSIGN) || + (pc->type == CT_COMMA) || + (pc->type == CT_COMPARE) || + (pc->type == CT_IF) || + (pc->type == CT_ELSE) || + (pc->type == CT_DO) || + (pc->type == CT_SWITCH) || + (pc->type == CT_WHILE) || + (pc->type == CT_BRACE_OPEN) || + (pc->type == CT_VBRACE_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE) || + (pc->parent_type == CT_ELSEIF) || + (pc->parent_type == CT_DO) || + (pc->parent_type == CT_FOR) || + (pc->parent_type == CT_SWITCH) || + (pc->parent_type == CT_WHILE) || + (pc->parent_type == CT_FUNC_DEF) || + (pc->parent_type == CT_ENUM) || + ((pc->flags & PCF_IN_ENUM) != 0) || + chunk_is_str(pc, ":", 1) || + chunk_is_str(pc, "+", 1) || + chunk_is_str(pc, "-", 1)) + { + return(true); + } + return(false); +} + + +/** + * Does a scan of level 0 BEFORE stuff in combine.cpp is called. + * At this point, VSemis have been added only in VBraces. + * Otherwise, all level info is correct, except for unbraced functions. + * + * We are looking for unbraced functions. + */ +void pawn_prescan(void) +{ + /* Start at the beginning and step through the entire file, and clean up + * any questionable stuff + */ + + chunk_t *pc; + bool did_nl = true; + + pc = chunk_get_head(); + while (pc != NULL) + { + if (did_nl && (pc->type != CT_PREPROC) && + !chunk_is_newline(pc) && (pc->level == 0)) + { + /* pc now points to the start of a line */ + pc = pawn_process_line(pc); + } + /* note that continued lines are ignored */ + if (pc != NULL) + { + did_nl = (pc->type == CT_NEWLINE); + } + + pc = chunk_get_next_nc(pc); + } +} + + +/** + * Functions prototypes and definitions can only appear in level 0. + * + * Function prototypes start with "native", "forward", or are just a function + * with a trailing semicolon instead of a open brace (or something else) + * + * somefunc(params) <-- def + * stock somefunc(params) <-- def + * somefunc(params); <-- proto + * forward somefunc(params) <-- proto + * native somefunc[rect](params) <-- proto + * + * Functions start with 'stock', 'static', 'public', or '@' (on level 0) + * + * Variable definitions start with 'stock', 'static', 'new', or 'public'. + */ +static chunk_t *pawn_process_line(chunk_t *start) +{ + chunk_t *pc; + chunk_t *fcn = NULL; + + //LOG_FMT(LSYS, "%s: %d - %.*s\n", __func__, + // start->orig_line, start->len, start->str); + + if ((start->type == CT_NEW) || + chunk_is_str(start, "const", 5)) + { + return(pawn_process_variable(start)); + } + + /* if a open paren is found before an assign, then this is a function */ + if (start->type == CT_WORD) + { + fcn = start; + } + pc = start; + while (((pc = chunk_get_next_nc(pc)) != NULL) && + !chunk_is_str(pc, "(", 1) && + (pc->type != CT_ASSIGN) && + (pc->type != CT_NEWLINE)) + { + if ((pc->level == 0) && + ((pc->type == CT_FUNCTION) || + (pc->type == CT_WORD))) + { + fcn = pc; + } + } + + if (pc != NULL) + { + if (pc->type == CT_ASSIGN) + { + return(pawn_process_variable(pc)); + } + } + + if (fcn != NULL) + { + //LOG_FMT(LSYS, "FUNCTION: %.*s\n", fcn->len, fcn->str); + return(pawn_mark_function0(start, fcn)); + } + + if (start->type == CT_ENUM) + { + pc = chunk_get_next_type(start, CT_BRACE_CLOSE, start->level); + return(pc); + } + + //LOG_FMT(LSYS, "%s: Don't understand line %d, starting with '%.*s' [%s]\n", + // __func__, start->orig_line, start->len, start->str, get_token_name(start->type)); + return(start); +} + + +/** + * follows a variable definition at level 0 until the end. + * Adds a semicolon at the end, if needed. + */ +static chunk_t *pawn_process_variable(chunk_t *start) +{ + chunk_t *prev = NULL; + chunk_t *pc = start; + + while ((pc = chunk_get_next_nc(pc)) != NULL) + { + if ((pc->type == CT_NEWLINE) && + !pawn_continued(prev, start->level)) + { + if ((prev->type != CT_VSEMICOLON) && + (prev->type != CT_SEMICOLON)) + { + pawn_add_vsemi_after(prev); + } + break; + } + prev = pc; + } + return(pc); +} + + +void pawn_add_virtual_semicolons(void) +{ + chunk_t *prev; + chunk_t *pc; + + /** Add Pawn virtual semicolons */ + prev = NULL; + if ((cpd.lang_flags & LANG_PAWN) != 0) + { + pc = chunk_get_head(); + while ((pc = chunk_get_next(pc)) != NULL) + { + if (!chunk_is_comment(pc) && + !chunk_is_newline(pc) && + (pc->type != CT_VBRACE_CLOSE) && + (pc->type != CT_VBRACE_OPEN)) + { + prev = pc; + } + if ((prev == NULL) || + ((pc->type != CT_NEWLINE) && + (pc->type != CT_BRACE_CLOSE) && + (pc->type != CT_VBRACE_CLOSE))) + { + continue; + } + + /* we just hit a newline and we have a previous token */ + if (((prev->flags & PCF_IN_PREPROC) == 0) && + ((prev->flags & PCF_IN_ENUM) == 0) && + (prev->type != CT_VSEMICOLON) && + (prev->type != CT_SEMICOLON) && + !pawn_continued(prev, prev->brace_level)) + { + pawn_add_vsemi_after(prev); + prev = NULL; + } + } + } +} + + +/** + * We are on a level 0 function proto of def + */ +static chunk_t *pawn_mark_function0(chunk_t *start, chunk_t *fcn) +{ + chunk_t *last; + + /* handle prototypes */ + if (start == fcn) + { + last = chunk_get_next_type(fcn, CT_PAREN_CLOSE, fcn->level); + last = chunk_get_next(last); + if ((last != NULL) && (last->type == CT_SEMICOLON)) + { + LOG_FMT(LPFUNC, "%s: %d] '%.*s' proto due to semicolon\n", __func__, + fcn->orig_line, fcn->len, fcn->str); + fcn->type = CT_FUNC_PROTO; + return(last); + } + } + else + { + if ((start->type == CT_FORWARD) || + (start->type == CT_NATIVE)) + { + LOG_FMT(LPFUNC, "%s: %d] '%.*s' [%s] proto due to %s\n", __func__, + fcn->orig_line, fcn->len, fcn->str, + get_token_name(fcn->type), + get_token_name(start->type)); + fcn->type = CT_FUNC_PROTO; + return(chunk_get_next_nc(fcn)); + } + } + + /* Not a prototype, so it must be a function def */ + return(pawn_process_func_def(fcn)); +} + + +static chunk_t *pawn_process_func_def(chunk_t *pc) +{ + /* We are on a function definition */ + chunk_t *clp; + chunk_t *last; + chunk_t *next; + + pc->type = CT_FUNC_DEF; + + /* If we don't have a brace open right after the close fparen, then + * we need to add virtual braces around the function body. + */ + clp = chunk_get_next_str(pc, ")", 1, 0); + last = chunk_get_next_ncnl(clp); + + if (last != NULL) + { + LOG_FMT(LPFUNC, "%s: %d] last is '%.*s' [%s]\n", __func__, + last->orig_line, last->len, last->str, get_token_name(last->type)); + } + + /* See if there is a state clause after the function */ + if ((last != NULL) && chunk_is_str(last, "<", 1)) + { + LOG_FMT(LPFUNC, "%s: %d] '%.*s' has state angle open %s\n", __func__, + pc->orig_line, pc->len, pc->str, get_token_name(last->type)); + + last->type = CT_ANGLE_OPEN; + last->parent_type = CT_FUNC_DEF; + while (((last = chunk_get_next(last)) != NULL) && + !chunk_is_str(last, ">", 1)) + { + } + + if (last != NULL) + { + LOG_FMT(LPFUNC, "%s: %d] '%.*s' has state angle close %s\n", __func__, + pc->orig_line, pc->len, pc->str, get_token_name(last->type)); + last->type = CT_ANGLE_CLOSE; + last->parent_type = CT_FUNC_DEF; + } + last = chunk_get_next_ncnl(last); + } + + if (last == NULL) + { + return(last); + } + if (last->type == CT_BRACE_OPEN) + { + last->parent_type = CT_FUNC_DEF; + last = chunk_get_next_type(last, CT_BRACE_CLOSE, last->level); + if (last != NULL) + { + last->parent_type = CT_FUNC_DEF; + } + } + else + { + LOG_FMT(LPFUNC, "%s: %d] '%.*s' fdef: expected brace open: %s\n", __func__, + pc->orig_line, pc->len, pc->str, get_token_name(last->type)); + + chunk_t chunk; + chunk = *last; + chunk.str = "{"; + chunk.len = 0; + chunk.type = CT_VBRACE_OPEN; + chunk.parent_type = CT_FUNC_DEF; + + chunk_t *prev = chunk_add_before(&chunk, last); + last = prev; + + /* find the next newline at level 0 */ + prev = chunk_get_next_ncnl(prev); + do + { + LOG_FMT(LPFUNC, "%s:%d] check %s, level %d\n", __func__, + prev->orig_line, get_token_name(prev->type), prev->level); + if ((prev->type == CT_NEWLINE) && + (prev->level == 0)) + { + next = chunk_get_next_ncnl(prev); + if ((next != NULL) && + (next->type != CT_ELSE) && + (next->type != CT_WHILE_OF_DO)) + { + break; + } + } + prev->level++; + prev->brace_level++; + last = prev; + } while ((prev = chunk_get_next(prev)) != NULL); + + if (last != NULL) + { + LOG_FMT(LPFUNC, "%s:%d] ended on %s, level %d\n", __func__, + last->orig_line, get_token_name(last->type), last->level); + } + + chunk = *last; + chunk.str = "}"; + chunk.len = 0; + chunk.column += last->len; + chunk.type = CT_VBRACE_CLOSE; + chunk.level = 0; + chunk.brace_level = 0; + chunk.parent_type = CT_FUNC_DEF; + last = chunk_add_after(&chunk, last); + } + return(last); +} + + +/** + * We are in a virtual brace and hit a newline. + * If this should end the vbrace, then insert a VSEMICOLON and return that. + * + * @param pc The newline (CT_NEWLINE) + * @return Either the newline or the newly inserted virtual semicolon + */ +chunk_t *pawn_check_vsemicolon(chunk_t *pc) +{ + chunk_t *vb_open; + chunk_t *prev; + + /* Grab the open VBrace */ + vb_open = chunk_get_prev_type(pc, CT_VBRACE_OPEN, -1); + + /** + * Grab the item before the newline + * Don't do anything if: + * - the only thing previous is the V-Brace open + * - in a preprocessor + * - level > (vb_open->level + 1) -- ie, in () or [] + * - it is something that needs a continuation + * + arith, assign, bool, comma, compare + */ + prev = chunk_get_prev_ncnl(pc); + if ((prev == NULL) || + (prev == vb_open) || + ((prev->flags & PCF_IN_PREPROC) != 0) || + pawn_continued(prev, vb_open->level + 1)) + { + if (prev != NULL) + { + LOG_FMT(LPVSEMI, "%s: no VSEMI on line %d, prev='%.*s' [%s]\n", + __func__, prev->orig_line, prev->len, prev->str, get_token_name(prev->type)); + } + return(pc); + } + + return(pawn_add_vsemi_after(prev)); +} diff --git a/src/log_levels.h b/src/log_levels.h new file mode 100644 index 0000000000..98e96e8c9a --- /dev/null +++ b/src/log_levels.h @@ -0,0 +1,93 @@ +/** + * @file log_levels.h + * + * Enum for log levels. + * Use these for the log severities in LOG_FMT(), etc. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef LOG_LEVELS_H_INCLUDED +#define LOG_LEVELS_H_INCLUDED + +enum +{ + LSYS = 0, + LERR = 1, + LWARN = 2, + LNOTE = 3, + LINFO = 4, + LDATA = 5, + + LFILELIST = 8, /* Files in the file list file */ + LLINEENDS = 9, /* Show which line endings are used */ + LCASTS = 10, /* align casts */ + LALBR = 11, /* align braces */ + LALTD = 12, /* Align Typedef */ + LALPP = 13, /* align #define */ + LALPROTO = 14, /* align prototype */ + LALNLC = 15, /* align backslash-newline */ + LALTC = 16, /* align trailing comments */ + LALADD = 17, /* align add */ + LALASS = 18, /* align assign */ + LFVD = 19, /* fix_var_def */ + LFVD2 = 20, /* fix_var_def-2 */ + LINDENT = 21, /* indent_text */ + LINDENT2 = 22, /* indent_text tab level */ + LINDPSE = 23, /* indent_text stack */ + LINDPC = 24, /* indent play-by-play */ + LNEWLINE = 25, /* newlines */ + LPF = 26, /* Parse Frame */ + LSTMT = 27, /* Marking statements/expressions */ + LTOK = 28, /* Tokenize */ + LALRC = 29, /* align right comment */ + LCMTIND = 30, /* Comment Indent */ + LINDLINE = 31, /* indent line */ + LSIB = 32, /* Scan IB */ + LRETURN = 33, /* add/remove parens for return */ + LBRDEL = 34, /* brace removal */ + LFCN = 35, /* function detection */ + LFCNP = 36, /* function parameters */ + LPCU = 37, /* parse cleanup */ + LDYNKW = 38, /* dynamic keywords */ + LOUTIND = 39, /* output indent */ + LBCSAFTER = 40, /* Brace cleanup stack - after each token */ + LBCSPOP = 41, /* Brace cleanup stack - log pops */ + LBCSPUSH = 42, /* Brace cleanup stack - log push */ + LBCSSWAP = 43, /* Brace cleanup stack - log swaps */ + LFTOR = 44, /* Class Ctor or Dtor */ + LAS = 45, /* align_stack */ + LPPIS = 46, /* Preprocessor Indent and Space */ + LTYPEDEF = 47, /* Typedef and function types */ + LVARDEF = 48, /* Variable def marking */ + LDEFVAL = 49, /* define values */ + LPVSEMI = 50, /* Pawn: virtual semicolons */ + LPFUNC = 51, /* Pawn: function recognition */ + LSPLIT = 52, /* Line splitting */ + LFTYPE = 53, /* Function type detection */ + LTEMPL = 54, /* Template detection */ + LPARADD = 55, /* adding parens in if/while */ + LPARADD2 = 56, /* adding parens in if/while - details */ + LCMTNL = 57, /* newlines before comments */ + LTEMPFUNC = 58, /* Template function detection */ + LSCANSEMI = 59, /* scan semi colon removal */ + LDELSEMI = 60, /* Removing semicolons */ + LFPARAM = 61, /* Testing for a full parameter */ + LNL1LINE = 62, /* NL check for 1 liners */ + LPFCHK = 63, /* Parse Frame check fcn call */ + LAVDB = 64, /* align var def braces */ + LSORT = 65, /* Sorting */ + LSPACE = 66, /* Space */ + LALIGN = 67, /* align */ + LALAGAIN = 68, /* align again */ + LOPERATOR = 69, /* operator */ + LASFCP = 70, /* Align Same Function Call Params */ + LINDLINED = 71, /* indent line details */ + LBCTRL = 72, /* beautifier control */ + LRMRETURN = 73, /* remove 'return;' */ + LPPIF = 74, /* #if/#else/#endif pair processing */ + LMCB = 75, /* mod_case_brace */ + LBRCH = 76, /* if brace chain */ +}; + +#endif /* LOG_LEVELS_H_INCLUDED */ diff --git a/src/logger.cpp b/src/logger.cpp new file mode 100644 index 0000000000..19eb96c754 --- /dev/null +++ b/src/logger.cpp @@ -0,0 +1,374 @@ +/** + * @file logger.cpp + * + * Functions to do logging. + * + * If a log statement ends in a newline, the current log is ended. + * When the log severity changes, an implicit newline is inserted. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "logger.h" + +#include +#include +#include "unc_ctype.h" + + +/** Private log structure */ +struct log_buf +{ + FILE *log_file; + log_sev_t sev; + int in_log; + char buf[256]; + int buf_len; + log_mask_t mask; + bool show_hdr; +}; +static struct log_buf g_log; + + +/** + * Initializes the log subsystem - call this first. + * This function sets the log stream and enables the top 3 sevs (0-2). + * + * @param log_file NULL for stderr or the FILE stream for logs. + */ +void log_init(FILE *log_file) +{ + memset(&g_log, 0, sizeof(g_log)); + + /* set the top 3 severities */ + log_set_sev(0, true); + log_set_sev(1, true); + log_set_sev(2, true); + + g_log.log_file = (log_file != NULL) ? log_file : stderr; +} + + +/** + * Show or hide the severity prefix "<1>" + * + * @param true=show false=hide + */ +void log_show_sev(bool show) +{ + g_log.show_hdr = show; +} + + +/** + * Returns whether a log severity is active. + * + * @param sev The severity + * @return true/false + */ +bool log_sev_on(log_sev_t sev) +{ + return(logmask_test(&g_log.mask, sev)); +} + + +/** + * Sets a log sev on or off + * + * @param sev The severity + * @return true/false + */ +void log_set_sev(log_sev_t sev, bool value) +{ + logmask_set_sev(&g_log.mask, sev, value); +} + + +/** + * Sets the log mask + * + * @param mask The mask to copy + */ +void log_set_mask(const log_mask_t *mask) +{ + if (mask != NULL) + { + memcpy(g_log.mask.bits, mask->bits, sizeof(g_log.mask.bits)); + } +} + + +/** + * Gets the log mask + * + * @param mask Where to copy the mask + */ +void log_get_mask(log_mask_t *mask) +{ + if (mask != NULL) + { + memcpy(mask->bits, g_log.mask.bits, sizeof(g_log.mask.bits)); + } +} + + +/** + * Flushes the cached log text to the stream + * + * @param force_nl Append NL if not present + */ +static void log_flush(bool force_nl) +{ + int dummy; /* get the compiler to shut up */ + + if (g_log.buf_len > 0) + { + if (force_nl && (g_log.buf[g_log.buf_len - 1] != '\n')) + { + g_log.buf[g_log.buf_len++] = '\n'; + g_log.buf[g_log.buf_len] = 0; + } + dummy = fwrite(g_log.buf, 1, g_log.buf_len, g_log.log_file); + + g_log.buf_len = 0; + } +} + + +/** + * Starts the log statment by flushing if needed and printing the header + * + * @param sev The log severity + * @return The number of bytes available + */ +static size_t log_start(log_sev_t sev) +{ + if (sev != g_log.sev) + { + if (g_log.buf_len > 0) + { + log_flush(true); + } + g_log.sev = sev; + g_log.in_log = false; + } + + /* If not in a log, the buffer is empty. Add the header, if enabled. */ + if (!g_log.in_log && g_log.show_hdr) + { + g_log.buf_len = snprintf(g_log.buf, sizeof(g_log.buf), "<%d>", sev); + } + + int cap = ((int)sizeof(g_log.buf) - 2) - g_log.buf_len; + + return((cap > 0) ? (size_t)cap : 0); +} + + +/** + * Cleans up after a log statement by detecting whether the log is done, + * (it ends in a newline) and possibly flushing the log. + */ +static void log_end(void) +{ + g_log.in_log = (g_log.buf[g_log.buf_len - 1] != '\n'); + if (!g_log.in_log || (g_log.buf_len > (int)(sizeof(g_log.buf) / 2))) + { + log_flush(false); + } +} + + +/** + * Logs a string of known length + * + * @param sev The severity + * @param str The pointer to the string + * @param len The length of the string from strlen(str) + */ +void log_str(log_sev_t sev, const char *str, int len) +{ + if ((str == NULL) || (len <= 0) || !log_sev_on(sev)) + { + return; + } + + size_t cap = log_start(sev); + if (cap > 0) + { + if (len > (int)cap) + { + len = cap; + } + memcpy(&g_log.buf[g_log.buf_len], str, len); + g_log.buf_len += len; + g_log.buf[g_log.buf_len] = 0; + } + log_end(); +} + + +/** + * Logs a formatted string -- similiar to printf() + * + * @param sev The severity + * @param fmt The format string + * @param ... Additional arguments + */ +void log_fmt(log_sev_t sev, const char *fmt, ...) +{ + va_list args; + int len; + size_t cap; + + if ((fmt == NULL) || !log_sev_on(sev)) + { + return; + } + + /* Some implementation of vsnprintf() return the number of characters + * that would have been stored if the buffer was large enough instead of + * the number of characters actually stored. + */ + cap = log_start(sev); + + /* Add on the variable log parameters to the log string */ + va_start(args, fmt); + len = vsnprintf(&g_log.buf[g_log.buf_len], cap, fmt, args); + va_end(args); + + if (len > 0) + { + if (len > (int)cap) + { + len = cap; + } + g_log.buf_len += len; + g_log.buf[g_log.buf_len] = 0; + } + + log_end(); +} + + +/** + * Dumps hex characters inline, no newlines inserted + * + * @param sev The severity + * @param data The data to log + * @param len The number of bytes to log + */ +void log_hex(log_sev_t sev, const void *vdata, int len) +{ + const UINT8 *dat = (const UINT8 *)vdata; + int idx; + char buf[80]; + + if ((vdata == NULL) || !log_sev_on(sev)) + { + return; + } + + idx = 0; + while (len-- > 0) + { + buf[idx++] = to_hex_char(*dat >> 4); + buf[idx++] = to_hex_char(*dat); + dat++; + + if (idx >= (int)(sizeof(buf) - 3)) + { + buf[idx] = 0; + log_str(sev, buf, idx); + idx = 0; + } + } + + if (idx > 0) + { + buf[idx] = 0; + log_str(sev, buf, idx); + } +} + + +/** + * Logs a block of data in a pretty hex format + * Numbers on the left, characters on the right, just like I like it. + * + * @param sev The severity + * @param data The data to log + * @param len The number of bytes to log + */ +void log_hex_blk(log_sev_t sev, const void *data, int len) +{ + static char buf[80] = "nnn | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | cccccccccccccccc\n"; + const UINT8 *dat = (const UINT8 *)data; + int idx; + int count; + int str_idx = 0; + int chr_idx = 0; + int tmp; + int total; + + if ((data == NULL) || (len <= 0) || !log_sev_on(sev)) + { + return; + } + + /* + * Dump the specified number of bytes in hex, 16 byte per line by + * creating a string and then calling log_str() + */ + + /* Loop through the data of the current iov */ + count = 0; + total = 0; + for (idx = 0; idx < len; idx++) + { + if (count == 0) + { + str_idx = 6; + chr_idx = 56; + + buf[0] = to_hex_char(total >> 12); + buf[1] = to_hex_char(total >> 8); + buf[2] = to_hex_char(total >> 4); + } + + tmp = dat[idx]; + + buf[str_idx] = to_hex_char(tmp >> 4); + buf[str_idx + 1] = to_hex_char(tmp); + str_idx += 3; + + buf[chr_idx++] = unc_isprint(tmp) ? tmp : '.'; + + total++; + count++; + if (count >= 16) + { + count = 0; + log_str(sev, buf, 73); + } + } + + /* + ** Print partial line if any + */ + if (count != 0) + { + /* Clear out any junk */ + while (count < 16) + { + buf[str_idx] = ' '; /* MSB hex */ + buf[str_idx + 1] = ' '; /* LSB hex */ + str_idx += 3; + + buf[chr_idx++] = ' '; + + count++; + } + log_str(sev, buf, 73); + } +} diff --git a/src/logger.h b/src/logger.h new file mode 100644 index 0000000000..3bc4311303 --- /dev/null +++ b/src/logger.h @@ -0,0 +1,153 @@ +/** + * @file logger.h + * + * Functions to do logging. + * The macros check whether the logsev is active before evaluating the + * parameters. Use them instead of the functions. + * + * If a log statement ends in a newline, the current log is ended. + * When the log severity changes, an implicit newline is inserted. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef LOGGER_H_INCLUDED +#define LOGGER_H_INCLUDED + +#include "logmask.h" +#include /* strlen() */ +#include /* FILE */ + + +/** + * Initializes the log subsystem - call this first. + * This function sets the log stream and enables the top 3 sevs (0-2). + * + * @param log_file NULL for stderr or the FILE stream for logs. + */ +void log_init(FILE *log_file); + + +/** + * Show or hide the severity prefix "<1>" + * + * @param true=show false=hide + */ +void log_show_sev(bool show); + + +/** + * Returns whether a log severity is active. + * + * @param sev The severity + * @return true/false + */ +bool log_sev_on(log_sev_t sev); + + +/** + * Sets a log sev on or off + * + * @param sev The severity + * @return true/false + */ +void log_set_sev(log_sev_t sev, bool value); + + +/** + * Sets the log mask + * + * @param mask The mask to copy + */ +void log_set_mask(const log_mask_t *mask); + + +/** + * Gets the log mask + * + * @param mask Where to copy the mask + */ +void log_get_mask(log_mask_t *mask); + + +/** + * Logs a string of known length + * + * @param sev The severity + * @param str The pointer to the string + * @param len The length of the string from strlen(str) + */ +void log_str(log_sev_t sev, const char *str, int len); + +#define LOG_STR(sev, str, len) \ + do { if (log_sev_on(sev)) { log_str(sev, str, len); } } while (0) + +#define LOG_STRING(sev, str) \ + do { if (log_sev_on(sev)) { log_str(sev, str, strlen(str)); } } while (0) + + +/** + * Logs a formatted string -- similiar to printf() + * + * @param sev The severity + * @param fmt The format string + * @param ... Additional arguments + */ +void log_fmt(log_sev_t sev, const char *fmt, ...) __attribute__((format(printf, 2, 3))); + +#ifdef NO_MACRO_VARARG +#define LOG_FMT log_fmt +#else +#define LOG_FMT(sev, args...) \ + do { if (log_sev_on(sev)) { log_fmt(sev, ## args); } } while (0) +#endif + + +/** + * Dumps hex characters inline, no newlines inserted + * + * @param sev The severity + * @param data The data to log + * @param len The number of bytes to log + */ +void log_hex(log_sev_t sev, const void *vdata, int len); + +#define LOG_HEX(sev, ptr, len) \ + do { if (log_sev_on(sev)) { log_hex(sev, ptr, len); } } while (0) + + +/** + * Logs a block of data in a pretty hex format + * Numbers on the left, characters on the right, just like I like it. + * + * "nnn | XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX | ................" + * 0 ^6 54^ ^56 72^ + * + * nnn is the line number or index/16 + * + * @param sev The severity + * @param data The data to log + * @param len The number of bytes to log + */ +void log_hex_blk(log_sev_t sev, const void *data, int len); + +#define LOG_HEX_BLK(sev, ptr, len) \ + do { if (log_sev_on(sev)) { log_hex_blk(sev, ptr, len); } } while (0) + + +/** + * Returns the HEX digit for a low nibble in a number + * + * @param nibble The nibble + * @return '0', '1', '2', '3', '4', '5', '6', '7', + * '8', '9', 'a', 'b', 'c', 'd', 'e', or 'f' + */ +static_inline char to_hex_char(int nibble) +{ + const char *hex_string = "0123456789abcdef"; + + return(hex_string[nibble & 0x0F]); +} + + +#endif /* LOGGER_H_INCLUDED */ diff --git a/src/logmask.cpp b/src/logmask.cpp new file mode 100644 index 0000000000..64a63f1ca0 --- /dev/null +++ b/src/logmask.cpp @@ -0,0 +1,152 @@ +/** + * @file logmask.cpp + * + * Functions to convert between a string and a severity mask. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "logmask.h" +#include /* snprintf() */ +#include /* strtoul() */ +#include "unc_ctype.h" + + +/** + * Convert a logmask into a string + * + * @param mask the mask to convert + * @param buf the buffer to hold the string + * @param size the size of the buffer + * @return buf (pass through) + */ +char *logmask_to_str(const log_mask_t *mask, char *buf, int size) +{ + int last_sev = -1; + bool is_range = false; + int sev; + int len = 0; + + if ((mask == NULL) || (buf == NULL) || (size <= 0)) + { + if ((buf != NULL) && (size > 0)) + { + *buf = 0; + } + return(buf); + } + + for (sev = 0; sev < 256; sev++) + { + if (logmask_test(mask, sev)) + { + if (last_sev == -1) + { + len += snprintf(&buf[len], size - len, "%d,", sev); + } + else + { + is_range = true; + } + last_sev = sev; + } + else + { + if (is_range) + { + buf[len - 1] = '-'; /* change last comma to a dash */ + len += snprintf(&buf[len], size - len, "%d,", last_sev); + is_range = false; + } + last_sev = -1; + } + } + + /* handle a range that ends on the last bit */ + if (is_range && (last_sev != -1)) + { + buf[len - 1] = '-'; /* change last comma to a dash */ + len += snprintf(&buf[len], size - len, "%d", last_sev); + } + else + { + /* Eat the last comma */ + if (len > 0) + { + len--; + } + } + + buf[len] = 0; + + return(buf); +} + + +/** + * Parses a string into a log severity + * + * @param str The string to parse + * @param mask The mask to populate + */ +void logmask_from_string(const char *str, log_mask_t *mask) +{ + char *ptmp; + bool was_dash = false; + int last_level = -1; + int level; + int idx; + + if ((str == NULL) || (mask == NULL)) + { + return; + } + + /* Start with a clean mask */ + logmask_set_all(mask, false); + + /* If the first character is 'A', set all sevs */ + if (unc_toupper(*str) == 'A') + { + logmask_set_all(mask, true); + str++; + } + + while (*str != 0) + { + if (unc_isspace(*str)) + { + str++; + continue; + } + + if (unc_isdigit(*str)) + { + level = strtoul(str, &ptmp, 10); + str = ptmp; + + logmask_set_sev(mask, level, true); + if (was_dash) + { + for (idx = last_level + 1; idx < level; idx++) + { + logmask_set_sev(mask, idx, true); + } + was_dash = false; + } + + last_level = level; + } + else if (*str == '-') + { + was_dash = true; + str++; + } + else /* probably a comma */ + { + last_level = -1; + was_dash = false; + str++; + } + } +} diff --git a/src/logmask.h b/src/logmask.h new file mode 100644 index 0000000000..484f73b83f --- /dev/null +++ b/src/logmask.h @@ -0,0 +1,90 @@ +/** + * @file logmask.h + * + * Functions to manipulate a log severity mask. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef LOGMASK_H_INCLUDED +#define LOGMASK_H_INCLUDED + +#include "base_types.h" +#include /* memset() */ + + +typedef UINT8 log_sev_t; + + +/** A simple array of 256 bits */ +typedef struct +{ + UINT8 bits[32]; /* 256 levels */ +} log_mask_t; + + +/** + * Tests whether a sev bit is set in the mask + * + * @param sev The severity to check + * @return true (is set) or false (not set) + */ +static_inline bool logmask_test(const log_mask_t *mask, log_sev_t sev) +{ + return((mask->bits[sev >> 3] & (1 << (sev & 0x07))) != 0); +} + + +/** + * Sets a set bit in the mask + * + * @param sev The severity to check + * @param value true (set bit) or false (clear bit) + */ +static_inline void logmask_set_sev(log_mask_t *mask, log_sev_t sev, bool value) +{ + if (value) + { + mask->bits[sev >> 3] |= (1 << (sev & 0x07)); + } + else + { + mask->bits[sev >> 3] &= ~(1 << (sev & 0x07)); + } +} + + +/** + * Sets all bits to the same value + * + * @param value true (set bit) or false (clear bit) + */ +static_inline void logmask_set_all(log_mask_t *mask, bool value) +{ + memset(mask->bits, value ? 0xff : 0, sizeof(mask->bits)); +} + + +/** + * Convert a logmask into a string. + * The string is a comma-delimited list of severities. + * Example: 1,3,5-10 + * + * @param mask the mask to convert + * @param buf the buffer to hold the string + * @param size the size of the buffer + * @return buf (pass through) + */ +char *logmask_to_str(const log_mask_t *mask, char *buf, int size); + + +/** + * Parses a string into a log severity + * + * @param str The string to parse + * @param mask The mask to populate + */ +void logmask_from_string(const char *str, log_mask_t *mask); + + +#endif /* LOGMASK_H_INCLUDED */ diff --git a/src/md5.cpp b/src/md5.cpp new file mode 100644 index 0000000000..4e66eaeab0 --- /dev/null +++ b/src/md5.cpp @@ -0,0 +1,326 @@ +/** + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + * + * @license Public Domain / GPL v2+ + */ + +#include "md5.h" +#include /* memcpy, memset */ + + +/** + * Reverse the bytes in 32-bit chunks. + * 'buf' might not be word-aligned. + * + * @param buf The byte array to reverse + * @param n_u32 The number of UINT32's in the data + */ +void MD5::reverse_u32(UINT8 *buf, int n_u32) +{ + UINT8 tmp; + + if (m_big_endian) + { + /* change { 4, 3, 2, 1 } => { 1, 2, 3, 4 } */ + while (n_u32-- > 0) + { + tmp = buf[0]; + buf[0] = buf[3]; + buf[3] = tmp; + + tmp = buf[1]; + buf[1] = buf[2]; + buf[2] = tmp; + + buf += 4; + } + } + else + { + /* change { 4, 3, 2, 1 } => { 3, 4, 1, 2 } */ + while (n_u32-- > 0) + { + tmp = buf[0]; + buf[0] = buf[1]; + buf[1] = tmp; + + tmp = buf[2]; + buf[2] = buf[3]; + buf[3] = tmp; + + buf += 4; + } + } +} + + +MD5::MD5() +{ + m_buf[0] = 0x01020304; + + /* + * Little endian = { 4, 3, 2, 1 } + * Big endian = { 1, 2, 3, 4 } + * PDP endian = { 3, 4, 1, 2 } + * + * The MD5 stuff is written for little endian. + */ + + m_need_byteswap = *(UINT8 *)m_buf != 4; + m_big_endian = *(UINT8 *)m_buf == 1; +} + + +/** + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + * initialization constants. + */ +void MD5::Init() +{ + m_buf[0] = 0x67452301; + m_buf[1] = 0xefcdab89; + m_buf[2] = 0x98badcfe; + m_buf[3] = 0x10325476; + + m_bits[0] = 0; + m_bits[1] = 0; +} + + +/** + * Update context to reflect the concatenation of another buffer full + * of bytes. + */ +void MD5::Update(const void *data, UINT32 len) +{ + const UINT8 *buf = (const UINT8 *)data; + UINT32 t; + + /* Update bitcount */ + t = m_bits[0]; + if ((m_bits[0] = t + ((UINT32)len << 3)) < t) + { + m_bits[1]++; /* Carry from low to high */ + } + m_bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + + /* Handle any leading odd-sized chunks */ + if (t) + { + UINT8 *p = (UINT8 *)m_in + t; + + t = 64 - t; + if (len < t) + { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + if (m_need_byteswap) + { + reverse_u32(m_in, 16); + } + Transform(m_buf, (UINT32 *)m_in); + buf += t; + len -= t; + } + /* Process data in 64-byte chunks */ + + while (len >= 64) + { + memcpy(m_in, buf, 64); + if (m_need_byteswap) + { + reverse_u32(m_in, 16); + } + Transform(m_buf, (UINT32 *)m_in); + buf += 64; + len -= 64; + } + + /* Save off any remaining bytes of data */ + memcpy(m_in, buf, len); +} + + +/** + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ +void MD5::Final(UINT8 digest[16]) +{ + UINT32 count; + UINT8 *p; + + /* Compute number of bytes mod 64 */ + count = (m_bits[0] >> 3) & 0x3F; + + /* Set the first char of padding to 0x80. This is safe since there is + * always at least one byte free */ + p = m_in + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) + { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + if (m_need_byteswap) + { + reverse_u32(m_in, 16); + } + Transform(m_buf, (UINT32 *)m_in); + + /* Now fill the next block with 56 bytes */ + memset(m_in, 0, 56); + } + else + { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + if (m_need_byteswap) + { + reverse_u32(m_in, 14); + } + + /* Append length in bits and transform */ + ((UINT32 *)m_in)[14] = m_bits[0]; + ((UINT32 *)m_in)[15] = m_bits[1]; + + Transform(m_buf, (UINT32 *)m_in); + if (m_need_byteswap) + { + reverse_u32((UINT8 *)m_buf, 4); + } + memcpy(digest, m_buf, 16); +} + + +/* The four core functions - F1 is optimized somewhat */ + +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f, w, x, y, z, data, s) \ + (w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x) + +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5::Update blocks + * the data and converts bytes into longwords for this routine. + */ +void MD5::Transform(UINT32 buf[4], UINT32 in_data[16]) +{ + UINT32 a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in_data[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in_data[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in_data[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in_data[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in_data[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in_data[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in_data[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in_data[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in_data[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in_data[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in_data[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in_data[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in_data[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in_data[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in_data[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in_data[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in_data[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in_data[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in_data[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in_data[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in_data[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in_data[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in_data[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in_data[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in_data[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in_data[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in_data[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in_data[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in_data[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in_data[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in_data[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in_data[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in_data[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in_data[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in_data[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in_data[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in_data[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in_data[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in_data[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in_data[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in_data[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in_data[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in_data[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in_data[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in_data[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in_data[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in_data[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in_data[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in_data[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in_data[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in_data[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in_data[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in_data[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in_data[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in_data[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in_data[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in_data[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in_data[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in_data[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in_data[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in_data[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in_data[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in_data[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in_data[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + + +void MD5::Calc(const void *data, UINT32 length, UINT8 digest[16]) +{ + MD5 md5; + + md5.Init(); + md5.Update(data, length); + md5.Final(digest); +} diff --git a/src/md5.h b/src/md5.h new file mode 100644 index 0000000000..d86f57594c --- /dev/null +++ b/src/md5.h @@ -0,0 +1,39 @@ +/** + * @file md5.h + * A simple class for MD5 calculation + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef MD5_H_INCLUDED +#define MD5_H_INCLUDED + +#include "base_types.h" + +class MD5 +{ +public: + MD5(); + ~MD5() { } + + void Init(); + void Update(const void *data, UINT32 len); + + void Final(UINT8 digest[16]); + + /* internal function */ + static void Transform(UINT32 buf[4], UINT32 in_data[16]); + + static void Calc(const void *data, UINT32 length, UINT8 digest[16]); + +private: + UINT32 m_buf[4]; + UINT32 m_bits[2]; + UINT8 m_in[64]; + bool m_need_byteswap; + bool m_big_endian; + + void reverse_u32(UINT8 *buf, int n_u32); +}; + +#endif /* MD5_H_INCLUDED */ diff --git a/src/newlines.cpp b/src/newlines.cpp new file mode 100644 index 0000000000..6708a7cbdf --- /dev/null +++ b/src/newlines.cpp @@ -0,0 +1,2425 @@ +/** + * @file newlines.cpp + * Adds or removes newlines. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +static void newlines_double_space_struct_enum_union(chunk_t *open_brace); +static bool one_liner_nl_ok(chunk_t *pc); +static void nl_handle_define(chunk_t *pc); +static void newline_iarf_pair(chunk_t *before, chunk_t *after, argval_t av); + +/** + * Check to see if we are allowed to increase the newline count. + * The only case where we can't is if nl_squeeze_ifdef=true and a preproc is + * after the newline. + */ +static bool can_increase_nl(chunk_t *nl) +{ + if (cpd.settings[UO_nl_squeeze_ifdef].b) + { + chunk_t *pc = chunk_get_next(nl); + + if ((pc != NULL) && (pc->type == CT_PREPROC) && + (pc->parent_type == CT_PP_ENDIF)) + { + return(false); + } + } + return(true); +} + + +/** + * Double the newline, if allowed. + */ +static void double_newline(chunk_t *nl) +{ + chunk_t *prev = chunk_get_prev(nl); + + LOG_FMT(LNEWLINE, "%s: add newline after %.*s on line %d", + __func__, prev->len, prev->str, prev->orig_line); + + if (!can_increase_nl(nl)) + { + LOG_FMT(LNEWLINE, " - denied\n"); + return; + } + LOG_FMT(LNEWLINE, " - done\n"); + nl->nl_count = 2; +} + + +/* + * Basic approach: + * 1. Find next open brace + * 2. Find next close brace + * 3. Determine why the braces are there + * a. struct/union/enum "enum [name] {" + * c. assignment "= {" + * b. if/while/switch/for/etc ") {" + * d. else "} else {" + */ + +//#define DEBUG_NEWLINES +static void setup_newline_add(const chunk_t *prev, chunk_t *nl, const chunk_t *next) +{ + memset(nl, 0, sizeof(*nl)); + nl->nl_count = 1; + nl->flags = (prev->flags & PCF_COPY_FLAGS) & ~PCF_IN_PREPROC; + if ((prev->flags & PCF_IN_PREPROC) && (next->flags & PCF_IN_PREPROC)) + { + nl->flags |= PCF_IN_PREPROC; + } + if ((nl->flags & PCF_IN_PREPROC) != 0) + { + nl->type = CT_NL_CONT; + nl->str = "\\\n"; + nl->len = 2; + } + else + { + nl->type = CT_NEWLINE; + nl->str = "\n"; + nl->len = 1; + } +} + + +/** + * 2 parts: + * - if/switch/while/for after braces + * - else before/after braces + * - do after braces + * - do/while before braces + */ +chunk_t *newline_add_before2(chunk_t *pc, const char *fcn, int line) +{ + chunk_t nl; + chunk_t *prev; + + prev = chunk_get_prev(pc); + if (chunk_is_newline(prev)) + { + /* Already has a newline before this chunk */ + return(prev); + } + + LOG_FMT(LNEWLINE, "%s: '%.*s' on line %d (called from %s line %d)\n", + __func__, pc->len, pc->str, pc->orig_line, fcn, line); + + setup_newline_add(prev, &nl, pc); + + return(chunk_add_before(&nl, pc)); +} + + +chunk_t *newline_add_after2(chunk_t *pc, const char *fcn, int line) +{ + chunk_t nl; + chunk_t *next; + + next = chunk_get_next(pc); + if (chunk_is_newline(next)) + { + /* Already has a newline after this chunk */ + return(next); + } + + LOG_FMT(LNEWLINE, "%s: '%.*s' on line %d (called from %s line %d)\n", + __func__, pc->len, pc->str, pc->orig_line, fcn, line); + + setup_newline_add(pc, &nl, next); + + return(chunk_add_after(&nl, pc)); +} + + +#define newline_min_after(ref, cnt) newline_min_after2(ref, cnt, __func__, __LINE__) + +static void newline_min_after2(chunk_t *ref, INT32 count, + const char *func, int line) +{ + chunk_t *pc = ref; + chunk_t *next; + + LOG_FMT(LNEWLINE, "%s: '%.*s' line %d - count %d : caller=%s:%d\n", + __func__, ref->len, ref->str, ref->orig_line, count, func, line); + + do + { + pc = chunk_get_next(pc); + } while ((pc != NULL) && !chunk_is_newline(pc)); + + //LOG_FMT(LNEWLINE, "%s: on %s, line %d, col %d\n", + // __func__, get_token_name(pc->type), pc->orig_line, pc->orig_col); + + next = chunk_get_next(pc); + if (chunk_is_comment(next) && (next->nl_count == 1) && + chunk_is_comment(chunk_get_prev(pc))) + { + newline_min_after(next, count); + return; + } + else + { + if (chunk_is_newline(pc) && can_increase_nl(pc)) + { + if (pc->nl_count < count) + { + pc->nl_count = count; + } + } + } +} + + +/** + * Add a newline between two tokens. + * If there is already a newline between then, nothing is done. + * Otherwise a newline is inserted. + * + * If end is CT_BRACE_OPEN and a comment and newline follow, then + * the brace open is moved instead of inserting a newline. + * + * In this situation: + * if (...) { //comment + * + * you get: + * if (...) //comment + * { + */ +chunk_t *newline_add_between2(chunk_t *start, chunk_t *end, + const char *func, int line) +{ + chunk_t *pc; + + if ((start == NULL) || (end == NULL)) + { + return(NULL); + } + + LOG_FMT(LNEWLINE, "%s: '%.*s'[%s] line %d:%d and '%.*s' line %d:%d : caller=%s:%d\n", + __func__, start->len, start->str, get_token_name(start->type), + start->orig_line, start->orig_col, + end->len, end->str, end->orig_line, end->orig_col, func, line); + + /* Back-up check for one-liners (should never be true!) */ + if (!one_liner_nl_ok(start)) + { + return(NULL); + } + + /* Scan for a line break */ + for (pc = start; pc != end; pc = chunk_get_next(pc)) + { + if (chunk_is_newline(pc)) + { + return(pc); + } + } + + /* If the second one is a brace open, then check to see + * if a comment + newline follows + */ + if (end->type == CT_BRACE_OPEN) + { + pc = chunk_get_next(end); + if (chunk_is_comment(pc)) + { + pc = chunk_get_next(pc); + if (chunk_is_newline(pc)) + { + /* Move the open brace to after the newline */ + chunk_move_after(end, pc); + return(pc); + } + } + } + + return(newline_add_before(end)); +} + + +/** + * Removes any CT_NEWLINE or CT_NL_CONT between start and end. + * Start must be before end on the chunk list. + * If the 'PCF_IN_PREPROC' status differs between two tags, we can't remove + * the newline. + * + * @param start The starting chunk (cannot be a newline) + * @param end The ending chunk (cannot be a newline) + * @return true/false - removed something + */ +void newline_del_between2(chunk_t *start, chunk_t *end, + const char *func, int line) +{ + chunk_t *next; + chunk_t *prev; + chunk_t *pc = start; + + LOG_FMT(LNEWLINE, "%s: '%.*s' line %d:%d and '%.*s' line %d:%d : caller=%s:%d preproc=%d/%d\n", + __func__, start->len, start->str, start->orig_line, start->orig_col, + end->len, end->str, end->orig_line, end->orig_col, func, line, + ((start->flags & PCF_IN_PREPROC) != 0), + ((end->flags & PCF_IN_PREPROC) != 0)); + + /* Can't remove anything if the preproc status differs */ + if (!chunk_same_preproc(start, end)) + { + return; + } + + do + { + next = chunk_get_next(pc); + if (chunk_is_newline(pc)) + { + prev = chunk_get_prev(pc); + if ((!chunk_is_comment(prev) && !chunk_is_comment(next)) || + chunk_is_newline(prev) || + chunk_is_newline(next)) + { + if (chunk_safe_to_del_nl(pc)) + { + chunk_del(pc); + align_to_column(next, prev->column + space_col_align(prev, next)); + } + } + else + { + if (pc->nl_count > 1) + { + pc->nl_count = 1; + } + } + } + pc = next; + } while (pc != end); + + if (chunk_is_str(end, "{", 1) && + (chunk_is_str(start, ")", 1) || + (start->type == CT_DO) || + (start->type == CT_ELSE))) + { + if (chunk_get_prev_nl(end) != start) + { + chunk_move_after(end, start); + } + } +} + + +/** + * Add or remove a newline between the closing paren and opening brace. + * Also uncuddles anything on the closing brace. (may get fixed later) + * + * "if (...) { \n" or "if (...) \n { \n" + */ +static void newlines_if_for_while_switch(chunk_t *start, argval_t nl_opt) +{ + chunk_t *pc; + chunk_t *close_paren; + chunk_t *brace_open; + + if ((nl_opt == AV_IGNORE) || + (((start->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b)) + { + return; + } + + pc = chunk_get_next_ncnl(start); + if ((pc != NULL) && (pc->type == CT_SPAREN_OPEN)) + { + close_paren = chunk_get_next_type(pc, CT_SPAREN_CLOSE, pc->level); + brace_open = chunk_get_next_ncnl(close_paren); + + if ((brace_open != NULL) && (brace_open->type == CT_BRACE_OPEN) && + one_liner_nl_ok(brace_open)) + { + if (cpd.settings[UO_nl_multi_line_cond].b) + { + while ((pc = chunk_get_next(pc)) != close_paren) + { + if (chunk_is_newline(pc)) + { + nl_opt = AV_ADD; + break; + } + } + } + + newline_iarf_pair(close_paren, brace_open, nl_opt); + + newline_add_between(brace_open, chunk_get_next_ncnl(brace_open)); + + /* Make sure nothing is cuddled with the closing brace */ + pc = chunk_get_next_type(brace_open, CT_BRACE_CLOSE, brace_open->level); + newline_add_between(pc, chunk_get_next_nblank(pc)); + } + } +} + + +/** + * Add or remove extra newline before the chunk. + * Adds before comments + * Doesn't do anything if open brace before it + * "code\n\ncomment\nif (...)" or "code\ncomment\nif (...)" + */ +static void newlines_if_for_while_switch_pre_blank_lines(chunk_t *start, argval_t nl_opt) +{ + chunk_t *pc; + chunk_t *prev; + chunk_t *next; + chunk_t *last_nl = NULL; + int level = start->level; + bool do_add = nl_opt & AV_ADD; + + if ((nl_opt == AV_IGNORE) || + (((start->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b)) + { + return; + } + + /* + * look backwards until we find + * open brace (don't add or remove) + * 2 newlines in a row (don't add) + * something else (don't remove) + */ + for (pc = chunk_get_prev(start); pc != NULL; pc = chunk_get_prev(pc)) + { + if (chunk_is_newline(pc)) + { + last_nl = pc; + /* if we found 2 or more in a row */ + if ((pc->nl_count > 1) || chunk_is_newline(chunk_get_prev_nvb(pc))) + { + /* need to remove */ + if (nl_opt & AV_REMOVE) + { + /* if we're also adding, take care of that here */ + pc->nl_count = do_add ? 2 : 1; + /* can keep using pc because anything other than newline stops loop, and we delete if newline */ + while (chunk_is_newline(prev = chunk_get_prev_nvb(pc))) + { + /* Make sure we don't combine a preproc and non-preproc */ + if (!chunk_safe_to_del_nl(prev)) + { + break; + } + chunk_del(prev); + } + } + + return; + } + } + else if (chunk_is_opening_brace(pc) || (pc->level < level)) + { + return; + } + else if (chunk_is_comment(pc)) + { + /* vbrace close is ok because it won't go into output, so we should skip it */ + last_nl = NULL; + continue; + } + else + { + if (do_add) /* we found something previously besides a comment or a new line */ + { + /* if we have run across a newline */ + if (last_nl != NULL) + { + if (last_nl->nl_count < 2) + { + double_newline(last_nl); + } + } + else + { + /* we didn't run into a nl, so we need to add one */ + if (((next = chunk_get_next(pc)) != NULL) && + chunk_is_comment(next)) + { + pc = next; + } + if ((last_nl = newline_add_after(pc)) != NULL) + { + double_newline(last_nl); + } + } + } + + return; + } + } +} + + +static chunk_t *get_closing_brace(chunk_t *start) +{ + chunk_t *pc; + int level = start->level; + + for (pc = start; (pc = chunk_get_next(pc)) != NULL;) + { + if (((pc->type == CT_BRACE_CLOSE) || (pc->type == CT_VBRACE_CLOSE)) && (pc->level == level)) + { + return(pc); + } + /* for some reason, we can have newlines between if and opening brace that are lower level than either */ + if (!chunk_is_newline(pc) && (pc->level < level)) + { + return(NULL); + } + } + + return(NULL); +} + + +/** + * remove any consecutive newlines following this chunk + * skip vbraces + */ +static void remove_next_newlines(chunk_t *start) +{ + chunk_t *next; + + while ((next = chunk_get_next(start)) != NULL) + { + if (chunk_is_newline(next) && chunk_safe_to_del_nl(next)) + { + chunk_del(next); + } + else if (chunk_is_vbrace(next)) + { + start = next; + } + else + { + break; + } + } +} + + +/** + * Add or remove extra newline after end of the block started in chunk. + * Doesn't do anything if close brace after it + * Interesting issue is that at this point, nls can be before or after vbraces + * VBraces will stay VBraces, conversion to real ones should have already happened + * "if (...)\ncode\ncode" or "if (...)\ncode\n\ncode" + */ +static void newlines_if_for_while_switch_post_blank_lines(chunk_t *start, argval_t nl_opt) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + bool have_pre_vbrace_nl = false; + int nl_count; + + if ((nl_opt == AV_IGNORE) || + (((start->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b)) + { + return; + } + + /* first find ending brace */ + if ((pc = get_closing_brace(start)) == NULL) + { + return; + } + + /* if we're dealing with an if, we actually want to add or remove blank lines after any elses */ + if (start->type == CT_IF) + { + while (true) + { + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && ((next->type == CT_ELSE) || (next->type == CT_ELSEIF))) + { + /* point to the closing brace of the else */ + if ((pc = get_closing_brace(next)) == NULL) + { + return; + } + } + else + { + break; + } + } + } + + /* if we're dealing with a do/while, we actually want to add or remove blank lines after while and its condition */ + if (start->type == CT_DO) + { + /* point to the next semicolon */ + if ((pc = chunk_get_next_type(pc, CT_SEMICOLON, start->level)) == NULL) + { + return; + } + } + + bool isVBrace = pc->type == CT_VBRACE_CLOSE; + if ((prev = chunk_get_prev_nvb(pc)) == NULL) + { + return; + } + + have_pre_vbrace_nl = isVBrace && chunk_is_newline(prev); + if (nl_opt & AV_REMOVE) + { + /* if vbrace, have to check before and after */ + /* if chunk before vbrace, remove any nls after vbrace */ + if (have_pre_vbrace_nl) + { + prev->nl_count = 1; + remove_next_newlines(pc); + } + else if (chunk_is_newline(next = chunk_get_next_nvb(pc))) /* otherwise just deal with nls after brace */ + { + next->nl_count = 1; + remove_next_newlines(next); + } + } + + /* may have a nl before and after vbrace */ + /* don't do anything with it if the next non nl chunk is a closing brace */ + if (nl_opt & AV_ADD) + { + if ((next = chunk_get_next_nnl(pc)) == NULL) + { + return; + } + + if (next->type != CT_BRACE_CLOSE) + { + /* if vbrace, have to check before and after */ + /* if chunk before vbrace, check its count */ + nl_count = have_pre_vbrace_nl ? prev->nl_count : 0; + if (chunk_is_newline(next = chunk_get_next_nvb(pc))) + { + nl_count += next->nl_count; + } + + /* if we have no newlines, add one and make it double */ + if (nl_count == 0) + { + if (((next = chunk_get_next(pc)) != NULL) && + chunk_is_comment(next)) + { + pc = next; + } + + if ((next = newline_add_after(pc)) == NULL) + { + return; + } + double_newline(next); + } + else if (nl_count == 1) /* if we don't have enough newlines */ + { + /* if we have one before vbrace, need to add one after */ + if (have_pre_vbrace_nl) + { + next = newline_add_after(pc); + } + else + { + prev = chunk_get_prev_nnl(next); + pc = chunk_get_next_nl(next); + //LOG_FMT(LSYS, " -- pc1=%.*s [%s]\n", pc->len, pc->str, get_token_name(pc->type)); + + pc = chunk_get_next(pc); + //LOG_FMT(LSYS, " -- pc2=%.*s [%s]\n", pc->len, pc->str, get_token_name(pc->type)); + if ((pc != NULL) && (pc->type == CT_PREPROC) && + (pc->parent_type == CT_PP_ENDIF) && + cpd.settings[UO_nl_squeeze_ifdef].b) + { + LOG_FMT(LNEWLINE, "%s: cannot add newline after line %d due to nl_squeeze_ifdef\n", + __func__, prev->orig_line); + } + else + { + /* make nl after double */ + double_newline(next); + } + } + } + } + } +} + + +/** + * Adds or removes a newline between the keyword and the open brace. + * If there is something after the '{' on the same line, then + * the newline is removed unconditionally. + * + * "struct [name] {" or "struct [name] \n {" + */ +static void newlines_struct_enum_union(chunk_t *start, argval_t nl_opt, bool leave_trailing) +{ + chunk_t *pc; + chunk_t *next; + + if ((nl_opt == AV_IGNORE) || + (((start->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b)) + { + return; + } + + /* step past any junk between the keyword and the open brace + * Quit if we hit a semicolon, which is not expected. + */ + int level = start->level; + pc = start; + while (((pc = chunk_get_next_ncnl(pc)) != NULL) && (pc->level >= level)) + { + if ((pc->level == level) && + ((pc->type == CT_BRACE_OPEN) || chunk_is_semicolon(pc))) + { + break; + } + start = pc; + } + + /* If we hit a brace open, then we need to toy with the newlines */ + if ((pc != NULL) && (pc->type == CT_BRACE_OPEN)) + { + /* Skip over embedded C comments */ + next = chunk_get_next(pc); + while ((next != NULL) && (next->type == CT_COMMENT)) + { + next = chunk_get_next(next); + } + if (leave_trailing && + !chunk_is_comment(next) && + !chunk_is_newline(next)) + { + nl_opt = AV_IGNORE; + } + + newline_iarf_pair(start, pc, nl_opt); + } +} + + +/** + * Cuddles or un-cuddles a chunk with a previous close brace + * + * "} while" vs "} \n while" + * "} else" vs "} \n else" + * + * @param start The chunk - should be CT_ELSE or CT_WHILE_OF_DO + */ +static void newlines_cuddle_uncuddle(chunk_t *start, argval_t nl_opt) +{ + chunk_t *br_close; + + if (((start->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b) + { + return; + } + + br_close = chunk_get_prev_ncnl(start); + if ((br_close != NULL) && (br_close->type == CT_BRACE_CLOSE)) + { + newline_iarf_pair(br_close, start, nl_opt); + } +} + + +/** + * Adds/removes a newline between else and '{'. + * "else {" or "else \n {" + */ +static void newlines_do_else(chunk_t *start, argval_t nl_opt) +{ + chunk_t *next; + + if ((nl_opt == AV_IGNORE) || + (((start->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b)) + { + return; + } + + next = chunk_get_next_ncnl(start); + if ((next != NULL) && (next->type == CT_BRACE_OPEN)) + { + if (!one_liner_nl_ok(next)) + { + return; + } + newline_iarf_pair(start, next, nl_opt); + if ((nl_opt & AV_ADD) != 0) + { + chunk_t *tmp = chunk_get_next(next); + if ((tmp != NULL) && !chunk_is_newline(tmp)) + { + newline_add_between(next, tmp); + } + } + } +} + + +/** + * We are at the open brace for a function body. + * put a newline after the block of variable definitions + */ +static void newline_fnc_var_def(chunk_t *br_open, int nl_count) +{ + chunk_t *prev = NULL; + chunk_t *next; + chunk_t *pc; + + pc = chunk_get_next_ncnl(br_open); + while (pc != NULL) + { + if (chunk_is_type(pc) || (pc->type == CT_QUALIFIER) || (pc->type == CT_DC_MEMBER)) + { + pc = chunk_get_next_ncnl(pc); + continue; + } + + if (((pc->type == CT_WORD) || (pc->type == CT_FUNC_CTOR_VAR)) && + ((pc->flags & PCF_VAR_1ST) != 0)) + { + pc = chunk_get_next_type(pc, CT_SEMICOLON, pc->level); + prev = pc; + pc = chunk_get_next_ncnl(pc); + continue; + } + + break; + } + + /* prev is either NULL or points to a semicolon */ + if (prev != NULL) + { + next = chunk_get_next_ncnl(prev); + if ((next != NULL) && (next->type != CT_BRACE_CLOSE)) + { + newline_min_after(prev, 1 + cpd.settings[UO_nl_func_var_def_blk].n); + } + } +} + + +/** + * Handles the brace_on_func_line setting and decides if the closing brace + * of a pair should be right after a newline. + * The only cases where the closing brace shouldn't be the first thing on a line + * is where the opening brace has junk after it AND where a one-liner in a + * class is supposed to be preserved. + * + * General rule for break before close brace: + * If the brace is part of a function (call or definition) OR if the only + * thing after the opening brace is comments, the there must be a newline + * before the close brace. + * + * Example of no newline before close + * struct mystring { int len; + * char str[]; }; + * while (*(++ptr) != 0) { } + * + * Examples of newline before close + * void foo() { + * } + * + */ +static void newlines_brace_pair(chunk_t *br_open) +{ + chunk_t *prev; + chunk_t *next; + chunk_t *pc; + argval_t val = AV_IGNORE; + bool nl_close_brace = false; + + if (((br_open->flags & PCF_IN_PREPROC) != 0) && + !cpd.settings[UO_nl_define_macro].b) + { + return; + } + + if (cpd.settings[UO_nl_collapse_empty_body].b) + { + next = chunk_get_next_nnl(br_open); + if ((next != NULL) && (next->type == CT_BRACE_CLOSE)) + { + pc = chunk_get_next(br_open); + + while ((pc != NULL) && (pc->type != CT_BRACE_CLOSE)) + { + next = chunk_get_next(pc); + if (pc->type == CT_NEWLINE) + { + if (chunk_safe_to_del_nl(pc)) + { + chunk_del(pc); + } + } + pc = next; + } + return; + } + } + + /* Make sure we don't break a one-liner */ + if (!one_liner_nl_ok(br_open)) + { + return; + } + + next = chunk_get_next_nc(br_open); + + /** Insert a newline between the '=' and open brace, if needed */ + if (br_open->parent_type == CT_ASSIGN) + { + /* Only mess with it if the open brace is followed by a newline */ + if (chunk_is_newline(next)) + { + prev = chunk_get_prev_ncnl(br_open); + + newline_iarf_pair(prev, br_open, cpd.settings[UO_nl_assign_brace].a); + } + } + + /* Eat any extra newlines after the brace open */ + if (cpd.settings[UO_eat_blanks_after_open_brace].b) + { + if (chunk_is_newline(next)) + { + if (next->nl_count > 1) + { + next->nl_count = 1; + } + } + } + + /* Handle the cases where the brace is part of a function call or definition */ + if ((br_open->parent_type == CT_FUNC_DEF) || + (br_open->parent_type == CT_FUNC_CALL) || + (br_open->parent_type == CT_FUNC_CALL_USER) || + (br_open->parent_type == CT_FUNC_CLASS) || + (br_open->parent_type == CT_OC_MSG_DECL)) + { + /* Need to force a newline before the close brace, if not in a class body */ + if ((br_open->flags & PCF_IN_CLASS) == 0) + { + nl_close_brace = true; + } + + /* handle newlines after the open brace */ + pc = chunk_get_next_ncnl(br_open); + newline_add_between(br_open, pc); + + val = ((br_open->parent_type == CT_FUNC_DEF) || + (br_open->parent_type == CT_FUNC_CLASS) || + (br_open->parent_type == CT_OC_MSG_DECL)) ? + cpd.settings[UO_nl_fdef_brace].a : + cpd.settings[UO_nl_fcall_brace].a; + + if (val != AV_IGNORE) + { + /* Grab the chunk before the open brace */ + prev = chunk_get_prev_ncnl(br_open); + + newline_iarf_pair(prev, br_open, val); + } + + if (cpd.settings[UO_nl_func_var_def_blk].n > 0) + { + newline_fnc_var_def(br_open, cpd.settings[UO_nl_func_var_def_blk].n); + } + } + + /* Grab the matching brace close */ + chunk_t *br_close; + br_close = chunk_get_next_type(br_open, CT_BRACE_CLOSE, br_open->level); + if (br_close == NULL) + { + return; + } + + if (!nl_close_brace) + { + /** + * If the open brace hits a CT_NEWLINE, CT_NL_CONT, CT_COMMENT_MULTI, or + * CT_COMMENT_CPP without hitting anything other than CT_COMMENT, then + * there should be a newline before the close brace. + */ + pc = chunk_get_next(br_open); + while ((pc != NULL) && (pc->type == CT_COMMENT)) + { + pc = chunk_get_next(pc); + } + if (chunk_is_newline(pc) || chunk_is_comment(pc)) + { + nl_close_brace = true; + } + } + + prev = chunk_get_prev_nblank(br_close); + if (nl_close_brace) + { + newline_add_between(prev, br_close); + } + else + { + newline_del_between(prev, br_close); + } +} + + +/** + * Put a empty line between the 'case' statement and the previous case colon + * or semicolon. + * Does not work with PAWN (?) + */ +static void newline_case(chunk_t *start) +{ + chunk_t *pc; + chunk_t *prev = start; + + // printf("%s case (%s) on line %d col %d\n", + // __func__, c_chunk_names[start->type], + // start->orig_line, start->orig_col); + + /* Scan backwards until a '{' or ';' or ':'. Abort if a multi-newline is found */ + do + { + prev = chunk_get_prev_nc(prev); + if ((prev != NULL) && chunk_is_newline(prev) && (prev->nl_count > 1)) + { + return; + } + } while ((prev != NULL) && + (prev->type != CT_BRACE_OPEN) && + (prev->type != CT_BRACE_CLOSE) && + (prev->type != CT_SEMICOLON) && + (prev->type != CT_CASE_COLON)); + + if (prev == NULL) + { + return; + } + + pc = newline_add_between(prev, start); + if (pc == NULL) + { + return; + } + + /* Only add an extra line after a semicolon or brace close */ + if ((prev->type == CT_SEMICOLON) || + (prev->type == CT_BRACE_CLOSE)) + { + if (chunk_is_newline(pc) && (pc->nl_count < 2)) + { + double_newline(pc); + } + } +} + + +static void newline_case_colon(chunk_t *start) +{ + chunk_t *pc = start; + + /* Scan forwards until a non-comment is found */ + do + { + pc = chunk_get_next(pc); + } while (chunk_is_comment(pc)); + + if ((pc != NULL) && !chunk_is_newline(pc)) + { + newline_add_before(pc); + } +} + + +/** + * Put a empty line after a return statement, unless it is followed by a + * close brace. + * + * May not work with PAWN + */ +static void newline_return(chunk_t *start) +{ + chunk_t *pc; + chunk_t *semi; + chunk_t *after; + + semi = chunk_get_next_type(start, CT_SEMICOLON, start->level); + after = chunk_get_next_nblank(semi); + + /* If we hit a brace or an 'else', then a newline isn't needed */ + if ((after == NULL) || + (after->type == CT_BRACE_CLOSE) || + (after->type == CT_ELSE)) + { + return; + } + + for (pc = chunk_get_next(semi); pc != after; pc = chunk_get_next(pc)) + { + if (pc->type == CT_NEWLINE) + { + if (pc->nl_count < 2) + { + double_newline(pc); + } + return; + } + } +} + + +/** + * Does the Ignore, Add, Remove, or Force thing between two chunks + * + * @param before The first chunk + * @param after The second chunk + * @param av The IARF value + */ +static void newline_iarf_pair(chunk_t *before, chunk_t *after, argval_t av) +{ + if ((before != NULL) && (after != NULL)) + { + if ((av & AV_REMOVE) != 0) + { + newline_del_between(before, after); + } + + if ((av & AV_ADD) != 0) + { + newline_add_between(before, after); + } + } +} + + +/** + * Does a simple Ignore, Add, Remove, or Force after the given chunk + * + * @param pc The chunk + * @param av The IARF value + */ +void newline_iarf(chunk_t *pc, argval_t av) +{ + newline_iarf_pair(pc, chunk_get_next_nnl(pc), av); +} + + +/** + * Formats a function declaration + * Start points to the open paren + */ +static void newline_func_def(chunk_t *start) +{ + chunk_t *pc; + chunk_t *prev = NULL; + chunk_t *tmp; + + if (cpd.settings[UO_nl_func_paren].a != AV_IGNORE) + { + prev = chunk_get_prev_ncnl(start); + if (prev != NULL) + { + newline_iarf(prev, cpd.settings[UO_nl_func_paren].a); + } + } + + /* Handle break newlines type and function */ + prev = chunk_get_prev_ncnl(start); + /* Don't split up a function variable */ + prev = (prev->type == CT_PAREN_CLOSE) ? NULL : chunk_get_prev_ncnl(prev); + + if (prev != NULL) + { + if (prev->type == CT_OPERATOR) + { + tmp = prev; + prev = chunk_get_prev_ncnl(prev); + } + else + { + tmp = start; + } + if ((prev != NULL) && (prev->type == CT_DC_MEMBER)) + { + if (cpd.settings[UO_nl_func_scope_name].a != AV_IGNORE) + { + newline_iarf(prev, cpd.settings[UO_nl_func_scope_name].a); + } + } + + argval_t a = (tmp->parent_type == CT_FUNC_PROTO) ? + cpd.settings[UO_nl_func_proto_type_name].a : + cpd.settings[UO_nl_func_type_name].a; + if ((tmp->flags & PCF_IN_CLASS) && + (cpd.settings[UO_nl_func_type_name_class].a != AV_IGNORE)) + { + a = cpd.settings[UO_nl_func_type_name_class].a; + } + + if (a != AV_IGNORE) + { + /* If we are on a '::', step back two tokens + * TODO: do we also need to check for '.' ? + */ + while ((prev != NULL) && (prev->type == CT_DC_MEMBER)) + { + prev = chunk_get_prev_ncnl(prev); + prev = skip_template_prev(prev); + prev = chunk_get_prev_ncnl(prev); + } + + if ((prev != NULL) && + (prev->type != CT_BRACE_CLOSE) && + (prev->type != CT_SEMICOLON)) + { + newline_iarf(prev, a); + } + } + } + + pc = chunk_get_next_ncnl(start); + if (chunk_is_str(pc, ")", 1)) + { + if (cpd.settings[UO_nl_func_decl_empty].a != AV_IGNORE) + { + newline_iarf(start, cpd.settings[UO_nl_func_decl_empty].a); + } + return; + } + + newline_iarf(start, cpd.settings[UO_nl_func_decl_start].a); + + /* Now scan for commas */ + for (pc = chunk_get_next_ncnl(start); + (pc != NULL) && (pc->level > start->level); + pc = chunk_get_next_ncnl(pc)) + { + prev = pc; + if ((pc->type == CT_COMMA) && (pc->level == (start->level + 1))) + { + tmp = chunk_get_next(pc); + if (chunk_is_comment(tmp)) + { + pc = tmp; + } + newline_iarf(pc, cpd.settings[UO_nl_func_decl_args].a); + } + } + + /* and fix up the close paren */ + if ((prev != NULL) && (pc != NULL) && (pc->type == CT_FPAREN_CLOSE)) + { + prev = chunk_get_prev_nnl(pc); + if (prev->type != CT_FPAREN_OPEN) + { + newline_iarf(prev, cpd.settings[UO_nl_func_decl_end].a); + } + } +} + + +/** + * Checks to see if it is OK to add a newline around the chunk. + * Don't want to break one-liners... + */ +static bool one_liner_nl_ok(chunk_t *pc) +{ + LOG_FMT(LNL1LINE, "%s: check [%s] parent=[%s] flg=%x, on line %d, col %d - ", + __func__, get_token_name(pc->type), get_token_name(pc->parent_type), + pc->flags, pc->orig_line, pc->orig_col); + + if ((pc->flags & PCF_ONE_LINER) && + ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_BRACE_CLOSE))) + { + if (cpd.settings[UO_nl_class_leave_one_liners].b && + (pc->flags & PCF_IN_CLASS)) + { + LOG_FMT(LNL1LINE, "false (class)\n"); + return(false); + } + + if (cpd.settings[UO_nl_assign_leave_one_liners].b && + (pc->parent_type == CT_ASSIGN)) + { + LOG_FMT(LNL1LINE, "false (assign)\n"); + return(false); + } + + if (cpd.settings[UO_nl_enum_leave_one_liners].b && + (pc->parent_type == CT_ENUM)) + { + LOG_FMT(LNL1LINE, "false (enum)\n"); + return(false); + } + + if (cpd.settings[UO_nl_getset_leave_one_liners].b && + (pc->parent_type == CT_GETSET)) + { + LOG_FMT(LNL1LINE, "false (get/set)\n"); + return(false); + } + + if (cpd.settings[UO_nl_func_leave_one_liners].b && + (pc->parent_type == CT_FUNC_DEF)) + { + LOG_FMT(LNL1LINE, "false (func def)\n"); + return(false); + } + + if (cpd.settings[UO_nl_if_leave_one_liners].b && + ((pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE))) + { + LOG_FMT(LNL1LINE, "false (if/else)\n"); + return(false); + } + } + LOG_FMT(LNL1LINE, "true\n"); + return(true); +} + + +static void nl_create_one_liner(chunk_t *vbrace_open) +{ + chunk_t *tmp; + chunk_t *first; + + /* See if we get a newline between the next text and the vbrace_close */ + tmp = chunk_get_next_ncnl(vbrace_open); + first = tmp; + while ((tmp != NULL) && (tmp->type != CT_VBRACE_CLOSE)) + { + if (chunk_is_newline(tmp)) + { + return; + } + tmp = chunk_get_next(tmp); + } + + if (tmp != NULL) + { + newline_del_between(vbrace_open, first); + } +} + + +/** + * Step through all chunks. + */ +void newlines_cleanup_braces(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + chunk_t *tmp; + argval_t arg; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if (pc->type == CT_IF) + { + newlines_if_for_while_switch(pc, cpd.settings[UO_nl_if_brace].a); + } + else if (pc->type == CT_ELSEIF) + { + arg = cpd.settings[UO_nl_elseif_brace].a; + newlines_if_for_while_switch( + pc, (arg != AV_IGNORE) ? arg : cpd.settings[UO_nl_if_brace].a); + } + else if (pc->type == CT_FOR) + { + newlines_if_for_while_switch(pc, cpd.settings[UO_nl_for_brace].a); + } + else if (pc->type == CT_CATCH) + { + newlines_cuddle_uncuddle(pc, cpd.settings[UO_nl_brace_catch].a); + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && (next->type == CT_BRACE_OPEN)) + { + newlines_do_else(pc, cpd.settings[UO_nl_catch_brace].a); + } + else + { + newlines_if_for_while_switch(pc, cpd.settings[UO_nl_catch_brace].a); + } + } + else if (pc->type == CT_WHILE) + { + newlines_if_for_while_switch(pc, cpd.settings[UO_nl_while_brace].a); + } + else if (pc->type == CT_SWITCH) + { + newlines_if_for_while_switch(pc, cpd.settings[UO_nl_switch_brace].a); + } + else if (pc->type == CT_DO) + { + newlines_do_else(pc, cpd.settings[UO_nl_do_brace].a); + } + else if (pc->type == CT_ELSE) + { + newlines_cuddle_uncuddle(pc, cpd.settings[UO_nl_brace_else].a); + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && (next->type == CT_ELSEIF)) + { + newline_iarf_pair(pc, next, cpd.settings[UO_nl_else_if].a); + } + newlines_do_else(pc, cpd.settings[UO_nl_else_brace].a); + } + else if (pc->type == CT_TRY) + { + newlines_do_else(pc, cpd.settings[UO_nl_try_brace].a); + } + else if (pc->type == CT_GETSET) + { + newlines_do_else(pc, cpd.settings[UO_nl_getset_brace].a); + } + else if (pc->type == CT_FINALLY) + { + newlines_cuddle_uncuddle(pc, cpd.settings[UO_nl_brace_finally].a); + newlines_do_else(pc, cpd.settings[UO_nl_finally_brace].a); + } + else if (pc->type == CT_WHILE_OF_DO) + { + newlines_cuddle_uncuddle(pc, cpd.settings[UO_nl_brace_while].a); + } + else if (pc->type == CT_BRACE_OPEN) + { + if (cpd.settings[UO_nl_brace_brace].a != AV_IGNORE) + { + next = chunk_get_next_nc(pc, CNAV_PREPROC); + if ((next != NULL) && (next->type == CT_BRACE_OPEN)) + { + newline_iarf_pair(pc, next, cpd.settings[UO_nl_brace_brace].a); + } + } + + if (cpd.settings[UO_nl_ds_struct_enum_cmt].b && + ((pc->parent_type == CT_ENUM) || + (pc->parent_type == CT_STRUCT) || + (pc->parent_type == CT_UNION))) + { + newlines_double_space_struct_enum_union(pc); + } + + if ((pc->parent_type == CT_CLASS) && (pc->level == pc->brace_level)) + { + newlines_do_else(chunk_get_prev_nnl(pc), + cpd.settings[UO_nl_class_brace].a); + } + + next = chunk_get_next_nnl(pc); + if (next == NULL) + { + // do nothing + } + else if (next->type == CT_BRACE_CLOSE) + { + //TODO: add an option to split open empty statements? { }; + } + else if (next->type == CT_BRACE_OPEN) + { + // already handled + } + else + { + next = chunk_get_next_ncnl(pc); + + // Handle nl_after_brace_open + if ((pc->level == pc->brace_level) && + cpd.settings[UO_nl_after_brace_open].b) + { + if (!one_liner_nl_ok(pc)) + { + /* no change - preserve one liner body */ + } + else if ((pc->flags & (PCF_IN_ARRAY_ASSIGN | PCF_IN_PREPROC)) != 0) + { + /* no change - don't break up array assignments or preprocessors */ + } + else + { + /* Step back from next to the first non-newline item */ + tmp = chunk_get_prev(next); + while (tmp != pc) + { + if (chunk_is_comment(tmp)) + { + if (!cpd.settings[UO_nl_after_brace_open_cmt].b && + (tmp->type != CT_COMMENT_MULTI)) + { + break; + } + } + tmp = chunk_get_prev(tmp); + } + /* Add the newline */ + newline_iarf(tmp, AV_ADD); + } + } + } + + newlines_brace_pair(pc); + } + else if (pc->type == CT_BRACE_CLOSE) + { + if (cpd.settings[UO_nl_brace_brace].a != AV_IGNORE) + { + next = chunk_get_next_nc(pc, CNAV_PREPROC); + if ((next != NULL) && (next->type == CT_BRACE_CLOSE)) + { + newline_iarf_pair(pc, next, cpd.settings[UO_nl_brace_brace].a); + } + } + + if (cpd.settings[UO_eat_blanks_before_close_brace].b) + { + /* Limit the newlines before the close brace to 1 */ + prev = chunk_get_prev(pc); + if (chunk_is_newline(prev)) + { + prev->nl_count = 1; + } + } + else if (cpd.settings[UO_nl_ds_struct_enum_close_brace].b && + ((pc->parent_type == CT_ENUM) || + (pc->parent_type == CT_STRUCT) || + (pc->parent_type == CT_UNION))) + { + if ((pc->flags & PCF_ONE_LINER) == 0) + { + /* Make sure the } is preceeded by two newlines */ + prev = chunk_get_prev(pc); + if (!chunk_is_newline(prev)) + { + prev = newline_add_before(pc); + } + if (prev->nl_count < 2) + { + double_newline(prev); + } + } + } + + /* Force a newline after a function def */ + if (cpd.settings[UO_nl_after_brace_close].b || + (pc->parent_type == CT_FUNC_DEF) || + (pc->parent_type == CT_OC_MSG_DECL)) + { + next = chunk_get_next(pc); + if ((next != NULL) && + (next->type != CT_SEMICOLON) && + (next->type != CT_COMMA) && + ((pc->flags & (PCF_IN_ARRAY_ASSIGN | PCF_IN_TYPEDEF)) == 0) && + !chunk_is_newline(next) && + !chunk_is_comment(next)) + { + newline_iarf(pc, AV_ADD); + } + } + } + else if (pc->type == CT_VBRACE_OPEN) + { + if (cpd.settings[UO_nl_after_vbrace_open].b) + { + next = chunk_get_next(pc); + if ((next->type != CT_VBRACE_CLOSE) && + !chunk_is_comment(next) && + !chunk_is_newline(next)) + { + newline_iarf(pc, AV_ADD); + } + } + + if (((pc->parent_type == CT_IF) && + cpd.settings[UO_nl_create_if_one_liner].b) || + ((pc->parent_type == CT_FOR) && + cpd.settings[UO_nl_create_for_one_liner].b) || + ((pc->parent_type == CT_WHILE) && + cpd.settings[UO_nl_create_while_one_liner].b)) + { + nl_create_one_liner(pc); + } + } + else if (pc->type == CT_STRUCT) + { + newlines_struct_enum_union(pc, cpd.settings[UO_nl_struct_brace].a, true); + } + else if (pc->type == CT_UNION) + { + newlines_struct_enum_union(pc, cpd.settings[UO_nl_union_brace].a, true); + } + else if (pc->type == CT_ENUM) + { + newlines_struct_enum_union(pc, cpd.settings[UO_nl_enum_brace].a, true); + } + else if (pc->type == CT_CASE) + { + /* Note: 'default' also maps to CT_CASE */ + if (cpd.settings[UO_nl_before_case].b) + { + newline_case(pc); + } + } + else if (pc->type == CT_THROW) + { + newline_iarf(chunk_get_prev_ncnl(pc), cpd.settings[UO_nl_before_throw].a); + } + else if (pc->type == CT_CASE_COLON) + { + if (cpd.settings[UO_nl_after_case].b) + { + newline_case_colon(pc); + } + } + else if (pc->type == CT_SPAREN_CLOSE) + { + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && (next->type == CT_BRACE_OPEN)) + { + /* TODO: + * this could be used to control newlines between the + * the if/while/for/switch close paren and the open brace, but + * that is currently handled elsewhere. + */ + } + } + else if (pc->type == CT_RETURN) + { + if (cpd.settings[UO_nl_after_return].b) + { + newline_return(pc); + } + } + else if (pc->type == CT_SEMICOLON) + { + if (((pc->flags & (PCF_IN_SPAREN | PCF_IN_PREPROC)) == 0) && + cpd.settings[UO_nl_after_semicolon].b) + { + next = chunk_get_next(pc); + while ((next != NULL) && (next->type == CT_VBRACE_CLOSE)) + { + next = chunk_get_next(next); + } + if ((next != NULL) && + !chunk_is_comment(next) && + !chunk_is_newline(next)) + { + if (one_liner_nl_ok(next)) + { + newline_iarf(pc, AV_ADD); + } + } + } + } + else if (pc->type == CT_FPAREN_OPEN) + { + if (((pc->parent_type == CT_FUNC_DEF) || + (pc->parent_type == CT_FUNC_PROTO) || + (pc->parent_type == CT_FUNC_CLASS) || + (pc->parent_type == CT_OPERATOR)) + && + ((cpd.settings[UO_nl_func_decl_start].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_decl_args].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_decl_end].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_decl_empty].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_type_name].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_type_name_class].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_scope_name].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_proto_type_name].a != AV_IGNORE) || + (cpd.settings[UO_nl_func_paren].a != AV_IGNORE))) + { + newline_func_def(pc); + } + } + else if (pc->type == CT_ANGLE_CLOSE) + { + if (pc->parent_type == CT_TEMPLATE) + { + next = chunk_get_next_ncnl(pc); + if ((next != NULL) && + (next->level == next->brace_level)) + { + tmp = chunk_get_prev_ncnl(chunk_get_prev_type(pc, CT_ANGLE_OPEN, pc->level)); + if ((tmp != NULL) && (tmp->type == CT_TEMPLATE)) + { + newline_iarf(pc, cpd.settings[UO_nl_template_class].a); + } + } + } + } + else if (pc->type == CT_NAMESPACE) + { + newlines_struct_enum_union(pc, cpd.settings[UO_nl_namespace_brace].a, false); + } + else if (pc->type == CT_SQUARE_OPEN) + { + if ((pc->parent_type == CT_ASSIGN) && + ((pc->flags & PCF_ONE_LINER) == 0)) + { + tmp = chunk_get_prev_ncnl(pc); + newline_iarf(tmp, cpd.settings[UO_nl_assign_square].a); + + argval_t arg = cpd.settings[UO_nl_after_square_assign].a; + + if (cpd.settings[UO_nl_assign_square].a & AV_ADD) + { + arg = AV_ADD; + } + newline_iarf(pc, arg); + + /* if there is a newline after the open, then force a newline + * before the close */ + tmp = chunk_get_next_nc(pc); + if (chunk_is_newline(tmp)) + { + tmp = chunk_get_next_type(pc, CT_SQUARE_CLOSE, pc->level); + if (tmp != NULL) + { + newline_add_before(tmp); + } + } + } + } + else if (pc->type == CT_PRIVATE) + { + /** Make sure there is a newline before an access spec */ + if (cpd.settings[UO_nl_before_access_spec].n > 0) + { + prev = chunk_get_prev(pc); + if (!chunk_is_newline(prev)) + { + newline_add_before(pc); + } + } + } + else if (pc->type == CT_PRIVATE_COLON) + { + /** Make sure there is a newline after an access spec */ + if (cpd.settings[UO_nl_after_access_spec].n > 0) + { + next = chunk_get_next(pc); + if (!chunk_is_newline(next)) + { + newline_add_before(next); + } + } + } + else if (pc->type == CT_PP_DEFINE) + { + if (cpd.settings[UO_nl_multi_line_define].b) + { + nl_handle_define(pc); + } + } + else + { + /* ignore it */ + } + } +} + + +/** + * Find the next newline or nl_cont + */ +static void nl_handle_define(chunk_t *pc) +{ + chunk_t *nl = pc; + chunk_t *ref = NULL; + + while ((nl = chunk_get_next(nl)) != NULL) + { + if (nl->type == CT_NEWLINE) + { + return; + } + if ((nl->type == CT_MACRO) || + ((nl->type == CT_FPAREN_CLOSE) && (nl->parent_type == CT_MACRO_FUNC))) + { + ref = nl; + } + if (nl->type == CT_NL_CONT) + { + if (ref != NULL) + { + newline_add_after(ref); + } + return; + } + } +} + + +void newline_after_multiline_comment(void) +{ + chunk_t *pc; + chunk_t *tmp; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type != CT_COMMENT_MULTI) + { + continue; + } + + tmp = pc; + while (((tmp = chunk_get_next(tmp)) != NULL) && !chunk_is_newline(tmp)) + { + if (!chunk_is_comment(tmp)) + { + newline_add_before(tmp); + break; + } + } + } +} + + +/** + * Handle insertion/removal of blank lines before if/for/while/do + */ +void newlines_insert_blank_lines(void) +{ + chunk_t *pc; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if (pc->type == CT_IF) + { + newlines_if_for_while_switch_pre_blank_lines(pc, cpd.settings[UO_nl_before_if].a); + newlines_if_for_while_switch_post_blank_lines(pc, cpd.settings[UO_nl_after_if].a); + } + else if (pc->type == CT_FOR) + { + newlines_if_for_while_switch_pre_blank_lines(pc, cpd.settings[UO_nl_before_for].a); + newlines_if_for_while_switch_post_blank_lines(pc, cpd.settings[UO_nl_after_for].a); + } + else if (pc->type == CT_WHILE) + { + newlines_if_for_while_switch_pre_blank_lines(pc, cpd.settings[UO_nl_before_while].a); + newlines_if_for_while_switch_post_blank_lines(pc, cpd.settings[UO_nl_after_while].a); + } + else if (pc->type == CT_SWITCH) + { + newlines_if_for_while_switch_pre_blank_lines(pc, cpd.settings[UO_nl_before_switch].a); + newlines_if_for_while_switch_post_blank_lines(pc, cpd.settings[UO_nl_after_switch].a); + } + else if (pc->type == CT_DO) + { + newlines_if_for_while_switch_pre_blank_lines(pc, cpd.settings[UO_nl_before_do].a); + newlines_if_for_while_switch_post_blank_lines(pc, cpd.settings[UO_nl_after_do].a); + } + else + { + /* ignore it */ + } + } +} + + +void newlines_squeeze_ifdef(void) +{ + chunk_t *pc; + chunk_t *ppr; + chunk_t *pnl; + chunk_t *nnl; + chunk_t *tmp1; + chunk_t *tmp2; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if ((pc->type == CT_PREPROC) && (pc->level > 0)) + { + ppr = chunk_get_next(pc); + + if ((ppr->type == CT_PP_IF) || + (ppr->type == CT_PP_ELSE) || + (ppr->type == CT_PP_ENDIF)) + { + pnl = NULL; + nnl = chunk_get_next_nl(ppr); + if (ppr->type == CT_PP_ENDIF) + { + pnl = chunk_get_prev_nl(pc); + } + + if (nnl != NULL) + { + if (pnl != NULL) + { + if (pnl->nl_count > 1) + { + nnl->nl_count += pnl->nl_count - 1; + pnl->nl_count = 1; + + tmp1 = chunk_get_prev_nnl(pnl); + tmp2 = chunk_get_prev_nnl(nnl); + + LOG_FMT(LNEWLINE, "%s: moved from after line %d to after %d\n", + __func__, tmp1->orig_line, tmp2->orig_line); + } + } + else + { + if (nnl->nl_count > 1) + { + tmp1 = chunk_get_prev_nnl(nnl); + LOG_FMT(LNEWLINE, "%s: trimmed newlines after line %d from %d\n", + __func__, tmp1->orig_line, nnl->nl_count); + nnl->nl_count = 1; + } + } + } + } + } + } +} + + +void newlines_eat_start_end(void) +{ + chunk_t *pc; + + /* Process newlines at the start of the file */ + if (((cpd.settings[UO_nl_start_of_file].a & AV_REMOVE) != 0) || + (((cpd.settings[UO_nl_start_of_file].a & AV_ADD) != 0) && + (cpd.settings[UO_nl_start_of_file_min].n > 0))) + { + pc = chunk_get_head(); + if (pc != NULL) + { + if (pc->type == CT_NEWLINE) + { + if (cpd.settings[UO_nl_start_of_file].a == AV_REMOVE) + { + chunk_del(pc); + } + else if ((cpd.settings[UO_nl_start_of_file].a == AV_FORCE) || + (pc->nl_count < cpd.settings[UO_nl_start_of_file_min].n)) + { + pc->nl_count = cpd.settings[UO_nl_start_of_file_min].n; + } + } + else if (((cpd.settings[UO_nl_start_of_file].a & AV_ADD) != 0) && + (cpd.settings[UO_nl_start_of_file_min].n > 0)) + { + chunk_t chunk; + memset(&chunk, 0, sizeof(chunk)); + chunk.orig_line = pc->orig_line; + chunk.type = CT_NEWLINE; + chunk.nl_count = cpd.settings[UO_nl_start_of_file_min].n; + chunk_add_before(&chunk, pc); + } + } + } + + /* Process newlines at the end of the file */ + if (((cpd.settings[UO_nl_end_of_file].a & AV_REMOVE) != 0) || + (((cpd.settings[UO_nl_end_of_file].a & AV_ADD) != 0) && + (cpd.settings[UO_nl_end_of_file_min].n > 0))) + { + pc = chunk_get_tail(); + if (pc != NULL) + { + if (pc->type == CT_NEWLINE) + { + if (cpd.settings[UO_nl_end_of_file].a == AV_REMOVE) + { + chunk_del(pc); + } + else if ((cpd.settings[UO_nl_end_of_file].a == AV_FORCE) || + (pc->nl_count < cpd.settings[UO_nl_end_of_file_min].n)) + { + pc->nl_count = cpd.settings[UO_nl_end_of_file_min].n; + } + } + else if (((cpd.settings[UO_nl_end_of_file].a & AV_ADD) != 0) && + (cpd.settings[UO_nl_end_of_file_min].n > 0)) + { + chunk_t chunk; + memset(&chunk, 0, sizeof(chunk)); + chunk.orig_line = pc->orig_line; + chunk.type = CT_NEWLINE; + chunk.nl_count = cpd.settings[UO_nl_end_of_file_min].n; + chunk_add(&chunk); + } + } + } +} + + +/** + * Searches for a chunk of type chunk_type and moves them, if needed. + * Will not move tokens that are on their own line or have other than + * exactly 1 newline before (UO_pos_comma == TRAIL) or after (UO_pos_comma == LEAD). + * We can't remove a newline if it is right before a preprocessor. + */ +void newlines_chunk_pos(c_token_t chunk_type, tokenpos_e mode) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + + if (mode == TP_IGNORE) + { + return; + } + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if (pc->type == chunk_type) + { + prev = chunk_get_prev_nc(pc); + next = chunk_get_next_nc(pc); + + /* if both are newlines or neither are newlines, skip this chunk */ + if (chunk_is_newline(prev) == chunk_is_newline(next)) + { + continue; + } + + if (chunk_is_newline(next)) + { + chunk_t *next2 = chunk_get_next(next); + if ((next2 != NULL) && (next2->type == CT_PREPROC)) + { + continue; + } + } + + /*NOTE: may end up processing a chunk twice if changed */ + if (mode == TP_TRAIL) + { + if (chunk_is_newline(prev) && (prev->nl_count == 1)) + { + /* Back up to the next non-comment item */ + prev = chunk_get_prev_nc(prev); + if ((prev != NULL) && !chunk_is_newline(prev) && + !(prev->flags & PCF_IN_PREPROC)) + { + chunk_move_after(pc, prev); + } + } + } + else /* (mode == TP_LEAD) */ + { + if (chunk_is_newline(next) && (next->nl_count == 1)) + { + /* move the CT_BOOL to after the newline */ + chunk_move_after(pc, next); + } + } + } + } +} + + +/** + * Searches for CT_CLASS_COLON and moves them, if needed. + * Also breaks up the args + */ +void newlines_class_colon_pos(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + tokenpos_e mode = cpd.settings[UO_pos_class_colon].tp; + chunk_t *ccolon = NULL; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + if ((ccolon == NULL) && (pc->type != CT_CLASS_COLON)) + { + continue; + } + + if (pc->type == CT_CLASS_COLON) + { + ccolon = pc; + prev = chunk_get_prev_nc(pc); + next = chunk_get_next_nc(pc); + + if (!chunk_is_newline(prev) && !chunk_is_newline(next) && + ((cpd.settings[UO_nl_class_colon].a & AV_ADD) != 0)) + { + newline_add_after(pc); + prev = chunk_get_prev_nc(pc); + next = chunk_get_next_nc(pc); + } + + if (cpd.settings[UO_nl_class_colon].a == AV_REMOVE) + { + if (chunk_is_newline(prev) && + chunk_safe_to_del_nl(prev)) + { + chunk_del(prev); + prev = chunk_get_prev_nc(pc); + } + if (chunk_is_newline(next) && + chunk_safe_to_del_nl(next)) + { + chunk_del(next); + next = chunk_get_next_nc(pc); + } + } + + if (mode == TP_TRAIL) + { + if (chunk_is_newline(prev) && (prev->nl_count == 1) && + chunk_safe_to_del_nl(prev)) + { + chunk_swap(pc, prev); + } + } + else if (mode == TP_LEAD) + { + if (chunk_is_newline(next) && (next->nl_count == 1) && + chunk_safe_to_del_nl(next)) + { + chunk_swap(pc, next); + } + } + } + else + { + if ((pc->type == CT_BRACE_OPEN) || (pc->type == CT_SEMICOLON)) + { + ccolon = NULL; + continue; + } + + if ((pc->type == CT_COMMA) && (pc->level == ccolon->level)) + { + if ((cpd.settings[UO_nl_class_init_args].a & AV_ADD) != 0) + { + if (cpd.settings[UO_pos_class_comma].tp == TP_TRAIL) + { + newline_add_after(pc); + } + else if (cpd.settings[UO_pos_class_comma].tp == TP_LEAD) + { + newline_add_before(pc); + next = chunk_get_next_nc(pc); + if (chunk_is_newline(next) && chunk_safe_to_del_nl(next)) + { + chunk_del(next); + } + } + } + else if (cpd.settings[UO_nl_class_init_args].a == AV_REMOVE) + { + next = chunk_get_next(pc); + if (chunk_is_newline(next) && chunk_safe_to_del_nl(next)) + { + chunk_del(next); + } + } + } + } + } +} + + +/** + * Scans for newline tokens and limits the nl_count. + * A newline token has a minimum nl_count of 1. + * Note that a blank line is actually 2 newlines, unless the newline is the + * first chunk. But we don't handle the first chunk. + * So, most comparisons have +1 below. + */ +void do_blank_lines(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + chunk_t *pcmt; + + /* Don't process the first token, as we don't care if it is a newline */ + pc = chunk_get_head(); + + while ((pc = chunk_get_next(pc)) != NULL) + { + if (pc->type != CT_NEWLINE) + { + continue; + } + + next = chunk_get_next(pc); + prev = chunk_get_prev_nc(pc); + pcmt = chunk_get_prev(pc); + + /* Limit consecutive newlines */ + if ((cpd.settings[UO_nl_max].n > 0) && + (pc->nl_count > (cpd.settings[UO_nl_max].n))) + { + pc->nl_count = cpd.settings[UO_nl_max].n; + } + + /** Control blanks before multi-line comments */ + if ((cpd.settings[UO_nl_before_block_comment].n > pc->nl_count) && + (next != NULL) && + (next->type == CT_COMMENT_MULTI)) + { + /* Don't add blanks after a open brace */ + if ((prev == NULL) || + ((prev->type != CT_BRACE_OPEN) && + (prev->type != CT_VBRACE_OPEN))) + { + LOG_FMT(LCMTNL, "%s: NL-MLCommentC: line %d\n", __func__, next->orig_line); + pc->nl_count = cpd.settings[UO_nl_before_block_comment].n; + } + } + + /** Control blanks before single line C comments */ + if ((cpd.settings[UO_nl_before_c_comment].n > pc->nl_count) && + (next != NULL) && + (next->type == CT_COMMENT)) + { + /* Don't add blanks after a open brace */ + if ((prev == NULL) || + ((prev->type != CT_BRACE_OPEN) && + (prev->type != CT_VBRACE_OPEN) && + (pcmt->type != CT_COMMENT))) + { + LOG_FMT(LCMTNL, "%s: NL-CommentC: line %d\n", __func__, next->orig_line); + pc->nl_count = cpd.settings[UO_nl_before_c_comment].n; + } + } + + /** Control blanks before CPP comments */ + if ((cpd.settings[UO_nl_before_cpp_comment].n > pc->nl_count) && + (next != NULL) && + (next->type == CT_COMMENT_CPP)) + { + /* Don't add blanks after a open brace */ + if ((prev == NULL) || + ((prev->type != CT_BRACE_OPEN) && + (prev->type != CT_VBRACE_OPEN) && + (pcmt->type != CT_COMMENT_CPP))) + { + LOG_FMT(LCMTNL, "%s: NL-CommentCPP: line %d\n", __func__, next->orig_line); + pc->nl_count = cpd.settings[UO_nl_before_cpp_comment].n; + } + } + + /** Control blanks before an access spec */ + if ((cpd.settings[UO_nl_before_access_spec].n > 0) && + (cpd.settings[UO_nl_before_access_spec].n != pc->nl_count) && + (next != NULL) && + (next->type == CT_PRIVATE)) + { + /* Don't add blanks after a open brace */ + if ((prev == NULL) || + ((prev->type != CT_BRACE_OPEN) && + (prev->type != CT_VBRACE_OPEN))) + { + LOG_FMT(LCMTNL, "%s: NL-BeforePrivate: line %d\n", __func__, next->orig_line); + pc->nl_count = cpd.settings[UO_nl_before_access_spec].n; + } + } + + /** Control blanks after an access spec */ + if ((cpd.settings[UO_nl_after_access_spec].n > 0) && + (cpd.settings[UO_nl_after_access_spec].n != pc->nl_count) && + (prev != NULL) && + (prev->type == CT_PRIVATE_COLON)) + { + LOG_FMT(LCMTNL, "%s: NL-AfterPrivate: line %d\n", __func__, prev->orig_line); + pc->nl_count = cpd.settings[UO_nl_after_access_spec].n; + } + + /* Add blanks after function bodies */ + if ((prev != NULL) && (prev->type == CT_BRACE_CLOSE) && + ((prev->parent_type == CT_FUNC_DEF) || + (prev->parent_type == CT_FUNC_CLASS) || + (prev->parent_type == CT_OC_MSG_DECL) || + (prev->parent_type == CT_ASSIGN))) + { + if (prev->flags & PCF_ONE_LINER) + { + if (cpd.settings[UO_nl_after_func_body_one_liner].n > pc->nl_count) + { + pc->nl_count = cpd.settings[UO_nl_after_func_body_one_liner].n; + } + } + else + { + if ((cpd.settings[UO_nl_after_func_body].n > 0) && + (cpd.settings[UO_nl_after_func_body].n != pc->nl_count)) + { + pc->nl_count = cpd.settings[UO_nl_after_func_body].n; + } + } + } + + /* Add blanks after function prototypes */ + if ((prev != NULL) && + (prev->type == CT_SEMICOLON) && + (prev->parent_type == CT_FUNC_PROTO)) + { + if (cpd.settings[UO_nl_after_func_proto].n > pc->nl_count) + { + pc->nl_count = cpd.settings[UO_nl_after_func_proto].n; + } + if ((cpd.settings[UO_nl_after_func_proto_group].n > pc->nl_count) && + (next != NULL) && + (next->parent_type != CT_FUNC_PROTO) && + can_increase_nl(pc)) + { + pc->nl_count = cpd.settings[UO_nl_after_func_proto_group].n; + } + } + + /* Change blanks between a function comment and body */ + if ((cpd.settings[UO_nl_comment_func_def].n != 0) && + chunk_is_comment(pcmt) && + (next != NULL) && (next->parent_type == CT_FUNC_DEF)) + { + if (cpd.settings[UO_nl_comment_func_def].n != pc->nl_count) + { + LOG_FMT(LCMTNL, "%s: nl_comment_func_def affected line %d\n", __func__, pc->orig_line); + pc->nl_count = cpd.settings[UO_nl_comment_func_def].n; + } + } + + /* Change blanks after a try-catch-finally block */ + if ((cpd.settings[UO_nl_after_try_catch_finally].n != 0) && + (cpd.settings[UO_nl_after_try_catch_finally].n != pc->nl_count) && + (prev != NULL) && (next != NULL)) + { + if ((prev->type == CT_BRACE_CLOSE) && + ((prev->parent_type == CT_CATCH) || + (prev->parent_type == CT_FINALLY))) + { + if ((next->type != CT_BRACE_CLOSE) && + (next->type != CT_CATCH) && + (next->type != CT_FINALLY)) + { + pc->nl_count = cpd.settings[UO_nl_after_try_catch_finally].n; + } + } + } + + /* Change blanks after a try-catch-finally block */ + if ((cpd.settings[UO_nl_between_get_set].n != 0) && + (cpd.settings[UO_nl_between_get_set].n != pc->nl_count) && + (prev != NULL) && (next != NULL)) + { + if ((prev->parent_type == CT_GETSET) && + (next->type != CT_BRACE_CLOSE) && + ((prev->type == CT_BRACE_CLOSE) || + (prev->type == CT_SEMICOLON))) + { + pc->nl_count = cpd.settings[UO_nl_between_get_set].n; + } + } + + /* Change blanks after a try-catch-finally block */ + if ((cpd.settings[UO_nl_around_cs_property].n != 0) && + (cpd.settings[UO_nl_around_cs_property].n != pc->nl_count) && + (prev != NULL) && (next != NULL)) + { + if ((prev->type == CT_BRACE_CLOSE) && + (prev->parent_type == CT_CS_PROPERTY) && + (next->type != CT_BRACE_CLOSE)) + { + pc->nl_count = cpd.settings[UO_nl_around_cs_property].n; + } + else if ((next->parent_type == CT_CS_PROPERTY) && + (next->flags & PCF_STMT_START)) + { + pc->nl_count = cpd.settings[UO_nl_around_cs_property].n; + } + } + } +} + + +void newlines_cleanup_dup(void) +{ + chunk_t *pc; + chunk_t *next; + + pc = chunk_get_head(); + next = pc; + + while (pc != NULL) + { + next = chunk_get_next(next); + if ((next != NULL) && + (pc->type == CT_NEWLINE) && + (next->type == CT_NEWLINE)) + { + chunk_del(pc); + } + pc = next; + } +} + + +/** + * Make sure there is a blank line after a commented group of values + */ +static void newlines_double_space_struct_enum_union(chunk_t *open_brace) +{ + chunk_t *pc = open_brace; + chunk_t *prev; + + while (((pc = chunk_get_next_nc(pc)) != NULL) && + (pc->level > open_brace->level)) + { + if ((pc->level != (open_brace->level + 1)) || + (pc->type != CT_NEWLINE)) + { + continue; + } + + /* If the newline is NOT after a comment or a brace open and + * it is before a comment, then make sure that the newline is + * at least doubled + */ + prev = chunk_get_prev(pc); + if (!chunk_is_comment(prev) && + (prev->type != CT_BRACE_OPEN) && + chunk_is_comment(chunk_get_next(pc))) + { + if (pc->nl_count < 2) + { + double_newline(pc); + } + } + } +} diff --git a/src/options.cpp b/src/options.cpp new file mode 100644 index 0000000000..76417e7724 --- /dev/null +++ b/src/options.cpp @@ -0,0 +1,1742 @@ +/** + * @file options.cpp + * Parses the options from the config file. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "args.h" +#include "prototypes.h" +#include "uncrustify_version.h" +#include +#ifdef HAVE_STRINGS_H +#include /* strcasecmp() */ +#endif +#include +#include +#include +#include "unc_ctype.h" + + +static std::map option_name_map; +static std::map group_map; +static uncrustify_groups current_group; + + +static void unc_add_option(const char *name, + uncrustify_options id, + argtype_e type, + const char *short_desc = NULL, + const char *long_desc = NULL, + int min_val = 0, + int max_val = 16); + + +void unc_begin_group(uncrustify_groups id, const char *short_desc, + const char *long_desc) +{ + current_group = id; + + group_map_value value; + + value.id = id; + value.short_desc = short_desc; + value.long_desc = long_desc; + + group_map[id] = value; +} + + +void unc_add_option(const char *name, uncrustify_options id, argtype_e type, + const char *short_desc, const char *long_desc, + int min_val, int max_val) +{ + group_map[current_group].options.push_back(id); + + option_map_value value; + + value.id = id; + value.group_id = current_group; + value.type = type; + value.name = name; + value.short_desc = short_desc; + value.long_desc = long_desc; + value.min_val = 0; + + /* Calculate the max/min values */ + switch (type) + { + case AT_BOOL: + value.max_val = 1; + break; + + case AT_IARF: + value.max_val = 3; + break; + + case AT_NUM: + value.min_val = min_val; + value.max_val = max_val; + break; + + case AT_LINE: + value.max_val = 3; + break; + + case AT_POS: + value.max_val = 2; + break; + + case AT_STRING: + value.max_val = 0; + break; + + default: + fprintf(stderr, "FATAL: Illegal option type %d for '%s'\n", type, name); + exit(EXIT_FAILURE); + } + + option_name_map[name] = value; + + int name_len = strlen(name); + if (name_len > cpd.max_option_name_len) + { + cpd.max_option_name_len = name_len; + } +} + + +const option_map_value *unc_find_option(const char *name) +{ + if (option_name_map.find(name) == option_name_map.end()) + { + return(NULL); + } + return(&option_name_map[name]); +} + + +void register_options(void) +{ + unc_begin_group(UG_general, "General options"); + unc_add_option("newlines", UO_newlines, AT_LINE, + "The type of line endings"); + unc_add_option("input_tab_size", UO_input_tab_size, AT_NUM, + "The original size of tabs in the input", "", 1, 32); + unc_add_option("output_tab_size", UO_output_tab_size, AT_NUM, + "The size of tabs in the output (only used if align_with_tabs=true)", "", 1, 32); + unc_add_option("string_escape_char", UO_string_escape_char, AT_NUM, + "The ASCII value of the string escape char, usually 92 (\\) or 94 (^). (Pawn)", "", 0, 255); + unc_add_option("string_escape_char2", UO_string_escape_char2, AT_NUM, + "Alternate string escape char for Pawn. Only works right before the quote char.", "", 0, 255); + + unc_begin_group(UG_space, "Spacing options"); + unc_add_option("sp_arith", UO_sp_arith, AT_IARF, + "Add or remove space around arithmetic operator '+', '-', '/', '*', etc"); + unc_add_option("sp_assign", UO_sp_assign, AT_IARF, + "Add or remove space around assignment operator '=', '+=', etc"); + unc_add_option("sp_before_assign", UO_sp_before_assign, AT_IARF, + "Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign."); + unc_add_option("sp_after_assign", UO_sp_after_assign, AT_IARF, + "Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign."); + unc_add_option("sp_enum_assign", UO_sp_enum_assign, AT_IARF, + "Add or remove space around assignment '=' in enum"); + unc_add_option("sp_enum_before_assign", UO_sp_enum_before_assign, AT_IARF, + "Add or remove space before assignment '=' in enum. Overrides sp_enum_assign."); + unc_add_option("sp_enum_after_assign", UO_sp_enum_after_assign, AT_IARF, + "Add or remove space after assignment '=' in enum. Overrides sp_enum_assign."); + unc_add_option("sp_pp_concat", UO_sp_pp_concat, AT_IARF, + "Add or remove space around preprocessor '##' concatenation operator. Default=Add"); + unc_add_option("sp_pp_stringify", UO_sp_pp_stringify, AT_IARF, + "Add or remove space after preprocessor '#' stringify operator. Default=Add"); + unc_add_option("sp_bool", UO_sp_bool, AT_IARF, + "Add or remove space around boolean operators '&&' and '||'"); + unc_add_option("sp_compare", UO_sp_compare, AT_IARF, + "Add or remove space around compare operator '<', '>', '==', etc"); + unc_add_option("sp_inside_paren", UO_sp_inside_paren, AT_IARF, + "Add or remove space inside '(' and ')'"); + unc_add_option("sp_paren_paren", UO_sp_paren_paren, AT_IARF, + "Add or remove space between nested parens"); + unc_add_option("sp_balance_nested_parens", UO_sp_balance_nested_parens, AT_BOOL, + "Whether to balance spaces inside nested parens"); + unc_add_option("sp_paren_brace", UO_sp_paren_brace, AT_IARF, + "Add or remove space between ')' and '{'"); + unc_add_option("sp_before_ptr_star", UO_sp_before_ptr_star, AT_IARF, + "Add or remove space before pointer star '*'"); + unc_add_option("sp_before_unnamed_ptr_star", UO_sp_before_unnamed_ptr_star, AT_IARF, + "Add or remove space before pointer star '*' that isn't followed by a variable name\n" + "If set to 'ignore', sp_before_ptr_star is used instead."); + unc_add_option("sp_between_ptr_star", UO_sp_between_ptr_star, AT_IARF, + "Add or remove space between pointer stars '*'"); + unc_add_option("sp_after_ptr_star", UO_sp_after_ptr_star, AT_IARF, + "Add or remove space after pointer star '*', if followed by a word."); + unc_add_option("sp_after_ptr_star_func", UO_sp_after_ptr_star_func, AT_IARF, + "Add or remove space after a pointer star '*', if followed by a func proto/def."); + unc_add_option("sp_before_ptr_star_func", UO_sp_before_ptr_star_func, AT_IARF, + "Add or remove space before a pointer star '*', if followed by a func proto/def."); + unc_add_option("sp_before_byref", UO_sp_before_byref, AT_IARF, + "Add or remove space before a reference sign '&'"); + unc_add_option("sp_before_unnamed_byref", UO_sp_before_unnamed_byref, AT_IARF, + "Add or remove space before a reference sign '&' that isn't followed by a variable name\n" + "If set to 'ignore', sp_before_byref is used instead."); + unc_add_option("sp_after_byref", UO_sp_after_byref, AT_IARF, + "Add or remove space after reference sign '&', if followed by a word."); + unc_add_option("sp_after_byref_func", UO_sp_after_byref_func, AT_IARF, + "Add or remove space after a reference sign '&', if followed by a func proto/def."); + unc_add_option("sp_before_byref_func", UO_sp_before_byref_func, AT_IARF, + "Add or remove space before a reference sign '&', if followed by a func proto/def."); + unc_add_option("sp_after_type", UO_sp_after_type, AT_IARF, + "Add or remove space between type and word. Default=Force"); + unc_add_option("sp_template_angle", UO_sp_template_angle, AT_IARF, + "Add or remove space in 'template <' vs 'template<'.\n" + "If set to ignore, sp_before_angle is used."); + unc_add_option("sp_before_angle", UO_sp_before_angle, AT_IARF, + "Add or remove space before '<>'"); + unc_add_option("sp_inside_angle", UO_sp_inside_angle, AT_IARF, + "Add or remove space inside '<' and '>'"); + unc_add_option("sp_after_angle", UO_sp_after_angle, AT_IARF, + "Add or remove space after '<>'"); + unc_add_option("sp_angle_paren", UO_sp_angle_paren, AT_IARF, + "Add or remove space between '<>' and '(' as found in 'new List();'"); + unc_add_option("sp_angle_word", UO_sp_angle_word, AT_IARF, + "Add or remove space between '<>' and a word as in 'List m;'"); + unc_add_option("sp_before_sparen", UO_sp_before_sparen, AT_IARF, + "Add or remove space before '(' of 'if', 'for', 'switch', and 'while'"); + unc_add_option("sp_inside_sparen", UO_sp_inside_sparen, AT_IARF, + "Add or remove space inside if-condition '(' and ')'"); + unc_add_option("sp_inside_sparen_close", UO_sp_inside_sparen_close, AT_IARF, + "Add or remove space before if-condition ')'. Overrides sp_inside_sparen."); + unc_add_option("sp_after_sparen", UO_sp_after_sparen, AT_IARF, + "Add or remove space after ')' of 'if', 'for', 'switch', and 'while'"); + unc_add_option("sp_sparen_brace", UO_sp_sparen_brace, AT_IARF, + "Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while'"); + unc_add_option("sp_invariant_paren", UO_sp_invariant_paren, AT_IARF, + "Add or remove space between 'invariant' and '(' in the D language."); + unc_add_option("sp_after_invariant_paren", UO_sp_after_invariant_paren, AT_IARF, + "Add or remove space after the ')' in 'invariant (C) c' in the D language."); + unc_add_option("sp_special_semi", UO_sp_special_semi, AT_IARF, + "Add or remove space before empty statement ';' on 'if', 'for' and 'while'"); + unc_add_option("sp_before_semi", UO_sp_before_semi, AT_IARF, + "Add or remove space before ';'. Default=Remove"); + unc_add_option("sp_before_semi_for", UO_sp_before_semi_for, AT_IARF, + "Add or remove space before ';' in non-empty 'for' statements"); + unc_add_option("sp_before_semi_for_empty", UO_sp_before_semi_for_empty, AT_IARF, + "Add or remove space before a semicolon of an empty part of a for statement."); + unc_add_option("sp_after_semi", UO_sp_after_semi, AT_IARF, + "Add or remove space after ';', except when followed by a comment. Default=Add"); + unc_add_option("sp_after_semi_for", UO_sp_after_semi_for, AT_IARF, + "Add or remove space after ';' in non-empty 'for' statements. Default=Force"); + unc_add_option("sp_after_semi_for_empty", UO_sp_after_semi_for_empty, AT_IARF, + "Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; )."); + unc_add_option("sp_before_square", UO_sp_before_square, AT_IARF, + "Add or remove space before '[' (except '[]')"); + unc_add_option("sp_before_squares", UO_sp_before_squares, AT_IARF, + "Add or remove space before '[]'"); + unc_add_option("sp_inside_square", UO_sp_inside_square, AT_IARF, + "Add or remove space inside '[' and ']'"); + unc_add_option("sp_after_comma", UO_sp_after_comma, AT_IARF, + "Add or remove space after ','"); + unc_add_option("sp_before_comma", UO_sp_before_comma, AT_IARF, + "Add or remove space before ','"); + unc_add_option("sp_before_ellipsis", UO_sp_before_ellipsis, AT_IARF, + "Add or remove space before the variadic '...'"); + unc_add_option("sp_after_class_colon", UO_sp_after_class_colon, AT_IARF, + "Add or remove space after class ':'"); + unc_add_option("sp_before_class_colon", UO_sp_before_class_colon, AT_IARF, + "Add or remove space before class ':'"); + unc_add_option("sp_before_case_colon", UO_sp_before_case_colon, AT_IARF, + "Add or remove space before case ':'. Default=Remove"); + unc_add_option("sp_after_operator", UO_sp_after_operator, AT_IARF, + "Add or remove space between 'operator' and operator sign"); + unc_add_option("sp_after_operator_sym", UO_sp_after_operator_sym, AT_IARF, + "Add or remove space between the operator symbol and the open paren, as in 'operator ++('"); + unc_add_option("sp_after_cast", UO_sp_after_cast, AT_IARF, + "Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a'"); + unc_add_option("sp_inside_paren_cast", UO_sp_inside_paren_cast, AT_IARF, + "Add or remove spaces inside cast parens"); + unc_add_option("sp_cpp_cast_paren", UO_sp_cpp_cast_paren, AT_IARF, + "Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)'"); + unc_add_option("sp_sizeof_paren", UO_sp_sizeof_paren, AT_IARF, + "Add or remove space between 'sizeof' and '('"); + unc_add_option("sp_after_tag", UO_sp_after_tag, AT_IARF, + "Add or remove space after the tag keyword (Pawn)"); + unc_add_option("sp_inside_braces_enum", UO_sp_inside_braces_enum, AT_IARF, + "Add or remove space inside enum '{' and '}'"); + unc_add_option("sp_inside_braces_struct", UO_sp_inside_braces_struct, AT_IARF, + "Add or remove space inside struct/union '{' and '}'"); + unc_add_option("sp_inside_braces", UO_sp_inside_braces, AT_IARF, + "Add or remove space inside '{' and '}'"); + unc_add_option("sp_inside_braces_empty", UO_sp_inside_braces_empty, AT_IARF, + "Add or remove space inside '{}'"); + unc_add_option("sp_type_func", UO_sp_type_func, AT_IARF, + "Add or remove space between return type and function name\n" + "A minimum of 1 is forced except for pointer return types."); + unc_add_option("sp_func_proto_paren", UO_sp_func_proto_paren, AT_IARF, + "Add or remove space between function name and '(' on function declaration"); + unc_add_option("sp_func_def_paren", UO_sp_func_def_paren, AT_IARF, + "Add or remove space between function name and '(' on function definition"); + unc_add_option("sp_inside_fparens", UO_sp_inside_fparens, AT_IARF, + "Add or remove space inside empty function '()'"); + unc_add_option("sp_inside_fparen", UO_sp_inside_fparen, AT_IARF, + "Add or remove space inside function '(' and ')'"); + unc_add_option("sp_square_fparen", UO_sp_square_fparen, AT_IARF, + "Add or remove space between ']' and '(' when part of a function call."); + unc_add_option("sp_fparen_brace", UO_sp_fparen_brace, AT_IARF, + "Add or remove space between ')' and '{' of function"); + unc_add_option("sp_func_call_paren", UO_sp_func_call_paren, AT_IARF, + "Add or remove space between function name and '(' on function calls"); + unc_add_option("sp_func_call_user_paren", UO_sp_func_call_user_paren, AT_IARF, + "Add or remove space between the user function name and '(' on function calls\n" + "You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file."); + unc_add_option("sp_func_class_paren", UO_sp_func_class_paren, AT_IARF, + "Add or remove space between a constructor/destructor and the open paren"); + unc_add_option("sp_return_paren", UO_sp_return_paren, AT_IARF, + "Add or remove space between 'return' and '('"); + unc_add_option("sp_attribute_paren", UO_sp_attribute_paren, AT_IARF, + "Add or remove space between '__attribute__' and '('"); + unc_add_option("sp_defined_paren", UO_sp_defined_paren, AT_IARF, + "Add or remove space between 'defined' and '(' in '#if defined (FOO)'"); + unc_add_option("sp_throw_paren", UO_sp_throw_paren, AT_IARF, + "Add or remove space between 'throw' and '(' in 'throw (something)'"); + unc_add_option("sp_macro", UO_sp_macro, AT_IARF, + "Add or remove space between macro and value"); + unc_add_option("sp_macro_func", UO_sp_macro_func, AT_IARF, + "Add or remove space between macro function ')' and value"); + unc_add_option("sp_else_brace", UO_sp_else_brace, AT_IARF, + "Add or remove space between 'else' and '{' if on the same line"); + unc_add_option("sp_brace_else", UO_sp_brace_else, AT_IARF, + "Add or remove space between '}' and 'else' if on the same line"); + unc_add_option("sp_brace_typedef", UO_sp_brace_typedef, AT_IARF, + "Add or remove space between '}' and the name of a typedef on the same line"); + unc_add_option("sp_catch_brace", UO_sp_catch_brace, AT_IARF, + "Add or remove space between 'catch' and '{' if on the same line"); + unc_add_option("sp_brace_catch", UO_sp_brace_catch, AT_IARF, + "Add or remove space between '}' and 'catch' if on the same line"); + unc_add_option("sp_finally_brace", UO_sp_finally_brace, AT_IARF, + "Add or remove space between 'finally' and '{' if on the same line"); + unc_add_option("sp_brace_finally", UO_sp_brace_finally, AT_IARF, + "Add or remove space between '}' and 'finally' if on the same line"); + unc_add_option("sp_try_brace", UO_sp_try_brace, AT_IARF, + "Add or remove space between 'try' and '{' if on the same line"); + unc_add_option("sp_getset_brace", UO_sp_getset_brace, AT_IARF, + "Add or remove space between get/set and '{' if on the same line"); + unc_add_option("sp_before_dc", UO_sp_before_dc, AT_IARF, + "Add or remove space before the '::' operator"); + unc_add_option("sp_after_dc", UO_sp_after_dc, AT_IARF, + "Add or remove space after the '::' operator"); + unc_add_option("sp_d_array_colon", UO_sp_d_array_colon, AT_IARF, + "Add or remove around the D named array initializer ':' operator"); + unc_add_option("sp_not", UO_sp_not, AT_IARF, + "Add or remove space after the '!' (not) operator. Default=Remove"); + unc_add_option("sp_inv", UO_sp_inv, AT_IARF, + "Add or remove space after the '~' (invert) operator. Default=Remove"); + unc_add_option("sp_addr", UO_sp_addr, AT_IARF, + "Add or remove space after the '&' (address-of) operator. Default=Remove\n" + "This does not affect the spacing after a '&' that is part of a type."); + unc_add_option("sp_member", UO_sp_member, AT_IARF, + "Add or remove space around the '.' or '->' operators. Default=Remove"); + unc_add_option("sp_deref", UO_sp_deref, AT_IARF, + "Add or remove space after the '*' (dereference) operator. Default=Remove\n" + "This does not affect the spacing after a '*' that is part of a type."); + unc_add_option("sp_sign", UO_sp_sign, AT_IARF, + "Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove"); + unc_add_option("sp_incdec", UO_sp_incdec, AT_IARF, + "Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove"); + + unc_add_option("sp_before_nl_cont", UO_sp_before_nl_cont, AT_IARF, + "Add or remove space before a backslash-newline at the end of a line. Default=Add"); + + unc_add_option("sp_after_oc_scope", UO_sp_after_oc_scope, AT_IARF, + "Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;'"); + unc_add_option("sp_after_oc_colon", UO_sp_after_oc_colon, AT_IARF, + "Add or remove space after the colon in message specs\n" + "'-(int) f:(int) x;' vs '-(int) f: (int) x;'"); + unc_add_option("sp_before_oc_colon", UO_sp_before_oc_colon, AT_IARF, + "Add or remove space before the colon in message specs\n" + "'-(int) f: (int) x;' vs '-(int) f : (int) x;'"); + unc_add_option("sp_after_send_oc_colon", UO_sp_after_send_oc_colon, AT_IARF, + "Add or remove space after the colon in message specs\n" + "'[object setValue:1];' vs '[object setValue: 1];'"); + unc_add_option("sp_before_send_oc_colon", UO_sp_before_send_oc_colon, AT_IARF, + "Add or remove space before the colon in message specs\n" + "'[object setValue:1];' vs '[object setValue :1];'"); + unc_add_option("sp_after_oc_type", UO_sp_after_oc_type, AT_IARF, + "Add or remove space after the (type) in message specs\n" + "'-(int)f: (int) x;' vs '-(int)f: (int)x;'"); + unc_add_option("sp_after_oc_return_type", UO_sp_after_oc_return_type, AT_IARF, + "Add or remove space after the first (type) in message specs\n" + "'-(int) f:(int)x;' vs '-(int)f:(int)x;'"); + unc_add_option("sp_after_oc_at_sel", UO_sp_after_oc_at_sel, AT_IARF, + "Add or remove space between '@selector' and '('\n" + "'@selector(msgName).' vs '@selector (msgName)'"); + + unc_add_option("sp_cond_colon", UO_sp_cond_colon, AT_IARF, + "Add or remove space around the ':' in 'b ? t : f'"); + unc_add_option("sp_cond_question", UO_sp_cond_question, AT_IARF, + "Add or remove space around the '?' in 'b ? t : f'"); + unc_add_option("sp_case_label", UO_sp_case_label, AT_IARF, + "Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here."); + unc_add_option("sp_range", UO_sp_range, AT_IARF, + "Control the space around the D '..' operator."); + + unc_add_option("sp_cmt_cpp_start", UO_sp_cmt_cpp_start, AT_IARF, + "Control the space after the opening of a C++ comment '// A' vs '//A'"); + + unc_begin_group(UG_indent, "Indenting"); + unc_add_option("indent_columns", UO_indent_columns, AT_NUM, + "The number of columns to indent per level.\n" + "Usually 2, 3, 4, or 8."); + unc_add_option("indent_with_tabs", UO_indent_with_tabs, AT_NUM, + "How to use tabs when indenting code\n" + "0=spaces only\n" + "1=indent with tabs, align with spaces\n" + "2=indent and align with tabs", "", 0, 2); + unc_add_option("indent_align_string", UO_indent_align_string, AT_BOOL, + "Whether to indent strings broken by '\\' so that they line up"); + unc_add_option("indent_xml_string", UO_indent_xml_string, AT_NUM, + "The number of spaces to indent multi-line XML strings.\n" + "Requires indent_align_string=True"); + unc_add_option("indent_brace", UO_indent_brace, AT_NUM, + "Spaces to indent '{' from level"); + unc_add_option("indent_braces", UO_indent_braces, AT_BOOL, + "Whether braces are indented to the body level"); + unc_add_option("indent_braces_no_func", UO_indent_braces_no_func, AT_BOOL, + "Disabled indenting function braces if indent_braces is true"); + unc_add_option("indent_brace_parent", UO_indent_brace_parent, AT_BOOL, + "Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc."); + unc_add_option("indent_namespace", UO_indent_namespace, AT_BOOL, + "Whether the 'namespace' body is indented"); + unc_add_option("indent_namespace_level", UO_indent_namespace_level, AT_NUM, + "The number of spaces to indent a namespace block"); + unc_add_option("indent_namespace_limit", UO_indent_namespace_limit, AT_NUM, + "If the body of the namespace is longer than this number, it won't be indented.\n" + "Requires indent_namespace=true. Default=0 (no limit)", NULL, 0, 255); + unc_add_option("indent_extern", UO_indent_extern, AT_BOOL, + "Whether the 'extern \"C\"' body is indented"); + unc_add_option("indent_class", UO_indent_class, AT_BOOL, + "Whether the 'class' body is indented"); + unc_add_option("indent_class_colon", UO_indent_class_colon, AT_BOOL, + "Whether to indent the stuff after a leading class colon"); + unc_add_option("indent_else_if", UO_indent_else_if, AT_BOOL, + "False=treat 'else\\nif' as 'else if' for indenting purposes\n" + "True=indent the 'if' one level\n"); + unc_add_option("indent_var_def_blk", UO_indent_var_def_blk, AT_NUM, + "Amount to indent variable declarations after a open brace. neg=relative, pos=absolute"); + + unc_add_option("indent_func_call_param", UO_indent_func_call_param, AT_BOOL, + "True: indent continued function call parameters one indent level\n" + "False: align parameters under the open paren"); + unc_add_option("indent_func_def_param", UO_indent_func_def_param, AT_BOOL, + "Same as indent_func_call_param, but for function defs"); + unc_add_option("indent_func_proto_param", UO_indent_func_proto_param, AT_BOOL, + "Same as indent_func_call_param, but for function protos"); + unc_add_option("indent_func_class_param", UO_indent_func_class_param, AT_BOOL, + "Same as indent_func_call_param, but for class declarations"); + unc_add_option("indent_func_ctor_var_param", UO_indent_func_ctor_var_param, AT_BOOL, + "Same as indent_func_call_param, but for class variable constructors"); + unc_add_option("indent_template_param", UO_indent_template_param, AT_BOOL, + "Same as indent_func_call_param, but for templates"); + unc_add_option("indent_func_param_double", UO_indent_func_param_double, AT_BOOL, + "Double the indent for indent_func_xxx_param options"); + + unc_add_option("indent_func_const", UO_indent_func_const, AT_NUM, + "Indentation column for standalone 'const' function decl/proto qualifier"); + unc_add_option("indent_func_throw", UO_indent_func_throw, AT_NUM, + "Indentation column for standalone 'throw' function decl/proto qualifier"); + + unc_add_option("indent_member", UO_indent_member, AT_NUM, + "The number of spaces to indent a continued '->' or '.'\n" + "Usually set to 0, 1, or indent_columns."); + unc_add_option("indent_sing_line_comments", UO_indent_sing_line_comments, AT_NUM, + "Spaces to indent single line ('//') comments on lines before code"); + unc_add_option("indent_relative_single_line_comments", UO_indent_relative_single_line_comments, AT_BOOL, + "If set, will indent trailing single line ('//') comments relative\n" + "to the code instead of trying to keep the same absolute column"); + unc_add_option("indent_switch_case", UO_indent_switch_case, AT_NUM, + "Spaces to indent 'case' from 'switch'\n" + "Usually 0 or indent_columns."); + unc_add_option("indent_case_shift", UO_indent_case_shift, AT_NUM, + "Spaces to shift the 'case' line, without affecting any other lines\n" + "Usually 0."); + unc_add_option("indent_case_brace", UO_indent_case_brace, AT_NUM, + "Spaces to indent '{' from 'case'.\n" + "By default, the brace will appear under the 'c' in case.\n" + "Usually set to 0 or indent_columns."); + unc_add_option("indent_col1_comment", UO_indent_col1_comment, AT_BOOL, + "Whether to indent comments found in first column"); + unc_add_option("indent_label", UO_indent_label, AT_NUM, + "How to indent goto labels\n" + " >0 : absolute column where 1 is the leftmost column\n" + " <=0 : subtract from brace indent", "", -16, 16); + unc_add_option("indent_access_spec", UO_indent_access_spec, AT_NUM, + "Same as indent_label, but for access specifiers that are followed by a colon", "", -16, 16); + unc_add_option("indent_access_spec_body", UO_indent_access_spec_body, AT_BOOL, + "Indent the code after an access specifier by one level.\n" + "If set, this option forces 'indent_access_spec=0'"); + unc_add_option("indent_paren_nl", UO_indent_paren_nl, AT_BOOL, + "If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended)"); + unc_add_option("indent_paren_close", UO_indent_paren_close, AT_NUM, + "Controls the indent of a close paren after a newline.\n" + "0: Indent to body level\n" + "1: Align under the open paren\n" + "2: Indent to the brace level"); + unc_add_option("indent_comma_paren", UO_indent_comma_paren, AT_BOOL, + "Controls the indent of a comma when inside a paren." + "If TRUE, aligns under the open paren"); + unc_add_option("indent_bool_paren", UO_indent_bool_paren, AT_BOOL, + "Controls the indent of a BOOL operator when inside a paren." + "If TRUE, aligns under the open paren"); + unc_add_option("indent_square_nl", UO_indent_square_nl, AT_BOOL, + "If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended)"); + unc_add_option("indent_preserve_sql", UO_indent_preserve_sql, AT_BOOL, + "Don't change the relative indent of ESQL/C 'EXEC SQL' bodies"); + unc_add_option("indent_align_assign", UO_indent_align_assign, AT_BOOL, + "Align continued statements at the '='. Default=True\n" + "If FALSE or the '=' is followed by a newline, the next line is indent one tab."); + + unc_begin_group(UG_newline, "Newline adding and removing options"); + unc_add_option("nl_collapse_empty_body", UO_nl_collapse_empty_body, AT_BOOL, + "Whether to collapse empty blocks between '{' and '}'"); + + unc_add_option("nl_assign_leave_one_liners", UO_nl_assign_leave_one_liners, AT_BOOL, + "Don't split one-line braced assignments - 'foo_t f = { 1, 2 };'"); + unc_add_option("nl_class_leave_one_liners", UO_nl_class_leave_one_liners, AT_BOOL, + "Don't split one-line braced statements inside a class xx { } body"); + unc_add_option("nl_enum_leave_one_liners", UO_nl_enum_leave_one_liners, AT_BOOL, + "Don't split one-line enums: 'enum foo { BAR = 15 };'"); + unc_add_option("nl_getset_leave_one_liners", UO_nl_getset_leave_one_liners, AT_BOOL, + "Don't split one-line get or set functions"); + unc_add_option("nl_func_leave_one_liners", UO_nl_func_leave_one_liners, AT_BOOL, + "Don't split one-line function definitions - 'int foo() { return 0; }'"); + unc_add_option("nl_if_leave_one_liners", UO_nl_if_leave_one_liners, AT_BOOL, + "Don't split one-line if/else statements - 'if(a) b++;'"); + + unc_add_option("nl_start_of_file", UO_nl_start_of_file, AT_IARF, + "Add or remove newlines at the start of the file"); + unc_add_option("nl_start_of_file_min", UO_nl_start_of_file_min, AT_NUM, + "The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force'"); + unc_add_option("nl_end_of_file", UO_nl_end_of_file, AT_IARF, + "Add or remove newline at the end of the file"); + unc_add_option("nl_end_of_file_min", UO_nl_end_of_file_min, AT_NUM, + "The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force')"); + unc_add_option("nl_assign_brace", UO_nl_assign_brace, AT_IARF, + "Add or remove newline between '=' and '{'"); + unc_add_option("nl_assign_square", UO_nl_assign_square, AT_IARF, + "Add or remove newline between '=' and '[' (D only)"); + unc_add_option("nl_after_square_assign", UO_nl_after_square_assign, AT_IARF, + "Add or remove newline after '= [' (D only). Will also affect the newline before the ']'"); + unc_add_option("nl_func_var_def_blk", UO_nl_func_var_def_blk, AT_NUM, + "The number of newlines after a block of variable definitions"); + unc_add_option("nl_fcall_brace", UO_nl_fcall_brace, AT_IARF, + "Add or remove newline between a function call's ')' and '{', as in:\n" + "list_for_each(item, &list) { }"); + unc_add_option("nl_enum_brace", UO_nl_enum_brace, AT_IARF, + "Add or remove newline between 'enum' and '{'"); + unc_add_option("nl_struct_brace", UO_nl_struct_brace, AT_IARF, + "Add or remove newline between 'struct and '{'"); + unc_add_option("nl_union_brace", UO_nl_union_brace, AT_IARF, + "Add or remove newline between 'union' and '{'"); + unc_add_option("nl_if_brace", UO_nl_if_brace, AT_IARF, + "Add or remove newline between 'if' and '{'"); + unc_add_option("nl_brace_else", UO_nl_brace_else, AT_IARF, + "Add or remove newline between '}' and 'else'"); + unc_add_option("nl_elseif_brace", UO_nl_elseif_brace, AT_IARF, + "Add or remove newline between 'else if' and '{'\n" + "If set to ignore, nl_if_brace is used instead"); + unc_add_option("nl_else_brace", UO_nl_else_brace, AT_IARF, + "Add or remove newline between 'else' and '{'"); + unc_add_option("nl_else_if", UO_nl_else_if, AT_IARF, + "Add or remove newline between 'else' and 'if'"); + unc_add_option("nl_brace_finally", UO_nl_brace_finally, AT_IARF, + "Add or remove newline between '}' and 'finally'"); + unc_add_option("nl_finally_brace", UO_nl_finally_brace, AT_IARF, + "Add or remove newline between 'finally' and '{'"); + unc_add_option("nl_try_brace", UO_nl_try_brace, AT_IARF, + "Add or remove newline between 'try' and '{'"); + unc_add_option("nl_getset_brace", UO_nl_getset_brace, AT_IARF, + "Add or remove newline between get/set and '{'"); + unc_add_option("nl_for_brace", UO_nl_for_brace, AT_IARF, + "Add or remove newline between 'for' and '{'"); + unc_add_option("nl_catch_brace", UO_nl_catch_brace, AT_IARF, + "Add or remove newline between 'catch' and '{'"); + unc_add_option("nl_brace_catch", UO_nl_brace_catch, AT_IARF, + "Add or remove newline between '}' and 'catch'"); + unc_add_option("nl_while_brace", UO_nl_while_brace, AT_IARF, + "Add or remove newline between 'while' and '{'"); + unc_add_option("nl_brace_brace", UO_nl_brace_brace, AT_IARF, + "Add or remove newline between two open or close braces.\n" + "Due to general newline/brace handling, REMOVE may not work."); + unc_add_option("nl_do_brace", UO_nl_do_brace, AT_IARF, + "Add or remove newline between 'do' and '{'"); + unc_add_option("nl_brace_while", UO_nl_brace_while, AT_IARF, + "Add or remove newline between '}' and 'while' of 'do' statement"); + unc_add_option("nl_switch_brace", UO_nl_switch_brace, AT_IARF, + "Add or remove newline between 'switch' and '{'"); + unc_add_option("nl_multi_line_cond", UO_nl_multi_line_cond, AT_BOOL, + "Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc.\n" + "Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace."); + unc_add_option("nl_multi_line_define", UO_nl_multi_line_define, AT_BOOL, + "Force a newline in a define after the macro name for multi-line defines."); + unc_add_option("nl_before_case", UO_nl_before_case, AT_BOOL, + "Whether to put a newline before 'case' statement"); + unc_add_option("nl_before_throw", UO_nl_before_throw, AT_IARF, + "Add or remove newline between ')' and 'throw'"); + unc_add_option("nl_after_case", UO_nl_after_case, AT_BOOL, + "Whether to put a newline after 'case' statement"); + unc_add_option("nl_namespace_brace", UO_nl_namespace_brace, AT_IARF, + "Newline between namespace and {"); + unc_add_option("nl_template_class", UO_nl_template_class, AT_IARF, + "Add or remove newline between 'template<>' and whatever follows."); + unc_add_option("nl_class_brace", UO_nl_class_brace, AT_IARF, + "Add or remove newline between 'class' and '{'"); + unc_add_option("nl_class_init_args", UO_nl_class_init_args, AT_IARF, + "Add or remove newline after each ',' in the constructor member initialization"); + unc_add_option("nl_func_type_name", UO_nl_func_type_name, AT_IARF, + "Add or remove newline between return type and function name in a function definition"); + unc_add_option("nl_func_type_name_class", UO_nl_func_type_name_class, AT_IARF, + "Add or remove newline between return type and function name inside a class {}\n" + "Uses nl_func_type_name or nl_func_proto_type_name if set to ignore."); + unc_add_option("nl_func_scope_name", UO_nl_func_scope_name, AT_IARF, + "Add or remove newline between function scope and name in a definition\n" + "Controls the newline after '::' in 'void A::f() { }'"); + unc_add_option("nl_func_proto_type_name", UO_nl_func_proto_type_name, AT_IARF, + "Add or remove newline between return type and function name in a prototype"); + unc_add_option("nl_func_paren", UO_nl_func_paren, AT_IARF, + "Add or remove newline between a function name and the opening '('"); + unc_add_option("nl_func_decl_start", UO_nl_func_decl_start, AT_IARF, + "Add or remove newline after '(' in a function declaration"); + unc_add_option("nl_func_decl_args", UO_nl_func_decl_args, AT_IARF, + "Add or remove newline after each ',' in a function declaration"); + unc_add_option("nl_func_decl_end", UO_nl_func_decl_end, AT_IARF, + "Add or remove newline before the ')' in a function declaration"); + unc_add_option("nl_func_decl_empty", UO_nl_func_decl_empty, AT_IARF, + "Add or remove newline between '()' in a function declaration."); + unc_add_option("nl_fdef_brace", UO_nl_fdef_brace, AT_IARF, + "Add or remove newline between function signature and '{'"); + unc_add_option("nl_after_return", UO_nl_after_return, AT_BOOL, + "Whether to put a newline after 'return' statement"); + unc_add_option("nl_return_expr", UO_nl_return_expr, AT_IARF, + "Add or remove a newline between the return keyword and return expression."); + unc_add_option("nl_after_semicolon", UO_nl_after_semicolon, AT_BOOL, + "Whether to put a newline after semicolons, except in 'for' statements"); + unc_add_option("nl_after_brace_open", UO_nl_after_brace_open, AT_BOOL, + "Whether to put a newline after brace open.\n" + "This also adds a newline before the matching brace close."); + unc_add_option("nl_after_brace_open_cmt", UO_nl_after_brace_open_cmt, AT_BOOL, + "If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is\n" + "placed between the open brace and a trailing single-line comment."); + unc_add_option("nl_after_vbrace_open", UO_nl_after_vbrace_open, AT_BOOL, + "Whether to put a newline after a virtual brace open.\n" + "These occur in un-braced if/while/do/for statement bodies."); + unc_add_option("nl_after_brace_close", UO_nl_after_brace_close, AT_BOOL, + "Whether to put a newline after a brace close.\n" + "Does not apply if followed by a necessary ';'."); + unc_add_option("nl_define_macro", UO_nl_define_macro, AT_BOOL, + "Whether to alter newlines in '#define' macros"); + unc_add_option("nl_squeeze_ifdef", UO_nl_squeeze_ifdef, AT_BOOL, + "Whether to not put blanks after '#ifxx', '#elxx', or before '#endif'"); + unc_add_option("nl_before_if", UO_nl_before_if, AT_IARF, + "Add or remove newline before 'if'"); + unc_add_option("nl_after_if", UO_nl_after_if, AT_IARF, + "Add or remove newline after 'if'"); + unc_add_option("nl_before_for", UO_nl_before_for, AT_IARF, + "Add or remove newline before 'for'"); + unc_add_option("nl_after_for", UO_nl_after_for, AT_IARF, + "Add or remove newline after 'for'"); + unc_add_option("nl_before_while", UO_nl_before_while, AT_IARF, + "Add or remove newline before 'while'"); + unc_add_option("nl_after_while", UO_nl_after_while, AT_IARF, + "Add or remove newline after 'while'"); + unc_add_option("nl_before_switch", UO_nl_before_switch, AT_IARF, + "Add or remove newline before 'switch'"); + unc_add_option("nl_after_switch", UO_nl_after_switch, AT_IARF, + "Add or remove newline after 'switch'"); + unc_add_option("nl_before_do", UO_nl_before_do, AT_IARF, + "Add or remove newline before 'do'"); + unc_add_option("nl_after_do", UO_nl_after_do, AT_IARF, + "Add or remove newline after 'do'"); + unc_add_option("nl_ds_struct_enum_cmt", UO_nl_ds_struct_enum_cmt, AT_BOOL, + "Whether to double-space commented-entries in struct/enum"); + unc_add_option("nl_ds_struct_enum_close_brace", UO_nl_ds_struct_enum_close_brace, AT_BOOL, + "Whether to double-space before the close brace of a struct/union/enum"); + unc_add_option("nl_class_colon", UO_nl_class_colon, AT_IARF, + "Add or remove a newline around a class colon.\n" + "Related to pos_class_colon, nl_class_init_args, and pos_comma."); + unc_add_option("nl_create_if_one_liner", UO_nl_create_if_one_liner, AT_BOOL, + "Change simple unbraced if statements into a one-liner\n" + "'if(b)\\n i++;' => 'if(b) i++;'"); + unc_add_option("nl_create_for_one_liner", UO_nl_create_for_one_liner, AT_BOOL, + "Change simple unbraced for statements into a one-liner\n" + "'for (i=0;i<5;i++)\\n foo(i);' => 'for (i=0;i<5;i++) foo(i);'"); + unc_add_option("nl_create_while_one_liner", UO_nl_create_while_one_liner, AT_BOOL, + "Change simple unbraced while statements into a one-liner\n" + "'while (i<5)\\n foo(i++);' => 'while (i<5) foo(i++);'"); + + unc_begin_group(UG_blankline, "Blank line options", "Note that it takes 2 newlines to get a blank line"); + unc_add_option("nl_max", UO_nl_max, AT_NUM, + "The maximum consecutive newlines"); + unc_add_option("nl_after_func_proto", UO_nl_after_func_proto, AT_NUM, + "The number of newlines after a function prototype, if followed by another function prototype"); + unc_add_option("nl_after_func_proto_group", UO_nl_after_func_proto_group, AT_NUM, + "The number of newlines after a function prototype, if not followed by another function prototype"); + unc_add_option("nl_after_func_body", UO_nl_after_func_body, AT_NUM, + "The number of newlines after '}' of a multi-line function body"); + unc_add_option("nl_after_func_body_one_liner", UO_nl_after_func_body_one_liner, AT_NUM, + "The number of newlines after '}' of a single line function body"); + unc_add_option("nl_before_block_comment", UO_nl_before_block_comment, AT_NUM, + "The minimum number of newlines before a multi-line comment.\n" + "Doesn't apply if after a brace open or another multi-line comment."); + unc_add_option("nl_before_c_comment", UO_nl_before_c_comment, AT_NUM, + "The minimum number of newlines before a single-line C comment.\n" + "Doesn't apply if after a brace open or other single-line C comments."); + unc_add_option("nl_before_cpp_comment", UO_nl_before_cpp_comment, AT_NUM, + "The minimum number of newlines before a CPP comment.\n" + "Doesn't apply if after a brace open or other CPP comments."); + unc_add_option("nl_after_multiline_comment", UO_nl_after_multiline_comment, AT_BOOL, + "Whether to force a newline after a mulit-line comment."); + + unc_add_option("nl_before_access_spec", UO_nl_before_access_spec, AT_NUM, + "The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label.\n" + "Will not change the newline count if after a brace open.\n" + "0 = No change."); + unc_add_option("nl_after_access_spec", UO_nl_after_access_spec, AT_NUM, + "The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label.\n" + "0 = No change."); + + unc_add_option("nl_comment_func_def", UO_nl_comment_func_def, AT_NUM, + "The number of newlines between a function def and the function comment.\n" + "0 = No change."); + + unc_add_option("nl_after_try_catch_finally", UO_nl_after_try_catch_finally, AT_NUM, + "The number of newlines after a try-catch-finally block that isn't followed by a brace close.\n" + "0 = No change."); + unc_add_option("nl_around_cs_property", UO_nl_around_cs_property, AT_NUM, + "The number of newlines before and after a property, indexer or event decl.\n" + "0 = No change."); + unc_add_option("nl_between_get_set", UO_nl_between_get_set, AT_NUM, + "The number of newlines between the get/set/add/remove handlers in C#.\n" + "0 = No change."); + + unc_add_option("eat_blanks_after_open_brace", UO_eat_blanks_after_open_brace, AT_BOOL, + "Whether to remove blank lines after '{'"); + unc_add_option("eat_blanks_before_close_brace", UO_eat_blanks_before_close_brace, AT_BOOL, + "Whether to remove blank lines before '}'"); + + unc_begin_group(UG_position, "Positioning options"); + unc_add_option("pos_arith", UO_pos_arith, AT_POS, + "The position of arithmetic operators in wrapped expressions"); + unc_add_option("pos_assign", UO_pos_assign, AT_POS, + "The position of assignment in wrapped expressions"); + unc_add_option("pos_bool", UO_pos_bool, AT_POS, + "The position of boolean operators in wrapped expressions"); + unc_add_option("pos_compare", UO_pos_compare, AT_POS, + "The position of comparison operators in wrapped expressions"); + unc_add_option("pos_conditional", UO_pos_conditional, AT_POS, + "The position of conditional (b ? t : f) operators in wrapped expressions"); + unc_add_option("pos_comma", UO_pos_comma, AT_POS, + "The position of the comma in wrapped expressions"); + unc_add_option("pos_class_comma", UO_pos_class_comma, AT_POS, + "The position of the comma in the constructor initialization list"); + unc_add_option("pos_class_colon", UO_pos_class_colon, AT_POS, + "The position of colons between constructor and member initialization"); + + unc_begin_group(UG_linesplit, "Line Splitting options"); + unc_add_option("code_width", UO_code_width, AT_NUM, + "Try to limit code width to N number of columns", "", 16, 256); + unc_add_option("ls_for_split_full", UO_ls_for_split_full, AT_BOOL, + "Whether to fully split long 'for' statements at semi-colons"); + unc_add_option("ls_func_split_full", UO_ls_func_split_full, AT_BOOL, + "Whether to fully split long function protos/calls at commas"); + + unc_begin_group(UG_align, "Code alignment (not left column spaces/tabs)"); + unc_add_option("align_keep_tabs", UO_align_keep_tabs, AT_BOOL, + "Whether to keep non-indenting tabs"); + unc_add_option("align_with_tabs", UO_align_with_tabs, AT_BOOL, + "Whether to use tabs for aligning"); + unc_add_option("align_on_tabstop", UO_align_on_tabstop, AT_BOOL, + "Whether to bump out to the next tab when aligning"); + unc_add_option("align_number_left", UO_align_number_left, AT_BOOL, + "Whether to left-align numbers"); + unc_add_option("align_func_params", UO_align_func_params, AT_BOOL, + "Align variable definitions in prototypes and functions"); + unc_add_option("align_same_func_call_params", UO_align_same_func_call_params, AT_BOOL, + "Align parameters in single-line functions that have the same name.\n" + "The function names must already be aligned with each other."); + unc_add_option("align_var_def_span", UO_align_var_def_span, AT_NUM, + "The span for aligning variable definitions (0=don't align)", "", 0, 5000); + unc_add_option("align_var_def_star_style", UO_align_var_def_star_style, AT_NUM, + "How to align the star in variable definitions.\n" + " 0=Part of the type 'void * foo;'\n" + " 1=Part of the variable 'void *foo;'\n" + " 2=Dangling 'void *foo;'", "", 0, 2); + unc_add_option("align_var_def_amp_style", UO_align_var_def_amp_style, AT_NUM, + "How to align the '&' in variable definitions.\n" + " 0=Part of the type\n" + " 1=Part of the variable\n" + " 2=Dangling", "", 0, 2); + unc_add_option("align_var_def_thresh", UO_align_var_def_thresh, AT_NUM, + "The threshold for aligning variable definitions (0=no limit)", "", 0, 5000); + unc_add_option("align_var_def_gap", UO_align_var_def_gap, AT_NUM, + "The gap for aligning variable definitions"); + unc_add_option("align_var_def_colon", UO_align_var_def_colon, AT_BOOL, + "Whether to align the colon in struct bit fields"); + unc_add_option("align_var_def_attribute", UO_align_var_def_attribute, AT_BOOL, + "Whether to align any attribute after the variable name"); + unc_add_option("align_var_def_inline", UO_align_var_def_inline, AT_BOOL, + "Whether to align inline struct/enum/union variable definitions"); + unc_add_option("align_assign_span", UO_align_assign_span, AT_NUM, + "The span for aligning on '=' in assignments (0=don't align)", "", 0, 5000); + unc_add_option("align_assign_thresh", UO_align_assign_thresh, AT_NUM, + "The threshold for aligning on '=' in assignments (0=no limit)", "", 0, 5000); + unc_add_option("align_enum_equ_span", UO_align_enum_equ_span, AT_NUM, + "The span for aligning on '=' in enums (0=don't align)", "", 0, 5000); + unc_add_option("align_enum_equ_thresh", UO_align_enum_equ_thresh, AT_NUM, + "The threshold for aligning on '=' in enums (0=no limit)", "", 0, 5000); + unc_add_option("align_var_struct_span", UO_align_var_struct_span, AT_NUM, + "The span for aligning struct/union (0=don't align)", "", 0, 5000); + unc_add_option("align_var_struct_thresh", UO_align_var_struct_thresh, AT_NUM, + "The threshold for aligning struct/union member definitions (0=no limit)", "", 0, 5000); + unc_add_option("align_var_struct_gap", UO_align_var_struct_gap, AT_NUM, + "The gap for aligning struct/union member definitions"); + unc_add_option("align_struct_init_span", UO_align_struct_init_span, AT_NUM, + "The span for aligning struct initializer values (0=don't align)", "", 0, 5000); + unc_add_option("align_typedef_gap", UO_align_typedef_gap, AT_NUM, + "The minimum space between the type and the synonym of a typedef"); + unc_add_option("align_typedef_span", UO_align_typedef_span, AT_NUM, + "The span for aligning single-line typedefs (0=don't align)"); + unc_add_option("align_typedef_func", UO_align_typedef_func, AT_NUM, + "How to align typedef'd functions with other typedefs\n" + "0: Don't mix them at all\n" + "1: align the open paren with the types\n" + "2: align the function type name with the other type names"); + unc_add_option("align_typedef_star_style", UO_align_typedef_star_style, AT_NUM, + "Controls the positioning of the '*' in typedefs. Just try it.\n" + "0: Align on typedef type, ignore '*'\n" + "1: The '*' is part of type name: typedef int *pint;\n" + "2: The '*' is part of the type, but dangling: typedef int *pint;", "", 0, 2); + unc_add_option("align_typedef_amp_style", UO_align_typedef_amp_style, AT_NUM, + "Controls the positioning of the '&' in typedefs. Just try it.\n" + "0: Align on typedef type, ignore '&'\n" + "1: The '&' is part of type name: typedef int &pint;\n" + "2: The '&' is part of the type, but dangling: typedef int &pint;", "", 0, 2); + + unc_add_option("align_right_cmt_span", UO_align_right_cmt_span, AT_NUM, + "The span for aligning comments that end lines (0=don't align)", "", 0, 5000); + unc_add_option("align_right_cmt_mix", UO_align_right_cmt_mix, AT_BOOL, + "If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment"); + unc_add_option("align_right_cmt_gap", UO_align_right_cmt_gap, AT_NUM, + "If a trailing comment is more than this number of columns away from the text it follows,\n" + "it will qualify for being aligned."); + unc_add_option("align_right_cmt_at_col", UO_align_right_cmt_at_col, AT_NUM, + "Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore)", "", 0, 200); + unc_add_option("align_func_proto_span", UO_align_func_proto_span, AT_NUM, + "The span for aligning function prototypes (0=don't align)", "", 0, 5000); + unc_add_option("align_func_proto_gap", UO_align_func_proto_gap, AT_NUM, + "Minimum gap between the return type and the function name."); + unc_add_option("align_on_operator", UO_align_on_operator, AT_BOOL, + "Align function protos on the 'operator' keyword instead of what follows"); + unc_add_option("align_mix_var_proto", UO_align_mix_var_proto, AT_BOOL, + "Whether to mix aligning prototype and variable declarations.\n" + "If true, align_var_def_XXX options are used instead of align_func_proto_XXX options."); + unc_add_option("align_single_line_func", UO_align_single_line_func, AT_BOOL, + "Align single-line functions with function prototypes, uses align_func_proto_span"); + unc_add_option("align_single_line_brace", UO_align_single_line_brace, AT_BOOL, + "Aligning the open brace of single-line functions.\n" + "Requires align_single_line_func=true, uses align_func_proto_span"); + unc_add_option("align_single_line_brace_gap", UO_align_single_line_brace_gap, AT_NUM, + "Gap for align_single_line_brace.\n"); + unc_add_option("align_oc_msg_spec_span", UO_align_oc_msg_spec_span, AT_NUM, + "The span for aligning ObjC msg spec (0=don't align)", "", 0, 5000); + unc_add_option("align_nl_cont", UO_align_nl_cont, AT_BOOL, + "Whether to align macros wrapped with a backslash and a newline.\n" + "This will not work right if the macro contains a multi-line comment."); + unc_add_option("align_pp_define_gap", UO_align_pp_define_gap, AT_NUM, + "The minimum space between label and value of a preprocessor define"); + unc_add_option("align_pp_define_span", UO_align_pp_define_span, AT_NUM, + "The span for aligning on '#define' bodies (0=don't align)", "", 0, 5000); + unc_add_option("align_left_shift", UO_align_left_shift, AT_BOOL, + "Align lines that start with '<<' with previous '<<'. Default=true"); + + unc_add_option("align_oc_msg_colon", UO_align_oc_msg_colon, AT_BOOL, + "Align parameters in an Obj-C message on the ':'"); + + unc_begin_group(UG_comment, "Comment modifications"); + unc_add_option("cmt_width", UO_cmt_width, AT_NUM, + "Try to wrap comments at cmt_width columns", "", 16, 256); + unc_add_option("cmt_reflow_mode", UO_cmt_reflow_mode, AT_NUM, + "Set the comment reflow mode (default: 0)\n" + "0: no reflowing (apart from the line wrapping due to cmt_width)\n" + "1: no touching at all\n" + "2: full reflow\n", "", 0, 2); + unc_add_option("cmt_indent_multi", UO_cmt_indent_multi, AT_BOOL, + "If false, disable all multi-line comment changes, including cmt_width and leading chars.\n" + "Default is true."); + unc_add_option("cmt_c_group", UO_cmt_c_group, AT_BOOL, + "Whether to group c-comments that look like they are in a block"); + unc_add_option("cmt_c_nl_start", UO_cmt_c_nl_start, AT_BOOL, + "Whether to put an empty '/*' on the first line of the combined c-comment"); + unc_add_option("cmt_c_nl_end", UO_cmt_c_nl_end, AT_BOOL, + "Whether to put a newline before the closing '*/' of the combined c-comment"); + unc_add_option("cmt_cpp_group", UO_cmt_cpp_group, AT_BOOL, + "Whether to group cpp-comments that look like they are in a block"); + unc_add_option("cmt_cpp_nl_start", UO_cmt_cpp_nl_start, AT_BOOL, + "Whether to put an empty '/*' on the first line of the combined cpp-comment"); + unc_add_option("cmt_cpp_nl_end", UO_cmt_cpp_nl_end, AT_BOOL, + "Whether to put a newline before the closing '*/' of the combined cpp-comment"); + unc_add_option("cmt_cpp_to_c", UO_cmt_cpp_to_c, AT_BOOL, + "Whether to change cpp-comments into c-comments"); + unc_add_option("cmt_star_cont", UO_cmt_star_cont, AT_BOOL, + "Whether to put a star on subsequent comment lines"); + unc_add_option("cmt_sp_before_star_cont", UO_cmt_sp_before_star_cont, AT_NUM, + "The number of spaces to insert at the start of subsequent comment lines"); + unc_add_option("cmt_sp_after_star_cont", UO_cmt_sp_after_star_cont, AT_NUM, + "The number of spaces to insert after the star on subsequent comment lines"); + + unc_add_option("cmt_multi_check_last", UO_cmt_multi_check_last, AT_BOOL, + "For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of\n" + "the comment are the same length. Default=True"); + + unc_add_option("cmt_insert_file_header", UO_cmt_insert_file_header, AT_STRING, + "The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment.\n" + "Will substitute $(filename) with the current file's name."); + unc_add_option("cmt_insert_file_footer", UO_cmt_insert_file_footer, AT_STRING, + "The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment.\n" + "Will substitute $(filename) with the current file's name."); + unc_add_option("cmt_insert_func_header", UO_cmt_insert_func_header, AT_STRING, + "The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment.\n" + "Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff.\n" + "Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... }"); + unc_add_option("cmt_insert_class_header", UO_cmt_insert_class_header, AT_STRING, + "The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment.\n" + "Will substitute $(class) with the class name."); + unc_add_option("cmt_insert_before_preproc", UO_cmt_insert_before_preproc, AT_BOOL, + "If a preprocessor is encountered when stepping backwards from a function name, then\n" + "this option decides whether the comment should be inserted.\n" + "Affects cmt_insert_func_header and cmt_insert_class_header."); + + unc_begin_group(UG_codemodify, "Code modifying options (non-whitespace)"); + unc_add_option("mod_full_brace_do", UO_mod_full_brace_do, AT_IARF, + "Add or remove braces on single-line 'do' statement"); + unc_add_option("mod_full_brace_for", UO_mod_full_brace_for, AT_IARF, + "Add or remove braces on single-line 'for' statement"); + unc_add_option("mod_full_brace_function", UO_mod_full_brace_function, AT_IARF, + "Add or remove braces on single-line function definitions. (Pawn)"); + unc_add_option("mod_full_brace_if", UO_mod_full_brace_if, AT_IARF, + "Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'."); + unc_add_option("mod_full_brace_if_chain", UO_mod_full_brace_if_chain, AT_BOOL, + "Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if.\n" + "If any must be braced, they are all braced. If all can be unbraced, then the braces are removed."); + unc_add_option("mod_full_brace_nl", UO_mod_full_brace_nl, AT_NUM, + "Don't remove braces around statements that span N newlines", "", 0, 5000); + unc_add_option("mod_full_brace_while", UO_mod_full_brace_while, AT_IARF, + "Add or remove braces on single-line 'while' statement"); + unc_add_option("mod_paren_on_return", UO_mod_paren_on_return, AT_IARF, + "Add or remove unnecessary paren on 'return' statement"); + unc_add_option("mod_pawn_semicolon", UO_mod_pawn_semicolon, AT_BOOL, + "Whether to change optional semicolons to real semicolons"); + unc_add_option("mod_full_paren_if_bool", UO_mod_full_paren_if_bool, AT_BOOL, + "Add parens on 'while' and 'if' statement around bools"); + unc_add_option("mod_remove_extra_semicolon", UO_mod_remove_extra_semicolon, AT_BOOL, + "Whether to remove superfluous semicolons"); + unc_add_option("mod_add_long_function_closebrace_comment", UO_mod_add_long_function_closebrace_comment, AT_NUM, + "If a function body exceeds the specified number of newlines and doesn't have a comment after\n" + "the close brace, a comment will be added."); + unc_add_option("mod_add_long_switch_closebrace_comment", UO_mod_add_long_switch_closebrace_comment, AT_NUM, + "If a switch body exceeds the specified number of newlines and doesn't have a comment after\n" + "the close brace, a comment will be added."); + unc_add_option("mod_add_long_ifdef_endif_comment", UO_mod_add_long_ifdef_endif_comment, AT_NUM, + "If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after\n" + "the #else, a comment will be added."); + unc_add_option("mod_add_long_ifdef_else_comment", UO_mod_add_long_ifdef_else_comment, AT_NUM, + "If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after\n" + "the #endif, a comment will be added."); + unc_add_option("mod_sort_import", UO_mod_sort_import, AT_BOOL, + "If TRUE, will sort consecutive single-line 'import' statements [Java, D]"); + unc_add_option("mod_sort_using", UO_mod_sort_using, AT_BOOL, + "If TRUE, will sort consecutive single-line 'using' statements [C#]"); + unc_add_option("mod_sort_include", UO_mod_sort_include, AT_BOOL, + "If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C]\n" + "This is generally a bad idea, as it may break your code."); + unc_add_option("mod_move_case_break", UO_mod_move_case_break, AT_BOOL, + "If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace."); + unc_add_option("mod_case_brace", UO_mod_case_brace, AT_IARF, + "Will add or remove the braces around a fully braced case statement.\n" + "Will only remove the braces if there are no variable declarations in the block."); + unc_add_option("mod_remove_empty_return", UO_mod_remove_empty_return, AT_BOOL, + "If TRUE, it will remove a void 'return;' that appears as the last statement in a function."); + + unc_begin_group(UG_preprocessor, "Preprocessor options"); + unc_add_option("pp_indent", UO_pp_indent, AT_IARF, + "Control indent of preprocessors inside #if blocks at brace level 0"); + unc_add_option("pp_indent_at_level", UO_pp_indent_at_level, AT_BOOL, + "Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false)"); + unc_add_option("pp_indent_count", UO_pp_indent_count, AT_NUM, + "If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1."); + unc_add_option("pp_space", UO_pp_space, AT_IARF, + "Add or remove space after # based on pp_level of #if blocks"); + unc_add_option("pp_space_count", UO_pp_space_count, AT_NUM, + "Sets the number of spaces added with pp_space"); + unc_add_option("pp_indent_region", UO_pp_indent_region, AT_NUM, + "The indent for #region and #endregion in C# and '#pragma region' in C/C++"); + unc_add_option("pp_region_indent_code", UO_pp_region_indent_code, AT_BOOL, + "Whether to indent the code between #region and #endregion"); + unc_add_option("pp_indent_if", UO_pp_indent_if, AT_NUM, + "If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level"); + unc_add_option("pp_if_indent_code", UO_pp_if_indent_code, AT_BOOL, + "Control whether to indent the code between #if, #else and #endif when not at file-level"); + unc_add_option("pp_define_at_level", UO_pp_define_at_level, AT_BOOL, + "Whether to indent '#define' at the brace level (true) or from column 1 (false)"); +} + + +const group_map_value *get_group_name(int ug) +{ + for (group_map_it it = group_map.begin(); + it != group_map.end(); + it++) + { + if (it->second.id == ug) + { + return(&it->second); + } + } + return(NULL); +} + + +const option_map_value *get_option_name(int uo) +{ + for (option_name_map_it it = option_name_map.begin(); + it != option_name_map.end(); + it++) + { + if (it->second.id == uo) + { + return(&it->second); + } + } + return(NULL); +} + + +/** + * Convert the value string to the correct type in dest. + */ +static void convert_value(const option_map_value *entry, const char *val, op_val_t *dest) +{ + const option_map_value *tmp; + bool btrue; + int mult; + + if (entry->type == AT_LINE) + { + if (strcasecmp(val, "CRLF") == 0) + { + dest->le = LE_CRLF; + return; + } + if (strcasecmp(val, "LF") == 0) + { + dest->le = LE_LF; + return; + } + if (strcasecmp(val, "CR") == 0) + { + dest->le = LE_CR; + return; + } + if (strcasecmp(val, "AUTO") != 0) + { + LOG_FMT(LWARN, "%s:%d Expected AUTO, LF, CRLF, or CR for %s, got %s\n", + cpd.filename, cpd.line_number, entry->name, val); + cpd.error_count++; + } + dest->le = LE_AUTO; + return; + } + + if (entry->type == AT_POS) + { + if ((strcasecmp(val, "LEAD") == 0) || + (strcasecmp(val, "START") == 0)) + { + dest->tp = TP_LEAD; + return; + } + if ((strcasecmp(val, "TRAIL") == 0) || + (strcasecmp(val, "END") == 0)) + { + dest->tp = TP_TRAIL; + return; + } + if (strcasecmp(val, "IGNORE") != 0) + { + LOG_FMT(LWARN, "%s:%d Expected IGNORE, LEAD/START, or TRAIL/END for %s, got %s\n", + cpd.filename, cpd.line_number, entry->name, val); + cpd.error_count++; + } + dest->tp = TP_IGNORE; + return; + } + + if (entry->type == AT_NUM) + { + if (unc_isdigit(*val) || + (unc_isdigit(val[1]) && ((*val == '-') || (*val == '+')))) + { + dest->n = strtol(val, NULL, 0); + return; + } + else + { + /* Try to see if it is a variable */ + mult = 1; + if (*val == '-') + { + mult = -1; + val++; + } + + if (((tmp = unc_find_option(val)) != NULL) && (tmp->type == entry->type)) + { + dest->n = cpd.settings[tmp->id].n * mult; + return; + } + } + LOG_FMT(LWARN, "%s:%d Expected a number for %s, got %s\n", + cpd.filename, cpd.line_number, entry->name, val); + cpd.error_count++; + dest->n = 0; + return; + } + + if (entry->type == AT_BOOL) + { + if ((strcasecmp(val, "true") == 0) || + (strcasecmp(val, "t") == 0) || + (strcmp(val, "1") == 0)) + { + dest->b = true; + return; + } + + if ((strcasecmp(val, "false") == 0) || + (strcasecmp(val, "f") == 0) || + (strcmp(val, "0") == 0)) + { + dest->b = false; + return; + } + + btrue = true; + if ((*val == '-') || (*val == '~')) + { + btrue = false; + val++; + } + + if (((tmp = unc_find_option(val)) != NULL) && (tmp->type == entry->type)) + { + dest->b = cpd.settings[tmp->id].b ? btrue : !btrue; + return; + } + LOG_FMT(LWARN, "%s:%d Expected 'True' or 'False' for %s, got %s\n", + cpd.filename, cpd.line_number, entry->name, val); + cpd.error_count++; + dest->b = false; + return; + } + + if (entry->type == AT_STRING) + { + dest->str = strdup(val); + return; + } + + /* Must be AT_IARF */ + + if ((strcasecmp(val, "add") == 0) || (strcasecmp(val, "a") == 0)) + { + dest->a = AV_ADD; + return; + } + if ((strcasecmp(val, "remove") == 0) || (strcasecmp(val, "r") == 0)) + { + dest->a = AV_REMOVE; + return; + } + if ((strcasecmp(val, "force") == 0) || (strcasecmp(val, "f") == 0)) + { + dest->a = AV_FORCE; + return; + } + if ((strcasecmp(val, "ignore") == 0) || (strcasecmp(val, "i") == 0)) + { + dest->a = AV_IGNORE; + return; + } + if (((tmp = unc_find_option(val)) != NULL) && (tmp->type == entry->type)) + { + dest->a = cpd.settings[tmp->id].a; + return; + } + LOG_FMT(LWARN, "%s:%d Expected 'Add', 'Remove', 'Force', or 'Ignore' for %s, got %s\n", + cpd.filename, cpd.line_number, entry->name, val); + cpd.error_count++; + dest->a = AV_IGNORE; +} + + +int set_option_value(const char *name, const char *value) +{ + const option_map_value *entry; + + if ((entry = unc_find_option(name)) != NULL) + { + convert_value(entry, value, &cpd.settings[entry->id]); + return(entry->id); + } + return(-1); +} + + +int load_option_file(const char *filename) +{ + FILE *pfile; + char buffer[256]; + char *ptr; + int id; + char *args[32]; + int argc; + int idx; + + cpd.line_number = 0; + + pfile = fopen(filename, "r"); + if (pfile == NULL) + { + LOG_FMT(LERR, "%s: fopen(%s) failed: %s (%d)\n", + __func__, filename, strerror(errno), errno); + cpd.error_count++; + return(-1); + } + + /* Read in the file line by line */ + while (fgets(buffer, sizeof(buffer), pfile) != NULL) + { + cpd.line_number++; + + /* Chop off trailing comments */ + if ((ptr = strchr(buffer, '#')) != NULL) + { + *ptr = 0; + } + + /* Blow away the '=' to make things simple */ + if ((ptr = strchr(buffer, '=')) != NULL) + { + *ptr = ' '; + } + + /* Blow away all commas */ + ptr = buffer; + while ((ptr = strchr(ptr, ',')) != NULL) + { + *ptr = ' '; + } + + /* Split the line */ + argc = Args::SplitLine(buffer, args, ARRAY_SIZE(args) - 1); + if (argc < 2) + { + if (argc > 0) + { + LOG_FMT(LWARN, "%s:%d Wrong number of arguments: %s...\n", + filename, cpd.line_number, buffer); + cpd.error_count++; + } + continue; + } + args[argc] = NULL; + + if (strcasecmp(args[0], "type") == 0) + { + for (idx = 1; idx < argc; idx++) + { + add_keyword(args[idx], CT_TYPE, LANG_ALL); + } + } + else if (strcasecmp(args[0], "define") == 0) + { + add_define(args[1], args[2]); + } + else if (strcasecmp(args[0], "macro-open") == 0) + { + add_keyword(args[1], CT_MACRO_OPEN, LANG_ALL); + } + else if (strcasecmp(args[0], "macro-close") == 0) + { + add_keyword(args[1], CT_MACRO_CLOSE, LANG_ALL); + } + else if (strcasecmp(args[0], "macro-else") == 0) + { + add_keyword(args[1], CT_MACRO_ELSE, LANG_ALL); + } + else if (strcasecmp(args[0], "set") == 0) + { + if (argc < 3) + { + LOG_FMT(LWARN, "%s:%d 'set' requires at least three arguments\n", + filename, cpd.line_number); + } + else + { + c_token_t id = find_token_name(args[1]); + if (id != CT_NONE) + { + LOG_FMT(LNOTE, "%s:%d set '%s':", filename, cpd.line_number, args[1]); + for (idx = 2; idx < argc; idx++) + { + LOG_FMT(LNOTE, " '%s'", args[idx]); + add_keyword(args[idx], id, LANG_ALL); + } + LOG_FMT(LNOTE, "\n"); + } + else + { + LOG_FMT(LWARN, "%s:%d unknown type '%s':", filename, cpd.line_number, args[1]); + } + } + } + else + { + /* must be a regular option = value */ + if ((id = set_option_value(args[0], args[1])) < 0) + { + LOG_FMT(LWARN, "%s:%d Unknown symbol '%s'\n", + filename, cpd.line_number, args[0]); + cpd.error_count++; + } + } + } + + fclose(pfile); + return(0); +} + + +int save_option_file(FILE *pfile, bool withDoc) +{ + std::string val_string; + const char *val_str; + int val_len; + int name_len; + int idx; + + fprintf(pfile, "# Uncrustify %s\n", UNCRUSTIFY_VERSION); + + /* Print the options by group */ + for (group_map_it jt = group_map.begin(); jt != group_map.end(); jt++) + { + if (withDoc) + { + fputs("\n#\n", pfile); + fprintf(pfile, "# %s\n", jt->second.short_desc); + fputs("#\n\n", pfile); + } + + bool first = true; + + for (option_list_it it = jt->second.options.begin(); it != jt->second.options.end(); it++) + { + const option_map_value *option = get_option_name(*it); + + if (withDoc && (option->short_desc != NULL) && (*option->short_desc != 0)) + { + fprintf(pfile, "%s# ", first ? "" : "\n"); + for (idx = 0; option->short_desc[idx] != 0; idx++) + { + fputc(option->short_desc[idx], pfile); + if ((option->short_desc[idx] == '\n') && + (option->short_desc[idx + 1] != 0)) + { + fputs("# ", pfile); + } + } + if (option->short_desc[idx - 1] != '\n') + { + fputc('\n', pfile); + } + } + first = false; + val_string = op_val_to_string(option->type, cpd.settings[option->id]); + val_str = val_string.c_str(); + val_len = strlen(val_str); + name_len = strlen(option->name); + + fprintf(pfile, "%s %*.s= ", + option->name, cpd.max_option_name_len - name_len, " "); + if (option->type == AT_STRING) + { + fprintf(pfile, "\"%s\"", val_str); + } + else + { + fprintf(pfile, "%s", val_str); + } + if (withDoc) + { + fprintf(pfile, "%*.s # %s", + 8 - val_len, " ", + argtype_to_string(option->type).c_str()); + } + fputs("\n", pfile); + } + } + + if (withDoc) + { + fprintf(pfile, + "\n" + "# You can force a token to be a type with the 'type' option.\n" + "# Example:\n" + "# type myfoo1 myfoo2\n" + "#\n" + "# You can create custom macro-based indentation using macro-open,\n" + "# macro-else and macro-close.\n" + "# Example:\n" + "# macro-open BEGIN_TEMPLATE_MESSAGE_MAP\n" + "# macro-open BEGIN_MESSAGE_MAP\n" + "# macro-close END_MESSAGE_MAP\n" + "#\n" + "# You can assign any keyword to any type with the set option.\n" + "# set func_call_user _ N_\n" + "#\n" + "# The full syntax description of all custom definition config entries\n" + "# is shown below:\n" + "#\n" + "# define custom tokens as:\n" + "# - embed whitespace in token using '\' escape character, or\n" + "# put token in quotes\n" + "# - these: ' \" and ` are recognized as quote delimiters\n" + "#\n" + "# type token1 token2 token3 ...\n" + "# ^ optionally specify multiple tokens on a single line\n" + "# define def_token output_token\n" + "# ^ output_token is optional, then NULL is assumed\n" + "# macro-open token\n" + "# macro-close token\n" + "# macro-else token\n" + "# set id token1 token2 ...\n" + "# ^ optionally specify multiple tokens on a single line\n" + "# ^ id is one of the names in token_enum.h sans the CT_ prefix,\n" + "# e.g. PP_PRAGMA\n" + "#\n" + "# all tokens are separated by any mix of ',' commas, '=' equal signs\n" + "# and whitespace (space, tab)\n" + "#\n" + ); + } + + /* Print custom keywords */ + const chunk_tag_t *ct; + idx = 0; + while ((ct = get_custom_keyword_idx(idx)) != NULL) + { + if (ct->type == CT_TYPE) + { + fprintf(pfile, "type %*.s%s\n", + cpd.max_option_name_len - 4, " ", ct->tag); + } + else if (ct->type == CT_MACRO_OPEN) + { + fprintf(pfile, "macro-open %*.s%s\n", + cpd.max_option_name_len - 11, " ", ct->tag); + } + else if (ct->type == CT_MACRO_CLOSE) + { + fprintf(pfile, "macro-close %*.s%s\n", + cpd.max_option_name_len - 12, " ", ct->tag); + } + else if (ct->type == CT_MACRO_ELSE) + { + fprintf(pfile, "macro-else %*.s%s\n", + cpd.max_option_name_len - 11, " ", ct->tag); + } + else + { + const char *tn = get_token_name(ct->type); + + fprintf(pfile, "set %s %*.s%s\n", tn, + int(cpd.max_option_name_len - (4 + strlen(tn))), " ", ct->tag); + } + } + + /* Print custom defines */ + const define_tag_t *dt; + idx = 0; + while ((dt = get_define_idx(idx)) != NULL) + { + fprintf(pfile, "define %*.s%s \"%s\"\n", + cpd.max_option_name_len - 6, " ", dt->tag, dt->value); + } + + fclose(pfile); + return(0); +} + + +void print_options(FILE *pfile, bool verbose) +{ + int max_width = 0; + int cur_width; + const char *text; + + const char *names[] = + { + "{ False, True }", + "{ Ignore, Add, Remove, Force }", + "Number", + "{ Auto, LF, CR, CRLF }", + "{ Ignore, Lead, Trail }", + "String", + }; + + option_name_map_it it; + + /* Find the max width of the names */ + for (it = option_name_map.begin(); it != option_name_map.end(); it++) + { + cur_width = strlen(it->second.name); + if (cur_width > max_width) + { + max_width = cur_width; + } + } + max_width++; + + fprintf(pfile, "# Uncrustify %s\n", UNCRUSTIFY_VERSION); + + /* Print the all out */ + for (group_map_it jt = group_map.begin(); jt != group_map.end(); jt++) + { + fprintf(pfile, "#\n# %s\n#\n\n", jt->second.short_desc); + + for (option_list_it it = jt->second.options.begin(); it != jt->second.options.end(); it++) + { + const option_map_value *option = get_option_name(*it); + cur_width = strlen(option->name); + fprintf(pfile, "%s%*c%s\n", + option->name, + max_width - cur_width, ' ', + names[option->type]); + + text = option->short_desc; + + if (text != NULL) + { + fputs(" ", pfile); + while (*text != 0) + { + fputc(*text, pfile); + if (*text == '\n') + { + fputs(" ", pfile); + } + text++; + } + } + fputs("\n\n", pfile); + } + } +} + + +/** + * Sets non-zero settings defaults + * + * TODO: select from various sets? - i.e., K&R, GNU, Linux, Ben + */ +void set_option_defaults(void) +{ + cpd.settings[UO_newlines].le = LE_AUTO; + cpd.settings[UO_input_tab_size].n = 8; + cpd.settings[UO_output_tab_size].n = 8; + cpd.settings[UO_indent_columns].n = 8; + cpd.settings[UO_indent_with_tabs].n = 1; + cpd.settings[UO_indent_label].n = 1; + cpd.settings[UO_indent_access_spec].n = 1; + cpd.settings[UO_sp_before_comma].a = AV_REMOVE; + cpd.settings[UO_string_escape_char].n = '\\'; + cpd.settings[UO_sp_not].a = AV_REMOVE; + cpd.settings[UO_sp_inv].a = AV_REMOVE; + cpd.settings[UO_sp_addr].a = AV_REMOVE; + cpd.settings[UO_sp_deref].a = AV_REMOVE; + cpd.settings[UO_sp_member].a = AV_REMOVE; + cpd.settings[UO_sp_sign].a = AV_REMOVE; + cpd.settings[UO_sp_incdec].a = AV_REMOVE; + cpd.settings[UO_sp_after_type].a = AV_FORCE; + cpd.settings[UO_sp_before_nl_cont].a = AV_ADD; + cpd.settings[UO_sp_before_case_colon].a = AV_REMOVE; + cpd.settings[UO_sp_before_semi].a = AV_REMOVE; + cpd.settings[UO_sp_after_semi].a = AV_ADD; + cpd.settings[UO_sp_after_semi_for].a = AV_FORCE; + cpd.settings[UO_cmt_indent_multi].b = true; + cpd.settings[UO_cmt_multi_check_last].b = true; + cpd.settings[UO_pp_indent_count].n = 1; + cpd.settings[UO_align_left_shift].b = true; + cpd.settings[UO_indent_align_assign].b = true; + cpd.settings[UO_sp_pp_concat].a = AV_ADD; + cpd.settings[UO_sp_pp_stringify].a = AV_ADD; +} + + +std::string argtype_to_string(argtype_e argtype) +{ + switch (argtype) + { + case AT_BOOL: + return("false/true"); + + case AT_IARF: + return("ignore/add/remove/force"); + + case AT_NUM: + return("number"); + + case AT_LINE: + return("auto/lf/crlf/cr"); + + case AT_POS: + return("ignore/lead/trail"); + + case AT_STRING: + return("string"); + + default: + LOG_FMT(LWARN, "Unknown argtype '%d'\n", argtype); + return(""); + } +} + + +std::string bool_to_string(bool val) +{ + if (val) + { + return("true"); + } + else + { + return("false"); + } +} + + +std::string argval_to_string(argval_t argval) +{ + switch (argval) + { + case AV_IGNORE: + return("ignore"); + + case AV_ADD: + return("add"); + + case AV_REMOVE: + return("remove"); + + case AV_FORCE: + return("force"); + + default: + LOG_FMT(LWARN, "Unknown argval '%d'\n", argval); + return(""); + } +} + + +std::string number_to_string(int number) +{ + char buffer[12]; // 11 + 1 + + sprintf(buffer, "%d", number); + + /*NOTE: this creates a std:string class from the char array. + * It isn't returning a pointer to stack memory. + */ + return(buffer); +} + + +std::string lineends_to_string(lineends_e linends) +{ + switch (linends) + { + case LE_LF: + return("lf"); + + case LE_CRLF: + return("crlf"); + + case LE_CR: + return("cr"); + + case LE_AUTO: + return("auto"); + + default: + LOG_FMT(LWARN, "Unknown lineends '%d'\n", linends); + return(""); + } +} + + +std::string tokenpos_to_string(tokenpos_e tokenpos) +{ + switch (tokenpos) + { + case TP_IGNORE: + return("ignore"); + + case TP_LEAD: + return("lead"); + + case TP_TRAIL: + return("trail"); + + default: + LOG_FMT(LWARN, "Unknown tokenpos '%d'\n", tokenpos); + return(""); + } +} + + +std::string op_val_to_string(argtype_e argtype, op_val_t op_val) +{ + switch (argtype) + { + case AT_BOOL: + return(bool_to_string(op_val.b)); + + case AT_IARF: + return(argval_to_string(op_val.a)); + + case AT_NUM: + return(number_to_string(op_val.n)); + + case AT_LINE: + return(lineends_to_string(op_val.le)); + + case AT_POS: + return(tokenpos_to_string(op_val.tp)); + + case AT_STRING: + return(op_val.str != NULL ? op_val.str : ""); + + default: + LOG_FMT(LWARN, "Unknown argtype '%d'\n", argtype); + return(""); + } +} diff --git a/src/options.h b/src/options.h new file mode 100644 index 0000000000..0d0473504a --- /dev/null +++ b/src/options.h @@ -0,0 +1,591 @@ +/** + * @file options.h + * Enum and settings for all the options. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef OPTIONS_H_INCLUDED +#define OPTIONS_H_INCLUDED + +#include +#include +#include + +enum argtype_e +{ + AT_BOOL, /**< true / false */ + AT_IARF, /**< Ignore / Add / Remove / Force */ + AT_NUM, /**< Number */ + AT_LINE, /**< Line Endings */ + AT_POS, /**< start/end or Trail/Lead */ + AT_STRING, /**< string value */ +}; + +/** Arg values - these are bit fields*/ +enum argval_t +{ + AV_IGNORE = 0, + AV_ADD = 1, + AV_REMOVE = 2, + AV_FORCE = 3, /**< remove + add */ +}; + +/** Line endings */ +enum lineends_e +{ + LE_LF, /* "\n" */ + LE_CRLF, /* "\r\n" */ + LE_CR, /* "\r" */ + + LE_AUTO, /* keep last */ +}; + +/** Token position */ +enum tokenpos_e +{ + TP_IGNORE, /* don't change it */ + TP_LEAD, /* at the start of a line or leading */ + TP_TRAIL, /* at the end of a line or trailing */ +}; + +union op_val_t +{ + argval_t a; + int n; + bool b; + lineends_e le; + tokenpos_e tp; + const char *str; +}; + +/** Groups for options */ +enum uncrustify_groups +{ + UG_general, + UG_indent, + UG_space, + UG_align, + UG_newline, + UG_position, + UG_linesplit, + UG_blankline, + UG_codemodify, + UG_comment, + UG_preprocessor, + UG_group_count +}; + +/** + * Keep this grouped by functionality + */ +enum uncrustify_options +{ + UO_newlines, // Set to AUTO, LF, CRLF, or CR + + /* + * Basic Indenting stuff + */ + //UO_indent, //TODO: 0=don't change indentation, 1=change indentation + + UO_input_tab_size, // tab size on input file: usually 8 + UO_output_tab_size, // tab size for output: usually 8 + + UO_indent_columns, // ie 3 or 8 + UO_indent_with_tabs, // 1=only to the 'level' indent, 2=use tabs for indenting + //UO_indent_brace_struct, //TODO: spaces to indent brace after struct/enum/union def + //UO_indent_paren, //TODO: indent for open paren on next line (1) + UO_indent_paren_nl, // indent-align under paren for open followed by nl + UO_indent_square_nl, // indent-align under square for open followed by nl + UO_indent_paren_close, // indent of close paren after a newline + UO_indent_comma_paren, // indent of comma if inside a paren + UO_indent_bool_paren, // indent of bool if inside a paren + UO_pp_indent, // indent preproc 1 space per level (add/ignore/remove) + UO_pp_indent_at_level, // indent #if, #else, #endif at brace level + UO_pp_indent_count, + UO_pp_define_at_level, // indent #define at brace level + UO_pp_space, // spaces between # and word (add/ignore/remove) + UO_pp_space_count, // the number of spaces for add/force + UO_pp_indent_region, // indent of #region and #endregion, see indent_label + UO_pp_region_indent_code, // whether to indent the code inside region stuff + UO_pp_indent_if, + UO_pp_if_indent_code, + + UO_indent_switch_case, // spaces to indent case from switch + UO_indent_case_shift, // spaces to shift the line with the 'case' + UO_indent_case_brace, // spaces to indent '{' from case (usually 0 or indent_columns) + + UO_indent_brace, // spaces to indent '{' from level (usually 0) + UO_indent_braces, // whether to indent the braces or not + UO_indent_braces_no_func, // whether to not indent the function braces (depends on UO_indent_braces) + UO_indent_brace_parent, // indent the braces based on the parent size (if=3, for=4, etc) + UO_indent_label, // 0=left >0=col from left, <0=sub from brace indent + UO_indent_access_spec, // same as indent_label, but for "private:", "public:" + UO_indent_access_spec_body, // indent private/public/protected inside a class (overrides indent_access_spec) + + UO_indent_align_string, // True/False - indent align broken strings + UO_indent_xml_string, // Number amount to indent XML strings + + UO_indent_col1_comment, // indent comments in column 1 + + UO_indent_func_call_param, // indent continued function calls to indent_columns + UO_indent_func_proto_param, // same, but for function protos + UO_indent_func_def_param, // same, but for function defs + UO_indent_func_class_param, // same, but for classes + UO_indent_func_ctor_var_param, + UO_indent_template_param, + UO_indent_func_param_double, // double the tab indent for + + UO_indent_func_const, // indentation for standalone "const" qualifier + UO_indent_func_throw, // indentation for standalone "throw" qualifier + + UO_indent_namespace, // indent stuff inside namespace braces + UO_indent_namespace_level, // level to indent namespace blocks + UO_indent_namespace_limit, // no indent if namespace is longer than this + UO_indent_extern, + UO_indent_class, // indent stuff inside class braces + UO_indent_class_colon, // indent stuff after a class colon + + UO_indent_member, // indent lines broken at a member '.' or '->' + + UO_indent_sing_line_comments, // indent single line ('//') comments on lines before code + UO_indent_relative_single_line_comments, // indent single line ('//') comments after code + UO_indent_preserve_sql, // preserve indent of EXEC SQL statement body + UO_indent_align_assign, + + UO_indent_else_if, + UO_indent_var_def_blk, // indent a variable def block that appears at the top + + /* + * Misc inter-element spacing + */ + + UO_sp_paren_brace, // space between ')' and '{' + UO_sp_fparen_brace, // space between ')' and '{' of function + UO_sp_sparen_brace, // space between ')' and '{' of if, while, etc + + UO_sp_after_cast, // space after C & D cast - "(int) a" vs "(int)a" + UO_sp_inside_paren_cast, // spaces inside the parens of a cast + UO_sp_cpp_cast_paren, + + UO_sp_before_byref, // space before '&' of 'fcn(int& idx)' + UO_sp_before_unnamed_byref, + UO_sp_after_byref, // space after a '&' as in 'int& var' + + UO_sp_after_type, // space between type and word + + UO_sp_inside_fparen, // space inside 'foo( xxx )' vs 'foo(xxx)' + UO_sp_inside_fparens, // space inside 'foo( )' vs 'foo()' + UO_sp_inside_paren, // space inside '+ ( xxx )' vs '+ (xxx)' + UO_sp_inside_square, // space inside 'byte[ 5 ]' vs 'byte[5]' + UO_sp_inside_sparen, // space inside 'if( xxx )' vs 'if(xxx)' + UO_sp_inside_sparen_close, + UO_sp_inside_angle, // space inside '<>', as in '' + + UO_sp_before_sparen, // space before '(' of 'if/for/while/switch' + UO_sp_after_sparen, /* space after ')' of 'if/for/while/switch' + * the do-while does not get set here */ + UO_sp_after_invariant_paren, + UO_sp_invariant_paren, + + UO_sp_template_angle, + UO_sp_before_angle, // space before '<>', as in '' + UO_sp_after_angle, // space after '<>', as in '' + UO_sp_angle_paren, // space between '<>' and '(' in "a = new List();" + UO_sp_angle_word, // space between '<>' and a word in "List a;" + + UO_sp_before_square, // space before single '[' + UO_sp_before_squares, // space before '[]', as in 'byte []' + + UO_sp_paren_paren, // space between nested parens - '( (' vs '((' + UO_sp_balance_nested_parens, // balance spaces inside nested parens + + UO_sp_return_paren, // space between 'return' and '(' + UO_sp_sizeof_paren, // space between 'sizeof' and '(' + + UO_sp_after_comma, // space after ',' + UO_sp_before_comma, // space before ',' + + UO_sp_before_ellipsis, // space before '...' + + UO_sp_arith, // space around + - / * etc + UO_sp_bool, // space around || && + UO_sp_pp_concat, // space around ## + UO_sp_pp_stringify, // space around # + UO_sp_compare, // space around < > ==, etc + UO_sp_assign, // space around =, +=, etc + UO_sp_before_assign, // space before =, +=, etc + UO_sp_after_assign, // space after =, +=, etc + UO_sp_enum_assign, // space around = in enum + UO_sp_enum_before_assign, // space before = in enum + UO_sp_enum_after_assign, // space after = in enum + UO_sp_after_class_colon, // space after class ':' + UO_sp_before_class_colon, // space before class ':' + UO_sp_before_case_colon, + + UO_sp_func_def_paren, // space between 'func' and '(' - "foo (" vs "foo(" + UO_sp_func_call_paren, // space between 'func' and '(' - "foo (" vs "foo(" + UO_sp_func_call_user_paren, + UO_sp_func_proto_paren, // space between 'func' and '(' - "foo (" vs "foo(" + UO_sp_func_class_paren, // space between ctor/dtor and '(' + + UO_sp_attribute_paren, // space between '__attribute__' and '(' + UO_sp_defined_paren, + UO_sp_throw_paren, + + UO_sp_type_func, // space between return type and 'func' + // a minimum of 1 is forced except for '*' + UO_sp_before_ptr_star, // space before a '*' that is part of a type + UO_sp_before_unnamed_ptr_star, + UO_sp_after_ptr_star, // space after a '*' that is part of a type + UO_sp_after_ptr_star_func, // space between a '*' and a function proto/def + UO_sp_before_ptr_star_func, + UO_sp_after_byref_func, + UO_sp_before_byref_func, + UO_sp_between_ptr_star, // space between two '*' that are part of a type + + UO_sp_special_semi, /* space empty stmt ';' on while, if, for + * example "while (*p++ = ' ') ;" */ + UO_sp_before_semi, // space before all ';' + UO_sp_before_semi_for, // space before the two ';' in a for() - non-empty + UO_sp_before_semi_for_empty, // space before ';' in empty for statement + UO_sp_after_semi, + UO_sp_after_semi_for, + UO_sp_after_semi_for_empty, // space after final ';' in empty for statement + UO_sp_inside_braces, // space inside '{' and '}' - "{ 1, 2, 3 }" + UO_sp_inside_braces_empty, // space inside '{' and '}' - "{ }" + UO_sp_inside_braces_enum, // space inside enum '{' and '}' - "{ a, b, c }" + UO_sp_inside_braces_struct, // space inside struct/union '{' and '}' + + UO_sp_macro, // space between macro and value, ie '#define a 6' + UO_sp_macro_func, // space between macro and value, ie '#define a 6' + + UO_sp_square_fparen, // weird pawn stuff: native yark[rect](a[rect]) + UO_sp_after_tag, // pawn: space after a tag colon + + UO_sp_after_operator, // space after operator when followed by a punctuator + UO_sp_after_operator_sym, // space after operator when followed by a punctuator + UO_sp_else_brace, + UO_sp_brace_else, + UO_sp_brace_typedef, + + UO_sp_catch_brace, + UO_sp_brace_catch, + UO_sp_finally_brace, + UO_sp_brace_finally, + UO_sp_try_brace, + UO_sp_getset_brace, + + UO_sp_before_dc, + UO_sp_after_dc, + UO_sp_d_array_colon, + UO_sp_not, + UO_sp_inv, + UO_sp_addr, + UO_sp_deref, + UO_sp_member, + UO_sp_sign, + UO_sp_incdec, + UO_sp_before_nl_cont, + UO_sp_after_oc_scope, + UO_sp_before_oc_colon, + UO_sp_after_oc_colon, + UO_sp_before_send_oc_colon, + UO_sp_after_send_oc_colon, + UO_sp_after_oc_type, + UO_sp_after_oc_return_type, + UO_sp_after_oc_at_sel, + UO_sp_cond_colon, + UO_sp_cond_question, + UO_sp_case_label, + UO_sp_range, + UO_sp_cmt_cpp_start, + + /* + * Line splitting options (for long lines) + */ + + UO_code_width, // ie 80 columns + UO_ls_for_split_full, // try to split long 'for' statements at semi-colons + UO_ls_func_split_full, // try to split long func proto/def at comma + //UO_ls_before_bool_op, //TODO: break line before of after boolean op + //UO_ls_before_paren, //TODO: break before open paren + //UO_ls_after_arith, //TODO: break after arith op '+', etc + //UO_ls_honor_newlines, //TODO: don't remove newlines on split lines + + + /* + * code alignment (not left column spaces/tabs) + */ + + UO_align_with_tabs, // use tabs for aligning (0/1) + UO_align_keep_tabs, // keep non-indenting tabs + UO_align_on_tabstop, // always align on tabstops + UO_align_nl_cont, // align the back-slash \n combo (macros) + UO_align_enum_equ_span, // align the '=' in enums + UO_align_enum_equ_thresh, // threshold for aligning on '=' in enums. 0=no limit + UO_align_assign_span, // align on '='. 0=don't align + UO_align_assign_thresh, // threshold for aligning on '='. 0=no limit + UO_align_right_cmt_span, // align comment that end lines. 0=don't align + UO_align_right_cmt_mix, // mix comments after '}' and preproc with others + UO_align_right_cmt_gap, + UO_align_right_cmt_at_col, // align comment that end lines at or beyond column N; 'pulls in' comments as a bonus side effect + UO_align_func_params, // align prototype variable defs on variable + UO_align_same_func_call_params, + UO_align_var_def_span, // align variable defs on variable (span for regular stuff) + UO_align_var_def_thresh, // align variable defs threshold + UO_align_var_def_gap, // align variable defs gap + UO_align_var_def_colon_gap, // align variable defs gap for bit colons + UO_align_var_def_inline, // also align inline struct/enum/union var defs + UO_align_var_def_star_style, // see UO_align_typedef_star_style + UO_align_var_def_amp_style, // see UO_align_typedef_star_style + UO_align_var_def_colon, // align the colon in struct bit fields + UO_align_var_def_attribute, + UO_align_var_struct_span, // span for struct/union (0=don't align) + UO_align_var_struct_thresh, // threshold for struct/union, 0=no limit + UO_align_var_struct_gap, // gap for struct/union + UO_align_pp_define_span, // align bodies in #define statments + //UO_align_pp_define_col_min, //TODO: min column for a #define value + //UO_align_pp_define_col_max, //TODO: max column for a #define value + UO_align_pp_define_gap, // min space between define label and value "#define a <---> 16" + //UO_align_enum_col_min, //TODO: the min column for enum '=' alignment + //UO_align_enum_col_max, //TODO: the max column for enum '=' alignment + UO_align_struct_init_span, // align structure initializer values + UO_align_func_proto_span, // align function prototypes + UO_align_func_proto_gap, // align function prototypes + UO_align_on_operator, + UO_align_mix_var_proto, // mix function prototypes and variable decl + UO_align_single_line_func, // mix single line function with prototypes + UO_align_single_line_brace, // align the open brace of single line functions + UO_align_single_line_brace_gap, // gap for align_single_line_brace + UO_align_oc_msg_spec_span, // align ObjC msg spec + UO_align_number_left, // left-align numbers (not fully supported, yet) + UO_align_typedef_span, // align single-line typedefs + UO_align_typedef_gap, // minimum spacing + UO_align_typedef_func, // how to align func type with types + UO_align_typedef_star_style, // Start aligning style + // 0: '*' not part of type + // 1: '*' part of the type - no space + // 2: '*' part of type, dangling + UO_align_typedef_amp_style, // align_typedef_star_style for ref '&' stuff + //UO_align_struct_array_brace, // TODO: align array of structure initializers + UO_align_left_shift, + UO_align_oc_msg_colon, + + + /* + * Newline adding and removing options + */ + + UO_nl_fdef_brace, // "int foo() {" vs "int foo()\n{" + UO_nl_func_paren, // newline between function and open paren + UO_nl_func_decl_start, // newline after the '(' in a function decl + UO_nl_func_decl_args, // newline after each ',' in a function decl + UO_nl_func_decl_end, // newline before the ')' in a function decl + UO_nl_func_decl_empty, // as above, but for empty parens '()' + UO_nl_func_type_name, // newline between return type and func name in def + UO_nl_func_type_name_class, // newline between return type and func name in class + UO_nl_func_scope_name, + UO_nl_func_proto_type_name, // nl_func_type_name, but for prottypes + UO_nl_func_var_def_blk, // newline after a block of variable defs + UO_nl_before_case, // newline before 'case' statement + UO_nl_before_throw, + UO_nl_after_return, /* newline after return statement */ + UO_nl_return_expr, + UO_nl_after_case, /* disallow nested "case 1: a=3;" */ + UO_nl_after_semicolon, // disallow multiple statements on a line "a=1;b=4;" + UO_nl_after_brace_open, // force a newline after a brace open + UO_nl_after_brace_open_cmt, // put the newline before the comment + UO_nl_after_vbrace_open, // force a newline after a virtual brace open + UO_nl_after_brace_close, // force a newline after a brace close + UO_nl_fcall_brace, /* newline between function call and open brace */ + UO_nl_squeeze_ifdef, /* no blanks after #ifxx, #elxx, or before #endif */ + UO_nl_enum_brace, /* nl between enum and brace */ + UO_nl_struct_brace, /* nl between struct and brace */ + UO_nl_union_brace, /* nl between union and brace */ + UO_nl_assign_brace, /* nl between '=' and brace */ + UO_nl_assign_square, /* nl between '=' and '[' */ + UO_nl_after_square_assign, /* nl after '= [' */ + UO_nl_class_brace, /* nl between class name and brace */ + UO_nl_namespace_brace, /* nl between namespace name and brace */ + + UO_nl_brace_brace, /* nl between '{{' or '}}' */ + UO_nl_do_brace, /* nl between do and { */ + UO_nl_if_brace, /* nl between if and { */ + UO_nl_for_brace, /* nl between for and { */ + UO_nl_else_if, + UO_nl_else_brace, /* nl between else and { */ + UO_nl_finally_brace, /* nl between finally and { */ + UO_nl_brace_finally, /* nl between } and finally */ + UO_nl_try_brace, /* nl between try and { */ + UO_nl_getset_brace, /* nl between get/set and { */ + UO_nl_catch_brace, /* nl between catch and { */ + UO_nl_brace_catch, /* nl between } and catch */ + UO_nl_while_brace, /* nl between while and { */ + UO_nl_switch_brace, /* nl between switch and { */ + UO_nl_brace_else, // nl between } and else + UO_nl_brace_while, // nl between } and while of do stmt + + UO_nl_multi_line_cond, /* nl between ) and { when cond spans >=2 lines */ + UO_nl_elseif_brace, // nl between close paren and open brace in 'else if () {' + + UO_nl_multi_line_define, // nl after define XXX for multi-line define + + UO_nl_before_if, // nl before if + UO_nl_after_if, // nl after if/else + UO_nl_before_for, // nl before for + UO_nl_after_for, // nl after for close + UO_nl_before_while, // nl before while + UO_nl_after_while, // nl after while close + UO_nl_before_switch, // nl before switch + UO_nl_after_switch, // nl after switch close + UO_nl_before_do, // nl before do + UO_nl_after_do, // nl after while of do + UO_nl_ds_struct_enum_cmt, // nl between commented-elements of struct/enum + UO_nl_ds_struct_enum_close_brace, // force nl before } of struct/union/enum + + UO_nl_define_macro, // alter newlines in #define macros + UO_nl_start_of_file, // alter newlines at the start of file + UO_nl_start_of_file_min, // min number of newlines at the start of the file + UO_nl_end_of_file, // alter newlines at the end of file + UO_nl_end_of_file_min, // min number of newlines at the end of the file + + UO_nl_class_colon, // nl before/after class colon (tied to UO_pos_class_colon) + UO_nl_class_init_args, // newline after comma in class init args + UO_nl_collapse_empty_body, // change { \n } into {} + UO_nl_class_leave_one_liners, // leave one-line function bodies in "class xx { here }" + UO_nl_assign_leave_one_liners, // leave one-line assign bodies in "foo_t f = { a, b, c };" + UO_nl_enum_leave_one_liners, // leave one-line enum bodies in "enum FOO { BAR = 5 };" + UO_nl_getset_leave_one_liners, // leave one-line get/set bodies + UO_nl_func_leave_one_liners, // leave one-line function def bodies + UO_nl_if_leave_one_liners, + + UO_nl_template_class, // newline between '>' and class in "template class" + + UO_nl_create_if_one_liner, + UO_nl_create_for_one_liner, + UO_nl_create_while_one_liner, + + UO_pos_arith, // position of trailing/leading arithmetic ops + UO_pos_assign, // position of trailing/leading = + UO_pos_bool, // position of trailing/leading &&/|| + UO_pos_compare, // position of trailing/leading <=/>, etc + UO_pos_conditional, // position of trailing/leading (b ? t : f) + UO_pos_comma, // position of comma in functions + UO_pos_class_comma, // position of comma in constructor init list + UO_pos_class_colon, // position of trailing/leading class colon + + + /* + * Blank line options + */ + + UO_nl_before_block_comment, // before a block comment (stand-alone comment-multi), except after brace open + UO_nl_before_cpp_comment, + UO_nl_before_c_comment, + UO_nl_after_multiline_comment, // NL after multiline comment + UO_nl_after_func_body, // after the closing brace of a function body + UO_nl_after_func_body_one_liner, // after the closing brace of a single line function body + UO_nl_after_func_proto, // after each prototype + UO_nl_after_func_proto_group, // after a block of prototypes + //UO_nl_after_var_def_group, // after a group of variable defs at top of proc + //UO_nl_after_ifdef, // after #if or #ifdef - but not if covers whole file + UO_nl_max, // maximum consecutive newlines (3 = 2 blank lines) + UO_nl_before_access_spec, // number of newlines before "private:", "public:" (0=no change) + UO_nl_after_access_spec, // number of newlines after "private:", "public:" (0=no change) + UO_nl_comment_func_def, + UO_nl_after_try_catch_finally, + UO_nl_between_get_set, + UO_nl_around_cs_property, + + UO_eat_blanks_after_open_brace, // remove blank lines after { + UO_eat_blanks_before_close_brace, // remove blank lines before } + + + /* + * code modifying options (non-whitespace) + */ + + UO_mod_paren_on_return, // add or remove paren on return + UO_mod_full_brace_nl, // max number of newlines to span w/o braces + UO_mod_full_brace_if, // add or remove braces on if + UO_mod_full_brace_if_chain, + UO_mod_full_brace_for, // add or remove braces on for + UO_mod_full_brace_do, // add or remove braces on do + UO_mod_full_brace_while, // add or remove braces on while + UO_mod_pawn_semicolon, // add optional semicolons + UO_mod_full_brace_function, // add optional braces on Pawn functions + UO_mod_full_paren_if_bool, + UO_mod_remove_extra_semicolon, // remove extra semicolons + UO_mod_add_long_function_closebrace_comment, + UO_mod_add_long_switch_closebrace_comment, + UO_mod_add_long_ifdef_else_comment, + UO_mod_add_long_ifdef_endif_comment, + UO_mod_sort_import, + UO_mod_sort_using, + UO_mod_sort_include, + UO_mod_move_case_break, + UO_mod_case_brace, + UO_mod_remove_empty_return, + + + /* + * Comment modifications + */ + + UO_cmt_width, // column to wrap comments + UO_cmt_reflow_mode, // comment reflow style + UO_cmt_indent_multi, // change left indent of multiline comments + UO_cmt_star_cont, // put a star on subsequent comment lines + UO_cmt_sp_before_star_cont, // # of spaces for subsequent comment lines (before possible star) + UO_cmt_sp_after_star_cont, // # of spaces for subsequent comment lines (after star) + UO_cmt_cpp_to_c, // convert CPP comments to C comments + UO_cmt_cpp_group, // if UO_cmt_cpp_to_c, try to group in one big C comment + UO_cmt_c_group, // try to group neighboring C comments + UO_cmt_c_nl_start, // put a blank /* at the start of a combined group + UO_cmt_c_nl_end, // put a nl before the */ in a combined group + UO_cmt_cpp_nl_start, // put a blank /* at the start of a converted group + UO_cmt_cpp_nl_end, // put a nl before the */ in a converted group + UO_cmt_multi_check_last, + + UO_cmt_insert_file_header, + UO_cmt_insert_file_footer, + UO_cmt_insert_func_header, + UO_cmt_insert_class_header, + UO_cmt_insert_before_preproc, + + UO_string_escape_char, // the string escape char to use + UO_string_escape_char2, // the string escape char to use + + /* This is used to get the enumeration count */ + UO_option_count +}; + +struct group_map_value +{ + uncrustify_groups id; + const char *short_desc; + const char *long_desc; + std::list options; +}; + +struct option_map_value +{ + uncrustify_options id; + uncrustify_groups group_id; + argtype_e type; + int min_val; + int max_val; + const char *name; + const char *short_desc; + const char *long_desc; +}; + + +typedef std::map::iterator option_name_map_it; +typedef std::map::iterator group_map_it; +typedef std::list::iterator option_list_it; +typedef std::list::const_iterator option_list_cit; + + +#endif /* OPTIONS_H_INCLUDED */ diff --git a/src/output.cpp b/src/output.cpp new file mode 100644 index 0000000000..b07b50e470 --- /dev/null +++ b/src/output.cpp @@ -0,0 +1,1479 @@ +/** + * @file output.cpp + * Does all the output & comment formatting. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "prototypes.h" +#include "chunk_list.h" +#include "unc_ctype.h" +#include +#include + +static void output_comment_multi(chunk_t *pc); +static void output_comment_multi_simple(chunk_t *pc); + +struct cmt_reflow +{ + chunk_t *pc; + int column; /* Column of the comment start */ + int br_column; /* Brace column (for indenting with tabs) */ + int word_count; /* number of words on this line */ + bool kw_subst; /* do keyword substitution */ + const char *cont_text; /* fixed text to output at the start of the line (3-chars) */ + bool reflow; /* reflow the current line */ +}; + + +static chunk_t *output_comment_c(chunk_t *pc); +static chunk_t *output_comment_cpp(chunk_t *pc); +static void add_comment_text(const char *text, int len, + cmt_reflow& cmt, bool esc_close); + +/** + * All output text is sent here, one char at a time. + */ +static void add_char(char ch) +{ + static char last_char = 0; + + /* If we did a '\r' and it isn't followed by a '\n', then output a newline */ + if ((last_char == '\r') && (ch != '\n')) + { + fputs(cpd.newline, cpd.fout); + cpd.column = 1; + cpd.did_newline = 1; + } + + /* convert a newline into the LF/CRLF/CR sequence */ + if (ch == '\n') + { + fputs(cpd.newline, cpd.fout); + cpd.column = 1; + cpd.did_newline = 1; + } + else if (ch == '\r') + { + /* do not output '\r' */ + cpd.column = 1; + cpd.did_newline = 1; + } + else + { + /* Explicitly disallow a tab after a space */ + if ((ch == '\t') && (last_char == ' ')) + { + int endcol = next_tab_column(cpd.column); + while (cpd.column < endcol) + { + add_char(' '); + } + return; + } + else + { + fputc(ch, cpd.fout); + if (ch == '\t') + { + cpd.column = next_tab_column(cpd.column); + } + else + { + cpd.column++; + } + } + } + last_char = ch; +} + + +static void add_text(const char *text) +{ + char ch; + + while ((ch = *text) != 0) + { + text++; + add_char(ch); + } +} + + +static void add_text_len(const char *text, int len) +{ + while (len-- > 0) + { + add_char(*text); + text++; + } +} + + +/** + * Count the number of characters to the end of the next chunk of text. + * If it exceeds the limit, return true. + */ +static bool next_word_exceeds_limit(const char *text) +{ + int length = 0; + + /* Count any whitespace */ + while ((*text != 0) && unc_isspace(*text)) + { + text++; + length++; + } + + /* Count non-whitespace */ + while ((*text != 0) && !unc_isspace(*text)) + { + text++; + length++; + } + return((cpd.column + length - 1) > cpd.settings[UO_cmt_width].n); +} + + +/** + * Advance to a specific column + * cpd.column is the current column + * + * @param column The column to advance to + */ +static void output_to_column(int column, bool allow_tabs) +{ + int nc; + + cpd.did_newline = 0; + if (allow_tabs) + { + /* tab out as far as possible and then use spaces */ + while ((nc = next_tab_column(cpd.column)) <= column) + { + add_text("\t"); + } + } + /* space out the final bit */ + while (cpd.column < column) + { + add_text(" "); + } +} + + +/** + * Output to the column using indent_with_tabs as the rule. + * + * @param column the column that we should end up in + * @param brace_col the level that indent_with_tabs=1 should tab to + */ +static void output_indent(int column, int brace_col) +{ + cpd.did_newline = 0; + if ((cpd.column == 1) && (cpd.settings[UO_indent_with_tabs].n != 0)) + { + if (cpd.settings[UO_indent_with_tabs].n == 2) + { + brace_col = column; + } + + /* tab out as far as possible and then use spaces */ + while (next_tab_column(cpd.column) <= brace_col) + { + add_text("\t"); + } + } + + /* space out the rest */ + while (cpd.column < column) + { + add_text(" "); + } +} + + +void output_parsed(FILE *pfile) +{ + chunk_t *pc; + int cnt; + + output_options(pfile); + output_defines(pfile); + output_types(pfile); + + fprintf(pfile, "-=====-\n"); + fprintf(pfile, "Line Tag Parent Columns Br/Lvl/pp Flag Nl Text"); + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + fprintf(pfile, "\n%3d> %13.13s[%13.13s][%2d/%2d/%2d][%d/%d/%d][%8x][%d-%d]", + pc->orig_line, get_token_name(pc->type), + get_token_name(pc->parent_type), + pc->column, pc->orig_col, pc->orig_col_end, + pc->brace_level, pc->level, pc->pp_level, + pc->flags, pc->nl_count, pc->after_tab); + + if ((pc->type != CT_NEWLINE) && (pc->len != 0)) + { + for (cnt = 0; cnt < pc->column; cnt++) + { + fprintf(pfile, " "); + } + if (pc->type != CT_NL_CONT) + { + fprintf(pfile, "%.*s", pc->len, pc->str); + } + else + { + fprintf(pfile, "\\"); + } + } + } + fprintf(pfile, "\n-=====-\n"); + fflush(pfile); +} + + +void output_options(FILE *pfile) +{ + int idx; + const option_map_value *ptr; + + fprintf(pfile, "-== Options ==-\n"); + for (idx = 0; idx < UO_option_count; idx++) + { + ptr = get_option_name(idx); + if (ptr != NULL) + { + if (ptr->type == AT_STRING) + { + fprintf(pfile, "%3d) %32s = \"%s\"\n", + ptr->id, ptr->name, + op_val_to_string(ptr->type, cpd.settings[ptr->id]).c_str()); + } + else + { + fprintf(pfile, "%3d) %32s = %s\n", + ptr->id, ptr->name, + op_val_to_string(ptr->type, cpd.settings[ptr->id]).c_str()); + } + } + } +} + + +/** + * This renders the chunk list to a file. + */ +void output_text(FILE *pfile) +{ + chunk_t *pc; + chunk_t *prev; + int cnt; + int lvlcol; + bool allow_tabs; + + cpd.fout = pfile; + + cpd.did_newline = 1; + cpd.column = 1; + + if (cpd.bom != NULL) + { + add_text_len(cpd.bom->str, cpd.bom->len); + } + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type == CT_NEWLINE) + { + for (cnt = 0; cnt < pc->nl_count; cnt++) + { + add_char('\n'); + } + cpd.did_newline = 1; + cpd.column = 1; + LOG_FMT(LOUTIND, " xx\n"); + } + else if (pc->type == CT_NL_CONT) + { + /* FIXME: this really shouldn't be done here! */ + if ((pc->flags & PCF_WAS_ALIGNED) == 0) + { + if (cpd.settings[UO_sp_before_nl_cont].a & AV_REMOVE) + { + pc->column = cpd.column + (cpd.settings[UO_sp_before_nl_cont].a == AV_FORCE); + } + else + { + /* Try to keep the same relative spacing */ + prev = chunk_get_prev(pc); + if ((prev != NULL) && (prev->nl_count == 0)) + { + int orig_sp = (pc->orig_col - prev->orig_col_end); + pc->column = cpd.column + orig_sp; + if ((cpd.settings[UO_sp_before_nl_cont].a != AV_IGNORE) && + (pc->column < (cpd.column + 1))) + { + pc->column = cpd.column + 1; + } + } + } + } + output_to_column(pc->column, (cpd.settings[UO_indent_with_tabs].n == 2)); + add_char('\\'); + add_char('\n'); + cpd.did_newline = 1; + cpd.column = 1; + LOG_FMT(LOUTIND, " \\xx\n"); + } + else if (pc->type == CT_COMMENT_MULTI) + { + if (cpd.settings[UO_cmt_indent_multi].b) + { + output_comment_multi(pc); + } + else + { + output_comment_multi_simple(pc); + } + } + else if (pc->type == CT_COMMENT_CPP) + { + pc = output_comment_cpp(pc); + } + else if (pc->type == CT_COMMENT) + { + pc = output_comment_c(pc); + } + else if (pc->type == CT_JUNK) + { + /* do not adjust the column for junk */ + add_text_len(pc->str, pc->len); + } + else if (pc->len == 0) + { + /* don't do anything for non-visible stuff */ + LOG_FMT(LOUTIND, " <%d> -", pc->column); + } + else + { + /* indent to the 'level' first */ + if (cpd.did_newline) + { + if (cpd.settings[UO_indent_with_tabs].n == 1) + { + /* FIXME: it would be better to properly set column_indent in + * indent_text(), but this hack for '}' and ':' seems to work. */ + if ((pc->type == CT_BRACE_CLOSE) || + chunk_is_str(pc, ":", 1) || + (pc->type == CT_PREPROC)) + { + lvlcol = pc->column; + } + else + { + lvlcol = pc->column_indent; + if (lvlcol > pc->column) + { + lvlcol = pc->column; + } + } + + if (lvlcol > 1) + { + output_to_column(lvlcol, true); + } + } + allow_tabs = (cpd.settings[UO_indent_with_tabs].n == 2) || + (chunk_is_comment(pc) && + (cpd.settings[UO_indent_with_tabs].n != 0)); + + LOG_FMT(LOUTIND, " %d> col %d/%d - ", pc->orig_line, pc->column, cpd.column); + } + else + { + /** + * Reformatting multi-line comments can screw up the column. + * Make sure we don't mess up the spacing on this line. + * This has to be done here because comments are not formatted + * until the output phase. + */ + if (pc->column < cpd.column) + { + reindent_line(pc, cpd.column); + } + + /* not the first item on a line */ + if (cpd.settings[UO_align_keep_tabs].b) + { + allow_tabs = pc->after_tab; + } + else + { + prev = chunk_get_prev(pc); + allow_tabs = (cpd.settings[UO_align_with_tabs].b && + ((pc->flags & PCF_WAS_ALIGNED) != 0) && + (((pc->column - 1) % cpd.settings[UO_output_tab_size].n) == 0) && + ((prev->column + prev->len + 1) != pc->column)); + } + LOG_FMT(LOUTIND, " %d -", pc->column); + } + + output_to_column(pc->column, allow_tabs); + add_text_len(pc->str, pc->len); + cpd.did_newline = chunk_is_newline(pc); + } + } +} + + +/** + * Given a multi-line comment block that starts in column X, figure out how + * much subsequent lines should be indented. + * + * The answer is either 0 or 1. + * + * The decision is based on: + * - the first line length + * - the second line leader length + * - the last line length + * + * If the first and last line are the same length and don't contain any alnum + * chars and (the first line len > 2 or the second leader is the same as the + * first line length), then the indent is 0. + * + * If the leader on the second line is 1 wide or missing, then the indent is 1. + * + * Otherwise, the indent is 0. + * + * @param str The comment string + * @param len Length of the comment + * @param start_col Starting column + * @return 0 or 1 + */ +static int calculate_comment_body_indent(const char *str, int len, int start_col) +{ + int idx = 0; + int first_len = 0; + int last_len = 0; + int width = 0; + + if (!cpd.settings[UO_cmt_indent_multi].b) + { + return(0); + } + + if (cpd.settings[UO_cmt_multi_check_last].b) + { + /* find the last line length */ + for (idx = len - 1; idx > 0; idx--) + { + if ((str[idx] == '\n') || (str[idx] == '\r')) + { + idx++; + while ((idx < len) && ((str[idx] == ' ') || (str[idx] == '\t'))) + { + idx++; + } + last_len = len - idx; + break; + } + } + } + + /* find the first line length */ + for (idx = 0; idx < len; idx++) + { + if ((str[idx] == '\n') || (str[idx] == '\r')) + { + first_len = idx; + while ((str[first_len - 1] == ' ') || (str[first_len - 1] == '\t')) + { + first_len--; + } + + /* handle DOS endings */ + if ((str[idx] == '\r') && (str[idx + 1] == '\n')) + { + idx++; + } + idx++; + break; + } + } + + /* Scan the second line */ + width = 0; + for (/* nada */; idx < len; idx++) + { + if ((str[idx] == ' ') || (str[idx] == '\t')) + { + if (width > 0) + { + break; + } + continue; + } + if ((str[idx] == '\n') || (str[idx] == '\r')) + { + /* Done with second line */ + break; + } + + /* Count the leading chars */ + if ((str[idx] == '*') || + (str[idx] == '|') || + (str[idx] == '\\') || + (str[idx] == '#') || + (str[idx] == '+')) + { + width++; + } + else + { + break; + } + } + + //LOG_FMT(LSYS, "%s: first=%d last=%d width=%d\n", __func__, first_len, last_len, width); + + /*TODO: make the first_len minimum (4) configurable? */ + if ((first_len == last_len) && ((first_len > 4) || (first_len == width))) + { + return(0); + } + + return((width == 2) ? 0 : 1); +} + + +static chunk_t *get_next_function(chunk_t *pc) +{ + while ((pc = chunk_get_next(pc)) != NULL) + { + if ((pc->type == CT_FUNC_DEF) || + (pc->type == CT_OC_MSG_DECL) || + (pc->type == CT_FUNC_PROTO)) + { + return(pc); + } + } + return(NULL); +} + + +static chunk_t *get_next_class(chunk_t *pc) +{ + while ((pc = chunk_get_next(pc)) != NULL) + { + if (pc->type == CT_CLASS) + { + return(chunk_get_next(pc)); + } + } + return(NULL); +} + + +/** + * Adds the javadoc-style @param and @return stuff, based on the params and + * return value for pc. + * If the arg list is '()' or '(void)', then no @params are added. + * Likewise, if the return value is 'void', then no @return is added. + */ +static void add_comment_javaparam(chunk_t *pc, cmt_reflow& cmt) +{ + chunk_t *fpo; + chunk_t *fpc; + chunk_t *tmp; + chunk_t *prev; + bool has_param = true; + bool need_nl = false; + + fpo = chunk_get_next_type(pc, CT_FPAREN_OPEN, pc->level); + if (fpo == NULL) + { + return; + } + fpc = chunk_get_next_type(fpo, CT_FPAREN_CLOSE, pc->level); + if (fpc == NULL) + { + return; + } + + /* Check for 'foo()' and 'foo(void)' */ + if (chunk_get_next_ncnl(fpo) == fpc) + { + has_param = false; + } + else + { + tmp = chunk_get_next_ncnl(fpo); + if ((tmp == chunk_get_prev_ncnl(fpc)) && + chunk_is_str(tmp, "void", 4)) + { + has_param = false; + } + } + + if (has_param) + { + tmp = fpo; + prev = NULL; + while ((tmp = chunk_get_next(tmp)) != NULL) + { + if ((tmp->type == CT_COMMA) || (tmp == fpc)) + { + if (need_nl) + { + add_comment_text("\n ", 2, cmt, false); + } + need_nl = true; + add_text("@param"); + if (prev != NULL) + { + add_text(" "); + add_text_len(prev->str, prev->len); + add_text(" TODO"); + } + prev = NULL; + if (tmp == fpc) + { + break; + } + } + if (tmp->type == CT_WORD) + { + prev = tmp; + } + } + } + + /* Do the return stuff */ + tmp = chunk_get_prev_ncnl(pc); + if ((tmp != NULL) && !chunk_is_str(tmp, "void", 4)) + { + if (need_nl) + { + add_comment_text("\n ", 2, cmt, false); + } + add_text("@return TODO"); + } +} + + +/** + * text starts with '$('. see if this matches a keyword and add text based + * on that keyword. + * @return the number of characters eaten from the text + */ +static int add_comment_kw(const char *text, int len, cmt_reflow& cmt) +{ + if ((len >= 11) && (memcmp(text, "$(filename)", 11) == 0)) + { + add_text(path_basename(cpd.filename)); + return(11); + } + if ((len >= 8) && (memcmp(text, "$(class)", 8) == 0)) + { + chunk_t *tmp = get_next_class(cmt.pc); + if (tmp != NULL) + { + add_text_len(tmp->str, tmp->len); + return(8); + } + } + + /* If we can't find the function, we are done */ + chunk_t *fcn = get_next_function(cmt.pc); + if (fcn == NULL) + { + return(0); + } + + if ((len >= 11) && (memcmp(text, "$(function)", 11) == 0)) + { + if (fcn->parent_type == CT_OPERATOR) + { + add_text_len("operator ", 9); + } + add_text_len(fcn->str, fcn->len); + return(11); + } + if ((len >= 12) && (memcmp(text, "$(javaparam)", 12) == 0)) + { + add_comment_javaparam(fcn, cmt); + return(12); + } + if ((len >= 9) && (memcmp(text, "$(fclass)", 9) == 0)) + { + chunk_t *tmp = chunk_get_prev_ncnl(fcn); + if ((tmp != NULL) && (tmp->type == CT_OPERATOR)) + { + tmp = chunk_get_prev_ncnl(tmp); + } + if ((tmp != NULL) && ((tmp->type == CT_DC_MEMBER) || + (tmp->type == CT_MEMBER))) + { + tmp = chunk_get_prev_ncnl(tmp); + add_text_len(tmp->str, tmp->len); + return(9); + } + } + return(0); +} + + +/** + * Outputs a comment. The initial opening '//' may be included in the text. + * Subsequent openings (if combining comments), should not be included. + * The closing (for C/D comments) should not be included. + * + * TODO: + * If reflowing text, the comment should be added one word (or line) at a time. + * A newline should only be sent if a blank line is encountered or if the next + * line is indented beyond the current line (optional?). + * If the last char on a line is a ':' or '.', then the next line won't be + * combined. + */ +static void add_comment_text(const char *text, int len, + cmt_reflow& cmt, bool esc_close) +{ + bool was_star = false; + bool was_slash = false; + bool was_dollar = false; + bool in_word = false; + + for (int idx = 0; idx < len; idx++) + { + if (!was_dollar && cmt.kw_subst && + (text[idx] == '$') && (len > (idx + 3)) && (text[idx + 1] == '(')) + { + idx += add_comment_kw(&text[idx], len - idx, cmt); + if (idx >= len) + { + break; + } + } + + /* Split the comment */ + if (text[idx] == '\n') + { + in_word = false; + add_char('\n'); + output_indent(cmt.column, cmt.br_column); + add_text(cmt.cont_text); + } + else if (cmt.reflow && + (text[idx] == ' ') && + (cpd.settings[UO_cmt_width].n > 0) && + ((cpd.column > cpd.settings[UO_cmt_width].n) || + next_word_exceeds_limit(text + idx))) + { + in_word = false; + add_char('\n'); + output_indent(cmt.column, cmt.br_column); + add_text(cmt.cont_text); + } + else + { + /* Escape a C closure in a CPP comment */ + if (esc_close && + ((was_star && (text[idx] == '/')) || + (was_slash && (text[idx] == '*')))) + { + add_char(' '); + } + if (!in_word && !unc_isspace(text[idx])) + { + cmt.word_count++; + } + in_word = !unc_isspace(text[idx]); + add_char(text[idx]); + was_star = (text[idx] == '*'); + was_slash = (text[idx] == '/'); + was_dollar = (text[idx] == '$'); + } + } +} + + +static void output_cmt_start(cmt_reflow& cmt, chunk_t *pc) +{ + cmt.word_count = 0; + cmt.pc = pc; + cmt.column = pc->column; + cmt.br_column = pc->column_indent; + + if ((pc->parent_type == CT_COMMENT_START) || + (pc->parent_type == CT_COMMENT_WHOLE)) + { + if (!cpd.settings[UO_indent_col1_comment].b && + (pc->orig_col == 1)) + { + cmt.column = 1; + cmt.br_column = 1; + } + } + else if (pc->parent_type == CT_COMMENT_END) + { + /* Make sure we have at least one space past the last token */ + chunk_t *prev = chunk_get_prev(pc); + if (prev != NULL) + { + int col_min = prev->column + prev->len + 1; + if (cmt.column < col_min) + { + cmt.column = col_min; + } + } + } + + /* Bump out to the column */ + output_indent(cmt.column, cmt.br_column); + + cmt.kw_subst = (pc->flags & PCF_INSERTED) != 0; +} + + +/** + * Checks to see if the current comment can be combined with the next comment. + * The two can be combined if: + * 1. They are the same type + * 2. There is exactly one newline between then + * 3. They are indented to the same level + */ +static bool can_combine_comment(chunk_t *pc, cmt_reflow& cmt) +{ + /* We can't combine if there is something other than a newline next */ + if (pc->parent_type == CT_COMMENT_START) + { + return(false); + } + + /* next is a newline for sure, make sure it is a single newline */ + chunk_t *next = chunk_get_next(pc); + if ((next != NULL) && (next->nl_count == 1)) + { + /* Make sure the comment is the same type at the same column */ + next = chunk_get_next(next); + if ((next != NULL) && + (next->type == pc->type) && + (((next->column == 1) && (pc->column == 1)) || + ((next->column == cmt.br_column) && (pc->column == cmt.br_column)) || + ((next->column > cmt.br_column) && (pc->parent_type == CT_COMMENT_END)))) + { + return(true); + } + } + return(false); +} + + +/** + * Outputs the C comment at pc. + * C comment combining is done here + * + * @return the last chunk output'd + */ +static chunk_t *output_comment_c(chunk_t *first) +{ + cmt_reflow cmt; + cmt.reflow = (cpd.settings[UO_cmt_reflow_mode].n != 1); + + output_cmt_start(cmt, first); + + cmt.cont_text = cpd.settings[UO_cmt_star_cont].b ? " *" : " "; + + /* See if we can combine this comment with the next comment */ + if (!cpd.settings[UO_cmt_c_group].b || + !can_combine_comment(first, cmt)) + { + /* Just add the single comment */ + add_comment_text(first->str, first->len, cmt, false); + return(first); + } + + add_text_len("/*", 2); + if (cpd.settings[UO_cmt_c_nl_start].b) + { + add_comment_text("\n", 1, cmt, false); + } + chunk_t *pc = first; + while (can_combine_comment(pc, cmt)) + { + add_comment_text(pc->str + 2, pc->len - 4, cmt, false); + add_comment_text("\n", 1, cmt, false); + pc = chunk_get_next(chunk_get_next(pc)); + } + add_comment_text(pc->str + 2, pc->len - 4, cmt, false); + if (cpd.settings[UO_cmt_c_nl_end].b) + { + cmt.cont_text = " "; + add_comment_text("\n", 1, cmt, false); + } + add_comment_text("*/", 2, cmt, false); + return(pc); +} + + +/** + * Outputs the CPP comment at pc. + * CPP comment combining is done here + * + * @return the last chunk output'd + */ +static chunk_t *output_comment_cpp(chunk_t *first) +{ + cmt_reflow cmt; + cmt.reflow = (cpd.settings[UO_cmt_reflow_mode].n != 1); + + output_cmt_start(cmt, first); + + /* CPP comments can't be grouped unless they are converted to C comments */ + if (!cpd.settings[UO_cmt_cpp_to_c].b) + { + cmt.cont_text = (cpd.settings[UO_sp_cmt_cpp_start].a & AV_REMOVE) ? "//" : "// "; + + if (cpd.settings[UO_sp_cmt_cpp_start].a == AV_IGNORE) + { + add_comment_text(first->str, first->len, cmt, false); + } + else + { + add_comment_text(first->str, 2, cmt, false); + + const char *tmp = first->str + 2; + int len = first->len - 2; + + if (cpd.settings[UO_sp_cmt_cpp_start].a & AV_REMOVE) + { + while ((len > 0) && unc_isspace(*tmp)) + { + len--; + tmp++; + } + } + if (len > 0) + { + if (cpd.settings[UO_sp_cmt_cpp_start].a & AV_ADD) + { + if (!unc_isspace(*tmp)) + { + add_comment_text(" ", 1, cmt, false); + } + } + add_comment_text(tmp, len, cmt, false); + } + } + + return(first); + } + + /* We are going to convert the CPP comments to C comments */ + cmt.cont_text = cpd.settings[UO_cmt_star_cont].b ? " * " : " "; + + /* See if we can combine this comment with the next comment */ + if (!cpd.settings[UO_cmt_cpp_group].b || + !can_combine_comment(first, cmt)) + { + /* nothing to group: just output a single line */ + add_text_len("/*", 2); + if (!unc_isspace(first->str[2])) + { + add_char(' '); + } + add_comment_text(first->str + 2, first->len - 2, cmt, true); + add_text_len(" */", 3); + return(first); + } + + add_text_len("/*", 2); + if (cpd.settings[UO_cmt_cpp_nl_start].b) + { + add_comment_text("\n", 1, cmt, false); + } + else + { + add_text_len(" ", 1); + } + chunk_t *pc = first; + + int offs; + while (can_combine_comment(pc, cmt)) + { + offs = unc_isspace(pc->str[2]) ? 1 : 0; + add_comment_text(pc->str + 2 + offs, pc->len - (2 + offs), cmt, true); + add_comment_text("\n", 1, cmt, false); + pc = chunk_get_next(chunk_get_next(pc)); + } + offs = unc_isspace(pc->str[2]) ? 1 : 0; + add_comment_text(pc->str + 2 + offs, pc->len - (2 + offs), cmt, true); + if (cpd.settings[UO_cmt_cpp_nl_end].b) + { + cmt.cont_text = ""; + add_comment_text("\n", 1, cmt, false); + } + add_comment_text(" */", 3, cmt, false); + return(pc); +} + + +/** + * A multiline comment -- woopeee! + * The only trick here is that we have to trim out whitespace characters + * to get the comment to line up. + */ +static void output_comment_multi(chunk_t *pc) +{ + int cmt_col = pc->column; + const char *cmt_str; + int remaining; + char ch; + chunk_t *prev; + char *line; + int line_len; + int line_count = 0; + int ccol; + int col_diff = 0; + int xtra = 1; + char lead[80]; + bool nl_end = false; + + cmt_reflow cmt; + cmt.reflow = (cpd.settings[UO_cmt_reflow_mode].n != 1); + + output_cmt_start(cmt, pc); + cmt.cont_text = !cpd.settings[UO_cmt_indent_multi].b ? "" : + cpd.settings[UO_cmt_star_cont].b ? " * " : " "; + + prev = chunk_get_prev(pc); + if ((prev != NULL) && (prev->type != CT_NEWLINE)) + { + cmt_col = pc->orig_col; + } + else + { + col_diff = pc->orig_col - pc->column; + } + + xtra = calculate_comment_body_indent(pc->str, pc->len, pc->column); + + //LOG_FMT(LSYS, "Indenting1 line %d to col %d (orig=%d) col_diff=%d xtra=%d\n", + // pc->orig_line, cmt_col, pc->orig_col, col_diff, xtra); + + ccol = pc->column; + remaining = pc->len; + cmt_str = pc->str; + line_len = 0; + cmt.column = ccol; + cmt.br_column = ccol; + line = new char[remaining + 1024]; + while (remaining > 0) + { + ch = *cmt_str; + cmt_str++; + remaining--; + + /* handle the CRLF and CR endings. convert both to LF */ + if (ch == '\r') + { + ch = '\n'; + if (*cmt_str == '\n') + { + cmt_str++; + remaining--; + } + } + + /* Find the start column */ + if (line_len == 0) + { + nl_end = false; + if (ch == ' ') + { + ccol++; + continue; + } + else if (ch == '\t') + { + ccol = calc_next_tab_column(ccol, cpd.settings[UO_input_tab_size].n); + continue; + } + else + { + //LOG_FMT(LSYS, "%d] Text starts in col %d\n", line_count, ccol); + } + } + + /* + * Now see if we need/must fold the next line with the current to enable full reflow + */ + if ((cpd.settings[UO_cmt_reflow_mode].n == 2) && + (ch == '\n') && + (remaining > 0)) + { + int nxt_len = 0; + int next_nonempty_line = -1; + int prev_nonempty_line = -1; + int nwidx = line_len; + bool star_is_bullet = false; + + /* strip trailing whitespace from the line collected so far */ + line[nwidx] = 0; // sentinel + while (nwidx > 0) + { + nwidx--; + if ((prev_nonempty_line < 0) && + !unc_isspace(line[nwidx]) && + (line[nwidx] != '*') && // block comment: skip '*' at end of line + ((pc->flags & PCF_IN_PREPROC) + ? (line[nwidx] != '\\') || + ((line[nwidx + 1] != 'r') && + (line[nwidx + 1] != '\n')) + : true)) + { + prev_nonempty_line = nwidx; // last nonwhitespace char in the previous line + } + } + + for (nxt_len = 0; + (nxt_len <= remaining) && + (cmt_str[nxt_len] != 'r') && + (cmt_str[nxt_len] != '\n'); + nxt_len++) + { + if ((next_nonempty_line < 0) && + !unc_isspace(cmt_str[nxt_len]) && + (cmt_str[nxt_len] != '*') && + ((nxt_len == remaining) || + ((pc->flags & PCF_IN_PREPROC) + ? (cmt_str[nxt_len] != '\\') || + ((cmt_str[nxt_len+1] != 'r') && + (cmt_str[nxt_len+1] != '\n')) + : true))) + { + next_nonempty_line = nxt_len; // first nonwhitespace char in the next line + } + } + + /* + * see if we should fold up; usually that'd be a YES, but there are a few + * situations where folding/reflowing by merging lines is frowned upon: + * + * - ASCII art in the comments (most often, these are drawings done in +-\/|.,*) + * + * - Doxygen/JavaDoc/etc. parameters: these often start with \ or @, at least + * something clearly non-alphanumeric (you see where we're going with this?) + * + * - bullet lists that are closely spaced: bullets are always non-alphanumeric + * characters, such as '-' or '+' (or, oh horor, '*' - that's bloody ambiguous + * to parse :-( ... with or without '*' comment start prefix, that's the + * question, then.) + * + * - semi-HTML formatted code, e.g.
...
comment sections (NDoc, etc.) + * + * - New lines which form a new paragraph without there having been added an + * extra empty line between the last sentence and the new one. + * A bit like this, really; so it is opportune to check if the last line ended + * in a terminal (that would be the set '.:;!?') and the new line starts with + * a capital. + * Though new lines starting with comment delimiters, such as '(', should be + * pulled up. + * + * So it bores down to this: the only folding (& reflowing) that's going to happen + * is when the next line starts with an alphanumeric character AND the last + * line didn't end with an non-alphanumeric character, except: ',' AND the next + * line didn't start with a '*' all of a sudden while the previous one didn't + * (the ambiguous '*'-for-bullet case!) + */ + if (prev_nonempty_line >= 0 && next_nonempty_line >= 0 && + (((unc_isalnum(line[prev_nonempty_line]) || + strchr(",)]", line[prev_nonempty_line])) && + (unc_isalnum(cmt_str[next_nonempty_line]) || + strchr("([", cmt_str[next_nonempty_line]))) || + (('.' == line[prev_nonempty_line]) && // dot followed by non-capital is NOT a new sentence start + unc_isupper(cmt_str[next_nonempty_line]))) && + !star_is_bullet) + { + // rewind the line to the last non-alpha: + line_len = prev_nonempty_line + 1; + // roll the current line forward to the first non-alpha: + cmt_str += next_nonempty_line; + remaining -= next_nonempty_line; + // override the NL and make it a single whitespace: + ch = ' '; + } + } + + line[line_len++] = ch; + + /* If we just hit an end of line OR we just hit end-of-comment... */ + if ((ch == '\n') || (remaining == 0)) + { + line_count++; + + /* strip trailing tabs and spaces before the newline */ + if (ch == '\n') + { + line_len--; + while ((line_len > 0) && + ((line[line_len - 1] == ' ') || + (line[line_len - 1] == '\t'))) + { + line_len--; + } + if ((line[line_len - 1] == '\\') && (line[line_len - 2] != '*')) + { + if (pc->flags & PCF_IN_PREPROC) + { + bool do_space = false; + + /* Kill off the backslash-newline */ + line_len--; + while ((line_len > 0) && + ((line[line_len - 1] == ' ') || + (line[line_len - 1] == '\t'))) + { + do_space = true; + line_len--; + } + if (do_space) + { + line[line_len++] = ' '; + } + line[line_len++] = '\\'; + } + } + nl_end = true; + } + line[line_len] = 0; + + if (line_count == 1) + { + /* this is the first line - add unchanged */ + output_indent(cmt_col, cmt_col); + add_comment_text(line, line_len, cmt, false); + if (nl_end) + { + add_char('\n'); + } + } + else + { + /* This is not the first line, so we need to indent to the + * correct column. Each line is indented a minimum of three spaces. + * Those three spaces are filled with whatever lead char should be + * there. + */ + ccol -= col_diff; + if (ccol < (cmt_col + 3)) + { + ccol = cmt_col + 3; + } + + if (line_len == 0) + { + /* Empty line - just a '\n' */ + if (cpd.settings[UO_cmt_star_cont].b) + { + output_indent(cmt_col + xtra + cpd.settings[UO_cmt_sp_before_star_cont].n, + cmt_col); + add_char('*'); + } + add_char('\n'); + } + else + { + /* If this doesn't start with a '*' or '|'. + * '\name' is a common parameter documentation thing. + */ + if (cpd.settings[UO_cmt_indent_multi].b && + (line[0] != '*') && (line[0] != '|') && (line[0] != '#') && + ((line[0] != '\\') || unc_isalpha(line[1])) && (line[0] != '+')) + { + int start_col = cmt_col + xtra + cpd.settings[UO_cmt_sp_before_star_cont].n; + + if (cpd.settings[UO_cmt_star_cont].b) + { + output_indent(start_col, cmt_col); + add_text("* "); + output_to_column(ccol + cpd.settings[UO_cmt_sp_after_star_cont].n, + false); + } + else + { + output_indent(ccol, cmt_col); + } + } + else + { + output_indent(cmt_col + xtra + cpd.settings[UO_cmt_sp_before_star_cont].n, + cmt_col); + + int idx = 0; + int sidx = 0; + if (xtra > 0) + { + lead[idx++] = ' '; + } + /* keep the indentation of the start of the line intact when folding/reflowing. */ + while ((idx < int(sizeof(lead) - 1)) && !unc_isspace(line[sidx])) + { + lead[idx++] = line[sidx++]; + } + for (sidx = 0; sidx < cpd.settings[UO_cmt_sp_after_star_cont].n; sidx++) + { + lead[idx++] = ' '; + } + lead[idx] = 0; + cmt.cont_text = lead; + } + + add_comment_text(line, line_len, cmt, false); + if (nl_end) + { + add_text_len("\n", 1); + } + } + } + line_len = 0; + ccol = 1; + } + } + delete[] line; +} + + +/** + * Output a multiline comment without any reformatting other than shifting + * it left or right to get the column right. + * Oh, and trim trailing whitespace. + */ +static void output_comment_multi_simple(chunk_t *pc) +{ + int cmt_col = pc->column; + const char *cmt_str; + int remaining; + char ch; + char line[1024]; + int line_len; + int line_count = 0; + int ccol; + int col_diff = 0; + bool nl_end = false; + + if (chunk_is_newline(chunk_get_prev(pc))) + { + /* The comment should be indented correctly */ + cmt_col = pc->column; + col_diff = pc->orig_col - pc->column; + } + else + { + /* The comment starts after something else */ + cmt_col = pc->orig_col; + col_diff = 0; + } + + //LOG_FMT(LSYS, "Indenting1 line %d to col %d (orig=%d) col_diff=%d xtra=%d\n", + // pc->orig_line, cmt_col, pc->orig_col, col_diff, xtra); + + ccol = pc->column; + remaining = pc->len; + cmt_str = pc->str; + line_len = 0; + while (remaining > 0) + { + ch = *cmt_str; + cmt_str++; + remaining--; + + /* handle the CRLF and CR endings. convert both to LF */ + if (ch == '\r') + { + ch = '\n'; + if (*cmt_str == '\n') + { + cmt_str++; + remaining--; + } + } + + /* Find the start column */ + if (line_len == 0) + { + nl_end = false; + if (ch == ' ') + { + ccol++; + continue; + } + else if (ch == '\t') + { + ccol = calc_next_tab_column(ccol, cpd.settings[UO_input_tab_size].n); + continue; + } + else + { + //LOG_FMT(LSYS, "%d] Text starts in col %d, col_diff=%d, real=%d\n", + // line_count, ccol, col_diff, ccol - col_diff); + } + } + + line[line_len++] = ch; + + /* If we just hit an end of line OR we just hit end-of-comment... */ + if ((ch == '\n') || (remaining == 0)) + { + line_count++; + + /* strip trailing tabs and spaces before the newline */ + if (ch == '\n') + { + line_len--; + while ((line_len > 0) && + ((line[line_len - 1] == ' ') || + (line[line_len - 1] == '\t'))) + { + line_len--; + } + /* REVISIT: the check for '*' seem unnecessary */ + if ((line[line_len - 1] == '\\') && (line[line_len - 2] != '*')) + { + /* Kill off the backslash-newline */ + line_len--; + while ((line_len > 0) && + ((line[line_len - 1] == ' ') || + (line[line_len - 1] == '\t'))) + { + line_len--; + } + line[line_len++] = ' '; + line[line_len++] = '\\'; + } + nl_end = true; + } + line[line_len] = 0; + + if (line_count > 1) + { + ccol -= col_diff; + } + + if (line_len > 0) + { + output_indent(ccol, cmt_col); + add_text_len(line, line_len); + } + if (nl_end) + { + add_char('\n'); + } + line_len = 0; + ccol = 1; + } + } +} diff --git a/src/parens.cpp b/src/parens.cpp new file mode 100644 index 0000000000..fab4ca77c7 --- /dev/null +++ b/src/parens.cpp @@ -0,0 +1,179 @@ +/** + * @file parens.cpp + * Adds or removes parens. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +static void add_parens_between(chunk_t *first, chunk_t *last); +static void check_bool_parens(chunk_t *popen, chunk_t *pclose, int nest); + + +void do_parens(void) +{ + chunk_t *pc; + chunk_t *pclose; + + if (cpd.settings[UO_mod_full_paren_if_bool].b) + { + pc = chunk_get_head(); + while ((pc = chunk_get_next_ncnl(pc)) != NULL) + { + if ((pc->type != CT_SPAREN_OPEN) || + ((pc->parent_type != CT_IF) && + (pc->parent_type != CT_ELSEIF) && + (pc->parent_type != CT_SWITCH))) + { + continue; + } + + /* Grab the close sparen */ + pclose = chunk_get_next_type(pc, CT_SPAREN_CLOSE, pc->level); + if (pclose != NULL) + { + check_bool_parens(pc, pclose, 0); + pc = pclose; + } + } + } +} + + +/** + * Add an open paren after first and add a close paren before the last + */ +static void add_parens_between(chunk_t *first, chunk_t *last) +{ + chunk_t pc; + chunk_t *first_n; + chunk_t *last_p; + chunk_t *tmp; + + LOG_FMT(LPARADD, "%s: line %d between %.*s [lvl=%d] and %.*s [lvl=%d]\n", + __func__, first->orig_line, + first->len, first->str, first->level, + last->len, last->str, last->level); + + /* Don't do anything if we have a bad sequence, ie "&& )" */ + first_n = chunk_get_next_ncnl(first); + if (first_n == last) + { + return; + } + + memset(&pc, 0, sizeof(pc)); + + pc.type = CT_PAREN_OPEN; + pc.str = "("; + pc.len = 1; + pc.flags = first_n->flags & PCF_COPY_FLAGS; + pc.level = first_n->level; + pc.pp_level = first_n->pp_level; + pc.brace_level = first_n->brace_level; + + chunk_add_before(&pc, first_n); + + last_p = chunk_get_prev_ncnl(last); + pc.type = CT_PAREN_CLOSE; + pc.str = ")"; + pc.flags = last_p->flags & PCF_COPY_FLAGS; + pc.level = last_p->level; + pc.pp_level = last_p->pp_level; + pc.brace_level = last_p->brace_level; + + chunk_add_after(&pc, last_p); + + for (tmp = first_n; + tmp != last_p; + tmp = chunk_get_next_ncnl(tmp)) + { + tmp->level++; + } + last_p->level++; +} + + +/** + * Scans between two parens and adds additional parens if needed. + * This function is recursive. If it hits another open paren, it'll call itself + * with the new bounds. + * + * Adds optional parens in an IF or SWITCH conditional statement. + * + * This basically just checks for a CT_COMPARE that isn't surrounded by parens. + * The edges for the compare are the open, close and any CT_BOOL tokens. + * + * This only handleds VERY simple patterns: + * (!a && b) => (!a && b) -- no change + * (a && b == 1) => (a && (b == 1)) + * (a == 1 || b > 2) => ((a == 1) || (b > 2)) + * + * FIXME: we really should bail if we transition between a preprocessor and + * a non-preprocessor + */ +static void check_bool_parens(chunk_t *popen, chunk_t *pclose, int nest) +{ + chunk_t *pc; + chunk_t *ref = popen; + chunk_t *next; + bool hit_compare = false; + + LOG_FMT(LPARADD, "%s(%d): popen on %d, col %d, pclose on %d, col %d, level=%d\n", + __func__, nest, + popen->orig_line, popen->orig_col, + pclose->orig_line, pclose->orig_col, + popen->level); + + pc = popen; + while (((pc = chunk_get_next_ncnl(pc)) != NULL) && (pc != pclose)) + { + if (pc->type == CT_BOOL) + { + LOG_FMT(LPARADD2, " -- bool [%.*s] at line %d col %d, level %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col, pc->level); + if (hit_compare) + { + hit_compare = false; + add_parens_between(ref, pc); + } + ref = pc; + } + else if (pc->type == CT_COMPARE) + { + LOG_FMT(LPARADD2, " -- compare [%.*s] at line %d col %d, level %d\n", + pc->len, pc->str, pc->orig_line, pc->orig_col, pc->level); + hit_compare = true; + } + else if (chunk_is_paren_open(pc)) + { + next = chunk_get_next_type(pc, (c_token_t)(pc->type + 1), pc->level); + if (next != NULL) + { + check_bool_parens(pc, next, nest + 1); + pc = next; + } + } + else if ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_SQUARE_OPEN) || + (pc->type == CT_ANGLE_OPEN)) + { + /* Skip [], {}, and <> */ + pc = chunk_get_next_type(pc, (c_token_t)(pc->type + 1), pc->level); + } + } + + if (hit_compare && (ref != popen)) + { + add_parens_between(ref, pclose); + } +} diff --git a/src/parse_frame.cpp b/src/parse_frame.cpp new file mode 100644 index 0000000000..37aa0057a1 --- /dev/null +++ b/src/parse_frame.cpp @@ -0,0 +1,287 @@ +/** + * @file parse_frame.cpp + * Does the parse frame stuff, which is used to handle #ifdef stuff + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "prototypes.h" +#include "chunk_list.h" +#include +#include +#include + +/** + * Logs one parse frame + */ +void pf_log(int logsev, struct parse_frame *pf) +{ + int idx; + + LOG_FMT(logsev, "[%s] BrLevel=%d Level=%d PseTos=%d\n", + get_token_name(pf->in_ifdef), + pf->brace_level, pf->level, pf->pse_tos); + + LOG_FMT(logsev, " *"); + for (idx = 1; idx <= pf->pse_tos; idx++) + { + LOG_FMT(logsev, " [%s-%d]", + get_token_name(pf->pse[idx].type), + pf->pse[idx].stage); + } + LOG_FMT(logsev, "\n"); +} + + +static void pf_log_frms(int logsev, const char *txt, struct parse_frame *pf) +{ + int idx; + + LOG_FMT(logsev, "%s Parse Frames(%d):", txt, cpd.frame_count); + for (idx = 0; idx < cpd.frame_count; idx++) + { + LOG_FMT(logsev, " [%s-%d]", + get_token_name(cpd.frames[idx].in_ifdef), + cpd.frames[idx].ref_no); + } + LOG_FMT(logsev, "-[%s-%d]\n", get_token_name(pf->in_ifdef), pf->ref_no); +} + + +/** + * Logs the entire parse frame stack + */ +void pf_log_all(int logsev) +{ + int idx; + + LOG_FMT(logsev, "##=- Parse Frame : %d entries\n", cpd.frame_count); + + for (idx = 0; idx < cpd.frame_count; idx++) + { + LOG_FMT(logsev, "## <%d> ", idx); + + pf_log(logsev, &cpd.frames[idx]); + } + LOG_FMT(logsev, "##=-\n"); +} + + +/** + * Copies src to dst. + */ +void pf_copy(struct parse_frame *dst, const struct parse_frame *src) +{ + memcpy(dst, src, sizeof(struct parse_frame)); +} + + +/** + * Push a copy of the parse frame onto the stack. + * This is called on #if and #ifdef. + */ +void pf_push(struct parse_frame *pf) +{ + static int ref_no = 1; + + if (cpd.frame_count < (int)ARRAY_SIZE(cpd.frames)) + { + pf_copy(&cpd.frames[cpd.frame_count], pf); + cpd.frame_count++; + pf->ref_no = ref_no++; + } + LOG_FMT(LPF, "%s: count = %d\n", __func__, cpd.frame_count); +} + + +/** + * Push a copy of the parse frame onto the stack, under the tos. + * If this were a linked list, just add before the last item. + * This is called on the first #else and #elif. + */ +void pf_push_under(struct parse_frame *pf) +{ + struct parse_frame *npf1; + struct parse_frame *npf2; + + LOG_FMT(LPF, "%s: before count = %d\n", __func__, cpd.frame_count); + + if ((cpd.frame_count < (int)ARRAY_SIZE(cpd.frames)) && + (cpd.frame_count >= 1)) + { + npf1 = &cpd.frames[cpd.frame_count - 1]; + npf2 = &cpd.frames[cpd.frame_count]; + pf_copy(npf2, npf1); + pf_copy(npf1, pf); + cpd.frame_count++; + } + + LOG_FMT(LPF, "%s: after count = %d\n", __func__, cpd.frame_count); +} + + +/** + * Copy the top item off the stack into pf. + * This is called on #else and #elif. + */ +void pf_copy_tos(struct parse_frame *pf) +{ + if (cpd.frame_count > 0) + { + pf_copy(pf, &cpd.frames[cpd.frame_count - 1]); + } + LOG_FMT(LPF, "%s: count = %d\n", __func__, cpd.frame_count); +} + + +/** + * Copy the 2nd top item off the stack into pf. + * This is called on #else and #elif. + * The stack contains [...] [base] [if] at this point. + * We want to copy [base]. + */ +static void pf_copy_2nd_tos(struct parse_frame *pf) +{ + if (cpd.frame_count > 1) + { + pf_copy(pf, &cpd.frames[cpd.frame_count - 2]); + } + LOG_FMT(LPF, "%s: count = %d\n", __func__, cpd.frame_count); +} + + +/** + * Deletes the top frame from the stack. + */ +void pf_trash_tos(void) +{ + if (cpd.frame_count > 0) + { + cpd.frame_count--; + } + LOG_FMT(LPF, "%s: count = %d\n", __func__, cpd.frame_count); +} + + +/** + * Pop the top item off the stack and copy into pf. + * This is called on #endif + */ +void pf_pop(struct parse_frame *pf) +{ + if (cpd.frame_count > 0) + { + pf_copy_tos(pf); + pf_trash_tos(); + } + //fprintf(stderr, "%s: count = %d\n", __func__, cpd.frame_count); +} + + +/** + * Returns the pp_indent to use for this line + */ +int pf_check(struct parse_frame *frm, chunk_t *pc) +{ + int in_ifdef = frm->in_ifdef; + int b4_cnt = cpd.frame_count; + int pp_level = cpd.pp_level; + const char *txt = NULL; + + if (pc->type != CT_PREPROC) + { + return(pp_level); + } + + LOG_FMT(LPFCHK, "%s: %5d] %s\n", + __func__, pc->orig_line, get_token_name(pc->parent_type)); + pf_log_frms(LPFCHK, "TOP", frm); + + if ((pc->flags & PCF_IN_PREPROC) != 0) + { + LOG_FMT(LPF, " "); + pf_log(LPF, frm); + + if (pc->parent_type == CT_PP_IF) + { + /* An #if pushes a copy of the current frame on the stack */ + cpd.pp_level++; + pf_push(frm); + frm->in_ifdef = CT_PP_IF; + txt = "if-push"; + } + else if (pc->parent_type == CT_PP_ELSE) + { + pp_level--; + + /** + * For #else of #elif, we want to keep the #if part and throw out the + * else parts. + * We check to see what the top type is to see if we just push or + * pop and then push. + * We need to use the copy right before the if. + */ + if (frm->in_ifdef == CT_PP_IF) + { + /* we have [...] [base]-[if], so push an [else] */ + pf_push(frm); + frm->in_ifdef = CT_PP_ELSE; + } + /* we have [...] [base] [if]-[else], copy [base] over [else] */ + pf_copy_2nd_tos(frm); + frm->in_ifdef = CT_PP_ELSE; + txt = "else-push"; + } + else if (pc->parent_type == CT_PP_ENDIF) + { + /** + * we may have [...] [base] [if]-[else] or [...] [base]-[if]. + * Throw out the [else]. + */ + cpd.pp_level--; + pp_level--; + + if (frm->in_ifdef == CT_PP_ELSE) + { + /** + * We have: [...] [base] [if]-[else] + * We want: [...]-[if] + */ + pf_copy_tos(frm); /* [...] [base] [if]-[if] */ + frm->in_ifdef = cpd.frames[cpd.frame_count - 2].in_ifdef; + pf_trash_tos(); /* [...] [base]-[if] */ + pf_trash_tos(); /* [...]-[if] */ + + txt = "endif-trash/pop"; + } + else if (frm->in_ifdef == CT_PP_IF) + { + /** + * We have: [...] [base] [if] + * We want: [...] [base] + */ + pf_pop(frm); + txt = "endif-pop"; + } + else + { + txt = "???"; + } + } + } + + if (txt != NULL) + { + LOG_FMT(LPF, "%s: %d> %s: %s in_ifdef=%d/%d counts=%d/%d\n", __func__, + pc->orig_line, get_token_name(pc->parent_type), txt, + in_ifdef, frm->in_ifdef, b4_cnt, cpd.frame_count); + pf_log_all(LPF); + LOG_FMT(LPF, " "); + pf_log(LPF, frm); + } + + pf_log_frms(LPFCHK, "END", frm); + + return(pp_level); +} diff --git a/src/prototypes.h b/src/prototypes.h new file mode 100644 index 0000000000..8bad5320c9 --- /dev/null +++ b/src/prototypes.h @@ -0,0 +1,323 @@ +/** + * @file prototypes.h + * Big jumble of prototypes used in Uncrustify. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef C_PARSE_PROTOTYPES_H_INCLUDED +#define C_PARSE_PROTOTYPES_H_INCLUDED + +#include "uncrustify_types.h" + +#include + +/* + * uncrustify.cpp + */ + +const char *get_token_name(c_token_t token); +c_token_t find_token_name(const char *text); +void log_pcf_flags(log_sev_t sev, UINT32 flags); +const char *path_basename(const char *path); +int path_dirname_len(const char *filename); +const char *get_file_extension(int& idx); + + +/* + * detect.cpp + */ + +void detect_options(const char *data, int data_len); + + +/* + * output.cpp + */ + +void output_text(FILE *pfile); +void output_parsed(FILE *pfile); +void output_options(FILE *pfile); + + +/* + * options.cpp + */ + +void unc_begin_group(uncrustify_groups id, const char *short_desc, const char *long_desc = NULL); +void register_options(void); +void set_option_defaults(void); +int load_option_file(const char *filename); +int save_option_file(FILE *pfile, bool withDoc); +int set_option_value(const char *name, const char *value); +const group_map_value *get_group_name(int ug); +const option_map_value *get_option_name(int uo); +void print_options(FILE *pfile, bool verbose); + +std::string argtype_to_string(argtype_e argtype); +std::string bool_to_string(bool val); +std::string argval_to_string(argval_t argval); +std::string number_to_string(int number); +std::string lineends_to_string(lineends_e linends); +std::string tokenpos_to_string(tokenpos_e tokenpos); +std::string op_val_to_string(argtype_e argtype, op_val_t op_val); + +/* + * indent.cpp + */ + +void indent_text(void); +void indent_preproc(void); +void indent_to_column(chunk_t *pc, int column); +void align_to_column(chunk_t *pc, int column); + +#define reindent_line(pc, col) reindent_line2(pc, col, __func__, __LINE__) +void reindent_line2(chunk_t *pc, int column, const char *fcn_name, int lineno); + + +/* + * align.cpp + */ + +void align_all(void); +void align_backslash_newline(void); +void align_right_comments(void); +void align_preprocessor(void); +void align_struct_initializers(void); +chunk_t *align_nl_cont(chunk_t *start); +chunk_t *align_assign(chunk_t *first, int span, int thresh); +void quick_align_again(void); + + +/* + * braces.cpp + */ + +void do_braces(void); +void add_long_closebrace_comment(void); +chunk_t *insert_comment_after(chunk_t *ref, c_token_t cmt_type, int cmt_len, const char *cmt_text); + + +/* + * sorting.cpp + */ + +void sort_imports(void); + + +/* + * parens.cpp + */ + +void do_parens(void); + + +/* + * space.cpp + */ + +void space_text(void); +void space_text_balance_nested_parens(void); +int space_col_align(chunk_t *first, chunk_t *second); + +void space_add_after(chunk_t *pc, int count); + + +/* + * combine.cpp + */ + +void fix_symbols(void); +void combine_labels(void); +void mark_comments(void); +void make_type(chunk_t *pc); + +chunk_t *skip_template_next(chunk_t *ang_open); +chunk_t *skip_template_prev(chunk_t *ang_close); + +chunk_t *skip_attribute_next(chunk_t *attr); +chunk_t *skip_attribute_prev(chunk_t *fp_close); + +void remove_extra_returns(); + + +/* + * newlines.cpp + */ + +void newlines_cleanup_braces(void); +void newlines_insert_blank_lines(void); +void newlines_squeeze_ifdef(void); +void newlines_eat_start_end(void); +void newlines_chunk_pos(c_token_t chunk_type, tokenpos_e mode); +void newlines_class_colon_pos(void); +void newlines_cleanup_dup(void); +void newline_after_multiline_comment(void); +void do_blank_lines(void); +void newline_iarf(chunk_t *pc, argval_t av); + +#define newline_add_before(pc) newline_add_before2(pc, __func__, __LINE__) +chunk_t *newline_add_before2(chunk_t *pc, const char *fcn, int line); + +#define newline_add_after(pc) newline_add_after2(pc, __func__, __LINE__) +chunk_t *newline_add_after2(chunk_t *pc, const char *fcn, int line); + + +#define newline_del_between(start, end) \ + newline_del_between2(start, end, __func__, __LINE__) + +void newline_del_between2(chunk_t *start, chunk_t *end, + const char *func, int line); + +#define newline_add_between(start, end) \ + newline_add_between2(start, end, __func__, __LINE__) + +chunk_t *newline_add_between2(chunk_t *start, chunk_t *end, + const char *func, int line); + +/* + * tokenize.cpp + */ + +void tokenize(const char *data, int data_len, chunk_t *ref); + + +/* + * tokenize_cleanup.cpp + */ + +void tokenize_cleanup(void); + + +/* + * brace_cleanup.cpp + */ + +void brace_cleanup(void); + + +/* + * keywords.cpp + */ + +int load_keyword_file(const char *filename); +const chunk_tag_t *find_keyword(const char *word, int len); +void add_keyword(const char *tag, c_token_t type, int lang_flags); +void output_types(FILE *pfile); +const chunk_tag_t *get_custom_keyword_idx(int& idx); +void clear_keyword_file(void); +pattern_class get_token_pattern_class(c_token_t tok); +bool keywords_are_sorted(void); + + +/* + * defines.cpp + */ + +int load_define_file(const char *filename); +const define_tag_t *find_define(const char *word, int len); +void add_define(const char *tag, const char *value); +const define_tag_t *get_define_idx(int& idx); +void output_defines(FILE *pfile); +void clear_defines(void); +void add_long_preprocessor_conditional_block_comment(void); + + +/* + * punctuators.cpp + */ +const chunk_tag_t *find_punctuator(const char *str, int lang_flags); + + +/* + * parse_frame.cpp + */ + +void pf_copy(struct parse_frame *dst, const struct parse_frame *src); +void pf_push(struct parse_frame *pf); +void pf_push_under(struct parse_frame *pf); +void pf_copy_tos(struct parse_frame *pf); +void pf_trash_tos(void); +void pf_pop(struct parse_frame *pf); +int pf_check(struct parse_frame *frm, chunk_t *pc); + + +/* + * width.cpp + */ +void do_code_width(void); + + +/* + * lang_pawn.cpp + */ +void pawn_prescan(void); +void pawn_add_virtual_semicolons(); +chunk_t *pawn_check_vsemicolon(chunk_t *pc); +void pawn_scrub_vsemi(void); +chunk_t *pawn_add_vsemi_after(chunk_t *pc); + + +/* + * universalindentgui.cpp + */ +void print_universal_indent_cfg(FILE *pfile); + + +/* + * semicolons.cpp + */ +void remove_extra_semicolons(void); + + +/** + * Advances to the next tab stop. + * Column 1 is the left-most column. + * + * @param col The current column + * @param tabsize The tabsize + * @return the next tabstop column + */ +static_inline +int calc_next_tab_column(int col, int tabsize) +{ + if (col <= 0) + { + col = 1; + } + col = 1 + ((((col - 1) / tabsize) + 1) * tabsize); + return(col); +} + + +/** + * Advances to the next tab stop for output. + * + * @param col The current column + * @return the next tabstop column + */ +static_inline +int next_tab_column(int col) +{ + return(calc_next_tab_column(col, cpd.settings[UO_output_tab_size].n)); +} + + +/** + * Advances to the next tab stop if not currently on one. + * + * @param col The current column + * @return the next tabstop column + */ +static_inline +int align_tab_column(int col) +{ + if ((col % cpd.settings[UO_output_tab_size].n) != 1) + { + calc_next_tab_column(col, cpd.settings[UO_output_tab_size].n); + } + return(col); +} + + +#endif /* C_PARSE_PROTOTYPES_H_INCLUDED */ diff --git a/src/punctuators.cpp b/src/punctuators.cpp new file mode 100644 index 0000000000..e8a75dbca6 --- /dev/null +++ b/src/punctuators.cpp @@ -0,0 +1,154 @@ +/** + * @file punctuators.cpp + * Manages the table of punctutators. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include + + +/** + * + * The file "punctuators.h" was generated by punc.py from this file. + * If you change one of the below symbol tables, re-run punc.py. + * $ python scripts/punc.py > src/punctuators.h + * + */ + + +/* 4-char symbols */ +static const chunk_tag_t symbols4[] = +{ + { "!<>=", CT_COMPARE, LANG_D }, + { ">>>=", CT_ASSIGN, LANG_D | LANG_JAVA | LANG_PAWN }, +}; + +/* 3-char symbols */ +static const chunk_tag_t symbols3[] = +{ + { "!<=", CT_COMPARE, LANG_D }, + { "!<>", CT_COMPARE, LANG_D }, + { "!==", CT_COMPARE, LANG_D }, + { "!>=", CT_COMPARE, LANG_D }, + { "->*", CT_MEMBER, LANG_C | LANG_CPP | LANG_D }, + { "...", CT_ELLIPSIS, LANG_C | LANG_CPP | LANG_D | LANG_PAWN }, + { "<<=", CT_ASSIGN, LANG_ALL }, + { "<>=", CT_COMPARE, LANG_D }, + { "===", CT_COMPARE, LANG_D }, + { ">>=", CT_ASSIGN, LANG_ALL }, + { ">>>", CT_ARITH, LANG_D | LANG_JAVA | LANG_PAWN }, +}; + +/* 2-char symbols */ +static const chunk_tag_t symbols2[] = +{ + { "!<", CT_COMPARE, LANG_D }, + { "!=", CT_COMPARE, LANG_ALL }, + { "!>", CT_COMPARE, LANG_D }, + { "!~", CT_COMPARE, LANG_D }, + { "##", CT_PP, LANG_C | LANG_CPP | LANG_OC }, + { "%=", CT_ASSIGN, LANG_ALL }, + { "&&", CT_BOOL, LANG_ALL }, + { "&=", CT_ASSIGN, LANG_ALL }, + { "*=", CT_ASSIGN, LANG_ALL }, + { "++", CT_INCDEC_AFTER, LANG_ALL }, + { "+=", CT_ASSIGN, LANG_ALL }, + { "--", CT_INCDEC_AFTER, LANG_ALL }, + { "-=", CT_ASSIGN, LANG_ALL }, + { "->", CT_MEMBER, LANG_C | LANG_CPP | LANG_CS | LANG_OC | LANG_D }, + { ".*", CT_MEMBER, LANG_C | LANG_CPP | LANG_D }, + { "..", CT_RANGE, LANG_D }, + { "/=", CT_ASSIGN, LANG_ALL }, + { "::", CT_DC_MEMBER, LANG_C | LANG_CPP | LANG_CS | LANG_D }, + { "<<", CT_ARITH, LANG_ALL }, + { "<=", CT_COMPARE, LANG_ALL }, + { "<>", CT_COMPARE, LANG_D }, + { "==", CT_COMPARE, LANG_ALL }, + { ">=", CT_COMPARE, LANG_ALL }, + { ">>", CT_ARITH, LANG_ALL & ~LANG_CS }, + { "[]", CT_TSQUARE, LANG_ALL }, + { "^=", CT_ASSIGN, LANG_ALL }, + { "|=", CT_ASSIGN, LANG_ALL }, + { "||", CT_BOOL, LANG_ALL }, + { "~=", CT_COMPARE, LANG_D }, + { "~~", CT_COMPARE, LANG_D }, + { "=>", CT_LAMBDA, LANG_VALA | LANG_CS }, + { "??", CT_COMPARE, LANG_CS }, +}; + +/* 1-char symbols */ +static const chunk_tag_t symbols1[] = +{ + { "!", CT_NOT, LANG_ALL }, + { "#", CT_POUND, LANG_C | LANG_CPP | LANG_CS | LANG_D | LANG_OC | LANG_PAWN }, + { "$", CT_COMPARE, LANG_D }, + { "%", CT_ARITH, LANG_ALL }, + { "&", CT_AMP, LANG_ALL }, + { "(", CT_PAREN_OPEN, LANG_ALL }, + { ")", CT_PAREN_CLOSE, LANG_ALL }, + { "*", CT_STAR, LANG_ALL }, + { "+", CT_PLUS, LANG_ALL }, + { ",", CT_COMMA, LANG_ALL }, + { "-", CT_MINUS, LANG_ALL }, + { ".", CT_DOT, LANG_ALL }, + { "/", CT_ARITH, LANG_ALL }, + { ":", CT_COLON, LANG_ALL }, + { ";", CT_SEMICOLON, LANG_ALL }, + { "<", CT_ANGLE_OPEN, LANG_ALL }, + { "=", CT_ASSIGN, LANG_ALL }, + { ">", CT_ANGLE_CLOSE, LANG_ALL }, + { "?", CT_QUESTION, LANG_ALL }, + { "[", CT_SQUARE_OPEN, LANG_ALL }, + { "]", CT_SQUARE_CLOSE, LANG_ALL }, + { "^", CT_ARITH, LANG_ALL }, + { "{", CT_BRACE_OPEN, LANG_ALL }, + { "|", CT_ARITH, LANG_ALL }, + { "}", CT_BRACE_CLOSE, LANG_ALL }, + { "~", CT_INV, LANG_ALL }, +}; + +#include "punctuators.h" + +const chunk_tag_t *find_punctuator(const char *str, int lang_flags) +{ + const chunk_tag_t *p_match = NULL; + const lookup_entry_t *p_tab = punc_table; + + int ch_idx = 0; + + /*REVISIT: it might be faster to do a bsearch() on the first char. + * the rest of the group have at most 5 entries, so it wouldn't help + */ + + while (ch_idx < 4) + { + if (p_tab->ch == str[ch_idx]) + { + /* Match */ + if ((p_tab->tag != NULL) && + ((p_tab->tag->lang_flags & lang_flags) != 0)) + { + p_match = p_tab->tag; + } + if (p_tab->next_idx == 0) + { + /* This is the end of the chain */ + break; + } + p_tab = &punc_table[p_tab->next_idx]; + ch_idx++; + } + else if (p_tab->left_in_group == 0) + { + /* The last entry in this group didn't match */ + break; + } + else + { + p_tab++; + } + } + return(p_match); +} diff --git a/src/punctuators.h b/src/punctuators.h new file mode 100644 index 0000000000..b53c701ef7 --- /dev/null +++ b/src/punctuators.h @@ -0,0 +1,78 @@ +/** + * @file punctuators.h + * Automatically generated + */ +static const lookup_entry_t punc_table[] = +{ + { '!', 25, 26, &symbols1[0] }, // 0: '!' + { '#', 24, 35, &symbols1[1] }, // 1: '#' + { '$', 23, 0, &symbols1[2] }, // 2: '$' + { '%', 22, 36, &symbols1[3] }, // 3: '%' + { '&', 21, 37, &symbols1[4] }, // 4: '&' + { '(', 20, 0, &symbols1[5] }, // 5: '(' + { ')', 19, 0, &symbols1[6] }, // 6: ')' + { '*', 18, 39, &symbols1[7] }, // 7: '*' + { '+', 17, 40, &symbols1[8] }, // 8: '+' + { ',', 16, 0, &symbols1[9] }, // 9: ',' + { '-', 15, 42, &symbols1[10] }, // 10: '-' + { '.', 14, 46, &symbols1[11] }, // 11: '.' + { '/', 13, 49, &symbols1[12] }, // 12: '/' + { ':', 12, 50, &symbols1[13] }, // 13: ':' + { ';', 11, 0, &symbols1[14] }, // 14: ';' + { '<', 10, 51, &symbols1[15] }, // 15: '<' + { '=', 9, 56, &symbols1[16] }, // 16: '=' + { '>', 8, 59, &symbols1[17] }, // 17: '>' + { '?', 7, 64, &symbols1[18] }, // 18: '?' + { '[', 6, 65, &symbols1[19] }, // 19: '[' + { ']', 5, 0, &symbols1[20] }, // 20: ']' + { '^', 4, 66, &symbols1[21] }, // 21: '^' + { '{', 3, 0, &symbols1[22] }, // 22: '{' + { '|', 2, 67, &symbols1[23] }, // 23: '|' + { '}', 1, 0, &symbols1[24] }, // 24: '}' + { '~', 0, 69, &symbols1[25] }, // 25: '~' + { '<', 3, 30, &symbols2[0] }, // 26: '!<' + { '=', 2, 33, &symbols2[1] }, // 27: '!=' + { '>', 1, 34, &symbols2[2] }, // 28: '!>' + { '~', 0, 0, &symbols2[3] }, // 29: '!~' + { '=', 1, 0, &symbols3[0] }, // 30: '!<=' + { '>', 0, 32, &symbols3[1] }, // 31: '!<>' + { '=', 0, 0, &symbols4[0] }, // 32: '!<>=' + { '=', 0, 0, &symbols3[2] }, // 33: '!==' + { '=', 0, 0, &symbols3[3] }, // 34: '!>=' + { '#', 0, 0, &symbols2[4] }, // 35: '##' + { '=', 0, 0, &symbols2[5] }, // 36: '%=' + { '&', 1, 0, &symbols2[6] }, // 37: '&&' + { '=', 0, 0, &symbols2[7] }, // 38: '&=' + { '=', 0, 0, &symbols2[8] }, // 39: '*=' + { '+', 1, 0, &symbols2[9] }, // 40: '++' + { '=', 0, 0, &symbols2[10] }, // 41: '+=' + { '-', 2, 0, &symbols2[11] }, // 42: '--' + { '=', 1, 0, &symbols2[12] }, // 43: '-=' + { '>', 0, 45, &symbols2[13] }, // 44: '->' + { '*', 0, 0, &symbols3[4] }, // 45: '->*' + { '*', 1, 0, &symbols2[14] }, // 46: '.*' + { '.', 0, 48, &symbols2[15] }, // 47: '..' + { '.', 0, 0, &symbols3[5] }, // 48: '...' + { '=', 0, 0, &symbols2[16] }, // 49: '/=' + { ':', 0, 0, &symbols2[17] }, // 50: '::' + { '<', 2, 54, &symbols2[18] }, // 51: '<<' + { '=', 1, 0, &symbols2[19] }, // 52: '<=' + { '>', 0, 55, &symbols2[20] }, // 53: '<>' + { '=', 0, 0, &symbols3[6] }, // 54: '<<=' + { '=', 0, 0, &symbols3[7] }, // 55: '<>=' + { '=', 1, 58, &symbols2[21] }, // 56: '==' + { '>', 0, 0, &symbols2[30] }, // 57: '=>' + { '=', 0, 0, &symbols3[8] }, // 58: '===' + { '=', 1, 0, &symbols2[22] }, // 59: '>=' + { '>', 0, 61, &symbols2[23] }, // 60: '>>' + { '=', 1, 0, &symbols3[9] }, // 61: '>>=' + { '>', 0, 63, &symbols3[10] }, // 62: '>>>' + { '=', 0, 0, &symbols4[1] }, // 63: '>>>=' + { '?', 0, 0, &symbols2[31] }, // 64: '??' + { ']', 0, 0, &symbols2[24] }, // 65: '[]' + { '=', 0, 0, &symbols2[25] }, // 66: '^=' + { '=', 1, 0, &symbols2[26] }, // 67: '|=' + { '|', 0, 0, &symbols2[27] }, // 68: '||' + { '=', 1, 0, &symbols2[28] }, // 69: '~=' + { '~', 0, 0, &symbols2[29] }, // 70: '~~' +}; diff --git a/src/semicolons.cpp b/src/semicolons.cpp new file mode 100644 index 0000000000..900c336fb3 --- /dev/null +++ b/src/semicolons.cpp @@ -0,0 +1,117 @@ +/** + * @file semicolons.cpp + * Removes extra semicolons + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "ChunkStack.h" +#include "prototypes.h" + +#include +#include +#include +#include +#include "unc_ctype.h" +#include + +static void check_unknown_brace_close(chunk_t *semi, chunk_t *brace_close); + + +static void remove_semicolon(chunk_t *pc) +{ + LOG_FMT(LDELSEMI, "%s: Removed semicolon at line %d, col %d\n", + __func__, pc->orig_line, pc->orig_col); + /* TODO: do we want to shift stuff back a column? */ + chunk_del(pc); +} + + +/** + * Removes superfluous semicolons: + * - after brace close whose parent is IF, ELSE, SWITCH, WHILE, FOR + * - after another semicolon where parent is not FOR + * - (D) after brace close whose parent is ENUM/STRUCT/UNION + * - after an open brace + */ +void remove_extra_semicolons(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev; + + pc = chunk_get_head(); + while (pc != NULL) + { + next = chunk_get_next_ncnl(pc); + + if ((pc->type == CT_SEMICOLON) && + ((prev = chunk_get_prev_ncnl(pc)) != NULL)) + { + LOG_FMT(LSCANSEMI, "Semi on %d:%d, prev = '%.*s' [%s/%s]\n", + pc->orig_line, pc->orig_col, prev->len, prev->str, + get_token_name(prev->type), get_token_name(prev->parent_type)); + + if ((prev->type == CT_BRACE_CLOSE) && + ((prev->parent_type == CT_IF) || + (prev->parent_type == CT_ELSEIF) || + (prev->parent_type == CT_ELSE) || + (prev->parent_type == CT_SWITCH) || + (prev->parent_type == CT_WHILE) || + (prev->parent_type == CT_FOR) || + (prev->parent_type == CT_FUNC_DEF) || + (prev->parent_type == CT_OC_MSG_DECL) || + (prev->parent_type == CT_FUNC_CLASS))) + { + remove_semicolon(pc); + } + else if ((prev->type == CT_BRACE_CLOSE) && + (prev->parent_type == CT_NONE)) + { + check_unknown_brace_close(pc, prev); + } + else if ((prev->type == CT_SEMICOLON) && + (prev->parent_type != CT_FOR)) + { + remove_semicolon(pc); + } + else if ((cpd.lang_flags & LANG_D) && + ((prev->parent_type == CT_ENUM) || + (prev->parent_type == CT_UNION) || + (prev->parent_type == CT_STRUCT))) + { + remove_semicolon(pc); + } + else if (prev->type == CT_BRACE_OPEN) + { + remove_semicolon(pc); + } + } + + pc = next; + } +} + + +/** + * We are on a semicolon that is after an unidentified brace close. + * Check for what is before the brace open. + * Do not remove if it is a square close, word or type. + */ +static void check_unknown_brace_close(chunk_t *semi, chunk_t *brace_close) +{ + chunk_t *pc; + + pc = chunk_get_prev_type(brace_close, CT_BRACE_OPEN, brace_close->level); + pc = chunk_get_prev_ncnl(pc); + if ((pc != NULL) && + (pc->type != CT_WORD) && + (pc->type != CT_TYPE) && + (pc->type != CT_SQUARE_CLOSE) && + (pc->type != CT_TSQUARE)) + { + remove_semicolon(semi); + } +} diff --git a/src/sorting.cpp b/src/sorting.cpp new file mode 100644 index 0000000000..8a412f2b05 --- /dev/null +++ b/src/sorting.cpp @@ -0,0 +1,169 @@ +/** + * @file braces.cpp + * Adds or removes braces. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" + + +/** + * Compare two series of chunks, starting with the given ones. + */ +static int compare_chunks(chunk_t *pc1, chunk_t *pc2) +{ + if (pc1 == pc2) + { + return(0); + } + + while ((pc1 != NULL) && (pc2 != NULL)) + { + int min_len = (pc1->len < pc2->len) ? pc1->len : pc2->len; + int ret_val = memcmp(pc1->str, pc2->str, min_len); + + if (ret_val != 0) + { + return(ret_val); + } + if (pc1->len != pc2->len) + { + return(pc1->len - pc2->len); + } + + /* Same word, same length. Step to the next chunk. */ + pc1 = chunk_get_next(pc1); + pc2 = chunk_get_next(pc2); + + /* If we hit a newline or NULL, we are done */ + if ((pc1 == NULL) || chunk_is_newline(pc1) || + (pc2 == NULL) || chunk_is_newline(pc2)) + { + break; + } + } + + if ((pc1 == NULL) || !chunk_is_newline(pc2)) + { + return(-1); + } + if (!chunk_is_newline(pc1)) + { + return(1); + } + return(0); +} + + +/** + * Sorting should be pretty rare and should usually only include a few chunks. + * We need to minimize the number of swaps, as those are expensive. + * So, we do a min sort. + */ +static void do_the_sort(chunk_t **chunks, int num_chunks) +{ + int start_idx, min_idx, idx; + + LOG_FMT(LSORT, "%s: %d chunks:", __func__, num_chunks); + for (idx = 0; idx < num_chunks; idx++) + { + LOG_FMT(LSORT, " [%.*s]", chunks[idx]->len, chunks[idx]->str); + } + LOG_FMT(LSORT, "\n"); + + for (start_idx = 0; start_idx < (num_chunks - 1); start_idx++) + { + /* Find the index of the minimum value */ + min_idx = start_idx; + for (idx = start_idx + 1; idx < num_chunks; idx++) + { + if (compare_chunks(chunks[idx], chunks[min_idx]) < 0) + { + min_idx = idx; + } + } + + /* Swap the lines if the minimum isn't the first entry */ + if (min_idx != start_idx) + { + chunk_swap_lines(chunks[start_idx], chunks[min_idx]); + + /* Don't need to swap, since we only want the side-effects */ + chunks[min_idx] = chunks[start_idx]; + } + } +} + + +void sort_imports(void) +{ + chunk_t *chunks[256]; /* 256 should be enough, right? */ + int num_chunks = 0; + chunk_t *pc; + chunk_t *next; + chunk_t *p_last = NULL; + chunk_t *p_imp = NULL; + + pc = chunk_get_head(); + while (pc != NULL) + { + next = chunk_get_next(pc); + + if (chunk_is_newline(pc)) + { + bool did_import = false; + + if ((p_imp != NULL) && (p_last != NULL) && + ((p_last->type == CT_SEMICOLON) || + (p_imp->flags & PCF_IN_PREPROC))) + { + if (num_chunks < (int)ARRAY_SIZE(chunks)) + { + chunks[num_chunks++] = p_imp; + } + did_import = true; + } + if (!did_import || (pc->nl_count > 1)) + { + if (num_chunks > 1) + { + do_the_sort(chunks, num_chunks); + } + num_chunks = 0; + memset(chunks, 0, sizeof(chunks)); + } + p_imp = NULL; + p_last = NULL; + } + else if (pc->type == CT_IMPORT) + { + if (cpd.settings[UO_mod_sort_import].b) + { + p_imp = chunk_get_next(pc); + } + } + else if (pc->type == CT_USING) + { + if (cpd.settings[UO_mod_sort_using].b) + { + p_imp = chunk_get_next(pc); + } + } + else if (pc->type == CT_PP_INCLUDE) + { + if (cpd.settings[UO_mod_sort_include].b) + { + p_imp = chunk_get_next(pc); + p_last = pc; + } + } + else if (!chunk_is_comment(pc)) + { + p_last = pc; + } + pc = next; + } +} diff --git a/src/space.cpp b/src/space.cpp new file mode 100644 index 0000000000..c0dd1f198a --- /dev/null +++ b/src/space.cpp @@ -0,0 +1,1547 @@ +/** + * @file space.cpp + * Adds or removes inter-chunk spaces. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" +#include "char_table.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +argval_t do_space(chunk_t *first, chunk_t *second, bool complete); + +struct no_space_table_s +{ + c_token_t first; + c_token_t second; +}; + +/** this table lists out all combos where a space should NOT be present + * CT_UNKNOWN is a wildcard. + * + * TODO: some of these are no longer needed. + */ +struct no_space_table_s no_space_table[] = +{ + { CT_INCDEC_BEFORE, CT_WORD }, + { CT_UNKNOWN, CT_INCDEC_AFTER }, + { CT_UNKNOWN, CT_LABEL_COLON }, + { CT_UNKNOWN, CT_PRIVATE_COLON }, + { CT_UNKNOWN, CT_SEMICOLON }, + { CT_UNKNOWN, CT_D_TEMPLATE }, + { CT_D_TEMPLATE, CT_UNKNOWN }, + { CT_MACRO_FUNC, CT_FPAREN_OPEN }, + { CT_PAREN_OPEN, CT_UNKNOWN }, + { CT_UNKNOWN, CT_PAREN_CLOSE }, + { CT_FPAREN_OPEN, CT_UNKNOWN }, + { CT_UNKNOWN, CT_SPAREN_CLOSE }, + { CT_SPAREN_OPEN, CT_UNKNOWN }, + { CT_UNKNOWN, CT_FPAREN_CLOSE }, + { CT_UNKNOWN, CT_COMMA }, + { CT_POS, CT_UNKNOWN }, + { CT_STAR, CT_UNKNOWN }, + { CT_VBRACE_CLOSE, CT_UNKNOWN }, + { CT_VBRACE_OPEN, CT_UNKNOWN }, + { CT_UNKNOWN, CT_VBRACE_CLOSE }, + { CT_UNKNOWN, CT_VBRACE_OPEN }, + { CT_PREPROC, CT_UNKNOWN }, + { CT_PREPROC_INDENT, CT_UNKNOWN }, + { CT_NEG, CT_UNKNOWN }, + { CT_UNKNOWN, CT_SQUARE_OPEN }, + { CT_UNKNOWN, CT_SQUARE_CLOSE }, + { CT_SQUARE_OPEN, CT_UNKNOWN }, + { CT_PAREN_CLOSE, CT_WORD }, + { CT_PAREN_CLOSE, CT_FUNC_DEF }, + { CT_PAREN_CLOSE, CT_FUNC_CALL }, + { CT_PAREN_CLOSE, CT_ADDR }, + { CT_PAREN_CLOSE, CT_FPAREN_OPEN }, + { CT_OC_SEL_NAME, CT_OC_SEL_NAME }, +}; + +#define log_rule(rule) \ + do { if (log_sev_on(LSPACE)) { \ + log_rule2(__LINE__, (rule), first, second, complete); } \ + } while (0) + +static void log_rule2(int line, const char *rule, chunk_t *first, chunk_t *second, bool complete) +{ + LOG_FMT(LSPACE, "Spacing: line %d [%s/%s] '%.*s' <===> [%s/%s] '%.*s' : %s[%d]%s", + first->orig_line, + get_token_name(first->type), get_token_name(first->parent_type), + first->len, first->str, + get_token_name(second->type), get_token_name(second->parent_type), + second->len, second->str, + rule, line, + complete ? "\n" : ""); +} + + +/** + * Decides how to change inter-chunk spacing. + * Note that the order of the if statements is VERY important. + * + * @param first The first chunk + * @param second The second chunk + * @return AV_IGNORE, AV_ADD, AV_REMOVE or AV_FORCE + */ +argval_t do_space(chunk_t *first, chunk_t *second, bool complete = true) +{ + int idx; + argval_t arg; + chunk_t *next; + + if ((first->type == CT_IGNORED) || (second->type == CT_IGNORED)) + { + log_rule("IGNORED"); + return(AV_REMOVE); + } + if ((first->type == CT_PP) || (second->type == CT_PP)) + { + log_rule("sp_pp_concat"); + return(cpd.settings[UO_sp_pp_concat].a); + } + if (first->type == CT_POUND) + { + log_rule("sp_pp_stringify"); + return(cpd.settings[UO_sp_pp_stringify].a); + } + + if ((first->type == CT_SPACE) || (second->type == CT_SPACE)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((second->type == CT_NEWLINE) || + (second->type == CT_VBRACE_OPEN)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if ((first->type == CT_VBRACE_OPEN) && (second->type != CT_NL_CONT)) + { + log_rule("ADD"); + return(AV_ADD); + } + if ((first->type == CT_VBRACE_CLOSE) && (second->type != CT_NL_CONT)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if (second->type == CT_VSEMICOLON) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if (first->type == CT_MACRO_FUNC) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if (second->type == CT_NL_CONT) + { + log_rule("sp_before_nl_cont"); + return(cpd.settings[UO_sp_before_nl_cont].a); + } + + if ((first->type == CT_D_ARRAY_COLON) || + (second->type == CT_D_ARRAY_COLON)) + { + log_rule("sp_d_array_colon"); + return(cpd.settings[UO_sp_d_array_colon].a); + } + + if ((first->type == CT_CASE) && CharTable::IsKw1(second->str[0])) + { + log_rule("sp_case_label"); + return(argval_t(cpd.settings[UO_sp_case_label].a | AV_ADD)); + } + + if ((first->type == CT_QUESTION) || (second->type == CT_QUESTION)) + { + if (cpd.settings[UO_sp_cond_question].a != AV_IGNORE) + { + return(cpd.settings[UO_sp_cond_question].a); + } + } + if ((first->type == CT_COND_COLON) || (second->type == CT_COND_COLON)) + { + if (cpd.settings[UO_sp_cond_colon].a != AV_IGNORE) + { + return(cpd.settings[UO_sp_cond_colon].a); + } + } + if ((first->type == CT_RANGE) || (second->type == CT_RANGE)) + { + return(cpd.settings[UO_sp_range].a); + } + + if ((first->type == CT_COLON) && (first->parent_type == CT_SQL_EXEC)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + /* Macro stuff can only return IGNORE, ADD, or FORCE */ + if (first->type == CT_MACRO) + { + log_rule("sp_macro"); + arg = cpd.settings[UO_sp_macro].a; + return((argval_t)(arg | ((arg != AV_IGNORE) ? AV_ADD : AV_IGNORE))); + } + + if ((first->type == CT_FPAREN_CLOSE) && (first->parent_type == CT_MACRO_FUNC)) + { + log_rule("sp_macro_func"); + arg = cpd.settings[UO_sp_macro_func].a; + return((argval_t)(arg | ((arg != AV_IGNORE) ? AV_ADD : AV_IGNORE))); + } + + if (first->type == CT_PREPROC) + { + /* Remove spaces, unless we are ignoring. See indent_preproc() */ + if (cpd.settings[UO_pp_space].a == AV_IGNORE) + { + log_rule("IGNORE"); + return(AV_IGNORE); + } + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if (second->type == CT_SEMICOLON) + { + if (second->parent_type == CT_FOR) + { + if ((cpd.settings[UO_sp_before_semi_for_empty].a != AV_IGNORE) && + ((first->type == CT_SPAREN_OPEN) || (first->type == CT_SEMICOLON))) + { + log_rule("sp_before_semi_for_empty"); + return(cpd.settings[UO_sp_before_semi_for_empty].a); + } + if (cpd.settings[UO_sp_before_semi_for].a != AV_IGNORE) + { + log_rule("sp_before_semi_for"); + return(cpd.settings[UO_sp_before_semi_for].a); + } + } + + arg = cpd.settings[UO_sp_before_semi].a; + log_rule("sp_before_semi"); + if ((first->type == CT_SPAREN_CLOSE) && + (first->parent_type != CT_WHILE_OF_DO)) + { + log_rule("sp_special_semi"); + arg = (argval_t)(arg | cpd.settings[UO_sp_special_semi].a); + } + return(arg); + } + + /* "for (;;)" vs "for (;; )" and "for (a;b;c)" vs "for (a; b; c)" */ + if (first->type == CT_SEMICOLON) + { + if (first->parent_type == CT_FOR) + { + if ((cpd.settings[UO_sp_after_semi_for_empty].a != AV_IGNORE) && + (second->type == CT_SPAREN_CLOSE)) + { + log_rule("sp_after_semi_for_empty"); + return(cpd.settings[UO_sp_after_semi_for_empty].a); + } + if (cpd.settings[UO_sp_after_semi_for].a != AV_IGNORE) + { + log_rule("sp_after_semi_for"); + return(cpd.settings[UO_sp_after_semi_for].a); + } + + } + else if (!chunk_is_comment(second)) + { + log_rule("sp_after_semi"); + return(cpd.settings[UO_sp_after_semi].a); + } + /* Let the comment spacing rules handle this */ + } + + if (((first->type == CT_NEG) || (first->type == CT_POS) || (first->type == CT_ARITH)) && + ((second->type == CT_NEG) || (second->type == CT_POS) || (second->type == CT_ARITH))) + { + log_rule("ADD"); + return(AV_ADD); + } + + /* "return(a);" vs "return (foo_t)a + 3;" vs "return a;" vs "return;" */ + if (first->type == CT_RETURN) + { + if ((second->type == CT_PAREN_OPEN) && + (second->parent_type == CT_RETURN)) + { + log_rule("sp_return_paren"); + return(cpd.settings[UO_sp_return_paren].a); + } + /* everything else requires a space */ + log_rule("FORCE"); + return(AV_FORCE); + } + + /* "sizeof(foo_t)" vs "sizeof foo_t" */ + if (first->type == CT_SIZEOF) + { + if (second->type == CT_PAREN_OPEN) + { + log_rule("sp_sizeof_paren"); + return(cpd.settings[UO_sp_sizeof_paren].a); + } + log_rule("FORCE"); + return(AV_FORCE); + } + + /* handle '::' */ + if (first->type == CT_DC_MEMBER) + { + log_rule("sp_after_dc"); + return(cpd.settings[UO_sp_after_dc].a); + } + if ((second->type == CT_DC_MEMBER) && + ((first->type == CT_WORD) || (first->type == CT_TYPE))) + { + log_rule("sp_before_dc"); + return(cpd.settings[UO_sp_before_dc].a); + } + + /* "a,b" vs "a, b" */ + if (first->type == CT_COMMA) + { + log_rule("sp_after_comma"); + return(cpd.settings[UO_sp_after_comma].a); + } + if (second->type == CT_COMMA) + { + log_rule("sp_before_comma"); + return(cpd.settings[UO_sp_before_comma].a); + } + + if ((second->type == CT_ELLIPSIS) && + (cpd.settings[UO_sp_before_ellipsis].a != AV_IGNORE)) + { + log_rule("sp_before_ellipsis"); + return(cpd.settings[UO_sp_before_ellipsis].a); + } + + if (first->type == CT_TAG_COLON) + { + if (second->type == CT_ELLIPSIS) + { + log_rule("FORCE"); + return(AV_FORCE); + } + log_rule("sp_after_tag"); + return(cpd.settings[UO_sp_after_tag].a); + } + if ((first->type == CT_ELLIPSIS) && CharTable::IsKw1(second->str[0])) + { + log_rule("FORCE"); + return(AV_FORCE); + } + if (second->type == CT_ELLIPSIS) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if (second->type == CT_TAG_COLON) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + /* handle '~' */ + if (first->type == CT_DESTRUCTOR) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + /* "((" vs "( (" */ + if ((chunk_is_str(first, "(", 1) && chunk_is_str(second, "(", 1)) || + (chunk_is_str(first, ")", 1) && chunk_is_str(second, ")", 1))) + { + log_rule("sp_paren_paren"); + return(cpd.settings[UO_sp_paren_paren].a); + } + + /* "if (" vs "if(" */ + if (second->type == CT_SPAREN_OPEN) + { + log_rule("sp_before_sparen"); + return(cpd.settings[UO_sp_before_sparen].a); + } + + if ((first->type == CT_LAMBDA) || + (second->type == CT_LAMBDA)) + { + log_rule("sp_assign (lambda)"); + return(cpd.settings[UO_sp_assign].a); + } + + if (second->type == CT_ASSIGN) + { + if (second->flags & PCF_IN_ENUM) + { + if (cpd.settings[UO_sp_enum_before_assign].a != AV_IGNORE) + { + log_rule("sp_enum_before_assign"); + return(cpd.settings[UO_sp_enum_before_assign].a); + } + log_rule("sp_enum_assign"); + return(cpd.settings[UO_sp_enum_assign].a); + } + if (cpd.settings[UO_sp_before_assign].a != AV_IGNORE) + { + log_rule("sp_before_assign"); + return(cpd.settings[UO_sp_before_assign].a); + } + log_rule("sp_assign"); + return(cpd.settings[UO_sp_assign].a); + } + + if (first->type == CT_ASSIGN) + { + if (first->flags & PCF_IN_ENUM) + { + if (cpd.settings[UO_sp_enum_after_assign].a != AV_IGNORE) + { + log_rule("sp_enum_after_assign"); + return(cpd.settings[UO_sp_enum_after_assign].a); + } + log_rule("sp_enum_assign"); + return(cpd.settings[UO_sp_enum_assign].a); + } + if (cpd.settings[UO_sp_after_assign].a != AV_IGNORE) + { + log_rule("sp_after_assign"); + return(cpd.settings[UO_sp_after_assign].a); + } + log_rule("sp_assign"); + return(cpd.settings[UO_sp_assign].a); + } + + /* "a [x]" vs "a[x]" */ + if ((second->type == CT_SQUARE_OPEN) && (second->parent_type != CT_OC_MSG)) + { + log_rule("sp_before_square"); + return(cpd.settings[UO_sp_before_square].a); + } + + /* "byte[]" vs "byte []" */ + if (second->type == CT_TSQUARE) + { + log_rule("sp_before_squares"); + return(cpd.settings[UO_sp_before_squares].a); + } + + /* spacing around template < > stuff */ + if ((first->type == CT_ANGLE_OPEN) || + (second->type == CT_ANGLE_CLOSE)) + { + log_rule("sp_inside_angle"); + return(cpd.settings[UO_sp_inside_angle].a); + } + if (second->type == CT_ANGLE_OPEN) + { + if ((first->type == CT_TEMPLATE) && + (cpd.settings[UO_sp_template_angle].a != AV_IGNORE)) + { + log_rule("sp_template_angle"); + return(cpd.settings[UO_sp_template_angle].a); + } + log_rule("sp_before_angle"); + return(cpd.settings[UO_sp_before_angle].a); + } + if (first->type == CT_ANGLE_CLOSE) + { + if ((second->type == CT_WORD) || CharTable::IsKw1(second->str[0])) + { + if (cpd.settings[UO_sp_angle_word].a != AV_IGNORE) + { + log_rule("sp_angle_word"); + return(cpd.settings[UO_sp_angle_word].a); + } + } + if ((second->type == CT_FPAREN_OPEN) || + (second->type == CT_PAREN_OPEN)) + { + log_rule("sp_angle_paren"); + return(cpd.settings[UO_sp_angle_paren].a); + } + if (second->type == CT_DC_MEMBER) + { + log_rule("sp_before_dc"); + return(cpd.settings[UO_sp_before_dc].a); + } + if ((second->type != CT_BYREF) && + (second->type != CT_PTR_TYPE)) + { + log_rule("sp_after_angle"); + return(cpd.settings[UO_sp_after_angle].a); + } + } + + if ((first->type == CT_BYREF) && + (cpd.settings[UO_sp_after_byref_func].a != AV_IGNORE) && + ((first->parent_type == CT_FUNC_DEF) || + (first->parent_type == CT_FUNC_PROTO))) + { + log_rule("sp_after_byref_func"); + return(cpd.settings[UO_sp_after_byref_func].a); + } + + if ((first->type == CT_BYREF) && CharTable::IsKw1(second->str[0])) + { + log_rule("sp_after_byref"); + return(cpd.settings[UO_sp_after_byref].a); + } + + if (second->type == CT_BYREF) + { + if (cpd.settings[UO_sp_before_byref_func].a != AV_IGNORE) + { + next = chunk_get_next(second); + if ((next != NULL) && + ((next->type == CT_FUNC_DEF) || + (next->type == CT_FUNC_PROTO))) + { + return(cpd.settings[UO_sp_before_byref_func].a); + } + } + + if (cpd.settings[UO_sp_before_unnamed_byref].a != AV_IGNORE) + { + next = chunk_get_next_nc(second); + if ((next != NULL) && (next->type != CT_WORD)) + { + log_rule("sp_before_unnamed_byref"); + return(cpd.settings[UO_sp_before_unnamed_byref].a); + } + } + log_rule("sp_before_byref"); + return(cpd.settings[UO_sp_before_byref].a); + } + + if (first->type == CT_SPAREN_CLOSE) + { + if ((second->type == CT_BRACE_OPEN) && + (cpd.settings[UO_sp_sparen_brace].a != AV_IGNORE)) + { + log_rule("sp_sparen_brace"); + return(cpd.settings[UO_sp_sparen_brace].a); + } + if (!chunk_is_comment(second) && + (cpd.settings[UO_sp_after_sparen].a != AV_IGNORE)) + { + log_rule("sp_after_sparen"); + return(cpd.settings[UO_sp_after_sparen].a); + } + } + + if ((second->type == CT_FPAREN_OPEN) && + (first->parent_type == CT_OPERATOR) && + (cpd.settings[UO_sp_after_operator_sym].a != AV_IGNORE)) + { + log_rule("sp_after_operator_sym"); + return(cpd.settings[UO_sp_after_operator_sym].a); + } + + /* spaces between function and open paren */ + if ((first->type == CT_FUNC_CALL) || + (first->type == CT_FUNC_CTOR_VAR)) + { + log_rule("sp_func_call_paren"); + return(cpd.settings[UO_sp_func_call_paren].a); + } + if (first->type == CT_FUNC_CALL_USER) + { + log_rule("sp_func_call_user_paren"); + return(cpd.settings[UO_sp_func_call_user_paren].a); + } + if (first->type == CT_ATTRIBUTE) + { + log_rule("sp_attribute_paren"); + return(cpd.settings[UO_sp_attribute_paren].a); + } + if (first->type == CT_FUNC_DEF) + { + log_rule("sp_func_def_paren"); + return(cpd.settings[UO_sp_func_def_paren].a); + } + if (first->type == CT_CPP_CAST) + { + log_rule("sp_cpp_cast_paren"); + return(cpd.settings[UO_sp_cpp_cast_paren].a); + } + + if ((first->type == CT_PAREN_CLOSE) && + ((second->type == CT_PAREN_OPEN) || + (second->type == CT_FPAREN_OPEN))) + { + /* "(int)a" vs "(int) a" or "cast(int)a" vs "cast(int) a" */ + if ((first->parent_type == CT_C_CAST) || + (first->parent_type == CT_D_CAST)) + { + log_rule("sp_after_cast"); + return(cpd.settings[UO_sp_after_cast].a); + } + + /* Must be an indirect/chained function call? */ + log_rule("REMOVE"); + return(AV_REMOVE); /* TODO: make this configurable? */ + } + + if ((first->type == CT_FUNC_PROTO) || + ((second->type == CT_FPAREN_OPEN) && + (second->parent_type == CT_FUNC_PROTO))) + { + log_rule("sp_func_proto_paren"); + return(cpd.settings[UO_sp_func_proto_paren].a); + } + if (first->type == CT_FUNC_CLASS) + { + log_rule("sp_func_class_paren"); + return(cpd.settings[UO_sp_func_class_paren].a); + } + if ((first->type == CT_CLASS) && (first->parent_type != CT_OC_MSG)) + { + log_rule("FORCE"); + return(AV_FORCE); + } + + if ((first->type == CT_BRACE_OPEN) && (second->type == CT_BRACE_CLOSE)) + { + log_rule("sp_inside_braces_empty"); + return(cpd.settings[UO_sp_inside_braces_empty].a); + } + + if (second->type == CT_BRACE_CLOSE) + { + if (second->parent_type == CT_ENUM) + { + log_rule("sp_inside_braces_enum"); + return(cpd.settings[UO_sp_inside_braces_enum].a); + } + if ((second->parent_type == CT_STRUCT) || + (second->parent_type == CT_UNION)) + { + log_rule("sp_inside_braces_struct"); + return(cpd.settings[UO_sp_inside_braces_struct].a); + } + log_rule("sp_inside_braces"); + return(cpd.settings[UO_sp_inside_braces].a); + } + + if (first->type == CT_D_CAST) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_PP_DEFINED) && (second->type == CT_PAREN_OPEN)) + { + log_rule("sp_defined_paren"); + return(cpd.settings[UO_sp_defined_paren].a); + } + + if ((first->type == CT_THROW) && (second->type == CT_PAREN_OPEN)) + { + log_rule("sp_throw_paren"); + return(cpd.settings[UO_sp_throw_paren].a); + } + + if ((first->type == CT_THIS) && (second->type == CT_PAREN_OPEN)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_STATE) && (second->type == CT_PAREN_OPEN)) + { + log_rule("ADD"); + return(AV_ADD); + } + + if ((first->type == CT_DELEGATE) && (second->type == CT_PAREN_OPEN)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_MEMBER) || (second->type == CT_MEMBER)) + { + log_rule("sp_member"); + return(cpd.settings[UO_sp_member].a); + } + + if (first->type == CT_C99_MEMBER) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_SUPER) && (second->type == CT_PAREN_OPEN)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_FPAREN_CLOSE) && (second->type == CT_BRACE_OPEN)) + { + log_rule("sp_fparen_brace"); + return(cpd.settings[UO_sp_fparen_brace].a); + } + + if ((first->type == CT_D_TEMPLATE) || (second->type == CT_D_TEMPLATE)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_ELSE) && (second->type == CT_BRACE_OPEN)) + { + log_rule("sp_else_brace"); + return(cpd.settings[UO_sp_else_brace].a); + } + + if ((first->type == CT_ELSE) && (second->type == CT_ELSEIF)) + { + log_rule("FORCE"); + return(AV_FORCE); + } + + if ((first->type == CT_CATCH) && (second->type == CT_BRACE_OPEN)) + { + log_rule("sp_catch_brace"); + return(cpd.settings[UO_sp_catch_brace].a); + } + + if ((first->type == CT_FINALLY) && (second->type == CT_BRACE_OPEN)) + { + log_rule("sp_finally_brace"); + return(cpd.settings[UO_sp_finally_brace].a); + } + + if ((first->type == CT_TRY) && (second->type == CT_BRACE_OPEN)) + { + log_rule("sp_try_brace"); + return(cpd.settings[UO_sp_try_brace].a); + } + + if ((first->type == CT_GETSET) && (second->type == CT_BRACE_OPEN)) + { + log_rule("sp_getset_brace"); + return(cpd.settings[UO_sp_getset_brace].a); + } + + if ((second->type == CT_PAREN_OPEN) && + (second->parent_type == CT_INVARIANT)) + { + log_rule("sp_invariant_paren"); + return(cpd.settings[UO_sp_invariant_paren].a); + } + + if (first->type == CT_PAREN_CLOSE) + { + if (first->parent_type == CT_D_TEMPLATE) + { + log_rule("FORCE"); + return(AV_FORCE); + } + + if (first->parent_type == CT_INVARIANT) + { + log_rule("sp_after_invariant_paren"); + return(cpd.settings[UO_sp_after_invariant_paren].a); + } + + /* Arith after a cast comes first */ + if (second->type == CT_ARITH) + { + log_rule("sp_arith"); + return(cpd.settings[UO_sp_arith].a); + } + + /* "(int)a" vs "(int) a" or "cast(int)a" vs "cast(int) a" */ + if ((first->parent_type == CT_C_CAST) || + (first->parent_type == CT_D_CAST)) + { + log_rule("sp_after_cast"); + return(cpd.settings[UO_sp_after_cast].a); + } + + /* "(struct foo) {...}" vs "(struct foo){...}" */ + if (second->type == CT_BRACE_OPEN) + { + log_rule("sp_paren_brace"); + return(cpd.settings[UO_sp_paren_brace].a); + } + + /* D-specific: "delegate(some thing) dg */ + if (first->parent_type == CT_DELEGATE) + { + log_rule("ADD"); + return(AV_ADD); + } + + /* PAWN-specific: "state (condition) next" */ + if (first->parent_type == CT_STATE) + { + log_rule("ADD"); + return(AV_ADD); + } + } + + /* "foo(...)" vs "foo( ... )" */ + if ((first->type == CT_FPAREN_OPEN) || (second->type == CT_FPAREN_CLOSE)) + { + if ((first->type == CT_FPAREN_OPEN) && (second->type == CT_FPAREN_CLOSE)) + { + log_rule("sp_inside_fparens"); + return(cpd.settings[UO_sp_inside_fparens].a); + } + log_rule("sp_inside_fparen"); + return(cpd.settings[UO_sp_inside_fparen].a); + } + + if (first->type == CT_PAREN_CLOSE) + { + if (first->parent_type == CT_OC_RTYPE) + { + log_rule("sp_after_oc_return_type"); + return(cpd.settings[UO_sp_after_oc_return_type].a); + } + else if ((first->parent_type == CT_OC_MSG_SPEC) || + (first->parent_type == CT_OC_MSG_DECL)) + { + log_rule("sp_after_oc_type"); + return(cpd.settings[UO_sp_after_oc_type].a); + } + } + + if ((first->type == CT_OC_SEL) && (second->type == CT_PAREN_OPEN)) + { + log_rule("sp_after_oc_at_sel"); + return(cpd.settings[UO_sp_after_oc_at_sel].a); + } + + /* C cast: "(int)" vs "( int )" + * D cast: "cast(int)" vs "cast( int )" + * CPP cast: "int(a + 3)" vs "int( a + 3 )" + */ + if (first->type == CT_PAREN_OPEN) + { + if ((first->parent_type == CT_C_CAST) || + (first->parent_type == CT_CPP_CAST) || + (first->parent_type == CT_D_CAST)) + { + log_rule("sp_inside_paren_cast"); + return(cpd.settings[UO_sp_inside_paren_cast].a); + } + log_rule("sp_inside_paren"); + return(cpd.settings[UO_sp_inside_paren].a); + } + + if (second->type == CT_PAREN_CLOSE) + { + if ((second->parent_type == CT_C_CAST) || + (second->parent_type == CT_CPP_CAST) || + (second->parent_type == CT_D_CAST)) + { + log_rule("sp_inside_paren_cast"); + return(cpd.settings[UO_sp_inside_paren_cast].a); + } + log_rule("sp_inside_paren"); + return(cpd.settings[UO_sp_inside_paren].a); + } + + /* "[3]" vs "[ 3 ]" */ + if ((first->type == CT_SQUARE_OPEN) || (second->type == CT_SQUARE_CLOSE)) + { + log_rule("sp_inside_square"); + return(cpd.settings[UO_sp_inside_square].a); + } + if ((first->type == CT_SQUARE_CLOSE) && (second->type == CT_FPAREN_OPEN)) + { + log_rule("sp_square_fparen"); + return(cpd.settings[UO_sp_square_fparen].a); + } + + /* "if(...)" vs "if( ... )" */ + if ((second->type == CT_SPAREN_CLOSE) && + (cpd.settings[UO_sp_inside_sparen_close].a != AV_IGNORE)) + { + log_rule("sp_inside_sparen_close"); + return(cpd.settings[UO_sp_inside_sparen_close].a); + } + if ((first->type == CT_SPAREN_OPEN) || (second->type == CT_SPAREN_CLOSE)) + { + log_rule("sp_inside_sparen"); + return(cpd.settings[UO_sp_inside_sparen].a); + } + + if ((cpd.settings[UO_sp_after_class_colon].a != AV_IGNORE) && + (first->type == CT_CLASS_COLON)) + { + log_rule("sp_after_class_colon"); + return(cpd.settings[UO_sp_after_class_colon].a); + } + if ((cpd.settings[UO_sp_before_class_colon].a != AV_IGNORE) && + (second->type == CT_CLASS_COLON)) + { + log_rule("sp_before_class_colon"); + return(cpd.settings[UO_sp_before_class_colon].a); + } + if ((cpd.settings[UO_sp_before_case_colon].a != AV_IGNORE) && + (second->type == CT_CASE_COLON)) + { + log_rule("sp_before_case_colon"); + return(cpd.settings[UO_sp_before_case_colon].a); + } + + if (first->type == CT_DOT) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if (second->type == CT_DOT) + { + log_rule("ADD"); + return(AV_ADD); + } + + if ((first->type == CT_ARITH) || (second->type == CT_ARITH)) + { + log_rule("sp_arith"); + return(cpd.settings[UO_sp_arith].a); + } + if ((first->type == CT_BOOL) || (second->type == CT_BOOL)) + { + arg = cpd.settings[UO_sp_bool].a; + if ((cpd.settings[UO_pos_bool].tp != TP_IGNORE) && + (first->orig_line != second->orig_line) && + (arg != AV_REMOVE)) + { + arg = (argval_t)(arg | AV_ADD); + } + log_rule("sp_bool"); + return(arg); + } + if ((first->type == CT_COMPARE) || (second->type == CT_COMPARE)) + { + log_rule("sp_compare"); + return(cpd.settings[UO_sp_compare].a); + } + + if ((first->type == CT_PAREN_OPEN) && (second->type == CT_PTR_TYPE)) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + + if ((first->type == CT_PTR_TYPE) && + (second->type == CT_PTR_TYPE) && + (cpd.settings[UO_sp_between_ptr_star].a != AV_IGNORE)) + { + log_rule("sp_between_ptr_star"); + return(cpd.settings[UO_sp_between_ptr_star].a); + } + + if ((first->type == CT_PTR_TYPE) && + (cpd.settings[UO_sp_after_ptr_star_func].a != AV_IGNORE) && + ((first->parent_type == CT_FUNC_DEF) || + (first->parent_type == CT_FUNC_PROTO))) + { + log_rule("sp_after_ptr_star_func"); + return(cpd.settings[UO_sp_after_ptr_star_func].a); + } + + if ((first->type == CT_PTR_TYPE) && + (cpd.settings[UO_sp_after_ptr_star].a != AV_IGNORE) && + CharTable::IsKw1(second->str[0])) + { + log_rule("sp_after_ptr_star"); + return(cpd.settings[UO_sp_after_ptr_star].a); + } + + if (second->type == CT_PTR_TYPE) + { + if (cpd.settings[UO_sp_before_ptr_star_func].a != AV_IGNORE) + { + /* Find the next non-'*' chunk */ + next = second; + do + { + next = chunk_get_next(next); + } while ((next != NULL) && (next->type == CT_PTR_TYPE)); + + if ((next != NULL) && + ((next->type == CT_FUNC_DEF) || + (next->type == CT_FUNC_PROTO))) + { + return(cpd.settings[UO_sp_before_ptr_star_func].a); + } + } + + if (cpd.settings[UO_sp_before_unnamed_ptr_star].a != AV_IGNORE) + { + next = chunk_get_next_nc(second); + while ((next != NULL) && (next->type == CT_PTR_TYPE)) + { + next = chunk_get_next_nc(next); + } + if ((next != NULL) && (next->type != CT_WORD)) + { + log_rule("sp_before_unnamed_ptr_star"); + return(cpd.settings[UO_sp_before_unnamed_ptr_star].a); + } + } + if (cpd.settings[UO_sp_before_ptr_star].a != AV_IGNORE) + { + log_rule("sp_before_ptr_star"); + return(cpd.settings[UO_sp_before_ptr_star].a); + } + } + + if (first->type == CT_OPERATOR) + { + log_rule("sp_after_operator"); + return(cpd.settings[UO_sp_after_operator].a); + } + + if ((second->type == CT_FUNC_PROTO) || (second->type == CT_FUNC_DEF)) + { + if (first->type != CT_PTR_TYPE) + { + log_rule("sp_type_func|ADD"); + return((argval_t)(cpd.settings[UO_sp_type_func].a | AV_ADD)); + } + log_rule("sp_type_func"); + return(cpd.settings[UO_sp_type_func].a); + } + + if (first->type == CT_BRACE_CLOSE) + { + if (second->type == CT_ELSE) + { + log_rule("sp_brace_else"); + return(cpd.settings[UO_sp_brace_else].a); + } + else if (second->type == CT_CATCH) + { + log_rule("sp_brace_catch"); + return(cpd.settings[UO_sp_brace_catch].a); + } + else if (second->type == CT_FINALLY) + { + log_rule("sp_brace_finally"); + return(cpd.settings[UO_sp_brace_finally].a); + } + } + + if (first->type == CT_BRACE_OPEN) + { + if (first->parent_type == CT_ENUM) + { + log_rule("sp_inside_braces_enum"); + return(cpd.settings[UO_sp_inside_braces_enum].a); + } + else if ((first->parent_type == CT_UNION) || + (first->parent_type == CT_STRUCT)) + { + log_rule("sp_inside_braces_struct"); + return(cpd.settings[UO_sp_inside_braces_struct].a); + } + else if (!chunk_is_comment(second)) + { + log_rule("sp_inside_braces"); + return(cpd.settings[UO_sp_inside_braces].a); + } + } + + if (second->type == CT_BRACE_CLOSE) + { + if (second->parent_type == CT_ENUM) + { + log_rule("sp_inside_braces_enum"); + return(cpd.settings[UO_sp_inside_braces_enum].a); + } + else if ((second->parent_type == CT_UNION) || + (second->parent_type == CT_STRUCT)) + { + log_rule("sp_inside_braces_struct"); + return(cpd.settings[UO_sp_inside_braces_struct].a); + } + log_rule("sp_inside_braces"); + return(cpd.settings[UO_sp_inside_braces].a); + } + + if ((first->type == CT_BRACE_CLOSE) && + (first->flags & PCF_IN_TYPEDEF) && + ((first->parent_type == CT_ENUM) || + (first->parent_type == CT_STRUCT) || + (first->parent_type == CT_UNION))) + { + log_rule("sp_brace_typedef"); + return(cpd.settings[UO_sp_brace_typedef].a); + } + + if (second->type == CT_SPAREN_OPEN) + { + log_rule("sp_before_sparen"); + return(cpd.settings[UO_sp_before_sparen].a); + } + + if ((second->type != CT_PTR_TYPE) && + ((first->type == CT_QUALIFIER) || (first->type == CT_TYPE))) + { + arg = cpd.settings[UO_sp_after_type].a; + log_rule("sp_after_type"); + return((arg != AV_REMOVE) ? arg : AV_FORCE); + } + + if ((first->type == CT_MACRO_OPEN) || + (first->type == CT_MACRO_CLOSE) || + (first->type == CT_MACRO_ELSE)) + { + if (second->type == CT_PAREN_OPEN) + { + log_rule("sp_func_call_paren"); + return(cpd.settings[UO_sp_func_call_paren].a); + } + log_rule("IGNORE"); + return(AV_IGNORE); + } + + /* If nothing claimed the PTR_TYPE, then return ignore */ + if ((first->type == CT_PTR_TYPE) || (second->type == CT_PTR_TYPE)) + { + log_rule("IGNORE"); + return(AV_IGNORE); + } + + if (first->type == CT_NOT) + { + log_rule("sp_not"); + return(cpd.settings[UO_sp_not].a); + } + if (first->type == CT_INV) + { + log_rule("sp_inv"); + return(cpd.settings[UO_sp_inv].a); + } + if (first->type == CT_ADDR) + { + log_rule("sp_addr"); + return(cpd.settings[UO_sp_addr].a); + } + if (first->type == CT_DEREF) + { + log_rule("sp_deref"); + return(cpd.settings[UO_sp_deref].a); + } + if ((first->type == CT_POS) || (first->type == CT_NEG)) + { + log_rule("sp_sign"); + return(cpd.settings[UO_sp_sign].a); + } + if ((first->type == CT_INCDEC_BEFORE) || (second->type == CT_INCDEC_AFTER)) + { + log_rule("sp_incdec"); + return(cpd.settings[UO_sp_incdec].a); + } + if (second->type == CT_CS_SQ_COLON) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + if (first->type == CT_CS_SQ_COLON) + { + log_rule("FORCE"); + return(AV_FORCE); + } + if (first->type == CT_OC_SCOPE) + { + log_rule("sp_after_oc_scope"); + return(cpd.settings[UO_sp_after_oc_scope].a); + } + if (first->type == CT_OC_COLON) + { + if (first->parent_type == CT_OC_MSG) + { + log_rule("sp_after_send_oc_colon"); + return(cpd.settings[UO_sp_after_send_oc_colon].a); + } + else + { + log_rule("sp_after_oc_colon"); + return(cpd.settings[UO_sp_after_oc_colon].a); + } + } + if (second->type == CT_OC_COLON) + { + if (first->parent_type == CT_OC_MSG) + { + log_rule("sp_before_send_oc_colon"); + return(cpd.settings[UO_sp_before_send_oc_colon].a); + } + else + { + log_rule("sp_before_oc_colon"); + return(cpd.settings[UO_sp_before_oc_colon].a); + } + } + + if ((second->type == CT_COMMENT) && (second->parent_type == CT_COMMENT_EMBED)) + { + log_rule("FORCE"); + return(AV_FORCE); + } + + if (chunk_is_comment(second)) + { + log_rule("IGNORE"); + return(AV_IGNORE); + } + + if (first->type == CT_COMMENT) + { + log_rule("FORCE"); + return(AV_FORCE); + } + + for (idx = 0; idx < (int)ARRAY_SIZE(no_space_table); idx++) + { + if (((no_space_table[idx].first == CT_UNKNOWN) || + (no_space_table[idx].first == first->type)) + && + ((no_space_table[idx].second == CT_UNKNOWN) || + (no_space_table[idx].second == second->type))) + { + log_rule("REMOVE"); + return(AV_REMOVE); + } + } + log_rule("ADD"); + return(AV_ADD); +} + + +/** + * Marches through the whole file and checks to see how many spaces should be + * between two chunks + */ +void space_text(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *tmp; + int column, prev_column; + int delta; + + pc = chunk_get_head(); + if (pc == NULL) + { + return; + } + column = pc->column; + while (pc != NULL) + { + next = chunk_get_next(pc); + if (next == NULL) + { + break; + } + + /* If the current chunk contains a newline, do not change the column + * of the next item */ + if ((pc->type == CT_NEWLINE) || + (pc->type == CT_NL_CONT) || + (pc->type == CT_COMMENT_MULTI)) + { + column = next->column; + } + else + { + /* Set to the minimum allowed column */ + if (pc->nl_count == 0) + { + column += pc->len; + } + else + { + column = pc->orig_col_end; + } + prev_column = column; + + /** + * Apply a general safety check + * If the two chunks combined will tokenize differently, then we + * must force a space. + * Two chunks -- "()" and "[]" will always tokenize differently. + * They are always safe to not have a space after them. + */ + pc->flags &= ~PCF_FORCE_SPACE; + if ((pc->len > 0) && + !chunk_is_str(pc, "[]", 2) && + !chunk_is_str(pc, "()", 2)) + { + /* Find the next non-empty chunk on this line */ + tmp = next; + while ((tmp != NULL) && (tmp->len == 0) && !chunk_is_newline(tmp)) + { + tmp = chunk_get_next(tmp); + } + if ((tmp != NULL) && (tmp->len > 0)) + { + bool kw1 = CharTable::IsKw2(pc->str[pc->len - 1]); + bool kw2 = CharTable::IsKw1(next->str[0]); + if (kw1 && kw2) + { + /* back-to-back words need a space */ + pc->flags |= PCF_FORCE_SPACE; + } + else if (!kw1 && !kw2 && (pc->len < 4) && (next->len < 4)) + { + /* We aren't dealing with keywords. concat and try punctuators */ + char buf[9]; + memcpy(buf, pc->str, pc->len); + memcpy(buf + pc->len, next->str, next->len); + buf[pc->len + next->len] = 0; + + const chunk_tag_t *ct; + ct = find_punctuator(buf, cpd.lang_flags); + if ((ct != NULL) && ((int)strlen(ct->tag) != pc->len)) + { + /* punctuator parsed to a different size.. */ + pc->flags |= PCF_FORCE_SPACE; + } + } + } + } + + int av = do_space(pc, next, false); + if (pc->flags & PCF_FORCE_SPACE) + { + av |= AV_ADD; + } + switch (av) + { + case AV_FORCE: + /* add exactly one space */ + column++; + break; + + case AV_ADD: + delta = 1; + if ((next->orig_col >= pc->orig_col_end) && (pc->orig_col_end != 0)) + { + /* Keep the same relative spacing, minimum 1 */ + delta = next->orig_col - pc->orig_col_end; + if (delta < 1) + { + delta = 1; + } + } + column += delta; + break; + + case AV_REMOVE: + /* the symbols will be back-to-back "a+3" */ + break; + + default: + /* Keep the same relative spacing, if possible */ + if ((next->orig_col >= pc->orig_col_end) && (pc->orig_col_end != 0)) + { + column += next->orig_col - pc->orig_col_end; + } + break; + } + + if (chunk_is_comment(next) && + chunk_is_newline(chunk_get_next(next)) && + (column < (int)next->orig_col)) + { + if (cpd.settings[UO_indent_relative_single_line_comments].b) + { + column = pc->column + (next->orig_col - pc->orig_col_end); + } + else + { + column = next->orig_col; + } + } + next->column = column; + + LOG_FMT(LSPACE, " = %s @ %d\n", + (av == AV_IGNORE) ? "IGNORE" : + (av == AV_ADD) ? "ADD" : + (av == AV_ADD) ? "REMOVE" : "FORCE", + column - prev_column); + } + + pc = next; + } +} + + +/** + * Marches through the whole file and adds spaces around nested parens + */ +void space_text_balance_nested_parens(void) +{ + chunk_t *first; + chunk_t *next; + chunk_t *cur; + chunk_t *prev; + + first = chunk_get_head(); + while (first != NULL) + { + next = chunk_get_next(first); + if (next == NULL) + { + break; + } + + if (chunk_is_str(first, "(", 1) && chunk_is_str(next, "(", 1)) + { + /* insert a space between the two opening parens */ + space_add_after(first, 1); + + /* find the closing paren that matches the 'first' open paren and force + * a space before it */ + cur = next; + prev = cur; + while ((cur = chunk_get_next(cur)) != NULL) + { + if (cur->level == first->level) + { + space_add_after(prev, 1); + break; + } + prev = cur; + } + } + else if (chunk_is_str(first, ")", 1) && chunk_is_str(next, ")", 1)) + { + /* insert a space between the two closing parens */ + space_add_after(first, 1); + + /* find the opening paren that matches the 'next' close paren and force + * a space after it */ + cur = first; + while ((cur = chunk_get_prev(cur)) != NULL) + { + if (cur->level == next->level) + { + space_add_after(cur, 1); + break; + } + } + } + + first = next; + } +} + + +/** + * Calculates the column difference between two chunks. + * The rules are bent a bit here, as AV_IGNORE and AV_ADD become AV_FORCE. + * So the column difference is either first->len or first->len + 1. + * + * @param first The first chunk + * @param second The second chunk + * @return the column difference between the two chunks + */ +int space_col_align(chunk_t *first, chunk_t *second) +{ + int coldiff; + argval_t av; + + av = do_space(first, second); + + coldiff = first->len; + switch (av) + { + case AV_ADD: + case AV_FORCE: + coldiff++; + break; + + case AV_REMOVE: + break; + + case AV_IGNORE: + if (second->orig_col > (first->orig_col + first->len)) + { + coldiff++; + } + break; + } + return(coldiff); +} + + +void space_add_after(chunk_t *pc, int count) +{ + if (count <= 0) + { + return; + } + + chunk_t *next = chunk_get_next(pc); + + /* don't add at the end of the file or before a newline */ + if ((next == NULL) || chunk_is_newline(next)) + { + return; + } + + /* Limit to 16 spaces */ + if (count > 16) + { + count = 16; + } + + /* Two CT_SPACE in a row -- use the max of the two */ + if (next->type == CT_SPACE) + { + if (next->len < count) + { + next->len = count; + } + return; + } + + chunk_t sp; + + memset(&sp, 0, sizeof(sp)); + + sp.flags = pc->flags & PCF_COPY_FLAGS; + sp.type = CT_SPACE; + sp.str = " "; // 16 spaces + sp.len = count; + sp.level = pc->level; + sp.brace_level = pc->brace_level; + sp.pp_level = pc->pp_level; + sp.column = pc->column + pc->len; + sp.orig_line = pc->orig_line; + + chunk_add_after(&sp, pc); +} diff --git a/src/token_enum.h b/src/token_enum.h new file mode 100644 index 0000000000..041cb4ad34 --- /dev/null +++ b/src/token_enum.h @@ -0,0 +1,283 @@ +/** + * @file token_enum.h + * List of the different tokens used in the program. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef TOKEN_ENUM_H_INCLUDED +#define TOKEN_ENUM_H_INCLUDED + +/** + * This is an enum of all the different chunks/tokens/elements that the + * program can work with. The parser and scanner assigns one of these to + * each chunk/token. + * + * The script 'make_token_names.sh' creates token_names.h, so be sure to run + * that after adding or removing an entry. + */ +typedef enum +{ + CT_NONE, + CT_SOF, /* Start of the file */ + CT_EOF, + CT_UNKNOWN, + + CT_JUNK, /* junk collected when parsing is disabled */ + + CT_WHITESPACE, /* whitespace without any newlines */ + CT_SPACE, /* a fixed number of spaces to support weird spacing rules */ + CT_NEWLINE, /* CRA, one or more newlines */ + CT_NL_CONT, /* CRA, backslash-newline */ + CT_COMMENT_CPP, /* C++ comment (always followed by CT_NEWLINE) */ + CT_COMMENT, /* C-comment, single line */ + CT_COMMENT_MULTI, /* Multi-lined comment */ + CT_COMMENT_EMBED, /* comment parent_type: non-newline before and after */ + CT_COMMENT_START, /* comment parent_type: newline before */ + CT_COMMENT_END, /* comment parent_type: newline after */ + CT_COMMENT_WHOLE, /* comment parent_type: newline before and after */ + + CT_IGNORED, /* a chunk of ignored text */ + + CT_WORD, /* variable, type, function name, etc */ + CT_NUMBER, + CT_NUMBER_FP, + CT_STRING, /* quoted string "hi" or 'a' or for include */ + CT_STRING_MULTI, /* quoted string with embedded newline */ + CT_IF, /* built-in keywords */ + CT_ELSE, + CT_ELSEIF, + CT_FOR, + CT_WHILE, + CT_WHILE_OF_DO, + CT_SWITCH, + CT_CASE, + CT_DO, + CT_VOLATILE, + CT_TYPEDEF, + CT_STRUCT, + CT_ENUM, + CT_SIZEOF, + CT_RETURN, + CT_BREAK, + CT_UNION, + CT_GOTO, + CT_CONTINUE, + CT_C_CAST, /* C-style cast: "(int)5.6" */ + CT_CPP_CAST, /* C++-style cast: "int(5.6)" */ + CT_D_CAST, /* D-style cast: "cast(type)" */ + CT_TYPE_CAST, /* static_cast(exp) */ + CT_TYPENAME, /* typename type */ + CT_TEMPLATE, /* template<...> */ + + CT_ASSIGN, /* =, +=, /=, etc */ + CT_ASSIGN_NL, /* Assign followed by a newline - fake item for indenting */ + CT_SASSIGN, /* 'and_eq' */ + CT_COMPARE, /* ==, !=, <=, >= */ + CT_SCOMPARE, /* compare op that is a string 'is', 'neq' */ + CT_BOOL, /* || or && */ + CT_SBOOL, /* or, and */ + CT_ARITH, /* +, -, /, <<, etc */ + CT_SARITH, /* 'not', 'xor' */ + CT_DEREF, /* * dereference */ + CT_INCDEC_BEFORE, /* ++a or --a */ + CT_INCDEC_AFTER, /* a++ or a-- */ + CT_MEMBER, /* . or -> */ + CT_DC_MEMBER, /* :: */ + CT_C99_MEMBER, /* . in structure stuff */ + CT_INV, /* ~ */ + CT_DESTRUCTOR, /* ~ */ + CT_NOT, /* ! */ + CT_D_TEMPLATE, /* ! as in Foo!(A) */ + CT_ADDR, /* & */ + CT_NEG, /* - as in -1 */ + CT_POS, /* + as in +1 */ + CT_STAR, /* * : raw char to be changed */ + CT_PLUS, /* + : raw char to be changed */ + CT_MINUS, /* - : raw char to be changed */ + CT_AMP, /* & : raw char to be changed */ + CT_BYREF, /* & in function def/proto params */ + + CT_POUND, /* # */ + CT_PREPROC, /* # at the start of a line */ + CT_PREPROC_INDENT, /* # at the start of a line that gets indented: #region */ + CT_PREPROC_BODY, /* body of every preproc EXCEPT #define */ + CT_PP, /* ## */ + CT_ELLIPSIS, /* ... */ + CT_RANGE, /* .. */ + + CT_SEMICOLON, + CT_VSEMICOLON, /* virtual semicolon for PAWN */ + CT_COLON, + CT_CASE_COLON, + CT_CLASS_COLON, /* colon after a class def or constructor */ + CT_D_ARRAY_COLON, /* D named array initializer colon */ + CT_COND_COLON, /* conditional colon in 'b ? t : f' */ + CT_QUESTION, + CT_COMMA, + + CT_ASM, + CT_ATTRIBUTE, + CT_CATCH, + CT_CLASS, + CT_DELETE, + CT_EXPORT, + CT_FRIEND, + CT_MUTABLE, + CT_NAMESPACE, + CT_NEW, /* may turn into CT_PBRACED if followed by a '(' */ + CT_OPERATOR, + CT_PRIVATE, + CT_PRIVATE_COLON, + CT_THROW, + CT_TRY, + CT_USING, + CT_D_WITH, /* D: paren+braced */ + CT_D_MODULE, + CT_SUPER, + CT_DELEGATE, + CT_BODY, + CT_DEBUG, + CT_DEBUGGER, + CT_INVARIANT, + CT_UNITTEST, + CT_UNSAFE, + CT_FINALLY, + CT_IMPORT, + CT_SCOPE, + CT_LAZY, + CT_D_MACRO, + + /* note for paren/brace/square pairs: close MUST be open + 1 */ + CT_PAREN_OPEN, + CT_PAREN_CLOSE, + + CT_ANGLE_OPEN, /* template */ + CT_ANGLE_CLOSE, + + CT_SPAREN_OPEN, /* 'special' paren after if/for/switch/while */ + CT_SPAREN_CLOSE, + + CT_FPAREN_OPEN, /* 'function' paren after fcn/macro fcn */ + CT_FPAREN_CLOSE, + + CT_BRACE_OPEN, + CT_BRACE_CLOSE, + + CT_VBRACE_OPEN, + CT_VBRACE_CLOSE, + + CT_SQUARE_OPEN, + CT_SQUARE_CLOSE, + + CT_TSQUARE, /* special case of [] */ + + CT_MACRO_OPEN, /* stuff specified via custom-pair */ + CT_MACRO_CLOSE, + CT_MACRO_ELSE, + + /* agregate types */ + CT_LABEL, /* a non-case label */ + CT_LABEL_COLON, /* the colon for a label */ + CT_FUNCTION, /* function - unspecified, call mark_function() */ + CT_FUNC_CALL, /* function call */ + CT_FUNC_CALL_USER, /* function call (special user) */ + CT_FUNC_DEF, /* function definition/implementation */ + CT_FUNC_PROTO, /* function prototype */ + CT_FUNC_CLASS, /* ctor or dtor for a class */ + CT_FUNC_CTOR_VAR, /* variable or class initialization */ + CT_FUNC_WRAP, /* macro that wraps the function name */ + CT_MACRO_FUNC, /* function-like macro */ + CT_MACRO, /* a macro def */ + CT_QUALIFIER, /* static, const, etc */ + CT_EXTERN, /* extern */ + CT_ALIGN, /* paren'd qualifier: align(4) struct a { } */ + CT_TYPE, + CT_PTR_TYPE, /* a '*' as part of a type */ + CT_TYPE_WRAP, /* macro that wraps a type name */ + + CT_BIT_COLON, /* a ':' in a variable declaration */ + + CT_OC_DYNAMIC, + CT_OC_END, /* ObjC: @end */ + CT_OC_IMPL, /* ObjC: @implementation */ + CT_OC_INTF, /* ObjC: @interface */ + CT_OC_PROPERTY, /* ObjC: @property */ + CT_OC_CLASS, /* ObjC: the name after @interface or @implementation */ + CT_OC_CLASS_EXT, /* ObjC: a pair of empty parens after the class name in a @interface or @implementation */ + CT_OC_CATEGORY, /* ObjC: the category name in parens after the class name in a @interface or @implementation */ + CT_OC_SCOPE, /* ObjC: the '-' or '+' in '-(void) func: (int) i;' */ + CT_OC_MSG, /* ObjC: parent type to '[class func : param];' stuff */ + CT_OC_MSG_SPEC, /* ObjC: msg spec '-(void) func: (int) i;' */ + CT_OC_MSG_DECL, /* ObjC: msg decl '-(void) func: (int) i { }' */ + CT_OC_RTYPE, /* ObjC: marks closing parens of the return type after scope */ + CT_OC_COLON, /* ObjC: the colon in a msg spec */ + CT_OC_SEL, /* ObjC: @selector */ + CT_OC_SEL_NAME, /* ObjC: selector name */ + + /* start PP types */ + CT_PP_DEFINE, /* #define */ + CT_PP_DEFINED, /* #if defined */ + CT_PP_INCLUDE, /* #include */ + CT_PP_IF, /* #if, #ifdef, or #ifndef */ + CT_PP_ELSE, /* #else or #elif */ + CT_PP_ENDIF, /* #endif */ + CT_PP_ASSERT, + CT_PP_EMIT, + CT_PP_ENDINPUT, + CT_PP_ERROR, + CT_PP_FILE, + CT_PP_LINE, + CT_PP_SECTION, + CT_PP_UNDEF, + + CT_PP_BODYCHUNK, /* everything after this gets put in CT_PREPROC_BODY */ + + CT_PP_PRAGMA, /* pragma's should not be altered */ + CT_PP_REGION, /* C# #region */ + CT_PP_ENDREGION, /* C# #endregion */ + CT_PP_REGION_INDENT, /* Dummy token for indenting a C# #region */ + CT_PP_IF_INDENT, /* Dummy token for indenting a #if stuff */ + CT_PP_OTHER, /* #line, #error, #pragma, etc */ + /* end PP types */ + + /* PAWN stuff */ + CT_CHAR, + CT_DEFINED, + CT_FORWARD, + CT_NATIVE, + CT_STATE, + CT_STOCK, + CT_TAGOF, + CT_DOT, + CT_TAG, + CT_TAG_COLON, + + /* C-sharp crap */ + CT_LOCK, /* lock/unlock */ + CT_AS, + CT_IN, /* "foreach (T c in x)" or "foo(in char c)" or "in { ..." */ + CT_BRACED, /* simple braced items: try {} */ + CT_VERSION, /* turns into CT_IF if not followed by '=' */ + CT_THIS, /* may turn into CT_PBRACED if followed by a '(' */ + CT_BASE, /* C# thingy */ + CT_DEFAULT, /* may be changed into CT_CASE */ + CT_GETSET, /* must be followed by CT_BRACE_OPEN or reverts to CT_WORD */ + CT_GETSET_EMPTY, /* get/set/add/remove followed by a semicolon */ + CT_CONCAT, /* The '~' between strings */ + CT_CS_SQ_STMT, /* '[assembly: xxx]' or '[Attribute()]' or '[Help()]', etc */ + CT_CS_SQ_COLON, /* the colon in one of those [] thingys */ + CT_CS_PROPERTY, /* word or ']' followed by '{' */ + + /* Embedded SQL - always terminated with a semicolon */ + CT_SQL_EXEC, /* the 'EXEC' in 'EXEC SQL ...' */ + CT_SQL_BEGIN, /* the 'EXEC' in 'EXEC SQL BEGIN ...' */ + CT_SQL_END, /* the 'EXEC' in 'EXEC SQL END ...' */ + CT_SQL_WORD, /* CT_WORDs in the 'EXEC SQL' statement */ + + /* Vala stuff */ + CT_CONSTRUCT, /* braced "construct { }" or qualifier "(construct int x)" */ + CT_LAMBDA, +} c_token_t; + +#endif /* TOKEN_ENUM_H_INCLUDED */ diff --git a/src/token_names.h b/src/token_names.h new file mode 100644 index 0000000000..04cf85c496 --- /dev/null +++ b/src/token_names.h @@ -0,0 +1,237 @@ +/* + * Generated by make_token_names.sh on Mon Oct 12 21:57:27 CDT 2009 + */ +#ifndef TOKEN_NAMES_H_INCLUDED +#define TOKEN_NAMES_H_INCLUDED + +const char *token_names[] = +{ + "NONE", + "SOF", + "EOF", + "UNKNOWN", + "JUNK", + "WHITESPACE", + "SPACE", + "NEWLINE", + "NL_CONT", + "COMMENT_CPP", + "COMMENT", + "COMMENT_MULTI", + "COMMENT_EMBED", + "COMMENT_START", + "COMMENT_END", + "COMMENT_WHOLE", + "IGNORED", + "WORD", + "NUMBER", + "NUMBER_FP", + "STRING", + "STRING_MULTI", + "IF", + "ELSE", + "ELSEIF", + "FOR", + "WHILE", + "WHILE_OF_DO", + "SWITCH", + "CASE", + "DO", + "VOLATILE", + "TYPEDEF", + "STRUCT", + "ENUM", + "SIZEOF", + "RETURN", + "BREAK", + "UNION", + "GOTO", + "CONTINUE", + "C_CAST", + "CPP_CAST", + "D_CAST", + "TYPE_CAST", + "TYPENAME", + "TEMPLATE", + "ASSIGN", + "ASSIGN_NL", + "SASSIGN", + "COMPARE", + "SCOMPARE", + "BOOL", + "SBOOL", + "ARITH", + "SARITH", + "DEREF", + "INCDEC_BEFORE", + "INCDEC_AFTER", + "MEMBER", + "DC_MEMBER", + "C99_MEMBER", + "INV", + "DESTRUCTOR", + "NOT", + "D_TEMPLATE", + "ADDR", + "NEG", + "POS", + "STAR", + "PLUS", + "MINUS", + "AMP", + "BYREF", + "POUND", + "PREPROC", + "PREPROC_INDENT", + "PREPROC_BODY", + "PP", + "ELLIPSIS", + "RANGE", + "SEMICOLON", + "VSEMICOLON", + "COLON", + "CASE_COLON", + "CLASS_COLON", + "D_ARRAY_COLON", + "COND_COLON", + "QUESTION", + "COMMA", + "ASM", + "ATTRIBUTE", + "CATCH", + "CLASS", + "DELETE", + "EXPORT", + "FRIEND", + "MUTABLE", + "NAMESPACE", + "NEW", + "OPERATOR", + "PRIVATE", + "PRIVATE_COLON", + "THROW", + "TRY", + "USING", + "D_WITH", + "D_MODULE", + "SUPER", + "DELEGATE", + "BODY", + "DEBUG", + "DEBUGGER", + "INVARIANT", + "UNITTEST", + "UNSAFE", + "FINALLY", + "IMPORT", + "SCOPE", + "LAZY", + "D_MACRO", + "PAREN_OPEN", + "PAREN_CLOSE", + "ANGLE_OPEN", + "ANGLE_CLOSE", + "SPAREN_OPEN", + "SPAREN_CLOSE", + "FPAREN_OPEN", + "FPAREN_CLOSE", + "BRACE_OPEN", + "BRACE_CLOSE", + "VBRACE_OPEN", + "VBRACE_CLOSE", + "SQUARE_OPEN", + "SQUARE_CLOSE", + "TSQUARE", + "MACRO_OPEN", + "MACRO_CLOSE", + "MACRO_ELSE", + "LABEL", + "LABEL_COLON", + "FUNCTION", + "FUNC_CALL", + "FUNC_CALL_USER", + "FUNC_DEF", + "FUNC_PROTO", + "FUNC_CLASS", + "FUNC_CTOR_VAR", + "FUNC_WRAP", + "MACRO_FUNC", + "MACRO", + "QUALIFIER", + "EXTERN", + "ALIGN", + "TYPE", + "PTR_TYPE", + "TYPE_WRAP", + "BIT_COLON", + "OC_DYNAMIC", + "OC_END", + "OC_IMPL", + "OC_INTF", + "OC_PROPERTY", + "OC_CLASS", + "OC_CLASS_EXT", + "OC_CATEGORY", + "OC_SCOPE", + "OC_MSG", + "OC_MSG_SPEC", + "OC_MSG_DECL", + "OC_RTYPE", + "OC_COLON", + "OC_SEL", + "OC_SEL_NAME", + "PP_DEFINE", + "PP_DEFINED", + "PP_INCLUDE", + "PP_IF", + "PP_ELSE", + "PP_ENDIF", + "PP_ASSERT", + "PP_EMIT", + "PP_ENDINPUT", + "PP_ERROR", + "PP_FILE", + "PP_LINE", + "PP_SECTION", + "PP_UNDEF", + "PP_BODYCHUNK", + "PP_PRAGMA", + "PP_REGION", + "PP_ENDREGION", + "PP_REGION_INDENT", + "PP_IF_INDENT", + "PP_OTHER", + "CHAR", + "DEFINED", + "FORWARD", + "NATIVE", + "STATE", + "STOCK", + "TAGOF", + "DOT", + "TAG", + "TAG_COLON", + "LOCK", + "AS", + "IN", + "BRACED", + "VERSION", + "THIS", + "BASE", + "DEFAULT", + "GETSET", + "GETSET_EMPTY", + "CONCAT", + "CS_SQ_STMT", + "CS_SQ_COLON", + "CS_PROPERTY", + "SQL_EXEC", + "SQL_BEGIN", + "SQL_END", + "SQL_WORD", + "CONSTRUCT", + "LAMBDA", +}; + +#endif /* TOKEN_NAMES_H_INCLUDED */ + diff --git a/src/tokenize.cpp b/src/tokenize.cpp new file mode 100644 index 0000000000..e1ace6308f --- /dev/null +++ b/src/tokenize.cpp @@ -0,0 +1,1202 @@ +/** + * @file tokenize.cpp + * This file breaks up the text stream into tokens or chunks. + * + * Each routine needs to set pc->len and pc->type. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "char_table.h" +#include "prototypes.h" +#include "chunk_list.h" +#include +#include +#include +#include +#include "unc_ctype.h" + + +static bool parse_string(chunk_t *pc, int quote_idx, bool allow_escape); + +#include "d.tokenize.cpp" + +/** + * A string-in-string search. Like strstr() with a haystack length. + */ +static const char *str_search(const char *needle, const char *haystack, int haystack_len) +{ + int needle_len = strlen(needle); + + while (haystack_len-- >= needle_len) + { + if (memcmp(needle, haystack, needle_len) == 0) + { + return(haystack); + } + haystack++; + } + return(NULL); +} + + +/** + * Figure of the length of the comment at text. + * The next bit of text starts with a '/', so it might be a comment. + * There are three types of comments: + * - C comments that start with '/ *' and end with '* /' + * - C++ comments that start with // + * - D nestable comments '/+' '+/' + * + * @param pc The structure to update, str is an input. + * @return Whether a comment was parsed + */ +static bool parse_comment(chunk_t *pc) +{ + int len = 2; + bool is_d = (cpd.lang_flags & LANG_D) != 0; + int d_level = 0; + int bs_cnt; + + if ((pc->str[0] != '/') || + ((pc->str[1] != '*') && (pc->str[1] != '/') && + ((pc->str[1] != '+') || !is_d))) + { + return(false); + } + + /* account for opening two chars */ + cpd.column += 2; + + if (pc->str[1] == '/') + { + pc->type = CT_COMMENT_CPP; + while (true) + { + bs_cnt = 0; + while ((pc->str[len] != '\n') && + (pc->str[len] != '\r') && + (pc->str[len] != 0)) + { + if (pc->str[len] == '\\') + { + bs_cnt++; + } + else + { + bs_cnt = 0; + } + len++; + } + + /* If we hit an odd number of backslashes right before the newline, + * then we keep going. + */ + if (((bs_cnt & 1) == 0) || (pc->str[len] == 0)) + { + break; + } + if (pc->str[len] == '\r') + { + len++; + } + if (pc->str[len] == '\n') + { + len++; + } + } + } + else if (pc->str[len] == 0) + { + /* unexpected end of file */ + return(false); + } + else if (pc->str[1] == '+') + { + pc->type = CT_COMMENT; + d_level++; + while ((d_level > 0) && (pc->str[len + 1] != 0)) + { + if ((pc->str[len] == '+') && (pc->str[len + 1] == '/')) + { + len += 2; + cpd.column += 2; + d_level--; + continue; + } + + if ((pc->str[len] == '/') && (pc->str[len + 1] == '+')) + { + len += 2; + cpd.column += 2; + d_level++; + continue; + } + + if ((pc->str[len] == '\n') || (pc->str[len] == '\r')) + { + pc->type = CT_COMMENT_MULTI; + pc->nl_count++; + cpd.column = 0; + cpd.line_number++; + + if (pc->str[len] == '\r') + { + if (pc->str[len + 1] == '\n') + { + cpd.le_counts[LE_CRLF]++; + len++; + } + else + { + cpd.le_counts[LE_CR]++; + } + } + else + { + cpd.le_counts[LE_LF]++; + } + } + len++; + cpd.column++; + } + } + else + { + pc->type = CT_COMMENT; + while (pc->str[len + 1] != 0) + { + if ((pc->str[len] == '*') && (pc->str[len + 1] == '/')) + { + len += 2; + cpd.column += 2; + + /* If there is another C comment right after this one, combine them */ + int tmp_len = len; + while ((pc->str[tmp_len] == ' ') || + (pc->str[tmp_len] == '\t')) + { + tmp_len++; + } + if ((pc->str[tmp_len] != '/') || (pc->str[tmp_len + 1] != '*')) + { + break; + } + pc->len = tmp_len; + } + + if ((pc->str[len] == '\n') || (pc->str[len] == '\r')) + { + pc->type = CT_COMMENT_MULTI; + pc->nl_count++; + cpd.column = 0; + cpd.line_number++; + + if (pc->str[len] == '\r') + { + if (pc->str[len + 1] == '\n') + { + cpd.le_counts[LE_CRLF]++; + len++; + } + else + { + cpd.le_counts[LE_CR]++; + } + } + else + { + cpd.le_counts[LE_LF]++; + } + } + len++; + cpd.column++; + } + } + pc->len = len; + if (cpd.unc_off) + { + if (str_search(UNCRUSTIFY_ON_TEXT, pc->str, pc->len) != NULL) + { + LOG_FMT(LBCTRL, "Found '%s' on line %d\n", UNCRUSTIFY_ON_TEXT, pc->orig_line); + cpd.unc_off = false; + } + } + else + { + if (str_search(UNCRUSTIFY_OFF_TEXT, pc->str, pc->len) != NULL) + { + LOG_FMT(LBCTRL, "Found '%s' on line %d\n", UNCRUSTIFY_OFF_TEXT, pc->orig_line); + cpd.unc_off = true; + } + } + return(true); +} + + +/** + * Count the number of characters in the number. + * The next bit of text starts with a number (0-9 or '.'), so it is a number. + * Count the number of characters in the number. + * + * This should cover all number formats for all languages. + * Note that this is not a strict parser. It will happily parse numbers in + * an invalid format. + * + * For example, only D allows underscores in the numbers, but they are + * allowed in all formats. + * + * @param pc The structure to update, str is an input. + * @return Whether a number was parsed + */ +static bool parse_number(chunk_t *pc) +{ + int len; + int tmp; + bool is_float; + bool did_hex = false; + + /* A number must start with a digit or a dot, followed by a digit */ + if (!unc_isdigit(pc->str[0]) && + ((pc->str[0] != '.') || !unc_isdigit(pc->str[1]))) + { + return(false); + } + len = 1; + + is_float = (pc->str[0] == '.'); + if (is_float && (pc->str[1] == '.')) + { + return(false); + } + + /* Check for Hex, Octal, or Binary + * Note that only D and Pawn support binary, but who cares? + */ + if (pc->str[0] == '0') + { + switch (unc_toupper(pc->str[1])) + { + case 'X': /* hex */ + did_hex = true; + do + { + len++; + } while (unc_isxdigit(pc->str[len]) || (pc->str[len] == '_')); + break; + + case 'B': /* binary */ + do + { + len++; + } while ((pc->str[len] == '0') || (pc->str[len] == '1') || + (pc->str[len] == '_')); + break; + + case '0': /* octal */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + do + { + len++; + } while (((pc->str[len] >= '0') && (pc->str[len] <= '7')) || + (pc->str[len] == '_')); + break; + + default: + /* either just 0 or 0.1 or 0UL, etc */ + break; + } + } + else + { + /* Regular int or float */ + while (unc_isdigit(pc->str[len]) || (pc->str[len] == '_')) + { + len++; + } + } + + /* Check if we stopped on a decimal point & make sure it isn't '..' */ + if ((pc->str[len] == '.') && (pc->str[len + 1] != '.')) + { + len++; + is_float = true; + if (did_hex) + { + while (unc_isxdigit(pc->str[len]) || (pc->str[len] == '_')) + { + len++; + } + } + else + { + while (unc_isdigit(pc->str[len]) || (pc->str[len] == '_')) + { + len++; + } + } + } + + /* Check exponent + * Valid exponents per language (not that it matters): + * C/C++/D/Java: eEpP + * C#/Pawn: eE + */ + tmp = unc_toupper(pc->str[len]); + if ((tmp == 'E') || (tmp == 'P')) + { + is_float = true; + len++; + if ((pc->str[len] == '+') || (pc->str[len] == '-')) + { + len++; + } + while (unc_isdigit(pc->str[len]) || (pc->str[len] == '_')) + { + len++; + } + } + + /* Check the suffixes + * Valid suffixes per language (not that it matters): + * Integer Float + * C/C++: uUlL64 lLfF + * C#: uUlL fFdDMm + * D: uUL ifFL + * Java: lL fFdD + * Pawn: (none) (none) + * + * Note that i, f, d, and m only appear in floats. + */ + while (1) + { + tmp = unc_toupper(pc->str[len]); + if ((tmp == 'I') || (tmp == 'F') || (tmp == 'D') || (tmp == 'M')) + { + is_float = true; + } + else if ((tmp != 'L') && (tmp != 'U')) + { + break; + } + len++; + } + + /* skip the Microsoft-specific '64' suffix */ + if ((pc->str[len] == '6') && (pc->str[len + 1] == '4')) + { + len += 2; + } + + /* It there is anything left, then we are probably dealing with garbage or + * some sick macro junk. Eat it. + */ + while (unc_isalnum(pc->str[len])) + { + len++; + } + + pc->len = len; + pc->type = is_float ? CT_NUMBER_FP : CT_NUMBER; + cpd.column += len; + return(true); +} + + +/** + * Count the number of characters in a quoted string. + * The next bit of text starts with a quote char " or ' or <. + * Count the number of characters until the matching character. + * + * @param pc The structure to update, str is an input. + * @return Whether a string was parsed + */ +static bool parse_string(chunk_t *pc, int quote_idx, bool allow_escape) +{ + bool escaped = 0; + int end_ch; + int len = quote_idx; + char escape_char = cpd.settings[UO_string_escape_char].n; + char escape_char2 = cpd.settings[UO_string_escape_char2].n; + + pc->type = CT_STRING; + + end_ch = CharTable::Get(pc->str[len]) & 0xff; + len++; + + cpd.column += len; + for (/* nada */; pc->str[len] != 0; len++) + { + cpd.column++; + + if ((pc->str[len] == '\n') || + ((pc->str[len] == '\r') && (pc->str[len + 1] != '\n'))) + { + cpd.line_number++; + cpd.column = 1; + pc->nl_count++; + pc->type = CT_STRING_MULTI; + } + if (!escaped) + { + if (pc->str[len] == escape_char) + { + escaped = (escape_char != 0); + } + else if ((pc->str[len] == escape_char2) && + (pc->str[len + 1] == end_ch)) + { + escaped = allow_escape; + } + else if (pc->str[len] == end_ch) + { + len++; + break; + } + } + else + { + escaped = false; + } + } + + /* D can have suffixes */ + if (((cpd.lang_flags & LANG_D) != 0) && + ((pc->str[len] == 'c') || + (pc->str[len] == 'w') || + (pc->str[len] == 'd'))) + { + len++; + cpd.column++; + } + pc->len = len; + return(true); +} + + +/** + * Literal string, ends with single " + * Two "" don't end the string. + * + * @param pc The structure to update, str is an input. + * @return Whether a string was parsed + */ +static bool parse_cs_string(chunk_t *pc) +{ + int len = 2; + + /* go until we hit a zero (end of file) or a single " */ + while (pc->str[len] != 0) + { + if ((pc->str[len] == '"') && (pc->str[len + 1] == '"')) + { + len += 2; + } + else + { + len++; + if (pc->str[len - 1] == '"') + { + break; + } + } + } + + pc->len = len; + pc->type = CT_STRING; + cpd.column += len; + return(true); +} + + +/** + * Count the number of characters in a word. + * The first character is already valid for a keyword + * + * @param pc The structure to update, str is an input. + * @return Whether a word was parsed (always true) + */ +bool parse_word(chunk_t *pc, bool skipcheck) +{ + int len = 1; + const chunk_tag_t *tag; + + while ((pc->str[len] < 127) && CharTable::IsKw2(pc->str[len])) + { + len++; + } + cpd.column += len; + pc->len = len; + pc->type = CT_WORD; + + if (skipcheck) + { + return(true); + } + + /* Detect pre-processor functions now */ + if ((cpd.in_preproc == CT_PP_DEFINE) && + (cpd.preproc_ncnl_count == 1)) + { + if (pc->str[len] == '(') + { + pc->type = CT_MACRO_FUNC; + } + else + { + pc->type = CT_MACRO; + } + } + + /* Turn it into a keyword now */ + tag = find_keyword(pc->str, len); + if (tag != NULL) + { + pc->type = tag->type; + } + return(true); +} + + +/** + * Count the number of whitespace characters. + * + * @param pc The structure to update, str is an input. + * @return Whether whitespace was parsed + */ +static bool parse_whitespace(chunk_t *pc) +{ + int len = 0; + int nl_count = 0; + bool last_was_tab = false; + + while ((pc->str[len] != 0) && + ((pc->str[len] <= ' ') || (pc->str[len] >= 127))) + { + last_was_tab = false; + switch (pc->str[len]) + { + case '\r': + if (pc->str[len + 1] == '\n') + { + /* CRLF ending */ + len++; + cpd.le_counts[LE_CRLF]++; + } + else + { + /* CR ending */ + cpd.le_counts[LE_CR]++; + } + nl_count++; + cpd.column = 1; + cpd.line_number++; + break; + + case '\n': + /* LF ending */ + cpd.le_counts[LE_LF]++; + nl_count++; + cpd.column = 1; + cpd.line_number++; + break; + + case '\t': + cpd.column = calc_next_tab_column(cpd.column, + cpd.settings[UO_input_tab_size].n); + last_was_tab = true; + break; + + case ' ': + cpd.column++; + break; + + default: + break; + } + len++; + } + + if (len > 0) + { + pc->nl_count = nl_count; + pc->type = nl_count ? CT_NEWLINE : CT_WHITESPACE; + pc->len = len; + pc->after_tab = last_was_tab; + } + return(len != 0); +} + + +/** + * Count the number of non-ascii characters at the start of a file. + * + * @param pc The structure to update, str is an input. + * @return Whether a BOM was parsed + */ +static bool parse_bom(chunk_t *pc) +{ + int len = 0; + + while ((pc->str[len] != 0) && + ((pc->str[len] <= 0) || (pc->str[len] >= 127))) + { + len++; + } + + if (len > 0) + { + pc->type = CT_SOF; + pc->len = len; + } + return(len != 0); +} + + +/** + * Called when we hit a backslash. + * If there is nothing but whitespace until the newline, then this is a + * backslash newline + */ +static bool parse_bs_newline(chunk_t *pc) +{ + pc->len = 1; + + while (unc_isspace(pc->str[pc->len])) + { + if ((pc->str[pc->len] == '\r') || (pc->str[pc->len] == '\n')) + { + if (pc->str[pc->len] == '\n') + { + pc->len++; + } + else /* it is '\r' */ + { + pc->len++; + if (pc->str[pc->len] == '\n') + { + pc->len++; + } + } + pc->type = CT_NL_CONT; + pc->nl_count = 1; + return(true); + } + pc->len++; + } + return(false); +} + + +/** + * Parses any number of tab or space chars followed by a newline. + * Does not change pc->len if a newline isn't found. + * This is not the same as parse_whitespace() because it only consumes until + * a single newline is encountered. + */ +static bool parse_newline(chunk_t *pc) +{ + int len = pc->len; + + while ((pc->str[len] == ' ') || (pc->str[len] == '\t')) + { + len++; + } + if ((pc->str[len] == '\r') || (pc->str[len] == '\n')) + { + if (pc->str[len] == '\n') + { + len++; + } + else /* it is '\r' */ + { + len++; + if (pc->str[len] == '\n') + { + len++; + } + } + pc->len = len; + return(true); + } + return(false); +} + + +static bool parse_ignored(chunk_t *pc) +{ + int nl_count = 0; + + /* Parse off newlines */ + while (parse_newline(pc)) + { + nl_count++; + } + if (nl_count > 0) + { + cpd.column = 1; + cpd.line_number += nl_count; + pc->nl_count = nl_count; + pc->type = CT_NEWLINE; + return(true); + } + + /* Look for the ending comment and let it pass */ + if (parse_comment(pc) && !cpd.unc_off) + { + return(true); + } + pc->len = 0; + + /* Reset the chunk & scan to until a newline */ + while ((pc->str[pc->len] != 0) && + (pc->str[pc->len] != '\r') && + (pc->str[pc->len] != '\n')) + { + pc->len++; + } + if (pc->len > 0) + { + pc->type = CT_IGNORED; + return(true); + } + return(false); +} + + +/** + * Skips the next bit of whatever and returns the type of block. + * + * pc->str is the input text. + * pc->len in the output length. + * pc->type is the output type + * pc->column is output column + * + * @param pc The structure to update, str is an input. + * @return true/false - whether anything was parsed + */ +static bool parse_next(chunk_t *pc) +{ + const chunk_tag_t *punc; + + if ((pc == NULL) || (pc->str == NULL) || (*pc->str == 0)) + { + //fprintf(stderr, "All done!\n"); + return(false); + } + + /* Save off the current column */ + pc->orig_line = cpd.line_number; + pc->column = cpd.column; + pc->orig_col = cpd.column; + pc->len = 0; + pc->type = CT_NONE; + pc->nl_count = 0; + pc->flags = 0; + + /* If it is turned off, we put everything except newlines into CT_UNKNOWN */ + if (cpd.unc_off) + { + if (parse_ignored(pc)) + { + return(true); + } + } + + if (chunk_get_head() == NULL) + { + if (parse_bom(pc)) + { + return(true); + } + } + + /** + * Parse whitespace + */ + if (parse_whitespace(pc)) + { + return(true); + } + + /** + * Handle unknown/unhandled preprocessors + */ + if ((cpd.in_preproc > CT_PP_BODYCHUNK) && + (cpd.in_preproc <= CT_PP_OTHER)) + { + /* Chunk to a newline or comment */ + pc->type = CT_PREPROC_BODY; + char last = 0; + while (pc->str[pc->len] != 0) + { + char ch = pc->str[pc->len]; + + if ((ch == '\n') || (ch == '\r')) + { + /* Back off if this is an escaped newline */ + if (last == '\\') + { + pc->len--; + } + break; + } + + /* Quit on a C++ comment start */ + if ((ch == '/') && (pc->str[pc->len + 1] == '/')) + { + break; + } + last = ch; + pc->len++; + } + if (pc->len > 0) + { + return(true); + } + } + + /** + * Detect backslash-newline + * + * REVISIT: does this need to handle other line endings? + */ + if ((pc->str[0] == '\\') && parse_bs_newline(pc)) + { + cpd.column = 1; + cpd.line_number++; + return(true); + } + + /** + * Parse comments + */ + if (parse_comment(pc)) + { + return(true); + } + + /* Check for C# literal strings, ie @"hello" */ + if (((cpd.lang_flags & LANG_CS) != 0) && (*pc->str == '@')) + { + if (pc->str[1] == '"') + { + parse_cs_string(pc); + return(true); + } + if (CharTable::IsKw1(pc->str[1]) && parse_word(pc, true)) + { + return(true); + } + } + + /* Check for Obj-C NSString constants, ie @"hello" */ + if (((cpd.lang_flags & LANG_OC) != 0) && (*pc->str == '@')) + { + if (pc->str[1] == '"') + { + parse_string(pc, 1, true); + return(true); + } + } + + /* PAWN specific stuff */ + if ((cpd.lang_flags & LANG_PAWN) != 0) + { + /* Check for PAWN strings: \"hi" or !"hi" or !\"hi" or \!"hi" */ + if ((pc->str[0] == '\\') || (pc->str[0] == '!')) + { + if (pc->str[1] == '"') + { + parse_string(pc, 1, (*pc->str == '!')); + return(true); + } + else if (((pc->str[1] == '\\') || (pc->str[1] == '!')) && + (pc->str[2] == '"')) + { + parse_string(pc, 2, false); + return(true); + } + } + } + + /** + * Parse strings and character constants + */ + + if (parse_number(pc)) + { + return(true); + } + + if ((cpd.lang_flags & LANG_D) != 0) + { + /* D specific stuff */ + if (d_parse_string(pc)) + { + return(true); + } + } + else + { + /* Not D stuff */ + + /* Check for L'a', L"abc", 'a', "abc", strings */ + if ((((*pc->str == 'L') || (*pc->str == 'S')) && + ((pc->str[1] == '"') || (pc->str[1] == '\''))) || + (*pc->str == '"') || + (*pc->str == '\'') || + ((*pc->str == '<') && (cpd.in_preproc == CT_PP_INCLUDE))) + { + parse_string(pc, unc_isalpha(*pc->str) ? 1 : 0, true); + return(true); + } + + if ((*pc->str == '<') && (cpd.in_preproc == CT_PP_DEFINE)) + { + if (chunk_get_tail()->type == CT_MACRO) + { + /* We have "#define XXX <", assume '<' starts an include string */ + parse_string(pc, 0, false); + return(true); + } + } + } + + /* Check for pawn/ObjectiveC identifiers */ + if ((*pc->str == '@') && + CharTable::IsKw2(pc->str[1]) && + parse_word(pc, false)) + { + return(true); + } + + if (CharTable::IsKw1(*pc->str) && parse_word(pc, false)) + { + return(true); + } + + if ((punc = find_punctuator(pc->str, cpd.lang_flags)) != NULL) + { + pc->type = punc->type; + pc->len = strlen(punc->tag); + cpd.column += pc->len; + pc->flags |= PCF_PUNCTUATOR; + return(true); + } + + + /* throw away this character */ + pc->type = CT_UNKNOWN; + pc->len = 1; + + LOG_FMT(LWARN, "%s:%d Garbage in col %d: %x\n", + cpd.filename, pc->orig_line, cpd.column, *pc->str); + cpd.error_count++; + return(true); +} + + +/** + * This function parses or tokenizes the whole buffer into a list. + * It has to do some tricks to parse preprocessors. + * + * If output_text() were called immediately after, two things would happen: + * - trailing whitespace are removed. + * - leading space & tabs are converted to the appropriate format. + * + * All the tokens are inserted before ref. If ref is NULL, they are inserted + * at the end of the list. Line numbers are relative to the start of the data. + */ +void tokenize(const char *data, int data_len, chunk_t *ref) +{ + int idx = 0; + chunk_t chunk; + chunk_t *pc = NULL; + chunk_t *rprev = NULL; + chunk_t *prev = NULL; + struct parse_frame frm; + bool last_was_tab = false; + + memset(&frm, 0, sizeof(frm)); + memset(&chunk, 0, sizeof(chunk)); + + cpd.line_number = 1; + cpd.column = 1; + + while (idx < data_len) + { + chunk.str = &data[idx]; + if (!parse_next(&chunk)) + { + LOG_FMT(LERR, "%s:%d Bailed before the end?\n", + cpd.filename, cpd.line_number); + cpd.error_count++; + break; + } + + /* Bump up the index */ + idx += chunk.len; + + /* Don't create an entry for whitespace */ + if (chunk.type == CT_WHITESPACE) + { + last_was_tab = chunk.after_tab; + continue; + } + + if (chunk.type == CT_SOF) + { + cpd.bom = chunk_dup(&chunk); + continue; + } + + if (chunk.type == CT_NEWLINE) + { + last_was_tab = chunk.after_tab; + chunk.after_tab = false; + chunk.len = 0; + } + else if (chunk.type == CT_NL_CONT) + { + last_was_tab = chunk.after_tab; + chunk.after_tab = false; + chunk.len = 2; + chunk.str = "\\\n"; + } + else + { + chunk.after_tab = last_was_tab; + last_was_tab = false; + } + + /* Strip trailing whitespace (for CPP comments and PP blocks) */ + while ((chunk.len > 0) && + ((chunk.str[chunk.len - 1] == ' ') || + (chunk.str[chunk.len - 1] == '\t'))) + { + chunk.len--; + } + + /* Store off the end column */ + chunk.orig_col_end = cpd.column; + + /* Add the chunk to the list */ + rprev = pc; + if (!chunk_is_newline(pc) && !chunk_is_comment(pc)) + { + prev = pc; + } + if (rprev != NULL) + { + pc->flags |= rprev->flags & PCF_COPY_FLAGS; + + /* a newline can't be in a preprocessor */ + if (pc->type == CT_NEWLINE) + { + pc->flags &= ~PCF_IN_PREPROC; + } + } + if (ref != NULL) + { + chunk.flags |= PCF_INSERTED; + } + else + { + chunk.flags &= ~PCF_INSERTED; + } + pc = chunk_add_before(&chunk, ref); + + /* A newline marks the end of a preprocessor */ + if (pc->type == CT_NEWLINE) // || (pc->type == CT_COMMENT_MULTI)) + { + cpd.in_preproc = CT_NONE; + cpd.preproc_ncnl_count = 0; + } + + /* Special handling for preprocessor stuff */ + if (cpd.in_preproc != CT_NONE) + { + pc->flags |= PCF_IN_PREPROC; + + /* Count words after the preprocessor */ + if (!chunk_is_comment(pc) && !chunk_is_newline(pc)) + { + cpd.preproc_ncnl_count++; + } + + /* Figure out the type of preprocessor for #include parsing */ + if (cpd.in_preproc == CT_PREPROC) + { + if ((pc->type < CT_PP_DEFINE) || (pc->type > CT_PP_OTHER)) + { + pc->type = CT_PP_OTHER; + } + cpd.in_preproc = pc->type; + } + } + else + { + /* Check for a preprocessor start */ + if ((pc->type == CT_POUND) && + ((rprev == NULL) || (rprev->type == CT_NEWLINE))) + { + pc->type = CT_PREPROC; + pc->flags |= PCF_IN_PREPROC; + cpd.in_preproc = CT_PREPROC; + } + } + } + + /* Set the cpd.newline string for this file */ + if ((cpd.settings[UO_newlines].le == LE_LF) || + ((cpd.settings[UO_newlines].le == LE_AUTO) && + (cpd.le_counts[LE_LF] >= cpd.le_counts[LE_CRLF]) && + (cpd.le_counts[LE_LF] >= cpd.le_counts[LE_CR]))) + { + /* LF line ends */ + strcpy(cpd.newline, "\n"); + LOG_FMT(LLINEENDS, "Using LF line endings\n"); + } + else if ((cpd.settings[UO_newlines].le == LE_CRLF) || + ((cpd.settings[UO_newlines].le == LE_AUTO) && + (cpd.le_counts[LE_CRLF] >= cpd.le_counts[LE_LF]) && + (cpd.le_counts[LE_CRLF] >= cpd.le_counts[LE_CR]))) + { + /* CRLF line ends */ + strcpy(cpd.newline, "\r\n"); + LOG_FMT(LLINEENDS, "Using CRLF line endings\n"); + } + else + { + /* CR line ends */ + strcpy(cpd.newline, "\r"); + LOG_FMT(LLINEENDS, "Using CR line endings\n"); + } +} + + +/** + * A simplistic fixed-sized needle in the fixed-size haystack string search. + */ +int str_find(const char *needle, int needle_len, + const char *haystack, int haystack_len) +{ + int idx; + + for (idx = 0; idx < (haystack_len - needle_len); idx++) + { + if (memcmp(needle, haystack + idx, needle_len) == 0) + { + return(idx); + } + } + return(-1); +} diff --git a/src/tokenize_cleanup.cpp b/src/tokenize_cleanup.cpp new file mode 100644 index 0000000000..3c3b4d1761 --- /dev/null +++ b/src/tokenize_cleanup.cpp @@ -0,0 +1,744 @@ +/** + * @file tokenize_cleanup.cpp + * Looks at simple sequences to refine the chunk types. + * Examples: + * - change '[' + ']' into '[]'/ + * - detect "version = 10;" vs "version (xxx) {" + * + * @author Ben Gardner + * @license GPL v2+ + */ +#include "uncrustify_types.h" +#include "prototypes.h" +#include "chunk_list.h" +#include "char_table.h" +#include "unc_ctype.h" +#include + +static void check_template(chunk_t *start); + + +void tokenize_cleanup(void) +{ + chunk_t *pc = chunk_get_head(); + chunk_t *prev = NULL; + chunk_t *next; + chunk_t *tmp; + chunk_t *tmp2; + bool in_type_cast = false; + + pc = chunk_get_head(); + next = chunk_get_next_ncnl(pc); + while ((pc != NULL) && (next != NULL)) + { + /* Change '[' + ']' into '[]' */ + if ((pc->type == CT_SQUARE_OPEN) && (next->type == CT_SQUARE_CLOSE)) + { + pc->type = CT_TSQUARE; + pc->str = "[]"; + pc->len = 2; + chunk_del(next); + pc->orig_col_end += 1; + next = chunk_get_next_ncnl(pc); + } + + if ((pc->type == CT_DOT) && ((cpd.lang_flags & LANG_ALLC) != 0)) + { + pc->type = CT_MEMBER; + } + + /* Determine the version stuff (D only) */ + if (pc->type == CT_VERSION) + { + if (next->type == CT_PAREN_OPEN) + { + pc->type = CT_IF; + } + else + { + if (next->type != CT_ASSIGN) + { + LOG_FMT(LERR, "%s:%d %s: version: Unexpected token %s\n", + cpd.filename, pc->orig_line, __func__, get_token_name(next->type)); + cpd.error_count++; + } + pc->type = CT_WORD; + } + } + + /** + * Change CT_BASE before CT_PAREN_OPEN to CT_WORD. + * public myclass() : base() { + * } + */ + if ((pc->type == CT_BASE) && (next->type == CT_PAREN_OPEN)) + { + pc->type = CT_WORD; + } + + /** + * Change CT_WORD after CT_ENUM, CT_UNION, or CT_STRUCT to CT_TYPE + * Change CT_WORD before CT_WORD to CT_TYPE + */ + if (next->type == CT_WORD) + { + if ((pc->type == CT_ENUM) || + (pc->type == CT_UNION) || + (pc->type == CT_STRUCT)) + { + next->type = CT_TYPE; + } + if (pc->type == CT_WORD) + { + pc->type = CT_TYPE; + } + } + + /* change extern to qualifier if extern isn't followed by a string or + * an open paren + */ + if (pc->type == CT_EXTERN) + { + if (next->type == CT_STRING) + { + /* Probably 'extern "C"' */ + } + else if (next->type == CT_PAREN_OPEN) + { + /* Probably 'extern (C)' */ + } + else + { + /* Something else followed by a open brace */ + tmp = chunk_get_next_ncnl(next); + if ((tmp != NULL) || (tmp->type != CT_BRACE_OPEN)) + { + pc->type = CT_QUALIFIER; + } + } + } + + /** + * Change CT_STAR to CT_PTR_TYPE if preceeded by CT_TYPE, + * CT_QUALIFIER, or CT_PTR_TYPE. + */ + if ((next->type == CT_STAR) && + ((pc->type == CT_TYPE) || + (pc->type == CT_QUALIFIER) || + (pc->type == CT_PTR_TYPE))) + { + next->type = CT_PTR_TYPE; + } + + if ((pc->type == CT_TYPE_CAST) && + (next->type == CT_ANGLE_OPEN)) + { + next->parent_type = CT_TYPE_CAST; + in_type_cast = true; + } + + /** + * Change angle open/close to CT_COMPARE, if not a template thingy + */ + if ((pc->type == CT_ANGLE_OPEN) && (pc->parent_type != CT_TYPE_CAST)) + { + if (pc->flags & PCF_IN_PREPROC) + { + pc->type = CT_COMPARE; + } + else + { + check_template(pc); + } + } + if ((pc->type == CT_ANGLE_CLOSE) && (pc->parent_type != CT_TEMPLATE)) + { + if (in_type_cast) + { + in_type_cast = false; + pc->parent_type = CT_TYPE_CAST; + } + else + { + pc->type = CT_COMPARE; + } + } + + if ((cpd.lang_flags & LANG_D) != 0) + { + /* Check for the D string concat symbol '~' */ + if ((pc->type == CT_INV) && + ((prev->type == CT_STRING) || + (prev->type == CT_WORD) || + (next->type == CT_STRING))) + { + pc->type = CT_CONCAT; + } + + /* Check for the D template symbol '!' */ + if ((pc->type == CT_NOT) && + (prev->type == CT_WORD) && + (next->type == CT_PAREN_OPEN)) + { + pc->type = CT_D_TEMPLATE; + } + } + + if ((cpd.lang_flags & LANG_CPP) != 0) + { + /* Change Word before '::' into a type */ + if ((pc->type == CT_WORD) && (next->type == CT_DC_MEMBER)) + { + pc->type = CT_TYPE; + } + } + + /* Change get/set to CT_WORD if not followed by a brace open */ + if ((pc->type == CT_GETSET) && (next->type != CT_BRACE_OPEN)) + { + if ((next->type == CT_SEMICOLON) && + ((prev->type == CT_BRACE_CLOSE) || + (prev->type == CT_BRACE_OPEN) || + (prev->type == CT_SEMICOLON))) + { + pc->type = CT_GETSET_EMPTY; + next->parent_type = CT_GETSET; + } + else + { + pc->type = CT_WORD; + } + } + + /* Change item after operator (>=, ==, etc) to a CT_FUNCTION */ + if (pc->type == CT_OPERATOR) + { + LOG_FMT(LOPERATOR, "%s: %d:%d operator", __func__, pc->orig_line, pc->orig_col); + + /* Handle special case of () operator -- [] already handled */ + if (next->type == CT_PAREN_OPEN) + { + tmp = chunk_get_next(next); + if ((tmp != NULL) && (tmp->type == CT_PAREN_CLOSE)) + { + next->str = "()"; + next->len = 2; + next->type = CT_FUNCTION; + next->parent_type = CT_OPERATOR; + chunk_del(tmp); + next->orig_col_end += 1; + LOG_FMT(LOPERATOR, " ()"); + } + } + else + { + /* Scan until we hit a '(' or ';' */ + tmp = next; + while ((tmp != NULL) && + (tmp->type != CT_PAREN_OPEN) && + (tmp->type != CT_SEMICOLON)) + { + LOG_FMT(LOPERATOR, " %.*s", tmp->len, tmp->str); + tmp = chunk_get_next_ncnl(tmp); + } + + if ((tmp != NULL) && (tmp->type == CT_PAREN_OPEN)) + { + /* Mark chunks between 'operator' and '('. + * If 'next' is a WORD, then the last 'type' present + * is the function name. Otherwise, the item after the + * 'operator' is the function name. + */ + tmp2 = next; + if ((next->flags & PCF_PUNCTUATOR) == 0) + { + tmp = chunk_get_next_ncnl(next); + while ((tmp != NULL) && (tmp->type != CT_PAREN_OPEN)) + { + tmp->parent_type = CT_OPERATOR; + make_type(tmp); + if (tmp->type == CT_TYPE) + { + tmp2 = tmp; + } + tmp = chunk_get_next_ncnl(tmp); + } + if (tmp2->type != CT_TYPE) + { + tmp2 = next; + } + } + + LOG_FMT(LOPERATOR, " [%.*s]", tmp2->len, tmp2->str); + + tmp2->type = CT_FUNCTION; + tmp2->parent_type = CT_OPERATOR; + } + LOG_FMT(LOPERATOR, "\n"); + } + if (chunk_is_addr(prev)) + { + prev->type = CT_BYREF; + } + } + + /* Change private, public, protected into either a qualifier or label */ + if (pc->type == CT_PRIVATE) + { + /* Handle Qt slots - maybe should just check for a CT_WORD? */ + if (chunk_is_str(next, "slots", 5)) + { + tmp = chunk_get_next(next); + if ((tmp != NULL) && (tmp->type == CT_COLON)) + { + next = tmp; + } + } + if (next->type == CT_COLON) + { + next->type = CT_PRIVATE_COLON; + if ((tmp = chunk_get_next_ncnl(next)) != NULL) + { + tmp->flags |= PCF_STMT_START | PCF_EXPR_START; + } + } + else + { + pc->type = chunk_is_str(pc, "signals", 7) ? CT_WORD : CT_QUALIFIER; + } + } + + /* Look for 'EXEC' 'SQL' */ + if (chunk_is_str(pc, "EXEC", 4) && chunk_is_str(next, "SQL", 3)) + { + tmp = chunk_get_prev(pc); + if (chunk_is_newline(tmp)) + { + tmp = chunk_get_next(next); + if (chunk_is_str_case(tmp, "BEGIN", 5)) + { + pc->type = CT_SQL_BEGIN; + } + else if (chunk_is_str_case(tmp, "END", 3)) + { + pc->type = CT_SQL_END; + } + else + { + pc->type = CT_SQL_EXEC; + } + + /* Change words into CT_SQL_WORD until CT_SEMICOLON */ + while (tmp != NULL) + { + if (tmp->type == CT_SEMICOLON) + { + break; + } + if ((tmp->len > 0) && isalpha(*tmp->str)) + { + tmp->type = CT_SQL_WORD; + } + tmp = chunk_get_next_ncnl(tmp); + } + } + } + + /* Detect Objective C class name */ + if ((pc->type == CT_OC_IMPL) || (pc->type == CT_OC_INTF)) + { + next->type = CT_OC_CLASS; + next->parent_type = pc->type; + + tmp = chunk_get_next_ncnl(next); + if (tmp != NULL) + { + tmp->flags |= PCF_STMT_START | PCF_EXPR_START; + } + + tmp = chunk_get_next_type(pc, CT_OC_END, pc->level); + if (tmp != NULL) + { + tmp->parent_type = pc->type; + } + } + + /* Detect Objective-C categories */ + /* @interface ClassName (CategoryName) */ + /* @implementation ClassName (CategoryName) */ + if (((pc->type == CT_OC_IMPL) || (pc->type == CT_OC_INTF)) && + (next->type == CT_PAREN_OPEN)) + { + next->parent_type = pc->type; + + tmp = chunk_get_next_ncnl(next); + if (tmp != NULL) + { + if (tmp->next->type == CT_PAREN_CLOSE) + { + tmp->type = CT_OC_CLASS_EXT; + tmp->parent_type = pc->type; + } + else + { + tmp->type = CT_OC_CATEGORY; + tmp->flags |= PCF_STMT_START | PCF_EXPR_START; + } + } + + tmp = chunk_get_next_type(pc, CT_PAREN_CLOSE, pc->level); + if (tmp != NULL) + { + tmp->parent_type = pc->type; + } + } + + + /* Detect Objective-C class extensions */ + /* @interface ClassName () */ + /* @implementation ClassName () */ + + + /** + * Objective C @dynamic and @synthesize + * @dynamic xxx, yyy; + * @synthesize xxx, yyy; + * Just find the semicolon and mark it. + */ + if (pc->type == CT_OC_DYNAMIC) + { + tmp = chunk_get_next_type(pc, CT_SEMICOLON, pc->level); + if (tmp != NULL) + { + tmp->parent_type = pc->type; + } + } + + /* Detect Objective C @property + * @property NSString *stringProperty; + * @property(nonatomic, retain) NSMutableDictionary *shareWith; + */ + if (pc->type == CT_OC_PROPERTY) + { + if (next->type != CT_PAREN_OPEN) + { + next->flags |= PCF_STMT_START | PCF_EXPR_START; + } + else + { + next->parent_type = pc->type; + + tmp = chunk_get_next_type(pc, CT_PAREN_CLOSE, pc->level); + if (tmp != NULL) + { + tmp->parent_type = pc->type; + tmp = chunk_get_next_ncnl(tmp); + if (tmp != NULL) + { + tmp->flags |= PCF_STMT_START | PCF_EXPR_START; + + tmp = chunk_get_next_type(tmp, CT_SEMICOLON, pc->level); + if (tmp != NULL) + { + tmp->parent_type = pc->type; + } + } + } + } + } + + /* Detect Objective C @selector + * @selector(msgNameWithNoArg) + * @selector(msgNameWith1Arg:) + * @selector(msgNameWith2Args:arg2Name:) + */ + if ((pc->type == CT_OC_SEL) && (next->type == CT_PAREN_OPEN)) + { + next->parent_type = pc->type; + + tmp = chunk_get_next(next); + if (tmp != NULL) + { + tmp->type = CT_OC_SEL_NAME; + tmp->parent_type = pc->type; + + while ((tmp = chunk_get_next_ncnl(tmp)) != NULL) + { + if (tmp->type == CT_PAREN_CLOSE) + { + tmp->parent_type = CT_OC_SEL; + break; + } + tmp->type = CT_OC_SEL_NAME; + tmp->parent_type = pc->type; + } + } + } + + /* Handle special preprocessor junk */ + if (pc->type == CT_PREPROC) + { + pc->parent_type = next->type; + } + + /* Detect "pragma region" and "pragma endregion" */ + if ((pc->type == CT_PP_PRAGMA) && (next->type == CT_PREPROC_BODY)) + { + if ((memcmp(next->str, "region", 6) == 0) || + (memcmp(next->str, "endregion", 9) == 0)) + { + pc->type = (*next->str == 'r') ? CT_PP_REGION : CT_PP_ENDREGION; + + prev->parent_type = pc->type; + } + } + + /* Check for C# nullable types '?' is in next */ + if ((cpd.lang_flags & LANG_CS) && + (next->type == CT_QUESTION) && + (next->orig_col == (pc->orig_col + pc->len))) + { + tmp = chunk_get_next_ncnl(next); + if (tmp != NULL) + { + bool doit = ((tmp->type == CT_PAREN_CLOSE) || + (tmp->type == CT_ANGLE_CLOSE)); + + if (tmp->type == CT_WORD) + { + tmp2 = chunk_get_next_ncnl(tmp); + if ((tmp2 != NULL) && + ((tmp2->type == CT_SEMICOLON) || + (tmp2->type == CT_ASSIGN) || + (tmp2->type == CT_COMMA))) + { + doit = true; + } + } + + if (doit) + { + pc->len++; + chunk_del(next); + next = tmp; + } + } + } + + /* Convert '>' + '>' into '>>' */ + if ((cpd.lang_flags & LANG_CS) && + (pc->type == CT_ANGLE_CLOSE) && + (next->type == CT_ANGLE_CLOSE) && + (pc->parent_type == CT_NONE) && + ((pc->orig_col + pc->len) == next->orig_col) && + (next->parent_type == CT_NONE)) + { + pc->len++; + pc->type = CT_ARITH; + tmp = chunk_get_next_ncnl(next); + chunk_del(next); + next = tmp; + } + + /* Change 'default(' into a sizeof-like statement */ + if ((cpd.lang_flags & LANG_CS) && + (pc->type == CT_DEFAULT) && + (next->type == CT_PAREN_OPEN)) + { + pc->type = CT_SIZEOF; + } + + if ((pc->type == CT_UNSAFE) && (next->type != CT_BRACE_OPEN)) + { + pc->type = CT_QUALIFIER; + } + + /* TODO: determine other stuff here */ + + prev = pc; + pc = next; + next = chunk_get_next_ncnl(pc); + } +} + + +/** + * If there is nothing but CT_WORD and CT_MEMBER, then it's probably a + * template thingy. Otherwise, it's likely a comparison. + */ +static void check_template(chunk_t *start) +{ + chunk_t *pc; + chunk_t *end; + chunk_t *prev; + chunk_t *next; + bool in_if = false; + + LOG_FMT(LTEMPL, "%s: Line %d, col %d:", __func__, start->orig_line, start->orig_col); + + prev = chunk_get_prev_ncnl(start); + if (prev == NULL) + { + return; + } + + if (prev->type == CT_TEMPLATE) + { + LOG_FMT(LTEMPL, " CT_TEMPLATE:"); + + /* We have: "template< ... >", which is a template declaration */ + int level = 1; + for (pc = chunk_get_next_ncnl(start); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + LOG_FMT(LTEMPL, " [%s,%d]", get_token_name(pc->type), level); + + if (chunk_is_str(pc, "<", 1)) + { + level++; + } + else if (chunk_is_str(pc, ">", 1)) + { + level--; + if (level == 0) + { + break; + } + } + } + end = pc; + } + else + { + /* We may have something like "a< ... >", which is a template use + * '...' may consist of anything except braces {}, a semicolon, and + * unbalanced parens. + * if we are inside an 'if' statement and hit a CT_BOOL, then it isn't a + * template. + */ + + /* A template requires a word/type right before the open angle */ + if ((prev->type != CT_WORD) && (prev->type != CT_TYPE) && (prev->parent_type != CT_OPERATOR)) + { + LOG_FMT(LTEMPL, " - after %s + ( - Not a template\n", get_token_name(prev->type)); + start->type = CT_COMPARE; + return; + } + + LOG_FMT(LTEMPL, " - prev %s -", get_token_name(prev->type)); + + /* Scan back and make sure we aren't inside square parens */ + pc = start; + while ((pc = chunk_get_prev_ncnl(pc)) != NULL) + { + if ((pc->type == CT_SEMICOLON) || + (pc->type == CT_BRACE_OPEN) || + (pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_SQUARE_CLOSE) || + (pc->type == CT_SEMICOLON)) + { + break; + } + if (pc->type == CT_IF) + { + in_if = true; + break; + } + if (pc->type == CT_SQUARE_OPEN) + { + LOG_FMT(LTEMPL, " - Not a template: after a square open\n"); + start->type = CT_COMPARE; + return; + } + } + + /* Scan forward to the angle close + * If we have a comparison in there, then it can't be a template. + */ + c_token_t tokens[16]; + int num_tokens = 1; + + tokens[0] = CT_ANGLE_OPEN; + for (pc = chunk_get_next_ncnl(start); pc != NULL; pc = chunk_get_next_ncnl(pc)) + { + LOG_FMT(LTEMPL, " [%s,%d]", get_token_name(pc->type), num_tokens); + + if (chunk_is_str(pc, "<", 1)) + { + tokens[num_tokens++] = CT_ANGLE_OPEN; + } + else if (chunk_is_str(pc, ">", 1)) + { + if (--num_tokens <= 0) + { + break; + } + if (tokens[num_tokens] != CT_ANGLE_OPEN) + { + /* unbalanced parens */ + break; + } + } + else if (in_if && + ((pc->type == CT_BOOL) || + (pc->type == CT_COMPARE))) + { + break; + } + else if ((pc->type == CT_BRACE_OPEN) || + (pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_SEMICOLON)) + { + break; + } + else if (pc->type == CT_PAREN_OPEN) + { + if (num_tokens >= (int)(ARRAY_SIZE(tokens) - 1)) + { + break; + } + tokens[num_tokens++] = pc->type; + } + else if (pc->type == CT_PAREN_CLOSE) + { + num_tokens--; + if (tokens[num_tokens] != (pc->type - 1)) + { + /* unbalanced parens */ + break; + } + } + } + end = pc; + } + + if ((end != NULL) && (end->type == CT_ANGLE_CLOSE)) + { + pc = chunk_get_next_ncnl(end); + if ((pc != NULL) && + (pc->type != CT_NUMBER)) + { + LOG_FMT(LTEMPL, " - Template Detected\n"); + + start->parent_type = CT_TEMPLATE; + + pc = start; + while (pc != end) + { + next = chunk_get_next_ncnl(pc); + pc->flags |= PCF_IN_TEMPLATE; + if (next->type != CT_PAREN_OPEN) + { + make_type(pc); + } + pc = next; + } + end->parent_type = CT_TEMPLATE; + end->flags |= PCF_IN_TEMPLATE; + return; + } + } + + LOG_FMT(LTEMPL, " - Not a template: end = %s\n", + (end != NULL) ? get_token_name(end->type) : ""); + start->type = CT_COMPARE; +} diff --git a/src/unc_ctype.h b/src/unc_ctype.h new file mode 100644 index 0000000000..f4c039dd2b --- /dev/null +++ b/src/unc_ctype.h @@ -0,0 +1,79 @@ +/** + * @file unc_ctype.h + * The ctype function are only required to handle values 0-255 and EOF. + * A char is sign-extended when cast to an int. + * With some C libraries, these values cause a crash. + * These wrappers will properly handle all char values. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef UNC_CTYPE_H_INCLUDED +#define UNC_CTYPE_H_INCLUDED + +#include + +/** + * Truncate anything except EOF (-1) to 0-255 + */ +static inline int unc_fix_ctype(int ch) +{ + return((ch == -1) ? -1 : (ch & 0xff)); +} + + +static inline int unc_isspace(int ch) +{ + return(isspace(unc_fix_ctype(ch))); +} + + +static inline int unc_isprint(int ch) +{ + return(isprint(unc_fix_ctype(ch))); +} + + +static inline int unc_isalpha(int ch) +{ + return(isalpha(unc_fix_ctype(ch))); +} + + +static inline int unc_isalnum(int ch) +{ + return(isalnum(unc_fix_ctype(ch))); +} + + +static inline int unc_toupper(int ch) +{ + return(toupper(unc_fix_ctype(ch))); +} + + +static inline int unc_tolower(int ch) +{ + return(tolower(unc_fix_ctype(ch))); +} + + +static inline int unc_isxdigit(int ch) +{ + return(isxdigit(unc_fix_ctype(ch))); +} + + +static inline int unc_isdigit(int ch) +{ + return(isdigit(unc_fix_ctype(ch))); +} + + +static inline int unc_isupper(int ch) +{ + return(isalpha(unc_fix_ctype(ch)) && (unc_toupper(unc_fix_ctype(ch)) == ch)); +} + + +#endif /* UNC_CTYPE_H_INCLUDED */ diff --git a/src/uncrustify.cpp b/src/uncrustify.cpp new file mode 100644 index 0000000000..536ca865c8 --- /dev/null +++ b/src/uncrustify.cpp @@ -0,0 +1,1686 @@ +/** + * @file uncrustify.cpp + * This file takes an input C/C++/D/Java file and reformats it. + * + * @author Ben Gardner + * @license GPL v2+ + */ +#define DEFINE_PCF_NAMES +#define DEFINE_CHAR_TABLE + +#include "uncrustify_version.h" +#include "uncrustify_types.h" +#include "char_table.h" +#include "chunk_list.h" +#include "prototypes.h" +#include "token_names.h" +#include "args.h" +#include "logger.h" +#include "log_levels.h" +#include "md5.h" +#include "backup.h" + +#include +#include +#include +#include +#include +#include "unc_ctype.h" +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_STRINGS_H +#include /* strcasecmp() */ +#endif + +/* Global data */ +struct cp_data cpd; + + +static int language_from_tag(const char *tag); +static int language_from_filename(const char *filename); +static const char *language_to_string(int lang); +static char *read_stdin(int& out_len); +static void uncrustify_start(const char *data, int data_len); +static void uncrustify_end(); +static void uncrustify_file(const char *data, int data_len, FILE *pfout, + const char *parsed_file); +static void do_source_file(const char *filename_in, + const char *filename_out, + const char *parsed_file, + bool no_backup, bool keep_mtime); +static void process_source_list(const char *source_list, const char *prefix, + const char *suffix, bool no_backup, bool keep_mtime); +static int load_header_files(); + +static const char *make_output_filename(char *buf, int buf_size, + const char *filename, + const char *prefix, + const char *suffix); + +static int load_mem_file(const char *filename, file_mem& fm); + + +/** + * Replace the brain-dead and non-portable basename(). + * Returns a pointer to the character after the last '/'. + * The returned value always points into path, unless path is NULL. + * + * Input Returns + * NULL => "" + * "/some/path/" => "" + * "/some/path" => "path" + * "afile" => "afile" + * + * @param path The path to look at + * @return Pointer to the character after the last path seperator + */ +const char *path_basename(const char *path) +{ + if (path == NULL) + { + return(""); + } + + const char *last_path = path; + char ch; + + while ((ch = *path) != 0) + { + path++; + if (ch == PATH_SEP) + { + last_path = path; + } + } + return(last_path); +} + + +/** + * Returns the length of the directory part of the filename. + */ +int path_dirname_len(const char *filename) +{ + if (filename == NULL) + { + return(0); + } + return((int)(path_basename(filename) - filename)); +} + + +static void usage_exit(const char *msg, const char *argv0, int code) +{ + if (msg != NULL) + { + fprintf(stderr, "%s\n", msg); + } + if ((code != EXIT_SUCCESS) || (argv0 == NULL)) + { + fprintf(stderr, "Try running with -h for usage information\n"); + exit(code); + } + fprintf(stdout, + "Usage:\n" + "%s [options] [files ...]\n" + "\n" + "If no input files are specified, the input is read from stdin\n" + "If reading from stdin, you should specify the language using -l\n" + "\n" + "If -F is used or files are specified on the command line, the output filename is\n" + "'prefix/filename' + suffix\n" + "\n" + "When reading from stdin or doing a single file via the '-f' option,\n" + "the output is dumped to stdout, unless redirected with -o FILE.\n" + "\n" + "Errors are always dumped to stderr\n" + "\n" + "The '-f' and '-o' options may not be used with '-F', '--replace' or '--no-backup'.\n" + "The '--prefix' and '--suffix' options may not be used with '--replace' or '--no-backup'.\n" + "\n" + "Basic Options:\n" + " -c CFG : use the config file CFG\n" + " -f FILE : process the single file FILE (output to stdout, use with -o)\n" + " -o FILE : Redirect stdout to FILE\n" + " -F FILE : read files to process from FILE, one filename per line\n" + " files : files to process (can be combined with -F)\n" + " --suffix SFX : Append SFX to the output filename. The default is '.uncrustify'\n" + " --prefix PFX : Prepend PFX to the output filename path.\n" + " --replace : replace source files (creates a backup)\n" + " --no-backup : replace files, no backup. Useful if files are under source control\n" +#ifdef HAVE_UTIME_H + " --mtime : preserve mtime on replaced files\n" +#endif + " -l : language override: C, CPP, D, CS, JAVA, PAWN, OC, OC+\n" + " -t : load a file with types (usually not needed)\n" + " -q : quiet mode - no output on stderr (-L will override)\n" + "\n" + "Config/Help Options:\n" + " -h -? --help --usage : print this message and exit\n" + " --version : print the version and exit\n" + " --show-config : print out option documentation and exit\n" + " --update-config : Output a new config file. Use with -o FILE\n" + " --update-config-with-doc : Output a new config file. Use with -o FILE\n" + " --universalindent : Output a config file for Universal Indent GUI\n" + " --detect : detects the config from a source file. Use with '-f FILE'\n" + " Detection is fairly limited.\n" + "\n" + "Debug Options:\n" + " -p FILE : dump debug info to a file\n" + " -L SEV : Set the log severity (see log_levels.h)\n" + " -s : Show the log severity in the logs\n" + " --decode FLAG: Print FLAG (chunk flags) as text and exit\n" + "\n" + "Usage Examples\n" + "cat foo.d | uncrustify -q -c my.cfg -l d\n" + "uncrustify -c my.cfg -f foo.d\n" + "uncrustify -c my.cfg -f foo.d -L0-2,20-23,51\n" + "uncrustify -c my.cfg -f foo.d -o foo.d\n" + "uncrustify -c my.cfg foo.d\n" + "uncrustify -c my.cfg --replace foo.d\n" + "uncrustify -c my.cfg --no-backup foo.d\n" + "uncrustify -c my.cfg --prefix=out -F files.txt\n" + "\n" + "Note: Use comments containing ' *INDENT-OFF*' and ' *INDENT-ON*' to disable\n" + " processing of parts of the source file.\n" + "\n" + "There are currently %d options and minimal documentation.\n" + "Try UniversalIndentGUI and good luck.\n" + "\n" + , + path_basename(argv0), UO_option_count); + exit(code); +} + + +static void version_exit(void) +{ + printf("uncrustify %s\n", UNCRUSTIFY_VERSION); + exit(0); +} + + +static void redir_stdout(const char *output_file) +{ + /* Reopen stdout */ + FILE *my_stdout = stdout; + + if (output_file != NULL) + { + my_stdout = freopen(output_file, "wb", stdout); + if (my_stdout == NULL) + { + LOG_FMT(LERR, "Unable to open %s for write: %s (%d)\n", + output_file, strerror(errno), errno); + usage_exit(NULL, NULL, 56); + } + LOG_FMT(LNOTE, "Redirecting output to %s\n", output_file); + } +} + + +int main(int argc, char *argv[]) +{ + char *data = NULL; + int data_len = 0; + const char *cfg_file = "uncrustify.cfg"; + const char *parsed_file = NULL; + const char *source_file = NULL; + const char *output_file = NULL; + const char *source_list = NULL; + log_mask_t mask; + int idx; + const char *p_arg; + + /* If ran without options... check keywork sort and show the usage info */ + if (argc == 1) + { + keywords_are_sorted(); + usage_exit(NULL, argv[0], EXIT_SUCCESS); + } + + /* Build options map */ + register_options(); + + Args arg(argc, argv); + + if (arg.Present("--version") || arg.Present("-v")) + { + version_exit(); + } + if (arg.Present("--help") || arg.Present("-h") || + arg.Present("--usage") || arg.Present("-?")) + { + usage_exit(NULL, argv[0], EXIT_SUCCESS); + } + + if (arg.Present("--show-config")) + { + print_options(stdout, true); + return(0); + } + +#ifdef WIN32 + /* tell windoze not to change what I write to stdout */ + (void) _setmode(_fileno(stdout), _O_BINARY); +#endif + + /* Init logging */ + log_init(stderr); + if (arg.Present("-q")) + { + logmask_from_string("", &mask); + log_set_mask(&mask); + } + if (((p_arg = arg.Param("-L")) != NULL) || + ((p_arg = arg.Param("--log")) != NULL)) + { + logmask_from_string(p_arg, &mask); + log_set_mask(&mask); + } + + if ((p_arg = arg.Param("--decode")) != NULL) + { + log_pcf_flags(LSYS, strtoul(p_arg, NULL, 16)); + exit(EXIT_SUCCESS); + } + + /* Get the config file name */ + if (((cfg_file = arg.Param("--config")) == NULL) && + ((cfg_file = arg.Param("-c")) == NULL)) + { + /* Handled later */ + } + +#ifndef WIN32 + /* Try to file a config at an alternate location */ + char buf[512]; + if (cfg_file == NULL) + { + cfg_file = getenv("UNCRUSTIFY_CONFIG"); + if (cfg_file == NULL) + { + const char *home = getenv("HOME"); + + if (home != NULL) + { + struct stat tmp_stat; + + snprintf(buf, sizeof(buf), "%s/.uncrustify.cfg", home); + if (stat(buf, &tmp_stat) == 0) + { + cfg_file = buf; + } + } + } + } +#endif + + /* Get the parsed file name */ + if (((parsed_file = arg.Param("--parsed")) != NULL) || + ((parsed_file = arg.Param("-p")) != NULL)) + { + LOG_FMT(LNOTE, "Will export parsed data to: %s\n", parsed_file); + } + + /* Enable log sevs? */ + if (arg.Present("-s") || arg.Present("--show")) + { + log_show_sev(true); + } + + /* Load the config file */ + set_option_defaults(); + + /* Load type files */ + idx = 0; + while ((p_arg = arg.Params("-t", idx)) != NULL) + { + load_keyword_file(p_arg); + } + + /* add types */ + idx = 0; + while ((p_arg = arg.Params("--type", idx)) != NULL) + { + add_keyword(p_arg, CT_TYPE, LANG_ALL); + } + + /* Load define files */ + idx = 0; + while ((p_arg = arg.Params("-d", idx)) != NULL) + { + load_define_file(p_arg); + } + + /* add defines */ + idx = 0; + while ((p_arg = arg.Params("--define", idx)) != NULL) + { + add_define(p_arg, NULL); + } + + /* Check for a language override */ + if ((p_arg = arg.Param("-l")) != NULL) + { + cpd.lang_flags = language_from_tag(p_arg); + if (cpd.lang_flags == 0) + { + LOG_FMT(LWARN, "Ignoring unknown language: %s\n", p_arg); + } + } + + /* Get the source file name */ + if (((source_file = arg.Param("--file")) == NULL) && + ((source_file = arg.Param("-f")) == NULL)) + { + // not using a single file, source_file is NULL + } + + if (((source_list = arg.Param("--files")) == NULL) && + ((source_list = arg.Param("-F")) == NULL)) + { + // not using a file list, source_list is NULL + } + + const char *prefix = arg.Param("--prefix"); + const char *suffix = arg.Param("--suffix"); + + bool no_backup = arg.Present("--no-backup"); + bool replace = arg.Present("--replace"); + bool keep_mtime = arg.Present("--mtime"); + bool update_config = arg.Present("--update-config"); + bool update_config_wd = arg.Present("--update-config-with-doc"); + bool detect = arg.Present("--detect"); + + /* Grab the output override */ + output_file = arg.Param("-o"); + + LOG_FMT(LDATA, "output_file = %s\n", (output_file != NULL) ? output_file : "null"); + LOG_FMT(LDATA, "source_file = %s\n", (source_file != NULL) ? source_file : "null"); + LOG_FMT(LDATA, "source_list = %s\n", (source_list != NULL) ? source_list : "null"); + LOG_FMT(LDATA, "prefix = %s\n", (prefix != NULL) ? prefix : "null"); + LOG_FMT(LDATA, "suffix = %s\n", (suffix != NULL) ? suffix : "null"); + LOG_FMT(LDATA, "replace = %d\n", replace); + LOG_FMT(LDATA, "no_backup = %d\n", no_backup); + LOG_FMT(LDATA, "detect = %d\n", detect); + + if (replace || no_backup) + { + if ((prefix != NULL) || (suffix != NULL)) + { + usage_exit("Cannot use --replace with --prefix or --suffix", argv[0], 66); + } + if ((source_file != NULL) || (output_file != NULL)) + { + usage_exit("Cannot use --replace or --no-backup with -f or -o", argv[0], 66); + } + } + else + { + if ((prefix == NULL) && (suffix == NULL)) + { + suffix = ".uncrustify"; + } + } + + /* Try to load the config file, if available. + * It is optional for "--universalindent" and "--detect", but required for + * everything else. + */ + if (cfg_file != NULL) + { + cpd.filename = cfg_file; + if (load_option_file(cfg_file) < 0) + { + usage_exit("Unable to load the config file", argv[0], 56); + } + } + + if (arg.Present("--universalindent")) + { + FILE *pfile = stdout; + + if (output_file != NULL) + { + pfile = fopen(output_file, "w"); + if (pfile == NULL) + { + fprintf(stderr, "Unable to open %s for write: %s (%d)\n", + output_file, strerror(errno), errno); + return(EXIT_FAILURE); + } + } + + print_universal_indent_cfg(pfile); + + return(EXIT_SUCCESS); + } + + if (detect) + { + file_mem fm; + + if ((source_file == NULL) || (source_list != NULL)) + { + fprintf(stderr, "The --detect option requires a single input file\n"); + return(EXIT_FAILURE); + } + + /* Do some simple language detection based on the filename extension */ + if (cpd.lang_flags == 0) + { + cpd.lang_flags = language_from_filename(source_file); + } + + /* Try to read in the source file */ + if (load_mem_file(source_file, fm) < 0) + { + LOG_FMT(LERR, "Failed to load (%s)\n", source_file); + cpd.error_count++; + return(EXIT_FAILURE); + } + + uncrustify_start(fm.data, fm.length); + detect_options(fm.data, fm.length); + uncrustify_end(); + free(fm.data); + + redir_stdout(output_file); + save_option_file(stdout, update_config_wd); + return(EXIT_SUCCESS); + } + + /* Everything beyond this point requires a config file, so complain and + * bail if we don't have one. + */ + if (cfg_file == NULL) + { +#ifdef WIN32 + usage_exit("Specify the config file: -c file", argv[0], 58); +#else + usage_exit("Specify the config file with '-c file' or set UNCRUSTIFY_CONFIG", + argv[0], 58); +#endif + } + + /* + * Done parsing args + */ + + if (update_config || update_config_wd) + { + redir_stdout(output_file); + save_option_file(stdout, update_config_wd); + return(0); + } + + /* Check for unused args (ignore them) */ + idx = 1; + p_arg = arg.Unused(idx); + + /* Check args - for multifile options */ + if ((source_list != NULL) || (p_arg != NULL)) + { + if (source_file != NULL) + { + usage_exit("Cannot specify both the single file option and a mulit-file option.", + argv[0], 67); + } + + if (output_file != NULL) + { + usage_exit("Cannot specify -o with a mulit-file option.", + argv[0], 68); + } + } + + /* This relies on cpd.filename being the config file name */ + load_header_files(); + + if ((source_file == NULL) && (source_list == NULL) && (p_arg == NULL)) + { + /* no input specified, so use stdin */ + if (cpd.lang_flags == 0) + { + cpd.lang_flags = LANG_C; + } + + redir_stdout(output_file); + + data = read_stdin(data_len); + if (data == NULL) + { + LOG_FMT(LERR, "Out of memory\n"); + return(100); + } + + cpd.filename = "stdin"; + + /* Done reading from stdin */ + LOG_FMT(LSYS, "Parsing: %d bytes from stdin as language %s\n", + data_len, language_to_string(cpd.lang_flags)); + + uncrustify_file(data, data_len, stdout, parsed_file); + free(data); + data_len = 0; + data = NULL; + } + else if (source_file != NULL) + { + /* Doing a single file */ + do_source_file(source_file, output_file, parsed_file, no_backup, keep_mtime); + } + else + { + /* Doing multiple files */ + if (prefix != NULL) + { + LOG_FMT(LSYS, "Output prefix: %s/\n", prefix); + } + if (suffix != NULL) + { + LOG_FMT(LSYS, "Output suffix: %s\n", suffix); + } + + /* Do the files on the command line first */ + idx = 1; + while ((p_arg = arg.Unused(idx)) != NULL) + { + char outbuf[1024]; + do_source_file(p_arg, + make_output_filename(outbuf, sizeof(outbuf), p_arg, prefix, suffix), + NULL, no_backup, keep_mtime); + } + + if (source_list != NULL) + { + process_source_list(source_list, prefix, suffix, no_backup, keep_mtime); + } + } + + clear_keyword_file(); + clear_defines(); + + return((cpd.error_count != 0) ? 1 : 0); +} + + +static void process_source_list(const char *source_list, + const char *prefix, const char *suffix, + bool no_backup, bool keep_mtime) +{ + FILE *p_file = fopen(source_list, "r"); + + if (p_file == NULL) + { + LOG_FMT(LERR, "%s: fopen(%s) failed: %s (%d)\n", + __func__, source_list, strerror(errno), errno); + cpd.error_count++; + return; + } + + char linebuf[256]; + int argc; + char *args[3]; + int line = 0; + int idx; + + while (fgets(linebuf, sizeof(linebuf), p_file) != NULL) + { + line++; + argc = Args::SplitLine(linebuf, args, ARRAY_SIZE(args)); + + LOG_FMT(LFILELIST, "%3d]", line); + for (idx = 0; idx < argc; idx++) + { + LOG_FMT(LFILELIST, " [%s]", args[idx]); + } + LOG_FMT(LFILELIST, "\n"); + + if ((argc == 1) && (*args[0] != '#')) + { + char outbuf[1024]; + do_source_file(args[0], + make_output_filename(outbuf, sizeof(outbuf), args[0], prefix, suffix), + NULL, no_backup, keep_mtime); + } + } + fclose(p_file); +} + + +static char *read_stdin(int& out_len) +{ + char *data; + char *new_data; + int data_size; + int data_len; + int len; + + /* Start with 64k */ + data_size = 64 * 1024; + data = (char *)malloc(data_size); + data_len = 0; + + if (data == NULL) + { + return(NULL); + } + + while ((len = fread(&data[data_len], 1, data_size - data_len, stdin)) > 0) + { + data_len += len; + if (data_len == data_size) + { + /* Double the buffer size */ + data_size *= 2; + if ((new_data = (char *)realloc(data, data_size)) == NULL) + { + free(data); + return(NULL); + } + data = new_data; + } + } + + assert(data_len < data_size); + /* Make sure the buffer is terminated */ + data[data_len] = 0; + + out_len = data_len; + + return(data); +} + + +static void make_folders(const char *filename) +{ + int idx; + int last_idx = 0; + char outname[1024]; + + snprintf(outname, sizeof(outname), "%s", filename); + + for (idx = 0; outname[idx] != 0; idx++) + { + if ((outname[idx] == '/') || (outname[idx] == '\\')) + { + outname[idx] = PATH_SEP; + } + + if ((idx > last_idx) && (outname[idx] == PATH_SEP)) + { + outname[idx] = 0; + + if ((strcmp(&outname[last_idx], ".") != 0) && + (strcmp(&outname[last_idx], "..") != 0)) + { + //fprintf(stderr, "%s: %s\n", __func__, outname); + mkdir(outname, 0750); + } + outname[idx] = PATH_SEP; + } + + if (outname[idx] == PATH_SEP) + { + last_idx = idx + 1; + } + } +} + + +/** + * Loads a file into memory + */ +static int load_mem_file(const char *filename, file_mem& fm) +{ + int retval = -1; + struct stat my_stat; + FILE *p_file; + + fm.data = NULL; + fm.length = 0; + + /* Grab the stat info for the file */ + if (stat(filename, &my_stat) < 0) + { + return(-1); + } + +#ifdef HAVE_UTIME_H + /* Save off mtime */ + fm.utb.modtime = my_stat.st_mtime; +#endif + + /* Try to read in the file */ + p_file = fopen(filename, "rb"); + if (p_file == NULL) + { + return(-1); + } + + fm.length = my_stat.st_size; + fm.data = (char *)malloc(fm.length + 1); + if (fm.data == NULL) + { + LOG_FMT(LERR, "%s: fopen(%s) failed: out of memory\n", __func__, filename); + cpd.error_count++; + } + else if (fread(fm.data, fm.length, 1, p_file) != 1) + { + LOG_FMT(LERR, "%s: fread(%s) failed: %s (%d)\n", + __func__, filename, strerror(errno), errno); + cpd.error_count++; + } + else + { + fm.data[fm.length] = 0; + retval = 0; + } + fclose(p_file); + + if ((retval != 0) && (fm.data != NULL)) + { + free(fm.data); + fm.data = NULL; + fm.length = 0; + } + return(retval); +} + + +/** + * Try to load the file from the config folder first and then by name + */ +static int load_mem_file_config(const char *filename, file_mem& fm) +{ + int retval; + char buf[1024]; + + snprintf(buf, sizeof(buf), "%.*s%s", + path_dirname_len(cpd.filename), cpd.filename, filename); + + retval = load_mem_file(buf, fm); + if (retval < 0) + { + retval = load_mem_file(filename, fm); + if (retval < 0) + { + LOG_FMT(LERR, "Failed to load (%s) or (%s)\n", buf, filename); + cpd.error_count++; + } + } + return(retval); +} + + +static int load_header_files() +{ + int retval = 0; + + if ((cpd.settings[UO_cmt_insert_file_header].str != NULL) && + (cpd.settings[UO_cmt_insert_file_header].str[0] != 0)) + { + retval |= load_mem_file_config(cpd.settings[UO_cmt_insert_file_header].str, + cpd.file_hdr); + } + if ((cpd.settings[UO_cmt_insert_file_footer].str != NULL) && + (cpd.settings[UO_cmt_insert_file_footer].str[0] != 0)) + { + retval |= load_mem_file_config(cpd.settings[UO_cmt_insert_file_footer].str, + cpd.file_ftr); + } + if ((cpd.settings[UO_cmt_insert_func_header].str != NULL) && + (cpd.settings[UO_cmt_insert_func_header].str[0] != 0)) + { + retval |= load_mem_file_config(cpd.settings[UO_cmt_insert_func_header].str, + cpd.func_hdr); + } + if ((cpd.settings[UO_cmt_insert_class_header].str != NULL) && + (cpd.settings[UO_cmt_insert_class_header].str[0] != 0)) + { + retval |= load_mem_file_config(cpd.settings[UO_cmt_insert_class_header].str, + cpd.class_hdr); + } + return(retval); +} + + +static const char *make_output_filename(char *buf, int buf_size, + const char *filename, + const char *prefix, + const char *suffix) +{ + int len = 0; + + if (prefix != NULL) + { + len = snprintf(buf, buf_size, "%s/", prefix); + } + + snprintf(&buf[len], buf_size - len, "%s%s", filename, + (suffix != NULL) ? suffix : ""); + + return(buf); +} + + +/** + * Reinvent the wheel with a file comparision function... + */ +static bool file_content_matches(const char *filename1, const char *filename2) +{ + struct stat st1, st2; + int fd1, fd2; + UINT8 buf1[1024], buf2[1024]; + int len1 = 0, len2 = 0; + int minlen; + + /* Check the sizes first */ + if ((stat(filename1, &st1) != 0) || + (stat(filename2, &st2) != 0) || + (st1.st_size != st2.st_size)) + { + return(false); + } + + if ((fd1 = open(filename1, O_RDONLY)) < 0) + { + return(false); + } + if ((fd2 = open(filename2, O_RDONLY)) < 0) + { + close(fd1); + return(false); + } + + while ((len1 >= 0) && (len2 >= 0)) + { + if (len1 == 0) + { + len1 = read(fd1, buf1, sizeof(buf1)); + } + if (len2 == 0) + { + len2 = read(fd2, buf2, sizeof(buf2)); + } + if ((len1 <= 0) || (len2 <= 0)) + { + break; + } + minlen = (len1 < len2) ? len1 : len2; + if (memcmp(buf1, buf2, minlen) != 0) + { + break; + } + len1 -= minlen; + len2 -= minlen; + } + + close(fd1); + close(fd2); + + return((len1 == 0) && (len2 == 0)); +} + + +const char *fix_filename(const char *filename) +{ + char *tmp_file; + + /* Create 'outfile.uncrustify' */ + tmp_file = new char[strlen(filename) + 16]; + if (tmp_file != NULL) + { + sprintf(tmp_file, "%s.uncrustify", filename); + } + return(tmp_file); +} + + +/** + * Does a source file. + * + * @param filename_in the file to read + * @param filename_out NULL (stdout) or the file to write + * @param parsed_file NULL or the filename for the parsed debug info + * @param no_backup don't create a backup, if filename_out == filename_in + * @param keep_mtime don't change the mtime (dangerous) + */ +static void do_source_file(const char *filename_in, + const char *filename_out, + const char *parsed_file, + bool no_backup, + bool keep_mtime) +{ + FILE *pfout; + bool did_open = false; + bool need_backup = false; + file_mem fm; + const char *filename_tmp = NULL; + + /* Do some simple language detection based on the filename extension */ + if (cpd.lang_flags == 0) + { + cpd.lang_flags = language_from_filename(filename_in); + } + + /* Try to read in the source file */ + if (load_mem_file(filename_in, fm) < 0) + { + LOG_FMT(LERR, "Failed to load (%s)\n", filename_in); + cpd.error_count++; + return; + } + + LOG_FMT(LSYS, "Parsing: %s as language %s\n", + filename_in, language_to_string(cpd.lang_flags)); + + if (filename_out == NULL) + { + pfout = stdout; + } + else + { + /* If the out file is the same as the in file, then use a temp file */ + filename_tmp = filename_out; + if (strcmp(filename_in, filename_out) == 0) + { + /* Create 'outfile.uncrustify' */ + filename_tmp = fix_filename(filename_out); + if (filename_tmp == NULL) + { + LOG_FMT(LERR, "%s: Out of memory\n", __func__); + cpd.error_count++; + free(fm.data); + return; + } + + if (!no_backup) + { + if (backup_copy_file(filename_in, fm.data, fm.length) != SUCCESS) + { + LOG_FMT(LERR, "%s: Failed to create backup file for %s\n", + __func__, filename_in); + free(fm.data); + cpd.error_count++; + return; + } + need_backup = true; + } + } + make_folders(filename_tmp); + + pfout = fopen(filename_tmp, "wb"); + if (pfout == NULL) + { + LOG_FMT(LERR, "%s: Unable to create %s: %s (%d)\n", + __func__, filename_tmp, strerror(errno), errno); + cpd.error_count++; + free(fm.data); + if ((filename_tmp != NULL) && (filename_tmp != filename_out)) + { + delete [] (char *)filename_tmp; + filename_tmp = NULL; + } + return; + } + did_open = true; + //LOG_FMT(LSYS, "Output file %s\n", filename_out); + } + + cpd.filename = filename_in; + uncrustify_file(fm.data, fm.length, pfout, parsed_file); + + free(fm.data); + + if (did_open) + { + fclose(pfout); + + if (need_backup) + { + backup_create_md5_file(filename_in); + } + + if ((filename_tmp != NULL) && (filename_tmp != filename_out)) + { + /* We need to compare and then do a rename */ + if (file_content_matches(filename_tmp, filename_out)) + { + /* No change - remove tmp file */ + (void)unlink(filename_tmp); + } + else + { +#ifdef WIN32 + /* windows can't rename a file if the target exists, so delete it + * first. This may cause data loss if the tmp file gets deleted + * or can't be renamed. + */ + (void) unlink(filename_out); +#endif + /* Change - rename filename_tmp to filename_out */ + if (rename(filename_tmp, filename_out) != 0) + { + LOG_FMT(LERR, "%s: Unable to rename '%s' to '%s'\n", + __func__, filename_tmp, filename_out); + cpd.error_count++; + } + } + delete [] (char *)filename_tmp; + filename_tmp = NULL; + } + +#ifdef HAVE_UTIME_H + if (keep_mtime) + { + /* update mtime -- don't care if it fails */ + fm.utb.actime = time(NULL); + (void)utime(filename_in, &fm.utb); + } +#endif + } +} + + +static void add_file_header() +{ + if (!chunk_is_comment(chunk_get_head())) + { + /*TODO: detect the typical #ifndef FOO / #define FOO sequence */ + tokenize(cpd.file_hdr.data, cpd.file_hdr.length, chunk_get_head()); + } +} + + +static void add_file_footer() +{ + chunk_t *pc = chunk_get_tail(); + + /* Back up if the file ends with a newline */ + if ((pc != NULL) && chunk_is_newline(pc)) + { + pc = chunk_get_prev(pc); + } + if ((pc != NULL) && + (!chunk_is_comment(pc) || !chunk_is_newline(chunk_get_prev(pc)))) + { + pc = chunk_get_tail(); + if (!chunk_is_newline(pc)) + { + LOG_FMT(LSYS, "Adding a newline at the end of the file\n"); + newline_add_after(pc); + } + tokenize(cpd.file_ftr.data, cpd.file_ftr.length, NULL); + } +} + + +static void add_func_header(c_token_t type, file_mem& fm) +{ + chunk_t *pc; + chunk_t *ref; + chunk_t *tmp; + bool do_insert; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next_ncnlnp(pc)) + { + if (pc->type != type) + { + continue; + } + + do_insert = false; + + /* On a function proto or def. Back up to a close brace or semicolon on + * the same level + */ + ref = pc; + while ((ref = chunk_get_prev(ref)) != NULL) + { + /* Bail if we change level */ + if (ref->level != pc->level) + { + do_insert = true; + break; + } + + /* If we hit an angle close, back up to the angle open */ + if (ref->type == CT_ANGLE_CLOSE) + { + ref = chunk_get_prev_type(ref, CT_ANGLE_OPEN, ref->level, CNAV_PREPROC); + continue; + } + + /* Bail if we hit a preprocessor and cmt_insert_before_preproc is false */ + if (ref->flags & PCF_IN_PREPROC) + { + tmp = chunk_get_prev_type(ref, CT_PREPROC, ref->level); + if ((tmp != NULL) && (tmp->parent_type == CT_PP_IF)) + { + tmp = chunk_get_prev_nnl(tmp); + if (chunk_is_comment(tmp) && + !cpd.settings[UO_cmt_insert_before_preproc].b) + { + break; + } + } + } + + /* Ignore 'right' comments */ + if (chunk_is_comment(ref) && chunk_is_newline(chunk_get_prev(ref))) + { + break; + } + + if ((ref->level == pc->level) && + ((ref->flags & PCF_IN_PREPROC) || + (ref->type == CT_SEMICOLON) || + (ref->type == CT_BRACE_CLOSE))) + { + do_insert = true; + break; + } + } + if (do_insert) + { + /* Insert between after and ref */ + chunk_t *after = chunk_get_next_ncnl(ref); + tokenize(fm.data, fm.length, after); + for (tmp = chunk_get_next(ref); tmp != after; tmp = chunk_get_next(tmp)) + { + tmp->level = after->level; + } + } + } +} + + +static void uncrustify_start(const char *data, int data_len) +{ + /** + * Parse the text into chunks + */ + tokenize(data, data_len, NULL); + + /* Add the file header */ + if (cpd.file_hdr.data != NULL) + { + add_file_header(); + } + + /* Add the file footer */ + if (cpd.file_ftr.data != NULL) + { + add_file_footer(); + } + + /** + * Change certain token types based on simple sequence. + * Example: change '[' + ']' to '[]' + * Note that level info is not yet available, so it is OK to do all + * processing that doesn't need to know level info. (that's very little!) + */ + tokenize_cleanup(); + + /** + * Detect the brace and paren levels and insert virtual braces. + * This handles all that nasty preprocessor stuff + */ + brace_cleanup(); + + /** + * At this point, the level information is available and accurate. + */ + + if ((cpd.lang_flags & LANG_PAWN) != 0) + { + pawn_prescan(); + } + + /** + * Re-type chunks, combine chunks + */ + fix_symbols(); + + /** + * Look at all colons ':' and mark labels, :? sequences, etc. + */ + combine_labels(); +} + + +static void uncrustify_file(const char *data, int data_len, FILE *pfout, + const char *parsed_file) +{ + uncrustify_start(data, data_len); + + /** + * Done with detection. Do the rest only if the file will go somewhere. + * The detection code needs as few changes as possible. + */ + if (pfout != NULL) + { + /** + * Add comments before function defs and classes + */ + if (cpd.func_hdr.data != NULL) + { + add_func_header(CT_FUNC_DEF, cpd.func_hdr); + } + if (cpd.class_hdr.data != NULL) + { + add_func_header(CT_CLASS, cpd.class_hdr); + } + + /** + * Change virtual braces into real braces... + */ + do_braces(); + + /* Scrub extra semicolons */ + if (cpd.settings[UO_mod_remove_extra_semicolon].b) + { + remove_extra_semicolons(); + } + + /* Remove unnecessary returns */ + if (cpd.settings[UO_mod_remove_empty_return].b) + { + remove_extra_returns(); + } + + /** + * Add parens + */ + do_parens(); + + /** + * Insert line breaks as needed + */ + do_blank_lines(); + newlines_cleanup_braces(); + if (cpd.settings[UO_nl_after_multiline_comment].b) + { + newline_after_multiline_comment(); + } + newlines_insert_blank_lines(); + if (cpd.settings[UO_pos_bool].tp != TP_IGNORE) + { + newlines_chunk_pos(CT_BOOL, cpd.settings[UO_pos_bool].tp); + } + if (cpd.settings[UO_pos_compare].tp != TP_IGNORE) + { + newlines_chunk_pos(CT_COMPARE, cpd.settings[UO_pos_compare].tp); + } + if (cpd.settings[UO_pos_conditional].tp != TP_IGNORE) + { + newlines_chunk_pos(CT_COND_COLON, cpd.settings[UO_pos_conditional].tp); + newlines_chunk_pos(CT_QUESTION, cpd.settings[UO_pos_conditional].tp); + } + if (cpd.settings[UO_pos_comma].tp != TP_IGNORE) + { + newlines_chunk_pos(CT_COMMA, cpd.settings[UO_pos_comma].tp); + } + if (cpd.settings[UO_pos_assign].tp != TP_IGNORE) + { + newlines_chunk_pos(CT_ASSIGN, cpd.settings[UO_pos_assign].tp); + } + if (cpd.settings[UO_pos_arith].tp != TP_IGNORE) + { + newlines_chunk_pos(CT_ARITH, cpd.settings[UO_pos_arith].tp); + } + newlines_class_colon_pos(); + if (cpd.settings[UO_nl_squeeze_ifdef].b) + { + newlines_squeeze_ifdef(); + } + newlines_eat_start_end(); + newlines_cleanup_dup(); + + mark_comments(); + + /** + * Add balanced spaces around nested params + */ + if (cpd.settings[UO_sp_balance_nested_parens].b) + { + space_text_balance_nested_parens(); + } + + /* Scrub certain added semicolons */ + if (((cpd.lang_flags & LANG_PAWN) != 0) && + cpd.settings[UO_mod_pawn_semicolon].b) + { + pawn_scrub_vsemi(); + } + + /* Sort imports/using/include */ + if (cpd.settings[UO_mod_sort_import].b || + cpd.settings[UO_mod_sort_include].b || + cpd.settings[UO_mod_sort_using].b) + { + sort_imports(); + } + + /** + * Fix same-line inter-chunk spacing + */ + space_text(); + + /** + * Do any aligning of preprocessors + */ + if (cpd.settings[UO_align_pp_define_span].n > 0) + { + align_preprocessor(); + } + + /** + * Indent the text + */ + indent_preproc(); + indent_text(); + + /* Insert trailing comments after certain close braces */ + if ((cpd.settings[UO_mod_add_long_switch_closebrace_comment].n > 0) || + (cpd.settings[UO_mod_add_long_function_closebrace_comment].n > 0)) + { + add_long_closebrace_comment(); + } + + /* Insert trailing comments after certain preprocessor conditional blocks */ + if ((cpd.settings[UO_mod_add_long_ifdef_else_comment].n > 0) || + (cpd.settings[UO_mod_add_long_ifdef_endif_comment].n > 0)) + { + add_long_preprocessor_conditional_block_comment(); + } + + /** + * Aligning everything else and reindent + */ + align_all(); + indent_text(); + + if (cpd.settings[UO_code_width].n > 0) + { + int max_passes = 3; + int prev_changes; + do + { + prev_changes = cpd.changes; + do_code_width(); + if (prev_changes != cpd.changes) + { + align_all(); + indent_text(); + } + } while ((prev_changes != cpd.changes) && (--max_passes > 0)); + } + + /** + * And finally, align the backslash newline stuff + */ + align_right_comments(); + if (cpd.settings[UO_align_nl_cont].b) + { + align_backslash_newline(); + } + + /** + * Now render it all to the output file + */ + output_text(pfout); + } + + /* Special hook for dumping parsed data for debugging */ + if (parsed_file != NULL) + { + FILE *p_file = fopen(parsed_file, "w"); + if (p_file != NULL) + { + output_parsed(p_file); + fclose(p_file); + } + else + { + LOG_FMT(LERR, "%s: Failed to open '%s' for write: %s (%d)\n", + __func__, parsed_file, strerror(errno), errno); + } + } + + uncrustify_end(); +} + + +static void uncrustify_end() +{ + /* Free all the memory */ + chunk_t *pc; + + while ((pc = chunk_get_head()) != NULL) + { + chunk_del(pc); + } + + if (cpd.bom != NULL) + { + chunk_del(cpd.bom); + cpd.bom = NULL; + } + + /* Clean up some state variables */ + cpd.unc_off = false; + cpd.al_cnt = 0; + cpd.did_newline = true; + cpd.frame_count = 0; + cpd.pp_level = 0; + cpd.changes = 0; + cpd.in_preproc = CT_NONE; + cpd.consumed = false; + memset(cpd.le_counts, 0, sizeof(cpd.le_counts)); + cpd.preproc_ncnl_count = 0; +} + + +const char *get_token_name(c_token_t token) +{ + if ((token >= 0) && (token < (int)ARRAY_SIZE(token_names)) && + (token_names[token] != NULL)) + { + return(token_names[token]); + } + return("???"); +} + + +/** + * Grab the token id for the text. + * returns CT_NONE on failure t match + */ +c_token_t find_token_name(const char *text) +{ + int idx; + + if ((text != NULL) && (*text != 0)) + { + for (idx = 1; idx < (int)ARRAY_SIZE(token_names); idx++) + { + if (strcasecmp(text, token_names[idx]) == 0) + { + return((c_token_t)idx); + } + } + } + return(CT_NONE); +} + + +static bool ends_with(const char *filename, const char *tag) +{ + int len1 = strlen(filename); + int len2 = strlen(tag); + + if ((len2 <= len1) && (strcmp(&filename[len1 - len2], tag) == 0)) + { + return(true); + } + return(false); +} + + +struct file_lang +{ + const char *ext; + const char *tag; + int lang; +}; + +struct file_lang languages[] = +{ + { ".c", "C", LANG_C }, + { ".cpp", "CPP", LANG_CPP }, + { ".d", "D", LANG_D }, + { ".cs", "CS", LANG_CS }, + { ".vala", "VALA", LANG_VALA }, + { ".java", "JAVA", LANG_JAVA }, + { ".pawn", "PAWN", LANG_PAWN }, + { ".p", "", LANG_PAWN }, + { ".sma", "", LANG_PAWN }, + { ".inl", "", LANG_PAWN }, + { ".h", "", LANG_CPP }, + { ".cxx", "", LANG_CPP }, + { ".hpp", "", LANG_CPP }, + { ".hxx", "", LANG_CPP }, + { ".cc", "", LANG_CPP }, + { ".di", "", LANG_D }, + { ".m", "OC", LANG_OC }, + { ".mm", "OC+", LANG_OC | LANG_CPP }, + { ".sqc", "", LANG_C }, // embedded SQL + { ".es", "ECMA", LANG_ECMA }, +}; + +/** + * Set idx = 0 before the first call. + * Done when returns NULL + */ +const char *get_file_extension(int& idx) +{ + const char *val = NULL; + + if (idx < (int)ARRAY_SIZE(languages)) + { + val = languages[idx].ext; + } + idx++; + return(val); +} + + +/** + * Find the language for the file extension + * Default to C + * + * @param filename The name of the file + * @return LANG_xxx + */ +static int language_from_filename(const char *filename) +{ + int i; + + for (i = 0; i < (int)ARRAY_SIZE(languages); i++) + { + if (ends_with(filename, languages[i].ext)) + { + return(languages[i].lang); + } + } + return(LANG_C); +} + + +/** + * Find the language for the file extension + * + * @param filename The name of the file + * @return LANG_xxx or 0 (no match) + */ +static int language_from_tag(const char *tag) +{ + int i; + + for (i = 0; i < (int)ARRAY_SIZE(languages); i++) + { + if (strcasecmp(tag, languages[i].tag) == 0) + { + return(languages[i].lang); + } + } + return(0); +} + + +/** + * Gets the tag text for a language + * + * @param lang The LANG_xxx enum + * @return A string + */ +static const char *language_to_string(int lang) +{ + int i; + + /* Check for an exact match first */ + for (i = 0; i < (int)ARRAY_SIZE(languages); i++) + { + if (languages[i].lang == lang) + { + return(languages[i].tag); + } + } + + /* Check for the first set language bit */ + for (i = 0; i < (int)ARRAY_SIZE(languages); i++) + { + if ((languages[i].lang & lang) != 0) + { + return(languages[i].tag); + } + } + return("???"); +} + + +void log_pcf_flags(log_sev_t sev, UINT32 flags) +{ + if (!log_sev_on(sev)) + { + return; + } + + log_fmt(sev, "[0x%X:", flags); + + const char *tolog = NULL; + for (int i = 0; i < (int)ARRAY_SIZE(pcf_names); i++) + { + if ((flags & (1 << i)) != 0) + { + if (tolog != NULL) + { + log_str(sev, tolog, strlen(tolog)); + log_str(sev, ",", 1); + } + tolog = pcf_names[i]; + } + } + + if (tolog != NULL) + { + log_str(sev, tolog, strlen(tolog)); + } + + log_str(sev, "]\n", 2); +} diff --git a/src/uncrustify_types.h b/src/uncrustify_types.h new file mode 100644 index 0000000000..eea3cb928c --- /dev/null +++ b/src/uncrustify_types.h @@ -0,0 +1,343 @@ +/** + * @file uncrustify_types.h + * + * Defines some types for the uncrustify program + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef UNCRUSTIFY_TYPES_H_INCLUDED +#define UNCRUSTIFY_TYPES_H_INCLUDED + + +#include "base_types.h" +#include "options.h" +#include "token_enum.h" /* c_token_t */ +#include "log_levels.h" +#include "logger.h" +#include +#include +#ifdef HAVE_UTIME_H +#include +#endif + +#define UNCRUSTIFY_OFF_TEXT " *INDENT-OFF*" +#define UNCRUSTIFY_ON_TEXT " *INDENT-ON*" + +/** + * Brace stage enum used in brace_cleanup + */ +enum brstage_e +{ + BS_NONE, + BS_PAREN1, /* if/for/switch/while */ + BS_OP_PAREN1, /* optional paren: catch () { */ + BS_WOD_PAREN, /* while of do parens */ + BS_WOD_SEMI, /* semicolon after while of do */ + BS_BRACE_DO, /* do */ + BS_BRACE2, /* if/else/for/switch/while */ + BS_ELSE, /* expecting 'else' after 'if' */ + BS_ELSEIF, /* expecting 'if' after 'else' */ + BS_WHILE, /* expecting 'while' after 'do' */ + BS_CATCH, /* expecting 'catch' or 'finally' after 'try' */ +}; + +struct chunk_t; + +/** + * Structure for counting nested level + */ +struct paren_stack_entry +{ + c_token_t type; /**< the type that opened the entry */ + int level; /**< Level of opening type */ + int open_line; /**< line that open symbol is on */ + chunk_t *pc; /**< Chunk that opened the level */ + int brace_indent; /**< indent for braces - may not relate to indent */ + int indent; /**< indent level (depends on use) */ + int indent_tmp; /**< temporary indent level (depends on use) */ + int indent_tab; /**< the 'tab' indent (always <= real column) */ + int ref; + c_token_t parent; /**< if, for, function, etc */ + brstage_e stage; + bool in_preproc; /**< whether this was created in a preprocessor */ + bool non_vardef; /**< Hit a non-vardef line */ +}; + +/* TODO: put this on a linked list */ +struct parse_frame +{ + int ref_no; + int level; // level of parens/square/angle/brace + int brace_level; // level of brace/vbrace + int pp_level; // level of preproc #if stuff + + int sparen_count; + + struct paren_stack_entry pse[128]; + int pse_tos; + int paren_count; + + c_token_t in_ifdef; + int stmt_count; + int expr_count; + + bool maybe_decl; + bool maybe_cast; +}; + +#define PCF_FORCE_SPACE (1 << 0) /* must have a space after this token */ +#define PCF_STMT_START (1 << 1) /* marks the start of a statment */ +#define PCF_EXPR_START (1 << 2) +#define PCF_IN_PREPROC (1 << 3) /* in a preprocessor */ +#define PCF_DONT_INDENT (1 << 4) /* already aligned! */ +#define PCF_VAR_DEF (1 << 5) /* variable name in a variable def */ +#define PCF_VAR_1ST (1 << 6) /* 1st variable def in a statement */ +#define PCF_VAR_1ST_DEF (PCF_VAR_DEF | PCF_VAR_1ST) +#define PCF_VAR_INLINE (1 << 7) /* type was an inline struct/enum/union */ +#define PCF_IN_ENUM (1 << 8) /* in enum */ +#define PCF_IN_FCN_DEF (1 << 9) /* inside function def parens */ +#define PCF_IN_FCN_CALL (1 << 10) /* inside function call parens */ +#define PCF_IN_SPAREN (1 << 11) /* inside for/if/while/switch parens */ +#define PCF_RIGHT_COMMENT (1 << 12) +#define PCF_OLD_FCN_PARAMS (1 << 13) +#define PCF_WAS_ALIGNED (1 << 14) +#define PCF_IN_TEMPLATE (1 << 15) +#define PCF_IN_TYPEDEF (1 << 16) +#define PCF_IN_CONST_ARGS (1 << 17) +#define PCF_LVALUE (1 << 18) /* left of assignment */ +#define PCF_IN_ARRAY_ASSIGN (1 << 19) +#define PCF_IN_CLASS (1 << 20) +#define PCF_IN_NAMESPACE (1 << 21) +#define PCF_IN_FOR (1 << 22) +#define PCF_ONE_LINER (1 << 23) +#define PCF_ONE_CLASS (PCF_ONE_LINER | PCF_IN_CLASS) +#define PCF_EMPTY_BODY (1 << 24) +#define PCF_ANCHOR (1 << 25) /* aligning anchor */ +#define PCF_PUNCTUATOR (1 << 26) +#define PCF_INSERTED (1 << 27) /* chunk was inserted from another file */ +#define PCF_ALIGN_START (1 << 28) +#define PCF_VAR_TYPE (1 << 29) /* part of a variable def type */ +#define PCF_LONG_BLOCK (1 << 30) /* the block is 'long' by some measure */ +#define PCF_OWN_STR (1 << 31) /* chunk owns the memory at str */ + + +/* flags that get copied when a new chunk is inserted */ +#define PCF_COPY_FLAGS \ + (PCF_IN_PREPROC | PCF_IN_SPAREN | PCF_IN_ENUM | \ + PCF_IN_FCN_DEF | PCF_IN_FCN_CALL | PCF_IN_TYPEDEF | \ + PCF_IN_ARRAY_ASSIGN | PCF_IN_CLASS | PCF_IN_NAMESPACE | \ + PCF_IN_CLASS | PCF_IN_FOR | PCF_IN_TEMPLATE) + +#ifdef DEFINE_PCF_NAMES +static const char *pcf_names[] = +{ + "FORCE_SPACE", + "STMT_START", + "EXPR_START", + "IN_PREPROC", + "DONT_INDENT", + "VAR_DEF", + "VAR_1ST", + "VAR_INLINE", + "IN_ENUM", + "IN_FCN_DEF", + "IN_FCN_CALL", + "IN_SPAREN", + "RIGHT_COMMENT", + "OLD_FCN_PARAMS", + "WAS_ALIGNED", + "IN_TEMPLATE", + "IN_TYPEDEF", + "IN_CONST_ARGS", + "LVALUE", + "IN_ARRAY_ASSIGN", + "IN_CLASS", + "IN_NAMESPACE", + "IN_FOR", + "ONE_LINER", + "EMPTY_BODY", + "ANCHOR", + "PUNCTUATOR", + "INSERTED", + "ALIGN_START", + "VAR_TYPE", + "LONG_BLOCK", + "OWN_STR", +}; +#endif + +struct align_ptr_t +{ + chunk_t *next; /* NULL or the chunk that should be under this one */ + bool right_align; /* AlignStack.m_right_align */ + int star_style; /* AlignStack.m_star_style */ + int amp_style; /* AlignStack.m_amp_style */ + int gap; /* AlignStack.m_gap */ + + /* col_adj is the amount to alter the column for the token. + * For example, a dangling '*' would be set to -1. + * A right-aligned word would be a positive value. + */ + int col_adj; + chunk_t *ref; + chunk_t *start; +}; + +/** This is the main type of this program */ +struct chunk_t +{ + chunk_t *next; + chunk_t *prev; + align_ptr_t align; + c_token_t type; + c_token_t parent_type; /* usually CT_NONE */ + UINT32 orig_line; + UINT32 orig_col; + UINT32 orig_col_end; + UINT32 flags; /* see PCF_xxx */ + int column; /* column of chunk */ + int column_indent; /* if 1st on a line, set to the 'indent' + * column, which may be less that the real column */ + int nl_count; /* number of newlines in CT_NEWLINE */ + int level; /* nest level in {, (, or [ */ + int brace_level; /* nest level in braces only */ + int pp_level; /* nest level in #if stuff */ + bool after_tab; /* whether this token was after a tab */ + int len; /* # of bytes at str that make up the token */ + const char *str; /* pointer to the token text */ +}; + +enum +{ + LANG_C = 0x0001, + LANG_CPP = 0x0002, + LANG_D = 0x0004, + LANG_CS = 0x0008, /*<< C# or C-sharp */ + LANG_JAVA = 0x0010, + LANG_OC = 0x0020, /*<< Objective C */ + LANG_VALA = 0x0040, /*<< Like C# */ + LANG_PAWN = 0x0080, + LANG_ECMA = 0x0100, + + LANG_ALLC = 0x017f, + LANG_ALL = 0x0fff, + + FLAG_PP = 0x8000, /*<< only appears in a preprocessor */ +}; + +/** + * Pattern classes for special keywords + */ +enum pattern_class +{ + PATCLS_NONE, + PATCLS_BRACED, // keyword + braced stmt: do, try + PATCLS_PBRACED, // keyword + parens + braced stmt: switch, if, for, while + PATCLS_OPBRACED, // keyword + optional parens + braced stmt: catch, version + PATCLS_VBRACED, // keyword + value + braced stmt: namespace + PATCLS_PAREN, // keyword + parens: while-of-do + PATCLS_OPPAREN, // keyword + optional parens: invariant (D lang) + PATCLS_ELSE, // Special case of PATCLS_BRACED for handling CT_IF +}; + +typedef struct +{ + const char *tag; + c_token_t type; + int lang_flags; +} chunk_tag_t; + +typedef struct +{ + char ch; + char left_in_group; + UINT16 next_idx; + const chunk_tag_t *tag; +} lookup_entry_t; + +typedef struct +{ + const char *tag; + const char *value; +} define_tag_t; + + +struct align_t +{ + int col; + c_token_t type; + int len; // of the token + space +}; + +typedef struct +{ + chunk_t *pc; + int seqnum; +} chunk_stack_entry_t; + +typedef struct chunk_stack +{ + chunk_stack_entry_t *cse; + int len; + int size; +} chunk_stack_t; + +struct file_mem +{ + char *data; + int length; +#ifdef HAVE_UTIME_H + struct utimbuf utb; +#endif +}; + +struct cp_data +{ + FILE *fout; + + UINT32 error_count; + const char *filename; + + file_mem file_hdr; /* for cmt_insert_file_header */ + file_mem file_ftr; /* for cmt_insert_file_footer */ + file_mem func_hdr; /* for cmt_insert_func_header */ + file_mem class_hdr; /* for cmt_insert_class_header */ + + int lang_flags; // LANG_xxx + + bool unc_off; + UINT32 line_number; + UINT16 column; /* column for parsing */ + + /* stuff to auto-detect line endings */ + UINT32 le_counts[LE_AUTO]; + char newline[5]; + + bool consumed; + + int did_newline; + c_token_t in_preproc; + int preproc_ncnl_count; + + chunk_t *bom; + + /* bumped up when a line is split or indented */ + int changes; + + struct align_t al[80]; + int al_cnt; + bool al_c99_array; + + /* Here are all the settings */ + op_val_t settings[UO_option_count]; + int max_option_name_len; + + struct parse_frame frames[16]; + int frame_count; + int pp_level; +}; + +extern struct cp_data cpd; + +#endif /* UNCRUSTIFY_TYPES_H_INCLUDED */ diff --git a/src/uncrustify_version.h b/src/uncrustify_version.h new file mode 100644 index 0000000000..cdfdc456f9 --- /dev/null +++ b/src/uncrustify_version.h @@ -0,0 +1,14 @@ +/** + * @file uncrustify_version.h + * Simply defines UNCRUSTIFY_VERSION. + * I don't particularly like how autoconf and friends handle the version... + * + * @author Ben Gardner + * @license GPL v2+ + */ +#ifndef UNCRUSTIFY_VERSION_H_INCLUDED +#define UNCRUSTIFY_VERSION_H_INCLUDED + +#define UNCRUSTIFY_VERSION "0.54" + +#endif /* UNCRUSTIFY_VERSION_H_INCLUDED */ diff --git a/src/universalindentgui.cpp b/src/universalindentgui.cpp new file mode 100644 index 0000000000..e5cc8b1036 --- /dev/null +++ b/src/universalindentgui.cpp @@ -0,0 +1,256 @@ +/** + * @file universalindentgui.cpp + * Exports the config file for UniversalIndentGUI + */ +#include "prototypes.h" +#include "uncrustify_version.h" +#include "unc_ctype.h" +#include + + + +void print_universal_indent_cfg(FILE *pfile) +{ + const group_map_value *p_grp; + const char *p_name; + + /* Dump the header and the categories */ + fprintf(pfile, "[header]\n"); + + /* Add all the categories */ + char ch = '='; + int idx; + + fprintf(pfile, "categories"); + for (idx = 0; idx < UG_group_count; idx++) + { + p_grp = get_group_name(idx); + if (p_grp != NULL) + { + fprintf(pfile, "%c%s", ch, p_grp->short_desc); + ch = '|'; + } + } + fprintf(pfile, "\n"); + + fprintf(pfile, + "cfgFileParameterEnding=cr\n" + "configFilename=uncrustify.cfg\n"); + + + /* Add all the recognized file extensions */ + ch = '='; + idx = 0; + fprintf(pfile, "fileTypes"); + while ((p_name = get_file_extension(idx)) != NULL) + { + fprintf(pfile, "%c*%s", ch, p_name); + ch = '|'; + } + fprintf(pfile, "\n"); + + /* Add the rest of the constant file header */ + fprintf(pfile, + "indenterFileName=uncrustify\n" + "indenterName=Uncrustify (C, C++, C#, ObjectiveC, D, Java, Pawn, VALA)\n" + "inputFileName=indentinput\n" + "inputFileParameter=\"-f \"\n" + "manual=http://uncrustify.sourceforge.net/config.txt\n" + "outputFileName=indentoutput\n" + "outputFileParameter=\"-o \"\n" + "stringparaminquotes=false\n" + "parameterOrder=ipo\n" + "showHelpParameter=-h\n" + "stringparaminquotes=false\n" + "useCfgFileParameter=\"-c \"\n" + "version=%s\n", + UNCRUSTIFY_VERSION); + + /* Now add each option */ + for (idx = 0; idx < UG_group_count; idx++) + { + p_grp = get_group_name(idx); + if (p_grp == NULL) + { + continue; + } + + for (option_list_cit it = p_grp->options.begin(); it != p_grp->options.end(); it++) + { + const option_map_value *option = get_option_name(*it); + + // Create a better readable name from the options name + // by replacing '_' by a space and use some upper case characters. + char *optionNameReadable = new char[strlen(option->name) + 1]; + strcpy(optionNameReadable, option->name); + + bool was_space = true; + for (char *character = optionNameReadable; *character != 0; character++) + { + if (*character == '_') + { + *character = ' '; + was_space = true; + } + else if (was_space) + { + *character = unc_toupper(*character); + was_space = false; + } + } + + fprintf(pfile, "\n[%s]\n", optionNameReadable); + fprintf(pfile, "Category=%d\n", idx); + fprintf(pfile, "Description=\""); + + const char *tmp = option->short_desc; + ch = 0; + + /* Output the decription which may contain forbidden chars */ + while (*tmp != 0) + { + switch (*tmp) + { + case '<': + fprintf(pfile, "<"); + break; + + case '>': + fprintf(pfile, ">"); + break; + + case '&': + fprintf(pfile, "&"); + break; + + case '\n': + fprintf(pfile, "
"); + break; + + default: + fputc(*tmp, pfile); + } + tmp++; + } + + fprintf(pfile, "\"\n"); + + + // Handle some options independent of their type and most by their type. + switch (option->id) + { + // Indenting with tabs selector becomes a multiple selector and not only a number. Also its default enabled. + case UO_indent_with_tabs: + fprintf(pfile, "Enabled=true\n"); + fprintf(pfile, "EditorType=multiple\n"); + fprintf(pfile, "Choices=\"%s=0|%s=1|%s=2\"\n", option->name, option->name, option->name); + fprintf(pfile, "ChoicesReadable=\"Spaces only|Indent with tabs, align with spaces|Indent and align with tabs\"\n"); + fprintf(pfile, "ValueDefault=%d\n", cpd.settings[option->id].n); + break; + + // All not specially handled options are created only dependent by their type. + default: + fprintf(pfile, "Enabled=false\n"); + switch (option->type) + { + case AT_BOOL: + // [align_keep_tabs] + // Category=3 + // Description=Whether to keep non-indenting tabs + // Value=0 + // ValueDefault=0 + // EditorType=boolean + // TrueFalse="align_keep_tabs=true|align_keep_tabs=false" + fprintf(pfile, "EditorType=boolean\n"); + fprintf(pfile, "TrueFalse=%s=true|%s=false\n", option->name, option->name); + fprintf(pfile, "ValueDefault=%d\n", cpd.settings[option->id].n); + break; + + case AT_IARF: + fprintf(pfile, "EditorType=multiple\n"); + fprintf(pfile, "Choices=\"%s=ignore|%s=add|%s=remove|%s=force\"\n", + option->name, option->name, option->name, option->name); + fprintf(pfile, "ChoicesReadable=\"Ignore %s|Add %s|Remove %s|Force %s\"\n", + optionNameReadable, optionNameReadable, optionNameReadable, optionNameReadable); + fprintf(pfile, "ValueDefault=%d\n", cpd.settings[option->id].n); + // [nl_after_switch] + // Category=4 + // Description=Add or remove newline after 'switch' + // Value=3 + // ValueDefault=-1 + // Enabled=true + // EditorType=multiple + // Choices="nl_after_switch=ignore|nl_after_switch=add|nl_after_switch=remove|nl_after_switch=force" + break; + + case AT_NUM: + // [align_assign_span] + // CallName="align_assign_span=" + // Category=3 + // Description="The span for aligning on '=' in assignments (0=don't align)" + // EditorType=numeric + // Enabled=false + // MaxVal=300 + // MinVal=0 + // Value=0 + // ValueDefault=0 + fprintf(pfile, "EditorType=numeric\n"); + fprintf(pfile, "CallName=\"%s=\"\n", option->name); + fprintf(pfile, "MinVal=%d\n", option->min_val); + fprintf(pfile, "MaxVal=%d\n", option->max_val); + fprintf(pfile, "ValueDefault=%d\n", cpd.settings[option->id].n); + break; + + case AT_LINE: + // [newlines] + // Category=0 + // Description=The type of line endings + // Value=0 + // ValueDefault=-1 + // Enabled=true + // EditorType=multiple + // Choices="newlines=auto|newlines=lf|newlines=crlf|newlines=cr" + fprintf(pfile, "EditorType=multiple\n"); + fprintf(pfile, "Choices=\"%s=lf|%s=crlf|%s=cr|%s=auto\"\n", + option->name, option->name, option->name, option->name); + fprintf(pfile, "ChoicesReadable=\"Newlines Mac|Newlines Win|Newlines Unix|Newlines Auto\"\n"); + fprintf(pfile, "ValueDefault=%d\n", cpd.settings[option->id].n); + break; + + case AT_POS: + // [pos_bool] + // Category=5 + // Description=The position of boolean operators in wrapped expressions + // Enabled=false + // Value=0 + // ValueDefault=-1 + // EditorType=multiple + // Choices="pos_bool=ignore|pos_bool=lead|pos_bool=trail" + fprintf(pfile, "EditorType=multiple\n"); + fprintf(pfile, "Choices=\"%s=ignore|%s=lead|%s=trail\"\n", + option->name, option->name, option->name); + fprintf(pfile, "ChoicesReadable=\"Ignore %s|Lead %s|Trail %s\"\n", + optionNameReadable, optionNameReadable, optionNameReadable); + fprintf(pfile, "ValueDefault=%d\n", cpd.settings[option->id].n); + break; + + case AT_STRING: + { + fprintf(pfile, "CallName=%s=\n", option->name); + fprintf(pfile, "EditorType=string\n"); + std::string val_string; + const char *val_str; + val_string = op_val_to_string(option->type, cpd.settings[option->id]); + val_str = val_string.c_str(); + fprintf(pfile, "ValueDefault=%s\n", val_str); + } + break; + + default: + break; + } + } + delete [] optionNameReadable; + } + } +} diff --git a/src/width.cpp b/src/width.cpp new file mode 100644 index 0000000000..ce73e77d11 --- /dev/null +++ b/src/width.cpp @@ -0,0 +1,561 @@ +/** + * @file width.cpp + * Limits line width. + * + * @author Ben Gardner + * @license GPL v2+ + */ + +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" + +static void split_line(chunk_t *pc); +static void split_fcn_params(chunk_t *start); +static void split_fcn_params_full(chunk_t *start); +static void split_for_stmt(chunk_t *start); + +static_inline bool is_past_width(chunk_t *pc) +{ + return((pc->column + pc->len) > cpd.settings[UO_code_width].n); +} + + +/** + * Split right after the chunk + */ +static void split_before_chunk(chunk_t *pc) +{ + LOG_FMT(LSPLIT, "%s: %.*s\n", __func__, pc->len, pc->str); + + if (!chunk_is_newline(pc) && + !chunk_is_newline(chunk_get_prev(pc))) + { + newline_add_before(pc); + reindent_line(pc, pc->brace_level * cpd.settings[UO_indent_columns].n); + cpd.changes++; + } +} + + +/** + * Step forward until a token goes beyond the limit and then call split_line() + * to split the line at or before that point. + */ +void do_code_width(void) +{ + chunk_t *pc; + + LOG_FMT(LSPLIT, "%s\n", __func__); + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (!chunk_is_newline(pc) && + !chunk_is_comment(pc) && + (pc->type != CT_SPACE) && + is_past_width(pc)) + { + split_line(pc); + } + } +} + + +struct cw_entry +{ + chunk_t *pc; + int pri; +}; + +struct token_pri +{ + c_token_t tok; + int pri; +}; + +static const token_pri pri_table[] = +{ + { CT_SEMICOLON, 1 }, + { CT_COMMA, 2 }, + { CT_BOOL, 3 }, + { CT_COMPARE, 4 }, + { CT_ARITH, 5 }, + { CT_ASSIGN, 6 }, + //{ CT_DC_MEMBER, 10 }, + //{ CT_MEMBER, 10 }, +}; + + +static int get_split_pri(c_token_t tok) +{ + int idx; + + for (idx = 0; idx < (int)ARRAY_SIZE(pri_table); idx++) + { + if (pri_table[idx].tok == tok) + { + return(pri_table[idx].pri); + } + } + return(0); +} + + +/** + * Checks to see if pc is a better spot to split. + * This should only be called going BACKWARDS (ie prev) + * A lower level wins + * + * Splitting Preference: + * - semicolon + * - comma + * - boolean op + * - comparison + * - arithmetic op + * - assignment + */ +static void try_split_here(cw_entry& ent, chunk_t *pc) +{ + chunk_t *prev; + int pc_pri = get_split_pri(pc->type); + + if (pc_pri == 0) + { + return; + } + + /* Can't split after a newline */ + prev = chunk_get_prev(pc); + if ((prev == NULL) || chunk_is_newline(prev)) + { + return; + } + + /* Check levels first */ + bool change = false; + if ((ent.pc == NULL) || (pc->level < ent.pc->level)) + { + change = true; + } + else + { + if ((pc->level > ent.pc->level) && + (pc_pri <= ent.pri)) + { + change = true; + } + } + + if (change) + { + ent.pc = pc; + ent.pri = pc_pri; + } +} + + +/** + * Scan backwards to find the most appropriate spot to split the line + * and insert a newline. + * + * See if this needs special function handling. + * Scan backwards and find the best token for the split. + * + * @param start The first chunk that exceeded the limit + */ +static void split_line(chunk_t *start) +{ + LOG_FMT(LSPLIT, "%s: line %d, col %d token:%.*s[%s] (IN_FUNC=%d) ", + __func__, start->orig_line, start->column, start->len, start->str, + get_token_name(start->type), + (start->flags & (PCF_IN_FCN_DEF | PCF_IN_FCN_CALL)) != 0); + + /* Don't break before a close, comma, or colon */ + if ((start->type == CT_PAREN_CLOSE) || + (start->type == CT_PAREN_OPEN) || + (start->type == CT_FPAREN_CLOSE) || + (start->type == CT_FPAREN_OPEN) || + (start->type == CT_SPAREN_CLOSE) || + (start->type == CT_SPAREN_OPEN) || + (start->type == CT_ANGLE_CLOSE) || + (start->type == CT_BRACE_CLOSE) || + (start->type == CT_COMMA) || + (start->type == CT_SEMICOLON) || + (start->type == CT_VSEMICOLON) || + (start->len == 0)) + { + LOG_FMT(LSPLIT, " ** NO GO **\n"); + + /*TODO: Add in logic to handle 'hard' limits by backing up a token */ + return; + } + + /* Check to see if we are in a for statment */ + if ((start->flags & PCF_IN_FOR) != 0) + { + LOG_FMT(LSPLIT, " ** FOR SPLIT **\n"); + split_for_stmt(start); + if (!is_past_width(start)) + { + return; + } + LOG_FMT(LSPLIT, "%s: for split didn't work\n", __func__); + } + + /* If this is in a function call or prototype, split on commas or right + * after the open paren + */ + else if (((start->flags & PCF_IN_FCN_DEF) != 0) || + ((start->level == (start->brace_level + 1)) && + ((start->flags & PCF_IN_FCN_CALL) != 0))) + { + LOG_FMT(LSPLIT, " ** FUNC SPLIT **\n"); + + if (cpd.settings[UO_ls_func_split_full].b) + { + split_fcn_params_full(start); + if (!is_past_width(start)) + { + return; + } + } + split_fcn_params(start); + if (!is_past_width(start)) + { + return; + } + LOG_FMT(LSPLIT, "%s: func split didn't work\n", __func__); + } + + /** + * Try to find the best spot to split the line + */ + cw_entry ent; + + memset(&ent, 0, sizeof(ent)); + chunk_t *pc = start; + chunk_t *prev; + + while (((pc = chunk_get_prev(pc)) != NULL) && !chunk_is_newline(pc)) + { + if (pc->type != CT_SPACE) + { + try_split_here(ent, pc); + } + } + + if (ent.pc == NULL) + { + LOG_FMT(LSPLIT, "%s: TRY_SPLIT yielded NO SOLUTION for line %d at %.*s [%s]\n", + __func__, start->orig_line, start->len, start->str, get_token_name(start->type)); + } + else + { + LOG_FMT(LSPLIT, "%s: TRY_SPLIT yielded '%.*s' [%s] on line %d\n", __func__, + ent.pc->len, ent.pc->str, get_token_name(ent.pc->type), ent.pc->orig_line); + } + + /* Break before the token instead of after it according to the pos_xxx rules */ + if ((chunk_is_token(ent.pc, CT_ARITH) && + (cpd.settings[UO_pos_arith].tp == TP_LEAD)) || + (chunk_is_token(ent.pc, CT_ASSIGN) && + (cpd.settings[UO_pos_assign].tp == TP_LEAD)) || + (chunk_is_token(ent.pc, CT_COMPARE) && + (cpd.settings[UO_pos_compare].tp == TP_LEAD)) || + ((chunk_is_token(ent.pc, CT_COND_COLON) || + chunk_is_token(ent.pc, CT_QUESTION)) && + (cpd.settings[UO_pos_compare].tp == TP_LEAD)) || + (chunk_is_token(ent.pc, CT_BOOL) && + (cpd.settings[UO_pos_bool].tp == TP_LEAD))) + { + pc = ent.pc; + } + else + { + pc = chunk_get_next(ent.pc); + } + if (pc == NULL) + { + pc = start; + } + + /* add a newline before pc */ + prev = chunk_get_prev(pc); + if ((prev != NULL) && !chunk_is_newline(pc) && !chunk_is_newline(prev)) + { + int plen = (pc->len < 5) ? pc->len : 5; + int slen = (start->len < 5) ? start->len : 5; + LOG_FMT(LSPLIT, " '%.*s' [%s], started on token '%.*s' [%s]\n", + plen, pc->str, get_token_name(pc->type), + slen, start->str, get_token_name(start->type)); + + split_before_chunk(pc); + } +} + + +/** + * A for statment is too long. + * Step backwards and forwards to find the semicolons + * Try splitting at the semicolons first. + * If that doesn't work, then look for a comma at paren level. + * If that doesn't work, then look for an assignment at paren level. + * If that doesn't work, then give up. + */ +static void split_for_stmt(chunk_t *start) +{ + int count = 0; + int max_cnt = cpd.settings[UO_ls_for_split_full].b ? 2 : 1; + chunk_t *st[2]; + chunk_t *pc; + chunk_t *open_paren = NULL; + int nl_cnt = 0; + + LOG_FMT(LSPLIT, "%s: starting on %.*s, line %d\n", + __func__, start->len, start->str, start->orig_line); + + /* Find the open paren so we know the level and count newlines */ + pc = start; + while ((pc = chunk_get_prev(pc)) != NULL) + { + if (pc->type == CT_SPAREN_OPEN) + { + open_paren = pc; + break; + } + if (pc->nl_count > 0) + { + nl_cnt += pc->nl_count; + } + } + if (open_paren == NULL) + { + LOG_FMT(LSYS, "No open paren\n"); + return; + } + + /* see if we started on the semicolon */ + pc = start; + if ((pc->type == CT_SEMICOLON) && (pc->parent_type == CT_FOR)) + { + st[count++] = pc; + } + + /* first scan backwards for the semicolons */ + while ((count < max_cnt) && ((pc = chunk_get_prev(pc)) != NULL) && + (pc->flags & PCF_IN_SPAREN)) + { + if ((pc->type == CT_SEMICOLON) && (pc->parent_type == CT_FOR)) + { + st[count++] = pc; + } + } + + /* And now scan forward */ + pc = start; + while ((count < max_cnt) && ((pc = chunk_get_next(pc)) != NULL) && + (pc->flags & PCF_IN_SPAREN)) + { + if ((pc->type == CT_SEMICOLON) && (pc->parent_type == CT_FOR)) + { + st[count++] = pc; + } + } + + while (--count >= 0) + { + LOG_FMT(LSPLIT, "%s: split before %.*s\n", __func__, st[count]->len, st[count]->str); + split_before_chunk(chunk_get_next(st[count])); + } + + if (!is_past_width(start) || (nl_cnt > 0)) + { + return; + } + + /* Still past width, check for commas at paren level */ + pc = open_paren; + while ((pc = chunk_get_next(pc)) != start) + { + if ((pc->type == CT_COMMA) && (pc->level == (open_paren->level + 1))) + { + split_before_chunk(chunk_get_next(pc)); + if (!is_past_width(pc)) + { + return; + } + } + } + + /* Still past width, check for a assignments at paren level */ + pc = open_paren; + while ((pc = chunk_get_next(pc)) != start) + { + if ((pc->type == CT_ASSIGN) && (pc->level == (open_paren->level + 1))) + { + split_before_chunk(chunk_get_next(pc)); + if (!is_past_width(pc)) + { + return; + } + } + } + /* Oh, well. We tried. */ +} + + +/** + * Splits the parameters at every comma that is at the fparen level. + * + * @param start the offending token + */ +static void split_fcn_params_full(chunk_t *start) +{ + LOG_FMT(LSPLIT, "%s", __func__); + + chunk_t *fpo; + chunk_t *pc; + + /* Find the opening fparen */ + fpo = start; + while (((fpo = chunk_get_prev(fpo)) != NULL) && + (fpo->type != CT_FPAREN_OPEN)) + { + /* do nothing */ + } + + /* Now break after every comma */ + pc = fpo; + while ((pc = chunk_get_next_ncnl(pc)) != NULL) + { + if (pc->level <= fpo->level) + { + break; + } + if ((pc->level == (fpo->level + 1)) && (pc->type == CT_COMMA)) + { + split_before_chunk(chunk_get_next(pc)); + } + } +} + + +/** + * Figures out where to split a function def/proto/call + * + * For fcn protos and defs. Also fcn calls where level == brace_level: + * - find the open fparen + * + if it doesn't have a newline right after it + * * see if all parameters will fit individually after the paren + * * if not, throw a newline after the open paren & return + * - scan backwards to the open fparen or comma + * + if there isn't a newline after that item, add one & return + * + otherwise, add a newline before the start token + * + * @param start the offending token + * @return the token that should have a newline + * inserted before it + */ +static void split_fcn_params(chunk_t *start) +{ + LOG_FMT(LSPLIT, " %s: ", __func__); + + chunk_t *prev; + chunk_t *fpo; + chunk_t *pc; + + /* Find the opening fparen */ + fpo = start; + while (((fpo = chunk_get_prev(fpo)) != NULL) && + (fpo->type != CT_FPAREN_OPEN)) + { + /* do nothing */ + } + + pc = chunk_get_next(fpo); + if (!chunk_is_newline(pc)) + { + int min_col = pc->column; + int max_width = 0; + int cur_width = 0; + int last_col = -1; + + LOG_FMT(LSPLIT, " mincol=%d, max_width=%d ", + min_col, + cpd.settings[UO_code_width].n - min_col); + + while (pc != NULL) + { + if (chunk_is_newline(pc)) + { + last_col = -1; + } + else + { + if (last_col < 0) + { + last_col = pc->column; + } + cur_width += (pc->column - last_col) + pc->len; + last_col = pc->column + pc->len; + + if ((pc->type == CT_COMMA) || + (pc->type == CT_FPAREN_CLOSE)) + { + cur_width--; + LOG_FMT(LSPLIT, " width=%d ", cur_width); + if (cur_width > max_width) + { + max_width = cur_width; + if ((max_width + min_col) > cpd.settings[UO_code_width].n) + { + break; + } + } + cur_width = 0; + last_col = -1; + if (pc->type == CT_FPAREN_CLOSE) + { + break; + } + } + } + pc = chunk_get_next(pc); + } + + if ((max_width + min_col) > cpd.settings[UO_code_width].n) + { + LOG_FMT(LSPLIT, " - A param won't fit, nl after open paren."); + split_before_chunk(chunk_get_next(fpo)); + return; + } + } + + /* back up until the prev is a comma */ + prev = pc; + while ((prev = chunk_get_prev(prev)) != NULL) + { + if (chunk_is_newline(prev) || + (prev->type == CT_COMMA)) + { + break; + } + if (prev->type == CT_FPAREN_OPEN) + { + /* Don't split "()" */ + pc = chunk_get_next(prev); + if (pc->type != c_token_t(prev->type + 1)) + { + break; + } + } + } + if (prev != NULL) + { + LOG_FMT(LSPLIT, " -- ended on [%s] -- ", get_token_name(prev->type)); + } + if (prev != NULL) + { + split_before_chunk(chunk_get_next(prev)); + } +} diff --git a/tests/c-sharp.test b/tests/c-sharp.test new file mode 100644 index 0000000000..a111fdf537 --- /dev/null +++ b/tests/c-sharp.test @@ -0,0 +1,26 @@ +# +# Test cases specifically for the C# language. +# $Id: c-sharp.test 1526 2009-03-30 02:11:29Z bengardner $ +# +# test.name config.file input.file + +10000 mono.cfg cs/simple.cs +10001 getset.cfg cs/getset.cs +10002 ben.cfg cs/simple.cs +10003 ben.cfg cs/region.cs +10010 ben.cfg cs/var-member.cs +10011 ben.cfg cs/strings.cs + +10020 region-0.cfg cs/region.cs +10021 region-1.cfg cs/region.cs +10022 region-2.cfg cs/region.cs +10023 region-3.cfg cs/region.cs + +10030 sort_imports.cfg cs/sort_using.cs + +10040 tcf.cfg cs/tcf.cs +10041 tcf.cfg cs/gs.cs + +10050 cs_generics.cfg cs/generics.cs + +10060 ben.cfg cs/unsafe.cs diff --git a/tests/c.test b/tests/c.test new file mode 100644 index 0000000000..6d55ce5cd3 --- /dev/null +++ b/tests/c.test @@ -0,0 +1,258 @@ +# +# Test cases specifically for the C language. +# $Id: c.test 1630 2009-10-10 17:18:35Z bengardner $ +# +# test.name config.file input.file + + +# little general tests + +00000 indent.cfg c/comment-indent.c +00001 cpp_to_c-1.cfg c/comment-indent.c +00002 cpp_to_c-2.cfg c/comment-indent.c +00003 cpp_to_c-3.cfg c/comment-indent.c + +00004 indent-1.cfg c/switch.c + +00005 ben.cfg c/cmt-align.c + +00006 indent.cfg c/comment-convert.c +00007 cpp_to_c-1.cfg c/comment-convert.c +00008 cpp_to_c-2.cfg c/comment-convert.c +00009 cpp_to_c-3.cfg c/comment-convert.c + +# brace styles +00010 ben.cfg c/braces.c +00011 brace-allman.cfg c/braces.c +00012 brace-banner.cfg c/braces.c +00013 brace-gnu.cfg c/braces.c +00014 brace-kr.cfg c/braces.c +00015 brace-ws.cfg c/braces.c +00016 brace-ws2.cfg c/braces.c + +00020 ben.cfg c/define-if-indent.c +00050 brace-remove-2.cfg c/brace-remove.c +00051 brace-remove-all.cfg c/brace-remove.c +00052 brace-remove-all.cfg c/brace-remove2.c +00053 nl_brace_test.cfg c/brace.c +00054 if_chain.cfg c/if_chain.c +00055 cgal.cfg c/braces-2.c + +00060 ben.cfg c/braces-2.c +00061 ben.cfg c/braces-3.c +00062 ben.cfg c/braces-4.c +00065 ben.cfg c/braces-5.c +00066 ben.cfg c/vb-while.c +00067 ben.cfg c/vb-do.c +00068 ben.cfg c/bsnl.c +00069 ben.cfg c/vb-pp.c + +00070 ben.cfg c/return-multi.c +00071 ben.cfg c/include_define.h +00072 star_pos-0.cfg c/align-proto.c +00073 ben.cfg c/nl_proto_endif.c + +00081 else-if-1.cfg c/else-if.c +00082 else-if-2.cfg c/else-if.c + +00091 cond-1.cfg c/cond.c +00092 cond-2.cfg c/cond.c + +00101 ben.cfg c/bugs-1.c +00102 ben.cfg c/bugs-2.c +00103 ben.cfg c/bugs-3.c +00104 ben.cfg c/bugs-4.c +00105 ben.cfg c/bugs-5.c +00106 ben.cfg c/bugs-6.c +00107 ben.cfg c/bugs-7.c +00108 ben.cfg c/bugs-8.c + +00110 ben.cfg c/misc.c +00111 brace-kr-br.cfg c/misc.c + +00120 sp_cmt_cpp_start_remove.cfg c/sp_cmt_cpp_start.c +00121 sp_cmt_cpp_start_add.cfg c/sp_cmt_cpp_start.c +00122 sp_cmt_cpp_start_force.cfg c/sp_cmt_cpp_start.c + +00130 ben.cfg c/minus-minus.c + +00140 ben.cfg c/global-vars.c +00141 ben.cfg c/deref.c +00142 ben.cfg c/type-cast.c +00143 ben.cfg c/t3.in.c +00144 ben.cfg c/align-proto-vars.c + +# casts +00150 ben.cfg c/casts.c +00151 cast-sp-r.cfg c/casts.c +00152 cast-sp-a.cfg c/casts.c +00153 cast-type.cfg c/casts.c +00154 sp_after_cast.cfg c/casts.c + +# fcn indents +00160 indent_func_param.cfg c/fcn_indent.c +00161 indent_func_call_param.cfg c/fcn_indent.c +00162 indent_func_def_param.cfg c/fcn_indent.c +00163 indent_func_proto_param.cfg c/fcn_indent.c + +00170 /dev/null c/beautifier-off.c + +# switch & case stuff +00201 case-1.cfg c/case.c +00202 case-2.cfg c/case.c +00203 case-3.cfg c/case.c + +# structure initializers +00301 ben.cfg c/align-struct-init.c +00302 ben.cfg c/one-liner-init.c +00303 1liner-split.cfg c/one-liner-init.c +00304 1liner-no-split.cfg c/one-liner-init.c + +00310 /dev/null c/sp_embed_comment.c + +# aligning tresholds +00401 align-1.cfg c/align-equ.c +00402 align-1.cfg c/align-var.c +00403 align-2.cfg c/align-var.c +00404 align-3.cfg c/align-var.c +00405 align-3.cfg c/bits.c + +00411 ben.cfg c/align-typedef.c +00412 align_typedef_func-0.cfg c/align-typedef.c +00413 align_typedef_func-1.cfg c/align-typedef.c +00414 align_typedef_func-2.cfg c/align-typedef.c + +00421 nl_ds_struct_enum-1.cfg c/nl_ds_struct_enum.c +00422 nl_ds_struct_enum-2.cfg c/nl_ds_struct_enum.c + +00430 indent_paren_close-0.cfg c/paren-indent.c +00431 indent_paren_close-1.cfg c/paren-indent.c +00432 indent_paren_close-2.cfg c/paren-indent.c + +# boolean and comma positioning +00501 bool-pos-eol.cfg c/bool-pos.c +00502 bool-pos-sol.cfg c/bool-pos.c +00503 pos_compare-sol.cfg c/pos_compare.c +00504 pos_compare-eol.cfg c/pos_compare.c +00505 pos_conditional-sol.cfg c/pos_conditional.c +00506 pos_conditional-eol.cfg c/pos_conditional.c + +00600 indent.cfg c/dos.c +00601 indent.cfg c/mac.c +00611 pp-indent-1.cfg c/pp-space.c +00612 pp-indent-2.cfg c/pp-space.c +00613 pp-indent-3.cfg c/pp-space.c +00614 pp-space.cfg c/pp-space.c + +00615 pp-indent-2.cfg c/pp-nest.c + +00620 ben.cfg c/indent-assign.c +00621 nl_endif.cfg c/nl_endif.c + +00631 nl_assign1.cfg c/nl_assign.c +00632 nl_assign2.cfg c/nl_assign.c + +# function def newlines +00701 func-def-1.cfg c/function-def.c +00702 func-def-2.cfg c/function-def.c +00703 func-def-3.cfg c/function-def.c + +00710 add_long_closebrace_comment_1.cfg c/add_long_comment.c + +# nl_after_semicolon and nl_after_open_brace +00721 nl_semicolon.cfg c/nl-semicolon.c + +# function types +00801 ben.cfg c/fcn_type.c +00802 ben.cfg c/funcfunc.c + +# code width +00901 width.cfg c/code_width.c +00902 width-2.cfg c/code_width.c +00903 width-3.cfg c/code_width.c + +# pascal ptr_type +00910 pascal_ptr.cfg c/pascal_ptr.c +00911 empty_body.cfg c/pascal_ptr.c + +01000 mod-paren.cfg c/mod-paren.c +01001 nl-comment.cfg c/nl-comment.c +01002 mod-paren2.cfg c/mod-paren.c + +01005 mod_case_brace_add.cfg c/mod_case_brace.c +01006 mod_case_brace_rm.cfg c/mod_case_brace.c + +01011 del_semicolon.cfg c/semicolons.c +01012 ben.cfg c/semicolons.c + +01015 /dev/null c/paren_indent.c +01016 align_attr.cfg c/align_attr.c + +01020 kw_subst.cfg c/kw_subst.c +01021 kw_subst3.cfg c/hello.c +01022 kw_subst3.cfg c/kw_subst.c + +01030 multi.cfg c/multi.h + +01035 func_wrap1.cfg c/func_wrap.c +01036 func_wrap2.cfg c/func_wrap.c +01037 type_wrap.cfg c/type_wrap.c + +01040 newline_after_endif.cfg c/newline_after_endif.c + +01050 func_call_user.cfg c/func_call_user.c + +# big general tests +20000 ben.cfg c/i2c-core.c +20001 preproc-cleanup.cfg c/directfb.h + +# clark's style - blank lines before and after flow control, indented comments +20100 clark.cfg c/i2c-core.c +20101 clark.cfg c/comment-indent.c +20102 clark.cfg c/indent.cpp +20103 clark.cfg c/output.cpp + +20200 xml-str.cfg c/xml.c +20201 xml-str.cfg c/align-string.c + +20300 ben.cfg c/preproc-if.c +20301 d.cfg c/preproc-if.c +20302 cpp_to_c-1.cfg c/nl-cont.c +20303 cpp_to_c-1.cfg c/nl-cont2.c + +20310 ben.cfg c/empty-for.c +20311 ben.cfg c/pragma.c + +20315 pp_ret.cfg c/pp_ret.c + +20320 nl_create_one_liner.cfg c/nl_create_one_liner.c +20325 sort_imports.cfg c/sort_include.c + +# some embedded sql stuff +21000 ben.cfg sql/mysql.sqc +21001 ben.cfg sql/sta-select.sqc + + +21010 pp_if_indent-0.cfg c/ifdef-indent.c +21011 pp_if_indent-1.cfg c/ifdef-indent.c +21012 pp_if_indent-2.cfg c/ifdef-indent.c +21013 pp_if_indent-3.cfg c/ifdef-indent.c + +21015 endif.cfg c/endif.c +21016 cmt_nl_end.cfg c/cmt_nl_end.c + +21021 cmt_multi-1.cfg c/cmt_multi.c +21022 cmt_multi-2.cfg c/cmt_multi.c + +21031 align_right_cmt_gap-1.cfg c/cmt_right_align.c +21032 align_right_cmt_gap-2.cfg c/cmt_right_align.c + +21051 return-1.cfg c/nl_return_expr.c +21052 return-2.cfg c/nl_return_expr.c +21053 return-3.cfg c/nl_return_expr.c +21054 return-4.cfg c/nl_return_expr.c + +66601 ger.cfg c/custom_types_ssl.c +66602 custom_types_ssl.cfg c/custom_types_ssl.c +66603 ger.cfg c/pp_concat_asn1.h + diff --git a/tests/config/1liner-no-split.cfg b/tests/config/1liner-no-split.cfg new file mode 100644 index 0000000000..7106d58ea4 --- /dev/null +++ b/tests/config/1liner-no-split.cfg @@ -0,0 +1,523 @@ +# +# My favorite format ("--update-config-with-doc") +# +# $Id: 1liner-split.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 3 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 0 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = force # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +align_func_params = true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 1 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 12 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = true # false/true +nl_assign_leave_one_liners = true +nl_enum_leave_one_liners = true +nl_func_leave_one_liners = true +nl_if_leave_one_liners = true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force + +nl_getset_brace = force + +mod_full_paren_if_bool = true + +sp_before_semi_for_empty = force + diff --git a/tests/config/1liner-split.cfg b/tests/config/1liner-split.cfg new file mode 100644 index 0000000000..4e8244fccf --- /dev/null +++ b/tests/config/1liner-split.cfg @@ -0,0 +1,523 @@ +# +# My favorite format ("--update-config-with-doc") +# +# $Id: 1liner-split.cfg 933 2007-09-25 19:05:30Z bengardner $ +# + + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 3 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 0 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +align_func_params = true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 1 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 12 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = true # false/true +nl_assign_leave_one_liners = false +nl_enum_leave_one_liners = false +nl_func_leave_one_liners = false + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true +nl_after_vbrace_open = true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +#mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +# mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +# mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +# mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +# mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +# mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +# mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +# mod_pawn_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force + +nl_getset_brace = force + +mod_full_paren_if_bool = true + +sp_before_semi_for_empty = force + diff --git a/tests/config/add_long_closebrace_comment_1.cfg b/tests/config/add_long_closebrace_comment_1.cfg new file mode 100644 index 0000000000..5827edf6e2 --- /dev/null +++ b/tests/config/add_long_closebrace_comment_1.cfg @@ -0,0 +1,3 @@ +mod_add_long_switch_closebrace_comment = 8 +mod_add_long_function_closebrace_comment = 8 + diff --git a/tests/config/al.cfg b/tests/config/al.cfg new file mode 100644 index 0000000000..6d9e1a16d1 --- /dev/null +++ b/tests/config/al.cfg @@ -0,0 +1,924 @@ +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 4 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 4 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 4 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = false # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 4 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 4 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 4 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 4 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 1 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = force # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = true # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = remove # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = force # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = remove # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = remove # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = remove # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = force # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = force # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = force # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = force # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = force # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = force # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = force # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f: (int) x;' vs '+(int) f : (int) x;' +sp_before_oc_colon = force # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '+(int)f : (int)x;' +sp_after_oc_type = force # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 20 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 0 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 30 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 10 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 12 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 30 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 30 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 8 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 4 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 2 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 2 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_oc_msg_spec_span = 3 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 2 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 50 # number + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = force # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = force # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = add # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = true # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = add # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = remove # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = remove # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = true # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = true # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = add # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = add # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = add # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = add # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = add # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = add # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = add # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = add # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = add # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = add # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = true # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = true # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = trail # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 80 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = true # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = true # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 3 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 1 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 3 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 5 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 5 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 1 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 1 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 1 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = true # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = add # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 1 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 1 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 10 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_witdth columns +cmt_width = 80 # number + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = true # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 1 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = remove # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP + diff --git a/tests/config/align-1.cfg b/tests/config/align-1.cfg new file mode 100644 index 0000000000..0ab10280c7 --- /dev/null +++ b/tests/config/align-1.cfg @@ -0,0 +1,94 @@ +# +# My favorite format +# +# $Id: align-1.cfg 829 2007-08-02 00:44:09Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops + +align_enum_equ_span = 4 + +align_nl_cont = TRUE +align_func_params = FALSE +align_var_def_span = 2 +align_var_def_thresh = 16 +align_var_def_inline = TRUE +align_var_def_star_style = 0 +align_var_def_colon = TRUE +align_assign_span = 2 +align_assign_thresh = 3 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_var_struct_thresh = 16 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/tests/config/align-2.cfg b/tests/config/align-2.cfg new file mode 100644 index 0000000000..d5fec224ba --- /dev/null +++ b/tests/config/align-2.cfg @@ -0,0 +1,94 @@ +# +# My favorite format +# +# $Id: align-2.cfg 829 2007-08-02 00:44:09Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops + +align_enum_equ_span = 4 + +align_nl_cont = TRUE +align_func_params = TRUE +align_var_def_span = 2 +align_var_def_thresh = 16 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 2 +align_assign_thresh = 3 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_var_struct_thresh = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/tests/config/align-3.cfg b/tests/config/align-3.cfg new file mode 100644 index 0000000000..83dd528c2e --- /dev/null +++ b/tests/config/align-3.cfg @@ -0,0 +1,94 @@ +# +# My favorite format +# +# $Id: align-3.cfg 829 2007-08-02 00:44:09Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops + +align_enum_equ_span = 4 + +align_nl_cont = TRUE +align_func_params = TRUE +align_var_def_span = 1 +align_var_def_thresh = 16 +align_var_def_inline = TRUE +align_var_def_star_style = 2 +align_var_def_colon = TRUE +align_assign_span = 2 +align_assign_thresh = 3 +align_struct_init_span = 3 +align_var_struct_span = 1 +align_var_struct_thresh = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/tests/config/align_attr.cfg b/tests/config/align_attr.cfg new file mode 100644 index 0000000000..784c3b895d --- /dev/null +++ b/tests/config/align_attr.cfg @@ -0,0 +1,4 @@ +align_var_def_span=2 +set attribute _PREPROCESSOR_SOMETHING +align_var_def_attribute = true + diff --git a/tests/config/align_fcall-2.cfg b/tests/config/align_fcall-2.cfg new file mode 100644 index 0000000000..f738ab7154 --- /dev/null +++ b/tests/config/align_fcall-2.cfg @@ -0,0 +1,5 @@ + +align_same_func_call_params = true +sp_after_comma = force +align_number_left = true + diff --git a/tests/config/align_fcall.cfg b/tests/config/align_fcall.cfg new file mode 100644 index 0000000000..70bd174351 --- /dev/null +++ b/tests/config/align_fcall.cfg @@ -0,0 +1,4 @@ + +align_same_func_call_params = true +sp_after_comma = force + diff --git a/tests/config/align_right_cmt_gap-1.cfg b/tests/config/align_right_cmt_gap-1.cfg new file mode 100644 index 0000000000..a18b76df76 --- /dev/null +++ b/tests/config/align_right_cmt_gap-1.cfg @@ -0,0 +1,5 @@ +indent_columns = 3 +indent_with_tabs = 0 +align_right_cmt_span = 8 +align_right_cmt_mix = false +align_right_cmt_gap = 0 diff --git a/tests/config/align_right_cmt_gap-2.cfg b/tests/config/align_right_cmt_gap-2.cfg new file mode 100644 index 0000000000..fd2d3dd430 --- /dev/null +++ b/tests/config/align_right_cmt_gap-2.cfg @@ -0,0 +1,5 @@ +indent_columns = 3 +indent_with_tabs = 0 +align_right_cmt_span = 8 +align_right_cmt_mix = false +align_right_cmt_gap = 3 diff --git a/tests/config/align_typedef_func-0.cfg b/tests/config/align_typedef_func-0.cfg new file mode 100644 index 0000000000..45cbfcdd16 --- /dev/null +++ b/tests/config/align_typedef_func-0.cfg @@ -0,0 +1,6 @@ + +align_typedef_func = 0 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 + diff --git a/tests/config/align_typedef_func-1.cfg b/tests/config/align_typedef_func-1.cfg new file mode 100644 index 0000000000..1b0c2d518b --- /dev/null +++ b/tests/config/align_typedef_func-1.cfg @@ -0,0 +1,6 @@ + +align_typedef_func = 1 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 + diff --git a/tests/config/align_typedef_func-2.cfg b/tests/config/align_typedef_func-2.cfg new file mode 100644 index 0000000000..e2ef75f4f6 --- /dev/null +++ b/tests/config/align_typedef_func-2.cfg @@ -0,0 +1,8 @@ + +align_typedef_func = 2 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 2 + +sp_after_ptr_star = remove + diff --git a/tests/config/amxmodx.cfg b/tests/config/amxmodx.cfg new file mode 100644 index 0000000000..8378348941 --- /dev/null +++ b/tests/config/amxmodx.cfg @@ -0,0 +1,214 @@ +# +# AMX Mod X style for Pawn (or as close as possible) +# +# $Id: amxmodx.cfg 1579 2009-06-13 16:29:25Z bengardner $ +# + +####################### +# Basic Indenting Stuff + +# (a/i/r) comment notation for add/ignore/remove which is the actual setting +input_tab_size = 4 # tab size on input file: usually 8 +output_tab_size = 4 # tab size for output: usually 8 +indent_columns = 4 # ie 3 or 8 +indent_with_tabs = 2 # 1=only to the 'level' indent, 2=use tab indenting +#indent_paren_nl = 1 # indent-align under paren for open followed by nl + +pp_indent = remove # indent preproc 1 space per level (a/i/r) +pp_space = remove # spaces between # and word (add/ignore/remove) + +indent_switch_case = 2 # spaces to indent case from switch +#indent_case_brace = 0 # spaces to indent '{' from case + # (usually 0 or indent_columns) + +#indent_brace = 0 # spaces to indent '{' from level (usually 0) +indent_braces = 0 # whether to indent the braces or not +#indent_label = 0 # 0=left >0=col from left (absolute column), + # <0=sub from brace indent (relative column) + +indent_align_string = false # True/False - indent align broken strings +indent_col1_comment = true # indent comments in column 1 +indent_func_call_param = true # indent continued function calls to indent_columns otherwise index_columns + spaces to align with open paren. + +indent_namespace = true # indent stuff inside namespace braces +indent_class = true # indent stuff inside class braces + + +############################ +# Misc Inter-element Spacing +# Force,Ignore,Add,Remove + +# ignored by nl_*_brace = true +sp_paren_brace = force # space between ')' and '{' +sp_fparen_brace = force # space between ')' and '{' of function +sp_sparen_brace = force # space between ')' and '{' of if, while, etc + +sp_after_cast = force # space after cast - "(int) a" vs "(int)a" + +sp_before_byref = force # space before '&' of 'fcn(int& idx)' + +sp_inside_fparen = remove # space inside 'foo( xxx )' vs 'foo(xxx)' +sp_inside_fparens = remove # space inside 'foo( )' vs 'foo()' +sp_inside_paren = remove # space inside '+ ( xxx )' vs '+ (xxx)' +sp_inside_square = remove # space inside 'byte[ 5 ]' vs 'byte[5]' +sp_inside_sparen = remove # space inside 'if( xxx )' vs 'if(xxx)' +sp_inside_angle = ignore # space inside '<>', as in '' + +sp_before_sparen = force # space before '(' of 'if/for/while/switch' +sp_after_sparen = force # space after ')' of 'if/for/while/switch' + # the do-while does not get set here + +sp_before_angle = ignore # space before '<>', as in '' +sp_after_angle = ignore # space after '<>', as in '' + +sp_before_square = ignore # space before single '[' +sp_before_squares = remove # space before '[]', as in 'byte []' + +sp_paren_paren = remove # space between nested parens - '( (' vs '((' + +sp_return_paren = remove # space between 'return' and '(' +sp_sizeof_paren = remove # space between 'sizeof' and '(' + +sp_after_comma = force # space after ',' + +sp_arith = force # space around + - / * etc +sp_bool = force # space around || && +sp_compare = force # space around < > ==, etc +sp_assign = force # space around =, +=, etc + +sp_func_def_paren = remove # space between 'func' and '(' - "foo (" vs "foo(" +sp_func_call_paren = remove # space between 'func' and '(' - "foo (" vs "foo(" +sp_func_proto_paren = remove # space between 'func' and '(' - "foo (" vs "foo(" +sp_func_class_paren = remove # space between ctor/dtor and '(' + +#sp_type_func = 1 # space between return type and 'func' + # a minimum of 1 is forced except for '*' + + +sp_special_semi = remove # space empty stmt ';' on while, if, for + # example "while (*p++ = ' ') ;" +sp_before_semi = remove # space before all ';' +sp_after_semi = force +sp_inside_braces = remove # space inside '{' and '}' - "{ 1, 2, 3 }" +sp_inside_braces_enum = remove # space inside enum '{' and '}' - "{ a, b, c }" +sp_inside_braces_struct = remove # space inside struct/union '{' and '}' + +sp_macro = force # space between macro and value, ie '#define a 6' +sp_macro_func = force # space between macro and value, ie '#define a 6' + +sp_square_fparen = ignore # weird pawn stuff: native yark[rect](a[rect]) +sp_after_tag = remove # pawn: space after a tag colon + + +################################ +# Code Alignment +# (not left column spaces/tabs) + +align_with_tabs = true # use tabs for aligning (0/1) +align_keep_tabs = false # keep non-indenting tabs +align_on_tabstop = true # always align on tabstops +align_nl_cont = false # align the back-slash \n combo (macros) +align_enum_equ_span = 1 # align the '=' in enums +align_assign_span = 1 # align on '='. 0=don't align +align_assign_thresh = 0 # threshold for aligning on '='. 0=no limit +align_right_cmt_span = 8 # align comment that end lines. 0=don't align +align_var_def_span = 1 # align variable defs on variable (span for regular stuff) +align_var_def_thresh = 0 # align variable defs threshold +align_var_def_inline = true # also align inline struct/enum/union var defs +align_var_def_star_style = 1 # the star is part of the variable name +align_var_def_colon = false # align the colon in struct bit fields +align_var_struct_span = 1 # span for struct/union (0=don't align) +align_pp_define_span = 1 # align bodies in #define statments +align_pp_define_gap = 1 # min space between define label and value "#define a <---> 16" + +align_struct_init_span = 1 # align structure initializer values +align_func_proto_span = 1 # align function prototypes +align_number_left = false # left-align numbers (not fully supported, yet) +align_typedef_span = 1 # align single-line typedefs +align_typedef_gap = 1 # minimum spacing +align_typedef_star_style = 1 # Start aligning style + # 0: '*' not part of type + # 1: '*' part of the type - no space + # 2: '*' part of type, dangling + + +##################################### +# Newline Adding and Removing Options +# Add/Remove/Ignore + +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_func_decl_start = ignore # newline after the '(' in a function decl +nl_func_decl_args = ignore # newline after each ',' in a function decl +nl_func_decl_end = ignore # newline before the ')' in a function decl +nl_func_type_name = ignore # newline between return type and func name in def +nl_func_var_def_blk = 0 # newline after a block of variable defs +nl_before_case = true # newline before 'case' statement +nl_after_return = false # newline after return statement +nl_after_case = true # disallow nested "case 1: a=3;" +nl_fcall_brace = add # newline between function call and open brace +nl_squeeze_ifdef = false # no blanks after #ifxx, #elxx, or before #endif TRUE/F +nl_enum_brace = ignore # nl between enum and brace +nl_struct_brace = ignore # nl between struct and brace +nl_union_brace = ignore # nl between union and brace +nl_assign_brace = ignore # nl between '=' and brace +nl_class_brace = ignore # nl between class name and brace +nl_namespace_brace = ignore # nl between namespace name and brace + +nl_do_brace = add # nl between do and { +nl_if_brace = add # nl between if and { +nl_for_brace = add # nl between for and { +nl_else_brace = add # nl between else and { +nl_while_brace = add # nl between while and { +nl_switch_brace = add # nl between switch and { +nl_brace_else = add # nl between } and else +nl_brace_while = add # nl between } and while of do stmt + +nl_elseif_brace = add # nl between close paren and open brace in 'else if () {' + +nl_define_macro = 0 # alter newlines in #define macros +nl_start_of_file = ignore # alter newlines at the start of file +nl_start_of_file_min = 0 # min number of newlines at the start of the file +nl_end_of_file = ignore # alter newlines at the end of file +nl_end_of_file_min = 0 # min number of newlines at the end of the file + +pos_bool = start # end=move &&/|| to EOL ignore=gnore, start=move to SOL + +##################### +# Blank Line Options + +nl_before_block_comment = 2 # before a block comment (stand-alone + # comment-multi), except after brace open +nl_after_func_body = 2 # after the closing brace of a function body +nl_after_func_proto = 2 # after each prototype +nl_after_func_proto_group = 2 # after a block of prototypes +nl_max = 2 # maximum consecutive newlines (3=2 lines) + +eat_blanks_after_open_brace = true # remove blank lines after { +eat_blanks_before_close_brace = true # remove blank lines before } + +######################## +# Code Modifying Options +# (non-whitespace) + +mod_paren_on_return = remove # add or remove paren on return +mod_full_brace_nl = 1 # max number of newlines to span w/o braces +mod_full_brace_if = add # add or remove braces on if +mod_full_brace_for = add # add or remove braces on for +mod_full_brace_do = add # add or remove braces on do +mod_full_brace_while = add # add or remove braces on while +mod_pawn_semicolon = True # add optional semicolons +mod_full_brace_function = add # add optional braces on Pawn functions + + +####################### +# Comment Modifications + +cmt_star_cont = false # put a star on subsequent comment lines +cmt_cpp_to_c = false # convert CPP comments to C comments +cmt_cpp_group = false # if UO_cmt_cpp_to_c, try to group in one big C comment +cmt_cpp_nl_start = false # put a blank /* at the start of a converted group +cmt_cpp_nl_end = false # put a nl before the */ in a converted group + + +string_escape_char=94 +string_escape_char2=92 \ No newline at end of file diff --git a/tests/config/avalon.cfg b/tests/config/avalon.cfg new file mode 100644 index 0000000000..6d8b51bd3e --- /dev/null +++ b/tests/config/avalon.cfg @@ -0,0 +1,382 @@ +# Sets the line endings for the output file +newlines = AUTO # AUTO/LF/CRLF/CR + +# The original tab space value. +# Used to determine what was already aligned. (TODO) +input_tab_size = 2 # number + +# Size of tabs in the output. +# Only important if indent_with_tabs=2. +output_tab_size = 2 # number + +# The number of columns to indent. +# Usually 2, 3, 4, or 8. +indent_columns = 2 # number + +# How to use tabs when indenting code. +# 0 = Use spaces only +# 1 = Use tabs to the brace-level indent (very portable) +# 2 = Use tabs whenever possible +indent_with_tabs = 0 # number + +# If an open paren is followed by a newline, indent the next line +# so that it lines up after the open paren. +# Not recommended. +indent_paren_nl = false # bool + +# Changes the space between # and, say, define. +pp_space = ignore # IARF + +# Changes the indent of preprocessors. +pp_indent = ignore # IARF + +# Spaces to indent case from switch (usually 0 or indent_columns). +indent_switch_case = 2 # number * REVISIT: make TRUE/FALSE? * + +# Spaces to indent '{' from level (usually 0). For GNU style, set to 2. +indent_brace = 0 # number + +# Whether braces are indented to the body level or not. +indent_braces = false # bool + +indent_class = false +indent_namespace = false + +# How to indent goto labels. +# > 0 : Absolute column (1=leftmost column) +# <= 0 : Subtract from brace indent +indent_label = -2 # number + +# Whether to indent broken strings so that they line up. +indent_align_string = false # bool + +# Whether to indent comments found in column 1. +indent_col1_comment = false # bool + +# If true, indent continued function call parameters one indent level. +indent_func_call_param = false # bool + + + +# +# Spacing Options +# + +# Space between ')' and '{' +sp_paren_brace = force # IARF + +# Space after cast - "(int) a" vs "(int)a" +sp_after_cast = remove # IARF + +# Space before & in function definition param: +sp_before_byref = remove # IARF + +# Space inside 'foo( xxx )' vs 'foo(xxx)' +sp_inside_fparen = remove # IARF + +# space inside '+ ( xxx )' vs '+ (xxx)' +sp_inside_paren = remove # IARF + +# space inside 'byte[ 5 ]' vs 'byte[5]' +sp_inside_square = remove # IARF + +# Space inside 'if( xxx )' vs 'if(xxx)' +sp_inside_sparen = remove # IARF + +# Space inside '<>' +sp_inside_angle = remove # IARF + +# Space before '(' of 'if/for/while/switch'. +sp_before_sparen = force # IARF + +# Space after ')' of 'if/for/while/switch' +sp_after_sparen = force # IARF + +# Space before '<>' +sp_before_angle = remove # IARF + +# Space after '<>' +sp_after_angle = remove # IARF + +# space before all '[', except '[]' +sp_before_square = force # IARF + +# space before '[]' +sp_before_squares = remove # IARF + +# space between nested parens - '( (' vs '((' +sp_paren_paren = remove # IARF + +# space between 'return' and '(' +sp_return_paren = force # IARF + +# space between 'sizeof' and '(' +sp_sizeof_paren = remove # IARF + +# space after ',' +sp_after_comma = force # IARF + +# space around + - / * etc +sp_arith = force # IARF + +# space around || && +sp_bool = force # IARF + +# space around < > ==, etc +sp_compare = force # IARF + +# space around =, +=, etc +sp_assign = force # IARF + +# space between 'func' and '(' - "foo (" vs "foo(" +sp_func_def_paren = remove # IARF + +# space between 'func' and '(' - "foo (" vs "foo(" +sp_func_call_paren = remove # IARF + +# space between 'func' and '(' - "foo (" vs "foo(" +sp_func_proto_paren = remove # IARF + +# Space between return type and 'func' +#sp_type_func = force # IARF + +# Space empty stmt ';' on while, if, for +sp_special_semi = force # IARF + +# Space before all ';' +sp_before_semi = remove # IARF + +# Space inside '{' and '}' - "{ 1, 2, 3 }" +sp_inside_braces = remove # IARF + +# Space inside enum '{' and '}' - "{ a, b, c }" +sp_inside_braces_enum = remove # IARF + +# Space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # IARF + + + +# +# Code alignment (not left column spaces/tabs) +# + +# Use tabs for aligning. +align_with_tabs = false # bool + +# Keep non-indenting tabs. +align_keep_tabs = false # bool + +# When aligning, bump out to the next tabstop. +align_on_tabstop = false # bool + +# Align the back-slash \n combo (macros) +align_nl_cont = true # bool + +# Align the '=' in enums +align_enum_equ_span = 0 # bool + +# The span for aligning on '=' in assignments. 0=don't align +align_assign_span = 0 # number + +# Span for aligning comments that end lines. 0=don't align +align_right_cmt_span = 0 # number + +# Span for aligning variable definitions +align_var_def_span = 0 # number + +# Whether to align inline struct/enum/union var defs +align_var_def_inline = 0 # bool + +# Whether the star is part of the variable name or not. +align_var_def_star_style = 2 # bool + +# Align the colon in struct bit fields +align_var_def_colon = false # bool + +# Span for struct/union (0=don't align) +align_var_struct_span = 0 # number + +# align bodies in #define statments +align_pp_define_span = 0 # number + +# Min space between define label and value "#define a <---> 16" +align_pp_define_gap = 1 # number + +# Align structure initializer values +align_struct_init_span = 0 # number + +# Align function prototypes +align_func_proto_span = 0 # number + +# left-align numbers +#align_number_left: bool * a little buggy * + +# align single-line typedefs +#align_typedef_span: number + +# minimum spacing +#align_typedef_gap: number + +# Start aligning style +# 0: '*' not part of type +# 1: '*' part of the type - no space +# 2: '*' part of type, dangling +align_typedef_star_style = 0 # number + + + +# +# Newline adding and removing options +# + +# "int foo() {" vs "int foo()\n{" +nl_fdef_brace = force # IARF + +# Newline after '(' in a function decl +nl_func_decl_start = remove # IARF + +# Newline after each ',' in a function decl +nl_func_decl_args = remove # IARF + +# Newline before the ')' in a function decl +nl_func_decl_end = remove # IARF + +# Newline between return type and func name in def +nl_func_type_name = remove # IARF + +# Newline after a block of variable defs +nl_func_var_def_blk = 0 # number + +# newline before 'case' statement +nl_before_case = false # bool + +# newline after return statement +nl_after_return = true # bool + +# Disallow nested "case 1: a=3;" +nl_after_case = true # bool + +# newline between function call and open brace +nl_fcall_brace = remove # IARF + +# No blanks after #ifxx, #elxx, or before #endif +nl_squeeze_ifdef = false # bool + +# nl between enum and brace +nl_enum_brace = remove # IARF + +# nl between struct and brace +nl_struct_brace = remove # IARF + +# nl between union and brace +nl_union_brace = remove # IARF + +# nl between = and { +nl_assign_brace = remove # IARF + +# nl between do and { +nl_do_brace = remove # IARF + +# nl between if and { +nl_if_brace = remove # IARF + +# nl between for and { +nl_for_brace = remove # IARF + +# nl between else and { +nl_else_brace = remove # IARF + +# nl between while and { +nl_while_brace = remove # IARF + +# nl between switch and { +nl_switch_brace = remove # IARF + +# nl between } and else +nl_brace_else = remove # IARF + +# nl between } and while of do stmt +nl_brace_while = remove # IARF + +# Alter newlines in #define macros +nl_define_macro = false # bool + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # IARF + +# Number of newlines at the start of the file. Only used if nl_start_of_file is Add or Force +#nl_start_of_file_min: number + +# Add or remove newlines at the end of the file +nl_end_of_file = force # IARF + +# Number of newlines at the end of the file. Only used if nl_end_of_file is Add or Force +nl_end_of_file_min = 1 # number + +# -1: boolean ops are at the end of the line +# 0: do not move boolean ops (default) +# 1: boolean ops are at the start of the line +pos_bool = Trail # position (Trail, None, Lead) + + + +# +# Blank line options +# Note that it takes 2 newlines to get a blank line. +# + +# Minimum number of newlines before a multi-line comment. +nl_before_block_comment = 2 # number + +# Newlines after the closing brace of a function body +nl_after_func_body = 2 # number + +# Newlines after a single function prototype. +nl_after_func_proto = 1 # number + +# Newlines after a prototype, if not followed by another prototype. +nl_after_func_proto_group = 2 # number + +# The maximum consecutive newlines. +nl_max = 4 # number + +# Remove blank lines after { +eat_blanks_after_open_brace = true # bool + +# Remove blank lines before } +eat_blanks_before_close_brace = true # bool + + + +# +# code modifying options (non-whitespace) +# + +# Add or remove unecessary paren on return. +mod_paren_on_return = remove # IARF + +# add or remove braces on single-statement if +mod_full_brace_if = add # IARF + +# add or remove braces on single-statement for +mod_full_brace_for = add # IARF + +# add or remove braces on single-statement do +mod_full_brace_do = add # IARF + +# add or remove braces on single-statement while +mod_full_brace_while = add # IARF + +# don't remove braces around statements that span X newlines +#mod_full_brace_nl: number + + + +# +# Comment modifications +# + +# Put a star on subsequent comment lines +#cmt_star_cont: bool + diff --git a/tests/config/avalon2.cfg b/tests/config/avalon2.cfg new file mode 100644 index 0000000000..6c6288bb4c --- /dev/null +++ b/tests/config/avalon2.cfg @@ -0,0 +1,385 @@ +# Sets the line endings for the output file +newlines = AUTO # AUTO/LF/CRLF/CR + +# The original tab space value. +# Used to determine what was already aligned. (TODO) +input_tab_size = 2 # number + +# Size of tabs in the output. +# Only important if indent_with_tabs=2. +output_tab_size = 2 # number + +# The number of columns to indent. +# Usually 2, 3, 4, or 8. +indent_columns = 2 # number + +# How to use tabs when indenting code. +# 0 = Use spaces only +# 1 = Use tabs to the brace-level indent (very portable) +# 2 = Use tabs whenever possible +indent_with_tabs = 0 # number + +# If an open paren is followed by a newline, indent the next line +# so that it lines up after the open paren. +# Not recommended. +indent_paren_nl = false # bool + +# Changes the space between # and, say, define. +pp_space = ignore # IARF + +# Changes the indent of preprocessors. +pp_indent = ignore # IARF + +# Spaces to indent case from switch (usually 0 or indent_columns). +indent_switch_case = 2 # number * REVISIT: make TRUE/FALSE? * + +# Spaces to indent '{' from level (usually 0). For GNU style, set to 2. +indent_brace = 0 # number + +# Whether braces are indented to the body level or not. +indent_braces = false # bool + +indent_class = false +indent_namespace = false + +# How to indent goto labels. +# > 0 : Absolute column (1=leftmost column) +# <= 0 : Subtract from brace indent +indent_label = -2 # number + +# Whether to indent broken strings so that they line up. +indent_align_string = false # bool + +# Whether to indent comments found in column 1. +indent_col1_comment = false # bool + +# If true, indent continued function call parameters one indent level. +indent_func_call_param = false # bool + + + +# +# Spacing Options +# + +# Space between ')' and '{' +sp_paren_brace = force # IARF + +# Space after cast - "(int) a" vs "(int)a" +sp_after_cast = remove # IARF + +# Space before & in function definition param: +sp_before_byref = remove # IARF + +# Space inside 'foo( xxx )' vs 'foo(xxx)' +sp_inside_fparen = remove # IARF + +# space inside '+ ( xxx )' vs '+ (xxx)' +sp_inside_paren = remove # IARF + +# space inside 'byte[ 5 ]' vs 'byte[5]' +sp_inside_square = remove # IARF + +# Space inside 'if( xxx )' vs 'if(xxx)' +sp_inside_sparen = remove # IARF + +# Space inside '<>' +sp_inside_angle = remove # IARF + +# Space before '(' of 'if/for/while/switch'. +sp_before_sparen = force # IARF + +# Space after ')' of 'if/for/while/switch' +sp_after_sparen = force # IARF + +# Space before '<>' +sp_before_angle = remove # IARF + +# Space after '<>' +sp_after_angle = remove # IARF +sp_angle_paren = remove # IARF +sp_angle_word = force # IARF + +# space before all '[', except '[]' +sp_before_square = force # IARF + +# space before '[]' +sp_before_squares = remove # IARF + +# space between nested parens - '( (' vs '((' +sp_paren_paren = remove # IARF + +# space between 'return' and '(' +sp_return_paren = force # IARF + +# space between 'sizeof' and '(' +sp_sizeof_paren = remove # IARF + +# space after ',' +sp_after_comma = force # IARF + +# space around + - / * etc +sp_arith = force # IARF + +# space around || && +sp_bool = force # IARF + +# space around < > ==, etc +sp_compare = force # IARF + +# space around =, +=, etc +sp_assign = force # IARF + +# space between 'func' and '(' - "foo (" vs "foo(" +sp_func_def_paren = remove # IARF + +# space between 'func' and '(' - "foo (" vs "foo(" +sp_func_call_paren = remove # IARF + +# space between 'func' and '(' - "foo (" vs "foo(" +sp_func_proto_paren = remove # IARF + +# Space between return type and 'func' +#sp_type_func = force # IARF + +# Space empty stmt ';' on while, if, for +sp_special_semi = force # IARF + +# Space before all ';' +sp_before_semi = remove # IARF + +# Space inside '{' and '}' - "{ 1, 2, 3 }" +sp_inside_braces = remove # IARF + +# Space inside enum '{' and '}' - "{ a, b, c }" +sp_inside_braces_enum = remove # IARF + +# Space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # IARF + + + +# +# Code alignment (not left column spaces/tabs) +# + +# Use tabs for aligning. +align_with_tabs = false # bool + +# Keep non-indenting tabs. +align_keep_tabs = false # bool + +# When aligning, bump out to the next tabstop. +align_on_tabstop = false # bool + +# Align the back-slash \n combo (macros) +align_nl_cont = true # bool + +# Align the '=' in enums +align_enum_equ_span = 0 # bool + +# The span for aligning on '=' in assignments. 0=don't align +align_assign_span = 0 # number + +# Span for aligning comments that end lines. 0=don't align +align_right_cmt_span = 0 # number + +# Span for aligning variable definitions +align_var_def_span = 0 # number + +# Whether to align inline struct/enum/union var defs +align_var_def_inline = 0 # bool + +# Whether the star is part of the variable name or not. +align_var_def_star_style = 2 # bool + +# Align the colon in struct bit fields +align_var_def_colon = false # bool + +# Span for struct/union (0=don't align) +align_var_struct_span = 0 # number + +# align bodies in #define statments +align_pp_define_span = 0 # number + +# Min space between define label and value "#define a <---> 16" +align_pp_define_gap = 1 # number + +# Align structure initializer values +align_struct_init_span = 0 # number + +# Align function prototypes +align_func_proto_span = 0 # number + +# left-align numbers +#align_number_left: bool * a little buggy * + +# align single-line typedefs +#align_typedef_span: number + +# minimum spacing +#align_typedef_gap: number + +# Start aligning style +# 0: '*' not part of type +# 1: '*' part of the type - no space +# 2: '*' part of type, dangling +align_typedef_star_style = 0 # number + + + +# +# Newline adding and removing options +# + +# "int foo() {" vs "int foo()\n{" +nl_fdef_brace = force # IARF + +# Newline after '(' in a function decl +nl_func_decl_start = remove # IARF + +# Newline after each ',' in a function decl +nl_func_decl_args = remove # IARF + +# Newline before the ')' in a function decl +nl_func_decl_end = remove # IARF + +# Newline between return type and func name in def +nl_func_type_name = remove # IARF + +# Newline after a block of variable defs +nl_func_var_def_blk = 0 # number + +# newline before 'case' statement +nl_before_case = false # bool + +# newline after return statement +nl_after_return = true # bool + +# Disallow nested "case 1: a=3;" +nl_after_case = true # bool + +# newline between function call and open brace +nl_fcall_brace = remove # IARF + +# No blanks after #ifxx, #elxx, or before #endif +nl_squeeze_ifdef = false # bool + +# nl between enum and brace +nl_enum_brace = remove # IARF + +# nl between struct and brace +nl_struct_brace = remove # IARF + +# nl between union and brace +nl_union_brace = remove # IARF + +# nl between = and { +nl_assign_brace = remove # IARF + +# nl between do and { +nl_do_brace = remove # IARF + +# nl between if and { +nl_if_brace = remove # IARF + +# nl between for and { +nl_for_brace = remove # IARF + +# nl between else and { +nl_else_brace = remove # IARF + +# nl between while and { +nl_while_brace = remove # IARF + +# nl between switch and { +nl_switch_brace = remove # IARF + +# nl between } and else +nl_brace_else = remove # IARF + +# nl between } and while of do stmt +nl_brace_while = remove # IARF + +# Alter newlines in #define macros +nl_define_macro = false # bool + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # IARF + +# Number of newlines at the start of the file. Only used if nl_start_of_file is Add or Force +#nl_start_of_file_min: number + +# Add or remove newlines at the end of the file +nl_end_of_file = force # IARF + +# Number of newlines at the end of the file. Only used if nl_end_of_file is Add or Force +nl_end_of_file_min = 1 # number + +# -1: boolean ops are at the end of the line +# 0: do not move boolean ops (default) +# 1: boolean ops are at the start of the line +pos_bool = Trail # position (Trail, None, Lead) + +sp_before_byref = remove +sp_before_ptr_star = remove + +# +# Blank line options +# Note that it takes 2 newlines to get a blank line. +# + +# Minimum number of newlines before a multi-line comment. +nl_before_block_comment = 2 # number + +# Newlines after the closing brace of a function body +nl_after_func_body = 2 # number + +# Newlines after a single function prototype. +nl_after_func_proto = 1 # number + +# Newlines after a prototype, if not followed by another prototype. +nl_after_func_proto_group = 2 # number + +# The maximum consecutive newlines. +nl_max = 4 # number + +# Remove blank lines after { +eat_blanks_after_open_brace = true # bool + +# Remove blank lines before } +eat_blanks_before_close_brace = true # bool + + + +# +# code modifying options (non-whitespace) +# + +# Add or remove unecessary paren on return. +mod_paren_on_return = remove # IARF + +# add or remove braces on single-statement if +mod_full_brace_if = add # IARF + +# add or remove braces on single-statement for +mod_full_brace_for = add # IARF + +# add or remove braces on single-statement do +mod_full_brace_do = add # IARF + +# add or remove braces on single-statement while +mod_full_brace_while = add # IARF + +# don't remove braces around statements that span X newlines +#mod_full_brace_nl: number + + + +# +# Comment modifications +# + +# Put a star on subsequent comment lines +#cmt_star_cont: bool + diff --git a/tests/config/avalon3.cfg b/tests/config/avalon3.cfg new file mode 100644 index 0000000000..53ec070d3f --- /dev/null +++ b/tests/config/avalon3.cfg @@ -0,0 +1,506 @@ + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 2 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 2 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 2 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = true # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 0 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 2 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = -2 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = remove # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = force # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = remove # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = force # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = force # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = remove # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = remove # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force +sp_angle_word = force +sp_angle_paren = remove + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = force # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 2 # false/true + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 1 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = true # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 2 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = remove # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 0 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = remove # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = remove # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = force # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = force # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = force # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = remove # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = remove # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = remove # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = force # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = false # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = lead # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 3 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 1 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = ignore # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = ignore # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = true # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force diff --git a/tests/config/avalon4.cfg b/tests/config/avalon4.cfg new file mode 100644 index 0000000000..35551a2a99 --- /dev/null +++ b/tests/config/avalon4.cfg @@ -0,0 +1,676 @@ + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 2 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 2 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 2 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = true # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 2 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = remove # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = force # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = remove # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = force # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = force # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = remove # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = remove # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = remove # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = force # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = force # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = force # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = force # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = force # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = force # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 1 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = true # false/true + +# Don't touch one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = remove # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 0 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = remove # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = remove # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = remove # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = remove # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = remove # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = force # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = force # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = force # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = remove # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = remove # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = remove # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = force # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = true # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = trail # ignore/lead/trail +pos_class_comma = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = lead # ignore/lead/trail + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 3 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 1 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 2 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 1 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = true # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = remove # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = remove # ignore/add/remove/force + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/ben.cfg b/tests/config/ben.cfg new file mode 100644 index 0000000000..c65f30f4e5 --- /dev/null +++ b/tests/config/ben.cfg @@ -0,0 +1,214 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = remove +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_before_semi_for_empty = force + +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_assign_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = true +nl_after_brace_open = true +nl_after_vbrace_open = true +nl_after_access_spec = 1 +nl_assign_leave_one_liners = true +nl_class_leave_one_liners = true +nl_enum_leave_one_liners = true +nl_getset_leave_one_liners = true +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = remove +pp_space = remove +sp_after_dc = remove +sp_before_dc = remove +sp_attribute_paren = remove +sp_defined_paren = force + +mod_add_long_function_closebrace_comment = 40 +mod_add_long_switch_closebrace_comment = 40 +mod_remove_extra_semicolon = TRUE + +sp_brace_typedef = force +nl_after_brace_close = TRUE + diff --git a/tests/config/blc-1.cfg b/tests/config/blc-1.cfg new file mode 100644 index 0000000000..94c86e8d31 --- /dev/null +++ b/tests/config/blc-1.cfg @@ -0,0 +1,21 @@ +# +# Blank Line Count test 1 +# +# $Id: blc-1.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +nl_max = 4 +nl_before_block_comment = 2 +nl_after_func_body = 2 +nl_after_func_proto_group = 2 + +nl_start_of_file = Remove +nl_end_of_file = Force +nl_end_of_file_min = 1 + + diff --git a/tests/config/bool-pos-eol.cfg b/tests/config/bool-pos-eol.cfg new file mode 100644 index 0000000000..1f6cfd650b --- /dev/null +++ b/tests/config/bool-pos-eol.cfg @@ -0,0 +1,18 @@ +# +# moves boolean ops to the end of line +# +# $Id: bool-pos-eol.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_bool = Trail +pos_comma = Trail +pos_class_comma = trail +sp_after_comma = force + +align_right_cmt_span = 2 + diff --git a/tests/config/bool-pos-sol.cfg b/tests/config/bool-pos-sol.cfg new file mode 100644 index 0000000000..1bfd263584 --- /dev/null +++ b/tests/config/bool-pos-sol.cfg @@ -0,0 +1,18 @@ +# +# moves boolean ops to the end of line +# +# $Id: bool-pos-sol.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_bool = Lead +pos_comma = Lead +pos_class_comma = Lead +sp_after_comma = force + +align_right_cmt_span = 2 + diff --git a/tests/config/brace-allman.cfg b/tests/config/brace-allman.cfg new file mode 100644 index 0000000000..cd5a9aa5b9 --- /dev/null +++ b/tests/config/brace-allman.cfg @@ -0,0 +1,27 @@ +# +# Allman style +# +# $Id: brace-allman.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +# brace settings +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_brace_while = remove +nl_brace_else = add + diff --git a/tests/config/brace-banner.cfg b/tests/config/brace-banner.cfg new file mode 100644 index 0000000000..67ffc67f59 --- /dev/null +++ b/tests/config/brace-banner.cfg @@ -0,0 +1,40 @@ +# +# Banner style +# +# $Id: brace-banner.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 2 # new tab size +indent_columns = output_tab_size + +indent_braces = TRUE +indent_braces_no_func = TRUE + +# brace settings +nl_assign_brace = remove # "= {" vs "= \n {" +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_fcall_brace = remove # "foo() {" vs "foo()\n{" +nl_fdef_brace = remove # "int foo() {" vs "int foo()\n{" +nl_brace_while = add +nl_brace_else = add + +# spaces around braces +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_assign = add +sp_fparen_brace = add + +eat_blanks_after_open_brace = True + +sp_else_brace = force + diff --git a/tests/config/brace-gnu.cfg b/tests/config/brace-gnu.cfg new file mode 100644 index 0000000000..d6c82939b2 --- /dev/null +++ b/tests/config/brace-gnu.cfg @@ -0,0 +1,42 @@ +# +# GNU style +# +# $Id: brace-gnu.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 2 # new tab size +indent_columns = 2 + +# indent extra 2 spaces per brace pair +indent_brace = 2 + +# brace placement +# nl_assign_brace = add # "= {" vs "= \n {" +# nl_enum_brace = add # "enum {" vs "enum \n {" +# nl_union_brace = add # "union {" vs "union \n {" +# nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_brace_while = add +nl_brace_else = add + +# spaces around braces +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_assign = add +sp_else_brace = force + +# nl_squeeze_ifdef = TRUE +# nl_func_var_def_blk = 1 +# nl_before_case = 1 +# nl_after_return = TRUE + + diff --git a/tests/config/brace-kr-br.cfg b/tests/config/brace-kr-br.cfg new file mode 100644 index 0000000000..21bc75dd09 --- /dev/null +++ b/tests/config/brace-kr-br.cfg @@ -0,0 +1,43 @@ +# +# K&R style +# +# $Id: brace-kr.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +# brace placement +nl_assign_brace = remove # "= {" vs "= \n {" +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_brace_while = remove +nl_brace_else = remove + +# spaces around braces +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_assign = add +sp_else_brace = force + +# nl_squeeze_ifdef = TRUE +# nl_func_var_def_blk = 1 +# nl_before_case = 1 +# nl_after_return = TRUE + +nl_after_brace_open = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_if = add + diff --git a/tests/config/brace-kr.cfg b/tests/config/brace-kr.cfg new file mode 100644 index 0000000000..3528240740 --- /dev/null +++ b/tests/config/brace-kr.cfg @@ -0,0 +1,40 @@ +# +# K&R style +# +# $Id: brace-kr.cfg 1492 2009-02-27 03:25:26Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +# brace placement +nl_assign_brace = remove # "= {" vs "= \n {" +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_brace_while = remove +nl_brace_else = remove + +# spaces around braces +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_assign = add +sp_else_brace = force + +# nl_squeeze_ifdef = TRUE +# nl_func_var_def_blk = 1 +# nl_before_case = 1 +# nl_after_return = TRUE + +sp_brace_else = force + diff --git a/tests/config/brace-remove-2.cfg b/tests/config/brace-remove-2.cfg new file mode 100644 index 0000000000..e693d6da42 --- /dev/null +++ b/tests/config/brace-remove-2.cfg @@ -0,0 +1,12 @@ +# +# Removes all unecessary braces unless the body spans more than 2 lines +# + + +mod_paren_on_return = remove # "return 1;" vs "return (1);" +mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = remove # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" +mod_full_brace_nl = 2 # don't remove if more than 3 newlines + diff --git a/tests/config/brace-remove-all.cfg b/tests/config/brace-remove-all.cfg new file mode 100644 index 0000000000..07a86efb13 --- /dev/null +++ b/tests/config/brace-remove-all.cfg @@ -0,0 +1,13 @@ +# +# Removes all unecessary braces +# + + +mod_paren_on_return = remove # "return 1;" vs "return (1);" +mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = remove # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" + +nl_else_if = remove + diff --git a/tests/config/brace-ws.cfg b/tests/config/brace-ws.cfg new file mode 100644 index 0000000000..1fe8f525c7 --- /dev/null +++ b/tests/config/brace-ws.cfg @@ -0,0 +1,29 @@ +# +# Whitesmith style +# +# $Id: brace-ws.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +indent_braces = TRUE + +# brace settings +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_brace_while = add +nl_brace_else = add + diff --git a/tests/config/brace-ws2.cfg b/tests/config/brace-ws2.cfg new file mode 100644 index 0000000000..813312bcd0 --- /dev/null +++ b/tests/config/brace-ws2.cfg @@ -0,0 +1,30 @@ +# +# Whitesmith style +# +# $Id: brace-ws2.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +indent_braces = TRUE +indent_braces_no_func = TRUE + +# brace settings +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_brace_while = add +nl_brace_else = add + diff --git a/tests/config/byref-center.cfg b/tests/config/byref-center.cfg new file mode 100644 index 0000000000..9f8b3da975 --- /dev/null +++ b/tests/config/byref-center.cfg @@ -0,0 +1,13 @@ +# +# Places the byref as follows: "int & foo" +# +# $Id: byref-center.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = force +sp_after_byref = force + +indent_class = True + diff --git a/tests/config/byref-left.cfg b/tests/config/byref-left.cfg new file mode 100644 index 0000000000..88bd125dfa --- /dev/null +++ b/tests/config/byref-left.cfg @@ -0,0 +1,13 @@ +# +# Places the byref as follows: "int &foo" +# +# $Id: byref-left.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = force +sp_after_byref = remove + +indent_class = True + diff --git a/tests/config/byref-right.cfg b/tests/config/byref-right.cfg new file mode 100644 index 0000000000..2b9a4a6916 --- /dev/null +++ b/tests/config/byref-right.cfg @@ -0,0 +1,13 @@ +# +# Places the byref as follows: "int& foo" +# +# $Id: byref-right.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + diff --git a/tests/config/case-1.cfg b/tests/config/case-1.cfg new file mode 100644 index 0000000000..fc9e5acb1a --- /dev/null +++ b/tests/config/case-1.cfg @@ -0,0 +1,17 @@ +# +# My favorite format +# +# $Id: case-1.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +indent_switch_case = 0 +indent_case_brace = 0 + +nl_before_case = True # blank line before case except after { +nl_after_case = True # disallow case X: a++; break; + diff --git a/tests/config/case-2.cfg b/tests/config/case-2.cfg new file mode 100644 index 0000000000..34b09efd68 --- /dev/null +++ b/tests/config/case-2.cfg @@ -0,0 +1,19 @@ +# +# My favorite format +# +# $Id: case-2.cfg 1182 2008-05-09 21:21:40Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +indent_switch_case = indent_columns +indent_case_brace = 0 + +nl_before_case = True # blank line before case except after { +nl_after_case = True # disallow case X: a++; break; + +mod_move_case_break = True + diff --git a/tests/config/case-3.cfg b/tests/config/case-3.cfg new file mode 100644 index 0000000000..cbbbb0d572 --- /dev/null +++ b/tests/config/case-3.cfg @@ -0,0 +1,17 @@ +# +# My favorite format +# +# $Id: case-3.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +indent_switch_case = indent_columns +indent_case_brace = -indent_columns + +nl_before_case = True # blank line before case except after { +nl_after_case = True # disallow case X: a++; break; + diff --git a/tests/config/cast-sp-a.cfg b/tests/config/cast-sp-a.cfg new file mode 100644 index 0000000000..6e592ede00 --- /dev/null +++ b/tests/config/cast-sp-a.cfg @@ -0,0 +1,194 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = remove +sp_inside_paren_cast = force +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = false +nl_after_brace_open = false +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = ignore +pp_space = ignore diff --git a/tests/config/cast-sp-r.cfg b/tests/config/cast-sp-r.cfg new file mode 100644 index 0000000000..a221fefcfa --- /dev/null +++ b/tests/config/cast-sp-r.cfg @@ -0,0 +1,194 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_inside_paren_cast = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = remove +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = false +nl_after_brace_open = false +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = ignore +pp_space = ignore diff --git a/tests/config/cast-type.cfg b/tests/config/cast-type.cfg new file mode 100644 index 0000000000..aaca14501c --- /dev/null +++ b/tests/config/cast-type.cfg @@ -0,0 +1,198 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_inside_paren_cast = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = remove +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = false +nl_after_brace_open = false +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = ignore +pp_space = ignore + +type UINT UInt UInt32 UInt16 Uint UINT8 UINT16 UINT32 uint32_t + + diff --git a/tests/config/cast-types.txt b/tests/config/cast-types.txt new file mode 100644 index 0000000000..cfc74c6efa --- /dev/null +++ b/tests/config/cast-types.txt @@ -0,0 +1,28 @@ +# +# a simple list of stuff that should be detected as a CT_TYPE +# this usually isn't necessary because types are detected from the context. +# +# In the future, I may allow arbitrary CT_xxx stuff to be specified, as +# well as a language +# + +INT8 +UINT8 +INT16 +UINT16 +INT32 +UINT32 +INT64 +UINT64 +FLOAT +CHAR +DOUBLE +TRUE +FALSE +BOOL +FILE +DIR + +# this is for the type-cast.c test +bat + diff --git a/tests/config/cgal.cfg b/tests/config/cgal.cfg new file mode 100644 index 0000000000..274e99d8d2 --- /dev/null +++ b/tests/config/cgal.cfg @@ -0,0 +1,213 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = force +sp_inside_sparen_close = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = remove +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_before_semi_for_empty = force + +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_assign_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = true +nl_after_brace_open = true +nl_after_vbrace_open = true +nl_after_access_spec = 1 +nl_assign_leave_one_liners = true +nl_class_leave_one_liners = true +nl_enum_leave_one_liners = true +nl_getset_leave_one_liners = true +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = remove +pp_space = remove +sp_after_dc = remove +sp_before_dc = remove +sp_attribute_paren = remove +sp_defined_paren = force + +mod_add_long_function_closebrace_comment = 40 +mod_add_long_switch_closebrace_comment = 40 + +sp_brace_typedef = force + diff --git a/tests/config/clark.cfg b/tests/config/clark.cfg new file mode 100644 index 0000000000..c3aefae7c7 --- /dev/null +++ b/tests/config/clark.cfg @@ -0,0 +1,506 @@ + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 2 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 2 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 2 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = true # false/true + +# Whether the 'namespace' body is indented +indent_namespace = true # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 2 # number + +# indent single line ('//') comments on lines before code +indent_sing_line_comments = 2 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 2 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 2 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = add # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = add # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = add # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = add # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = add # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = add # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = add # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = add # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = ignore # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = ignore # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = ignore # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 2 # false/true + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 0 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +nl_before_if = force # ignore/add/remove/force +nl_after_if = force # ignore/add/remove/force +nl_before_for = force # ignore/add/remove/force +nl_after_for = force # ignore/add/remove/force +nl_before_while = force # ignore/add/remove/force +nl_after_while = force # ignore/add/remove/force +nl_before_switch = force # ignore/add/remove/force +nl_after_switch = force # ignore/add/remove/force +nl_before_do = force # ignore/add/remove/force +nl_after_do = force # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = add # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = add # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = add # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = false # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 0 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 0 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 1 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = remove # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = remove # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = remove # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 3 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = remove # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force diff --git a/tests/config/class-colon-pos-eol-add.cfg b/tests/config/class-colon-pos-eol-add.cfg new file mode 100644 index 0000000000..86271a2765 --- /dev/null +++ b/tests/config/class-colon-pos-eol-add.cfg @@ -0,0 +1,21 @@ +# +# moves class colon ops to the end of line +# +# $Id: class-colon-pos-eol-add.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_class_colon = Trail +pos_comma = Trail +pos_class_comma = trail +indent_class_colon = True +nl_class_init_args = Add +nl_class_colon = Add + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/class-colon-pos-eol.cfg b/tests/config/class-colon-pos-eol.cfg new file mode 100644 index 0000000000..9b0252cb57 --- /dev/null +++ b/tests/config/class-colon-pos-eol.cfg @@ -0,0 +1,18 @@ +# +# moves class colon ops to the end of line +# +# $Id: class-colon-pos-eol.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_class_colon = Trail + +indent_class_colon = True + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/class-colon-pos-sol-add.cfg b/tests/config/class-colon-pos-sol-add.cfg new file mode 100644 index 0000000000..9ea5a06fe0 --- /dev/null +++ b/tests/config/class-colon-pos-sol-add.cfg @@ -0,0 +1,22 @@ +# +# moves class colon ops to the end of line +# +# $Id: class-colon-pos-sol-add.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_class_colon = Lead +pos_comma = Trail +pos_class_comma = trail +indent_class_colon = True +nl_class_init_args = Add +nl_class_colon = Add +sp_inside_fparen = force + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/class-colon-pos-sol.cfg b/tests/config/class-colon-pos-sol.cfg new file mode 100644 index 0000000000..87c21f61f4 --- /dev/null +++ b/tests/config/class-colon-pos-sol.cfg @@ -0,0 +1,18 @@ +# +# moves class colon ops to the end of line +# +# $Id: class-colon-pos-sol.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_class_colon = Lead + +indent_class_colon = True + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/class-header.h b/tests/config/class-header.h new file mode 100644 index 0000000000..32e68a34d9 --- /dev/null +++ b/tests/config/class-header.h @@ -0,0 +1,4 @@ +/** + * CLASS: $(class) + * TODO: DESCRIPTION + */ diff --git a/tests/config/class-nl_func-add.cfg b/tests/config/class-nl_func-add.cfg new file mode 100644 index 0000000000..ed4afc9b0c --- /dev/null +++ b/tests/config/class-nl_func-add.cfg @@ -0,0 +1,23 @@ +# +# moves class colon ops to the end of line +# +# $Id: class-nl_func-add.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_class_colon = Trail +pos_comma = Trail +pos_class_comma = trail +indent_class_colon = True +nl_class_init_args = Add +nl_class_colon = Add + +nl_fdef_brace = force + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/class-nl_func-del.cfg b/tests/config/class-nl_func-del.cfg new file mode 100644 index 0000000000..03c0bbf0f1 --- /dev/null +++ b/tests/config/class-nl_func-del.cfg @@ -0,0 +1,24 @@ +# +# moves class colon ops to the end of line +# +# $Id: class-nl_func-del.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +pos_class_colon = Trail +pos_comma = Trail +pos_class_comma = trail +indent_class_colon = True +nl_class_init_args = Add +nl_class_colon = Add + +nl_fdef_brace = remove +sp_fparen_brace = force + +sp_after_dc = remove +sp_before_dc = remove + diff --git a/tests/config/cmt_indent-1.cfg b/tests/config/cmt_indent-1.cfg new file mode 100644 index 0000000000..d701a57d91 --- /dev/null +++ b/tests/config/cmt_indent-1.cfg @@ -0,0 +1,6 @@ +indent_with_tabs = 2 +indent_columns = 2 +indent_namespace = true +indent_class = true +nl_collapse_empty_body = true + diff --git a/tests/config/cmt_indent-2.cfg b/tests/config/cmt_indent-2.cfg new file mode 100644 index 0000000000..e7c8699c92 --- /dev/null +++ b/tests/config/cmt_indent-2.cfg @@ -0,0 +1,7 @@ +indent_with_tabs = 2 +indent_columns = 2 +indent_namespace = true +indent_class = true +nl_collapse_empty_body = true +cmt_indent_multi = false + diff --git a/tests/config/cmt_indent-3.cfg b/tests/config/cmt_indent-3.cfg new file mode 100644 index 0000000000..69682efbcb --- /dev/null +++ b/tests/config/cmt_indent-3.cfg @@ -0,0 +1,8 @@ +indent_with_tabs = 2 +indent_columns = 2 +indent_namespace = true +indent_class = true +nl_collapse_empty_body = true +cmt_indent_multi = true +cmt_star_cont = true + diff --git a/tests/config/cmt_multi-1.cfg b/tests/config/cmt_multi-1.cfg new file mode 100644 index 0000000000..a7ff3c6a1e --- /dev/null +++ b/tests/config/cmt_multi-1.cfg @@ -0,0 +1,3 @@ +indent_columns = 4 +cmt_multi_check_last = false + diff --git a/tests/config/cmt_multi-2.cfg b/tests/config/cmt_multi-2.cfg new file mode 100644 index 0000000000..566efeb7bf --- /dev/null +++ b/tests/config/cmt_multi-2.cfg @@ -0,0 +1,3 @@ +indent_columns = 4 +cmt_multi_check_last = true + diff --git a/tests/config/cmt_nl_end.cfg b/tests/config/cmt_nl_end.cfg new file mode 100644 index 0000000000..6f5fa06edd --- /dev/null +++ b/tests/config/cmt_nl_end.cfg @@ -0,0 +1,7 @@ +indent_columns=3 +indent_with_tabs=0 +input_tab_size=3 +nl_end_of_file_min=1 +nl_after_if=force # X+1 +nl_before_if=force # x+y + diff --git a/tests/config/cmt_right.cfg b/tests/config/cmt_right.cfg new file mode 100644 index 0000000000..ef9f042790 --- /dev/null +++ b/tests/config/cmt_right.cfg @@ -0,0 +1,2 @@ +indent_columns = 4 +align_right_cmt_span = 5 diff --git a/tests/config/comment-align.cfg b/tests/config/comment-align.cfg new file mode 100644 index 0000000000..397723eed3 --- /dev/null +++ b/tests/config/comment-align.cfg @@ -0,0 +1,4 @@ +indent_columns = 4 +sp_inside_braces = force +align_right_cmt_span = 6 + diff --git a/tests/config/cond-1.cfg b/tests/config/cond-1.cfg new file mode 100644 index 0000000000..29b18457df --- /dev/null +++ b/tests/config/cond-1.cfg @@ -0,0 +1,5 @@ + +indent_columns = 3 +sp_cond_colon = force +sp_cond_question = force + diff --git a/tests/config/cond-2.cfg b/tests/config/cond-2.cfg new file mode 100644 index 0000000000..0d8ac0fbbe --- /dev/null +++ b/tests/config/cond-2.cfg @@ -0,0 +1,5 @@ + +indent_columns = 3 +sp_cond_colon = add +sp_cond_question = add + diff --git a/tests/config/const_throw.cfg b/tests/config/const_throw.cfg new file mode 100644 index 0000000000..3fc6324ba2 --- /dev/null +++ b/tests/config/const_throw.cfg @@ -0,0 +1,8 @@ +# Indentation column for standalone 'const' function decl/proto qualifier +# e.g., int GetFoo(void)\n const\n { return (m_Foo); } +indent_func_const = 69 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +# e.g., int GetFoo(void)\n throw (std::bad_alloc)\n { return (m_Foo); } +indent_func_throw = 41 # number + diff --git a/tests/config/cpp_to_c-1.cfg b/tests/config/cpp_to_c-1.cfg new file mode 100644 index 0000000000..6de32d8d21 --- /dev/null +++ b/tests/config/cpp_to_c-1.cfg @@ -0,0 +1,20 @@ +# +# CPP to C comment conversion +# +# $Id: cpp_to_c-1.cfg 986 2007-10-31 01:23:01Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 4 +indent_columns = 4 + +cmt_star_cont = true +cmt_cpp_to_c = true +# cmt_cpp_group = true +# cmt_cpp_nl_start = true +# cmt_cpp_nl_end = true + +align_right_cmt_span = 2 + +code_width = 80 + diff --git a/tests/config/cpp_to_c-2.cfg b/tests/config/cpp_to_c-2.cfg new file mode 100644 index 0000000000..3b27893641 --- /dev/null +++ b/tests/config/cpp_to_c-2.cfg @@ -0,0 +1,18 @@ +# +# CPP to C comment conversion +# +# $Id: cpp_to_c-2.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 4 +indent_columns = 4 + +cmt_star_cont = true +cmt_cpp_to_c = true +cmt_cpp_group = true +# cmt_cpp_nl_start = true +# cmt_cpp_nl_end = true + +align_right_cmt_span = 2 + diff --git a/tests/config/cpp_to_c-3.cfg b/tests/config/cpp_to_c-3.cfg new file mode 100644 index 0000000000..a792d19ea2 --- /dev/null +++ b/tests/config/cpp_to_c-3.cfg @@ -0,0 +1,20 @@ +# +# CPP to C comment conversion +# +# $Id: cpp_to_c-3.cfg 906 2007-09-07 23:17:56Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 4 +indent_columns = 4 + +cmt_star_cont = true +cmt_cpp_to_c = true +cmt_cpp_group = true +cmt_cpp_nl_start = true +cmt_cpp_nl_end = true + +align_right_cmt_span = 2 + +nl_after_multiline_comment = true + diff --git a/tests/config/cs_generics.cfg b/tests/config/cs_generics.cfg new file mode 100644 index 0000000000..3f24846258 --- /dev/null +++ b/tests/config/cs_generics.cfg @@ -0,0 +1,6 @@ +sp_before_angle = remove +sp_inside_angle = remove +sp_angle_paren = remove +sp_compare = force +sp_sizeof_paren = remove + diff --git a/tests/config/cu.cfg b/tests/config/cu.cfg new file mode 100644 index 0000000000..c64fb051c5 --- /dev/null +++ b/tests/config/cu.cfg @@ -0,0 +1,180 @@ +# +# minuses: +# do not place NL after if () +# +# bad split if(long-condition) to multiple lines +# + + +# +# + +input_tab_size = 2 # original tab size + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +indent_columns = 2 +indent_align_string = true +indent_braces = false +indent_namespace = true +indent_class = true +indent_class_colon = true +indent_func_call_param = true +indent_func_def_param = true +indent_func_proto_param = true +indent_func_class_param = true +indent_func_ctor_var_param = true +indent_template_param = true +indent_member = 0 +indent_switch_case = 2 +indent_access_spec = -2 +indent_paren_nl = false +indent_paren_close = 1 +indent_comma_paren = true + +## +## inter-character spacing options +## + +sp_arith = add +sp_assign = add +sp_enum_assign = add +sp_bool = add +sp_compare = add +sp_inside_paren = remove +sp_balance_nested_parens = false +sp_before_ptr_star = remove +sp_before_unnamed_ptr_star = remove +sp_between_ptr_star = remove +sp_after_ptr_star = add +sp_before_byref = remove +sp_before_unnamed_byref = ignore +sp_after_byref = add +sp_after_type = add +sp_template_angle = remove +sp_before_angle = remove +sp_inside_angle = remove +sp_after_angle = remove +sp_angle_paren = remove +sp_angle_word = add +sp_before_sparen = add +sp_inside_sparen = remove +sp_after_sparen = remove +sp_before_square = remove +sp_before_squares = remove +sp_inside_square = remove +sp_after_comma = add +sp_before_comma = remove +sp_after_class_colon = add +sp_before_class_colon = add +sp_after_operator = remove +sp_after_operator_sym = remove +sp_after_cast = add +sp_inside_paren_cast = remove +sp_sizeof_paren = remove +sp_inside_braces_enum = remove +sp_inside_braces_struct = remove +sp_inside_braces = remove +sp_inside_braces_empty = add +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = remove +sp_inside_fparen = remove +sp_square_fparen = remove +sp_func_call_paren = remove +sp_func_class_paren = remove +sp_return_paren = add +sp_attribute_paren = add +sp_defined_paren = add +sp_before_dc = remove +sp_after_dc = remove +sp_not = remove +sp_inv = remove +sp_addr = remove +sp_member = remove +sp_deref = remove +sp_sign = remove +sp_incdec = remove + + +## +## Aligning stuff +## + +align_with_tabs = false +align_on_tabstop = true +align_keep_tabs = true +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +#align_same_func_call_params = true +align_var_def_span = 0 +#align_var_def_star_style = 0 +#align_var_def_amp_style = 0 + + +# +# New Line +# + +nl_collapse_empty_body = false +nl_func_leave_one_liners = false +nl_if_leave_one_liners = false +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = add +nl_else_brace = add +nl_else_if = add +nl_try_brace = add +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = add +nl_while_brace = add +nl_do_brace = add +nl_brace_while = add +nl_switch_brace = add +#nl_multi_line_cond = true +nl_before_case = true +nl_before_throw = add +nl_after_case = true +nl_namespace_brace = add +nl_template_class = add +nl_class_brace = add +nl_class_init_args = ignore +nl_func_type_name = add +nl_func_proto_type_name = add +nl_func_paren = remove +#nl_func_decl_start +nl_fdef_brace = add +nl_after_semicolon = true +nl_after_vbrace_open = true +nl_create_if_one_liner = false +nl_create_for_one_liner = false +nl_create_while_one_liner = false +nl_after_access_spec = 1 + +# +# +# + +code_width = 78 +ls_for_split_full = true +ls_func_split_full = true +nl_after_access_spec = 1 +eat_blanks_after_open_brace = true + +# +# Code modifying options (non-whitespace) +# + +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = add +mod_full_brace_if = add +mod_full_brace_while = add +mod_paren_on_return = remove +mod_remove_extra_semicolon = true + diff --git a/tests/config/custom-open.cfg b/tests/config/custom-open.cfg new file mode 100644 index 0000000000..a371481ed5 --- /dev/null +++ b/tests/config/custom-open.cfg @@ -0,0 +1,25 @@ +# +# $Id: custom-open.cfg 803 2007-07-25 00:36:25Z bengardner $ + +indent_columns = 4 +output_tab_size = indent_columns + +indent_with_tabs = 1 + +# Spaces to indent 'case' from 'switch' +indent_switch_case = indent_columns # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # indent_columns # number + +align_assign_span = 1 +align_assign_thresh = 16 + +macro-open MACRO_BEGIN_STUFF +macro-else MACRO_ELSE_STUFF +macro-close MACRO_END_STUFF +macro-open MACRO2_BEGIN_STUFF +macro-else MACRO2_ELSE_STUFF +macro-close MACRO2_END_STUFF +type foorbar_t +define MYDEFINE 1 diff --git a/tests/config/custom-open2.cfg b/tests/config/custom-open2.cfg new file mode 100644 index 0000000000..186ce92d68 --- /dev/null +++ b/tests/config/custom-open2.cfg @@ -0,0 +1,25 @@ +# +# $Id: custom-open2.cfg 803 2007-07-25 00:36:25Z bengardner $ + +indent_columns = 4 +output_tab_size = indent_columns + +indent_with_tabs = 0 + +# Spaces to indent 'case' from 'switch' +indent_switch_case = indent_columns # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # indent_columns # number + +align_assign_span = 1 +align_assign_thresh = 16 + +macro-open MACRO_BEGIN_STUFF +macro-else MACRO_ELSE_STUFF +macro-close MACRO_END_STUFF +macro-open MACRO2_BEGIN_STUFF +macro-else MACRO2_ELSE_STUFF +macro-close MACRO2_END_STUFF +type foorbar_t +define MYDEFINE 1 diff --git a/tests/config/custom_types_ssl.cfg b/tests/config/custom_types_ssl.cfg new file mode 100644 index 0000000000..cd1991b8ce --- /dev/null +++ b/tests/config/custom_types_ssl.cfg @@ -0,0 +1,126 @@ +# patch 20090404-xxx needed to cope with such custom types as these: + +input_tab_size = 8 +output_tab_size = 4 +indent_with_tabs = 1 +indent_columns = 4 + + +align_func_params = true + + +indent_func_call_param = true +indent_func_def_param = true +indent_func_proto_param = true + +sp_arith = add +sp_assign = add + +# Add or remove space around preprocessor '##' concatenation operator +sp_pp_concat = remove +# Add or remove space after preprocessor '#' stringify operator +sp_pp_stringify = remove + + + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = true # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 1 # number + +# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) +align_right_cmt_at_col = 0 # number + + + +sp_bool = add +sp_compare = add + + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = remove + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = add + + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = add + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = add + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = add + + + + + + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 3 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 5 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 2 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 5 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + + + + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = true # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = true # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = true # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +set type_wrap STACK_OF LHASH_OF + diff --git a/tests/config/d-tst2.cfg b/tests/config/d-tst2.cfg new file mode 100644 index 0000000000..88e34ebcb8 --- /dev/null +++ b/tests/config/d-tst2.cfg @@ -0,0 +1,103 @@ +# +# My favorite format +# +# $Id: d-tst2.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +newlines = LF # AUTO (default), DOS, MAC, or UNIX + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 1 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_func_call_param = TRUE + +nl_start_of_file = remove +# nl_start_of_file_min = 0 +nl_end_of_file = force +nl_end_of_file_min = 1 + +nl_assign_brace = remove # "= {" vs "= \n {" +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = remove # "foo() {" vs "foo()\n{" +nl_fdef_brace = remove # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE +nl_after_case = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_func_class_paren = remove +sp_before_angle = force +sp_after_angle = force +sp_inside_angle = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 99 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +# indent_square_nl = false + diff --git a/tests/config/d.cfg b/tests/config/d.cfg new file mode 100644 index 0000000000..959a2006e3 --- /dev/null +++ b/tests/config/d.cfg @@ -0,0 +1,98 @@ +# +# My favorite format +# +# $Id: d.cfg 1492 2009-02-27 03:25:26Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_case_brace = indent_columns +indent_class = true + +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE +nl_after_brace_open = TRUE +#nl_func_leave_one_liners = FALSE +#nl_class_leave_one_liners = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_square = remove +sp_before_squares = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_range = force + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 +align_typedef_star_style = 1 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +indent_paren_nl = TRUE diff --git a/tests/config/d2.cfg b/tests/config/d2.cfg new file mode 100644 index 0000000000..e829cd4e02 --- /dev/null +++ b/tests/config/d2.cfg @@ -0,0 +1,111 @@ +# +# My favorite format +# +# $Id: d2.cfg 1492 2009-02-27 03:25:26Z bengardner $ +# + +newlines = auto # AUTO (default), DOS, MAC, or UNIX + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 1 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_case_brace = indent_columns +indent_class = true + +nl_start_of_file = remove +# nl_start_of_file_min = 0 +nl_end_of_file = force +nl_end_of_file_min = 1 + +nl_assign_brace = remove # "= {" vs "= \n {" +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = remove # "foo() {" vs "foo()\n{" +nl_fdef_brace = remove # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE +nl_after_brace_open = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_func_class_paren = remove +sp_before_angle = force +sp_after_angle = force +sp_inside_angle = remove +sp_else_brace = force +sp_paren_brace = force +sp_fparen_brace = force +sp_range = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 99 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE +nl_assign_square = remove +sp_inside_square = remove +sp_d_array_colon = force +nl_after_square_assign = force + + diff --git a/tests/config/d3.cfg b/tests/config/d3.cfg new file mode 100644 index 0000000000..939dbbc5e2 --- /dev/null +++ b/tests/config/d3.cfg @@ -0,0 +1,95 @@ +# +# $Id: d.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_case_brace = indent_columns + +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_square = remove +sp_before_squares = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 +align_typedef_star_style = 1 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +indent_paren_nl = TRUE + +nl_assign_square = remove + + diff --git a/tests/config/d3a.cfg b/tests/config/d3a.cfg new file mode 100644 index 0000000000..4bb6a90f65 --- /dev/null +++ b/tests/config/d3a.cfg @@ -0,0 +1,100 @@ +# +# $Id: d.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_case_brace = indent_columns + +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_square = remove +sp_before_squares = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 +align_typedef_star_style = 1 + +# cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +indent_paren_nl = TRUE + +nl_assign_square = force +sp_inside_square = force + +sp_d_array_colon = remove + +align_var_def_span = 2 +align_var_def_colon = true + diff --git a/tests/config/del_semicolon.cfg b/tests/config/del_semicolon.cfg new file mode 100644 index 0000000000..6bd451dbb1 --- /dev/null +++ b/tests/config/del_semicolon.cfg @@ -0,0 +1,8 @@ +# +# $Id: 1liner-split.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + + +mod_remove_extra_semicolon = true +sp_after_semi_for = remove + diff --git a/tests/config/delete.cfg b/tests/config/delete.cfg new file mode 100644 index 0000000000..efc95b383b --- /dev/null +++ b/tests/config/delete.cfg @@ -0,0 +1,3 @@ +indent_columns = 2 +sp_arith = force + diff --git a/tests/config/else-if-1.cfg b/tests/config/else-if-1.cfg new file mode 100644 index 0000000000..222740afcf --- /dev/null +++ b/tests/config/else-if-1.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 2 +indent_columns = 2 +nl_else_if = remove +indent_else_if = false + diff --git a/tests/config/else-if-2.cfg b/tests/config/else-if-2.cfg new file mode 100644 index 0000000000..4db08c13ce --- /dev/null +++ b/tests/config/else-if-2.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 2 +indent_columns = 2 +nl_else_if = remove +indent_else_if = true + diff --git a/tests/config/empty_body.cfg b/tests/config/empty_body.cfg new file mode 100644 index 0000000000..8661812d8d --- /dev/null +++ b/tests/config/empty_body.cfg @@ -0,0 +1,15 @@ +# +# $Id: empty_body.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 8 +indent_columns = 4 + +sp_arith = force +sp_after_ptr_star = force +sp_before_ptr_star = remove +sp_between_ptr_star = remove + +nl_collapse_empty_body = True + diff --git a/tests/config/endif.cfg b/tests/config/endif.cfg new file mode 100644 index 0000000000..30bbc84443 --- /dev/null +++ b/tests/config/endif.cfg @@ -0,0 +1,88 @@ +indent_func_def_param=true +indent_paren_nl=true +nl_after_brace_open=true +nl_after_return=true +nl_after_semicolon=true +nl_after_vbrace_open=true +nl_assign_leave_one_liners=true +nl_before_case=true +nl_collapse_empty_body=true +pp_define_at_level=true +pp_if_indent_code=true +pp_indent_at_level=true +pp_region_indent_code=true +indent_columns=3 +indent_with_tabs=0 +nl_end_of_file_min=1 +nl_func_var_def_blk=1 +pp_indent_region=3 +pp_space_count=3 +mod_full_brace_while=add +mod_paren_on_return=force +nl_after_do=force +nl_after_for=force +nl_after_if=force +nl_after_switch=force +nl_after_while=force +nl_before_do=force +nl_before_for=force +nl_before_if=force +nl_before_switch=force +nl_before_while=force +nl_brace_else=force +nl_brace_while=force +nl_class_brace=force +nl_else_brace=force +nl_elseif_brace=force +nl_end_of_file=force +nl_fcall_brace=force +nl_fdef_brace=force +nl_for_brace=force +nl_func_decl_args=force +nl_func_decl_end=add +nl_func_decl_start=force +nl_func_paren=force +nl_func_proto_type_name=remove +nl_func_type_name=remove +nl_if_brace=force +nl_while_brace=add +pos_class_comma=trail +pos_comma=trail +pp_indent=force +sp_after_cast=remove +sp_after_comma=force +sp_after_oc_type=remove +sp_after_ptr_star=add +sp_after_sparen=force +sp_arith=force +sp_assign=force +sp_before_comma=remove +sp_before_ptr_star=remove +sp_before_semi=remove +sp_before_semi_for=remove +sp_before_semi_for_empty=remove +sp_before_sparen=remove +sp_before_square=remove +sp_before_squares=remove +sp_bool=force +sp_brace_else=force +sp_compare=force +sp_deref=remove +sp_fparen_brace=force +sp_func_call_paren=remove +sp_func_def_paren=remove +sp_func_proto_paren=remove +sp_incdec=remove +sp_inside_braces=force +sp_inside_fparen=remove +sp_inside_fparens=remove +sp_inside_paren=remove +sp_inside_paren_cast=remove +sp_inside_sparen=remove +sp_macro=force +sp_macro_func=force +sp_member=remove +sp_not=remove +sp_paren_paren=remove +sp_return_paren=force +sp_type_func=force diff --git a/tests/config/file-header.h b/tests/config/file-header.h new file mode 100644 index 0000000000..63fb5185ca --- /dev/null +++ b/tests/config/file-header.h @@ -0,0 +1,6 @@ +/** + * @file $(filename) + * Description + * + * $Id$ + */ diff --git a/tests/config/file_footer.txt b/tests/config/file_footer.txt new file mode 100644 index 0000000000..7ce80badaa --- /dev/null +++ b/tests/config/file_footer.txt @@ -0,0 +1,6 @@ +/** + * CVS History: + * $Log $ + * + */ + diff --git a/tests/config/file_header.txt b/tests/config/file_header.txt new file mode 100644 index 0000000000..5431d0ffc7 --- /dev/null +++ b/tests/config/file_header.txt @@ -0,0 +1,7 @@ +/*******************************************************************************//** + * + * @file $(filename) + * + * + * + ***********************************************************************************/ diff --git a/tests/config/func-def-1.cfg b/tests/config/func-def-1.cfg new file mode 100644 index 0000000000..1342537e91 --- /dev/null +++ b/tests/config/func-def-1.cfg @@ -0,0 +1,21 @@ +# +# My favorite format +# +# $Id: func-def-1.cfg 1026 2007-11-17 02:57:27Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +nl_func_decl_start = Add # newline after the '(' in a function decl +nl_func_decl_args = Add # newline after each ',' in a function decl +nl_func_decl_end = Add # newline before the ')' in a function decl + +nl_func_type_name = Add # newline between return type and function def +nl_func_proto_type_name = Add # newline between return type and function proto + +sp_after_ptr_star = remove +sp_before_ptr_star = force + diff --git a/tests/config/func-def-2.cfg b/tests/config/func-def-2.cfg new file mode 100644 index 0000000000..6a29d97fcb --- /dev/null +++ b/tests/config/func-def-2.cfg @@ -0,0 +1,21 @@ +# +# My favorite format +# +# $Id: func-def-2.cfg 1026 2007-11-17 02:57:27Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +nl_func_decl_start = Ignore # newline after the '(' in a function decl +nl_func_decl_args = Ignore # newline after each ',' in a function decl +nl_func_decl_end = Remove # newline before the ')' in a function decl + +nl_func_type_name = Add # newline between return type and function def +nl_func_proto_type_name = Remove # newline between return type and function proto + +sp_after_ptr_star = remove +sp_before_ptr_star = force + diff --git a/tests/config/func-def-3.cfg b/tests/config/func-def-3.cfg new file mode 100644 index 0000000000..31e5631aa2 --- /dev/null +++ b/tests/config/func-def-3.cfg @@ -0,0 +1,22 @@ +# +# My favorite format +# +# $Id: func-def-3.cfg 1026 2007-11-17 02:57:27Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +# everything on one line (TODO: line length checks) +nl_func_decl_start = Remove # newline after the '(' in a function decl +nl_func_decl_args = Remove # newline after each ',' in a function decl +nl_func_decl_end = Remove # newline before the ')' in a function decl + +nl_func_type_name = Remove # newline between return type and function def +nl_func_proto_type_name = Remove # newline between return type and function proto + +sp_after_ptr_star = remove +sp_before_ptr_star = force + diff --git a/tests/config/func-header.h b/tests/config/func-header.h new file mode 100644 index 0000000000..e6f839434c --- /dev/null +++ b/tests/config/func-header.h @@ -0,0 +1,5 @@ +/** + * $(function) + * TODO: DESCRIPTION + * $(javaparam) + */ diff --git a/tests/config/func-header2.h b/tests/config/func-header2.h new file mode 100644 index 0000000000..52bdf970f2 --- /dev/null +++ b/tests/config/func-header2.h @@ -0,0 +1,6 @@ +/** + * CLASS: $(fclass) + * METHOD: $(function) + * TODO: DESCRIPTION + * $(javaparam) + */ diff --git a/tests/config/func_call_user.cfg b/tests/config/func_call_user.cfg new file mode 100644 index 0000000000..ad5c7d4a4a --- /dev/null +++ b/tests/config/func_call_user.cfg @@ -0,0 +1,927 @@ +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 4 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 4 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 4 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = false # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 4 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 4 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 4 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 4 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 1 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = force # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = true # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = remove # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = force # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = remove # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = remove # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = remove # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = force # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = force # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = force # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = force # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = force # ignore/add/remove/force +sp_func_call_user_paren = remove # ignore/add/remove/force + +set func_call_user _ N_ + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = force # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = force # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = force # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f: (int) x;' vs '+(int) f : (int) x;' +sp_before_oc_colon = force # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '+(int)f : (int)x;' +sp_after_oc_type = force # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 20 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 0 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 30 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 10 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 12 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 30 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 30 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 8 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 4 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 2 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 2 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_oc_msg_spec_span = 3 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 2 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 50 # number + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = force # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = force # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = add # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = true # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = add # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = remove # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = remove # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = true # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = true # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = add # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = add # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = add # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = add # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = add # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = add # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = add # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = add # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = add # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = add # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = true # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = true # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = trail # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 80 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = true # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = true # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 3 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 1 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 3 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 5 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 5 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 1 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 1 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 1 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = true # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = add # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 1 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 1 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 10 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_witdth columns +cmt_width = 80 # number + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = true # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 1 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = remove # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP + diff --git a/tests/config/func_wrap1.cfg b/tests/config/func_wrap1.cfg new file mode 100644 index 0000000000..29d31ef945 --- /dev/null +++ b/tests/config/func_wrap1.cfg @@ -0,0 +1,3 @@ +set func_wrap FSUB +sp_inside_fparen = ignore + diff --git a/tests/config/func_wrap2.cfg b/tests/config/func_wrap2.cfg new file mode 100644 index 0000000000..09a5160f9e --- /dev/null +++ b/tests/config/func_wrap2.cfg @@ -0,0 +1,3 @@ +set func_wrap FSUB +sp_inside_fparen = force + diff --git a/tests/config/function_header.txt b/tests/config/function_header.txt new file mode 100644 index 0000000000..c6508a02d4 --- /dev/null +++ b/tests/config/function_header.txt @@ -0,0 +1,9 @@ +/*********************************************************************************** + * $(function) + *******************************************************************************//** + * + * + * + * $(javaparam) + * + **********************************************************************************/ diff --git a/tests/config/ger.cfg b/tests/config/ger.cfg new file mode 100644 index 0000000000..eb862191d8 --- /dev/null +++ b/tests/config/ger.cfg @@ -0,0 +1,360 @@ +# Uncrustify 0.52+svn +newlines = auto +input_tab_size = 8 +output_tab_size = 4 +string_escape_char = 92 +string_escape_char2 = 0 +indent_columns = 4 +indent_with_tabs = 1 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_extern = false +indent_class = true +indent_class_colon = false +indent_else_if = true +indent_var_def_blk = 0 +indent_func_call_param = true +indent_func_def_param = true +indent_func_proto_param = true +indent_func_class_param = true +indent_func_ctor_var_param = true +indent_template_param = true +indent_func_param_double = true +indent_func_const = 0 +indent_func_throw = 0 +indent_member = 0 +indent_sing_line_comments = 0 +indent_relative_single_line_comments = false +indent_switch_case = 0 +indent_case_shift = 0 +indent_case_brace = 4 +indent_col1_comment = false +indent_label = 1 +indent_access_spec = 1 +indent_access_spec_body = false +indent_paren_nl = false +indent_paren_close = 1 +indent_comma_paren = false +indent_bool_paren = false +indent_square_nl = false +indent_preserve_sql = false +indent_align_assign = true +sp_arith = add +sp_assign = add +sp_before_assign = ignore +sp_after_assign = ignore +sp_enum_assign = add +sp_enum_before_assign = ignore +sp_enum_after_assign = ignore +sp_pp_concat = remove +sp_pp_stringify = remove +sp_bool = add +sp_compare = add +sp_inside_paren = ignore +sp_paren_paren = ignore +sp_balance_nested_parens = false +sp_paren_brace = add +sp_before_ptr_star = add +sp_before_unnamed_ptr_star = ignore +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_after_ptr_star_func = remove +sp_before_ptr_star_func = add +sp_before_byref = remove +sp_before_unnamed_byref = ignore +sp_after_byref = remove +sp_after_byref_func = remove +sp_before_byref_func = add +sp_after_type = add +sp_template_angle = remove +sp_before_angle = remove +sp_inside_angle = remove +sp_after_angle = ignore +sp_angle_paren = remove +sp_angle_word = add +sp_before_sparen = add +sp_inside_sparen = remove +sp_inside_sparen_close = ignore +sp_after_sparen = add +sp_sparen_brace = add +sp_invariant_paren = remove +sp_after_invariant_paren = add +sp_special_semi = add +sp_before_semi = remove +sp_before_semi_for = remove +sp_before_semi_for_empty = remove +sp_after_semi_for_empty = remove +sp_before_square = remove +sp_before_squares = remove +sp_inside_square = remove +sp_after_comma = add +sp_before_comma = remove +sp_after_class_colon = remove +sp_before_class_colon = remove +sp_before_case_colon = remove +sp_after_operator = add +sp_after_operator_sym = remove +sp_after_cast = remove +sp_inside_paren_cast = remove +sp_cpp_cast_paren = remove +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = add +sp_inside_braces_struct = add +sp_inside_braces = add +sp_inside_braces_empty = remove +sp_type_func = remove +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = remove +sp_inside_fparen = remove +sp_square_fparen = remove +sp_fparen_brace = add +sp_func_call_paren = remove +sp_func_call_user_paren = remove +sp_func_class_paren = remove +sp_return_paren = add +sp_attribute_paren = remove +sp_defined_paren = remove +sp_throw_paren = remove +sp_macro = add +sp_macro_func = add +sp_else_brace = add +sp_brace_else = add +sp_brace_typedef = add +sp_catch_brace = add +sp_brace_catch = add +sp_finally_brace = add +sp_brace_finally = add +sp_try_brace = add +sp_getset_brace = add +sp_before_dc = remove +sp_after_dc = remove +sp_d_array_colon = ignore +sp_not = remove +sp_inv = remove +sp_addr = remove +sp_member = remove +sp_deref = remove +sp_sign = remove +sp_incdec = remove +sp_before_nl_cont = add +sp_after_oc_scope = remove +sp_after_oc_colon = add +sp_before_oc_colon = add +sp_after_send_oc_colon = add +sp_before_send_oc_colon = remove +sp_after_oc_type = add +sp_cond_colon = add +sp_cond_question = add +sp_case_label = ignore +sp_range = ignore +sp_cmt_cpp_start = add +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = false +align_func_params = false +align_same_func_call_params = false +align_var_def_span = 3 +align_var_def_star_style = 0 +align_var_def_amp_style = 0 +align_var_def_thresh = 5 +align_var_def_gap = 0 +align_var_def_colon = true +align_var_def_attribute = false +align_var_def_inline = true +align_assign_span = 0 +align_assign_thresh = 0 +align_enum_equ_span = 3 +align_enum_equ_thresh = 5 +align_var_struct_span = 2 +align_var_struct_thresh = 5 +align_var_struct_gap = 0 +align_struct_init_span = 3 +align_typedef_gap = 0 +align_typedef_span = 0 +align_typedef_func = 0 +align_typedef_star_style = 0 +align_typedef_amp_style = 0 +align_right_cmt_span = 4 +align_right_cmt_mix = true +# note the use of -5 here (-1 would probably have worked as well) to force +# comments which are stuck to the previous token (gap=0) into alignment with the +# others. Not the major feature, but a nice find. (min_val/max_val in +# options.cpp isn't validated against, it seems; well, I don't mind! :-) ) +align_right_cmt_gap = -5 +align_right_cmt_at_col = 1 +align_func_proto_span = 0 +align_func_proto_gap = 0 +align_on_operator = true +align_mix_var_proto = false +align_single_line_func = false +align_single_line_brace = false +align_single_line_brace_gap = 0 +align_oc_msg_spec_span = 0 +align_nl_cont = false +align_pp_define_gap = 0 +align_pp_define_span = 0 +align_left_shift = true +nl_collapse_empty_body = true +nl_assign_leave_one_liners = true +nl_class_leave_one_liners = true +nl_enum_leave_one_liners = true +nl_getset_leave_one_liners = true +nl_func_leave_one_liners = true +nl_if_leave_one_liners = false +nl_start_of_file = remove +nl_start_of_file_min = 0 +nl_end_of_file = add +nl_end_of_file_min = 2 +nl_assign_brace = ignore +nl_assign_square = ignore +nl_after_square_assign = ignore +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = add +nl_else_brace = add +nl_else_if = remove +nl_brace_finally = add +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = add +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = add +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_multi_line_cond = true +nl_multi_line_define = true +nl_before_case = true +nl_before_throw = add +nl_after_case = true +nl_namespace_brace = add +nl_template_class = ignore +nl_class_brace = add +nl_class_init_args = ignore +nl_func_type_name = remove +nl_func_scope_name = remove +nl_func_proto_type_name = remove +nl_func_paren = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_return_expr = remove +nl_after_semicolon = true +nl_after_brace_open = true +nl_after_brace_open_cmt = true +nl_after_vbrace_open = true +nl_after_brace_close = false +nl_define_macro = false +nl_squeeze_ifdef = false +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = true +nl_ds_struct_enum_close_brace = false +nl_class_colon = remove +nl_create_if_one_liner = false +nl_create_for_one_liner = false +nl_create_while_one_liner = false +pos_arith = ignore +pos_assign = ignore +pos_bool = ignore +pos_comma = ignore +pos_class_comma = ignore +pos_class_colon = ignore +code_width = 200 +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 2 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +nl_after_multiline_comment = false +nl_before_access_spec = 1 +nl_after_access_spec = 0 +nl_comment_func_def = 0 +nl_after_try_catch_finally = 0 +nl_around_cs_property = 0 +nl_between_get_set = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = ignore +mod_full_brace_for = ignore +mod_full_brace_function = ignore +mod_full_brace_if = ignore +mod_full_brace_nl = 1 +mod_full_brace_while = ignore +mod_paren_on_return = remove +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +mod_remove_extra_semicolon = false +mod_add_long_function_closebrace_comment = 1000 +mod_add_long_switch_closebrace_comment = 500 +mod_add_long_ifdef_endif_comment = 1 +mod_add_long_ifdef_else_comment = 1 +mod_sort_import = true +mod_sort_using = true +mod_sort_include = false +mod_move_case_break = false +mod_remove_empty_return = true +cmt_width = 0 +cmt_indent_multi = true +cmt_c_group = false +cmt_c_nl_start = true +cmt_c_nl_end = true +cmt_cpp_group = true +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +cmt_multi_check_last = true +cmt_insert_file_header = "" +cmt_insert_file_footer = "" +cmt_insert_func_header = "" +cmt_insert_class_header = "" +cmt_insert_before_preproc = false +pp_indent = ignore +pp_indent_at_level = false +pp_indent_count = 1 +pp_space = ignore +pp_space_count = 1 +pp_indent_region = 0 +pp_region_indent_code = false +pp_indent_if = 0 +pp_if_indent_code = false +pp_define_at_level = false +type BIO +set type_wrap LHASH_OF STACK_OF +set FUNCTION TYPEDEF_D2I_OF +type stname +type type + diff --git a/tests/config/getset.cfg b/tests/config/getset.cfg new file mode 100644 index 0000000000..b54471daef --- /dev/null +++ b/tests/config/getset.cfg @@ -0,0 +1,92 @@ +# +# Mono library format +# +# $Id: getset.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size +indent_label = 1 # pos: absolute col, neg: relative column +# indent_align_string = False # align broken strings +# brace_indent = 0 +indent_func_call_param = true # use indent tabstop + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = remove # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +sp_before_square = add +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = force # "int foo (){" vs "int foo(){" +sp_func_call_paren = force # "foo (" vs "foo(" +sp_func_proto_paren = force # "int foo ();" vs "int foo();" + +# align_with_tabs = FALSE # use tabs to align +# align_on_tabstop = FALSE # align on tabstops +# align_enum_equ_span = 4 +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +align_var_def_star_style = 1 +# align_var_def_colon = TRUE +# align_assign_span = 1 +# align_struct_init_span = 3 +# align_var_struct_span = 3 +# align_right_cmt_span = 3 +# align_pp_define_span = 3 +# align_pp_define_gap = 4 +# align_number_left = TRUE +# align_typedef_span = 5 +# align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +nl_getset_brace = force +sp_getset_brace = force +nl_after_brace_open = true + diff --git a/tests/config/if_chain.cfg b/tests/config/if_chain.cfg new file mode 100644 index 0000000000..f19271e7f3 --- /dev/null +++ b/tests/config/if_chain.cfg @@ -0,0 +1,116 @@ +# +# uncrustify config file for the linux kernel +# +# $Id: linux.cfg 488 2006-09-09 12:44:38Z bengardner $ +# + +indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size + +indent_label = 2 # pos: absolute col, neg: relative column + + +# +# inter-symbol newlines +# + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_brace_while = remove # "} while" vs "} \n while" - cuddle while +nl_brace_else = remove # "} else" vs "} \n else" - cuddle else +sp_brace_else = force +sp_else_brace = force +nl_func_var_def_blk = 1 +nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE; +# nl_before_case = 1 + + +# +# Source code modifications +# + +mod_paren_on_return = remove # "return 1;" vs "return (1);" +#mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_if_chain = true +mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = remove # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }" +mod_full_brace_nl = 3 # don't remove if more than 3 newlines + + +# +# inter-character spacing options +# + +# sp_return_paren = force # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_assign = add +sp_arith = add +sp_bool = add +sp_compare = add +sp_assign = add +sp_after_comma = add +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" + + +# +# Aligning stuff +# + +align_with_tabs = TRUE # use tabs to align +align_on_tabstop = TRUE # align on tabstops +# align_keep_tabs = true +align_enum_equ_span = 4 # '=' in enum definition +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +# align_var_def_star = FALSE +# align_var_def_colon = TRUE +# align_assign_span = 1 +align_struct_init_span = 3 # align stuff in a structure init '= { }' +align_right_cmt_span = 3 +# align_pp_define_span = 8; +# align_pp_define_gap = 4; + +cmt_star_cont = true + +# indent_brace = 0 + +mod_add_long_ifdef_endif_comment = 1 +mod_add_long_ifdef_else_comment = 1 +nl_func_paren = remove +nl_func_decl_start = remove +nl_func_decl_empty = remove +nl_func_decl_args = remove +nl_func_decl_end = remove +sp_inside_paren = remove +sp_inside_paren_cast = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_paren_paren = remove +sp_after_comma = force +sp_before_ptr_star = force +sp_after_ptr_star = remove +sp_between_ptr_star = remove +align_func_params = true +align_var_struct_span = 6 + diff --git a/tests/config/indent-1.cfg b/tests/config/indent-1.cfg new file mode 100644 index 0000000000..a0142ba1bc --- /dev/null +++ b/tests/config/indent-1.cfg @@ -0,0 +1,12 @@ +# $Id: indent-1.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs +input_tab_size = 4 # original tab size +output_tab_size = 4 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_member = indent_columns +indent_switch_case = indent_columns diff --git a/tests/config/indent.cfg b/tests/config/indent.cfg new file mode 100644 index 0000000000..708a814f76 --- /dev/null +++ b/tests/config/indent.cfg @@ -0,0 +1,14 @@ +# +# Indents the code and aligns trailing comments +# + +indent_with_tabs = 0 # 0=spaces, 1=tabs, 2=indent to level only + +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size + +indent_label = 2 # pos: absolute col, neg: relative column + +align_right_cmt_span = 3 # within x lines + diff --git a/tests/config/indent_func_call_param.cfg b/tests/config/indent_func_call_param.cfg new file mode 100644 index 0000000000..00e4dd1c78 --- /dev/null +++ b/tests/config/indent_func_call_param.cfg @@ -0,0 +1,10 @@ +indent_func_call_param = true +indent_func_def_param = false +indent_func_proto_param = false + +indent_columns = 3 +indent_with_tabs = 1 +output_tab_size = indent_columns + +nl_func_type_name = force + diff --git a/tests/config/indent_func_def_param.cfg b/tests/config/indent_func_def_param.cfg new file mode 100644 index 0000000000..d964ab1ca2 --- /dev/null +++ b/tests/config/indent_func_def_param.cfg @@ -0,0 +1,10 @@ +indent_func_call_param = false +indent_func_def_param = true +indent_func_proto_param = false + +indent_columns = 3 +indent_with_tabs = 1 +output_tab_size = indent_columns + +nl_func_proto_type_name = force + diff --git a/tests/config/indent_func_param.cfg b/tests/config/indent_func_param.cfg new file mode 100644 index 0000000000..3d8e8a7043 --- /dev/null +++ b/tests/config/indent_func_param.cfg @@ -0,0 +1,8 @@ +indent_func_call_param = true +indent_func_def_param = true +indent_func_proto_param = true + +indent_columns = 3 +indent_with_tabs = 1 +output_tab_size = indent_columns + diff --git a/tests/config/indent_func_proto_param.cfg b/tests/config/indent_func_proto_param.cfg new file mode 100644 index 0000000000..8fc638d179 --- /dev/null +++ b/tests/config/indent_func_proto_param.cfg @@ -0,0 +1,8 @@ +indent_func_call_param = false +indent_func_def_param = false +indent_func_proto_param = true + +indent_columns = 3 +indent_with_tabs = 1 +output_tab_size = indent_columns + diff --git a/tests/config/indent_namespace-f.cfg b/tests/config/indent_namespace-f.cfg new file mode 100644 index 0000000000..e45774f38a --- /dev/null +++ b/tests/config/indent_namespace-f.cfg @@ -0,0 +1,6 @@ +# +# $Id: nl_namespace-r.cfg 803 2007-07-25 00:36:25Z bengardner $ + +indent_class = True +indent_namespace = False + diff --git a/tests/config/indent_namespace-t.cfg b/tests/config/indent_namespace-t.cfg new file mode 100644 index 0000000000..14af2cb367 --- /dev/null +++ b/tests/config/indent_namespace-t.cfg @@ -0,0 +1,6 @@ +# +# $Id: nl_namespace-r.cfg 803 2007-07-25 00:36:25Z bengardner $ + +indent_class = True +indent_namespace = True + diff --git a/tests/config/indent_paren_close-0.cfg b/tests/config/indent_paren_close-0.cfg new file mode 100644 index 0000000000..832d823e7a --- /dev/null +++ b/tests/config/indent_paren_close-0.cfg @@ -0,0 +1,8 @@ + +indent_with_tabs = 1 +input_tab_size = 8 +output_tab_size = 8 +indent_columns = output_tab_size + +indent_paren_close = 0 + diff --git a/tests/config/indent_paren_close-1.cfg b/tests/config/indent_paren_close-1.cfg new file mode 100644 index 0000000000..88d8800ecf --- /dev/null +++ b/tests/config/indent_paren_close-1.cfg @@ -0,0 +1,17 @@ + +indent_with_tabs = 1 +input_tab_size = 8 +output_tab_size = 8 +indent_columns = output_tab_size + +indent_paren_close = 1 +indent_comma_paren = true +indent_bool_paren = true + +sp_after_comma = force +sp_inside_fparen = force +sp_inside_sparen = force +sp_inside_paren = force +pos_comma = lead + + diff --git a/tests/config/indent_paren_close-2.cfg b/tests/config/indent_paren_close-2.cfg new file mode 100644 index 0000000000..0f5441e780 --- /dev/null +++ b/tests/config/indent_paren_close-2.cfg @@ -0,0 +1,8 @@ + +indent_with_tabs = 1 +input_tab_size = 8 +output_tab_size = 8 +indent_columns = output_tab_size + +indent_paren_close = 2 + diff --git a/tests/config/indent_var_def.cfg b/tests/config/indent_var_def.cfg new file mode 100644 index 0000000000..41e59c17b2 --- /dev/null +++ b/tests/config/indent_var_def.cfg @@ -0,0 +1,1111 @@ +# Uncrustify 0.50+svn +# $Id: ben.cfg 1421 2008-11-14 00:56:36Z bengardner $ +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 3 # number + +indent_var_def_blk = -indent_columns + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 3 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = ignore # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, ie 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '-(int) f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = remove # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 1 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 16 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = true # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = force # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = force # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = force # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = force # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = true # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 3 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 1 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = true # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = true # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = force # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ diff --git a/tests/config/kw_subst.cfg b/tests/config/kw_subst.cfg new file mode 100644 index 0000000000..805b72d609 --- /dev/null +++ b/tests/config/kw_subst.cfg @@ -0,0 +1,9 @@ + +cmt_insert_file_header = file-header.h +cmt_insert_func_header = func-header.h +cmt_insert_class_header = class-header.h + +cmt_insert_before_preproc = true + +indent_namespace = true + diff --git a/tests/config/kw_subst2.cfg b/tests/config/kw_subst2.cfg new file mode 100644 index 0000000000..4a889fff0a --- /dev/null +++ b/tests/config/kw_subst2.cfg @@ -0,0 +1,5 @@ + +cmt_insert_file_header = file-header.h +cmt_insert_func_header = func-header2.h +cmt_insert_class_header = class-header.h + diff --git a/tests/config/kw_subst3.cfg b/tests/config/kw_subst3.cfg new file mode 100644 index 0000000000..c46b2964bb --- /dev/null +++ b/tests/config/kw_subst3.cfg @@ -0,0 +1,972 @@ +# Uncrustify 0.46 + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 4 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 4 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 4 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = false # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 4 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = add # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = add # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = add # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = add # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = add # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space between type and word +sp_after_type = force # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = ignore # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = add # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = add # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = add # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = ignore # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = add # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = ignore # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = ignore # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = ignore # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = ignore # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = add # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = ignore # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = ignore # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f: (int) x;' vs '+(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '+(int)f : (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 10 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 1 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 1 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 10 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 4 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 10 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = add # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = ignore # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = true # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 0 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 4 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 4 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 4 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = ignore # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 50 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 50 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# Whether to mess with the indent of multi-line comments +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 1 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "file_header.txt" # string +cmt_insert_file_footer = "file_footer.txt" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "function_header.txt" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = ignore # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = true # false/true + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = true # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = true # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP diff --git a/tests/config/long_namespace.cfg b/tests/config/long_namespace.cfg new file mode 100644 index 0000000000..c6bdb3de1d --- /dev/null +++ b/tests/config/long_namespace.cfg @@ -0,0 +1,2 @@ +indent_namespace = true +indent_namespace_limit = 6 diff --git a/tests/config/misc6.cfg b/tests/config/misc6.cfg new file mode 100644 index 0000000000..b27eea3c01 --- /dev/null +++ b/tests/config/misc6.cfg @@ -0,0 +1,4 @@ +sp_after_angle = remove +sp_before_ptr_star = force +sp_before_byref = force + diff --git a/tests/config/mod-paren.cfg b/tests/config/mod-paren.cfg new file mode 100644 index 0000000000..ad000a6544 --- /dev/null +++ b/tests/config/mod-paren.cfg @@ -0,0 +1,517 @@ +# +# My favorite format ("--update-config-with-doc") +# +# $Id: mod-paren.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 3 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 0 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +align_func_params = true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 1 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 12 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force + +nl_getset_brace = force + +mod_full_paren_if_bool = true + diff --git a/tests/config/mod-paren2.cfg b/tests/config/mod-paren2.cfg new file mode 100644 index 0000000000..e186dc910b --- /dev/null +++ b/tests/config/mod-paren2.cfg @@ -0,0 +1,517 @@ +# +# My favorite format ("--update-config-with-doc") +# +# $Id: mod-paren.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\). (Pawn) +string_escape_char = 92 # number + +# +# Indenting +# + +# The number of columns to indent per level (usually 2, 3, 4, or 8) +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to indent_columns. +indent_member = 3 # number + +# Spaces to indent 'case' from 'switch' +indent_switch_case = 0 # number + +# Spaces to indent '{' from 'case' +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels (>0=absolute column where 1 is the leftmost column, <=0=subtract from brace indent) +indent_label = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = force # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name (a minimum of 1 is forced except for pointer return types) +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +align_func_params = true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# Whether the pointer star is part of the variable name or not +align_var_def_star_style = 1 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 12 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type: typedef int * pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of the function body +nl_after_func_body = 2 # number + +# The minimum number of newlines before a multi-line comment (doesn't apply if after a brace open) +nl_before_block_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force + +nl_getset_brace = force + +mod_full_paren_if_bool = true + diff --git a/tests/config/mod_case_brace_add.cfg b/tests/config/mod_case_brace_add.cfg new file mode 100644 index 0000000000..ef4eba3329 --- /dev/null +++ b/tests/config/mod_case_brace_add.cfg @@ -0,0 +1,1179 @@ +# Uncrustify 0.52+svn + +mod_case_brace = add + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute +indent_var_def_blk = 0 # number + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 3 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 3 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = true # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':' +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, ie 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '-(int) f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = remove # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A' +sp_cmt_cpp_start = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 1 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 16 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align any attribute after the variable name +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Align function protos on the 'operator' keyword instead of what follows +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = true # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = force # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = force # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = force # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = force # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = true # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name in a definition +# Controls the newline after '::' in 'void A::f() { }' +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 3 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 1 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = true # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = true # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = remove # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ diff --git a/tests/config/mod_case_brace_rm.cfg b/tests/config/mod_case_brace_rm.cfg new file mode 100644 index 0000000000..2adeaf558a --- /dev/null +++ b/tests/config/mod_case_brace_rm.cfg @@ -0,0 +1,1179 @@ +# Uncrustify 0.52+svn + +mod_case_brace = remove + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 3 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 3 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute +indent_var_def_blk = 0 # number + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 3 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 3 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = true # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = ignore # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':' +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, ie 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = force # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = remove # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '-(int) f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = remove # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A' +sp_cmt_cpp_start = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 1 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 16 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align any attribute after the variable name +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 12 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 16 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 99 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 3 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 3 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 5 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Align function protos on the 'operator' keyword instead of what follows +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 4 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 3 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = true # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = add # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = add # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = force # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = force # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = force # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = force # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = true # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name in a definition +# Controls the newline after '::' in 'void A::f() { }' +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = true # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 4 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 3 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 1 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = true # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = true # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = true # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = remove # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ diff --git a/tests/config/mono.cfg b/tests/config/mono.cfg new file mode 100644 index 0000000000..0bc755c759 --- /dev/null +++ b/tests/config/mono.cfg @@ -0,0 +1,89 @@ +# +# Mono library format +# +# $Id: mono.cfg 947 2007-10-01 17:42:41Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 8 # new tab size +indent_columns = output_tab_size +indent_label = 1 # pos: absolute col, neg: relative column +# indent_align_string = False # align broken strings +# brace_indent = 0 +indent_func_call_param = true # use indent tabstop +indent_class = true + +nl_enum_brace = remove # "enum {" vs "enum \n {" +nl_union_brace = remove # "union {" vs "union \n {" +nl_struct_brace = remove # "struct {" vs "struct \n {" +nl_do_brace = remove # "do {" vs "do \n {" +nl_if_brace = remove # "if () {" vs "if () \n {" +nl_for_brace = remove # "for () {" vs "for () \n {" +nl_else_brace = remove # "else {" vs "else \n {" +nl_while_brace = remove # "while () {" vs "while () \n {" +nl_switch_brace = remove # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = remove # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +# nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +# mod_paren_on_return = add # "return 1;" vs "return (1);" +# mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +# mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +# mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +# mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +sp_before_square = add +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = force # "int foo (){" vs "int foo(){" +sp_func_call_paren = force # "foo (" vs "foo(" +sp_func_proto_paren = force # "int foo ();" vs "int foo();" + +# align_with_tabs = FALSE # use tabs to align +# align_on_tabstop = FALSE # align on tabstops +# align_enum_equ_span = 4 +# align_nl_cont = TRUE +# align_var_def_span = 2 +# align_var_def_inline = TRUE +align_var_def_star_style = 1 +# align_var_def_colon = TRUE +# align_assign_span = 1 +# align_struct_init_span = 3 +# align_var_struct_span = 3 +# align_right_cmt_span = 3 +# align_pp_define_span = 3 +# align_pp_define_gap = 4 +# align_number_left = TRUE +# align_typedef_span = 5 +# align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + diff --git a/tests/config/multi.cfg b/tests/config/multi.cfg new file mode 100644 index 0000000000..a356cfa138 --- /dev/null +++ b/tests/config/multi.cfg @@ -0,0 +1,3 @@ + +cmt_indent_multi = false + diff --git a/tests/config/newline_after_endif.cfg b/tests/config/newline_after_endif.cfg new file mode 100644 index 0000000000..177ecea7fd --- /dev/null +++ b/tests/config/newline_after_endif.cfg @@ -0,0 +1,160 @@ +align_func_params=true +align_keep_tabs=false +align_nl_cont=false +align_number_left=false +align_on_tabstop=false +align_right_cmt_mix=false +align_var_def_colon=false +align_var_def_inline=false +align_with_tabs=false +cmt_c_group=false +cmt_c_nl_end=false +cmt_c_nl_start=false +cmt_cpp_group=false +cmt_cpp_nl_end=false +cmt_cpp_nl_start=false +cmt_cpp_to_c=false +cmt_star_cont=false +eat_blanks_after_open_brace=false +eat_blanks_before_close_brace=false +indent_align_string=false +indent_bool_paren=false +indent_brace_parent=false +indent_braces=false +indent_braces_no_func=false +indent_class=false +indent_class_colon=false +indent_col1_comment=false +indent_comma_paren=false +indent_func_call_param=false +indent_func_class_param=false +indent_func_ctor_var_param=false +indent_func_def_param=true +indent_func_param_double=false +indent_func_proto_param=false +indent_namespace=false +indent_paren_nl=true +indent_preserve_sql=false +indent_square_nl=false +ls_for_split_full=false +ls_func_split_full=false +mod_full_paren_if_bool=false +mod_pawn_semicolon=false +mod_remove_extra_semicolon=true +mod_sort_import=false +mod_sort_include=false +mod_sort_using=false +nl_after_brace_open=true +nl_after_brace_open_cmt=false +nl_after_case=false +nl_after_multiline_comment=false +nl_after_return=true +nl_after_semicolon=true +nl_after_vbrace_open=true +nl_assign_leave_one_liners=true +nl_before_case=true +nl_class_leave_one_liners=false +nl_collapse_empty_body=true +nl_create_for_one_liner=false +nl_create_if_one_liner=false +nl_create_while_one_liner=false +nl_define_macro=false +nl_ds_struct_enum_close_brace=false +nl_ds_struct_enum_cmt=false +nl_enum_leave_one_liners=false +nl_func_leave_one_liners=false +nl_getset_leave_one_liners=false +nl_if_leave_one_liners=false +nl_multi_line_cond=false +nl_squeeze_ifdef=true +pp_define_at_level=true +pp_if_indent_code=true +pp_indent_at_level=true +pp_region_indent_code=true +sp_balance_nested_parens=false +align_assign_span=0 +align_right_cmt_span=3 +align_var_def_span=1 +align_var_def_star_style=0 +cmt_width=108 +code_width=108 +indent_case_brace=0 +indent_case_shift=0 +indent_columns=3 +indent_switch_case=3 +indent_with_tabs=0 +input_tab_size=3 +mod_add_long_function_closebrace_comment=1 +mod_add_long_switch_closebrace_comment=16 +nl_end_of_file_min=2 +nl_func_var_def_blk=1 +pp_indent_region=3 +pp_space_count=3 +mod_paren_on_return=force +nl_after_do=force +nl_after_for=force +nl_after_if=force +nl_after_switch=force +nl_after_while=force +nl_before_do=force +nl_before_for=force +nl_before_if=force +nl_before_switch=force +nl_before_while=force +nl_brace_else=force +nl_brace_while=force +nl_class_brace=force +nl_else_brace=force +nl_elseif_brace=force +nl_end_of_file=force +nl_fcall_brace=force +nl_fdef_brace=force +nl_for_brace=force +nl_func_decl_args=force +nl_func_decl_end=add +nl_func_decl_start=force +nl_func_paren=force +nl_func_proto_type_name=remove +nl_func_type_name=remove +nl_if_brace=force +nl_while_brace=add +pos_class_comma=trail +pos_comma=trail +pp_indent=force +sp_after_cast=remove +sp_after_comma=force +sp_after_oc_type=remove +sp_after_ptr_star=add +sp_after_sparen=force +sp_arith=force +sp_assign=force +sp_before_comma=remove +sp_before_ptr_star=remove +sp_before_semi=remove +sp_before_semi_for=remove +sp_before_semi_for_empty=remove +sp_before_sparen=remove +sp_before_square=remove +sp_before_squares=remove +sp_bool=force +sp_brace_else=force +sp_compare=force +sp_deref=remove +sp_fparen_brace=force +sp_func_call_paren=remove +sp_func_def_paren=remove +sp_func_proto_paren=remove +sp_incdec=remove +sp_inside_braces=force +sp_inside_fparen=remove +sp_inside_fparens=remove +sp_inside_paren=remove +sp_inside_paren_cast=remove +sp_inside_sparen=remove +sp_macro=force +sp_macro_func=force +sp_member=remove +sp_not=remove +sp_paren_paren=remove +sp_return_paren=force +sp_type_func=force diff --git a/tests/config/nl-comment.cfg b/tests/config/nl-comment.cfg new file mode 100644 index 0000000000..3375b35d74 --- /dev/null +++ b/tests/config/nl-comment.cfg @@ -0,0 +1,105 @@ +# +# My favorite format +# +# $Id: nl-comment.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_access_spec = 2 +indent_align_string = False # align broken strings +indent_brace = 0 +indent_member = indent_columns + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_try_brace = add # "for () {" vs "for () \n {" +nl_catch_brace = add # "for () {" vs "for () \n {" +nl_finally_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_func_params = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +# align_assign_thresh = 8 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +# indent_namespace = FALSE +indent_class = TRUE + +nl_before_c_comment = 3 +nl_before_block_comment = 3 +nl_before_cpp_comment = 4 + diff --git a/tests/config/nl_access_spec.cfg b/tests/config/nl_access_spec.cfg new file mode 100644 index 0000000000..7be9257a80 --- /dev/null +++ b/tests/config/nl_access_spec.cfg @@ -0,0 +1,8 @@ +nl_before_access_spec = 3 +nl_after_access_spec = 2 +indent_access_spec = 2 +indent_class = true +nl_after_brace_open = true +nl_after_semicolon = true +nl_class_brace = force + diff --git a/tests/config/nl_after_func_body-2.cfg b/tests/config/nl_after_func_body-2.cfg new file mode 100644 index 0000000000..4e4217fc7d --- /dev/null +++ b/tests/config/nl_after_func_body-2.cfg @@ -0,0 +1,16 @@ +# $Id: nl_after_func_body-2.cfg 1149 2008-03-06 04:25:09Z bengardner $ + +indent_class = true + +nl_fdef_brace = remove + +nl_class_leave_one_liners = true + +nl_after_func_body = 4 +nl_after_func_body_one_liner = 2 + +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true + +sp_fparen_brace = force + diff --git a/tests/config/nl_after_func_body.cfg b/tests/config/nl_after_func_body.cfg new file mode 100644 index 0000000000..008ee23925 --- /dev/null +++ b/tests/config/nl_after_func_body.cfg @@ -0,0 +1,13 @@ +# $Id: nl_after_func_body.cfg 1149 2008-03-06 04:25:09Z bengardner $ + +indent_class = true + +nl_fdef_brace = remove + +nl_after_func_body = 4 + +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true + +sp_fparen_brace = force + diff --git a/tests/config/nl_assign1.cfg b/tests/config/nl_assign1.cfg new file mode 100644 index 0000000000..de716d1d75 --- /dev/null +++ b/tests/config/nl_assign1.cfg @@ -0,0 +1,9 @@ + +indent_with_tabs=0 +indent_columns=4 +code_width=60 +pos_assign = lead +pos_arith = lead +sp_arith = force +sp_assign = force + diff --git a/tests/config/nl_assign2.cfg b/tests/config/nl_assign2.cfg new file mode 100644 index 0000000000..c6876cdfaf --- /dev/null +++ b/tests/config/nl_assign2.cfg @@ -0,0 +1,9 @@ + +indent_with_tabs=0 +indent_columns=4 +code_width=60 +pos_assign = trail +pos_arith = trail +sp_arith = force +sp_assign = force + diff --git a/tests/config/nl_brace_brace-a.cfg b/tests/config/nl_brace_brace-a.cfg new file mode 100644 index 0000000000..3421bb0413 --- /dev/null +++ b/tests/config/nl_brace_brace-a.cfg @@ -0,0 +1,3 @@ + +nl_brace_brace = add + diff --git a/tests/config/nl_brace_test.cfg b/tests/config/nl_brace_test.cfg new file mode 100644 index 0000000000..7bd6dae178 --- /dev/null +++ b/tests/config/nl_brace_test.cfg @@ -0,0 +1,1137 @@ +# Uncrustify 0.50+svn + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 8 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 2 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = false # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = true # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = false # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = true # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = add # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = add # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = remove # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = add # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = add # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = ignore # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word +sp_after_type = force # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = add # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = remove # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = add # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = add # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = ignore # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = add # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':' +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = ignore # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, ie 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = ignore # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, ie 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = ignore # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = add # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = add # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = add # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = add # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = add # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = ignore # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = add # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = add # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = add # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = add # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = add # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = add # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = add # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = add # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = add # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = add # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = add # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = add # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = add # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7' +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;' +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int) f: (int) x;' vs '-(int) f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = ignore # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 1 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 2 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 1 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 1 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 1 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 1 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 1 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 1 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 2 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 1 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = true # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. +align_right_cmt_gap = 1 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 1 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = true # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = add # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = add # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = add # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = add # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = force # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = add # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = add # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = add # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = add # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = ignore # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = true # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = force # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = force # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = force # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/lead/trail + +# The position of assignment in wrapped expressions +pos_assign = ignore # ignore/lead/trail + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 96 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = true # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 0 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 0 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 0 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a mulit-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 0 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = add # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = add # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = false # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = true # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = true # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = true # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = true # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = true # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = true # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = true # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitue $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceeded with a C/C++ comment. +# Will substitue $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceeded with a C/C++ comment. +# Will substitue $(class) with the class name. +cmt_insert_class_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = ignore # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ diff --git a/tests/config/nl_class-a.cfg b/tests/config/nl_class-a.cfg new file mode 100644 index 0000000000..6c7787d95e --- /dev/null +++ b/tests/config/nl_class-a.cfg @@ -0,0 +1,7 @@ +# +# $Id: nl_class-a.cfg 803 2007-07-25 00:36:25Z bengardner $ + +nl_class_brace = Add +indent_class = True +indent_namespace = True + diff --git a/tests/config/nl_class-r.cfg b/tests/config/nl_class-r.cfg new file mode 100644 index 0000000000..379ced41ff --- /dev/null +++ b/tests/config/nl_class-r.cfg @@ -0,0 +1,7 @@ +# +# $Id: nl_class-r.cfg 803 2007-07-25 00:36:25Z bengardner $ + +nl_class_brace = Remove +indent_class = True +indent_namespace = True + diff --git a/tests/config/nl_create_one_liner.cfg b/tests/config/nl_create_one_liner.cfg new file mode 100644 index 0000000000..381ee7d01f --- /dev/null +++ b/tests/config/nl_create_one_liner.cfg @@ -0,0 +1,8 @@ + +indent_columns = 3 +indent_func_call_param = true + +nl_create_if_one_liner = true +nl_create_for_one_liner = true +nl_create_while_one_liner = true + diff --git a/tests/config/nl_ds_struct_enum-1.cfg b/tests/config/nl_ds_struct_enum-1.cfg new file mode 100644 index 0000000000..077e016e32 --- /dev/null +++ b/tests/config/nl_ds_struct_enum-1.cfg @@ -0,0 +1,7 @@ +# +# Double-space commented struct/enum/union blocks +# + +nl_ds_struct_enum_cmt = true +nl_ds_struct_enum_close_brace = false + diff --git a/tests/config/nl_ds_struct_enum-2.cfg b/tests/config/nl_ds_struct_enum-2.cfg new file mode 100644 index 0000000000..a7ba6e01c5 --- /dev/null +++ b/tests/config/nl_ds_struct_enum-2.cfg @@ -0,0 +1,8 @@ +# +# Double-space commented struct/enum/union blocks +# Add an extra newline before the close brace +# + +nl_ds_struct_enum_cmt = true +nl_ds_struct_enum_close_brace = true + diff --git a/tests/config/nl_endif.cfg b/tests/config/nl_endif.cfg new file mode 100644 index 0000000000..177ecea7fd --- /dev/null +++ b/tests/config/nl_endif.cfg @@ -0,0 +1,160 @@ +align_func_params=true +align_keep_tabs=false +align_nl_cont=false +align_number_left=false +align_on_tabstop=false +align_right_cmt_mix=false +align_var_def_colon=false +align_var_def_inline=false +align_with_tabs=false +cmt_c_group=false +cmt_c_nl_end=false +cmt_c_nl_start=false +cmt_cpp_group=false +cmt_cpp_nl_end=false +cmt_cpp_nl_start=false +cmt_cpp_to_c=false +cmt_star_cont=false +eat_blanks_after_open_brace=false +eat_blanks_before_close_brace=false +indent_align_string=false +indent_bool_paren=false +indent_brace_parent=false +indent_braces=false +indent_braces_no_func=false +indent_class=false +indent_class_colon=false +indent_col1_comment=false +indent_comma_paren=false +indent_func_call_param=false +indent_func_class_param=false +indent_func_ctor_var_param=false +indent_func_def_param=true +indent_func_param_double=false +indent_func_proto_param=false +indent_namespace=false +indent_paren_nl=true +indent_preserve_sql=false +indent_square_nl=false +ls_for_split_full=false +ls_func_split_full=false +mod_full_paren_if_bool=false +mod_pawn_semicolon=false +mod_remove_extra_semicolon=true +mod_sort_import=false +mod_sort_include=false +mod_sort_using=false +nl_after_brace_open=true +nl_after_brace_open_cmt=false +nl_after_case=false +nl_after_multiline_comment=false +nl_after_return=true +nl_after_semicolon=true +nl_after_vbrace_open=true +nl_assign_leave_one_liners=true +nl_before_case=true +nl_class_leave_one_liners=false +nl_collapse_empty_body=true +nl_create_for_one_liner=false +nl_create_if_one_liner=false +nl_create_while_one_liner=false +nl_define_macro=false +nl_ds_struct_enum_close_brace=false +nl_ds_struct_enum_cmt=false +nl_enum_leave_one_liners=false +nl_func_leave_one_liners=false +nl_getset_leave_one_liners=false +nl_if_leave_one_liners=false +nl_multi_line_cond=false +nl_squeeze_ifdef=true +pp_define_at_level=true +pp_if_indent_code=true +pp_indent_at_level=true +pp_region_indent_code=true +sp_balance_nested_parens=false +align_assign_span=0 +align_right_cmt_span=3 +align_var_def_span=1 +align_var_def_star_style=0 +cmt_width=108 +code_width=108 +indent_case_brace=0 +indent_case_shift=0 +indent_columns=3 +indent_switch_case=3 +indent_with_tabs=0 +input_tab_size=3 +mod_add_long_function_closebrace_comment=1 +mod_add_long_switch_closebrace_comment=16 +nl_end_of_file_min=2 +nl_func_var_def_blk=1 +pp_indent_region=3 +pp_space_count=3 +mod_paren_on_return=force +nl_after_do=force +nl_after_for=force +nl_after_if=force +nl_after_switch=force +nl_after_while=force +nl_before_do=force +nl_before_for=force +nl_before_if=force +nl_before_switch=force +nl_before_while=force +nl_brace_else=force +nl_brace_while=force +nl_class_brace=force +nl_else_brace=force +nl_elseif_brace=force +nl_end_of_file=force +nl_fcall_brace=force +nl_fdef_brace=force +nl_for_brace=force +nl_func_decl_args=force +nl_func_decl_end=add +nl_func_decl_start=force +nl_func_paren=force +nl_func_proto_type_name=remove +nl_func_type_name=remove +nl_if_brace=force +nl_while_brace=add +pos_class_comma=trail +pos_comma=trail +pp_indent=force +sp_after_cast=remove +sp_after_comma=force +sp_after_oc_type=remove +sp_after_ptr_star=add +sp_after_sparen=force +sp_arith=force +sp_assign=force +sp_before_comma=remove +sp_before_ptr_star=remove +sp_before_semi=remove +sp_before_semi_for=remove +sp_before_semi_for_empty=remove +sp_before_sparen=remove +sp_before_square=remove +sp_before_squares=remove +sp_bool=force +sp_brace_else=force +sp_compare=force +sp_deref=remove +sp_fparen_brace=force +sp_func_call_paren=remove +sp_func_def_paren=remove +sp_func_proto_paren=remove +sp_incdec=remove +sp_inside_braces=force +sp_inside_fparen=remove +sp_inside_fparens=remove +sp_inside_paren=remove +sp_inside_paren_cast=remove +sp_inside_sparen=remove +sp_macro=force +sp_macro_func=force +sp_member=remove +sp_not=remove +sp_paren_paren=remove +sp_return_paren=force +sp_type_func=force diff --git a/tests/config/nl_func_decl_1.cfg b/tests/config/nl_func_decl_1.cfg new file mode 100644 index 0000000000..3f5aeda666 --- /dev/null +++ b/tests/config/nl_func_decl_1.cfg @@ -0,0 +1,11 @@ +nl_func_paren = remove +nl_func_decl_empty = remove +nl_func_decl_start = remove +nl_func_decl_args = remove +nl_func_decl_end = remove + +# a few more options to make the output pretty +sp_after_comma = force +sp_inside_paren = force +sp_inside_fparen = force + diff --git a/tests/config/nl_func_decl_2.cfg b/tests/config/nl_func_decl_2.cfg new file mode 100644 index 0000000000..e6771980f4 --- /dev/null +++ b/tests/config/nl_func_decl_2.cfg @@ -0,0 +1,13 @@ + +nl_func_paren = force +nl_func_decl_empty = force +nl_func_decl_start = force +nl_func_decl_args = force +nl_func_decl_end = force + +# a few more options to make the output pretty +sp_after_comma = force +sp_inside_paren = force +sp_inside_fparen = force +align_func_params = true + diff --git a/tests/config/nl_func_scope_name.cfg b/tests/config/nl_func_scope_name.cfg new file mode 100644 index 0000000000..ac59aa9d65 --- /dev/null +++ b/tests/config/nl_func_scope_name.cfg @@ -0,0 +1,7 @@ + +sp_cmt_cpp_start = add +# align_var_def_span = 16 +align_func_proto_span =16 +align_on_operator =true +nl_func_scope_name = add + diff --git a/tests/config/nl_func_type_name_class.cfg b/tests/config/nl_func_type_name_class.cfg new file mode 100644 index 0000000000..0dc5051729 --- /dev/null +++ b/tests/config/nl_func_type_name_class.cfg @@ -0,0 +1,8 @@ + +sp_cmt_cpp_start = add +# align_var_def_span = 16 +align_func_proto_span =16 +align_on_operator =true +nl_func_type_name = force +nl_func_type_name_class = remove +nl_func_proto_type_name = force diff --git a/tests/config/nl_func_type_name_force.cfg b/tests/config/nl_func_type_name_force.cfg new file mode 100644 index 0000000000..8314c421c9 --- /dev/null +++ b/tests/config/nl_func_type_name_force.cfg @@ -0,0 +1,8 @@ + +sp_cmt_cpp_start = add +# align_var_def_span = 16 +align_func_proto_span =16 +align_on_operator =true +nl_func_type_name = force +nl_func_proto_type_name = force + diff --git a/tests/config/nl_func_type_name_remove.cfg b/tests/config/nl_func_type_name_remove.cfg new file mode 100644 index 0000000000..58cc7afd6e --- /dev/null +++ b/tests/config/nl_func_type_name_remove.cfg @@ -0,0 +1,8 @@ + +sp_cmt_cpp_start = add +# align_var_def_span = 16 +align_func_proto_span =16 +align_on_operator =true +nl_func_type_name = remove +nl_func_proto_type_name = remove + diff --git a/tests/config/nl_namespace-a.cfg b/tests/config/nl_namespace-a.cfg new file mode 100644 index 0000000000..9f3d3a15b5 --- /dev/null +++ b/tests/config/nl_namespace-a.cfg @@ -0,0 +1,7 @@ +# +# $Id: nl_namespace-a.cfg 803 2007-07-25 00:36:25Z bengardner $ + +nl_namespace_brace = Add +indent_class = True +indent_namespace = True + diff --git a/tests/config/nl_namespace-r.cfg b/tests/config/nl_namespace-r.cfg new file mode 100644 index 0000000000..d85bbbc661 --- /dev/null +++ b/tests/config/nl_namespace-r.cfg @@ -0,0 +1,7 @@ +# +# $Id: nl_namespace-r.cfg 803 2007-07-25 00:36:25Z bengardner $ + +nl_namespace_brace = Remove +indent_class = True +indent_namespace = True + diff --git a/tests/config/nl_semicolon.cfg b/tests/config/nl_semicolon.cfg new file mode 100644 index 0000000000..50a3c94384 --- /dev/null +++ b/tests/config/nl_semicolon.cfg @@ -0,0 +1,101 @@ +# +# $Id: nl_semicolon.cfg 1579 2009-06-13 16:29:25Z bengardner $ + +nl_after_semicolon = True +nl_after_brace_open = True + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_member = indent_columns + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_before_semi_for = remove +sp_after_semi_for = force +sp_before_semi_for_empty = remove +sp_after_semi_for_empty = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +# align_assign_thresh = 8 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +# indent_namespace = FALSE +indent_class = TRUE + + diff --git a/tests/config/nl_template_class-force.cfg b/tests/config/nl_template_class-force.cfg new file mode 100644 index 0000000000..b45ab4e073 --- /dev/null +++ b/tests/config/nl_template_class-force.cfg @@ -0,0 +1,25 @@ +# +# Forces a newline between template '>' and class +# +# $Id: nl_template_class-force.cfg 1492 2009-02-27 03:25:26Z bengardner $ + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + +sp_func_def_paren = remove +sp_func_proto_paren = remove +sp_after_operator = force +sp_after_angle = force +sp_angle_word = force +sp_angle_paren = remove +sp_arith = force +sp_compare = force + +nl_template_class = force +sp_inside_braces = force +sp_inside_braces_struct = force + diff --git a/tests/config/nl_template_class-remove.cfg b/tests/config/nl_template_class-remove.cfg new file mode 100644 index 0000000000..9e0f4ab12f --- /dev/null +++ b/tests/config/nl_template_class-remove.cfg @@ -0,0 +1,27 @@ +# +# Removes newlines between template '>' and class +# +# $Id: nl_template_class-remove.cfg 1492 2009-02-27 03:25:26Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + +sp_func_def_paren = remove +sp_func_proto_paren = remove +sp_after_operator = force +sp_after_angle = force +sp_angle_word = force +sp_angle_paren = remove +sp_arith = force +sp_compare = force + +nl_template_class = remove + +sp_inside_braces = force +sp_inside_braces_struct = force + diff --git a/tests/config/nl_try-a.cfg b/tests/config/nl_try-a.cfg new file mode 100644 index 0000000000..ff2180f337 --- /dev/null +++ b/tests/config/nl_try-a.cfg @@ -0,0 +1,9 @@ +# +# $Id: nl_try-a.cfg 912 2007-09-15 20:44:54Z bengardner $ + +nl_catch_brace = force +nl_try_brace = force +nl_brace_catch = force + +nl_after_vbrace_open = true + diff --git a/tests/config/obj-c.cfg b/tests/config/obj-c.cfg new file mode 100644 index 0000000000..1e2cfff185 --- /dev/null +++ b/tests/config/obj-c.cfg @@ -0,0 +1,213 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = remove +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_before_semi_for_empty = force +sp_before_oc_colon = remove +sp_after_oc_colon = force +sp_after_oc_scope = remove +sp_after_oc_type = force + +align_oc_msg_spec_span = 2 + +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_assign_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = true +nl_after_brace_open = true +nl_after_vbrace_open = true +nl_after_access_spec = 1 +nl_assign_leave_one_liners = true +nl_class_leave_one_liners = true +nl_enum_leave_one_liners = true +nl_getset_leave_one_liners = true +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = remove +pp_space = remove +sp_after_dc = remove +sp_before_dc = remove +sp_attribute_paren = remove +sp_after_send_oc_colon = force + diff --git a/tests/config/oc-split.cfg b/tests/config/oc-split.cfg new file mode 100644 index 0000000000..918273791b --- /dev/null +++ b/tests/config/oc-split.cfg @@ -0,0 +1,2 @@ +align_oc_msg_colon = true + diff --git a/tests/config/op-space-force.cfg b/tests/config/op-space-force.cfg new file mode 100644 index 0000000000..74f859c1d9 --- /dev/null +++ b/tests/config/op-space-force.cfg @@ -0,0 +1,19 @@ +# +# Forces a space after an operator +# +# $Id: op-space-force.cfg 1224 2008-06-13 23:07:03Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + +sp_func_def_paren = remove +sp_func_proto_paren = remove +sp_after_operator = force + +sp_after_operator_sym = force + diff --git a/tests/config/op-space-remove.cfg b/tests/config/op-space-remove.cfg new file mode 100644 index 0000000000..a962c68532 --- /dev/null +++ b/tests/config/op-space-remove.cfg @@ -0,0 +1,18 @@ +# +# Removes a space after an operator +# +# $Id: op-space-remove.cfg 1224 2008-06-13 23:07:03Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + +sp_func_def_paren = remove +sp_func_proto_paren = remove +sp_after_operator = remove +sp_after_operator_sym = remove + diff --git a/tests/config/pascal_ptr.cfg b/tests/config/pascal_ptr.cfg new file mode 100644 index 0000000000..ef3c9bc7b3 --- /dev/null +++ b/tests/config/pascal_ptr.cfg @@ -0,0 +1,15 @@ +# +# My favorite format +# +# $Id: pascal_ptr.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 8 +indent_columns = 4 + +sp_arith = force +sp_after_ptr_star = force +sp_before_ptr_star = remove +sp_between_ptr_star = remove + diff --git a/tests/config/pawn-escape.cfg b/tests/config/pawn-escape.cfg new file mode 100644 index 0000000000..5ec5a4ebd7 --- /dev/null +++ b/tests/config/pawn-escape.cfg @@ -0,0 +1,50 @@ +# +# junk +# +# $Id: pawn-escape.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 4 +#output_tab_size = 4 +indent_columns = 4 + +align_pp_define_span = 1 +align_pp_define_gap = 3 +align_right_cmt_span = 2 + +nl_if_brace = remove +nl_elseif_brace = remove +nl_else_brace = remove +nl_brace_else = remove +nl_fdef_brace = force + +sp_arith = force +sp_macro = force +sp_macro_func = force +sp_sparen_brace = add +sp_after_sparen = add +sp_fparen_brace = force +sp_square_fparen = remove +sp_inside_braces = add +sp_after_tag = remove + +cmt_star_cont = true +#cmt_cpp_to_c = true +#cmt_cpp_group = true +#cmt_cpp_nl_start = true +#cmt_cpp_nl_end = true + + +mod_full_brace_if = add +mod_full_brace_for = add +mod_full_brace_do = add +mod_full_brace_while = add +mod_full_brace_function = add + +# note: for normal usage, this option is 'bad' +mod_pawn_semicolon = true + +# '^' - didn't want to make another option type +string_escape_char = 94 +string_escape_char = 94 diff --git a/tests/config/pawn.cfg b/tests/config/pawn.cfg new file mode 100644 index 0000000000..62811ab430 --- /dev/null +++ b/tests/config/pawn.cfg @@ -0,0 +1,50 @@ +# +# junk +# +# $Id: pawn.cfg 1552 2009-05-05 20:03:37Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 4 +#output_tab_size = 4 +indent_columns = 4 + +align_pp_define_span = 1 +align_pp_define_gap = 3 +align_right_cmt_span = 2 + +nl_if_brace = remove +nl_elseif_brace = remove +nl_else_brace = remove +nl_brace_else = remove +nl_fdef_brace = force + +sp_arith = force +sp_macro = force +sp_macro_func = force +sp_sparen_brace = force +sp_after_sparen = add +sp_fparen_brace = force +sp_square_fparen = remove +sp_inside_braces = add +sp_after_tag = remove +sp_else_brace = force +sp_brace_else = force +sp_paren_brace = force + +cmt_star_cont = true +#cmt_cpp_to_c = true +#cmt_cpp_group = true +#cmt_cpp_nl_start = true +#cmt_cpp_nl_end = true + + +mod_full_brace_if = add +mod_full_brace_for = add +mod_full_brace_do = add +mod_full_brace_while = add +mod_full_brace_function = add + +# note: for normal usage, this option is 'bad' +mod_pawn_semicolon = true + diff --git a/tests/config/pos_compare-eol.cfg b/tests/config/pos_compare-eol.cfg new file mode 100644 index 0000000000..e9022315c3 --- /dev/null +++ b/tests/config/pos_compare-eol.cfg @@ -0,0 +1,2 @@ +pos_compare = trail +sp_compare = force diff --git a/tests/config/pos_compare-sol.cfg b/tests/config/pos_compare-sol.cfg new file mode 100644 index 0000000000..896546bd11 --- /dev/null +++ b/tests/config/pos_compare-sol.cfg @@ -0,0 +1,2 @@ +pos_compare = lead +sp_compare = force diff --git a/tests/config/pos_conditional-eol.cfg b/tests/config/pos_conditional-eol.cfg new file mode 100644 index 0000000000..377c373d74 --- /dev/null +++ b/tests/config/pos_conditional-eol.cfg @@ -0,0 +1,2 @@ +pos_conditional = trail +sp_cond_question = force diff --git a/tests/config/pos_conditional-sol.cfg b/tests/config/pos_conditional-sol.cfg new file mode 100644 index 0000000000..bf1497b8dd --- /dev/null +++ b/tests/config/pos_conditional-sol.cfg @@ -0,0 +1,2 @@ +pos_conditional = lead +sp_cond_question = force diff --git a/tests/config/pp-indent-1.cfg b/tests/config/pp-indent-1.cfg new file mode 100644 index 0000000000..dcbd5b43e1 --- /dev/null +++ b/tests/config/pp-indent-1.cfg @@ -0,0 +1,14 @@ +# +# Remove all PP spacing and indent +# +# $Id: pp-indent-1.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +pp_indent = remove +pp_space = remove + +# Gives the format +# |#ifdef SOMETHING +# |#define X +# |#endif + diff --git a/tests/config/pp-indent-2.cfg b/tests/config/pp-indent-2.cfg new file mode 100644 index 0000000000..c12b79919e --- /dev/null +++ b/tests/config/pp-indent-2.cfg @@ -0,0 +1,15 @@ +# +# Remove all PP spacing and indent +# +# $Id: pp-indent-2.cfg 997 2007-11-08 00:06:09Z bengardner $ +# + +pp_indent = remove +pp_space = add +pp_space_count = 2 + +# Gives the format +# |#ifdef SOMETHING +# |# define X +# |#endif + diff --git a/tests/config/pp-indent-3.cfg b/tests/config/pp-indent-3.cfg new file mode 100644 index 0000000000..f00863addd --- /dev/null +++ b/tests/config/pp-indent-3.cfg @@ -0,0 +1,14 @@ +# +# Remove all PP spacing and indent +# +# $Id: pp-indent-3.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +pp_indent = add +pp_space = remove + +# Gives the format +# |#ifdef SOMETHING +# | #define X +# |#endif + diff --git a/tests/config/pp-space.cfg b/tests/config/pp-space.cfg new file mode 100644 index 0000000000..606452b48e --- /dev/null +++ b/tests/config/pp-space.cfg @@ -0,0 +1,7 @@ +indent_columns = 4 +indent_with_tabs = 1 +output_tab_size = 4 +pp_indent = add +pp_indent_count = 4 +pp_indent_at_level = false + diff --git a/tests/config/pp_define_at_level-1.cfg b/tests/config/pp_define_at_level-1.cfg new file mode 100644 index 0000000000..1b668768ec --- /dev/null +++ b/tests/config/pp_define_at_level-1.cfg @@ -0,0 +1,7 @@ +pp_define_at_level = true +indent_class = true +indent_columns = 4 +indent_with_tabs = 0 +output_tab_size = 8 + + diff --git a/tests/config/pp_if_indent-0.cfg b/tests/config/pp_if_indent-0.cfg new file mode 100644 index 0000000000..ff06e95ac9 --- /dev/null +++ b/tests/config/pp_if_indent-0.cfg @@ -0,0 +1,7 @@ +# default region indent +pp_indent = add +indent_columns = 4 +pp_if_indent_code = false +pp_indent_if = 0 +pp_indent_at_level = true + diff --git a/tests/config/pp_if_indent-1.cfg b/tests/config/pp_if_indent-1.cfg new file mode 100644 index 0000000000..25cc297db9 --- /dev/null +++ b/tests/config/pp_if_indent-1.cfg @@ -0,0 +1,7 @@ +# indented region code +pp_indent = add +indent_columns = 4 +pp_if_indent_code = true +pp_indent_if = 0 +pp_indent_at_level = true + diff --git a/tests/config/pp_if_indent-2.cfg b/tests/config/pp_if_indent-2.cfg new file mode 100644 index 0000000000..f3ec36813e --- /dev/null +++ b/tests/config/pp_if_indent-2.cfg @@ -0,0 +1,7 @@ +# out-dented region preprocs +pp_indent = add +indent_columns = 4 +pp_if_indent_code = false +pp_indent_if = -4 +pp_indent_at_level = true + diff --git a/tests/config/pp_if_indent-3.cfg b/tests/config/pp_if_indent-3.cfg new file mode 100644 index 0000000000..3815cefe07 --- /dev/null +++ b/tests/config/pp_if_indent-3.cfg @@ -0,0 +1,7 @@ +# Abs column region preproc +pp_indent = add +indent_columns = 4 +pp_if_indent_code = true +pp_indent_if = 0 +pp_indent_at_level = false + diff --git a/tests/config/pp_ret.cfg b/tests/config/pp_ret.cfg new file mode 100644 index 0000000000..2c70622974 --- /dev/null +++ b/tests/config/pp_ret.cfg @@ -0,0 +1,757 @@ + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 8 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 8 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 4 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = true # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = false # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 0 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = -4 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = add # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = add # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = add # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = add # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = remove # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = add # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = add # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = ignore # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = add # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = add # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = remove # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = add # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statment: for ( ; ; ). +sp_after_semi_for_empty = add # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = add # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = remove # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = ignore # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = ignore # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = ignore # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = ignore # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = ignore # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 0 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typdef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't touch one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = true # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Don't touch one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = true # false/true + +# Don't touch one-line get or set functions +nl_getset_leave_one_liners = true # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 0 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = add # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = add # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = add # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = add # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Newline between namespace and { +nl_namespace_brace = add # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = add # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# Whether to put a newline after a virtual brace open. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = ignore # ignore/lead/trail + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/lead/trail + +# +# Line Splitting options +# + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 2 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 0 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 0 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = ignore # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = ignore # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = ignore # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = ignore # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP diff --git a/tests/config/preproc-cleanup.cfg b/tests/config/preproc-cleanup.cfg new file mode 100644 index 0000000000..68af3fb1de --- /dev/null +++ b/tests/config/preproc-cleanup.cfg @@ -0,0 +1,123 @@ +# +# Clean up preprocessor output, ie from "gcc -E" +# +# $Id: preproc-cleanup.cfg 943 2007-09-27 02:14:59Z bengardner $ +# + +nl_after_semicolon = True +nl_after_brace_open = True + +newlines = LF # AUTO (default), CRLF, CR, or LF + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +# indent_label = 0 # pos: absolute col, neg: relative column +indent_align_string = False # align broken strings +indent_brace = 0 +indent_class = true +indent_member = indent_columns + +nl_start_of_file = remove +# nl_start_of_file_min = 0 +nl_end_of_file = force +nl_end_of_file_min = 1 +nl_max = 4 +nl_before_block_comment = 2 +nl_after_func_body = 2 +nl_after_func_proto_group = 2 + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_after_case = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +pos_bool = Trail # BOOL ops on trailing end + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_func_class_paren = remove +sp_before_angle = force +sp_after_angle = force +sp_inside_angle = remove +sp_sparen_brace = add +sp_fparen_brace = add +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 16 +align_nl_cont = TRUE +align_var_def_span = 1 +align_var_def_thresh = 12 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +align_assign_thresh = 12 +align_struct_init_span = 3 +align_var_struct_span = 99 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +sp_attribute_paren = remove +pp_indent = remove +pp_space = remove + diff --git a/tests/config/ptr_star-1.cfg b/tests/config/ptr_star-1.cfg new file mode 100644 index 0000000000..771c26ad0c --- /dev/null +++ b/tests/config/ptr_star-1.cfg @@ -0,0 +1,10 @@ +sp_after_ptr_star = force +sp_after_ptr_star_func = force +sp_before_ptr_star = remove +sp_between_ptr_star = remove +sp_before_unnamed_ptr_star = remove + +sp_before_byref = remove +sp_after_byref = force +sp_before_unnamed_byref = remove + diff --git a/tests/config/ptr_star-2.cfg b/tests/config/ptr_star-2.cfg new file mode 100644 index 0000000000..a3bb06748e --- /dev/null +++ b/tests/config/ptr_star-2.cfg @@ -0,0 +1,10 @@ +sp_after_ptr_star = remove +sp_after_ptr_star_func = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_before_unnamed_ptr_star = ignore + +sp_before_byref = force +sp_after_byref = remove +sp_before_unnamed_byref = ignore + diff --git a/tests/config/ptr_star-3.cfg b/tests/config/ptr_star-3.cfg new file mode 100644 index 0000000000..64656fe860 --- /dev/null +++ b/tests/config/ptr_star-3.cfg @@ -0,0 +1,10 @@ +sp_after_ptr_star = remove +sp_after_ptr_star_func = force +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_before_unnamed_ptr_star = remove + +sp_before_byref = remove +sp_after_byref = force +sp_before_unnamed_byref = force + diff --git a/tests/config/region-0.cfg b/tests/config/region-0.cfg new file mode 100644 index 0000000000..46736d3784 --- /dev/null +++ b/tests/config/region-0.cfg @@ -0,0 +1,7 @@ +# default region indent +indent_columns = 4 +pp_region_indent_code = false +pp_indent_region = 0 + +indent_class = true + diff --git a/tests/config/region-1.cfg b/tests/config/region-1.cfg new file mode 100644 index 0000000000..014a0765a4 --- /dev/null +++ b/tests/config/region-1.cfg @@ -0,0 +1,7 @@ +# indented region code +indent_columns = 4 +pp_region_indent_code = true +pp_indent_region = 0 + +indent_class = true + diff --git a/tests/config/region-2.cfg b/tests/config/region-2.cfg new file mode 100644 index 0000000000..16151de6cf --- /dev/null +++ b/tests/config/region-2.cfg @@ -0,0 +1,7 @@ +# out-dented region preprocs +indent_columns = 4 +pp_region_indent_code = false +pp_indent_region = -4 + +indent_class = true + diff --git a/tests/config/region-3.cfg b/tests/config/region-3.cfg new file mode 100644 index 0000000000..1745830319 --- /dev/null +++ b/tests/config/region-3.cfg @@ -0,0 +1,7 @@ +# Abs column region preproc +indent_columns = 4 +pp_region_indent_code = false +pp_indent_region = 2 + +indent_class = true + diff --git a/tests/config/return-1.cfg b/tests/config/return-1.cfg new file mode 100644 index 0000000000..4603a9c30f --- /dev/null +++ b/tests/config/return-1.cfg @@ -0,0 +1,11 @@ + +indent_columns = 4 +indent_with_tabs = 0 + +nl_after_return = true +mod_paren_on_return = add +nl_return_expr = remove + +sp_before_semi = remove +sp_inside_paren = remove + diff --git a/tests/config/return-2.cfg b/tests/config/return-2.cfg new file mode 100644 index 0000000000..af872ab908 --- /dev/null +++ b/tests/config/return-2.cfg @@ -0,0 +1,11 @@ + +indent_columns = 4 +indent_with_tabs = 0 + +nl_after_return = true +mod_paren_on_return = remove +nl_return_expr = remove + +sp_before_semi = remove +sp_inside_paren = remove + diff --git a/tests/config/return-3.cfg b/tests/config/return-3.cfg new file mode 100644 index 0000000000..26c81d4978 --- /dev/null +++ b/tests/config/return-3.cfg @@ -0,0 +1,11 @@ + +indent_columns = 4 +indent_with_tabs = 0 + +nl_after_return = true +mod_paren_on_return = remove +nl_return_expr = force + +sp_before_semi = remove +sp_inside_paren = remove + diff --git a/tests/config/return-4.cfg b/tests/config/return-4.cfg new file mode 100644 index 0000000000..36c85261e9 --- /dev/null +++ b/tests/config/return-4.cfg @@ -0,0 +1,11 @@ + +indent_columns = 4 +indent_with_tabs = 0 + +nl_after_return = true +mod_paren_on_return = force +nl_return_expr = force + +sp_before_semi = remove +sp_inside_paren = remove + diff --git a/tests/config/sef.cfg b/tests/config/sef.cfg new file mode 100644 index 0000000000..695ff66dc5 --- /dev/null +++ b/tests/config/sef.cfg @@ -0,0 +1,253 @@ +newlines = crlf +input_tab_size = 4 +output_tab_size = 4 +string_escape_char = 92 +string_escape_char2 = 0 +indent_columns = 4 +indent_with_tabs = 2 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = true +indent_class = false +indent_class_colon = false +indent_func_call_param = false +indent_func_class_param = true +indent_func_ctor_var_param = true +indent_func_param_double = true +indent_member = 0 +indent_sing_line_comments = 0 +indent_switch_case = 4 +indent_case_shift = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 1 +indent_access_spec = 1 +indent_paren_nl = false +indent_paren_close = 0 +indent_comma_paren = false +indent_bool_paren = false +indent_square_nl = false +indent_preserve_sql = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = add +sp_inside_paren = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = force +sp_before_ptr_star = remove +sp_between_ptr_star = ignore +sp_after_ptr_star = add +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = ignore +sp_after_angle = ignore +sp_angle_paren = ignore +sp_angle_word = ignore +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = force +sp_special_semi = ignore +sp_before_semi = ignore +sp_before_semi_for = ignore +sp_before_semi_for_empty = ignore +sp_after_semi_for_empty = ignore +sp_before_square = remove +sp_before_squares = ignore +sp_inside_square = ignore +sp_after_comma = add +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = ignore +sp_inside_paren_cast = ignore +sp_sizeof_paren = ignore +sp_after_tag = ignore +sp_inside_braces_enum = ignore +sp_inside_braces_struct = ignore +sp_inside_braces = ignore +sp_inside_angle = ignore +sp_type_func = remove +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = remove +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = add +sp_func_call_paren = remove +sp_func_class_paren = remove +sp_return_paren = ignore +sp_attribute_paren = ignore +sp_macro = ignore +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +sp_before_dc = ignore +sp_after_dc = remove +sp_d_array_colon = ignore +sp_not = remove +sp_inv = remove +sp_addr = remove +sp_deref = remove +align_keep_tabs = false +align_with_tabs = true +align_on_tabstop = true +align_number_left = false +align_func_params = false +align_var_def_span = 0 +align_var_def_star_style = 0 +align_var_def_amp_style = 0 +align_var_def_thresh = 0 +align_var_def_colon = false +align_var_def_inline = false +align_assign_span = 0 +align_assign_thresh = 0 +align_enum_equ_span = 0 +align_enum_equ_thresh = 0 +align_var_struct_span = 0 +align_var_struct_thresh = 0 +align_struct_init_span = 0 +align_typedef_gap = 0 +align_typedef_span = 0 +align_typedef_func = 0 +align_typedef_star_style = 0 +align_typedef_amp_style = 0 +align_right_cmt_span = 0 +align_func_proto_span = 0 +align_nl_cont = false +align_pp_define_gap = 0 +align_pp_define_span = 0 +nl_collapse_empty_body = false +nl_assign_leave_one_liners = false +nl_class_leave_one_liners = false +nl_enum_leave_one_liners = false +nl_getset_leave_one_liners = false +nl_func_leave_one_liners = true +nl_if_leave_one_liners = false +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = ignore +nl_assign_square = ignore +nl_after_square_assign = ignore +nl_func_var_def_blk = 0 +nl_fcall_brace = ignore +nl_enum_brace = ignore +nl_struct_brace = ignore +nl_union_brace = ignore +nl_if_brace = remove +nl_brace_else = add +nl_elseif_brace = remove +nl_else_brace = remove +nl_brace_finally = ignore +nl_finally_brace = ignore +nl_try_brace = ignore +nl_getset_brace = ignore +nl_for_brace = remove +nl_catch_brace = ignore +nl_brace_catch = ignore +nl_while_brace = remove +nl_do_brace = remove +nl_brace_while = add +nl_switch_brace = remove +nl_multi_line_cond = false +nl_before_case = false +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = force +nl_func_type_name = remove +nl_func_paren = remove +nl_func_decl_start = remove +nl_func_decl_args = remove +nl_func_decl_end = remove +nl_fdef_brace = ignore +nl_after_return = false +nl_after_semicolon = true +nl_after_brace_open = true +nl_after_brace_open_cmt = false +nl_after_vbrace_open = false +nl_define_macro = false +nl_squeeze_ifdef = false +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +nl_ds_struct_enum_close_brace = false +nl_class_colon = add +nl_create_if_one_liner = false +nl_create_for_one_liner = false +nl_create_while_one_liner = false +pos_bool = lead +pos_comma = trail +pos_class_comma = trail +pos_class_colon = lead +code_width = 80 +ls_for_split_full = true +ls_func_split_full = true +nl_max = 3 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 3 +nl_after_func_body_one_liner = 2 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +nl_after_multiline_comment = false +nl_before_access_spec = 1 +nl_after_access_spec = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = ignore +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +mod_remove_extra_semicolon = false +cmt_width = 80 +cmt_c_group = false +cmt_c_nl_start = false +cmt_c_nl_end = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = false +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +cmt_insert_file_header = "" +cmt_insert_func_header = "" +cmt_insert_class_header = "" +pp_indent = ignore +pp_indent_at_level = false +pp_space = ignore +pp_space_count = 0 +pp_indent_region = 0 +pp_region_indent_code = false +pp_indent_if = 0 +pp_if_indent_code = false +pp_define_at_level = false diff --git a/tests/config/sim.cfg b/tests/config/sim.cfg new file mode 100644 index 0000000000..717ed433f6 --- /dev/null +++ b/tests/config/sim.cfg @@ -0,0 +1,680 @@ +# +# $Id: sim.cfg 803 2007-07-25 00:36:25Z bengardner $ + +# +# General options +# + +# The type of line endings +newlines = lf # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 2 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 2 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 2 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = true # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 2 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = -2 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = remove # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = force # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = remove # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = force # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = remove # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = force # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = force # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = remove # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = remove # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 2 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 1 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = true # false/true + +# Don't touch one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = remove # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 0 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = remove # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = ignore # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = ignore # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = remove # ignore/add/remove/force + +# Add or remove newline when condition spans two or more lines +nl_multi_line_cond = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = force # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = force # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = force # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = remove # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = remove # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = remove # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = force # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = false # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove newline before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Add or remove a newline around a class colon. Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = force # ignore/add/remove/force + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = trail # ignore/lead/trail +pos_class_comma = trail + +# The position of colons between constructor and member initialization +pos_class_colon = trail # ignore/lead/trail + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 3 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 1 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 2 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = ignore # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = ignore # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = ignore # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = true # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = ignore # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = ignore # ignore/add/remove/force + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP diff --git a/tests/config/sort_imports.cfg b/tests/config/sort_imports.cfg new file mode 100644 index 0000000000..3bbd3dd851 --- /dev/null +++ b/tests/config/sort_imports.cfg @@ -0,0 +1,5 @@ + +mod_sort_import = true +mod_sort_include = true +mod_sort_using = true + diff --git a/tests/config/sp-for-semi.cfg b/tests/config/sp-for-semi.cfg new file mode 100644 index 0000000000..9855599178 --- /dev/null +++ b/tests/config/sp-for-semi.cfg @@ -0,0 +1,8 @@ + +sp_before_semi = remove +sp_before_semi_for = remove +sp_before_semi_for_empty = force +sp_after_semi_for_empty = ignore + + + diff --git a/tests/config/sp_after_cast.cfg b/tests/config/sp_after_cast.cfg new file mode 100644 index 0000000000..4729134b90 --- /dev/null +++ b/tests/config/sp_after_cast.cfg @@ -0,0 +1,194 @@ +newlines = auto +input_tab_size = 8 +output_tab_size = 3 +string_escape_char = 92 +indent_columns = 3 +indent_with_tabs = 0 +indent_align_string = false +indent_xml_string = 0 +indent_brace = 0 +indent_braces = false +indent_braces_no_func = false +indent_brace_parent = false +indent_namespace = false +indent_class = true +indent_class_colon = false +indent_func_call_param = false +indent_member = 3 +indent_sing_line_comments = 0 +indent_switch_case = 0 +indent_case_brace = 0 +indent_col1_comment = false +indent_label = 2 +indent_access_spec = 2 +indent_paren_nl = false +indent_square_nl = false +sp_arith = force +sp_assign = force +sp_bool = force +sp_compare = force +sp_inside_paren = remove +sp_inside_paren_cast = remove +sp_paren_paren = remove +sp_balance_nested_parens = false +sp_paren_brace = ignore +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove +sp_before_byref = remove +sp_after_byref = ignore +sp_before_angle = remove +sp_after_angle = force +sp_angle_paren = remove +sp_angle_word = force +sp_before_sparen = force +sp_inside_sparen = remove +sp_after_sparen = force +sp_sparen_brace = ignore +sp_special_semi = ignore +sp_before_semi = remove +sp_before_semi_for = ignore +sp_before_square = ignore +sp_before_squares = ignore +sp_inside_square = remove +sp_after_comma = force +sp_before_comma = remove +sp_after_operator = ignore +sp_after_cast = force +sp_sizeof_paren = remove +sp_after_tag = ignore +sp_inside_braces_enum = force +sp_inside_braces_struct = force +sp_inside_braces = force +sp_inside_angle = remove +sp_type_func = ignore +sp_func_proto_paren = remove +sp_func_def_paren = remove +sp_inside_fparens = ignore +sp_inside_fparen = remove +sp_square_fparen = ignore +sp_fparen_brace = ignore +sp_func_call_paren = remove +sp_func_class_paren = ignore +sp_return_paren = remove +sp_macro = ignore +sp_macro_func = ignore +sp_else_brace = ignore +sp_brace_else = ignore +sp_catch_brace = ignore +sp_brace_catch = ignore +sp_finally_brace = ignore +sp_brace_finally = ignore +sp_try_brace = ignore +sp_getset_brace = ignore +align_keep_tabs = false +align_with_tabs = false +align_on_tabstop = false +align_number_left = true +align_func_params = true +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_thresh = 0 +align_var_def_colon = true +align_var_def_inline = true +align_assign_span = 1 +align_assign_thresh = 0 +align_enum_equ_span = 4 +align_enum_equ_thresh = 0 +align_var_struct_span = 3 +align_struct_init_span = 3 +align_typedef_gap = 3 +align_typedef_span = 5 +align_typedef_star_style = 0 +align_right_cmt_span = 3 +align_func_proto_span = 0 +align_nl_cont = true +align_pp_define_gap = 4 +align_pp_define_span = 3 +code_width = 0 +nl_collapse_empty_body = false +nl_class_leave_one_liners = true +nl_start_of_file = ignore +nl_start_of_file_min = 0 +nl_end_of_file = ignore +nl_end_of_file_min = 0 +nl_assign_brace = add +nl_func_var_def_blk = 1 +nl_fcall_brace = add +nl_enum_brace = add +nl_struct_brace = add +nl_union_brace = add +nl_if_brace = add +nl_brace_else = add +nl_elseif_brace = ignore +nl_else_brace = add +nl_brace_finally = ignore +nl_finally_brace = add +nl_try_brace = add +nl_getset_brace = ignore +nl_for_brace = add +nl_catch_brace = add +nl_brace_catch = ignore +nl_while_brace = add +nl_do_brace = add +nl_brace_while = remove +nl_switch_brace = add +nl_before_case = true +nl_after_case = false +nl_namespace_brace = ignore +nl_template_class = ignore +nl_class_brace = ignore +nl_class_init_args = ignore +nl_func_type_name = ignore +nl_func_decl_start = ignore +nl_func_decl_args = ignore +nl_func_decl_end = ignore +nl_fdef_brace = add +nl_after_return = true +nl_after_semicolon = false +nl_after_brace_open = false +nl_define_macro = false +nl_squeeze_ifdef = true +nl_before_if = ignore +nl_after_if = ignore +nl_before_for = ignore +nl_after_for = ignore +nl_before_while = ignore +nl_after_while = ignore +nl_before_switch = ignore +nl_after_switch = ignore +nl_before_do = ignore +nl_after_do = ignore +nl_ds_struct_enum_cmt = false +pos_bool = ignore +pos_class_colon = ignore +ls_for_split_full = false +ls_func_split_full = false +nl_max = 0 +nl_after_func_proto = 0 +nl_after_func_proto_group = 0 +nl_after_func_body = 0 +nl_after_func_body_one_liner = 0 +nl_before_block_comment = 0 +nl_before_c_comment = 0 +nl_before_cpp_comment = 0 +eat_blanks_after_open_brace = true +eat_blanks_before_close_brace = true +mod_full_brace_do = add +mod_full_brace_for = add +mod_full_brace_function = ignore +mod_full_brace_if = add +mod_full_brace_nl = 0 +mod_full_brace_while = add +mod_paren_on_return = add +mod_pawn_semicolon = false +mod_full_paren_if_bool = false +cmt_cpp_group = false +cmt_cpp_nl_start = false +cmt_cpp_nl_end = false +cmt_cpp_to_c = false +cmt_star_cont = true +cmt_sp_before_star_cont = 0 +cmt_sp_after_star_cont = 0 +pp_indent = ignore +pp_space = ignore diff --git a/tests/config/sp_after_oc_at_sel_add.cfg b/tests/config/sp_after_oc_at_sel_add.cfg new file mode 100644 index 0000000000..13f5bd1e2e --- /dev/null +++ b/tests/config/sp_after_oc_at_sel_add.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size + +sp_after_oc_at_sel = add \ No newline at end of file diff --git a/tests/config/sp_after_oc_at_sel_force.cfg b/tests/config/sp_after_oc_at_sel_force.cfg new file mode 100644 index 0000000000..5b740d2ffc --- /dev/null +++ b/tests/config/sp_after_oc_at_sel_force.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size + +sp_after_oc_at_sel = force \ No newline at end of file diff --git a/tests/config/sp_after_oc_at_sel_remove.cfg b/tests/config/sp_after_oc_at_sel_remove.cfg new file mode 100644 index 0000000000..b3ba1f8aff --- /dev/null +++ b/tests/config/sp_after_oc_at_sel_remove.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size + +sp_after_oc_at_sel = remove \ No newline at end of file diff --git a/tests/config/sp_after_oc_return_type_add.cfg b/tests/config/sp_after_oc_return_type_add.cfg new file mode 100644 index 0000000000..6a11ffb7de --- /dev/null +++ b/tests/config/sp_after_oc_return_type_add.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size + +sp_after_oc_return_type = add \ No newline at end of file diff --git a/tests/config/sp_after_oc_return_type_force.cfg b/tests/config/sp_after_oc_return_type_force.cfg new file mode 100644 index 0000000000..dcb5a47c77 --- /dev/null +++ b/tests/config/sp_after_oc_return_type_force.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size + +sp_after_oc_return_type = force \ No newline at end of file diff --git a/tests/config/sp_after_oc_return_type_remove.cfg b/tests/config/sp_after_oc_return_type_remove.cfg new file mode 100644 index 0000000000..2738f64733 --- /dev/null +++ b/tests/config/sp_after_oc_return_type_remove.cfg @@ -0,0 +1,5 @@ +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +output_tab_size = 4 # new tab size +indent_columns = output_tab_size + +sp_after_oc_return_type = remove \ No newline at end of file diff --git a/tests/config/sp_before_ellipsis-f.cfg b/tests/config/sp_before_ellipsis-f.cfg new file mode 100644 index 0000000000..1074cb3d96 --- /dev/null +++ b/tests/config/sp_before_ellipsis-f.cfg @@ -0,0 +1,3 @@ + +sp_before_ellipsis = force + diff --git a/tests/config/sp_cmt_cpp_start_add.cfg b/tests/config/sp_cmt_cpp_start_add.cfg new file mode 100644 index 0000000000..a189715957 --- /dev/null +++ b/tests/config/sp_cmt_cpp_start_add.cfg @@ -0,0 +1,3 @@ + +sp_cmt_cpp_start = add + diff --git a/tests/config/sp_cmt_cpp_start_force.cfg b/tests/config/sp_cmt_cpp_start_force.cfg new file mode 100644 index 0000000000..80aa35c1bc --- /dev/null +++ b/tests/config/sp_cmt_cpp_start_force.cfg @@ -0,0 +1,3 @@ + +sp_cmt_cpp_start = force + diff --git a/tests/config/sp_cmt_cpp_start_remove.cfg b/tests/config/sp_cmt_cpp_start_remove.cfg new file mode 100644 index 0000000000..7089c805e8 --- /dev/null +++ b/tests/config/sp_cmt_cpp_start_remove.cfg @@ -0,0 +1,3 @@ + +sp_cmt_cpp_start = remove + diff --git a/tests/config/sp_throw_paren-f.cfg b/tests/config/sp_throw_paren-f.cfg new file mode 100644 index 0000000000..8d0b610f2e --- /dev/null +++ b/tests/config/sp_throw_paren-f.cfg @@ -0,0 +1,3 @@ + +sp_throw_paren = force + diff --git a/tests/config/sp_throw_paren-r.cfg b/tests/config/sp_throw_paren-r.cfg new file mode 100644 index 0000000000..0143383bf4 --- /dev/null +++ b/tests/config/sp_throw_paren-r.cfg @@ -0,0 +1,3 @@ + +sp_throw_paren = remove + diff --git a/tests/config/star_pos-0.cfg b/tests/config/star_pos-0.cfg new file mode 100644 index 0000000000..c5a93471f4 --- /dev/null +++ b/tests/config/star_pos-0.cfg @@ -0,0 +1,28 @@ +# +# Places the byref as follows: "int &foo" +# +# $Id: byref-left.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_columns = 3 + +align_typedef_span = 2 +align_typedef_gap = 3 +align_typedef_star_style = 0 +align_typedef_amp_style = 0 + +align_var_def_span = 2 +align_var_def_star_style = 0 +align_var_def_amp_style = 0 + +align_var_struct_span = 2 + +align_func_proto_span = 2 + +sp_before_ptr_star = remove +sp_between_ptr_star = remove +sp_after_ptr_star = force + +sp_before_byref = remove +sp_after_byref = force + diff --git a/tests/config/star_pos-1.cfg b/tests/config/star_pos-1.cfg new file mode 100644 index 0000000000..7e7f485c1f --- /dev/null +++ b/tests/config/star_pos-1.cfg @@ -0,0 +1,28 @@ +# +# Places the byref as follows: "int &foo" +# +# $Id: byref-left.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_columns = 3 + +align_typedef_span = 2 +align_typedef_gap = 3 +align_typedef_star_style = 1 +align_typedef_amp_style = 1 + +align_var_def_span = 2 +align_var_def_star_style = 1 +align_var_def_amp_style = 1 + +align_var_struct_span = 2 + +align_func_proto_span = 2 + +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove + +sp_before_byref = force +sp_after_byref = remove + diff --git a/tests/config/star_pos-2.cfg b/tests/config/star_pos-2.cfg new file mode 100644 index 0000000000..0b16844c76 --- /dev/null +++ b/tests/config/star_pos-2.cfg @@ -0,0 +1,28 @@ +# +# Places the byref as follows: "int &foo" +# +# $Id: byref-left.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_columns = 3 + +align_typedef_span = 2 +align_typedef_gap = 3 +align_typedef_star_style = 2 +align_typedef_amp_style = 2 + +align_var_def_span = 2 +align_var_def_star_style = 2 +align_var_def_amp_style = 2 + +align_var_struct_span = 2 + +align_func_proto_span = 2 + +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove + +sp_before_byref = force +sp_after_byref = remove + diff --git a/tests/config/tcf.cfg b/tests/config/tcf.cfg new file mode 100644 index 0000000000..d9b61be495 --- /dev/null +++ b/tests/config/tcf.cfg @@ -0,0 +1,5 @@ +nl_finally_brace = force +nl_after_try_catch_finally = 3 +nl_between_get_set = 2 +nl_around_cs_property = 2 + diff --git a/tests/config/template4.cfg b/tests/config/template4.cfg new file mode 100644 index 0000000000..adaa3532e9 --- /dev/null +++ b/tests/config/template4.cfg @@ -0,0 +1,2 @@ +sp_func_call_paren = remove + diff --git a/tests/config/template_sp-force.cfg b/tests/config/template_sp-force.cfg new file mode 100644 index 0000000000..fec45d4402 --- /dev/null +++ b/tests/config/template_sp-force.cfg @@ -0,0 +1,27 @@ +# +# Forces a newline between template '>' and class +# +# $Id: template_sp-force.cfg 1492 2009-02-27 03:25:26Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + +sp_func_def_paren = remove +sp_func_proto_paren = remove +sp_after_operator = force +sp_before_angle = force +sp_inside_angle = force +sp_after_angle = force +sp_angle_word = force +sp_angle_paren = force +sp_arith = force +sp_compare = remove # just to show a difference +sp_template_angle = remove +sp_inside_braces = force +sp_inside_braces_struct = force + diff --git a/tests/config/template_sp-remove.cfg b/tests/config/template_sp-remove.cfg new file mode 100644 index 0000000000..885d1977ca --- /dev/null +++ b/tests/config/template_sp-remove.cfg @@ -0,0 +1,27 @@ +# +# remove spaces around template defs +# +# $Id: template_sp-remove.cfg 1617 2009-10-10 14:52:36Z bengardner $ +# + +indent_columns = 3 + +sp_before_byref = remove +sp_after_byref = force + +indent_class = True + +sp_func_def_paren = remove +sp_func_proto_paren = remove +sp_func_call_paren = remove +sp_after_operator = remove +sp_before_angle = remove +sp_inside_angle = remove +sp_after_angle = remove +sp_angle_word = remove +sp_angle_paren = remove +sp_arith = force +sp_compare = force +sp_inside_braces = force +sp_inside_braces_struct = force + diff --git a/tests/config/type_wrap.cfg b/tests/config/type_wrap.cfg new file mode 100644 index 0000000000..343cdecb14 --- /dev/null +++ b/tests/config/type_wrap.cfg @@ -0,0 +1,8 @@ + + +set TYPE_WRAP STACK_OF +sp_before_ptr_star = force +sp_after_ptr_star = remove + +sp_assign = force + diff --git a/tests/config/var_def_gap.cfg b/tests/config/var_def_gap.cfg new file mode 100644 index 0000000000..e3f12a2137 --- /dev/null +++ b/tests/config/var_def_gap.cfg @@ -0,0 +1,19 @@ + +align_var_def_span = 3 +align_var_def_gap = 5 +align_var_def_star_style = 2 +align_var_def_amp_style = 2 +sp_after_ptr_star = remove +sp_between_ptr_star = remove +sp_before_ptr_star = force +sp_after_byref = force +sp_before_byref = remove + +# align_pp_define_span = 3 +# align_pp_define_gap = 3 + +align_number_left = true + +align_assign_span = 1 + +align_typedef_span = 2 diff --git a/tests/config/wessex.cfg b/tests/config/wessex.cfg new file mode 100644 index 0000000000..681c52bb0e --- /dev/null +++ b/tests/config/wessex.cfg @@ -0,0 +1,676 @@ + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 4 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 4 # number + +# The ascii value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 4 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs, align with spaces +# 2=indent and align with tabs +indent_with_tabs = 0 # number + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 4 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = false # false/true + +# Indent based on the size of the brace parent, ie 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = true # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Whether to indent continued function call parameters one indent level (true) or aligns instead of indent (false) +indent_func_call_param = false # false/true + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 0 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 4 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = force # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = force # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = force # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = remove # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*' +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space before reference sign '&' +sp_before_byref = force # ignore/add/remove/force + +# Add or remove space after reference sign '&' +sp_after_byref = remove # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = force # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = remove # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = force # ignore/add/remove/force + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = force # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = remove # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statment. +sp_before_semi_for_empty = remove # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside '[' and ']' +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = force # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = force # ignore/add/remove/force + +# Add or remove space after cast +sp_after_cast = remove # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = remove # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = remove # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = remove # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = force # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to use tabs for alinging +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = true # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 4 # number + +# How to align the star in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_star_style = 1 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 4 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = true # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = true # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 4 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 4 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 4 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 4 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 4 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 4 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 4 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typdef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 1 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 4 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 4 # number + +# Whether to align macros wrapped with a backslash and a newline +align_nl_cont = true # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 4 # number + +# +# Newline adding and removing options +# + +# Try to limit code width to N number of columns +code_width = 120 # number + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't touch one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = false # false/true + +# Don't touch one-line function bodies inside a class xx { } body +nl_class_leave_one_liners = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = force # ignore/add/remove/force + +# The number of newlines after a block of variable definitions +nl_func_var_def_blk = 1 # number + +# Add or remove newline between function call and '(' +nl_fcall_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = force # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = force # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = force # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = force # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = force # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = force # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = force # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = force # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = force # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = force # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = force # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = force # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = force # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = force # ignore/add/remove/force + +# Whether to put a newline before 'case' statement +nl_before_case = true # false/true + +# Whether to put a newline after 'case' statement +nl_after_case = true # false/true + +# Newline between namespace and { +nl_namespace_brace = force # ignore/add/remove/force + +# Add or remove newline between 'template<>' and 'class' +nl_template_class = force # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = force # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = force # ignore/add/remove/force + +# Add or remove newline between return type and function name in definition +nl_func_type_name = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = remove # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = force # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = remove # ignore/add/remove/force + +# Add or remove newline between function signature and '{' +nl_fdef_brace = force # ignore/add/remove/force + +# Whether to put a newline after 'return' statement +nl_after_return = false # false/true + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = true # false/true + +# Whether to put a newline after brace open +nl_after_brace_open = true # false/true + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = true # false/true + +# Add or remove newline before 'if' +nl_before_if = force # ignore/add/remove/force + +# Add or remove newline after 'if' +nl_after_if = remove # ignore/add/remove/force + +# Add or remove newline before 'for' +nl_before_for = force # ignore/add/remove/force + +# Add or remove newline after 'for' +nl_after_for = remove # ignore/add/remove/force + +# Add or remove newline before 'while' +nl_before_while = force # ignore/add/remove/force + +# Add or remove newline after 'while' +nl_after_while = remove # ignore/add/remove/force + +# Add or remove newline before 'switch' +nl_before_switch = force # ignore/add/remove/force + +# Add or remove newline after 'switch' +nl_after_switch = remove # ignore/add/remove/force + +# Add or remove newline before 'do' +nl_before_do = force # ignore/add/remove/force + +# Add or remove newline after 'do' +nl_after_do = remove # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# +# Positioning options +# + +# The position of boolean operators in wrapped expressions +pos_bool = trail # ignore/lead/trail + +# The position of the comma in wrapped expressions +pos_comma = trail # ignore/lead/trail + +# The position of colons between constructor and member initialization +pos_class_colon = lead # ignore/lead/trail + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = true # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = true # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 2 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 1 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 2 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 2 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 2 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 2 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 2 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 2 # number + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = true # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = true # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function defintions. (Pawn) +mod_full_brace_function = add # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement +mod_full_brace_if = add # ignore/add/remove/force + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = remove # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = true # false/true + +# +# Comment modifications +# + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# +# Preprocessor options +# + +# Add or remove indent of preprocessor directives +pp_indent = remove # ignore/add/remove/force + +# Add or remove space between # and, say, define +pp_space = remove # ignore/add/remove/force + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP + +macro-open BEGIN_TEMPLATE_MESSAGE_MAP +macro-open BEGIN_MESSAGE_MAP +macro-close END_MESSAGE_MAP + diff --git a/tests/config/width-2.cfg b/tests/config/width-2.cfg new file mode 100644 index 0000000000..3087c597c8 --- /dev/null +++ b/tests/config/width-2.cfg @@ -0,0 +1,39 @@ +# +# width stuff +# +# $Id: width-2.cfg 889 2007-08-25 21:14:12Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 8 +indent_columns = 4 + +nl_if_brace = remove +nl_elseif_brace = remove +nl_else_brace = remove +nl_brace_else = remove +nl_fdef_brace = force + +sp_arith = force +sp_macro = force +sp_macro_func = force +sp_sparen_brace = add +sp_after_sparen = add +sp_fparen_brace = force +sp_square_fparen = remove +sp_inside_braces = add +sp_after_tag = remove + +code_width = 60 +cmt_width = 60 +cmt_cpp_to_c = true +cmt_cpp_group = true +cmt_c_group = true +cmt_c_nl_end = true +cmt_star_cont = true + +sp_after_ptr_star = remove +sp_before_ptr_star = force + +ls_for_split_full = true +ls_func_split_full = false diff --git a/tests/config/width-3.cfg b/tests/config/width-3.cfg new file mode 100644 index 0000000000..1f0ec146fd --- /dev/null +++ b/tests/config/width-3.cfg @@ -0,0 +1,33 @@ +# +# width stuff +# +# $Id: width-3.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 8 +indent_columns = 4 + +nl_if_brace = remove +nl_elseif_brace = remove +nl_else_brace = remove +nl_brace_else = remove +nl_fdef_brace = force + +sp_arith = force +sp_macro = force +sp_macro_func = force +sp_sparen_brace = add +sp_after_sparen = add +sp_fparen_brace = force +sp_square_fparen = remove +sp_inside_braces = add +sp_after_tag = remove + +code_width = 80 + +sp_after_ptr_star = remove +sp_before_ptr_star = force + +ls_for_split_full = true +ls_func_split_full = true diff --git a/tests/config/width.cfg b/tests/config/width.cfg new file mode 100644 index 0000000000..0dd9e1e253 --- /dev/null +++ b/tests/config/width.cfg @@ -0,0 +1,33 @@ +# +# width stuff +# +# $Id: width.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 +input_tab_size = 8 +indent_columns = 4 + +nl_if_brace = remove +nl_elseif_brace = remove +nl_else_brace = remove +nl_brace_else = remove +nl_fdef_brace = force + +sp_arith = force +sp_macro = force +sp_macro_func = force +sp_sparen_brace = add +sp_after_sparen = add +sp_fparen_brace = force +sp_square_fparen = remove +sp_inside_braces = add +sp_after_tag = remove + +code_width = 60 + +sp_after_ptr_star = remove +sp_before_ptr_star = force + +ls_for_split_full = false +ls_func_split_full = true diff --git a/tests/config/xml-str.cfg b/tests/config/xml-str.cfg new file mode 100644 index 0000000000..0fbf8c7bcd --- /dev/null +++ b/tests/config/xml-str.cfg @@ -0,0 +1,98 @@ +# +# My favorite format +# +# $Id: xml-str.cfg 803 2007-07-25 00:36:25Z bengardner $ +# + +indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs +input_tab_size = 8 # original tab size +output_tab_size = 3 # new tab size +indent_columns = output_tab_size +indent_label = 2 # pos: absolute col, neg: relative column +indent_access_spec = 2 +indent_align_string = True # align broken strings +indent_xml_string = 2 # align broken strings +indent_brace = 0 +indent_member = indent_columns + +nl_assign_brace = add # "= {" vs "= \n {" +nl_enum_brace = add # "enum {" vs "enum \n {" +nl_union_brace = add # "union {" vs "union \n {" +nl_struct_brace = add # "struct {" vs "struct \n {" +nl_do_brace = add # "do {" vs "do \n {" +nl_if_brace = add # "if () {" vs "if () \n {" +nl_for_brace = add # "for () {" vs "for () \n {" +nl_else_brace = add # "else {" vs "else \n {" +nl_while_brace = add # "while () {" vs "while () \n {" +nl_switch_brace = add # "switch () {" vs "switch () \n {" +nl_func_var_def_blk = 1 +nl_before_case = 1 +nl_fcall_brace = add # "foo() {" vs "foo()\n{" +nl_fdef_brace = add # "int foo() {" vs "int foo()\n{" +nl_after_return = TRUE +nl_brace_while = remove +nl_brace_else = add +nl_squeeze_ifdef = TRUE + +mod_paren_on_return = add # "return 1;" vs "return (1);" +mod_full_brace_if = add # "if (a) a--;" vs "if (a) { a--; }" +mod_full_brace_for = add # "for () a--;" vs "for () { a--; }" +mod_full_brace_do = add # "do a--; while ();" vs "do { a--; } while ();" +mod_full_brace_while = add # "while (a) a--;" vs "while (a) { a--; }" + +sp_before_byref = remove +sp_before_semi = remove +sp_paren_paren = remove # space between (( and )) +sp_return_paren = remove # "return (1);" vs "return(1);" +sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_before_sparen = force # "if (" vs "if(" +sp_after_sparen = force # "if () {" vs "if (){" +sp_after_cast = remove # "(int) a" vs "(int)a" +sp_inside_braces = force # "{ 1 }" vs "{1}" +sp_inside_braces_struct = force # "{ 1 }" vs "{1}" +sp_inside_braces_enum = force # "{ 1 }" vs "{1}" +sp_inside_paren = remove +sp_inside_fparen = remove +sp_inside_sparen = remove +sp_inside_square = remove +#sp_type_func = ignore +sp_assign = force +sp_arith = force +sp_bool = force +sp_compare = force +sp_assign = force +sp_after_comma = force +sp_func_def_paren = remove # "int foo (){" vs "int foo(){" +sp_func_call_paren = remove # "foo (" vs "foo(" +sp_func_proto_paren = remove # "int foo ();" vs "int foo();" +sp_after_ptr_star = remove +sp_before_ptr_star = force +sp_between_ptr_star = remove + +align_with_tabs = FALSE # use tabs to align +align_on_tabstop = FALSE # align on tabstops +align_enum_equ_span = 4 +align_nl_cont = TRUE +align_var_def_span = 2 +align_var_def_inline = TRUE +align_var_def_star_style = 1 +align_var_def_colon = TRUE +align_assign_span = 1 +# align_assign_thresh = 8 +align_struct_init_span = 3 +align_var_struct_span = 3 +align_right_cmt_span = 3 +align_pp_define_span = 3 +align_pp_define_gap = 4 +align_number_left = TRUE +align_typedef_span = 5 +align_typedef_gap = 3 + +cmt_star_cont = TRUE + +eat_blanks_before_close_brace = TRUE +eat_blanks_after_open_brace = TRUE + +# indent_namespace = FALSE +indent_class = TRUE + diff --git a/tests/cpp.test b/tests/cpp.test new file mode 100644 index 0000000000..70943b6d3a --- /dev/null +++ b/tests/cpp.test @@ -0,0 +1,153 @@ +# +# Test cases specifically for the C++ language. +# $Id: cpp.test 1641 2009-10-16 01:29:30Z bengardner $ +# +# test.name config.file input.file + +30000 ben.cfg cpp/cout.cpp +#30001 ben.cfg cpp/alt_tokens.cpp +30002 ben.cfg cpp/constructor.cpp +30003 ben.cfg cpp/strings.cpp +30010 ben.cfg cpp/class.h +30011 ben.cfg cpp/misc.cpp +30012 avalon2.cfg cpp/misc2.cpp +30013 sim.cfg cpp/sim.h +30014 ben.cfg cpp/ctor-var.cpp +30015 ben.cfg cpp/exception.cpp +30016 custom-open.cfg cpp/custom-open.cpp +30017 custom-open2.cfg cpp/custom-open.cpp +30018 ben.cfg cpp/class-addr.h +30019 ben.cfg cpp/wacky-template.cpp + +30020 ben.cfg cpp/bool.cpp +30021 ben.cfg cpp/byref.cpp +30022 ben.cfg cpp/extern_c.h +30023 ben.cfg cpp/templates.cpp +30024 class-nl_func-add.cfg cpp/class-init.cpp +30025 class-nl_func-del.cfg cpp/class-init.cpp + +30026 byref-left.cfg cpp/byref.cpp +30027 byref-right.cfg cpp/byref.cpp +30028 byref-center.cfg cpp/byref.cpp + +30029 ben.cfg cpp/init_align.h + +30030 avalon.cfg cpp/Timestamp.h +30031 avalon.cfg cpp/operator.cpp +30032 op-space-force.cfg cpp/operator.cpp +30033 op-space-remove.cfg cpp/operator.cpp + +30040 nl_class-r.cfg cpp/nl-class.h +30041 nl_class-a.cfg cpp/nl-class.h + +30045 nl_func_decl_1.cfg cpp/nl_func_decl.cpp +30046 nl_func_decl_2.cfg cpp/nl_func_decl.cpp + +30050 nl_namespace-r.cfg cpp/nl-namespace.h +30051 nl_namespace-a.cfg cpp/nl-namespace.h + +30052 nl_try-a.cfg cpp/try-catch-nl.cpp + +30055 nl_after_func_body.cfg cpp/nl_func.cpp +30056 nl_after_func_body-2.cfg cpp/nl_func.cpp + +# Class colon positioning +30061 class-colon-pos-eol.cfg cpp/class-init.cpp +30062 class-colon-pos-sol.cfg cpp/class-init.cpp +30063 class-colon-pos-eol-add.cfg cpp/class-init.cpp +30064 class-colon-pos-sol-add.cfg cpp/class-init.cpp +30065 class-colon-pos-sol.cfg cpp/Example.h + +30070 nl_func_scope_name.cfg cpp/nl_func_scope_name.cpp + +30075 /dev/null cpp/goto.cpp + +30080 nl_brace_brace-a.cfg cpp/nl_brace_brace.cpp + +30100 nl_template_class-force.cfg cpp/templates.cpp +30101 nl_template_class-remove.cfg cpp/templates.cpp +30102 template_sp-force.cfg cpp/templates.cpp +30103 template_sp-remove.cfg cpp/templates.cpp +30104 avalon3.cfg cpp/templ_class.h +30105 avalon4.cfg cpp/av.h +30106 nl_template_class-force.cfg cpp/templates2.cpp +30107 nl_template_class-remove.cfg cpp/templates2.cpp +30108 nl_template_class-remove.cfg cpp/templates3.cpp +30109 template4.cfg cpp/templates4.cpp + +30201 cmt_indent-1.cfg cpp/cmt_indent.cpp +30202 cmt_indent-2.cfg cpp/cmt_indent.cpp +30203 cmt_indent-3.cfg cpp/cmt_indent.cpp +30204 comment-align.cfg cpp/comment-align.cpp +30205 cmt_right.cfg cpp/cmt_right.cpp + +30250 align_fcall.cfg cpp/align_fcall.cpp +30251 align_fcall-2.cfg cpp/align_fcall.cpp + +30255 ben.cfg cpp/align_constr.cpp + +30260 var_def_gap.cfg cpp/var_def_gap.cpp + +30270 const_throw.cfg cpp/const_throw.cpp +30271 sp_throw_paren-r.cfg cpp/sp_throw_paren.cpp +30272 sp_throw_paren-f.cfg cpp/sp_throw_paren.cpp + +# function def newlines +30701 func-def-1.cfg cpp/function-def.cpp +30702 func-def-2.cfg cpp/function-def.cpp +30703 func-def-3.cfg cpp/function-def.cpp + +30711 del_semicolon.cfg cpp/semicolons.cpp + +30720 wessex.cfg cpp/custom-open-2.cpp + +30730 ben.cfg cpp/qt-1.cpp +30731 nl_access_spec.cfg cpp/qt-1.cpp + +30740 sef.cfg cpp/sef.cpp +30741 al.cfg cpp/al.cpp +30742 delete.cfg cpp/delete.cpp + +30800 star_pos-0.cfg cpp/align-star-amp-pos.cpp +30801 star_pos-1.cfg cpp/align-star-amp-pos.cpp +30802 star_pos-2.cfg cpp/align-star-amp-pos.cpp + +30805 ptr_star-1.cfg cpp/ptr-star.cpp +30806 ptr_star-2.cfg cpp/ptr-star.cpp +30807 ptr_star-3.cfg cpp/ptr-star.cpp + +30810 ben.cfg cpp/ptr-star.cpp +30811 avalon4.cfg cpp/misc3.cpp +30812 ben.cfg cpp/misc4.cpp +30813 ben.cfg cpp/misc5.cpp +30814 misc6.cfg cpp/misc6.cpp + +30815 width-2.cfg cpp/cmt-reflow.cpp +30816 cu.cfg cpp/for_long.cpp + +30820 pp_define_at_level-1.cfg cpp/pp-define-indent.cpp + +30830 kw_subst2.cfg cpp/kw_subst.cpp +30831 kw_subst.cfg cpp/kw_subst2.cpp + +30840 nl_func_type_name_remove.cfg cpp/nl_func_type_name.cpp +30841 nl_func_type_name_force.cfg cpp/nl_func_type_name.cpp +30842 nl_func_type_name_class.cfg cpp/nl_func_type_name.cpp + +30845 ben.cfg cpp/deref.cpp + +30900 region-0.cfg cpp/region.cpp +30901 region-1.cfg cpp/region.cpp +30902 region-2.cfg cpp/region.cpp +30903 region-3.cfg cpp/region.cpp + +30910 indent_namespace-t.cfg cpp/indent_namespace.h +30911 indent_namespace-f.cfg cpp/indent_namespace.h +30912 long_namespace.cfg cpp/long_namespace.cpp + +30920 ben.cfg cpp/indent-off.cpp +30921 ben.cfg cpp/variadic-template.h +30922 sp_before_ellipsis-f.cfg cpp/variadic-template.h + +30930 indent_var_def.cfg cpp/indent_var_def.cpp + diff --git a/tests/d.test b/tests/d.test new file mode 100644 index 0000000000..f2689692e3 --- /dev/null +++ b/tests/d.test @@ -0,0 +1,33 @@ +# +# Test cases specifically for the D language. +# $Id: d.test 1435 2008-11-26 19:51:06Z bengardner $ +# +# test.name config.file input.file output.file + +40000 d.cfg d/HashMap.d +40001 d.cfg d/imports.d +40002 d.cfg d/volatile.d +40003 d.cfg d/volatile-1.d +40004 d.cfg d/volatile-2.d +40005 d.cfg d/volatile-3.d +40006 d.cfg d/Lexer.d +40007 d2.cfg d/Lexer.d + +40010 d.cfg d/template.d +40020 d.cfg d/funcfunc.d + +40021 d.cfg d/tst01.d +40022 d-tst2.cfg d/tst02.d +40023 d.cfg d/bug-indent.d +40024 d3.cfg d/tst03.d +40025 d3a.cfg d/tst03.d + +40030 d.cfg d/delegate.d + +40040 sort_imports.cfg d/sort_import.d + +40050 d.cfg d/strings.d +40051 d.cfg d/numbers.d +40052 d2.cfg d/numbers.d + + diff --git a/tests/difftest.sh b/tests/difftest.sh new file mode 100755 index 0000000000..b0564b3823 --- /dev/null +++ b/tests/difftest.sh @@ -0,0 +1,53 @@ +#! /bin/sh +# $Id: difftest.sh 798 2007-07-24 16:01:09Z bengardner $ +# +# Shows the difference for a failed test +# + +if [ -n "$1" ] ; then + case "$1" in + -h|--help|--usage) + fn=$(basename $0) + echo "Usage: $fn [TEST [LANG]]" + echo + echo " TEST : the test number pattern, may contain wildcards" + echo " LANG : the language folder name: c, cpp, cs, d, java, oc, pawn, sql" + echo + echo "The script will find all matching tests in the output folder and diff them against the same" + echo "file in the results folder. The language is only required if the same test number is used" + echo "for multiple languages and you only want to see one of them." + echo + echo "Examples:" + echo "$fn # show all test failures" + echo "$fn 30014 # show test failure 30014" + echo "$fn '*' cpp # show all CPP test failure" + exit 1 + ;; + esac +fi + +# Use '*' as the pattern if one wasn't defined +patt=$1 +if [ -z "$patt" ] ; then + patt="*" +fi +path="output" +if [ -n "$2" ] ; then + path="$path/$2" +fi + +# Find the tests that match, remove the .svn folders +files=$(find $path -name "$patt-*" -type f | sed "/\.svn/d") + +did1='' +for t in $files ; do + other=$(echo $t | sed "s/^output/results/") + diff -u $t $other + if [ "$?" = "1" ] ; then + did1='yup' + fi +done + +if [ -z "$did1" ] ; then + echo "No differences" +fi diff --git a/tests/ecma.test b/tests/ecma.test new file mode 100644 index 0000000000..7f467300b0 --- /dev/null +++ b/tests/ecma.test @@ -0,0 +1,9 @@ +# +# Test cases specifically for the C language. +# $Id: c.test 1455 2008-12-13 21:50:56Z bengardner $ +# +# test.name config.file input.file + + +90000 ben.cfg ecma/example-1.es + diff --git a/tests/embed.c b/tests/embed.c new file mode 100644 index 0000000000..5febd2ccd0 --- /dev/null +++ b/tests/embed.c @@ -0,0 +1,45 @@ + + +#include + +static const char *config_file = "config/ben.cfg"; +static const char *source_file = "input/c/bugs.c"; + + +int main(int argc, char *argv[]) +{ + FILE *pf; + + char cmd[1024]; + char buf[1024]; + int len; + + snprintf(cmd, sizeof(cmd),"uncrustify -q -c %s -f %s", config_file, source_file); + + /** + * NOTE: to feed the data into the stdin, you'll have to use posix_spawn(). + * Refer to posix_spawn_file_actions_addopen(). + * However, it is usually OK to just to create a temporary file and use + * that as the input. + */ + + pf = popen(cmd, "r"); + + if (pf == NULL) + { + fprintf(stderr, "Failed to run command '%s'\n", cmd); + } + else + { + printf("--== START OF FILE ==--\n", buf); + while (fgets(buf, sizeof(buf), pf) != NULL) + { + /* capture the output here */ + printf("%s", buf); + } + printf("\n--== END OF FILE ==--\n", buf); + + pclose(pf); + } + return 0; +} diff --git a/tests/fixtest.sh b/tests/fixtest.sh new file mode 100755 index 0000000000..76fac4bfdd --- /dev/null +++ b/tests/fixtest.sh @@ -0,0 +1,40 @@ +#! /bin/sh +# $Id: difftest.sh 798 2007-07-24 16:01:09Z bengardner $ +# +# Copies the files for a test from results/ to output/ +# + +if [ -z "$1" ] ; then + fn=$(basename $0) + echo "Usage: $fn TEST [...]" + echo + echo " TEST : the test number pattern, may contain wildcards" + echo " You can put multiple test numbers on the command line" + echo + echo "The script will find all matching tests in the results folder and copy them" + echo "into the output folder." + echo + echo "Examples:" + echo "$fn 30014 # copy test 30014" + echo "$fn 30014 00110 # copy tests 30014 and 00110" + echo "$fn '*' # copy all tests" + exit 1 +fi + +while [ -n "$1" ] ; do + # Use '*' as the pattern if one wasn't defined + patt=$1 + path="results" + + # Find the tests that match, remove the .svn folders + files=$(find $path -name "$patt-*" -type f | sed "/\.svn/d") + + did1='' + for t in $files ; do + other=$(echo $t | sed "s/^results/output/") + echo "cp $t $other" + cp $t $other + done + + shift 1 +done diff --git a/tests/input/align_fcall.cpp b/tests/input/align_fcall.cpp new file mode 100644 index 0000000000..cdedab54b4 --- /dev/null +++ b/tests/input/align_fcall.cpp @@ -0,0 +1,7 @@ +void foo() +{ +abc(1,2,3); +abc(10,20,30); +abc(100,200,300); +bat(1000,2000,3000); +} diff --git a/tests/input/c/add_long_comment.c b/tests/input/c/add_long_comment.c new file mode 100644 index 0000000000..5900de524f --- /dev/null +++ b/tests/input/c/add_long_comment.c @@ -0,0 +1,36 @@ +/** + * trailing comments are added at 8 newlines in this test. + * + * + */ +void short_function(void) +{ + /* this is a 'short' function, so no added comment */ +} + +void long_function(void) +{ + /* this is a 'long' function, so a comment is added */ + switch (some_int_value()) + { + case 0: + handle_zero(); + break; + + case 50: + handle_fifty(); + break; + + case 127: + handle_another_value(); + break; + + default: + boy_do_i_lack_imagination(); + break; + } + + /* call one last function... */ + one_last_func_call(); +} + diff --git a/tests/input/c/align-equ.c b/tests/input/c/align-equ.c new file mode 100644 index 0000000000..374ccbfb42 --- /dev/null +++ b/tests/input/c/align-equ.c @@ -0,0 +1,31 @@ + +// note - set threshold to three +void foo(void) +{ + a = 1; + bb = 2; + ccc = 3; + dddd = 4; + eeeee = 5; + ffffff = 6; + + + + a = 1; + eeeeee = 5; + fffffff = 6; + + + + a = 1; + eeeee = 5; + ccc = 3; + ffffff = 6; + + + a = 1; + iiiiiiiiiiiiieeeee = 5; + ccc = 3; + ffffff = 6; +} + diff --git a/tests/input/c/align-proto-vars.c b/tests/input/c/align-proto-vars.c new file mode 100644 index 0000000000..e1dd71ff58 --- /dev/null +++ b/tests/input/c/align-proto-vars.c @@ -0,0 +1,12 @@ +int doStuff(int i, + float f ); + +int doStuff(int i, + float f ); + + +MACRO_MODIFIER int doStuff(int i, + float f ); + +typedef void (*my_callback)(int id, +void *context); diff --git a/tests/input/c/align-proto.c b/tests/input/c/align-proto.c new file mode 100644 index 0000000000..64dfce0030 --- /dev/null +++ b/tests/input/c/align-proto.c @@ -0,0 +1,4 @@ +unsigned int align_here(); +int this_works(int x); +int bug(int); // BUG: left-aligned + diff --git a/tests/input/c/align-string.c b/tests/input/c/align-string.c new file mode 100644 index 0000000000..f652e88fb1 --- /dev/null +++ b/tests/input/c/align-string.c @@ -0,0 +1,14 @@ + +// note - set threshold to three +void foo(void) +{ + printf("This is the first line\n" + "And this is the second.\n"); + + fprintf(stderr, "This is the first line\n" + "And this is the second.\n"); + + fprintf(stderr, "Format string: %s", "This is the first line\n" + "And this is the second.\n"); +} + diff --git a/tests/input/c/align-struct-init.c b/tests/input/c/align-struct-init.c new file mode 100644 index 0000000000..084994ff3a --- /dev/null +++ b/tests/input/c/align-struct-init.c @@ -0,0 +1,48 @@ + +const char *token_names[] = +{ + [CT_POUND] = "POUND", + [CT_PREPROC] = "PREPROC", + [CT_PREPROC_BODY] = "PREPROC_BODY", + [CT_PP] = "PP", + [CT_ELIPSIS] = "ELIPSIS", + [CT_NAMESPACE]= "NAMESPACE", + [CT_NEW] = "NEW", + [CT_OPERATOR] = "OPERATOR", + [CT_THROW] = "THROW", + [CT_TRY] = "TRY", + [CT_USING] = "USING", + [CT_PAREN_OPEN] = "PAREN_OPEN", +}; + + +int main(int argc, char *argv[]) +{ + struct junk a[] = { + { "version", 0, 0, 0}, + {"file", 1, 150, 'f'}, + {"config", 1, 0, 'c'}, + {"parsed", 25, 0, 'p'}, + { NULL, 0, 0, 0} + }; +} + + color_t colors[] = { + {"red",{255,0,0}},{"blue",{0,255,0}}, + {"green",{0,0,255}},{"purple",{255,255,0}}, + }; + + struct foo_t bar = { + .name = "bar", + .age = 21 +}; + + + +struct foo_t bars[] = { + [0] = { .name = "bar", + .age = 21 }, + [1] = { .name = "barley", + .age = 55 }, +}; + diff --git a/tests/input/c/align-typedef.c b/tests/input/c/align-typedef.c new file mode 100644 index 0000000000..ae17eb4daa --- /dev/null +++ b/tests/input/c/align-typedef.c @@ -0,0 +1,11 @@ + +typedef int MY_INT; +typedef int * MY_INTP; +typedef int(*foo_t)(void *bar); +typedef int(*somefunc_t)(void *barstool); +typedef int int8_t __attribute__((__mode__(__QI__))); +typedef int uint8_t; +typedef struct _IDirectFBSurface IDirectFBSurface; +typedef struct _IDirectFBPalette IDirectFBPalette; +typedef struct timezone *__restrict __timezone_ptr_t; + diff --git a/tests/input/c/align-var.c b/tests/input/c/align-var.c new file mode 100644 index 0000000000..f653fcb02d --- /dev/null +++ b/tests/input/c/align-var.c @@ -0,0 +1,46 @@ +struct foo1 { + unsigned int d_ino; + const char *d_reclen; + unsigned short d_namlen; + char d_name[1]; +}; + +struct foo2 +{ + unsigned int a : 1; + unsigned int bcd : 3; + unsigned int ef : 2; + unsigned int gh : 2; + + unsigned short more; + + int fields; +}; + +struct foo { int a; char *b }; + +static int idx; +static const char **tmp; + +static char buf[64]; +static unsigned long how_long; +// comment +static int **tmp; +static char buf[64]; + + +void bar(int someval, + void *puser, + const char *filename, + struct willy *the_list, + int list_len) +{ + int idx; + const char **tmp; + char buf[64]; + + unsigned long how_long; + + return(-1); +} + diff --git a/tests/input/c/align_attr.c b/tests/input/c/align_attr.c new file mode 100644 index 0000000000..0f4cfee1f7 --- /dev/null +++ b/tests/input/c/align_attr.c @@ -0,0 +1,4 @@ + +char test[3] _PREPROCESSOR_SOMETHING; +int numberThatIsReallyCool _PREPROCESSOR_SOMETHING; + diff --git a/tests/input/c/beautifier-off.c b/tests/input/c/beautifier-off.c new file mode 100644 index 0000000000..5eca5b5250 --- /dev/null +++ b/tests/input/c/beautifier-off.c @@ -0,0 +1,32 @@ + + +#define FOO(bar) create_a_really_long_identifier name(some_function(bar1 + bar2), bar3, bar4); + +/* *INDENT-OFF* */ + int foo[] = { + 1, 3, 5, + 3, 5, 7, + 5, 7, 9, + }; +/* *INDENT-ON* */ + +#define multilinemacro do { (x+5); } while (0); \ +printf("a multilinemacro"); \ +printf("a multilinemacro2"); + +/* *INDENT-OFF* */ + +int main(int argc, char *argv[]) +{ + int a, b; +a = 1; // stupid comment \ +b = 2; + +/* *INDENT-ON* */ +return(a+b); +} + +/* *INDENT-OFF* */ +int a; +/* *INDENT-ON* */ + diff --git a/tests/input/c/bits.c b/tests/input/c/bits.c new file mode 100644 index 0000000000..9a12f484c8 --- /dev/null +++ b/tests/input/c/bits.c @@ -0,0 +1,7 @@ +struct foo { + unsigned long bar; + u_int ndots : 4, +nsort: 4, +: 0; +}; + diff --git a/tests/input/c/bool-pos.c b/tests/input/c/bool-pos.c new file mode 100644 index 0000000000..3aa1bfe4f2 --- /dev/null +++ b/tests/input/c/bool-pos.c @@ -0,0 +1,52 @@ +void foo(void) +{ + if ((a != 0) && + (b == 0) && + (c < 0) && (d > 0)) + { + printf("hi"); + } + + if (flag1 +#ifdef FLAG2 + || flag2 +#endif + ) + { + printf("yar"); + } + + if ((a != 0) + && (b == 0) + && (c < 0)) + { + printf("hi"); + } + + if ((a != 0) + && + (b == 0) + && + (c < 0)) + { + printf("hi"); + } + + if (!this -> writeOwiFile () || // comment1 + broken () || !saveArchiveData () /* comment2 */ + || broken () || !deleteCentralArchive () // comment3 + || broken () || !copyArchivFiles () // comment4 + || broken () || !appendToPlanetDb ()) // comment5 + { + ; + } + + foobar(param1, + param2, param3, + param4); + + foobar2(param1 + , param2, param3 + , param4); +} + diff --git a/tests/input/c/brace-remove.c b/tests/input/c/brace-remove.c new file mode 100644 index 0000000000..992e4fcb3d --- /dev/null +++ b/tests/input/c/brace-remove.c @@ -0,0 +1,65 @@ + +void foo(void) +{ + int a = 0; + while (a < 3) + { + a++; + } + + while (b < a) + b++; + + do + { + a--; + } while (a > 0); + + for (a = 0; a < 10; a++) + { + printf("a=%d\n", a); + } + + if (a == 10) + { + printf("a looks good\n"); + } + + if (state == ST_RUN) + { + if ((foo < bar) && + (bar > foo2)) + { + if (a < 5) + { + a *= a; + } + } + } + + while (*ptr++ != ',') + { + } +} + +// mod_full_brace_for = remove should not remove the braces in this example: +int main() { + if(true) // indent=1 + for(int i = 0; i < 3; i++) { + if(false) + continue; // indent=4 + } + else + return; // indent=2 +} + +// mod_full_brace_if = remove should not remove the braces in this example: +int main() { + if(true) { + for(int i = 0; i < 3; i++) + if(false) + continue; // indent=4 + } + else + return; // indent=2 +} diff --git a/tests/input/c/brace-remove2.c b/tests/input/c/brace-remove2.c new file mode 100644 index 0000000000..e5b73723cd --- /dev/null +++ b/tests/input/c/brace-remove2.c @@ -0,0 +1,52 @@ +/* else is tied to if(two) */ +int main() { + if (one) { + if (two) + sleep (1); + else + sleep (2); + } + + if (three) + sleep(1); + else + if (four) + sleep(2); +} + +/* else is tied to if(one) */ +int main() { + if (one) { + if (two) + sleep (1); + } + else { + if (three) + sleep (2); + } +} + +/* else.1 is tied to if(two), else.2 is tied to if(one) */ +int main() { + if (one) { + if (two) + sleep (1); + else { + if (three) + sleep (2); + } + } + else + sleep (3); +} +int main() { + + if (read_write == I2C_SMBUS_READ) + { + msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; + } + else + { + msg[0].len = data->block[0] + 1; + } +} diff --git a/tests/input/c/brace.c b/tests/input/c/brace.c new file mode 100644 index 0000000000..31f3b42b53 --- /dev/null +++ b/tests/input/c/brace.c @@ -0,0 +1,13 @@ + + + +int function(int arg) { + int i; + for (i=0;i<5;i++){ + /* Do something... */ + } + if(i<0){ + /*Do something else...*/ } + + return 0; +} diff --git a/tests/input/c/braces-2.c b/tests/input/c/braces-2.c new file mode 100644 index 0000000000..a34d73d80a --- /dev/null +++ b/tests/input/c/braces-2.c @@ -0,0 +1,14 @@ +while (a >= 0) +{ + if (b) + for (j = 0; j < 10; j++) + { + if (j == b) + { + return; + } + a++; + } + b--; +} + diff --git a/tests/input/c/braces-3.c b/tests/input/c/braces-3.c new file mode 100644 index 0000000000..1f1a20662b --- /dev/null +++ b/tests/input/c/braces-3.c @@ -0,0 +1,9 @@ +{ + list_for_each(k) { + if (a) + if (b) + { + c++; + } + } +} diff --git a/tests/input/c/braces-4.c b/tests/input/c/braces-4.c new file mode 100644 index 0000000000..385f4a8ef4 --- /dev/null +++ b/tests/input/c/braces-4.c @@ -0,0 +1,12 @@ +int foo(int bar) +{ +#ifndef CONFIG_1 + bar -= 3; +#else + for (j = 0; j < NR_CPUS; j++) + if (cpu_online(j)) + bar++; +#endif + return 0; +} + diff --git a/tests/input/c/braces-5.c b/tests/input/c/braces-5.c new file mode 100644 index 0000000000..c77cc91270 --- /dev/null +++ b/tests/input/c/braces-5.c @@ -0,0 +1,20 @@ +/** + * this is a really tough case - perhaps we shouldn't keep any #if crap + * unless they all end with the same stack? + */ +void foo(void) +{ + int a; +#ifdef CONFIG_BLK_DEV_INITRD + if (initrd_start) + ROOT_DEV = Root_RAM0; +#elif defined(CONFIG_ROOT_NFS) + ROOT_DEV = Root_NFS; +#elif defined(CONFIG_BLK_DEV_IDEDISK) + ROOT_DEV = Root_HDA1; +#else + ROOT_DEV = Root_SDA1; +#endif + return; +} + diff --git a/tests/input/c/braces.c b/tests/input/c/braces.c new file mode 100644 index 0000000000..20733afce2 --- /dev/null +++ b/tests/input/c/braces.c @@ -0,0 +1,79 @@ + +void foo(void) +{ + int a = 0; + while (a < 3) + { + a++; + } + + while (b < a) // trailing C++ comment + b++; + + do // trailing C++ comment + { + a--; + } while (a > 0); + + do + a--; + while (a > 0); + + for (a = 0; a < 10; a++) // trailing C++ comment + { + printf("a=%d\n", a); + } + + if (a == 10) // trailing C++ comment + { + printf("a looks good\n"); + } + else // trailing C++ comment + { + printf("not so good\n"); + } + + if (state == ST_RUN) + { + if ((foo < bar) && + (bar > foo2)) + { + if (a < 5) + { + a *= a; + } + else if (b != 0) + a /= b; + else // trailing C++ comment + a += b; + } + } + + list_for_each(k) { + if (a) + if (b) + { + c++; + } + } + + + while (1) + ; /* hang forever */ +} + +void f() { + if (buf[0] == '~' && strchr(tmp, '/') == NULL) { + buf = mallocstrcpy(buf, tmp); + matches = username_tab_completion(tmp, &num_matches); + } + /* If we're in the middle of the original line, copy the string + only up to the cursor position into buf, so tab completion + will result in buf's containing only the tab-completed + path/filename. */ + else if (strlen(buf) > strlen(tmp)) + buf = mallocstrcpy(buf, tmp); +} + +void f() {} void g() {} + diff --git a/tests/input/c/bsnl.c b/tests/input/c/bsnl.c new file mode 100644 index 0000000000..b2b38b8eb9 --- /dev/null +++ b/tests/input/c/bsnl.c @@ -0,0 +1,5 @@ +# define SOME_MACRO \ + bool has_err; \ + bool is_comp;\ + struct some_stream ostream + diff --git a/tests/input/c/bugs-1.c b/tests/input/c/bugs-1.c new file mode 100644 index 0000000000..39050c0793 --- /dev/null +++ b/tests/input/c/bugs-1.c @@ -0,0 +1,52 @@ +int oldfoo(bar) + char bar; +{ + return bar -2; +} + +int i2c_use_client(struct i2c_client *client) +{ + int ret; + + ret = i2c_inc_use_client(client); + if (ret) + return ret; + + if ((client->flags & I2C_CLIENT_ALLOW_USE) || (a && + something_else)) + { + if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + client->usage_count++; + else if (client->usage_count > 0) + goto busy; + else + client->usage_count++; + } + + return 0; + busy: + i2c_dec_use_client(client); + return -EBUSY; +} + +void get_name(void) +{ + a = (int)5; + + if (a) + if (b) + b--; + else + { + a++; + } + for (a=0; a < 10; a++) + if (b) + { + b--; + } + else + a++; + return; +} + diff --git a/tests/input/c/bugs-2.c b/tests/input/c/bugs-2.c new file mode 100644 index 0000000000..42bed259ea --- /dev/null +++ b/tests/input/c/bugs-2.c @@ -0,0 +1,22 @@ +static void tcps_proc_server_msg(void *p_user, const ptc_msg_info_t *p_info) +{ + if (z) + { + if (a) + /* comment */ + { + a++; + } + /* comment */ + else if (b) + { + b++; + } + /* Comment */ + else + { + c++; + } + } +} + diff --git a/tests/input/c/bugs-3.c b/tests/input/c/bugs-3.c new file mode 100644 index 0000000000..4f85044a24 --- /dev/null +++ b/tests/input/c/bugs-3.c @@ -0,0 +1,48 @@ + +#ifdef CRUD +#define JUNK a +#endif + +#ifdef __QNX__ +/** + * Does all that QNX trickery to get the MAC address of the interface + * + * @param if_name The interface name: ie "en0" or "eth0" + * @param mac Pointer to a 6-byte array + * @return SUCCESS or FAILURE + */ +static INT32 socket_get_mac_qnx(const CHAR *if_name, UINT8 *mac) +{ + CHAR ionet_name[50]; + INT32 en_fd; +#if QNX_RELEASE >= 630 + nic_config_t nic; + INT32 dcmd = DCMD_IO_NET_GET_CONFIG; +#else + Nic_t nic; + INT32 dcmd = DCMD_IO_NET_NICINFO; +#endif + INT32 ret_val = FAILURE; + + memset(mac, 0, 6); + + /* Build the full name */ + snprintf(ionet_name, sizeof(ionet_name), "/dev/io-net/%s", if_name); + + /* Open the device */ + en_fd = open(ionet_name, O_RDWR); + if (en_fd >= 0) + { + /* Get the interface info */ + if (devctl(en_fd, dcmd, &nic, sizeof(nic), NULL) == EOK) + { + memcpy(mac, nic.current_address, 6); + ret_val = SUCCESS; + } + + close(en_fd); + } + return(ret_val); +} +#endif + diff --git a/tests/input/c/bugs-4.c b/tests/input/c/bugs-4.c new file mode 100644 index 0000000000..e01c2c3266 --- /dev/null +++ b/tests/input/c/bugs-4.c @@ -0,0 +1,26 @@ + +static void set_md_connected(CHAR *msg_data) +{ + UINT32 rd_idx = 0; + CHAR mobile_device_id[MOBILE_DEVICE_NAME_LEN]; + CHAR ip_addr[IP_ADDRESS_LEN]; + CHAR mac_addr[MAC_ADDR_LEN]; + CHAR ap_name[AP_NAME_LEN]; + + rdc_strz(msg_data,MAX_SIZE,&rd_idx,mobile_device_id,0); + rdc_strz(msg_data,MAX_SIZE,&rd_idx,ip_addr,0); + rdc_strz(msg_data,MAX_SIZE,&rd_idx,mac_addr,0); + rdc_strz(msg_data,MAX_SIZE,&rd_idx,ap_name,0); + +#if defined (DB_MGR_ORACLE) + (void)db_set_md_connected(mobile_device_id,ip_addr,mac_addr,ap_name); + LOG(LFTR,"CONNECTED Loco %s, IP Addr %s,MAC Addr %s, AP Name %s", + mobile_device_id,ip_addr,mac_addr,ap_name); +#elif defined (DB_MGR_FILE) + LOG(LFTR,"%s CONNECTED Loco %s, IP Addr %s,MAC Addr %s, AP Name %s", + status_str,mobile_device_id,ip_addr,mac_addr,ap_name); +#else +#error Unknown device type must be DB_MGR_ORACLE or DB_MGR_FILE +#endif +} + diff --git a/tests/input/c/bugs-5.c b/tests/input/c/bugs-5.c new file mode 100644 index 0000000000..626eb7e651 --- /dev/null +++ b/tests/input/c/bugs-5.c @@ -0,0 +1,13 @@ + +static void log_roll_file(log_output_t *plo) +{ + INT32 retcode; + const CHAR *name_save; + const CHAR *name_temp; + + if (plo->pfile != NULL) + { + + } +} + diff --git a/tests/input/c/bugs-6.c b/tests/input/c/bugs-6.c new file mode 100644 index 0000000000..99ebbddab6 --- /dev/null +++ b/tests/input/c/bugs-6.c @@ -0,0 +1,19 @@ +/*=-------------------------------------------------------------------------=*\ +* +| FUNCTION NAME: mult2 +| +| DESCRIPTION: +| Multiplies a number by two. +| +| INPUTS/OUTPUTS: +| val - the number to double +| +| RETURNS: +| val * 2 +* +\*=-------------------------------------------------------------------------=*/ +int mult2(int val) +{ + return val * 2; +} + diff --git a/tests/input/c/bugs-7.c b/tests/input/c/bugs-7.c new file mode 100644 index 0000000000..a879aa1751 --- /dev/null +++ b/tests/input/c/bugs-7.c @@ -0,0 +1,25 @@ + +struct somestruct * +mult2(int val); + +somestruct * +dumb_func(int val); + + + +struct somestruct * +mult2(int val) +{ + int a; + + a = val + (foo * bar); + + a = val + (bar); + + a = val + (CFoo::bar_t)7; + + a = val + (myfoo.size); + + return NULL; +} + diff --git a/tests/input/c/bugs-8.c b/tests/input/c/bugs-8.c new file mode 100644 index 0000000000..8870a6636c --- /dev/null +++ b/tests/input/c/bugs-8.c @@ -0,0 +1,7 @@ + +void foo(void) +{ +p[0].x = x + (rx * cos(rs)); +p[0].y = y - (ry * sin(rs)); +} + diff --git a/tests/input/c/bugs.c b/tests/input/c/bugs.c new file mode 100644 index 0000000000..d75a478255 --- /dev/null +++ b/tests/input/c/bugs.c @@ -0,0 +1,35 @@ +typedef struct { + int a; + char b; +} foo_t; + +s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) +{ + union i2c_smbus_data data; + int i; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, + I2C_SMBUS_I2C_BLOCK_DATA,&data)) + return -1; + else { + for (i=1;i<=data.block[0];i ++) + values[i-1] = data.block[i]; + return data.block[0]; + } +} + +void foo(void) +{ + adap->nr= id & MAX_ID_MASK; + + list_for_each(item,&drivers) { + driver=list_entry(item, struct i2c_driver, list); + if (driver->detach_adapter) + if ((res = driver->detach_adapter(adap))) + { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } +} diff --git a/tests/input/c/case.c b/tests/input/c/case.c new file mode 100644 index 0000000000..ffceda0ecd --- /dev/null +++ b/tests/input/c/case.c @@ -0,0 +1,69 @@ +void foo(void) +{ + switch(ch) + { + // handle 'a' + case 'a': + { + handle_a(); + multiline(123, + 345); + break; + } + + // handle 'b' + case 'b': + handle_b(); + multiline(123, + 345); + break; + + // handle 'c' and 'd' + case 'c': + case 'd': + // c and d are really the same thing + handle_cd(); + multiline(123, + 345); + break; + + case 'e': + { + handle_a(); + multiline(123, + 345); + } + break; + // case1 + case (case1): + { + //do stuff + break; + } + case (case2): + { + //do stuff + break; + } + case (case3): + + /*do stuff*/ + break; + case (case3): + statement(); + { + another_statement(); + } + break; + + // really should not get here + default: + handle_default(); + multiline(123, + 345); + break; + } + multiline(123, + 345); +} + diff --git a/tests/input/c/casts.c b/tests/input/c/casts.c new file mode 100644 index 0000000000..f09f5c5e79 --- /dev/null +++ b/tests/input/c/casts.c @@ -0,0 +1,89 @@ + +#define SOME_VAL1 ((MYINT)-1) +#define SOME_VAL2 (-2) +#define SOME_VAL3 -3 +#define MULT(X,Y) (X) * (Y) +#define SOME_JUNK /*lint -e123 */(const mytype *)-1 + +typedef (*my_fcn_ptr_t)(char *, int); +typedef (my_fcn_t)(char *, int); + +void foo(void) +{ + uint crc = crc32_calc_full((const UINT8 *)"String", 6); + + crc = crc32_calc_full((const UINT8 *)&crc, sizeof(crc)); + + a = (b) - 4; + + a = (UINT) - 4; + a = (UINT) + 4; + a = (UINT) * 4; + a = (UINT) & 4; + + a = (uint32_t) - pb; + a = (uint32_t) + pb; + a = (uint32_t) * pb; + a = (uint32_t) & pb; + + a = (Uint) - 4; + a = (Uint) + 4; + a = (Uint) * 4; + a = (Uint) & 4; + + a = b * (int)flt; + a = b * ((int)flt); + + a = b * (int)flt; + a = b * (INT8)flt; + a = b * (Uint)flt; + + a = *(int)&b; + a = *(CHAR)&b; + a = *(Uint)&b; + + a = (int)*pb; + a = (CHAR)*pb; + a = (Uint)*pb; + + a = (int)'a'; + a = (UINT8)'a'; + a = (Uint)'a'; + + a = (int)*'a'; + a = (UINT8)*'a'; + a = (Uint)*'a'; + + a = (int)*5; + a = (UINT)*5; + a = (Uint)*5; + + a = (int)*ape; + a = (UINT)*ape; + a = (Uint)*ape; + + a = (int)ape; + a = (UINT)ape; + a = (Uint)ape; + + a = (int)sizeof(x); + a = (INT16)sizeof(x); + a = (Uint)sizeof(x); + + a = (int)foo(x); + a = (CHAR)foo(x); + a = (Uint)foo(x); + + a = (int)(x); + a = (CHAR)(x); + a = (Uint)(x); + + a = (int)*(x); + a = (CHAR)*(x); + a = (Uint)*(x); + + a = (unsigned int)(1 + 4); + a = (int)(1 + 1); + a = (void *)(&str); +} + diff --git a/tests/input/c/cmt-align.c b/tests/input/c/cmt-align.c new file mode 100644 index 0000000000..658bac4dbe --- /dev/null +++ b/tests/input/c/cmt-align.c @@ -0,0 +1,20 @@ +#ifndef HAVE_FOO +void foo(void) +{ + if (bar) + { + call_some_function(); /* call the function */ + return(foo); /* comment */ +} /* if (bar) */ +} +#endif /* HAVE_FOO */ +#ifndef HAVE_BAR /* bar isn't available on all HW */ +void bar(void) +{ + if (foo) + { + call_some_function(); /* call the function */ + return(foo); /* comment */ + } /* if (foo) */ +} +#endif /* HAVE_BAR */ diff --git a/tests/input/c/cmt_multi.c b/tests/input/c/cmt_multi.c new file mode 100644 index 0000000000..8e01c5fc18 --- /dev/null +++ b/tests/input/c/cmt_multi.c @@ -0,0 +1,17 @@ +/************************************************ + * This is a multiline comment. + * The first and last lines are the same length + ************************************************/ + +/**************************************************************************** + A multi-line comment that is broken in two parts. +*//** + Second part +****************************************************************************/ + +/**************************************************************************** + A multi-line comment that is broken in two parts. +*/ /** + Second part +****************************************************************************/ + diff --git a/tests/input/c/cmt_nl_end.c b/tests/input/c/cmt_nl_end.c new file mode 100644 index 0000000000..48929d07c9 --- /dev/null +++ b/tests/input/c/cmt_nl_end.c @@ -0,0 +1,12 @@ +int do_this +( + int x, + int y +) +{ + x += y; // x = x + y + if(x == 3) + x++; // x plus 1 + + return (x) +} diff --git a/tests/input/c/cmt_right_align.c b/tests/input/c/cmt_right_align.c new file mode 100644 index 0000000000..b707f0bb93 --- /dev/null +++ b/tests/input/c/cmt_right_align.c @@ -0,0 +1,47 @@ + +int foo1(int bar) +{ + if(bar) + { + if(b) + { + if(a) + { + if(r) + { + return(r); /* cool */ + } + else /* if (r) */ + { + return(bar); /* uncool */ + } /* if (r) */ + } /* if (a) */ + } /* if (b) */ + } /* if (bar) */ + + return(-1); +} /* foo */ + +int foo2(int bar) +{ + if(bar) + { + if(b) + { + if(a) + { + if(r) + { + return(r); + } + else + { + return(bar); + } /* if (r) */ + } /* if (a) */ + } /* if (b) */ + } /* if (bar) */ + + return(-1); +} /* foo */ + diff --git a/tests/input/c/code_width.c b/tests/input/c/code_width.c new file mode 100644 index 0000000000..ec060a9c09 --- /dev/null +++ b/tests/input/c/code_width.c @@ -0,0 +1,42 @@ + +static int short_function_name(struct device *dev, struct device_driver *drv); + +/* Assuming a 60-column limit */ +static int short_function_name(struct device *dev, struct device_driver *drv) +{ + this->translateLabels(labelID, completedLabelID, selectedLabelID, text, selectedText, completedText, fontId, selectedFontId, completedFontId); + call_some_really_long_function.of_some_sort(some_long_parameter1, some_long_parameter2); + + abc = call_some_other_really_long_function.of_some_sort(some_long_parameter1, some_long_parameter2); + + abc.def.ghi = call_some_other_really_long_function.of_some_sort(some_long_parameter1, some_long_parameter2); + + abcdefghijklmnopqrstuvwxyz = abc + def + ghi + jkl + mno + prq + stu+ vwx + yz; + + return 1; +} + +static void some_really_long_function_name(struct device *dev, struct device_driver *drv) +{ + if ((some_variable_name && somefunction(param1, param2, param3))) + { + asdfghjk = asdfasdfasd.aasdfasd + (asdfasd.asdas * 1234.65); + } + + for (struct something_really_really_excessive *a_long_ptr_name = get_first_item(); a_long_ptr_name != NULL; a_long_ptr_name = get_next_item(a_long_ptr_name)) + { + } + + for (a = get_first(); a != NULL; a = get_next(a)) + { + } + + for (a_ptr = get_first(); a_ptr != NULL; a_ptr = get_next(a)) + { + } + + register_clcmd( "examine", "do_examine", -1, "-Allows a player to examine the health and armor of a teammate" ); + register_clcmd( "/examine", "do_examine", -1, + "-Allows a player to examine the health and armor of a teammate" ); +} + diff --git a/tests/input/c/colon-asm.c b/tests/input/c/colon-asm.c new file mode 100644 index 0000000000..5125af1921 --- /dev/null +++ b/tests/input/c/colon-asm.c @@ -0,0 +1,19 @@ +static void +__marvel_access_rtc(void *info) +{ + struct marvel_rtc_access_info *rtc_access = info; + + register unsigned long __r0 __asm__("$0"); + register unsigned long __r16 __asm__("$16") = rtc_access->function; + register unsigned long __r17 __asm__("$17") = rtc_access->index; + register unsigned long __r18 __asm__("$18") = rtc_access->data; + + __asm__ __volatile__( + "call_pal %4 # cserve rtc" + : "=r"(__r16), "=r"(__r17), "=r"(__r18), "=r"(__r0) + : "i"(PAL_cserve), "0"(__r16), "1"(__r17), "2"(__r18) + : "$1", "$22", "$23", "$24", "$25"); + + rtc_access->data = __r0; +} + diff --git a/tests/input/c/comment-convert.c b/tests/input/c/comment-convert.c new file mode 100644 index 0000000000..4282ab0b1c --- /dev/null +++ b/tests/input/c/comment-convert.c @@ -0,0 +1,27 @@ +// This is your typical header comment + int foo(int bar) + { + int idx; + int res = 0; // trailing comment + // that spans two lines + + + // Comment with embedded /* C comment */ + for (idx = 1; idx < bar; idx++) + /* comment in virtual braces */ + res += idx; + + // Multi-line comment with embedded /* C comment */ and junk + // afterwards + res *= idx; // some comment + + // almost continued, but a NL in between + +// col1 comment in level 1 +// second comment + return(res); +} + + // col1 comment in level 0 + // and another + diff --git a/tests/input/c/comment-indent.c b/tests/input/c/comment-indent.c new file mode 100644 index 0000000000..d5295d6e3e --- /dev/null +++ b/tests/input/c/comment-indent.c @@ -0,0 +1,40 @@ +/** + * This is your typical header comment + */ + int foo(int bar) + { + int idx; + int res = 0; // trailing comment + // that spans two lines + for (idx = 1; idx < bar; idx++) + /* comment in virtual braces */ + res += idx; + + res *= idx; // some comment + + // almost continued, but a NL in between + +// col1 comment in level 1 +// second comment + return(res); +} + + // col1 comment in level 0 + // and another + +void foo() +{ + if( bar ) + { + foo(); + } + /*else if( bar2 ) + { + foo2(); + } + */else if( bar3 ) + { + foo3(); + } +} + diff --git a/tests/input/c/cond.c b/tests/input/c/cond.c new file mode 100644 index 0000000000..aec2f0a389 --- /dev/null +++ b/tests/input/c/cond.c @@ -0,0 +1,10 @@ + +int foo1(bool b, int tv, int fv) +{ + return b ? tv : fv; +} + +int foo2(bool b, int tv, int fv) +{ + return b?tv:fv; +} diff --git a/tests/input/c/custom_types_ssl.c b/tests/input/c/custom_types_ssl.c new file mode 100644 index 0000000000..2ff106c2f2 --- /dev/null +++ b/tests/input/c/custom_types_ssl.c @@ -0,0 +1,134 @@ +#ifndef HEADER_CONF_H +#define HEADER_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct + { + char *section; + char *name; + char *value; + } CONF_VALUE; + +DECLARE_STACK_OF(CONF_VALUE); +DECLARE_LHASH_OF(CONF_VALUE); + +struct conf_st; +struct conf_method_st; +typedef struct conf_method_st CONF_METHOD; + +int CONF_set_default_method(CONF_METHOD *meth); +void CONF_set_nconf(CONF *conf,LHASH_OF(CONF_VALUE) *hash); +LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf,const char *file, + long *eline); +#ifndef OPENSSL_NO_FP_API +LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, + long *eline); +#endif +LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,long *eline); +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, + const char *section); +char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group, + const char *name); +long CONF_get_number(LHASH_OF(CONF_VALUE) *conf,const char *group, + const char *name); +void CONF_free(LHASH_OF(CONF_VALUE) *conf); +int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); +int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); + + +#ifdef __cplusplus +} +#endif + + +void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash) + { + if (default_CONF_method == NULL) + default_CONF_method = NCONF_default(); + + default_CONF_method->init(conf); + conf->data = hash; + } + + +LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, + long *eline) + { + LHASH_OF(CONF_VALUE) *ltmp; + BIO *in=NULL; + +#ifdef OPENSSL_SYS_VMS + in=BIO_new_file(file, "r"); +#else + in=BIO_new_file(file, "rb"); +#endif + if (in == NULL) + { + CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); + return NULL; + } + + return ltmp; + } + +#ifndef OPENSSL_NO_FP_API +LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, + long *eline) + { + BIO *btmp; + LHASH_OF(CONF_VALUE) *ltmp; + if(!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { + CONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB); + return NULL; + } + ltmp = CONF_load_bio(conf, btmp, eline); + BIO_free(btmp); + return ltmp; + } +#endif + +LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, + long *eline) + { + CONF ctmp; + int ret; + + CONF_set_nconf(&ctmp, conf); + + ret = NCONF_load_bio(&ctmp, bp, eline); + if (ret) + return ctmp.data; + return NULL; + } + +STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, + const char *section) + { + if (conf == NULL) + { + return NULL; + } + else + { + CONF ctmp; + CONF_set_nconf(&ctmp, conf); + return NCONF_get_section(&ctmp, section); + } + } + +char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf,const char *group, + const char *name) + { + if (conf == NULL) + { + return NCONF_get_string(NULL, group, name); + } + else + { + return NCONF_get_string(&ctmp, group, name); + } + } + diff --git a/tests/input/c/define-if-indent.c b/tests/input/c/define-if-indent.c new file mode 100644 index 0000000000..1ef4727313 --- /dev/null +++ b/tests/input/c/define-if-indent.c @@ -0,0 +1,9 @@ + +#define foobar(x) \ +{ \ +for (i=0; i < x; i++) \ +{ \ +junk(i,x); \ +} \ +} + diff --git a/tests/input/c/deref.c b/tests/input/c/deref.c new file mode 100644 index 0000000000..100464fb7a --- /dev/null +++ b/tests/input/c/deref.c @@ -0,0 +1,14 @@ +void foo(int *pA, int *pB) +{ + *pB = some.arr[*pA]; + +foo(sizeof bar / sizeof * bar, baz); + +} + +#define MEM_READ_BYTE(phwi, addr, data) \ + * data = * ((PUCHAR)((phwi)->m_pVirtualMemory + addr)) + +#define MEM_WRITE_BYTE(phwi, addr, data) \ + * ((PUCHAR)((phwi)->m_pVirtualMemory + addr)) = (UCHAR)(data) + diff --git a/tests/input/c/directfb.h b/tests/input/c/directfb.h new file mode 100644 index 0000000000..c24a441f7a --- /dev/null +++ b/tests/input/c/directfb.h @@ -0,0 +1,2994 @@ +# 1 "/usr/include/directfb/directfb.h" +# 1 "" +# 1 "" +# 1 "/usr/include/directfb/directfb.h" +# 31 "/usr/include/directfb/directfb.h" +# 1 "/usr/include/directfb/dfb_types.h" 1 + + + +# 1 "/usr/include/sys/types.h" 1 3 4 +# 27 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/include/features.h" 1 3 4 +# 308 "/usr/include/features.h" 3 4 +# 1 "/usr/include/sys/cdefs.h" 1 3 4 +# 309 "/usr/include/features.h" 2 3 4 +# 331 "/usr/include/features.h" 3 4 +# 1 "/usr/include/gnu/stubs.h" 1 3 4 +# 332 "/usr/include/features.h" 2 3 4 +# 28 "/usr/include/sys/types.h" 2 3 4 + + + +# 1 "/usr/include/bits/types.h" 1 3 4 +# 28 "/usr/include/bits/types.h" 3 4 +# 1 "/usr/include/bits/wordsize.h" 1 3 4 +# 29 "/usr/include/bits/types.h" 2 3 4 + + +# 1 "/usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h" 1 3 4 +# 214 "/usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h" 3 4 +typedef unsigned int size_t; +# 32 "/usr/include/bits/types.h" 2 3 4 + + +typedef unsigned char __u_char; +typedef unsigned short int __u_short; +typedef unsigned int __u_int; +typedef unsigned long int __u_long; + + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef signed short int __int16_t; +typedef unsigned short int __uint16_t; +typedef signed int __int32_t; +typedef unsigned int __uint32_t; + + + + +__extension__ typedef signed long long int __int64_t; +__extension__ typedef unsigned long long int __uint64_t; + + + + + + + +__extension__ typedef long long int __quad_t; +__extension__ typedef unsigned long long int __u_quad_t; +# 129 "/usr/include/bits/types.h" 3 4 +# 1 "/usr/include/bits/typesizes.h" 1 3 4 +# 130 "/usr/include/bits/types.h" 2 3 4 + + + + + + +__extension__ typedef __u_quad_t __dev_t; +__extension__ typedef unsigned int __uid_t; +__extension__ typedef unsigned int __gid_t; +__extension__ typedef unsigned long int __ino_t; +__extension__ typedef __u_quad_t __ino64_t; +__extension__ typedef unsigned int __mode_t; +__extension__ typedef unsigned int __nlink_t; +__extension__ typedef long int __off_t; +__extension__ typedef __quad_t __off64_t; +__extension__ typedef int __pid_t; +__extension__ typedef struct { int __val[2]; } __fsid_t; +__extension__ typedef long int __clock_t; +__extension__ typedef unsigned long int __rlim_t; +__extension__ typedef __u_quad_t __rlim64_t; +__extension__ typedef unsigned int __id_t; +__extension__ typedef long int __time_t; +__extension__ typedef unsigned int __useconds_t; +__extension__ typedef long int __suseconds_t; + +__extension__ typedef int __daddr_t; +__extension__ typedef long int __swblk_t; +__extension__ typedef int __key_t; + + +__extension__ typedef int __clockid_t; + + +__extension__ typedef int __timer_t; + + +__extension__ typedef long int __blksize_t; + + + + +__extension__ typedef long int __blkcnt_t; +__extension__ typedef __quad_t __blkcnt64_t; + + +__extension__ typedef unsigned long int __fsblkcnt_t; +__extension__ typedef __u_quad_t __fsblkcnt64_t; + + +__extension__ typedef unsigned long int __fsfilcnt_t; +__extension__ typedef __u_quad_t __fsfilcnt64_t; + +__extension__ typedef int __ssize_t; + + + +typedef __off64_t __loff_t; +typedef __quad_t *__qaddr_t; +typedef char *__caddr_t; + + +__extension__ typedef int __intptr_t; + + +__extension__ typedef unsigned int __socklen_t; +# 32 "/usr/include/sys/types.h" 2 3 4 + + + +typedef __u_char u_char; +typedef __u_short u_short; +typedef __u_int u_int; +typedef __u_long u_long; +typedef __quad_t quad_t; +typedef __u_quad_t u_quad_t; +typedef __fsid_t fsid_t; + + + + +typedef __loff_t loff_t; + + + +typedef __ino_t ino_t; +# 62 "/usr/include/sys/types.h" 3 4 +typedef __dev_t dev_t; + + + + +typedef __gid_t gid_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __uid_t uid_t; + + + + + +typedef __off_t off_t; +# 100 "/usr/include/sys/types.h" 3 4 +typedef __pid_t pid_t; + + + + +typedef __id_t id_t; + + + + +typedef __ssize_t ssize_t; + + + + + +typedef __daddr_t daddr_t; +typedef __caddr_t caddr_t; + + + + + +typedef __key_t key_t; +# 133 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/include/time.h" 1 3 4 +# 74 "/usr/include/time.h" 3 4 + + +typedef __time_t time_t; + + + +# 92 "/usr/include/time.h" 3 4 +typedef __clockid_t clockid_t; +# 104 "/usr/include/time.h" 3 4 +typedef __timer_t timer_t; +# 134 "/usr/include/sys/types.h" 2 3 4 +# 147 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/lib/gcc/i486-linux-gnu/4.0.3/include/stddef.h" 1 3 4 +# 148 "/usr/include/sys/types.h" 2 3 4 + + + +typedef unsigned long int ulong; +typedef unsigned short int ushort; +typedef unsigned int uint; +# 191 "/usr/include/sys/types.h" 3 4 +typedef int int8_t __attribute__ ((__mode__ (__QI__))); +typedef int int16_t __attribute__ ((__mode__ (__HI__))); +typedef int int32_t __attribute__ ((__mode__ (__SI__))); +typedef int int64_t __attribute__ ((__mode__ (__DI__))); + + +typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__))); +typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__))); +typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__))); +typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__))); + +typedef int register_t __attribute__ ((__mode__ (__word__))); +# 213 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/include/endian.h" 1 3 4 +# 37 "/usr/include/endian.h" 3 4 +# 1 "/usr/include/bits/endian.h" 1 3 4 +# 38 "/usr/include/endian.h" 2 3 4 +# 214 "/usr/include/sys/types.h" 2 3 4 + + +# 1 "/usr/include/sys/select.h" 1 3 4 +# 31 "/usr/include/sys/select.h" 3 4 +# 1 "/usr/include/bits/select.h" 1 3 4 +# 32 "/usr/include/sys/select.h" 2 3 4 + + +# 1 "/usr/include/bits/sigset.h" 1 3 4 +# 23 "/usr/include/bits/sigset.h" 3 4 +typedef int __sig_atomic_t; + + + + +typedef struct + { + unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; + } __sigset_t; +# 35 "/usr/include/sys/select.h" 2 3 4 + + + +typedef __sigset_t sigset_t; + + + + + +# 1 "/usr/include/time.h" 1 3 4 +# 118 "/usr/include/time.h" 3 4 +struct timespec + { + __time_t tv_sec; + long int tv_nsec; + }; +# 45 "/usr/include/sys/select.h" 2 3 4 + +# 1 "/usr/include/bits/time.h" 1 3 4 +# 69 "/usr/include/bits/time.h" 3 4 +struct timeval + { + __time_t tv_sec; + __suseconds_t tv_usec; + }; +# 47 "/usr/include/sys/select.h" 2 3 4 + + +typedef __suseconds_t suseconds_t; + + + + + +typedef long int __fd_mask; +# 67 "/usr/include/sys/select.h" 3 4 +typedef struct + { + + + + + + + __fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask))]; + + + } fd_set; + + + + + + +typedef __fd_mask fd_mask; +# 99 "/usr/include/sys/select.h" 3 4 + +# 109 "/usr/include/sys/select.h" 3 4 +extern int select (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + struct timeval *__restrict __timeout); +# 128 "/usr/include/sys/select.h" 3 4 + +# 217 "/usr/include/sys/types.h" 2 3 4 + + +# 1 "/usr/include/sys/sysmacros.h" 1 3 4 +# 29 "/usr/include/sys/sysmacros.h" 3 4 +__extension__ +extern __inline unsigned int gnu_dev_major (unsigned long long int __dev) + __attribute__ ((__nothrow__)); +__extension__ +extern __inline unsigned int gnu_dev_minor (unsigned long long int __dev) + __attribute__ ((__nothrow__)); +__extension__ +extern __inline unsigned long long int gnu_dev_makedev (unsigned int __major, + unsigned int __minor) + __attribute__ ((__nothrow__)); + + +__extension__ extern __inline unsigned int +__attribute__ ((__nothrow__)) gnu_dev_major (unsigned long long int __dev) +{ + return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); +} + +__extension__ extern __inline unsigned int +__attribute__ ((__nothrow__)) gnu_dev_minor (unsigned long long int __dev) +{ + return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); +} + +__extension__ extern __inline unsigned long long int +__attribute__ ((__nothrow__)) gnu_dev_makedev (unsigned int __major, unsigned int __minor) +{ + return ((__minor & 0xff) | ((__major & 0xfff) << 8) + | (((unsigned long long int) (__minor & ~0xff)) << 12) + | (((unsigned long long int) (__major & ~0xfff)) << 32)); +} +# 220 "/usr/include/sys/types.h" 2 3 4 +# 231 "/usr/include/sys/types.h" 3 4 +typedef __blkcnt_t blkcnt_t; + + + +typedef __fsblkcnt_t fsblkcnt_t; + + + +typedef __fsfilcnt_t fsfilcnt_t; +# 266 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/include/bits/pthreadtypes.h" 1 3 4 +# 23 "/usr/include/bits/pthreadtypes.h" 3 4 +# 1 "/usr/include/bits/sched.h" 1 3 4 +# 83 "/usr/include/bits/sched.h" 3 4 +struct __sched_param + { + int __sched_priority; + }; +# 24 "/usr/include/bits/pthreadtypes.h" 2 3 4 + +typedef int __atomic_lock_t; + + +struct _pthread_fastlock +{ + long int __status; + __atomic_lock_t __spinlock; + +}; + + + +typedef struct _pthread_descr_struct *_pthread_descr; + + + + + +typedef struct __pthread_attr_s +{ + int __detachstate; + int __schedpolicy; + struct __sched_param __schedparam; + int __inheritsched; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void *__stackaddr; + size_t __stacksize; +} pthread_attr_t; + + + + + +__extension__ typedef long long __pthread_cond_align_t; + + + + +typedef struct +{ + struct _pthread_fastlock __c_lock; + _pthread_descr __c_waiting; + char __padding[48 - sizeof (struct _pthread_fastlock) + - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)]; + __pthread_cond_align_t __align; +} pthread_cond_t; + + + +typedef struct +{ + int __dummy; +} pthread_condattr_t; + + +typedef unsigned int pthread_key_t; + + + + + +typedef struct +{ + int __m_reserved; + int __m_count; + _pthread_descr __m_owner; + int __m_kind; + struct _pthread_fastlock __m_lock; +} pthread_mutex_t; + + + +typedef struct +{ + int __mutexkind; +} pthread_mutexattr_t; + + + +typedef int pthread_once_t; +# 152 "/usr/include/bits/pthreadtypes.h" 3 4 +typedef unsigned long int pthread_t; +# 267 "/usr/include/sys/types.h" 2 3 4 + + + +# 5 "/usr/include/directfb/dfb_types.h" 2 +# 1 "/usr/include/linux/types.h" 1 3 4 + + + + +# 1 "/usr/include/linux/posix_types.h" 1 3 4 + + + +# 1 "/usr/include/linux/stddef.h" 1 3 4 +# 5 "/usr/include/linux/posix_types.h" 2 3 4 +# 36 "/usr/include/linux/posix_types.h" 3 4 +typedef struct { + unsigned long fds_bits [(1024/(8 * sizeof(unsigned long)))]; +} __kernel_fd_set; + + +typedef void (*__kernel_sighandler_t)(int); + + +typedef int __kernel_key_t; +typedef int __kernel_mqd_t; + +# 1 "/usr/lib/gcc/i486-linux-gnu/4.0.3/include/asm/posix_types.h" 1 3 4 +# 14 "/usr/lib/gcc/i486-linux-gnu/4.0.3/include/asm/posix_types.h" 3 4 +# 1 "/usr/include/asm/posix_types.h" 1 3 4 +# 11 "/usr/include/asm/posix_types.h" 3 4 +# 1 "/usr/include/asm-i386/posix_types.h" 1 3 4 +# 10 "/usr/include/asm-i386/posix_types.h" 3 4 +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; + +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef unsigned short __kernel_old_dev_t; + + +typedef long long __kernel_loff_t; + + +typedef struct { + + + + int __val[2]; + +} __kernel_fsid_t; +# 12 "/usr/include/asm/posix_types.h" 2 3 4 +# 15 "/usr/lib/gcc/i486-linux-gnu/4.0.3/include/asm/posix_types.h" 2 3 4 +# 48 "/usr/include/linux/posix_types.h" 2 3 4 +# 6 "/usr/include/linux/types.h" 2 3 4 +# 1 "/usr/include/asm/types.h" 1 3 4 +# 11 "/usr/include/asm/types.h" 3 4 +# 1 "/usr/include/asm-i386/types.h" 1 3 4 + + + + + +typedef unsigned short umode_t; + + + + + + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + + +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +# 12 "/usr/include/asm/types.h" 2 3 4 +# 7 "/usr/include/linux/types.h" 2 3 4 +# 133 "/usr/include/linux/types.h" 3 4 +typedef __u16 __le16; +typedef __u16 __be16; +typedef __u32 __le32; +typedef __u32 __be32; + + + +typedef __u64 __le64; +typedef __u64 __be64; +# 6 "/usr/include/directfb/dfb_types.h" 2 +# 32 "/usr/include/directfb/directfb.h" 2 +# 1 "/usr/include/sys/time.h" 1 3 4 +# 26 "/usr/include/sys/time.h" 3 4 +# 1 "/usr/include/time.h" 1 3 4 +# 27 "/usr/include/sys/time.h" 2 3 4 + +# 1 "/usr/include/bits/time.h" 1 3 4 +# 29 "/usr/include/sys/time.h" 2 3 4 +# 38 "/usr/include/sys/time.h" 3 4 + +# 56 "/usr/include/sys/time.h" 3 4 +struct timezone + { + int tz_minuteswest; + int tz_dsttime; + }; + +typedef struct timezone *__restrict __timezone_ptr_t; +# 72 "/usr/include/sys/time.h" 3 4 +extern int gettimeofday (struct timeval *__restrict __tv, + __timezone_ptr_t __tz) __attribute__ ((__nothrow__)); + + + + +extern int settimeofday (__const struct timeval *__tv, + __const struct timezone *__tz) __attribute__ ((__nothrow__)); + + + + + +extern int adjtime (__const struct timeval *__delta, + struct timeval *__olddelta) __attribute__ ((__nothrow__)); + + + + +enum __itimer_which + { + + ITIMER_REAL = 0, + + + ITIMER_VIRTUAL = 1, + + + + ITIMER_PROF = 2 + + }; + + + +struct itimerval + { + + struct timeval it_interval; + + struct timeval it_value; + }; + + + + + + +typedef int __itimer_which_t; + + + + +extern int getitimer (__itimer_which_t __which, + struct itimerval *__value) __attribute__ ((__nothrow__)); + + + + +extern int setitimer (__itimer_which_t __which, + __const struct itimerval *__restrict __new, + struct itimerval *__restrict __old) __attribute__ ((__nothrow__)); + + + + +extern int utimes (__const char *__file, __const struct timeval __tvp[2]) + __attribute__ ((__nothrow__)); + + + +extern int lutimes (__const char *__file, __const struct timeval __tvp[2]) + __attribute__ ((__nothrow__)); + + +extern int futimes (int __fd, __const struct timeval __tvp[2]) __attribute__ ((__nothrow__)); +# 181 "/usr/include/sys/time.h" 3 4 + +# 33 "/usr/include/directfb/directfb.h" 2 + +# 1 "/usr/include/directfb/directfb_keyboard.h" 1 +# 40 "/usr/include/directfb/directfb_keyboard.h" +typedef enum { + DIKT_UNICODE = 0x0000, + + DIKT_SPECIAL = 0xF000, + DIKT_FUNCTION = 0xF100, + DIKT_MODIFIER = 0xF200, + DIKT_LOCK = 0xF300, + DIKT_DEAD = 0xF400, + DIKT_CUSTOM = 0xF500, + DIKT_IDENTIFIER = 0xF600 +} DFBInputDeviceKeyType; +# 71 "/usr/include/directfb/directfb_keyboard.h" +typedef enum { + DIMKI_SHIFT, + DIMKI_CONTROL, + DIMKI_ALT, + DIMKI_ALTGR, + DIMKI_META, + DIMKI_SUPER, + DIMKI_HYPER, + + DIMKI_FIRST = DIMKI_SHIFT, + DIMKI_LAST = DIMKI_HYPER +} DFBInputDeviceModifierKeyIdentifier; + + + + +typedef enum { + DIKI_UNKNOWN = ((DIKT_IDENTIFIER) | (0)), + + DIKI_A, + DIKI_B, + DIKI_C, + DIKI_D, + DIKI_E, + DIKI_F, + DIKI_G, + DIKI_H, + DIKI_I, + DIKI_J, + DIKI_K, + DIKI_L, + DIKI_M, + DIKI_N, + DIKI_O, + DIKI_P, + DIKI_Q, + DIKI_R, + DIKI_S, + DIKI_T, + DIKI_U, + DIKI_V, + DIKI_W, + DIKI_X, + DIKI_Y, + DIKI_Z, + + DIKI_0, + DIKI_1, + DIKI_2, + DIKI_3, + DIKI_4, + DIKI_5, + DIKI_6, + DIKI_7, + DIKI_8, + DIKI_9, + + DIKI_F1, + DIKI_F2, + DIKI_F3, + DIKI_F4, + DIKI_F5, + DIKI_F6, + DIKI_F7, + DIKI_F8, + DIKI_F9, + DIKI_F10, + DIKI_F11, + DIKI_F12, + + DIKI_SHIFT_L, + DIKI_SHIFT_R, + DIKI_CONTROL_L, + DIKI_CONTROL_R, + DIKI_ALT_L, + DIKI_ALT_R, + DIKI_ALTGR, + DIKI_META_L, + DIKI_META_R, + DIKI_SUPER_L, + DIKI_SUPER_R, + DIKI_HYPER_L, + DIKI_HYPER_R, + + DIKI_CAPS_LOCK, + DIKI_NUM_LOCK, + DIKI_SCROLL_LOCK, + + DIKI_ESCAPE, + DIKI_LEFT, + DIKI_RIGHT, + DIKI_UP, + DIKI_DOWN, + DIKI_TAB, + DIKI_ENTER, + DIKI_SPACE, + DIKI_BACKSPACE, + DIKI_INSERT, + DIKI_DELETE, + DIKI_HOME, + DIKI_END, + DIKI_PAGE_UP, + DIKI_PAGE_DOWN, + DIKI_PRINT, + DIKI_PAUSE, + + + + + + DIKI_QUOTE_LEFT, + DIKI_MINUS_SIGN, + DIKI_EQUALS_SIGN, + DIKI_BRACKET_LEFT, + DIKI_BRACKET_RIGHT, + DIKI_BACKSLASH, + DIKI_SEMICOLON, + DIKI_QUOTE_RIGHT, + DIKI_COMMA, + DIKI_PERIOD, + DIKI_SLASH, + + DIKI_LESS_SIGN, + + DIKI_KP_DIV, + DIKI_KP_MULT, + DIKI_KP_MINUS, + DIKI_KP_PLUS, + DIKI_KP_ENTER, + DIKI_KP_SPACE, + DIKI_KP_TAB, + DIKI_KP_F1, + DIKI_KP_F2, + DIKI_KP_F3, + DIKI_KP_F4, + DIKI_KP_EQUAL, + DIKI_KP_SEPARATOR, + + DIKI_KP_DECIMAL, + DIKI_KP_0, + DIKI_KP_1, + DIKI_KP_2, + DIKI_KP_3, + DIKI_KP_4, + DIKI_KP_5, + DIKI_KP_6, + DIKI_KP_7, + DIKI_KP_8, + DIKI_KP_9, + + DIKI_KEYDEF_END, + DIKI_NUMBER_OF_KEYS = DIKI_KEYDEF_END - ((DIKT_IDENTIFIER) | (0)) + +} DFBInputDeviceKeyIdentifier; + + + + +typedef enum { + + + + + + + DIKS_NULL = ((DIKT_UNICODE) | (0x00)), + DIKS_BACKSPACE = ((DIKT_UNICODE) | (0x08)), + DIKS_TAB = ((DIKT_UNICODE) | (0x09)), + DIKS_RETURN = ((DIKT_UNICODE) | (0x0D)), + DIKS_CANCEL = ((DIKT_UNICODE) | (0x18)), + DIKS_ESCAPE = ((DIKT_UNICODE) | (0x1B)), + DIKS_SPACE = ((DIKT_UNICODE) | (0x20)), + DIKS_EXCLAMATION_MARK = ((DIKT_UNICODE) | (0x21)), + DIKS_QUOTATION = ((DIKT_UNICODE) | (0x22)), + DIKS_NUMBER_SIGN = ((DIKT_UNICODE) | (0x23)), + DIKS_DOLLAR_SIGN = ((DIKT_UNICODE) | (0x24)), + DIKS_PERCENT_SIGN = ((DIKT_UNICODE) | (0x25)), + DIKS_AMPERSAND = ((DIKT_UNICODE) | (0x26)), + DIKS_APOSTROPHE = ((DIKT_UNICODE) | (0x27)), + DIKS_PARENTHESIS_LEFT = ((DIKT_UNICODE) | (0x28)), + DIKS_PARENTHESIS_RIGHT = ((DIKT_UNICODE) | (0x29)), + DIKS_ASTERISK = ((DIKT_UNICODE) | (0x2A)), + DIKS_PLUS_SIGN = ((DIKT_UNICODE) | (0x2B)), + DIKS_COMMA = ((DIKT_UNICODE) | (0x2C)), + DIKS_MINUS_SIGN = ((DIKT_UNICODE) | (0x2D)), + DIKS_PERIOD = ((DIKT_UNICODE) | (0x2E)), + DIKS_SLASH = ((DIKT_UNICODE) | (0x2F)), + DIKS_0 = ((DIKT_UNICODE) | (0x30)), + DIKS_1 = ((DIKT_UNICODE) | (0x31)), + DIKS_2 = ((DIKT_UNICODE) | (0x32)), + DIKS_3 = ((DIKT_UNICODE) | (0x33)), + DIKS_4 = ((DIKT_UNICODE) | (0x34)), + DIKS_5 = ((DIKT_UNICODE) | (0x35)), + DIKS_6 = ((DIKT_UNICODE) | (0x36)), + DIKS_7 = ((DIKT_UNICODE) | (0x37)), + DIKS_8 = ((DIKT_UNICODE) | (0x38)), + DIKS_9 = ((DIKT_UNICODE) | (0x39)), + DIKS_COLON = ((DIKT_UNICODE) | (0x3A)), + DIKS_SEMICOLON = ((DIKT_UNICODE) | (0x3B)), + DIKS_LESS_THAN_SIGN = ((DIKT_UNICODE) | (0x3C)), + DIKS_EQUALS_SIGN = ((DIKT_UNICODE) | (0x3D)), + DIKS_GREATER_THAN_SIGN = ((DIKT_UNICODE) | (0x3E)), + DIKS_QUESTION_MARK = ((DIKT_UNICODE) | (0x3F)), + DIKS_AT = ((DIKT_UNICODE) | (0x40)), + DIKS_CAPITAL_A = ((DIKT_UNICODE) | (0x41)), + DIKS_CAPITAL_B = ((DIKT_UNICODE) | (0x42)), + DIKS_CAPITAL_C = ((DIKT_UNICODE) | (0x43)), + DIKS_CAPITAL_D = ((DIKT_UNICODE) | (0x44)), + DIKS_CAPITAL_E = ((DIKT_UNICODE) | (0x45)), + DIKS_CAPITAL_F = ((DIKT_UNICODE) | (0x46)), + DIKS_CAPITAL_G = ((DIKT_UNICODE) | (0x47)), + DIKS_CAPITAL_H = ((DIKT_UNICODE) | (0x48)), + DIKS_CAPITAL_I = ((DIKT_UNICODE) | (0x49)), + DIKS_CAPITAL_J = ((DIKT_UNICODE) | (0x4A)), + DIKS_CAPITAL_K = ((DIKT_UNICODE) | (0x4B)), + DIKS_CAPITAL_L = ((DIKT_UNICODE) | (0x4C)), + DIKS_CAPITAL_M = ((DIKT_UNICODE) | (0x4D)), + DIKS_CAPITAL_N = ((DIKT_UNICODE) | (0x4E)), + DIKS_CAPITAL_O = ((DIKT_UNICODE) | (0x4F)), + DIKS_CAPITAL_P = ((DIKT_UNICODE) | (0x50)), + DIKS_CAPITAL_Q = ((DIKT_UNICODE) | (0x51)), + DIKS_CAPITAL_R = ((DIKT_UNICODE) | (0x52)), + DIKS_CAPITAL_S = ((DIKT_UNICODE) | (0x53)), + DIKS_CAPITAL_T = ((DIKT_UNICODE) | (0x54)), + DIKS_CAPITAL_U = ((DIKT_UNICODE) | (0x55)), + DIKS_CAPITAL_V = ((DIKT_UNICODE) | (0x56)), + DIKS_CAPITAL_W = ((DIKT_UNICODE) | (0x57)), + DIKS_CAPITAL_X = ((DIKT_UNICODE) | (0x58)), + DIKS_CAPITAL_Y = ((DIKT_UNICODE) | (0x59)), + DIKS_CAPITAL_Z = ((DIKT_UNICODE) | (0x5A)), + DIKS_SQUARE_BRACKET_LEFT = ((DIKT_UNICODE) | (0x5B)), + DIKS_BACKSLASH = ((DIKT_UNICODE) | (0x5C)), + DIKS_SQUARE_BRACKET_RIGHT = ((DIKT_UNICODE) | (0x5D)), + DIKS_CIRCUMFLEX_ACCENT = ((DIKT_UNICODE) | (0x5E)), + DIKS_UNDERSCORE = ((DIKT_UNICODE) | (0x5F)), + DIKS_GRAVE_ACCENT = ((DIKT_UNICODE) | (0x60)), + DIKS_SMALL_A = ((DIKT_UNICODE) | (0x61)), + DIKS_SMALL_B = ((DIKT_UNICODE) | (0x62)), + DIKS_SMALL_C = ((DIKT_UNICODE) | (0x63)), + DIKS_SMALL_D = ((DIKT_UNICODE) | (0x64)), + DIKS_SMALL_E = ((DIKT_UNICODE) | (0x65)), + DIKS_SMALL_F = ((DIKT_UNICODE) | (0x66)), + DIKS_SMALL_G = ((DIKT_UNICODE) | (0x67)), + DIKS_SMALL_H = ((DIKT_UNICODE) | (0x68)), + DIKS_SMALL_I = ((DIKT_UNICODE) | (0x69)), + DIKS_SMALL_J = ((DIKT_UNICODE) | (0x6A)), + DIKS_SMALL_K = ((DIKT_UNICODE) | (0x6B)), + DIKS_SMALL_L = ((DIKT_UNICODE) | (0x6C)), + DIKS_SMALL_M = ((DIKT_UNICODE) | (0x6D)), + DIKS_SMALL_N = ((DIKT_UNICODE) | (0x6E)), + DIKS_SMALL_O = ((DIKT_UNICODE) | (0x6F)), + DIKS_SMALL_P = ((DIKT_UNICODE) | (0x70)), + DIKS_SMALL_Q = ((DIKT_UNICODE) | (0x71)), + DIKS_SMALL_R = ((DIKT_UNICODE) | (0x72)), + DIKS_SMALL_S = ((DIKT_UNICODE) | (0x73)), + DIKS_SMALL_T = ((DIKT_UNICODE) | (0x74)), + DIKS_SMALL_U = ((DIKT_UNICODE) | (0x75)), + DIKS_SMALL_V = ((DIKT_UNICODE) | (0x76)), + DIKS_SMALL_W = ((DIKT_UNICODE) | (0x77)), + DIKS_SMALL_X = ((DIKT_UNICODE) | (0x78)), + DIKS_SMALL_Y = ((DIKT_UNICODE) | (0x79)), + DIKS_SMALL_Z = ((DIKT_UNICODE) | (0x7A)), + DIKS_CURLY_BRACKET_LEFT = ((DIKT_UNICODE) | (0x7B)), + DIKS_VERTICAL_BAR = ((DIKT_UNICODE) | (0x7C)), + DIKS_CURLY_BRACKET_RIGHT = ((DIKT_UNICODE) | (0x7D)), + DIKS_TILDE = ((DIKT_UNICODE) | (0x7E)), + DIKS_DELETE = ((DIKT_UNICODE) | (0x7F)), + + DIKS_ENTER = DIKS_RETURN, + + + + + DIKS_CURSOR_LEFT = ((DIKT_SPECIAL) | (0x00)), + DIKS_CURSOR_RIGHT = ((DIKT_SPECIAL) | (0x01)), + DIKS_CURSOR_UP = ((DIKT_SPECIAL) | (0x02)), + DIKS_CURSOR_DOWN = ((DIKT_SPECIAL) | (0x03)), + DIKS_INSERT = ((DIKT_SPECIAL) | (0x04)), + DIKS_HOME = ((DIKT_SPECIAL) | (0x05)), + DIKS_END = ((DIKT_SPECIAL) | (0x06)), + DIKS_PAGE_UP = ((DIKT_SPECIAL) | (0x07)), + DIKS_PAGE_DOWN = ((DIKT_SPECIAL) | (0x08)), + DIKS_PRINT = ((DIKT_SPECIAL) | (0x09)), + DIKS_PAUSE = ((DIKT_SPECIAL) | (0x0A)), + DIKS_OK = ((DIKT_SPECIAL) | (0x0B)), + DIKS_SELECT = ((DIKT_SPECIAL) | (0x0C)), + DIKS_GOTO = ((DIKT_SPECIAL) | (0x0D)), + DIKS_CLEAR = ((DIKT_SPECIAL) | (0x0E)), + DIKS_POWER = ((DIKT_SPECIAL) | (0x0F)), + DIKS_POWER2 = ((DIKT_SPECIAL) | (0x10)), + DIKS_OPTION = ((DIKT_SPECIAL) | (0x11)), + DIKS_MENU = ((DIKT_SPECIAL) | (0x12)), + DIKS_HELP = ((DIKT_SPECIAL) | (0x13)), + DIKS_INFO = ((DIKT_SPECIAL) | (0x14)), + DIKS_TIME = ((DIKT_SPECIAL) | (0x15)), + DIKS_VENDOR = ((DIKT_SPECIAL) | (0x16)), + + DIKS_ARCHIVE = ((DIKT_SPECIAL) | (0x17)), + DIKS_PROGRAM = ((DIKT_SPECIAL) | (0x18)), + DIKS_CHANNEL = ((DIKT_SPECIAL) | (0x19)), + DIKS_FAVORITES = ((DIKT_SPECIAL) | (0x1A)), + DIKS_EPG = ((DIKT_SPECIAL) | (0x1B)), + DIKS_PVR = ((DIKT_SPECIAL) | (0x1C)), + DIKS_MHP = ((DIKT_SPECIAL) | (0x1D)), + DIKS_LANGUAGE = ((DIKT_SPECIAL) | (0x1E)), + DIKS_TITLE = ((DIKT_SPECIAL) | (0x1F)), + DIKS_SUBTITLE = ((DIKT_SPECIAL) | (0x20)), + DIKS_ANGLE = ((DIKT_SPECIAL) | (0x21)), + DIKS_ZOOM = ((DIKT_SPECIAL) | (0x22)), + DIKS_MODE = ((DIKT_SPECIAL) | (0x23)), + DIKS_KEYBOARD = ((DIKT_SPECIAL) | (0x24)), + DIKS_PC = ((DIKT_SPECIAL) | (0x25)), + DIKS_SCREEN = ((DIKT_SPECIAL) | (0x26)), + + DIKS_TV = ((DIKT_SPECIAL) | (0x27)), + DIKS_TV2 = ((DIKT_SPECIAL) | (0x28)), + DIKS_VCR = ((DIKT_SPECIAL) | (0x29)), + DIKS_VCR2 = ((DIKT_SPECIAL) | (0x2A)), + DIKS_SAT = ((DIKT_SPECIAL) | (0x2B)), + DIKS_SAT2 = ((DIKT_SPECIAL) | (0x2C)), + DIKS_CD = ((DIKT_SPECIAL) | (0x2D)), + DIKS_TAPE = ((DIKT_SPECIAL) | (0x2E)), + DIKS_RADIO = ((DIKT_SPECIAL) | (0x2F)), + DIKS_TUNER = ((DIKT_SPECIAL) | (0x30)), + DIKS_PLAYER = ((DIKT_SPECIAL) | (0x31)), + DIKS_TEXT = ((DIKT_SPECIAL) | (0x32)), + DIKS_DVD = ((DIKT_SPECIAL) | (0x33)), + DIKS_AUX = ((DIKT_SPECIAL) | (0x34)), + DIKS_MP3 = ((DIKT_SPECIAL) | (0x35)), + DIKS_PHONE = ((DIKT_SPECIAL) | (0x36)), + DIKS_AUDIO = ((DIKT_SPECIAL) | (0x37)), + DIKS_VIDEO = ((DIKT_SPECIAL) | (0x38)), + + DIKS_INTERNET = ((DIKT_SPECIAL) | (0x39)), + DIKS_MAIL = ((DIKT_SPECIAL) | (0x3A)), + DIKS_NEWS = ((DIKT_SPECIAL) | (0x3B)), + DIKS_DIRECTORY = ((DIKT_SPECIAL) | (0x3C)), + DIKS_LIST = ((DIKT_SPECIAL) | (0x3D)), + DIKS_CALCULATOR = ((DIKT_SPECIAL) | (0x3E)), + DIKS_MEMO = ((DIKT_SPECIAL) | (0x3F)), + DIKS_CALENDAR = ((DIKT_SPECIAL) | (0x40)), + DIKS_EDITOR = ((DIKT_SPECIAL) | (0x41)), + + DIKS_RED = ((DIKT_SPECIAL) | (0x42)), + DIKS_GREEN = ((DIKT_SPECIAL) | (0x43)), + DIKS_YELLOW = ((DIKT_SPECIAL) | (0x44)), + DIKS_BLUE = ((DIKT_SPECIAL) | (0x45)), + + DIKS_CHANNEL_UP = ((DIKT_SPECIAL) | (0x46)), + DIKS_CHANNEL_DOWN = ((DIKT_SPECIAL) | (0x47)), + DIKS_BACK = ((DIKT_SPECIAL) | (0x48)), + DIKS_FORWARD = ((DIKT_SPECIAL) | (0x49)), + DIKS_FIRST = ((DIKT_SPECIAL) | (0x4A)), + DIKS_LAST = ((DIKT_SPECIAL) | (0x4B)), + DIKS_VOLUME_UP = ((DIKT_SPECIAL) | (0x4C)), + DIKS_VOLUME_DOWN = ((DIKT_SPECIAL) | (0x4D)), + DIKS_MUTE = ((DIKT_SPECIAL) | (0x4E)), + DIKS_AB = ((DIKT_SPECIAL) | (0x4F)), + DIKS_PLAYPAUSE = ((DIKT_SPECIAL) | (0x50)), + DIKS_PLAY = ((DIKT_SPECIAL) | (0x51)), + DIKS_STOP = ((DIKT_SPECIAL) | (0x52)), + DIKS_RESTART = ((DIKT_SPECIAL) | (0x53)), + DIKS_SLOW = ((DIKT_SPECIAL) | (0x54)), + DIKS_FAST = ((DIKT_SPECIAL) | (0x55)), + DIKS_RECORD = ((DIKT_SPECIAL) | (0x56)), + DIKS_EJECT = ((DIKT_SPECIAL) | (0x57)), + DIKS_SHUFFLE = ((DIKT_SPECIAL) | (0x58)), + DIKS_REWIND = ((DIKT_SPECIAL) | (0x59)), + DIKS_FASTFORWARD = ((DIKT_SPECIAL) | (0x5A)), + DIKS_PREVIOUS = ((DIKT_SPECIAL) | (0x5B)), + DIKS_NEXT = ((DIKT_SPECIAL) | (0x5C)), + DIKS_BEGIN = ((DIKT_SPECIAL) | (0x5D)), + + DIKS_DIGITS = ((DIKT_SPECIAL) | (0x5E)), + DIKS_TEEN = ((DIKT_SPECIAL) | (0x5F)), + DIKS_TWEN = ((DIKT_SPECIAL) | (0x60)), + + DIKS_BREAK = ((DIKT_SPECIAL) | (0x61)), + DIKS_EXIT = ((DIKT_SPECIAL) | (0x62)), + DIKS_SETUP = ((DIKT_SPECIAL) | (0x63)), + + DIKS_CURSOR_LEFT_UP = ((DIKT_SPECIAL) | (0x64)), + DIKS_CURSOR_LEFT_DOWN = ((DIKT_SPECIAL) | (0x65)), + DIKS_CURSOR_UP_RIGHT = ((DIKT_SPECIAL) | (0x66)), + DIKS_CURSOR_DOWN_RIGHT = ((DIKT_SPECIAL) | (0x67)), + + + + + + + DIKS_F1 = (((DIKT_FUNCTION) | (1))), + DIKS_F2 = (((DIKT_FUNCTION) | (2))), + DIKS_F3 = (((DIKT_FUNCTION) | (3))), + DIKS_F4 = (((DIKT_FUNCTION) | (4))), + DIKS_F5 = (((DIKT_FUNCTION) | (5))), + DIKS_F6 = (((DIKT_FUNCTION) | (6))), + DIKS_F7 = (((DIKT_FUNCTION) | (7))), + DIKS_F8 = (((DIKT_FUNCTION) | (8))), + DIKS_F9 = (((DIKT_FUNCTION) | (9))), + DIKS_F10 = (((DIKT_FUNCTION) | (10))), + DIKS_F11 = (((DIKT_FUNCTION) | (11))), + DIKS_F12 = (((DIKT_FUNCTION) | (12))), + + + + + DIKS_SHIFT = (((DIKT_MODIFIER) | ((1 << DIMKI_SHIFT)))), + DIKS_CONTROL = (((DIKT_MODIFIER) | ((1 << DIMKI_CONTROL)))), + DIKS_ALT = (((DIKT_MODIFIER) | ((1 << DIMKI_ALT)))), + DIKS_ALTGR = (((DIKT_MODIFIER) | ((1 << DIMKI_ALTGR)))), + DIKS_META = (((DIKT_MODIFIER) | ((1 << DIMKI_META)))), + DIKS_SUPER = (((DIKT_MODIFIER) | ((1 << DIMKI_SUPER)))), + DIKS_HYPER = (((DIKT_MODIFIER) | ((1 << DIMKI_HYPER)))), + + + + + DIKS_CAPS_LOCK = ((DIKT_LOCK) | (0x00)), + DIKS_NUM_LOCK = ((DIKT_LOCK) | (0x01)), + DIKS_SCROLL_LOCK = ((DIKT_LOCK) | (0x02)), + + + + + DIKS_DEAD_ABOVEDOT = ((DIKT_DEAD) | (0x00)), + DIKS_DEAD_ABOVERING = ((DIKT_DEAD) | (0x01)), + DIKS_DEAD_ACUTE = ((DIKT_DEAD) | (0x02)), + DIKS_DEAD_BREVE = ((DIKT_DEAD) | (0x03)), + DIKS_DEAD_CARON = ((DIKT_DEAD) | (0x04)), + DIKS_DEAD_CEDILLA = ((DIKT_DEAD) | (0x05)), + DIKS_DEAD_CIRCUMFLEX = ((DIKT_DEAD) | (0x06)), + DIKS_DEAD_DIAERESIS = ((DIKT_DEAD) | (0x07)), + DIKS_DEAD_DOUBLEACUTE = ((DIKT_DEAD) | (0x08)), + DIKS_DEAD_GRAVE = ((DIKT_DEAD) | (0x09)), + DIKS_DEAD_IOTA = ((DIKT_DEAD) | (0x0A)), + DIKS_DEAD_MACRON = ((DIKT_DEAD) | (0x0B)), + DIKS_DEAD_OGONEK = ((DIKT_DEAD) | (0x0C)), + DIKS_DEAD_SEMIVOICED_SOUND = ((DIKT_DEAD) | (0x0D)), + DIKS_DEAD_TILDE = ((DIKT_DEAD) | (0x0E)), + DIKS_DEAD_VOICED_SOUND = ((DIKT_DEAD) | (0x0F)), + + + + + + + DIKS_CUSTOM0 = (((DIKT_CUSTOM) | (0))), + DIKS_CUSTOM1 = (((DIKT_CUSTOM) | (1))), + DIKS_CUSTOM2 = (((DIKT_CUSTOM) | (2))), + DIKS_CUSTOM3 = (((DIKT_CUSTOM) | (3))), + DIKS_CUSTOM4 = (((DIKT_CUSTOM) | (4))), + DIKS_CUSTOM5 = (((DIKT_CUSTOM) | (5))), + DIKS_CUSTOM6 = (((DIKT_CUSTOM) | (6))), + DIKS_CUSTOM7 = (((DIKT_CUSTOM) | (7))), + DIKS_CUSTOM8 = (((DIKT_CUSTOM) | (8))), + DIKS_CUSTOM9 = (((DIKT_CUSTOM) | (9))) +} DFBInputDeviceKeySymbol; + + + + +typedef enum { + DILS_SCROLL = 0x00000001, + DILS_NUM = 0x00000002, + DILS_CAPS = 0x00000004 +} DFBInputDeviceLockState; + + + + +typedef enum { + DIKSI_BASE = 0x00, + + DIKSI_BASE_SHIFT = 0x01, + + DIKSI_ALT = 0x02, + + DIKSI_ALT_SHIFT = 0x03, + + + DIKSI_LAST = DIKSI_ALT_SHIFT +} DFBInputDeviceKeymapSymbolIndex; + + + + +typedef struct { + int code; + + DFBInputDeviceLockState locks; + + DFBInputDeviceKeyIdentifier identifier; + DFBInputDeviceKeySymbol symbols[DIKSI_LAST+1]; + +} DFBInputDeviceKeymapEntry; +# 35 "/usr/include/directfb/directfb.h" 2 +# 68 "/usr/include/directfb/directfb.h" +extern const unsigned int directfb_major_version; +extern const unsigned int directfb_minor_version; +extern const unsigned int directfb_micro_version; +extern const unsigned int directfb_binary_age; +extern const unsigned int directfb_interface_age; + + + + + +const char * DirectFBCheckVersion( unsigned int required_major, + unsigned int required_minor, + unsigned int required_micro ); + + + + + + +typedef struct _IDirectFB IDirectFB; + + + + + + +typedef struct _IDirectFBScreen IDirectFBScreen; + + + + + +typedef struct _IDirectFBDisplayLayer IDirectFBDisplayLayer; + + + + + +typedef struct _IDirectFBSurface IDirectFBSurface; + + + + +typedef struct _IDirectFBPalette IDirectFBPalette; + + + + + + +typedef struct _IDirectFBWindow IDirectFBWindow; + + + + +typedef struct _IDirectFBInputDevice IDirectFBInputDevice; + + + + +typedef struct _IDirectFBEventBuffer IDirectFBEventBuffer; + + + + +typedef struct _IDirectFBFont IDirectFBFont; + + + + +typedef struct _IDirectFBImageProvider IDirectFBImageProvider; + + + + +typedef struct _IDirectFBVideoProvider IDirectFBVideoProvider; + + + + +typedef struct _IDirectFBDataBuffer IDirectFBDataBuffer; + + + + +typedef struct _IDirectFBGL IDirectFBGL; + + + + + + + +typedef enum { + DFB_OK, + DFB_FAILURE, + DFB_INIT, + DFB_BUG, + DFB_DEAD, + DFB_UNSUPPORTED, + DFB_UNIMPLEMENTED, + DFB_ACCESSDENIED, + DFB_INVARG, + DFB_NOSYSTEMMEMORY, + DFB_NOVIDEOMEMORY, + DFB_LOCKED, + DFB_BUFFEREMPTY, + DFB_FILENOTFOUND, + DFB_IO, + DFB_BUSY, + DFB_NOIMPL, + DFB_MISSINGFONT, + DFB_TIMEOUT, + DFB_MISSINGIMAGE, + DFB_THIZNULL, + DFB_IDNOTFOUND, + DFB_INVAREA, + DFB_DESTROYED, + DFB_FUSION, + DFB_BUFFERTOOLARGE, + DFB_INTERRUPTED, + DFB_NOCONTEXT, + DFB_TEMPUNAVAIL, + DFB_LIMITEXCEEDED, + DFB_NOSUCHMETHOD, + DFB_NOSUCHINSTANCE, + DFB_ITEMNOTFOUND, + DFB_VERSIONMISMATCH, + DFB_NOSHAREDMEMORY +} DFBResult; + + + + +typedef enum { + DFB_FALSE = 0, + DFB_TRUE = !DFB_FALSE +} DFBBoolean; + + + + +typedef struct { + int x; + int y; +} DFBPoint; + + + + +typedef struct { + int x; + int w; +} DFBSpan; + + + + +typedef struct { + int w; + int h; +} DFBDimension; + + + + +typedef struct { + int x; + int y; + int w; + int h; +} DFBRectangle; + + + + + + +typedef struct { + float x; + float y; + float w; + float h; +} DFBLocation; + + + + + + +typedef struct { + int x1; + int y1; + int x2; + int y2; +} DFBRegion; + + + + + + +typedef struct { + int l; + int t; + int r; + int b; +} DFBInsets; + + + + +typedef struct { + int x1; + int y1; + int x2; + int y2; + int x3; + int y3; +} DFBTriangle; + + + + +typedef struct { + __u8 a; + __u8 r; + __u8 g; + __u8 b; +} DFBColor; +# 335 "/usr/include/directfb/directfb.h" +DFBResult DirectFBError( + const char *msg, + DFBResult result + ); + + + + +DFBResult DirectFBErrorFatal( + const char *msg, + DFBResult result + ); + + + + +const char *DirectFBErrorString( + DFBResult result + ); + + + + + + +const char *DirectFBUsageString( void ); + + + + + + +DFBResult DirectFBInit( + int *argc, + char **argv[] + ); + + + + + + +DFBResult DirectFBSetOption( + const char *name, + const char *value + ); + + + + +DFBResult DirectFBCreate( + IDirectFB **interface + + ); + + +typedef unsigned int DFBScreenID; +typedef unsigned int DFBDisplayLayerID; +typedef unsigned int DFBDisplayLayerSourceID; +typedef unsigned int DFBWindowID; +typedef unsigned int DFBInputDeviceID; + +typedef __u32 DFBDisplayLayerIDs; +# 428 "/usr/include/directfb/directfb.h" +typedef enum { + DFSCL_NORMAL = 0x00000000, + + + + + DFSCL_FULLSCREEN, + + + + DFSCL_EXCLUSIVE + + + + + + +} DFBCooperativeLevel; + + + + +typedef enum { + DLCAPS_NONE = 0x00000000, + + DLCAPS_SURFACE = 0x00000001, + + + + DLCAPS_OPACITY = 0x00000002, + + DLCAPS_ALPHACHANNEL = 0x00000004, + + DLCAPS_SCREEN_LOCATION = 0x00000008, + + + DLCAPS_FLICKER_FILTERING = 0x00000010, + + DLCAPS_DEINTERLACING = 0x00000020, + + + DLCAPS_SRC_COLORKEY = 0x00000040, + DLCAPS_DST_COLORKEY = 0x00000080, + + + DLCAPS_BRIGHTNESS = 0x00000100, + DLCAPS_CONTRAST = 0x00000200, + DLCAPS_HUE = 0x00000400, + DLCAPS_SATURATION = 0x00000800, + DLCAPS_LEVELS = 0x00001000, + + DLCAPS_FIELD_PARITY = 0x00002000, + DLCAPS_WINDOWS = 0x00004000, + DLCAPS_SOURCES = 0x00008000, + DLCAPS_ALPHA_RAMP = 0x00010000, + + + + + + DLCAPS_PREMULTIPLIED = 0x00020000, + + DLCAPS_SCREEN_POSITION = 0x00100000, + DLCAPS_SCREEN_SIZE = 0x00200000, + + DLCAPS_ALL = 0x0033FFFF +} DFBDisplayLayerCapabilities; + + + + +typedef enum { + DSCCAPS_NONE = 0x00000000, + + DSCCAPS_VSYNC = 0x00000001, + + DSCCAPS_POWER_MANAGEMENT = 0x00000002, + + DSCCAPS_MIXERS = 0x00000010, + DSCCAPS_ENCODERS = 0x00000020, + DSCCAPS_OUTPUTS = 0x00000040, + + DSCCAPS_ALL = 0x00000073 +} DFBScreenCapabilities; + + + + +typedef enum { + DLOP_NONE = 0x00000000, + DLOP_ALPHACHANNEL = 0x00000001, + + + DLOP_FLICKER_FILTERING = 0x00000002, + DLOP_DEINTERLACING = 0x00000004, + + DLOP_SRC_COLORKEY = 0x00000008, + DLOP_DST_COLORKEY = 0x00000010, + DLOP_OPACITY = 0x00000020, + + DLOP_FIELD_PARITY = 0x00000040 +} DFBDisplayLayerOptions; + + + + +typedef enum { + DLBM_UNKNOWN = 0x00000000, + + DLBM_FRONTONLY = 0x00000001, + DLBM_BACKVIDEO = 0x00000002, + DLBM_BACKSYSTEM = 0x00000004, + DLBM_TRIPLE = 0x00000008, + DLBM_WINDOWS = 0x00000010 + +} DFBDisplayLayerBufferMode; + + + + +typedef enum { + DSDESC_CAPS = 0x00000001, + DSDESC_WIDTH = 0x00000002, + DSDESC_HEIGHT = 0x00000004, + DSDESC_PIXELFORMAT = 0x00000008, + DSDESC_PREALLOCATED = 0x00000010, + + + + + + + DSDESC_PALETTE = 0x00000020 + + +} DFBSurfaceDescriptionFlags; + + + + +typedef enum { + DPDESC_CAPS = 0x00000001, + DPDESC_SIZE = 0x00000002, + DPDESC_ENTRIES = 0x00000004 + + +} DFBPaletteDescriptionFlags; + + + + +typedef enum { + DSCAPS_NONE = 0x00000000, + + DSCAPS_PRIMARY = 0x00000001, + DSCAPS_SYSTEMONLY = 0x00000002, + + DSCAPS_VIDEOONLY = 0x00000004, + + DSCAPS_DOUBLE = 0x00000010, + DSCAPS_SUBSURFACE = 0x00000020, + + DSCAPS_INTERLACED = 0x00000040, + + + + DSCAPS_SEPARATED = 0x00000080, + + + + DSCAPS_STATIC_ALLOC = 0x00000100, + + + + + + DSCAPS_TRIPLE = 0x00000200, + + DSCAPS_PREMULTIPLIED = 0x00001000, + + DSCAPS_DEPTH = 0x00010000, + + DSCAPS_ALL = 0x000113F7, + + + DSCAPS_FLIPPING = DSCAPS_DOUBLE | DSCAPS_TRIPLE + +} DFBSurfaceCapabilities; + + + + +typedef enum { + DPCAPS_NONE = 0x00000000 +} DFBPaletteCapabilities; + + + + +typedef enum { + DSDRAW_NOFX = 0x00000000, + DSDRAW_BLEND = 0x00000001, + DSDRAW_DST_COLORKEY = 0x00000002, + + DSDRAW_SRC_PREMULTIPLY = 0x00000004, + + DSDRAW_DST_PREMULTIPLY = 0x00000008, + DSDRAW_DEMULTIPLY = 0x00000010, + + DSDRAW_XOR = 0x00000020 + +} DFBSurfaceDrawingFlags; + + + + +typedef enum { + DSBLIT_NOFX = 0x00000000, + DSBLIT_BLEND_ALPHACHANNEL = 0x00000001, + + DSBLIT_BLEND_COLORALPHA = 0x00000002, + + DSBLIT_COLORIZE = 0x00000004, + + DSBLIT_SRC_COLORKEY = 0x00000008, + DSBLIT_DST_COLORKEY = 0x00000010, + + DSBLIT_SRC_PREMULTIPLY = 0x00000020, + + DSBLIT_DST_PREMULTIPLY = 0x00000040, + DSBLIT_DEMULTIPLY = 0x00000080, + + DSBLIT_DEINTERLACE = 0x00000100 + + +} DFBSurfaceBlittingFlags; + + + + +typedef enum { + DFXL_NONE = 0x00000000, + + DFXL_FILLRECTANGLE = 0x00000001, + DFXL_DRAWRECTANGLE = 0x00000002, + DFXL_DRAWLINE = 0x00000004, + DFXL_FILLTRIANGLE = 0x00000008, + + DFXL_BLIT = 0x00010000, + DFXL_STRETCHBLIT = 0x00020000, + DFXL_TEXTRIANGLES = 0x00040000, + + DFXL_DRAWSTRING = 0x01000000, + + DFXL_ALL = 0x0107000F +} DFBAccelerationMask; +# 699 "/usr/include/directfb/directfb.h" +typedef struct { + DFBAccelerationMask acceleration_mask; + DFBSurfaceDrawingFlags drawing_flags; + DFBSurfaceBlittingFlags blitting_flags; + unsigned int video_memory; +} DFBCardCapabilities; + + + + + +typedef enum { + DLTF_NONE = 0x00000000, + + DLTF_GRAPHICS = 0x00000001, + DLTF_VIDEO = 0x00000002, + DLTF_STILL_PICTURE = 0x00000004, + DLTF_BACKGROUND = 0x00000008, + + DLTF_ALL = 0x0000000F +} DFBDisplayLayerTypeFlags; + + + + + +typedef enum { + DIDTF_NONE = 0x00000000, + + DIDTF_KEYBOARD = 0x00000001, + DIDTF_MOUSE = 0x00000002, + DIDTF_JOYSTICK = 0x00000004, + DIDTF_REMOTE = 0x00000008, + DIDTF_VIRTUAL = 0x00000010, + + DIDTF_ALL = 0x0000001F +} DFBInputDeviceTypeFlags; + + + + +typedef enum { + DICAPS_KEYS = 0x00000001, + DICAPS_AXES = 0x00000002, + DICAPS_BUTTONS = 0x00000004, + + DICAPS_ALL = 0x00000007 +} DFBInputDeviceCapabilities; + + + + +typedef enum { + DIBI_LEFT = 0x00000000, + DIBI_RIGHT = 0x00000001, + DIBI_MIDDLE = 0x00000002, + + DIBI_FIRST = DIBI_LEFT, + + DIBI_LAST = 0x0000001F +} DFBInputDeviceButtonIdentifier; +# 768 "/usr/include/directfb/directfb.h" +typedef enum { + DIAI_X = 0x00000000, + DIAI_Y = 0x00000001, + DIAI_Z = 0x00000002, + + DIAI_FIRST = DIAI_X, + + DIAI_LAST = 0x0000001F +} DFBInputDeviceAxisIdentifier; + + + + +typedef enum { + DWDESC_CAPS = 0x00000001, + DWDESC_WIDTH = 0x00000002, + DWDESC_HEIGHT = 0x00000004, + DWDESC_PIXELFORMAT = 0x00000008, + DWDESC_POSX = 0x00000010, + DWDESC_POSY = 0x00000020, + DWDESC_SURFACE_CAPS = 0x00000040 + +} DFBWindowDescriptionFlags; + + + + +typedef enum { + DBDESC_FILE = 0x00000001, + + DBDESC_MEMORY = 0x00000002 + +} DFBDataBufferDescriptionFlags; + + + + +typedef enum { + DWCAPS_NONE = 0x00000000, + DWCAPS_ALPHACHANNEL = 0x00000001, + + DWCAPS_DOUBLEBUFFER = 0x00000002, + + + + + + + + DWCAPS_INPUTONLY = 0x00000004, + + + DWCAPS_NODECORATION = 0x00000008, + DWCAPS_ALL = 0x0000000F +} DFBWindowCapabilities; +# 834 "/usr/include/directfb/directfb.h" +typedef enum { + DFFA_NONE = 0x00000000, + DFFA_NOKERNING = 0x00000001, + DFFA_NOHINTING = 0x00000002, + DFFA_MONOCHROME = 0x00000004, + DFFA_NOCHARMAP = 0x00000008 + +} DFBFontAttributes; + + + + +typedef enum { + DFDESC_ATTRIBUTES = 0x00000001, + DFDESC_HEIGHT = 0x00000002, + DFDESC_WIDTH = 0x00000004, + DFDESC_INDEX = 0x00000008, + DFDESC_FIXEDADVANCE = 0x00000010 + + +} DFBFontDescriptionFlags; +# 869 "/usr/include/directfb/directfb.h" +typedef struct { + DFBFontDescriptionFlags flags; + + DFBFontAttributes attributes; + int height; + int width; + unsigned int index; + int fixed_advance; +} DFBFontDescription; +# 916 "/usr/include/directfb/directfb.h" +typedef enum { + DSPF_UNKNOWN = 0x00000000, + + + DSPF_ARGB1555 = ( (((0 ) & 0x7F) ) | (((15) & 0x1F) << 7) | (((1) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((2 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_RGB16 = ( (((1 ) & 0x7F) ) | (((16) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((2 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_RGB24 = ( (((2 ) & 0x7F) ) | (((24) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((3 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_RGB32 = ( (((3 ) & 0x7F) ) | (((24) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((4 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_ARGB = ( (((4 ) & 0x7F) ) | (((24) & 0x1F) << 7) | (((8) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((4 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_A8 = ( (((5 ) & 0x7F) ) | (((0) & 0x1F) << 7) | (((8) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_YUY2 = ( (((6 ) & 0x7F) ) | (((16) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((2 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_RGB332 = ( (((7 ) & 0x7F) ) | (((8) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_UYVY = ( (((8 ) & 0x7F) ) | (((16) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((2 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_I420 = ( (((9 ) & 0x7F) ) | (((12) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((2 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_YV12 = ( (((10 ) & 0x7F) ) | (((12) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((2 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_LUT8 = ( (((11 ) & 0x7F) ) | (((8) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((1 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_ALUT44 = ( (((12 ) & 0x7F) ) | (((4) & 0x1F) << 7) | (((4) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((1 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_AiRGB = ( (((13 ) & 0x7F) ) | (((24) & 0x1F) << 7) | (((8) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((4 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((1 ) ? 1 :0) << 31) ), + + + DSPF_A1 = ( (((14 ) & 0x7F) ) | (((0) & 0x1F) << 7) | (((1) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((1 ) & 0x07) << 17) | (((0 ) & 0x07) << 20) | (((7 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_NV12 = ( (((15 ) & 0x7F) ) | (((12) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((2 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_NV16 = ( (((16 ) & 0x7F) ) | (((24) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((2 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_ARGB2554 = ( (((17 ) & 0x7F) ) | (((14) & 0x1F) << 7) | (((2) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((2 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_ARGB4444 = ( (((18 ) & 0x7F) ) | (((12) & 0x1F) << 7) | (((4) & 0x0F) << 12) | (((1 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((2 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((0 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ), + + + DSPF_NV21 = ( (((19 ) & 0x7F) ) | (((12) & 0x1F) << 7) | (((0) & 0x0F) << 12) | (((0 ) ? 1 :0) << 16) | (((0 ) & 0x07) << 17) | (((1 ) & 0x07) << 20) | (((0 ) & 0x07) << 23) | (((2 ) & 0x03) << 26) | (((0 ) & 0x03) << 28) | (((0 ) ? 1 :0) << 30) | (((0 ) ? 1 :0) << 31) ) +} DFBSurfacePixelFormat; +# 1012 "/usr/include/directfb/directfb.h" +typedef struct { + DFBSurfaceDescriptionFlags flags; + + DFBSurfaceCapabilities caps; + int width; + int height; + DFBSurfacePixelFormat pixelformat; + + struct { + void *data; + int pitch; + } preallocated[2]; + + struct { + DFBColor *entries; + unsigned int size; + } palette; +} DFBSurfaceDescription; + + + + +typedef struct { + DFBPaletteDescriptionFlags flags; + + DFBPaletteCapabilities caps; + unsigned int size; + DFBColor *entries; + +} DFBPaletteDescription; + + + + + + + +typedef struct { + DFBDisplayLayerTypeFlags type; + + DFBDisplayLayerCapabilities caps; + + + char name[32]; + + int level; + int regions; + + + + int sources; +} DFBDisplayLayerDescription; + + + + + + + +typedef struct { + DFBDisplayLayerSourceID source_id; + + char name[24]; +} DFBDisplayLayerSourceDescription; + + + + + + + +typedef struct { + DFBScreenCapabilities caps; + + + char name[32]; + + int mixers; + + int encoders; + + int outputs; + +} DFBScreenDescription; +# 1104 "/usr/include/directfb/directfb.h" +typedef struct { + DFBInputDeviceTypeFlags type; + + DFBInputDeviceCapabilities caps; + + + + int min_keycode; + + + + + int max_keycode; + + + + + DFBInputDeviceAxisIdentifier max_axis; + + DFBInputDeviceButtonIdentifier max_button; + + + char name[32]; + + char vendor[40]; +} DFBInputDeviceDescription; + + + + +typedef struct { + DFBWindowDescriptionFlags flags; + + DFBWindowCapabilities caps; + int width; + int height; + DFBSurfacePixelFormat pixelformat; + int posx; + int posy; + DFBSurfaceCapabilities surface_caps; +} DFBWindowDescription; + + + + +typedef struct { + DFBDataBufferDescriptionFlags flags; + + const char *file; + + struct { + const void *data; + unsigned int length; + } memory; +} DFBDataBufferDescription; + + + + +typedef enum { + DFENUM_OK = 0x00000000, + DFENUM_CANCEL = 0x00000001 +} DFBEnumerationResult; + + + + +typedef DFBEnumerationResult (*DFBVideoModeCallback) ( + int width, + int height, + int bpp, + void *callbackdata +); + + + + + +typedef DFBEnumerationResult (*DFBScreenCallback) ( + DFBScreenID screen_id, + DFBScreenDescription desc, + void *callbackdata +); + + + + + +typedef DFBEnumerationResult (*DFBDisplayLayerCallback) ( + DFBDisplayLayerID layer_id, + DFBDisplayLayerDescription desc, + void *callbackdata +); + + + + + +typedef DFBEnumerationResult (*DFBInputDeviceCallback) ( + DFBInputDeviceID device_id, + DFBInputDeviceDescription desc, + void *callbackdata +); + + + + + + + +typedef int (*DFBGetDataCallback) ( + void *buffer, + unsigned int length, + void *callbackdata +); + + + + +typedef enum { + DVCAPS_BASIC = 0x00000000, + DVCAPS_SEEK = 0x00000001, + DVCAPS_SCALE = 0x00000002, + DVCAPS_INTERLACED = 0x00000004, + DVCAPS_BRIGHTNESS = 0x00000010, + DVCAPS_CONTRAST = 0x00000020, + DVCAPS_HUE = 0x00000040, + DVCAPS_SATURATION = 0x00000080 +} DFBVideoProviderCapabilities; + + + + +typedef enum { + DCAF_NONE = 0x00000000, + DCAF_BRIGHTNESS = 0x00000001, + DCAF_CONTRAST = 0x00000002, + DCAF_HUE = 0x00000004, + DCAF_SATURATION = 0x00000008 +} DFBColorAdjustmentFlags; + + + + + + + +typedef struct { + DFBColorAdjustmentFlags flags; + + __u16 brightness; + __u16 contrast; + __u16 hue; + __u16 saturation; +} DFBColorAdjustment; +# 1319 "/usr/include/directfb/directfb.h" +struct _IDirectFB { void *priv; int magic; DFBResult (*AddRef)( IDirectFB *thiz ); DFBResult (*Release)( IDirectFB *thiz ); DFBResult (*SetCooperativeLevel) ( IDirectFB *thiz, DFBCooperativeLevel level ); DFBResult (*SetVideoMode) ( IDirectFB *thiz, int width, int height, int bpp ); DFBResult (*GetCardCapabilities) ( IDirectFB *thiz, DFBCardCapabilities *ret_caps ); DFBResult (*EnumVideoModes) ( IDirectFB *thiz, DFBVideoModeCallback callback, void *callbackdata ); DFBResult (*CreateSurface) ( IDirectFB *thiz, const DFBSurfaceDescription *desc, IDirectFBSurface **ret_interface ); DFBResult (*CreatePalette) ( IDirectFB *thiz, const DFBPaletteDescription *desc, IDirectFBPalette **ret_interface ); DFBResult (*EnumScreens) ( IDirectFB *thiz, DFBScreenCallback callback, void *callbackdata ); DFBResult (*GetScreen) ( IDirectFB *thiz, DFBScreenID screen_id, IDirectFBScreen **ret_interface ); DFBResult (*EnumDisplayLayers) ( IDirectFB *thiz, DFBDisplayLayerCallback callback, void *callbackdata ); DFBResult (*GetDisplayLayer) ( IDirectFB *thiz, DFBDisplayLayerID layer_id, IDirectFBDisplayLayer **ret_interface ); DFBResult (*EnumInputDevices) ( IDirectFB *thiz, DFBInputDeviceCallback callback, void *callbackdata ); DFBResult (*GetInputDevice) ( IDirectFB *thiz, DFBInputDeviceID device_id, IDirectFBInputDevice **ret_interface ); DFBResult (*CreateEventBuffer) ( IDirectFB *thiz, IDirectFBEventBuffer **ret_buffer ); DFBResult (*CreateInputEventBuffer) ( IDirectFB *thiz, DFBInputDeviceCapabilities caps, DFBBoolean global, IDirectFBEventBuffer **ret_buffer ); DFBResult (*CreateImageProvider) ( IDirectFB *thiz, const char *filename, IDirectFBImageProvider **ret_interface ); DFBResult (*CreateVideoProvider) ( IDirectFB *thiz, const char *filename, IDirectFBVideoProvider **ret_interface ); DFBResult (*CreateFont) ( IDirectFB *thiz, const char *filename, const DFBFontDescription *desc, IDirectFBFont **ret_interface ); DFBResult (*CreateDataBuffer) ( IDirectFB *thiz, const DFBDataBufferDescription *desc, IDirectFBDataBuffer **ret_interface ); DFBResult (*SetClipboardData) ( IDirectFB *thiz, const char *mime_type, const void *data, unsigned int size, struct timeval *ret_timestamp ); DFBResult (*GetClipboardData) ( IDirectFB *thiz, char **ret_mimetype, void **ret_data, unsigned int *ret_size ); DFBResult (*GetClipboardTimeStamp) ( IDirectFB *thiz, struct timeval *ret_timestamp ); DFBResult (*Suspend) ( IDirectFB *thiz ); DFBResult (*Resume) ( IDirectFB *thiz ); DFBResult (*WaitIdle) ( IDirectFB *thiz ); DFBResult (*WaitForSync) ( IDirectFB *thiz ); DFBResult (*GetInterface) ( IDirectFB *thiz, const char *type, const char *implementation, void *arg, void **ret_interface ); }; +# 1681 "/usr/include/directfb/directfb.h" +typedef enum { + DLSCL_SHARED = 0, + DLSCL_EXCLUSIVE, + + DLSCL_ADMINISTRATIVE + +} DFBDisplayLayerCooperativeLevel; + + + + + +typedef enum { + DLBM_DONTCARE = 0, + + DLBM_COLOR, + + DLBM_IMAGE, + DLBM_TILE +} DFBDisplayLayerBackgroundMode; + + + + +typedef enum { + DLCONF_NONE = 0x00000000, + + DLCONF_WIDTH = 0x00000001, + DLCONF_HEIGHT = 0x00000002, + DLCONF_PIXELFORMAT = 0x00000004, + DLCONF_BUFFERMODE = 0x00000008, + DLCONF_OPTIONS = 0x00000010, + DLCONF_SOURCE = 0x00000020, + DLCONF_SURFACE_CAPS = 0x00000040, + + DLCONF_ALL = 0x0000007F +} DFBDisplayLayerConfigFlags; + + + + +typedef struct { + DFBDisplayLayerConfigFlags flags; + + int width; + int height; + DFBSurfacePixelFormat pixelformat; + DFBDisplayLayerBufferMode buffermode; + DFBDisplayLayerOptions options; + DFBDisplayLayerSourceID source; + + DFBSurfaceCapabilities surface_caps; + +} DFBDisplayLayerConfig; + + + + +typedef enum { + DSPM_ON = 0, + DSPM_STANDBY, + DSPM_SUSPEND, + DSPM_OFF +} DFBScreenPowerMode; + + + + + +typedef enum { + DSMCAPS_NONE = 0x00000000, + + DSMCAPS_FULL = 0x00000001, + DSMCAPS_SUB_LEVEL = 0x00000002, + + DSMCAPS_SUB_LAYERS = 0x00000004, + + DSMCAPS_BACKGROUND = 0x00000008 +} DFBScreenMixerCapabilities; + + + + + + + +typedef struct { + DFBScreenMixerCapabilities caps; + + DFBDisplayLayerIDs layers; + + + int sub_num; + + DFBDisplayLayerIDs sub_layers; + + + char name[24]; +} DFBScreenMixerDescription; + + + + +typedef enum { + DSMCONF_NONE = 0x00000000, + + DSMCONF_TREE = 0x00000001, + DSMCONF_LEVEL = 0x00000002, + DSMCONF_LAYERS = 0x00000004, + + DSMCONF_BACKGROUND = 0x00000010, + + DSMCONF_ALL = 0x00000017 +} DFBScreenMixerConfigFlags; + + + + +typedef enum { + DSMT_UNKNOWN = 0x00000000, + + DSMT_FULL = 0x00000001, + DSMT_SUB_LEVEL = 0x00000002, + DSMT_SUB_LAYERS = 0x00000003 +} DFBScreenMixerTree; + + + + +typedef struct { + DFBScreenMixerConfigFlags flags; + + DFBScreenMixerTree tree; + + int level; + DFBDisplayLayerIDs layers; + + DFBColor background; +} DFBScreenMixerConfig; + + + + + +typedef enum { + DSOCAPS_NONE = 0x00000000, + + DSOCAPS_CONNECTORS = 0x00000001, + + DSOCAPS_ENCODER_SEL = 0x00000010, + DSOCAPS_SIGNAL_SEL = 0x00000020, + DSOCAPS_CONNECTOR_SEL = 0x00000040, + + DSOCAPS_ALL = 0x00000071 +} DFBScreenOutputCapabilities; + + + + +typedef enum { + DSOC_UNKNOWN = 0x00000000, + + DSOC_VGA = 0x00000001, + DSOC_SCART = 0x00000002, + DSOC_YC = 0x00000004, + DSOC_CVBS = 0x00000008 +} DFBScreenOutputConnectors; + + + + +typedef enum { + DSOS_NONE = 0x00000000, + + DSOS_VGA = 0x00000001, + DSOS_YC = 0x00000002, + DSOS_CVBS = 0x00000004, + DSOS_RGB = 0x00000008, + DSOS_YCBCR = 0x00000010 +} DFBScreenOutputSignals; + + + + + + + +typedef struct { + DFBScreenOutputCapabilities caps; + + DFBScreenOutputConnectors all_connectors; + DFBScreenOutputSignals all_signals; + + char name[24]; +} DFBScreenOutputDescription; + + + + +typedef enum { + DSOCONF_NONE = 0x00000000, + + DSOCONF_ENCODER = 0x00000001, + DSOCONF_SIGNALS = 0x00000002, + DSOCONF_CONNECTORS = 0x00000004, + + DSOCONF_ALL = 0x00000007 +} DFBScreenOutputConfigFlags; + + + + +typedef struct { + DFBScreenOutputConfigFlags flags; + + int encoder; + DFBScreenOutputSignals out_signals; + DFBScreenOutputConnectors out_connectors; +} DFBScreenOutputConfig; + + + + + +typedef enum { + DSECAPS_NONE = 0x00000000, + + DSECAPS_TV_STANDARDS = 0x00000001, + DSECAPS_TEST_PICTURE = 0x00000002, + DSECAPS_MIXER_SEL = 0x00000004, + DSECAPS_OUT_SIGNALS = 0x00000008, + DSECAPS_SCANMODE = 0x00000010, + + DSECAPS_BRIGHTNESS = 0x00000100, + DSECAPS_CONTRAST = 0x00000200, + DSECAPS_HUE = 0x00000400, + DSECAPS_SATURATION = 0x00000800, + + DSECAPS_ALL = 0x00000f1f +} DFBScreenEncoderCapabilities; + + + + +typedef enum { + DSET_UNKNOWN = 0x00000000, + + DSET_CRTC = 0x00000001, + DSET_TV = 0x00000002 +} DFBScreenEncoderType; + + + + +typedef enum { + DSETV_UNKNOWN = 0x00000000, + + DSETV_PAL = 0x00000001, + DSETV_NTSC = 0x00000002, + DSETV_SECAM = 0x00000004 +} DFBScreenEncoderTVStandards; + + + + +typedef enum { + DSESM_UNKNOWN = 0x00000000, + + DSESM_INTERLACED = 0x00000001, + DSESM_PROGRESSIVE = 0x00000002 +} DFBScreenEncoderScanMode; + + + + + + + +typedef struct { + DFBScreenEncoderCapabilities caps; + DFBScreenEncoderType type; + + DFBScreenEncoderTVStandards tv_standards; + DFBScreenOutputSignals out_signals; + + char name[24]; +} DFBScreenEncoderDescription; + + + + +typedef enum { + DSECONF_NONE = 0x00000000, + + DSECONF_TV_STANDARD = 0x00000001, + DSECONF_TEST_PICTURE = 0x00000002, + DSECONF_MIXER = 0x00000004, + DSECONF_OUT_SIGNALS = 0x00000008, + DSECONF_SCANMODE = 0x00000010, + DSECONF_TEST_COLOR = 0x00000020, + DSECONF_ADJUSTMENT = 0x00000040, + + DSECONF_ALL = 0x0000007F +} DFBScreenEncoderConfigFlags; + + + + +typedef enum { + DSETP_OFF = 0x00000000, + + DSETP_MULTI = 0x00000001, + DSETP_SINGLE = 0x00000002, + + DSETP_WHITE = 0x00000010, + DSETP_YELLOW = 0x00000020, + DSETP_CYAN = 0x00000030, + DSETP_GREEN = 0x00000040, + DSETP_MAGENTA = 0x00000050, + DSETP_RED = 0x00000060, + DSETP_BLUE = 0x00000070, + DSETP_BLACK = 0x00000080 +} DFBScreenEncoderTestPicture; + + + + +typedef struct { + DFBScreenEncoderConfigFlags flags; + + DFBScreenEncoderTVStandards tv_standard; + DFBScreenEncoderTestPicture test_picture; + int mixer; + DFBScreenOutputSignals out_signals; + DFBScreenEncoderScanMode scanmode; + + DFBColor test_color; + + DFBColorAdjustment adjustment; +} DFBScreenEncoderConfig; +# 2030 "/usr/include/directfb/directfb.h" +struct _IDirectFBScreen { void *priv; int magic; DFBResult (*AddRef)( IDirectFBScreen *thiz ); DFBResult (*Release)( IDirectFBScreen *thiz ); DFBResult (*GetID) ( IDirectFBScreen *thiz, DFBScreenID *ret_screen_id ); DFBResult (*GetDescription) ( IDirectFBScreen *thiz, DFBScreenDescription *ret_desc ); DFBResult (*EnumDisplayLayers) ( IDirectFBScreen *thiz, DFBDisplayLayerCallback callback, void *callbackdata ); DFBResult (*SetPowerMode) ( IDirectFBScreen *thiz, DFBScreenPowerMode mode ); DFBResult (*WaitForSync) ( IDirectFBScreen *thiz ); DFBResult (*GetMixerDescriptions) ( IDirectFBScreen *thiz, DFBScreenMixerDescription *ret_descriptions ); DFBResult (*GetMixerConfiguration) ( IDirectFBScreen *thiz, int mixer, DFBScreenMixerConfig *ret_config ); DFBResult (*TestMixerConfiguration) ( IDirectFBScreen *thiz, int mixer, const DFBScreenMixerConfig *config, DFBScreenMixerConfigFlags *ret_failed ); DFBResult (*SetMixerConfiguration) ( IDirectFBScreen *thiz, int mixer, const DFBScreenMixerConfig *config ); DFBResult (*GetEncoderDescriptions) ( IDirectFBScreen *thiz, DFBScreenEncoderDescription *ret_descriptions ); DFBResult (*GetEncoderConfiguration) ( IDirectFBScreen *thiz, int encoder, DFBScreenEncoderConfig *ret_config ); DFBResult (*TestEncoderConfiguration) ( IDirectFBScreen *thiz, int encoder, const DFBScreenEncoderConfig *config, DFBScreenEncoderConfigFlags *ret_failed ); DFBResult (*SetEncoderConfiguration) ( IDirectFBScreen *thiz, int encoder, const DFBScreenEncoderConfig *config ); DFBResult (*GetOutputDescriptions) ( IDirectFBScreen *thiz, DFBScreenOutputDescription *ret_descriptions ); DFBResult (*GetOutputConfiguration) ( IDirectFBScreen *thiz, int output, DFBScreenOutputConfig *ret_config ); DFBResult (*TestOutputConfiguration) ( IDirectFBScreen *thiz, int output, const DFBScreenOutputConfig *config, DFBScreenOutputConfigFlags *ret_failed ); DFBResult (*SetOutputConfiguration) ( IDirectFBScreen *thiz, int output, const DFBScreenOutputConfig *config ); }; +# 2236 "/usr/include/directfb/directfb.h" +struct _IDirectFBDisplayLayer { void *priv; int magic; DFBResult (*AddRef)( IDirectFBDisplayLayer *thiz ); DFBResult (*Release)( IDirectFBDisplayLayer *thiz ); DFBResult (*GetID) ( IDirectFBDisplayLayer *thiz, DFBDisplayLayerID *ret_layer_id ); DFBResult (*GetDescription) ( IDirectFBDisplayLayer *thiz, DFBDisplayLayerDescription *ret_desc ); DFBResult (*GetSourceDescriptions) ( IDirectFBDisplayLayer *thiz, DFBDisplayLayerSourceDescription *ret_descriptions ); DFBResult (*GetCurrentOutputField) ( IDirectFBDisplayLayer *thiz, int *ret_field ); DFBResult (*GetSurface) ( IDirectFBDisplayLayer *thiz, IDirectFBSurface **ret_interface ); DFBResult (*GetScreen) ( IDirectFBDisplayLayer *thiz, IDirectFBScreen **ret_interface ); DFBResult (*SetCooperativeLevel) ( IDirectFBDisplayLayer *thiz, DFBDisplayLayerCooperativeLevel level ); DFBResult (*GetConfiguration) ( IDirectFBDisplayLayer *thiz, DFBDisplayLayerConfig *ret_config ); DFBResult (*TestConfiguration) ( IDirectFBDisplayLayer *thiz, const DFBDisplayLayerConfig *config, DFBDisplayLayerConfigFlags *ret_failed ); DFBResult (*SetConfiguration) ( IDirectFBDisplayLayer *thiz, const DFBDisplayLayerConfig *config ); DFBResult (*SetScreenLocation) ( IDirectFBDisplayLayer *thiz, float x, float y, float width, float height ); DFBResult (*SetScreenPosition) ( IDirectFBDisplayLayer *thiz, int x, int y ); DFBResult (*SetScreenRectangle) ( IDirectFBDisplayLayer *thiz, int x, int y, int width, int height ); DFBResult (*SetOpacity) ( IDirectFBDisplayLayer *thiz, __u8 opacity ); DFBResult (*SetSourceRectangle) ( IDirectFBDisplayLayer *thiz, int x, int y, int width, int height ); DFBResult (*SetFieldParity) ( IDirectFBDisplayLayer *thiz, int field ); DFBResult (*SetSrcColorKey) ( IDirectFBDisplayLayer *thiz, __u8 r, __u8 g, __u8 b ); DFBResult (*SetDstColorKey) ( IDirectFBDisplayLayer *thiz, __u8 r, __u8 g, __u8 b ); DFBResult (*GetLevel) ( IDirectFBDisplayLayer *thiz, int *ret_level ); DFBResult (*SetLevel) ( IDirectFBDisplayLayer *thiz, int level ); DFBResult (*SetBackgroundMode) ( IDirectFBDisplayLayer *thiz, DFBDisplayLayerBackgroundMode mode ); DFBResult (*SetBackgroundImage) ( IDirectFBDisplayLayer *thiz, IDirectFBSurface *surface ); DFBResult (*SetBackgroundColor) ( IDirectFBDisplayLayer *thiz, __u8 r, __u8 g, __u8 b, __u8 a ); DFBResult (*GetColorAdjustment) ( IDirectFBDisplayLayer *thiz, DFBColorAdjustment *ret_adj ); DFBResult (*SetColorAdjustment) ( IDirectFBDisplayLayer *thiz, const DFBColorAdjustment *adj ); DFBResult (*CreateWindow) ( IDirectFBDisplayLayer *thiz, const DFBWindowDescription *desc, IDirectFBWindow **ret_interface ); DFBResult (*GetWindow) ( IDirectFBDisplayLayer *thiz, DFBWindowID window_id, IDirectFBWindow **ret_interface ); DFBResult (*EnableCursor) ( IDirectFBDisplayLayer *thiz, int enable ); DFBResult (*GetCursorPosition) ( IDirectFBDisplayLayer *thiz, int *ret_x, int *ret_y ); DFBResult (*WarpCursor) ( IDirectFBDisplayLayer *thiz, int x, int y ); DFBResult (*SetCursorAcceleration) ( IDirectFBDisplayLayer *thiz, int numerator, int denominator, int threshold ); DFBResult (*SetCursorShape) ( IDirectFBDisplayLayer *thiz, IDirectFBSurface *shape, int hot_x, int hot_y ); DFBResult (*SetCursorOpacity) ( IDirectFBDisplayLayer *thiz, __u8 opacity ); DFBResult (*WaitForSync) ( IDirectFBDisplayLayer *thiz ); }; +# 2649 "/usr/include/directfb/directfb.h" +typedef enum { + DSFLIP_NONE = 0x00000000, + + DSFLIP_WAIT = 0x00000001, + + DSFLIP_BLIT = 0x00000002, + + + + DSFLIP_ONSYNC = 0x00000004, + + + + DSFLIP_PIPELINE = 0x00000008, + + DSFLIP_WAITFORSYNC = DSFLIP_WAIT | DSFLIP_ONSYNC +} DFBSurfaceFlipFlags; + + + + +typedef enum { + DSTF_LEFT = 0x00000000, + DSTF_CENTER = 0x00000001, + DSTF_RIGHT = 0x00000002, + + DSTF_TOP = 0x00000004, + + DSTF_BOTTOM = 0x00000008, + + + DSTF_TOPLEFT = DSTF_TOP | DSTF_LEFT, + DSTF_TOPCENTER = DSTF_TOP | DSTF_CENTER, + DSTF_TOPRIGHT = DSTF_TOP | DSTF_RIGHT, + + DSTF_BOTTOMLEFT = DSTF_BOTTOM | DSTF_LEFT, + DSTF_BOTTOMCENTER = DSTF_BOTTOM | DSTF_CENTER, + DSTF_BOTTOMRIGHT = DSTF_BOTTOM | DSTF_RIGHT +} DFBSurfaceTextFlags; + + + + + +typedef enum { + DSLF_READ = 0x00000001, + + DSLF_WRITE = 0x00000002 +} DFBSurfaceLockFlags; + + + + +typedef enum { + + + + DSPD_NONE = 0, + DSPD_CLEAR = 1, + DSPD_SRC = 2, + DSPD_SRC_OVER = 3, + DSPD_DST_OVER = 4, + DSPD_SRC_IN = 5, + DSPD_DST_IN = 6, + DSPD_SRC_OUT = 7, + DSPD_DST_OUT = 8 +} DFBSurfacePorterDuffRule; + + + + +typedef enum { + DSBF_ZERO = 1, + DSBF_ONE = 2, + DSBF_SRCCOLOR = 3, + DSBF_INVSRCCOLOR = 4, + DSBF_SRCALPHA = 5, + DSBF_INVSRCALPHA = 6, + DSBF_DESTALPHA = 7, + DSBF_INVDESTALPHA = 8, + DSBF_DESTCOLOR = 9, + DSBF_INVDESTCOLOR = 10, + DSBF_SRCALPHASAT = 11 +} DFBSurfaceBlendFunction; + + + + +typedef struct { + float x; + float y; + float z; + float w; + + float s; + float t; +} DFBVertex; + + + + +typedef enum { + DTTF_LIST, + DTTF_STRIP, + DTTF_FAN +} DFBTriangleFormation; +# 2763 "/usr/include/directfb/directfb.h" +struct _IDirectFBSurface { void *priv; int magic; DFBResult (*AddRef)( IDirectFBSurface *thiz ); DFBResult (*Release)( IDirectFBSurface *thiz ); DFBResult (*GetCapabilities) ( IDirectFBSurface *thiz, DFBSurfaceCapabilities *ret_caps ); DFBResult (*GetSize) ( IDirectFBSurface *thiz, int *ret_width, int *ret_height ); DFBResult (*GetVisibleRectangle) ( IDirectFBSurface *thiz, DFBRectangle *ret_rect ); DFBResult (*GetPixelFormat) ( IDirectFBSurface *thiz, DFBSurfacePixelFormat *ret_format ); DFBResult (*GetAccelerationMask) ( IDirectFBSurface *thiz, IDirectFBSurface *source, DFBAccelerationMask *ret_mask ); DFBResult (*GetPalette) ( IDirectFBSurface *thiz, IDirectFBPalette **ret_interface ); DFBResult (*SetPalette) ( IDirectFBSurface *thiz, IDirectFBPalette *palette ); DFBResult (*SetAlphaRamp) ( IDirectFBSurface *thiz, __u8 a0, __u8 a1, __u8 a2, __u8 a3 ); DFBResult (*Lock) ( IDirectFBSurface *thiz, DFBSurfaceLockFlags flags, void **ret_ptr, int *ret_pitch ); DFBResult (*Unlock) ( IDirectFBSurface *thiz ); DFBResult (*Flip) ( IDirectFBSurface *thiz, const DFBRegion *region, DFBSurfaceFlipFlags flags ); DFBResult (*SetField) ( IDirectFBSurface *thiz, int field ); DFBResult (*Clear) ( IDirectFBSurface *thiz, __u8 r, __u8 g, __u8 b, __u8 a ); DFBResult (*SetClip) ( IDirectFBSurface *thiz, const DFBRegion *clip ); DFBResult (*SetColor) ( IDirectFBSurface *thiz, __u8 r, __u8 g, __u8 b, __u8 a ); DFBResult (*SetColorIndex) ( IDirectFBSurface *thiz, unsigned int index ); DFBResult (*SetSrcBlendFunction) ( IDirectFBSurface *thiz, DFBSurfaceBlendFunction function ); DFBResult (*SetDstBlendFunction) ( IDirectFBSurface *thiz, DFBSurfaceBlendFunction function ); DFBResult (*SetPorterDuff) ( IDirectFBSurface *thiz, DFBSurfacePorterDuffRule rule ); DFBResult (*SetSrcColorKey) ( IDirectFBSurface *thiz, __u8 r, __u8 g, __u8 b ); DFBResult (*SetSrcColorKeyIndex) ( IDirectFBSurface *thiz, unsigned int index ); DFBResult (*SetDstColorKey) ( IDirectFBSurface *thiz, __u8 r, __u8 g, __u8 b ); DFBResult (*SetDstColorKeyIndex) ( IDirectFBSurface *thiz, unsigned int index ); DFBResult (*SetBlittingFlags) ( IDirectFBSurface *thiz, DFBSurfaceBlittingFlags flags ); DFBResult (*Blit) ( IDirectFBSurface *thiz, IDirectFBSurface *source, const DFBRectangle *source_rect, int x, int y ); DFBResult (*TileBlit) ( IDirectFBSurface *thiz, IDirectFBSurface *source, const DFBRectangle *source_rect, int x, int y ); DFBResult (*BatchBlit) ( IDirectFBSurface *thiz, IDirectFBSurface *source, const DFBRectangle *source_rects, const DFBPoint *dest_points, int num ); DFBResult (*StretchBlit) ( IDirectFBSurface *thiz, IDirectFBSurface *source, const DFBRectangle *source_rect, const DFBRectangle *destination_rect ); DFBResult (*TextureTriangles) ( IDirectFBSurface *thiz, IDirectFBSurface *texture, const DFBVertex *vertices, const int *indices, int num, DFBTriangleFormation formation ); DFBResult (*SetDrawingFlags) ( IDirectFBSurface *thiz, DFBSurfaceDrawingFlags flags ); DFBResult (*FillRectangle) ( IDirectFBSurface *thiz, int x, int y, int w, int h ); DFBResult (*DrawRectangle) ( IDirectFBSurface *thiz, int x, int y, int w, int h ); DFBResult (*DrawLine) ( IDirectFBSurface *thiz, int x1, int y1, int x2, int y2 ); DFBResult (*DrawLines) ( IDirectFBSurface *thiz, const DFBRegion *lines, unsigned int num_lines ); DFBResult (*FillTriangle) ( IDirectFBSurface *thiz, int x1, int y1, int x2, int y2, int x3, int y3 ); DFBResult (*FillRectangles) ( IDirectFBSurface *thiz, const DFBRectangle *rects, unsigned int num ); DFBResult (*FillSpans) ( IDirectFBSurface *thiz, int y, const DFBSpan *spans, unsigned int num ); DFBResult (*SetFont) ( IDirectFBSurface *thiz, IDirectFBFont *font ); DFBResult (*GetFont) ( IDirectFBSurface *thiz, IDirectFBFont **ret_font ); DFBResult (*DrawString) ( IDirectFBSurface *thiz, const char *text, int bytes, int x, int y, DFBSurfaceTextFlags flags ); DFBResult (*DrawGlyph) ( IDirectFBSurface *thiz, unsigned int index, int x, int y, DFBSurfaceTextFlags flags ); DFBResult (*GetSubSurface) ( IDirectFBSurface *thiz, const DFBRectangle *rect, IDirectFBSurface **ret_interface ); DFBResult (*GetGL) ( IDirectFBSurface *thiz, IDirectFBGL **ret_interface ); DFBResult (*Dump) ( IDirectFBSurface *thiz, const char *directory, const char *prefix ); }; +# 3354 "/usr/include/directfb/directfb.h" +struct _IDirectFBPalette { void *priv; int magic; DFBResult (*AddRef)( IDirectFBPalette *thiz ); DFBResult (*Release)( IDirectFBPalette *thiz ); DFBResult (*GetCapabilities) ( IDirectFBPalette *thiz, DFBPaletteCapabilities *ret_caps ); DFBResult (*GetSize) ( IDirectFBPalette *thiz, unsigned int *ret_size ); DFBResult (*SetEntries) ( IDirectFBPalette *thiz, const DFBColor *entries, unsigned int num_entries, unsigned int offset ); DFBResult (*GetEntries) ( IDirectFBPalette *thiz, DFBColor *ret_entries, unsigned int num_entries, unsigned int offset ); DFBResult (*FindBestMatch) ( IDirectFBPalette *thiz, __u8 r, __u8 g, __u8 b, __u8 a, unsigned int *ret_index ); DFBResult (*CreateCopy) ( IDirectFBPalette *thiz, IDirectFBPalette **ret_interface ); }; +# 3433 "/usr/include/directfb/directfb.h" +typedef enum { + DIKS_UP = 0x00000000, + DIKS_DOWN = 0x00000001 +} DFBInputDeviceKeyState; + + + + +typedef enum { + DIBS_UP = 0x00000000, + DIBS_DOWN = 0x00000001 +} DFBInputDeviceButtonState; + + + + +typedef enum { + DIBM_LEFT = 0x00000001, + DIBM_RIGHT = 0x00000002, + DIBM_MIDDLE = 0x00000004 +} DFBInputDeviceButtonMask; + + + + +typedef enum { + DIMM_SHIFT = (1 << DIMKI_SHIFT), + DIMM_CONTROL = (1 << DIMKI_CONTROL), + DIMM_ALT = (1 << DIMKI_ALT), + DIMM_ALTGR = (1 << DIMKI_ALTGR), + DIMM_META = (1 << DIMKI_META), + DIMM_SUPER = (1 << DIMKI_SUPER), + DIMM_HYPER = (1 << DIMKI_HYPER) +} DFBInputDeviceModifierMask; +# 3476 "/usr/include/directfb/directfb.h" +struct _IDirectFBInputDevice { void *priv; int magic; DFBResult (*AddRef)( IDirectFBInputDevice *thiz ); DFBResult (*Release)( IDirectFBInputDevice *thiz ); DFBResult (*GetID) ( IDirectFBInputDevice *thiz, DFBInputDeviceID *ret_device_id ); DFBResult (*GetDescription) ( IDirectFBInputDevice *thiz, DFBInputDeviceDescription *ret_desc ); DFBResult (*GetKeymapEntry) ( IDirectFBInputDevice *thiz, int keycode, DFBInputDeviceKeymapEntry *ret_entry ); DFBResult (*CreateEventBuffer) ( IDirectFBInputDevice *thiz, IDirectFBEventBuffer **ret_buffer ); DFBResult (*AttachEventBuffer) ( IDirectFBInputDevice *thiz, IDirectFBEventBuffer *buffer ); DFBResult (*GetKeyState) ( IDirectFBInputDevice *thiz, DFBInputDeviceKeyIdentifier key_id, DFBInputDeviceKeyState *ret_state ); DFBResult (*GetModifiers) ( IDirectFBInputDevice *thiz, DFBInputDeviceModifierMask *ret_modifiers ); DFBResult (*GetLockState) ( IDirectFBInputDevice *thiz, DFBInputDeviceLockState *ret_locks ); DFBResult (*GetButtons) ( IDirectFBInputDevice *thiz, DFBInputDeviceButtonMask *ret_buttons ); DFBResult (*GetButtonState) ( IDirectFBInputDevice *thiz, DFBInputDeviceButtonIdentifier button, DFBInputDeviceButtonState *ret_state ); DFBResult (*GetAxis) ( IDirectFBInputDevice *thiz, DFBInputDeviceAxisIdentifier axis, int *ret_pos ); DFBResult (*GetXY) ( IDirectFBInputDevice *thiz, int *ret_x, int *ret_y ); }; +# 3605 "/usr/include/directfb/directfb.h" +typedef enum { + DFEC_NONE = 0x00, + DFEC_INPUT = 0x01, + DFEC_WINDOW = 0x02, + DFEC_USER = 0x03 + +} DFBEventClass; + + + + +typedef enum { + DIET_UNKNOWN = 0, + DIET_KEYPRESS, + DIET_KEYRELEASE, + DIET_BUTTONPRESS, + DIET_BUTTONRELEASE, + DIET_AXISMOTION +} DFBInputEventType; + + + + +typedef enum { + DIEF_NONE = 0x000, + DIEF_TIMESTAMP = 0x001, + DIEF_AXISABS = 0x002, + DIEF_AXISREL = 0x004, + + DIEF_KEYCODE = 0x008, + + DIEF_KEYID = 0x010, + + DIEF_KEYSYMBOL = 0x020, + + DIEF_MODIFIERS = 0x040, + + DIEF_LOCKS = 0x080, + + DIEF_BUTTONS = 0x100, + + DIEF_GLOBAL = 0x200 + + + + + +} DFBInputEventFlags; + + + + +typedef struct { + DFBEventClass clazz; + + DFBInputEventType type; + DFBInputDeviceID device_id; + DFBInputEventFlags flags; + + + + struct timeval timestamp; + + + int key_code; + + + + DFBInputDeviceKeyIdentifier key_id; + + DFBInputDeviceKeySymbol key_symbol; + + + + DFBInputDeviceModifierMask modifiers; + + DFBInputDeviceLockState locks; + + + + DFBInputDeviceButtonIdentifier button; + + DFBInputDeviceButtonMask buttons; + + + + DFBInputDeviceAxisIdentifier axis; + + + int axisabs; + + int axisrel; + +} DFBInputEvent; + + + + +typedef enum { + DWET_NONE = 0x00000000, + + DWET_POSITION = 0x00000001, + + + DWET_SIZE = 0x00000002, + + + DWET_CLOSE = 0x00000004, + + DWET_DESTROYED = 0x00000008, + + + DWET_GOTFOCUS = 0x00000010, + DWET_LOSTFOCUS = 0x00000020, + + DWET_KEYDOWN = 0x00000100, + + DWET_KEYUP = 0x00000200, + + + DWET_BUTTONDOWN = 0x00010000, + + DWET_BUTTONUP = 0x00020000, + + DWET_MOTION = 0x00040000, + + DWET_ENTER = 0x00080000, + + DWET_LEAVE = 0x00100000, + + DWET_WHEEL = 0x00200000, + + + DWET_POSITION_SIZE = DWET_POSITION | DWET_SIZE, + + + + DWET_ALL = 0x003F033F +} DFBWindowEventType; + + + + +typedef struct { + DFBEventClass clazz; + + DFBWindowEventType type; + DFBWindowID window_id; + + + + int x; + + + int y; + + + + + + int cx; + int cy; + + + int step; + + + int w; + int h; + + + int key_code; + + + + DFBInputDeviceKeyIdentifier key_id; + + DFBInputDeviceKeySymbol key_symbol; + + + DFBInputDeviceModifierMask modifiers; + DFBInputDeviceLockState locks; + + + DFBInputDeviceButtonIdentifier button; + + + DFBInputDeviceButtonMask buttons; + + + struct timeval timestamp; +} DFBWindowEvent; + + + + +typedef struct { + DFBEventClass clazz; + + unsigned int type; + void *data; +} DFBUserEvent; + + + + +typedef union { + DFBEventClass clazz; + DFBInputEvent input; + DFBWindowEvent window; + DFBUserEvent user; +} DFBEvent; +# 3827 "/usr/include/directfb/directfb.h" +struct _IDirectFBEventBuffer { void *priv; int magic; DFBResult (*AddRef)( IDirectFBEventBuffer *thiz ); DFBResult (*Release)( IDirectFBEventBuffer *thiz ); DFBResult (*Reset) ( IDirectFBEventBuffer *thiz ); DFBResult (*WaitForEvent) ( IDirectFBEventBuffer *thiz ); DFBResult (*WaitForEventWithTimeout) ( IDirectFBEventBuffer *thiz, unsigned int seconds, unsigned int milli_seconds ); DFBResult (*GetEvent) ( IDirectFBEventBuffer *thiz, DFBEvent *ret_event ); DFBResult (*PeekEvent) ( IDirectFBEventBuffer *thiz, DFBEvent *ret_event ); DFBResult (*HasEvent) ( IDirectFBEventBuffer *thiz ); DFBResult (*PostEvent) ( IDirectFBEventBuffer *thiz, const DFBEvent *event ); DFBResult (*WakeUp) ( IDirectFBEventBuffer *thiz ); DFBResult (*CreateFileDescriptor) ( IDirectFBEventBuffer *thiz, int *ret_fd ); }; +# 3939 "/usr/include/directfb/directfb.h" +typedef enum { + DWOP_NONE = 0x00000000, + DWOP_COLORKEYING = 0x00000001, + DWOP_ALPHACHANNEL = 0x00000002, + + DWOP_OPAQUE_REGION = 0x00000004, + + DWOP_SHAPED = 0x00000008, + + + DWOP_KEEP_POSITION = 0x00000010, + + DWOP_KEEP_SIZE = 0x00000020, + + DWOP_KEEP_STACKING = 0x00000040, + + DWOP_GHOST = 0x00001000, + + + DWOP_INDESTRUCTIBLE = 0x00002000, + + DWOP_ALL = 0x0000307F +} DFBWindowOptions; + + + + +typedef enum { + DWSC_MIDDLE = 0x00000000, + + DWSC_UPPER = 0x00000001, + + + + + DWSC_LOWER = 0x00000002 + + + + +} DFBWindowStackingClass; +# 3988 "/usr/include/directfb/directfb.h" +struct _IDirectFBWindow { void *priv; int magic; DFBResult (*AddRef)( IDirectFBWindow *thiz ); DFBResult (*Release)( IDirectFBWindow *thiz ); DFBResult (*GetID) ( IDirectFBWindow *thiz, DFBWindowID *ret_window_id ); DFBResult (*GetPosition) ( IDirectFBWindow *thiz, int *ret_x, int *ret_y ); DFBResult (*GetSize) ( IDirectFBWindow *thiz, int *ret_width, int *ret_height ); DFBResult (*CreateEventBuffer) ( IDirectFBWindow *thiz, IDirectFBEventBuffer **ret_buffer ); DFBResult (*AttachEventBuffer) ( IDirectFBWindow *thiz, IDirectFBEventBuffer *buffer ); DFBResult (*EnableEvents) ( IDirectFBWindow *thiz, DFBWindowEventType mask ); DFBResult (*DisableEvents) ( IDirectFBWindow *thiz, DFBWindowEventType mask ); DFBResult (*GetSurface) ( IDirectFBWindow *thiz, IDirectFBSurface **ret_surface ); DFBResult (*SetOptions) ( IDirectFBWindow *thiz, DFBWindowOptions options ); DFBResult (*GetOptions) ( IDirectFBWindow *thiz, DFBWindowOptions *ret_options ); DFBResult (*SetColorKey) ( IDirectFBWindow *thiz, __u8 r, __u8 g, __u8 b ); DFBResult (*SetColorKeyIndex) ( IDirectFBWindow *thiz, unsigned int index ); DFBResult (*SetOpacity) ( IDirectFBWindow *thiz, __u8 opacity ); DFBResult (*SetOpaqueRegion) ( IDirectFBWindow *thiz, int x1, int y1, int x2, int y2 ); DFBResult (*GetOpacity) ( IDirectFBWindow *thiz, __u8 *ret_opacity ); DFBResult (*SetCursorShape) ( IDirectFBWindow *thiz, IDirectFBSurface *shape, int hot_x, int hot_y ); DFBResult (*RequestFocus) ( IDirectFBWindow *thiz ); DFBResult (*GrabKeyboard) ( IDirectFBWindow *thiz ); DFBResult (*UngrabKeyboard) ( IDirectFBWindow *thiz ); DFBResult (*GrabPointer) ( IDirectFBWindow *thiz ); DFBResult (*UngrabPointer) ( IDirectFBWindow *thiz ); DFBResult (*GrabKey) ( IDirectFBWindow *thiz, DFBInputDeviceKeySymbol symbol, DFBInputDeviceModifierMask modifiers ); DFBResult (*UngrabKey) ( IDirectFBWindow *thiz, DFBInputDeviceKeySymbol symbol, DFBInputDeviceModifierMask modifiers ); DFBResult (*Move) ( IDirectFBWindow *thiz, int dx, int dy ); DFBResult (*MoveTo) ( IDirectFBWindow *thiz, int x, int y ); DFBResult (*Resize) ( IDirectFBWindow *thiz, int width, int height ); DFBResult (*SetStackingClass) ( IDirectFBWindow *thiz, DFBWindowStackingClass stacking_class ); DFBResult (*Raise) ( IDirectFBWindow *thiz ); DFBResult (*Lower) ( IDirectFBWindow *thiz ); DFBResult (*RaiseToTop) ( IDirectFBWindow *thiz ); DFBResult (*LowerToBottom) ( IDirectFBWindow *thiz ); DFBResult (*PutAtop) ( IDirectFBWindow *thiz, IDirectFBWindow *lower ); DFBResult (*PutBelow) ( IDirectFBWindow *thiz, IDirectFBWindow *upper ); DFBResult (*Close) ( IDirectFBWindow *thiz ); DFBResult (*Destroy) ( IDirectFBWindow *thiz ); }; +# 4356 "/usr/include/directfb/directfb.h" +struct _IDirectFBFont { void *priv; int magic; DFBResult (*AddRef)( IDirectFBFont *thiz ); DFBResult (*Release)( IDirectFBFont *thiz ); DFBResult (*GetAscender) ( IDirectFBFont *thiz, int *ret_ascender ); DFBResult (*GetDescender) ( IDirectFBFont *thiz, int *ret_descender ); DFBResult (*GetHeight) ( IDirectFBFont *thiz, int *ret_height ); DFBResult (*GetMaxAdvance) ( IDirectFBFont *thiz, int *ret_maxadvance ); DFBResult (*GetKerning) ( IDirectFBFont *thiz, unsigned int prev_index, unsigned int current_index, int *ret_kern_x, int *ret_kern_y ); DFBResult (*GetStringWidth) ( IDirectFBFont *thiz, const char *text, int bytes, int *ret_width ); DFBResult (*GetStringExtents) ( IDirectFBFont *thiz, const char *text, int bytes, DFBRectangle *ret_logical_rect, DFBRectangle *ret_ink_rect ); DFBResult (*GetGlyphExtents) ( IDirectFBFont *thiz, unsigned int index, DFBRectangle *ret_rect, int *ret_advance ); }; +# 4492 "/usr/include/directfb/directfb.h" +typedef enum { + DICAPS_NONE = 0x00000000, + DICAPS_ALPHACHANNEL = 0x00000001, + + DICAPS_COLORKEY = 0x00000002 + + +} DFBImageCapabilities; + + + + + +typedef struct { + DFBImageCapabilities caps; + + __u8 colorkey_r; + __u8 colorkey_g; + __u8 colorkey_b; +} DFBImageDescription; + + + + + +typedef void (*DIRenderCallback)(DFBRectangle *rect, void *ctx); +# 4526 "/usr/include/directfb/directfb.h" +struct _IDirectFBImageProvider { void *priv; int magic; DFBResult (*AddRef)( IDirectFBImageProvider *thiz ); DFBResult (*Release)( IDirectFBImageProvider *thiz ); DFBResult (*GetSurfaceDescription) ( IDirectFBImageProvider *thiz, DFBSurfaceDescription *ret_dsc ); DFBResult (*GetImageDescription) ( IDirectFBImageProvider *thiz, DFBImageDescription *ret_dsc ); DFBResult (*RenderTo) ( IDirectFBImageProvider *thiz, IDirectFBSurface *destination, const DFBRectangle *destination_rect ); DFBResult (*SetRenderCallback) ( IDirectFBImageProvider *thiz, DIRenderCallback callback, void *callback_data ); }; +# 4592 "/usr/include/directfb/directfb.h" +typedef int (*DVFrameCallback)(void *ctx); +# 4602 "/usr/include/directfb/directfb.h" +struct _IDirectFBVideoProvider { void *priv; int magic; DFBResult (*AddRef)( IDirectFBVideoProvider *thiz ); DFBResult (*Release)( IDirectFBVideoProvider *thiz ); DFBResult (*GetCapabilities) ( IDirectFBVideoProvider *thiz, DFBVideoProviderCapabilities *ret_caps ); DFBResult (*GetSurfaceDescription) ( IDirectFBVideoProvider *thiz, DFBSurfaceDescription *ret_dsc ); DFBResult (*PlayTo) ( IDirectFBVideoProvider *thiz, IDirectFBSurface *destination, const DFBRectangle *destination_rect, DVFrameCallback callback, void *ctx ); DFBResult (*Stop) ( IDirectFBVideoProvider *thiz ); DFBResult (*SeekTo) ( IDirectFBVideoProvider *thiz, double seconds ); DFBResult (*GetPos) ( IDirectFBVideoProvider *thiz, double *ret_seconds ); DFBResult (*GetLength) ( IDirectFBVideoProvider *thiz, double *ret_seconds ); DFBResult (*GetColorAdjustment) ( IDirectFBVideoProvider *thiz, DFBColorAdjustment *ret_adj ); DFBResult (*SetColorAdjustment) ( IDirectFBVideoProvider *thiz, const DFBColorAdjustment *adj ); }; +# 4708 "/usr/include/directfb/directfb.h" +struct _IDirectFBDataBuffer { void *priv; int magic; DFBResult (*AddRef)( IDirectFBDataBuffer *thiz ); DFBResult (*Release)( IDirectFBDataBuffer *thiz ); DFBResult (*Flush) ( IDirectFBDataBuffer *thiz ); DFBResult (*SeekTo) ( IDirectFBDataBuffer *thiz, unsigned int offset ); DFBResult (*GetPosition) ( IDirectFBDataBuffer *thiz, unsigned int *ret_offset ); DFBResult (*GetLength) ( IDirectFBDataBuffer *thiz, unsigned int *ret_length ); DFBResult (*WaitForData) ( IDirectFBDataBuffer *thiz, unsigned int length ); DFBResult (*WaitForDataWithTimeout) ( IDirectFBDataBuffer *thiz, unsigned int length, unsigned int seconds, unsigned int milli_seconds ); DFBResult (*GetData) ( IDirectFBDataBuffer *thiz, unsigned int length, void *ret_data, unsigned int *ret_read ); DFBResult (*PeekData) ( IDirectFBDataBuffer *thiz, unsigned int length, int offset, void *ret_data, unsigned int *ret_read ); DFBResult (*HasData) ( IDirectFBDataBuffer *thiz ); DFBResult (*PutData) ( IDirectFBDataBuffer *thiz, const void *data, unsigned int length ); DFBResult (*CreateImageProvider) ( IDirectFBDataBuffer *thiz, IDirectFBImageProvider **interface ); }; diff --git a/tests/input/c/dos.c b/tests/input/c/dos.c new file mode 100644 index 0000000000..108c3b1ccf --- /dev/null +++ b/tests/input/c/dos.c @@ -0,0 +1,33 @@ +/** + * This is your typical header comment + */ +int foo(int bar) +{ + int idx; + int res = 0; // trailing comment + // that spans two lines + for (idx = 1; idx < bar; idx++) + { + /* comment in virtual braces */ + res += idx; + } + + + res *= idx; // some comment + + // almost continued, but a NL in between + +// col1 comment in level 1 + return(res); +} + +// col1 comment in level 0 + +/* + Silly multiline comment. + + Oh yes. + + Really +*/ + diff --git a/tests/input/c/else-if.c b/tests/input/c/else-if.c new file mode 100644 index 0000000000..06cc37f2eb --- /dev/null +++ b/tests/input/c/else-if.c @@ -0,0 +1,29 @@ +int test (int A, int B) { + + int C; + + if (A == 0) + if (B == 0) + C = 1; + else if (B == 1) + C = 2; + else + C = 3; + else if (A == 1) + if (B == 0) + C = 4; + else if (B == 1) + C = 5; + else + C = 6; + else + if (B == 0) + C = 7; + else if (B == 1) + C = 8; + else + C = 9; + + return C; +} + diff --git a/tests/input/c/empty-for.c b/tests/input/c/empty-for.c new file mode 100644 index 0000000000..d9fb686a02 --- /dev/null +++ b/tests/input/c/empty-for.c @@ -0,0 +1,6 @@ +void foo(void) +{ + for (;x<2;x++) + { + } +} diff --git a/tests/input/c/endif.c b/tests/input/c/endif.c new file mode 100644 index 0000000000..fd621299e1 --- /dev/null +++ b/tests/input/c/endif.c @@ -0,0 +1,30 @@ +int do_this +( + int x, + int y +) +{ + + x++; + #ifdef ABC + #ifdef DEF + x += y; + #endif + #endif +a++; + #ifdef ABC +b++; + #ifdef DEF + c++; + #ifdef HIJ + d++; + #endif +e++; + #endif +f++; + #endif +g++; + + return (x) +} + diff --git a/tests/input/c/enum-struct-init.c b/tests/input/c/enum-struct-init.c new file mode 100644 index 0000000000..6660e4a4c9 --- /dev/null +++ b/tests/input/c/enum-struct-init.c @@ -0,0 +1,31 @@ + +enum foo_idx +{ + FOO_1, + FOO_2, + FOO_3, +}; + +struct foo +{ + const char *str; + int values[8]; +}; + +struct foo bar[] = +{ + [FOO_1] = { + "junk", + { 1 } }, + + [FOO_2] = { + "morejunk", + {1, 2, 3} }, + + [FOO_3] = { + "somemore", + {1, 2, 3, 4, 5, 6} }, + +}; + + diff --git a/tests/input/c/fcn_indent.c b/tests/input/c/fcn_indent.c new file mode 100644 index 0000000000..f1e40bd61d --- /dev/null +++ b/tests/input/c/fcn_indent.c @@ -0,0 +1,26 @@ +int this_is_a_function_proto(int a, +char * b); + +int this_is_a_function_def(int a, +char * b) +{ +this_is_a_function_call(a, +b); + +a = another_function_call(a, +b); + +} + +typedef short (*hello1)(char coolParam, + ushort *, + unsigned int anotherone); + +short (*hello2)(char coolParam, + ulong *, + uchar, + unsigned int anotherone); + +short hello3 (char coolParam, + ushort *, + unsigned int anotherone); diff --git a/tests/input/c/fcn_type.c b/tests/input/c/fcn_type.c new file mode 100644 index 0000000000..fc05208690 --- /dev/null +++ b/tests/input/c/fcn_type.c @@ -0,0 +1,36 @@ +typedef void (*my_fcn_ptr)(char *, int); +typedef const char *(my_fcn_ptr)(char *, int); +typedef int (my_fcn_ptr)(char *, int); +typedef struct foo *(my_fcn_ptr)(char *, int); +typedef enum foo *(*my_fcn_ptr)(char *, int); +typedef const struct foo *(*my_fcn_ptr)(char *, int); +typedef BOOL (my_fcn_ptr)(char *, int); +typedef INT32 (*my_fcn_ptr)(char *, int); +typedef int INT32; +typedef struct foo { + int a; +} fooey; + +typedef struct { + int a; +} queso; + +struct myfoo { + INT32 age; + const struct foo *(*my_fcn_ptr)(char *, int); + const CHAR *name; + MYTYPE (*foo)(int, char); + void *user; + void (*foo)(int, char); +}; + +SMU foo(void) +{ + a = 4; + return SMUIFY(a); +} + +typedef struct { + void (*newObject)(const object_info * info, const IObject * *interface, struct object_h* instance); +} IObjectFactory; + diff --git a/tests/input/c/for-space.c b/tests/input/c/for-space.c new file mode 100644 index 0000000000..1064d49381 --- /dev/null +++ b/tests/input/c/for-space.c @@ -0,0 +1,17 @@ +void f() +{ +for ( ; it != Values.end(); ++it) +BTree.insert(std::pair < int, double > (*it, double (*it) + 1.0)); + + +for ( ; vIt != Values.end(); ++vIt) +{ } +for ( ; vIt != Values.end(); ++vIt) +{ } + +for ( ; ; ) ; +for (int i = 0; i < 42; ) i += 3; + +for (int i = 0; i < 42; ++i) k += 3; +} + diff --git a/tests/input/c/func_call_user.c b/tests/input/c/func_call_user.c new file mode 100644 index 0000000000..275d8c5ed8 --- /dev/null +++ b/tests/input/c/func_call_user.c @@ -0,0 +1,7 @@ +int func(n) +{ + int a = foo (); + char *a = _("some text"); + char *str = N_("other text"); +} + diff --git a/tests/input/c/func_param.c b/tests/input/c/func_param.c new file mode 100644 index 0000000000..2be0f71bf5 --- /dev/null +++ b/tests/input/c/func_param.c @@ -0,0 +1,12 @@ +typedef short (*hello1)(char coolParam, + ushort *, + unsigned int anotherone); + +short (*hello2)(char coolParam, + ulong *, + uchar, + unsigned int anotherone); + +short hello3 (char coolParam, + ushort *, + unsigned int anotherone); diff --git a/tests/input/c/func_wrap.c b/tests/input/c/func_wrap.c new file mode 100644 index 0000000000..7589d03b66 --- /dev/null +++ b/tests/input/c/func_wrap.c @@ -0,0 +1,3 @@ + +void FSUB(MPI_Foo)(MPI_Fint* sendcount); + diff --git a/tests/input/c/funcfunc.c b/tests/input/c/funcfunc.c new file mode 100644 index 0000000000..ee717abc2c --- /dev/null +++ b/tests/input/c/funcfunc.c @@ -0,0 +1,5 @@ +int main() +{ + mWriter( "class Clst_"c )( cluster.getChild( HO_SHORT_NAME ).getText() )( " : Cluster {"c ).newline; +} + diff --git a/tests/input/c/function-def.c b/tests/input/c/function-def.c new file mode 100644 index 0000000000..778d121fb9 --- /dev/null +++ b/tests/input/c/function-def.c @@ -0,0 +1,24 @@ +void foo1(int param1, int param2, char *param2); + +void foo2(int param1, + int param2, + char *param2); + +void foo3(int param1, + int param2, + char *param2 + ); + +struct whoopee *foo4(int param1, int param2, char *param2); + +const struct snickers * +foo5(int param1, int param2, char *param2); + + +void foo(int param1, int param2, char *param2) +{ + printf("boo!\n"); +} + +EXPORT int DoStuff(int Num); + diff --git a/tests/input/c/global-vars.c b/tests/input/c/global-vars.c new file mode 100644 index 0000000000..9576341b1b --- /dev/null +++ b/tests/input/c/global-vars.c @@ -0,0 +1,7 @@ + +static int another_try; +struct something yup; +align_me_t please; +const char *name = "hello"; +static nothing really; + diff --git a/tests/input/c/hello.c b/tests/input/c/hello.c new file mode 100644 index 0000000000..5849783c7d --- /dev/null +++ b/tests/input/c/hello.c @@ -0,0 +1,13 @@ +#include + +void HelloWorld(char* pString) +{ + printf("%s\n", pString); +} /* HelloWorld */ + +int main() +{ + HelloWorld("Hello world"); + + return 0; +} /* main */ diff --git a/tests/input/c/i2c-core.c b/tests/input/c/i2c-core.c new file mode 100644 index 0000000000..29bdb5848b --- /dev/null +++ b/tests/input/c/i2c-core.c @@ -0,0 +1,1234 @@ +/* i2c-core.c - a device driver for the iic-bus interface */ +/* ------------------------------------------------------------------------- */ +/* Copyright (C) 1995-99 Simon G. Vogl + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* ------------------------------------------------------------------------- */ + +/* With some changes from Kyösti Mälkki . + All SMBus-related things are written by Frodo Looijaard + SMBus 2.0 support by Mark Studebaker */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static LIST_HEAD(adapters); +static LIST_HEAD(drivers); +static DECLARE_MUTEX(core_lists); +static DEFINE_IDR(i2c_adapter_idr); + +static int i2c_device_match(struct device *dev, struct device_driver *drv) +{ + return 1; +} + +static int i2c_bus_suspend(struct device * dev, pm_message_t state) +{ + int rc = 0; + + if (dev->driver && dev->driver->suspend) + rc = dev->driver->suspend(dev,state,0); + return rc; +} + +static int i2c_bus_resume(struct device * dev) +{ + int rc = 0; + + if (dev->driver && dev->driver->resume) + rc = dev->driver->resume(dev,0); + return rc; +} + +struct bus_type i2c_bus_type = { + .name = "i2c", + .match = i2c_device_match, + .suspend = i2c_bus_suspend, + .resume = i2c_bus_resume, +}; + +static int i2c_device_probe(struct device *dev) +{ + return -ENODEV; +} + +static int i2c_device_remove(struct device *dev) +{ + return 0; +} + +void i2c_adapter_dev_release(struct device *dev) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + complete(&adap->dev_released); +} + +struct device_driver i2c_adapter_driver = { + .name = "i2c_adapter", + .bus = &i2c_bus_type, + .probe = i2c_device_probe, + .remove = i2c_device_remove, +}; + +static void i2c_adapter_class_dev_release(struct class_device *dev) +{ + struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); + complete(&adap->class_dev_released); +} + +struct class i2c_adapter_class = { + .name = "i2c-adapter", + .release = &i2c_adapter_class_dev_release, +}; + +static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + return sprintf(buf, "%s\n", adap->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); + + +static void i2c_client_release(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + complete(&client->released); +} + +static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + return sprintf(buf, "%s\n", client->name); +} + +/* + * We can't use the DEVICE_ATTR() macro here as we want the same filename for a + * different type of a device. So beware if the DEVICE_ATTR() macro ever + * changes, this definition will also have to change. + */ +static struct device_attribute dev_attr_client_name = { + .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, + .show = &show_client_name, +}; + + +/* --------------------------------------------------- + * registering functions + * --------------------------------------------------- + */ + +/* ----- + * i2c_add_adapter is called from within the algorithm layer, + * when a new hw adapter registers. A new device is register to be + * available for clients. + */ +int i2c_add_adapter(struct i2c_adapter *adap) +{ + int id, res = 0; + struct list_head *item; + struct i2c_driver *driver; + + down(&core_lists); + + if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { + res = -ENOMEM; + goto out_unlock; + } + + res = idr_get_new(&i2c_adapter_idr, adap, &id); + if (res < 0) { + if (res == -EAGAIN) + res = -ENOMEM; + goto out_unlock; + } + + adap->nr = id & MAX_ID_MASK; + init_MUTEX(&adap->bus_lock); + init_MUTEX(&adap->clist_lock); + list_add_tail(&adap->list,&adapters); + INIT_LIST_HEAD(&adap->clients); + + /* Add the adapter to the driver core. + * If the parent pointer is not set up, + * we add this adapter to the host bus. + */ + if (adap->dev.parent == NULL) + adap->dev.parent = &platform_bus; + sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); + adap->dev.driver = &i2c_adapter_driver; + adap->dev.release = &i2c_adapter_dev_release; + device_register(&adap->dev); + device_create_file(&adap->dev, &dev_attr_name); + + /* Add this adapter to the i2c_adapter class */ + memset(&adap->class_dev, 0x00, sizeof(struct class_device)); + adap->class_dev.dev = &adap->dev; + adap->class_dev.class = &i2c_adapter_class; + strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); + class_device_register(&adap->class_dev); + + dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); + + /* inform drivers of new adapters */ + list_for_each(item,&drivers) { + driver = list_entry(item, struct i2c_driver, list); + if (driver->flags & I2C_DF_NOTIFY) + /* We ignore the return code; if it fails, too bad */ + driver->attach_adapter(adap); + } + +out_unlock: + up(&core_lists); + return res; +} + + +int i2c_del_adapter(struct i2c_adapter *adap) +{ + struct list_head *item, *_n; + struct i2c_adapter *adap_from_list; + struct i2c_driver *driver; + struct i2c_client *client; + int res = 0; + + down(&core_lists); + + /* First make sure that this adapter was ever added */ + list_for_each_entry(adap_from_list, &adapters, list) { + if (adap_from_list == adap) + break; + } + if (adap_from_list != adap) { + pr_debug("i2c-core: attempting to delete unregistered " + "adapter [%s]\n", adap->name); + res = -EINVAL; + goto out_unlock; + } + + list_for_each(item,&drivers) { + driver = list_entry(item, struct i2c_driver, list); + if (driver->detach_adapter) + if ((res = driver->detach_adapter(adap))) { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } + + /* detach any active clients. This must be done first, because + * it can fail; in which case we give up. */ + list_for_each_safe(item, _n, &adap->clients) { + client = list_entry(item, struct i2c_client, list); + + /* detaching devices is unconditional of the set notify + * flag, as _all_ clients that reside on the adapter + * must be deleted, as this would cause invalid states. + */ + if ((res=client->driver->detach_client(client))) { + dev_err(&adap->dev, "detach_client failed for client " + "[%s] at address 0x%02x\n", client->name, + client->addr); + goto out_unlock; + } + } + + /* clean up the sysfs representation */ + init_completion(&adap->dev_released); + init_completion(&adap->class_dev_released); + class_device_unregister(&adap->class_dev); + device_remove_file(&adap->dev, &dev_attr_name); + device_unregister(&adap->dev); + list_del(&adap->list); + + /* wait for sysfs to drop all references */ + wait_for_completion(&adap->dev_released); + wait_for_completion(&adap->class_dev_released); + + /* free dynamically allocated bus id */ + idr_remove(&i2c_adapter_idr, adap->nr); + + dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); + + out_unlock: + up(&core_lists); + return res; +} + + +/* ----- + * What follows is the "upwards" interface: commands for talking to clients, + * which implement the functions to access the physical information of the + * chips. + */ + +int i2c_add_driver(struct i2c_driver *driver) +{ + struct list_head *item; + struct i2c_adapter *adapter; + int res = 0; + + down(&core_lists); + + /* add the driver to the list of i2c drivers in the driver core */ + driver->driver.name = driver->name; + driver->driver.bus = &i2c_bus_type; + driver->driver.probe = i2c_device_probe; + driver->driver.remove = i2c_device_remove; + + res = driver_register(&driver->driver); + if (res) + goto out_unlock; + + list_add_tail(&driver->list,&drivers); + pr_debug("i2c-core: driver [%s] registered\n", driver->name); + + /* now look for instances of driver on our adapters */ + if (driver->flags & I2C_DF_NOTIFY) { + list_for_each(item,&adapters) { + adapter = list_entry(item, struct i2c_adapter, list); + driver->attach_adapter(adapter); + } + } + + out_unlock: + up(&core_lists); + return res; +} + +int i2c_del_driver(struct i2c_driver *driver) +{ + struct list_head *item1, *item2, *_n; + struct i2c_client *client; + struct i2c_adapter *adap; + + int res = 0; + + down(&core_lists); + + /* Have a look at each adapter, if clients of this driver are still + * attached. If so, detach them to be able to kill the driver + * afterwards. + * + * Removing clients does not depend on the notify flag, else + * invalid operation might (will!) result, when using stale client + * pointers. + */ + list_for_each(item1,&adapters) { + adap = list_entry(item1, struct i2c_adapter, list); + if (driver->detach_adapter) { + if ((res = driver->detach_adapter(adap))) { + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); + goto out_unlock; + } + } else { + list_for_each_safe(item2, _n, &adap->clients) { + client = list_entry(item2, struct i2c_client, list); + if (client->driver != driver) + continue; + dev_dbg(&adap->dev, "detaching client [%s] " + "at 0x%02x\n", client->name, + client->addr); + if ((res = driver->detach_client(client))) { + dev_err(&adap->dev, "detach_client " + "failed for client [%s] at " + "0x%02x\n", client->name, + client->addr); + goto out_unlock; + } + } + } + } + + driver_unregister(&driver->driver); + list_del(&driver->list); + pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); + + out_unlock: + up(&core_lists); + return 0; +} + +static int __i2c_check_addr(struct i2c_adapter *adapter, unsigned int addr) +{ + struct list_head *item; + struct i2c_client *client; + + list_for_each(item,&adapter->clients) { + client = list_entry(item, struct i2c_client, list); + if (client->addr == addr) + return -EBUSY; + } + return 0; +} + +int i2c_check_addr(struct i2c_adapter *adapter, int addr) +{ + int rval; + + down(&adapter->clist_lock); + rval = __i2c_check_addr(adapter, addr); + up(&adapter->clist_lock); + + return rval; +} + +int i2c_attach_client(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + + down(&adapter->clist_lock); + if (__i2c_check_addr(client->adapter, client->addr)) { + up(&adapter->clist_lock); + return -EBUSY; + } + list_add_tail(&client->list,&adapter->clients); + up(&adapter->clist_lock); + + if (adapter->client_register) { + if (adapter->client_register(client)) { + dev_dbg(&adapter->dev, "client_register " + "failed for client [%s] at 0x%02x\n", + client->name, client->addr); + } + } + + if (client->flags & I2C_CLIENT_ALLOW_USE) + client->usage_count = 0; + + client->dev.parent = &client->adapter->dev; + client->dev.driver = &client->driver->driver; + client->dev.bus = &i2c_bus_type; + client->dev.release = &i2c_client_release; + + snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), + "%d-%04x", i2c_adapter_id(adapter), client->addr); + dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", + client->name, client->dev.bus_id); + device_register(&client->dev); + device_create_file(&client->dev, &dev_attr_client_name); + + return 0; +} + + +int i2c_detach_client(struct i2c_client *client) +{ + struct i2c_adapter *adapter = client->adapter; + int res = 0; + + if ((client->flags & I2C_CLIENT_ALLOW_USE) + && (client->usage_count > 0)) { + dev_warn(&client->dev, "Client [%s] still busy, " + "can't detach\n", client->name); + return -EBUSY; + } + + if (adapter->client_unregister) { + res = adapter->client_unregister(client); + if (res) { + dev_err(&client->dev, + "client_unregister [%s] failed, " + "client not detached\n", client->name); + goto out; + } + } + + down(&adapter->clist_lock); + list_del(&client->list); + init_completion(&client->released); + device_remove_file(&client->dev, &dev_attr_client_name); + device_unregister(&client->dev); + up(&adapter->clist_lock); + wait_for_completion(&client->released); + + out: + return res; +} + +static int i2c_inc_use_client(struct i2c_client *client) +{ + + if (!try_module_get(client->driver->owner)) + return -ENODEV; + if (!try_module_get(client->adapter->owner)) { + module_put(client->driver->owner); + return -ENODEV; + } + + return 0; +} + +static void i2c_dec_use_client(struct i2c_client *client) +{ + module_put(client->driver->owner); + module_put(client->adapter->owner); +} + +int i2c_use_client(struct i2c_client *client) +{ + int ret; + + ret = i2c_inc_use_client(client); + if (ret) + return ret; + + if (client->flags & I2C_CLIENT_ALLOW_USE) { + if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + client->usage_count++; + else if (client->usage_count > 0) + goto busy; + else + client->usage_count++; + } + + return 0; + busy: + i2c_dec_use_client(client); + return -EBUSY; +} + +int i2c_release_client(struct i2c_client *client) +{ + if(client->flags & I2C_CLIENT_ALLOW_USE) { + if(client->usage_count>0) + client->usage_count--; + else { + pr_debug("i2c-core: %s used one too many times\n", + __FUNCTION__); + return -EPERM; + } + } + + i2c_dec_use_client(client); + + return 0; +} + +void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) +{ + struct list_head *item; + struct i2c_client *client; + + down(&adap->clist_lock); + list_for_each(item,&adap->clients) { + client = list_entry(item, struct i2c_client, list); + if (!try_module_get(client->driver->owner)) + continue; + if (NULL != client->driver->command) { + up(&adap->clist_lock); + client->driver->command(client,cmd,arg); + down(&adap->clist_lock); + } + module_put(client->driver->owner); + } + up(&adap->clist_lock); +} + +static int __init i2c_init(void) +{ + int retval; + + retval = bus_register(&i2c_bus_type); + if (retval) + return retval; + retval = driver_register(&i2c_adapter_driver); + if (retval) + return retval; + return class_register(&i2c_adapter_class); +} + +static void __exit i2c_exit(void) +{ + class_unregister(&i2c_adapter_class); + driver_unregister(&i2c_adapter_driver); + bus_unregister(&i2c_bus_type); +} + +subsys_initcall(i2c_init); +module_exit(i2c_exit); + +/* ---------------------------------------------------- + * the functional interface to the i2c busses. + * ---------------------------------------------------- + */ + +int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) +{ + int ret; + + if (adap->algo->master_xfer) { +#ifdef DEBUG + for (ret = 0; ret < num; ret++) { + dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, " + "len=%d\n", ret, msgs[ret].flags & I2C_M_RD ? + 'R' : 'W', msgs[ret].addr, msgs[ret].len); + } +#endif + + down(&adap->bus_lock); + ret = adap->algo->master_xfer(adap,msgs,num); + up(&adap->bus_lock); + + return ret; + } else { + dev_dbg(&adap->dev, "I2C level transfers not supported\n"); + return -ENOSYS; + } +} + +int i2c_master_send(struct i2c_client *client,const char *buf ,int count) +{ + int ret; + struct i2c_adapter *adap=client->adapter; + struct i2c_msg msg; + + msg.addr = client->addr; + msg.flags = client->flags & I2C_M_TEN; + msg.len = count; + msg.buf = (char *)buf; + + ret = i2c_transfer(adap, &msg, 1); + + /* If everything went ok (i.e. 1 msg transmitted), return #bytes + transmitted, else error code. */ + return (ret == 1) ? count : ret; +} + +int i2c_master_recv(struct i2c_client *client, char *buf ,int count) +{ + struct i2c_adapter *adap=client->adapter; + struct i2c_msg msg; + int ret; + + msg.addr = client->addr; + msg.flags = client->flags & I2C_M_TEN; + msg.flags |= I2C_M_RD; + msg.len = count; + msg.buf = buf; + + ret = i2c_transfer(adap, &msg, 1); + + /* If everything went ok (i.e. 1 msg transmitted), return #bytes + transmitted, else error code. */ + return (ret == 1) ? count : ret; +} + + +int i2c_control(struct i2c_client *client, + unsigned int cmd, unsigned long arg) +{ + int ret = 0; + struct i2c_adapter *adap = client->adapter; + + dev_dbg(&client->adapter->dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg); + switch (cmd) { + case I2C_RETRIES: + adap->retries = arg; + break; + case I2C_TIMEOUT: + adap->timeout = arg; + break; + default: + if (adap->algo->algo_control!=NULL) + ret = adap->algo->algo_control(adap,cmd,arg); + } + return ret; +} + +/* ---------------------------------------------------- + * the i2c address scanning function + * Will not work for 10-bit addresses! + * ---------------------------------------------------- + */ +static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind, + int (*found_proc) (struct i2c_adapter *, int, int)) +{ + int err; + + /* Make sure the address is valid */ + if (addr < 0x03 || addr > 0x77) { + dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n", + addr); + return -EINVAL; + } + + /* Skip if already in use */ + if (i2c_check_addr(adapter, addr)) + return 0; + + /* Make sure there is something at this address, unless forced */ + if (kind < 0) { + if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL) < 0) + return 0; + + /* prevent 24RF08 corruption */ + if ((addr & ~0x0f) == 0x50) + i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL); + } + + /* Finally call the custom detection function */ + err = found_proc(adapter, addr, kind); + + /* -ENODEV can be returned if there is a chip at the given address + but it isn't supported by this chip driver. We catch it here as + this isn't an error. */ + return (err == -ENODEV) ? 0 : err; +} + +int i2c_probe(struct i2c_adapter *adapter, + struct i2c_client_address_data *address_data, + int (*found_proc) (struct i2c_adapter *, int, int)) +{ + int i, err; + int adap_id = i2c_adapter_id(adapter); + + /* Forget it if we can't probe using SMBUS_QUICK */ + if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) + return -1; + + /* Force entries are done first, and are not affected by ignore + entries */ + if (address_data->forces) { + unsigned short **forces = address_data->forces; + int kind; + + for (kind = 0; forces[kind]; kind++) { + for (i = 0; forces[kind][i] != I2C_CLIENT_END; + i += 2) { + if (forces[kind][i] == adap_id + || forces[kind][i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found force " + "parameter for adapter %d, " + "addr 0x%02x, kind %d\n", + adap_id, forces[kind][i + 1], + kind); + err = i2c_probe_address(adapter, + forces[kind][i + 1], + kind, found_proc); + if (err) + return err; + } + } + } + } + + /* Probe entries are done second, and are not affected by ignore + entries either */ + for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { + if (address_data->probe[i] == adap_id + || address_data->probe[i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found probe parameter for " + "adapter %d, addr 0x%02x\n", adap_id, + address_data->probe[i + 1]); + err = i2c_probe_address(adapter, + address_data->probe[i + 1], + -1, found_proc); + if (err) + return err; + } + } + + /* Normal entries are done last, unless shadowed by an ignore entry */ + for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { + int j, ignore; + + ignore = 0; + for (j = 0; address_data->ignore[j] != I2C_CLIENT_END; + j += 2) { + if ((address_data->ignore[j] == adap_id || + address_data->ignore[j] == ANY_I2C_BUS) + && address_data->ignore[j + 1] + == address_data->normal_i2c[i]) { + dev_dbg(&adapter->dev, "found ignore " + "parameter for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->ignore[j + 1]); + } + ignore = 1; + break; + } + if (ignore) + continue; + + dev_dbg(&adapter->dev, "found normal entry for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->normal_i2c[i]); + err = i2c_probe_address(adapter, address_data->normal_i2c[i], + -1, found_proc); + if (err) + return err; + } + + return 0; +} + +struct i2c_adapter* i2c_get_adapter(int id) +{ + struct i2c_adapter *adapter; + + down(&core_lists); + adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); + if (adapter && !try_module_get(adapter->owner)) + adapter = NULL; + + up(&core_lists); + return adapter; +} + +void i2c_put_adapter(struct i2c_adapter *adap) +{ + module_put(adap->owner); +} + +/* The SMBus parts */ + +#define POLY (0x1070U << 3) +static u8 +crc8(u16 data) +{ + int i; + + for(i = 0; i < 8; i++) { + if (data & 0x8000) + data = data ^ POLY; + data = data << 1; + } + return (u8)(data >> 8); +} + +/* CRC over count bytes in the first array plus the bytes in the rest + array if it is non-null. rest[0] is the (length of rest) - 1 + and is included. */ +static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest) +{ + int i; + + for(i = 0; i < count; i++) + crc = crc8((crc ^ first[i]) << 8); + if(rest != NULL) + for(i = 0; i <= rest[0]; i++) + crc = crc8((crc ^ rest[i]) << 8); + return crc; +} + +static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) +{ + return i2c_smbus_partial_pec(0, count, first, rest); +} + +/* Returns new "size" (transaction type) + Note that we convert byte to byte_data and byte_data to word_data + rather than invent new xxx_PEC transactions. */ +static int i2c_smbus_add_pec(u16 addr, u8 command, int size, + union i2c_smbus_data *data) +{ + u8 buf[3]; + + buf[0] = addr << 1; + buf[1] = command; + switch(size) { + case I2C_SMBUS_BYTE: + data->byte = i2c_smbus_pec(2, buf, NULL); + size = I2C_SMBUS_BYTE_DATA; + break; + case I2C_SMBUS_BYTE_DATA: + buf[2] = data->byte; + data->word = buf[2] || + (i2c_smbus_pec(3, buf, NULL) << 8); + size = I2C_SMBUS_WORD_DATA; + break; + case I2C_SMBUS_WORD_DATA: + /* unsupported */ + break; + case I2C_SMBUS_BLOCK_DATA: + data->block[data->block[0] + 1] = + i2c_smbus_pec(2, buf, data->block); + size = I2C_SMBUS_BLOCK_DATA_PEC; + break; + } + return size; +} + +static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, + union i2c_smbus_data *data) +{ + u8 buf[3], rpec, cpec; + + buf[1] = command; + switch(size) { + case I2C_SMBUS_BYTE_DATA: + buf[0] = (addr << 1) | 1; + cpec = i2c_smbus_pec(2, buf, NULL); + rpec = data->byte; + break; + case I2C_SMBUS_WORD_DATA: + buf[0] = (addr << 1) | 1; + buf[2] = data->word & 0xff; + cpec = i2c_smbus_pec(3, buf, NULL); + rpec = data->word >> 8; + break; + case I2C_SMBUS_WORD_DATA_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_PROC_CALL_PEC: + /* unsupported */ + cpec = rpec = 0; + break; + case I2C_SMBUS_BLOCK_DATA_PEC: + buf[0] = (addr << 1); + buf[2] = (addr << 1) | 1; + cpec = i2c_smbus_pec(3, buf, data->block); + rpec = data->block[data->block[0] + 1]; + break; + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + buf[0] = (addr << 1) | 1; + rpec = i2c_smbus_partial_pec(partial, 1, + buf, data->block); + cpec = data->block[data->block[0] + 1]; + break; + default: + cpec = rpec = 0; + break; + } + if (rpec != cpec) { + pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", + rpec, cpec); + return -1; + } + return 0; +} + +s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) +{ + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + value,0,I2C_SMBUS_QUICK,NULL); +} + +s32 i2c_smbus_read_byte(struct i2c_client *client) +{ + union i2c_smbus_data data; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data)) + return -1; + else + return 0x0FF & data.byte; +} + +s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) +{ + union i2c_smbus_data data; /* only for PEC */ + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,&data); +} + +s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) +{ + union i2c_smbus_data data; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data)) + return -1; + else + return 0x0FF & data.byte; +} + +s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) +{ + union i2c_smbus_data data; + data.byte = value; + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,command, + I2C_SMBUS_BYTE_DATA,&data); +} + +s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) +{ + union i2c_smbus_data data; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA, &data)) + return -1; + else + return 0x0FFFF & data.word; +} + +s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) +{ + union i2c_smbus_data data; + data.word = value; + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,command, + I2C_SMBUS_WORD_DATA,&data); +} + +s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, + u8 length, u8 *values) +{ + union i2c_smbus_data data; + int i; + if (length > I2C_SMBUS_BLOCK_MAX) + length = I2C_SMBUS_BLOCK_MAX; + for (i = 1; i <= length; i++) + data.block[i] = values[i-1]; + data.block[0] = length; + return i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_WRITE,command, + I2C_SMBUS_BLOCK_DATA,&data); +} + +/* Returns the number of read bytes */ +s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) +{ + union i2c_smbus_data data; + int i; + if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, + I2C_SMBUS_READ,command, + I2C_SMBUS_I2C_BLOCK_DATA,&data)) + return -1; + else { + for (i = 1; i <= data.block[0]; i++) + values[i-1] = data.block[i]; + return data.block[0]; + } +} + +/* Simulate a SMBus command using the i2c protocol + No checking of parameters is done! */ +static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, + unsigned short flags, + char read_write, u8 command, int size, + union i2c_smbus_data * data) +{ + /* So we need to generate a series of msgs. In the case of writing, we + need to use only one message; when reading, we need two. We initialize + most things with sane defaults, to keep the code below somewhat + simpler. */ + unsigned char msgbuf0[34]; + unsigned char msgbuf1[34]; + int num = read_write == I2C_SMBUS_READ?2:1; + struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, + { addr, flags | I2C_M_RD, 0, msgbuf1 } + }; + int i; + + msgbuf0[0] = command; + switch(size) { + case I2C_SMBUS_QUICK: + msg[0].len = 0; + /* Special case: The read/write field is used as data */ + msg[0].flags = flags | (read_write==I2C_SMBUS_READ)?I2C_M_RD:0; + num = 1; + break; + case I2C_SMBUS_BYTE: + if (read_write == I2C_SMBUS_READ) { + /* Special case: only a read! */ + msg[0].flags = I2C_M_RD | flags; + num = 1; + } + break; + case I2C_SMBUS_BYTE_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = 1; + else { + msg[0].len = 2; + msgbuf0[1] = data->byte; + } + break; + case I2C_SMBUS_WORD_DATA: + if (read_write == I2C_SMBUS_READ) + msg[1].len = 2; + else { + msg[0].len=3; + msgbuf0[1] = data->word & 0xff; + msgbuf0[2] = (data->word >> 8) & 0xff; + } + break; + case I2C_SMBUS_PROC_CALL: + num = 2; /* Special case */ + read_write = I2C_SMBUS_READ; + msg[0].len = 3; + msg[1].len = 2; + msgbuf0[1] = data->word & 0xff; + msgbuf0[2] = (data->word >> 8) & 0xff; + break; + case I2C_SMBUS_BLOCK_DATA: + case I2C_SMBUS_BLOCK_DATA_PEC: + if (read_write == I2C_SMBUS_READ) { + dev_err(&adapter->dev, "Block read not supported " + "under I2C emulation!\n"); + return -1; + } else { + msg[0].len = data->block[0] + 2; + if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) { + dev_err(&adapter->dev, "smbus_access called with " + "invalid block write size (%d)\n", + data->block[0]); + return -1; + } + if(size == I2C_SMBUS_BLOCK_DATA_PEC) + (msg[0].len)++; + for (i = 1; i <= msg[0].len; i++) + msgbuf0[i] = data->block[i-1]; + } + break; + case I2C_SMBUS_BLOCK_PROC_CALL: + case I2C_SMBUS_BLOCK_PROC_CALL_PEC: + dev_dbg(&adapter->dev, "Block process call not supported " + "under I2C emulation!\n"); + return -1; + case I2C_SMBUS_I2C_BLOCK_DATA: + if (read_write == I2C_SMBUS_READ) { + msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; + } else { + msg[0].len = data->block[0] + 1; + if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { + dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " + "invalid block write size (%d)\n", + data->block[0]); + return -1; + } + for (i = 1; i <= data->block[0]; i++) + msgbuf0[i] = data->block[i]; + } + break; + default: + dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n", + size); + return -1; + } + + if (i2c_transfer(adapter, msg, num) < 0) + return -1; + + if (read_write == I2C_SMBUS_READ) + switch(size) { + case I2C_SMBUS_BYTE: + data->byte = msgbuf0[0]; + break; + case I2C_SMBUS_BYTE_DATA: + data->byte = msgbuf1[0]; + break; + case I2C_SMBUS_WORD_DATA: + case I2C_SMBUS_PROC_CALL: + data->word = msgbuf1[0] | (msgbuf1[1] << 8); + break; + case I2C_SMBUS_I2C_BLOCK_DATA: + /* fixed at 32 for now */ + data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; + for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) + data->block[i+1] = msgbuf1[i]; + break; + } + return 0; +} + + +s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, + char read_write, u8 command, int size, + union i2c_smbus_data * data) +{ + s32 res; + int swpec = 0; + u8 partial = 0; + + flags &= I2C_M_TEN | I2C_CLIENT_PEC; + if((flags & I2C_CLIENT_PEC) && + !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) { + swpec = 1; + if(read_write == I2C_SMBUS_READ && + size == I2C_SMBUS_BLOCK_DATA) + size = I2C_SMBUS_BLOCK_DATA_PEC; + else if(size == I2C_SMBUS_PROC_CALL) + size = I2C_SMBUS_PROC_CALL_PEC; + else if(size == I2C_SMBUS_BLOCK_PROC_CALL) { + i2c_smbus_add_pec(addr, command, + I2C_SMBUS_BLOCK_DATA, data); + partial = data->block[data->block[0] + 1]; + size = I2C_SMBUS_BLOCK_PROC_CALL_PEC; + } else if(read_write == I2C_SMBUS_WRITE && + size != I2C_SMBUS_QUICK && + size != I2C_SMBUS_I2C_BLOCK_DATA) + size = i2c_smbus_add_pec(addr, command, size, data); + } + + if (adapter->algo->smbus_xfer) { + down(&adapter->bus_lock); + res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, + command,size,data); + up(&adapter->bus_lock); + } else + res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, + command,size,data); + + if(res >= 0 && swpec && + size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA && + (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC || + size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) { + if(i2c_smbus_check_pec(addr, command, size, partial, data)) + return -1; + } + return res; +} + + +/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL_GPL(i2c_adapter_dev_release); +EXPORT_SYMBOL_GPL(i2c_adapter_driver); +EXPORT_SYMBOL_GPL(i2c_adapter_class); +EXPORT_SYMBOL_GPL(i2c_bus_type); + +EXPORT_SYMBOL(i2c_add_adapter); +EXPORT_SYMBOL(i2c_del_adapter); +EXPORT_SYMBOL(i2c_add_driver); +EXPORT_SYMBOL(i2c_del_driver); +EXPORT_SYMBOL(i2c_attach_client); +EXPORT_SYMBOL(i2c_detach_client); +EXPORT_SYMBOL(i2c_use_client); +EXPORT_SYMBOL(i2c_release_client); +EXPORT_SYMBOL(i2c_clients_command); +EXPORT_SYMBOL(i2c_check_addr); + +EXPORT_SYMBOL(i2c_master_send); +EXPORT_SYMBOL(i2c_master_recv); +EXPORT_SYMBOL(i2c_control); +EXPORT_SYMBOL(i2c_transfer); +EXPORT_SYMBOL(i2c_get_adapter); +EXPORT_SYMBOL(i2c_put_adapter); +EXPORT_SYMBOL(i2c_probe); + +EXPORT_SYMBOL(i2c_smbus_xfer); +EXPORT_SYMBOL(i2c_smbus_write_quick); +EXPORT_SYMBOL(i2c_smbus_read_byte); +EXPORT_SYMBOL(i2c_smbus_write_byte); +EXPORT_SYMBOL(i2c_smbus_read_byte_data); +EXPORT_SYMBOL(i2c_smbus_write_byte_data); +EXPORT_SYMBOL(i2c_smbus_read_word_data); +EXPORT_SYMBOL(i2c_smbus_write_word_data); +EXPORT_SYMBOL(i2c_smbus_write_block_data); +EXPORT_SYMBOL(i2c_smbus_read_i2c_block_data); + +MODULE_AUTHOR("Simon G. Vogl "); +MODULE_DESCRIPTION("I2C-Bus main module"); +MODULE_LICENSE("GPL"); diff --git a/tests/input/c/if_chain.c b/tests/input/c/if_chain.c new file mode 100644 index 0000000000..04103d6e46 --- /dev/null +++ b/tests/input/c/if_chain.c @@ -0,0 +1,70 @@ +void foo(void) +{ + if (cond_a) { + fcn_a(); + fcn_b(); + } else { + fcn_c(); + } + + if (cond_b) { + fcn_d(); + } else { + fcn_e(); + } + + if (cond_c) { + fcn_f(); + fcn_g(); + } else + fcn_h(); + + if (cond_d) + fcn_i(); + else { + fcn_j(); + fcn_k(); + } + + if (cond_e) + fcn_l(); + else + fcn_m(); + + if (cond_f) + fcn_n(); + else if (cond_g) { + fcn_o(); + while (cond_g) { + fcn_p(); + } + } else if (cond_h) + while (cond_i) { + fcn_q(); + fcn_r(); + } + else + fcn_s(); +} + +/* this next bit test whether vbraces can be successfully converted + * when the closing brace is in an #ifdef. + * Note that the author should have braced the code to begin with. + */ +void bar(void) +{ + if (jiffies >= hw_priv->Counter[ port ].time) { + hw_priv->Counter[ port ].fRead = 1; + if (port == MAIN_PORT) { + hw_priv->Counter[ MAIN_PORT ].time = jiffies + HZ * 6; + } else + hw_priv->Counter[ port ].time = + +#ifdef SOME_DEFINE + hw_priv->Counter[ port - 1 ].time + HZ * 2; + +#else /* ifdef SOME_DEFINE */ + hw_priv->Counter[ MAIN_PORT ].time + HZ * 2; +#endif /* ifdef SOME_DEFINE */ + } +} diff --git a/tests/input/c/ifdef-indent.c b/tests/input/c/ifdef-indent.c new file mode 100644 index 0000000000..3a1018dbc2 --- /dev/null +++ b/tests/input/c/ifdef-indent.c @@ -0,0 +1,35 @@ +#ifdef foo +#include +#else +#include +#endif + +int +show_interrupts(struct seq_file *p, void *v) +{ +#ifndef CONFIG_SMP + a++; +#else + for (b = 0; b < 9; b++) + if (b & 1) + k++; +#endif + + if (v) + { + bar(v); + #if DEBUG == 1 + printf("yup\n"); + #endif + } +} + +void foo() +{ +int i=0; +#if DEBUG == 1 +i--; +#endif +i++; +} + diff --git a/tests/input/c/ifdef-nest.c b/tests/input/c/ifdef-nest.c new file mode 100644 index 0000000000..68baf1fcc0 --- /dev/null +++ b/tests/input/c/ifdef-nest.c @@ -0,0 +1,15 @@ + +namespace MonoTests.System.IO.IsolatedStorageTest { + public class NonAbstractIsolatedStorage : IsolatedStorage { + public NonAbstractIsolatedStorage () { + string s = String.Format ("{0} {1}", + Environment.NewLine, +#if NET_2_0 + String.Empty); +#else + " "); +#endif + } + } +} + diff --git a/tests/input/c/include_define.h b/tests/input/c/include_define.h new file mode 100644 index 0000000000..13380cac3c --- /dev/null +++ b/tests/input/c/include_define.h @@ -0,0 +1,5 @@ +#define MY_HEADER + +#include MY_HEADER + + diff --git a/tests/input/c/indent-assign.c b/tests/input/c/indent-assign.c new file mode 100644 index 0000000000..58ed9c52bd --- /dev/null +++ b/tests/input/c/indent-assign.c @@ -0,0 +1,13 @@ +void foo(void) +{ + int a; + junk(a = 3); +} + +void f() +{ + int x = size_t(1.0) + + 2; + int y = (size_t(1.0) + + 5); +} diff --git a/tests/input/c/indent.cpp b/tests/input/c/indent.cpp new file mode 100644 index 0000000000..6157444b51 --- /dev/null +++ b/tests/input/c/indent.cpp @@ -0,0 +1,1084 @@ +/** + * @file indent.cpp + * Does all the indenting stuff. + * + * $Id: indent.cpp 548 2006-10-21 02:31:55Z bengardner $ + */ +#include "uncrustify_types.h" +#include "chunk_list.h" +#include "prototypes.h" +#include +#include +#include +#include +#include + + +/** + * General indenting approach: + * Indenting levels are put into a stack. + * + * The stack entries contain: + * - opening type + * - brace column + * - continuation column + * + * Items that start a new stack item: + * - preprocessor (new parse frame) + * - Brace Open (Virtual brace also) + * - Paren, Square, Angle open + * - Assignments + * - C++ '<<' operator (ie, cout << "blah") + * - case + * - class colon + * - return + * - types + * - any other continued statement + * + * Note that the column of items marked 'PCF_WAS_ALIGNED' is not changed. + * + * For an open brace: + * - indent increases by indent_columns + * - if part of if/else/do/while/switch/etc, an extra indent may be applied + * - if in a paren, then cont-col is set to column + 1, ie "({ some code })" + * + * Open paren/square/angle: + * cont-col is set to the column of the item after the open paren, unless + * followed by a newline, then it is set to (brace-col + indent_columns). + * Examples: + * a_really_long_funcion_name( + * param1, param2); + * a_really_long_funcion_name(param1, + * param2); + * + * Assignments: + * Assignments are continued aligned with the first item after the assignment, + * unless the assign is followed by a newline. + * Examples: + * some.variable = asdf + asdf + + * asdf; + * some.variable = + * asdf + asdf + asdf; + * + * C++ << operator: + * Handled the same as assignment. + * Examples: + * cout << "this is test number: " + * << test_number; + * + * case: + * Started with case or default. + * Terminated with close brace at level or another case or default. + * Special indenting according to various rules. + * - indent of case label + * - indent of case body + * - how to handle optional braces + * Examples: + * { + * case x: { + * a++; + * break; + * } + * case y: + * b--; + * break; + * default: + * c++; + * break; + * } + * + * Class colon: + * Indent continuation by indent_columns: + * class my_class : + * baseclass1, + * baseclass2 + * { + * + * Return: same as assignemts + * If the return statement is not fully paren'd, then the indent continues at + * the column of the item after the return. If it is paren'd, then the paren + * rules apply. + * return somevalue + + * othervalue; + * + * Type: pretty much the same as assignments + * Examples: + * int foo, + * bar, + * baz; + * + * Any other continued item: + * There shouldn't be anything not covered by the above cases, but any other + * continued item is indented by indent_columns: + * Example: + * somereallycrazylongname.with[lotsoflongstuff]. + * thatreallyannoysme.whenIhavetomaintain[thecode] = 3; + */ + +static void indent_comment(chunk_t *pc, int col); + + +void indent_to_column(chunk_t *pc, int column) +{ + if (column < pc->column) + { + column = pc->column; + } + reindent_line(pc, column); +} + +/** + * Changes the initial indent for a line to the given column + * + * @param pc The chunk at the start of the line + * @param column The desired column + */ +void reindent_line(chunk_t *pc, int column) +{ + int col_delta; + int min_col; + + LOG_FMT(LINDLINE, "%s: %d] col %d on %.*s [%s] => %d\n", + __func__, pc->orig_line, pc->column, pc->len, pc->str, + get_token_name(pc->type), column); + + if (column == pc->column) + { + return; + } + col_delta = column - pc->column; + pc->column = column; + min_col = pc->column; + + do + { + min_col += pc->len; + pc = chunk_get_next(pc); + if (pc != NULL) + { + if (chunk_is_comment(pc)) + { + pc->column = pc->orig_col; + if (pc->column < min_col) + { + pc->column = min_col + 1; + } + LOG_FMT(LINDLINE, "%s: set comment on line %d to col %d (orig %d)\n", + __func__, pc->orig_line, pc->column, pc->orig_col); + } + else + { + pc->column += col_delta; + if (pc->column < min_col) + { + pc->column = min_col; + } + } + } + } while ((pc != NULL) && (pc->nl_count == 0)); +} + + +/** + * Starts a new entry + * + * @param frm The parse frame + * @param pc The chunk causing the push + */ +static void indent_pse_push(struct parse_frame& frm, chunk_t *pc) +{ + static int ref = 0; + + /* check the stack depth */ + if (frm.pse_tos < (int)ARRAY_SIZE(frm.pse)) + { + /* Bump up the index and initialize it */ + frm.pse_tos++; + memset(&frm.pse[frm.pse_tos], 0, sizeof(frm.pse[frm.pse_tos])); + + LOG_FMT(LINDPSE, "%4d] OPEN [%d,%s] level=%d\n", + pc->orig_line, frm.pse_tos, get_token_name(pc->type), pc->level); + + frm.pse[frm.pse_tos].type = pc->type; + frm.pse[frm.pse_tos].level = pc->level; + frm.pse[frm.pse_tos].open_line = pc->orig_line; + frm.pse[frm.pse_tos].ref = ++ref; + frm.pse[frm.pse_tos].in_preproc = (pc->flags & PCF_IN_PREPROC) != 0; + } +} + + +/** + * Removes the top entry + * + * @param frm The parse frame + * @param pc The chunk causing the push + */ +static void indent_pse_pop(struct parse_frame& frm, chunk_t *pc) +{ + /* Bump up the index and initialize it */ + if (frm.pse_tos > 0) + { + if (pc != NULL) + { + LOG_FMT(LINDPSE, "%4d] CLOSE [%d,%s] on %s, started on line %d, level=%d/%d\n", + pc->orig_line, frm.pse_tos, + get_token_name(frm.pse[frm.pse_tos].type), + get_token_name(pc->type), + frm.pse[frm.pse_tos].open_line, + frm.pse[frm.pse_tos].level, + pc->level); + } + else + { + LOG_FMT(LINDPSE, " EOF] CLOSE [%d,%s], started on line %d\n", + frm.pse_tos, get_token_name(frm.pse[frm.pse_tos].type), + frm.pse[frm.pse_tos].open_line); + } + frm.pse_tos--; + } +} + + +static int token_indent(c_token_t type) +{ + switch (type) + { + case CT_IF: + case CT_DO: + return(3); + + case CT_FOR: + case CT_ELSE: // wacky, but that's what is wanted + return(4); + + case CT_WHILE: + return(6); + + case CT_SWITCH: + return(7); + + case CT_ELSEIF: + return(8); + + default: + return(0); //cpd.settings[UO_indent_braces].n; + } +} + + +/** + * Change the top-level indentation only by changing the column member in + * the chunk structures. + * The level indicator must already be set. + */ +void indent_text(void) +{ + chunk_t *pc; + chunk_t *next; + chunk_t *prev = NULL; + bool did_newline = true; + int idx; + int vardefcol = 0; + int indent_size = cpd.settings[UO_indent_columns].n; + int tmp; + struct parse_frame frm; + bool in_preproc = false, was_preproc = false; + int indent_column; + int cout_col = 0; // for aligning << stuff + int cout_level = 0; // for aligning << stuff + int parent_token_indent = 0; + + memset(&frm, 0, sizeof(frm)); + + /* dummy top-level entry */ + frm.pse[0].indent = 1; + frm.pse[0].indent_tmp = 1; + frm.pse[0].type = CT_EOF; + + pc = chunk_get_head(); + while (pc != NULL) + { + /* Handle proprocessor transitions */ + was_preproc = in_preproc; + in_preproc = (pc->flags & PCF_IN_PREPROC) != 0; + + if (cpd.settings[UO_indent_brace_parent].b) + { + parent_token_indent = token_indent(pc->parent_type); + } + + /* Clean up after a #define */ + if (!in_preproc) + { + while ((frm.pse_tos > 0) && frm.pse[frm.pse_tos].in_preproc) + { + indent_pse_pop(frm, pc); + } + } + else + { + pf_check(&frm, pc); + + if (!was_preproc) + { + /* Transition into a preproc by creating a dummy indent */ + frm.level++; + indent_pse_push(frm, pc); + + frm.pse[frm.pse_tos].indent = 1 + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + } + } + + if ((cout_col > 0) && + (chunk_is_semicolon(pc) || + (pc->level < cout_level))) + { + cout_col = 0; + cout_level = 0; + } + + /** + * Handle non-brace closures + */ + + int old_pse_tos; + do + { + old_pse_tos = frm.pse_tos; + + /* End anything that drops a level + * REVISIT: not sure about the preproc check + */ + if (!chunk_is_newline(pc) && + !chunk_is_comment(pc) && + ((pc->flags & PCF_IN_PREPROC) == 0) && + (frm.pse[frm.pse_tos].level > pc->level)) + { + indent_pse_pop(frm, pc); + } + + if (frm.pse[frm.pse_tos].level == pc->level) + { + /* process virtual braces closes (no text output) */ + if ((pc->type == CT_VBRACE_CLOSE) && + (frm.pse[frm.pse_tos].type == CT_VBRACE_OPEN)) + { + indent_pse_pop(frm, pc); + frm.level--; + pc = chunk_get_next(pc); + } + + /* End any assign operations with a semicolon on the same level */ + if ((frm.pse[frm.pse_tos].type == CT_ASSIGN) && + (chunk_is_semicolon(pc) || + (pc->type == CT_COMMA) || + (pc->type == CT_BRACE_OPEN))) + { + indent_pse_pop(frm, pc); + } + + /* End any CPP class colon crap */ + if ((frm.pse[frm.pse_tos].type == CT_CLASS_COLON) && + ((pc->type == CT_BRACE_OPEN) || + chunk_is_semicolon(pc))) + { + indent_pse_pop(frm, pc); + } + + /* a case is ended with another case or a close brace */ + if ((frm.pse[frm.pse_tos].type == CT_CASE) && + ((pc->type == CT_BRACE_CLOSE) || + (pc->type == CT_CASE))) + { + indent_pse_pop(frm, pc); + } + + /* a return is ended with a semicolon */ + if ((frm.pse[frm.pse_tos].type == CT_RETURN) && + chunk_is_semicolon(pc)) + { + indent_pse_pop(frm, pc); + } + + /* Close out parens and squares */ + if ((frm.pse[frm.pse_tos].type == (pc->type - 1)) && + ((pc->type == CT_PAREN_CLOSE) || + (pc->type == CT_SPAREN_CLOSE) || + (pc->type == CT_FPAREN_CLOSE) || + (pc->type == CT_SQUARE_CLOSE) || + (pc->type == CT_ANGLE_CLOSE))) + { + indent_pse_pop(frm, pc); + frm.paren_count--; + } + } + } while (old_pse_tos > frm.pse_tos); + + /* Grab a copy of the current indent */ + indent_column = frm.pse[frm.pse_tos].indent_tmp; + + if (!chunk_is_newline(pc) && !chunk_is_comment(pc)) + { + LOG_FMT(LINDPC, " -=[ %.*s ]=- top=%d %s %d/%d\n", + pc->len, pc->str, + frm.pse_tos, + get_token_name(frm.pse[frm.pse_tos].type), + frm.pse[frm.pse_tos].indent_tmp, + frm.pse[frm.pse_tos].indent); + } + + /** + * Handle stuff that can affect the current indent: + * - brace close + * - vbrace open + * - brace open + * - case (immediate) + * - labels (immediate) + * - class colons (immediate) + * + * And some stuff that can't + * - open paren + * - open square + * - assignment + * - return + */ + + if (pc->type == CT_BRACE_CLOSE) + { + if (frm.pse[frm.pse_tos].type == CT_BRACE_OPEN) + { + indent_pse_pop(frm, pc); + frm.level--; + + /* Update the indent_column if needed */ + if (!cpd.settings[UO_indent_braces].b && + (parent_token_indent == 0)) + { + indent_column = frm.pse[frm.pse_tos].indent_tmp; + } + + if ((pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE) || + (pc->parent_type == CT_ELSEIF) || + (pc->parent_type == CT_DO) || + (pc->parent_type == CT_WHILE) || + (pc->parent_type == CT_SWITCH) || + (pc->parent_type == CT_FOR)) + { + indent_column += cpd.settings[UO_indent_brace].n; + } + } + } + else if (pc->type == CT_VBRACE_OPEN) + { + frm.level++; + indent_pse_push(frm, pc); + + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + + /* Always indent on virtual braces */ + indent_column = frm.pse[frm.pse_tos].indent_tmp; + } + else if (pc->type == CT_BRACE_OPEN) + { + frm.level++; + indent_pse_push(frm, pc); + + if (frm.paren_count != 0) + { + /* We are inside ({ ... }) -- indent one tab from the paren */ + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + } + else + { + /* Use the prev indent level + indent_size. */ + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + + /* If this brace is part of a statement, bump it out by indent_brace */ + if ((pc->parent_type == CT_IF) || + (pc->parent_type == CT_ELSE) || + (pc->parent_type == CT_ELSEIF) || + (pc->parent_type == CT_DO) || + (pc->parent_type == CT_WHILE) || + (pc->parent_type == CT_SWITCH) || + (pc->parent_type == CT_FOR)) + { + if (parent_token_indent != 0) + { + frm.pse[frm.pse_tos].indent += parent_token_indent - indent_size; + } + else + { + frm.pse[frm.pse_tos].indent += cpd.settings[UO_indent_brace].n; + indent_column += cpd.settings[UO_indent_brace].n; + } + } + else if (pc->parent_type == CT_CASE) + { + /* The indent_case_brace setting affects the parent CT_CASE */ + frm.pse[frm.pse_tos].indent_tmp += cpd.settings[UO_indent_case_brace].n; + frm.pse[frm.pse_tos].indent += cpd.settings[UO_indent_case_brace].n; + } + else if ((pc->parent_type == CT_CLASS) && !cpd.settings[UO_indent_class].b) + { + frm.pse[frm.pse_tos].indent -= indent_size; + } + else if ((pc->parent_type == CT_NAMESPACE) && !cpd.settings[UO_indent_namespace].b) + { + frm.pse[frm.pse_tos].indent -= indent_size; + } + } + + if ((pc->flags & PCF_DONT_INDENT) != 0) + { + frm.pse[frm.pse_tos].indent = pc->column; + indent_column = pc->column; + } + else + { + /** + * If there isn't a newline between the open brace and the next + * item, just indent to wherever the next token is. + * This covers this sort of stuff: + * { a++; + * b--; }; + */ + next = chunk_get_next_ncnl(pc); + if (!chunk_is_newline_between(pc, next)) + { + frm.pse[frm.pse_tos].indent = next->column; + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.pse[frm.pse_tos].open_line = pc->orig_line; + + /* Update the indent_column if needed */ + if (cpd.settings[UO_indent_braces].n || + (parent_token_indent != 0)) + { + indent_column = frm.pse[frm.pse_tos].indent_tmp; + } + } + } + else if (pc->type == CT_CASE) + { + /* Start a case - indent UO_indent_switch_case from the switch level */ + tmp = frm.pse[frm.pse_tos].indent + cpd.settings[UO_indent_switch_case].n; + + indent_pse_push(frm, pc); + + frm.pse[frm.pse_tos].indent = tmp; + frm.pse[frm.pse_tos].indent_tmp = tmp - indent_size; + + /* Always set on case statements */ + indent_column = frm.pse[frm.pse_tos].indent_tmp; + } + else if (pc->type == CT_LABEL) + { + /* Labels get sent to the left or backed up */ + if (cpd.settings[UO_indent_label].n > 0) + { + indent_column = cpd.settings[UO_indent_label].n; + } + else + { + indent_column = frm.pse[frm.pse_tos].indent + + cpd.settings[UO_indent_label].n; + } + } + else if (pc->type == CT_CLASS_COLON) + { + /* just indent one level */ + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + + indent_column = frm.pse[frm.pse_tos].indent_tmp; + + if (cpd.settings[UO_indent_class_colon].b) + { + prev = chunk_get_prev(pc); + if (chunk_is_newline(prev)) + { + frm.pse[frm.pse_tos].indent += 2; + /* don't change indent of current line */ + } + } + } + else if ((pc->type == CT_PAREN_OPEN) || + (pc->type == CT_SPAREN_OPEN) || + (pc->type == CT_FPAREN_OPEN) || + (pc->type == CT_SQUARE_OPEN) || + (pc->type == CT_ANGLE_OPEN)) + { + /* Open parens and squares - never update indent_column */ + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = pc->column + pc->len; + + if (cpd.settings[UO_indent_func_call_param].b && + (pc->type == CT_FPAREN_OPEN) && + (pc->parent_type == CT_FUNC_CALL)) + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + indent_size; + } + + if ((chunk_is_str(pc, "(", 1) && !cpd.settings[UO_indent_paren_nl].b) || + (chunk_is_str(pc, "[", 1) && !cpd.settings[UO_indent_square_nl].b)) + { + next = chunk_get_next_nc(pc); + if (chunk_is_newline(next)) + { + int sub = 1; + if (frm.pse[frm.pse_tos - 1].type == CT_ASSIGN) + { + sub = 2; + } + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - sub].indent + indent_size; + } + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + frm.paren_count++; + } + else if (pc->type == CT_ASSIGN) + { + /** + * if there is a newline after the '=', just indent one level, + * otherwise align on the '='. + * Never update indent_column. + */ + next = chunk_get_next(pc); + if (next != NULL) + { + indent_pse_push(frm, pc); + if (chunk_is_newline(next)) + { + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent_tmp + indent_size; + } + else + { + frm.pse[frm.pse_tos].indent = pc->column + pc->len + 1; + } + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + } + } + else if (pc->type == CT_RETURN) + { + /* don't count returns inside a () or [] */ + if (pc->level == pc->brace_level) + { + indent_pse_push(frm, pc); + frm.pse[frm.pse_tos].indent = frm.pse[frm.pse_tos - 1].indent + pc->len + 1; + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos - 1].indent; + } + } + else if (chunk_is_str(pc, "<<", 2)) + { + if (cout_col == 0) + { + cout_col = pc->column; + cout_level = pc->level; + } + } + else + { + /* anything else? */ + } + + + /** + * Indent the line if needed + */ + if (did_newline && !chunk_is_newline(pc) && (pc->len != 0)) + { + /** + * Check for special continuations. + * Note that some of these could be done as a stack item like + * everything else + */ + + prev = chunk_get_prev_ncnl(pc); + if ((pc->type == CT_MEMBER) || + (pc->type == CT_DC_MEMBER) || + ((prev != NULL) && + ((prev->type == CT_MEMBER) || + (prev->type == CT_DC_MEMBER)))) + { + tmp = cpd.settings[UO_indent_member].n + indent_column; + LOG_FMT(LINDENT, "%s: %d] member => %d\n", + __func__, pc->orig_line, tmp); + reindent_line(pc, tmp); + } + else if (chunk_is_str(pc, "<<", 2) && (cout_col > 0)) + { + LOG_FMT(LINDENT, "%s: %d] cout_col => %d\n", + __func__, pc->orig_line, cout_col); + reindent_line(pc, cout_col); + } + else if ((vardefcol > 0) && + (pc->type == CT_WORD) && + ((pc->flags & PCF_VAR_DEF) != 0) && + (prev != NULL) && (prev->type == CT_COMMA)) + { + LOG_FMT(LINDENT, "%s: %d] Vardefcol => %d\n", + __func__, pc->orig_line, vardefcol); + reindent_line(pc, vardefcol); + } + else if ((pc->type == CT_STRING) && (prev->type == CT_STRING) && + cpd.settings[UO_indent_align_string].b) + { + LOG_FMT(LINDENT, "%s: %d] String => %d\n", + __func__, pc->orig_line, prev->column); + reindent_line(pc, prev->column); + } + else if (chunk_is_comment(pc)) + { + LOG_FMT(LINDENT, "%s: %d] comment => %d\n", + __func__, pc->orig_line, frm.pse[frm.pse_tos].indent_tmp); + indent_comment(pc, frm.pse[frm.pse_tos].indent_tmp); + } + else if (pc->type == CT_PREPROC) + { + /* Preprocs are always in column 1. See indent_preproc() */ + if (pc->column != 1) + { + reindent_line(pc, 1); + } + } + else + { + if (pc->column != indent_column) + { + LOG_FMT(LINDENT, "%s: %d] indent => %d [%.*s]\n", + __func__, pc->orig_line, indent_column, pc->len, pc->str); + reindent_line(pc, indent_column); + } + } + did_newline = false; + } + + /** + * Handle variable definition continuation indenting + */ + if ((pc->type == CT_WORD) && + ((pc->flags & PCF_IN_FCN_DEF) == 0) && + ((pc->flags & PCF_VAR_1ST_DEF) == PCF_VAR_1ST_DEF)) + { + vardefcol = pc->column; + } + if (chunk_is_semicolon(pc) || + ((pc->type == CT_BRACE_OPEN) && (pc->parent_type == CT_FUNCTION))) + { + vardefcol = 0; + } + + /* if we hit a newline, reset indent_tmp */ + if (chunk_is_newline(pc) || + (pc->type == CT_COMMENT_MULTI) || + (pc->type == CT_COMMENT_CPP)) + { + frm.pse[frm.pse_tos].indent_tmp = frm.pse[frm.pse_tos].indent; + + /** + * Handle the case of a multi-line #define w/o anything on the + * first line (indent_tmp will be 1 or 0) + */ + if ((pc->type == CT_NL_CONT) && + (frm.pse[frm.pse_tos].indent_tmp <= indent_size)) + { + frm.pse[frm.pse_tos].indent_tmp = indent_size + 1; + } + + /* Get ready to indent the next item */ + did_newline = true; + } + + if (!chunk_is_comment(pc) && !chunk_is_newline(pc)) + { + prev = pc; + } + pc = chunk_get_next(pc); + } + + /* Throw out any stuff inside a preprocessor - no need to warn */ + while ((frm.pse_tos > 0) && frm.pse[frm.pse_tos].in_preproc) + { + indent_pse_pop(frm, pc); + } + + for (idx = 1; idx <= frm.pse_tos; idx++) + { + LOG_FMT(LWARN, "%s:%d Unmatched %s\n", + cpd.filename, frm.pse[idx].open_line, + get_token_name(frm.pse[idx].type)); + cpd.error_count++; + } +} + +/** + * returns true if forward scan reveals only single newlines or comments + * stops when hits code + * false if next thing hit is a closing brace, also if 2 newlines in a row + */ + + +static bool single_line_comment_indent_rule_applies(chunk_t *start) +{ + chunk_t *pc = start; + int nl_count = 0; + if (!chunk_is_single_line_comment(pc)) + { + return(false); + } + /* scan forward, if only single newlines and comments before next line of code, we want to apply */ + while ((pc = chunk_get_next(pc)) != NULL) + { + if (chunk_is_newline(pc)) + { + if (nl_count > 0 || pc->nl_count > 1) + { + return(false); + } + + nl_count++; + } + else + { + nl_count = 0; + if (!chunk_is_single_line_comment(pc)) + { + /* here we check for things to run into that we wouldn't want to indent the comment for */ + /* for example, non-single line comment, closing brace */ + if (chunk_is_comment(pc) || chunk_is_closing_brace(pc)) + { + return(false); + } + + return(true); + } + } + } + + return(false); +} + +/** + * REVISIT: This needs to be re-checked, maybe cleaned up + * + * Indents comments in a (hopefully) smart manner. + * + * There are two type of comments that get indented: + * - stand alone (ie, no tokens on the line before the comment) + * - trailing comments (last token on the line apart from a linefeed) + * + note that a stand-alone comment is a special case of a trailing + * + * The stand alone comments will get indented in one of three ways: + * - column 1: + * + There is an empty line before the comment AND the indent level is 0 + * + The comment was originally in column 1 + * + * - Same column as trailing comment on previous line (ie, aligned) + * + if originally within TBD (3) columns of the previous comment + * + * - syntax indent level + * + doesn't fit in the previous categories + * + * Options modify this behavior: + * - keep original column (don't move the comment, if possible) + * - keep relative column (move out the same amount as first item on line) + * - fix trailing comment in column TBD + * + * @param pc The comment, which is the first item on a line + * @param col The column if this is to be put at indent level + */ +static void indent_comment(chunk_t *pc, int col) +{ + chunk_t *nl; + chunk_t *prev; + + LOG_FMT(LCMTIND, "%s: line %d, col %d, level %d: ", __func__, + pc->orig_line, pc->orig_col, pc->level); + + /* force column 1 comment to column 1 if not changing them */ + if ((pc->orig_col == 1) && !cpd.settings[UO_indent_col1_comment].b) + { + LOG_FMT(LCMTIND, "rule 1 - keep in col 1\n"); + pc->column = 1; + return; + } + + nl = chunk_get_prev(pc); + + /* outside of any expression or statement? */ + if (pc->level == 0) + { + if ((nl != NULL) && (nl->nl_count > 1)) + { + LOG_FMT(LCMTIND, "rule 2 - level 0, nl before\n"); + pc->column = 1; + return; + } + } + + prev = chunk_get_prev(nl); + if (chunk_is_comment(prev) && (nl->nl_count == 1)) + { + int coldiff = prev->orig_col - pc->orig_col; + + if ((coldiff <= 3) && (coldiff >= -3)) + { + pc->column = prev->column; + LOG_FMT(LCMTIND, "rule 3 - prev comment, coldiff = %d, now in %d\n", + coldiff, pc->column); + return; + } + } + /* check if special single line comment rule applies */ + if (cpd.settings[UO_indent_sing_line_comments].n > 0 && single_line_comment_indent_rule_applies(pc)) + { + pc->column = col + cpd.settings[UO_indent_sing_line_comments].n; + LOG_FMT(LCMTIND, "rule 4 - single line comment indent, now in %d\n", pc->column); + return; + } + LOG_FMT(LCMTIND, "rule 5 - fall-through, stay in %d\n", col); + + pc->column = col; +} + + +/** + * Put spaces on either side of the preproc (#) symbol. + * This is done by pointing pc->str into pp_str and adjusting the + * length. + */ +void indent_preproc(void) +{ + chunk_t *pc; + chunk_t *next; + int pp_level; + int pp_level_sub = 0; + int tmp; + + /* Define a string of 16 spaces + # + 16 spaces */ + static const char *pp_str = " # "; + static const char *alt_str = " %: "; + + /* Scan to see if the whole file is covered by one #ifdef */ + int stage = 0; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (chunk_is_comment(pc) || chunk_is_newline(pc)) + { + continue; + } + + if (stage == 0) + { + /* Check the first PP, make sure it is an #if type */ + if (pc->type != CT_PREPROC) + { + break; + } + next = chunk_get_next(pc); + if ((next == NULL) || (next->type != CT_PP_IF)) + { + break; + } + stage = 1; + } + else if (stage == 1) + { + /* Scan until a PP at level 0 is found - the close to the #if */ + if ((pc->type == CT_PREPROC) && + (pc->pp_level == 0)) + { + stage = 2; + } + continue; + } + else if (stage == 2) + { + /* We should only see the rest of the preprocessor */ + if ((pc->type == CT_PREPROC) || + ((pc->flags & PCF_IN_PREPROC) == 0)) + { + stage = 0; + break; + } + } + } + + if (stage == 2) + { + LOG_FMT(LINFO, "The whole file is covered by a #IF\n"); + pp_level_sub = 1; + } + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type != CT_PREPROC) + { + continue; + } + + if (pc->column != 1) + { + /* Don't handle preprocessors that aren't in column 1 */ + LOG_FMT(LINFO, "%s: Line %d doesn't start in column 1 (%d)\n", + __func__, pc->orig_line, pc->column); + continue; + } + + /* point into pp_str */ + if (pc->len == 2) + { + /* alternate token crap */ + pc->str = &alt_str[16]; + } + else + { + pc->str = &pp_str[16]; + } + + pp_level = pc->pp_level - pp_level_sub; + if (pp_level < 0) + { + pp_level = 0; + } + else if (pp_level > 16) + { + pp_level = 16; + } + + /* Note that the indent is removed by default */ + if ((cpd.settings[UO_pp_indent].a & AV_ADD) != 0) + { + /* Need to add some spaces */ + pc->str -= pp_level; + pc->len += pp_level; + } + else if (cpd.settings[UO_pp_indent].a == AV_IGNORE) + { + tmp = (pc->orig_col <= 16) ? pc->orig_col - 1 : 16; + pc->str -= tmp; + pc->len += tmp; + } + + /* Add spacing by adjusting the length */ + if ((cpd.settings[UO_pp_space].a & AV_ADD) != 0) + { + pc->len += pp_level; + } + + next = chunk_get_next(pc); + if (next != NULL) + { + reindent_line(next, pc->len + 1); + } + + LOG_FMT(LPPIS, "%s: Indent line %d to %d (len %d, next->col %d)\n", + __func__, pc->orig_line, pp_level, pc->len, next->column); + } +} diff --git a/tests/input/c/kw_subst.c b/tests/input/c/kw_subst.c new file mode 100644 index 0000000000..5d37f823f4 --- /dev/null +++ b/tests/input/c/kw_subst.c @@ -0,0 +1,22 @@ +#include + +int foo1() +{ +} + +/** header comment */ +#if 2 +int foo2(void) +{ +} +#endif + +#if 1 +void foo3(int a) +{ +} +#endif + +void *foo4(int a, int b, int c) +{ +} diff --git a/tests/input/c/mac.c b/tests/input/c/mac.c new file mode 100644 index 0000000000..ce4e793786 --- /dev/null +++ b/tests/input/c/mac.c @@ -0,0 +1 @@ +/** * This is your typical header comment */ int foo(int bar) { int idx; int res = 0; // trailing comment // that spans two lines for (idx = 1; idx < bar; idx++) /* comment in virtual braces */ res += idx; res *= idx; // some comment // almost continued, but a NL in between // col1 comment in level 1 return(res); } // col1 comment in level 0 \ No newline at end of file diff --git a/tests/input/c/minus-minus.c b/tests/input/c/minus-minus.c new file mode 100644 index 0000000000..4eb6923738 --- /dev/null +++ b/tests/input/c/minus-minus.c @@ -0,0 +1,33 @@ +int a = 5; +int *b = &a; +int negneg(void) +{ + return - -a; +} + +int pospos(void) +{ + return + +a; +} + +int negpos(void) +{ + return - +a; +} + +int posneg(void) +{ + return + -a; +} + +#if VERSION < -5 +int negnegneg(void) +{ + return - - -a; +} +#else +int negat(void) +{ + return - *b; +} +#endif diff --git a/tests/input/c/misc.c b/tests/input/c/misc.c new file mode 100644 index 0000000000..cd948007cd --- /dev/null +++ b/tests/input/c/misc.c @@ -0,0 +1,32 @@ +/********************/ +/* Before Unrustify */ +/********************/ + +#define MACRO( cond, action ) if ((cond)) (action) + +void hurz(murks) +{ + if (murks = 4) // This comment belongs to (murks = 4) + schrott(); // And this to schrott() +#ifdef SCHNIEPEL + else if (murks = 6) // This comment belongs to (murks = 6) + // I had to write more comment than one line + // so I inserted some comment only blocks + schniepel(); +#endif // SCHNIEPEL + else + flursen(); + + if (murks = 4) // This comment belongs to (murks = 4) +#ifdef FOO + foo(); +#else + bar(); +#endif + if (murks = 4) // This comment belongs to (murks = 4) + { + schrott(); // And this to schrott() + } + return; +} // hurz() + diff --git a/tests/input/c/mod-paren.c b/tests/input/c/mod-paren.c new file mode 100644 index 0000000000..600f823b68 --- /dev/null +++ b/tests/input/c/mod-paren.c @@ -0,0 +1,58 @@ + +int foo(int a, int b) +{ +if ( ! (a || b) ) +{ +return (1); +} +return 0; +} + +void fooo() +{ +if(enabled) value = 1; + +if(enabled && value==100) +{ +} + +if(value==100) +{ +} + +if(value==100 && i<15 || enabled) +{ +} + +if(!failed && (value==100 && i<15) || enabled) +{ +} + +} + +void foo3() +{ + if (strcmp(a, b) == 0 && total < 5) + { + add_item(a); + } + + if (glob_add_path(gd, gd->dir, NULL, + (flags & GLOB_MARK) && S_ISDIR(gd->st.st_mode)) != 0) + { + bar(); + } + return ; +} + +int foo1(void) +{ + FOO_ERROR("connect: can only connected from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN); +return ERR_OK; +} + +int foo2(void) +{ + +return (-1); +} diff --git a/tests/input/c/mod_case_brace.c b/tests/input/c/mod_case_brace.c new file mode 100644 index 0000000000..4bd9abde6b --- /dev/null +++ b/tests/input/c/mod_case_brace.c @@ -0,0 +1,57 @@ +int foo(int bar) +{ + switch (bar) + { + case 0: { + showit(0); + } +c++; + break; + + case 1: { + showit(bar); + break; + } + + case 2: + break; + + case 3: { + int a = bar * 3; + showit(a); + } +c++; + break; + case 4: + foo(bar - 1); + { + showit(0); + } + case 10: + switch (gl_bug) + { + case 'a': { + gl_foo = true; + break; + } + + case 'b': + case 'c': { + gl_foo = false; + break; + } + default: + { + // nothing + } + break; + } + break; + + default: + { + } + break; + } +return(-1); +} diff --git a/tests/input/c/multi.h b/tests/input/c/multi.h new file mode 100644 index 0000000000..33acea3440 --- /dev/null +++ b/tests/input/c/multi.h @@ -0,0 +1,12 @@ +/* +This is a multiline +comment that should +not be indented +*/ +{ + /* + No trailing spaces + + in this comment + */ +} diff --git a/tests/input/c/newline_after_endif.c b/tests/input/c/newline_after_endif.c new file mode 100644 index 0000000000..2a0cbe62f8 --- /dev/null +++ b/tests/input/c/newline_after_endif.c @@ -0,0 +1,53 @@ +int main +( +) +{ + #ifdef useJPLvelocity + for(i = 0; i < x; i++) + y++; + #endif + + return (0); +} /* main */ + +int main +( +) +{ + if(y < 3) + y++; + + #ifdef ABC + if(y < 3) + y++ // comment + #endif + + if(y < 3) + y++; + + y++; + + return (0); +} /* main */ + +int main +( +) +{ + #ifdef ABC + if(j < y) + { + if(j < x) + { + j++; + #ifdef XYZ + if(j < x) + j++; + #endif + } + } + #endif + + return (0); +} /* main */ + diff --git a/tests/input/c/nl-comment.c b/tests/input/c/nl-comment.c new file mode 100644 index 0000000000..6e45b39446 --- /dev/null +++ b/tests/input/c/nl-comment.c @@ -0,0 +1,32 @@ +namespace foo { +/** + * This is your typical header comment + */ + int foo(int bar) + { + int idx; + int res = 0; // trailing comment + // that spans two lines + /* multi-line comment + */ + idx = 50; + /* single line comment */ + for (idx = 1; idx < bar; idx++) + /* comment in virtual braces */ + res += idx; + + res *= idx; // some comment + + // almost continued, but a NL in between + + i++; +// col1 comment in level 1 +// second comment + return(res); +} + + // col1 comment in level 0 + // and another + + } + diff --git a/tests/input/c/nl-cont.c b/tests/input/c/nl-cont.c new file mode 100644 index 0000000000..7061bf41f9 --- /dev/null +++ b/tests/input/c/nl-cont.c @@ -0,0 +1,16 @@ + +#define FOO(bar) create_a_really_long_identifier name(some_function(bar1 + bar2), bar3, bar4); + +#define multilinemacro do { (x+5); } while (0); \ +printf("a multilinemacro"); \ +printf("a multilinemacro2"); + +int main(int argc, char *argv[]) +{ + int a, b; +a = 1; // stupid comment \\ +b = 2; + +return(a+b); +} + diff --git a/tests/input/c/nl-cont2.c b/tests/input/c/nl-cont2.c new file mode 100644 index 0000000000..b3f079e331 --- /dev/null +++ b/tests/input/c/nl-cont2.c @@ -0,0 +1,16 @@ + +#define FOO(bar) create_a_really_long_identifier name(some_function(bar1 + bar2), bar3, bar4); + +#define multilinemacro do { (x+5); } while (0); \ +printf("a multilinemacro"); \ +printf("a multilinemacro2"); + +int main(int argc, char *argv[]) +{ + int a, b; +a = 1; // stupid comment \ +b = 2; + +return(a+b); +} + diff --git a/tests/input/c/nl-semicolon.c b/tests/input/c/nl-semicolon.c new file mode 100644 index 0000000000..8e0f59d388 --- /dev/null +++ b/tests/input/c/nl-semicolon.c @@ -0,0 +1,21 @@ +void foo(void) +{ + a = 5; b = 3; j = 6; + + for (a = 0; a < j; a++) + { + b *= (a + b); + } +} + +struct somestruct { int a; char b; foo c; bar *d; }; + +struct foo { int a; char *b }; + +void f() +{ +for (;;) +nothing(); +foobar(); +} +; diff --git a/tests/input/c/nl-ver-def.c b/tests/input/c/nl-ver-def.c new file mode 100644 index 0000000000..9684ed2745 --- /dev/null +++ b/tests/input/c/nl-ver-def.c @@ -0,0 +1,9 @@ +void foo(void) +{ + int a; + int b;// comment + + /* comment */ + a = b; + return; +} diff --git a/tests/input/c/nl_assign.c b/tests/input/c/nl_assign.c new file mode 100644 index 0000000000..b2495c1394 --- /dev/null +++ b/tests/input/c/nl_assign.c @@ -0,0 +1,19 @@ + +void foo() +{ + some.really_long.variable_name + = another.big.one[55] + + something_else; + + some.really_long.variable_name = + another.big.one[55] + + something_else; + + some.really_long.variable_name = another.big.one[55] + + something_else; + + a_really_long_assignment_to_test = line_breaks_around_assign_and_arith; + + a_really_long_assignment_to_test = line_breaks_around + assign_and_arith; + +} diff --git a/tests/input/c/nl_create_one_liner.c b/tests/input/c/nl_create_one_liner.c new file mode 100644 index 0000000000..16887eca54 --- /dev/null +++ b/tests/input/c/nl_create_one_liner.c @@ -0,0 +1,17 @@ +void foo() +{ +if (a) + b++; +if (a) { + b++; +} +if (a) + if (b) + c++; + +for (i=0;i<5;i++) + bar(i); +while (i>0) +bar(--i); + +} diff --git a/tests/input/c/nl_ds_struct_enum.c b/tests/input/c/nl_ds_struct_enum.c new file mode 100644 index 0000000000..d19964ae2b --- /dev/null +++ b/tests/input/c/nl_ds_struct_enum.c @@ -0,0 +1,21 @@ +struct foo { + unsigned int d_ino; + /* Comment */ + unsigned short d_reclen; + unsigned short d_namlen; + /* Comment */ + char d_name[1]; +}; + +struct foo +{ + /* Comment */ + unsigned int d_ino; + unsigned short d_reclen; + unsigned short d_namlen; + /* Comment */ + char d_name[1]; +}; + +struct foo { int a; char *b }; + diff --git a/tests/input/c/nl_endif.c b/tests/input/c/nl_endif.c new file mode 100644 index 0000000000..d738d74a43 --- /dev/null +++ b/tests/input/c/nl_endif.c @@ -0,0 +1,13 @@ +int main +( +) +{ + #ifdef useJPLvelocity + + for(i = 0; i < x; i++) + y++; + #endif + + return (0); +} /* main */ + diff --git a/tests/input/c/nl_proto_endif.c b/tests/input/c/nl_proto_endif.c new file mode 100644 index 0000000000..f50766b89c --- /dev/null +++ b/tests/input/c/nl_proto_endif.c @@ -0,0 +1,10 @@ + +#include + +static void status_cb(status_t *status); +static int add_conn(const char *path); + +#ifdef USE_FOO_CMD +static void foo_cmd(void *user, const info_t *info); +#endif + diff --git a/tests/input/c/nl_return_expr.c b/tests/input/c/nl_return_expr.c new file mode 100644 index 0000000000..425a677a84 --- /dev/null +++ b/tests/input/c/nl_return_expr.c @@ -0,0 +1,23 @@ + +int foo1(void) +{ + return NewClass(1); +} + +int foo2(void) +{ + return + NewClass(2); +} + +int foo3(void) +{ + return(3); +} + +int foo4(void) +{ + return + (4); +} + diff --git a/tests/input/c/one-liner-init.c b/tests/input/c/one-liner-init.c new file mode 100644 index 0000000000..4702fff963 --- /dev/null +++ b/tests/input/c/one-liner-init.c @@ -0,0 +1,16 @@ + +enum boo { FOO = 1 }; + +void foo(void) +{ + char str[123] = { 0 }; + + enum hoo { NOO = 1 }; + + strcat(str, "foo"); +} + +void f(){if(bar())baz(1);else baz(2);} + +int foo() { return 0; } + diff --git a/tests/input/c/output.cpp b/tests/input/c/output.cpp new file mode 100644 index 0000000000..4563c43b71 --- /dev/null +++ b/tests/input/c/output.cpp @@ -0,0 +1,657 @@ +/** + * @file output.cpp + * Does all the output & comment formatting. + * + * $Id: output.cpp 510 2006-09-20 01:14:56Z bengardner $ + */ + +#include "uncrustify_types.h" +#include "prototypes.h" +#include "chunk_list.h" +#include +#include + + + +void add_char(char ch) +{ + /* convert a newline into the LF/CRLF/CR sequence */ + if (ch == '\n') + { + fputs(cpd.newline, cpd.fout); + cpd.column = 1; + cpd.did_newline = 1; + } + else + { + fputc(ch, cpd.fout); + if (ch == '\t') + { + cpd.column = next_tab_column(cpd.column); + } + else + { + cpd.column++; + } + } +} + +void add_text(const char *text) +{ + char ch; + + while ((ch = *text) != 0) + { + text++; + add_char(ch); + } +} + +void add_text_len(const char *text, int len) +{ + while (len-- > 0) + { + add_char(*text); + text++; + } +} + + +/** + * Advance to a specific column + * cpd.column is the current column + * + * @param column The column to advance to + */ +void output_to_column(int column, bool allow_tabs) +{ + int nc; + + cpd.did_newline = 0; + if (allow_tabs) + { + /* tab out as far as possible and then use spaces */ + while ((nc = next_tab_column(cpd.column)) <= column) + { + add_text("\t"); + } + } + /* space out the final bit */ + while (cpd.column < column) + { + add_text(" "); + } +} + +void output_indent(int column, int brace_col) +{ + if ((cpd.column == 1) && (cpd.settings[UO_indent_with_tabs].n != 0)) + { + if (cpd.settings[UO_indent_with_tabs].n == 2) + { + brace_col = column; + } + + /* tab out as far as possible and then use spaces */ + int nc; + while ((nc = next_tab_column(cpd.column)) <= brace_col) + { + add_text("\t"); + } + } + + /* space out the rest */ + while (cpd.column < column) + { + add_text(" "); + } +} + + + +void output_parsed(FILE *pfile) +{ + chunk_t *pc; + int cnt; + + output_options(pfile); + output_defines(pfile); + output_types(pfile); + + fprintf(pfile, "-=====-\n"); + fprintf(pfile, "Line Tag Parent Columns Br/Lvl/pp Flg Nl Text"); + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + fprintf(pfile, "\n%3d> %13.13s[%13.13s][%2d/%2d/%2d][%d/%d/%d][%6x][%d-%d]", + pc->orig_line, get_token_name(pc->type), + get_token_name(pc->parent_type), + pc->column, pc->orig_col, pc->orig_col_end, + pc->brace_level, pc->level, pc->pp_level, + pc->flags, pc->nl_count, pc->after_tab); + + if ((pc->type != CT_NEWLINE) && (pc->len != 0)) + { + for (cnt = 0; cnt < pc->column; cnt++) + { + fprintf(pfile, " "); + } + fprintf(pfile, "%.*s", pc->len, pc->str); + } + } + fprintf(pfile, "\n-=====-\n"); + fflush(pfile); +} + +void output_options(FILE *pfile) +{ + int idx; + const option_map_value *ptr; + + fprintf(pfile, "-== Options ==-\n"); + for (idx = 0; idx < UO_option_count; idx++) + { + ptr = get_option_name(idx); + if (ptr != NULL) + { + if (ptr->type == AT_BOOL) + { + fprintf(pfile, "%3d) %32s = %s\n", + ptr->id, ptr->name, + cpd.settings[ptr->id].b ? "True" : "False"); + } + else if (ptr->type == AT_IARF) + { + fprintf(pfile, "%3d) %32s = %s\n", + ptr->id, ptr->name, + (cpd.settings[ptr->id].a == AV_ADD) ? "Add" : + (cpd.settings[ptr->id].a == AV_REMOVE) ? "Remove" : + (cpd.settings[ptr->id].a == AV_FORCE) ? "Force" : "Ignore"); + } + else if (ptr->type == AT_LINE) + { + fprintf(pfile, "%3d) %32s = %s\n", + ptr->id, ptr->name, + (cpd.settings[ptr->id].le == LE_AUTO) ? "Auto" : + (cpd.settings[ptr->id].le == LE_LF) ? "LF" : + (cpd.settings[ptr->id].le == LE_CRLF) ? "CRLF" : + (cpd.settings[ptr->id].le == LE_CR) ? "CR" : "???"); + } + else /* AT_NUM */ + { + fprintf(pfile, "%3d) %32s = %d\n", + ptr->id, ptr->name, cpd.settings[ptr->id].n); + } + } + } +} + +/** + * This renders the chunk list to a file. + */ +void output_text(FILE *pfile) +{ + chunk_t *pc; + chunk_t *prev; + int cnt; + int lvlcol; + bool allow_tabs; + + cpd.fout = pfile; + + for (pc = chunk_get_head(); pc != NULL; pc = chunk_get_next(pc)) + { + if (pc->type == CT_NEWLINE) + { + for (cnt = 0; cnt < pc->nl_count; cnt++) + { + add_char('\n'); + } + cpd.did_newline = 1; + cpd.column = 1; + LOG_FMT(LOUTIND, " xx\n"); + } + else if (pc->type == CT_COMMENT_MULTI) + { + output_comment_multi(pc); + } + else if (pc->type == CT_COMMENT_CPP) + { + pc = output_comment_cpp(pc); + } + else if (pc->len == 0) + { + /* don't do anything for non-visible stuff */ + LOG_FMT(LOUTIND, " <%d> -", pc->column); + } + else + { + /* indent to the 'level' first */ + if (cpd.did_newline) + { + if (cpd.settings[UO_indent_with_tabs].n == 1) + { + lvlcol = 1 + (pc->brace_level * cpd.settings[UO_indent_columns].n); + if ((pc->column >= lvlcol) && (lvlcol > 1)) + { + output_to_column(lvlcol, true); + } + } + allow_tabs = (cpd.settings[UO_indent_with_tabs].n == 2) || + (chunk_is_comment(pc) && + (cpd.settings[UO_indent_with_tabs].n != 0)); + + LOG_FMT(LOUTIND, " %d> col %d/%d - ", pc->orig_line, pc->column, cpd.column); + } + else + { + /* not the first item on a line */ + if (cpd.settings[UO_align_keep_tabs].b) + { + allow_tabs = pc->after_tab; + } + else + { + prev = chunk_get_prev(pc); + allow_tabs = (cpd.settings[UO_align_with_tabs].b && + ((pc->flags & PCF_WAS_ALIGNED) != 0) && + (((pc->column - 1) % cpd.settings[UO_output_tab_size].n) == 0) && + ((prev->column + prev->len + 1) != pc->column)); + } + LOG_FMT(LOUTIND, " %d -", pc->column); + } + + output_to_column(pc->column, allow_tabs); + add_text_len(pc->str, pc->len); + cpd.did_newline = chunk_is_newline(pc); + } + } +} + + +/** + * Given a multi-line comemnt block that starts in column X, figure out how + * much subsequent lines should be indented. + * + * The answer is either 0 or 1. + * + * The decision is based on: + * - the first line length + * - the second line leader length + * - the last line length + * + * If the first and last line are the same length and don't contain any alnum + * chars and (the first line len > 2 or the second leader is the same as the + * first line length), then the indent is 0. + * + * If the leader on the second line is 1 wide or missing, then the indent is 1. + * + * Otherwise, the indent is 0. + * + * @param str The comment string + * @param len Length of the comment + * @param start_col Starting column + * @return 0 or 1 + */ +static int calculate_comment_body_indent(const char *str, int len, int start_col) +{ + int idx = 0; + int first_len = 0; + int last_len = 0; + int width = 0; + + /* find the last line length */ + for (idx = len - 1; idx > 0; idx--) + { + if ((str[idx] == '\n') || (str[idx] == '\r')) + { + idx++; + while ((idx < len) && ((str[idx] == ' ') || (str[idx] == '\t'))) + { + idx++; + } + last_len = len - idx; + break; + } + } + + /* find the first line length */ + for (idx = 0; idx < len; idx++) + { + if ((str[idx] == '\n') || (str[idx] == '\r')) + { + first_len = idx; + while ((str[first_len - 1] == ' ') || (str[first_len - 1] == '\t')) + { + first_len--; + } + + /* handle DOS endings */ + if ((str[idx] == '\r') && (str[idx + 1] == '\n')) + { + idx++; + } + idx++; + break; + } + } + + /* Scan the second line */ + width = 0; + for ( /* nada */; idx < len; idx++) + { + if ((str[idx] == ' ') || (str[idx] == '\t')) + { + if (width > 0) + { + break; + } + continue; + } + if ((str[idx] == '\n') || (str[idx] == '\r')) + { + /* Done with second line */ + break; + } + + /* Count the leading chars */ + if ((str[idx] == '*') || + (str[idx] == '|') || + (str[idx] == '\\') || + (str[idx] == '#') || + (str[idx] == '+')) + { + width++; + } + else + { + break; + } + } + + //LOG_FMT(LSYS, "%s: first=%d last=%d width=%d\n", __func__, first_len, last_len, width); + + /*TODO: make the first_len minimum (4) configurable? */ + if ((first_len == last_len) && ((first_len > 4) || first_len == width)) + { + return(0); + } + + return((width == 2) ? 0 : 1); +} + +/** + * Outputs the CPP comment at pc. + * CPP comment combining is done here + * + * @return the last chunk output'd + */ +chunk_t *output_comment_cpp(chunk_t *first) +{ + int col = first->column; + int col_br = 1 + (first->brace_level * cpd.settings[UO_indent_columns].n); + + /* Make sure we have at least one space past the last token */ + if (first->parent_type == CT_COMMENT_END) + { + chunk_t *prev = chunk_get_prev(first); + if (prev != NULL) + { + int col_min = prev->column + prev->len + 1; + if (col < col_min) + { + col = col_min; + } + } + } + + /* Bump out to the column */ + output_indent(col, col_br); + + if (!cpd.settings[UO_cmt_cpp_to_c].b) + { + add_text_len(first->str, first->len); + return(first); + } + + /* If we are grouping, see if there is something to group */ + bool combined = false; + if (cpd.settings[UO_cmt_cpp_group].b) + { + /* next is a newline by definition */ + chunk_t *next = chunk_get_next(first); + if ((next != NULL) && (next->nl_count == 1)) + { + next = chunk_get_next(next); + + /** + * Only combine the next comment if they are both at indent level or + * the second one is NOT at indent or less + * + * A trailing comment cannot be combined with a comment at indent + * level or less + */ + if ((next != NULL) && + (next->type == CT_COMMENT_CPP) && + (((next->column == 1) && (first->column == 1)) || + ((next->column == col_br) && (first->column == col_br)) || + ((next->column > col_br) && (first->parent_type == CT_COMMENT_END)))) + { + combined = true; + } + } + } + + if (!combined) + { + /* nothing to group: just output a single line */ + add_text_len("/*", 2); + if ((first->str[2] != ' ') && (first->str[2] != '\t')) + { + add_char(' '); + } + add_text_len(&first->str[2], first->len - 2); + add_text_len(" */", 3); + return(first); + } + + chunk_t *pc = first; + chunk_t *last = first; + + /* Output the first line */ + add_text_len("/*", 2); + if (combined && cpd.settings[UO_cmt_cpp_nl_start].b) + { + /* I suppose someone more clever could do this without a goto or + * repeating too much code... + */ + goto cpp_newline; + } + goto cpp_addline; + + /* Output combined lines */ + while ((pc = chunk_get_next(pc)) != NULL) + { + if ((pc->type == CT_NEWLINE) && (pc->nl_count == 1)) + { + continue; + } + if (pc->type != CT_COMMENT_CPP) + { + break; + } + if (((pc->column == 1) && (first->column == 1)) || + ((pc->column == col_br) && (first->column == col_br)) || + ((pc->column > col_br) && (first->parent_type == CT_COMMENT_END))) + { + last = pc; +cpp_newline: + add_char('\n'); + output_indent(col, col_br); + add_char(' '); + add_char(cpd.settings[UO_cmt_star_cont].b ? '*' : ' '); +cpp_addline: + if ((pc->str[2] != ' ') && (pc->str[2] != '\t')) + { + add_char(' '); + } + add_text_len(&pc->str[2], pc->len - 2); + } + } + + if (cpd.settings[UO_cmt_cpp_nl_end].b) + { + add_char('\n'); + output_indent(col, col_br); + } + add_text_len(" */", 3); + return(last); +} + +void output_comment_multi(chunk_t *pc) +{ + int cmt_col = pc->column; + const char *cmt_str; + int remaining; + char ch; + chunk_t *prev; + char line[1024]; + int line_len; + int line_count = 0; + int ccol; + int col_diff = 0; + int xtra = 1; + + prev = chunk_get_prev(pc); + if ((prev != NULL) && (prev->type != CT_NEWLINE)) + { + cmt_col = pc->orig_col; + } + else + { + col_diff = pc->orig_col - pc->column; + } + + // fprintf(stderr, "Indenting1 line %d to col %d (orig=%d) col_diff=%d\n", + // pc->orig_line, cmt_col, pc->orig_col, col_diff); + + xtra = calculate_comment_body_indent(pc->str, pc->len, pc->column); + + ccol = 1; + remaining = pc->len; + cmt_str = pc->str; + line_len = 0; + while (remaining > 0) + { + ch = *cmt_str; + cmt_str++; + remaining--; + + /* handle the CRLF and CR endings. convert both to LF */ + if (ch == '\r') + { + ch = '\n'; + if (*cmt_str == '\n') + { + cmt_str++; + remaining--; + } + } + + /* Find the start column */ + if (line_len == 0) + { + if (ch == ' ') + { + ccol++; + continue; + } + else if (ch == '\t') + { + ccol = calc_next_tab_column(ccol, cpd.settings[UO_input_tab_size].n); + continue; + } + else + { + //fprintf(stderr, "%d] Text starts in col %d\n", line_count, ccol); + } + } + + line[line_len++] = ch; + + /* If we just hit an end of line OR we just hit end-of-comment... */ + if ((ch == '\n') || (remaining == 0)) + { + line_count++; + + /* strip trailing tabs and spaces before the newline */ + if (ch == '\n') + { + line_len--; + while ((line_len > 0) && + ((line[line_len - 1] == ' ') || + (line[line_len - 1] == '\t'))) + { + line_len--; + } + line[line_len++] = ch; + } + line[line_len] = 0; + + if (line_count == 1) + { + /* this is the first line - add unchanged */ + + /*TODO: need to support indent_with_tabs mode 1 */ + output_to_column(cmt_col, cpd.settings[UO_indent_with_tabs].b); + add_text_len(line, line_len); + } + else + { + /* This is not the first line, so we need to indent to the + * correct column. + */ + ccol -= col_diff; + if (ccol < cmt_col) + { + ccol = cmt_col; + } + + if (line[0] == '\n') + { + /* Emtpy line - just a '\n' */ + if (cpd.settings[UO_cmt_star_cont].b) + { + output_to_column(cmt_col, cpd.settings[UO_indent_with_tabs].b); + add_text((xtra == 1) ? " *" : "*"); + } + add_char('\n'); + } + else + { + /* If this doesn't start with a '*' or '|' */ + if ((line[0] != '*') && (line[0] != '|') && (line[0] != '#') && + (line[0] != '\\') && (line[0] != '+')) + { + output_to_column(cmt_col, cpd.settings[UO_indent_with_tabs].b); + if (cpd.settings[UO_cmt_star_cont].b) + { + add_text((xtra == 1) ? " * " : "* "); + } + else + { + add_text(" "); + } + output_to_column(ccol, cpd.settings[UO_indent_with_tabs].b); + } + else + { + output_to_column(cmt_col + xtra, cpd.settings[UO_indent_with_tabs].b); + } + add_text_len(line, line_len); + } + } + line_len = 0; + ccol = 1; + } + } +} diff --git a/tests/input/c/paren-indent.c b/tests/input/c/paren-indent.c new file mode 100644 index 0000000000..df5b1c14a4 --- /dev/null +++ b/tests/input/c/paren-indent.c @@ -0,0 +1,46 @@ +static void *foo(int param1, + char *param2 + ); + + +static void *foo +( + int param1, + char *param2 +) +{ + for ( + int i = 0; + i< 10; + i++ + ) + { + bar( + arg1, + arg2 + ); + if ( ( abc < bcd ) + &&( 123 < abc ) + ) + { + none(arg1, + arg2, + arg3 + ); + } + } +} + + +void CWarningAnalyzer::SetEffect(int FilterNumber + ,bool Exclude + , int Red + , int Green + , int Blue + , bool Italic + , bool Bold + , bool Underlined + ) +{ + /* TODO */ +} diff --git a/tests/input/c/paren_indent.c b/tests/input/c/paren_indent.c new file mode 100644 index 0000000000..4b0ff44734 --- /dev/null +++ b/tests/input/c/paren_indent.c @@ -0,0 +1,12 @@ +function1 +(something1); + +function2 + (something2); + +x = (float) +(number); + +x = (float) + (number); + diff --git a/tests/input/c/pascal_ptr.c b/tests/input/c/pascal_ptr.c new file mode 100644 index 0000000000..5b0116baf0 --- /dev/null +++ b/tests/input/c/pascal_ptr.c @@ -0,0 +1,13 @@ +foobar_t* a; +int *b; +int * c; +something no; + +char * main() +{ + int i = (5*3)+2; +} + +void foo(int* a, int *b, int * c) +{ +} diff --git a/tests/input/c/pos_compare.c b/tests/input/c/pos_compare.c new file mode 100644 index 0000000000..b0942de058 --- /dev/null +++ b/tests/input/c/pos_compare.c @@ -0,0 +1,11 @@ +void foo(void) +{ + if ((a_really_long_number > + another_really_long_number) + || + (some_really_long_bool + != another_really_long_bool)) + { + foo2(); + } +} diff --git a/tests/input/c/pos_conditional.c b/tests/input/c/pos_conditional.c new file mode 100644 index 0000000000..100545e5c3 --- /dev/null +++ b/tests/input/c/pos_conditional.c @@ -0,0 +1,14 @@ +void foo(void) +{ + // conditional colon + a = bar() ? 2 : + 3; + a = bar() ? 2 + : 3; + + // conditional question + a = bar() ? + 2 : 3; + a = bar() + ? 2 : 3; +} diff --git a/tests/input/c/pp-nest.c b/tests/input/c/pp-nest.c new file mode 100644 index 0000000000..b602471bae --- /dev/null +++ b/tests/input/c/pp-nest.c @@ -0,0 +1,15 @@ +#if AA +int foo() { + #if BB +#else + #if CC + #else + #endif + #endif +} + #endif + +int bar() +{ +} + diff --git a/tests/input/c/pp-space.c b/tests/input/c/pp-space.c new file mode 100644 index 0000000000..67cf3e55e3 --- /dev/null +++ b/tests/input/c/pp-space.c @@ -0,0 +1,30 @@ +/** + * Some file header comment thingy. + */ +#ifndef SOME_H_INCLUDED +#define SOME_H_INCLUDED + +#include "Somefile.h" + +#define SOMEMACRO (1+4) + +#ifdef WIN32 + +#include "windows_compat.h" + +#else /* not WIN32 */ + +#if defined HAVE_STDINT_H +#include +#elif defined HAVE_INTTYPES_H +#include +#define YOUR_OS_SUCKS +#else +#error "Don't know where int8_t is defined" +#endif + +typedef uint32_t UINT32; + +#endif /* ifdef WIN32 */ + +#endif /* SOME_H_INCLUDED */ diff --git a/tests/input/c/pp_concat_asn1.h b/tests/input/c/pp_concat_asn1.h new file mode 100644 index 0000000000..9874cf0493 --- /dev/null +++ b/tests/input/c/pp_concat_asn1.h @@ -0,0 +1,296 @@ +#ifndef HEADER_ASN1_H +#define HEADER_ASN1_H + +#define V_ASN1_UNIVERSAL 0x00 +#define V_ASN1_APPLICATION 0x40 +#define V_ASN1_CONTEXT_SPECIFIC 0x80 +#define V_ASN1_PRIVATE 0xc0 + +#define V_ASN1_CONSTRUCTED 0x20 +#define V_ASN1_PRIMITIVE_TAG 0x1f +#define V_ASN1_PRIMATIVE_TAG 0x1f + +#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ +#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ +#define V_ASN1_ANY -4 /* used in ASN1 template code */ + +#define V_ASN1_NEG 0x100 /* negative flag */ + +#define V_ASN1_UNDEF -1 +#define V_ASN1_EOC 0 +#define V_ASN1_BOOLEAN 1 /**/ +#define V_ASN1_INTEGER 2 +#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) +#define V_ASN1_BIT_STRING 3 +#define V_ASN1_OCTET_STRING 4 +#define V_ASN1_NULL 5 +#define V_ASN1_OBJECT 6 /* object identifier */ +#define V_ASN1_OBJECT_DESCRIPTOR 7 +#define V_ASN1_EXTERNAL 8 /* external / instance of */ +#define V_ASN1_REAL 9 +#define V_ASN1_ENUMERATED 10 +#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) +#define V_ASN1_EMBEDDED_PDV 11 +#define V_ASN1_UTF8STRING 12 +#define V_ASN1_SEQUENCE 16 +#define V_ASN1_SET 17 +#define V_ASN1_NUMERICSTRING 18 /**/ +#define V_ASN1_PRINTABLESTRING 19 +#define V_ASN1_T61STRING 20 +#define V_ASN1_TELETEXSTRING 20 /* alias */ +#define V_ASN1_VIDEOTEXSTRING 21 /**/ +#define V_ASN1_IA5STRING 22 +#define V_ASN1_UTCTIME 23 +#define V_ASN1_GENERALIZEDTIME 24 /**/ +#define V_ASN1_GRAPHICSTRING 25 /**/ +#define V_ASN1_ISO64STRING 26 /**/ +#define V_ASN1_VISIBLESTRING 26 /* alias */ +#define V_ASN1_GENERALSTRING 27 /**/ +#define V_ASN1_UNIVERSALSTRING 28 /**/ +#define V_ASN1_BMPSTRING 30 + +/* For use with d2i_ASN1_type_bytes() */ +#define B_ASN1_NUMERICSTRING 0x0001 +#define B_ASN1_PRINTABLESTRING 0x0002 +#define B_ASN1_T61STRING 0x0004 +#define B_ASN1_TELETEXSTRING 0x0004 +#define B_ASN1_VIDEOTEXSTRING 0x0008 +#define B_ASN1_IA5STRING 0x0010 +#define B_ASN1_GRAPHICSTRING 0x0020 +#define B_ASN1_ISO64STRING 0x0040 +#define B_ASN1_VISIBLESTRING 0x0040 +#define B_ASN1_GENERALSTRING 0x0080 +#define B_ASN1_UNIVERSALSTRING 0x0100 +#define B_ASN1_OCTET_STRING 0x0200 +#define B_ASN1_BIT_STRING 0x0400 +#define B_ASN1_BMPSTRING 0x0800 +#define B_ASN1_UNKNOWN 0x1000 +#define B_ASN1_UTF8STRING 0x2000 +#define B_ASN1_UTCTIME 0x4000 +#define B_ASN1_GENERALIZEDTIME 0x8000 +#define B_ASN1_SEQUENCE 0x10000 + +/* For use with ASN1_mbstring_copy() */ +#define MBSTRING_FLAG 0x1000 +#define MBSTRING_UTF8 (MBSTRING_FLAG) +#define MBSTRING_ASC (MBSTRING_FLAG|1) +#define MBSTRING_BMP (MBSTRING_FLAG|2) +#define MBSTRING_UNIV (MBSTRING_FLAG|4) + +#define SMIME_OLDMIME 0x400 +#define SMIME_CRLFEOL 0x800 +#define SMIME_STREAM 0x1000 + +struct X509_algor_st; +DECLARE_STACK_OF(X509_ALGOR); + +#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */ +#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */ + +/* We MUST make sure that, except for constness, asn1_ctx_st and + asn1_const_ctx are exactly the same. Fortunately, as soon as + the old ASN1 parsing macros are gone, we can throw this away + as well... */ +typedef struct asn1_ctx_st + { + unsigned char *p; /* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + size_t slen; /* length of last 'get object' */ + unsigned char *max; /* largest value of p allowed */ + unsigned char *q;/* temporary variable */ + unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_CTX; + +typedef struct asn1_const_ctx_st + { + const unsigned char *p;/* work char pointer */ + int eos; /* end of sequence read for indefinite encoding */ + int error; /* error code to use when returning an error */ + int inf; /* constructed if 0x20, indefinite is 0x21 */ + int tag; /* tag from last 'get object' */ + int xclass; /* class from last 'get object' */ + size_t slen; /* length of last 'get object' */ + const unsigned char *max; /* largest value of p allowed */ + const unsigned char *q;/* temporary variable */ + const unsigned char **pp;/* variable */ + int line; /* used in error processing */ + } ASN1_const_CTX; + +/* These are used internally in the ASN1_OBJECT to keep track of + * whether the names and data need to be free()ed */ +#define ASN1_OBJECT_FLAG_DYNAMIC 0x01 /* internal use */ +#define ASN1_OBJECT_FLAG_CRITICAL 0x02 /* critical x509v3 object id */ +#define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04 /* internal use */ +#define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08 /* internal use */ +typedef struct asn1_object_st + { + const char *sn,*ln; + int nid; + size_t length; + const unsigned char *data; /* data remains const after init */ + int flags; /* Should we free this one */ + } ASN1_OBJECT; + +#define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */ +/* This indicates that the ASN1_STRING is not a real value but just a place + * holder for the location where indefinite length constructed data should + * be inserted in the memory buffer + */ +#define ASN1_STRING_FLAG_NDEF 0x010 + +/* This flag is used by the CMS code to indicate that a string is not + * complete and is a place holder for content when it had all been + * accessed. The flag will be reset when content has been written to it. + */ + +#define ASN1_STRING_FLAG_CONT 0x020 + +/* This is the base type that holds just about everything :-) */ +typedef struct asn1_string_st + { + size_t length; + int type; + unsigned char *data; + /* The value of the following field depends on the type being + * held. It is mostly being used for BIT_STRING so if the + * input data has a non-zero 'unused bits' value, it will be + * handled correctly */ + long flags; + } ASN1_STRING; + +/* ASN1_ENCODING structure: this is used to save the received + * encoding of an ASN1 type. This is useful to get round + * problems with invalid encodings which can break signatures. + */ + +typedef struct ASN1_ENCODING_st + { + unsigned char *enc; /* DER encoding */ + size_t len; /* Length of encoding */ + int modified; /* set to 1 if 'enc' is invalid */ + } ASN1_ENCODING; + +/* Used with ASN1 LONG type: if a long is set to this it is omitted */ +#define ASN1_LONG_UNDEF 0x7fffffffL + +#define STABLE_FLAGS_MALLOC 0x01 +#define STABLE_NO_MASK 0x02 +#define DIRSTRING_TYPE \ + (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) +#define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) + +/* Declarations for template structures: for full definitions + * see asn1t.h + */ +typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; +typedef struct ASN1_ITEM_st ASN1_ITEM; +typedef struct ASN1_TLC_st ASN1_TLC; +/* This is just an opaque pointer */ +typedef struct ASN1_VALUE_st ASN1_VALUE; + +/* Declare ASN1 functions: the implement macro in in asn1t.h */ + +#define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) + +#define DECLARE_ASN1_FUNCTIONS_name(type, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name); \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) + +#define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name); \ + DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ + type *d2i_##name(type **a, const unsigned char **in, size_t len); \ + int i2d_##name(const type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(itname) + +#define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ + type *d2i_##name(type **a, const unsigned char **in, size_t len); \ + int i2d_##name(const type *a, unsigned char **out); \ + DECLARE_ASN1_ITEM(name) + +#define DECLARE_ASN1_NDEF_FUNCTION(name) \ + int i2d_##name##_NDEF(const name *a, unsigned char **out) + +#define DECLARE_ASN1_FUNCTIONS_const(name) \ + DECLARE_ASN1_ALLOC_FUNCTIONS(name); \ + DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name) + +#define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ + type *name##_new(void); \ + void name##_free(type *a) + +#define DECLARE_ASN1_PRINT_FUNCTION(stname) \ + DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname) + +#define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ + int fname##_print_ctx(BIO *out, const stname *x, int indent, \ + const ASN1_PCTX *pctx) + + +/* + * WARNING WARNING WARNING + * + * uncrustify still introduces whitespace in here at some spots, but then + * one might ask how crazy we want to go regarding ## encumbered parsing? + * There's always the copout of INDENT-OFF markers for files like these, + * once you've got them 95% right through uncrustify and that extra 5% + * by hand ;-) + */ +#define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,size_t) +#define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) +#define TYPEDEF_I2D_OF_CONST(type) typedef int i2d_of_const_##type(const type *,unsigned char **) /* [i_a] */ +#define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type); TYPEDEF_I2D_OF_CONST(type) /* [i_a] */ + + +/* Macro to include ASN1_ITEM pointer from base type */ +#define ASN1_ITEM_ref(iptr) (&(iptr##_it)) + +#define ASN1_ITEM_rptr(ref) (&(ref##_it)) + +#define DECLARE_ASN1_ITEM(name) \ + extern const ASN1_ITEM name##_it; + + +#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER) + +DECLARE_STACK_OF(ASN1_INTEGER); +DECLARE_ASN1_SET_OF(ASN1_INTEGER); + +DECLARE_STACK_OF(ASN1_GENERALSTRING); + +typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; + +DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY); +DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY); + + +#define B_ASN1_DIRECTORYSTRING \ + B_ASN1_PRINTABLESTRING| \ + B_ASN1_TELETEXSTRING|\ + B_ASN1_BMPSTRING|\ + B_ASN1_UNIVERSALSTRING|\ + B_ASN1_UTF8STRING + +#define B_ASN1_DISPLAYTEXT \ + B_ASN1_IA5STRING| \ + B_ASN1_VISIBLESTRING| \ + B_ASN1_BMPSTRING|\ + B_ASN1_UTF8STRING + +#endif + diff --git a/tests/input/c/pp_ret.c b/tests/input/c/pp_ret.c new file mode 100644 index 0000000000..c35e429496 --- /dev/null +++ b/tests/input/c/pp_ret.c @@ -0,0 +1,14 @@ +#if 0 +int +#else +unsigned +#endif +f() +{ +return 0; +} + +#ifdef FOO +#define BAR . +#endif + diff --git a/tests/input/c/pragma.c b/tests/input/c/pragma.c new file mode 100644 index 0000000000..a0dcd9756b --- /dev/null +++ b/tests/input/c/pragma.c @@ -0,0 +1,13 @@ + +#pragma do not change anything in this pragma! + +// This next bit should parse as '#', pragma, preproc-body, nl-cont, +// preproc-body, nl-cont, preproc-body +#pragma multi \ + line \ + pragma + +#pragma mark -------- Protected Member Functions ---------------- + +#pragma some comment follows // comment + diff --git a/tests/input/c/preproc-if.c b/tests/input/c/preproc-if.c new file mode 100644 index 0000000000..71fbf7923b --- /dev/null +++ b/tests/input/c/preproc-if.c @@ -0,0 +1,35 @@ + +int main() +{ +int a; +#ifndef SOMEDEF +int b; +#endif /* SOMEDEF */ + +if (a) +{ +} +#ifndef SOMEDEF +else if (b) +{ +} +#endif /* SOMEDEF */ + +/* same thing w/o preprocs for reference */ +if (a) +{ +} +else if (b) +{ +} + +#ifdef FOO +do +{ +Foo(); +} +#endif +while(Loop--); +} + + diff --git a/tests/input/c/return-multi.c b/tests/input/c/return-multi.c new file mode 100644 index 0000000000..846ca21c2e --- /dev/null +++ b/tests/input/c/return-multi.c @@ -0,0 +1,46 @@ + +static inline long +get_tv32(struct timeval *o, struct timeval32 __user *i) +{ + return !access_ok(VERIFY_READ, i, sizeof(*i)) || + (__get_user(o->tv_sec, &i->tv_sec) | + __get_user(o->tv_usec, &i->tv_usec)); +} + +static inline long +get_tv32(struct timeval *o, struct timeval32 __user *i) +{ + return (!access_ok(VERIFY_READ, i, sizeof(*i)) || + (__get_user(o->tv_sec, &i->tv_sec) | + __get_user(o->tv_usec, &i->tv_usec))); +} + +const char * +dcrp_license_feature(int32_t idx) +{ +#define FEATURESTR(f) \ + case DCRMIB_LICENSE_##f: \ + return DCRP_LICENSE_FEATURE_##f##_STR + + switch(idx) { + DCRP_LICENSE_FOREACH_FEATURES(FEATURESTR); + } + + return ""; + +} + + +static int +isValidLicenseType(int32_t idx) +{ +#define CHECKFEATURE(f) \ + case DCRMIB_LICENSE_##f: \ + return 1 + + switch(idx) { + DCRP_LICENSE_FOREACH_FEATURES(CHECKFEATURE); + } + + return n * foo(5); +} diff --git a/tests/input/c/semicolons.c b/tests/input/c/semicolons.c new file mode 100644 index 0000000000..d7e2379a0e --- /dev/null +++ b/tests/input/c/semicolons.c @@ -0,0 +1,75 @@ + +int foo(int bar) +{ + for (;;) + { + break; + };; + if (a) + { + foo();; + }; + + if (b) + if (c) + bar(); + else + ; + + else + { + foo();;;;; + }; + switch (a) + { + case 1: break; + case 2: break; + default: break;; + };; + while (b-->0) + { + bar();; + }; + do + { + bar(); + } while (b-->0 ); +}; + +enum FPP { + FPP_ONE = 1, + FPP_TWO = 2, +};; + +struct narg { + int abc; ; ; + char def; ; ; + ; + ;const char *ghi; +}; + +void f2(void) +{ + { i++; }; + + for (;;) ; + + for (;;) { ; } +} + +int main(int argc, char *argv[]) +{ +if( argc == 1 ) +{ +printf("one"); +}; +else if( argc == 2 ) +{ +printf("two"); +}; +else +{ +printf("%d", argc); +}; +return 0; +} diff --git a/tests/input/c/sort_include.c b/tests/input/c/sort_include.c new file mode 100644 index 0000000000..1396444d90 --- /dev/null +++ b/tests/input/c/sort_include.c @@ -0,0 +1,11 @@ +// should be ddd, eee, fff +#include "ddd" +#include "fff" +#include "eee" + +// should be aaa, ccc +#include "ccc" +#include "aaa" +// should be just bbb +#include "bbb" + diff --git a/tests/input/c/sp_cmt_cpp_start.c b/tests/input/c/sp_cmt_cpp_start.c new file mode 100644 index 0000000000..194cff4421 --- /dev/null +++ b/tests/input/c/sp_cmt_cpp_start.c @@ -0,0 +1,7 @@ + +//zero +// one +// two +// three +void foo(void); + diff --git a/tests/input/c/sp_embed_comment.c b/tests/input/c/sp_embed_comment.c new file mode 100644 index 0000000000..88a54dff96 --- /dev/null +++ b/tests/input/c/sp_embed_comment.c @@ -0,0 +1,8 @@ +void f(); +void g(int); +void h() +{ +f(/*foo*/); +g(42/*foo*/); +g(/*foo*/42); +} diff --git a/tests/input/c/struct-brace.c b/tests/input/c/struct-brace.c new file mode 100644 index 0000000000..7d08b4ca88 --- /dev/null +++ b/tests/input/c/struct-brace.c @@ -0,0 +1,17 @@ +struct foo { + unsigned int d_ino; + unsigned short d_reclen; + unsigned short d_namlen; + char d_name[1]; +}; + +struct foo +{ + unsigned int d_ino; + unsigned short d_reclen; + unsigned short d_namlen; + char d_name[1]; +}; + +struct foo { int a; char *b }; + diff --git a/tests/input/c/switch-case.c b/tests/input/c/switch-case.c new file mode 100644 index 0000000000..add9fcfafb --- /dev/null +++ b/tests/input/c/switch-case.c @@ -0,0 +1,117 @@ + +asmlinkage unsigned long +osf_setsysinfo(unsigned long op, void __user *buffer, unsigned long nbytes, + int __user *start, void __user *arg) +{ + switch (op) { + case SSI_IEEE_FP_CONTROL: { + unsigned long swcr, fpcr; + unsigned int *state; + + /* + * Alpha Architecture Handbook 4.7.7.3: + * To be fully IEEE compiant, we must track the current IEEE + * exception state in software, because spurrious bits can be + * set in the trap shadow of a software-complete insn. + */ + + if (get_user(swcr, (unsigned long __user *)buffer)) + return -EFAULT; + state = ¤t_thread_info()->ieee_state; + + /* Update softare trap enable bits. */ + *state = (*state & ~IEEE_SW_MASK) | (swcr & IEEE_SW_MASK); + + /* Update the real fpcr. */ + fpcr = rdfpcr() & FPCR_DYN_MASK; + fpcr |= ieee_swcr_to_fpcr(swcr); + wrfpcr(fpcr); + + return 0; + } + + case SSI_IEEE_RAISE_EXCEPTION: { + unsigned long exc, swcr, fpcr, fex; + unsigned int *state; + + if (get_user(exc, (unsigned long __user *)buffer)) + return -EFAULT; + state = ¤t_thread_info()->ieee_state; + exc &= IEEE_STATUS_MASK; + + /* Update softare trap enable bits. */ + swcr = (*state & IEEE_SW_MASK) | exc; + *state |= exc; + + /* Update the real fpcr. */ + fpcr = rdfpcr(); + fpcr |= ieee_swcr_to_fpcr(swcr); + wrfpcr(fpcr); + + /* If any exceptions set by this call, and are unmasked, + send a signal. Old exceptions are not signaled. */ + fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr; + if (fex) { + siginfo_t info; + int si_code = 0; + + if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND; + if (fex & IEEE_TRAP_ENABLE_INE) si_code = FPE_FLTRES; + if (fex & IEEE_TRAP_ENABLE_UNF) si_code = FPE_FLTUND; + if (fex & IEEE_TRAP_ENABLE_OVF) si_code = FPE_FLTOVF; + if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV; + if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV; + + info.si_signo = SIGFPE; + info.si_errno = 0; + info.si_code = si_code; + info.si_addr = NULL; /* FIXME */ + send_sig_info(SIGFPE, &info, current); + } + return 0; + } + + case SSI_IEEE_STATE_AT_SIGNAL: + case SSI_IEEE_IGNORE_STATE_AT_SIGNAL: + /* + * Not sure anybody will ever use this weird stuff. These + * ops can be used (under OSF/1) to set the fpcr that should + * be used when a signal handler starts executing. + */ + break; + + case SSI_NVPAIRS: { + unsigned long v, w, i; + unsigned int old, new; + + for (i = 0; i < nbytes; ++i) { + + if (get_user(v, 2*i + (unsigned int __user *)buffer)) + return -EFAULT; + if (get_user(w, 2*i + 1 + (unsigned int __user *)buffer)) + return -EFAULT; + switch (v) { + case SSIN_UACPROC: + again: + old = current_thread_info()->flags; + new = old & ~(UAC_BITMASK << UAC_SHIFT); + new = new | (w & UAC_BITMASK) << UAC_SHIFT; + if (cmpxchg(¤t_thread_info()->flags, + old, new) != old) + goto again; + break; + + default: + return -EOPNOTSUPP; + } + } + return 0; + } + + default: + break; + } + + return -EOPNOTSUPP; +} + diff --git a/tests/input/c/switch.c b/tests/input/c/switch.c new file mode 100644 index 0000000000..5b760363cf --- /dev/null +++ b/tests/input/c/switch.c @@ -0,0 +1,29 @@ + +int foo(int op) +{ + switch (op) + { + case 1: { + do_something(); + return 0; + } + + case 2: + do_something_else(); + return 1; + + case 3: + case 4: + /* don't do anything */ + break; + + case 5: + return 3; + + default: + break; + } + + return -1; +} + diff --git a/tests/input/c/t3.in.c b/tests/input/c/t3.in.c new file mode 100644 index 0000000000..e352f7360f --- /dev/null +++ b/tests/input/c/t3.in.c @@ -0,0 +1,10 @@ +extern /*@observer@*/ /*@null@*/ const dcroid_t* dcrp_oidget +( + /*@in@*/ const char* h, + /*@in@*/const char* t + ) /*@ensures maxRead(result) >= 0@*/; + +extern /*@observer@*/const char* dcrp_oidlabel +( + /*@in@*/const dcroid_t* oid + ); diff --git a/tests/input/c/type-cast.c b/tests/input/c/type-cast.c new file mode 100644 index 0000000000..5760b46629 --- /dev/null +++ b/tests/input/c/type-cast.c @@ -0,0 +1,14 @@ + +void foo(void) +{ + drab bar; + bar = (bat) * r; + bar = (int) * r; + bar = (UINT8) * r; + bar = (time_t) * r; + + a = &arg[dog * 13]; + b = arg[dog * cat]; + hc = "0123456789ABCDEF"[0xf & *val]; +} + diff --git a/tests/input/c/type_wrap.c b/tests/input/c/type_wrap.c new file mode 100644 index 0000000000..13b7445517 --- /dev/null +++ b/tests/input/c/type_wrap.c @@ -0,0 +1,4 @@ +void foo(void) +{ + STACK_OF(X509) * st=sk_X509_new_null(); +} diff --git a/tests/input/c/vb-do.c b/tests/input/c/vb-do.c new file mode 100644 index 0000000000..1cefd1df14 --- /dev/null +++ b/tests/input/c/vb-do.c @@ -0,0 +1,22 @@ + +struct beef a = +{ + 1, 2, 3 +}; + +void get_name(void) +{ + int _ = 3; + do + a--; + while (a); + + while (a) //something + a--; + + do + while (a) //something + a--; + while (b--); +} + diff --git a/tests/input/c/vb-pp.c b/tests/input/c/vb-pp.c new file mode 100644 index 0000000000..5ea209c58a --- /dev/null +++ b/tests/input/c/vb-pp.c @@ -0,0 +1,35 @@ + +void f() { +if(0) +#pragma omp atomic +i++; +} + + +void f() { +if(0) +#if foo +i++; +#else +i+=2; +#endif +} + +void f() +{ +while(108) { +if(42) +#pragma omp critical +{ } +if(23) +#pragma omp critical +++i; +while (16) +{ } +int i = 15; +if(8) +#pragma omp atomic +i += 4; +} +} + diff --git a/tests/input/c/vb-while.c b/tests/input/c/vb-while.c new file mode 100644 index 0000000000..222917487d --- /dev/null +++ b/tests/input/c/vb-while.c @@ -0,0 +1,41 @@ +unsigned long xdl_adler32(unsigned long adler, unsigned char const *buf, + unsigned int len) +{ + int k; + unsigned long s1 = adler & 0xffff; + unsigned long s2 = (adler >> 16) & 0xffff; + + if (!buf) + return 1; + + while (len > 0) + { + k = len < NMAX ? len :NMAX; + len -= k; + while (k >= 16) + { + DO16(buf); + buf += 16; + k -= 16; + } + if (k != 0) + do + { + s1 += *buf++; + s2 += s1; + } while (--k); + s1 %= BASE; + s2 %= BASE; + } + + return(s2 << 16) | s1; +} + +void f(){ +while(1) +if(2) +3; +else +4; +} + diff --git a/tests/input/c/xml.c b/tests/input/c/xml.c new file mode 100644 index 0000000000..fe7afdf4c4 --- /dev/null +++ b/tests/input/c/xml.c @@ -0,0 +1,9 @@ +void foo(void) +{ +const char *a= "" +"" +"" +"" +""; +} + diff --git a/tests/input/cpp/Example.h b/tests/input/cpp/Example.h new file mode 100644 index 0000000000..deede79a3d --- /dev/null +++ b/tests/input/cpp/Example.h @@ -0,0 +1,10 @@ +class Example +{ + + Example() + : member(0) + {} + + int member; + +}; diff --git a/tests/input/cpp/Timestamp.h b/tests/input/cpp/Timestamp.h new file mode 100644 index 0000000000..60dc3791b0 --- /dev/null +++ b/tests/input/cpp/Timestamp.h @@ -0,0 +1,169 @@ +/** + * @file Timestamp.h + * Definition of class example::Timestamp. + */ + +#ifndef __Timestamp_h_ +#define __Timestamp_h_ + +#include + +namespace example { + +class IStreamable; +class InStream; +class OutStream; + +/** + * Timestamp is a timestamp with nanosecond resolution. + */ +class Timestamp + : public IStreamable +{ + +public: + + /** + * Default constructor. + */ + Timestamp(); + + /** + * Constructor. + * + * @param sec The seconds + * @param nsec The nanoseconds + */ + Timestamp(long sec, unsigned long nsec); + + /** + * Destructor. + */ + virtual ~Timestamp(); + + /** + * Adds two timestamps. + * + * @param rhs The other timestamp + * @return The resulting timestamp + */ + Timestamp operator+ (const Timestamp& rhs) const; + + /** + * Substracts two timestamps. + * + * @param rhs The other timestamp + * @return The resulting timestamp + */ + Timestamp operator- (const Timestamp& rhs) const; + + /** + * Compares two timestamps. + * + * @param rhs The other timestamp + * @return true if timestamp is smaller than the given timestamp + */ + bool operator< (const Timestamp& rhs) const; + + /** + * Compares two timestamps. + * + * @param rhs The other timestamp + * @return true if timestamp is greater than the given timestamp + */ + bool operator> (const Timestamp& rhs) const; + + /** + * Compares two timestamps. + * + * @param rhs The other timestamp + * @return true if timestamp is equal to the given timestamp + */ + bool operator== (const Timestamp& rhs) const; + + /** + * Compares two timestamps. + * + * @param rhs The other timestamp + * @return true if timestamp is not equal to the given timestamp + */ + bool operator!= (const Timestamp& rhs) const; + + /** + * Adds an other timestamp. + * + * @param rhs The other timestamp + */ + void operator+= (const Timestamp& rhs); + + /** + * Adds milliseconds. + * + * @param ms The milliseconds + * @return The resulting timestamp + */ + Timestamp addMilliseconds(unsigned long ms) const; + + /** + * Adds nanoseconds. + * + * @param ns The nanoseconds + * @return The resulting timestamp + */ + Timestamp addNanoseconds(unsigned long ns) const; + + /** + * Checks if this timestamp is zero. + * + * @return true if timestamp is zero + */ + bool isZero() const; + + /** + * Gets the milliseconds. + * @attention Negativ timestamp return zero + * + * @return The milliseconds + */ + unsigned long getMilliseconds() const; + + /** + * Divide timestamps by two. + * + * @return The resulting timestamp + */ + Timestamp divideByTwo(); + + /** + * Gets the string-representation. + * + * @return The string representation + */ + std::string getString() const; + + /** + * Gets the string-representation in milliseconds. + * + * @return The string representation + */ + std::string getStringMilliseconds() const; + + /** + * Resets the timestamp. + */ + void reset(); + + /** The seconds */ + long sec; + + /** The nanoseconds */ + unsigned long nsec; + + InStream& operator << (InStream& in); + + OutStream& operator >> (OutStream& out) const; + +}; +} // namespace + +#endif // __Timestamp_h_ diff --git a/tests/input/cpp/al.cpp b/tests/input/cpp/al.cpp new file mode 100644 index 0000000000..3c232decf4 --- /dev/null +++ b/tests/input/cpp/al.cpp @@ -0,0 +1,28 @@ +/* ctest4 */ +fm_status fm2000EventHandlingInitialize(fm_int sw); +fm_status fm2000MacTableOverflowStart(fm_int sw); +fm_bool fm2000ProcessMATableEntry( fm_mac_table_work_list *pWork, + fm_int sw, + fm_int index, + fm_thread * event_handler, + fm_uint32 * numUpdates, + fm_event **event); +void foo() +{ + Logger log = new Logger(); + Logger log= new Logger( ); + + log.foo.bar = 5; + log.narf.sweat = "cat"; +for (i = 0; i<5; i++) bar(i); +} +int this_works(int x); +int bug(int); // BUG: left-aligned +typedef int fooman; + enum FLAGS + { + FLAGS_decimal = 1, // decimal + FLAGS_unsigned = 2, // u or U suffix + FLAGS_long = 4, // l or L suffix + }; + diff --git a/tests/input/cpp/align-func-params.cpp b/tests/input/cpp/align-func-params.cpp new file mode 100644 index 0000000000..46c4f5cc53 --- /dev/null +++ b/tests/input/cpp/align-func-params.cpp @@ -0,0 +1,35 @@ +class test +{ + public: + + TYPE_EXPORT method1(int a, + float b); + + TYPE_EXPORT method2(int& d, + float e); + + TYPE_EXPORT method3(int* f, + float g); + + TYPE_EXPORT method4(int a); + TYPE_EXPORT method5(int & a); + TYPE_EXPORT method6(int * a); + + TYPE_EXPORT method7(float a); + TYPE_EXPORT method8(float & a); + TYPE_EXPORT method9(float * a); + + TYPE_EXPORT method3(int* f, char foo, + float g); + + TYPE_EXPORT method1(int a, + float b) + { + int c; + + if ( true ) callProc; + // do stuff. + } +} + + diff --git a/tests/input/cpp/align-star-amp-pos.cpp b/tests/input/cpp/align-star-amp-pos.cpp new file mode 100644 index 0000000000..4d0c3ff76d --- /dev/null +++ b/tests/input/cpp/align-star-amp-pos.cpp @@ -0,0 +1,47 @@ + +/** First, the typedefs */ +typedef int MY_INT; +typedef int * MY_INTP; +typedef int & MY_INTR; +typedef CFoo& foo_ref_t; +typedef int(*foo_t)(void *bar); +typedef int(*somefunc_t)(void *barstool); + +/* Now, the types */ +struct foo1 { + unsigned int d_ino; + const char *d_reclen; + unsigned short d_namlen; + char d_name[1]; + CFoo&fref; +}; + +struct foo { int a; char *b }; + +static int idx; +static const char **tmp; + CFoo&fref; + +static char buf[64]; +static unsigned long how_long; +// comment +static int **tmp; +static char buf[64]; + + +void bar(int someval, + void *puser, + const char *filename, + struct willy *the_list, + int list_len) +{ + int idx; + const char **tmp; + char buf[64]; + CFoo&fref; + + unsigned long how_long; + + return(-1); +} + diff --git a/tests/input/cpp/align_constr.cpp b/tests/input/cpp/align_constr.cpp new file mode 100644 index 0000000000..1a22f6d9df --- /dev/null +++ b/tests/input/cpp/align_constr.cpp @@ -0,0 +1,16 @@ +struct TelegramIndex +{ +TelegramIndex(const char* pN, unsigned long nI) : +pTelName(pN), +nTelIndex(n) +{ +} + +~TelegramIndex() +{ +} + +const char* const pTelName; +unsigned long nTelIndex; +}; + diff --git a/tests/input/cpp/align_fcall.cpp b/tests/input/cpp/align_fcall.cpp new file mode 100644 index 0000000000..f45af45a99 --- /dev/null +++ b/tests/input/cpp/align_fcall.cpp @@ -0,0 +1,10 @@ +void foo() +{ +abc(1,2,3); +abc(10,20,30); +abc(100,200,300); +cab(3,2,1,0); +brat("foo",2000,3000); +brat("question",2,-42); +brat("a",-22, 1); +} diff --git a/tests/input/cpp/alt_tokens.cpp b/tests/input/cpp/alt_tokens.cpp new file mode 100644 index 0000000000..d8b3f464f2 --- /dev/null +++ b/tests/input/cpp/alt_tokens.cpp @@ -0,0 +1,5 @@ +%:include // #include +int main(int argc, char *argv[]) <% // { +int array<:10:>; // int array[10]; +%> // } + diff --git a/tests/input/cpp/av.h b/tests/input/cpp/av.h new file mode 100644 index 0000000000..7a90197c25 --- /dev/null +++ b/tests/input/cpp/av.h @@ -0,0 +1,49 @@ +/* +2) There seems to be a problem handling .h-files compared to .cpp-files. +The following problem only occurs in header-files, in source-files the +output is as desired. +*/ + +static inline void foo() +{ +//BEFORE: +if (cond) callFunc(); +// DESIRED: +if (cond) { + callFunc(); +} +// AFTER: +if (cond) {callFunc();} + + +/* +3) The spacing around pointer stars is not always maintained as desired. +*/ +//BEFORE: + Buffer* buffer; +//AFTER: + Buffer*buffer; + + +/* +4) Inside of casts the types are not formatted as outside. +*/ +//BEFORE: +T* t = dynamic_cast(obj); +//AFTER: +T* t = dynamic_cast(obj); + +/* +5) Inside some template-stuff the spacing goes weird. Multiple spaces +are inserted, although the configuration (should) say otherwise. +*/ +//BEFORE: +for (std::map::iterator it = map.begin(); it != map.end(); it++) { + bar(it); +} +//AFTER: +for (std::map < Key, Value * > ::iterator it = map.begin(); it != map.end(); it++) { + bar(it); +} + } + diff --git a/tests/input/cpp/bool.cpp b/tests/input/cpp/bool.cpp new file mode 100644 index 0000000000..30d4cb293d --- /dev/null +++ b/tests/input/cpp/bool.cpp @@ -0,0 +1,11 @@ +bool foo(char c) +{ + if (c == 'a') + { + return true; + } + else + { + return false; + } +} diff --git a/tests/input/cpp/byref.cpp b/tests/input/cpp/byref.cpp new file mode 100644 index 0000000000..16bd78132c --- /dev/null +++ b/tests/input/cpp/byref.cpp @@ -0,0 +1,41 @@ +bool foo(int & idx) +{ + if (idx < m_count) + { + idx++; + return m_bool[idx-1]; + } + return false; +} + +class Foo { +public: + Foo(); + Foo(const Foo& f); +}; + +template< class T > class ListManager +{ +protected: + T head; + +public: + ListManager() + { + head.next = head.prev = &head; + } + + ListManager(const ListManager& ref) + { + head.next = head.prev = &head; + } +} + +const Foo & Foo::operator ==(Foo& me){ + ::sockaddr* ptr = (::sockaddr*)&host; + return me; +} + +MyType& MyClass::myMethode() { + const MyType& t = getSomewhere(); +} diff --git a/tests/input/cpp/class-addr.h b/tests/input/cpp/class-addr.h new file mode 100644 index 0000000000..8aca3bd453 --- /dev/null +++ b/tests/input/cpp/class-addr.h @@ -0,0 +1,11 @@ +class C +{ +public: +A* B; +C& D; +const C& D; +static C& D; +public C& D; +E=C& D; +}; + diff --git a/tests/input/cpp/class-init.cpp b/tests/input/cpp/class-init.cpp new file mode 100644 index 0000000000..4fe441aa59 --- /dev/null +++ b/tests/input/cpp/class-init.cpp @@ -0,0 +1,58 @@ + +class Foo : public Bar +{ + +}; + +#define CTOR(i, _) : T(X()), \ + y() \ +{ } + +class Foo2 : +public Bar +{ + +}; + +class GLOX_API ClientBase : public Class, public OtherClass, + public ThridClass, public ForthClass + { + }; + +ClientBase :: ClientBase (const std::string& ns, + const std::string& ns1, + const std::string& ns2) +{ + +} + +Foo::Foo(int bar) : someVar(bar), othervar(0) +{ +} + +Foo::Foo(int bar) : someVar(bar), + othervar(0) +{ +} + +Foo::Foo(int bar) +: someVar(bar), othervar(0) +{ +} + +Foo::Foo(int bar) : +someVar(bar), othervar(0) +{ +} + +Foo::Foo(int bar) : +someVar(bar), + othervar(0) +{ +} + +Foo::Foo(int bar) +: someVar(bar), + othervar(0) +{ +} diff --git a/tests/input/cpp/class.h b/tests/input/cpp/class.h new file mode 100644 index 0000000000..abe40a3449 --- /dev/null +++ b/tests/input/cpp/class.h @@ -0,0 +1,52 @@ +#ifndef _FOO_BAR_H_INCLUDED_ +#define _FOO_BAR_H_INCLUDED_ + +class CFooBarDlg : public CDialog +{ +// Construction +public: + CFooBarDlg(CFooBar *pDataMan, + CWnd* pParent = NULL ); + virtual ~CFooBarDlg(); + + void Initialize( BYTE nDelay ); + + UINT GetCount() { return (m_nCount); } + + void SetCount(int count) + { + if ((count > 0) && (count < MAX_COUNT)) + { + m_nCount = count; + } + }; + + // Dialog Data + //{{AFX_DATA(CATCSMgrDlg) + enum { IDD = IDD_ATCS_MGR_DLG }; + //}}AFX_DATA + +protected: + int m_nCount; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CATCSMgrDlg) +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation + + // Generated message map functions + //{{AFX_MSG(CATCSMgrDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnBtnSendFooBar(); + afx_msg void OnSelchangeFooBarCombo(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#endif /* _FOO_BAR_H_INCLUDED_ */ + diff --git a/tests/input/cpp/cmt-reflow.cpp b/tests/input/cpp/cmt-reflow.cpp new file mode 100644 index 0000000000..29598f2bee --- /dev/null +++ b/tests/input/cpp/cmt-reflow.cpp @@ -0,0 +1,34 @@ + +typedef enum stuff +{ +Value1 = 0x00000400 , // Just a comment for the value +Value2 = 0x00000800 , // A much longer comment that needs to be truncated to fit within a set character width. In this case, its 80 characters so two truncates are required. +} JustAnEnum; + +// this is another comment that is meant to exceed the code width so that it can be wrapped +// and combined to see how that works. + +/* this is another comment that is meant to exceed the code width so that it can be wrapped + * and combined to see how that works. */ + +/* Line A */ + +/* Line 1 */ +/* line 2 */ +/* line 3 */ +/* line 4 */ + +/** + * Multi-line comment + */ +void foo(void) +{ +/** + * Multi-line comment + */ + int idx; + /** + * Multi-line comment + */ +} + diff --git a/tests/input/cpp/cmt_indent.cpp b/tests/input/cpp/cmt_indent.cpp new file mode 100644 index 0000000000..542a0fd288 --- /dev/null +++ b/tests/input/cpp/cmt_indent.cpp @@ -0,0 +1,32 @@ +namespace { + + /* If we're in the middle of the original line, copy the string + only up to the cursor position into buf, so tab completion + will result in buf's containing only the tab-completed + path/filename. */ + + class Test { + + Test() {} + ~Test() {} + + /** Call this method to + run the test + + \param n test number + \returns the test result + */ + bool Run(int n); + + /** Call this method to + stop the test + + \param n test number + \returns the test result + */ + bool Run(int n); + + }; + +} + diff --git a/tests/input/cpp/cmt_right.cpp b/tests/input/cpp/cmt_right.cpp new file mode 100644 index 0000000000..121ea044b3 --- /dev/null +++ b/tests/input/cpp/cmt_right.cpp @@ -0,0 +1,26 @@ +class X +{ + struct Zone + { + // int a; + // int b; + int c; + int d; + double e; + inline Zone(int _c) : c(_c) + { } // constructor for zone search + + inline Zone( + //int _a, + //int _b, + int _c, + int _d, double _e) : + //a(_a), + //b(_b), + c(_c), + d(_d), + e(_e) + { } + }; +}; + diff --git a/tests/input/cpp/comment-align.cpp b/tests/input/cpp/comment-align.cpp new file mode 100644 index 0000000000..403bf773ab --- /dev/null +++ b/tests/input/cpp/comment-align.cpp @@ -0,0 +1,34 @@ +template +inline void +x3(T & a, T & b, T & c) +{ + T temp; + if (b < a) + { + if (c < a) + { // b , c < a + if (b < c) + { // b < c < a + temp = a; + a = b; + b = c; + c = temp; + } + else + { // c <=b < a + std::swap(c, a); + } + } + else + { // b < a <=c + // second line of comment + std::swap(a, b); + } + } + 0; + 0; + 0; + if (1) // always + do_something(); +} + diff --git a/tests/input/cpp/const_throw.cpp b/tests/input/cpp/const_throw.cpp new file mode 100644 index 0000000000..b1210b9bb1 --- /dev/null +++ b/tests/input/cpp/const_throw.cpp @@ -0,0 +1,8 @@ +void GetFoo(void) +const + { return (m_Foo); } + +int GetFoo(void) + throw (std::bad_alloc) + { return (m_Foo); } + diff --git a/tests/input/cpp/constructor.cpp b/tests/input/cpp/constructor.cpp new file mode 100644 index 0000000000..46abf36a91 --- /dev/null +++ b/tests/input/cpp/constructor.cpp @@ -0,0 +1,31 @@ + +IMPLEMENT_DYNAMIC(CPropertiesDlg, CDialog) +CPropertiesDlg::CPropertiesDlg( CPtcMsgSimControlModule *pcmPtcMsg, + CWnd* pParent /*=NULL*/): + CDialog( CPropertiesDlg::IDD, pParent ), + m_pspRouter( pcmPtcMsg ), + m_pspScm( pcmPtcMsg ) +{ + m_pcmPtcMsg = pcmPtcMsg; +} + +CPropertiesDlg::~CPropertiesDlg() +{ +} + +void CPropertiesDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +CFooBar::CFooBar(CWnd* pParent /*=NULL*/) + : CDialog(CFooBar::IDD, pParent), + m_parent(pParent) +{ + //{{AFX_DATA_INIT(CRouterBrowser) + //}}AFX_DATA_INIT + + m_nFoo = 0; + m_nBar = 0; +} + diff --git a/tests/input/cpp/cout.cpp b/tests/input/cpp/cout.cpp new file mode 100644 index 0000000000..c3c9366dd2 --- /dev/null +++ b/tests/input/cpp/cout.cpp @@ -0,0 +1,17 @@ +void foo() +{ + cout.setf(ios::showpoint); + cout.setf(ios::floatfield,ios::fixed); + + what.the.hell.cout << "hello" + << "world!" + << "This" + << "is a" + << "test!"; + + *aaaaaa = (bbbbb(cccccPtr->ddd) & YYYYYYYYYYYYYYYYYYYYYYYY) | + ((bbbbb(cccccPtr->nnnnnnnn) << ZZZZZZZZZZZZZZZZZZZZZZZZZZZ) + & WWWWWWWWWWWWWWWWWWWWWWWWWW) | ((bbbbb(cccccPtr->hhhhhhhhhhhhhh) + << FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) + & EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE); +} diff --git a/tests/input/cpp/ctor-var.cpp b/tests/input/cpp/ctor-var.cpp new file mode 100644 index 0000000000..2551d8bdcf --- /dev/null +++ b/tests/input/cpp/ctor-var.cpp @@ -0,0 +1,4 @@ +int foo() +{ + TextBody textbody(GetBody().GetText()); +} diff --git a/tests/input/cpp/custom-open-2.cpp b/tests/input/cpp/custom-open-2.cpp new file mode 100644 index 0000000000..422cb1bfc6 --- /dev/null +++ b/tests/input/cpp/custom-open-2.cpp @@ -0,0 +1,46 @@ + + +BEGIN_MESSAGE_MAP(CUSB2_camera_developementDlg, CDialog) +ON_COMMAND(IDC_ESCAPE, On_Escape) +ON_COMMAND(IDC_8_BIT, On_8_Bit) +ON_COMMAND(IDC_14_BIT, On_14_Bit) +ON_COMMAND(IDC_ACQUIRE, On_Acquire) +ON_COMMAND(IDC_SAVE_COLUMN_AVERAGES, On_Save_Column_Averages) +ON_COMMAND(IDC_SAVE_ROW_AVERAGES, On_Save_Row_Averages) +ON_WM_PAINT() +ON_WM_QUERYDRAGICON() +ON_WM_CTLCOLOR() +END_MESSAGE_MAP() + +namespace one +{ + namespace two + { + int Func(int a, + int b) + { + return a + b; + } + } +} + +using namespace one::two; + +void Func2(int c, + int d) +{ +} + +int main() +{ + int a; + + switch (a) + { + case 0: + Func2(1, Func(1, 2)); + Func2(1, one::two::Func(1, 2)); + break; + } +} + diff --git a/tests/input/cpp/custom-open.cpp b/tests/input/cpp/custom-open.cpp new file mode 100644 index 0000000000..1544fd7447 --- /dev/null +++ b/tests/input/cpp/custom-open.cpp @@ -0,0 +1,26 @@ + +void className::set(const objectName& obj) +{ + statement1(); +MACRO_BEGIN_STUFF(param) +DOSTUFF(params) +MACRO_ELSE_STUFF() +DOMORESTUFF(moreparams) +junk = 1; +MACRO2_BEGIN_STUFF +junk += 3; +MACRO2_ELSE_STUFF +junk += 4; +MACRO2_END_STUFF +DOLASTSTUFF(lastparams) +MACRO_END_STUFF() + statement2(); +} + + +MACRO2_BEGIN_STUFF + // comment +MACRO2_ELSE_STUFF + /* Comment */ +MACRO2_END_STUFF + diff --git a/tests/input/cpp/delete.cpp b/tests/input/cpp/delete.cpp new file mode 100644 index 0000000000..fff916e3f9 --- /dev/null +++ b/tests/input/cpp/delete.cpp @@ -0,0 +1,10 @@ + +void x(int **d) { +delete *d; +} + +void x(int& d) { +delete &d; +} + + diff --git a/tests/input/cpp/deref.cpp b/tests/input/cpp/deref.cpp new file mode 100644 index 0000000000..abfb70c7c4 --- /dev/null +++ b/tests/input/cpp/deref.cpp @@ -0,0 +1,15 @@ + +myNewValue = something[arrayNumber] *someOtherValue; +myNewValue = multidimentional[arrayNumber][anotherNumber] *someOtherValue; +myNewValue = noArrayVariableWorksFine * someOtherValue; + + +int func(int * thingy, +volatile int *arrayThingy[NUMBER]); + +int func(int * thingy, +volatile int *arrayThingy[NUMBER][anotherNumber]); + +int func(int * thingy, +volatile int *noArrayThingyWorksFine); + diff --git a/tests/input/cpp/exception.cpp b/tests/input/cpp/exception.cpp new file mode 100644 index 0000000000..ad0cc8862c --- /dev/null +++ b/tests/input/cpp/exception.cpp @@ -0,0 +1,33 @@ + #include + + +void foo() +{ + char *buf; + try { + buf = new unsigned char[1024]; + if( buf == 0 ) + throw "Out of memory"; + } + catch( char * str ) { + cout << "Exception: " << str << '\n'; + } +} + +void bar() +{ + char *buf; + + try + { + buf = new unsigned char[1024]; + if( buf == 0 ) + throw "Out of memory"; + } + catch( char * str ) + { + cout << "Exception: " << str << '\n'; + } +} + + diff --git a/tests/input/cpp/extern_c.h b/tests/input/cpp/extern_c.h new file mode 100644 index 0000000000..ee9a360d98 --- /dev/null +++ b/tests/input/cpp/extern_c.h @@ -0,0 +1,35 @@ +#ifndef cRecordMarking_HEADER +#define cRecordMarking_HEADER + +#include "DIS/cPduSnapshot.h" + +typedef void* disConnectionH; + +#ifdef __cplusplus +extern "C" +{ +#endif + + disConnectionH createDisConnection(); + + void setAddressAndPort_DisConnect(disConnectionH record, const char *addr); + + /* Open network connection */ + int open_DisConnect(disConnectionH record); + + /* Close network connection */ + void close_DisConnect(disConnectionH record); + + /* Send one pdu */ + int sendPdu_DisConnect(disConnectionH record, pduSnapshotH pdu); + + /* Receive one pdu */ + int recvPdu_DisConnect(disConnectionH record, pduSnapshotH pdu); + + void FreeDisConnection(disConnectionH connection); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/tests/input/cpp/for_long.cpp b/tests/input/cpp/for_long.cpp new file mode 100644 index 0000000000..7685f61415 --- /dev/null +++ b/tests/input/cpp/for_long.cpp @@ -0,0 +1,8 @@ +void foo() +{ +for(std::map::iterator it=m_stat_http_conn_total.m_stat_response_codes.begin(); it!=m_stat_http_conn_total.m_stat_response_codes.end(); ++i) +{ +bar(it); +} +} + diff --git a/tests/input/cpp/function-def.cpp b/tests/input/cpp/function-def.cpp new file mode 100644 index 0000000000..0c35974297 --- /dev/null +++ b/tests/input/cpp/function-def.cpp @@ -0,0 +1,64 @@ +int &Function() +{ +static int x; +return (x); +} + +void foo1(int param1, int param2, char *param2); + +void foo2(int param1, + int param2, + char *param2); + +void foo3(int param1, + int param2, // comment + char *param2 + ); + +struct whoopee *foo4(int param1, int param2, char *param2 /* comment */); + +const struct snickers * +foo5(int param1, int param2, char *param2); + + +void foo(int param1, int param2, char *param2) +{ + printf("boo!\n"); +} + +int classname::method(); + +int classname::method() +{ + foo(); +} + +int +classname::method2(); + +int +classname::method2() +{ + foo2(); +} + +const int& className::method1(void) const +{ + // stuff +} + +const longtypename& className::method2(void) const +{ + // stuff +} + +int &foo(); + +int &foo() +{ + list_for_each(a,b) { + bar(a); + } + return nuts; +} + diff --git a/tests/input/cpp/goto.cpp b/tests/input/cpp/goto.cpp new file mode 100644 index 0000000000..0f50d1828c --- /dev/null +++ b/tests/input/cpp/goto.cpp @@ -0,0 +1,11 @@ +#define x struct z +#define max(a, b) ((a) > (b) ? (a) : (b)) + +void f() +{ + goto p; +p: + goto q; +q: + goto p; +} diff --git a/tests/input/cpp/indent-off.cpp b/tests/input/cpp/indent-off.cpp new file mode 100644 index 0000000000..8e7b854ad8 --- /dev/null +++ b/tests/input/cpp/indent-off.cpp @@ -0,0 +1,21 @@ +struct X { +void operator-(int); +void operator+(int); +void operator()(); +}; +/* *INDENT-OFF* */ + struct Y { + void operator-(int){} + + + void operator+(int){} \ + void operator()(){} + + }; +/* *INDENT-ON* */ +struct Y { +void operator-(int){} +void operator+(int){} +void operator()(){} +}; + diff --git a/tests/input/cpp/indent_namespace.h b/tests/input/cpp/indent_namespace.h new file mode 100644 index 0000000000..f97bd324b0 --- /dev/null +++ b/tests/input/cpp/indent_namespace.h @@ -0,0 +1,32 @@ +namespace ns1 { + + void bar1(void); + + class foo1 + { + int i1; + }; +} + +namespace ns2 +{ + + void bar2(void); + + class foo2 + { + int i2; + }; +} + +namespace +{ + + void bar3(void); + class foo3 + { + int i3; + }; + +} + diff --git a/tests/input/cpp/indent_var_def.cpp b/tests/input/cpp/indent_var_def.cpp new file mode 100644 index 0000000000..394cfb6350 --- /dev/null +++ b/tests/input/cpp/indent_var_def.cpp @@ -0,0 +1,7 @@ +void function(){ +int n; +float f; +anotherFunction(); +char foo; +somethingelse(); +} diff --git a/tests/input/cpp/init_align.h b/tests/input/cpp/init_align.h new file mode 100644 index 0000000000..ff1dcc9be3 --- /dev/null +++ b/tests/input/cpp/init_align.h @@ -0,0 +1,22 @@ +struct file_lang languages[] = +{ + { ".c", "C", LANG_C }, + { ".cpp", "CPP", LANG_CPP }, + { ".d", "D", LANG_D }, + { ".cs", "CS", LANG_CS }, + { ".vala", "VALA", LANG_VALA }, + { ".java", "JAVA", LANG_JAVA }, + { ".pawn", "PAWN", LANG_PAWN }, + { ".p", "", LANG_PAWN }, + { ".sma", "", LANG_PAWN }, + { ".inl", "", LANG_PAWN }, + { ".h", "", LANG_CPP }, + { ".cxx", "", LANG_CPP }, + { ".hpp", "", LANG_CPP }, + { ".hxx", "", LANG_CPP }, + { ".cc", "", LANG_CPP }, + { ".di", "", LANG_D }, + { ".m", "OC", LANG_OC }, + { ".sqc", "", LANG_C }, // embedded SQL +}; + diff --git a/tests/input/cpp/kw_subst.cpp b/tests/input/cpp/kw_subst.cpp new file mode 100644 index 0000000000..4a5acb8a05 --- /dev/null +++ b/tests/input/cpp/kw_subst.cpp @@ -0,0 +1,29 @@ +#include + +class CFoo +{ +int foo1(int arg); +int foo2(); +}; + +int CFoo::foo1(int arg) +{ +} + +int CFoo::foo2() +{ +} + +int CFoo::operator +() +{ +} + +map func() +{ + // some codes +} + +int some_func(void) +{ +} + diff --git a/tests/input/cpp/kw_subst2.cpp b/tests/input/cpp/kw_subst2.cpp new file mode 100644 index 0000000000..f6a94e9c53 --- /dev/null +++ b/tests/input/cpp/kw_subst2.cpp @@ -0,0 +1,33 @@ +#include + +namespace bar +{ + +class CFoo +{ +int foo1(int arg); +int foo2(); +}; + +int CFoo::foo1(int arg, char arg2) +{ +} + +int CFoo::foo2() +{ +} + +int CFoo::operator +() +{ +} + +map func() +{ + // some codes +} + +int some_func(void) +{ +} + +} diff --git a/tests/input/cpp/long_namespace.cpp b/tests/input/cpp/long_namespace.cpp new file mode 100644 index 0000000000..89fe443555 --- /dev/null +++ b/tests/input/cpp/long_namespace.cpp @@ -0,0 +1,15 @@ +namespace boo3 { +int Fun1() +{ + return 42; +} +} + +namespace boo4 { + int Fun2() + { + int a = 7; + int b = 8; + return a+b; + } +} diff --git a/tests/input/cpp/misc.cpp b/tests/input/cpp/misc.cpp new file mode 100644 index 0000000000..98124777af --- /dev/null +++ b/tests/input/cpp/misc.cpp @@ -0,0 +1,51 @@ + +/* Not detected as a prototype? Spacing wrong. */ +static struct my_entry *get_first_entry(const CHAR *blah); +static CFooo::entry *get_next_entry(const CHAR *blah); +static struct my_entry *get_next_entry(const CHAR *blah); + +/* Not handling prototype params: */ +typedef void (*function_name)(my_t * p_my, int foo); +typedef void (*function_name)(my_t * , int ); + +typedef enum +{ + one = 1, + three = 3, + five_hundred = 5, + a_really_really_big_number = 6, + two = 7, + a_really_really_really_big_number = 8, +}yuck_t; + +const char *names[] = +{ + one = "one", + three = "three", + five_hundred = "five_hundred", + a_really_really_big_number = "a_really_really_big_number", + two = "two", + a_really_really_really_big_number = "a_really_really_really_big_number", +}; + +bool foo(char c) +{ + xWindow *pWindow = ::RelatedWindow(); + + /* space between ] and ( */ + function_list[idx](param); + + /* Indenting with multiple members: */ + sass.asdfvas->asdfasd[asdfasdf]. + asdfasdf = 5; + + dookie::wookie << "asd" + << "bag" + << "sag"; +} + +#ifndef abc + +#define abc 123 /* some comment */ + +#endif /* another comment diff --git a/tests/input/cpp/misc2.cpp b/tests/input/cpp/misc2.cpp new file mode 100644 index 0000000000..f1be44785d --- /dev/null +++ b/tests/input/cpp/misc2.cpp @@ -0,0 +1,59 @@ +/* +I tried to modify the spaces when using casts like static_cast etc. by +using sp_before_angle, sp_after_angle and sp_inside_angle. Even setting +all of those options to remove results in the following: +*/ + +myvar = dynamic_cast < MyClass* > (other); +// expected: +//myvar = dynamic_cast*>(other); + +/* +Sometime pointers and references are still not detected correctly in +special cases - i guess. +*/ +//When using "sp_before_ptr_star = remove" the result is: +typedef std::list::iterator iterator; +//typedef std::list::iterator iterator; +//------------------------------^ This space show not be there + +typedef void (T::*Routine)(void); + +//Similar with "sp_before_byref = remove": +unsigned long allocate(unsigned long size, void* & p); +//unsigned long allocate(unsigned long size, void* & p); +//------------------------------------------------^ The same here + +void foo(void) +{ + Listbob = new List (); + + /* Align assignments */ + align_assign(chunk_get_head(), + cpd.settings[UO_align_assign_span].n, + cpd.settings[UO_align_assign_thresh].n); +} + +Args::Args(int argc, char **argv) +{ + m_count = argc; + m_values = argv; + int len = (argc >> 3) + 1; + m_used = new UINT8[len]; + if (m_used != NULL) + { + memset(m_used, 0, len); + } +} + +void Args(int argc, char **argv) +{ + m_count = argc; + m_values = argv; + int len = (argc >> 3) + 1; + m_used = new UINT8[len]; + if (m_used != NULL) + { + memset(m_used, 0, len); + } +} diff --git a/tests/input/cpp/misc3.cpp b/tests/input/cpp/misc3.cpp new file mode 100644 index 0000000000..c7c10d6cf1 --- /dev/null +++ b/tests/input/cpp/misc3.cpp @@ -0,0 +1,25 @@ +// When constructing an object there should not be any space between the & and the variable name: + +MyClass my1(foo,& bar); +MyClass my2(foo, bar); +MyClass my3(foo, bar + 3); +MyClass my4(42); +MyClass my5(foo(), bar); +MyClass my6(int foo, int& bar); +MyClass my7(const int foo, int& bar); + + +//When using references inside of casts there is also an additional space after the &: + +MyClass& myInst = static_cast(otherInst); + + +// When using the qt-specific signals and slots the pointer star is separated from the type with a space: + +connect(&mapper, SIGNAL(mapped(QWidget *)), this, SLOT(onSomeEvent(QWidget*))); + +extern int select(int __nfds, fd_set * __restrict __readfds, + fd_set * __restrict __writefds, + fd_set * __restrict __exceptfds, + struct timeval * __restrict __timeout); + diff --git a/tests/input/cpp/misc4.cpp b/tests/input/cpp/misc4.cpp new file mode 100644 index 0000000000..725fa160f0 --- /dev/null +++ b/tests/input/cpp/misc4.cpp @@ -0,0 +1,28 @@ +struct X { + void operator deleteme(void*); + void deallocate(int*p){ + operator delete((void*)p); + delete((void*)q); + } +}; + +int f(bool b) { +typedef int mytype; +if (b) +return int(42.0); +else +return mytype(42.0); +} + +struct X { +double f(int n) +{ +return double(n); +} +}; + +inline value_type operator () () const + { + return (double(rnd32()) * (0.5 / 0x80000000)); + } + diff --git a/tests/input/cpp/misc5.cpp b/tests/input/cpp/misc5.cpp new file mode 100644 index 0000000000..570a4a76d0 --- /dev/null +++ b/tests/input/cpp/misc5.cpp @@ -0,0 +1,13 @@ +typedef std::list::iterator iterator; +double foo() +{ + if (a c) +{ +throw int(); +return(double()); +} + call_a_function(42, + double(-1), + "charray"); +return(foo(n)); +} diff --git a/tests/input/cpp/misc6.cpp b/tests/input/cpp/misc6.cpp new file mode 100644 index 0000000000..95cc038312 --- /dev/null +++ b/tests/input/cpp/misc6.cpp @@ -0,0 +1,3 @@ +#include +void f(std::vector * vip, std::vector & vir); + diff --git a/tests/input/cpp/nl-class.h b/tests/input/cpp/nl-class.h new file mode 100644 index 0000000000..128974b76c --- /dev/null +++ b/tests/input/cpp/nl-class.h @@ -0,0 +1,59 @@ +#ifndef NL_CLASS_H_INCLUDED +#define NL_CLASS_H_INCLUDED + +#include + +namespace example { + +class IStreamable; +class InStream; +class OutStream; + +/** + * Timestamp is a timestamp with nanosecond resolution. + */ +class Inher + : public IStreamable +{ + +public: + Inher(); + virtual ~Inher(); + +}; + +/** + * Timestamp is a timestamp with nanosecond resolution. + */ +class Inher2 + : public IStreamable { + +public: + + Inher2(); + Inher2(long sec, unsigned long nsec); + +}; + +class Simple { + +public: + + Simple(); + virtual ~Simple(); + +}; + +class Simple2 +{ + +public: + + Simple2(); + virtual ~Simple2(); + +}; + +} // namespace + +#endif // NL_CLASS_H_INCLUDED diff --git a/tests/input/cpp/nl-namespace.h b/tests/input/cpp/nl-namespace.h new file mode 100644 index 0000000000..a436fcb738 --- /dev/null +++ b/tests/input/cpp/nl-namespace.h @@ -0,0 +1,15 @@ +namespace ns1 { + + void *foo(void); + void bar(void); + +} + +namespace ns2 +{ + + void *foo(void); + void bar(void); + +} + diff --git a/tests/input/cpp/nl_brace_brace.cpp b/tests/input/cpp/nl_brace_brace.cpp new file mode 100644 index 0000000000..b698546aec --- /dev/null +++ b/tests/input/cpp/nl_brace_brace.cpp @@ -0,0 +1,18 @@ + +SHOW_VAR status_vars[]= { { "Aborted_clients", (char *)&aborted_threads, +SHOW_LONGLONG, } }; + +SHOW_VAR status_vars[]= +{ +{ "Aborted_clients", (char *)&aborted_threads, +SHOW_LONGLONG, } +}; + +SHOW_VAR status_vars[]= +{ +{ +"Aborted_clients", (char *)&aborted_threads, +SHOW_LONGLONG, +} +}; + diff --git a/tests/input/cpp/nl_func.cpp b/tests/input/cpp/nl_func.cpp new file mode 100644 index 0000000000..e27d7e55a8 --- /dev/null +++ b/tests/input/cpp/nl_func.cpp @@ -0,0 +1,23 @@ +class BSRRE1D_file : PhysicalFile +{ + int getFoo() { return(m_foo); } + void setFoo(int foo) { m_foo = foo; } + public BSRRE1D_file() + { + this.addFormatName("BSRRE1DF"); + } +private int m_foo; + public void xxx() + { + ahoj(); + } // comment + public void yyy() + { + ahoj(); + } + /* comment 2 */ + public void xxx() + { + ahoj(); + } +} diff --git a/tests/input/cpp/nl_func_decl.cpp b/tests/input/cpp/nl_func_decl.cpp new file mode 100644 index 0000000000..7305ffbbd6 --- /dev/null +++ b/tests/input/cpp/nl_func_decl.cpp @@ -0,0 +1,22 @@ +void bla() +{ +} + +void bla2 +( +) +{ +} + +void ble( int a, char b ) +{ +} + +void ble2 +( +int a, +char b +) +{ +} + diff --git a/tests/input/cpp/nl_func_scope_name.cpp b/tests/input/cpp/nl_func_scope_name.cpp new file mode 100644 index 0000000000..d221e9744e --- /dev/null +++ b/tests/input/cpp/nl_func_scope_name.cpp @@ -0,0 +1,2 @@ +void A::f() +{} diff --git a/tests/input/cpp/nl_func_type_name.cpp b/tests/input/cpp/nl_func_type_name.cpp new file mode 100644 index 0000000000..16bd38652e --- /dev/null +++ b/tests/input/cpp/nl_func_type_name.cpp @@ -0,0 +1,42 @@ + +//zero +// one +// two +// three +void foo(void); + +struct A +{ +public: +long_complicated_type f(); +A& operator+(const A& other); +}; + +A& A::operator+(const A& other) +{} + +B +operator+(const B& other) +{} + +B foo(const B& other) +{} + +class A +{ +public: +int aFunct() { return a; } +int bFunc(); +}; + +// Another file +int +A::bFunc() +{ +// some code +} + +template +typename Foo::Type Foo::Func() +{ +} diff --git a/tests/input/cpp/operator.cpp b/tests/input/cpp/operator.cpp new file mode 100644 index 0000000000..3c720fe72b --- /dev/null +++ b/tests/input/cpp/operator.cpp @@ -0,0 +1,71 @@ + +struct bar; +struct foo +{ +operator bar*(); +}; + +class Foo { + Foo operator+ (const Foo& rhs) const; + + const Foo& operator ==(Foo& me); + + bool operator> (const Foo& rhs) const; + + InStream& operator << (InStream& in); +} + +const Foo& Foo::operator ==(Foo& me) +{ +} + +Foo Foo::operator+ (const Foo& rhs) const +{ +} + +bool Foo::operator> (const Foo& rhs) const +{ +} + +class Example +{ + char m_array[256]; + + Example & operator=(const Example &rhs); + Example & operator+=(const Example &rhs); + const Example operator+(const Example &other) const; + bool operator==(const Example &other) const; + bool operator!=(const Example &other) const; + Example operator+ (const Example & x, const Example & y); + Example operator* (const Example & x, const Example & y); + + double& operator() (int row, int col); + double operator() (int row, int col) const; + void operator++ (); + int& operator* (); + Example& operator++ (); // prefix ++ + Example operator++ (int); // postfix ++ + + bool operator < (const Example& lhs, const Example& rhs) const; + + int operator()(int index) + { + i = ~ ~3; + return index + 1; + } + + char& operator[](unsigned i) + { + return m_array[i & 0xff]; + } +} + bool Example::operator==(const Example &other) const + { + /*TODO: compare something? */ + return false; + } + bool Example::operator!=(const Example &other) const + { + return ! operator ==(other); + } + diff --git a/tests/input/cpp/pp-define-indent.cpp b/tests/input/cpp/pp-define-indent.cpp new file mode 100644 index 0000000000..8ec5657fdc --- /dev/null +++ b/tests/input/cpp/pp-define-indent.cpp @@ -0,0 +1,35 @@ + +#define outpsize +#define some(f)\ +foo(f) + +class CRC +{ +public: +int foo; +// Initial CRC Start Value + #define 24BITCRC ((ULONG) 0x00864CFB) // This line is not aligned with the other lines +char ch; +#define MULTI LINE DEFINE \ + in column 0 \ +that spans +//// Operations //// +public: +... +} + +{ +#if defined(WIN32) + SYSTEMTIME st; + DWORD ThreadId; +#else + struct timeval mytv; + struct tm *mytm; + pid_t ProcessId; +#endif + +#if SOME COND + (void)loop; +#endif +} + diff --git a/tests/input/cpp/ptr-star.cpp b/tests/input/cpp/ptr-star.cpp new file mode 100644 index 0000000000..3bf97b3b81 --- /dev/null +++ b/tests/input/cpp/ptr-star.cpp @@ -0,0 +1,34 @@ +int dx = m_ClipBox.GetWidth() * GetZoom(); + +m_ClipBox.m_Pos.y = PaintClipBox.y * GetZoom(); + +int* i; +char*i; + +int MyFunc(std::string& s, char*) { +char *c = const_cast(s.c_str()); +} + +int YerFunc(std::string& s, char**) { +char **c; +int a = b[0] * c; +} + +int*X(int *i, int*); + +int *i = &a; +int *i = *b; +int *i = &*c; + +int *Aclass::X(int* i, int *); + +class Aclass { +int *X(int* i, int *); +} +extern "C" { +int foo1(int *a); +int foo2(sometype *a); +} +int bar1(int *a); +int bar2(sometype *a); + diff --git a/tests/input/cpp/qt-1.cpp b/tests/input/cpp/qt-1.cpp new file mode 100644 index 0000000000..60d802fd8f --- /dev/null +++ b/tests/input/cpp/qt-1.cpp @@ -0,0 +1,18 @@ +class Foo: public QObject +{ +Q_OBJECT + +private slots: +void mySlot(); + +public slots: +void publicSlot(); + +signals: +void somesignal(); + +}; + +class foo{bool b;public:int i;};class bar:public +foo{void*p;protected:double d;}; + diff --git a/tests/input/cpp/region.cpp b/tests/input/cpp/region.cpp new file mode 100644 index 0000000000..284470843d --- /dev/null +++ b/tests/input/cpp/region.cpp @@ -0,0 +1,20 @@ +class X : Y { + int foo1; + #pragma region something + int foo2 = 2; + #pragma endregion + int foo() + { + + #pragma region something else + int foo3 = 3; + #pragma region nested + int foo4 = 0; + #pragma endregion + int foo5 = 0; + #pragma endregion + } + +} + + diff --git a/tests/input/cpp/sef.cpp b/tests/input/cpp/sef.cpp new file mode 100644 index 0000000000..1588e7d052 --- /dev/null +++ b/tests/input/cpp/sef.cpp @@ -0,0 +1,4 @@ +CFoo::CFoo(const DWORD something, const RECT& positionRect, const UINT aNumber, bool thisIsReadOnly, const CString& windowTitle, CInfo *pStructInfo, int widthOfSomething) : CSuperFoo(something, positionRect, aNumber, +thisIsReadOnly, windowTitle), m_pInfo(pInfo), m_width(widthOfSomething) +{ +} diff --git a/tests/input/cpp/semicolons.cpp b/tests/input/cpp/semicolons.cpp new file mode 100644 index 0000000000..73350766f6 --- /dev/null +++ b/tests/input/cpp/semicolons.cpp @@ -0,0 +1,95 @@ +static int foo(int bar); + +static int foo(int bar) +{ + for (;;) + { + break; + };; + if (a) + { + foo();; + }; + + if (b) + if (c) + bar(); + else + ; + + else + { + foo();;;;; + }; + switch (a) + { + case 1: break; + case 2: break; + default: break;; + };; + while (b-->0) + { + bar();; + }; + do + { + bar(); + } while (b-->0 ); +}; + +enum FPP { + FPP_ONE = 1, + FPP_TWO = 2, +};; + +struct narg { + int abc; ; ; + char def; ; ; + ; + ;const char *ghi; +}; + +class CFooRun { + long stick(); + int bar() { m_ick++; }; + + CFooRun();; + ~CFooRun() {}; +}; + +void f() +{ + if (tmp[0] == "disk") + { + tmp = split (tmp[1], ","); + DiskEntry entry = { tmp[0], tmp[2], + stxxl::int64 (str2int (tmp[1])) * + stxxl::int64 (1024 * 1024) }; + disks_props.push_back (entry); + } +} + +template < class > struct type; + +template < class T > +class X { + typedef type < T > base ; + void f () { + ( base :: operator * () ) ;; + }; +}; + +namespace N +{ +class C +{ +#define NOP(x) { } +}; +} + +namespace N +{ + class C + { + }; +} diff --git a/tests/input/cpp/sim.h b/tests/input/cpp/sim.h new file mode 100644 index 0000000000..29c5287918 --- /dev/null +++ b/tests/input/cpp/sim.h @@ -0,0 +1,50 @@ +namespace ns { + +template class TOtherClass> class Example +{ + int foo; +} + +} + +template class Example +{ + + T getValue() const; + + /** A pointer to a T returning function in the software environment */ + T (FunctionProvider::*pF)(); + +}; + + +#if !defined(EVERYTHING_OK) +#error Define EVERYTHING_OK if you would like to compile your code \ +or not if you would like to stop! +#endif + + +template +class Example +{ + + Vector2() + : x(1), + y(1) + {} + + Vector2() + : x(1.0), + y(1.0) + {} + + Vector2() + : x(1.0f), + y(1.0f) + {} + + V x; + V y; + +}; + diff --git a/tests/input/cpp/sp_throw_paren.cpp b/tests/input/cpp/sp_throw_paren.cpp new file mode 100644 index 0000000000..f45f1a9a72 --- /dev/null +++ b/tests/input/cpp/sp_throw_paren.cpp @@ -0,0 +1,7 @@ + +void foo() +{ + throw(x); + throw (y); + throw (z); +} diff --git a/tests/input/cpp/strings.cpp b/tests/input/cpp/strings.cpp new file mode 100644 index 0000000000..359734fe20 --- /dev/null +++ b/tests/input/cpp/strings.cpp @@ -0,0 +1,7 @@ +void foo() +{ + BSTR test = L"SID"; + CHAR s[] = "This is a \"test\""; + CHAR ch = 'a'; +} + diff --git a/tests/input/cpp/templ_class.h b/tests/input/cpp/templ_class.h new file mode 100644 index 0000000000..0f10224439 --- /dev/null +++ b/tests/input/cpp/templ_class.h @@ -0,0 +1,16 @@ +template class SpecialClass> +class Example +{ + // Copy constructor with other variants of Example + template class OtherSpecialClass> + Example(const Example& other) + { + // do something useful here + } + + /** The normal member var based on the template arguments */ + SpecialClass memberVar; + +}; + + diff --git a/tests/input/cpp/templates.cpp b/tests/input/cpp/templates.cpp new file mode 100644 index 0000000000..b7c79b2878 --- /dev/null +++ b/tests/input/cpp/templates.cpp @@ -0,0 +1,147 @@ +#include +#include +#include + +class MyClass +{ +public: + std::map < int, bool > someData; + std::map < int, std::list < bool > > otherData; +}; + +void foo() +{ + List < byte >bob = new List (); + +} + +A foo; +A bar; +A baz; +A > bay; + +void asd(void) +{ +A foo; +A bar; +A baz; +A > bay; + if (a < b && b > c) + { + a = b < c > 0; + } + if (a < bar() > c) + { + } + a < up_lim() ? do_hi() : do_low; + a[ ac] = d; +} + +template class MyClass +{ + +} + + template + class MyClass + { + } + + template class MyClass : myvar(0), + myvar2(0) + { + + } + + template class MyClass + : myvar(0), + myvar2(0) + { + + } + + +static int max_value() + { + return (std :: numeric_limits :: max ) (); + } + +template < class Config_ > +priority_queue < Config_ > :: ~ priority_queue () { + + } + +template +T test(T a) { +return a; +} + +int main() { +int k,j; +h g; +k=test(j); +return 0; +} + +template class ConcreteStorageClass> +class RotationMatrix + : public StaticBaseMatrix +{ + +public: + + RotationMatrix() + : StaticBaseMatrix() + { + // do some initialization + } + + void assign(const OtherClass& other) + { + // do something + } + +}; + +int main() +{ + MyClass foo; +} + +template< typename CharT, int N, typename Traits > +inline std::basic_ostream& FWStreamOut(std::basic_ostream &os, + const W::S &s) + { + return operator<< >( os, s ); + } + +struct foo { +type1 < int & > bar; +}; +struct foo { +type1 < int const > bar; +}; + + +template void f(); +template void g() { +f(); +f< i >(); +f(); +f(); +} +void h() { g<42>(); } + +#include +std::vector A(2); +std::vector B; +std::vectorC(2); +std::vectorD; + +templatestruct X{templatevoid operator()(U);}; + +templateclass Y{templatevoid f(V);}; + +void (* foobar)(void) = NULL; +std::vector functions; + diff --git a/tests/input/cpp/templates2.cpp b/tests/input/cpp/templates2.cpp new file mode 100644 index 0000000000..46d4156007 --- /dev/null +++ b/tests/input/cpp/templates2.cpp @@ -0,0 +1,54 @@ +void f() +{ +call_a_function(42, +double(-1), +"charray"); +call_a_function(42, +double(-1), +"charray" +); +call_a_function( +42, +double(-1), +"charray" +); +call_a_template_function +(42); +call_a_template_function +(42); +call_a_template_function(42); +call_a_template_function( +42 +); +call_a_template_function< +int, +int, +int +> +(42); +} +template +class W; +template +class X; +template< +class T, +class U> +class Y; +template< +class T, +class U +> +class Z; diff --git a/tests/input/cpp/templates3.cpp b/tests/input/cpp/templates3.cpp new file mode 100644 index 0000000000..cf9974d0be --- /dev/null +++ b/tests/input/cpp/templates3.cpp @@ -0,0 +1,18 @@ +template +struct T { + typedef int result; +}; +template +struct X { + typedef typename T::result result; +}; + +template +class new_alloc { +public: + void deallocate (int* p, int /*num*/) + { + T::operator delete((void *)p); + } +}; + diff --git a/tests/input/cpp/templates4.cpp b/tests/input/cpp/templates4.cpp new file mode 100644 index 0000000000..10b96e4ac5 --- /dev/null +++ b/tests/input/cpp/templates4.cpp @@ -0,0 +1,17 @@ +#define FOO(X) \ +template \ +inline X<_blk_sz, _run_type, __pos_type> operator - ( \ +const X<_blk_sz, _run_type, __pos_type> & a, \ +typename X<_blk_sz, _run_type, __pos_type>::_pos_type off) \ +{ \ +return X<_blk_sz, _run_type, __pos_type>(a.array, a.pos - off); \ +} \ +template \ +inline X<_blk_sz, _run_type, __pos_type> & operator -= ( \ +X < _blk_sz, _run_type, __pos_type > & a, \ +typename X<_blk_sz, _run_type, __pos_type>::_pos_type off) \ +{ \ +a.pos -= off; \ +return a; \ +} + diff --git a/tests/input/cpp/try-catch-nl.cpp b/tests/input/cpp/try-catch-nl.cpp new file mode 100644 index 0000000000..447f3cbdbe --- /dev/null +++ b/tests/input/cpp/try-catch-nl.cpp @@ -0,0 +1,10 @@ +int foo() +{ +try { foo(bar); } catch (int *e) { return 0; } + +if (false) try { throw int(); } catch(...){} + +if (a) { return 1; } else { return 0; } +return 1; +} + diff --git a/tests/input/cpp/var_def_gap.cpp b/tests/input/cpp/var_def_gap.cpp new file mode 100644 index 0000000000..0cca962b4a --- /dev/null +++ b/tests/input/cpp/var_def_gap.cpp @@ -0,0 +1,27 @@ +#define A -3 +#define B 163 +#define C 2 + +void foo() +{ + const std::string &targetName1 = pEntry->getTargetName(); + const Point3d_t currentPosition1 = pSatOrbit->GetPositionAtTime(jdNow); +} + +void foo2() +{ + const std::string ** targetName2 = pEntry->getTargetName(); + const Point3d_t currentPosition2 = pSatOrbit->GetPositionAtTime(jdNow); +} + +void foo2() +{ + const std::string** targetName3 = pEntry->getTargetName(); + const Point3d_t currentPosition3 = pSatOrbit->GetPositionAtTime(jdNow); +} + +typedef int MY_INT; +typedef int *MY_INTP; +typedef int (*foo_t)(void *bar); +typedef int (*somefunc_t)(void *barstool); + diff --git a/tests/input/cpp/variadic-template.h b/tests/input/cpp/variadic-template.h new file mode 100644 index 0000000000..f522097c6e --- /dev/null +++ b/tests/input/cpp/variadic-template.h @@ -0,0 +1,10 @@ +template +struct __index_holder_impl<__i, __index_holder<_Indexes...>, +_IdxHolder, _Elements...> +{ +typedef typename __index_holder_impl<__i + 1, +__index_holder<_Indexes..., +__i>, +_Elements...>::type type; +}; diff --git a/tests/input/cpp/wacky-template.cpp b/tests/input/cpp/wacky-template.cpp new file mode 100644 index 0000000000..99e01b6ea5 --- /dev/null +++ b/tests/input/cpp/wacky-template.cpp @@ -0,0 +1,12 @@ +template +template + +void turbo_dec_1_15::compute_tail(gamma_t const & gamma, +gamma2_t const & gamma2, +alpha_t const & alpha, +beta_t const & beta, +tail_extrinsic_t & tail_extrinsic, +rec_tail_t const & rec_tail) +{ +} diff --git a/tests/input/cs/generics.cs b/tests/input/cs/generics.cs new file mode 100644 index 0000000000..7bbe04c7c3 --- /dev/null +++ b/tests/input/cs/generics.cs @@ -0,0 +1,11 @@ + +int foo() +{ +a.b(); +a.b>(); +a.b < c, d > (); +a.b < c, e < d > > (); +a.b < c, e < d > > (); + +return default (T); +} diff --git a/tests/input/cs/getset.cs b/tests/input/cs/getset.cs new file mode 100644 index 0000000000..59aaa5bcf9 --- /dev/null +++ b/tests/input/cs/getset.cs @@ -0,0 +1,14 @@ +public bool Enabled +{ +get { return enabled; } +} + + +public bool Enabled +{ +get +{ +return enabled; +} +} + diff --git a/tests/input/cs/gs.cs b/tests/input/cs/gs.cs new file mode 100644 index 0000000000..16adc60405 --- /dev/null +++ b/tests/input/cs/gs.cs @@ -0,0 +1,30 @@ +private string s = ""; +public int Amount +{ +get +{ +; +} +set +{ +; +} +} +public EventHandler MyCustomEventHandler +{ +add +{ +; +} +remove +{ +; +} +} +public this[string index] +{ +get; +set; +} +private string s2 = ""; + diff --git a/tests/input/cs/region.cs b/tests/input/cs/region.cs new file mode 100644 index 0000000000..4f8667f252 --- /dev/null +++ b/tests/input/cs/region.cs @@ -0,0 +1,20 @@ +class X : Y { + int foo1; + #region something + int foo2 = 2; + #endregion + int foo() + { + + #region something else + int foo3 = 3; + #region nested + int foo4 = 0; + #endregion + int foo5 = 0; + #endregion + } + +} + + diff --git a/tests/input/cs/simple.cs b/tests/input/cs/simple.cs new file mode 100644 index 0000000000..30acd134d5 --- /dev/null +++ b/tests/input/cs/simple.cs @@ -0,0 +1,114 @@ +class X : Y { +bool Method (int argument_1, int argument_2) +{ + #region something + int foo = 0; + #endregion + +if (argument_1 == argument_2) +throw new Exception (Locale.GetText ("They are equal!")); + +if (argument_1 < argument_2) { +if (argument_1 * 3 > 4) +return true; +else +return false; +} + +// +// This sample helps keep your sanity while using 8-spaces for tabs +// +VeryLongIdentifierWhichTakesManyArguments ( +Argument1, +Argument2, Argument3, +NestedCallHere ( +MoreNested)); +} + +bool MyProperty { +get { return x; } + +set { x = value; } +} + +void AnotherMethod () +{ + Logger log = new Logger(); + log.foo.bar = 5; + log.narf.sweat = "cat"; + +if ((a + 5) != 4) { +} + +while (blah) { +if (a) +continue; +b++; +} +} +} + +object lockA; +object lockB; + +void Foo () { + lock (lockA) { + lock (lockB) { + } + } +} + +void Bar () { + lock (lockB) { + lock (lockA) { + } + } +} + + +// class library +class Blah { + Hashtable ht; + void Foo (int zzz, Entry blah) { + lock (ht) { + ht.Add (zzz, blah); + } + } + + void Bar () + { + lock (ht) { + foreach (Entry e in ht) + EachBar (e); + } + } + + virtual void EachBar (Entry e) + { + } +} + +// User +class MyBlah { + byte[] box = new byte[6]; + + box[2] = 56; + + void DoStuff () + { + lock (this) { + int i = GetNumber (); + Entry e = GetEntry (); + + Foo (i, e); + } + } + + override void EachBar (Entry e) + { + lock (this) { + DoSomething (e); + } + } +} + diff --git a/tests/input/cs/sort_using.cs b/tests/input/cs/sort_using.cs new file mode 100644 index 0000000000..881b4d5b56 --- /dev/null +++ b/tests/input/cs/sort_using.cs @@ -0,0 +1,18 @@ +// should be ddd, eee, fff +using b.ddd; +using b.fff; +using b.eee; + +// should be aaa, ccc +using ccc; +using aaa; +// should be just bbb +using bbb; + +// should not change these, as it can't handle multi-line imports +using mango.ccc; +using mango.bbb, + mango.aaa; + +void foo(); + diff --git a/tests/input/cs/strings.cs b/tests/input/cs/strings.cs new file mode 100644 index 0000000000..6794e7629f --- /dev/null +++ b/tests/input/cs/strings.cs @@ -0,0 +1,8 @@ +void foo() +{ + string s1 = L"C:\\foo\\bar"; + string s2 = S"C:\\foo\\bar"; + string s3 = "This is a \"test\""; + string s4 = "C:\\"; +} + diff --git a/tests/input/cs/tcf.cs b/tests/input/cs/tcf.cs new file mode 100644 index 0000000000..f3ac36645e --- /dev/null +++ b/tests/input/cs/tcf.cs @@ -0,0 +1,32 @@ +void foo() +{ +try +{ +; +} +catch (Exception e) +{ +; +} +finally { +; +} +bar(); + +try +{ +; +} +catch (Exception e) +{ +; +} +catch (Exception e) +{ +; +} +finally { +; +} +bar(); +} diff --git a/tests/input/cs/unsafe.cs b/tests/input/cs/unsafe.cs new file mode 100644 index 0000000000..5dc90cb4a9 --- /dev/null +++ b/tests/input/cs/unsafe.cs @@ -0,0 +1,7 @@ +public class Class1 +{ + public unsafe bool GetValue () + { + return true; + } +} diff --git a/tests/input/cs/var-member.cs b/tests/input/cs/var-member.cs new file mode 100644 index 0000000000..0f7ffb2393 --- /dev/null +++ b/tests/input/cs/var-member.cs @@ -0,0 +1,24 @@ +namespace Foo.Man.Chu +{ + /// + /// Summary description for MainForm. + /// + public class MainForm : System.Windows.Forms.Form + { + #region Initialize the private properties + private System.Windows.Forms.MenuItem File; + private System.Windows.Forms.MenuItem Exit; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private Properties Prop; + private About Abt; + public MainForm mainform; + private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.Timer timer1; + private System.ComponentModel.IContainer components; + protected string strTitle; + #endregion + + } +} + diff --git a/tests/input/d/HashMap.d b/tests/input/d/HashMap.d new file mode 100644 index 0000000000..618b3e590e --- /dev/null +++ b/tests/input/d/HashMap.d @@ -0,0 +1,1059 @@ +/******************************************************************************* + + @file HashMap.d + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for damages + of any kind arising from the use of this software. + + Permission is hereby granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and/or + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment within documentation of + said product would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any distribution + of the source. + + 4. Derivative works are permitted, but they must carry this notice + in full and credit the original source. + + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + Written by Doug Lea with assistance from members of JCP JSR-166 + Expert Group and released to the public domain, as explained at + http://creativecommons.org/licenses/publicdomain + + @version Initial version, July 2004 + @author Doug Lea; ported/modified by Kris + +*******************************************************************************/ + +module mango.cache.HashMap; + +/****************************************************************************** + +******************************************************************************/ + +extern (C) +{ + int memcmp (char *, char *, uint); +} + + +/** + * A hash table supporting full concurrency of retrievals and + * adjustable expected concurrency for updates. This class obeys the + * same functional specification as {@link java.util.Hashtable}, and + * includes versions of methods corresponding to each method of + * Hashtable. However, even though all operations are + * thread-safe, retrieval operations do not entail locking, + * and there is not any support for locking the entire table + * in a way that prevents all access. This class is fully + * interoperable with Hashtable in programs that rely on its + * thread safety but not on its synchronization details. + * + *

Retrieval operations (including get) generally do not + * block, so may overlap with update operations (including + * put and remove). Retrievals reflect the results + * of the most recently completed update operations holding + * upon their onset. For aggregate operations such as putAll + * and clear, concurrent retrievals may reflect insertion or + * removal of only some entries. Similarly, Iterators and + * Enumerations return elements reflecting the state of the hash table + * at some point at or since the creation of the iterator/enumeration. + * They do not throw + * {@link ConcurrentModificationException}. However, iterators are + * designed to be used by only one thread at a time. + * + *

The allowed concurrency among update operations is guided by + * the optional concurrencyLevel constructor argument + * (default 16), which is used as a hint for internal sizing. The + * table is internally partitioned to try to permit the indicated + * number of concurrent updates without contention. Because placement + * in hash tables is essentially random, the actual concurrency will + * vary. Ideally, you should choose a value to accommodate as many + * threads as will ever concurrently modify the table. Using a + * significantly higher value than you need can waste space and time, + * and a significantly lower value can lead to thread contention. But + * overestimates and underestimates within an order of magnitude do + * not usually have much noticeable impact. A value of one is + * appropriate when it is known that only one thread will modify and + * all others will only read. Also, resizing this or any other kind of + * hash table is a relatively slow operation, so, when possible, it is + * a good idea to provide estimates of expected table sizes in + * constructors. + * + *

This class and its views and iterators implement all of the + * optional methods of the {@link Map} and {@link Iterator} + * interfaces. + * + *

Like {@link java.util.Hashtable} but unlike {@link + * java.util.HashMap}, this class does NOT allow null to be + * used as a key or value. + * + *

This class is a member of the + * + * Java Collections Framework. + * + * @since 1.5 + * @author Doug Lea + * @param the type of keys maintained by this map + * @param the type of mapped values + */ + +class HashMap +{ + alias void[] K; + alias Object V; + alias jhash hash; // jhash, fnv, or walter + + /* + * The basic strategy is to subdivide the table among Segments, + * each of which itself is a concurrently readable hash table. + */ + + /* ---------------- Constants -------------- */ + + /** + * The default initial number of table slots for this table. + * Used when not otherwise specified in constructor. + */ + private const uint DEFAULT_INITIAL_CAPACITY = 16; + + /** + * The maximum capacity, used if a higher value is implicitly + * specified by either of the constructors with arguments. MUST + * be a power of two <= 1<<30 to ensure that entries are indexible + * using ints. + */ + private const uint MAXIMUM_CAPACITY = 1 << 30; + + /** + * The default load factor for this table. Used when not + * otherwise specified in constructor. + */ + private const float DEFAULT_LOAD_FACTOR = 0.75f; + + /** + * The default number of concurrency control segments. + **/ + private const uint DEFAULT_SEGMENTS = 16; + + /** + * The maximum number of segments to allow; used to bound + * constructor arguments. + */ + private const uint MAX_SEGMENTS = 1 << 16; // slightly conservative + + + /* ---------------- Fields -------------- */ + + /** + * Mask value for indexing into segments. The upper bits of a + * key's hash code are used to choose the segment. + **/ + private final int segmentMask; + + /** + * Shift value for indexing within segments. + **/ + private final int segmentShift; + + /** + * The segments, each of which is a specialized hash table + */ + private final Segment[] segments; + + + /* ---------------- Small Utilities -------------- */ + + /** + * Returns a hash code for non-null Object x. + * Uses the same hash code spreader as most other java.util hash tables. + * @param x the object serving as a key + * @return the hash code + */ + private static final uint walter(K x) + { + uint h = typeid(char[]).getHash (&x); + h += ~(h << 9); + h ^= (h >>> 14); + h += (h << 4); + h ^= (h >>> 10); + return h; + } + + /** + * Returns a hash code for non-null Object x. + * uses the FNV hash function + * @param x the object serving as a key + * @return the hash code + */ + private static final uint fnv(K x) + { + uint hash = 2_166_136_261; + + foreach (ubyte c; cast(ubyte[]) x) + { + hash ^= c; + hash *= 16_777_619; + } + return hash; + } + + + + /** + * hash() -- hash a variable-length key into a 32-bit value + * k : the key (the unaligned variable-length array of bytes) + * len : the length of the key, counting by bytes + * level : can be any 4-byte value + * Returns a 32-bit value. Every bit of the key affects every bit of + * the return value. Every 1-bit and 2-bit delta achieves avalanche. + * About 36+6len instructions. + * + * The best hash table sizes are powers of 2. There is no need to do + * mod a prime (mod is sooo slow!). If you need less than 32 bits, + * use a bitmask. For example, if you need only 10 bits, do + * h = (h & hashmask(10)); + * In which case, the hash table should have hashsize(10) elements. + * + * If you are hashing n strings (ub1 **)k, do it like this: + * for (i=0, h=0; i= 12) + { + a += *cast(uint *)(k+0); + b += *cast(uint *)(k+4); + c += *cast(uint *)(k+8); + + a -= b; a -= c; a ^= (c>>13); + b -= c; b -= a; b ^= (a<<8); + c -= a; c -= b; c ^= (b>>13); + a -= b; a -= c; a ^= (c>>12); + b -= c; b -= a; b ^= (a<<16); + c -= a; c -= b; c ^= (b>>5); + a -= b; a -= c; a ^= (c>>3); + b -= c; b -= a; b ^= (a<<10); + c -= a; c -= b; c ^= (b>>15); + k += 12; len -= 12; + } + + // handle the last 11 bytes + c += x.length; + switch (len) + { + case 11: c+=(cast(uint)k[10]<<24); + case 10: c+=(cast(uint)k[9]<<16); + case 9 : c+=(cast(uint)k[8]<<8); + case 8 : b+=(cast(uint)k[7]<<24); + case 7 : b+=(cast(uint)k[6]<<16); + case 6 : b+=(cast(uint)k[5]<<8); + case 5 : b+=k[4]; + case 4 : a+=(cast(uint)k[3]<<24); + case 3 : a+=(cast(uint)k[2]<<16); + case 2 : a+=(cast(uint)k[1]<<8); + case 1 : a+=k[0]; + default: + } + + a -= b; a -= c; a ^= (c>>13); + b -= c; b -= a; b ^= (a<<8); + c -= a; c -= b; c ^= (b>>13); + a -= b; a -= c; a ^= (c>>12); + b -= c; b -= a; b ^= (a<<16); + c -= a; c -= b; c ^= (b>>5); + a -= b; a -= c; a ^= (c>>3); + b -= c; b -= a; b ^= (a<<10); + c -= a; c -= b; c ^= (b>>15); + + return c; + } + + + /** + * Returns the segment that should be used for key with given hash + * @param hash the hash code for the key + * @return the segment + */ + private final Segment segmentFor(uint hash) + { + return segments[(hash >>> segmentShift) & segmentMask]; + } + + /* ---------------- Inner Classes -------------- */ + + /** + * ConcurrentHashMap list entry. Note that this is never exported + * out as a user-visible Map.Entry. + * + * Because the value field is volatile, not final, it is legal wrt + * the Java Memory Model for an unsynchronized reader to see null + * instead of initial value when read via a data race. Although a + * reordering leading to this is not likely to ever actually + * occur, the Segment.readValueUnderLock method is used as a + * backup in case a null (pre-initialized) value is ever seen in + * an unsynchronized access method. + */ + private static class HashEntry + { + final K key; + final uint hash; + final V value; + final HashEntry next; + + this (K key, uint hash, HashEntry next, V value) + { + this.key = key; + this.hash = hash; + this.next = next; + this.value = value; + } + } + + /** + * Segments are specialized versions of hash tables. This + * subclasses from ReentrantLock opportunistically, just to + * simplify some locking and avoid separate construction. + **/ + static class Segment + { + /* + * Segments maintain a table of entry lists that are ALWAYS + * kept in a consistent state, so can be read without locking. + * Next fields of nodes are immutable (final). All list + * additions are performed at the front of each bin. This + * makes it easy to check changes, and also fast to traverse. + * When nodes would otherwise be changed, new nodes are + * created to replace them. This works well for hash tables + * since the bin lists tend to be short. (The average length + * is less than two for the default load factor threshold.) + * + * Read operations can thus proceed without locking, but rely + * on selected uses of volatiles to ensure that completed + * write operations performed by other threads are + * noticed. For most purposes, the "count" field, tracking the + * number of elements, serves as that volatile variable + * ensuring visibility. This is convenient because this field + * needs to be read in many read operations anyway: + * + * - All (unsynchronized) read operations must first read the + * "count" field, and should not look at table entries if + * it is 0. + * + * - All (synchronized) write operations should write to + * the "count" field after structurally changing any bin. + * The operations must not take any action that could even + * momentarily cause a concurrent read operation to see + * inconsistent data. This is made easier by the nature of + * the read operations in Map. For example, no operation + * can reveal that the table has grown but the threshold + * has not yet been updated, so there are no atomicity + * requirements for this with respect to reads. + * + * As a guide, all critical volatile reads and writes to the + * count field are marked in code comments. + */ + + /** + * The number of elements in this segment's region. + **/ + int count; + + /** + * The table is rehashed when its size exceeds this threshold. + * (The value of this field is always (int)(capacity * + * loadFactor).) + */ + int threshold; + + /** + * The per-segment table. Declared as a raw type, casted + * to HashEntry on each use. + */ + HashEntry[] table; + + /** + * The load factor for the hash table. Even though this value + * is same for all segments, it is replicated to avoid needing + * links to outer object. + * @serial + */ + final float loadFactor; + + this (int initialCapacity, float lf) + { + loadFactor = lf; + setTable (new HashEntry[initialCapacity]); + } + + /** + * Set table to new HashEntry array. + * Call only while holding lock or in constructor. + **/ + private final void setTable (HashEntry[] newTable) + { + threshold = cast(int) (newTable.length * loadFactor); + volatile table = newTable; + } + + /** + * Return properly casted first entry of bin for given hash + */ + private final HashEntry getFirst (uint hash) + { + HashEntry[] tab; + + volatile tab = table; + return tab [hash & (tab.length - 1)]; + } + + /** + * Return true if the two keys match + */ + private static final bool matchKey (K a, K b) + { + if (a.length == b.length) + return cast(bool) (memcmp (cast(char*) a, cast(char*) b, a.length) == 0); + return false; + } + + /* Specialized implementations of map methods */ + + final V get (K key, uint hash) + { + int c; + + // read-volatile + volatile c = count; + if (c) + { + HashEntry e = getFirst (hash); + while (e) + { + if (hash == e.hash && matchKey (key, e.key)) + { + V v; + volatile v = e.value; + if (v) + return v; + + synchronized (this) + return e.value; + } + e = e.next; + } + } + return null; + } + + + final bool containsKey (K key, uint hash) + { + int c; + + // read-volatile + volatile c = count; + if (c) + { + HashEntry e = getFirst (hash); + while (e) + { + if (e.hash == hash && matchKey (key, e.key)) + return true; + e = e.next; + } + } + return false; + } + + + + final synchronized V replace (K key, uint hash, V newValue) + { + HashEntry e = getFirst(hash); + while (e && (e.hash != hash || !matchKey (key, e.key))) + e = e.next; + + V oldValue = null; + if (e) + volatile + { + oldValue = e.value; + e.value = newValue; + } + return oldValue; + } + + + final synchronized V put (K key, uint hash, V value, bool onlyIfAbsent) + { + int c; + + volatile c = count; + if (c++ > threshold) + rehash(); + + HashEntry[] tab; + volatile tab = table; + uint index = hash & (tab.length - 1); + HashEntry first = tab[index]; + HashEntry e = first; + + while (e && (e.hash != hash || !matchKey (key, e.key))) + e = e.next; + + V oldValue; + if (e) + { + volatile oldValue = e.value; + if (!onlyIfAbsent) + volatile e.value = value; + } + else + { + oldValue = null; + tab[index] = new HashEntry (key, hash, first, value); + + // write-volatile + volatile count = c; + } + return oldValue; + } + + + private final void rehash () + { + HashEntry[] oldTable; + + volatile oldTable = table; + int oldCapacity = oldTable.length; + if (oldCapacity >= MAXIMUM_CAPACITY) + return; + + /* + * Reclassify nodes in each list to new Map. Because we are + * using power-of-two expansion, the elements from each bin + * must either stay at same index, or move with a power of two + * offset. We eliminate unnecessary node creation by catching + * cases where old nodes can be reused because their next + * fields won't change. Statistically, at the default + * threshold, only about one-sixth of them need cloning when + * a table doubles. The nodes they replace will be garbage + * collectable as soon as they are no longer referenced by any + * reader thread that may be in the midst of traversing table + * right now. + */ + + HashEntry[] newTable = new HashEntry[oldCapacity << 1]; + threshold = cast(int) (newTable.length * loadFactor); + int sizeMask = newTable.length - 1; + + for (int i = 0; i < oldCapacity ; ++i) + { + // We need to guarantee that any existing reads of old Map can + // proceed. So we cannot yet null out each bin. + HashEntry e = oldTable[i]; + + if (e) + { + HashEntry next = e.next; + uint idx = e.hash & sizeMask; + + // Single node on list + if (next is null) + newTable[idx] = e; + else + { + // Reuse trailing consecutive sequence at same slot + HashEntry lastRun = e; + int lastIdx = idx; + for (HashEntry last=next; last; last = last.next) + { + uint k = last.hash & sizeMask; + if (k != lastIdx) + { + lastIdx = k; + lastRun = last; + } + } + newTable[lastIdx] = lastRun; + + // Clone all remaining nodes + for (HashEntry p = e; p !is lastRun; p = p.next) + { + uint k = p.hash & sizeMask; + HashEntry n = newTable[k]; + newTable[k] = new HashEntry(p.key, p.hash, n, p.value); + } + } + } + } + volatile table = newTable; + } + + /** + * Remove; match on key only if value null, else match both. + */ + final synchronized V remove (K key, uint hash, V value) + { + int c; + HashEntry[] tab; + + volatile c = count - 1; + volatile tab = table; + + uint index = hash & (tab.length - 1); + HashEntry first = tab[index]; + HashEntry e = first; + + while (e && (e.hash != hash || !matchKey (key, e.key))) + e = e.next; + + V oldValue = null; + if (e) + { + V v; + volatile v = e.value; + if (value is null || value == v) + { + oldValue = v; + + // All entries following removed node can stay + // in list, but all preceding ones need to be + // cloned. + HashEntry newFirst = e.next; + for (HashEntry p = first; p !is e; p = p.next) + newFirst = new HashEntry (p.key, p.hash, newFirst, p.value); + tab[index] = newFirst; + + // write-volatile + volatile count = c; + } + } + return oldValue; + } + + + final synchronized void clear() + { + if (count) + { + HashEntry[] tab; + volatile tab = table; + + for (int i = 0; i < tab.length ; i++) + tab[i] = null; + + // write-volatile + volatile count = 0; + } + } + } + + + + /* ---------------- Public operations -------------- */ + + /** + * Creates a new, empty map with the specified initial + * capacity and the specified load factor. + * + * @param initialCapacity the initial capacity. The implementation + * performs internal sizing to accommodate this many elements. + * @param loadFactor the load factor threshold, used to control resizing. + * @param concurrencyLevel the estimated number of concurrently + * updating threads. The implementation performs internal sizing + * to try to accommodate this many threads. + * @throws IllegalArgumentException if the initial capacity is + * negative or the load factor or concurrencyLevel are + * nonpositive. + */ + public this (uint initialCapacity, float loadFactor, uint concurrencyLevel) + { + assert (loadFactor > 0); + + if (concurrencyLevel > MAX_SEGMENTS) + concurrencyLevel = MAX_SEGMENTS; + + // Find power-of-two sizes best matching arguments + int sshift = 0; + int ssize = 1; + while (ssize < concurrencyLevel) + { + ++sshift; + ssize <<= 1; + } + + segmentShift = 32 - sshift; + segmentMask = ssize - 1; + this.segments = new Segment[ssize]; + + if (initialCapacity > MAXIMUM_CAPACITY) + initialCapacity = MAXIMUM_CAPACITY; + + int c = initialCapacity / ssize; + if (c * ssize < initialCapacity) + ++c; + + int cap = 1; + while (cap < c) + cap <<= 1; + + for (int i = 0; i < this.segments.length; ++i) + this.segments[i] = new Segment (cap, loadFactor); + } + + /** + * Creates a new, empty map with the specified initial + * capacity, and with default load factor and concurrencyLevel. + * + * @param initialCapacity The implementation performs internal + * sizing to accommodate this many elements. + * @throws IllegalArgumentException if the initial capacity of + * elements is negative. + */ + public this (uint initialCapacity) + { + this(initialCapacity, DEFAULT_LOAD_FACTOR, DEFAULT_SEGMENTS); + } + + /** + * Creates a new, empty map with a default initial capacity, + * load factor, and concurrencyLevel. + */ + public this () + { + this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_SEGMENTS); + } + + /** + * Returns the value to which the specified key is mapped in this table. + * + * @param key a key in the table. + * @return the value to which the key is mapped in this table; + * null if the key is not mapped to any value in + * this table. + * @throws NullPointerException if the key is + * null. + */ + public V get (K key) + { + uint hash = hash(key); // throws NullPointerException if key null + return segmentFor(hash).get(key, hash); + } + + /** + * Tests if the specified object is a key in this table. + * + * @param key possible key. + * @return true if and only if the specified object + * is a key in this table, as determined by the + * equals method; false otherwise. + * @throws NullPointerException if the key is + * null. + */ + public bool containsKey (K key) + { + uint hash = hash(key); // throws NullPointerException if key null + return segmentFor(hash).containsKey(key, hash); + } + + /** + * Maps the specified key to the specified + * value in this table. Neither the key nor the + * value can be null. + * + *

The value can be retrieved by calling the get method + * with a key that is equal to the original key. + * + * @param key the table key. + * @param value the value. + * @return the previous value of the specified key in this table, + * or null if it did not have one. + * @throws NullPointerException if the key or value is + * null. + */ + public V put (K key, V value) + { + assert (value); + + uint hash = hash(key); + return segmentFor(hash).put(key, hash, value, false); + } + + /** + * If the specified key is not already associated + * with a value, associate it with the given value. + * This is equivalent to + *

+     *   if (!map.containsKey(key))
+     *      return map.put(key, value);
+     *   else
+     *      return map.get(key);
+     * 
+ * Except that the action is performed atomically. + * @param key key with which the specified value is to be associated. + * @param value value to be associated with the specified key. + * @return previous value associated with specified key, or null + * if there was no mapping for key. + * @throws NullPointerException if the specified key or value is + * null. + */ + public V putIfAbsent (K key, V value) + { + assert (value); + + uint hash = hash(key); + return segmentFor(hash).put(key, hash, value, true); + } + + + /** + * Removes the key (and its corresponding value) from this + * table. This method does nothing if the key is not in the table. + * + * @param key the key that needs to be removed. + * @return the value to which the key had been mapped in this table, + * or null if the key did not have a mapping. + * @throws NullPointerException if the key is + * null. + */ + public V remove (K key) + { + uint hash = hash(key); + return segmentFor(hash).remove(key, hash, null); + } + + /** + * Remove entry for key only if currently mapped to given value. + * Acts as + *
+     *  if (map.get(key).equals(value)) {
+     *     map.remove(key);
+     *     return true;
+     * } else return false;
+     * 
+ * except that the action is performed atomically. + * @param key key with which the specified value is associated. + * @param value value associated with the specified key. + * @return true if the value was removed + * @throws NullPointerException if the specified key is + * null. + */ + public bool remove (K key, V value) + { + uint hash = hash(key); + return cast(bool) (segmentFor(hash).remove(key, hash, value) !is null); + } + + + /** + * Replace entry for key only if currently mapped to some value. + * Acts as + *
+     *  if ((map.containsKey(key)) {
+     *     return map.put(key, value);
+     * } else return null;
+     * 
+ * except that the action is performed atomically. + * @param key key with which the specified value is associated. + * @param value value to be associated with the specified key. + * @return previous value associated with specified key, or null + * if there was no mapping for key. + * @throws NullPointerException if the specified key or value is + * null. + */ + public V replace (K key, V value) + { + assert (value); + + uint hash = hash(key); + return segmentFor(hash).replace(key, hash, value); + } + + + /** + * Removes all mappings from this map. + */ + public void clear () + { + for (int i = 0; i < segments.length; ++i) + segments[i].clear(); + } + + + /** + * Returns an enumeration of the keys in this table. + * + * @return an enumeration of the keys in this table. + * @see #keySet + */ + public KeyIterator keys () + { + return new KeyIterator (this); + } + + /** + * Returns an enumeration of the values in this table. + * + * @return an enumeration of the values in this table. + * @see #values + */ + public ValueIterator elements () + { + return new ValueIterator (this); + } + + /********************************************************************** + + Iterate over all keys in hashmap + + **********************************************************************/ + + int opApply (int delegate(inout char[]) dg) + { + int result = 0; + KeyIterator iterator = keys (); + + while (iterator.hasNext) + { + char[] ca = cast(char[]) iterator.next; + if ((result = dg (ca)) != 0) + break; + } + return result; + } + + /********************************************************************** + + Iterate over all keys in hashmap + + **********************************************************************/ + + int opApply (int delegate(inout char[], inout Object) dg) + { + int result = 0; + KeyIterator iterator = keys (); + + while (iterator.hasNext) + { + HashEntry he = iterator.nextElement; + char[] ca = cast(char[]) he.key; + if ((result = dg (ca, he.value)) != 0) + break; + } + return result; + } + + + /* ---------------- Iterator Support -------------- */ + + abstract static class HashIterator + { + int nextSegmentIndex; + int nextTableIndex; + HashEntry[] currentTable; + HashEntry nextEntry; + HashEntry lastReturned; + HashMap map; + + this (HashMap map) + { + this.map = map; + nextSegmentIndex = map.segments.length - 1; + nextTableIndex = -1; + advance(); + } + + final void advance () + { + if (nextEntry !is null && (nextEntry = nextEntry.next) !is null) + return; + + while (nextTableIndex >= 0) + { + if ( (nextEntry = currentTable[nextTableIndex--]) !is null) + return; + } + + while (nextSegmentIndex >= 0) + { + Segment seg = map.segments[nextSegmentIndex--]; + volatile if (seg.count) + { + currentTable = seg.table; + for (int j = currentTable.length - 1; j >= 0; --j) + { + if ((nextEntry = currentTable[j]) !is null) + { + nextTableIndex = j - 1; + return; + } + } + } + } + } + + public bool hasNext () + { + return cast(bool) (nextEntry !is null); + } + + HashEntry nextElement () + { + if (nextEntry is null) + throw new Exception ("no such element in HashMap"); + + lastReturned = nextEntry; + advance (); + return lastReturned; + } + } + + static class KeyIterator : HashIterator + { + this (HashMap map) {super (map);} + public K next() { return super.nextElement().key; } + } + + static class ValueIterator : HashIterator + { + this (HashMap map) {super (map);} + public V next() { volatile return super.nextElement().value; } + } + +} diff --git a/tests/input/d/Lexer.d b/tests/input/d/Lexer.d new file mode 100644 index 0000000000..cbbd6fd1ea --- /dev/null +++ b/tests/input/d/Lexer.d @@ -0,0 +1,2335 @@ +/+ + Copyright (c) 1999-2006 by Digital Mars + All Rights Reserved + written by Walter Bright www.digitalmars.com + License for redistribution is by either the Artistic License in artistic.txt, or the GNU General Public License in gnu.txt. + See the included readme.txt for details. + D Language conversion by: J Duncan ++/ + +/** + d language lexer +*/ + +module dparser.Lexer; + +import dparser.Root; + +import dparser.Tokens; +import dparser.Token; +import dparser.Keyword; + +import dparser.Types; + +import dparser.Module; +import dparser.Identifier; +import dparser.unialpha; + +import dparser.OutBuffer; + +//private import std.ctype; +//private import std.string; +//import dwf.core.debugapi; + +int errno = 0; + +//#if _WIN32 && __DMC__ +// from \dm\src\include\setlocal.h +//extern "C" char * __cdecl __locale_decpoint; +char* __locale_decpoint; +//#endif +//const uint LS = 0x2028; // UTF line separator +//const uint PS = 0x2029; // UTF paragraph separator + +//extern int isUniAlpha(unsigned u); +//extern int HtmlNamedEntity(unsigned char *p, int length); + +/** + Lexer object +*/ + +class Lexer +{ + + static Identifier[char[]] stringtable; + static OutBuffer stringbuffer; + static Token* freelist; + + Token token; // current token + Module mod; // current module + Loc loc; // for error messages + ubyte *base; // pointer to start of buffer + ubyte *end; // past end of buffer + ubyte *p; // current character + int doDocComment; // collect doc comment information + int anyToken; // !=0 means seen at least one token + int commentToken; // !=0 means comments are TOKcomment's + + + this( Module mod, ubyte* base, uint begoffset, uint endoffset, int doDocComment, int commentToken ) + { + if( stringbuffer is null ) + stringbuffer = new OutBuffer; + loc = Loc(mod, 1); + + this.base = base; + this.end = base + endoffset; + this.p = base + begoffset; + this.mod = mod; + this.doDocComment = doDocComment; + this.commentToken = commentToken; + + /* + If first line starts with '#!', ignore the line + */ + + if( p[0] == '#' && p[1] =='!' ) + { + p += 2; + while( true ) + { + ubyte c = *p; + switch( c ) + { + case '\n': + p++; + break; + + case '\r': + p++; + if( *p == '\n' ) + p++; + break; + + case 0: + case 0x1A: + break; + + default: + if( c & 0x80 ) + { + uint u = decodeUTF(); + if( u == PS || u == LS ) + break; + } + p++; + continue; + } + break; + } + + loc.linnum = 2; + } + + } + + + + // generate a unique identifier for this string + static Identifier idPool( in char[] str ) + { +// StringValue sv; +// uint len = s.length; +// StringValue sv = stringtable.update(s, len); +// Identifier* id = cast(Identifier*) sv.ptrvalue; +// if( id is null ) + if( (str in stringtable) == null ) + { + stringtable[str] = new Identifier( str, TOK.TOKidentifier ); + } + return stringtable[str]; + } + + static void initKeywords() + { + // build character map + cmtable_init(); + + // create keyword tokens & identifiers + dparser.Keyword.initKeywords(); + + // create standard lexer tokens + dparser.Token.createLexerTokens(); + } + + // Combine two document comments into one. + static char[] combineComments( char[] c1, char[] c2 ) + { + char[] c = c2; + if( c1.length ) + { + c = c1; + if( c2.length ) + { + c = c1 ~ "\n" ~ c2; + } + } + return c; + } + + // Decode UTF character. Issue error messages for invalid sequences. Return decoded character, advance p to last character in UTF sequence. + //! fix + uint decodeUTF() + { + ubyte* s = p; + ubyte c = *s; + + assert( c & 0x80 ); + if( !(c & 0x80) ) + return c; + + return cast(uint) 'X'; + /* + dchar u; + uint len; + + + + // Check length of remaining string up to 6 UTF-8 characters + for( len = 1; len < 6 && s[len]; len++ ) + { + + } + /+ + uint idx = 0; + char* msg = utf_decodeChar( s, len, &idx, &u ); + p += idx - 1; + if( msg ) + { + error(msg); + } + +/ + return u; + */ + } + + void error( ... ) + { + if( (mod !is null) && !global.gag ) + { + writefln( formatLoc( loc, _arguments, _argptr ) ); + /* + char[] p = loc.toChars(); + if( p.length ) + writef( "%s: ", p ); + writefx( stdout, _arguments, _argptr, 1 ); + */ + if( global.errors >= global.max_errors ) // moderate blizzard of cascading messages + throw new Exception( "too many errors" ); + } + + global.errors++; + } + + void errorLoc(Loc loc, ...) + { + if( (mod !is null) && !global.gag ) + { + writefln( formatLoc( loc, _arguments, _argptr ) ); + /* + char[] p = loc.toChars(); + if( p.length ) + writef("%s: ", p); + writefx(stdout, _arguments, _argptr, 1); + */ + if( global.errors >= 20 ) // moderate blizzard of cascading messages + throw new Exception( "too many errors" ); + } + + global.errors++; + } + + + TOK nextToken() + { + if( token.next ) + { + Token* t = token.next; + memcpy( &token, t, Token.sizeof ); +// t.next = freelist; +// freelist = t; + } + else + { + scan( &token ); + } +// token.print(); + return token.value; + } + + Token* peek( inout Token ct ) + { + Token* t; + if( ct.next ) + t = ct.next; + else + { + t = new Token; + scan( t ); + t.next = null; + ct.next = t; + } + return t; + } + + // Turn next token in buffer into a token. + + void scan( Token* t ) + { +// debug writefln("scan token"); + uint lastLine = loc.linnum; + uint linnum; + t.blockComment = null; + t.lineComment = null; + while( true ) + { + t.ptr = p; +// debug writefln( " p = %d, *p = ", cast(uint)p, cast(char)*p ); + switch( *p ) + { + case 0: + case 0x1a: + t.value = TOK.TOKeof; // end of file +// debug writefln( " EOF" ); + return; + + case ' ': + case '\t': + case '\v': + case '\f': + p++; +// debug writefln( " whitespace" ); + continue; // skip white space + + case '\r': +// debug writefln( " cr" ); + p++; + if( *p != '\n' ) // if CR stands by itself + loc.linnum++; + continue; // skip white space + + case '\n': +// debug writefln( " nl" ); + p++; + loc.linnum++; + continue; // skip white space + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + t.value = number(t); + return; + +/* + #if CSTRINGS + case '\'': + t.value = charConstant(t, 0); + return; + + case '"': + t.value = stringConstant(t,0); + return; + + case 'l': + case 'L': + if( p[1] == '\'') + { + p++; + t.value = charConstant(t, 1); + return; + } + else if( p[1] == '"') + { + p++; + t.value = stringConstant(t, 1); + return; + } + #else +*/ + case '\'': +// debug writefln( " char" ); + t.value = charConstant(t,0); + return; + + case 'r': +// debug writefln( " wysiwyg" ); + if( p[1] != '"') + goto case_ident; + p++; + case '`': + t.value = wysiwygStringConstant(t, *p); + return; + + case 'x': +// debug writefln( " hex string" ); + if( p[1] != '"') + goto case_ident; + p++; + t.value = hexStringConstant(t); + return; + + + case '"': +// debug writefln( " string" ); + t.value = escapeStringConstant( t, 0 ); +// debug writefln( t.ustring ); + return; + + case '\\': // escaped string literal +// debug writefln( " escaped string literal" ); + uint c; + stringbuffer.offset = 0; + do + { + p++; + c = escapeSequence(); + stringbuffer.write(c); + } while (*p == '\\'); +// t.len = stringbuffer.offset; +// stringbuffer.write(cast(byte)0); + t.ustring = stringbuffer.toString; +// memcpy( t.ustring.ptr, stringbuffer.data, stringbuffer.offset ); + t.postfix = 0; + t.value = TOK.TOKstring; + return; + + case 'l': + case 'L': +// #endif + + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'm': case 'n': case 'o': + case 'p': case 'q': /*case 'r':*/ case 's': case 't': + case 'u': case 'v': case 'w': /*case 'x':*/ case 'y': + case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '_': + case_ident: + { +// debug writefln( " identifier" ); + ubyte c; + do + { + c = *++p; + } while( isidchar(c) || (c & 0x80 && isUniAlpha( decodeUTF())) ); + +// sv = stringtable.update((char *)t.ptr, p - t.ptr); + char[] tmp; + tmp.length = p - t.ptr; + memcpy( tmp.ptr, t.ptr, p - t.ptr ); + Identifier id; + Identifier* pid = tmp in stringtable; + if( pid ) + { + id = *pid; + } + + if( id is null ) + { + id = new Identifier( tmp, TOK.TOKidentifier ); + stringtable[tmp] = id; + } + + t.ident = id; + t.value = cast(TOK) id.value; + anyToken = 1; + + // if special identifier token + if( *t.ptr == '_') + { + static char date[11+1]; + static char time[8+1]; + static char timestamp[24+1]; + + if( !date[0] ) // lazy evaluation + { + //!! + /+ + time_t t; + char *p; + .time(&t); + p = ctime(&t); + assert(p); + sprintf(date.ptr, "%.6s %.4s", p + 4, p + 20); + sprintf(time.ptr, "%.8s", p + 11); + sprintf(timestamp.ptr, "%.24s", p); + +/ + } + + if( mod && id is Id.FILE ) + { + t.value = TOK.TOKstring; + if( loc.filename.length ) + t.ustring = loc.filename; + else + t.ustring = mod.ident.toChars(); + goto Llen; + } + else if( mod && id == Id.LINE ) + { + t.value = TOK.TOKint64v; + t.uns64value = loc.linnum; + } + else if( id == Id.DATE ) + { + t.value = TOK.TOKstring; + //! t.ustring = date; + goto Llen; + } + else if( id == Id.TIME ) + { + t.value = TOK.TOKstring; + //! t.ustring = time; + goto Llen; + } + else if( id == Id.TIMESTAMP ) + { + t.value = TOK.TOKstring; + //! t.ustring = timestamp; + Llen: + t.postfix = 0; +// t.len = strlen((char *)t.ustring); + } + } + //printf("t.value = %d\n",t.value); + return; + } + + // comments + case '/': + p++; + switch( *p ) + { + case '=': + p++; + t.value = TOK.TOKdivass; + return; + + case '*': // '/*' + p++; + linnum = loc.linnum; + while( true ) + { + while( true ) + { + ubyte c = *p; + switch( c ) + { + case '/': + break; + + case '\n': + loc.linnum++; + p++; + continue; + + case '\r': + p++; + if( *p != '\n') + loc.linnum++; + continue; + + case 0: + case 0x1A: + error("unterminated /* */ comment"); + p = end; + t.value = TOK.TOKeof; + return; + + default: + if( c & 0x80) + { + uint u = decodeUTF(); + if( u == PS || u == LS ) + loc.linnum++; + } + p++; + continue; + } + break; + } + p++; + if( p[-2] == '*' && p - 3 != t.ptr ) + break; + } + + if( commentToken ) + { + t.value = TOK.TOKcomment; + return; + } + // if /** but not /**/ + else if( doDocComment && t.ptr[2] == '*' && p - 4 != t.ptr ) + getDocComment( t, lastLine == linnum ); //! ? + continue; + + case '/': // do // style comments + linnum = loc.linnum; + while (1) + { + ubyte c = *++p; + switch (c) + { + case '\n': + break; + + case '\r': + if( p[1] == '\n') + p++; + break; + + case 0: + case 0x1a: + if( commentToken ) + { + p = end; + t.value = TOK.TOKcomment; + return; + } + if( doDocComment && t.ptr[2] == '/' ) + getDocComment( t, lastLine == linnum ); + p = end; + t.value = TOK.TOKeof; + return; + + default: + if( c & 0x80) + { + uint u = decodeUTF(); + if( u == PS || u == LS) + break; + } + continue; + } + break; + } + + if( commentToken ) + { + p++; + loc.linnum++; + t.value = TOK.TOKcomment; + return; + } + if( doDocComment && t.ptr[2] == '/' ) + getDocComment( t, lastLine == linnum ); + + p++; + loc.linnum++; + continue; + + case '+': + { int nest; + linnum = loc.linnum; + p++; + nest = 1; + while (1) + { + ubyte c = *p; + switch (c) + { + case '/': + p++; + if( *p == '+') + { + p++; + nest++; + } + continue; + + case '+': + p++; + if( *p == '/') + { + p++; + if( --nest == 0) + break; + } + continue; + + case '\r': + p++; + if( *p != '\n') + loc.linnum++; + continue; + + case '\n': + loc.linnum++; + p++; + continue; + + case 0: + case 0x1A: + error("unterminated /+ +/ comment"); + p = end; + t.value = TOK.TOKeof; + return; + + default: + if( c & 0x80 ) + { + uint u = decodeUTF(); + if( u == PS || u == LS) + loc.linnum++; + } + p++; + continue; + } + break; + } + if( commentToken ) + { + t.value = TOK.TOKcomment; + return; + } + if( doDocComment && t.ptr[2] == '+' && p - 4 != t.ptr ) + { + // if /++ but not /++/ + getDocComment(t, lastLine == linnum); + } + continue; + } + default: + break; + } + t.value = TOK.TOKdiv; + return; + + case '.': + p++; + if( isdigit(*p)) + { + p--; + t.value = inreal(t); + } + else if( p[0] == '.') + { + if( p[1] == '.') + { + p += 2; + t.value = TOK.TOKdotdotdot; + } + else + { + p++; + t.value = TOK.TOKslice; + } + } + else + t.value = TOK.TOKdot; + return; + + case '&': + p++; + if( *p == '=') + { + p++; + t.value = TOK.TOKandass; + } + else if( *p == '&') + { + p++; + t.value = TOK.TOKandand; + } + else + t.value = TOK.TOKand; + return; + + // |, ||, |= + case '|': + p++; + if( *p == '=' ) + { p++; + t.value = TOK.TOKorass; + } + else if( *p == '|') + { p++; + t.value = TOK.TOKoror; + } + else + t.value = TOK.TOKor; + return; + + case '-': + p++; + if( *p == '=') + { p++; + t.value = TOK.TOKminass; + } + else if( *p == '-') + { p++; + t.value = TOK.TOKminusminus; + } + else + t.value = TOK.TOKmin; + return; + + // +, +=, ++ + case '+': + p++; + if( *p == '=') + { + p++; + t.value = TOK.TOKaddass; // += + } + else if( *p == '+') + { p++; + t.value = TOK.TOKplusplus; // ++ + } + else + t.value = TOK.TOKadd; // + + return; + + // <, <=, <<=, <<, <>=, <> + case '<': + p++; + if( *p == '=') + { p++; + t.value = TOK.TOKle; // <= + } + else if( *p == '<') + { p++; + if( *p == '=') + { p++; + t.value = TOK.TOKshlass; // <<= + } + else + t.value = TOK.TOKshl; // << + } + else if( *p == '>') + { p++; + if( *p == '=') + { p++; + t.value = TOK.TOKleg; // <>= + } + else + t.value = TOK.TOKlg; // <> + } + else + t.value = TOK.TOKlt; // < + return; + + // >, >>, >>>, >=, >>=, >>>= + case '>': + p++; + if( *p == '=') + { p++; + t.value = TOK.TOKge; // >= + } + else if( *p == '>') + { p++; + if( *p == '=') + { p++; + t.value = TOK.TOKshrass; // >>= + } + else if( *p == '>') + { p++; + if( *p == '=') + { p++; + t.value = TOK.TOKushrass; // >>>= + } + else + t.value = TOK.TOKushr; // >>> + } + else + t.value = TOK.TOKshr; // >> + } + else + t.value = TOK.TOKgt; // > + return; + + case '!': + p++; + if( *p == '=') + { p++; + if( *p == '=') + { + p++; + t.value = TOK.TOKnotidentity; // !== + } + else + t.value = TOK.TOKnotequal; // != + } + else if( *p == '<') + { + p++; + if( *p == '>') + { + p++; + if( *p == '=') + { + p++; + t.value = TOK.TOKunord; // !<>= + } + else + t.value = TOK.TOKue; // !<> + } + else if( *p == '=') + { + p++; + t.value = TOK.TOKug; // !<= + } + else + t.value = TOK.TOKuge; // !< + } + else if( *p == '>') + { p++; + if( *p == '=') + { + p++; + t.value = TOK.TOKul; // !>= + } + else + t.value = TOK.TOKule; // !> + } + else + t.value = TOK.TOKnot; // ! + return; + + case '=': + p++; + if( *p == '=') + { + p++; + if( *p == '=') + { + p++; + t.value = TOK.TOKidentity; // === + } + else + t.value = TOK.TOKequal; // == + } + else + t.value = TOK.TOKassign; // = + return; + + case '~': + p++; + if( *p == '=' ) + { + p++; + t.value = TOK.TOKcatass; // ~= + } + else + t.value = TOK.TOKtilde; // ~ + return; + + // SINGLE + case '(': p++; t.value = TOK.TOKlparen; return; + case ')': p++; t.value = TOK.TOKrparen; return; + case '[': p++; t.value = TOK.TOKlbracket; return; + case ']': p++; t.value = TOK.TOKrbracket; return; + case '{': p++; t.value = TOK.TOKlcurly; return; + case '}': p++; t.value = TOK.TOKrcurly; return; + case '?': p++; t.value = TOK.TOKquestion; return; + case ',': p++; t.value = TOK.TOKcomma; return; + case ';': p++; t.value = TOK.TOKsemicolon; return; + case ':': p++; t.value = TOK.TOKcolon; return; + case '$': p++; t.value = TOK.TOKdollar; return; + // DOUBLE + case '*': p++; if( *p == '=' ) { p++; t.value = TOK.TOKmulass; } else t.value = TOK.TOKmul; return; + case '%': p++; if( *p == '=' ) { p++; t.value = TOK.TOKmodass; } else t.value = TOK.TOKmod; return; + case '^': p++; if( *p == '=' ) { p++; t.value = TOK.TOKxorass; } else t.value = TOK.TOKxor; return; +// removed 148 case '~': p++; if( *p == '=' ) { p++; t.value = TOK.TOKcatass; } else t.value = TOK.TOKtilde; return; + + + case '#': + p++; + Pragma(); + continue; + + default: + { + debug writefln( " default char" ); + ubyte c = *p; + if( c & 0x80 ) + { + uint u = decodeUTF(); + // Check for start of unicode identifier + if( isUniAlpha(u) ) + goto case_ident; + + if( u == PS || u == LS ) + { + loc.linnum++; + p++; + continue; + } + } + if( isprint(c)) + error("unsupported char '%s'", cast(char)c); + else + error("unsupported char 0x%02x", cast(ubyte)c); + p++; + continue; + } + } + } + } + + + + // Parse escape sequence. + uint escapeSequence() + { + uint c; + int n; + int ndigits; + + c = *p; + switch ( c ) + { + case '\'': + case '"': + case '?': + case '\\': + Lconsume: + p++; + break; + + case 'a': c = 7; goto Lconsume; + case 'b': c = 8; goto Lconsume; + case 'f': c = 12; goto Lconsume; + case 'n': c = 10; goto Lconsume; + case 'r': c = 13; goto Lconsume; + case 't': c = 9; goto Lconsume; + case 'v': c = 11; goto Lconsume; + + case 'u': + ndigits = 4; + goto Lhex; + case 'U': + ndigits = 8; + goto Lhex; + case 'x': + ndigits = 2; + Lhex: + p++; + c = *p; + if( ishex(c)) + { + uint v; + n = 0; + v = 0; + while (1) + { + if( isdigit(c)) + c -= '0'; + else if( islower(c)) + c -= 'a' - 10; + else + c -= 'A' - 10; + v = v * 16 + c; + c = *++p; + if( ++n == ndigits) + break; + if( !ishex(c)) + { error("escape hex sequence has %d hex digits instead of %d", n, ndigits); + break; + } + } +//! if( ndigits != 2 && !utf_isValidDchar(v)) +//! error("invalid UTF character \\U%08x", v); + c = v; + } + else + error("undefined escape hex sequence \\%s\n",c); + break; + + case '&': // named character entity + for( ubyte *idstart = ++p; 1; p++ ) + { + switch( *p ) + { + case ';': + //!!! + /+ + c = HtmlNamedEntity(idstart, p - idstart); + if( c == ~0 ) + { + error("unnamed character entity &%.*s;", p - idstart, idstart); + c = ' '; + } + + p++; + +/ + break; + + default: + if( isalpha(*p) || (p != idstart + 1 && isdigit(*p))) + continue; + error("unterminated named entity"); + break; + } + break; + } + break; + + case 0: + case 0x1a: // end of file + c = '\\'; + break; + + default: + if( isoctal(c) ) + { + ubyte v; + n = 0; + do + { + v = v * 8 + (c - '0'); + c = *++p; + } while (++n < 3 && isoctal(c)); + c = v; + } + else + error("undefined escape sequence \\%s\n",c); + break; + } + return c; + } + + /************************************** + */ + + TOK wysiwygStringConstant( Token *t, int tc ) + { + uint c; + Loc start = loc; + + p++; + stringbuffer.offset = 0; + while (1) + { + c = *p++; + switch( c ) + { + case '\n': + loc.linnum++; + break; + + case '\r': + if( *p == '\n') + continue; // ignore + c = '\n'; // treat EndOfLine as \n character + loc.linnum++; + break; + + case 0: + case 0x1a: + error("unterminated string constant starting at %s", start.toChars()); + t.ustring = ""; + t.postfix = 0; + return TOK.TOKstring; + + case '"': + case '`': + if( c == tc) + { +// t.len = stringbuffer.offset; + stringbuffer.write(cast(byte)0); + t.ustring = stringbuffer.toString; +// t.ustring = (ubyte *)mem.malloc(stringbuffer.offset); +// memcpy(t.ustring, stringbuffer.data, stringbuffer.offset); + stringPostfix(t); + return TOK.TOKstring; + } + break; + + default: + if( c & 0x80) + { + p--; + uint u = decodeUTF(); + p++; + if( u == PS || u == LS) + loc.linnum++; + stringbuffer.write(u); + continue; + } + break; + } + stringbuffer.write(c); + } + } + + /************************************** + * Lex hex strings: + * x"0A ae 34FE BD" + */ + + TOK hexStringConstant(Token *t) + { + uint c; + Loc start = loc; + uint n = 0; + uint v; + + p++; + stringbuffer.offset = 0; + while (1) + { + c = *p++; + switch (c) + { + case ' ': + case '\t': + case '\v': + case '\f': + continue; // skip white space + + case '\r': + if( *p == '\n') + continue; // ignore + // Treat isolated '\r' as if it were a '\n' + case '\n': + loc.linnum++; + continue; + + case 0: + case 0x1a: + error("unterminated string constant starting at %s", start.toChars()); + t.ustring = ""; + t.postfix = 0; + return TOK.TOKstring; + + case '"': + if( n & 1 ) + { + error("odd number (%d) of hex characters in hex string", n); + stringbuffer.write(v); + } +// t.len = stringbuffer.offset; +// stringbuffer.write(cast(byte)0); + t.ustring = stringbuffer.toString; +// t.ustring = (ubyte *)mem.malloc(stringbuffer.offset); +// memcpy(t.ustring, stringbuffer.data, stringbuffer.offset); + stringPostfix(t); + return TOK.TOKstring; + + default: + if( c >= '0' && c <= '9') + c -= '0'; + else if( c >= 'a' && c <= 'f') + c -= 'a' - 10; + else if( c >= 'A' && c <= 'F') + c -= 'A' - 10; + else if( c & 0x80) + { + p--; + uint u = decodeUTF(); + p++; + if( u == PS || u == LS) + loc.linnum++; + else + error("non-hex character \\u%x", u); + } + else + error("non-hex character '%s'", c); + if( n & 1) + { + v = (v << 4) | c; + stringbuffer.write(v); + } + else + v = c; + n++; + break; + } + } + } + + /************************************** + */ + + TOK escapeStringConstant(Token *t, int wide) + { + uint c; + Loc start = loc; + p++; + stringbuffer.offset = 0; + // debug writefln( "escape string constant: %s", std.string.toString( cast(char*)p ) ); + while( 1 ) + { + c = *p++; + switch( c ) + { + case '\\': + switch (*p) + { + case 'u': + case 'U': + case '&': + c = escapeSequence(); + stringbuffer.write(c); + continue; + + default: + c = escapeSequence(); + break; + } + break; + + case '\n': + loc.linnum++; + break; + + case '\r': + if( *p == '\n') + continue; // ignore + c = '\n'; // treat EndOfLine as \n character + loc.linnum++; + break; + + case '"': +// writefln( "end of string: ", stringbuffer.toString ); + t.ustring = stringbuffer.toString().dup; + // t.len = stringbuffer.offset; + // stringbuffer.write(cast(byte)0); + // t.ustring = (ubyte *)mem.malloc(stringbuffer.offset); + // memcpy(t.ustring, stringbuffer.data, stringbuffer.offset); + stringPostfix(t); + + return TOK.TOKstring; + + case 0: + case 0x1a: + p--; + error("unterminated string constant starting at %s", start.toChars()); + t.ustring = ""; +// t.len = 0; + t.postfix = 0; + return TOK.TOKstring; + + default: + if( c & 0x80 ) + { + p--; + c = decodeUTF(); + if( c == LS || c == PS ) + { + c = '\n'; + loc.linnum++; + } + p++; + stringbuffer.write(cast(char)c); + continue; + } + break; + } + stringbuffer.write(cast(char)c); +// writefln( stringbuffer.toString ); + } + } + + //************************************** + TOK charConstant(Token *t, int wide) + { + uint c; + TOK tk = TOK.TOKcharv; + //printf("Lexer.charConstant\n"); + p++; + c = *p++; + switch( c ) + { + case '\\': + switch (*p) + { + case 'u': + t.uns64value = escapeSequence(); + tk = TOK.TOKwcharv; + break; + + case 'U': + case '&': + t.uns64value = escapeSequence(); + tk = TOK.TOKdcharv; + break; + + default: + t.uns64value = escapeSequence(); + break; + } + break; + + case '\n': + L1: + loc.linnum++; + case '\r': + case 0: + case 0x1a: + case '\'': + error("unterminated character constant"); + return tk; + + default: + if( c & 0x80) + { + p--; + c = decodeUTF(); + p++; + if( c == LS || c == PS ) + goto L1; + if( c < 0xd800 || (c >= 0xe000 && c < 0xfffe)) + tk = TOK.TOKwcharv; + else + tk = TOK.TOKdcharv; + } + t.uns64value = c; + break; + } + + if( *p != '\'' ) + { + error("unterminated character constant"); + return tk; + } + p++; + return tk; + } + + // Get postfix of string literal. + void stringPostfix(Token *t) + { + switch( *p ) + { + case 'c': + case 'w': + case 'd': + t.postfix = *p; + p++; + break; + + default: + t.postfix = 0; + break; + } + } + + /*************************************** + * Read \u or \U unicode sequence + * Input: + * u 'u' or 'U' + */ + /* + uint Wchar(uint u) + { + uint value; + uint n; + ubyte c; + uint nchars; + + nchars = (u == 'U') ? 8 : 4; + value = 0; + for (n = 0; 1; n++) + { + ++p; + if( n == nchars) + break; + c = *p; + if( !ishex(c)) + { + error("\\%s sequence must be followed by %d hex characters", u, nchars); + break; + } + if( isdigit(c)) + c -= '0'; + else if( islower(c)) + c -= 'a' - 10; + else + c -= 'A' - 10; + value <<= 4; + value |= c; + } + return value; + } + */ + + /************************************** + * Read in a number. + * If it's an integer, store it in tok.TKutok.Vlong. + * integers can be decimal, octal or hex + * Handle the suffixes U, UL, LU, L, etc. + * If it's double, store it in tok.TKutok.Vdouble. + * Returns: + * TKnum + * TKdouble,... + */ + + TOK number(Token *t) + { + //debug writefln("Lexer.number()"); + // We use a state machine to collect numbers + enum STATE + { + STATE_initial, + STATE_0, + STATE_decimal, + STATE_octal, + STATE_octale, + STATE_hex, + STATE_binary, + STATE_hex0, + STATE_binary0, + STATE_hexh, + STATE_error + } + + enum FLAGS + { + FLAGS_decimal = 1, // decimal + FLAGS_unsigned = 2, // u or U suffix + FLAGS_long = 4, // l or L suffix + } + FLAGS flags = FLAGS.FLAGS_decimal; + + int i; + TOK result; + int base; + stringbuffer.offset = 0; +// stringbuffer.data = null; + STATE state = STATE.STATE_initial; + ubyte* start = p; + + TOK _isreal() + { + p = start; + return inreal(t); + } + + while( true ) + { + char c = cast(char)*p; + switch( state ) + { + case STATE.STATE_initial: // opening state + if( c == '0' ) + state = STATE.STATE_0; + else + state = STATE.STATE_decimal; + break; + + case STATE.STATE_0: + flags = cast(FLAGS) (flags & ~FLAGS.FLAGS_decimal); + switch (c) + { + // #if ZEROH +// case 'H': // 0h +// case 'h': +// goto hexh; + // #endif + case 'X': + case 'x': + state = STATE.STATE_hex0; + break; + + case '.': + if( p[1] == '.') // .. is a separate token + goto done; + case 'i': + case 'f': + case 'F': + goto _Real; + // #if ZEROH +// case 'E': +// case 'e': +// goto case_hex; + // #endif + case 'B': + case 'b': + state = STATE.STATE_binary0; + break; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + state = STATE.STATE_octal; + break; + + // #if ZEROH +// case '8': case '9': case 'A': +// case 'C': case 'D': case 'F': +// case 'a': case 'c': case 'd': case 'f': +// case_hex: +// state = STATE.STATE_hexh; +// break; + // #endif + case '_': + state = STATE.STATE_octal; + p++; + continue; + + default: + goto done; + } + break; + + case STATE.STATE_decimal: // reading decimal number + + // if its not a digit - decimal complete or not a decimal + if( !isdigit( c ) ) + { +// debug writefln( "\tnon-digit( %s )", c ); + // #if ZEROH +// if( ishex(c) || c == 'H' || c == 'h' ) +// goto hexh; + // #endif + //! wtf ? + // ignore embedded _ + if( c == '_' ) + { + p++; + continue; + } + + // check decimal point - make real + if( c == '.' && p[1] != '.' ) + goto _Real; + + // check for mantra - make real + if( c == 'i' || c == 'f' || c == 'F' || c == 'e' || c == 'E' ) + { + _Real: // It's a real number. Back up and rescan as a real + p = start; + return inreal(t); + } + + goto done; + } + break; + + case STATE.STATE_hex0: // reading hex number + case STATE.STATE_hex: + if( !ishex(c) ) + { + if( c == '_') // ignore embedded _ + { + p++; + continue; + } + if( c == '.' && p[1] != '.' ) + goto _Real; + if( c == 'P' || c == 'p' || c == 'i' ) + goto _Real; + if( state == STATE.STATE_hex0 ) + error("Hex digit expected, not '%s'", c); + goto done; + } + state = STATE.STATE_hex; + break; + + // #if ZEROH +// hexh: +// state = STATE.STATE_hexh; +// +// case STATE.STATE_hexh: // parse numbers like 0FFh +// if( !ishex(c)) +// { +// if( c == 'H' || c == 'h') +// { +// p++; +// base = 16; +// goto done; +// } +// else +// { +// // Check for something like 1E3 or 0E24 +// if( memchr(stringbuffer.data.ptr, 'E', stringbuffer.offset) || memchr( stringbuffer.data.ptr, 'e', stringbuffer.offset)) +// goto _Real; +// error("Hex digit expected, not '%s'", c); +// goto done; +// } +// } +// break; + // #endif + + case STATE.STATE_octal: // reading octal number + case STATE.STATE_octale: // reading octal number with non-octal digits + if( !isoctal(c) ) + { +// #if ZEROH +// if( ishex(c) || c == 'H' || c == 'h' ) +// goto hexh; +// #endif + if( c == '_' ) // ignore embedded _ + { + p++; + continue; + } + if( c == '.' && p[1] != '.' ) + goto _Real; + if( c == 'i' ) + goto _Real; + if( isdigit(c) ) + state = STATE.STATE_octale; + else + goto done; + } + break; + + case STATE.STATE_binary0: // starting binary number + case STATE.STATE_binary: // reading binary number + if( c != '0' && c != '1') + { + // #if ZEROH +// if( ishex(c) || c == 'H' || c == 'h' ) +// goto hexh; + // #endif + if( c == '_' ) // ignore embedded _ + { + p++; + continue; + } + if( state == STATE.STATE_binary0 ) + { + error("binary digit expected"); + state = STATE.STATE_error; + break; + } + else + goto done; + } + state = STATE.STATE_binary; + break; + + case STATE.STATE_error: // for error recovery + if( !isdigit(c) ) // scan until non-digit + goto done; + break; + + default: + assert(0); + } + stringbuffer.write(cast(char)c); + p++; + } + done: + stringbuffer.write( cast(char)0 ); // terminate string + +// debug writefln( "\tdigit complete( %s )", stringbuffer.toString ); + + if( state == STATE.STATE_octale ) + error("Octal digit expected"); + + uinteger_t n; // unsigned >=64 bit integer type + + if( stringbuffer.offset == 2 && ( state == STATE.STATE_decimal || state == STATE.STATE_0 ) ) + n = stringbuffer.data[0] - '0'; + else + { + // Convert string to integer + char* p = cast(char*)stringbuffer.data.ptr; + int r = 10; + int d; + if( *p == '0' ) + { + if( p[1] == 'x' || p[1] == 'X') + { + // "0x#" + p += 2; + r = 16; + } + else if( p[1] == 'b' || p[1] == 'B') + { + // "0b#" - binary + p += 2; + r = 2; + } + else if( isdigit(p[1])) + { + p += 1; + r = 8; + } + } + + n = 0; + + while( true ) + { + if( *p >= '0' && *p <= '9' ) + d = *p - '0'; + else if( *p >= 'a' && *p <= 'z' ) + d = *p - 'a' + 10; + else if( *p >= 'A' && *p <= 'Z' ) + d = *p - 'A' + 10; + else + break; + + if( d >= r ) + break; + + if( n * r + d < n) + { + error( "integer overflow" ); + break; + } + + n = n * r + d; + p++; + } + + // if n needs more than 64 bits + if( n.sizeof > 8 && n > 0xffffffffffffffffL ) + error("integer overflow"); + } + + // Parse trailing 'u', 'U', 'l' or 'L' in any combination + while( true ) + { + ubyte f; + switch( *p ) + { + case 'U': + case 'u': + f = FLAGS.FLAGS_unsigned; + goto L1; + case 'L': + case 'l': + f = FLAGS.FLAGS_long; + L1: + p++; + if( flags & f ) + error("unrecognized token"); + flags = cast(FLAGS) (flags | f); + continue; + default: + break; + } + break; + } + + switch ( flags ) + { + case 0: + /* Octal or Hexadecimal constant. + * First that fits: int, uint, long, ulong + */ + if( n & 0x8000000000000000L ) + result = TOK.TOKuns64v; + else if( n & 0xffffffff00000000L ) + result = TOK.TOKint64v; + else if( n & 0x80000000 ) + result = TOK.TOKuns32v; + else + result = TOK.TOKint32v; + break; + + case FLAGS.FLAGS_decimal: + /* First that fits: int, long, long long + */ + if( n & 0x8000000000000000L ) + { + error("signed integer overflow"); + result = TOK.TOKuns64v; + } + else if( n & 0xffffffff80000000L ) + result = TOK.TOKint64v; + else + result = TOK.TOKint32v; + break; + + case FLAGS.FLAGS_unsigned: + case FLAGS.FLAGS_decimal | FLAGS.FLAGS_unsigned: + /* First that fits: uint, ulong + */ + if( n & 0xffffffff00000000L ) + result = TOK.TOKuns64v; + else + result = TOK.TOKuns32v; + break; + + case FLAGS.FLAGS_decimal | FLAGS.FLAGS_long: + if( n & 0x8000000000000000L ) + { + error("signed integer overflow"); + result = TOK.TOKuns64v; + } + else + result = TOK.TOKint64v; + break; + + case FLAGS.FLAGS_long: + if( n & 0x8000000000000000L ) + result = TOK.TOKuns64v; + else + result = TOK.TOKint64v; + break; + + case FLAGS.FLAGS_unsigned | FLAGS.FLAGS_long: + case FLAGS.FLAGS_decimal | FLAGS.FLAGS_unsigned | FLAGS.FLAGS_long: + result = TOK.TOKuns64v; + break; + + default: + debug writefln("%x",flags); + assert(0); + } + t.uns64value = n; + return result; + } + + /************************************** + * Read in characters, converting them to real. + * Bugs: + * Exponent overflow not detected. + * Too much requested precision is not detected. + */ + + TOK inreal(Token *t) + { + int dblstate; + uint c; + char hex; // is this a hexadecimal-floating-constant? + TOK result; + + //printf("Lexer.inreal()\n"); + stringbuffer.offset = 0; + dblstate = 0; + hex = 0; + Lnext: + while (1) + { + // Get next char from input + c = *p++; + //printf("dblstate = %d, c = '%s'\n", dblstate, c); + while (1) + { + switch (dblstate) + { + case 0: // opening state + if( c == '0') + dblstate = 9; + else if( c == '.') + dblstate = 3; + else + dblstate = 1; + break; + + case 9: + dblstate = 1; + if( c == 'X' || c == 'x') + { + hex++; + break; + } + case 1: // digits to left of . + case 3: // digits to right of . + case 7: // continuing exponent digits + if( !isdigit(c) && !(hex && isxdigit(c))) + { + if( c == '_') + goto Lnext; // ignore embedded '_' + dblstate++; + continue; + } + break; + + case 2: // no more digits to left of . + if( c == '.') + { + dblstate++; + break; + } + case 4: // no more digits to right of . + if( (c == 'E' || c == 'e') || hex && (c == 'P' || c == 'p')) + { + dblstate = 5; + hex = 0; // exponent is always decimal + break; + } + if( hex) + error("binary-exponent-part required"); + goto done; + + case 5: // looking immediately to right of E + dblstate++; + if( c == '-' || c == '+') + break; + case 6: // 1st exponent digit expected + if( !isdigit(c)) + error("exponent expected"); + dblstate++; + break; + + case 8: // past end of exponent digits + goto done; + } + break; + } + stringbuffer.write(c); + } + done: + p--; + + stringbuffer.write(cast(byte)0); + +// #if _WIN32 && __DMC__ + char *save = __locale_decpoint; + __locale_decpoint = "."; +// #endif + t.float80value = strtold(cast(char *)stringbuffer.data.ptr, null); + errno = 0; + switch( *p ) + { + case 'F': + case 'f': + strtof(cast(char *)stringbuffer.data.ptr, null); + result = TOK.TOKfloat32v; + p++; + break; + + default: + strtod(cast(char *)stringbuffer.data.ptr, null); + result = TOK.TOKfloat64v; + break; + + case 'L': + case 'l': + result = TOK.TOKfloat80v; + p++; + break; + } + if( *p == 'i' || *p == 'I') + { + p++; + switch( result ) + { + case TOK.TOKfloat32v: + result = TOK.TOKimaginary32v; + break; + case TOK.TOKfloat64v: + result = TOK.TOKimaginary64v; + break; + case TOK.TOKfloat80v: + result = TOK.TOKimaginary80v; + break; + } + } +// #if _WIN32 && __DMC__ + __locale_decpoint = save; +// #endif + if( errno == ERANGE) + error("number is not representable"); + return result; + } + + + + + /********************************************* + * Do pragma. + * Currently, the only pragma supported is: + * #line linnum [filespec] + */ + + void Pragma() + { + Token tok; + int linnum; + char[] filespec; + Loc loc = this.loc; + + scan(&tok); + + if( tok.value != TOK.TOKidentifier || tok.ident != Id.line ) + goto Lerr; + + scan(&tok); + if( tok.value == TOK.TOKint32v || tok.value == TOK.TOKint64v ) + linnum = tok.uns64value - 1; + else + goto Lerr; + + while (1) + { + switch (*p) + { + case 0: + case 0x1a: + case '\n': + Lnewline: + this.loc.linnum = linnum; + if( filespec.length ) + this.loc.filename = filespec; + return; + + case '\r': + p++; + if( *p != '\n') + { p--; + goto Lnewline; + } + continue; + + case ' ': + case '\t': + case '\v': + case '\f': + p++; + continue; // skip white space + + case '_': + if( mod && memcmp(p, cast(char*)"__FILE__", 8) == 0) + { + p += 8; +//! filespec = mem.strdup(loc.filename ? loc.filename : mod.ident.toChars()); + } + continue; + + case '"': + if( filespec ) + goto Lerr; + stringbuffer.offset = 0; + p++; + while (1) + { + uint c; + c = *p; + switch (c) + { + case '\n': + case '\r': + case 0: + case 0x1a: + goto Lerr; + + case '"': + stringbuffer.write(cast(byte)0); + // filespec = mem.strdup((char *)stringbuffer.data); + filespec = stringbuffer.toString.dup; + p++; + break; + + default: + if( c & 0x80 ) + { + uint u = decodeUTF(); + if( u == PS || u == LS ) + goto Lerr; + } + stringbuffer.write(c); + p++; + continue; + } + break; + } + continue; + + default: + if( *p & 0x80 ) + { + uint u = decodeUTF(); + if( u == PS || u == LS) + goto Lnewline; + } + goto Lerr; + } + } + + Lerr: + errorLoc(loc, "#line integer [\"filespec\"]\\n expected"); + } + + + + /*************************************************** + * Parse doc comment embedded between t.ptr and p. + * Remove trailing blanks and tabs from lines. + * Replace all newlines with \n. + * Remove leading comment character from each line. + * Decide if it's a lineComment or a blockComment. + * Append to previous one for this token. + */ + + void getDocComment( Token *t, uint lineComment ) + { + auto OutBuffer buf = new OutBuffer; + ubyte ct = t.ptr[2]; + ubyte *q = t.ptr + 3; // start of comment text + int linestart = 0; + + ubyte *qend = p; + + if( ct == '*' || ct == '+') + qend -= 2; + + // Scan over initial row of ****'s or ++++'s or ////'s + for (; q < qend; q++) + { + if( *q != ct) + break; + } + + // Remove trailing row of ****'s or ++++'s + if( ct != '/') + { + for (; q < qend; qend--) + { + if( qend[-1] != ct) + break; + } + } + + for (; q < qend; q++) + { + ubyte c = *q; + + switch (c) + { + case '*': + case '+': + if( linestart && c == ct) + { linestart = 0; + // Trim preceding whitespace up to preceding \n + while (buf.offset && (buf.data[buf.offset - 1] == ' ' || buf.data[buf.offset - 1] == '\t')) + buf.offset--; + continue; + } + break; + + case ' ': + case '\t': + break; + + case '\r': + if( q[1] == '\n') + continue; // skip the \r + goto Lnewline; + + default: + if( c == 226) + { + // If LS or PS + if( q[1] == 128 && + (q[2] == 168 || q[2] == 169)) + { + q += 2; + goto Lnewline; + } + } + linestart = 0; + break; + + Lnewline: + c = '\n'; // replace all newlines with \n + case '\n': + linestart = 1; + + // Trim trailing whitespace + while (buf.offset && (buf.data[buf.offset - 1] == ' ' || buf.data[buf.offset - 1] == '\t')) + buf.offset--; + + break; + } + buf.write(c); + } + + // Always end with a newline + if( !buf.offset || buf.data[buf.offset - 1] != '\n' ) + buf.writenl(); + + //buf.write(cast(char)0); + + // It's a line comment if the start of the doc comment comes + // after other non-whitespace on the same line. +// ubyte** dc = (lineComment && anyToken) +// ? &t.lineComment +// : &t.blockComment; + + char[] dc = (lineComment && anyToken) ? t.lineComment : t.blockComment; + + // Combine with previous doc comment, if any + if( dc.length ) + dc = combineComments( dc, buf.toString().dup ); + else + dc = buf.toString().dup; + +// writefln( dc ); + + if( lineComment && anyToken ) + t.lineComment = dc; + else + t.blockComment = dc; + + } + +} + +// character maps +static ubyte[256] cmtable; + +const int CMoctal = 0x1; +const int CMhex = 0x2; +const int CMidchar = 0x4; + +ubyte isoctal (ubyte c) { return cmtable[c] & CMoctal; } +ubyte ishex (ubyte c) { return cmtable[c] & CMhex; } +ubyte isidchar(ubyte c) { return cmtable[c] & CMidchar; } + +static void cmtable_init() +{ + for( uint c = 0; c < cmtable.length; c++ ) + { + if( '0' <= c && c <= '7' ) + cmtable[c] |= CMoctal; + if( isdigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') ) + cmtable[c] |= CMhex; + if( isalnum(c) || c == '_' ) + cmtable[c] |= CMidchar; + } +} + + +/+ +struct StringValue +{ + union + { + int intvalue; + void *ptrvalue; + dchar *string; + } + + char[] lstring; +} +#define CASE_BASIC_TYPES + case TOKwchar: case TOKdchar: + case TOKbit: case TOKbool: case TOKchar: + case TOKint8: case TOKuns8: + case TOKint16: case TOKuns16: + case TOKint32: case TOKuns32: + case TOKint64: case TOKuns64: + case TOKfloat32: case TOKfloat64: case TOKfloat80: + case TOKimaginary32: case TOKimaginary64: case TOKimaginary80: + case TOKcomplex32: case TOKcomplex64: case TOKcomplex80: + case TOKvoid: + +#define CASE_BASIC_TYPES_X(t) \ + case TOKvoid: t = Type::tvoid; goto LabelX; \ + case TOKint8: t = Type::tint8; goto LabelX; \ + case TOKuns8: t = Type::tuns8; goto LabelX; \ + case TOKint16: t = Type::tint16; goto LabelX; \ + case TOKuns16: t = Type::tuns16; goto LabelX; \ + case TOKint32: t = Type::tint32; goto LabelX; \ + case TOKuns32: t = Type::tuns32; goto LabelX; \ + case TOKint64: t = Type::tint64; goto LabelX; \ + case TOKuns64: t = Type::tuns64; goto LabelX; \ + case TOKfloat32: t = Type::tfloat32; goto LabelX; \ + case TOKfloat64: t = Type::tfloat64; goto LabelX; \ + case TOKfloat80: t = Type::tfloat80; goto LabelX; \ + case TOKimaginary32: t = Type::timaginary32; goto LabelX; \ + case TOKimaginary64: t = Type::timaginary64; goto LabelX; \ + case TOKimaginary80: t = Type::timaginary80; goto LabelX; \ + case TOKcomplex32: t = Type::tcomplex32; goto LabelX; \ + case TOKcomplex64: t = Type::tcomplex64; goto LabelX; \ + case TOKcomplex80: t = Type::tcomplex80; goto LabelX; \ + case TOKbit: t = Type::tbit; goto LabelX; \ + case TOKchar: t = Type::tchar; goto LabelX; \ + case TOKwchar: t = Type::twchar; goto LabelX; \ + case TOKdchar: t = Type::tdchar; goto LabelX; \ + LabelX ++/ diff --git a/tests/input/d/bug-indent.d b/tests/input/d/bug-indent.d new file mode 100644 index 0000000000..512ba2d412 --- /dev/null +++ b/tests/input/d/bug-indent.d @@ -0,0 +1,17 @@ +class C +{ + //--------------| <= (1) + Axxxxxxxxxxxxxxxx.A createAssignment() + { + return(null); + } + void func2(){ + foreach (v; container) { + v.f(); + } + } + + // | <= (2) + void func3(TemplType !(T) aValue){ + } +} diff --git a/tests/input/d/casts.d b/tests/input/d/casts.d new file mode 100644 index 0000000000..42d5491637 --- /dev/null +++ b/tests/input/d/casts.d @@ -0,0 +1,13 @@ +void foo(int a) +{ + char ch; + + ch = cast(char) a; + ch = cast(char) 45; + ch = (char) a; // not a d cast + ch = (int)45; + ch = cast(foo)*bar; + ch = cast(foo)-bar; + ch = cast(foo)+45; + ch = cast(foo)&45; +} diff --git a/tests/input/d/delegate.d b/tests/input/d/delegate.d new file mode 100644 index 0000000000..0115ae00f7 --- /dev/null +++ b/tests/input/d/delegate.d @@ -0,0 +1,20 @@ +module er; + +void delegate(ubyte[] a) TSender; +bool delegate(ushort a) TVerifier; +typedef ushort TAddr; + +public void delegate(ubyte[] a) TSender; +public bool delegate(ushort a) TVerifier; +public typedef ushort TAddr; + +void delegate() dg; + dg = { int y; }; + + int opApply(int delegate(inout Type [, ...]) dg); + +void main() +{ + assert( findIf( "bcecg", ( int x ) { return x == 'a'; } ) == 5 ); +} + diff --git a/tests/input/d/funcfunc.d b/tests/input/d/funcfunc.d new file mode 100644 index 0000000000..ee717abc2c --- /dev/null +++ b/tests/input/d/funcfunc.d @@ -0,0 +1,5 @@ +int main() +{ + mWriter( "class Clst_"c )( cluster.getChild( HO_SHORT_NAME ).getText() )( " : Cluster {"c ).newline; +} + diff --git a/tests/input/d/imports.d b/tests/input/d/imports.d new file mode 100644 index 0000000000..758fefb732 --- /dev/null +++ b/tests/input/d/imports.d @@ -0,0 +1,8 @@ + +private import mango.cache.Payload; + +private import mango.io.Exception, + mango.io.PickleRegistry; + +public import mango.cluster.model.ICluster; + diff --git a/tests/input/d/numbers.d b/tests/input/d/numbers.d new file mode 100644 index 0000000000..e51bf8ace4 --- /dev/null +++ b/tests/input/d/numbers.d @@ -0,0 +1,45 @@ + +/* This file goes over all the various number formats for D */ + +int foo(int bar) +{ + int a; + + /* + * Interger Literals + */ + + /* Suffixes */ + a = 0L + 123U + 345u + 456Lu + 567LU + 678UL + 789_uL; + + /* Decimal */ + a = 0 + 123456 + 123_456 + 1_2_3_4_5_6; + + /* Binary */ + a = 0b1010101 + 0B1001; + + /* Octal */ + a = 01234567_ + 07_6_5_2; + + /* Hexadecimal */ + a = 0x1234567890abcdefABCDEF_ + 0X7_6_5_2; + + float b; + real c; + ifloat d; + ireal e; + + /* Floats: float [FloatSuffix] [ImaginarySuffix] */ + + /* HexFloat */ + b = 0xabc.defp-1024 + 0x.defP-64 + 0x123p+32 + 0x123P+16 + 0x123p1024; + d = 0x123p45 + 0x234.fi + 0. + .3f; + e = 3 + 5i; + e = 3.4 + 5.6i; +} + +/* test '..' ranges */ +void main() { + char[] c = "kkkkkkkkkkkkkkkkkkkkk"; + writefln("%s", c[2..3]); +} diff --git a/tests/input/d/sort_import.d b/tests/input/d/sort_import.d new file mode 100644 index 0000000000..d929f8e8bf --- /dev/null +++ b/tests/input/d/sort_import.d @@ -0,0 +1,19 @@ +// should be ddd, eee, fff +import ddd; +import fff; +import eee; + +// should be aaa, ccc +import ccc; +import aaa; +// should be just bbb +import bbb; + +// should not change these, as it can't handle multi-line imports +private import mango.ccc; +private import mango.bbb, + mango.aaa; + +void foo(); + + diff --git a/tests/input/d/strings.d b/tests/input/d/strings.d new file mode 100644 index 0000000000..a62adec32a --- /dev/null +++ b/tests/input/d/strings.d @@ -0,0 +1,32 @@ + +/* This file goes over all the various string formats for D */ + +int foo(int bar) +{ + char [] a; + char b; + + a = r"WYSIWYG"; + a = `WYSIWYG`; + b = 'c'; + a = x"12 34 5678 90"; + a = "This\nis a \"test\""; + a = \' ~ \" ~ \? ~ \\ ~ \a ~ \b ~ \f ~ \n ~ \r ~ \t ~ \v; + a = \x1B ~ \0 ~ \74 ~ \123; + a = \u1234 ~ \U12345678; + a = \& ~ 'a'; + a = "Another" " " "Test"; + + /+ test back to back EscapeSequences +/ + a = \r\n\xff\&\u1234; + + a = "char"c; + a = "wchar"w; + a = "dchar"d; + + /* + * multi line string + */ + a = r"Line 1 + line 2"; +} diff --git a/tests/input/d/template.d b/tests/input/d/template.d new file mode 100644 index 0000000000..f4f228e8ca --- /dev/null +++ b/tests/input/d/template.d @@ -0,0 +1,25 @@ + +template Foo(T, U) +{ +class Bar { } + +T foo(T t, U u) { } + +T abc; + +typedef T* FooType; +typedef Tte** FooType0; +typedef int* FooType1; +typedef const char FooType2; +} + +alias Foo!(int, char) f; +f.Bar b; +f.foo(1,2); +f.abc = 3; + +class Abc(T) +{ + T t; +} + diff --git a/tests/input/d/tst01.d b/tests/input/d/tst01.d new file mode 100644 index 0000000000..3a3728f23b --- /dev/null +++ b/tests/input/d/tst01.d @@ -0,0 +1,23 @@ +package void writeRegister(int aRegisterOffset, ushort aValue) +in { + assert(aRegisterOffset >= 0); + assert(aRegisterOffset < IMAGE_SIZE); +} body { +int idx = aRegisterOffset / 2; + mMemCache[idx] = aValue; + uint readback; + uint st; + uint st2; + volatile { + mMemImage[idx] = aValue; + //readback = (cast(uint*)mMemImage.ptr)[ idx/2 ]; + //st = mMemImage[ 0x28/2 ]; + //st2 = mMemImage[ 0x2A/2 ]; + } + //if( aValue != readback ) + { + //debug(IRQ) writefln( "writeRegister %04x, %04x", aRegisterOffset, aValue); + } + // comment +} +// diff --git a/tests/input/d/tst02.d b/tests/input/d/tst02.d new file mode 100644 index 0000000000..0b428d6004 --- /dev/null +++ b/tests/input/d/tst02.d @@ -0,0 +1,30 @@ + package static ushort calcHeaderCrc(bool aStartupFrame, bool aSyncFrame, ushort aFrameId, ushort aPayloadWords) { + uint crcData = aPayloadWords; + + crcData |= (aFrameId << 7); + + if (aSyncFrame) { + crcData |= BIT_19; + } + + if (aStartupFrame) { + crcData |= BIT_18; + } + + ushort crc = 0x1a; + const ushort table[16] = [ + 0x0000, 0x0385, 0x070A, 0x048F, + 0x0591, 0x0614, 0x029B, 0x011E, + 0x00A7, 0x0322, 0x07AD, 0x0428, + 0x0536, 0x06B3, 0x023C, 0x01B9]; + + for (int i = 0; i < 5; ++i) { + if (i != 0) { + crcData <<= 4; + } + crc = ((crc << 4) & 0x7FF) ^ table[((crc >> 7) ^ (crcData >> 16)) & 0x0F]; + } + + return(crc); + } + diff --git a/tests/input/d/tst03.d b/tests/input/d/tst03.d new file mode 100644 index 0000000000..611f12f940 --- /dev/null +++ b/tests/input/d/tst03.d @@ -0,0 +1,145 @@ +import std.stdio; + +void foo() +{ +float f = x % y; +double d = x % y; +real r = x % y; +result = (x < y); // false if x or y is nan +assert(e == 0); +int array[17]; +array[] = value; +int array[17]; +for (i = 0; i < array.length; i++) + func(array[i]); +int array[17]; +foreach (int value; array) + func(value); +int[] array; + +array.length = array.length + 1; +array[array.length - 1] = x; +char[] s1; +char[] s2; +char[] s; + +s = s1 ~ s2; +s ~= "hello"; + + +writefln("Calling all cars %s times!", ntimes); +Louter: + for (i = 0; i < 10; i++) + { + for (j = 0; j < 10; j++) + { + if (j == 3) + break Louter; + if (j == 4) + continue Louter; + } + } + // break Louter goes here + typedef bit bHandle; + typedef int iHandle = -1; +typedef void* Handle = cast(void*)(-1); +Handle h; +h = func(); +if (h != Handle.init) + ; +char[] string = "hello"; + +if (string < "betty") +; +int* p = address; + +volatile { i = *p; } + +char [] ml = "This text spans +multiple +lines +"; + +} + +void dostring(char[] s) +{ + switch (s) + { + case "hello": ; + case "goodbye": ; + case "maybe": ; + default: ; + } +} + +struct ABC +{ + int z; // z is aligned to the default + + align (1) int x; // x is byte aligned + align (4) + { + ... // declarations in {} are dword aligned + } + align (2): // switch to word alignment from here on + + int y; // y is word aligned +} + +struct Foo +{ + int i; + union + { + struct { int x; long y; } + char* p; + } +} + +struct Foo { int x; int y; } // note there is no terminating ; +Foo foo; + + +struct Foo { int x; int y; } + +off = Foo.y.offsetof; + +union U { int a; long b; } +U x = { a:5 }; + +struct S { int a; int b; } +S x = { b:3, a:5 }; + +int[3] a = [ 3, 2, 0 ]; +int[3] a = [ 3, 2 ]; // unsupplied initializers are 0, just like in C +int[3] a = [ 2:0, 0:3, 1:2 ]; +int[3] a = [ 2:0, 0:3, 2 ]; // if not supplied, the index is the + // previous one plus one. + +enum color { black, red, green } +int[3] c = [ black:3, green:2, red:5 ]; + +char[] file = `c:\root\file.c`; +char[] quoteString = \" r"[^\\]*(\\.[^\\]*)*" \"; + +char[] hello = "hello world" \n; +char[] foo_ascii = "hello"; // string is taken to be ascii +wchar[] foo_wchar = "hello"; // string is taken to be wchar + +enum COLORS { red, blue, green }; + +char[][COLORS.max + 1] cstring = +[ + COLORS.red : "red", + COLORS.blue : "blue", + COLORS.green : "green", +]; + + const ushort table1[16] = [ + 0x00A7, 0x0322, 0x07AD, 0x0428, + 0x0536, 0x06B3, 0x023C, 0x01B9]; + + const ushort table2[16] = [ 0x0000, 0x0385, 0x070A, 0x048F, + 0x0536, 0x06B3, 0x023C, 0x01B9]; + diff --git a/tests/input/d/volatile-1.d b/tests/input/d/volatile-1.d new file mode 100644 index 0000000000..c9f41d3f8f --- /dev/null +++ b/tests/input/d/volatile-1.d @@ -0,0 +1,10 @@ +{ + while (a) + { + volatile if (b) + { + b--; + break; + } + } +} diff --git a/tests/input/d/volatile-2.d b/tests/input/d/volatile-2.d new file mode 100644 index 0000000000..bc5a0de4c3 --- /dev/null +++ b/tests/input/d/volatile-2.d @@ -0,0 +1,8 @@ +{ + if (e) + volatile + { + a++; + } + return oldValue; +} diff --git a/tests/input/d/volatile-3.d b/tests/input/d/volatile-3.d new file mode 100644 index 0000000000..039f788a60 --- /dev/null +++ b/tests/input/d/volatile-3.d @@ -0,0 +1,7 @@ +{ + if (e) + { + if (!value) + volatile e.value = value; + } +} diff --git a/tests/input/d/volatile.d b/tests/input/d/volatile.d new file mode 100644 index 0000000000..c42d1893cb --- /dev/null +++ b/tests/input/d/volatile.d @@ -0,0 +1,27 @@ +void foo(void) +{ +while (nextSegmentIndex >= 0) +{ + Segment seg = map.segments[nextSegmentIndex--]; + volatile if (seg.count) + { + currentTable = seg.table; + for (int j = currentTable.length - 1; j >= 0; --j) + { + if ((nextEntry = currentTable[j]) !is null) + { + nextTableIndex = j - 1; + return; + } + } + } +} + +if (e) + volatile + { + oldValue = e.value; + e.value = newValue; + } +return oldValue; +} diff --git a/tests/input/ecma/example-1.es b/tests/input/ecma/example-1.es new file mode 100644 index 0000000000..0bc9b775ab --- /dev/null +++ b/tests/input/ecma/example-1.es @@ -0,0 +1,10 @@ +x = 0; // A global variable +var y = 'Hello!'; // Another global variable + +function f(){ + var z = 'foxes'; // A local variable + twenty = 20; // Global because keyword var is not used + return x; // We can use x here because it is global +} +// The value of z is no longer available + diff --git a/tests/input/oc/Declarations.h b/tests/input/oc/Declarations.h new file mode 100644 index 0000000000..e1ad3c6be4 --- /dev/null +++ b/tests/input/oc/Declarations.h @@ -0,0 +1,22 @@ + +@interface EmptyClass : NSObject +-(void)aMessage:(id)arg; +@end + +@interface EmptyClass : NSObject {} +-(void)aMessage:(id)arg; +@end + +@interface NSObject (ObjectAdditions) +-(void)aMessage:(id)arg; +@end + +@protocol TestProtocol +-(void)aMessage:(id)arg; +@end + +@interface TestClass : NSObject { +} +-(void)aMessage:(id)arg; +@end + diff --git a/tests/input/oc/Fraction.h b/tests/input/oc/Fraction.h new file mode 100644 index 0000000000..364b1de800 --- /dev/null +++ b/tests/input/oc/Fraction.h @@ -0,0 +1,14 @@ +#import + +@interface Fraction: NSObject { + int numerator; + int denominator; +} + +-(void) print; +-(void) setNumerator: (int) d; +-(void) setDenominator: (int) d; +-(int) numerator; +-(int) denominator; +-(void) setNumDen :(int)n:(int)d; +@end diff --git a/tests/input/oc/Fraction.m b/tests/input/oc/Fraction.m new file mode 100644 index 0000000000..20994f34de --- /dev/null +++ b/tests/input/oc/Fraction.m @@ -0,0 +1,24 @@ +#import "Fraction.h" +#import + +@implementation Fraction +-(void) print { + printf( "%i/%i", numerator, denominator ); +} + +-(void) setNumerator: (int) n { + numerator = n; +} + +-(void) setDenominator: (int) d { + denominator = d; +} + +-(int) denominator { + return denominator; +} + +-(int) numerator { + return numerator; +} +@end diff --git a/tests/input/oc/exceptions.m b/tests/input/oc/exceptions.m new file mode 100644 index 0000000000..ff728fd8bf --- /dev/null +++ b/tests/input/oc/exceptions.m @@ -0,0 +1,15 @@ + +int main( int argc, const char *argv[] ) { + @try { + [NSException raise:NSInternalInconsistency + format:@"An internal inconsistency was raised"]; + } + @catch (NSException *e) { + NSLog(@"Catch"); + } + @finally { + NSLog(@"Finally"); + } + + return 0; +} diff --git a/tests/input/oc/main.m b/tests/input/oc/main.m new file mode 100644 index 0000000000..f2fdf16ad1 --- /dev/null +++ b/tests/input/oc/main.m @@ -0,0 +1,21 @@ +#import +#import "Fraction.h" + +int main( int argc, const char *argv[] ) { + // create a new instance + Fraction *frac = [[Fraction alloc] init]; + + // set the values + [frac setNumerator: 1]; + [frac setDenominator: 3]; + + // print it + printf( "The fraction is: " ); + [frac print]; + printf( "\n" ); + + // free memory + [frac release]; + + return 0; +} diff --git a/tests/input/oc/misc.m b/tests/input/oc/misc.m new file mode 100644 index 0000000000..994148cfdf --- /dev/null +++ b/tests/input/oc/misc.m @@ -0,0 +1,19 @@ +- (id)init +{ +GLfloat wc[3][3] = {{ 0.6, 0.6, 0.0 }, { 1.0, 0.7, 0.1 }, { 0.5, 0.7, 0.2 +},}; +GLfloat cc[3][3] = {{ 0.0, 0.0, 0.6 }, { 0.3, 0.1, 0.5 }, { 0.0, 0.0, 0.5 +},}; +GLfloat sc[3] = {0.75, 0.75, 0.75}; + +return [self initWithWarmColors:(float *)&wc coolColors:(float *)&cc +surfaceColor:sc enableTexturing:NO enableSpecular:YES +enableQuakeDisruptor:NO]; + + [NSException raise:NSInternalInconsistency + format:@"An internal inconsistency was raised"]; + +for (i = 0; i <[a count]; i++) { + } +} + diff --git a/tests/input/oc/oc-split.m b/tests/input/oc/oc-split.m new file mode 100644 index 0000000000..3b656bfcc7 --- /dev/null +++ b/tests/input/oc/oc-split.m @@ -0,0 +1,10 @@ +[self findstart:&startBarcode end:&endBarcode forLine:greenScalePixels derivative:greenDerivative centerAt:xAxisCenterPoint min:&minValue max:&maxValue]; + +[self findstart:&startBarcode + end:&endBarcode + forLine:greenScalePixels + derivative:greenDerivative + centerAt:xAxisCenterPoint + min:&minValue + max:&maxValue]; + diff --git a/tests/input/oc/return_type.m b/tests/input/oc/return_type.m new file mode 100644 index 0000000000..62a5c24632 --- /dev/null +++ b/tests/input/oc/return_type.m @@ -0,0 +1,36 @@ +#import +#import + +@interface Fraction : NSObject { + int numerator; + int denominator; +} +-(void) print; +-(void)setNumerator:(int)d; +-(void)setDenominator:(int)d; +-(int) numerator; +-(int)denominator; +-(void) setNumDen:(int)n:(int)d; +@end + +@implementation Fraction +-(void)print { + printf("%i/%i", numerator, denominator); +} + +-(void) setNumerator:(int)n { + numerator = n; +} + +-(void) setDenominator:(int)d { + denominator = d; +} + +-(int) denominator { + return(denominator); +} + +-(int) numerator { + return(numerator); +} +@end diff --git a/tests/input/oc/selector.m b/tests/input/oc/selector.m new file mode 100644 index 0000000000..317b9bc800 --- /dev/null +++ b/tests/input/oc/selector.m @@ -0,0 +1,3 @@ +@selector(methodNameWithArg:); +@selector (methodNameNoArg); +@selector (methodNameArg1:arg2: ); \ No newline at end of file diff --git a/tests/input/oc/sort_import.m b/tests/input/oc/sort_import.m new file mode 100644 index 0000000000..48a3b2289a --- /dev/null +++ b/tests/input/oc/sort_import.m @@ -0,0 +1,11 @@ +// should be ddd, eee, fff +#import "ddd" +#import "fff" +#import "eee" + +// should be aaa, ccc +#import "ccc" +#import "aaa" +// should be just bbb +#import "bbb" + diff --git a/tests/input/oc/string.m b/tests/input/oc/string.m new file mode 100644 index 0000000000..f3fca80f20 --- /dev/null +++ b/tests/input/oc/string.m @@ -0,0 +1,11 @@ + +- (void)moreScannedData:(Image*)img from:(int)start to:(int)stop; +-(void)moreScannedData : (Image*)img from : (int)start to : (int)stop; + +public bool Enabled +{ + NSString* whatever = @"some lovely text, the fox and co"; + + a = (enderedImage->h - toplines - bottomlines); +} + diff --git a/tests/input/pawn/comment.p b/tests/input/pawn/comment.p new file mode 100644 index 0000000000..785521ac25 --- /dev/null +++ b/tests/input/pawn/comment.p @@ -0,0 +1,38 @@ +/* parse C comments interactively, using events and a state machine */ +main() + state plain +@keypressed(key) + { + state (key == '/') slash + if (key != '/') + echo key + } +@keypressed(key) + { + state (key != '/') plain + state (key == '*') comment + echo '/' /* print '/' held back from previous state */ + if (key != '/') + echo key + } +@keypressed(key) + { + echo key + state (key == '*') star + } +@keypressed(key) + { + echo key + state (key != '*') comment + state (key == '/') plain + } +echo(key) + printchar key, yellow +echo(key) + printchar key, green +printchar(ch, colour) + { + setattr .foreground = colour + printf "%c", ch + } + diff --git a/tests/input/pawn/crusty_ex-1.sma b/tests/input/pawn/crusty_ex-1.sma new file mode 100755 index 0000000000..35ee051531 --- /dev/null +++ b/tests/input/pawn/crusty_ex-1.sma @@ -0,0 +1,26 @@ +public hudtext16(textblock[],colr,colg,colb,posx,posy,screen,time,id) +{ + new y + if(contain(textblock,"^n") == -1) { // if there is no linebreak in the text, we can just show it as it is + set_hudmessage(colr, colg, colb, float(posx)/1000.0, float(posy)/1000.0, 0, 6.0, float(time), 0.2, 0.2, screen) + show_hudmessage(id,textblock) + } + else { // more than one line + new out[128],rowcounter=0,tmp[512],textremain=true;y=screen + + new i = contain(textblock,"^n") + + do + { + } + while(textremain > 0); + + copy(out,i,textblock) // we need to get the first line of text before the loop + + do + { + } + while(textremain) + } + return screen-y // we will return how many screens of text we printed +} diff --git a/tests/input/pawn/enum.pawn b/tests/input/pawn/enum.pawn new file mode 100644 index 0000000000..588efc3584 --- /dev/null +++ b/tests/input/pawn/enum.pawn @@ -0,0 +1,82 @@ + +enum rect { left, top , right, bottom } + +enum boot (<<= 1) { a=1, b, c, d } + +enum booty (<<= 1) +{ +a=1, b, c, d +} + +forward addvector(a[], const b[], size) + +enum message { + text[40 char], + priority +} + +enum token + { + t_type, + Rational: t_value, + t_word[20], + } + +new bool:flag = true + +increment(&value, incr=1) value += incr + +new msg[message] = { !"My Text", 1 } +main() { + new my_rect[rect] + + my_rect[left] = 10 + my_rect[right] = 100 + my_rect[top] = 10 + my_rect[bottom] = 100 + + for (new i = 0; rect:i < rect; i++) + my_rect[rect:i] *= 2 + + new vect[3] = { 1, 2, 3 } + addvector(vect, {5, 5, 5}, 3) + + new Float:xpos + new Float:ypos + + new a = 5 + increment(a) + increment(a, _) + increment(a, 1) +} + +sum(a, b) + return a + b + +power(x, y) + { + /* returns x raised to the power of y */ + assert y >= 0 + new r = 1 + for (new i = 0; i < y; i++) + r *= x + return r + } + +addvector(a[], const b[], size) + { + for (new i = 0; i < size; i++) + a[i] += b[i] + } + +stock remove_filepath(szFilePath[], szFile[], pMax) +{ + new len = strlen(szFilePath); + + while ((--len >= 0) && (szFilePath[len] != '/') && +(szFilePath[len] != '\'')) { } + + copy(szFile, pMax, szFilePath[len + 1]); + + return; +} diff --git a/tests/input/pawn/functions.pawn b/tests/input/pawn/functions.pawn new file mode 100644 index 0000000000..cdda5e0508 --- /dev/null +++ b/tests/input/pawn/functions.pawn @@ -0,0 +1,23 @@ + +// prototypes +forward bar() +native baz() +foo(); + +enum rect { left, top , right, bottom } +native intersect[rect](src1[rect], src2[rect]) + +native getparam(a[], b[], size) = host_getparam + +// function w/o brace +main() +printf("hello\n") +foo() bar() + +stock ts_is_waiting(id) return(ts_get_message(id) == TSMSG_WAITING) + +// regular old functions +baz() { + do_something() +} + diff --git a/tests/input/pawn/rpn_calc.pawn b/tests/input/pawn/rpn_calc.pawn new file mode 100644 index 0000000000..2965d9c771 --- /dev/null +++ b/tests/input/pawn/rpn_calc.pawn @@ -0,0 +1,71 @@ +/* main rpn parser and lexical analysis, part of the RPN calculator */ +#include +#include +enum token + { + t_type, /* operator or token type */ + Rational: t_value, /* value, if t_type is "Number" */ + t_word[20], /* raw string */ + } + +const Number = '0' +const EndOfExpr = '#' + +rpncalc(const string[]) + { + new index + new field[token] + for ( ;; ) + { + field = gettoken(string, index) + switch (field[t_type]) + { + case Number: + push field[t_value] + case '+': + push pop() + pop() + case '-': + push - pop() + pop() + case '*': + push pop() * pop() + case '/', ':': + push 1.0 / pop() * pop() + case EndOfExpr: + break /* exit "for" loop */ + default: + printf "Unknown operator '%s'\n", field[t_word] + } + } + + printf "Result = %r\n", pop() + + if (clearstack()) + print "Stack not empty\n", red + } + +gettoken(const string[], &index) + { + /* first get the next "word" from the string */ + new word[20] + word = strtok(string, index) + /* then parse it */ + new field[token] + field[t_word] = word + if (strlen(word) == 0) + { + field[t_type] = EndOfExpr /* special "stop" symbol */ + field[t_value] = 0 + } + else if ('0' <= word[0] <= '9') + { + field[t_type] = Number + field[t_value] = rationalstr(word) + } + else + { + field[t_type] = word[0] + field[t_value] = 0 + } + return field + } + diff --git a/tests/input/pawn/str-escape.p b/tests/input/pawn/str-escape.p new file mode 100644 index 0000000000..5600eae39d --- /dev/null +++ b/tests/input/pawn/str-escape.p @@ -0,0 +1,6 @@ +main() +{ + printf "This is a testof the ^" alternate escape char, value 0x5e" + printf "If ^" it doesn't work, there ^"should be some errors" +} + diff --git a/tests/input/pawn/switch-vsemi.sma b/tests/input/pawn/switch-vsemi.sma new file mode 100644 index 0000000000..c2efacfba4 --- /dev/null +++ b/tests/input/pawn/switch-vsemi.sma @@ -0,0 +1,16 @@ +public plugin_init() +{ + new i=5 + + switch(i){ + case 3: return false + case 5: + { + i = 6 + return true + } + default: { + return true + } + } +} \ No newline at end of file diff --git a/tests/input/pawn/tags.pawn b/tests/input/pawn/tags.pawn new file mode 100644 index 0000000000..4193b2a7da --- /dev/null +++ b/tests/input/pawn/tags.pawn @@ -0,0 +1,63 @@ + +enum token + { + t_type, + Rational: t_value, + t_word[20], + } + + +new bool:flag = true /* "flag" can only hold "true" or "false" */ +const error:success = 0 +const error:fatal= 1 +const error:nonfatal = 2 +error:errno = fatal + +native printf(const format[], {Float, _}: ...); + + new Float:chance_to_avoid = (p_resists[id][RESISTIDX_FIRE] >= RESIST_MAX_VALUE) ? + 1.00 : (float( p_resists[id][RESISTIDX_FIRE] ) / float( RESIST_MAX_VALUE )) + + xplevel_lev[j] = XP_PER_LEVEL_BASE_LT + ( (j - 10) * XP_PER_LEVEL_LT) + + floatround( float( j / 20 ) * XP_PER_LEVEL_LT ); + + +main() { + new Float:xpos + new Float:ypos + + new apple:elstar /* variable "elstar" with tag "apple" */ + new orange:valencia /* variable "valencia" with tag "orange" */ + new x /* untagged variable "x" */ + elstar = valencia /* tag mismatch */ + elstar = x /* tag mismatch */ + x = valencia /* ok */ + + new Float:chance_to_avoid = (p_resists[id][RESISTIDX_FIRE] >= RESIST_MAX_VALUE) ? + 1.00 : (float( p_resists[id][RESISTIDX_FIRE] ) / float( RESIST_MAX_VALUE )) + + xplevel_lev[j] = XP_PER_LEVEL_BASE_LT + ( (j - 10) * XP_PER_LEVEL_LT) + + floatround( float( j / 20 ) * XP_PER_LEVEL_LT ); + + if (apple:valencia < elstar) + valencia = orange:elstar + +some_label: // target for a goto + #pragma rational Float + + new Float:limit = -5.0 + new Float:value = -1.0 + if (value < limit) + printf("Value %f below limit %f\n", _:value, _:limit) + else + printf("Value above limit\n") + goto some_label +} + +foo() + if (ape) + dofunc(1) + else if (monkey) + dofunc(2) + else + dofunc(3) diff --git a/tests/input/pawn/test1.pawn b/tests/input/pawn/test1.pawn new file mode 100644 index 0000000000..ecefe6e03c --- /dev/null +++ b/tests/input/pawn/test1.pawn @@ -0,0 +1,59 @@ + +#define SCROLLMSG_SIZE 512 + +#define SCROLLMSG_SIZE 512 + +#define MIN(%1,%2) ((%1) < (%2) ? (%1) : (%2)) +#define MAX(%1,%2) ((%1)>(%2)?(%1):(%2)) + + +//Why doesn't it make them all one space? + +#define ADMIN_NORMAL (1<<1) +#define ADMIN_STEAM (1<<2) + + +#define ADMIN_NORMAL (1<<1) +#define ADMIN_STEAM (1<<2) + +//Why space before and after colon? + +new Float:g_xPos +new Float : g_xPos + +// col1 + // col2 + // col3 + // col4 + // col5 + +//Why so many tabs? +main() { + remove_task(123) /* remove current messaging */ + + remove_user_flags(0, read_flags("z")) // Remove 'user' flag from server rights + + new idtype = ADMIN_STEAM | ADMIN_LOOKUP // trail 1 + new idtype = ADMIN_STEAM|ADMIN_LOOKUP // trail 2 + // trail 3 + // trail 4 + + if (idtype & ADMIN_STEAM) + { + a++ + } + else if (equali(t_arg, "ip")) + { + b++ + } + + for (new _i=0; _i<_num; _i++) + { + c++ + } + + for (new _i = 0; _i < _num; _i++) + { + d++ + } +} diff --git a/tests/input/pawn/traffic.p b/tests/input/pawn/traffic.p new file mode 100644 index 0000000000..f5cf0f7fd4 --- /dev/null +++ b/tests/input/pawn/traffic.p @@ -0,0 +1,28 @@ +/* traffic light synchronizer, using states in an event-driven model */ +#include