Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e09e900d

Von Sven Schöling vor mehr als 9 Jahren hinzugefügt

  • ID e09e900d226835ec8d8983e0df5861157bcb2897
  • Vorgänger ffa9f969
  • Nachfolger 07062a3c

$&, $' und $` grösstenteils entfernt.

Unterschiede anzeigen:

SL/Locale.pm
441 441

  
442 442
  my ($yy, $mm, $dd) = $self->parse_date($myconfig, $date);
443 443

  
444
  $output_format =~ /d+/;
444
  $output_format =~ /(d+)/;
445 445
  substr($output_format, $-[0], $+[0] - $-[0]) =
446
    sprintf("%0" . (length($&)) . "d", $dd);
446
    sprintf("%0" . (length($1)) . "d", $dd);
447 447

  
448
  $output_format =~ /m+/;
448
  $output_format =~ /(m+)/;
449 449
  substr($output_format, $-[0], $+[0] - $-[0]) =
450
    sprintf("%0" . (length($&)) . "d", $mm);
450
    sprintf("%0" . (length($1)) . "d", $mm);
451 451

  
452 452
  $output_format =~ /y+/;
453 453
  substr($output_format, $-[0], $+[0] - $-[0]) = $yy;
......
474 474
  $yy = $yy % 100 if 2 == $yy_len;
475 475

  
476 476
  my $format = ref $myconfig eq '' ? "$myconfig" : $myconfig->{dateformat};
477
  $format =~ s{ d+ }{ sprintf("%0" . (length($&)) . "d", $dd) }gex;
478
  $format =~ s{ m+ }{ sprintf("%0" . (length($&)) . "d", $mm) }gex;
479
  $format =~ s{ y+ }{ sprintf("%0${yy_len}d",            $yy) }gex;
477
  $format =~ s{ (d+) }{ sprintf("%0" . (length($1)) . "d", $dd) }gex;
478
  $format =~ s{ (m+) }{ sprintf("%0" . (length($1)) . "d", $mm) }gex;
479
  $format =~ s{ (y+) }{ sprintf("%0${yy_len}d",            $yy) }gex;
480 480

  
481 481
  $main::lxdebug->leave_sub();
482 482

  
SL/Template/Excel.pm
48 48
  my $contents = join("", @lines);
49 49
  my @indices;
50 50
  $contents =~ s%
51
    $self->{tag_start} [<]* (\s?) [<>\s]* ([\w\s]+) [<>\s]* $self->{tag_end}
51
    ( $self->{tag_start} [<]* (\s?) [<>\s]* ([\w\s]+) [<>\s]* $self->{tag_end} )
52 52
  %
53
    $self->format_vars(align_right => $1 ne '', varstring => $2, length => length($&), indices =>  \@indices)
53
    $self->format_vars(align_right => $2 ne '', varstring => $3, length => length($1), indices =>  \@indices)
54 54
  %egx;
55 55

  
56 56
  if (!defined($contents)) {
SL/Template/LaTeX.pm
269 269
      $new_contents .= $self->substitute_vars(substr($contents, 0, $pos_foreach), @indices);
270 270
      substr($contents, 0, $pos_foreach) = "";
271 271

  
272
      if ($contents !~ m|^$self->{tag_start_qm}foreach (.+?)$self->{tag_end_qm}|) {
272
      if ($contents !~ m|^($self->{tag_start_qm}foreach (.+?)$self->{tag_end_qm})|) {
273 273
        $self->{"error"} = "Malformed $self->{tag_start}foreach$self->{tag_end}.";
274 274
        $main::lxdebug->leave_sub();
275 275
        return undef;
276 276
      }
277 277

  
278
      my $var = $1;
278
      my $var = $2;
279 279

  
280
      substr($contents, 0, length($&)) = "";
280
      substr($contents, 0, length($1)) = "";
281 281

  
282 282
      my $block;
283 283
      ($block, $contents) = $self->find_end($contents);
......
420 420
  my $contents = join("", @lines);
421 421

  
422 422
  # detect pagebreak block and its parameters
423
  if ($contents =~ /$self->{tag_start_qm}pagebreak\s+(\d+)\s+(\d+)\s+(\d+)\s*$self->{tag_end_qm}(.*?)$self->{tag_start_qm}end(\s*pagebreak)?$self->{tag_end_qm}/s) {
424
    $self->{"chars_per_line"} = $1;
425
    $self->{"lines_on_first_page"} = $2;
426
    $self->{"lines_on_second_page"} = $3;
427
    $self->{"pagebreak_block"} = $4;
423
  if ($contents =~ /^(.*)($self->{tag_start_qm}pagebreak\s+(\d+)\s+(\d+)\s+(\d+)\s*$self->{tag_end_qm}(.*?)$self->{tag_start_qm}end(\s*pagebreak)?$self->{tag_end_qm})/s) {
424
    $self->{"chars_per_line"} = $3;
425
    $self->{"lines_on_first_page"} = $4;
426
    $self->{"lines_on_second_page"} = $5;
427
    $self->{"pagebreak_block"} = $6;
428 428

  
429
    substr($contents, length($`), length($&)) = "";
429
    substr($contents, length($1), length($2)) = "";
430 430
  }
431 431

  
432 432
  $self->{"forced_pagebreaks"} = [];
SL/Template/OpenDocument.pm
210 210

  
211 211
  while ($contents ne "") {
212 212
    if (substr($contents, 0, 1) eq "<") {
213
      $contents =~ m|^<[^>]+>|;
214
      my $tag = $&;
215
      substr($contents, 0, length($&)) = "";
213
      $contents =~ m|^(<[^>]+>)|;
214
      my $tag = $1;
215
      substr($contents, 0, length($1)) = "";
216 216

  
217 217
      $self->{current_text_style} = $1 if $tag =~ m|text:style-name\s*=\s*"([^"]+)"|;
218 218

  
......
224 224
        if ($table_row =~ m|\&lt;\%foreachrow\s+(.*?)\%\&gt;|) {
225 225
          my $var = $1;
226 226

  
227
          $contents =~ m|\&lt;\%foreachrow\s+.*?\%\&gt;|;
228
          substr($contents, length($`), length($&)) = "";
227
          $contents =~ m|^(.*?)(\&lt;\%foreachrow\s+.*?\%\&gt;)|;
228
          substr($contents, length($1), length($2)) = "";
229 229

  
230
          ($table_row, $contents) = $self->find_end($contents, length($`));
230
          ($table_row, $contents) = $self->find_end($contents, length($1));
231 231
          if (!$table_row) {
232 232
            $self->{"error"} = "Unclosed <\%foreachrow\%>." unless ($self->{"error"});
233 233
            $main::lxdebug->leave_sub();
......
238 238
          $table_row .=  $1;
239 239
          $end_tag    =  $2;
240 240

  
241
          substr $contents, 0, length($&), '';
241
          substr $contents, 0, length($2), '';
242 242

  
243 243
          my $new_text = $self->parse_foreach($var, $table_row, $tag, $end_tag, @indices);
244 244
          if (!defined($new_text)) {
......
262 262
      }
263 263

  
264 264
    } else {
265
      $contents =~ /^[^<]+/;
266
      my $text = $&;
265
      $contents =~ /^([^<]+)/;
266
      my $text = $1;
267 267

  
268 268
      my $pos_if = index($text, '&lt;%if');
269 269
      my $pos_foreach = index($text, '&lt;%foreach');
......
278 278
        $new_contents .= $self->substitute_vars(substr($contents, 0, $pos_foreach), @indices);
279 279
        substr($contents, 0, $pos_foreach) = "";
280 280

  
281
        if ($contents !~ m|^\&lt;\%foreach (.*?)\%\&gt;|) {
281
        if ($contents !~ m|^(\&lt;\%foreach (.*?)\%\&gt;)|) {
282 282
          $self->{"error"} = "Malformed <\%foreach\%>.";
283 283
          $main::lxdebug->leave_sub();
284 284
          return undef;
285 285
        }
286 286

  
287
        my $var = $1;
287
        my $var = $2;
288 288

  
289
        substr($contents, 0, length($&)) = "";
289
        substr($contents, 0, length($1)) = "";
290 290

  
291 291
        my $block;
292 292
        ($block, $contents) = $self->find_end($contents);
SL/Template/Simple.pm
162 162
  $$new_contents .= $self->substitute_vars(substr($$contents, 0, $pos_if), @indices);
163 163
  substr($$contents, 0, $pos_if) = "";
164 164

  
165
  if ($$contents !~ m/^$self->{tag_start_qm}if
165
  if ($$contents !~ m/^( $self->{tag_start_qm}if
166 166
                     \s*
167
                     (not\b|\!)?           # $1 -- Eventuelle Negierung
167
                     (not\b|\!)?           # $2 -- Eventuelle Negierung
168 168
                     \s+
169
                     (\b.+?\b)             # $2 -- Name der zu überprüfenden Variablen
170
                     (                     # $3 -- Beginn des optionalen Vergleiches
169
                     (\b.+?\b)             # $3 -- Name der zu überprüfenden Variablen
170
                     (                     # $4 -- Beginn des optionalen Vergleiches
171 171
                       \s*
172
                       ([!=])              # $4 -- Negierung des Vergleiches speichern
173
                       ([=~])              # $5 -- Art des Vergleiches speichern
172
                       ([!=])              # $5 -- Negierung des Vergleiches speichern
173
                       ([=~])              # $6 -- Art des Vergleiches speichern
174 174
                       \s*
175
                       (                   # $6 -- Gequoteter String oder Bareword
175
                       (                   # $7 -- Gequoteter String oder Bareword
176 176
                         $self->{quot_re}
177
                         (.*?)(?<!\\)      # $7 -- Gequoteter String -- direkter Vergleich mit eq bzw. ne oder Patternmatching; Escapete Anführungs als Teil des Strings belassen
177
                         (.*?)(?<!\\)      # $8 -- Gequoteter String -- direkter Vergleich mit eq bzw. ne oder Patternmatching; Escapete Anführungs als Teil des Strings belassen
178 178
                         $self->{quot_re}
179 179
                       |
180
                         (\b.+?\b)         # $8 -- Bareword -- als Index für $form benutzen
180
                         (\b.+?\b)         # $9 -- Bareword -- als Index für $form benutzen
181 181
                       )
182 182
                     )?
183 183
                     \s*
184
                     $self->{tag_end_qm}
184
                     $self->{tag_end_qm} )
185 185
                    /x) {
186 186
    $self->{"error"} = "Malformed $self->{tag_start}if$self->{tag_end}.";
187 187
    $main::lxdebug->leave_sub();
188 188
    return undef;
189 189
  }
190 190

  
191
  my $not           = $1;
192
  my $var           = $2;
193
  my $comparison    = $3; # Optionaler Match um $4..$8
194
  my $operator_neg  = $4; # '=' oder '!' oder undef, wenn kein Vergleich erkannt
195
  my $operator_type = $5; # '=' oder '~' für Stringvergleich oder Regex
196
  my $quoted_word   = $7; # nur gültig, wenn quoted string angegeben (siehe unten); dann "value" aus <%if var == "value" %>
197
  my $bareword      = $8; # undef, falls quoted string angegeben wurde; andernfalls "othervar" aus <%if var == othervar %>
191
  my $not           = $2;
192
  my $var           = $3;
193
  my $comparison    = $4; # Optionaler Match um $4..$8
194
  my $operator_neg  = $5; # '=' oder '!' oder undef, wenn kein Vergleich erkannt
195
  my $operator_type = $6; # '=' oder '~' für Stringvergleich oder Regex
196
  my $quoted_word   = $8; # nur gültig, wenn quoted string angegeben (siehe unten); dann "value" aus <%if var == "value" %>
197
  my $bareword      = $9; # undef, falls quoted string angegeben wurde; andernfalls "othervar" aus <%if var == othervar %>
198 198

  
199 199
  $not = !$not if ($operator_neg && $operator_neg eq '!');
200 200

  
201
  substr($$contents, 0, length($&)) = "";
201
  substr($$contents, 0, length($1)) = "";
202 202

  
203 203
  my $block;
204 204
  ($block, $$contents) = $self->find_end($$contents, 0, "$var $comparison", $not);

Auch abrufbar als: Unified diff