From 1a895f37b9cb868234a2278a410a234259b08905 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Tue, 4 May 2021 17:51:28 +0100 Subject: [PATCH] Fix running the tests with -fsanitize=address. --- src/case.c | 8 ++++---- tools/case.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/case.c b/src/case.c index 04c9736a..b11c869c 100644 --- a/src/case.c +++ b/src/case.c @@ -1,6 +1,6 @@ /* Unicode Case Conversion * - * Copyright (C) 2012-2018 Reece H. Dunn + * Copyright (C) 2012-2018, 2021 Reece H. Dunn * * This file is part of ucd-tools. * @@ -2822,7 +2822,7 @@ static const struct case_conversion_entry case_conversion_data[] = codepoint_t ucd_toupper(codepoint_t c) { int begin = 0; - int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]); + int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]) - 1; while (begin <= end) { int pos = (begin + end) / 2; @@ -2840,7 +2840,7 @@ codepoint_t ucd_toupper(codepoint_t c) codepoint_t ucd_tolower(codepoint_t c) { int begin = 0; - int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]); + int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]) - 1; while (begin <= end) { int pos = (begin + end) / 2; @@ -2858,7 +2858,7 @@ codepoint_t ucd_tolower(codepoint_t c) codepoint_t ucd_totitle(codepoint_t c) { int begin = 0; - int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]); + int end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]) - 1; while (begin <= end) { int pos = (begin + end) / 2; diff --git a/tools/case.py b/tools/case.py index 9daa5740..33cd5472 100755 --- a/tools/case.py +++ b/tools/case.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# Copyright (C) 2012-2018 Reece H. Dunn +# Copyright (C) 2012-2018, 2021 Reece H. Dunn # # This file is part of ucd-tools. # @@ -33,7 +33,7 @@ for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'): if __name__ == '__main__': sys.stdout.write("""/* Unicode Case Conversion * - * Copyright (C) 2012-2018 Reece H. Dunn + * Copyright (C) 2012-2018, 2021 Reece H. Dunn * * This file is part of ucd-tools. * @@ -83,7 +83,7 @@ struct case_conversion_entry sys.stdout.write('codepoint_t ucd_to%s(codepoint_t c)\n' % case) sys.stdout.write('{\n') sys.stdout.write('\tint begin = 0;\n') - sys.stdout.write('\tint end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]);\n') + sys.stdout.write('\tint end = sizeof(case_conversion_data)/sizeof(case_conversion_data[0]) - 1;\n') sys.stdout.write('\twhile (begin <= end)\n') sys.stdout.write('\t{\n') sys.stdout.write('\t\tint pos = (begin + end) / 2;\n')