| 1271 | // ---------------------------------------------------------------------------------------- |
| 1272 | |
| 1273 | int xml_parser:: |
| 1274 | change_entity ( |
| 1275 | std::istream& in |
| 1276 | ) |
| 1277 | { |
| 1278 | |
| 1279 | std::istream::int_type buf[6]; |
| 1280 | |
| 1281 | |
| 1282 | buf[1] = in.get(); |
| 1283 | |
| 1284 | // if this is an undefined entity reference then return error |
| 1285 | if (buf[1] != 'a' && |
| 1286 | buf[1] != 'l' && |
| 1287 | buf[1] != 'g' && |
| 1288 | buf[1] != 'q' |
| 1289 | ) |
| 1290 | return -1; |
| 1291 | |
| 1292 | |
| 1293 | buf[2] = in.get(); |
| 1294 | // if this is an undefined entity reference then return error |
| 1295 | if (buf[2] != 'm' && |
| 1296 | buf[2] != 't' && |
| 1297 | buf[2] != 'p' && |
| 1298 | buf[2] != 'u' |
| 1299 | ) |
| 1300 | return -1; |
| 1301 | |
| 1302 | |
| 1303 | buf[3] = in.get(); |
| 1304 | // if this is an undefined entity reference then return error |
| 1305 | if (buf[3] != 'p' && |
| 1306 | buf[3] != ';' && |
| 1307 | buf[3] != 'o' |
| 1308 | ) |
| 1309 | return -1; |
| 1310 | |
| 1311 | // check if this is < or > |
| 1312 | if (buf[3] == ';') |
| 1313 | { |
| 1314 | if (buf[2] != 't') |
| 1315 | return -1; |
| 1316 | |
| 1317 | // if this is < then return '<' |
| 1318 | if (buf[1] == 'l') |
| 1319 | return '<'; |
| 1320 | // if this is > then return '>' |
| 1321 | if (buf[1] == 'g') |
| 1322 | return '>'; |
| 1323 | |
| 1324 | // it is neither so it must be an undefined entity reference |
| 1325 | return -1; |
| 1326 | } |
| 1327 | |
| 1328 | |
| 1329 | buf[4] = in.get(); |
| 1330 | // if this should be & |