dofile.pl (1.1.1.2) | dofile.pl (1.1.1.1) |
---|---|
1#! /usr/bin/env perl | 1#! /usr/bin/env perl |
2# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. | 2# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. |
3# 4# Licensed under the OpenSSL license (the "License"). You may not use 5# this file except in compliance with the License. You can obtain a copy 6# in the file LICENSE in the source distribution or at 7# https://www.openssl.org/source/license.html 8 9# Reads one or more template files and runs it through Text::Template 10# 11# It is assumed that this scripts is called with -Mconfigdata, a module 12# that holds configuration data in %config 13 14use strict; 15use warnings; 16 | 3# 4# Licensed under the OpenSSL license (the "License"). You may not use 5# this file except in compliance with the License. You can obtain a copy 6# in the file LICENSE in the source distribution or at 7# https://www.openssl.org/source/license.html 8 9# Reads one or more template files and runs it through Text::Template 10# 11# It is assumed that this scripts is called with -Mconfigdata, a module 12# that holds configuration data in %config 13 14use strict; 15use warnings; 16 |
17use FindBin; | |
18use Getopt::Std; 19 20# We actually expect to get the following hash tables from configdata: 21# 22# %config 23# %target 24# %withargs 25# %unified_info --- 8 unchanged lines hidden (view full) --- 34# http://search.cpan.org/~mjd/Text-Template-1.46/lib/Text/Template.pm#Automatic_postprocessing_of_template_hunks 35 36package OpenSSL::Template; 37 38# Because we know that Text::Template isn't a core Perl module, we use 39# a fallback in case it's not installed on the system 40use File::Basename; 41use File::Spec::Functions; | 17use Getopt::Std; 18 19# We actually expect to get the following hash tables from configdata: 20# 21# %config 22# %target 23# %withargs 24# %unified_info --- 8 unchanged lines hidden (view full) --- 33# http://search.cpan.org/~mjd/Text-Template-1.46/lib/Text/Template.pm#Automatic_postprocessing_of_template_hunks 34 35package OpenSSL::Template; 36 37# Because we know that Text::Template isn't a core Perl module, we use 38# a fallback in case it's not installed on the system 39use File::Basename; 40use File::Spec::Functions; |
42use lib "$FindBin::Bin/perl"; | 41use lib catdir(dirname(__FILE__)); |
43use with_fallback qw(Text::Template); 44 45#use parent qw/Text::Template/; 46use vars qw/@ISA/; 47push @ISA, qw/Text::Template/; 48 49# Override constructor 50sub new { --- 43 unchanged lines hidden (view full) --- 94# It might be practical to quotify some strings and have them protected 95# from possible harm. These functions primarly quote things that might 96# be interpreted wrongly by a perl eval. 97 98# quotify1 STRING 99# This adds quotes (") around the given string, and escapes any $, @, \, 100# " and ' by prepending a \ to them. 101sub quotify1 { | 42use with_fallback qw(Text::Template); 43 44#use parent qw/Text::Template/; 45use vars qw/@ISA/; 46push @ISA, qw/Text::Template/; 47 48# Override constructor 49sub new { --- 43 unchanged lines hidden (view full) --- 93# It might be practical to quotify some strings and have them protected 94# from possible harm. These functions primarly quote things that might 95# be interpreted wrongly by a perl eval. 96 97# quotify1 STRING 98# This adds quotes (") around the given string, and escapes any $, @, \, 99# " and ' by prepending a \ to them. 100sub quotify1 { |
102 my $s = my $orig = shift @_; | 101 my $s = shift @_; |
103 $s =~ s/([\$\@\\"'])/\\$1/g; | 102 $s =~ s/([\$\@\\"'])/\\$1/g; |
104 $s ne $orig || $s =~ /\s/ ? '"'.$s.'"' : $s; | 103 '"'.$s.'"'; |
105} 106 107# quotify_l LIST 108# For each defined element in LIST (i.e. elements that aren't undef), have 109# it quotified with 'quotofy1' 110sub quotify_l { 111 map { 112 if (!defined($_)) { --- 58 unchanged lines hidden (view full) --- 171 $x } @ARGV) 172 : join("", <STDIN>); 173 174# Engage! ############################################################ 175 176# Load the full template (combination of files) into Text::Template 177# and fill it up with our data. Output goes directly to STDOUT 178 | 104} 105 106# quotify_l LIST 107# For each defined element in LIST (i.e. elements that aren't undef), have 108# it quotified with 'quotofy1' 109sub quotify_l { 110 map { 111 if (!defined($_)) { --- 58 unchanged lines hidden (view full) --- 170 $x } @ARGV) 171 : join("", <STDIN>); 172 173# Engage! ############################################################ 174 175# Load the full template (combination of files) into Text::Template 176# and fill it up with our data. Output goes directly to STDOUT 177 |
179my $template = 180 OpenSSL::Template->new(TYPE => 'STRING', 181 SOURCE => $text, 182 PREPEND => qq{use lib "$FindBin::Bin/perl";}); | 178my $template = OpenSSL::Template->new(TYPE => 'STRING', SOURCE => $text ); |
183 184sub output_reset_on { 185 $template->output_reset_on(); 186 ""; 187} 188sub output_on { 189 $template->output_on(); 190 ""; --- 20 unchanged lines hidden --- | 179 180sub output_reset_on { 181 $template->output_reset_on(); 182 ""; 183} 184sub output_on { 185 $template->output_on(); 186 ""; --- 20 unchanged lines hidden --- |