comparison dwtx/jface/internal/text/html/HTML2TextReader.d @ 134:51e6e63f930e

Regex fix for casts
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 01:46:20 +0200
parents 7d818bd32d63
children 6dcb0baaa031
comparison
equal deleted inserted replaced
133:7d818bd32d63 134:51e6e63f930e
250 do { 250 do {
251 251
252 ch= nextChar(); 252 ch= nextChar();
253 253
254 while (ch !is -1 && ch !is '>') { 254 while (ch !is -1 && ch !is '>') {
255 buf.append(Character.toLowerCase((char) ch)); 255 buf.append(Character.toLowerCase(cast(wchar) ch));
256 ch= nextChar(); 256 ch= nextChar();
257 if (ch is '"'){ 257 if (ch is '"'){
258 buf.append(Character.toLowerCase((char) ch)); 258 buf.append(Character.toLowerCase(cast(wchar) ch));
259 ch= nextChar(); 259 ch= nextChar();
260 while (ch !is -1 && ch !is '"'){ 260 while (ch !is -1 && ch !is '"'){
261 buf.append(Character.toLowerCase((char) ch)); 261 buf.append(Character.toLowerCase(cast(wchar) ch));
262 ch= nextChar(); 262 ch= nextChar();
263 } 263 }
264 } 264 }
265 if (ch is '<' && !isInComment(buf)) { 265 if (ch is '<' && !isInComment(buf)) {
266 unread(ch); 266 unread(ch);
273 273
274 if (!isInComment(buf) || isCommentEnd(buf)) { 274 if (!isInComment(buf) || isCommentEnd(buf)) {
275 break; 275 break;
276 } 276 }
277 // unfinished comment 277 // unfinished comment
278 buf.append((char) ch); 278 buf.append(cast(wchar) ch);
279 } while (true); 279 } while (true);
280 280
281 return html2Text(buf.toString()); 281 return html2Text(buf.toString());
282 } 282 }
283 283
296 return null; 296 return null;
297 } 297 }
298 298
299 299
300 private void unread(int ch) throws IOException { 300 private void unread(int ch) throws IOException {
301 ((PushbackReader) getReader()).unread(ch); 301 (cast(PushbackReader) getReader()).unread(ch);
302 } 302 }
303 303
304 protected String entity2Text(String symbol) { 304 protected String entity2Text(String symbol) {
305 if (symbol.length() > 1 && symbol.charAt(0) is '#') { 305 if (symbol.length() > 1 && symbol.charAt(0) is '#') {
306 int ch; 306 int ch;
308 if (symbol.charAt(1) is 'x') { 308 if (symbol.charAt(1) is 'x') {
309 ch= Integer.parseInt(symbol.substring(2), 16); 309 ch= Integer.parseInt(symbol.substring(2), 16);
310 } else { 310 } else {
311 ch= Integer.parseInt(symbol.substring(1), 10); 311 ch= Integer.parseInt(symbol.substring(1), 10);
312 } 312 }
313 return EMPTY_STRING + (char)ch; 313 return EMPTY_STRING + cast(wchar)ch;
314 } catch (NumberFormatException e) { 314 } catch (NumberFormatException e) {
315 } 315 }
316 } else { 316 } else {
317 String str= (String) fgEntityLookup.get(symbol); 317 String str= cast(String) fgEntityLookup.get(symbol);
318 if (str !is null) { 318 if (str !is null) {
319 return str; 319 return str;
320 } 320 }
321 } 321 }
322 return "&" + symbol; // not found //$NON-NLS-1$ 322 return "&" + symbol; // not found //$NON-NLS-1$
326 * A '&' has been read. Process a entity 326 * A '&' has been read. Process a entity
327 */ 327 */
328 private String processEntity() throws IOException { 328 private String processEntity() throws IOException {
329 StringBuffer buf= new StringBuffer(); 329 StringBuffer buf= new StringBuffer();
330 int ch= nextChar(); 330 int ch= nextChar();
331 while (Character.isLetterOrDigit((char)ch) || ch is '#') { 331 while (Character.isLetterOrDigit(cast(wchar)ch) || ch is '#') {
332 buf.append((char) ch); 332 buf.append(cast(wchar) ch);
333 ch= nextChar(); 333 ch= nextChar();
334 } 334 }
335 335
336 if (ch is ';') 336 if (ch is ';')
337 return entity2Text(buf.toString()); 337 return entity2Text(buf.toString());
338 338
339 buf.insert(0, '&'); 339 buf.insert(0, '&');
340 if (ch !is -1) 340 if (ch !is -1)
341 buf.append((char) ch); 341 buf.append(cast(wchar) ch);
342 return buf.toString(); 342 return buf.toString();
343 } 343 }
344 } 344 }