Browse Source

Fix running the tests with -fsanitize=address.

master
Reece H. Dunn 4 years ago
parent
commit
1a895f37b9
2 changed files with 7 additions and 7 deletions
  1. 4
    4
      src/case.c
  2. 3
    3
      tools/case.py

+ 4
- 4
src/case.c View File

/* Unicode Case Conversion /* 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. * This file is part of ucd-tools.
* *
codepoint_t ucd_toupper(codepoint_t c) codepoint_t ucd_toupper(codepoint_t c)
{ {
int begin = 0; 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) while (begin <= end)
{ {
int pos = (begin + end) / 2; int pos = (begin + end) / 2;
codepoint_t ucd_tolower(codepoint_t c) codepoint_t ucd_tolower(codepoint_t c)
{ {
int begin = 0; 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) while (begin <= end)
{ {
int pos = (begin + end) / 2; int pos = (begin + end) / 2;
codepoint_t ucd_totitle(codepoint_t c) codepoint_t ucd_totitle(codepoint_t c)
{ {
int begin = 0; 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) while (begin <= end)
{ {
int pos = (begin + end) / 2; int pos = (begin + end) / 2;

+ 3
- 3
tools/case.py View File

#!/usr/bin/python #!/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. # This file is part of ucd-tools.
# #
if __name__ == '__main__': if __name__ == '__main__':
sys.stdout.write("""/* Unicode Case Conversion 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. * This file is part of ucd-tools.
* *
sys.stdout.write('codepoint_t ucd_to%s(codepoint_t c)\n' % case) sys.stdout.write('codepoint_t ucd_to%s(codepoint_t c)\n' % case)
sys.stdout.write('{\n') sys.stdout.write('{\n')
sys.stdout.write('\tint begin = 0;\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('\twhile (begin <= end)\n')
sys.stdout.write('\t{\n') sys.stdout.write('\t{\n')
sys.stdout.write('\t\tint pos = (begin + end) / 2;\n') sys.stdout.write('\t\tint pos = (begin + end) / 2;\n')

Loading…
Cancel
Save