perl: refactor .pod name section extractor into its own module
[openssl.git] / util / extract-names.pl
index 744a8e2324e6cc7aaa2641d644ac2cfe1eeeafe8..2a24e1a99b374be80b49d00361965422131b4e30 100644 (file)
@@ -1,17 +1,26 @@
-#!/usr/bin/perl
+#! /usr/bin/env perl
+# Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
 
 $/ = "";                       # Eat a paragraph at once.
 while(<STDIN>) {
-    chop;
+    s|\R$||;
     s/\n/ /gm;
     if (/^=head1 /) {
        $name = 0;
     } elsif ($name) {
        if (/ - /) {
            s/ - .*//;
-           s/,[ \t]+/,/g;
-           s/^[ \t]+//g;
-           s/[ \t]+$//g;
+           s/,\s+/,/g;
+           s/\s+,/,/g;
+           s/^\s+//g;
+           s/\s+$//g;
+           s/\s/_/g;
            push @words, split ',';
        }
     }