1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4
5#*************************************************************************
6#
7# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8#
9# Copyright 2000, 2010 Oracle and/or its affiliates.
10#
11# OpenOffice.org - a multi-platform office productivity suite
12#
13# This file is part of OpenOffice.org.
14#
15# OpenOffice.org is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Lesser General Public License version 3
17# only, as published by the Free Software Foundation.
18#
19# OpenOffice.org is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22# GNU Lesser General Public License version 3 for more details
23# (a copy is included in the LICENSE file that accompanied this code).
24#
25# You should have received a copy of the GNU Lesser General Public License
26# version 3 along with OpenOffice.org.  If not, see
27# <http://www.openoffice.org/license.html>
28# for a copy of the LGPLv3 License.
29#
30#*************************************************************************
31
32
33#*****************************************************************************************
34# ASCII parser for the changeover of the current build.lst files to XML files            *
35# programmer: Pascal Junck, Sun Microsystems GmbH                                        *
36#*****************************************************************************************
37
38# this is the first step for the changeover of the current 'build.lst' files to the new
39# 'build.xlist'(XML) files
40# before we create the new ones we have to parse all important informations from the old files
41# important parameters are:
42# 1. 'module name'
43# 2. 'module dependency names'
44# 3. 'dependency type'
45# 4. 'job dir'
46# 5. 'depending directories'
47# 6. 'job platform'(only: 'w', 'u', 'm' and 'all')
48# 7. 'job'(only: 'nmake' means 'make')
49# 8. 'build requirements'(here called: 'restrictions')
50
51
52#################################  begin of main   #######################################
53
54use strict;
55use lib ("/home/vg119683/work/modules");
56
57use XMLBuildListParser;
58
59# get and work with each argument(build.lst files) of the commando line
60# e.g. if the user wants to parse the build.lst file(s):
61#   user input (on unix) for all modules    : 'perl -w ascii_parser.pl /so/ws/SRC680/src.m42/*/prj/build.lst'
62#   user input (on windows) for one module  : 'perl -w ascii_parser.pl O:/SRC680/src.m42/[module]/prj/build.lst'
63# get all arguments (build.lst files) of the commando line in this global variable '@buildlist_files'
64my @buildlist_files = @ARGV;
65# global variable for each file name that we want to parse in ASCII
66my $parse_file = "";
67# set the global variable '$debug' (= 1) to see all results on the terminal,
68# else (= 0) it shows nothing of the working output!
69my $debug = 0;
70
71# open the filehandle 'ERROR_LOG' for all errors
72open (ERROR_LOG, ">>ascii_parse.log")
73  or die "Error. Open the file <ascii_parse.log> wasn't successful!\n\n";
74
75# reference of the instance of a new object
76my $XMLTree;
77
78foreach (@buildlist_files)
79{
80   # get each element (= module) in '$parse_file'
81   $parse_file = $_;
82
83   # open the filehandle 'PARSE_ASCII' for each module/file that we want to parse
84   open (PARSE_ASCII, $parse_file)
85     or die "Error. Open the module <$parse_file> wasn't successful!\n\n";
86
87   # create a new object
88   $XMLTree = XMLBuildListParser->new();
89
90   # invoking of the main subroutine
91   reading_file();
92
93   # is the file name 'build.lst' in the path on the command line?
94   # if not, we can not parse and create the new 'build.xlist' file
95   if ($parse_file =~ /build(\w+)?\.lst\S*$/)
96   {
97      my $path = $parse_file;
98
99      $path =~ s/build(\w+)?\.lst\S*$/build\.xlist/;
100
101      $XMLTree->saveXMLFile($path);
102   }
103   else
104   {
105      add_errorlog_no_buildlst_file_found_statement($parse_file);
106   }
107
108   # close the current $parse_file
109   close(PARSE_ASCII);
110
111}
112# after all files were read close the errorlog file
113close(ERROR_LOG);
114
115
116###########################  begin of subroutines  #####################################
117#
118#                       global used variable: $parse_file
119#
120########################################################################################
121
122
123########################################################################################
124#       sub: reading_file
125#      gets: $_ (current file)
126#   returns: -
127########################################################################################
128sub reading_file
129{
130   # variable for the name of the current module
131   my $module_name = "";
132
133   # hashes for the infos beginning at the second line of the build.lst files
134   my %dir_of_job_platform = ();
135   my %dir_of_alias = ();
136
137   # control variable for the module dependency line of the file
138   #   like line 1 of module 'sal' (dependencies means the colon(s)) (SRC680/src.m42)
139   #   "sa      sal     :       xml2cmp NULL"
140   my $module_dependency_line_exists = 0;
141   my $module_dependency_line_was_read = 0;
142
143   # this line variables are for checking that all lines will be read
144   # counts each line
145   my $line_number = 0;
146   # for the sum of the informative lines (='module dependency line' and 'nmake' lines of the file)
147   my $info_line_sum = 0;
148   # for the sum of the no-info lines, like:
149   # job lines: 'usr1', 'get', ... and comment lines: '# ...' or empty lines
150   my $no_info_line_sum = 0;
151
152   # read all lines of the file to resolve the first alias
153   # with the matching dir to know all aliases and directories
154   # at the later second file reading
155   while (<PARSE_ASCII>)
156   {
157      # the variable for each line of a file
158      my $line = $_;
159
160      # count each line for more exact error descriptions in the log file
161      $line_number += 1;
162
163      # remember it, if this line exists
164      if ( (is_module_dependency_line($line)) && ($module_dependency_line_exists == 0) )
165      {
166         $module_dependency_line_exists = 1;
167
168         # get the name of the current module
169         $module_name = get_module_name($line);
170      }
171
172      # skip all lines, that hasn't the job 'nmake'
173      next if (!(is_nmake_line($line)));
174
175      # check that the infos (job directory, job platform and alias) exist
176      if (my ($job_dir, $job_platform, $alias) = get_alias_resolving_infos($line))
177      {
178         # prove that it's a valid job_platform
179         # and that each first alias and matching job platform exists only once
180         check_alias_and_job_platform($job_dir, $job_platform, $alias, \%dir_of_job_platform,
181                                      \%dir_of_alias, $module_name, $line_number);
182      }
183      else
184      {
185         chomp;
186         add_errorlog_unknown_format_statement($line, $module_name, $line_number);
187         next;
188      }
189   }
190   # reset the $line_number, because we count it again
191   $line_number = 0;
192
193   # read the same file again
194   seek (PARSE_ASCII,0,0);
195
196   # read each line of the file for all other informations
197   # e.g. line 8 of module 'sal'
198   # "sa  sal\systools\win32\guistdio  nmake  -     n          sa_guistdio     sa_uwinapi.n          NULL"
199   #             $job_dir              $job     $job_platform   1.$alias   2.$alias + alias platform
200   while (<PARSE_ASCII>)
201   {
202      # the variable for each line of a file
203      my $line = $_;
204
205      # count each line to check at the end of the file that all lines were read
206      # and for more exact error descriptions in the log file
207      $line_number += 1;
208
209      # is it a 'nmake' or a 'module dependency' line?
210      # if not: print this line to STDOUT,
211      #         count one to the no-info lines,
212      #         try to get the information about the module name from this line
213      #         and skip the line
214      if ( (!(is_nmake_line($line))) && (!(is_module_dependency_line($line))) )
215      {
216         my $no_info_line = show_no_info_line($line, $line_number);
217
218         $no_info_line_sum += $no_info_line;
219
220         # if no module dependency line exists get the name of the current module from another line
221         $module_name = get_module_name($line) if (!($module_name));
222
223         # skip the no-info line
224         next;
225      }
226
227      # only if the module dependency line exists and it wasn't read get the infos about it
228      if ( ($module_dependency_line_exists) && (!($module_dependency_line_was_read)) )
229      {
230         ($module_dependency_line_was_read, $info_line_sum) = get_module_dependency_line_infos
231                                                              ($line, $module_name, $line_number);
232      }
233
234      # get all 'nmake' line infos
235      my $info_line = get_nmake_line_infos($line, \%dir_of_alias, \%dir_of_job_platform,
236                                           $module_name, $line_number);
237
238      # count the info lines;
239      $info_line_sum += $info_line;
240   }
241
242   if ($debug == 1)
243   {
244      # show the sums of the info and no-info lines
245      lines_sums_output($module_name, $line_number, $info_line_sum, $no_info_line_sum);
246   }
247}
248
249########################################################################################
250#       sub: is_module_dependency_line
251#      gets: $line
252#   returns: 1 (true) or 0 (false)
253########################################################################################
254sub is_module_dependency_line
255{
256   my $line = shift;
257
258   # if the module dpendency line exists return 1, otherwise 0
259   ($line =~ /^\w+\s+\S+\s+:+\s+/)
260   ? return 1
261   : return 0;
262}
263
264########################################################################################
265#       sub: is_nmake_line
266#      gets: $line
267#   returns: '1' (true) or '0' (false)
268########################################################################################
269sub is_nmake_line
270{
271   my $line = shift;
272
273   # these lines are NO nmake lines:
274   # 1. a empty line
275   # 2. a comment line (perhaps with the job 'nmake')
276   #    like line 20 of module 'bridges' (SRC680/src.m42)
277   #    "#br  bridges\source\cli_uno  nmake  -  w,vc7  br_cli_uno br_unotypes NULL========= "
278   # 3. the module dependency line
279   #    like line 1 of module 'sal' (dependencies means the colon(s)) (SRC680/src.m42)
280   #    "sa      sal     :       xml2cmp N                                    ULL"
281   # 4. a 'p' job platform line (for OS2)
282   # 5. a line with a job, which is not 'nmake'
283   ($line =~ (/^[^\s+\#]/) && (!(/\s+:+\s+/)) && (!(/\s+p\s+/)) && (/\bnmake\b/) )
284   ? return 1
285   : return 0;
286}
287
288########################################################################################
289#       sub: get_alias_resolving_infos
290#      gets: $line
291#   returns: $job_dir, $job_platform, $alias
292########################################################################################
293sub get_alias_resolving_infos
294{
295   my $line = shift;
296
297   if ($line =~ /^\w+\s+(\S+)\s+\w+\s+\-\s+(\w+)\,?(\w+)?\s+(\S+)\s+/)
298   {
299      # get the current work directory
300      my $temp_job_dir = $1;
301
302      my $job_dir = change_job_directory($temp_job_dir);
303
304      # get the job platform of the current job
305      # if it is a 'n' job platform transform it to 'w'
306      # because 'n' can be used now as 'w' (both means windows)
307      my $job_platform = $2;
308      $job_platform = "w" if($job_platform eq "n");
309
310      # get the first alias in each line
311      my $alias = $4;
312
313      return ($job_dir, $job_platform, $alias);
314   }
315   return (undef, undef, undef);
316}
317
318########################################################################################
319#       sub: change_job_directory
320#      gets: $job_dir
321#   returns: $changed_job_dir
322########################################################################################
323# we don't need the module name and the first '\' in the current directory
324sub change_job_directory
325{
326   my $changed_job_dir = shift;
327
328   # ignore the module name
329   $changed_job_dir =~ s/^\w+//;
330   # change all other '\' against the '/' of the current dir
331   $changed_job_dir =~ s/\\/\//g;
332
333   # get only a "/" if we are in the root directory
334   $changed_job_dir = "/" if ($changed_job_dir eq "");
335
336   return $changed_job_dir;
337}
338
339########################################################################################
340#       sub: check_alias_and_job_platform
341#      gets: $job_dir, $job_platform, $alias, $dir_of_job_platform_ref,
342#            $dir_of_alias_ref, $module_name, $line_number
343#   returns: -
344########################################################################################
345# get it in the hash only if it is a valid job platform,
346# like 'w', 'u', 'm' and 'n'
347# 'all' is also valid but it doesn't exist in an alias platform(!)
348sub check_alias_and_job_platform
349{
350   my ($job_dir, $job_platform, $alias, $dir_of_job_platform_ref,
351       $dir_of_alias_ref, $module_name, $line_number) = @_;
352
353   # is it a valid job_platform?
354   if ($job_platform =~ /(w|u|m|n|all)/)
355   {
356      # get only the 'w', 'u', 'm' and 'n' based job platforms
357      if ($job_platform =~ /[wumn]/)
358      {
359         # doesn't the key already exist?
360         (!(exists $$dir_of_job_platform_ref{$job_platform.$alias}))
361           # get the first alias with the matching job platform in the hash
362         ? get_alias_and_job_platform($job_platform, $alias, $dir_of_job_platform_ref)
363           # this is a line with a redundant alias and job platform
364         : add_errorlog_alias_redundancy_statement($module_name, $alias, $job_platform, $line_number);
365      }
366      if (!(exists $$dir_of_alias_ref{$alias}))
367      {
368         # get each first alias with the matching job platform
369         get_alias_and_matching_directory($dir_of_alias_ref, $alias, $job_dir);
370      }
371   }
372   # it's not a valid job platform
373   else
374   {
375      add_errorlog_invalid_platform_statement($module_name, $job_platform, $line_number);
376   }
377}
378
379########################################################################################
380#       sub: get_alias_and_job_platform
381#      gets: $job_platform, $alias, $dir_of_job_platform_ref
382#   returns: -
383########################################################################################
384# get the the job platform and the first alias as a unique key
385# and the job platform as value of the hash
386# it's for checking later that the alias platform is equal to the job platform
387#   e.g.: line 6 + 7 of the module 'gtk' (SRC680/src.m42)
388#   "gt  gtk\pkgconfig  nmake  -  u   gt_pkg   NULL"
389#   "gt  gtk\glib       nmake  -  u   gt_glib gt_pkg.u NULL"
390#   the alias 'gt_pkg' has the directory 'gtk\pkgconfig' (we need only 'pkgconfig')
391#   and it has the job platform 'u' - compare it with the alias platform 'gt_pkg.u'
392sub get_alias_and_job_platform
393{
394   my ($job_platform, $alias, $dir_of_job_platform_ref) = @_;
395
396   # key = 'job platform' and 'first alias'   =>   value = 'job platform'
397   $$dir_of_job_platform_ref{$job_platform.$alias} = $job_platform;
398}
399
400########################################################################################
401#       sub: get_alias_and_matching_directory
402#      gets: $dir_of_alias_ref, $alias, $job_dir
403#   returns: -
404########################################################################################
405# fill the hash with the first alias and the matching directory
406#   e.g. line 14 of module 'setup2' (SRC680/src.m42)
407#   "se  setup2\win\source\unloader   nmake   -   w   se_wulo se_unotypes NULL"
408#   key = 'se_wulo'     =>    value = 'win/source/unloader'
409sub get_alias_and_matching_directory
410{
411   my ($dir_of_alias_ref, $alias, $job_dir) = @_;
412
413   #     key = 'first alias'  => value = 'job directory'
414   $$dir_of_alias_ref{$alias} = $job_dir;
415}
416
417########################################################################################
418#       sub: show_no_info_line
419#      gets: $line, $line_number
420#   returns: $no_info_line
421########################################################################################
422sub show_no_info_line
423{
424   my ($line, $line_number) = @_;
425   my $no_info_line += 1;
426
427   chomp($line);
428
429   print"Ignore line <$line_number>:\n\"$line\"\n\n" if ($debug);
430
431   return $no_info_line;
432}
433
434########################################################################################
435#       sub: get_module_name
436#      gets: $line
437#   returns: $module_name
438########################################################################################
439sub get_module_name
440{
441   my $line = shift;
442   my $module_name = "";
443
444   if ($line =~ /^\w+\s+([\w\.\-]+)\\?/)
445   {
446      $module_name = $1;
447   }
448
449   # set the 'module name' in the data structure tree
450   $XMLTree->setModuleName($module_name);
451
452   return $module_name;
453}
454
455########################################################################################
456#       sub: get_module_dependency_line_infos
457#      gets: $line, $module_name, $line_number
458#   returns: $module_dependency_line_was_read, $info_line_sum
459########################################################################################
460# get the informations about the module dependency line
461# like line 1 of module 'sal' (SRC680/src.m42)
462#    "sa     sal              :                       xml2cmp             NULL"
463#        $module_name   $module_dependency    @module_dependency_names
464sub get_module_dependency_line_infos
465{
466   my ($line, $module_name, $line_number) = @_;
467   my $module_dependency = "";
468   my @module_dependency_names = ();
469   my %dep_modules_and_products = ();
470   my $product = "";
471
472   my $module_dependency_line_was_read = 1;
473   my $info_line_sum = 1;
474
475   if ($debug)
476   {
477      print"\nline number               : <$line_number>\n";
478      print"module-name               : <$module_name>\n";
479   }
480
481   # get the dependencies
482   if ($line =~ /\s+(:+)\s+/)
483   {
484      $module_dependency = $1;
485      print"module-dependency         : <$module_dependency>\n" if ($debug);
486
487      # transform the dependency type to the corresponding tag name
488      if ($module_dependency eq ":")
489      {
490         $module_dependency = "md-simple";
491      }
492      elsif ($module_dependency eq "::")
493      {
494         $module_dependency = "md-always";
495      }
496      elsif ($module_dependency eq ":::")
497      {
498         $module_dependency = "md-force";
499      }
500   }
501
502   # get a list of all depending module names
503   if ($line =~ /:+\s+([\S\s]+)\s+NULL/)
504   {
505      @module_dependency_names = split(/\s+/, $1);
506
507      foreach my $module (@module_dependency_names)
508      {
509         # check whether that there is another product (as "all") of a module
510         if ($module =~ /(\S+):+(\S+)/)
511         {
512            $dep_modules_and_products{$2} = $1;
513         }
514         else
515         {
516            $dep_modules_and_products{$module} = "all";
517         }
518      }
519   }
520
521   # add the dependency module names, the module dependency type and the product to the data structure
522   foreach my $module (sort keys %dep_modules_and_products)
523   {
524      print"module-dependency-name(s) : key <$module>  value <".$dep_modules_and_products{$module}.">\n" if ($debug);
525
526      $XMLTree->addModuleDependencies($module, $module_dependency, $dep_modules_and_products{$module});
527   }
528
529   return ($module_dependency_line_was_read, $info_line_sum);
530}
531
532########################################################################################
533#       sub: get_nmake_line_infos
534#      gets: $line, \%dir_of_alias, \%dir_of_job_platform, $module_name, $line_number
535#   returns: $info_line
536########################################################################################
537# get all infos about the 'nmake' lines
538# e.g. line 8 of module 'sal'
539# "sa  sal\systools\win32\guistdio  nmake  -     n         sa_guistdio     sa_uwinapi.n          NULL"
540#             $job_dir              $job     $job_platform  1.$alias   2.$alias + alias platform
541sub get_nmake_line_infos
542{
543   my ($line, $dir_of_alias_ref, $dir_of_job_platform_ref, $module_name, $line_number) = @_;
544   my $directories_ref = "";
545   my $info_line = 0;
546
547   # get the infos about the 'nmake' lines
548   if ($line =~ /^\w+\s+(\S+)\s+(\w+)\s+\-\s+(\w+)\,?(\S+)?/)
549   {
550      # get the current working directory
551      my $temp_job_dir = $1;
552      my $job_dir = change_job_directory($temp_job_dir);
553
554      # get the job
555      my $job = $2;
556      $job = "make" if ($job eq "nmake");
557
558      # get the job platform of the current job
559      # if it is a 'n' job platform transform it to 'wnt'
560      # available values are: 'wnt', 'unx', 'mac' or 'all'
561      my $job_platform = $3;
562      $job_platform = change_job_platform_name($job_platform);
563
564      # get the first alias in each line
565      my $restriction = $4;
566      my %build_req = ( "$restriction" => "$job_platform") if ($restriction && $job_platform);
567
568
569      # get all aliases (but not the first) in an array
570      my $aliases_ref = get_aliases($line);
571
572      # filter the list of aliases, which has a 'p' job platform
573      # and transform a 'n' ending alias platform to a 'w' ending alias platform
574      filter_aliases($aliases_ref);
575
576      # resolve all aliases (alias[.job platform] => matching directory)
577      $directories_ref = resolve_aliases($aliases_ref, $dir_of_alias_ref,
578                                         $dir_of_job_platform_ref, $module_name, $line_number);
579
580      # count the informative lines
581      $info_line = 1;
582
583      $XMLTree->addJob($job_dir, $job, $job_platform, $directories_ref, \%build_req);
584
585      # show the infos, that we know about each line
586      if ($debug == 1)
587      {
588         show_line_infos($line_number, $job_dir, $job, $job_platform, $restriction, $aliases_ref, $directories_ref);
589      }
590   }
591   return $info_line;
592}
593
594########################################################################################
595#       sub: change_job_platform_name
596#      gets: $job_platform
597#   returns: $job_platform
598########################################################################################
599sub change_job_platform_name
600{
601   my $job_platform = shift;
602
603   $job_platform = "wnt" if($job_platform eq "n" || $job_platform eq "w");
604   $job_platform = "unx" if($job_platform eq "u");
605   $job_platform = "mac" if($job_platform eq "m");
606
607   return $job_platform;
608}
609
610########################################################################################
611#       sub: get_aliases
612#      gets: $_ (current line)
613#   returns: \@aliases
614########################################################################################
615# get all aliases of the line in an array
616sub get_aliases
617{
618   my $line = shift;
619   my @aliases = ();
620
621   # get all aliases in an array (but cut out the first alias)
622   if ($line =~ /\-\s+[\w+\,]+\s+([\S\s]+)\s+NULL$/)
623   {
624      print"\nall job aliases           : <$1>\n" if ($debug);
625
626      @aliases = split /\s+/, $1;
627
628      # we don't need the first alias (it stands for the current job directory)
629      shift @aliases;
630   }
631   return \@aliases;
632}
633
634########################################################################################
635#       sub: filter_aliases
636#      gets: $aliases_ref
637#   returns: -
638########################################################################################
639# filter all aliases, because we only need the 'w', 'u' and 'm' job platform based aliases
640sub filter_aliases
641{
642   my $aliases_ref = shift;
643
644   # get the highest index of the array (number of elements of the array - 1)
645   # also works: my $index = scalar(@$aliases_ref)-1;
646   my $index = $#{@{$aliases_ref}};
647
648   for (; $index >= 0; $index--)
649   {
650      # filter the 'p' job platform based aliases from '@aliases'
651      splice(@$aliases_ref, $index, 1) if ($$aliases_ref[$index] =~ /\.p$/);
652
653      # transform a '.n' ending alias platform to '.w' ending alias platform
654      if ($$aliases_ref[$index] =~ /\.n$/)
655      {
656         $$aliases_ref[$index] =~ s/\.n$/\.w/;
657         splice(@$aliases_ref, $index, 1, $$aliases_ref[$index]);
658      }
659   }
660}
661
662########################################################################################
663#       sub: resolve_aliases
664#      gets: $aliases_ref, $dir_of_alias_ref, $dir_of_job_platform_ref,
665#            $module_name, $line_number
666#   returns: \@directories
667########################################################################################
668# here we get each alias with the matching job directory
669sub resolve_aliases
670{
671   my ($aliases_ref, $dir_of_alias_ref, $dir_of_job_platform_ref, $module_name, $line_number) = @_;
672
673   my @directories = ();
674   my ($alias_platform, $alias, $temp_alias) = "";
675
676   # resolving all directory aliases
677   foreach $temp_alias (@$aliases_ref)
678   {
679      ($alias, $alias_platform) = compare_job_platform_with_alias_platform
680                                  ($temp_alias, $dir_of_job_platform_ref, $module_name, $line_number);
681
682      # does the alias exist?
683      if (exists $$dir_of_alias_ref{$alias})
684      {
685         # then get the matching directory in the array
686         push (@directories, $$dir_of_alias_ref{$alias});
687      }
688      else
689      {
690         add_errorlog_no_directory_of_alias_statement($module_name, $alias, $line_number);
691      }
692   }
693   return \@directories;
694}
695
696########################################################################################
697#       sub: compare_job_platform_with_alias_platform
698#      gets: $alias, $dir_of_job_platform_ref, $module_name, $line_number
699#   returns: $alias
700########################################################################################
701sub compare_job_platform_with_alias_platform
702{
703   my ($alias, $dir_of_job_platform_ref, $module_name, $line_number) = @_;
704
705   my $alias_platform = "";
706
707   # compare the alias platform (with a dot and an ending letter, like "al_alib.u")
708   # with the job platform of the line in which this alias was resolved
709   if ($alias =~ /\.([wum])$/)
710   {
711      $alias_platform = $1;
712
713      # don't memorize the ending dot and letter
714      $alias =~ s/\.\w$//;
715
716      # if the value(= job platform) of the hash or the alias platform has no value
717      # set it to "no valid value"
718      if (!(exists $$dir_of_job_platform_ref{$alias_platform.$alias}))
719      {
720         $$dir_of_job_platform_ref{$alias_platform.$alias} = "no valid value";
721      }
722      $alias_platform = "no valid value" if (!($alias_platform));
723
724      # are the job platform and the alias platform equal?
725      if ($$dir_of_job_platform_ref{$alias_platform.$alias} ne $alias_platform)
726      {
727         add_errorlog_not_equal_platforms_statement
728         ($module_name, $alias, $alias_platform, $dir_of_job_platform_ref, $line_number);
729      }
730   }
731   return ($alias, $alias_platform);
732}
733
734########################################################################################
735#       sub: show_line_infos
736#      gets: $line_number, $job_dir, $job, $job_platform, $restriction,
737#            $aliases_ref, $directories_ref
738#   returns: -
739########################################################################################
740# print the infos about each line
741sub show_line_infos
742{
743   my ($line_number, $job_dir, $job, $job_platform, $restriction, $aliases_ref, $directories_ref) = @_;
744
745   print"line number               : <$line_number>\n";
746   print"job directory             : <$job_dir>\n";
747   print"job                       : <$job>\n";
748   print"job platform              : <$job_platform>\n" if ($job_platform =~ /(w|u|m|all)/);
749   print"restriction               : <$restriction>\n" if ($restriction);
750   print"alias dependencies        : <@$aliases_ref>\n";
751   print"directory dependencies    : <@$directories_ref>\n\n";
752}
753
754########################################################################################
755#       sub: lines_sums_output
756#      gets: $module_name, $line_number, $info_line_sum, $no_info_line_sum
757#   returns: -
758########################################################################################
759sub lines_sums_output
760{
761   # this line variables are for checking that all lines will be read:
762   my ($module_name, $line_number, $info_line_sum, $no_info_line_sum) = @_;
763   my $lines_sum = 0;
764
765   add_errorlog_no_module_name_statement() if (!($module_name));
766
767   # were all lines read? and is the checksum okay?
768   $lines_sum = $info_line_sum + $no_info_line_sum;
769   if ($lines_sum == $line_number)
770   {
771      print"All $line_number line(s) of module <$module_name> were read and checked!\n\n";
772   }
773   else
774   {
775      add_errorlog_different_lines_sums_statement($module_name);
776   }
777
778   print"module: <$module_name>\n".
779        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n".
780        "   info line(s) sum    =  $info_line_sum\n".
781        "no-info line(s) sum    =  $no_info_line_sum\n".
782        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n".
783        "  total line(s) sum    =  $line_number\n\n\n";
784}
785
786
787############################ ERROR_LOG subroutines #####################################
788
789
790########################################################################################
791#       sub: add_errorlog_invalid_job_platform_statement
792#      gets: $module_name, $platform, $line_number
793#   returns: -
794########################################################################################
795sub add_errorlog_invalid_job_platform_statement
796{
797   my ($module_name, $job_platform, $line_number) = @_;
798
799   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
800                   "The job platform <$job_platform> is not valid.\n\n";
801}
802
803########################################################################################
804#       sub: add_errorlog_not_equal_platforms_statement
805#      gets: $module_name, $alias, $alias_platform, $dir_of_job_platform_ref, $line_number
806#   returns: -
807########################################################################################
808sub add_errorlog_not_equal_platforms_statement
809{
810   my ($module_name, $alias, $alias_platform, $dir_of_job_platform_ref, $line_number) = @_;
811
812   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
813                   "The alias platform <$alias.$alias_platform> is not equal ".
814                   "with the job platform <$$dir_of_job_platform_ref{$alias_platform.$alias}>.\n\n";
815}
816
817########################################################################################
818#       sub: add_errorlog_no_directory_of_alias_statement
819#      gets: $module_name, $alias, $line_number
820#   returns: -
821########################################################################################
822sub add_errorlog_no_directory_of_alias_statement
823{
824   my ($module_name, $alias, $line_number) = @_;
825
826   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
827                   "The directory of the alias <$alias> doesn't exist!\n\n";
828}
829
830########################################################################################
831#       sub: add_errorlog_no_module_name_statement
832#      gets: -
833#   returns: -
834########################################################################################
835sub add_errorlog_no_module_name_statement
836{
837   print ERROR_LOG "Error. No module name found in dir/file <$parse_file>.\n\n";
838}
839
840########################################################################################
841#       sub: add_errorlog_alias_redundancy_statement
842#      gets: $module_name, $alias, $job_platform, $line_number
843#   returns: -
844########################################################################################
845sub add_errorlog_alias_redundancy_statement
846{
847   my ($module_name, $alias, $job_platform, $line_number)= @_;
848
849   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.\n".
850                   "The alias <$alias> with the job platform <$job_platform> is redundant.\n\n";
851}
852
853########################################################################################
854#       sub: add_errorlog_unknown_format_statement
855#      gets: $module_name, $line_number
856#   returns: -
857########################################################################################
858sub add_errorlog_unknown_format_statement
859{
860   my ($line, $module_name, $line_number) = @_;
861
862   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file> line <$line_number>.".
863                   "\nUnknown format:\n\"$line\"\n\n";
864}
865
866########################################################################################
867#       sub: add_errorlog_different_lines_sums_statement
868#      gets: $module_name
869#   returns: -
870########################################################################################
871sub add_errorlog_different_lines_sums_statement
872{
873   my $module_name = shift;
874
875   print ERROR_LOG "Error in module <$module_name> of dir/file <$parse_file>.\n".
876                   "The sums of all info and no-info lines are not correct!\n\n";
877}
878
879########################################################################################
880#       sub: add_errorlog_no_buildlst_file_found_statement
881#      gets: $parse_file
882#   returns: -
883########################################################################################
884sub add_errorlog_no_buildlst_file_found_statement
885{
886   my $parse_file = shift;
887
888   print ERROR_LOG "Error in command line argument <$parse_file>.\n".
889                   "File 'build.lst' not found!\n";
890}
891
892############################# end of the subroutines ###################################
893