From: Yoshito Umaoka Date: Wed, 27 Jul 2011 23:12:11 +0000 (+0000) Subject: ICU-8541 Delete NonAsciiFileDetector tool. We no longer use the tool at all. X-Git-Tag: milestone-59-0-1~4615 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3844edbe5173c81c0237ca64282746da5b768116;p=icu ICU-8541 Delete NonAsciiFileDetector tool. We no longer use the tool at all. X-SVN-Rev: 30435 --- diff --git a/.gitignore b/.gitignore index abf72284971..26b3685f3d6 100644 --- a/.gitignore +++ b/.gitignore @@ -954,7 +954,6 @@ tools/release/java/APIChangeReport* tools/release/java/Makefile.local tools/release/java/classes tools/release/java/lib -tools/release/java/src/com/ibm/icu/dev/tools/misc/*.class tools/trac/IcuCodeTools/0.11/*.egg-info tools/trac/IcuCodeTools/0.11/build tools/trac/IcuCodeTools/0.11/icucodetools/*.pyc diff --git a/tools/release/java/src/com/ibm/icu/dev/tools/misc/NonAsciiFileDetector.java b/tools/release/java/src/com/ibm/icu/dev/tools/misc/NonAsciiFileDetector.java deleted file mode 100644 index a2497798ac4..00000000000 --- a/tools/release/java/src/com/ibm/icu/dev/tools/misc/NonAsciiFileDetector.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - ********************************************************************** - * Copyright (c) 2008-2010, International Business Machines - * Corporation and others. All Rights Reserved. - ********************************************************************** - */ -package com.ibm.icu.dev.tools.misc; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.File; -import java.io.FilenameFilter; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; -import java.util.Vector; - -public class NonAsciiFileDetector -{ - - private static boolean VERBOSE = false; - - public static class ICUSourceFileFilter implements FilenameFilter - { - int matched = 0; - int skipped = 0; - public boolean accept(File dir, String name) - { - boolean doAccept = name.endsWith(".cpp") || name.endsWith(".c") || name.endsWith(".h") || name.endsWith(".java"); - if(doAccept) { - matched++; - } else { - skipped++; - } - return doAccept; - } - public String stats() { - return "Checked " + matched + " files and skipped " + skipped + " files"; - } - } - - public static int isNonAscii(File file) throws IOException - { - BufferedReader in = new BufferedReader(new FileReader(file)); - int line = 0; - while (true) { - String str = in.readLine(); - if (str == null) { - in.close(); - return -1; - } - for (int i = 0; i < str.length(); i ++) { - if (str.charAt(i) > 0x7f || str.charAt(i)==0x07) { - System.out.println("Ascii test failed in " - + file.getAbsolutePath() + " line " - + line + " string\n" + str); - // non-latin1 - in.close(); - return line; - } - } - line ++; - } - } - - public static void listFiles(File file, - FilenameFilter filter, - Vector list) throws IOException - { - if(VERBOSE) System.err.println(" .. checking " + file.getPath() ); - File files[] = file.listFiles(); - if (files != null && files.length > 0) { - for (int i = 0; i < files.length; i ++) { - if (files[i].isDirectory()) { - if(files[i].getAbsolutePath().equals(files[i].getCanonicalPath())) { - if(!files[i].getName().equals(".svn")) { // skip .svn dirs - listFiles(files[i], filter, list); - } - } else { - if(VERBOSE) { - System.err.println(".. skipping symlink " + files[i].getPath()); - } - } - } - else { - if (filter.accept(file, files[i].getName())) { - list.add(files[i]); - } - } - } - } - } - - public static Map getNonAsciiFiles(File directory, - FilenameFilter filter) - throws IOException - { - Vector files = new Vector(); - Map result = new TreeMap(); - listFiles(directory, filter, files); - int filecount = files.size(); - if (filecount == 0) { - return null; - } - for (int i = 0; i < filecount; i ++) { - int isnonascii = isNonAscii(files.elementAt(i)); - if (isnonascii != -1) { - result.put(files.elementAt(i).getAbsolutePath(),new Integer(isnonascii)); - } - } - return result; - } - - public static void main(String arg[]) - { - int nextArg = 0; - for(nextArg = 0;nextArg nonascii = getNonAsciiFiles(dir, isff); - boolean noised = false; - System.out.println(); - if (nonascii != null && nonascii.size() > 0) { - for (Entry e : nonascii.entrySet()) { - if(!noised) { - System.out.println("Non ascii files in " + arg[nextArg] + ": "); - noised = true; - } - System.out.println("" - +e.getKey() + ":" - +e.getValue()); - bad++; - } - } else { -// if (VERBOSE==true) { - System.out.println("No non ascii files in " + arg[nextArg]); -// } - } -// if(VERBOSE==true) { - System.out.println( isff.stats()); -// } - } catch (IOException e) { - System.err.println("Error processing " + arg[nextArg]); - e.printStackTrace(); - } - } - if(bad>0) { - System.err.println(bad+" non-ascii files found in total."); - } - } -} -