Changeset 2253 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Conf.pm
- Timestamp:
- Aug 30, 2017, 5:07:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2252 r2253 192 192 if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.\?\[\]\*\+\\]+)\s*=\s*(.*)$/) { 193 193 pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n"); 194 $lh->{$1}->{$2}=$3; 194 my ($what, $var, $value) = ($1, $2, $3); 195 # Add support for multi-lines 196 while ($value =~ s/\\\s*$//o) { 197 $_ = <CONF>; 198 die "Still processing continuations for $what $var at EOF" if (not defined $_); 199 s/[\r\n]//go; 200 $value .= "\n$_"; 201 } 202 $lh->{$what}->{$var}=$value; 203 } elsif ((/^\s*#/o) || (/^\s*$/o)) { 204 # ignore 205 } else { 206 chomp(); 207 warn "unexpected line '$_' in $f"; 195 208 } 196 209 } … … 513 526 } 514 527 528 =item B<pb_conf_update_v0> 529 530 This function transform the old configuration v0 file as first param into a new v1 one as second param 531 532 =cut 533 534 sub pb_conf_update_v0 { 535 536 my $orig = shift; 537 my $dest = shift; 538 539 open(ORIG,$orig) || confess "Unable to open $orig"; 540 confess "Will not erase existing $dest while transforming $orig" if (-f $dest); 541 open(DEST,"> $dest") || confess "Unable to write into $dest"; 542 print DEST "--- %YAML 1.0\n"; 543 my $parambkp = ""; 544 my $pbconfverbkp = $PBCONFVER; 545 # We force migration from v0 to v1 546 $PBCONFVER = 0; 547 my $lh0; 548 $lh0 = pb_conf_cache($orig,$lh0); 549 $PBCONFVER = $pbconfverbkp; 550 551 # We can't just write the YAML if we want to ckeep comments ! 552 while (<ORIG>) { 553 if ($_ =~ /^#/) { 554 # Keep comments 555 print DEST $_; 556 } else { 557 if (/^\s*([A-z0-9-_]+)\s+(.+)$/) { 558 # Handle parameters 559 my ($param,$void) = ($1, $2); 560 print DEST " $param:\n" if ($param ne $parambkp); 561 print DEST " $lh0->{$param} $lh0->{$param}->{$var}\n"; 562 $parambkp = $param; 563 } else { 564 pb_log(0,"Unable to handle line $_\n"); 565 } 566 } 567 } 568 close(ORIG); 569 close(DEST); 570 return(); 571 } 572 515 573 =back 516 574
Note:
See TracChangeset
for help on using the changeset viewer.