10000 numbers: Use private copy of xmlCopyCharMultiByte · GNOME/libxslt@2ee18b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ee18b3

Browse files
committed
numbers: Use private copy of xmlCopyCharMultiByte
Allows to deprecate the function in libxml2.
1 parent 329ac5e commit 2ee18b3

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

libxslt/numbers.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,37 @@ static char alpha_lower_list[] = "abcdefghijklmnopqrstuvwxyz";
6363
static xsltFormatToken default_token;
6464

6565
/*
66-
* **** Start temp insert ****
66+
* Helper functions copied from libxml2
67+
*/
68+
69+
/**
70+
* xsltCopyCharMultiByte:
71+
* @out: pointer to an array of xmlChar
72+
* @val: the char value
6773
*
68-
* The following routine xsltUTF8Charcmp will be replaced with calls to
69-
* the corresponding libxml routine at a later date (when other
70-
* inter-library dependencies require it).
74+
* append the char value in the array
75+
*
76+
* Returns the number of xmlChar written
7177
*/
78+
static int
79+
xsltCopyCharMultiByte(xmlChar *out, int val) {
80+
if ((out == NULL) || (val < 0)) return(0);
81+
if (val >= 0x80) {
82+
xmlChar *savedout = out;
83+
int bits;
84+
if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
85+
else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
86+
else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
87+
else {
88+
return(0);
89+
}
90+
for ( ; bits >= 0; bits-= 6)
91+
*out++= ((val >> bits) & 0x3F) | 0x80 ;
92+
return (out - savedout);
93+
}
94+
*out = val;
95+
return 1;
96+
}
7297

7398
/**
7499
* xsltUTF8Charcmp
@@ -98,7 +123,6 @@ xsltIsLetterDigit(int val) {
98123
xmlIsDigitQ(val);
99124
}
100125

101-
/***** Stop temp insert *****/
102126
/************************************************************************
103127
* *
104128
* Utility functions *
@@ -174,7 +198,7 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
174198
break;
175199
}
176200
pointer -= groupingCharacterLen;
177-
xmlCopyCharMultiByte(pointer, groupingCharacter);
201+
xsltCopyCharMultiByte(pointer, groupingCharacter);
178202
}
179203

180204
val = digit_zero + (int)fmod(number, 10.0);
@@ -192,7 +216,7 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
192216
* it is. So, we generate it into the buffer temp_char, then
193217
* copy from there into temp_string.
194218
*/
195-
len = xmlCopyCharMultiByte(temp_char, val);
219+
len = xsltCopyCharMultiByte(temp_char, val);
196220
if ( (pointer - len) < temp_string ) {
197221
i = -1;
198222
break;

0 commit comments

Comments
 (0)
0