refactor: cleanups post unsubtree'ing univalue

Mostly changes to remove src/univalue exceptions from the various linters,
and the required code changes to make them happy. As well as minor doc
changes.
This commit is contained in:
fanquake 2022-06-11 14:29:09 +01:00
parent e2aa7047f9
commit d873ff96e5
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1
22 changed files with 32 additions and 56 deletions

2
.gitignore vendored
View File

@ -44,8 +44,6 @@ src/obj
share/setup.nsi
share/qt/Info.plist
src/univalue/gen
src/qt/*.moc
src/qt/moc_*.cpp
src/qt/forms/ui_*.h

View File

@ -174,7 +174,6 @@ LCOV_FILTER_PATTERN = \
-p "src/leveldb/" \
-p "src/crc32c/" \
-p "src/bench/" \
-p "src/univalue" \
-p "src/crypto/ctaes" \
-p "src/minisketch" \
-p "src/secp256k1" \

View File

@ -18,7 +18,6 @@ export COMMIT_RANGE
test/lint/git-subtree-check.sh src/crypto/ctaes
test/lint/git-subtree-check.sh src/secp256k1
test/lint/git-subtree-check.sh src/minisketch
test/lint/git-subtree-check.sh src/univalue
test/lint/git-subtree-check.sh src/leveldb
test/lint/git-subtree-check.sh src/crc32c
test/lint/check-doc.py

View File

@ -35,7 +35,6 @@ EXCLUDE_DIRS = [
"src/leveldb/",
"src/minisketch",
"src/secp256k1/",
"src/univalue/",
"src/crc32c/",
]

View File

@ -1158,10 +1158,6 @@ Current subtrees include:
- src/crypto/ctaes
- Upstream at https://github.com/bitcoin-core/ctaes ; maintained by Core contributors.
- src/univalue
- Subtree at https://github.com/bitcoin-core/univalue-subtree ; maintained by Core contributors.
- Deviates from upstream https://github.com/jgarzik/univalue.
- src/minisketch
- Upstream at https://github.com/sipa/minisketch ; maintained by Core contributors.

View File

@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/licenses/mit-license.php.
#ifndef __UNIVALUE_H__
#define __UNIVALUE_H__
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H
#include <charconv>
#include <cstdint>
@ -194,4 +194,4 @@ extern const UniValue NullUniValue;
const UniValue& find_value( const UniValue& obj, const std::string& name);
#endif // __UNIVALUE_H__
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H

View File

@ -1,6 +1,5 @@
// Automatically generated file. Do not modify.
#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
static const char *escapes[256] = {
"\\u0000",
"\\u0001",
@ -259,4 +258,4 @@ static const char *escapes[256] = {
nullptr,
nullptr,
};
#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H

View File

@ -1,8 +1,8 @@
// Copyright 2016 Wladimir J. van der Laan
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/licenses/mit-license.php.
#ifndef UNIVALUE_UTFFILTER_H
#define UNIVALUE_UTFFILTER_H
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H
#include <string>
@ -116,4 +116,4 @@ private:
}
};
#endif
#endif // BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_UTFFILTER_H

View File

@ -3,7 +3,7 @@
// file COPYING or https://opensource.org/licenses/mit-license.php.
#include <univalue.h>
#include "univalue_utffilter.h"
#include <univalue_utffilter.h>
#include <cstdio>
#include <cstdint>

View File

@ -3,7 +3,7 @@
// file COPYING or https://opensource.org/licenses/mit-license.php.
#include <univalue.h>
#include "univalue_escapes.h"
#include <univalue_escapes.h>
#include <memory>
#include <string>

View File

@ -12,10 +12,8 @@ UNIVALUE_INCLUDE_DIR_INT = %reldir%/include
UNIVALUE_DIST_HEADERS_INT =
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue.h
UNIVALUE_LIB_HEADERS_INT =
UNIVALUE_LIB_HEADERS_INT += %reldir%/lib/univalue_utffilter.h
UNIVALUE_LIB_HEADERS_INT += %reldir%/lib/univalue_escapes.h
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue_utffilter.h
UNIVALUE_DIST_HEADERS_INT += %reldir%/include/univalue_escapes.h
UNIVALUE_LIB_SOURCES_INT =
UNIVALUE_LIB_SOURCES_INT += %reldir%/lib/univalue.cpp

View File

@ -12,15 +12,7 @@
#error JSON_TEST_SRC must point to test source directory
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
std::string srcdir(JSON_TEST_SRC);
static bool test_failed = false;
#define d_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", filename.c_str()); } }
#define f_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", __func__); } }
static std::string rtrim(std::string s)
{
@ -41,9 +33,9 @@ static void runtest(std::string filename, const std::string& jdata)
bool testResult = val.read(jdata);
if (wantPass) {
d_assert(testResult == true);
assert(testResult == true);
} else {
d_assert(testResult == false);
assert(testResult == false);
}
if (wantRoundTrip) {
@ -141,30 +133,30 @@ void unescape_unicode_test()
bool testResult;
// Escaped ASCII (quote)
testResult = val.read("[\"\\u0022\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\"");
assert(testResult);
assert(val[0].get_str() == "\"");
// Escaped Basic Plane character, two-byte UTF-8
testResult = val.read("[\"\\u0191\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\xc6\x91");
assert(testResult);
assert(val[0].get_str() == "\xc6\x91");
// Escaped Basic Plane character, three-byte UTF-8
testResult = val.read("[\"\\u2191\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\xe2\x86\x91");
assert(testResult);
assert(val[0].get_str() == "\xe2\x86\x91");
// Escaped Supplementary Plane character U+1d161
testResult = val.read("[\"\\ud834\\udd61\"]");
f_assert(testResult);
f_assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
assert(testResult);
assert(val[0].get_str() == "\xf0\x9d\x85\xa1");
}
int main (int argc, char *argv[])
{
for (unsigned int fidx = 0; fidx < ARRAY_SIZE(filenames); fidx++) {
runtest_file(filenames[fidx]);
for (const auto& f: filenames) {
runtest_file(f);
}
unescape_unicode_test();
return test_failed ? 1 : 0;
return 0;
}

View File

@ -28,7 +28,6 @@ To do a full check with `-r`, make sure that you have fetched the upstream repos
maintained:
* for `src/secp256k1`: https://github.com/bitcoin-core/secp256k1.git (branch master)
* for `src/leveldb`: https://github.com/bitcoin-core/leveldb-subtree.git (branch bitcoin-fork)
* for `src/univalue`: https://github.com/bitcoin-core/univalue-subtree.git (branch master)
* for `src/crypto/ctaes`: https://github.com/bitcoin-core/ctaes.git (branch master)
* for `src/crc32c`: https://github.com/bitcoin-core/crc32c-subtree.git (branch bitcoin-fork)
* for `src/minisketch`: https://github.com/sipa/minisketch.git (branch master)

View File

@ -21,7 +21,7 @@ ALL_SOURCE_FILENAMES_REGEXP = r"^.*\.(cpp|h|py|sh)$"
ALLOWED_FILENAME_REGEXP = "^[a-zA-Z0-9/_.@][a-zA-Z0-9/_.@-]*$"
ALLOWED_SOURCE_FILENAME_REGEXP = "^[a-z0-9_./-]+$"
ALLOWED_SOURCE_FILENAME_EXCEPTION_REGEXP = (
"^src/(secp256k1/|minisketch/|univalue/|test/fuzz/FuzzedDataProvider.h)"
"^src/(secp256k1/|minisketch/|test/fuzz/FuzzedDataProvider.h)"
)
ALLOWED_PERMISSION_NON_EXECUTABLES = 0o644
ALLOWED_PERMISSION_EXECUTABLES = 0o755

View File

@ -77,7 +77,7 @@ def main():
matching_files_filtered = []
for matching_file in matching_files:
if not re.search('^src/(leveldb|secp256k1|minisketch|tinyformat|univalue|test/fuzz/strprintf.cpp)', matching_file):
if not re.search('^src/(leveldb|secp256k1|minisketch|tinyformat|test/fuzz/strprintf.cpp)', matching_file):
matching_files_filtered.append(matching_file)
matching_files_filtered.sort()

View File

@ -22,7 +22,6 @@ EXCLUDE_FILES_WITH_PREFIX = ['src/crypto/ctaes',
'src/crc32c',
'src/secp256k1',
'src/minisketch',
'src/univalue',
'src/tinyformat.h',
'src/bench/nanobench.h',
'src/test/fuzz/FuzzedDataProvider.h']

View File

@ -19,7 +19,7 @@ EXCLUDED_DIRS = ["src/leveldb/",
"src/crc32c/",
"src/secp256k1/",
"src/minisketch/",
"src/univalue/"]
]
EXPECTED_BOOST_INCLUDES = ["boost/algorithm/string/replace.hpp",
"boost/date_time/posix_time/posix_time.hpp",

View File

@ -60,7 +60,6 @@ REGEXP_EXTERNAL_DEPENDENCIES_EXCLUSIONS = [
"src/secp256k1/",
"src/minisketch/",
"src/tinyformat.h",
"src/univalue/"
]
LOCALE_DEPENDENT_FUNCTIONS = [

View File

@ -41,7 +41,7 @@ def main():
exit_code = 0
shell_files = get_shell_files_list()
for file_path in shell_files:
if re.search('src/(secp256k1|minisketch|univalue)/', file_path):
if re.search('src/(secp256k1|minisketch)/', file_path):
continue
with open(file_path, 'r', encoding='utf-8') as file_obj:

View File

@ -68,7 +68,7 @@ def main():
]
files = get_files(files_cmd)
# remove everything that doesn't match this regex
reg = re.compile(r'src/[leveldb,secp256k1,minisketch,univalue]')
reg = re.compile(r'src/[leveldb,secp256k1,minisketch]')
files[:] = [file for file in files if not reg.match(file)]
# build the `shellcheck` command

View File

@ -12,7 +12,7 @@ Note: Will exit successfully regardless of spelling errors.
from subprocess import check_output, STDOUT, CalledProcessError
IGNORE_WORDS_FILE = 'test/lint/spelling.ignore-words.txt'
FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/leveldb/", ":(exclude)src/crc32c/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)src/univalue/", ":(exclude)contrib/builder-keys/keys.txt", ":(exclude)contrib/guix/patches"]
FILES_ARGS = ['git', 'ls-files', '--', ":(exclude)build-aux/m4/", ":(exclude)contrib/seeds/*.txt", ":(exclude)depends/", ":(exclude)doc/release-notes/", ":(exclude)src/leveldb/", ":(exclude)src/crc32c/", ":(exclude)src/qt/locale/", ":(exclude)src/qt/*.qrc", ":(exclude)src/secp256k1/", ":(exclude)src/minisketch/", ":(exclude)contrib/builder-keys/keys.txt", ":(exclude)contrib/guix/patches"]
def check_codespell_install():

View File

@ -22,7 +22,6 @@ EXCLUDED_DIRS = ["depends/patches/",
"src/crc32c/",
"src/secp256k1/",
"src/minisketch/",
"src/univalue/",
"doc/release-notes/",
"src/qt/locale"]