Subversion Repositories gelsvn

Rev

Rev 198 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 198 Rev 217
Line 56... Line 56...
56
                 'starts_with'     => 5,
56
                 'starts_with'     => 5,
57
                 'ends_with'       => 5,
57
                 'ends_with'       => 5,
58
                 'contains'        => 5,
58
                 'contains'        => 5,
59
                 'compares'        => 5,
59
                 'compares'        => 5,
60
                 'duplicate_index' => 5,
60
                 'duplicate_index' => 5,
-
 
61
                 'transdir'        => 5,
61
                );
62
                );
62
 
63
 
63
my(%target_type_vars) = ('type_is_static'   => 1,
64
my(%target_type_vars) = ('type_is_static'   => 1,
64
                         'need_staticflags' => 1,
65
                         'need_staticflags' => 1,
65
                         'type_is_dynamic'  => 1,
66
                         'type_is_dynamic'  => 1,
66
                         'type_is_binary'   => 1,
67
                         'type_is_binary'   => 1,
67
                        );
68
                        );
68
 
69
 
-
 
70
my(%arrow_op_ref) = ('custom_type'     => 'custom types',
-
 
71
                     'grouped_.*_file' => 'grouped files',
-
 
72
                     'feature'         => 'features',
-
 
73
                    );
-
 
74
 
69
# ************************************************************
75
# ************************************************************
70
# Subroutine Section
76
# Subroutine Section
71
# ************************************************************
77
# ************************************************************
72
 
78
 
73
sub new {
79
sub new {
Line 106... Line 112...
106
 
112
 
107
  return $self;
113
  return $self;
108
}
114
}
109
 
115
 
110
 
116
 
111
sub basename {
117
sub tp_basename {
112
  my($self) = shift;
118
  my($self) = shift;
113
  my($file) = shift;
119
  my($file) = shift;
114
 
120
 
115
  if ($self->{'cslashes'}) {
121
  if ($self->{'cslashes'}) {
116
    $file =~ s/.*[\/\\]//;
122
    $file =~ s/.*[\/\\]//;
Line 120... Line 126...
120
  }
126
  }
121
  return $file;
127
  return $file;
122
}
128
}
123
 
129
 
124
 
130
 
125
sub tp_dirname {
131
sub validated_dirname {
126
  my($self)  = shift;
132
  my($self)  = shift;
127
  my($file)  = shift;
133
  my($file)  = shift;
128
  my($index) = rindex($file, ($self->{'cslashes'} ? '\\' : '/'));
134
  my($index) = rindex($file, ($self->{'cslashes'} ? '\\' : '/'));
129
 
135
 
130
  if ($index >= 0) {
136
  if ($index >= 0) {
Line 134... Line 140...
134
    return '.';
140
    return '.';
135
  }
141
  }
136
}
142
}
137
 
143
 
138
 
144
 
-
 
145
sub tp_dirname {
-
 
146
  my($self)  = shift;
-
 
147
  my($file)  = shift;
-
 
148
  my($index) = rindex($file, ($self->{'cslashes'} ? '\\' : '/'));
-
 
149
 
-
 
150
  if ($index >= 0) {
-
 
151
    return substr($file, 0, $index);
-
 
152
  }
-
 
153
  else {
-
 
154
    return '.';
-
 
155
  }
-
 
156
}
-
 
157
 
-
 
158
 
139
sub strip_line {
159
sub strip_line {
140
  #my($self) = shift;
160
  #my($self) = shift;
141
  #my($line) = shift;
161
  #my($line) = shift;
142
 
162
 
143
  ## Override strip_line() from Parser.
163
  ## Override strip_line() from Parser.
Line 390... Line 410...
390
 
410
 
391
 
411
 
392
sub process_foreach {
412
sub process_foreach {
393
  my($self)   = shift;
413
  my($self)   = shift;
394
  my($index)  = $self->{'foreach'}->{'count'};
414
  my($index)  = $self->{'foreach'}->{'count'};
-
 
415
  my($base)   = $self->{'foreach'}->{'base'}->[$index];
395
  my($text)   = $self->{'foreach'}->{'text'}->[$index];
416
  my($text)   = $self->{'foreach'}->{'text'}->[$index];
396
  my($status) = 1;
417
  my($status) = 1;
397
  my($error)  = undef;
418
  my($error)  = undef;
398
  my(@values) = ();
419
  my(@values) = ();
399
  my($name)   = $self->{'foreach'}->{'name'}->[$index];
420
  my($name)   = $self->{'foreach'}->{'name'}->[$index];
400
  my(@cmds)   = ();
421
  my(@cmds)   = ();
401
  my($val)    = $self->{'foreach'}->{'vars'}->[$index];
422
  my($val)    = $self->{'foreach'}->{'vars'}->[$index];
-
 
423
  my($check_for_mixed) = undef;
402
 
424
 
403
  if ($val =~ /^((\w+),\s*)?flag_overrides\((.*)\)$/) {
425
  if ($val =~ /^((\w+),\s*)?flag_overrides\((.*)\)$/) {
404
    my($over) = $self->get_flag_overrides($3);
426
    my($over) = $self->get_flag_overrides($3);
405
    $name = $2;
427
    $name = $2;
406
    if (defined $over) {
428
    if (defined $over) {
Line 437... Line 459...
437
      }
459
      }
438
      if (!defined $name) {
460
      if (!defined $name) {
439
        $name = $n;
461
        $name = $n;
440
        $name =~ s/s$//;
462
        $name =~ s/s$//;
441
      }
463
      }
-
 
464
      if (!$check_for_mixed && !$self->{'prjc'}->is_keyword($n)) {
-
 
465
        $check_for_mixed = 1;
-
 
466
      }
442
    }
467
    }
443
  }
468
  }
444
 
469
 
445
  ## Perform the commands on the built up @values
470
  ## Perform the commands on the built up @values
446
  foreach my $cmd (reverse @cmds) {
471
  foreach my $cmd (reverse @cmds) {
Line 458... Line 483...
458
    $$scope{'forfirst'}    = 1;
483
    $$scope{'forfirst'}    = 1;
459
    $$scope{'fornotfirst'} = '';
484
    $$scope{'fornotfirst'} = '';
460
 
485
 
461
    ## If the foreach values are mixed (HASH and SCALAR), then
486
    ## If the foreach values are mixed (HASH and SCALAR), then
462
    ## remove the SCALAR values.
487
    ## remove the SCALAR values.
-
 
488
    if ($check_for_mixed) {
463
    my(%mixed) = ();
489
      my(%mixed) = ();
464
    my($mixed) = 0;
490
      my($mixed) = 0;
465
    for(my $i = 0; $i <= $#values; ++$i) {
491
      for(my $i = 0; $i <= $#values; ++$i) {
466
      $mixed{$values[$i]} = $self->set_current_values($values[$i]);
492
        $mixed{$values[$i]} = $self->set_current_values($values[$i]);
467
      $mixed |= $mixed{$values[$i]};
493
        $mixed |= $mixed{$values[$i]};
468
    }
494
      }
469
    if ($mixed) {
495
      if ($mixed) {
470
      my(@nvalues) = ();
496
        my(@nvalues) = ();
471
      foreach my $key (sort keys %mixed) {
497
        foreach my $key (sort keys %mixed) {
472
        if ($mixed{$key}) {
498
          if ($mixed{$key}) {
473
          push(@nvalues, $key);
499
            push(@nvalues, $key);
-
 
500
          }
474
        }
501
        }
475
      }
-
 
476
 
502
 
477
      ## Set the new values only if they are different
503
        ## Set the new values only if they are different
478
      ## from the original (except for order).
504
        ## from the original (except for order).
479
      my(@sorted) = sort(@values);
505
        my(@sorted) = sort(@values);
480
      if (@sorted != @nvalues) {
506
        if (@sorted != @nvalues) {
481
        @values = @nvalues;
507
          @values = @nvalues;
-
 
508
        }
482
      }
509
      }
483
    }
510
    }
484
 
511
 
485
    for(my $i = 0; $i <= $#values; ++$i) {
512
    for(my $i = 0; $i <= $#values; ++$i) {
486
      my($value) = $values[$i];
513
      my($value) = $values[$i];
Line 496... Line 523...
496
      }
523
      }
497
      if ($i == $#values) {
524
      if ($i == $#values) {
498
        $$scope{'forlast'}    = 1;
525
        $$scope{'forlast'}    = 1;
499
        $$scope{'fornotlast'} = '';
526
        $$scope{'fornotlast'} = '';
500
      }
527
      }
501
      $$scope{'forcount'} = $i + 1;
528
      $$scope{'forcount'} = $i + $base;
502
 
529
 
503
      ## We don't use adjust_value here because these names
530
      ## We don't use adjust_value here because these names
504
      ## are generated from a foreach and should not be adjusted.
531
      ## are generated from a foreach and should not be adjusted.
505
      $$scope{$name} = $value;
532
      $$scope{$name} = $value;
506
 
533
 
Line 598... Line 625...
598
    if ($name =~ /(\w+)->/) {
625
    if ($name =~ /(\w+)->/) {
599
      $pre = $1;
626
      $pre = $1;
600
    }
627
    }
601
 
628
 
602
    ## Replace the custom_type key with the actual custom type
629
    ## Replace the custom_type key with the actual custom type
603
    if ($name =~ /^custom_type\->/) {
630
    if (index($name, 'custom_type->') == 0) {
604
      my($ct) = $self->get_value('custom_type');
631
      my($ct) = $self->get_value('custom_type');
605
      if (defined $ct) {
632
      if (defined $ct) {
606
        $name = $ct;
633
        $name = $ct;
607
      }
634
      }
608
    }
635
    }
-
 
636
    elsif ($name =~ /^grouped_(.*_file)\->/) {
-
 
637
      $name = $1;
-
 
638
    }
609
 
639
 
610
    my($key) = (defined $$fo{$name} ? $name :
640
    my($key) = (defined $$fo{$name} ? $name :
611
                   (defined $$fo{$name . 's'} ? $name . 's' : undef));
641
                   (defined $$fo{$name . 's'} ? $name . 's' : undef));
612
    if (defined $key) {
642
    if (defined $key) {
613
      if (defined $prjc->{'matching_assignments'}->{$key}) {
643
      if (defined $prjc->{'matching_assignments'}->{$key}) {
Line 649... Line 679...
649
 
679
 
650
 
680
 
651
sub get_multiple {
681
sub get_multiple {
652
  my($self)  = shift;
682
  my($self)  = shift;
653
  my($name)  = shift;
683
  my($name)  = shift;
654
  my($value) = $self->get_value_with_default($name);
-
 
655
  return (defined $value ?
684
  return $self->doif_multiple(
656
              $self->doif_multiple($self->create_array($value)) :
685
                  $self->create_array(
657
              undef);
686
                           $self->get_value_with_default($name)));
658
}
687
}
659
 
688
 
660
 
689
 
661
sub doif_multiple {
690
sub doif_multiple {
662
  my($self)  = shift;
691
  my($self)  = shift;
Line 912... Line 941...
912
sub process_compound_if {
941
sub process_compound_if {
913
  my($self)   = shift;
942
  my($self)   = shift;
914
  my($str)    = shift;
943
  my($str)    = shift;
915
  my($status) = 0;
944
  my($status) = 0;
916
 
945
 
917
  if ($str =~ /\|\|/) {
946
  if (index($str, '||') >= 0) {
918
    my($ret) = 0;
947
    my($ret) = 0;
919
    foreach my $v (split(/\s*\|\|\s*/, $str)) {
948
    foreach my $v (split(/\s*\|\|\s*/, $str)) {
920
      $ret |= $self->process_compound_if($v);
949
      $ret |= $self->process_compound_if($v);
921
      if ($ret != 0) {
950
      if ($ret != 0) {
922
        return 1;
951
        return 1;
923
      }
952
      }
924
    }
953
    }
925
  }
954
  }
926
  elsif ($str =~ /\&\&/) {
955
  elsif (index($str, '&&') >= 0) {
927
    my($ret) = 1;
956
    my($ret) = 1;
928
    foreach my $v (split(/\s*\&\&\s*/, $str)) {
957
    foreach my $v (split(/\s*\&\&\s*/, $str)) {
929
      $ret &&= $self->process_compound_if($v);
958
      $ret &&= $self->process_compound_if($v);
930
      if ($ret == 0) {
959
      if ($ret == 0) {
931
        return 0;
960
        return 0;
Line 1052... Line 1081...
1052
  my($status)      = 1;
1081
  my($status)      = 1;
1053
  my($errorString) = undef;
1082
  my($errorString) = undef;
1054
 
1083
 
1055
  push(@{$self->{'lstack'}}, $self->get_line_number());
1084
  push(@{$self->{'lstack'}}, $self->get_line_number());
1056
  if (!$self->{'if_skip'}) {
1085
  if (!$self->{'if_skip'}) {
-
 
1086
    my($base)  = 1;
1057
    my($vname) = undef;
1087
    my($vname) = undef;
1058
    if ($val =~ /flag_overrides\([^\)]+\)/) {
1088
    if ($val =~ /flag_overrides\([^\)]+\)/) {
1059
    }
1089
    }
1060
    elsif ($val =~ /([^,]+),(.*)/) {
1090
    elsif ($val =~ /([^,]*),(.*)/) {
1061
      $vname = $1;
1091
      $vname = $1;
1062
      $val   = $2;
1092
      $val   = $2;
1063
      $vname =~ s/^\s+//;
1093
      $vname =~ s/^\s+//;
1064
      $vname =~ s/\s+$//;
1094
      $vname =~ s/\s+$//;
1065
      $val   =~ s/^\s+//;
1095
      $val   =~ s/^\s+//;
1066
      $val   =~ s/\s+$//;
1096
      $val   =~ s/\s+$//;
1067
 
1097
 
1068
      ## Due to the way flag_overrides works, we can't allow
-
 
1069
      ## the user to name the foreach variable when dealing
-
 
1070
      ## with custom types.
1098
      if ($vname eq '') {
1071
      if ($val =~ /^custom_type\->/ || $val eq 'custom_types') {
-
 
1072
        $status = 0;
1099
        $status = 0;
1073
        $errorString = 'The foreach variable can not be ' .
1100
        $errorString = 'The foreach variable name is not valid';
1074
                       'named when dealing with custom types';
-
 
1075
      }
1101
      }
-
 
1102
 
-
 
1103
      if ($val =~ /([^,]*),(.*)/) {
-
 
1104
        $base = $1;
-
 
1105
        $val  = $2;
-
 
1106
        $base =~ s/^\s+//;
-
 
1107
        $base =~ s/\s+$//;
-
 
1108
        $val  =~ s/^\s+//;
-
 
1109
        $val  =~ s/\s+$//;
-
 
1110
 
-
 
1111
        if ($base !~ /^\d+$/) {
-
 
1112
          $status = 0;
-
 
1113
          $errorString = 'The forcount specified is not a valid number';
-
 
1114
        }
-
 
1115
      }
-
 
1116
      elsif ($vname =~ /^\d+$/) {
-
 
1117
        $base  = $vname;
-
 
1118
        $vname = undef;
-
 
1119
      }
-
 
1120
 
-
 
1121
      ## Due to the way flag_overrides works, we can't allow
-
 
1122
      ## the user to name the foreach variable when dealing
-
 
1123
      ## with variables that can be used with the -> operator
-
 
1124
      if (defined $vname) {
-
 
1125
        foreach my $ref (keys %arrow_op_ref) {
-
 
1126
          my($name_re)  = $ref . 's';
1076
      elsif ($val =~ /^grouped_.*_file\->/ || $val =~ /^grouped_.*files$/) {
1127
          if ($val =~ /^$ref\->/ || $val =~ /^$name_re$/) {
1077
        $status = 0;
1128
            $status = 0;
1078
        $errorString = 'The foreach variable can not be ' .
1129
            $errorString = 'The foreach variable can not be ' .
1079
                       'named when dealing with grouped files';
1130
                           'named when dealing with ' .
-
 
1131
                           $arrow_op_ref{$ref};
-
 
1132
          }
-
 
1133
        }
1080
      }
1134
      }
1081
    }
1135
    }
1082
 
1136
 
1083
    push(@{$self->{'sstack'}}, $name);
1137
    push(@{$self->{'sstack'}}, $name);
1084
    my($index) = ++$self->{'foreach'}->{'count'};
1138
    my($index) = ++$self->{'foreach'}->{'count'};
1085
 
1139
 
-
 
1140
    $self->{'foreach'}->{'base'}->[$index]  = $base;
1086
    $self->{'foreach'}->{'name'}->[$index]  = $vname;
1141
    $self->{'foreach'}->{'name'}->[$index]  = $vname;
1087
    $self->{'foreach'}->{'vars'}->[$index]  = $val;
1142
    $self->{'foreach'}->{'vars'}->[$index]  = $val;
1088
    $self->{'foreach'}->{'text'}->[$index]  = '';
1143
    $self->{'foreach'}->{'text'}->[$index]  = '';
1089
    $self->{'foreach'}->{'scope'}->[$index] = {};
1144
    $self->{'foreach'}->{'scope'}->[$index] = {};
1090
    $self->{'foreach'}->{'scope_name'}->[$index] = undef;
1145
    $self->{'foreach'}->{'scope_name'}->[$index] = undef;
Line 1176... Line 1231...
1176
 
1231
 
1177
 
1232
 
1178
sub get_dirname {
1233
sub get_dirname {
1179
  my($self)  = shift;
1234
  my($self)  = shift;
1180
  my($name)  = shift;
1235
  my($name)  = shift;
1181
  my($value) = $self->get_value_with_default($name);
1236
  return $self->doif_dirname($self->get_value_with_default($name));
1182
  return (defined $value ?
-
 
1183
              $self->doif_dirname($value) : undef);
-
 
1184
}
1237
}
1185
 
1238
 
1186
 
1239
 
1187
sub doif_dirname {
1240
sub doif_dirname {
1188
  my($self)  = shift;
1241
  my($self)  = shift;
1189
  my($value) = shift;
1242
  my($value) = shift;
1190
 
1243
 
1191
  if (defined $value) {
1244
  if (defined $value) {
1192
    $value = $self->tp_dirname($value);
1245
    $value = $self->validated_dirname($value);
1193
    return ($value ne '.');
1246
    return ($value ne '.');
1194
  }
1247
  }
1195
  return undef;
1248
  return undef;
1196
}
1249
}
1197
 
1250
 
1198
 
1251
 
1199
sub handle_dirname {
1252
sub handle_dirname {
1200
  my($self) = shift;
1253
  my($self) = shift;
1201
  my($name) = shift;
1254
  my($name) = shift;
1202
 
1255
 
1203
  if (!$self->{'if_skip'}) {
-
 
1204
    $self->append_current(
1256
  $self->append_current(
1205
              $self->tp_dirname($self->get_value_with_default($name)));
1257
            $self->validated_dirname($self->get_value_with_default($name)));
1206
  }
-
 
1207
}
1258
}
1208
 
1259
 
1209
 
1260
 
1210
sub handle_basename {
1261
sub handle_basename {
1211
  my($self) = shift;
1262
  my($self) = shift;
1212
  my($name) = shift;
1263
  my($name) = shift;
1213
 
1264
 
1214
  if (!$self->{'if_skip'}) {
-
 
1215
    $self->append_current(
1265
  $self->append_current(
1216
              $self->basename($self->get_value_with_default($name)));
1266
            $self->tp_basename($self->get_value_with_default($name)));
1217
  }
-
 
1218
}
1267
}
1219
 
1268
 
1220
 
1269
 
1221
sub handle_basenoextension {
1270
sub handle_basenoextension {
1222
  my($self) = shift;
1271
  my($self) = shift;
1223
  my($name) = shift;
1272
  my($name) = shift;
1224
  my($val)  = $self->basename($self->get_value_with_default($name));
1273
  my($val)  = $self->tp_basename($self->get_value_with_default($name));
1225
 
1274
 
1226
  $val =~ s/\.[^\.]+$//;
1275
  $val =~ s/\.[^\.]+$//;
1227
  $self->append_current($val);
1276
  $self->append_current($val);
1228
}
1277
}
1229
 
1278
 
Line 1254... Line 1303...
1254
  my($self) = shift;
1303
  my($self) = shift;
1255
  my($name) = shift;
1304
  my($name) = shift;
1256
  my($val)  = $self->get_value_with_default($name);
1305
  my($val)  = $self->get_value_with_default($name);
1257
 
1306
 
1258
  if (defined $val) {
1307
  if (defined $val) {
1259
    if ($val =~ /<%eval\($name\)%>/) {
1308
    if (index($val, "<%eval($name)%>") >= 0) {
1260
      $self->warning("Infinite recursion detected in '$name'.");
1309
      $self->warning("Infinite recursion detected in '$name'.");
1261
    }
1310
    }
1262
    else {
1311
    else {
1263
      ## Enter the eval state
1312
      ## Enter the eval state
1264
      ++$self->{'eval'};
1313
      ++$self->{'eval'};
Line 1297... Line 1346...
1297
sub doif_duplicate_index {
1346
sub doif_duplicate_index {
1298
  my($self)  = shift;
1347
  my($self)  = shift;
1299
  my($value) = shift;
1348
  my($value) = shift;
1300
 
1349
 
1301
  if (defined $value) {
1350
  if (defined $value) {
1302
    my($base) = lc($self->basename($value));
1351
    my($base) = lc($self->tp_basename($value));
1303
    my($path) = $self->tp_dirname($value);
1352
    my($path) = $self->validated_dirname($value);
1304
 
1353
 
1305
    if (!defined $self->{'dupfiles'}->{$base}) {
1354
    if (!defined $self->{'dupfiles'}->{$base}) {
1306
      $self->{'dupfiles'}->{$base} = [$path];
1355
      $self->{'dupfiles'}->{$base} = [$path];
1307
    }
1356
    }
1308
    else {
1357
    else {
Line 1325... Line 1374...
1325
 
1374
 
1326
sub handle_duplicate_index {
1375
sub handle_duplicate_index {
1327
  my($self) = shift;
1376
  my($self) = shift;
1328
  my($name) = shift;
1377
  my($name) = shift;
1329
 
1378
 
1330
  if (!$self->{'if_skip'}) {
-
 
1331
    my($value) = $self->doif_duplicate_index(
1379
  my($value) = $self->doif_duplicate_index(
1332
                          $self->get_value_with_default($name));
1380
                        $self->get_value_with_default($name));
1333
    if (defined $value) {
1381
  if (defined $value) {
1334
      $self->append_current($value);
1382
    $self->append_current($value);
-
 
1383
  }
-
 
1384
}
-
 
1385
 
-
 
1386
 
-
 
1387
sub get_transdir {
-
 
1388
  my($self)  = shift;
-
 
1389
  my($name)  = shift;
-
 
1390
  return $self->doif_transdir($self->get_value_with_default($name));
-
 
1391
}
-
 
1392
 
-
 
1393
 
-
 
1394
sub doif_transdir {
-
 
1395
  my($self)  = shift;
-
 
1396
  my($value) = shift;
-
 
1397
 
-
 
1398
  if ($value =~ /([\/\\])/) {
-
 
1399
    return $self->{'prjc'}->translate_directory(
-
 
1400
                                  $self->tp_dirname($value)) . $1;
1335
    }
1401
  }
-
 
1402
 
-
 
1403
  return undef;
-
 
1404
}
-
 
1405
 
-
 
1406
 
-
 
1407
sub handle_transdir {
-
 
1408
  my($self)  = shift;
-
 
1409
  my($name)  = shift;
-
 
1410
  my($value) = $self->doif_transdir($self->get_value_with_default($name));
-
 
1411
 
-
 
1412
  if (defined $value) {
-
 
1413
    $self->append_current($value);
1336
  }
1414
  }
1337
}
1415
}
1338
 
1416
 
1339
 
1417
 
1340
sub prepare_parameters {
1418
sub prepare_parameters {
Line 1342... Line 1420...
1342
  my($prefix) = shift;
1420
  my($prefix) = shift;
1343
  my($input)  = $self->get_value($prefix . '->input_file');
1421
  my($input)  = $self->get_value($prefix . '->input_file');
1344
  my($output) = undef;
1422
  my($output) = undef;
1345
 
1423
 
1346
  if (defined $input) {
1424
  if (defined $input) {
1347
    if ($self->{'cslashes'}) {
1425
    $input =~ s/\//\\/g if ($self->{'cslashes'});
1348
      $input = $self->{'prjc'}->slash_to_backslash($input);
-
 
1349
    }
-
 
1350
    $output = $self->get_value($prefix . '->input_file->output_files');
1426
    $output = $self->get_value($prefix . '->input_file->output_files');
1351
 
1427
 
1352
    if (defined $output) {
1428
    if (defined $output) {
1353
      my($size) = scalar(@$output);
1429
      my($size) = scalar(@$output);
1354
      for(my $i = 0; $i < $size; ++$i) {
1430
      for(my $i = 0; $i < $size; ++$i) {
1355
        my($fo) = $self->get_flag_overrides($prefix . '->input_file, gendir');
1431
        my($fo) = $self->get_flag_overrides($prefix . '->input_file, gendir');
1356
        if (defined $fo) {
1432
        if (defined $fo) {
1357
          $$output[$i] = $fo . '/' . File::Basename::basename($$output[$i]);
1433
          $$output[$i] = $fo . '/' . $self->tp_basename($$output[$i]);
1358
        }
-
 
1359
        if ($self->{'cslashes'}) {
-
 
1360
          $$output[$i] = $self->{'prjc'}->slash_to_backslash($$output[$i]);
-
 
1361
        }
1434
        }
-
 
1435
        $$output[$i] =~ s/\//\\/g if ($self->{'cslashes'});
1362
      }
1436
      }
1363
    }
1437
    }
1364
  }
1438
  }
1365
 
1439
 
1366
  ## Set the parameters array with the determined input and output files
1440
  ## Set the parameters array with the determined input and output files
Line 1373... Line 1447...
1373
  my($line)        = shift;
1447
  my($line)        = shift;
1374
  my($length)      = 0;
1448
  my($length)      = 0;
1375
  my($status)      = 1;
1449
  my($status)      = 1;
1376
  my($errorString) = undef;
1450
  my($errorString) = undef;
1377
 
1451
 
1378
  if ($line eq '') {
-
 
1379
  }
-
 
1380
  elsif ($line =~ /^\w+(\(([^\)]+|\".*\"|[!]?(\w+\s*,\s*)?\w+\(.+\))\)|\->\w+([\w\-\>]+)?)?%>/) {
1452
  if ($line =~ /^\w+(\(([^\)]+|\".*\"|[!]?(\w+\s*,\s*)?\w+\(.+\))\)|\->\w+([\w\-\>]+)?)?%>/) {
1381
    ## Split the line into a name and value
1453
    ## Split the line into a name and value
1382
    my($name, $val) = ();
1454
    my($name, $val) = ();
1383
    if ($line =~ /([^%\(]+)(\(([^%]+)\))?%>/) {
1455
    if ($line =~ /([^%\(]+)(\(([^%]+)\))?%>/) {
1384
      $name = lc($1);
1456
      $name = lc($1);
1385
      $val  = $3;
1457
      $val  = $3;
-
 
1458
      $length += length($name);
1386
    }
1459
    }
1387
 
1460
 
1388
    $length += length($name);
-
 
1389
    if (defined $val) {
1461
    if (defined $val) {
1390
      ## Check for the parenthesis
1462
      ## Check for the parenthesis
1391
      if (($val =~ tr/(//) != ($val =~ tr/)//)) {
1463
      if (($val =~ tr/(//) != ($val =~ tr/)//)) {
1392
        $status = 0;
1464
        $status = 0;
1393
        $errorString = 'Missing the closing parenthesis';
1465
        $errorString = 'Missing the closing parenthesis';
Line 1467... Line 1539...
1467
  my($self)  = shift;
1539
  my($self)  = shift;
1468
  my($prjc)  = $self->{'prjc'};
1540
  my($prjc)  = $self->{'prjc'};
1469
  my($cwd)   = $self->getcwd();
1541
  my($cwd)   = $self->getcwd();
1470
 
1542
 
1471
  ## Set the current working directory
1543
  ## Set the current working directory
1472
  if ($self->{'cslashes'}) {
1544
  $cwd =~ s/\//\\/g if ($self->{'cslashes'});
1473
    $cwd = $prjc->slash_to_backslash($cwd);
-
 
1474
  }
-
 
1475
  $self->{'values'}->{'cwd'} = $cwd;
1545
  $self->{'values'}->{'cwd'} = $cwd;
1476
 
1546
 
1477
  ## Collect the components into {'values'} somehow
1547
  ## Collect the components into {'values'} somehow
1478
  foreach my $key (keys %{$prjc->{'valid_components'}}) {
1548
  foreach my $key (keys %{$prjc->{'valid_components'}}) {
1479
    my(@list) = $prjc->get_component_list($key);
1549
    my(@list) = $prjc->get_component_list($key);
Line 1520... Line 1590...
1520
  ## since each guid generated will be different.  We need
1590
  ## since each guid generated will be different.  We need
1521
  ## this to correspond to the same guid used in the workspace.
1591
  ## this to correspond to the same guid used in the workspace.
1522
  my($guid) = $prjc->update_project_info($self, 1, ['guid']);
1592
  my($guid) = $prjc->update_project_info($self, 1, ['guid']);
1523
  $self->{'values'}->{'guid'} = $guid;
1593
  $self->{'values'}->{'guid'} = $guid;
1524
 
1594
 
-
 
1595
  ## In order for VC7 to mix languages, we need to keep track
-
 
1596
  ## of the language associated with each project.
-
 
1597
  $prjc->update_project_info($self, 1, ['language']);
-
 
1598
 
1525
  ## Some Windows based projects can't deal with certain version
1599
  ## Some Windows based projects can't deal with certain version
1526
  ## values.  So, for those we provide a translated version.
1600
  ## values.  So, for those we provide a translated version.
1527
  my($version) = $prjc->get_assignment('version');
1601
  my($version) = $prjc->get_assignment('version');
1528
  if (defined $version) {
1602
  if (defined $version) {
1529
    $self->{'values'}->{'win_version'} =
1603
    $self->{'values'}->{'win_version'} =
Line 1531... Line 1605...
1531
  }
1605
  }
1532
}
1606
}
1533
 
1607
 
1534
 
1608
 
1535
sub parse_line {
1609
sub parse_line {
1536
  my($self)        = shift;
1610
  my($self)        = $_[0];
1537
  my($ih)          = shift;
1611
  #my($ih)          = $_[1];
1538
  my($line)        = shift;
1612
  my($line)        = $_[2];
1539
  my($status)      = 1;
1613
  my($status)      = 1;
1540
  my($errorString) = undef;
1614
  my($errorString) = undef;
1541
  my($startempty)  = (length($line) == 0 ? 1 : 0);
1615
  my($startempty)  = ($line eq '');
1542
 
1616
 
1543
  ## If processing a foreach or the line only
1617
  ## If processing a foreach or the line only
1544
  ## contains a keyword, then we do
1618
  ## contains a keyword, then we do
1545
  ## not need to add a newline to the end.
1619
  ## not need to add a newline to the end.
1546
  if (!$self->{'eval'} && $self->{'foreach'}->{'processing'} == 0) {
1620
  if (!$self->{'eval'} && $self->{'foreach'}->{'processing'} == 0 &&
1547
    if ($line !~ /^[ ]*<%(\w+)(\(((\w+\s*,\s*)?\w+\(.+\)|[^\)]+)\))?%>$/ ||
1621
      ($line !~ /^[ ]*<%(\w+)(\(((\w+\s*,\s*)?[!]?\w+\(.+\)|[^\)]+)\))?%>$/ ||
1548
        !defined $keywords{$1}) {
1622
       !defined $keywords{$1})) {
1549
      $line .= $self->{'crlf'};
1623
    $line .= $self->{'crlf'};
1550
    }
-
 
1551
  }
1624
  }
1552
 
1625
 
1553
  if (!$self->{'eval'} && $self->{'foreach'}->{'count'} < 0) {
1626
  if (!$self->{'eval'} && $self->{'foreach'}->{'count'} < 0) {
1554
    $self->{'built'} = '';
1627
    $self->{'built'} = '';
1555
  }
1628
  }
1556
 
1629
 
1557
  my($start) = index($line, '<%');
1630
  my($start) = index($line, '<%');
1558
  if ($start >= 0) {
1631
  if ($start >= 0) {
1559
    my($append_name) = 0;
1632
    my($append_name) = undef;
1560
    if ($start > 0) {
1633
    if ($start > 0) {
1561
      if (!$self->{'if_skip'}) {
1634
      if (!$self->{'if_skip'}) {
1562
        $self->append_current(substr($line, 0, $start));
1635
        $self->append_current(substr($line, 0, $start));
1563
      }
1636
      }
1564
      $line = substr($line, $start);
1637
      $line = substr($line, $start);
1565
    }
1638
    }
1566
    foreach my $item (split('<%', $line)) {
1639
    foreach my $item (split('<%', $line)) {
1567
      my($name)   = 1;
1640
      my($name)   = 1;
1568
      my($length) = length($item);
1641
      my($length) = length($item);
-
 
1642
      my($endi)   = index($item, '%>');
1569
      for(my $i = 0; $i < $length; ++$i) {
1643
      for(my $i = 0; $i < $length; ++$i) {
1570
        my($part) = substr($item, $i, 2);
-
 
1571
        if ($part eq '%>') {
1644
        if ($i == $endi) {
1572
          ++$i;
1645
          ++$i;
-
 
1646
          $endi = index($item, '%>', $i);
1573
          $name = 0;
1647
          $name = undef;
1574
          if ($append_name) {
1648
          if ($append_name) {
1575
            $append_name = 0;
1649
            $append_name = undef;
1576
            if (!$self->{'if_skip'}) {
1650
            if (!$self->{'if_skip'}) {
1577
              $self->append_current($part);
1651
              $self->append_current('%>');
1578
            }
1652
            }
1579
          }
1653
          }
1580
          if ($length != $i + 1) {
1654
          if ($length != $i + 1) {
1581
            if (!$self->{'if_skip'}) {
1655
            if (!$self->{'if_skip'}) {
1582
              $self->append_current(substr($item, $i + 1));
1656
              $self->append_current(substr($item, $i + 1));
Line 1584... Line 1658...
1584
            last;
1658
            last;
1585
          }
1659
          }
1586
        }
1660
        }
1587
        elsif ($name) {
1661
        elsif ($name) {
1588
          my($substr)  = substr($item, $i);
1662
          my($substr)  = substr($item, $i);
1589
          my($efcheck) = ($substr =~ /^endfor\%\>/);
1663
          my($efcheck) = (index($substr, 'endfor%>') == 0);
1590
          my($focheck) = ($efcheck ? 0 : ($substr =~ /^foreach\(/));
1664
          my($focheck) = ($efcheck ? 0 : (index($substr, 'foreach(') == 0));
1591
 
1665
 
1592
          if ($focheck && $self->{'foreach'}->{'count'} >= 0) {
1666
          if ($focheck && $self->{'foreach'}->{'count'} >= 0) {
1593
            ++$self->{'foreach'}->{'nested'};
1667
            ++$self->{'foreach'}->{'nested'};
1594
          }
1668
          }
1595
 
1669
 
Line 1600... Line 1674...
1600
            my($nlen) = 0;
1674
            my($nlen) = 0;
1601
            ($status,
1675
            ($status,
1602
             $errorString,
1676
             $errorString,
1603
             $nlen) = $self->process_name($substr);
1677
             $nlen) = $self->process_name($substr);
1604
 
1678
 
-
 
1679
            if (!$status) {
-
 
1680
              last;
-
 
1681
            }
1605
            if ($status && $nlen == 0) {
1682
            elsif ($nlen == 0) {
1606
              $errorString = "Could not parse this line at column $i";
1683
              $errorString = "Could not parse this line at column $i";
1607
              $status = 0;
1684
              $status = 0;
1608
            }
-
 
1609
            if (!$status) {
-
 
1610
              last;
1685
              last;
1611
            }
1686
            }
1612
 
1687
 
1613
            $i += ($nlen - 1);
1688
            $i += ($nlen - 1);
1614
          }
1689
          }
1615
          else  {
1690
          else  {
1616
            $name = 0;
1691
            $name = undef;
1617
            if (!$self->{'if_skip'}) {
1692
            if (!$self->{'if_skip'}) {
1618
              $self->append_current('<%' . substr($item, $i, 1));
1693
              $self->append_current('<%' . substr($item, $i, 1));
1619
              $append_name = 1;
1694
              $append_name = 1;
1620
            }
1695
            }
1621
          }
1696
          }
Line 1628... Line 1703...
1628
          if (!$self->{'if_skip'}) {
1703
          if (!$self->{'if_skip'}) {
1629
            $self->append_current(substr($item, $i, 1));
1704
            $self->append_current(substr($item, $i, 1));
1630
          }
1705
          }
1631
        }
1706
        }
1632
      }
1707
      }
-
 
1708
      last if (!$status);
1633
    }
1709
    }
1634
  }
1710
  }
1635
  else {
1711
  else {
1636
    if (!$self->{'if_skip'}) {
1712
    if (!$self->{'if_skip'}) {
1637
      $self->append_current($line);
1713
      $self->append_current($line);