| 1096 | } |
| 1097 | |
| 1098 | void Input::file_size() |
| 1099 | { |
| 1100 | off_t k = ftello(file_); |
| 1101 | if (k >= 0) |
| 1102 | { |
| 1103 | unsigned char buf[4]; |
| 1104 | switch (utfx_) |
| 1105 | { |
| 1106 | case file_encoding::latin: |
| 1107 | while (::fread(buf, 1, 1, file_) == 1) |
| 1108 | size_ += 1 + (buf[0] >= 0x80); |
| 1109 | break; |
| 1110 | case file_encoding::cp437: |
| 1111 | case file_encoding::cp850: |
| 1112 | case file_encoding::cp858: |
| 1113 | case file_encoding::ebcdic: |
| 1114 | case file_encoding::cp1250: |
| 1115 | case file_encoding::cp1251: |
| 1116 | case file_encoding::cp1252: |
| 1117 | case file_encoding::cp1253: |
| 1118 | case file_encoding::cp1254: |
| 1119 | case file_encoding::cp1255: |
| 1120 | case file_encoding::cp1256: |
| 1121 | case file_encoding::cp1257: |
| 1122 | case file_encoding::cp1258: |
| 1123 | case file_encoding::iso8859_2: |
| 1124 | case file_encoding::iso8859_3: |
| 1125 | case file_encoding::iso8859_4: |
| 1126 | case file_encoding::iso8859_5: |
| 1127 | case file_encoding::iso8859_6: |
| 1128 | case file_encoding::iso8859_7: |
| 1129 | case file_encoding::iso8859_8: |
| 1130 | case file_encoding::iso8859_9: |
| 1131 | case file_encoding::iso8859_10: |
| 1132 | case file_encoding::iso8859_11: |
| 1133 | case file_encoding::iso8859_13: |
| 1134 | case file_encoding::iso8859_14: |
| 1135 | case file_encoding::iso8859_15: |
| 1136 | case file_encoding::iso8859_16: |
| 1137 | case file_encoding::macroman: |
| 1138 | case file_encoding::koi8_r: |
| 1139 | case file_encoding::koi8_u: |
| 1140 | case file_encoding::koi8_ru: |
| 1141 | case file_encoding::custom: |
| 1142 | while (::fread(buf, 1, 1, file_) == 1) |
| 1143 | { |
| 1144 | int c = page_[buf[0]]; |
| 1145 | size_ += 1 + (c >= 0x80) + (c >= 0x0800); // + (c >= 0x010000); NOTE: page_[] value range < Unicode range |
| 1146 | } |
| 1147 | break; |
| 1148 | case file_encoding::utf16be: |
| 1149 | while (::fread(buf, 2, 1, file_) == 1) |
| 1150 | { |
| 1151 | int c = buf[0] << 8 | buf[1]; |
| 1152 | if (c >= 0xD800 && c < 0xE000) |
| 1153 | { |
| 1154 | // UTF-16 surrogate pair |
| 1155 | if (c < 0xDC00 && ::fread(buf + 2, 2, 1, file_) == 1 && (buf[2] & 0xFC) == 0xDC) |
nothing calls this directly
no outgoing calls
no test coverage detected