Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8c8a8b

Browse files
committed
Revert "Change mbbisearch to return the character range"
This reverts commit78ab944.After I had committedeb0d0d2 and78ab944, I decided to adda sanity check for a "can't happen" scenario just to be cautious.It turned out that it already happened in the official Unicode sourcedata, namely that a character can be both wide and a combiningcharacter. This fact renders the aforementioned commits unnecessary,so revert both of them.Discussion:https://www.postgresql.org/message-id/CAFBsxsH5ejH4-1xaTLpSK8vWoK1m6fA1JBtTM6jmBsLfmDki1g%40mail.gmail.com
1 parent0d906b2 commitf8c8a8b

File tree

3 files changed

+203
-208
lines changed

3 files changed

+203
-208
lines changed

‎src/common/unicode/generate-unicode_width_table.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
print
1818
"/* generated by src/common/unicode/generate-unicode_width_table.pl, do not edit */\n\n";
1919

20-
print"static const struct mbintervalwcwidth[] = {\n";
20+
print"static const struct mbintervalcombining[] = {\n";
2121

2222
foreachmy$line (<ARGV>)
2323
{
@@ -40,7 +40,7 @@
4040
# not a combining character, print out previous range if any
4141
if (defined($range_start))
4242
{
43-
printf"\t{0x%04X, 0x%04X, 0},\n",$range_start,$prev_codepoint;
43+
printf"\t{0x%04X, 0x%04X},\n",$range_start,$prev_codepoint;
4444
$range_start =undef;
4545
}
4646
}

‎src/common/wchar.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -585,18 +585,17 @@ struct mbinterval
585585
{
586586
unsigned shortfirst;
587587
unsigned shortlast;
588-
signedintwidth;
589588
};
590589

591590
/* auxiliary function for binary search in interval table */
592-
staticconststructmbinterval*
591+
staticint
593592
mbbisearch(pg_wcharucs,conststructmbinterval*table,intmax)
594593
{
595594
intmin=0;
596595
intmid;
597596

598597
if (ucs<table[0].first||ucs>table[max].last)
599-
returnNULL;
598+
return0;
600599
while (max >=min)
601600
{
602601
mid= (min+max) /2;
@@ -605,10 +604,10 @@ mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
605604
elseif (ucs<table[mid].first)
606605
max=mid-1;
607606
else
608-
return&table[mid];
607+
return1;
609608
}
610609

611-
returnNULL;
610+
return0;
612611
}
613612

614613

@@ -647,21 +646,17 @@ ucs_wcwidth(pg_wchar ucs)
647646
{
648647
#include"common/unicode_width_table.h"
649648

650-
conststructmbinterval*range;
651-
652649
/* test for 8-bit control characters */
653650
if (ucs==0)
654651
return0;
655652

656653
if (ucs<0x20|| (ucs >=0x7f&&ucs<0xa0)||ucs>0x0010ffff)
657654
return-1;
658655

659-
/* binary search in table of character widths */
660-
range=mbbisearch(ucs,wcwidth,
661-
sizeof(wcwidth) /sizeof(structmbinterval)-1);
662-
663-
if (range!=NULL)
664-
returnrange->width;
656+
/* binary search in table of non-spacing characters */
657+
if (mbbisearch(ucs,combining,
658+
sizeof(combining) /sizeof(structmbinterval)-1))
659+
return0;
665660

666661
/*
667662
* if we arrive here, ucs is not a combining or C0/C1 control character

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp