/* * [FindObsoleteRFCs.java] * * Summary: Find obsolete RFCs. * * Copyright: (c) 2012-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2012-12-23 initial release */ package com.mindprod.repair; import com.mindprod.common18.EIO; import com.mindprod.csv.CSVWriter; import com.mindprod.hunkio.HunkIO; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Find obsolete RFCs. *

* Manually update com.mindprod.htmlmacros.RFC.MAX_RFC * * @author Roedy Green, Canadian Mind Products * @version 1.0 2012-12-24 initial release * @since 2012-12-24 */ public class FindObsoleteRFCs { private static final Pattern pattern = Pattern.compile( "" + "RFC (\\d+)|" + "Obsoleted by: " + "RFC(\\d+)", Pattern.CASE_INSENSITIVE ); /** * Use findobsoleterfcs.btm to: * download http://www.faqs.org/rfcs/rfc-obsolete.html E:/com/mindprod/repair/obsoleterfcs.html * first. when done, copy E:/com/mindprod/repair/obsoleterfcs.csv to embellishments. * csvsort obsoleterfcs.csv 0n+ *

* Update upper limit in macro RFC * * @param args not used * * @throws IOException */ public static void main( final String[] args ) throws IOException { final String contents = HunkIO.readEntireFile( new File( "E:/com/mindprod/repair/obsoleterfcs.html" ) ); final File obs = new File( "E:/com/mindprod/repair/obsoleterfcs.csv" ); final PrintWriter prw = EIO.getPrintWriter( obs, 24 * 1024, EIO.UTF8 ); final CSVWriter w = new CSVWriter( prw, -1 /* quote level */, ',', '\"', '#', true ); final Matcher m = pattern.matcher( contents ); // Matchers are used both for matching and finding. String base = "unknown"; String replace; while ( m.find() ) { final int gc = m.groupCount(); assert gc == 2; final String first = m.group( 1 ); if ( first != null ) { base = first; } else { replace = m.group( 2 ); w.put( Integer.parseInt( base ) ); w.put( Integer.parseInt( replace ) ); w.nl(); } } w.close(); } }