Branch
Hash :
7bd8d1d9
Author :
Date :
2025-05-28T15:53:38
doc: Prefix autolinks with '#' Use `#func` instead of `func()` to ignore parameters and make all autolinks work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
/*
* chvalid.c: this module implements the character range
* validation APIs
*/
#define IN_LIBXML
#include "libxml.h"
#include <libxml/chvalid.h>
#include <stddef.h>
/*
* The initial tables ({func_name}_tab) are used to validate whether a
* single-byte character is within the specified group. Each table
* contains 256 bytes, with each byte representing one of the 256
* possible characters. If the table byte is set, the character is
* allowed.
*
*/
#include "codegen/ranges.inc"
/**
* Does a binary search of the range table to determine if char
* is valid
*
* @param val character to be validated
* @param rptr pointer to range to be used to validate
* @returns true if character valid, false otherwise
*/
int
xmlCharInRange (unsigned int val, const xmlChRangeGroup *rptr) {
int low, high, mid;
const xmlChSRange *sptr;
const xmlChLRange *lptr;
if (rptr == NULL) return(0);
if (val < 0x10000) { /* is val in 'short' or 'long' array? */
if (rptr->nbShortRange == 0)
return 0;
low = 0;
high = rptr->nbShortRange - 1;
sptr = rptr->shortRange;
while (low <= high) {
mid = (low + high) / 2;
if ((unsigned short) val < sptr[mid].low) {
high = mid - 1;
} else {
if ((unsigned short) val > sptr[mid].high) {
low = mid + 1;
} else {
return 1;
}
}
}
} else {
if (rptr->nbLongRange == 0) {
return 0;
}
low = 0;
high = rptr->nbLongRange - 1;
lptr = rptr->longRange;
while (low <= high) {
mid = (low + high) / 2;
if (val < lptr[mid].low) {
high = mid - 1;
} else {
if (val > lptr[mid].high) {
low = mid + 1;
} else {
return 1;
}
}
}
}
return 0;
}
/**
* @deprecated Use #xmlIsBaseChar_ch or #xmlIsBaseCharQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsBaseChar(unsigned int ch) {
return(xmlIsBaseCharQ(ch));
}
/**
* @deprecated Use #xmlIsBlank_ch or #xmlIsBlankQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsBlank(unsigned int ch) {
return(xmlIsBlankQ(ch));
}
/**
* @deprecated Use #xmlIsChar_ch or #xmlIsCharQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsChar(unsigned int ch) {
return(xmlIsCharQ(ch));
}
/**
* @deprecated Use #xmlIsCombiningQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsCombining(unsigned int ch) {
return(xmlIsCombiningQ(ch));
}
/**
* @deprecated Use #xmlIsDigit_ch or #xmlIsDigitQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsDigit(unsigned int ch) {
return(xmlIsDigitQ(ch));
}
/**
* @deprecated Use #xmlIsExtender_ch or #xmlIsExtenderQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsExtender(unsigned int ch) {
return(xmlIsExtenderQ(ch));
}
/**
* @deprecated Use #xmlIsIdeographicQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsIdeographic(unsigned int ch) {
return(xmlIsIdeographicQ(ch));
}
/**
* @deprecated Use #xmlIsPubidChar_ch or #xmlIsPubidCharQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsPubidChar(unsigned int ch) {
return(xmlIsPubidCharQ(ch));
}