diff options
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts')
29 files changed, 0 insertions, 5462 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/Gcov_test.sh b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/Gcov_test.sh deleted file mode 100755 index a3853773..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/Gcov_test.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash -# -# @author Guy Maurel -# @license GPL v2+ -# -# 30. 4. 2018 -# -# The script prepare a new version of uncrustify with the compile options: -# CMAKE_CXX_FLAGS -fprofile-arcs -ftest-coverage -# CMAKE_C_FLAGS -fprofile-arcs -ftest-coverage -# to use the facilities from gcov. -# Running uncrustify with all the test data will mark all parts of the sources -# which are used. -# The "not marked" portions, if any, should give the opportunity to prepare new -# test data to complete the whole tests. -# The results are stored in the directory ${TOTALS_DIR} -# The name of the file is ${source_file}.total -# The line(s) of code which are still not used by any of the tests cases are -# marked which the token "#####" at the beginning of the line. -# As the testing part (unc_tools.cpp, backup.cpp) are only used by a developper, -# all the lines are marked. -# Also the detect.cpp part of uncrustify is completly marked. -# -# TAKE ATTENTION: -# =============== -# -# Running the test is long. I need about 20 minutes. -# This is about 40 times so much as the ctest. -# The disk space necessary is also very big, about 3 Gbytes -# This is about 1500 times bigger as the sources. -# -SCRIPT_NAME=$0 -#echo "SCRIPT_NAME="${SCRIPT_NAME} -BASE_NAME=`basename ${SCRIPT_NAME}` -DIR_NAME=`dirname ${SCRIPT_NAME}` -if [ ${DIR_NAME} != "." ] ; -then - echo "you must use the script at the directory <uncrustify_directory>/scripts" - exit -fi -cd .. -SOURCES_LIST_H=`ls -1 src/*.h | cut -b 5-` -SOURCES_LIST_CPP=`ls -1 src/*.cpp | cut -b 5-` -# -rm -rf gcov_test -mkdir gcov_test -# -cd gcov_test -# build a new uncrustify binary -cmake -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_C_FLAGS="-fprofile-arcs -ftest-coverage" \ - -D CMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage" .. -make -# use uncrustify without parameter -./uncrustify -# -GCNO_LIST=`ls -1 ./CMakeFiles/uncrustify.dir/src/*.gcno` -for gcno_file in ${GCNO_LIST} -do - echo "gcno_file=${gcno_file}" - gcno_base_name=`basename ${gcno_file} .gcno` - echo ${gcno_base_name} - gcov ${gcno_file} -m -done -# -ADD_TEST_LIST="add_test_list.txt" -ADD_TEST_LIST_10="add_test_list_10.txt" -ADD_TEST_LIST_NUMBER="add_test_list_number.txt" -ADD_TEST_LIST_AWK="../scripts/add_test_list.awk" -ADD_TEST_LIST_CMD="add_test_list.sh" -# -# prepare a list of all tests -grep add_test ../build/tests/CTestTestfile.cmake > ${ADD_TEST_LIST} -cut -b 10- < ${ADD_TEST_LIST} > ${ADD_TEST_LIST_10} -cut --delimiter=" " --fields=1 < ${ADD_TEST_LIST_10} > ${ADD_TEST_LIST_NUMBER} -# -NUMBER_LIST=`cat ${ADD_TEST_LIST_NUMBER}` -# -# prepare a new script file to use uncrustify with all the tests cases -gawk --file ${ADD_TEST_LIST_AWK} \ - --assign sources_cpp="${SOURCES_LIST_CPP}" \ - --assign sources_h="${SOURCES_LIST_H}" < ${ADD_TEST_LIST} > ${ADD_TEST_LIST_CMD} -chmod +x ${ADD_TEST_LIST_CMD} -# -# ATTENTION: this takes about 10 minutes -# use the new script file ADD_TEST_LIST_CMD to build the information -./${ADD_TEST_LIST_CMD} -# -# compare, add the counts of each lines of generated gcov-tests -COMPARE_AND_ADD="../scripts/compare_the_gcov.awk" -TOTALS_DIR="Totals" -mkdir -p Totals -# -# choose -DO_IT_WITH_TEST="yes" -#DO_IT_WITH_TEST="no" -# -# and apply -if [ ${DO_IT_WITH_TEST} == "yes" ] -then - # do it with intermediate files - # to save the last file of each test - for test_number in ${NUMBER_LIST} - do - last_test_number=${test_number} - done - # - for source_file in ${SOURCES_LIST_CPP} - do - echo "source_file is ${source_file}" - I_file="blabla" - # this file doesn' exists - for test_number in ${NUMBER_LIST} - do - echo "source_file is ${source_file}: test_number=${test_number}" - H_DIR="${source_file}_Dir" - mkdir -p ${TOTALS_DIR}/${H_DIR} - TEST_FILE=${test_number}/${source_file}.gcov - if [ -s ${TEST_FILE} ] ; - then - O_file="${TOTALS_DIR}/${H_DIR}/${test_number}" - gawk --file ${COMPARE_AND_ADD} \ - --assign in_file="${I_file}" \ - --assign out_file="${O_file}" < ${TEST_FILE} - I_file=${O_file} - fi - # to brake before the end - #if [ "${test_number}" == "c-sharp_10010" ] - #if [ "${test_number}" == "c_10005" ] - #if [ "${test_number}" == "cpp_60042" ] - #then - # exit - #fi - done - # save the last file of each test - cp ${O_file} ${TOTALS_DIR}/${source_file}.total - done -else - # do it directly, without intermediate files - for source_file in ${SOURCES_LIST_CPP} - do - for test_number in ${NUMBER_LIST} - do - echo "source_file is ${source_file}: test_number=${test_number}" - TEST_FILE=${test_number}/${source_file}.gcov - TOTALS_FILE=${source_file} - if [ -s ${TEST_FILE} ] ; - then - gawk --file ${COMPARE_AND_ADD} \ - --assign in_file="${TOTALS_DIR}/${TOTALS_FILE}" \ - --assign out_file="${TOTALS_DIR}/${TOTALS_FILE}" < ${TEST_FILE} - fi - # to brake before the end - #if [ "${test_number}" == "c-sharp_10010" ] - #if [ "${test_number}" == "c_10005" ] - #if [ "${test_number}" == "cpp_60042" ] - #then - # exit - #fi - done - done -fi diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/Run_clang-tidy.sh b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/Run_clang-tidy.sh deleted file mode 100755 index c2f1c150..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/Run_clang-tidy.sh +++ /dev/null @@ -1,214 +0,0 @@ -#!/bin/bash -# -# 2017-02-27 -# -script_dir="$(dirname "$(readlink -f "$0")")" -# -SRC="${script_dir}/../src" -BUILD="${script_dir}/../build" -# -where=`pwd` -# -# build the lists -cd ${SRC} -list_of_C=`ls *.cpp` -list_of_H=`ls *.h` -list_of_files="${list_of_C} ${list_of_H}" -cd ${where} -# -RESULTS="${script_dir}/../results" -# -rm -rf ${RESULTS} -mkdir ${RESULTS} -# -COMPILE_COMMANDS="compile_commands.json" -cp ${BUILD}/${COMPILE_COMMANDS} ${SRC} -# -# choise one of list of checks -list_of_Check="\ - boost-use-to-string\ - cert-dcl21-cpp\ - cert-dcl50-cpp\ - cert-dcl58-cpp\ - cert-env33-c\ - cert-err34-c\ - cert-err52-cpp\ - cert-err58-cpp\ - cert-err60-cpp\ - cert-flp30-c\ - cert-msc50-cpp\ - cppcoreguidelines-interfaces-global-init\ - cppcoreguidelines-no-malloc\ - cppcoreguidelines-pro-bounds-array-to-pointer-decay\ - cppcoreguidelines-pro-bounds-constant-array-index\ - cppcoreguidelines-pro-bounds-pointer-arithmetic\ - cppcoreguidelines-pro-type-const-cast\ - cppcoreguidelines-pro-type-cstyle-cast\ - cppcoreguidelines-pro-type-member-init\ - cppcoreguidelines-pro-type-reinterpret-cast\ - cppcoreguidelines-pro-type-static-cast-downcast\ - cppcoreguidelines-pro-type-union-access\ - cppcoreguidelines-pro-type-vararg\ - cppcoreguidelines-slicing\ - cppcoreguidelines-special-member-functions\ - google-build-explicit-make-pair\ - google-build-namespaces\ - google-build-using-namespace\ - google-default-arguments\ - google-explicit-constructor\ - google-global-names-in-headers\ - google-readability-casting\ - google-readability-todo\ - google-runtime-int\ - google-runtime-member-string-references\ - google-runtime-memset\ - google-runtime-operator\ - google-runtime-references\ - hicpp-explicit-conversions\ - hicpp-function-size\ - hicpp-invalid-access-moved\ - hicpp-member-init\ - hicpp-named-parameter\ - hicpp-new-delete-operators\ - hicpp-no-assembler\ - hicpp-noexcept-move\ - hicpp-special-member-functions\ - hicpp-undelegated-constructor\ - hicpp-use-equals-default\ - hicpp-use-equals-delete\ - hicpp-use-override\ - llvm-header-guard\ - llvm-include-order\ - llvm-namespace-comment\ - llvm-twine-local" -#list_of_Check="misc-argument-comment\ -# misc-assert-side-effect\ -# misc-bool-pointer-implicit-conversion\ -# misc-dangling-handle\ -# misc-definitions-in-headers\ -# misc-fold-init-type\ -# misc-forward-declaration-namespace\ -# misc-forwarding-reference-overload\ -# misc-inaccurate-erase\ -# misc-incorrect-roundings\ -# misc-inefficient-algorithm\ -# misc-macro-parentheses\ -# misc-macro-repeated-side-effects\ -# misc-misplaced-const\ -# misc-misplaced-widening-cast\ -# misc-move-const-arg\ -# misc-move-constructor-init\ -# misc-move-forwarding-reference\ -# misc-multiple-statement-macro\ -# misc-new-delete-overloads\ -# misc-noexcept-move-constructor\ -# misc-non-copyable-objects\ -# misc-redundant-expression\ -# misc-sizeof-container\ -# misc-sizeof-expression\ -# misc-static-assert\ -# misc-string-compare\ -# misc-string-constructor\ -# misc-string-integer-assignment\ -# misc-string-literal-with-embedded-nul\ -# misc-suspicious-enum-usage\ -# misc-suspicious-missing-comma\ -# misc-suspicious-semicolon\ -# misc-suspicious-string-compare\ -# misc-swapped-arguments\ -# misc-throw-by-value-catch-by-reference\ -# misc-unconventional-assign-operator\ -# misc-undelegated-constructor\ -# misc-uniqueptr-reset-release\ -# misc-unused-alias-decls\ -# misc-unused-parameters\ -# misc-unused-raii\ -# misc-unused-using-decls\ -# misc-use-after-move\ -# misc-virtual-near-miss" -#list_of_Check="modernize-avoid-bind\ -# modernize-deprecated-headers\ -# modernize-loop-convert\ -# modernize-make-shared\ -# modernize-make-unique\ -# modernize-pass-by-value\ -# modernize-raw-string-literal\ -# modernize-redundant-void-arg\ -# modernize-replace-auto-ptr\ -# modernize-replace-random-shuffle\ -# modernize-return-braced-init-list\ -# modernize-shrink-to-fit\ -# modernize-use-auto\ -# modernize-use-bool-literals\ -# modernize-use-default-member-init\ -# modernize-use-emplace\ -# modernize-use-equals-default\ -# modernize-use-equals-delete\ -# modernize-use-nullptr\ -# modernize-use-override\ -# modernize-use-transparent-functors\ -# modernize-use-using\ -# mpi-buffer-deref\ -# mpi-type-mismatch\ -# performance-faster-string-find\ -# performance-for-range-copy\ -# performance-implicit-cast-in-loop\ -# performance-inefficient-string-concatenation\ -# performance-inefficient-vector-operation\ -# performance-type-promotion-in-math-fn\ -# performance-unnecessary-copy-initialization\ -# performance-unnecessary-value-param" -#list_of_Check="readability-avoid-const-params-in-decls\ -# readability-braces-around-statements\ -# readability-container-size-empty\ -# readability-delete-null-pointer\ -# readability-deleted-default\ -# readability-else-after-return\ -# readability-function-size\ -# readability-identifier-naming\ -# readability-implicit-bool-cast\ -# readability-inconsistent-declaration-parameter-name\ -# readability-misleading-indentation\ -# readability-misplaced-array-index\ -# readability-named-parameter\ -# readability-non-const-parameter\ -# readability-redundant-control-flow\ -# readability-redundant-declaration\ -# readability-redundant-function-ptr-dereference\ -# readability-redundant-member-init\ -# readability-redundant-smartptr-get\ -# readability-redundant-string-cstr\ -# readability-redundant-string-init\ -# readability-simplify-boolean-expr\ -# readability-static-definition-in-anonymous-namespace\ -# readability-uniqueptr-delete-release" -# -for file in ${list_of_files} -do - echo "test for "${file} - OUTPUT="${RESULTS}/${file}.txt" - for check in ${list_of_Check} - do - echo " test for "${check} - clang-tidy -checks="-*, ${check}" -header-filter="./${SRC}/*" ${SRC}/${file} \ - > ${OUTPUT} 2>/dev/null - if [[ -s ${OUTPUT} ]] - then - head ${OUTPUT} - break - else - rm -f ${OUTPUT} - fi - done -done -# -rm ${SRC}/${COMPILE_COMMANDS} -rmdir --ignore-fail-on-non-empty ${RESULTS} -if [[ -d ${RESULTS} ]] -then - echo "some problem(s) are still present" - exit 1 -else - echo "all clang-tidy are OK" - exit 0 -fi diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/add_test_list.awk b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/add_test_list.awk deleted file mode 100644 index 1fbe2840..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/add_test_list.awk +++ /dev/null @@ -1,56 +0,0 @@ -BEGIN { - Test_Count = 0; - count_cpp = split(sources_cpp, source_list_cpp, " "); - printf("#count_cpp= %d\n", count_cpp); - count_h = split(sources_h, source_list_h, " "); - printf("#count_h= %d\n", count_h); -} -{ - theLine = $0; - command = substr(theLine, 10); - split(command, parts, " "); - number = parts[1]; - lang = substr(parts[4], 14); - l_lang = length(lang); - lang_2 = substr(lang, 1, l_lang - 1); - config = substr(parts[5], 16); - input_file = substr(parts[7], 15); - - printf("echo \"Run uncrustify: The TESTNUMBER is %s\"\n", number); - printf("rm -rf %s\n", number); - printf("mkdir %s\n", number); - printf("cd %s\n", number); - printf("mkdir save\n"); - printf("../uncrustify -q -c \"../../tests/%s -f \"../../tests/%s -l %s -o /dev/null\n", - config, input_file, lang_2); - for (i = 1; i <= count_cpp; i++) { - source_file = source_list_cpp[i]; - function_file = sprintf("../CMakeFiles/uncrustify.dir/src/%s.gcno", source_file); - printf("if [ -s %s ] ;\n", function_file); - printf("then\n"); - printf(" gcov %s 2> /dev/null 1> /dev/null\n", function_file, source_file); - printf("fi\n"); - printf("if [ -s %s.* ] ;\n", source_file); - printf("then\n"); - printf(" mv -f %s.* ./save/\n", source_file); - printf("fi\n"); - } - for (i = 1; i <= count_h; i++) { - source_file = source_list_h[i]; - printf("if [ -s %s.* ] ;\n", source_file); - printf("then\n"); - printf(" mv -f %s.* ./save/\n", source_file); - printf("fi\n"); - } - printf(" rm *.gcov\n"); - printf(" mv save/* .\n"); - printf("rmdir save\n"); - printf("cd ..\n\n"); - # to brake before the end - #Test_Count = Test_Count + 1; - #if ( Test_Count == 1000) { - #if ( Test_Count == 109) { - #if ( Test_Count == 2) { - # printf("exit\n"); - #} -} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/check_options.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/check_options.py deleted file mode 100644 index 1d32224b..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/check_options.py +++ /dev/null @@ -1,80 +0,0 @@ -#! /usr/bin/env python -# -# Check the option usage. -# Make sure the union member matches the option type. -# -from os.path import dirname, join, abspath -from os import listdir, EX_OK, EX_DATAERR -from fnmatch import filter - -# just use the first letter of the member name - should be unique -map_access_type = { - 'b': 'AT_BOOL', - 'a': 'AT_IARF', - 'n': 'AT_NUM', - 'u': 'AT_UNUM', - 'l': 'AT_LINE', - 't': 'AT_POS', -} -map_option_type = {} - - -# checks if while accessing the cpd.settings the right union accessor is used in the file -def check_file(file_path): - problems = 0 - line_no = 0 - - fd = open(file_path, 'r') - for line in fd: - line_no += 1 - - pos_cpd_s = line.find('cpd.settings[UO_') - pos_cpd_e = line[pos_cpd_s:].find(']') - if pos_cpd_s > 0 and pos_cpd_e > 0: - pos_option_s = pos_cpd_s + 13 - pos_option_e = pos_cpd_s + pos_cpd_e - - option = line[pos_option_s : pos_option_e] - union_access = line[pos_option_e + 2] - - if option in map_option_type and union_access in map_access_type: - if map_option_type[option] != map_access_type[union_access]: - print("%s [%d] %s should use %s not %s" % (file_path, line_no, option, - map_option_type[option], map_access_type[union_access])) - problems += 1 - return problems - - -def fill_map_option_type(file_path): - # Read in all the options - fd = open(file_path, 'r') - for line in fd: - if line.find('unc_add_option') > 0 and line.find('UO_') > 0: - splits = line.split(',') - if len(splits) >= 3: - map_option_type[splits[1].strip()] = splits[2].strip() - fd.close() - - -def main(): - src_dir = join(dirname(dirname(abspath(__file__))), 'src') - fill_map_option_type(join(src_dir, 'options.cpp')) - - # Get a list of all the source files - ld = listdir(src_dir) - src_files = filter(ld, '*.cpp') - src_files.extend(filter(ld, '*.h')) - - # Check each source file - problems = 0 - for fn in src_files: - problems += check_file(join(src_dir, fn)) - if problems == 0: - print("No problems found") - return EX_OK - else: - return EX_DATAERR - -if __name__ == '__main__': - exit(main()) - diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/cmpcfg.pl b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/cmpcfg.pl deleted file mode 100755 index df119dc1..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/cmpcfg.pl +++ /dev/null @@ -1,101 +0,0 @@ -#!/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 (<FH>) { - 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/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/compare_the_gcov.awk b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/compare_the_gcov.awk deleted file mode 100644 index 30dba1ad..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/compare_the_gcov.awk +++ /dev/null @@ -1,136 +0,0 @@ -BEGIN { - number_of_lines = 0; - number_of_header = 0; - T_number_of_lines = 0; - T_number_of_header = 0; - input_file = in_file; - output_file = out_file; - # - # get the first line, if any. - getline aaa <input_file; - if (ERRNO != "") { - #printf("ERRNO is %s\n", ERRNO); - #printf("a new file will be created at %s\n", output_file); - # totals-file not found, this is the first run. - first_run = "yes"; - } else { - # totals-file is found. Read it into the arrays - first_run = "no"; - for ( i = 1; i < 20000; i++) { - theLine = aaa; - where_is_colon_1 = index(theLine, ":"); - part_1 = substr(theLine, 1, where_is_colon_1 - 1); - rest_1 = substr(theLine, where_is_colon_1 + 1); - where_is_colon_2 = index(rest_1, ":"); - part_2 = substr(rest_1, 1, where_is_colon_2 - 1) + 0; - rest_2 = substr(rest_1, where_is_colon_2 + 1); - if (part_2 == 0) { - # header part - T_number_of_header = T_number_of_header + 1; - T_header_part1[T_number_of_header] = part_1; - T_header_part2[T_number_of_header] = part_2; - T_header_part3[T_number_of_header] = rest_2; - } else { - # source lines - # a new line - T_number_of_lines = part_2; - T_source_part1[T_number_of_lines] = part_1; - T_source_part2[T_number_of_lines] = part_2; - T_source_part3[T_number_of_lines] = rest_2; - } - - aaa = ""; - # get the next line - getline aaa <input_file; - if (aaa == "") { - # EOF - break; - } - } - close(input_file); - # Test it - #printf("Test it\n"); - #for (i = 1; i <= T_number_of_header; i++) { - # printf("%8s:%5d:%s\n", T_header_part1[i], T_header_part2[i], T_header_part3[i]); - #} - #for (i = 1; i <= T_number_of_lines; i++) { - # printf("%8s:%5d:%s\n", T_source_part1[i], T_source_part2[i], T_source_part3[i]); - #} - } -} - -{ - theLine = $0; - where_is_colon_1 = index(theLine, ":"); - part_1 = substr(theLine, 1, where_is_colon_1 - 1); - rest_1 = substr(theLine, where_is_colon_1 + 1); - where_is_colon_2 = index(rest_1, ":"); - part_2 = substr(rest_1, 1, where_is_colon_2 - 1) + 0; - rest_2 = substr(rest_1, where_is_colon_2 + 1); - if (part_2 == 0) { - # header part - number_of_header = number_of_header + 1; - header_part1[number_of_header] = part_1; - header_part2[number_of_header] = part_2; - header_part3[number_of_header] = rest_2; - } else { - # source lines - # a new line - number_of_lines = part_2; - source_part1[number_of_lines] = part_1; - source_part2[number_of_lines] = part_2; - source_part3[number_of_lines] = rest_2; - where_ = index(part_1, "-"); - if (where_ > 0) { - # don't take care - } else { - where_2 = index(part_1, "#####"); - if (where_2 > 0) { - # don't take care - } else { - d_part_1 = part_1 + 0; - # look at T_source_part1[part_2] - where_3 = index(T_source_part1[part_2], "#####"); - if (where_3 > 0) { - sum = d_part_1; - # write the sum to T_source_part1 - T_source_part1[part_2] = d_part_1; - } else { - d_T = T_source_part1[part_2] + 0; - sum = d_part_1 + d_T; - # write the sum back to T_source_part1 - T_source_part1[part_2] = sum; - } - } - } - } -} -END { - if (first_run == "yes") { - # copy to T_ - T_number_of_header = number_of_header; - T_number_of_lines = number_of_lines; - for(i = 1; i <= T_number_of_header; i++) { - T_header_part1[i] = header_part1[i]; - T_header_part2[i] = header_part2[i]; - T_header_part3[i] = header_part3[i]; - } - for (i = 1; i <= T_number_of_lines; i++) { - T_source_part1[i] = source_part1[i]; - T_source_part2[i] = source_part2[i]; - T_source_part3[i] = source_part3[i]; - } - } - #printf("T_number_of_header is %d\n", T_number_of_header); - #printf("T_number_of_lines is %d\n", T_number_of_lines); - - # delete the previous version - printf("") > output_file; - for(i = 1; i <= T_number_of_header; i++) { - printf("%9s:%5d:%s\n", T_header_part1[i], T_header_part2[i], T_header_part3[i]) >> output_file; - } - for (i = 1; i <= T_number_of_lines; i++) { - printf("%9s:%5d:%s\n", T_source_part1[i], T_source_part2[i], T_source_part3[i]) >> output_file; - } - close(output_file); -} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_changelog.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_changelog.py deleted file mode 100755 index 8e042385..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_changelog.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python - -''' -This script attempts to extract what options have been added since the -specified revision (usually a tag, but any revision that git recognizes may be -provided). It accepts an optional second revision to use as the cut-off. The -default is your LOCAL "master". Thus, you should ensure that this is up to date -before running this script. - -This script works by extracting the set of options before and after every -commit that affected ':src/options.h' and computing the differences. It should, -therefore, be fairly robust (for example, options that moved around won't show -up). However, if an option is removed and subsequently re-added, or if an -option was added and subsequently removed, the resulting records will need to -be reconciled manually. -''' - -import argparse -import git -import os -import re -import sys -import time - -re_option = re.compile(r'extern (Bounded)?Option<[^>]+>') - - -# ----------------------------------------------------------------------------- -def extract_options(repo, blob_id): - from git.util import hex_to_bin - - blob = git.Blob(repo, hex_to_bin(blob_id)) - content = blob.data_stream.stream - options = set() - - for line in iter(content.readline, b''): - line = line.decode('utf-8').strip() - - if re_option.match(line): - line = content.readline().decode('utf-8').strip() - options.add(line.split(';')[0]) - - return options - - -# ============================================================================= -class Changeset(object): - # ------------------------------------------------------------------------- - def __init__(self, repo, sha): - self.sha = sha - self.added_options = set() - self.removed_options = set() - - commit = repo.commit(sha) - ad = time.gmtime(commit.authored_date) - self.date = time.strftime('%b %d %Y', ad).replace(' 0', ' ') - - info = repo.git.log('-1', '--raw', '--abbrev=40', '--pretty=', - sha, '--', ':src/options.h').split(' ') - if len(info) < 5: - return - - old_options = extract_options(repo, info[2]) - new_options = extract_options(repo, info[3]) - self.added_options = new_options.difference(old_options) - self.removed_options = old_options.difference(new_options) - - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser( - description='Generate changelog for new options') - - root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) - parser.add_argument('--repo', type=str, default=root, - help='Path to uncrustify git repository') - parser.add_argument('since', type=str, - help='Revision (tag) of previous uncrustify version') - parser.add_argument('until', type=str, default='master', nargs='?', - help='Revision (tag) of next uncrustify version') - - args = parser.parse_args() - repo = git.Repo(args.repo) - revs = repo.git.log('--pretty=%H', '--reverse', - '{}..{}'.format(args.since, args.until), - '--', ':src/options.h').split('\n') - - if revs == ['']: - print('No changes were found') - return 1 - - changes = [] - for r in revs: - c = Changeset(repo, r) - if len(c.added_options) or len(c.removed_options): - changes.append(c) - - for c in changes: - print(c.sha) - for o in c.added_options: - print(' Added : {:36} {}'.format(o, c.date)) - for o in c.removed_options: - print(' Removed : {:36} {}'.format(o, c.date)) - - return 0 - - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -if __name__ == '__main__': - sys.exit(main()) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_config_combinations_uniq_output.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_config_combinations_uniq_output.py deleted file mode 100644 index 2fa4fb0c..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_config_combinations_uniq_output.py +++ /dev/null @@ -1,493 +0,0 @@ -from __future__ import print_function # python >= 2.6 -from os import makedirs, path, listdir, rename, remove -from subprocess import Popen -from filecmp import cmp -from glob import iglob -from shutil import rmtree -from json import loads as json_loads, dump as json_dump -from sys import stderr, argv, path as sys_path - -""" -gen_config_combinations_uniq_output.py - -Creates from a given set of options all possible option settings -combinations, formats files with those and displays how much non equal -formatted outputs have been created. - -Expects arg1 to be a filepath to a json config file - (see config example below) - -:author: Daniel Chumak -:license: GPL v2+ -""" - - -# config = { -# "option_settings": { -# "AT_BOOL": ["False", "True"], -# "AT_IARF": ["ignore", "add", "remove", "force"], -# "AT_POS": ["ignore", "join", "lead", "lead_break", "lead_force", -# "trail", "trail_break", "trail_force"], -# "AT_LINE": ["auto", "lf", "crlf", "cr"], -# "AT_NUM": [-2, -1, 0, 1, 2, 3], -# "AT_UNUM": [0, 1, 2, 3] -# }, -# "options": [{ -# "name": "nl_func_type_name", -# "type": "AT_IARF" -# }, { -# "name": "nl_template_class", -# "type": "AT_IARF" -# }], -# "out_dir": "./Out", -# "in_files": ["./t.cpp", "./t2.cpp"], -# "unc_bin": "../build/uncrustify", -# "cleanup_lvl": 2, -# "force_cleanup": false, -# "json_output": false -# } -# - - -def len_index_combinations(max_indices): - """generator function that yields a list starting from - n_0 = 0, ... n_m-1 = 0, n_m = 0 - ... - n_0 = 0, ... n_m-1 = 0, n_m = n_m_max - ... - n_0 = 0, ... n_m-1 = 1, n_m = 0 - n_0 = 0, ... n_m-1 = 1, n_m = 1 - ... - n_0 = 0, ... n_m-1 = n_m-1_max, n_m = n_m_max - ... - n_0 = n_0_max, ... n_m-1 = n_m-1_max, n_m = n_m_max - - - :param max_indices: list of max values every position is going to reach - - :yield: list of values at the current step - """ - - fields = len(max_indices) - accu = [0] * fields - - # increment last position n, on max val move pos by one (n-1) and increment - # if (n-1) is max move again (n-2) and increment, ... - pos = fields - while pos >= 0: - yield (accu) - - pos = fields - 1 - accu[pos] += 1 - - # on reaching max reset value, move pos and increment at pos - while pos >= 0 and accu[pos] >= max_indices[pos]: - accu[pos] = 0 - pos -= 1 - - if pos >= 0: - accu[pos] += 1 - - -def write_config_files(config): - """Writes a configuration file for each possible combination of 'option' - settings - - :param config: configuration object, expects that it was processed by - check_config - """ - - options_len = len(config["options"]) - - # populate len_options with amount of settings for the types of each option - len_options = [0] * options_len - for i in range(options_len): - option_setting = config["options"][i]["type"] - len_options[i] = len(config["option_settings"][option_setting]) - - # write configuration files, one per possible combination - for combination in len_index_combinations(len_options): - len_indices = len(combination) - - # generate output filepath - file_path = config['out_dir'] + "/" - for i in range(len_indices): - option_name = config["options"][i]["name"] - file_path += ("%s__" % option_name) - for i in range(len_indices): - option_type = config["options"][i]["type"] - option_setting = combination[i] - file_path += ("%d__" % option_setting) - file_path += "unc.cfg" - - # write configuration file - with open(file_path, 'w') as f: - for i in range(len_indices): - option_name = config["options"][i]["name"] - option_type = config["options"][i]["type"] - option_setting = config["option_settings"][option_type][ - combination[i]] - - f.write("%s = %s\n" % (option_name, option_setting)) - - -def gen_equal_output_map(config): - """Formats 'in_files' with configs inside the 'out_dir' with Uncrustify and - groups formatted files with equal content together. - Expects config filename format generated by write_config_files - - :param config: configuration object, expects that it was processed by - check_config - :return: dict of files with equal content - key -- group index - value -- filepath list - """ - - # maps that will hold configurations that produce the same formatted files - equal_output_map = {} - # map len counter - map_val_idx = 0 - - # iterate through all generated config file names - - for cfg_path in sorted(iglob('%s/*.cfg' % config["out_dir"])): - for in_file_idx in range(len(config["in_files"])): - # extract substring form config gile name (removes __unc.cfg) - splits_file = cfg_path.split("__unc") - if len(splits_file) < 1: - raise Exception('split with "__unc" | Wrong split len: %d' - % len(splits_file)) - - out_path = ("%s__%d" % (splits_file[0], in_file_idx)) - - # gen formatted files with uncrustify binary - proc = Popen([config["unc_bin"], - "-c", cfg_path, - "-f", config["in_files"][in_file_idx], - "-o", out_path, - ]) - proc.wait() - if proc.returncode != 0: - continue - - # populate 'equal_output_map' map - if len(equal_output_map) == 0: - equal_output_map[0] = [out_path] - map_val_idx += 1 - else: - found_flag = False - for i in range(map_val_idx): - # compare first file of group i with the generated file - if cmp(equal_output_map[i][0], out_path): - equal_output_map[i].append(out_path) - found_flag = True - break - # create new group if files do not match - if not found_flag: - equal_output_map[map_val_idx] = [out_path] - map_val_idx += 1 - - return equal_output_map - - -def gen_output_dict(config, equal_output_map): - """Makes an output dict with the generated results. - - :param config: configuration object, expects that it was processed by - check_config - - :param equal_output_map: dict of files with equal content, - expects format generated by gen_equal_output_map - :return: output dict, format: - copies objects option_settings, options and in_files (renamed as - files) from the config object. Additionally has the object groups - that holds gourp - file - settings combination data - format: - groups = [ [fileIdx0[ - [settingIdx0, settingIdx1, ...], - [settingIdx0, settingIdx1, ...] ] ] - [fileIdx1[ - [settingIdx0, settingIdx1, ...], - [settingIdx0, settingIdx1, ...] ] ] - ] - """ - - output_dict = {"option_settings": config["option_settings"], - "options": config["options"], - "files": config["in_files"], - "groups": []} - - options_len = len(output_dict["options"]) - files_len = len(output_dict["files"]) - - for key in equal_output_map: - group_dict = [] - for file_arr_idx in range(files_len): - group_dict.append([]) - - for list_value in equal_output_map[key]: - split = list_value.rsplit("/", 1) - split = split[len(split) - 1].split("__") - split_len = len(split) - - # n option names + n option values + file idx - if split_len < options_len * 2 + 1: - print(" wrong split len on %s\n" % list_value, file=stderr) - continue - - file_idx = int(split[split_len - 1]) - file_combinations = [int(i) for i in split[options_len:split_len-1]] - - group_dict[file_idx].append(file_combinations) - - output_dict["groups"].append(group_dict) - - return output_dict - - -def write_output_dict_pretty(out_dict, out_path): - """pretty prints the output dict into a file - - :param out_dict: dict that will be printed, expects format generated by - gen_output_dict - - :param out_path: output filepath - """ - - group_id = 0 - options_len = len(out_dict["options"]) - - with open(out_path, 'w') as f: - - f.write("Files:\n") - for in_file_idx in range(len(out_dict["files"])): - f.write(" %d: %s\n" % (in_file_idx, - out_dict["files"][in_file_idx])) - - f.write("\nOptions:\n") - for option_idx in range(options_len): - f.write(" %d: %s\n" % (option_idx, - out_dict["options"][option_idx]["name"])) - f.write("\n\n") - - for group in out_dict["groups"]: - f.write("Group: %d\n" % group_id) - group_id += 1 - - for file_idx in range(len(group)): - file = group[file_idx] - - for combinations in file: - combination_strings = [] - for combination_idx in range(len(combinations)): - - combination_id = combinations[combination_idx] - combination_string = out_dict["option_settings"][ - out_dict["options"][combination_idx]["type"]][ - combination_id] - combination_strings.append(str(combination_string)) - f.write(" (%s: %s)\n" % (file_idx, - " - ".join(combination_strings))) - f.write("\n") - - -def load_config(file_path): - """reads a file and parses it as json - - :param file_path: path to the json file - - :return: json object - """ - - with open(file_path, 'r') as f: - string = f.read() - json = json_loads(string) - - return json - - -def make_abs_path(basis_abs_path, rel_path): - return path.normpath(path.join(basis_abs_path, rel_path)) - - -def check_config(config, cfg_path=""): - """checks if the provided config has all needed options, sets default - settings for optional options and transform relative paths into absolute - paths. - - :param config: config dict that will be checked - - :param cfg_path: if not empty transforms relative to absolute paths, - paths will be based upon the cfg_path. - """ - - extend_relative_paths = True if len(cfg_path) > 0 else False - cfg_path = path.abspath(path.dirname(cfg_path)) - - # -------------------------------------------------------------------------- - - if "option_settings" not in config: - raise Exception("config file: 'option_settings' missing") - - if len(config["option_settings"]) == 0: - raise Exception("config file: 'option_settings' values missing") - - # -------------------------------------------------------------------------- - - if "options" not in config: - raise Exception("config file: 'options' missing") - - if len(config["options"]) < 2: - raise Exception("config file: 'options' min. two options needed") - - for option_obj in config["options"]: - if "name" not in option_obj: - raise Exception("config file: 'options[{}]' name missing") - if "type" not in option_obj: - raise Exception("config file: 'options[{}]' type missing") - if option_obj["type"] not in config["option_settings"]: - raise Exception("config file: 'options[{type='%s'}]' not in option_" - "settings" % option_obj["type"]) - - # -------------------------------------------------------------------------- - - if "out_dir" not in config: - raise Exception("config file: 'out_dir' missing") - - if len(config['out_dir']) == 0: - raise Exception("config file: 'out_dir' value missing") - - if extend_relative_paths and not path.isabs(config['out_dir']): - config['out_dir'] = make_abs_path(cfg_path, config['out_dir']) - - # -------------------------------------------------------------------------- - - if "in_files" not in config: - raise Exception("config file: 'in_files' missing") - - if len(config['in_files']) == 0: - raise Exception("config file: 'in_files' values missing") - - for file_idx in range(len(config['in_files'])): - if extend_relative_paths and not path.isabs( - config['in_files'][file_idx]): - config['in_files'][file_idx] = make_abs_path(cfg_path, - config['in_files'][ - file_idx]) - - if not path.isfile(config['in_files'][file_idx]): - raise Exception("config file: '%s' is not a file" - % config['in_files'][file_idx]) - - # -------------------------------------------------------------------------- - - if "unc_bin" not in config: - raise Exception("config file: 'in_files' missing") - - if extend_relative_paths and not path.isabs(config['unc_bin']): - config['unc_bin'] = make_abs_path(cfg_path, config['unc_bin']) - - if not path.isfile(config['unc_bin']): - raise Exception("config file: '%s' is not a file" % config['unc_bin']) - - # Optional ----------------------------------------------------------------- - - if "cleanup_lvl" not in config: - config["cleanup_lvl"] = 1 - - if "force_cleanup" not in config: - config["force_cleanup"] = False - - if "json_output" not in config: - config["json_output"] = False - - -def cleanup(level, eq_map, clean_target_dir, keep_files=()): - """cleans up output_dir - - :param level: 0 - do nothing, - 1 - keep `keep_files` and 1 file for each group, - 2 - remove everything - - :param equal_output_map: dict of files with equal content, - expects format generated by gen_equal_output_map - - :param clean_target_dir: directory which content will be cleaned - - :param keep_files: list of files should not be removed - """ - - if level == 0: - return - - if level == 2: - rmtree(clean_target_dir) - - if level == 1: - rm_files = [clean_target_dir + "/" + f for f in - listdir(clean_target_dir)] - - for f in keep_files: - rm_files.remove(f) - - for idx in eq_map: - old_path = eq_map[idx][0] - new_path = ("%s/g_%d" % (path.dirname(path.abspath(old_path)), idx)) - rename(old_path, new_path) - - try: - rm_files.remove(old_path) - except ValueError: - pass # ignore that it is missing - - try: - rm_files.remove(new_path) - except ValueError: - pass # ignore that it is missing - - for f in rm_files: - remove(f) - - -def main(args): - config = load_config(args[0]) - check_config(config, args[0]) - - # gen output directory - if path.isfile(config["out_dir"]): - raise Exception("%s is a file" % config["out_dir"]) - - if not path.isdir(config["out_dir"]): - makedirs(config["out_dir"]) - elif not config["force_cleanup"] and config["cleanup_lvl"] > 0: - raise Exception("cleanup_lvl > 0 on an existing directory: %s" - % config["out_dir"]) - - write_config_files(config) - eq_map = gen_equal_output_map(config) - output_dict = gen_output_dict(config, eq_map) - - # write output as txt file - output_dict_path = path.join(config["out_dir"], "out.txt") - write_output_dict_pretty(output_dict, output_dict_path) - - # read ouput txt file to print it - with open(output_dict_path, 'r') as f: - print() - print(f.read()) - - keep_files = [output_dict_path] - - # write output as json file - if config["json_output"]: - output_dict_json_path = path.join(config["out_dir"], "out.json") - with open(output_dict_json_path, 'w') as f: - json_dump(output_dict, f) - keep_files.append(output_dict_json_path) - - # clean output directory - cleanup(config["cleanup_lvl"], eq_map, config["out_dir"], keep_files) - - -if __name__ == "__main__": - main(argv[1:]) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_config_combinations_uniq_output_example.json b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_config_combinations_uniq_output_example.json deleted file mode 100644 index 315fdfef..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/gen_config_combinations_uniq_output_example.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "option_settings": { - "AT_BOOL": ["False", "True"], - "AT_IARF": ["ignore", "add", "remove", "force"], - "AT_POS": ["ignore", "join", "lead", "lead_break", "lead_force", - "trail", "trail_break", "trail_force" - ], - "AT_LINE": ["auto", "lf", "crlf", "cr"], - "AT_NUM": [-2, -1, 0, 1, 2, 3], - "AT_UNUM": [0, 1, 2, 3] - }, - "options": [{ - "name": "nl_func_type_name", - "type": "AT_IARF" - }, { - "name": "nl_template_class", - "type": "AT_IARF" - }], - "out_dir": "./out_uniq_outputs", - "in_files": ["../src/uncrustify.cpp", "../src/width.h"], - "unc_bin": "../build/uncrustify", - "cleanup_lvl" : 0, - "force_cleanup": false, - "json_output": false -} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/grammar_permutator.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/grammar_permutator.py deleted file mode 100755 index cd42bd9f..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/grammar_permutator.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -import argparse - -from nltk.parse.generate import generate -from nltk import CFG -from os.path import exists -from sys import exit as sys_exit - -DEMO_GRAMMAR = """ - S -> 'import ' ImportList ';' | 'static import ' ImportList ';' - ImportList -> Import | ImportBindings | Import ', ' ImportList - Import -> ModuleFullyQualifiedName | ModuleAliasIdentifier ' = ' ModuleFullyQualifiedName - ImportBindings -> Import ' : ' ImportBindList - ImportBindList -> ImportBind | ImportBind ', ' ImportBindList - ImportBind -> Identifier | Identifier ' = ' Identifier - - ModuleAliasIdentifier -> Identifier - - Packages -> PackageName | Packages '.' PackageName - ModuleFullyQualifiedName -> ModuleName | Packages '.' ModuleName - PackageName -> Identifier - ModuleName -> Identifier - - Identifier -> 'x' -""" - - -def valid_file(arg_parser, *args): - """ - checks if on of the provided paths is a file - - - Parameters - ---------------------------------------------------------------------------- - :param arg_parser: - argument parser object that is called if no file is found - - :param args: list< str > - a list of file path that is going to be checked - - - :return: str - ---------------------------------------------------------------------------- - path to an existing file - """ - arg = None - found_flag = False - for arg in args: - if exists(arg): - found_flag = True - break - if not found_flag: - arg_parser.error("file(s) do not exist: %s" % args) - - return arg - - -def main(args): - grammar_string = DEMO_GRAMMAR - - if args.input_file_path: - with open(args.input_file_path, 'r') as f: - grammar_string = f.read() - - grammar = CFG.fromstring(grammar_string) - - for sentence in generate(grammar, depth=args.depth): - print(''.join(sentence)) - - return 0 - - -if __name__ == "__main__": - arg_parser = argparse.ArgumentParser() - - arg_parser.add_argument( - '-i', '--input_file_path', - metavar='<path>', - type=lambda x: valid_file(arg_parser, x), - help="Path to the grammar file", - required=False - ) - arg_parser.add_argument( - '-d', '--depth', - metavar='<nr>', - type=int, - default=9, - help='Max depth of grammar tree.' - ) - - FLAGS, unparsed = arg_parser.parse_known_args() - - sys_exit(main(FLAGS)) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_katehl.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_katehl.py deleted file mode 100755 index e241986a..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_katehl.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python - -import argparse -import io -import os -import re - -re_token = re.compile(r'^CT_(\w+),') -re_version = re.compile(r'.*UNCRUSTIFY_VERSION\s*"Uncrustify-([^"]+)"') -re_option = re.compile(r'extern (Bounded)?Option<[^>]+>') -re_enum_decl = re.compile(r'enum class (\w+)( *// *<(\w+)>)?') -re_enum_value = re.compile(r'(\w+)(?= *([,=]|//|$))') -re_aliases = re.compile(r'UNC_OPTVAL_ALIAS\(([^)]+)\)') - -version = '0.0' -options = set() -values = set() -tokens = set() - -root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -script = os.path.relpath(__file__, root) - - -# ----------------------------------------------------------------------------- -def read_enum(f): - global values - - for line in iter(f.readline, ''): - line = line.strip() - - if line.startswith('{'): - for line in iter(f.readline, ''): - line = line.strip() - - if line.startswith('};'): - return - - if 'UNC_INTERNAL' in line: - return - - if 'UNC_CONVERT_INTERNAL' in line: - return - - mv = re_enum_value.match(line) - if mv is not None: - values.add(mv.group(1).lower()) - - -# ----------------------------------------------------------------------------- -def write_items(out, items): - for i in sorted(items): - out.write(u' <item>{}</item>\n'.format(i)) - - -# ----------------------------------------------------------------------------- -def write_options(out, args): - write_items(out, options) - - -# ----------------------------------------------------------------------------- -def write_values(out, args): - write_items(out, values) - - -# ----------------------------------------------------------------------------- -def write_tokens(out, args): - write_items(out, tokens) - - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser(description='Generate uncrustify.xml') - parser.add_argument('output', type=str, - help='location of uncrustify.xml to write') - parser.add_argument('template', type=str, - help='location of uncrustify.xml.in ' + - 'to use as template') - parser.add_argument('version', type=str, - help='location of uncrustify_version.h to read') - parser.add_argument('options', type=str, - help='location of options.h to read') - parser.add_argument('optvals', type=str, - help='location of option.h to read') - parser.add_argument('tokens', type=str, - help='location of token_enum.h to read') - args = parser.parse_args() - - # Read version - with io.open(args.version, 'rt', encoding='utf-8') as f: - global version - for line in iter(f.readline, ''): - line = line.strip() - - mv = re_version.match(line) - if mv: - version = mv.group(1) - - # Read options - with io.open(args.options, 'rt', encoding='utf-8') as f: - global options - for line in iter(f.readline, ''): - line = line.strip() - - if re_option.match(line): - n, d = f.readline().split(';') - options.add(n) - - # Read option values - with io.open(args.optvals, 'rt', encoding='utf-8') as f: - global values - for line in iter(f.readline, ''): - line = line.strip() - - if re_enum_decl.match(line): - read_enum(f) - continue - - ma = re_aliases.match(line) - if ma: - for v in ma.group(1).split(',')[2:]: - v = v.strip()[1:-1] - values.add(v) - - # Read tokens - with io.open(args.tokens, 'rt', encoding='utf-8') as f: - global tokens - for line in iter(f.readline, ''): - line = line.strip() - - m = re_token.match(line) - if m and not m.group(1).endswith(u'_'): - tokens.add(m.group(1).lower()) - - # Declare replacements - replacements = { - u'##OPTION_KEYWORDS##': write_options, - u'##VALUE_KEYWORDS##': write_values, - u'##TOKEN_TYPE_KEYWORDS##': write_tokens, - } - - # Write output file - with io.open(args.output, 'wt', encoding='utf-8') as out: - with io.open(args.template, 'rt', encoding='utf-8') as t: - for line in t: - directive = line.strip() - if directive in replacements: - replacements[directive](out, args) - else: - if '##VERSION##' in line: - line = line.replace('##VERSION##', version) - out.write(line) - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -if __name__ == '__main__': - main() diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_option_enum.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_option_enum.py deleted file mode 100644 index c141bb04..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_option_enum.py +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/env python - -import argparse -import io -import os -import re - -re_enum_decl = re.compile(r'enum class (\w+)( *// *<(\w+)>)?') -re_enum_value = re.compile(r'(\w+)(?= *([,=]|//|$))') -re_values = re.compile(r'UNC_OPTVALS\((\w+)\)') -re_aliases = re.compile(r'UNC_OPTVAL_ALIAS\(([^)]+)\)') -enums = {} -values = {} - -root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -script = os.path.relpath(__file__, root) - - -# ============================================================================= -class Enumeration(object): - # ------------------------------------------------------------------------- - def __init__(self, name, prefix, f): - self.name = name - self.prefix = prefix - - self.values = [] - self.value_aliases = {} - - self.convert_internal = False - - for line in iter(f.readline, ''): - line = line.strip() - - if line.startswith('{'): - for line in iter(f.readline, ''): - line = line.strip() - if line.startswith('};'): - return - - if 'UNC_INTERNAL' in line: - return - - if 'UNC_CONVERT_INTERNAL' in line: - self.convert_internal = True - continue - - mv = re_enum_value.match(line) - if mv is not None: - v = mv.group(1) - self.values.append(v) - self.value_aliases[v] = [v.lower()] - - # ------------------------------------------------------------------------- - def add_aliases(self, value, *args): - aliases = [x[1:-1] for x in args] # strip quotes - self.value_aliases[value] += aliases - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -# ----------------------------------------------------------------------------- -def enum_value(enum, value): - if enum.prefix is not None: - return u'{}_{}'.format(enum.prefix, value) - return value - -# ----------------------------------------------------------------------------- -def write_banner(out, args): - out.write( - u'/**\n' - u' * @file {out_name}\n' - u' * Helpers for option enumerators.\n' - u' * Automatically generated by <code>{script}</code>\n' - u' * from {in_name}.\n' - u' */\n' - u'\n'.format( - in_name=os.path.basename(args.header), - out_name=os.path.basename(args.output), - script=script)) - - -# ----------------------------------------------------------------------------- -def write_value_strings(out, args): - for vn, vs in values.items(): - out.write(u'const char *const {}_values[] = {{\n'.format(vn)) - out.write(u'{}\n nullptr\n}};\n\n'.format( - u'\n'.join([u' "{}",'.format(x.lower()) for x in vs]))) - - -# ----------------------------------------------------------------------------- -def write_aliases(out, args): - for enum in enums.values(): - if enum.prefix is None: - continue - - for v in enum.values: - out.write(u'constexpr auto {p}_{v} = {n}::{v};\n'.format( - p=enum.prefix, n=enum.name, v=v)) - - out.write(u'\n') - - -# ----------------------------------------------------------------------------- -def write_conversions(out, args): - header = u'\n//{}\n'.format('-' * 77) - - for enum in enums.values(): - if enum.convert_internal: - continue - - out.write(header) - out.write( - u'bool convert_string(const char *in, {} &out)\n'.format( - enum.name)) - out.write( - u'{\n' - u' if (false)\n' - u' {\n' - u' }\n') - - for v in enum.values: - for a in enum.value_aliases[v]: - out.write( - u' else if (strcasecmp(in, "{}") == 0)\n' - u' {{\n' - u' out = {};\n' - u' return(true);\n' - u' }}\n'.format(a, enum_value(enum, v))) - - out.write( - u' else\n' - u' {\n' - u' return(false);\n' - u' }\n' - u'}\n\n') - - for enum in enums.values(): - out.write(header) - out.write(u'const char *to_string({} val)\n'.format(enum.name)) - out.write(u'{\n' - u' switch (val)\n' - u' {\n') - - for v in enum.values: - vs = v if enum.convert_internal else v.lower() - out.write( - u' case {}:\n' - u' return "{}";\n\n'.format( - enum_value(enum, v), vs)) - - out.write( - u' default:\n' - u' fprintf(stderr, "%s: Unknown {} \'%d\'\\n",\n' - u' __func__, static_cast<int>(val));\n' - u' log_flush(true);\n' - u' exit(EX_SOFTWARE);\n' - u' }}\n' - u'}}\n\n'.format(enum.name)) - - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser(description='Generate options.cpp') - parser.add_argument('output', type=str, - help='location of options.cpp to write') - parser.add_argument('header', type=str, - help='location of options.h to read') - parser.add_argument('template', type=str, - help='location of option_enum.cpp.in ' - 'to use as template') - args = parser.parse_args() - - with io.open(args.header, 'rt', encoding='utf-8') as f: - for line in iter(f.readline, ''): - line = line.strip() - - me = re_enum_decl.match(line) - if me is not None: - e = Enumeration(me.group(1), me.group(3), f) - enums[e.name] = e - continue - - mv = re_values.match(line) - if mv is not None: - enum_name = mv.group(1) - enum = enums['{}_e'.format(enum_name)] - values[enum_name] = enum.values - - ma = re_aliases.match(line) - if ma is not None: - alias_args = [x.strip() for x in ma.group(1).split(',')] - enum = enums[alias_args[0]] - enum.add_aliases(*alias_args[1:]) - - replacements = { - u'##BANNER##': write_banner, - u'##VALUE_STRINGS##': write_value_strings, - u'##ALIASES##': write_aliases, - u'##CONVERSIONS##': write_conversions, - } - - with io.open(args.output, 'wt', encoding='utf-8') as out: - with io.open(args.template, 'rt', encoding='utf-8') as t: - for line in t: - directive = line.strip() - if directive in replacements: - replacements[directive](out, args) - else: - out.write(line) - - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -if __name__ == '__main__': - main() diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_options.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_options.py deleted file mode 100755 index 71e97115..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_options.py +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env python - -import argparse -import io -import os -import re - -max_name_len = 60 - -re_name = re.compile(r'^[a-z][a-z0-9_]*$') -re_group = re.compile(r'//BEGIN') -re_option = re.compile(r'extern (Bounded)?Option<[^>]+>') -re_default = re.compile(r' *// *= *(.*)') -groups = [] - -root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -script = os.path.relpath(__file__, root) - - -# ============================================================================= -class Group(object): - # ------------------------------------------------------------------------- - def __init__(self, desc): - self.desc = desc - self.options = [] - - # ------------------------------------------------------------------------- - def append(self, option): - self.options.append(option) - - -# ============================================================================= -class Option(object): - # ------------------------------------------------------------------------- - def __init__(self, name, dval, decl, desc): - if re_name.match(name) is None: - raise ValueError('{!r} is not a valid option name'.format(name)) - if len(name) > max_name_len: - raise ValueError( - '{!r} (length={:d}) exceeds the maximum length {:d}'.format( - name, len(name), max_name_len)) - - self.desc = u'\n'.join(desc) - self.decl = decl[7:] - self.name = name - self.dval = dval - - # ------------------------------------------------------------------------- - def write_declaration(self, out): - out.write(u'{} {} = {{\n'.format(self.decl, self.name)) - out.write(u' "{}",\n'.format(self.name)) - out.write(u' u8R"__(\n{}\n)__"'.format(self.desc)) - if self.dval is not None: - out.write(u',\n {}'.format(self.dval)) - out.write(u'\n};\n\n') - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -# ----------------------------------------------------------------------------- -def extract_default(decl): - m = re_default.match(decl) - if m: - return m.group(1) - return None - - -# ----------------------------------------------------------------------------- -def write_banner(out, args): - out.write( - u'/**\n' - u' * @file {out_name}\n' - u' * Declaration and initializers for all options.\n' - u' * Automatically generated by <code>{script}</code>\n' - u' * from {in_name}.\n' - u' */\n' - u'\n'.format( - in_name=os.path.basename(args.header), - out_name=os.path.basename(args.output), - script=script)) - - -# ----------------------------------------------------------------------------- -def write_declarations(out, args): - for group in groups: - for option in group.options: - option.write_declaration(out) - - -# ----------------------------------------------------------------------------- -def write_registrations(out, args): - for group in groups: - out.write(u'\n begin_option_group(u8R"__(\n{}\n)__");\n\n'.format( - group.desc)) - - for option in group.options: - out.write(u' register_option(&options::{});\n'.format( - option.name)) - - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser(description='Generate options.cpp') - parser.add_argument('output', type=str, - help='location of options.cpp to write') - parser.add_argument('header', type=str, - help='location of options.h to read') - parser.add_argument('template', type=str, - help='location of options.cpp.in to use as template') - args = parser.parse_args() - - with io.open(args.header, 'rt', encoding='utf-8') as f: - desc = [] - for line in iter(f.readline, ''): - line = line.strip() - - if re_group.match(line): - groups.append(Group(line[8:])) - - elif not len(line): - desc = [] - - elif line == '//': - desc.append('') - - elif line.startswith('// '): - desc.append(line[3:]) - - elif re_option.match(line): - n, d = f.readline().split(';') - o = Option(n, extract_default(d.strip()), line, desc) - groups[-1].append(o) - - replacements = { - u'##BANNER##': write_banner, - u'##DECLARATIONS##': write_declarations, - u'##REGISTRATIONS##': write_registrations, - } - - with io.open(args.output, 'wt', encoding='utf-8') as out: - with io.open(args.template, 'rt', encoding='utf-8') as t: - for line in t: - directive = line.strip() - if directive in replacements: - replacements[directive](out, args) - else: - out.write(line) - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -if __name__ == '__main__': - main() diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_punctuator_table.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_punctuator_table.py deleted file mode 100755 index f3d90081..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_punctuator_table.py +++ /dev/null @@ -1,189 +0,0 @@ -#! /usr/bin/env python -# -# Creates a possibly faster lookup table for tokens, etc. -# -# @author Ben Gardner -# @author Matthew Woehlke -# @license GPL v2+ -# -import argparse -import os -import sys - - -# ----------------------------------------------------------------------------- -def scan_file(file_path): - cur_token = '' - token_idx = 0 - args = [] - - fd = open(file_path, 'r') - for line in fd: - 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() - if tok.startswith('R"'): - pos_paren_open = tok.find('(') - pos_paren_close = tok.rfind(')') - - if pos_paren_open == -1 or pos_paren_close == -1: - sys.stderr.write( - 'raw string parenthesis not found\n') - sys.exit(-1) - - tok = tok[pos_paren_open+1:pos_paren_close] - else: - 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): - # do the current level first - k = sorted(db) - if len(k) <= 0: - return - k.sort() - - start_idx = len(arr) - num_left = len(k) - - for i in k: - 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 - """ - strng = entry[0] - db_cur = db_top - for idx in range(0, len(strng)): - if not strng[idx] in db_cur: - db_cur[strng[idx]] = [strng[idx], 0, None, {}] - - dbe = db_cur[strng[idx]] - - if idx == len(strng) - 1: - dbe[2] = entry - else: - db_cur = dbe[3] - - -# ----------------------------------------------------------------------------- -def quote(s): - return '\'{}\''.format(s) - - -# ----------------------------------------------------------------------------- -def escape(s): - return quote(s.replace('\'', '\\\'')) - - -# ----------------------------------------------------------------------------- -def write_entry(out, max_len, ch, left_in_group, next_idx, tag, idx, tok): - out.write( - ' {{ {:>4}, {:>3d}, {:>3d}, {:{}} }}, // {:3d}: {}'.format( - ch, left_in_group, next_idx, tag, max_len, idx, tok).rstrip()) - out.write('\n') - - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser(description='Generate punctuator_table.h') - parser.add_argument('output', type=str, - help='location of punctuator_table.h to write') - parser.add_argument('header', type=str, - help='location of symbols_table.h to read') - args = parser.parse_args() - - root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - pl = scan_file(args.header) - pl.sort() - - db = {} - for a in pl: - add_to_db(a, db) - - arr = [] - build_table(db, '', arr) - - max_len = len('nullptr') - for i in arr: - rec = i[4] - if rec is not None and (len(rec[1]) + 1) > max_len: - max_len = len(rec[1]) + 1 - - in_name = os.path.basename(args.header) - out_name = os.path.basename(args.output) - guard = out_name.replace('.', '_').upper() - - with open(args.output, 'wt') as out: - out.write( - '/**\n' - ' * @file {out_name}\n' - ' * Automatically generated by <code>{script}</code>\n' - ' * from {in_name}.\n' - ' */\n' - '\n' - '#ifndef SRC_{guard}_\n' - '#define SRC_{guard}_\n' - '\n' - '// *INDENT-OFF*\n' - 'static const lookup_entry_t punc_table[] =\n' - '{{\n'.format( - in_name=in_name, out_name=out_name, guard=guard, - script=os.path.relpath(__file__, root))) - - idx = 0 - - for i in arr: - rec = i[4] - if len(i[0]) == 0: - write_entry(out, max_len, '0', '0', '0', 'nullptr', idx, '') - elif rec is None: - write_entry(out, max_len, escape(i[0]), i[2], i[3], - 'nullptr', idx, quote(i[1])) - else: - write_entry(out, max_len, escape(i[0]), i[2], i[3], - '&' + rec[1], idx, quote(i[1])) - idx += 1 - - out.write( - '}};\n' - '// *INDENT-ON*\n' - '\n' - '#endif /* SRC_{guard}_ */\n'.format(guard=guard)) - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -if __name__ == '__main__': - main() diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_version.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_version.py deleted file mode 100755 index 14e20018..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/make_version.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# -# Rebuilds the version using git describe -# -from sys import exit -from subprocess import Popen, check_call, PIPE -from os.path import join, dirname, abspath, exists -from os import name as os_name -from sys import argv, exit -import re - -if os_name == 'nt': - EX_OK = 0 - EX_USAGE = 64 - EX_IOERR = 74 -else: - from os import EX_IOERR, EX_OK, EX_USAGE - -def main(args): - root = dirname(dirname(abspath(__file__))) - git_path = join(root, '.git') - hg_path = join(root, '.hg') - - txt = "" - error_txt= "" - - if exists(git_path): - try: - proc = Popen(['git', 'describe', '--always', '--dirty'], stdout=PIPE, stderr=PIPE, cwd=root) - txt_b, error_txt_b = proc.communicate() - txt = txt_b.decode("UTF-8").strip().lower() - error_txt = "%d: %s" % (proc.returncode, error_txt_b.decode("UTF-8").strip().lower()) - except: - print("Failed to retrieve version from git") - exit(EX_IOERR) - elif exists(hg_path): - try: - check_call(['hg', 'gexport']) - proc0 = Popen(['hg', '--config', 'defaults.log=', 'log', '-r', '.', '--template', '{gitnode}'], stdout=PIPE, stderr=PIPE, cwd=root) - node_b, error_txt_b = proc0.communicate() - node = node_b.decode("UTF-8") - error_txt = "%d: %s" % (proc0.returncode, error_txt_b.decode("UTF-8").strip().lower()) - - proc1 = Popen(['git', '--git-dir=.hg/git', 'describe', '--long', '--tags', '--always', node], stdout=PIPE, stderr=PIPE, cwd=root) - txt_b, error_txt_b = proc1.communicate() - txt = txt_b.decode("UTF-8").lower() - error_txt += ", %d: %s" % (proc1.returncode, error_txt_b.decode("UTF-8").strip().lower()) - except: - print("Failed to retrieve version from hg") - exit(EX_IOERR) - else: - print("Unknown version control system in '%s'." % root) - exit(EX_USAGE) - - version_pattern = re.compile(r""" - ^ - ( #1: full match - uncrustify- - (\d+\.\d+(\.\d+)?) #2: version 0.64.2 (,#3 optional 3rd nr) - ( #4: additional version info (long string format) - -(\d+) #5: tag commit distance - -g(\w{7,}) #g-prefix + #6: commithash - )? - | - (\w{7,}) #7: commithash only format (last N commits pulled and no tag available) - ) - (-(dirty))? #9: optional dirty specifier (#8,) - $ - """, re.X) - r_match = version_pattern.match(txt) - - if r_match is None: - print("Regex version match failed on: '%s' (%s)" % (txt, error_txt)) - exit(EX_IOERR) - - if r_match.group(2) is not None: - string_groups = [r_match.group(2)] - if r_match.group(5) is not None and r_match.group(6) is not None: - string_groups.append(r_match.group(5)) - string_groups.append(r_match.group(6)) - else: - string_groups = [r_match.group(7)] - - if r_match.group(9) is not None: - string_groups.append(r_match.group(9)) - - - for g in string_groups: - if g is None: - print("Unexpected empty regex group") - exit(EX_IOERR) - - print("%s" % "-".join(string_groups)) - return EX_OK - - -if __name__ == "__main__": - main(argv[1:]) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/option_reducer.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/option_reducer.py deleted file mode 100755 index 403ff92b..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/option_reducer.py +++ /dev/null @@ -1,1125 +0,0 @@ -#!/usr/bin/python -""" -option_reducer.py - -reduces options in a given config file to the minimum while still maintaining -desired formatting - -:author: Daniel Chumak -:license: GPL v2+ -""" - -# Possible improvements: -# - parallelize add_back() -# - (maybe) reduce amount of written config file, see Uncrustify --set - -from __future__ import print_function # python >= 2.6 -import argparse - -from os import name as os_name, sep as os_path_sep, fdopen as os_fdopen, \ - remove as os_remove -from os.path import exists, join as path_join -from subprocess import Popen, PIPE -from sys import exit as sys_exit, stderr, stdout -from shutil import rmtree -from multiprocessing import cpu_count -from tempfile import mkdtemp, mkstemp -from contextlib import contextmanager -from collections import OrderedDict -from threading import Timer -from multiprocessing.pool import Pool -from itertools import combinations - -FLAGS = None -NULL_DEV = "/dev/null" if os_name != "nt" else "nul" - - -def enum(**enums): - return type('Enum', (), enums) - - -RESTULTSFLAG = enum(NONE=0, REMOVE=1, KEEP=2) -ERROR_CODE = enum(NONE=0, FLAGS=200, SANITY0=201, SANITY1=202) -MODES = ("reduce", "no-default") - - -@contextmanager -def make_temp_directory(): - """ - Wraps tempfile.mkdtemp to use it inside a with statement that auto deletes - the temporary directory with its content after the with block closes - - - :return: str - ---------------------------------------------------------------------------- - path to the generated directory - """ - temp_dir = mkdtemp() - try: - yield temp_dir - finally: - rmtree(temp_dir) - - -@contextmanager -def make_raw_temp_file(*args, **kwargs): - """ - Wraps tempfile.mkstemp to use it inside a with statement that auto deletes - the file after the with block closes - - - Parameters - ---------------------------------------------------------------------------- - :param args, kwargs: - arguments passed to mkstemp - - - :return: int, str - ---------------------------------------------------------------------------- - the file descriptor and the file path of the created temporary file - """ - fd, tmp_file_name = mkstemp(*args, **kwargs) - try: - yield (fd, tmp_file_name) - finally: - os_remove(tmp_file_name) - - -@contextmanager -def open_fd(*args, **kwargs): - """ - Wraps os.fdopen to use it inside a with statement that auto closes the - generated file descriptor after the with block closes - - - Parameters - ---------------------------------------------------------------------------- - :param args, kwargs: - arguments passed to os.fdopen - - - :return: TextIOWrapper - ---------------------------------------------------------------------------- - open file object connected to the file descriptor - """ - fp = os_fdopen(*args, **kwargs) - try: - yield fp - finally: - fp.close() - - -def term_proc(proc, timeout): - """ - helper function to terminate a process - - - Parameters - ---------------------------------------------------------------------------- - :param proc: process object - the process object that is going to be terminated - - :param timeout: dictionary - a dictionary (used as object reference) to set a flag that indicates - that the process is going to be terminated - """ - timeout["value"] = True - proc.terminate() - - -def uncrustify(unc_bin_path, cfg_file_path, unformatted_file_path, - lang=None, debug_file=None, check=False): - """ - executes Uncrustify and captures its stdout - - - Parameters - ---------------------------------------------------------------------------- - :param unc_bin_path: str - path to the Uncrustify binary - - :param cfg_file_path: str - path to a config file for Uncrustify - - :param unformatted_file_path: str - path to a file that is going to be formatted - - :param lang: str / None - Uncrustifys -l argument - - :param debug_file: str / None - Uncrustifys -p argument - - :param check: bool - Used to control whether Uncrustifys --check is going to be used - - - :return: str / None - ---------------------------------------------------------------------------- - returns the stdout from Uncrustify or None if the process takes to much - time (set to 5 sec) - """ - - args = [unc_bin_path, "-q", "-c", cfg_file_path, '-f', - unformatted_file_path] - if lang: - args.extend(("-l", lang)) - if debug_file: - args.extend(('-p', debug_file)) - if check: - args.append('--check') - - proc = Popen(args, stdout=PIPE, stderr=PIPE) - - timeout = {"value": False} - timer = Timer(5, term_proc, [proc, timeout]) - timer.start() - - output_b, error_txt_b = proc.communicate() - - timer.cancel() - - if timeout["value"]: - print("uncrustify proc timeout: %s" % ' '.join(args), file=stderr) - return None - - error = error_txt_b.decode("UTF-8") - if error: - print("Uncrustify %s stderr:\n %s" % (unformatted_file_path, error), - file=stderr) - - return output_b - - -def same_expected_generated(formatted_path, unc_bin_path, cfg_file_path, - input_path, lang=None): - """ - Calls uncrustify and compares its generated output with the content of a - file - - - Parameters - ---------------------------------------------------------------------------- - :param formatted_path: str - path to a file containing the expected content - - :params unc_bin_path, cfg_file_path, input_path, lang: str, str, str, - str / None - see uncrustify() - - - :return: bool - ---------------------------------------------------------------------------- - True if the strings match, False otherwise - """ - - expected_string = '' - with open(formatted_path, 'rb') as f: - expected_string = f.read() - - formatted_string = uncrustify(unc_bin_path, cfg_file_path, input_path, lang) - - return True if formatted_string == expected_string else False - - -def process_uncrustify(args): - """ - special wrapper for same_expected_generated() - - accesses global var(s): RESTULTSFLAG - - - Parameters - ---------------------------------------------------------------------------- - :param args: list / tuple< int, ... > - this function is intended to be called by multiprocessing.pool.map() - therefore all arguments are inside a list / tuple: - id: int - an index number needed by the caller to differentiate runs - - other parameters: - see same_expected_generated() - - - :return: tuple< int, RESTULTSFLAG > - ---------------------------------------------------------------------------- - returns a tuple containing the id and a RESTULTSFLAG, REMOVE if both - strings are equal, KEEP if not - """ - - id = args[0] - res = same_expected_generated(*args[1:]) - - return id, RESTULTSFLAG.REMOVE if res else RESTULTSFLAG.KEEP - - -def write_config_file(args): - """ - Writes all but one excluded option into a config file - - - Parameters - ---------------------------------------------------------------------------- - :param args: list / tuple< list< tuple< str, str > >, str, int > - this function is intended to be called by multiprocessing.pool.map() - therefore all arguments are inside a list / tuple: - - config_list: list< tuple< str, str > > - a list of tuples containing option names and values - - tmp_dir: str - path to a directory in which the config file is going to be - written - - exclude_idx: int - index for an option that is not going to be written into the - config file - """ - - config_list, tmp_dir, exclude_idx = args - - with open("%s%suncr-%d.cfg" % (tmp_dir, os_path_sep, exclude_idx), - 'w') as f: - print_config(config_list, target_file_obj=f, exclude_idx=exclude_idx) - - -def write_config_file2(args): - """ - Writes two option lists into a config file - - - Parameters - ---------------------------------------------------------------------------- - :param args: list< tuple< str, str > >, - list< tuple< str, str > >, str, int - this function is intended to be called by multiprocessing.pool.map() - therefore all arguments are inside a list / tuple: - - config_list: list< tuple< str, str > > - the first list of tuples containing option names and values - - test_list: list< tuple< str, str > > - the second list of tuples containing option names and values - - tmp_dir: str - path to a directory in which the config file is going to be - written - - idx: int - index that is going to be used for the filename - """ - - config_list0, config_list1, tmp_dir, idx = args - - with open("%s%suncr-r-%d.cfg" % (tmp_dir, os_path_sep, idx), 'w') as f: - print_config(config_list0, target_file_obj=f) - print("", end='\n', file=f) - print_config(config_list1, target_file_obj=f) - - -def gen_multi_combinations(elements, N): - """ - generator function that generates, based on a set of elements, all - combinations of 1..N elements - - - Parameters - ---------------------------------------------------------------------------- - :param elements: list / tuple - a list of elements from which the combinations will be generated - - :param N: - the max number of element in a combination - - - :return: list - ---------------------------------------------------------------------------- - yields a single combination of the elements - - >>> gen_multi_combinations(["a", "b", "c"], 3) - (a); (b); (c); (a,b); (a,c); (b,c); (a,b,c) - """ - - fields = len(elements) - if N > fields: - raise Exception("Error: N > len(options)") - if N <= 0: - raise Exception("Error: N <= 0") - - for n in range(1, N + 1): - yield combinations(elements, n) - - -def add_back(unc_bin_path, input_files, formatted_files, langs, options_r, - options_k, tmp_dir): - """ - lets Uncrustify format files with generated configs files until all - formatted files match their according expected files. - - Multiple config files are generated based on a (base) list of Uncrustify - options combined with additional (new) options derived from combinations of - another list of options. - - - accesses global var(s): RESTULTSFLAG - - - Parameters - ---------------------------------------------------------------------------- - :param unc_bin_path: str - path to the Uncrustify binary - - :param input_files: list / tuple< str > - a list containing paths to a files that are going to be formatted - - :param formatted_files: list / tuple< str > - a list containing paths to files containing the expected contents - - :param langs: list / tuple< str > / None - a list of languages the files, used as Uncrustifys -l argument - can be None or shorter than the amount of provided files - - :param options_r: list< tuple< str, str > > - the list of options from which combinations will be derived - - :param options_k: list< tuple< str, str > > - the (base) list of Uncrustify options - - :param tmp_dir: str - the directory in which the config files will be written to - - - :return: list< tuple< str, str > > / None - ---------------------------------------------------------------------------- - list of additional option that were needed to generate matching file - contents - """ - - lang_max_idx = -1 if langs is None else len(langs) - 1 - file_len = len(input_files) - - if len(formatted_files) != file_len: - raise Exception("len(input_files) != len(formatted_files)") - - for m_combination in gen_multi_combinations(options_r, len(options_r)): - for idx, (r_combination) in enumerate(m_combination): - write_config_file2((options_k, r_combination, tmp_dir, idx)) - - cfg_file_path = "%s%suncr-r-%d.cfg" % (tmp_dir, os_path_sep, idx) - res = [] - - for file_idx in range(file_len): - lang = None if idx > lang_max_idx else langs[file_idx] - - r = process_uncrustify( - (0, formatted_files[file_idx], unc_bin_path, cfg_file_path, - input_files[file_idx], lang)) - res.append(r[1]) - - # all files, flag = remove -> option can be removed -> equal output - if res.count(RESTULTSFLAG.REMOVE) == len(res): - return r_combination - return None - - -def sanity_raw_run(args): - """ - wrapper for same_expected_generated(), prints error message if the config - file does not generate the expected result - - Parameters - ---------------------------------------------------------------------------- - :param args: - see same_expected_generated - - - :return: - ---------------------------------------------------------------------------- - see same_expected_generated - """ - res = same_expected_generated(*args) - - if not res: - formatted_file_path = args[0] - config_file_path = args[2] - input_file_path = args[3] - - print("\nprovided config does not create formatted source file:\n" - " %s\n %s\n->| %s" - % (input_file_path, config_file_path, formatted_file_path), - file=stderr) - return res - - -def sanity_run(args): - """ - wrapper for same_expected_generated(), prints error message if the config - file does not generate the expected result - - - Parameters - ---------------------------------------------------------------------------- - :param args: - see same_expected_generated - - - :return: - ---------------------------------------------------------------------------- - see same_expected_generated - """ - res = same_expected_generated(*args) - - if not res: - formatted_file_path = args[0] - input_file_path = args[3] - - print("\ngenerated config does not create formatted source file:\n" - " %s\n %s" - % (input_file_path, formatted_file_path), file=stderr) - return res - - -def sanity_run_splitter(uncr_bin, config_list, input_files, formatted_files, - langs, tmp_dir, jobs): - """ - writes config option into a file and tests if every input file is formatted - so that is matches the content of the according expected file - - - Parameters - ---------------------------------------------------------------------------- - :param uncr_bin: str - path to the Uncrustify binary - - :param config_list: list< tuple< str, str > > - a list of tuples containing option names and values - - :param input_files: list / tuple< str > - a list containing paths to a files that are going to be formatted - - :param formatted_files: list / tuple< str > - a list containing paths to files containing the expected contents - - :param langs: list / tuple< str > / None - a list of languages the files, used as Uncrustifys -l argument - can be None or shorter than the amount of provided files - - :param tmp_dir: str - the directory in which the config files will be written to - - :param jobs: int - number of processes to use - - - :return: bool - ---------------------------------------------------------------------------- - True if all files generate correct results, False oterhwise - """ - - file_len = len(input_files) - if len(formatted_files) != file_len: - raise Exception("len(input_files) != len(formatted_files)") - - gen_cfg_path = path_join(tmp_dir, "gen.cfg") - with open(gen_cfg_path, 'w') as f: - print_config(config_list, target_file_obj=f) - - lang_max_idx = -1 if langs is None else len(langs) - 1 - args = [] - - for idx in range(file_len): - lang = None if idx > lang_max_idx else langs[idx] - - args.append((formatted_files[idx], uncr_bin, gen_cfg_path, - input_files[idx], lang)) - - pool = Pool(processes=jobs) - sr = pool.map(sanity_run, args) - - return False not in sr - - -def print_config(config_list, target_file_obj=stdout, exclude_idx=()): - """ - prints config options into a config file - - - Parameters - ---------------------------------------------------------------------------- - :param config_list: list< tuple< str, str > > - a list containing pairs of option names and option values - - :param target_file_obj: file object - see file param of print() - - :param exclude_idx: int / list< int > - index of option(s) that are not going to be printed - """ - - if not config_list: - return - config_list_len = len(config_list) - - # check if exclude_idx list is empty -> assign len - if type(exclude_idx) in (list, tuple) and not exclude_idx: - exclude_idx = [config_list_len] - else: - # sort it, unless it is an int -> transform into a list - try: - exclude_idx = sorted(exclude_idx) - except TypeError: - exclude_idx = [exclude_idx] - - # extracted first loop round: - # do not print '\n' for the ( here non-existing) previous line - if exclude_idx[0] != 0: - print("%s = %s" % (config_list[0][0].ljust(31, ' '), config_list[0][1]), - end='', file=target_file_obj) - # also print space if a single option was provided and it is going to be - # excluded. This is done in order to be able to differentiate between - # --empty-nochange and the case where all options can be removed - elif config_list_len == 1: - print(' ', end='', file=target_file_obj) - return - - start_idx = 1 - for end in exclude_idx: - end = min(end, config_list_len) - - for idx in range(start_idx, end): - print("\n%s = %s" - % (config_list[idx][0].ljust(31, ' '), config_list[idx][1]), - end='', file=target_file_obj) - - start_idx = min(end + 1, config_list_len) - - # after - for idx in range(start_idx, config_list_len): - print("\n%s = %s" - % (config_list[idx][0].ljust(31, ' '), config_list[idx][1]), - end='', file=target_file_obj) - - -def get_non_default_options(unc_bin_path, cfg_file_path): - """ - calls Uncrustify to generate a debug file from which a config only with - non default valued options are extracted - - accesses global var(s): NULL_DEV - - - Parameters - ---------------------------------------------------------------------------- - :param unc_bin_path: str - path to the Uncrustify binary - - :param cfg_file_path: str - path to a config file for Uncrustify - - - :return: list< str > - ---------------------------------------------------------------------------- - amount of lines in the provided and shortened config - """ - lines = [] - - with make_raw_temp_file(suffix='.unc') as (fd, file_path): - # make debug file - uncrustify(unc_bin_path, cfg_file_path, NULL_DEV, debug_file=file_path, - check=True) - - # extract non comment lines -> non default config lines - with open_fd(fd, 'r') as fp: - lines = fp.read().splitlines() - lines = [line for line in lines if not line[:1] == '#'] - - return lines - - -def parse_config_file(file_obj): - """ - Reads in a Uncrustify config file - - - Parameters - ---------------------------------------------------------------------------- - :param file_obj: - the file object of an opened config file - - - :return: list< tuple< str, str > > - ---------------------------------------------------------------------------- - a list containing pairs of option names and option values - """ - # dict used to only save the last option setting if the same option occurs - # multiple times, without this: - # optionA0 can be removed because optionA1 = s0, and - # optionA1 can be removed because optionA0 = s0 - # -> optionA0, optionA1 are both removed - config_map = OrderedDict() - - # special keys may not have this limitation, as for example - # 'set x y' and 'set x z' do not overwrite each other - special_keys = {'macro-open', 'macro-else', 'macro-close', 'set', 'type', - 'file_ext', 'define'} - special_list = [] - - for line in file_obj: - # cut comments - pound_pos = line.find('#') - if pound_pos != -1: - line = line[:pound_pos] - - split_pos = line.find('=') - if split_pos == -1: - split_pos = line.find(' ') - if split_pos == -1: - continue - - key = line[:split_pos].strip() - value = line[split_pos + 1:].strip() - - if key in special_keys: - special_list.append((key, value)) - else: - config_map[key] = value - - config_list = list(config_map.items()) - config_list += special_list - - return config_list - - -def count_lines(file_path): - """ - returns the count of lines in a file by counting '\n' chars - - Parameters - ---------------------------------------------------------------------------- - :param file_path: str - file in which the lines will be counted - - - :return: int - ---------------------------------------------------------------------------- - number a lines - """ - in_count = 0 - with open(file_path, 'r') as f: - in_count = f.read().count('\n') + 1 - return in_count - - -def reduce(options_list): - """ - Reduces the given options to a minimum - - accesses global var(s): FLAGS, RESTULTSFLAG, ERROR_CODE - - Parameters - ---------------------------------------------------------------------------- - :param options_list: list< tuple< str, str > > - the list of options that are going to be reduced - - :return: int, list< tuple< str, str > > - status return code, reduced options - """ - config_list_len = len(options_list) - ret_flag = ERROR_CODE.NONE - - file_count = len(FLAGS.input_file_path) - lang_max_idx = -1 if FLAGS.lang is None else len(FLAGS.lang) - 1 - - pool = Pool(processes=FLAGS.jobs) - with make_temp_directory() as tmp_dir: - # region sanity run ---------------------------------------------------- - args = [] - for idx in range(file_count): - lang = None if idx > lang_max_idx else FLAGS.lang[idx] - - args.append((FLAGS.formatted_file_path[idx], - FLAGS.uncrustify_binary_path, FLAGS.config_file_path, - FLAGS.input_file_path[idx], lang)) - sr = pool.map(sanity_raw_run, args) - del args[:] - - if False in sr: - return ERROR_CODE.SANITY0, [] - del sr[:] - - # endregion - # region config generator loop ----------------------------------------- - args = [] - - for e_idx in range(config_list_len): - args.append((options_list, tmp_dir, e_idx)) - pool.map(write_config_file, args) - - del args[:] - - # endregion - # region main loop ----------------------------------------------------- - args = [] - jobs = config_list_len * file_count - - for idx in range(jobs): - file_idx = idx // config_list_len - option_idx = idx % config_list_len - - cfg_file_path = "%s%suncr-%d.cfg" \ - % (tmp_dir, os_path_sep, option_idx) - lang = None if idx > lang_max_idx else FLAGS.lang[file_idx] - - args.append((idx, FLAGS.formatted_file_path[file_idx], - FLAGS.uncrustify_binary_path, cfg_file_path, - FLAGS.input_file_path[file_idx], lang)) - - results = pool.map(process_uncrustify, args) - del args[:] - # endregion - # region clean results ------------------------------------------------- - option_flags = [RESTULTSFLAG.NONE] * config_list_len - - for r in results: - idx = r[0] - flag = r[1] - - option_idx = idx % config_list_len - - if option_flags[option_idx] == RESTULTSFLAG.KEEP: - continue - - option_flags[option_idx] = flag - del results[:] - # endregion - - options_r = [options_list[idx] for idx, x in enumerate(option_flags) - if x == RESTULTSFLAG.REMOVE] - options_list = [options_list[idx] for idx, x in enumerate(option_flags) - if x == RESTULTSFLAG.KEEP] - - del option_flags[:] - - # region sanity run ---------------------------------------------------- - # options can be removed one at a time generating appropriate results, - # oddly enough sometimes a config generated this way can fail when a - # combination of multiple options is missing - s_flag = True - if options_r: - s_flag = sanity_run_splitter( - FLAGS.uncrustify_binary_path, options_list, - FLAGS.input_file_path, FLAGS.formatted_file_path, FLAGS.lang, - tmp_dir, FLAGS.jobs) - - if not s_flag: - ret_flag = ERROR_CODE.SANITY1 - print("\n\nstumbled upon complex option dependencies in \n" - " %s\n" - "trying to add back minimal amount of removed options\n" - % FLAGS.config_file_path, file=stderr) - - ret_options = add_back( - FLAGS.uncrustify_binary_path, FLAGS.input_file_path, - FLAGS.formatted_file_path, FLAGS.lang, options_r, - options_list, tmp_dir) - - if ret_options: - options_list.extend(ret_options) - - s_flag = sanity_run_splitter( - FLAGS.uncrustify_binary_path, options_list, - FLAGS.input_file_path, FLAGS.formatted_file_path, - FLAGS.lang, tmp_dir, FLAGS.jobs) - - if s_flag: - print("Success!", file=stderr) - ret_flag = ERROR_CODE.NONE - # endregion - return ret_flag, options_list if ret_flag == ERROR_CODE.NONE else [] - - -def reduce_mode(): - """ - the mode that minimizes a config file as much as possible - - accesses global var(s): FLAGS, ERROR_CODE - """ - ret_flag = ERROR_CODE.NONE - option_list = {} - - # gen & parse non default config - lines = get_non_default_options(FLAGS.uncrustify_binary_path, - FLAGS.config_file_path) - option_list = parse_config_file(lines) - config_list_len = len(option_list) - - config_lines_init = count_lines(FLAGS.config_file_path) - config_lines_ndef = len(lines) - del lines[:] - - # early return if all options are already removed at this point - if config_list_len == 0: - if not FLAGS.empty_nochange \ - or (config_lines_init - config_lines_ndef) > 0: - if not FLAGS.quiet: - print("\n%s" % '# '.ljust(78, '-')) - - print(" ") - - if not FLAGS.quiet: - print("%s" % '# '.ljust(78, '-')) - print("# initial config lines: %d,\n" - "# default options and unneeded lines: %d,\n" - "# unneeded options: 0,\n" - "# kept options: 0" - % (config_lines_init, config_lines_init)) - print("ret_flag: 0", file=stderr) - return ERROR_CODE.NONE - - # gen reduced options - config_lines_redu = -1 - for i in range(FLAGS.passes): - old_config_lines_redu = config_lines_redu - - ret_flag, option_list = reduce(option_list) - config_lines_redu = len(option_list) - - if ret_flag != ERROR_CODE.NONE \ - or config_lines_redu == old_config_lines_redu: - break - - if ret_flag == ERROR_CODE.NONE: - # use the debug file trick again to get correctly sorted options - with make_raw_temp_file(suffix='.unc') as (fd, file_path): - with open_fd(fd, 'w') as f: - print_config(option_list, target_file_obj=f) - - lines = get_non_default_options(FLAGS.uncrustify_binary_path, - file_path) - option_list = parse_config_file(lines) - - # print output + stats - if not FLAGS.empty_nochange or config_lines_ndef != config_lines_redu: - if not FLAGS.quiet: - print("\n%s" % '# '.ljust(78, '-')) - - print_config(option_list) - - if not FLAGS.quiet: - print("\n%s" % '# '.ljust(78, '-')) - print("# initial config lines: %d,\n" - "# default options and unneeded lines: %d,\n" - "# unneeded options: %d,\n" - "# kept options: %d" - % (config_lines_init, - config_lines_init - config_lines_ndef, - config_lines_ndef - config_lines_redu, - config_lines_redu)) - - print("ret_flag: %d" % ret_flag, file=stderr) - return ret_flag - - -def no_default_mode(): - """ - the mode removes all unnecessary lines and options with default values - - accesses global var(s): FLAGS, ERROR_CODE - """ - - lines = get_non_default_options(FLAGS.uncrustify_binary_path, - FLAGS.config_file_path, ) - config_lines_ndef = len(lines) - config_lines_init = count_lines(FLAGS.config_file_path) - - if not FLAGS.empty_nochange or (config_lines_ndef != config_lines_init): - if not FLAGS.quiet: - print("%s" % '# '.ljust(78, '-')) - - options_str = '\n'.join(lines) - if not options_str: - print(" ") - else: - print(options_str, file=stdout) - - if not FLAGS.quiet: - print("%s" % '# '.ljust(78, '-')) - print("# initial config lines: %d,\n" - "# default options and unneeded lines: %d,\n" - % (config_lines_init, config_lines_init - config_lines_ndef)) - - return ERROR_CODE.NONE - - -def main(): - """ - calls the mode that was specified by the -m script argument, - defaults to reduce_mode if not provided or unknown mode - - accesses global var(s): MODES, FLAGS - - - :return: int - ---------------------------------------------------------------------------- - return code - """ - if FLAGS.mode == MODES[1]: - return no_default_mode() - - return reduce_mode() - - -def valid_file(arg_parser, *args): - """ - checks if on of the provided paths is a file - - - Parameters - ---------------------------------------------------------------------------- - :param arg_parser: - argument parser object that is called if no file is found - - :param args: list< str > - a list of file path that is going to be checked - - - :return: str - ---------------------------------------------------------------------------- - path to an existing file - """ - arg = None - found_flag = False - for arg in args: - if exists(arg): - found_flag = True - break - if not found_flag: - arg_parser.error("file(s) do not exist: %s" % args) - - return arg - - -if __name__ == "__main__": - """ - parses all script arguments and calls main() - - accesses global var(s): FLAGS, ERROR_CODE, MODES - """ - arg_parser = argparse.ArgumentParser() - - group_general = arg_parser.add_argument_group( - 'general options', 'Options used by both modes') - - group_general.add_argument( - '-q', '--quiet', - default=False, - action='store_true', - help='Whether or not messages, other than the actual config output, ' - 'should be printed to stdout.' - ) - group_general.add_argument( - '--empty-nochange', - default=False, - action='store_true', - help='Do not print anything to stdout if no options could be removed' - ) - group_general.add_argument( - '-m', '--mode', - type=str, - choices=MODES, - default=MODES[0], - help="The script operation mode. Defaults to '%s'" % MODES[0] - ) - group_general.add_argument( - '-b', '--uncrustify_binary_path', - metavar='<path>', - type=lambda x: valid_file( - arg_parser, x, - "../build/uncrustify.exe", - "../build/Debug/uncrustify", - "../build/Debug/uncrustify.exe", - "../build/Release/uncrustify", - "../build/Release/uncrustify.exe"), - default="../build/uncrustify", - help="The Uncrustify binary file path. Is searched in known locations " - "in the 'Uncrustify/build/' directory if no <path> is provided." - ) - group_general.add_argument( - '-c', '--config_file_path', - metavar='<path>', - type=lambda x: valid_file(arg_parser, x), - required=True, - help='Path to the config file.' - ) - - group_reduce = arg_parser.add_argument_group( - 'reduce mode', 'Options to reduce configuration file options') - - group_reduce.add_argument( - '-i', '--input_file_path', - metavar='<path>', - type=lambda x: valid_file(arg_parser, x), - nargs='+', - action='append', - help="Path to the unformatted source file. " - "Required if mode '%s' is used" % MODES[0] - ) - group_reduce.add_argument( - '-f', '--formatted_file_path', - metavar='<path>', - type=lambda x: valid_file(arg_parser, x), - nargs='+', - action='append', - help="Path to the formatted source file. " - "Required if mode '%s' is used" % MODES[0] - ) - group_reduce.add_argument( - '-l', '--lang', - metavar='<str>', - nargs='+', - required=False, - action='append', - help='Uncrustify processing language for each input file' - ) - group_reduce.add_argument( - '-j', '--jobs', - metavar='<nr>', - type=int, - default=cpu_count(), - help='Number of concurrent jobs.' - ) - group_reduce.add_argument( - '-p', '--passes', - metavar='<nr>', - type=int, - default=5, - help='Max. number of cleaning passes.' - ) - - group_no_default = arg_parser.add_argument_group( - 'no-default mode', 'Options to remove configuration file option with ' - 'default values: ~~_Currently only the general' - ' options are used for this mode_~~') - FLAGS, unparsed = arg_parser.parse_known_args() - - if FLAGS.lang is not None: - FLAGS.lang = [j for i in FLAGS.lang for j in i] - - if FLAGS.mode == MODES[0]: - if not FLAGS.input_file_path or not FLAGS.formatted_file_path: - arg_parser.error("Flags -f and -i are required in Mode '%s'!" - % MODES[0]) - sys_exit(ERROR_CODE.FLAGS) - - # flatten 2 dimensional args: -f p -f p -f p -f p0 p1 p2 -> [[],[], ...] - FLAGS.input_file_path = [j for i in FLAGS.input_file_path for j in i] - - FLAGS.formatted_file_path = [j for i in - FLAGS.formatted_file_path for j in i] - - if len(FLAGS.input_file_path) != len(FLAGS.formatted_file_path): - print("Unequal amount of input and formatted file paths.", - file=stderr) - sys_exit(ERROR_CODE.FLAGS) - - sys_exit(main()) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/au-sm123.lnt b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/au-sm123.lnt deleted file mode 100644 index 6eaf9a6b..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/au-sm123.lnt +++ /dev/null @@ -1,237 +0,0 @@ -/* Date Stamp */ -d"_lint_au_sm123_lnt=au-sm123.lnt modified 5-Jan-2006" -/* To document usage use: -message( "Using " _lint_au_sm123_lnt ) */ -// --------------------------------------------------------------------- -// This file is provided by Gimpel Software (www.gimpel.com) for use with -// its products PC-lint and FlexeLint. -// -// Redistribution and use of this file, with or without modification, is -// permitted provided that any such redistribution retains this notice. -// --------------------------------------------------------------------- -// au-sm123.lnt -- Author options - Scott Meyers - -/* - This options file can be used to explicitly activate those - checks advocated in the publications: - - [12] Meyers, Scott, Effective C++, Addison-Wesley, Reading Mass., 1992 - [23] Meyers, Scott, More Effective C++, Addison-Wesley, 1996 - [30] Meyers, Scott, Effective C++ Third Edition, Addison-Wesley, 2005 - - You can use this file directly when linting your programs as in: - - lin au-sm123 files - - Most of the Scott Meyers checks are on by default. The - Elective Notes (19??), however, are not and so this file - is necessary to get the full impact of the Scott Meyers - multi-volume set of recommendations. - - Also, this file explicitly activates those Warnings and - Informationals advocated by Scott Meyers just in case they were - suppressed previously. For example, - - lin -w2 au-sm123 files - - has the effect of removing all Informational messages - other than those reactivated in this file. - - If you do not want code to adhere to all of the Scott Meyers' - checks we recommend that, rather than editing this file, you - include it within a file of your own. For example: let - my-sm.lnt contain - - au-sm123.lnt - -e1932 // allow concrete base classes - - In this way you inherit the checks specified in this file - except for the ones that you wish to specifically exclude. - - Then you can use my-sm.lnt in place of au-sm123.lnt - - You might consider placing this file (au-sm123.lnt) or your own - derivation of it (as shown above) in your global options - file. - - */ - -+e424 // Inappropriate deallocation -- [12, Item 5], [30, Item 16] --append(424, -- Effective C++ #5 & Eff. C++ 3rd Ed. item 16) -+e530 // Symbol not initialized -- [30, Item 4] --append( 530, --- Eff. C++ 3rd Ed. item 4 ) -+e603 // Symbol not initialized -- [30, Item 4] --append( 603, --- Eff. C++ 3rd Ed. item 4 ) -+e605 // Increase in pointer capability -- [12, Item 29] --append(605, -- Effective C++ #29 ) -+e644 // Variable may not have been initialized -- [30, Item 4] --append( 644, --- Eff. C++ 3rd Ed. item 4 ) -+e645 // Symbol may not have been initialized -- [30, Item 4] --append( 645, --- Eff. C++ 3rd Ed. item 4 ) -+e673 // Possibly inappropriate deallocation (Name1) for 'Name2' data. -- [30, Item 16] --append( 673, --- Eff. C++ 3rd Ed. item 16 ) -+e727 // Symbol not explicitly initialized -- [30, Item 4] --append( 727, --- Eff. C++ 3rd Ed. item 4 ) -+e728 // Symbol not explicitly initialized -- [30, Item 4] --append( 728, --- Eff. C++ 3rd Ed. item 4 ) -+e729 // Symbol not explicitly initialized -- [30, Item 4] --append( 729, --- Eff. C++ 3rd Ed. item 4 ) -+e738 // Symbol not explicitly initialized -- [30, Item 4] --append( 738, --- Eff. C++ 3rd Ed. item 4 ) -+e771 // Symbol conceivably not initialized -- [30, Item 4] --append( 771, --- Eff. C++ 3rd Ed. item 4 ) -+e772 // Symbol conceivably not initialized -- [30, Item 4] --append( 772, --- Eff. C++ 3rd Ed. item 4 ) -+e794 // Conceivable use of null pointer -- [12, Item 7] --append(794, -- Effective C++ #7 ) -+e802 // Conceivably passing a null pointer to function -- [12, Item 7] --append(802, -- Effective C++ #7 ) -+e818 // Pointer parameter could be declared ptr to const -- [30, Item 3] --append( 818, --- Eff. C++ 3rd Ed. item 3 ) -+e952 // Parameter could be declared const -- [30, Item 3] --append( 952, --- Eff. C++ 3rd Ed. item 3 ) -+e953 // Variable could be declared as const -- [30, Item 3] --append( 953, --- Eff. C++ 3rd Ed. item 3 ) -+e954 // Pointer variable could be declared as pointing to a const -- [30, Item 3] --append( 954, --- Eff. C++ 3rd Ed. item 3 ) -+e1072 // Reference variable must be initialized -- [30, Item 4] --append( 1072, --- Eff. C++ 3rd Ed. item 4 ) -+e1401 // member symbol not initialized by constructor -- [30, Item 4], [30, Item 13] --append( 1401, --- Eff. C++ 3rd Ed. item 4 & Eff. C++ 3rd Ed. item 13) -+e1402 // member not initialized -- [30, Item 4] --append( 1402, --- Eff. C++ 3rd Ed. item 4 ) -+e1403 // member not initialized -- [30, Item 4] --append( 1403, --- Eff. C++ 3rd Ed. item 4 ) -+e1411 // Member with different signature hides virtual member -- [30, Item 33] --append( 1411, --- Eff. C++ 3rd Ed. item 33 ) -+e1412 // Reference member is not initialized -- [30, Item 4] --append( 1412, --- Eff. C++ 3rd Ed. item 4 ) -+e1413 // function is returning a temporary via a reference -- [30, Item 21] --append( 1413, --- Eff. C++ 3rd Ed. item 21 ) -+e1506 // Call to virtual function within a constructor or destructor -- [30, Item 9] --append( 1506, --- Eff. C++ 3rd Ed. item 9 ) -+e1509 // base class destructor for class is not virtual -- [12, Item 14], [30, Item 7] --append(1509, -- Effective C++ #14 & Eff. C++ 3rd Ed. item 7) -+e1510 // base class has no destructor -- [12, Item 14] --append(1510, -- Effective C++ #14 ) -+e1511 // Member hides non-virtual member -- [12, Item 37], [30, Item 33], [30, Item 36] --append(1511, -- Effective C++ #37 & Eff. C++ 3rd Ed. item 33& Eff. C++ 3rd Ed. item 36) -+e1516 // Data member hides inherited member -- [30, Item 33] --append( 1516, --- Eff. C++ 3rd Ed. item 33 ) -+e1529 // not first checking for assignment to this -- [12, Item 17], [30, Item 11] --append(1529, -- Effective C++ #17 & Eff. C++ 3rd Ed. item 11) -+e1531 // Symbol should have compared argument against sizeof(class) -- [30, Item 51] --append( 1531, --- Eff. C++ 3rd Ed. item 51 ) -+e1534 // static variable found within inline function -- [23, Item 26], [30, Item 30] --append(1534, -- More Effective C++ #26 & Eff. C++ 3rd Ed. item 30) -+e1536 // Exposing low access member -- [12, Item 30] --append(1536, -- Effective C++ #30 ) -+e1537 // const function returns pointer data member -- [12, Item 29 ], [30, Item 28] --append(1537, -- Effective C++ #29 & Eff. C++ 3rd Ed. item 28) -+e1539 // member not assigned by assignment operator -- [12, Item 16], [30, Item 12] --append(1539, -- Effective C++ #16 & Eff. C++ 3rd Ed. item 12) -+e1540 // pointer member freed nor zero'ed by destructor -- [12, Item 6] --append(1540, -- Effective C++ #6 ) -+e1541 // member possibly not initialized by constructor -- [30, Item 4], [30, Item 13] --append( 1541, --- Eff. C++ 3rd Ed. item 4 & Eff. C++ 3rd Ed. item 13) -+e1542 // member possibly not initialized -- [30, Item 4] --append( 1542, --- Eff. C++ 3rd Ed. item 4 ) -+e1543 // member possibly not initialized -- [30, Item 4] --append( 1543, --- Eff. C++ 3rd Ed. item 4 ) -+e1544 // value indeterminate (order of initialization) -- [12, Item 47] --append(1544, -- Effective C++ #47 ) -+e1546 // throw() called within destuctor -- [23, Item 11], [30, Item 8] --append(1546, -- Effective C++ #11 & Eff. C++ 3rd Ed. item 8) -+e1547 // Assignment of array to pointer to base -- [23, Item 3] --append(1547, -- More Effective C++ #3 ) -+e1549 // Exception thrown for function not declared to throw -- [23, Item 11] --append(1549, -- More Effective C++ #11 ) -+e1551 // function may throw an exception in destructor -- [23, Item 11], [30, Item 8] --append(1551, -- More Effective C++ #11 & Eff. C++ 3rd Ed. item 8) -+e1557 // const member is not initialized -- [30, Item 4] --append( 1557, --- Eff. C++ 3rd Ed. item 4 ) -+e1559 // Uncaught exception 'Name' may be thrown in destructor -- [30, Item 8] --append( 1559, --- Eff. C++ 3rd Ed. item 8 ) -+e1722 // assignment operator does not return a reference -- [12, Item 15], [30, Item 10] --append(1722, -- Effective C++ #15 & Eff. C++ 3rd Ed. item 10) -+e1724 // Argument to copy constructor for class should be a const reference -- [30, Item 3], [30, Item 20] --append( 1724, --- Eff. C++ 3rd Ed. item 3 & Eff. C++ 3rd Ed. item 20) -+e1727 // inline not previously defined inline at -- [30, Item 30] --append( 1727, --- Eff. C++ 3rd Ed. item 30 ) -+e1729 // Initializer inversion detected for member -- [12, Item 13] --append(1729, -- Effective C++ #13 ) -+e1732 // new in constructor for class which has no assignment operator -- [12, Item 11] --append(1732, -- Effective C++ #11 ) -+e1733 // new in constructor for class which has no copy constructor -- [12, Item 11] --append(1733, -- Effective C++ #11 ) -+e1735 // Virtual function has default parameter -- [12, Item 38] --append(1735, -- Effective C++ #38 ) -+e1737 // 'Symbol' hides global operator new -- [12, Item 9] --append(1737, -- Effective C++ #9 ) -+e1739 // Binary operator should be non-member function -- [12, Item 19], [30, Item 24] --append(1739, -- Effective C++ #19 & Eff. C++ 3rd Ed. item 24) -+e1740 // pointer member not directly freed or zero'ed by destructor -- [12, Item 6] --append(1740, -- Effective C++ #6 ) -+e1741 // member conceivably not initialized by constructor -- [30, Item 4], [30, Item 13] --append( 1741, --- Eff. C++ 3rd Ed. item 4 & Eff. C++ 3rd Ed. item 13) -+e1742 // member conceivably not initialized -- [30, Item 4] --append( 1742, --- Eff. C++ 3rd Ed. item 4 ) -+e1743 // member conceivably not initialized -- [30, Item 4] --append( 1743, --- Eff. C++ 3rd Ed. item 4 ) -+e1744 // member possibly not initialized by private constructor -- [30, Item 4] --append( 1744, --- Eff. C++ 3rd Ed. item 4 ) -+e1745 // member not assigned by private assignment operator -- [12, Item 16], [30, Item 12] --append(1745, -- Effective C++ #16 & Eff. C++ 3rd Ed. item 12) -+e1746 // parameter of function could be made const ref -- [12, Item 22], [30, Item 3], [30, Item 20] --append(1746, -- Effective C++ #22 & Eff. C++ 3rd Ed. item 3& Eff. C++ 3rd Ed. item 20) -+e1747 // binary operator returning a reference -- [12, Item 23] --append(1747, -- Effective C++ #23 ) -+e1749 // base class of class need not be virtual -- [23, Item 24] --append(1749, -- More Effective C++ #24 ) -+e1752 // catch parameter Integer is not a reference -- [23, Item 13] --append(1752, -- More Effective C++ #13 ) -+e1753 // Overloading special operator -- [23, Item 7] --append(1753, -- More Effective C++ #7 ) -+e1754 // Expected 'Symbol' to be declared for class 'Symbol' -- [23, Item 22] --append(1754, -- More Effective C++ #22 ) -+e1757 // Discarded instance of post decrement/increment -- [23, Item 6] --append(1757, -- More Effective C++ #6 ) -+e1758 // Prefix increment/decrement operator returns a non-reference. -- [23, Item 6] --append(1758, -- More Effective C++ #6 ) -+e1759 // Postfix increment/decrement operator returns a reference. -- [23, Item 6] --append(1759, -- More Effective C++ #6 ) -+e1762 // Member function could be made const -- [30, Item 3] --append( 1762, --- Eff. C++ 3rd Ed. item 3 ) -+e1764 // Reference parameter could be declared const reference -- [30, Item 3] --append( 1764, --- Eff. C++ 3rd Ed. item 3 ) -+e1770 // function defined without function 'String' -- [30, Item 52] --append( 1770, --- Eff. C++ 3rd Ed. item 52 ) -+e1772 // Assignment operator is not returning *this -- [30, Item 10] --append( 1772, --- Eff. C++ 3rd Ed. item 10 ) -+e1904 // Old-style C comment -- [12, Item 4] --append(1904, -- Effective C++ #4 ) -+e1921 // Symbol not checking argument against sizeof(class) -- [30, Item 51] --append( 1921, --- Eff. C++ 3rd Ed. item 51 ) -+e1923 // macro could become const variable -- [12, Item 1], [30, Item 2] --append(1923, -- Effective C++ #1 & Eff. C++ 3rd Ed. item 2) -+e1924 // C-style cast -- [23, Item 2] --append(1924, -- More Effective C++ #2 ) -+e1925 // public data member -- [12, Item 20], [30, Item 22] --append(1925, -- Effective C++ #20 & Eff. C++ 3rd Ed. item 22) -+e1926 // 'Symbol's default constructor implicitly called -- [12, Item 12] --append(1926, -- Effective C++ #12 ) -+e1927 // 'Symbol' was not initialized in the constructor init list -- [12, Item 12] --append(1927, -- Effective C++ #12 ) -+e1928 // 'Symbol' did not appear in the ctor initializer list -- [12, Item 12] --append(1928, -- Effective C++ #12 ) -+e1929 // function returning a reference -- [12, Item 23], [30, Item 21] --append(1929, -- Effective C++ #23 & Eff. C++ 3rd Ed. item 21) --esym( 1929, operator<<, operator>> ) // but these op's are OK -+e1930 // Conversion operator found -- [23, Item 5] --append(1930, -- More Effective C++ #5 ) -+e1931 // Constructor can be used for implicit conversions -- [23, Item 5] --append(1931, -- More Effective C++ #5 ) -+e1932 // Base class is not abstract. -- [23, Item 33] --append(1932, -- More Effective C++ #33 ) -+e1934 // flags member functions operator<< and operator>> --append(1934, -- Effective C++ #19 ) -+e1961 // virtual member function could be made const -- [30, Item 3] --append( 1961, --- Eff. C++ 3rd Ed. item 3 ) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/co-gcc.h b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/co-gcc.h deleted file mode 100644 index e948a20f..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/co-gcc.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CO_GCC_H_ -#define CO_GCC_H_ - -#ifdef _lint /* Make sure no compiler comes this way */ - -/* - The headers included below must be generated; For C++, generate - with: - - g++ [usual build options] -E -dM t.cpp >lint_cppmac.h - - For C, generate with: - - gcc [usual build options] -E -dM t.c >lint_cmac.h - - ...where "t.cpp" and "t.c" are empty source files. - - It's important to use the same compiler options used when compiling - project code because they can affect the existence and precise - definitions of certain predefined macros. See the preamble to - co-gcc.lnt for details and a tutorial. - */ -#if defined(__cplusplus) -//# include "lint_cppmac.h" -#else -# include "lint_cmac.h" -#endif - - -/* If the macros given by the generated macro files must be adjusted - in order for Lint to cope, then you can do so here. */ - - -#endif /* _lint */ -#endif /* CO_GCC_H_ */ diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/co-gcc.lnt b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/co-gcc.lnt deleted file mode 100644 index f7bd38dd..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/co-gcc.lnt +++ /dev/null @@ -1,188 +0,0 @@ -/* co-gcc.lnt: This is the seed file for configuring Lint for use with - GCC versions 2.95.3 and later. - - Like all compiler options files this file is intended to be used - as follows: - - lint co-gcc.lnt source-files-to-be-linted - - Some of the information that co-gcc.lnt requires needs to be - furnished with the help of the gcc system itself. - - If any of these directions are unclear, you may gain a better insight - into what is happening by checking the file gcc-readme.txt - - For C, first create an empty file named empty.c and then - run the command (options are case sensitive): - - gcc -E -dM empty.c >lint_cmac.h - - This will capture macro definitions in a file that will be included - automatically at the beginning of each module by use of the -header - option within co-gcc.lnt. The macros may change as you change - compiler options so that ultimately you may want to incorporate - this step into a make facility. - - Next we need to determine the search directories. If you run - - gcc -c -v empty.c - - you will see among other things this coveted list. For example you - might get: - - ... - #include "..." search starts here - #include <...> search starts here - /usr/local/include - /usr/lib/gcc/i686-apple-darwin8/4.0.1/include - /usr/include - /System/Library/Frameworks - /Library/Frameworks - End of search list. - ... - - For each directory shown (there are five in the list above) prefix - the directory name by a "--i" and place it in a file whose name is, - say, include.lnt. You may then begin linting programs by using the - command - - lint co-gcc.lnt include.lnt source-files - - Note: it is conventional to place both .lnt files into a single .lnt - file called std.lnt - - For C++, run the command (options are again case sensitive): - - g++ -E -dM empty.c >lint_cppmac.h - - This will capture C++ macro definitions in a file that will be - included automatically at the beginning of each C++ module - at the request of co-gcc.lnt. - - Next we need to determine C++ search directories. If you run - - g++ -c -v empty.c - - As in the case of C you should prepend a --i onto each directory - displayed and place these options into a file such as include.lnt. - Again, there is nothing sacred about the name and if you intend to - do mixed C and C++ programming it will be necessary for you to use - a differently named file. The rest proceeds as before. - - Note, some options in this file (such as the size options, i.e. -sp4 - indicating that pointers are four bytes wide) may need to be changed. - See "System Dependent Options" below. -*/ - --cgnu // Notifies FlexeLint that gcc is being used. - -// Begin: System Dependent Options -// ------------------------------- --a#machine(i386) // #assert's machine(i386) (SVR4 facility). -+fdi // Use the directory of the including file --si4 // size of int --sp4 // size of pointer - -// ----------------------------- -// End: System Dependent Options - -+cpp(.cc,.c) // extensions for C++ that are commonly used in addition - // to the default extensions of .cpp and .cxx --header(scripts/pclint/co-gcc.h) // Includes header generated by GCC. -+libh(co-gcc.h) // Marks that header as library code. - -// ========================================================= -// +rw and -d options to cope with GNU syntax: -+ppw(ident) // Tolerate #ident keyword definitions for SCCS/RCS -+ppw(warning) - -// GCC provides alternative spellings of certain keywords: --rw_asgn(__inline,inline) --rw_asgn(__inline__,inline) --rw_asgn(__signed__,signed) --rw_asgn( __volatile__, volatile ) --rw_asgn( __volatile, volatile ) -++d__const=const // gconv.h uses __const rather than const -++dconst=const // ensure const expands to const. - --rw_asgn( asm, _up_to_brackets ) --rw_asgn( __asm, _up_to_brackets ) --rw_asgn( __asm__, _up_to_brackets ) -// This re-definition of the various spellings of the asm keyword enables -// Lint to pass gracefully over expression-statements like: -// __asm __volatile ("fsqrt" : "=t" (__result) : "0" (__x)); - -++d__attribute__()= // ignore this keyword and following parenthetical -++d__attribute()= // variant spelling of "__attribute__" - -// "__extension__" is GCC's way of allowing the use of non-standard -// constructs in a strict Standard-conforming mode. We don't currently -// have explicit support for it, but we can use local suppressions. For -// example, we can use -e(160) so that we will not see any Errors about -// GNU statement-expressions wrapped in __extension__(). -++d"__extension__=/*lint -e(160) */" - -++d__builtin_va_list=void* // used by stdarg.h -++d__builtin_stdarg_start()=_to_semi // ditto -++d__builtin_va_end()=_to_semi // ditto -++d"__builtin_va_arg(a,b)=(*( (b *) ( ((a) += sizeof(b)) - sizeof(b) )))" -++d__null=0 -+rw(_to_semi) // needed for the two macros above. -+rw(__typeof__) // activate __typeof__ keyword --d__typeof=__typeof__ // an alternative to using __typeof__ - -+rw( __restrict ) -+rw( __restrict__ ) --rw(__except) // This MS reserved word is used as an identifier -+rw( __complex__, __real__, __imag__ ) // reserved words that can be ignored. -++d__builtin_strchr=(char*) // permits the inline definition ... -++d__builtin_strpbrk=(char*) // of these functions to be linted ... -++d__builtin_strrchr=(char*) // without drawing a complaint -++d__builtin_strstr=(char*) // about the use of a non-standard name -++d__PRETTY_FUNCTION__=___function___ // lint defines ___function___ internally -++d__FUNCTION__=___function___ // lint defines ___function___ internally - - -// ========================================================= -// Other options supporting GNU C/C++ syntax: -+fld // enables the processing of _L_abel _D_esignators E.g.: - // union { double d; int i; } u = { d: 3.141 }; - -// +fwc // wchar_t might be builtin; if so, uncomment - // this option. - -// ========================================================= -// Generally useful suppressions: --wlib(1) // sets the warning level within library headers to 1 - // (no warnings, just syntax errors). Comment out if you - // are actually linting library headers. --elib(123) // 123 is really a warning, but it's in the "Error" range. --elib(93) // allow newlines within quoted string arguments to macros --elibsym(628) // Suppress 628 for __builtin symbols. - --esym(528,__huge_val,__nan,__qnan,__qnanf,__snan,__snanf) - // We don't care if we don't reference some GNU functions --esym(528,__gnu_malloc,__gnu_calloc) - -// The following functions exhibit variable return modes. -// That is, they may equally-usefully be called for a value -// as called just for their effects. Accordingly we inhibit -// Warning 534 for these functions. -// Feel free to add to or subtract from this list. - --esym(534,close,creat,fclose,fprintf,fputc, nanosleep, time) --esym(534,fputs,fscanf,fseek,fwrite,lseek,memcpy,memmove,memset) --esym(534,printf,puts,scanf,sprintf,sscanf,strcat,strcpy) --esym(534,strncat,strncpy,unlink,write, snprintf, dprintf) - -// For non-ANSI compilers we suppress messages 515 and 516 -// for functions known to have variable argument lists. -// For ANSI compilers, header files should take care of this. - --esym(515,fprintf,printf,sprintf,fscanf,scanf,sscanf) --esym(516,fprintf,printf,sprintf,fscanf,scanf,sscanf) --esym(1702,*operator<<,*operator>>) --esym(534,*operator<<,*operator>>) --esym(1055,*__builtin*) --esym(718,*__builtin*) // The compiler does not need these ... --esym(746,*__builtin*) // declared and it knows their prototypes. diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/lint_cfg.lnt b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/lint_cfg.lnt deleted file mode 100644 index 72530d53..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/lint_cfg.lnt +++ /dev/null @@ -1,55 +0,0 @@ -// These settings are used to adjust the pcLint checking for -// the operating unit source code - -// show pclint where to find Header files --i".\include" --i".\lib" --i".\src" - --iC:\mingw\include --iC:\mingw\lib\gcc\mingw32\4.8.1\include\ --iC:\mingw\lib\gcc\mingw32\4.8.1\include\-fixed --iC:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ --iC:\mingw\lib\gcc\mingw32\4.8.1\include\c++\mingw32 -//+libdir(D:\Programme\linaro\gcc-linaro-arm-linux-gnueabihf-4.9-2014.08\*) // define a directory as holding only headers, may be used with * or ? -//+libdir(D:\Programme\linaro\gcc-linaro-arm-linux-gnueabihf-4.9-2014.08\libc\usr\include\*) - -//+libclass(ansi) // use this if only ANSI headers are seen as unchecked libraries -+libclass(foreign) // ignore all headers comeing from a foreign directory using -i or the INCLUDE environment variable -//+libclass(angle) // ingore all headers specified with angle brackets -//+libclass(all) // ignore all header files -+libh(co-ggc.lnt) // ignore this file -//+libdir(uncrustify/scripts/*) -//-wlib(1) - -// Compiler specific configuration for Visual DSP - -// co-tiger.lnt use this file for tiger sharc as reference -scripts\pclint\co-gcc.lnt // Compiler Options for GCC - -// Configuration for checking the operating unit source code - -//-d__ARM_PCS_VFP --d__cplusplus --d_GNU_SOURCE -//-d__GNUC__ --d__STDC__ -//-d__GLIBCXX__=20130531 -//-d__SIZE_TYPE__=int -//-d__PTRDIFF_TYPE__=int -//-d__CHAR_BIT__=8 --dWIN32 --d__i386__ --dDEFINE_CHAR_TABLE --dDEFINE_PCF_NAMES - -// define compiler specific keywords - -//+rw(__inline) // activate the __inline keyword -//+ppw(import) // activate #import -//-d"_exit=_up_to_brackets" -//-d"extern 'C'=gobble" -//+fkp // complain about non-KR extensions - -// To print a stack usage report pclint has to know how much space is required by some functions -// define an upper limit of stack space usage for recursion and function pointers diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/pclint_cfg_eclipse.lnt b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/pclint_cfg_eclipse.lnt deleted file mode 100644 index d1945c5b..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/pclint_cfg_eclipse.lnt +++ /dev/null @@ -1,58 +0,0 @@ -// These are generale configuration options used for pcLint -// throughout all kind of projects. -// This was adjusted to nuinno policy. -// See manual (chapter LIVING WITH LINT) for further details. -// -// Project specific settings shall be included from a separate file -// at the end of this file - -//-i"%PCLINT_HOME%" // add pclint home directory to include path - -//-p // only run preprocessor (use this for debugging pclint test) -//+source // print source code (use this for debugging pclint test) --v // be not verbose (standard setting for normal operation) -//-voif // show the options that pclint uses (only for debugging pclint) -//+v // be verbose (use this for debugging pclint test) -//-v* // be more verbose (use this for debugging pclint) -//-vf // print included files (useful for debugging pclint test) --summary // prints a summary of all pclint results (useful for debugging pclint test) -//-format_summary=. -//-format_template= -//-format_verbosity=. - -+fan // allow anonymous unions -++fim // use multiple include directories -+fus // automatically recognize std namespace -+fbo // activate keyword bool, true, false --fkp // allow ANSI/ISO standard do not insist on Kernighan Richy style --fdh // do not append a .h to header names --ffb // do not establish a separate scope for declares within for clauses -+fsv // track static variables -+fll // enable long long types -+fqb // expect const and volatile before type -+e900 // print total number of errors/warnings - --d__USE_GNU=1 -scripts\pclint\lint_cfg.lnt // include project specific settings -scripts\pclint\policy.lnt // pclint rules from nuinno - --esym(123,min,max) // allows users to use min, max as variables - -// Disable unwanted warnings -//-strong(AB,bool) -//-strong(AB,boolean) -//-strong(AJX) // all typedef must match exactly - -// create output that is understood from Jenkins -+ffn // force full path names --width(0) // don't insert line breaks (unlimited output width). --hF1 // set message height one -+program_info(output_prefix = "tests\pclint\pclint_") - -// make error format same as GCC to display it in Eclipse --"format=%(%f:%l:%C:%) %t %n: %m" --frl // Enable warning 831 -+flm // make sure no foreign includes change the format -// env-xml.lnt // create output in xml format -// -"format_stack=%-20f %5a %-20t %5n %c %e" -// +stack( &file=test\pclint\pclint-stack-report.txt ) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/policy.lnt b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/policy.lnt deleted file mode 100644 index 911e74b7..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/policy.lnt +++ /dev/null @@ -1,396 +0,0 @@ -// uncrustify policy --passes(2) // number of analysis passes (higher values give better detection but slower) --static_depth(2) // number of analyzed redirection for static variables -//-w2 // suppress informational messages -// -strong(AJX) // All typedefs must match exactly --w3 // display informational messages -//-w4 // use the maximum warning level -//+fpn // warns about the use of pointer parameters without first checking for NULL -//+fsc // assumes string constants are const char* - -// all checks from 0 to 599 are enabled by +w2 --e10 // Expecting identifier or other declarator --e18 // symbol redefined --e19 // useless declaration --e14 // symbol previously defined --e26 // expected an expression found const/return --e30 // expected an integer constant --e31 // redefinition of symbol --e32 // field size should not be zero --e36 // redefining the storage class of symbol --e40 // undeclared identifier --e46 // field type should be an integral or enumeration type --e48 // bad type --e49 // expected a typed --e50 // attempted to take the address of a non-lvalue --e52 // expected an lvalue --e55 // bad type --e56 // bad type --e63 // expected an lvalue --e64 // type mismatch --e78 // typedef'd symbol used in expression --e85 // array has dimension 0 --e96 // unmatched left brace for linkage specification --e114 // inconsistent --e119 // too many arguments --e123 // macro defined with arguments --e129 // declaration expected --e200 // internal error --e438 // last value assignd to variable not used --e451 // header without include guard --e457 // enable for checking multithreading --e458 // enable for checking multithreading --e459 // enable for checking multithreading --e506 // allow constant value booleans --e514 // unusual use of boolean expression --e516 // symbol has arg type conflict --e520 // highest operation lacks side effects --e522 // highest operation lacks side effects --e526 // symbol not defined --e528 // symbol not referenced --e534 // ignoring return value of function --e537 // do not warn about repeated inclusion --e574 // signed / unsigned mix with relational --e578 // Declaration of symbol hides symbol --e585 // not a valid Trigraph sequence - -+e601 // Expected a type for symbol Symbol -+e602 // Comment within comment -+e603 // Symbol not initialized -+e604 // Returning address of auto variable -+e605 // Increase in pointer capability -+e606 // Non-ANSI escape sequence: -+e607 // Parameter of macro found within string -+e608 // Assigning to an array parameter -+e609 // Suspicious pointer conversion -+e610 // Suspicious pointer combination -+e611 // Suspicious cast -+e612 // Expected a declarator --e613 // Possible use of null pointer -+e614 // auto aggregate initializer not constant -+e615 // auto aggregate initializer has side effects -+e616 // control flows into case/default -+e617 // String is both a module and an include file -+e618 // Storage class specified after a type -+e619 // Loss of precision (Context) (Pointer to Pointer) -+e620 // Suspicious constant (small L or one?) -+e621 // Identifier clash -+e622 // Size of argument no. Integer inconsistent with format -+e623 // redefining the storage class of symbol -+e624 // typedef redeclared -+e625 // auto symbol has unusual type modifier -+e626 // Integer inconsistent with format -+e627 // indirect object inconsistent with format --e628 // no argument information provided for function -+e629 // static class for function is non standard -+e630 // ambiguous reference to symbol -+e631 // tag 'Symbol' defined differently at Location -+e632 // Assignment to strong type -+e633 // Assignment from a strong type -+e634 // Strong type mismatch in equality or conditional -+e635 // resetting strong parent of type -+e636 // ptr to strong type versus another type -+e637 // Expected index type for strong type -+e638 // Strong type mismatch for type in relational -+e639 // Strong type mismatch for type in binary operation -+e640 // Expected strong type 'Name' in Boolean context --e641 // Converting enum to int -+e642 // Format char 'Char' not supported by wsprintf -+e643 // Loss of precision in pointer cast -+e644 // Variable may not have been initialized -+e645 // Symbol may not have been initialized -+e646 // case/default within Kind loop; may have been misplaced -+e647 // Suspicious truncation -+e648 // Overflow in computing constant for operation: -+e649 // Sign fill during constant shift -+e650 // Constant out of range for operator -+e651 // Potentially confusing initializer --e652 // #define of symbol 'Symbol' declared previously -+e653 // Possible loss of fraction -+e654 // Option String obsolete; use -width(W,I) --e655 // bit-wise operation uses (compatible) enum's -+e656 // Arithmetic operation uses (compatible) enum's -+e657 // Unusual (nonportable) anonymous struct or union -+e658 // Anonymous union assumed -+e659 // Nothing follows '}' -+e660 // Option requests removing an extent that is not on the list -+e661 // possible access of out-of-bounds pointer -+e662 // possible creation of out-of-bounds pointer -+e663 // Suspicious array to pointer conversion -+e664 // Left side of logical OR (||) or logical AND (&&) does not return -+e665 // Unparenthesized parameter Integer in macro is passed an expression -+e666 // Expression with side effects passed to repeated parameter -+e667 // Inconsistent use of qualifiers for symbol -+e668 // Possibly passing a null pointer to function -+e669 // Possible data overrun for function -+e670 // Possible access beyond array for function -+e671 // Possibly passing to function a negative value -+e672 // Possible memory leak in assignment to pointer -+e673 // Possibly inappropriate deallocation -+e674 // Returning address of auto through variable -+e675 // No prior semantics associated with symbol -+e676 // Possibly negative subscript -+e677 // sizeof used within preprocessor statement -+e678 // Member field length (Integer) too small for enum precision -+e679 // Suspicious Truncation in arithmetic expression combining with pointer -+e680 // Suspicious Truncation in arithmetic expression converted to pointer -+e681 // Loop is not entered -+e682 // sizeof applied to a parameter whose type is a sized array -+e683 // function 'Symbol' #define'd -+e684 // Passing address of auto variable into caller space -+e685 // Relational operator always evaluates to same result -+e686 // Option is suspicious -+e687 // Suspicious use of comma operator -+e688 // Cast used within preprocessor conditional statement -+e689 // Apparent end of comment ignored -+e690 // Possible access of pointer pointing Integer bytes past null character by operator -+e691 // Suspicious use of backslash -+e692 // Decimal character follows octal escape sequence -+e693 // Hexadecimal digit immediately after is suspicious in string literal. -+e694 // The type of constant (precision Integer) is dialect dependent -+e695 // Inline function defined without a storage-class specifier ('static' recommended) -+e696 // Variable has value that is out of range for operator -+e697 // Quasi-boolean values should be equality-compared only with 0 -+e698 // Casual use of realloc can create a memory leak - -+e701 // Shift left of signed int variable --e702 // Shift right of signed int variable -+e703 // Shift left of signed long variable -+e704 // Shift right of signed long variable -+e705 // Integer nominally inconsistent with format -+e706 // indirect object inconsistent with format -+e707 // Mixing narrow and wide string literals in concatenation -+e708 // union initialization --e712 // Loss of precision --e713 // Loss of precision --e714 // external variable not referenced --e715 // Symbol not referenced --e716 // while(1) found, allow endless loops --e717 // do ... while(0) found -+e718 // Symbol undeclared, assumed to return int -+e719 // Too many arguments for format -+e720 // Boolean test of assignment -+e721 // Suspicious use of ; -+e722 // Suspicious use of ; -+e723 // Suspicious use of = -- A preprocessor definition began with an = sign. -+e725 // Expected positive indentation from Location --e726 // Extraneous comma ignored -+e727 // local static variable not explicitly initialized -+e728 // global static variable not explicitly initialized -+e729 // exteral variable not explicitly initialized --e730 // Boolean argument to function --e731 // Boolean argument to equal/not equal --e732 // Loss of sign -+e733 // Assigning address of auto variable to outer scope symbol -+e734 // Loss of precision int -+e735 // Loss of precision double -+e736 // Loss of precision float --e737 // Loss of sign in promotion from Type1 to Type2 -+e738 // Symbol not explicitly initialized -+e739 // Trigraph Sequence in literal (Quiet Change) -+e740 // Unusual pointer cast (incompatible indirect types) -+e741 // Unusual pointer cast (function qualification) -+e742 // Multiple character constant -+e743 // Negative character constant -+e744 // switch statement has no default -+e745 // function has no explicit type or class, int assumed -+e746 // call to function not made in the presence of a prototype --e747 // (noisy when using bool) Significant prototype coercion Type1 to Type2 -+e748 // Symbol is a register variable used with setjmp --e749 // check for unused enum values --e750 // ignore unused local macros --e751 // check for unused local typedefs --e752 // check for unused local declarations --e753 // check for unused local struct, union or enum tag --e754 // check for unused local structure member --e755 // ignore unused global macros --e756 // check for unused global typedefs --e757 // check for unused global declarations --e758 // check for unused global struct, union or enum tag --e759 // check if symbol can be moved from header to module -+e760 // check for redundant macros --e761 // check for redundant typedefs -+e762 // check for redundantly declared symbol -+e763 // check for redundant declaration for symbol -+e764 // check for switch statement without a case --e765 // check for external symbols that could be made static -+e766 // check for unused headers -+e767 // check for differing macros --e768 // check for global struct member that is never referenced --e769 // check for global enumeration constant that is never referenced -+e770 // tag is defined identically at several locations -+e771 // check for uninitialized symbols -+e772 // check for uninitialized symbols -+e773 // Expression-like macro not parenthesized --e774 // Boolean within 'String' always evaluates to [True/False] -+e775 // non-negative quantity cannot be less than zero -+e776 // Possible truncation of addition -+e777 // Testing float's for equality --e778 // Constant expression evaluates to 0 -+e779 // String constant in comparison operator -+e780 // Vacuous array element -+e782 // Line exceeds Integer characters -+e783 // Line does not end with new-line -+e784 // Nul character truncated from string -+e785 // Too few initializers for aggregate -+e786 // String concatenation within initializer -+e787 // enum constant should not be used within switch --e788 // enum constant not used within defaulted switch -+e789 // Assigning address of auto variable to static -+e790 // Suspicious truncation, integral to float -+e791 // unusual option sequence -+e792 // void cast of void expression -+e793 // ANSI/ISO limit of String 'Name' exceeded -+e794 // Conceivable use of null pointer -+e795 // Conceivable division by 0 -+e796 // Conceivable access of out-of-bounds pointer -+e797 // Conceivable creation of out-of-bounds pointer -+e798 // Redundant character -+e799 // numerical constant 'Integer' larger than unsigned long - --e801 // Use of goto is deprecated -+e802 // Conceivably passing a null pointer to function -+e803 // Conceivable data overrun for function -+e804 // Conceivable access beyond array for function -+e805 // Expected L"..." to initialize wide char string -+e806 // Small bit field is signed rather than unsigned -+e807 // Conceivably passing to function a negative value -+e808 // No explicit type given to symbol -+e809 // Possible return of address of auto through variable -+e810 // Arithmetic modification of custodial variable -+e811 // Possible deallocation of pointer alias -+e812 // static variable 'Symbol' has size 'Integer' -+e813 // auto variable 'Symbol' in function 'Symbol' has size 'Integer' -+e814 // useless declaration -+e815 // Arithmetic modification of unsaved pointer -+e816 // Non-ANSI format specification -+e817 // Conceivably negative subscript --e818 // Pointer parameter could be declared ptr to const -+e820 // Boolean test of a parenthesized assignment -+e821 // Right hand side of assignment not parenthesized -+e825 // control flows into case/default without -fallthrough comment -+e826 // Suspicious pointer-to-pointer conversion -+e827 // Loop not reachable -+e828 // redefinition of functions -+e829 // dangerous header was used -+e830 // print error location indicator -+e831 // print error location indicator -+e832 // Parameter 'Symbol' not explicitly declared -+e833 // Symbol is typed differently in another module --e834 // missing parentheses between operators --e835 // A zero has been given as [left/right] argument to operator -+e836 // Conceivable access of pointer pointing Integer bytes past nul -+e838 // Previously assigned value to variable has not been used -+e839 // Storage class of symbol 'Symbol' assumed static -+e840 // Use of null character in a string literal --e843 // Variable 'Symbol' (Location) could be declared as const -+e844 // Pointer variable could be declared as pointing to const --e845 // The [left/right] argument to operator is certain to be 0 -+e846 // Signedness of bit-field is implementation defined -+e847 // Thread has unprotected call to thread unsafe function -+e849 // Two enumerators have the same value --e850 // loop index variable is modified in body of the for loop --e864 // Expression possibly depends on order of evaluation -+e866 // Unusual use of 'String' in argument to sizeof - -+e900 // print total number of errors/warnings --e904 // Return statement before end of function 'Symbol' -+e905 // Non-literal format specifier used (with arguments) --e909 // Implicit conversion from Type to bool --e910 // Implicit conversion (Context) from 0 to pointer --e911 // (noisy) Implicit expression promotion from Type to Type --e912 // (noisy) Implicit binary conversion from Type1 to Type2 -+e913 // Implicit adjustment of expected argument type from Type1 to Type2 -+e914 // Implicit adjustment of function return value from Type1 to Type2 --e915 // (noisy) Implicit conversion (Context) Type1 to Type2 --e916 // Implicit pointer assignment conversion --e917 // (noisy) Prototype coercion Type1 to Type2 --e918 // Prototype coercion (Context) of pointers --e919 // (noisy) Implicit conversion (Context) Type to Type --e920 // Cast from Type to void --e931 // Both sides have side effects -+e932 // Passing near pointer to library function 'Symbol' -+e933 // Passing near pointer to far function (Context) -+e934 // taking address of near auto variable 'Symbol' --e935 // (noisy) int within struct -+e936 // type is missing for function arguments -+e937 // type is missing for function arguments -+e939 // return type is missing for function -+e940 // omitted braces within an initialize -+e943 // Too few initializers for aggregate -+e945 // Undefined struct used with extern --e946 // Relational or subtract operator applied to pointers -+e947 // Subtract operator applied to pointers --e950 // Non-ISO/ANSI reserved word or construct: -+e951 // Pointer to incomplete type employed in operation --e952 // Parameter could be declared const --e953 // Variable could be declared as const --e954 // Pointer variable could be declared as pointing to a const -+e955 // Parameter name missing from prototype for function --e956 // (use for multithreaded SW) Non const, non volatile static or external variable -+e957 // Function defined without a prototype in scope --e958 // (can help to save some bytes of memory) Padding of Integer byte(s) is required to align string on Integer byte boundary -+e962 // Macro defined identically at another location -+e963 // expect modifier (const, volatile) before type --e964 // Header file not directly used in module --e966 // Indirectly included header file 'FileName' not used in module -+e967 // Header file 'FileName' does not have a standard include guard --e970 // (noisy) Use of modifier or type outside of a typedef --e971 // (noisy) Use of 'char' without 'signed' or 'unsigned' -+e974 // print Worst case function for stack usage: --e1013 // symbol is not a member of class --e1015 // symbol not found in class --e1025 // no function or template matches invocation --e1039 // symbol is not a member of class --e1040 // symbol is not a legal declaration within class --e1042 // a least one class like operand is required with operator --e1048 // expected a constant expression --e1051 // symbol is both a function and a variable --e1052 // a type was expected, class assumed --e1054 // template variable declaration expects a type --e1055 // symbol undeclared, assumed to return int --e1057 // member cannot be used without an object --e1058 // initializing a non-const reference --e1065 // symbol not declared as "C" --e1062 // template must be either a class or a function --e1066 // symbol declared as "C" --e1075 // Ambiguous reference to symbol --e1077 // could not evaluate default template parameter --e1086 // do not warn about compount literals --e1087 // previous declaration is incompatible --e1401 // member not initialized by constructor --e1502 // object has no nonstatic data member --e1526 // Member function not defined --e1529 // symbol not first checking for assignment to this --e1536 // exposing low access member --e1540 // pointer member neither freed nor zeroed by destructor --e1551 // function may throw exception in destructor --e1554 // direct pointer copy of member within copy constructor --e1561 // reference initialization causes loss of const/volatile --e1566 // member might have been initialized by a separate function --e1702 // operator is both an ordinary function and a member function --e1704 // constructor has private access specification --e1711 // function needs not to be virtual --e1712 // default constructor not defined for class --e1714 // Member function not referenced --e1725 // class member is a reference --e1732 // constructor for class has no assignment operator --e1733 // constructor for class has no copy constructor --e1736 // redundant access specifier --e1740 // pointer member not directly freed or zeroed by destructor --e1746 // parameter could be made const reference --e1757 // discarded instance of post decrement/increment --e1762 // member could be made const --e1764 // reference parameter could be declared const --e1776 // converting a string literal to char* --e1786 // implicit conversion to bool --e1788 // variable is referenced only by its constructor or destructor --e1795 // Template was defined but not instantiated --e1904 // allow old style comments --e1923 // ignore defines that could be const variables --e1924 // C-style cast - -//scripts/pclint/au-sm123.lnt // also check Scott Meyers rules of all three books -//scripts/pclint/au-misra3.lnt // Misra 2012 rules -//scripts/pclint/au-barr10.lnt // Top 10 Bug-Killing Rules -//scripts/pclint/au-ds.lnt // Dan Saks diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/run-pclint-eclipse.bat b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/run-pclint-eclipse.bat deleted file mode 100644 index 1a778bfa..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/run-pclint-eclipse.bat +++ /dev/null @@ -1,104 +0,0 @@ -rem set to on for debugging -@echo off -setlocal - -rem Run this script from the project root directory - -echo ------------------------------------------------------ -echo Start pcLint analysis to check code quality ... - -set SRC_DIR=src -set EXC_DIR=lnt -set OUT_DIR=tests\pclint -set LNT_DIR=scripts\pclint - -rem Check if pcLint program is available -set prog=lint-nt.exe -for %%i in ("%path:;=";"%") do ( -rem echo %%~i - if exist %%~i\%prog% ( - set found=%%i - echo found %prog% in %%i - ) -) -if %found%=="" goto PROG_MISSING - -if NOT EXIST tests md tests -if NOT EXIST tests\pclint md tests\pclint - -rem create list of all C source files to analyze -rem FIXME: works only if there are no spaces in the paths - -dir /s/b %EXC_DIR%\*.lnt > .\%OUT_DIR%\exceptions.lnt - -rem to check single files activate one of the lines below -rem dir /s/b %SRC_DIR%\align_stack.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\align.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\args.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\backup.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\brace_cleanup.cpp> .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\braces.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\chunk_list.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\ChunkStack.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\combine.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\compat_posix.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\compat_win32.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\defines.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\detect.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\indent.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\keywords.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\lang_pawn.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\logger.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\logmask.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\md5.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\newlines.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\options_for_QT.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\options.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\output.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\parens.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\parse_frame.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\punctuators.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\semicolons.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\sorting.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\space.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\tokenize_cleanup.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\tokenize.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\unc_text.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\unc_tools.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\uncrustify_emscripten.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\uncrustify.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\unicode.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\universalindentgui.cpp > .\%OUT_DIR%\files.lnt -rem dir /s/b %SRC_DIR%\width.cpp > .\%OUT_DIR%\files.lnt - -rem to check all source files use the line below -dir /s/b %SRC_DIR%\*.cpp > .\%OUT_DIR%\files.lnt - -rem use this to save the pclint errors to a file for later review -rem lint-nt .\%LNT_DIR%\pclint_cfg_eclipse.lnt .\%OUT_DIR%\exceptions.lnt .\%OUT_DIR%\files.lnt > .\%OUT_DIR%\pclint-results.xml - -rem to make eclipse parse the pclint errors it has to be output to the console -lint-nt .\%LNT_DIR%\pclint_cfg_eclipse.lnt .\%OUT_DIR%\exceptions.lnt .\%OUT_DIR%\files.lnt - -rem type %OUT_DIR%\pclint-results.xml | more -rem type %OUT_DIR%\pclint-results.xml -rem echo pcLint output placed in %OUT_DIR%\pclint-results.xml - -goto END - -:PROG_MISSING -echo. -echo ------------------------------------------------------ -echo pcLint Error: %prog% not found. -echo Verify that PCLINT is correctly installed, the -echo installation was added to the PATH and the -echo environment variable PCLINT_HOME was set to its path. -echo ------------------------------------------------------ -echo. -goto END - -:END -echo pcLint finished -echo ------------------------------------------------------ -endlocal - diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/usage.txt b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/usage.txt deleted file mode 100644 index fff1c305..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/pclint/usage.txt +++ /dev/null @@ -1,16 +0,0 @@ -"pclint" is a static source code checker. -It helps detecting programming errors during development. - -To run the check you need a license for pclint. The results can either be saved to a text file or be displayed on top of the source code when using Eclipse. -The present configuration is ment for Windows using Mingw as toolchain. To run the check with another toolchain the paths in run-pclint-eclipse.bat need to be change. To run the check under Linux another tool called "flexelint" is required. - -Run the check from the top level directory of uncrustify by calling -run-pclint-eclipse.bat - -To run the check from Eclipse create a new target and use the script -as build command like that: -${workspace_loc:/uncrustify}/scripts/pclint/run-pclint-eclipse.bat - -The file policy.lnt determines which tests are performed. -The more tests are used the longer it takes but the more -precise will be the results.
\ No newline at end of file diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/prepare_list_of_authors.sh b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/prepare_list_of_authors.sh deleted file mode 100755 index 6485d377..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/prepare_list_of_authors.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/sh -# -# Prepare the list of authors -# guy maurel -# 2020-11-05 -# -LIST_1="TheListOfAuthors.txt" -echo "Author:" > ${LIST_1} -echo "2005 - 2016 : Ben Gardner" >> ${LIST_1} -echo "" >> ${LIST_1} -echo "Maintenance:" >> ${LIST_1} -echo "Guy Maurel" >> ${LIST_1} -echo "Matthew Woehlke" >> ${LIST_1} -echo "" >> ${LIST_1} -echo "until 2020-11-05:" >> ${LIST_1} -echo "Other collaborators:" >> ${LIST_1} -git log --format='%aN' \ - | sort -u \ - | grep -v "^ben$" \ - | grep -v "^bengardner$" \ - | grep -v "^Ben Gardner$" \ - | grep -v "^CDanU$" \ - | grep -v "^DVE2000$" \ - | grep -v "^Gilles$" \ - | grep -v "^Guy Maurel$" \ - | grep -v "^brmqk3$" \ - | grep -v "^csobeski$" \ - | grep -v "^dbeard$" \ - | grep -v "^gmaurel$" \ - | grep -v "^hdwobben$" \ - | grep -v "^ipaterson$" \ - | grep -v "^jlee975$" \ - | grep -v "^logan.gauthier@metova.com$" \ - | grep -v "^nivekkagicom$" \ - | grep -v "^popipo$" \ - | grep -v "^raefaldhia$" \ - | grep -v "^rdan$" \ - | grep -v "^tpltnt$" \ - | grep -v "^versusvoid$" \ - | grep -v "^void$" \ - >> ${LIST_1} -# -mv ${LIST_1} AUTHORS diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/release_tool.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/release_tool.py deleted file mode 100755 index 2dd71676..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/release_tool.py +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/env python - -import argparse -import git -import os -import re -import sys - -if sys.version_info[0] < 3: - input = raw_input - -re_desc = re.compile(r'^uncrustify-([0-9]+[.][0-9]+[.][0-9]+)') -re_branch = re.compile(r'^uncrustify-RC-([0-9]+[.][0-9]+[.][0-9]+)') -re_merge = re.compile(r'^Merge pull request #[0-9]+ from [^/]+/(.*)') -re_version = re.compile(r'^[0-9]+[.][0-9]+[.][0-9]+$') -re_option_count = re.compile(r'There are currently ([0-9]+) options') - - -# ----------------------------------------------------------------------------- -def fatal(msg): - raise Exception(msg) - - -# ----------------------------------------------------------------------------- -def get_version_str(repo, candidate=True, required=True): - if candidate: - b = repo.git.symbolic_ref('-q', '--short', 'HEAD') - m = re_branch.match(b) - if m: - return m.group(1) - - d = repo.git.describe('HEAD') - m = re_desc.match(d) - if m: - return m.group(1) - - if required: - fatal('Unable to determine current version') - - return None - - -# ----------------------------------------------------------------------------- -def get_version_info(repo, candidate=True, required=True): - s = get_version_str(repo, candidate, required) - return tuple(map(int, s.split('.'))) - - -# ----------------------------------------------------------------------------- -def get_option_count(executable): - import subprocess - - out = subprocess.check_output([executable, '--count-options']) - m = re_option_count.match(out.decode('utf-8')) - if m is None: - fatal('Failed to get option count from \'{}\''.format(executable)) - - return int(m.group(1)) - - -# ----------------------------------------------------------------------------- -def alter(repo, path, old, new): - p = os.path.join(repo.working_tree_dir, path) - with open(p, 'r') as f: - content = f.read() - content = re.sub(old, new, content) - with open(p, 'w') as f: - f.write(content) - print('Updated: {}'.format(path)) - - -# ----------------------------------------------------------------------------- -def generate(repo, version, path, *args): - import subprocess - - p = os.path.join(repo.working_tree_dir, path) - with open(p, 'w') as f: - c = subprocess.check_call(args, stdout=f) - print('Created: {}'.format(path)) - - alter(repo, path, - r'Uncrustify-[0-9.]+(-[0-9]+-[0-9a-f]+(-dirty)?)?', - r'Uncrustify-{}'.format(version)) - - -# ----------------------------------------------------------------------------- -def cmd_init(repo, args): - v = args.version - if v is None: - c = get_version_info(repo, candidate=False, required=False) - if c: - n = '.'.join(map(str, (c[0], c[1] + 1, 0))) - v = input('Version to be created? [{}] '.format(n)) - if len(v) == 0: - v = n - - else: - v = input('Version to be created? ') - - if not re_version.match(v): - fatal('Bad version number, \'{}\''.format(v)) - - repo.git.checkout('-b', 'uncrustify-RC-{}'.format(v)) - - -# ----------------------------------------------------------------------------- -def cmd_update(repo, args): - v = get_version_str(repo) - c = get_option_count(args.executable) - - alter(repo, 'CMakeLists.txt', - r'(set *[(] *UNCRUSTIFY_VERSION +")[0-9.]+', - r'\g<1>{}'.format(v)) - alter(repo, 'package.json', - r'("version" *): *"[0-9.]+"', - r'\g<1>: "{}"'.format(v)) - alter(repo, 'README.md', - r'[0-9]+ configurable options as of version [0-9.]+', - r'{} configurable options as of version {}'.format(c, v)) - alter(repo, 'documentation/htdocs/index.html', - r'[0-9]+ configurable options as of version [0-9.]+', - r'{} configurable options as of version {}'.format(c, v)) - - generate(repo, v, 'etc/defaults.cfg', - args.executable, '--show-config') - generate(repo, v, 'documentation/htdocs/default.cfg', - args.executable, '--show-config') - generate(repo, v, 'documentation/htdocs/config.txt', - args.executable, '--show-config') - generate(repo, v, 'etc/uigui_uncrustify.ini', - args.executable, '--universalindent') - - -# ----------------------------------------------------------------------------- -def cmd_commit(repo, args): - v = get_version_str(repo) - message = 'Prepare Uncrustify v{} release'.format(v) - - extra_args = [] - if args.amend: - extra_args += ['--amend', '--date=now'] - - repo.git.commit('-m', message, *extra_args) - - -# ----------------------------------------------------------------------------- -def cmd_tag(repo, args): - import uuid - - # Determine location of remote repository - if args.ssh: - s = 'git@{}:'.format(args.server) - else: - s = 'https://{}/'.format(args.server) - r = '{}{}/{}.git'.format(s, args.organization, args.project) - - # Fetch upstream - u = repo.create_remote(str(uuid.uuid4()), r) - try: - u.fetch(refspec='master') - - # Get log - if hasattr(args, 'commit'): - c = repo.commit(args.commit) - else: - c = repo.commit('{}/master'.format(u.name)) - m = re_merge.match(c.message.split('\n')[0]) - if m is None: - fatal('Last commit is not a merge of a release candidate?') - - m = re_branch.match(m.group(1)) - if m is None: - fatal('Failed to extract version from release candidate merge') - v = m.group(1) - - # Create and push tag - extra_args = {} - if args.force: - extra_args['force_with_lease'] = True - - tag = 'uncrustify-{}'.format(v) - message = 'Create Uncrustify v{} release'.format(v) - repo.git.tag('-a', tag, c, '-m', message, '--force') - u.push(refspec=tag, **extra_args) - - finally: - repo.delete_remote(u) - - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser( - description='Perform release-related actions') - - root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) - parser.add_argument('--repo', type=str, default=root, - help='path to uncrustify git repository') - - subparsers = parser.add_subparsers(title='subcommands', - help='action to perform') - - parser_init = subparsers.add_parser( - 'init', help='initialize new version') - parser_init.set_defaults(func=cmd_init) - parser_init.add_argument('-v', '--version', - help='version number for release') - - parser_update = subparsers.add_parser( - 'update', help='update version information') - parser_update.set_defaults(func=cmd_update) - parser_update.add_argument('executable', - help='path to uncrustify executable') - - parser_commit = subparsers.add_parser( - 'commit', help='commit changes for new version') - parser_commit.set_defaults(func=cmd_commit) - parser_commit.add_argument('-a', '--amend', action='store_true', - help='amend a previous release commit') - - parser_tag = subparsers.add_parser( - 'tag', help='tag release and push tag to github') - parser_tag.set_defaults(func=cmd_tag) - parser_tag.add_argument('--ssh', action='store_true', - help='use ssh (instead of HTTPS) to push') - parser_tag.add_argument('-s', '--server', default='github.com', - help='push to specified server') - parser_tag.add_argument('-o', '--organization', default='uncrustify', - help='push to specified user or organization') - parser_tag.add_argument('-p', '--project', default='uncrustify', - help='push to specified project') - parser_tag.add_argument('-c', '--commit', - help='tag specified commit ' - '(instead of latest \'master\')') - parser_tag.add_argument('-f', '--force', action='store_true', - help='force push the tag') - - args = parser.parse_args() - repo = git.Repo(args.repo) - args.func(repo, args) - - return 0 - - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -if __name__ == '__main__': - sys.exit(main()) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/run_ctest.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/run_ctest.py deleted file mode 100755 index 0267e0ad..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/run_ctest.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python - -import argparse -import math -import os -import subprocess -import sys - -from multiprocessing import cpu_count - -default_jobs = min(cpu_count() + 2, cpu_count() * 2) - -# ----------------------------------------------------------------------------- -def main(): - parser = argparse.ArgumentParser(description='Run CTest') - parser.add_argument('-q', '--quiet', action='store_true', - help='suppress output of failing tests') - parser.add_argument('-j', '--parallel', type=int, default=default_jobs, - help='number of jobs to use for parallel execution') - parser.add_argument('args', metavar='ARGS', nargs='*', default=[], - help='additional arguments to pass to CTest') - args = parser.parse_args() - - if not os.path.exists('CTestTestfile.cmake'): - print('No test configuration file found!') - print('(Note: This script must be run from your build directory.)') - sys.exit(-1) - - cmd = ['ctest', '-j{}'.format(args.parallel)] - if not args.quiet: - cmd.append('--output-on-failure') - cmd += args.args - - try: - subprocess.check_call(cmd) - except subprocess.CalledProcessError as exc: - sys.exit(exc.returncode) - - -# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -if __name__ == '__main__': - main() diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/tokenizer.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/tokenizer.py deleted file mode 100755 index 0bc33bac..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/tokenizer.py +++ /dev/null @@ -1,316 +0,0 @@ -#! /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: %s" % 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] is not 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 is not 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/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/update_emscripten_bindings.py b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/update_emscripten_bindings.py deleted file mode 100644 index d44a58a6..00000000 --- a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/scripts/update_emscripten_bindings.py +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/python -from __future__ import print_function # python >= 2.6, chained 'with' >= 2.7 - -from os.path import dirname, abspath -from os import fdopen as os_fdopen, remove as os_remove, name as os_name -from shutil import copy2 -from subprocess import Popen, PIPE -from sys import exit as sys_exit, stderr -from tempfile import mkstemp -from contextlib import contextmanager -from threading import Timer -import re - - -ROOT_DIR = dirname(dirname(abspath(__file__))) - -# ============================================================================== - -FILE_BINDINGS = "%s/src/uncrustify_emscripten.cpp" % ROOT_DIR -FILE_TS = "%s/emscripten/libUncrustify.d.ts" % ROOT_DIR - -REGION_START = "region enum bindings" -REGION_END = "endregion enum bindings" - -''' Enums which values need to be updated in the binding code ''' -ENUMS_INFO = [ - { - 'name': 'option_type_e', - 'substitute_name': 'OptionType', - 'filepath': '%s/src/option.h' % ROOT_DIR, - 'extra_arg': [], - 'filter_values': [], - 'suffix_chars': 0, - }, - { - 'name': 'iarf_e', - 'substitute_name': 'IARF', - 'filepath': '%s/src/option.h' % ROOT_DIR, - 'extra_arg': [], - 'filter_values': ['NOT_DEFINED'], - 'suffix_chars': 0, - }, - { - 'name': 'line_end_e', - 'substitute_name': 'LineEnd', - 'filepath': '%s/src/option.h' % ROOT_DIR, - 'extra_arg': [], - 'filter_values': [], - 'suffix_chars': 0, - }, - { - 'name': 'token_pos_e', - 'substitute_name': 'TokenPos', - 'filepath': '%s/src/option.h' % ROOT_DIR, - 'extra_arg': [], - 'filter_values': [], - 'suffix_chars': 0, - }, - { - 'name': 'log_sev_t', - 'substitute_name': 'LogType', - 'filepath': '%s/src/log_levels.h' % ROOT_DIR, - 'extra_arg': [], - 'filter_values': [], - 'suffix_chars': 1, - }, - { - 'name': 'c_token_t', - 'substitute_name': 'TokenType', - 'filepath': '%s/src/token_enum.h' % ROOT_DIR, - 'extra_arg': [], - 'filter_values': ['CT_TOKEN_COUNT_'], - 'suffix_chars': 3, - }, - { - 'name': 'lang_flag_e', - 'substitute_name': 'Language', - 'filepath': '%s/src/uncrustify_types.h' % ROOT_DIR, - 'extra_arg': ["-extra-arg=-std=c++1z", "-extra-arg=-DEMSCRIPTEN"], - 'filter_values': [ - 'LANG_ALLC', - 'LANG_ALL', - 'FLAG_HDR', - 'FLAG_DIG', - 'FLAG_PP', - ], - 'suffix_chars': 5, - }, -] - -# ============================================================================== - -NULL_DEV = "/dev/null" if os_name != "nt" else "nul" - - -@contextmanager -def make_raw_temp_file(*args, **kwargs): - fd, tmp_file_name = mkstemp(*args, **kwargs) - try: - yield (fd, tmp_file_name) - finally: - os_remove(tmp_file_name) - - -@contextmanager -def open_fd(*args, **kwargs): - fp = os_fdopen(*args, **kwargs) - try: - yield fp - finally: - fp.close() - - -def term_proc(proc, timeout): - """ - helper function terminate a process if a timer times out - - :param proc: the process object that is going to be terminated - :param timeout: value that will be set to indicate termination - """ - timeout["value"] = True - proc.terminate() - - -def proc_output(args, timeout_sec=10): - """ - grabs output from called program - :param args: string array containing program name and program arguments - :param timeout_sec: max sec the program can run without being terminated - :return: utf8 decoded program output in a string - """ - proc = Popen(args, stdout=PIPE) - - timeout = {"value": False} - if timeout_sec is not None: - timeout = {"value": False} - timer = Timer(timeout_sec, term_proc, [proc, timeout]) - timer.start() - - output_b, error_txt_b = proc.communicate() - - if timeout_sec is not None: - timer.cancel() - - output = output_b.decode("UTF-8") - - if timeout["value"]: - print("proc timeout: %s" % ' '.join(args), file=stderr) - - return output if not timeout["value"] else None - - -def get_enum_lines(enum_info): - """ - extracts enum values from a file via clang-check - - :param enum_info: dict with: - 'name' (name of the enum), - 'filepath' (file containing the enum definition), - 'extra_arg' (extra arguments passed to clang-check) - :return: list containing enum values - """ - cut_len = len(enum_info['name']) - - proc_args = ["clang-check", enum_info['filepath'], "-ast-dump", - '-ast-dump-filter=%s' % enum_info['name']] - proc_args += enum_info['extra_arg'] - - output = proc_output(proc_args) - if output is None or len(output) == 0: - print("ScriptError: %s - empty clang-check return" % get_enum_lines.__name__, - file=stderr) - return () - - reg_obj = re.compile("EnumConstantDecl.+col:\d+ (referenced )?(\w+)") - - lines = [m.group(2) for l in output.splitlines() - for m in [re.search(reg_obj, l)] if m] - lines = [line for line in lines if line not in enum_info['filter_values']] - - if len(lines) == 0: - print("ScriptError: %s - no enum_info names found" % get_enum_lines.__name__, - file=stderr) - return () - return lines - - -def write_ts(opened_file_obj, enum_info): - """ - writes enum values in a specific typescript d.ts file format - - :param opened_file_obj: opened file file object (with write permissions) - :param enum_info: dict with: - 'name' (name of the enum), - 'substitute_name' (substitute name for the enum), - 'filepath' (file containing the enum definition), - 'extra_arg' (extra arguments passed to clang-check) - :return: False on failure else True - """ - lines = get_enum_lines(enum_info) - if len(lines) == 0: - return False - - opened_file_obj.write( - ' export interface %sValue extends EmscriptenEnumTypeObject {}\n' - ' export interface %s extends EmscriptenEnumType\n' - ' {\n' - % (enum_info['substitute_name'], enum_info['substitute_name']) - ) - for line in lines: - opened_file_obj.write( - ' %s : %sValue;\n' - % (line[enum_info['suffix_chars']:], enum_info['substitute_name']) - ) - opened_file_obj.write( - ' }\n\n' - ) - return True - - -def write_bindings(opened_file_obj, enum_info): - """ - writes enum values in a specific emscripten embind enum bindings format - - :param opened_file_obj: opened file file object (with write permissions) - :param enum_info: dict with: - 'name' (name of the enum), - 'filepath' (file containing the enum definition), - 'extra_arg' (extra arguments passed to clang-check) - :return: False on failure else True - """ - lines = get_enum_lines(enum_info) - if len(lines) == 0: - return False - - opened_file_obj.write( - ' enum_<%s>("%s")' % (enum_info['name'], enum_info['substitute_name']) - ) - for line in lines: - opened_file_obj.write( - '\n .value("%s", %s::%s)' - % (line[enum_info['suffix_chars']:], enum_info['name'], line) - ) - opened_file_obj.write( - ';\n\n' - ) - return True - - -def update_file(file_path, writer_func, enums_info): - """ - reads in a file and replaces old enum value in a region, which is defined by - region start and end string, with updated ones - - :param file_path: file in which the replacement will be made - :param writer_func: name of the function that will be called to write new - content - :param enums_info:list of dicts each containing: - 'name' (name of the enum), - 'substitute_name' (substitute name for the enum), - 'filepath' (file containing the enum definition), - 'extra_arg' (extra arguments passed to clang-check) - :return: False on failure else True - """ - in_target_region = False - - reg_obj_start = re.compile(".*%s$" % REGION_START) - reg_obj_end = re.compile(".*%s$" % REGION_END) - reg_obj = reg_obj_start - - with make_raw_temp_file(suffix='.unc') as (fd, tmp_file_path): - with open(file_path, 'r') as fr, open_fd(fd, 'w') as fw: - for line in fr: - match = None if reg_obj is None else re.search(reg_obj, line) - - if match is None and not in_target_region: - fw.write(line) # write out of region code - - elif match is not None and not in_target_region: - fw.write(line) # hit the start region - - in_target_region = True - reg_obj = reg_obj_end - - for enum in enums_info: - succes_flag = writer_func(fw, enum) - if not succes_flag: # abort, keep input file clean - return False - - elif match is None and in_target_region: - pass # ignore old binding code - - elif match and in_target_region: # hit the endregion - fw.write(line) - - in_target_region = False - reg_obj = None - - copy2(tmp_file_path, file_path) # overwrite input file - return True - - -def main(): - flag = update_file(FILE_BINDINGS, write_bindings, ENUMS_INFO) - if not flag: - return 1 - - flag = update_file(FILE_TS, write_ts, ENUMS_INFO) - if not flag: - return 1 - - return 0 - - -if __name__ == "__main__": - sys_exit(main()) |