/[smeserver]/rpms/e-smith-lib/sme8/e-smith-lib-1.18.0-binmode.patch
ViewVC logotype

Contents of /rpms/e-smith-lib/sme8/e-smith-lib-1.18.0-binmode.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Wed Aug 20 21:25:30 2008 UTC (15 years, 9 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
New dev stream

1 diff -Nur -x '*.orig' -x '*.rej' e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/config.pm mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/config.pm
2 --- e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/config.pm 2008-07-31 09:12:57.000000000 -0600
3 +++ mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/config.pm 2008-07-31 09:09:54.000000000 -0600
4 @@ -170,9 +170,9 @@
5
6 =cut
7
8 -sub _readconf ($)
9 +sub _readconf
10 {
11 - my ($filename) = @_;
12 + my ($self, $filename) = @_;
13
14 my %config = ();
15
16 @@ -185,7 +185,8 @@
17 return \%config;
18 }
19
20 - binmode(FH, ":encoding(UTF-8)") if $filename =~ m{navigation};
21 + my $binmode = $self->_read_binmode;
22 + binmode(FH, $binmode) if $binmode;
23 while (my $line = <FH>)
24 {
25 chomp $line;
26 @@ -232,10 +233,9 @@
27
28 =cut
29
30 -sub _writeconf ($$)
31 +sub _writeconf
32 {
33 - shift while($#_ > 1);
34 - my ($filename, $config) = @_;
35 + my ($self, $filename, $config) = @_;
36
37 eval {
38 if (-f $filename && ! -r $filename)
39 @@ -245,7 +245,8 @@
40
41 sysopen (FH, "$filename.$$", O_RDWR | O_CREAT, 0660)
42 or die "Cannot open $filename.$$: $!\n";
43 - binmode(FH, ":utf8") if $filename =~ m{navigation};
44 + my $binmode = $self->_write_binmode;
45 + binmode(FH, $binmode) if $binmode;
46
47 die "Error writing to $filename.$$: $!" unless
48 printf FH <<EOF, scalar localtime;
49 @@ -386,7 +387,7 @@
50 };
51 bless $self, $class;
52
53 - $self->{CONFIG} = _readconf($filename);
54 + $self->{CONFIG} = $self->_readconf($filename);
55
56 return $self;
57 }
58 @@ -439,7 +440,7 @@
59
60 # read in config again, just in case it changed
61 $self->_lock_write;
62 - $self->{CONFIG} = _readconf($self->{FILENAME});
63 + $self->{CONFIG} = $self->_readconf($self->{FILENAME});
64
65 if (exists $self->{CONFIG}{$key} and
66 $self->{CONFIG}{$key} eq $value)
67 @@ -464,7 +465,7 @@
68 $self->{CONFIG} {$key} = $value;
69 &log("$self->{FILENAME}: NEW $key=$self->{CONFIG}{$key}");
70
71 - _writeconf ($self->{FILENAME}, $self->{CONFIG});
72 + $self->_writeconf ($self->{FILENAME}, $self->{CONFIG});
73 $self->_unlock;
74
75 return undef;
76 @@ -484,10 +485,10 @@
77
78 # read in config again, just in case it changed
79 $self->_lock_write;
80 - $self->{CONFIG} = _readconf($self->{FILENAME});
81 + $self->{CONFIG} = $self->_readconf($self->{FILENAME});
82
83 my $previous = delete $self->{CONFIG} {$key};
84 - _writeconf ($self->{FILENAME}, $self->{CONFIG});
85 + $self->_writeconf ($self->{FILENAME}, $self->{CONFIG});
86 $self->_unlock;
87
88 &log("$self->{FILENAME}: DELETE $key=$previous");
89 @@ -524,7 +525,7 @@
90 my $self = shift;
91
92 $self->{CONFIG} = ();
93 - _writeconf ($self->{FILENAME}, $self->{CONFIG});
94 + $self->_writeconf ($self->{FILENAME}, $self->{CONFIG});
95
96 &log("$self->{FILENAME}: CLEAR");
97
98 @@ -598,6 +599,25 @@
99 closelog();
100 }
101
102 +=item _read_binmode
103 +
104 +return undef, indicating that by default binmode() need not be called after
105 +file open.
106 +
107 +=end _private
108 +
109 +=cut
110 +
111 +sub _read_binmode
112 +{
113 + return undef;
114 +}
115 +
116 +sub _write_binmode
117 +{
118 + return undef;
119 +}
120 +
121 =head1 BUGS and CAVEATS
122
123 You can't have newlines in keys or values.
124 diff -Nur -x '*.orig' -x '*.rej' e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db/Record.pm mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db/Record.pm
125 --- e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db/Record.pm 2005-07-27 14:24:02.000000000 -0600
126 +++ mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db/Record.pm 2008-07-31 09:01:17.000000000 -0600
127 @@ -194,7 +194,6 @@
128 $ret = db_set_prop($self->{config}, $self->{key},
129 $property => $value);
130 }
131 - esmith::config::_writeconf($self->{db}->{file}, $self->{config});
132 return $ret;
133 }
134
135 @@ -223,7 +222,6 @@
136
137 my $val = $self->prop($property);
138 db_delete_prop($self->{config}, $self->{key}, $property);
139 - esmith::config::_writeconf($self->{db}->{file}, $self->{config});
140
141 return $val;
142 }
143 @@ -269,7 +267,6 @@
144
145 my $type = delete $merged_props{type};
146 db_set($self->{config}, $self->{key}, $type, \%merged_props);
147 - esmith::config::_writeconf($self->{db}->{file}, $self->{config});
148 }
149
150 =item B<reset_props>
151 @@ -313,7 +310,6 @@
152
153 my $type = delete $new_props{type} || $self->prop('type');
154 db_set($self->{config}, $self->{key}, $type, \%new_props);
155 - esmith::config::_writeconf($self->{db}->{file}, $self->{config});
156 }
157
158
159 @@ -331,7 +327,6 @@
160
161 croak "The DB is open read-only" if $self->{db}->is_ro;
162 db_delete($self->{config}, $self->{key});
163 - esmith::config::_writeconf($self->{db}->{file}, $self->{config});
164 }
165
166 =item B<show>
167 diff -Nur -x '*.orig' -x '*.rej' e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db.pm mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db.pm
168 --- e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db.pm 2006-02-16 20:52:14.000000000 -0700
169 +++ mezzanine_patched_e-smith-lib-1.18.0/root/usr/lib/perl5/site_perl/esmith/DB/db.pm 2008-07-31 09:03:47.000000000 -0600
170 @@ -255,7 +255,7 @@
171 my ( $self, $file ) = @_;
172
173 my %config;
174 - tie %config, 'esmith::config', $file;
175 + tie %config, $self->tie_class, $file;
176
177 return \%config;
178 }
179 @@ -404,7 +404,7 @@
180 }
181 my $type = exists $props->{type} ? delete $props->{type} : '';
182 db_set( $self->{config}, $key, $type, $props );
183 - esmith::config::_writeconf($self->{file}, $self->{config});
184 + $self->tie_class->_writeconf($self->{file}, $self->{config});
185
186 return esmith::DB::db::Record->_construct( $self, $key, $self->{config} );
187 }
188 @@ -474,6 +474,17 @@
189
190 =end testing
191
192 +=cut
193 +
194 +sub tie_class
195 +{
196 + return 'esmith::config';
197 +}
198 +
199 +sub close
200 +{
201 +}
202 +
203 =begin deprecated
204
205 =item B<list_by_type>

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed