Changeset 664 for CMT/v1r25-branch


Ignore:
Timestamp:
Jan 13, 2014, 4:09:37 PM (10 years ago)
Author:
rybkin
Message:

merge -r 646:663 HEAD

Location:
CMT/v1r25-branch
Files:
83 edited
4 copied

Legend:

Unmodified
Added
Removed
  • CMT/v1r25-branch

  • CMT/v1r25-branch/ChangeLog

    r646 r664  
     12014-01-10    <rybkin@lal.in2p3.fr> 522
     2
     3        * source/cmt_tag.cxx: Update authorship info
     4        * source/cmt_std.h: idem
     5        * source/cmt_awk.cxx: idem
     6        * source/cmt_system.cxx: idem
     7        * source/cmt_symbol.h: idem
     8        * source/cmt_project.h: idem
     9        * source/cmt_use.cxx: idem
     10        * source/cmt_install_area.cxx: idem
     11        * source/cmt_tag.h: idem
     12        * source/cmt_deps_builder.cxx: idem
     13        * source/cmt_fragment.cxx: idem
     14        * source/cmt_generators.cxx: idem
     15        * source/cmt_constituent.cxx: idem
     16        * source/cmt.cxx: idem
     17        * source/cmt_deps_builder.h: idem
     18        * source/cmt_syntax.cxx: idem
     19        * source/cmt_triggers.cxx: idem
     20        * source/cmt_fragment.h: idem
     21        * source/cmt_database.h: idem
     22        * source/cmt_error.cxx: idem
     23        * source/cmt_generators.h: idem
     24        * source/cmt_model.cxx: idem
     25        * source/cmt_commands.cxx: idem
     26        * source/cmt_constituent.h: idem
     27        * source/cmt_project.cxx: idem
     28        * source/cmt_generator.h: idem
     29        * source/cmt_pattern.cxx: idem
     30        * source/cmt_error.h: idem
     31        * source/cmt_regexp.h: idem
     32        * source/cmt_parser.h: idem
     33        * source/cmt_language.cxx: idem
     34        * source/cmt_commands.h: idem
     35        * source/cmt_lock.cxx: idem
     36        * source/cmt_string.h: idem
     37        * source/cmt_vcs.cxx: idem
     38        * source/cmt_cmtpath_pattern.cxx: idem
     39        * source/cmt_map.h: idem
     40        * source/cmt_database.cxx: idem
     41        * source/cmt_log.h: idem
     42        * source/cmt_language.h: idem
     43        * source/cmt_system.h: idem
     44        * source/cmt_vcs.h: idem
     45        * source/cmt_use.h: idem
     46        * source/cmt_cmtpath_pattern.h: idem
     47        * source/cmt_generator.cxx: idem
     48        * source/cmt_regexp.cxx: idem
     49        * source/cmt_cvs.cxx: idem
     50        * source/cmt_parser.cxx: idem
     51        * source/cmt_symbol.cxx: idem
     52        * source/cmt.h: idem
     53        * source/cmt_string.cxx: idem
     54        * mgr/fragments/nmake/packages_header: idem
     55        * mgr/fragments/packages_header: idem
     56        * src/NMakefile.core: idem
     57        * src/NMakefile.header: idem
     58        * src/setup.tcsh: idem
     59        * src/setup.zsh: idem
     60        * src/Makefile.core: idem
     61        * src/Makefile.header: idem
     62
     632014-01-06    <rybkin@lal.in2p3.fr> 521
     64
     65        * source/cmt_tag.h: In class Tag, introduce static function apply_tag to
     66        return map of tags and uses in which apply_tag statement appears for tag
     67        * source/cmt_tag.cxx: In class Tag, in function action_apply update map of
     68        tags and uses returned by function apply_tag, in function check_tag_used
     69        return true if tag appears in apply_tag statement, in function
     70        show_definition print uses in which apply_tag statement appears for tag
     71        * source/cmt_map.h: In templated class cmt_vnode, remove const modifiers
     72        for function find to allow for cmt_vnode value to be modified, in templated
     73        class cmt_vmap, in function find remove const modifier for return value
     74        to allow for cmt_vmap values to be modified
     75        * source/cmt_parser.cxx: Implement helper function parse_cmt_flags to parse
     76        -with(out)_cmt, -with(out)_projects, -(no)_strip_path flags from
     77        requirements file, in class Cmt, modify function configure_current_package
     78        to return location of requirements file if found, in function configure
     79        make use of function parse_cmt_flags, do not read user requirements file(s)
     80        for action_none
     81        * source/cmt_symbol.cxx: In class PathBuilder, introduce static function
     82        get_path_builder to return unique class instance, make assignment operator
     83        and copy constructor private to forbid copying, make other constructors
     84        private, in class Symbol functions create and set_strip_path make use of
     85        function get_path_builder
     86        * source/cmt.h: In class Cmt, modify function configure_current_package
     87        signature
     88        * mgr/requirements: Associate CMTv1 tag with with HEAD
     89       
     902013-12-13    <rybkin@lal.in2p3.fr> 520
     91
     92        * mgr/CMT.dtd: Correct CMT site URL
     93       
     942013-12-13    <rybkin@lal.in2p3.fr> 519
     95
     96        * source/cmt_symbol.cxx: In class Symbol function action, fully resolve
     97        setup, cleanup script path except for setup, cleanup shell script
     98        generation, in function print_clean, use unalias command to remove alias
     99        with Bourne syntax shell, in function print, fully resolve set value, do
     100        not mangle set, path name in Xml mode
     101        * source/cmt_parser.cxx: In class Cmt function print_context, do not mangle
     102        use prefix in Xml mode
     103       
     1042013-12-11    <rybkin@lal.in2p3.fr> 518
     105
     106        * source/cmt_commands.cxx: In class ArgParser, functions
     107        option(_no)_path_strip renamed option(_no)_strip_path, command line options
     108        -(no_)path_strip renamed -(no_)strip_path
     109        * source/cmt_commands.h: idem
     110        * source/cmt_symbol.h: In class class Symbol, function set_path_strip
     111        renamed set_strip_path
     112        * source/cmt_symbol.cxx: In class PathBuilder, functions get/set_path_strip
     113        renamed get/set_strip_path, member m_path_strip renamed m_strip_path
     114        * source/cmt.h: In class CmtContext, member m_path_strip renamed
     115        m_strip_path, in class Cmt, function get_path_strip renamed get_strip_path
     116        * source/cmt_parser.cxx: In class Cmt function do_setup, use
     117        -no_strip_path, -strip_path option names, function get_strip_path, class
     118        Symbol function set_strip_path
     119       
     1202013-12-06    <rybkin@lal.in2p3.fr> 517
     121
     122        * source/cmt_deps_builder.cxx: In helper function in_line_action, fix
     123        parsing in case neither quotes or comments are found
     124       
     1252013-12-05    <rybkin@lal.in2p3.fr> 516
     126
     127        * source/cmt_deps_builder.cxx: In helper function at_start_action, fix
     128        parsing Fortran INCLUDE statement, optimise in_line_action helper function,
     129        in helper function build_deps_text, fix parsing C++ style comments in case
     130        without other characters
     131        * source/cmt_parser.cxx: In class Cmt function do_broadcast, add package,
     132        version, offset info to printout of "cmt broadcast" command, similar to
     133        printout in CMTBCAST mode
     134       
     1352013-12-03    <rybkin@lal.in2p3.fr> 515
     136
     137        * source/cmt_symbol.h: In class SymbolValueList function print, class
     138        Symbol functions all_print, print introduce optional argument of type
     139        ostream reference, in class Symbol, declare static functions std_env_vars,
     140        set_path_strip
     141        * source/cmt_symbol.cxx: In class PathBuilder, introduce and implement
     142        functions filter_path_value, get/set_path_strip, constructor with
     143        path_strip argument and member m_path_strip to indicate whether to strip
     144        paths of non-existent directories, in unnamed namespace, introduce cache
     145        of command outputs for use in functions resolve_value,
     146        resolve_value_for_macros, suppress_OS_delimiters, in class Symbol function
     147        create, create PathBuilder instance with configured value of path_strip,
     148        in class Symbol, implement static functions std_env_vars, set_path_strip,
     149        control access to environment in functions resolve_value, class Symbol
     150        functions all_set, get_env_value, class SetBuilder function build, class
     151        PathBuilder function build, systematically use class PathBuilder function
     152        filter_path_value in class Symbol functions all_set, check_all_paths,
     153        print, in class PathBuilder function build, in class SymbolValueList
     154        function print, modify helper function find_path_entry so as not to access
     155        file system and return index of entry found, in class PathBuilder function
     156        build, make use of signature to enhance implementation of path_append /
     157        prepend commands, drop redundant cleaning of repeating path separators, in
     158        class SymbolValueList function print, implement enhanced cached
     159        requirements file generation, i.e., resolve sets for macros if possible,
     160        resolve paths fully if possible, so as to strip path of non-existent
     161        directories, implement use of argument of type ostream reference
     162        * source/cmt_use.cxx: In class Use function fill_standard_macros, generate
     163        CONFIG macros, if CONFIG environment variables are relevant, in setup
     164        Requirements mode
     165        * source/cmt_error.cxx: Cosmetic modifications to error messages
     166        * source/cmt_commands.h: In class ArgParser, declare functions
     167        option_with(out)_projects, option(_no)_path_strip
     168        * source/cmt_commands.cxx: In class ArgParser, implement introduced
     169        functions
     170        * source/cmt.h: In class CmtContext, introduce member m_use_projects to
     171        indicate whether to parse project files, member m_env_access to indicate
     172        whether symbols values can be taken from environment, member m_print_mode
     173        to hold corresponding value from class ArgParser instance, member
     174        m_path_strip to indicate whether to strip paths of non-existent
     175        directories, in class Cmt functions print, print_context introduce optional
     176        argument of type ostream reference, declare and implement inline functions
     177        get/set_env_access, get/set_print_mode, get_path_strip
     178        * source/cmt_parser.cxx: In class Cmt function configure_cmt_path, do not
     179        create projects if m_use_projects is false, in function do_broadcast, set
     180        cmtpath for all uses so as to fill in templates correctly, in function
     181        do_check_configuration, do not run class Symbol function check_all_paths
     182        for setup unless in Requirements mode (since paths checks are done in class
     183        Symbol function print), in function do_setup, implement procedure of cached
     184        requirements file generation, i.e., do not access environment to set
     185        symbols values and, by default, strip paths of non-existent directories if
     186        possible, in function guess_current_project, return if projects are not
     187        used, do not change m_autoconfigure_cmtpath value, in functions print,
     188        print_context, implement use of argument of type ostream reference, in
     189        function print_context, in Requirements mode, generate CONFIG sets if
     190        CONFIG environment variables are relevant, in function
     191        use_special_requirements, handle case when projects are not used
     192        * mgr/requirements: Associate CMTr25 tag with HEAD, append CMT to PATH as
     193        in CMT setup scripts
     194       
     1952013-11-13    <rybkin@lal.in2p3.fr> 514
     196
     197        * source/cmt_use.cxx: In class Use get_strategy function, make use of now
     198        fast get_project function rather than compute, in fill_standard_macros,
     199        get_package_name, get_project functions, simplify code
     200        * source/cmt_parser.cxx: In class Cmt install_scripts functions, make
     201        generated setup and cleanup scrips call CMT executable directly rather than
     202        via shell script wrapper
     203        * src/setup.sh: Reduce usage of external shell utilities by using POSIX
     204        shell features instead
     205        * src/cleanup.sh: idem, unset everything set by setup.sh
     206        * src/setup.csh: Reduce usage of external shell utilities by using C shell
     207        features instead
     208        * src/cleanup.csh: idem, unset everything set by setup.csh
     209        * src/cleanup.tcsh: Add script to unset TCSH specific environment setup
     210        * src/cleanup.zsh: Add script to unset Z shell specific environment setup
     211        * src/cleanup.bash: Add script to unset BASH specific environment setup
     212       
     2132013-11-08    <rybkin@lal.in2p3.fr> 513
     214
     215        * source/cmt.h: In class CmtContext, make assignment operator and copy
     216        constructor private to forbid copying, in class Cmt, inline simple member
     217        functions for speed-up, add static member to hold reference to CmtContext
     218        instance
     219        * source/cmt_parser.cxx: Initialize static class Cmt member, comment out
     220        inlined class Cmt methods implementation
     221       
     2222013-11-07    <rybkin@lal.in2p3.fr> 512
     223
     224        * source/cmt_tag.cxx: In class Tag mark function, do not activate tag if
     225        in list of tags to remove, making -tag_remove=<tag-list> option functional
     226        on any tags (rather than only those specified on the command line or in
     227        CMTEXTRATAGS environment variable)
     228        * source/cmt_syntax.cxx: In classes KwdBuildStrategy, KwdSetupStrategy,
     229        KwdStructureStrategy action project function, make error description
     230        detailed, in class SyntaxParser do_parse_words project function, print
     231        error message in case of syntax error encountered in value
     232        * source/cmt_parser.cxx: In class CmtContext, factor out processing of
     233        CMTEXTRATAGS environment variable value into separate initialize function,
     234        in class Cmt, move restore_all_tags call into configure function before all
     235        system tags handling to make all initially known tags available while
     236        reading project files, implement get_tags_remove function, in parser
     237        function initialise static CmtContext instance at very beginning
     238        * source/cmt.h: In class Cmt, declare get_tags_remove function
     239       
     2402013-11-05    <rybkin@lal.in2p3.fr> 511
     241
     242        * source/cmt_project.h: In class Project, change fill_selection function
     243        signature to return projects (pointers), introduce function fill_exclusion
     244        * source/cmt_project.cxx: In class ProjectFactory create_project function,
     245        use change_path function on project use object, in class Project implement
     246        fill_selection function for enhanced handling of special CMTHOME,
     247        CMTUSERCONTEXT projects (selected if current project only) and special
     248        depth values (0: CMTUSERCONTEXT project only, -1: CMTHOME project only),
     249        implement fill_exclusion function to exclude special CMTHOME,
     250        CMTUSERCONTEXT projects unless current project, in find_in_cmt_paths
     251        function fix search condition and comment out never used code, in
     252        container_action function issue warning or set error if container package
     253        cannot be located
     254        * source/cmt_use.h: In class Use, add member to hold project (pointer)
     255        package found in, add optional argument project (pointer) to change_path,
     256        select_alternate functions, add set_project function, inline located
     257        function, make m_located member private
     258        * source/cmt_use.cxx: In class Use, assign use project in function
     259        change_path, in class UseProjectAction run and class Use select_alternate
     260        functions, in particular, in functions get_cmtpath_and_offset,
     261        fill_standard_macros, get_project make use of added class member (project)
     262        for optimisation
     263        * source/cmt_generators.h: In class PackagesMakefileGenerator, add member
     264        m_ISINCLUDED
     265        * source/cmt_generators.cxx: In class PackagesMakefileGenerator
     266        constructor, reset function handle added member m_ISINCLUDED, in build
     267        function make use of class Project fill_exclusion function and added
     268        member to ensure packages from special CMTHOME, CMTUSERCONTEXT projects
     269        are only visited, if in current project
     270        * source/cmt_syntax.cxx: In class KwdBuildStrategy, KwdSetupStrategy,
     271        KwdStructureStrategy action functions use class Use get_project function
     272        for optimisation
     273        * source/cmt_commands.cxx: In class ArgParser option_disable_warnings,
     274        option_quiet, option_warnings functions, do not set CmtMessage level, add
     275        option value to CMTFLAGS, in option_use, option_pack, option_version,
     276        option_path functions only record option value, in option_tag,
     277        option_tag_add, option_tag_remove functions, only record option values, in
     278        option_with_version_directory, option_without_version_directory functions
     279        do not change strategy, add option value to CMTFLAGS, in class CommandHelp
     280        show_all function, add message for -home, -user_context options
     281        * source/cmt_pattern.cxx: In class Pattern expand function, use class Use
     282        get_project function for optimisation
     283        * source/cmt_parser.cxx: In class CmtContext constructor, process
     284        CMTEXTRATAGS environment variable value, in clear function, reset all
     285        members, in class Cmt configure function, attempt to locate current use
     286        or package if at least name is available from command line options before
     287        configure_current_package for optimisation, in configure_current_cmtpath
     288        function make use of class Use get_cmtpath_and_offset function,
     289        return from configure_current_package if current use is located, in
     290        configure_current_structuring_style function, do not parse command line
     291        arguments, make use of value from command line or parse CMTFLAGS to set
     292        strategy accordingly, in configure_home, configure_user_context functions,
     293        use value from command line if any, in restore_all_tags function, add tags
     294        from CmtContext m_extra_tags, m_tags, m_tags_add vectors, in
     295        configure_cmt_message function do not parse command line arguments, parse
     296        CMTFLAGS, in do_broadcast function, set error if depth option value cannot
     297        be parsed or is out of range (< -1), make use of class Project
     298        fill_selection, fill_exclusion functions to implement enhanced handling of
     299        special CMTHOME, CMTUSERCONTEXT projects packages (visited if in current
     300        project only) and and special depth values (0: CMTUSERCONTEXT project
     301        packages only, -1: CMTHOME project packages only), in
     302        do_check_configuration function, check tags from CmtContext m_extra_tags,
     303        m_tags, m_tags_add vectors, in do_show_clients function do not re-run
     304        configure, in guess_current_project function, do not use CmtSystem cd or
     305        pwd functions for optimisation, in parse_arguments function do not call
     306        restore_all_tags function, in parser function call parse_arguments first
     307        and then configure, restore_all_tags to make configuration process cleaner,
     308        do not call configure for action_build_temporary_name, in print function do
     309        not check tags or change m_extra_tags since that change affects nothing, in
     310        use_current_package, use_extra_file functions do not attempt to locate
     311        current package if current use located already, factor out
     312        Pattern::apply_all_globalsize and Tag::restore_tree calls into separate
     313        apply_globals function called after all requirements are read, in
     314        use_special_requirements function set special use style, structuring_style,
     315        project members if located, otherwise discard, in particular, that means
     316        that requirements file in special CMTHOME, CMTUSERCONTEXT projects is not
     317        mandatory
     318        * source/cmt_symbol.cxx: In class Symbol action function, make
     319        constituentsclean symbol private (like constituents)
     320        * source/cmt.h: In class CmtContext, add string vector members
     321        m_extra_tags, m_tags, m_tags_add, m_tags_remove instead of string
     322        m_extra_tags, in class Cmt, function reach_current_package renamed
     323        use_current_package, introduce apply_globals function
     324        * mgr/fragments/nmake/package: Ensure that not included packages are
     325        not visited
     326        * mgr/fragments/package: idem
     327        * src/Makefile.header: Update help messages for BCAST mode in presence of
     328        special CMTHOME, CMTUSERCONTEXT packages/projects
     329
     3302013-10-04    <rybkin@lal.in2p3.fr> 510
     331
     332        * mgr/cmt-make-time-sub-mem-io.awk: Add script to profile CMT commands
     333        utilisation in the Makefiles
     334
     3352013-07-31    <rybkin@lal.in2p3.fr> 509
     336
     337        * mgr/cmt_svn_checkout.py: Add support for devbranches directory -
     338        additional branches location - in Subversion repository.
     339
     3402013-07-10    <rybkin@lal.in2p3.fr> 508
     341
     342        * source/cmt_commands.cxx: In class ArgParser function option_use, make
     343        -use=<package>:<version>:<path> option fully functional with standard use
     344        statement syntax, in function option_path, make -path=<path> option
     345        functional for relative <path> as with standard use statement syntax
     346        * source/cmt_parser.cxx: In class Cmt functions reach_current_package,
     347        use_extra_file make diagnostic message more informative
     348
     3492013-07-09    <rybkin@lal.in2p3.fr> 507
     350
     351        * mgr/cmt_svn_checkout.py: Use a different algorithm in the class Checkout
     352        function trunk_tag in order to optimise the performance, suggested by
     353        Wim Lavrijsen. Add --debug command line option and SVNDEBUG environment
     354        variable to facilitate debugging
     355
     3562013-06-25    <rybkin@lal.in2p3.fr> 506
     357
     358        * mgr/fragments/application: Test use_stamps variable for a non-empty value
     359        since POSIX requires a non-null list of targets in rules
     360
    13612013-06-24    <rybkin@lal.in2p3.fr> 505
    2362
  • CMT/v1r25-branch/mgr/CMT.dtd

    r550 r664  
    1 <!ENTITY  % cmtns   "xmlns CDATA #FIXED 'http://www.cmtsite.org/cmt'">
     1<!ENTITY  % cmtns   "xmlns CDATA #FIXED 'http://www.cmtsite.net/cmt'">
    22<!ATTLIST setup     %cmtns;>
    33<!ATTLIST projects  %cmtns;>
  • CMT/v1r25-branch/mgr/cmt_dcc_version.sh

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/cmt_svn_checkout.py

    r605 r664  
    1515      --with_version_directory create version directory upon PATH checkout (default)
    1616      --url=URL                checkout PATH from repository URL
     17      --debug                  print lots of debugging information
    1718  -h, --help                   display this help and exit
    1819      --version                output version information and exit
    1920
    20 The SVNROOT, SVNTRUNK, SVNTAGS, and SVNBRANCHES environment variables specify repository URL of PATH, location of PATH trunk, tags, and branches (relatively to PATH) respectively.
     21The SVNROOT, SVNTRUNK, SVNTAGS, and SVNBRANCHES (also SVNDEVBRANCHES) environment variables specify repository URL of PATH, location of PATH trunk, tags, and branches (also devbranches) (relatively to PATH) respectively.
    2122
    2223Report bugs to <CMT-L@IN2P3.FR>.
    2324"""
    2425
    25 __version__ = '0.6.0'
    26 __date__ = 'Fri Mar 09 2012'
     26__version__ = '0.8.0'
     27__date__ = 'Wed Jul 31 2013'
    2728__author__ = 'Grigory Rybkin'
    2829
     
    4041import tempfile
    4142import re
     43
     44import logging
    4245
    4346self = 'cmt_svn_checkout.py'
     
    298301                 tags = None,
    299302                 branches = None,
     303                 devbranches = None,
    300304                 version = None,
    301305                 version_dir = None,
     
    307311        self.tags = tags
    308312        self.branches = branches
     313        self.devbranches = devbranches
    309314        self.version = version
    310315        self.version_dir = version_dir
     
    327332        if self.branches is None:
    328333            self.branches = os.getenv('SVNBRANCHES', 'branches')
     334        if self.devbranches is None:
     335            self.devbranches = os.getenv('SVNDEVBRANCHES', 'devbranches')
    329336
    330337    def cmtRepos(self):
     
    333340        self.tags= '.'
    334341        self.branches = '.'
     342        self.devbranches = '.'
    335343
    336344    def add(self, module):
     
    378386        """Attempt to determine the tag of the module's trunk.
    379387       
    380         Return the tag if its contents are the same as those of the trunk, and
    381         its last_changed_rev is greater than the trunk created_rev, None otherwise.
     388        Return the tag if its files are copied from the trunk and
     389        their last_changed_rev numbers are the same as those of the trunk files.
    382390        """
    383391        trunk = posixpath.join(module.url, self.trunk)
    384392#        trunk = posixpath.normpath(posixpath.join(module.url, self.trunk))
     393        cmd = 'svn ls -vR %s' % trunk
     394        sc, out = Utils.getstatusoutput(cmd)
     395        logger.debug('%s\n%s' % (cmd, out))
     396        if sc != 0:
     397            return None
     398        trunk_dirent = [line.split() for line in out.splitlines()]
     399        trunk_revs = dict([(line[-1], int(line[0])) for line in trunk_dirent if not line[-1].endswith(posixpath.sep)])
     400        logger.debug('%s' % trunk_revs)
     401
     402        curdir = posixpath.curdir + posixpath.sep
     403        for line in trunk_dirent:
     404            if line[-1] == curdir:
     405                class info(object): pass
     406                info.last_changed_rev = int(line[0])
     407                self.info_receiver(trunk, info, module)
     408                logger.debug('last_changed_rev: %d' % info.last_changed_rev)
     409                break
     410
     411#        cmd = 'svn info %s' % trunk
     412#         p = r'last\s+changed\s+rev:\s+(?P<rev>\d+)'
     413#         m = re.search(p, out, re.I)
     414#         if m:
     415#             class info(object): pass
     416#             info.last_changed_rev = int(m.group('rev'))
     417#             self.info_receiver(trunk, info, module)
     418# #            self.info_receiver(trunk, info, None)
     419# #             print >>sys.stderr, '%s: last_changed_rev %i' % \
     420# #                   (trunk, self.info.last_changed_rev)
     421# #            last_changed_rev = int(m.group('rev'))
     422#         else:
     423#             return None
     424
     425        tags = posixpath.join(module.url, self.tags)
     426#        tags = posixpath.normpath(posixpath.join(module.url, self.tags))
     427        cmd = 'svn ls -vR %s' % tags
     428#        cmd = 'svn ls -v %s' % tags
     429        sc, out = Utils.getstatusoutput(cmd)
     430        logger.debug('%s\n%s' % (cmd, out))
     431        if sc != 0:
     432            return None
     433        tags_dirent = [line.split() for line in out.splitlines()]
     434        tags_revs = dict()
     435        for ent in tags_dirent:
     436            try:
     437                tag, path = ent[-1].split(posixpath.sep, 1)
     438            except ValueError:
     439                continue
     440            if tag not in tags_revs:
     441                tags_revs[tag] = dict()
     442            if path and not path.endswith(posixpath.sep):
     443                # assume there are no empty directories in the tag
     444                tags_revs[tag][path] = int(ent[0])
     445        logger.debug('%s' % tags_revs)
     446
    385447        cmd = 'svn info %s' % trunk
    386448        sc, out = Utils.getstatusoutput(cmd)
     449        logger.debug('%s\n%s' % (cmd, out))
    387450        if sc != 0:
    388451            return None
    389         p = r'last\s+changed\s+rev:\s+(?P<rev>\d+)'
     452        p = r'repository\s+root:\s+(?P<root>%s://\S+)' % \
     453            ('(?:' + '|'.join(map(re.escape, client_context.schemes)) + ')')
    390454        m = re.search(p, out, re.I)
     455        logger.debug('pattern: %r' % (p))
    391456        if m:
    392             class info(object): pass
    393             info.last_changed_rev = int(m.group('rev'))
    394             self.info_receiver(trunk, info, module)
    395 #            self.info_receiver(trunk, info, None)
    396 #             print >>sys.stderr, '%s: last_changed_rev %i' % \
    397 #                   (trunk, self.info.last_changed_rev)
    398 #            last_changed_rev = int(m.group('rev'))
     457            root = m.group('root')
    399458        else:
    400459            return None
    401 
    402         tags = posixpath.join(module.url, self.tags)
    403 #        tags = posixpath.normpath(posixpath.join(module.url, self.tags))
    404         cmd = 'svn ls -v %s' % tags
     460        logger.debug('root: %s' % root)
     461        trunk_path = trunk[len(root):]
     462        tags_path = tags[len(root):]
     463        logger.debug('trunk_path: %s' % trunk_path)
     464        logger.debug('tags_path: %s' % tags_path)
     465        offset = len(trunk) - len(root) + len(posixpath.sep)
     466       
     467        # Usually, a tag is created as a server-side copy.
     468        # Sometimes, a tag is created as a copy of WC (working copy)
     469        # after commit.
     470        # Below, we try to take into account the latter case.
     471        cmd = 'svn log -v -q %s' % tags
    405472        sc, out = Utils.getstatusoutput(cmd)
     473        logger.debug('%s\n%s' % (cmd, out))
    406474        if sc != 0:
    407475            return None
    408 
    409         tags_dirent = [line.split() for line in out.splitlines()]
    410         rev_tag = dict([(int(line[0]), line[-1].rstrip(posixpath.sep)) for line in tags_dirent if line[-1].endswith(posixpath.sep)])
    411         revs = rev_tag.keys()
    412         revs.sort()
    413         revs.reverse()
    414 
    415         for rev in revs:
    416             if rev < self.info.last_changed_rev: break
    417 #            if rev < last_changed_rev: break
    418             tag = posixpath.join(tags, rev_tag[rev])
    419 #            tag = posixpath.normpath(posixpath.join(tags, rev_tag[rev]))
    420             if 0 == self.cmp(trunk, tag, client_context):
    421                 return rev_tag[rev]
     476        p = re.compile(
     477            r'^-{5,}$\s^r\d+.+$\s^Changed paths:$\s^\s+A\s+%s%s(?P<tag>[^%s]+)\s+\(from %s:\d+\)$(?P<replaced>(?:\s^\s+(?:R|A|D)\s+%s%s(?P=tag)%s(?P<path>.+)(?:\s+\(from %s%s(?P=path):\d+\))?$)*)' % (re.escape(tags_path), posixpath.sep, posixpath.sep, re.escape(trunk_path), re.escape(tags_path), posixpath.sep, posixpath.sep, re.escape(trunk_path), posixpath.sep)
     478            , re.M
     479            )
     480        tags_copied = list()
     481        tags_replaced_revs = dict()
     482        for m in p.finditer(out):
     483            logger.debug('tag: %s replaced: %r' % (m.group('tag'), m.group('replaced')))
     484            tags_copied.append(m.group('tag'))
     485            for line in m.group('replaced').strip().splitlines():
     486                l = line.split()
     487                if len(l) == 2: continue # action code D - deleted paths
     488                repl = l[3].rstrip(')')
     489                i = repl.rindex(':')
     490                path = repl[offset:i]
     491                rev = int(repl[i + 1:])
     492                logger.debug('path: %s rev: %d' % (path, rev))
     493
     494                if m.group('tag') not in tags_replaced_revs:
     495                    tags_replaced_revs[m.group('tag')] = dict()
     496                if path and not path.endswith(posixpath.sep):
     497                    # assume there are no empty directories in the tag
     498                    tags_replaced_revs[m.group('tag')][path] = rev
     499
     500        logger.debug('copied: %s' % tags_copied)
     501        logger.debug('replaced: %s' % tags_replaced_revs)
     502
     503        for t in tags_revs.keys():
     504            if t not in tags_copied:
     505                del tags_revs[t]
     506                logger.debug('%s: Not a trunk copy' % t)
     507
     508        for t in tags_replaced_revs:
     509            if t in tags_revs:
     510                tags_revs[t].update(tags_replaced_revs[t])
     511               
     512        for tag in tags_revs:
     513            logger.debug('Compare: %s -> %s' % (tag, tags_revs[tag]))
     514            if trunk_revs == tags_revs[tag]:
     515                return tag
    422516
    423517        return None
     518
     519#         tags_dirent = [line.split() for line in out.splitlines()]
     520#         rev_tag = dict([(int(line[0]), line[-1].rstrip(posixpath.sep)) for line in tags_dirent if line[-1].endswith(posixpath.sep)])
     521#         revs = rev_tag.keys()
     522#         revs.sort()
     523#         revs.reverse()
     524
     525#         for rev in revs:
     526#             logger.debug('rev: %s' % rev)
     527#             if rev < self.info.last_changed_rev: break
     528# #            if rev < last_changed_rev: break
     529#             tag = posixpath.join(tags, rev_tag[rev])
     530# #            tag = posixpath.normpath(posixpath.join(tags, rev_tag[rev]))
     531#             logger.debug('comparing: %s %s(%d)' % (trunk, tag, rev))
     532#             if 0 == self.cmp(trunk, tag, client_context):
     533#                 return rev_tag[rev]
     534
     535#         return None
    424536
    425537#         try:
     
    496608            else:
    497609                m.URL = [posixpath.join(m.url, p, m.version)
    498                          for p in (self.tags, self.branches)]
     610                         for p in (self.tags, self.branches, self.devbranches)]
    499611            m.URL = [client_context.svn_path_canonicalize(url) for url in m.URL]
    500612#            m.URL = [core.svn_path_canonicalize(url) for url in m.URL]
     
    572684                                    "offset=", "no_config",
    573685                                    "with_version_directory",
    574                                     "without_version_directory", "url="])
     686                                    "without_version_directory", "url=", "debug"])
    575687    except getopt.error, e:
    576688        print >>sys.stderr, '%s: %s' % (self, str(e))
    577689        print >>sys.stderr, "Try '%s --help' for more information." % self
    578690        return 1
     691
     692    global logger
     693    logging.basicConfig()
     694    logger = logging.getLogger(self)
     695    logger.setLevel(logging.INFO)
     696    if os.getenv('SVNDEBUG'):
     697        logger.setLevel(logging.DEBUG)
    579698
    580699    cmt_context = CmtContext()
     
    605724        elif o in ("--url",):
    606725            checkout.url = v
     726        elif o in ("--debug",):
     727            logger.setLevel(logging.DEBUG)
    607728
    608729    if not args:
  • CMT/v1r25-branch/mgr/fragments/application

    r646 r664  
    55        $(link_silent) ${LINKMACRO} -o $(@).new ${OBJS} $(cmt_installarea_linkopts) $(${CONSTITUENT}_use_linkopts) $(${CONSTITUENT}linkopts) && mv -f $(@).new $(@)
    66
    7 ifdef use_stamps
     7ifneq ($(strip $(use_stamps)),)
    88# Work around Make errors if stamps files do not exist
    99$(use_stamps) :
  • CMT/v1r25-branch/mgr/fragments/constituent

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/constituent_lock

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/jar

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/java

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/check_application

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/constituent

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/constituent_lock

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/jar

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/java

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/library

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/library_no_static

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • CMT/v1r25-branch/mgr/fragments/nmake/package

    r600 r664  
    11
     2cmt_${PACKAGE}_${ISINCLUDED} = 1
    23cmt_${PACKAGE}_${ISLOCAL} = 1
    34
     
    67
    78!if "$(LOG_LOCATION)" != ""
     9!if "$(cmt_${PACKAGE}_is_included)" != ""
    810!if "$(cmt_${PACKAGE}_is_local)" != ""
    911${PACKAGE}OutErr = >>$(LOG_LOCATION)\$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     
    1113!if "$(BCAST_GLOBAL)" != ""
    1214${PACKAGE}OutErr = >>$(LOG_LOCATION)\$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     15!endif
    1316!endif
    1417!endif
     
    2023${PACKAGE} : $(${PACKAGE}MgrPath)\NMake
    2124!endif
     25!if "$(cmt_${PACKAGE}_is_included)" != ""
    2226!if "$(cmt_${PACKAGE}_is_local)" != ""
    2327        @echo "#--------------------------------------------------------------" \
     
    7377!endif
    7478!endif
     79!else
     80       
     81!endif
    7582
    7683$(${PACKAGE}MgrPath)\NMake :
     84!if "$(cmt_${PACKAGE}_is_included)" != ""
    7785!if "$(cmt_${PACKAGE}_is_local)" != ""
    7886        $(echo) configuring ${PACKAGE}
     
    8593       
    8694!endif
     95!endif
     96!else
     97       
    8798!endif
    8899
     
    96107
    97108${PACKAGE}clean : $(${PACKAGE}MgrPath)\NMake
     109!if "$(cmt_${PACKAGE}_is_included)" != ""
    98110!if "$(cmt_${PACKAGE}_is_local)" != ""
    99111        @echo "#--------------------------------------------------------------" \
     
    125137!endif
    126138!endif
     139!else
     140       
     141!endif
    127142
    128143${PACKAGE}binclean : $(${PACKAGE}MgrPath)\NMake
     144!if "$(cmt_${PACKAGE}_is_included)" != ""
    129145!if "$(cmt_${PACKAGE}_is_local)" != ""
    130146        @echo "#--------------------------------------------------------------" \
     
    156172!endif
    157173!endif
     174!else
     175       
     176!endif
    158177
    159178${PACKAGE}uninstall : $(${PACKAGE}MgrPath)\NMake
     179!if "$(cmt_${PACKAGE}_is_included)" != ""
    160180!if "$(cmt_${PACKAGE}_is_local)" != ""
    161181        @echo "#--------------------------------------------------------------" \
     
    187207!endif
    188208!endif
     209!else
     210       
     211!endif
    189212
    190213${PACKAGE}check : $(${PACKAGE}MgrPath)\NMake
     214!if "$(cmt_${PACKAGE}_is_included)" != ""
    191215!if "$(cmt_${PACKAGE}_is_local)" != ""
    192216        @echo "#--------------------------------------------------------------" \
     
    218242!endif
    219243!endif
     244!else
     245       
     246!endif
    220247
    221248${PACKAGE} ${PACKAGE}clean ${PACKAGE}binclean ${PACKAGE}uninstall ${PACKAGE}check : FORCE
  • CMT/v1r25-branch/mgr/fragments/nmake/packages_header

    r600 r664  
    2727#    ignore: try all the groups even if one fails before going to the next package
    2828#            (may result in duplicated errors within a package)
    29 # Unix version taken from https://svnweb.cern.ch/trac/gaudi/browser/Gaudi/trunk/Makefile.cmt (Modified)
     29# Unix version taken from https://svnweb.cern.ch/trac/gaudi/browser/Gaudi/trunk/Makefile.cmt (Modified by Grigory Rybkin)
    3030Package_failure_handler = || exit
    3131!if "$(PACKAGE_FAILURE_POLICY)" != ""
  • CMT/v1r25-branch/mgr/fragments/package

    r600 r664  
    11
     2cmt_${PACKAGE}_${ISINCLUDED} = 1
    23cmt_${PACKAGE}_${ISLOCAL} = 1
    34
     
    67
    78ifdef LOG_LOCATION
     9ifdef cmt_${PACKAGE}_is_included
    810ifdef cmt_${PACKAGE}_is_local
    911${PACKAGE}OutErr = >>$(LOG_LOCATION)/$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     
    1113ifdef BCAST_GLOBAL
    1214${PACKAGE}OutErr = >>$(LOG_LOCATION)/$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     15endif
    1316endif
    1417endif
     
    2023${PACKAGE} : $(${PACKAGE}MgrPath)/Makefile
    2124endif
     25ifdef cmt_${PACKAGE}_is_included
    2226ifdef cmt_${PACKAGE}_is_local
    2327        @echo "#--------------------------------------------------------------" \
     
    6771endif
    6872endif
     73else
     74       
     75endif
    6976
    7077$(${PACKAGE}MgrPath)/Makefile :
     78ifdef cmt_${PACKAGE}_is_included
    7179ifdef cmt_${PACKAGE}_is_local
    7280        $(echo) configuring ${PACKAGE}
     
    8088endif
    8189endif
     90else
     91       
     92endif
    8293
    8394ifndef BCAST_ONLY
     
    90101
    91102${PACKAGE}clean ${PACKAGE}binclean ${PACKAGE}uninstall ${PACKAGE}check : $(${PACKAGE}MgrPath)/Makefile
     103ifdef cmt_${PACKAGE}_is_included
    92104ifdef cmt_${PACKAGE}_is_local
    93105        @echo "#--------------------------------------------------------------" \
     
    119131endif
    120132endif
     133else
     134       
     135endif
    121136
    122137${PACKAGE} ${PACKAGE}clean ${PACKAGE}binclean ${PACKAGE}uninstall ${PACKAGE}check : FORCE
  • CMT/v1r25-branch/mgr/fragments/packages_header

    r600 r664  
    4242#    ignore: try all the groups even if one fails before going to the next package
    4343#            (may result in duplicated errors within a package)
    44 # Taken from https://svnweb.cern.ch/trac/gaudi/browser/Gaudi/trunk/Makefile.cmt (Modified)
     44# Taken from https://svnweb.cern.ch/trac/gaudi/browser/Gaudi/trunk/Makefile.cmt (Modified by Grigory Rybkin)
    4545Package_failure_handler = || exit
    4646ifdef PACKAGE_FAILURE_POLICY
  • CMT/v1r25-branch/mgr/requirements

    r618 r664  
    66tag CMTr16 CMTr14
    77tag CMTr18 CMTr16
    8 tag CMTr0  CMTr18
    9 
     8tag CMTr0  CMTr25
     9
     10tag CMTv0  CMTv1
    1011#
    1112#  Automatic detection of some system features.
     
    125126             WIN32     "CMT\v"
    126127
    127 path_prepend PATH      "${CMTROOT}/${CMTBIN}" \
     128path_append PATH      "${CMTROOT}/${CMTBIN}" \
    128129             WIN32     "%CMTROOT%\%CMTBIN%"
    129130
  • CMT/v1r25-branch/source/cmt.cxx

    r527 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt.h

    r612 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    2425
    2526  void clear ();
     27  int initialize ();
    2628
    2729  ActionType m_action;
     
    3436  cmt_string m_cmt_version;
    3537  bool m_use_cmt;
     38  bool m_use_projects;
    3639 
    3740  cmt_string m_current_dir;
     
    5255  cmt_string m_current_version;
    5356 
    54   cmt_string m_extra_tags;
     57  //  cmt_string m_extra_tags;
     58  CmtSystem::cmt_string_vector m_extra_tags;
     59  CmtSystem::cmt_string_vector m_tags;
     60  CmtSystem::cmt_string_vector m_tags_add;
     61  CmtSystem::cmt_string_vector m_tags_remove;
     62
    5563  cmt_string m_configure_error;
    5664 
     
    6876
    6977  bool m_autoconfigure_cmtpath;
     78
     79  bool m_env_access;
     80  PrintMode m_print_mode;
     81  bool m_strip_path;
     82
     83private:
     84
     85  CmtContext& operator = (const CmtContext& other);
     86  CmtContext (const CmtContext& other);
    7087};
    7188
     
    7996  static void build_vsnet_file (const cmt_string& target);
    8097
    81   static bool build_nmake ();
     98  static inline bool build_nmake ();
    8299  static void build_OS9_makefile (const cmt_string& target);
    83100  static void build_prefix (const cmt_string& package, cmt_string& prefix);
     
    90107  static void configure_current_cmtpath ();
    91108  static void configure_current_dir ();
    92   static void configure_current_package ();
     109  static cmt_string configure_current_package ();
     110  //  static void configure_current_package ();
    93111  //  static void configure_current_structuring_style ();
    94112  static void configure_current_structuring_style (const ArgParser& ap);
     
    212230  static const cmt_string& filter_dir (const cmt_string& dir);
    213231
    214   static ActionType get_action ();
    215 
    216   static const cmt_string& get_cmt_home ();
    217   static const cmt_string& get_cmt_user_context ();
    218   static const cmt_string& get_cmt_version ();
    219   static const cmt_string& get_current_dir ();
     232  static inline ActionType get_action ();
     233
     234  static inline const cmt_string& get_cmt_home ();
     235  static inline const cmt_string& get_cmt_user_context ();
     236  static inline const cmt_string& get_cmt_version ();
     237  static inline const cmt_string& get_current_dir ();
    220238  static const cmt_string get_current_dir_real ();
    221   static const cmt_string& get_current_package ();
     239  static inline const cmt_string& get_current_package ();
    222240  static const cmt_string& get_current_path ();
    223241  static const cmt_string& get_current_cmtpath ();
    224242  static const cmt_string& get_current_offset ();
    225   static AccessMode get_current_access ();
    226   static CmtStructuringStyle get_current_structuring_style ();
    227   static CmtDirStyle get_current_style ();
     243  static inline AccessMode get_current_access ();
     244  static inline CmtStructuringStyle get_current_structuring_style ();
     245  static inline CmtDirStyle get_current_style ();
    228246  static const cmt_string& get_current_version ();
    229   static const cmt_string& get_current_target ();
    230   static bool get_debug ();
    231   static bool get_disable_warnings (); 
    232   static bool get_quiet ();
    233   static bool get_warnings ();
    234   static bool get_recursive ();
     247  static inline const cmt_string& get_current_target ();
     248  static inline const CmtSystem::cmt_string_vector& get_tags_remove ();
     249  static inline bool get_debug ();
     250  static inline bool get_disable_warnings (); 
     251  static inline bool get_quiet ();
     252  static inline bool get_warnings ();
     253  static inline bool get_recursive ();
    235254  static CmtScopeFilteringMode get_scope_filtering_mode ();
    236   static bool get_all_sets_done ();
     255  static inline bool get_all_sets_done ();
    237256
    238257  static void get_cmt_flags (CmtSystem::cmt_string_vector& flags);
     
    259278  static int parser (const cmt_string& command_line);
    260279  static int parser (int argc, char* argv[]);
    261   static void print (PrintMode mode);
     280  static void print (PrintMode mode, ostream& out = cout);
     281  //static void print (PrintMode mode);
    262282  static void print_clean (PrintMode mode);
    263   static void print_context (Use& use, PrintMode mode, const cmt_string& tag);
     283  static void print_context (Use& use, PrintMode mode, const cmt_string& tag, ostream& out = cout);
     284  //static void print_context (Use& use, PrintMode mode, const cmt_string& tag);
    264285  static void print_macros (PrintMode mode, const cmt_string& pattern = "",
    265286                            ostream& out = cout);
     
    268289  static void print_tabs (int tabs);
    269290  static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout);
    270   static int reach_current_package ();
     291  //  static int reach_current_package ();
     292  static int use_current_package ();
    271293  static int use_extra_file (const cmt_string& file);
     294  static int apply_globals ();
    272295  static void restore_all_tags (Use* use);
    273   static void set_current_access (AccessMode mode);
    274   static void set_recursive (bool mode);
    275   static void set_scope_filtering_mode (CmtScopeFilteringMode mode);
     296  static inline void set_current_access (AccessMode mode);
     297  static inline void set_recursive (bool mode);
     298  static inline void set_scope_filtering_mode (CmtScopeFilteringMode mode);
    276299  static void set_standard_macros ();
    277   static void set_all_sets_done ();
    278   static void reset_all_sets_done ();
     300  static inline void set_all_sets_done ();
     301  static inline void reset_all_sets_done ();
    279302  static void use_cmt ();
    280303  static void use_home_requirements ();
     
    287310                                const cmt_string& separator,
    288311                                cmt_string& result);
     312
     313  static inline const bool& get_env_access ();
     314  static inline void set_env_access (const bool& access);
     315  static inline const PrintMode& get_print_mode ();
     316  static inline void set_print_mode (const PrintMode& mode);
     317  static inline const bool& get_strip_path ();
     318
     319private:
     320  static CmtContext& m_cmt_context;
     321  //  static CmtContext * m_cmt_context;
    289322};
    290323
     324//----------------------------------------------------------
     325inline bool Cmt::build_nmake ()
     326{
     327  return (m_cmt_context.m_build_nmake);
     328}
     329
     330inline ActionType Cmt::get_action ()
     331{
     332  return (m_cmt_context.m_action);
     333}
     334
     335inline const cmt_string& Cmt::get_cmt_home ()
     336{
     337  return (m_cmt_context.m_cmt_home);
     338}
     339
     340inline const cmt_string& Cmt::get_cmt_user_context ()
     341{
     342  return (m_cmt_context.m_cmt_user_context);
     343}
     344
     345inline const cmt_string& Cmt::get_cmt_version ()
     346{
     347  return (m_cmt_context.m_cmt_version);
     348}
     349
     350inline const cmt_string& Cmt::get_current_dir ()
     351{
     352  return (m_cmt_context.m_current_dir);
     353}
     354
     355inline const cmt_string& Cmt::get_current_package ()
     356{
     357  return (m_cmt_context.m_current_package);
     358}
     359
     360inline AccessMode Cmt::get_current_access ()
     361{
     362  return (m_cmt_context.m_current_access);
     363}
     364
     365inline CmtStructuringStyle Cmt::get_current_structuring_style ()
     366{
     367  return (m_cmt_context.m_current_structuring_style);
     368}
     369
     370inline CmtDirStyle Cmt::get_current_style ()
     371{
     372  return (m_cmt_context.m_current_style);
     373}
     374
     375inline const cmt_string& Cmt::get_current_target ()
     376{
     377  return (m_cmt_context.m_current_target);
     378}
     379
     380inline const CmtSystem::cmt_string_vector& Cmt::get_tags_remove ()
     381{
     382  return m_cmt_context.m_tags_remove;
     383}
     384
     385inline bool Cmt::get_debug ()
     386{
     387  return (m_cmt_context.m_debug);
     388}
     389
     390inline bool Cmt::get_quiet ()
     391{
     392  return (m_cmt_context.m_quiet);
     393}
     394
     395inline bool Cmt::get_disable_warnings ()
     396{
     397  return (m_cmt_context.m_disable_warnings);
     398}
     399
     400inline bool Cmt::get_warnings ()
     401{
     402  return (m_cmt_context.m_warnings);
     403}
     404
     405inline bool Cmt::get_recursive ()
     406{
     407  return (m_cmt_context.m_recursive);
     408}
     409
     410inline bool Cmt::get_all_sets_done ()
     411{
     412  return (m_cmt_context.m_all_sets_done);
     413}
     414
     415inline void Cmt::set_current_access (AccessMode mode)
     416{
     417  m_cmt_context.m_current_access = mode;
     418}
     419
     420//----------------------------------------------------------
     421inline void Cmt::set_recursive (bool mode)
     422{
     423  m_cmt_context.m_recursive = mode;
     424}
     425
     426//----------------------------------------------------------
     427inline void Cmt::set_scope_filtering_mode (CmtScopeFilteringMode mode)
     428{
     429  m_cmt_context.m_scope_filtering_mode = mode;
     430}
     431
     432inline void Cmt::set_all_sets_done ()
     433{
     434  m_cmt_context.m_all_sets_done = true;
     435}
     436
     437inline void Cmt::reset_all_sets_done ()
     438{
     439  m_cmt_context.m_all_sets_done = false;
     440}
     441
     442inline const bool& Cmt::get_env_access ()
     443{
     444  return m_cmt_context.m_env_access;
     445}
     446
     447inline void Cmt::set_env_access (const bool& access)
     448{
     449  m_cmt_context.m_env_access = access;
     450}
     451
     452inline const PrintMode& Cmt::get_print_mode ()
     453{
     454  return m_cmt_context.m_print_mode;
     455}
     456
     457inline void Cmt::set_print_mode (const PrintMode& mode)
     458{
     459  m_cmt_context.m_print_mode = mode;
     460}
     461
     462inline const bool& Cmt::get_strip_path ()
     463{
     464  return m_cmt_context.m_strip_path;
     465}
     466//----------------------------------------------------------
     467
    291468#endif
  • CMT/v1r25-branch/source/cmt_awk.cxx

    r607 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_cmtpath_pattern.cxx

    r588 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_cmtpath_pattern.h

    r588 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_commands.cxx

    r612 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    256257  pv.push_back (&ArgParser::option_no_cleanup); i++;
    257258
     259  parsers.add ("-no_strip_p", i);
     260  parsers.add ("-no_strip_pa", i);
     261  parsers.add ("-no_strip_pat", i);
     262  parsers.add ("-no_strip_path", i);
     263  pv.push_back (&ArgParser::option_no_strip_path); i++;
     264
    258265  parsers.add ("-pac", i);
    259266  parsers.add ("-pack", i);
     
    263270  parsers.add ("-path", i);
    264271  pv.push_back (&ArgParser::option_path); i++;
     272
     273  parsers.add ("-strip_p", i);
     274  parsers.add ("-strip_pa", i);
     275  parsers.add ("-strip_pat", i);
     276  parsers.add ("-strip_path", i);
     277  pv.push_back (&ArgParser::option_strip_path); i++;
    265278
    266279  parsers.add ("-pr", i);
     
    346359  parsers.add ("-without_cmt", i);
    347360  pv.push_back (&ArgParser::option_without_cmt); i++;
     361
     362  parsers.add ("-with_p", i);
     363  parsers.add ("-with_pr", i);
     364  parsers.add ("-with_pro", i);
     365  parsers.add ("-with_proj", i);
     366  parsers.add ("-with_proje", i);
     367  parsers.add ("-with_projec", i);
     368  parsers.add ("-with_project", i);
     369  parsers.add ("-with_projects", i);
     370  pv.push_back (&ArgParser::option_with_projects); i++;
     371
     372  parsers.add ("-without_p", i);
     373  parsers.add ("-without_pr", i);
     374  parsers.add ("-without_pro", i);
     375  parsers.add ("-without_proj", i);
     376  parsers.add ("-without_proje", i);
     377  parsers.add ("-without_projec", i);
     378  parsers.add ("-without_project", i);
     379  parsers.add ("-without_projects", i);
     380  pv.push_back (&ArgParser::option_without_projects); i++;
    348381
    349382  parsers.add ("-warn", i);
     
    19031936{
    19041937  cmt.m_disable_warnings = true;
    1905   if (CmtMessage::level () <= Warning)
    1906     CmtMessage::set_level (Error);
     1938//   if (CmtMessage::level () <= Warning)
     1939//     CmtMessage::set_level (Error);
     1940  if (!Cmt::add_cmt_flag ("-disable_warnings"))
     1941    CmtError::set (CmtError::system_error, "Cannot add flag `-disable_warnings'");
    19071942}
    19081943
     
    19101945{
    19111946  cmt.m_quiet = true;
    1912   if (CmtMessage::level () <= Error)
    1913     CmtMessage::set_level (Fatal);
     1947//   if (CmtMessage::level () <= Error)
     1948//     CmtMessage::set_level (Fatal);
     1949  if (!Cmt::add_cmt_flag ("-quiet"))
     1950    CmtError::set (CmtError::system_error, "Cannot add flag `-quiet'");
    19141951}
    19151952
     
    19181955{
    19191956  cmt.m_warnings = true;
    1920   if (CmtMessage::level () != Warning)
    1921     CmtMessage::set_level (Warning);
     1957//   if (CmtMessage::level () != Warning)
     1958//     CmtMessage::set_level (Warning);
     1959  if (!Cmt::add_cmt_flag ("-warnings"))
     1960    CmtError::set (CmtError::system_error, "Cannot add flag `-warnings'");
    19221961}
    19231962
     
    19521991    {
    19531992      CmtSystem::cmt_string_vector words;
    1954 
    19551993      CmtSystem::split (arg, ":", words);
    19561994
    19571995      cmt.m_current_access = UserMode;
     1996
     1997      cmt.m_current_package = "";
     1998      cmt.m_current_version = "";
     1999      cmt.m_current_path = "";
    19582000
    19592001      if (words.size () > 0) cmt.m_current_package = words[0];
    19602002      if (words.size () > 1) cmt.m_current_version = words[1];
    19612003      if (words.size () > 2) cmt.m_current_path    = words[2];
    1962       (Use::current()).set (cmt.m_current_package,
    1963                             cmt.m_current_version,
    1964                             cmt.m_current_path);
    1965 
    1966       Use& use = Use::current();
    1967       if (use.get_package_name () == "cmt_standalone")
    1968         {
    1969           if (!CmtSystem::cd (use.path) || !CmtSystem::test_file ("requirements"))
    1970             {
    1971               CmtError::set (CmtError::package_not_found, use.get_info ());
    1972               return;
    1973             }
    1974           use.style = none_style;
    1975           use.structuring_style = without_version_directory;
    1976           use.change_path (CmtSystem::pwd ());
    1977         }
    1978       else if (!use.move_to ("", true))
    1979         {
    1980           CmtError::set (CmtError::package_not_found, use.get_info ());
    1981           return;
    1982         }
    1983       Project::order_all ();
    1984       Cmt::guess_current_project ();
    19852004    }
    19862005}
     
    19952014
    19962015      cmt.m_current_package = arg;
    1997       cmt.m_current_version = "";
    1998 
    1999       /*
    2000       cerr << "ArgParser::option_pack> "
    2001            << " cp=" << cmt.m_current_package
    2002            << " cv=" << cmt.m_current_version
    2003            << " cp=" << cmt.m_current_path << endl;
    2004       */
    2005 
    2006       (Use::current()).set (cmt.m_current_package,
    2007                             cmt.m_current_version,
    2008                             cmt.m_current_path);
     2016      //      cmt.m_current_version = "";
     2017
    20092018    }
    20102019}
     
    20162025      cmt.m_current_access = UserMode;
    20172026      cmt.m_current_version = arg;
    2018 
    2019       /*
    2020       cerr << "ArgParser::option_version> "
    2021            << " cp=" << cmt.m_current_package
    2022            << " cv=" << cmt.m_current_version
    2023            << " cp=" << cmt.m_current_path << endl;
    2024       */
    2025 
    2026       (Use::current()).set (cmt.m_current_package,
    2027                             cmt.m_current_version,
    2028                             cmt.m_current_path);
    20292027    }
    20302028}
     
    20362034      cmt.m_current_access = UserMode;
    20372035      cmt.m_current_path = arg;
    2038 
    2039       /*
    2040       cerr << "ArgParser::option_path> "
    2041            << " cp=" << cmt.m_current_package
    2042            << " cv=" << cmt.m_current_version
    2043            << " cp=" << cmt.m_current_path << endl;
    2044       */
    2045 
    2046       (Use::current()).set (cmt.m_current_package,
    2047                             cmt.m_current_version,
    2048                             cmt.m_current_path);
    2049 
    2050       //IProjectFactory& factory = ProjectFactory::instance ();
    2051       //CmtSystem::add_cmt_path (cmt.m_current_path, "argument", factory);
    2052       Use& use = Use::current();
    2053       if (use.get_package_name () == "cmt_standalone")
    2054         {
    2055           if (!CmtSystem::cd (use.path) || !CmtSystem::test_file ("requirements"))
    2056             {
    2057               CmtError::set (CmtError::package_not_found, use.get_info ());
    2058               return;
    2059             }
    2060           use.style = none_style;
    2061           use.structuring_style = without_version_directory;
    2062           use.change_path (CmtSystem::pwd ());
    2063         }
    2064       else if (!use.move_to ("", true))
    2065         {
    2066           CmtError::set (CmtError::package_not_found, use.get_info ());
    2067           return;
    2068         }
    2069       Project::order_all ();
    2070       Cmt::guess_current_project ();
    20712036    }
    20722037}
     
    20792044void ArgParser::option_e ()
    20802045{
    2081   //CmtMessage::warning ("extra statement = " + arg);
    20822046  extra_line = arg;
    20832047}
     
    20892053      cmt.m_cmt_home = arg;
    20902054    }
     2055}
     2056
     2057void ArgParser::option_no_strip_path ()
     2058{
     2059  cmt.m_strip_path = false;
     2060  if (!Cmt::add_cmt_flag ("-no_strip_path"))
     2061    CmtMessage::error ("Cannot add flag `-no_strip_path'");
     2062}
     2063
     2064void ArgParser::option_strip_path ()
     2065{
     2066  cmt.m_strip_path = true;
     2067  if (!Cmt::add_cmt_flag ("-strip_path"))
     2068    CmtMessage::error ("Cannot add flag `-strip_path'");
    20912069}
    20922070
     
    20982076  if (arg != "")
    20992077    {
     2078      cmt.m_tags.clear ();
     2079      CmtSystem::cmt_string_vector words;
     2080      CmtSystem::split (arg, " \t,", words);
     2081      for (int i = 0; i < words.size (); i++)
     2082        {
     2083          bool has (false);
     2084          for (int j = 0; j < cmt.m_tags.size (); j++)
     2085            {
     2086              if (cmt.m_tags[j] == words[i])
     2087                {
     2088                  has = true;
     2089                  break;
     2090                }
     2091            }
     2092          if (!has)
     2093            cmt.m_tags.push_back (words[i]);
     2094        }
     2095
     2096      if (cmt.m_tags.size () != 0)
     2097        {
     2098          cmt.m_extra_tags.clear ();
     2099          cmt.m_tags_add.clear ();
     2100          cmt.m_tags_remove.clear ();
     2101        }
     2102
     2103      /*
    21002104      Tag* tag;
    21012105      CmtSystem::cmt_string_vector words;
     
    21512155        // To be sure that a tag
    21522156        Cmt::guess_current_project ();
     2157      */
    21532158    }
    21542159}
     
    21562161void ArgParser::option_tag_add ()
    21572162{
     2163  CmtSystem::cmt_string_vector words;
     2164  CmtSystem::split (arg, " \t,", words);
     2165  for (int i = 0; i < words.size (); i++)
     2166    {
     2167      bool has (false);
     2168      for (int j = 0; j < cmt.m_tags_add.size (); j++)
     2169        {
     2170          if (cmt.m_tags_add[j] == words[i])
     2171            {
     2172              has = true;
     2173              break;
     2174            }
     2175        }
     2176      if (!has)
     2177        {
     2178          cmt.m_tags_add.push_back (words[i]);
     2179        }
     2180     
     2181      for (int j = 0; j < cmt.m_tags_remove.size (); j++)
     2182        {
     2183          if (cmt.m_tags_remove[j] == words[i])
     2184            {
     2185              cmt.m_tags_remove.erase(j);
     2186              break;
     2187            }
     2188        }
     2189    }
     2190  /*
    21582191  Tag* tag;
    21592192  CmtSystem::cmt_string_vector words;
     
    21882221        }
    21892222    }
     2223  */
    21902224}
    21912225
    21922226void ArgParser::option_tag_remove ()
    21932227{
     2228  CmtSystem::cmt_string_vector words;
     2229  CmtSystem::split (arg, " \t,", words);
     2230  for (int i = 0; i < words.size (); i++)
     2231    {
     2232      bool has (false);
     2233      for (int j = 0; j < cmt.m_tags_remove.size (); j++)
     2234        {
     2235          if (cmt.m_tags_remove[j] == words[i])
     2236            {
     2237              has = true;
     2238              break;
     2239            }
     2240        }
     2241      if (!has)
     2242        {
     2243          cmt.m_tags_remove.push_back (words[i]);
     2244        }
     2245
     2246      for (int j = 0; j < cmt.m_extra_tags.size (); j++)
     2247        {
     2248          if (cmt.m_extra_tags[j] == words[i])
     2249            {
     2250              cmt.m_extra_tags.erase(j);
     2251              break;
     2252            }
     2253        }
     2254      for (int j = 0; j < cmt.m_tags.size (); j++)
     2255        {
     2256          if (cmt.m_tags[j] == words[i])
     2257            {
     2258              cmt.m_tags.erase(j);
     2259              break;
     2260            }
     2261        }
     2262      for (int j = 0; j < cmt.m_tags_add.size (); j++)
     2263        {
     2264          if (cmt.m_tags_add[j] == words[i])
     2265            {
     2266              cmt.m_tags_add.erase(j);
     2267              break;
     2268            }
     2269        }
     2270    }
     2271  /*
    21942272  Tag::TagPtrVector tags = Tag::tags ();
    21952273  int i;
    21962274  Tag* tag;
    2197 
    2198   /*
    2199     for (i = 0; i < tags.size (); i++)
    2200     {
    2201     tag = tags[i];
    2202     if ((tag != 0) &&
    2203     (tag->selected))
    2204     {
    2205     if (!cmt.m_quiet) cerr << "  original tag_list=" << tag->name << tag->priority << endl;
    2206     }
    2207     }
    2208   */
    22092275
    22102276  CmtSystem::cmt_string_vector words;
     
    22592325            const cmt_string& a = words[i];
    22602326
    2261             //fprintf (stderr, "  a=[%s]\n", a.c_str ());
    2262 
    22632327            /// Then restore uname if the specified tag is CMTCONFIG
    22642328              if (a == CmtSystem::get_cmt_config ())
     
    22832347              tag->mark ("arguments");
    22842348          }
     2349  */
    22852350}
    22862351
     
    23072372}
    23082373
     2374void ArgParser::option_with_projects ()
     2375{
     2376  cmt.m_use_projects = true;
     2377  if (!Cmt::add_cmt_flag ("-with_projects"))
     2378    CmtMessage::error ("Cannot add flag `-with_projects'");
     2379}
     2380
     2381void ArgParser::option_without_projects ()
     2382{
     2383  cmt.m_use_projects = false;
     2384  if (!Cmt::add_cmt_flag ("-without_projects"))
     2385    CmtMessage::error ("Cannot add flag `-without_projects'");
     2386}
     2387
    23092388void ArgParser::option_with_version_directory ()
    23102389{
    23112390  cmt.m_current_structuring_style = with_version_directory;
    23122391
    2313   StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
    2314   if (def != 0)
    2315     {
    2316       def->m_default_value = true;
    2317       def->m_priority_value = false;
    2318     }
     2392  if (!Cmt::add_cmt_flag ("-with_version_directory"))
     2393    CmtError::set (CmtError::system_error, "Cannot add flag `-with_version_directory'");
     2394
    23192395}
    23202396
     
    23232399  cmt.m_current_structuring_style = without_version_directory;
    23242400
    2325   StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
    2326   if (def != 0)
    2327     {
    2328       def->m_default_value = false;
    2329       def->m_priority_value = true;
    2330     }
     2401  if (!Cmt::add_cmt_flag ("-without_version_directory"))
     2402    CmtError::set (CmtError::system_error, "Cannot add flag `-without_version_directory'");
     2403
    23312404}
    23322405
     
    23982471  cout << "#   -path=<path>            : set root path" << endl;
    23992472  cout << "#   -f=<requirements-file>  : set input file" << endl;
    2400   cout << "#   -e=<statement>          : add a one line statement" << endl;
     2473  cout << "#   -e=<statement(s)>       : add (multiple) statement(s)" << endl;
    24012474  cout << "#   -tag=<tag-list>         : select a new tag-set" << endl;
    24022475  cout << "#   -tag_add=<tag-list>     : add specific comma-separated tag(s)" << endl;
     
    24082481  cout << "#   -no_cleanup             : inhibit install area cleanup" << endl;
    24092482  cout << "#   -xml                    : output in XML format (cmt setup, cmt show projects, cmt show uses)" << endl;
     2483  cout << "#   -user_context=<path>    : set user context package/project directory" << endl;
     2484  cout << "#   -home=<path>            : set home package/project directory" << endl;
    24102485}
    24112486
  • CMT/v1r25-branch/source/cmt_commands.h

    r561 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    8384  void option_with_cmt ();
    8485  void option_without_cmt ();
     86  void option_with_projects ();
     87  void option_without_projects ();
    8588  void option_with_version_directory ();
    8689  void option_without_version_directory ();
    8790  void option_no_cleanup ();
     91  void option_no_strip_path ();
     92  void option_strip_path ();
    8893  void option_private ();
    8994  void option_public ();
  • CMT/v1r25-branch/source/cmt_constituent.cxx

    r637 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_constituent.h

    r588 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_cvs.cxx

    r461 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by: garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_database.cxx

    r535 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_database.h

    r535 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_deps_builder.cxx

    r606 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    226227        }
    227228    }
    228   else if (!strncmp (ptr, "      include", 13))
     229  else if (!strncmp (ptr, "include", 7) ||
     230           !strncmp (ptr, "INCLUDE", 7))
     231  //  else if (!strncmp (ptr, "      include", 13))
    229232    {
    230233      // fortran include statement
    231234
    232       ptr += 13;
     235      ptr += 7;
     236      //ptr += 13;
    233237
    234238      while ((*ptr == ' ') || (*ptr == '\t')) ptr++;
     
    239243          ptr++;
    240244        }
     245      else if (*ptr == '(')
     246        {
     247          term = ')';
     248          ptr++;
     249        }
    241250      else
    242251        {
     
    245254        }
    246255    }
     256  /*
    247257  else if (!strncmp (ptr, "\tinclude", 8))
    248258    {
     
    264274        }
    265275    }
     276  */
    266277  else
    267278    {
     
    308319static char* in_line_action (char* ptr, state_def& state)
    309320{
    310   char* pattern = ptr + strlen (ptr);
    311   int length = 0;
     321  //  char* pattern = ptr + strlen (ptr);\
     322  //  int length = 0;
    312323
    313324  /*
     
    318329  */
    319330
     331  char* beg = ptr;
     332  while (char* p = strpbrk (beg, "\"\'/"))
     333    if (*p == '"')
     334      {
     335        if (p == ptr || (p > ptr && *(p - 1) != '\\'))
     336          {
     337            state = in_string;
     338            return p + 1;
     339          }
     340        else
     341          { // '"' is escaped
     342            beg = p + 1;
     343          }
     344      }
     345    else if (*p == '\'')
     346      {
     347        if (p == ptr || (p > ptr && *(p - 1) != '\\'))
     348          {
     349            state = in_char;
     350            return p + 1;
     351          }
     352        else
     353          { // '\'' is escaped
     354            beg = p + 1;
     355          }
     356      }
     357    else
     358      { // we have '/'
     359        if (*(p + 1) == '*')
     360          {
     361            state = in_comment;
     362            return p + 2;
     363          }
     364        else if (*(p + 1) == '/')
     365          {
     366            state = in_line_comment;
     367            return p + 2;
     368          }
     369        else
     370          {
     371            beg = p + 1;
     372          }
     373      }
     374  /*
    320375  char* pos = strchr (ptr, '"');
    321376  if ((pos != 0) && (pos < pattern) && (pos > ptr) && (*(pos-1) != '\\'))
     
    334389    }
    335390
    336   pos = strstr (ptr, "/*");   //*/
     391  pos = strstr (ptr, "/*");
    337392  if ((pos != 0) && (pos < pattern))
    338393    {
     
    351406
    352407  ptr = pattern + length;
    353 
    354408  return (ptr);
     409*/
     410  return  ptr + strlen (ptr);
    355411}
    356412
     
    650706        } // while (strlen (ptr) > 0)
    651707     
    652       if (state == in_line) state = at_start;
     708      //if (state == in_line) state = at_start;
     709      switch (state)
     710        {
     711        case in_line:
     712        case in_line_comment:
     713          state = at_start;
     714          break;
     715        }
    653716      line_number++;
    654717
  • CMT/v1r25-branch/source/cmt_deps_builder.h

    r588 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_error.cxx

    r598 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    1819  {
    1920    error_names.add() = "ok";
    20     error_names.add() = "Warning";
     21    error_names.add() = "warning";
    2122    error_names.add() = "symbol not found";
    2223    error_names.add() = "pattern not found";
     
    159160
    160161  result = get_error_name (e.get_code ());
    161   result += " : ";
     162  result += ": ";
    162163  result += e.get_text ();
    163164
  • CMT/v1r25-branch/source/cmt_error.h

    r598 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_fragment.cxx

    r595 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_fragment.h

    r561 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_generator.cxx

    r637 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_generator.h

    r637 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_generators.cxx

    r637 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    28092810  m_PACKAGEFULLNAME.set ("PACKAGEFULLNAME");
    28102811  m_ISLOCAL.set ("ISLOCAL");
     2812  m_ISINCLUDED.set ("ISINCLUDED");
    28112813
    28122814  packages_header_fragment.set ("packages_header");
     
    28222824  m_PACKAGEFULLNAME = "";
    28232825  m_ISLOCAL = "";
     2826  m_ISINCLUDED = "";
    28242827
    28252828  packages_header_fragment.reset ();
     
    28672870      if (!packages_header_fragment.copy (m_output_file, 1, &m_PACKAGE)) return;
    28682871
    2869       Project* cur = Project::get_current ();
     2872      const Project* p_cur (Project::get_current ());
    28702873      Use::UsePtrVector uses (Use::get_ordered_uses ());
    28712874      uses.push_back (&Use::current ());
     2875
     2876      Project::ConstProjectPtrVector path_exclusions;
     2877      Project::fill_exclusion (path_exclusions);
     2878
    28722879      cmt_string temp;
    28732880      for (int i = uses.size () - 1; i >= 0; i--)
    28742881        {
    28752882          Use* use = uses[i];
     2883
    28762884          if (use->discarded) continue;
    28772885          if (use->m_hidden) continue;
     
    28792887          if (use->get_package ()->is_cmt ()) continue;
    28802888
    2881           if (use->get_project () == cur)
    2882             m_ISLOCAL = "is_local";
    2883           else
    2884             m_ISLOCAL = "is_not_local";
     2889          const Project* up = use->get_project ();
     2890
     2891          m_ISLOCAL = "is_not_local";
     2892          if (p_cur)
     2893            {
     2894              if (up)
     2895                {
     2896                  if (up == p_cur)
     2897                    {
     2898                      m_ISLOCAL = "is_local";
     2899                    }
     2900                }
     2901              else
     2902                {
     2903                  if (use->get_realpath ().find (p_cur->get_cmtpath_real ()) == 0)
     2904                    {
     2905                      m_ISLOCAL = "is_local";
     2906                    }
     2907                }
     2908            }
     2909          else if (use == &Use::current ())
     2910            {
     2911              m_ISLOCAL = "is_local";
     2912            }
     2913
     2914          m_ISINCLUDED = "is_included";
     2915          for (int j = 0; j < path_exclusions.size (); j++)
     2916            {
     2917              const Project* sp = path_exclusions[j];
     2918              if (up)
     2919                {
     2920                  if (up == sp)
     2921                    {
     2922                      m_ISINCLUDED = "is_not_included";
     2923                    }
     2924                }
     2925              else
     2926                {
     2927                  if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2928                    {
     2929                      m_ISINCLUDED = "is_not_included";
     2930                    }
     2931                }
     2932            }
    28852933
    28862934          temp = use->get_full_path ();
     
    28952943              temp += "mgr";
    28962944              break;
     2945            default:
     2946              break;
    28972947            }
    28982948#ifdef WIN32
     
    29002950#endif
    29012951          m_PACKAGEMGRPATH = temp;
    2902           //      fprintf (m_output_file, "%s\n", temp.c_str());
    29032952
    29042953          temp = "";
     
    29242973#endif
    29252974          m_PACKAGEFULLNAME = temp;
    2926           //      fprintf (m_output_file, "%s\n", temp.c_str());
    29272975
    29282976          m_PACKAGE = use->get_package_name ();
     
    29593007            }
    29603008
    2961           if (!package_fragment.copy (m_output_file, 6,
     3009          if (!package_fragment.copy (m_output_file, 7,
    29623010                                      &m_PACKAGE, &m_PACKAGEPREFIX,
    29633011                                      &m_DEPENDENCIES,
    29643012                                      &m_PACKAGEMGRPATH, &m_PACKAGEFULLNAME,
    2965                                       &m_ISLOCAL)) return;
     3013                                      &m_ISLOCAL, &m_ISINCLUDED)) return;
    29663014        }
    29673015
     
    29843032
    29853033      CmtSystem::close_ostream (m_output_file, new_file_name);
    2986       //  fclose (m_output_file);
    29873034
    29883035      commit (new_file_name);
  • CMT/v1r25-branch/source/cmt_generators.h

    r588 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    238239  Variable m_PACKAGEFULLNAME;
    239240  Variable m_ISLOCAL;
     241  Variable m_ISINCLUDED;
    240242
    241243  FragmentHandle packages_header_fragment;
  • CMT/v1r25-branch/source/cmt_install_area.cxx

    r565 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_language.cxx

    r561 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_language.h

    r561 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_lock.cxx

    r459 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_log.h

    r535 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_map.h

    r11 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    276277   *   Return 0 if not found
    277278   */
    278   const T* find (const K& key) const
     279  T* find (const K& key)
     280    //  const T* find (const K& key) const
    279281  {
    280282    if (key < m_key)
     
    504506   *   Returns 0 if not found
    505507   */
    506   const T* find (const K& key) const
     508  T* find (const K& key) const
     509    //  const T* find (const K& key) const
    507510  {
    508511    if (m_top != 0)
  • CMT/v1r25-branch/source/cmt_model.cxx

    r459 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_parser.cxx

    r642 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    1011#include <string.h>
    1112#include <ctype.h>
     13#include <errno.h>
    1214
    1315//----------------------------------------------------------
     
    5052}
    5153
     54//----------------------------------------------------------
    5255CmtContext::~CmtContext ()
    5356{
    5457}
    5558
     59//----------------------------------------------------------
    5660void CmtContext::clear ()
    5761{
     
    5963  m_build_nmake    = false;
    6064  m_cmt_config     = "";
    61   //m_cmt_path.clear ();
    62   //m_cmt_path_pwds.clear ();
    63   //m_cmt_path_sources.clear ();
    6465  m_cmt_root       = "";
     66  m_cmt_home       = "";
     67  m_cmt_user_context = "";
     68  m_cmt_site       = "";
    6569  m_cmt_version    = "";
    6670  m_use_cmt        = true;
     71  m_use_projects   = true;
     72
    6773  m_current_dir     = "";
    6874  m_current_file_path = "";
     
    7480  m_current_offset  = "";
    7581
    76   m_current_access   = DeveloperMode;
     82  m_current_access  = UserMode;
     83  m_current_style   = cmt_style;
     84  m_current_structuring_style = default_structuring_style;
    7785
    7886  m_current_tag      = "";
    7987  m_current_target   = "";
    8088  m_current_version  = "";
     89
     90  //  m_extra_tags       = "";
     91  m_extra_tags.clear ();
     92  m_tags.clear ();
     93  m_tags_add.clear ();
     94  m_tags_remove.clear ();
     95
     96  m_configure_error  = "";
     97
     98  m_debug = (::getenv ("CMTDEBUG") != 0) ? true : false;
     99
    81100  m_default_path     = "";
    82 
    83   //m_quiet            = false;
    84 
     101  m_quiet            = false;
    85102  m_disable_warnings = false;
    86103  m_warnings         = false;
     
    91108
    92109  m_standard_macros_done = false;
    93   m_current_access = UserMode;
    94   m_current_style = cmt_style;
    95   m_current_structuring_style = default_structuring_style;
    96110  m_all_sets_done = false;
     111
    97112  m_autoconfigure_cmtpath = false;
    98   m_debug = false;
    99   if (getenv ("CMTDEBUG") != 0) m_debug = true;
    100 }
    101 
     113
     114  m_env_access = true;
     115  m_print_mode = Csh;
     116  m_strip_path = false;
     117}
     118//----------------------------------------------------------
     119
     120int CmtContext::initialize ()
     121{
     122  int errors (0);
     123
     124  cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS");
     125  CmtSystem::cmt_string_vector words;
     126  CmtSystem::split (tags, " \t,", words);
     127  for (int i = 0; i < words.size (); i++)
     128    {
     129      bool has (false);
     130      for (int j = 0; j < m_extra_tags.size (); j++)
     131        {
     132          if (m_extra_tags[j] == words[i])
     133            {
     134              has = true;
     135              break;
     136            }
     137        }
     138      if (!has)
     139        m_extra_tags.push_back (words[i]);
     140    }
     141
     142  return - errors;
     143}
    102144//----------------------------------------------------------
    103145
     
    357399
    358400
     401//----------------------------------------------------------
     402//
     403//   The static Cmt member
     404//
     405//----------------------------------------------------------
     406
     407CmtContext& Cmt::m_cmt_context = Me;
     408//CmtContext * Cmt::m_cmt_context = &Me;
    359409
    360410//----------------------------------------------------------
     
    462512
    463513//----------------------------------------------------------
     514/*
    464515bool Cmt::build_nmake ()
    465516{
    466517  return (Me.m_build_nmake);
    467518}
    468 
     519*/
    469520//----------------------------------------------------------
    470521void Cmt::build_OS9_makefile (const cmt_string& target)
     
    497548void Cmt::clear ()
    498549{
    499   Me.m_quiet = false;
    500550  Me.clear ();
     551  //Me.m_quiet = false;
    501552
    502553  Database::clear ();
     
    507558
    508559//----------------------------------------------------------
     560namespace {
     561
     562bool parse_cmt_flags (const cmt_string& file_name, CmtContext& cmt)
     563{
     564  cmt_string Flags (Cmt::get_cmt_flags (file_name));
     565  if (CmtError::get_last_error_code () == CmtError::file_access_error)
     566    return false;
     567  if (Flags.size () == 0)
     568    return true;
     569
     570  cmt_string CmtFlags (Cmt::get_cmt_flags ());
     571  if (CmtFlags.size () != 0)
     572    Flags += " " + CmtFlags;
     573
     574  CmtSystem::cmt_string_vector flags;
     575  CmtSystem::split (Flags, " \t", flags);
     576  for (int i = 0; i < flags.size (); i++)
     577    {
     578      if (flags[i] == "-without_cmt" &&
     579          cmt.m_use_cmt)
     580        cmt.m_use_cmt = false;
     581      else if (flags[i] == "-with_cmt" &&
     582               !cmt.m_use_cmt)
     583        cmt.m_use_cmt = true;
     584      else if (flags[i] == "-without_projects" &&
     585               cmt.m_use_projects)
     586        cmt.m_use_projects = false;
     587      else if (flags[i] == "-with_projects" &&
     588               !cmt.m_use_projects)
     589        cmt.m_use_projects = true;
     590      else if (flags[i] == "-no_strip_path" &&
     591               cmt.m_strip_path)
     592        {
     593          cmt.m_strip_path = false;
     594          Symbol::set_strip_path (false);
     595        }
     596      else if (flags[i] == "-strip_path" &&
     597               !cmt.m_strip_path)
     598        {
     599          cmt.m_strip_path = true;
     600          Symbol::set_strip_path (true);
     601        }
     602    }
     603
     604  return true;
     605}
     606
     607}
     608
     609//----------------------------------------------------------
    509610//void Cmt::configure ()
    510611void Cmt::configure (const ArgParser& ap)
     
    515616  if (configured) return;
    516617
    517   Me.clear ();
     618  //  Me.clear ();
    518619
    519620  log << "configure_cmt_message" << log_endl;
     
    523624  log << "configure_default_path" << log_endl;
    524625  configure_default_path ();
     626
     627  log << "restore_all_tags" << log_endl;
     628  restore_all_tags (0);
    525629  log << "configure_version_tag" << log_endl;
    526630  configure_version_tag ();
     
    533637  log << "configure_site_tag" << log_endl;
    534638  configure_site_tag (0);
     639
     640  cmt_string requirements;
     641
     642  if (Me.m_current_package.size () != 0 &&
     643      Me.m_current_package != "cmt_standalone")
     644    {
     645      // we have a package name (not "cmt_standalone")
     646      Use& use = Use::current();
     647      use.set (Me.m_current_package,
     648               Me.m_current_version,
     649               Me.m_current_path);
     650      if (CmtSystem::absolute_path (Me.m_current_path))
     651        {
     652          if (!use.move_to ())
     653            {
     654              CmtError::set (CmtError::package_not_found, use.get_info ());
     655              return;
     656            }
     657        }
     658      else
     659        {
     660          if (!use.move_to ("", true))
     661            {
     662              // will try again later from CMTPATH entries
     663            }
     664        }
     665
     666      if (use.located ())
     667        {
     668          // parse additional options
     669          parse_cmt_flags ("requirements", m_cmt_context);
     670        }
     671    }
     672  else
     673    {
     674      if (Me.m_current_path.size () != 0 &&
     675          !CmtSystem::cd (Me.m_current_path))
     676        {
     677          CmtError::set (CmtError::path_not_found, Me.m_current_path);
     678          return;
     679        }
     680
     681      configure_current_dir ();
     682      configure_current_structuring_style (ap);
     683      cmt_string current_package_saved (Me.m_current_package);
     684      requirements = configure_current_package ();
     685      Me.m_current_package = current_package_saved;
     686      if (requirements.size () != 0)
     687        {
     688          // parse additional options
     689          parse_cmt_flags (requirements, m_cmt_context);
     690        }
     691    }
     692
    535693  log << "configure_current_dir" << log_endl;
    536694  configure_current_dir ();
     
    540698  //  log << "configure_current_dir" << log_endl;
    541699
    542 
    543700  bool save_quiet = Me.m_quiet;
    544701  Me.m_quiet = true;
     
    546703  Me.m_autoconfigure_cmtpath = true;
    547704  configure_cmt_path (0);
    548   Me.m_autoconfigure_cmtpath = false;
     705  //  Me.m_autoconfigure_cmtpath = false;
    549706
    550707  Me.m_quiet = save_quiet;
     
    553710
    554711  guess_current_project ();
     712
     713  if (Me.m_current_package.size () != 0 &&
     714      Me.m_current_package != "cmt_standalone")
     715    {
     716      Use& use = Use::current();
     717      if (!use.located ())
     718        {
     719          if (!use.move_to ())
     720            {
     721              CmtError::set (CmtError::package_not_found, use.get_info ());
     722              return;
     723            }
     724          else
     725            {
     726              use.get_full_path (Me.m_current_dir);
     727              switch (use.style)
     728                {
     729                case cmt_style:
     730                  Me.m_current_dir += CmtSystem::file_separator ();
     731                  Me.m_current_dir += "cmt";
     732                  break;
     733                case mgr_style:
     734                  Me.m_current_dir += CmtSystem::file_separator ();
     735                  Me.m_current_dir += "mgr";
     736                  break;
     737                default:
     738                  break;
     739                }
     740              Me.m_current_file_path = Me.m_current_dir;
     741
     742              Project::order_all ();
     743              Cmt::guess_current_project ();
     744            }
     745        }
     746    }
    555747
    556748  log << "configure_current_structuring_style" << log_endl;
     
    558750  configure_current_structuring_style (ap);
    559751
     752//   if (requirements.size () == 0)
     753//     {
    560754  log << "configure_current_package" << log_endl;
    561755  configure_current_package ();
     756//     }
    562757
    563758  Use& use = Use::current();
    564 
    565   use.set (Me.m_current_package,
    566            Me.m_current_version,
    567            Me.m_current_path,
    568            "",
    569            "");
    570 
    571   use.style = Me.m_current_style;
    572   use.structuring_style = Me.m_current_structuring_style;
    573 
    574   use.change_path (Me.m_current_path);
     759  if (!use.located ())
     760    {
     761      use.set (Me.m_current_package,
     762               Me.m_current_version,
     763               Me.m_current_path);
     764      use.style = Me.m_current_style;
     765
     766      if (use.style != none_style)
     767        {
     768          use.structuring_style = Me.m_current_structuring_style;
     769          use.change_path (Me.m_current_path, Project::get_current ());
     770        }
     771      else
     772        {
     773          use.real_path = Me.m_current_path;
     774        }
     775    }
     776  else if (const Project * p = Project::get_current ())
     777    {
     778      use.set_project (p);
     779    }
    575780
    576781  if (CmtError::has_pending_error ())
     
    584789{
    585790  if (!Me.m_autoconfigure_cmtpath) return;
     791
     792  if (!m_cmt_context.m_use_projects) return;
    586793
    587794  cmt_string s;
     
    621828{
    622829  Use& current_use = Use::current ();
    623 
     830  current_use.get_cmtpath_and_offset (Me.m_current_cmtpath, Me.m_current_offset);
     831  /*
    624832  Me.m_current_cmtpath = "";
    625833  Me.m_current_offset = "";
     
    633841
    634842      Me.m_current_offset = current_use.path;
    635 
     843  */
    636844      /**
    637845         try to remove this current CMTPATH entry from path.  This
     
    639847         absolute path.
    640848      */
    641      
     849  /*     
    642850      Me.m_current_offset.replace (Me.m_current_cmtpath, empty_string);
    643851      if (Me.m_current_offset[0] == CmtSystem::file_separator ())
     
    648856        }
    649857    }
     858  */
    650859}
    651860
     
    731940void Cmt::configure_current_dir ()
    732941{
     942  if (Me.m_current_dir.size () != 0) return;
     943
    733944  cmt_string file_name;
    734945
     
    788999  Me.m_current_file_path = mount_filter.get_current_dir ();
    7891000
    790   cmt_string t = Me.m_current_file_path;
    791 }
    792 
    793 //----------------------------------------------------------
    794 void Cmt::configure_current_package ()
     1001  //  cmt_string t = Me.m_current_file_path;
     1002}
     1003
     1004//----------------------------------------------------------
     1005cmt_string Cmt::configure_current_package ()
     1006//void Cmt::configure_current_package ()
    7951007{
    7961008  /*
     
    8001012    standard directory tree (i.e. <package>/<version>/cmt or mgr)
    8011013  */
     1014  Use& use = Use::current();
     1015  if (use.located ())
     1016    {
     1017      Me.m_current_style = use.style;
     1018      build_prefix (Me.m_current_package, Me.m_current_prefix);
     1019      build_config (Me.m_current_prefix, Me.m_current_config);
     1020
     1021      cmt_string req;
     1022      use.get_full_path (req);
     1023      switch (use.style)
     1024        {
     1025        case cmt_style:
     1026          req += CmtSystem::file_separator ();
     1027          req += "cmt";
     1028          break;
     1029        case mgr_style:
     1030          req += CmtSystem::file_separator ();
     1031          req += "mgr";
     1032          break;
     1033        default:
     1034          break;
     1035        }
     1036      req += CmtSystem::file_separator ();
     1037      req += "requirements";
     1038      return req;
     1039    }
    8021040
    8031041  cmt_string req = "..";
     
    8131051  else
    8141052    {
    815       cmt_string req = "..";
     1053      req = "..";
     1054      //      cmt_string req = "..";
    8161055      req += CmtSystem::file_separator ();
    8171056      req += "mgr";
     
    8271066          // This package is probably a standalone one
    8281067          Me.m_current_style = none_style;
     1068          req = "requirements";
     1069          if (!CmtSystem::test_file (req))
     1070            {
     1071              req = "";
     1072            }
    8291073        }
    8301074    }
     
    10621306      // Do NOT (re)set m_current_structuring_style yet
    10631307      // (as requirements may NOT exist, so this is not a package)
    1064       // rather do it in reach_current_package (if/when requirements is read)
     1308      // rather do it in use_current_package (if/when requirements is read)
    10651309      //Me.m_current_structuring_style = without_version_directory;
    10661310      build_prefix (Me.m_current_package, Me.m_current_prefix);
    10671311      build_config (Me.m_current_prefix, Me.m_current_config);
    10681312    }
     1313
     1314  return req;
    10691315}
    10701316
     
    10741320{
    10751321  cmt_string s;
    1076   s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
    1077   if (s == "without_version_directory")
    1078     {
    1079       Me.m_current_structuring_style = without_version_directory;
    1080     }
    1081   else if (s == "with_version_directory")
    1082     {
    1083       Me.m_current_structuring_style = with_version_directory;
    1084     }
    1085 
    1086   CmtSystem::cmt_string_vector flags;
    1087   Cmt::get_cmt_flags (flags);
    1088   for (int i = 0; i < flags.size (); i++)
    1089     {
    1090       const cmt_string& flag = flags[i];
    1091       if (flag == "-without_version_directory")
     1322  if (Me.m_current_structuring_style == default_structuring_style)
     1323    {
     1324      s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
     1325      if (s == "without_version_directory")
    10921326        {
    10931327          Me.m_current_structuring_style = without_version_directory;
    10941328        }
    1095       else if (flag == "-with_version_directory")
     1329      else if (s == "with_version_directory")
    10961330        {
    10971331          Me.m_current_structuring_style = with_version_directory;
    1098         }
    1099     }
    1100 
    1101   for (int i = 1; i < ap.argc; i++)
    1102     {
    1103       const cmt_string& arg = ap.argv[i];
    1104       if (arg[0] != '-') break;
    1105       if (arg == "-without_v" ||
    1106           arg == "-without_ve" ||
    1107           arg == "-without_ver" ||
    1108           arg == "-without_vers" ||
    1109           arg == "-without_versi" ||
    1110           arg == "-without_versio" ||
    1111           arg == "-without_version" ||
    1112           arg == "-without_version_" ||
    1113           arg == "-without_version_d" ||
    1114           arg == "-without_version_di" ||
    1115           arg == "-without_version_dir" ||
    1116           arg == "-without_version_dire" ||
    1117           arg == "-without_version_direc" ||
    1118           arg == "-without_version_direct" ||
    1119           arg == "-without_version_directo" ||
    1120           arg == "-without_version_director" ||
    1121           arg == "-without_version_directory")
    1122         {
    1123           Me.m_current_structuring_style = without_version_directory;
    1124           //      if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "without_version_directory"))
    1125           //        CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to"
    1126           //                           " `without_version_directory' in the environment");
    1127           if (!Cmt::add_cmt_flag ("-without_version_directory"))
    1128             CmtMessage::error ("Cannot add flag `-without_version_directory'");
    1129         }
    1130       else if (arg == "-with_v" ||
    1131                arg == "-with_ve" ||
    1132                arg == "-with_ver" ||
    1133                arg == "-with_vers" ||
    1134                arg == "-with_versi" ||
    1135                arg == "-with_versio" ||
    1136                arg == "-with_version" ||
    1137                arg == "-with_version_" ||
    1138                arg == "-with_version_d" ||
    1139                arg == "-with_version_di" ||
    1140                arg == "-with_version_dir" ||
    1141                arg == "-with_version_dire" ||
    1142                arg == "-with_version_direc" ||
    1143                arg == "-with_version_direct" ||
    1144                arg == "-with_version_directo" ||
    1145                arg == "-with_version_director" ||
    1146                arg == "-with_version_directory")
    1147         {
    1148           Me.m_current_structuring_style = with_version_directory;
    1149           //      if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "with_version_directory"))
    1150           //        CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to"
    1151           //                           " `with_version_directory' in the environment");
    1152           if (!Cmt::add_cmt_flag ("-with_version_directory"))
    1153             CmtMessage::error ("Cannot add flag `-with_version_directory'");
     1332        }
     1333     
     1334      CmtSystem::cmt_string_vector flags;
     1335      Cmt::get_cmt_flags (flags);
     1336      for (int i = 0; i < flags.size (); i++)
     1337        {
     1338          const cmt_string& flag = flags[i];
     1339          if (flag == "-without_version_directory")
     1340            {
     1341              Me.m_current_structuring_style = without_version_directory;
     1342            }
     1343          else if (flag == "-with_version_directory")
     1344            {
     1345              Me.m_current_structuring_style = with_version_directory;
     1346            }
     1347        }
     1348    }
     1349 
     1350  if (Me.m_current_structuring_style != default_structuring_style)
     1351    {
     1352      StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
     1353      if (def != 0)
     1354        {
     1355          def->m_default_value =
     1356            Me.m_current_structuring_style == with_version_directory;
     1357          def->m_priority_value =
     1358            Me.m_current_structuring_style == without_version_directory;
    11541359        }
    11551360    }
     
    11711376void Cmt::configure_home (Use* use)
    11721377{
    1173   Me.m_cmt_home = "";
    1174 
    1175   Symbol* symbol = Symbol::find ("CMTHOME");
    1176   if (symbol != 0)
    1177     {
    1178       Me.m_cmt_home = symbol->build_macro_value ();
    1179       Symbol::expand (Me.m_cmt_home);
    1180     }
    1181   else if (CmtSystem::testenv ("CMTHOME"))
    1182     {
    1183       Me.m_cmt_home = CmtSystem::getenv ("CMTHOME");
     1378  if (Me.m_cmt_home.size () == 0)
     1379    {
     1380      // if not passed on the command line
     1381      if (const Symbol* symbol = Symbol::find ("CMTHOME"))
     1382        {
     1383          Me.m_cmt_home = symbol->build_macro_value ();
     1384          Symbol::expand (Me.m_cmt_home);
     1385        }
     1386      else if (CmtSystem::testenv ("CMTHOME"))
     1387        {
     1388          Me.m_cmt_home = CmtSystem::getenv ("CMTHOME");
     1389        }
    11841390    }
    11851391
     
    11951401void Cmt::configure_user_context (Use* use)
    11961402{
    1197   Me.m_cmt_user_context = "";
    1198 
    1199   Symbol* symbol = Symbol::find ("CMTUSERCONTEXT");
    1200   if (symbol != 0)
    1201     {
    1202       Me.m_cmt_user_context = symbol->build_macro_value ();
    1203       Symbol::expand (Me.m_cmt_user_context);
    1204     }
    1205   else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
    1206     {
    1207       Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
     1403  if (Me.m_cmt_user_context.size () == 0)
     1404    {
     1405      // if not passed on the command line
     1406      if (const Symbol* symbol = Symbol::find ("CMTUSERCONTEXT"))
     1407        {
     1408          Me.m_cmt_user_context = symbol->build_macro_value ();
     1409          Symbol::expand (Me.m_cmt_user_context);
     1410        }
     1411      else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
     1412        {
     1413          Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
     1414        }
    12081415    }
    12091416
     
    12721479
    12731480  Cmt::configure_tags (use);
     1481
     1482  cmt_string s, t;
     1483  if (0 < Me.m_extra_tags.size ())
     1484    {
     1485      s = "CMTEXTRATAGS";
     1486      t = use != 0 ? use->get_package_name () : s;
     1487    }
     1488  for (int i = 0; i < Me.m_extra_tags.size (); i++)
     1489    {
     1490      Tag* tag = Tag::add (Me.m_extra_tags[i], PriorityUserTag, s, use);
     1491      tag->mark (t);
     1492    }
     1493
     1494  for (int i = 0; i < Me.m_tags.size (); i++)
     1495    {
     1496      const cmt_string& a = Me.m_tags[i];
     1497      if (i == 0)
     1498        {
     1499          Me.m_current_tag = a;
     1500        }
     1501//       // Then restore uname if the specified tag is CMTCONFIG
     1502//       if (a == CmtSystem::get_cmt_config ())
     1503//      {
     1504//        Cmt::configure_uname_tag ();
     1505//      }
     1506      Tag* tag = Tag::add (a, PriorityArgument, "arguments", 0);
     1507      tag->mark ("arguments");
     1508    }
     1509
     1510  for (int i = 0; i < Me.m_tags_add.size (); i++)
     1511    {
     1512      const cmt_string& a = Me.m_tags_add[i];
     1513//       // Then restore uname if the specified tag is CMTCONFIG
     1514//       if (a == CmtSystem::get_cmt_config ())
     1515//      {
     1516//        Cmt::configure_uname_tag ();
     1517//      }
     1518      Tag* tag = Tag::add (a, PriorityUserTag, "arguments", 0);
     1519      tag->mark ("arguments");
     1520    }
    12741521
    12751522  /*
     
    12771524  */
    12781525
     1526  /*
    12791527  if (CmtSystem::testenv ("CMTEXTRATAGS"))
    12801528    {
     
    13091557        }
    13101558    }
     1559  */
    13111560}
    13121561
     
    13191568
    13201569  log << "current_tag=" << Me.m_current_tag << log_endl;
     1570
     1571  cmt_string s = "CMTCONFIG";
    13211572
    13221573  Symbol* symbol = Symbol::find ("CMTCONFIG");
     
    13471598    {
    13481599      config_tag = CmtSystem::getenv ("CMTBIN");
     1600      s = "CMTBIN";
    13491601    }
    13501602
     
    13521604    {
    13531605      CmtSystem::get_uname (config_tag);
     1606      s = "uname";
    13541607    }
    13551608
    13561609  log << "current_tag=" << Me.m_current_tag << log_endl;
    13571610
    1358   cmt_string s = "CMTCONFIG";
     1611  //  cmt_string s = "CMTCONFIG";
    13591612  cmt_string t = s;
    13601613
     
    15521805          if (CmtMessage::level () != Warning)
    15531806            CmtMessage::set_level (Warning);
    1554           //      if (CmtMessage::level () > Warning)
    1555         }
    1556     }
    1557 
    1558   for (int i = 1; i < ap.argc; i++)
    1559     {
    1560       const cmt_string& arg = ap.argv[i];
    1561       if (arg[0] != '-') break;
    1562       if (arg == "-d" ||
    1563           arg == "-di" ||
    1564           arg == "-dis" ||
    1565           arg == "-disa" ||
    1566           arg == "-disab" ||
    1567           arg == "-disabl" ||
    1568           arg == "-disable" ||
    1569           arg == "-disable_" ||
    1570           arg == "-disable_w" ||
    1571           arg == "-disable_wa" ||
    1572           arg == "-disable_war" ||
    1573           arg == "-disable_warn" ||
    1574           arg == "-disable_warni" ||
    1575           arg == "-disable_warnin" ||
    1576           arg == "-disable_warning" ||
    1577           arg == "-disable_warnings")
    1578         {
    1579           Me.m_disable_warnings = true;
    1580           if (CmtMessage::level () <= Warning)
    1581             {
    1582               CmtMessage::set_level (Error);
    1583               //              if (!CmtSystem::putenv ("CMTERROR", "1"))
    1584               //                CmtMessage::error ("Cannot set `CMTERROR' in the environment");
    1585             }
    1586           if (!Cmt::add_cmt_flag ("-disable_warnings"))
    1587             CmtMessage::error ("Cannot add flag `-disable_warnings'");
    1588         }
    1589       else if (arg == "-q" ||
    1590                arg == "-qu" ||
    1591                arg == "-qui" ||
    1592                arg == "-quie" ||
    1593                arg == "-quiet")
    1594         {
    1595           Me.m_quiet = true;
    1596           if (CmtMessage::level () <= Error)
    1597             {
    1598               CmtMessage::set_level (Fatal);
    1599               //              if (!CmtSystem::putenv ("CMTFATAL", "1"))
    1600               //                CmtMessage::error ("Cannot set `CMTFATAL' in the environment");
    1601             }
    1602           if (!Cmt::add_cmt_flag ("-quiet"))
    1603             CmtMessage::error ("Cannot add flag `-quiet'");
    1604         }
    1605       else if (arg == "-warn" ||
    1606                arg == "-warni" ||
    1607                arg == "-warnin" ||
    1608                arg == "-warning" ||
    1609                arg == "-warnings")
    1610         {
    1611           Me.m_warnings = true;
    1612           //      if (CmtMessage::level () > Warning)
    1613           if (CmtMessage::level () != Warning)
    1614             {
    1615               CmtMessage::set_level (Warning);
    1616               //              if (!CmtSystem::putenv ("CMTWARNING", "1"))
    1617               //                CmtMessage::error ("Cannot set `CMTWARNING' in the environment");
    1618             }
    1619           if (!Cmt::add_cmt_flag ("-warnings"))
    1620             CmtMessage::error ("Cannot add flag `-warnings'");
    16211807        }
    16221808    }
     
    16681854
    16691855  CmtSystem::cmt_string_vector uses;
     1856  cmt_vector<int> use_indexes;
    16701857  CmtSystem::cmt_string_vector packages;
    16711858  CmtSystem::cmt_string_vector versions;
    1672   CmtSystem::cmt_string_vector path_selections;
     1859  Project::ConstProjectPtrVector path_selections;
     1860  //  CmtSystem::cmt_string_vector path_selections;
     1861  Project::ConstProjectPtrVector path_exclusions;
    16731862  CmtSystem::cmt_string_vector selections;
    16741863  CmtSystem::cmt_string_vector exclusions;
     
    16771866  bool is_cmt = false;
    16781867  int first = 0;
    1679   int i;
    16801868  bool ignore_errors = false;
    16811869  bool all_packages = false;
    1682 
     1870  int depth (1);
    16831871  bool local = true;
    1684 
    1685   for (i = 0; i < ap.arguments.size (); i++)
     1872  bool global (false);
     1873
     1874  for (int i = 0; i < ap.arguments.size (); i++)
    16861875    {
    16871876      const cmt_string& w = ap.arguments[i];
     
    16991888            {
    17001889              local = false;
     1890              global = false;
    17011891
    17021892              cmt_string depth_str;
    1703               int depth_value = 0;
     1893              int depth_value;
    17041894                         
    17051895              w.substr (7, depth_str);
    1706               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
    1707                   (depth_value < 1))
    1708                 {
     1896              int n = sscanf (depth_str.c_str (), "%d", &depth_value);
     1897              cmt_string msg;
     1898              switch (n)
     1899                {
     1900                case EOF:
     1901                  msg = "Cannot read `depth' value `";
     1902                  msg += depth_str;
     1903                  msg += cmt_string ("'");
     1904                  if (errno)
     1905                    msg += cmt_string (strerror (errno));
     1906                  CmtError::set (CmtError::system_error, msg);
     1907                  return;
     1908                  break;
     1909                case 0:
     1910                  msg = "Invalid `depth' value `";
     1911                  msg += depth_str;
     1912                  msg += cmt_string ("'");
     1913                  CmtError::set (CmtError::syntax_error, msg);
     1914                  return;
     1915                  break;
     1916                case 1:
     1917                  if (depth_value < -1)
     1918                    {
     1919                      char num[32]; sprintf (num, "%lu", -depth_value);
     1920                      msg = "Invalid `depth' value `-";
     1921                      msg += num;
     1922                      msg += cmt_string ("'");
     1923                      CmtError::set (CmtError::syntax_error, msg);
     1924                      return;
     1925                    }
     1926                  depth = depth_value;
     1927                  //cerr << "depth: " << depth << endl;
     1928                  break;
     1929                default:
     1930                  break;
     1931                }
     1932//               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
     1933//                   (depth_value < 1))
     1934//                {
    17091935                  // Syntax error
    17101936                  //  We shall restrict to packages found within
     
    17121938                  //  If CMTPATH is empty, nothing is selected.
    17131939                  // depth=1 is equivalent to local
    1714                 }
    1715 
    1716               Project::fill_selection (depth_value, path_selections);
     1940//                }
     1941
     1942//            Project::fill_selection (depth_value, path_selections);
    17171943            }
    17181944          else if (w.substr (0, 9) == "-exclude=")
     
    17381964          else if (w.substr (0, 7) == "-global")
    17391965            {
    1740               path_selections.clear ();
    1741 
     1966              //path_selections.clear ();
     1967              global = true;
    17421968              local = false;
    17431969            }
     
    17451971            {
    17461972              local = true;
     1973              global = false;
    17471974            }
    17481975          else if (w.substr (0, 8) == "-select=")
     
    17872014    }
    17882015
    1789   if (local)
    1790     {
    1791       Project::fill_selection (1, path_selections);
     2016  const Project* p_cur (Project::get_current ());
     2017  if (global)
     2018    {
     2019      Project::fill_exclusion (path_exclusions);
     2020    }
     2021  else if (local)
     2022    {
     2023      if (p_cur)
     2024        Project::fill_selection (1, path_selections);
     2025      else
     2026        path_selections.push_back (0); // means that we want Use::current ()
     2027      //        path_selections.push_back ((Use::current ()).get_realpath ());
     2028    }
     2029  else
     2030    {
     2031      if (!p_cur
     2032          && depth != 0
     2033          && depth != -1)
     2034        path_selections.push_back (0); // means that we want Use::current ()
     2035//      path_selections.push_back ((Use::current ()).get_realpath ());
     2036      Project::fill_selection (depth, path_selections);
     2037      /*
     2038      cerr << "depth: " << depth << endl;
     2039      for (int j = 0; j < path_selections.size (); j++)
     2040        {
     2041          const Project* sp = path_selections[j];
     2042          cerr << "path_selections: " << (sp ? sp->get_cmtpath () : "current use") << endl;
     2043        }
     2044      */
    17922045    }
    17932046
     
    18002053  //if (command.substr (0, 3) == "cmt") is_cmt = true;
    18012054
    1802   cmt_string curuse = CmtSystem::pwd ();
     2055  //cmt_string curuse = CmtSystem::pwd ();
    18032056  if (all_packages)
    18042057    {
     
    18062059      PathScanner scanner;
    18072060      Project::scan_paths (scanner, selector);
     2061      return;
    18082062    }
    18092063  else
    18102064    {
    1811       for (i = Uses.size () - 1; i >= 0; i--)
     2065      for (int i = Uses.size () - 1; i >= 0; i--)
    18122066        {
    18132067          Use* use = Uses[i];
     
    18152069          if (use->discarded) continue;
    18162070          if (use->m_hidden) continue;
    1817 
    18182071          if (!use->located ())
    18192072            {
    1820               CmtMessage::warning ("package " + use->get_package_name ()
    1821                                    + " " + use->version + " " + use->path
    1822                                    + " not found");
    1823               /*
    1824               if (!Me.m_quiet)
    1825                 {
    1826                   cerr << "#CMT> package " << use->get_package_name () <<
    1827                     " " << use->version << " " << use->path <<
    1828                     " not found" <<
    1829                     endl;
    1830                 }
    1831               */
     2073              CmtMessage::warning
     2074                (CmtError::get_error_name (CmtError::package_not_found)
     2075                 + ": " + use->get_info ());
     2076              continue;
    18322077            }
    1833           else
    1834             {
    1835               if (use->get_package_name () != "CMT")
    1836                 {
    1837                   cmt_string& s = uses.add ();
    1838 
    1839                   use->get_full_path (s);
    1840 
    1841                   s += CmtSystem::file_separator ();
    1842                   if (use->style == mgr_style) s += "mgr";
    1843                   else s += "cmt";
    1844 
    1845                   cmt_string& v = versions.add ();
    1846                   v = use->version;
    1847 
    1848                   cmt_string& p = packages.add ();
    1849                   p = use->get_package_name ();
    1850                 }
    1851             }
    1852         }
     2078          if (use->get_package_name () == "CMT") continue;
     2079
     2080          cmt_string& s = uses.add ();
     2081          use->get_full_path (s);
     2082          switch (use->style)
     2083            {
     2084            case cmt_style:
     2085              s += CmtSystem::file_separator ();
     2086              s += "cmt";
     2087              break;
     2088            case mgr_style:
     2089              s += CmtSystem::file_separator ();
     2090              s += "mgr";
     2091              break;
     2092            default:
     2093              break;
     2094            }
     2095//                   if (use->style == mgr_style) s += "mgr";
     2096//                   else s += "cmt";
     2097
     2098          cmt_string& v = versions.add ();
     2099          v = use->version;
     2100         
     2101          cmt_string& p = packages.add ();
     2102          p = use->get_package_name ();
     2103         
     2104          int& use_index = use_indexes.add ();
     2105          use_index = i;
     2106        }
    18532107         
    18542108      {
     2109        Use* use = &(Use::current ());
     2110       
    18552111        cmt_string& s = uses.add ();
     2112        use->get_full_path (s);
     2113        switch (use->style)
     2114          {
     2115          case cmt_style:
     2116            s += CmtSystem::file_separator ();
     2117            s += "cmt";
     2118            break;
     2119          case mgr_style:
     2120            s += CmtSystem::file_separator ();
     2121            s += "mgr";
     2122            break;
     2123          default:
     2124            break;
     2125          }
     2126//         if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
     2127//           {
     2128//             s = CmtSystem::pwd ();
     2129//           }
     2130//         else
     2131//           {
     2132//             use->get_full_path (s);
     2133
     2134//             s += CmtSystem::file_separator ();
    18562135                 
    1857         Use* use = &(Use::current ());
    1858 
    1859         if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
    1860           {
    1861             s = CmtSystem::pwd ();
    1862           }
    1863         else
    1864           {
    1865             use->get_full_path (s);
    1866 
    1867             s += CmtSystem::file_separator ();
    1868                  
    1869             if (use->style == mgr_style) s += "mgr";
    1870             else s += "cmt";
    1871           }
    1872 
    1873         curuse = s;
     2136//             if (use->style == mgr_style) s += "mgr";
     2137//             else s += "cmt";
     2138//           }
     2139        //curuse = s;
    18742140
    18752141        cmt_string& v = versions.add ();
     
    18782144        cmt_string& p = packages.add ();
    18792145        p = use->get_package_name ();
     2146         
     2147        int& use_index = use_indexes.add ();
     2148        use_index = -1;
    18802149      }
    18812150    }
     
    18912160    CmtSystem::putenv ("CMTBCAST", "");
    18922161
    1893   for (i = 0; i < uses.size (); i++)
     2162  for (int i = 0; i < uses.size (); i++)
    18942163    {
    18952164      const cmt_string& s = uses[i];
    18962165      const cmt_string& v = versions[i];
    18972166      const cmt_string& p = packages[i];
     2167      const int use_index = use_indexes[i];
     2168
     2169      const Use* use = use_index >= 0 ? Uses[use_index] : &(Use::current ());
     2170      const Project* up = use->get_project ();
     2171
    18982172      cmt_string cmtpath;
    18992173
    19002174      bool ok = true;
    1901       bool selected = true;
     2175      bool selected = global ? true : false;
    19022176      bool excluded = false;
    19032177
    1904       /**
    1905          Ensure that the current package is not skipped
    1906          due to symlinks in the paths
    1907        */
    1908       //      if (path_selections.size () > 0)
    1909       if (path_selections.size () > 0 && s != curuse)
     2178      ok = selected;
     2179      if (path_selections.size () > 0)
    19102180        {
    19112181          selected = false;
    1912 
    19132182          for (int j = 0; j < path_selections.size (); j++)
    19142183            {
    1915               const cmt_string& sel = path_selections[j];
    1916              
    1917               if (s.find (sel) != cmt_string::npos)
    1918                 {
    1919                   cmtpath = sel;
    1920                   selected = true;
    1921                   break;
    1922                 }
    1923             }
    1924 
     2184              const Project* sp = path_selections[j];
     2185              if (sp)
     2186                {
     2187                  if (up)
     2188                    {
     2189                      if (up == sp)
     2190                        {
     2191                          cmtpath = sp->get_cmtpath ();
     2192                          selected = true;
     2193                          break;
     2194                        }
     2195                    }
     2196                  else
     2197                    {
     2198                      if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2199                        {
     2200                          cmtpath = sp->get_cmtpath ();
     2201                          selected = true;
     2202                          break;
     2203                        }
     2204                    }
     2205                }
     2206              else if (use == &(Use::current ()))
     2207                {
     2208                  // means that we want Use::current ()
     2209                  // cmtpath = sp->get_cmtpath ();
     2210                  if (up)
     2211                    cmtpath = up->get_cmtpath ();
     2212                  else
     2213                    cmtpath = "";
     2214                  selected = true;
     2215                  break;
     2216                }
     2217              // const cmt_string& sel = path_selections[j];
     2218              // if (s.find (sel) != cmt_string::npos)
     2219//                 {
     2220//                cmtpath = sel;
     2221//                   selected = true;
     2222//                   break;
     2223//                 }
     2224            }
    19252225          ok = selected;
    19262226        }
     2227      else if (up)
     2228        cmtpath = up->get_cmtpath ();
    19272229
    19282230      if (ok)
     
    19602262        }
    19612263
    1962 
    19632264      if (ok)
    19642265        {
     
    19742275                  break;
    19752276                }
     2277            }
     2278
     2279          if (excluded) ok = false;
     2280        }
     2281
     2282      if (ok)
     2283        {
     2284          excluded = false;
     2285          for (int j = 0; j < path_exclusions.size (); j++)
     2286            {
     2287              const Project* sp = path_exclusions[j];
     2288              if (up)
     2289                {
     2290                  if (up == sp)
     2291                    {
     2292                      excluded = true;
     2293                      break;
     2294                    }
     2295                }
     2296              else
     2297                {
     2298                  if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2299                    {
     2300                      excluded = true;
     2301                      break;
     2302                    }
     2303                }
    19762304            }
    19772305
     
    20212349        }
    20222350
     2351      /*
    20232352      if (cmtpath == "")
    20242353        {
     
    20262355          cmtpath = Project::find_in_cmt_paths (sel);
    20272356        }
     2357      */
    20282358
    20292359      cmt_string cmd = command;
     
    20412371      static const cmt_string empty_string;
    20422372      static const cmt_string fs = CmtSystem::file_separator ();
    2043       cmt_string offset = s;
    2044       offset.replace (cmtpath, empty_string);
    2045       if (offset[0] == CmtSystem::file_separator ())
    2046         {
    2047           offset.replace (fs, empty_string);
    2048         }
    2049       CmtSystem::dirname (offset, offset);
    2050 
    2051       cmt_string n;
    2052       CmtSystem::basename (offset, n);
    2053       if (n == p)
    2054         {
     2373      cmt_string offset;
     2374      if (cmtpath.size ())
     2375        {
     2376          offset = s;
     2377          offset.replace (cmtpath, empty_string);
     2378          if (offset[0] == CmtSystem::file_separator ())
     2379            {
     2380              offset.replace (fs, empty_string);
     2381            }
    20552382          CmtSystem::dirname (offset, offset);
     2383         
     2384          cmt_string n;
     2385          CmtSystem::basename (offset, n);
     2386          if (n == p)
     2387            {
     2388              CmtSystem::dirname (offset, offset);
     2389            }
     2390          else
     2391            {
     2392              CmtSystem::dirname (offset, offset);
     2393              CmtSystem::dirname (offset, offset);
     2394            }
    20562395        }
    20572396      else
    20582397        {
    2059           CmtSystem::dirname (offset, offset);
    2060           CmtSystem::dirname (offset, offset);
    2061         }
    2062 
     2398          offset = use->real_path;
     2399        }
    20632400      cmd.replace_all (offset_template, offset);
    20642401
     
    20672404    {
    20682405      cout << "#--------------------------------------------------------------" << endl;
    2069       cout << "# Now trying [" << cmd << "] in " << s << " (" << i+1 << "/" << uses.size ()
     2406      cout << "# " << p << " " << v << " " << offset << ": Now trying [" << cmd << "] in " << s << " (" << i+1 << "/" << uses.size ()
    20702407           << ")" << endl;
    20712408      cout << "#--------------------------------------------------------------" << endl;
     
    29043241    }
    29053242
    2906   static CmtSystem::cmt_string_vector tags;
     3243  //  static CmtSystem::cmt_string_vector tags;
    29073244
    29083245  if (action_build_constituents_config != get_action ())
    2909     CmtSystem::split (Me.m_extra_tags, " \t,", tags);
    2910 
    2911   for (int i = 0; i < tags.size (); i++)
    2912     {
    2913       const cmt_string& t = tags[i];
    2914 
    2915       tag = Tag::find (t);
    2916       if (tag == 0) continue;
    2917 
    2918       if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
    2919         {
    2920           CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
    2921           //      cerr << "#CMT> The tag " << t << " is not used in any tag expression. Please check spelling" << endl;
    2922         }
    2923     }
    2924 
    2925   Symbol::check_all_paths ();
     3246    {
     3247    //    CmtSystem::split (Me.m_extra_tags, " \t,", tags);
     3248
     3249    //  for (int i = 0; i < tags.size (); i++)
     3250      //    {
     3251      //      const cmt_string& t = tags[i];
     3252      for (int i = 0; i < Me.m_extra_tags.size (); i++)
     3253        {
     3254          const cmt_string& t = Me.m_extra_tags[i];
     3255          tag = Tag::find (t);
     3256          if (tag == 0) continue;
     3257          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3258            {
     3259              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3260            }
     3261        }
     3262      for (int i = 0; i < Me.m_tags.size (); i++)
     3263        {
     3264          const cmt_string& t = Me.m_tags[i];
     3265          tag = Tag::find (t);
     3266          if (tag == 0) continue;
     3267          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3268            {
     3269              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3270            }
     3271        }
     3272      for (int i = 0; i < Me.m_tags_add.size (); i++)
     3273        {
     3274          const cmt_string& t = Me.m_tags_add[i];
     3275          tag = Tag::find (t);
     3276          if (tag == 0) continue;
     3277          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3278            {
     3279              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3280            }
     3281        }
     3282    }
     3283
     3284  if (action_setup != get_action () ||
     3285      Requirements == ap.mode)
     3286    // PathBuilder::filter_path_value is called
     3287    // for each path in Symbol::print
     3288    Symbol::check_all_paths ();
    29263289
    29273290  env = CmtSystem::getenv ("CMTSITE");
     
    29403303    {
    29413304      CmtMessage::warning ("The CMTSITE value " + env + " is not used in any tag expression. Please check spelling");
    2942       //      cerr << "#CMT> The CMTSITE value " << env << " is not used in any tag expression. Please check spelling" << endl;
    29433305    }
    29443306
     
    43234685      break;
    43244686    case Requirements :
     4687      /*
    43254688      CmtSystem::cmt_string_vector flags;
    43264689      get_cmt_flags (flags);
    43274690      cout << "\n# CMTFLAGS: -without_cmt";
     4691      cout << " -without_projects" ;
    43284692      for (int i = 0; i < flags.size (); i++)
    43294693        {
     
    43324696          else if (flags[i] == "-with_cmt")
    43334697            cout << " -without_cmt";
     4698          else if (flags[i] == "-without_projects")
     4699            cout << " -with_projects";
     4700          else if (flags[i] == "-with_projects")
     4701            cout << " -without_projects";
    43344702          else
    43354703            cout << " " << flags[i];
    43364704        }
    43374705      cout << endl;
     4706      */
    43384707      break;
    4339     }
    4340   print (ap.mode);
     4708    default:
     4709      break;
     4710    }
     4711
     4712  ostringstream os;
     4713  ostringstream oh;
     4714  bool reset (false);
     4715  CmtSystem::cmt_string_vector flags;
     4716  cmt_string strip_path_flag;
     4717  bool strip_path (false);
     4718
     4719  bool strip_saved (get_strip_path ());
     4720  bool access_saved (Cmt::get_env_access ());
     4721
     4722  switch (ap.mode)
     4723    {
     4724    case Requirements :
     4725
     4726      get_cmt_flags (flags);
     4727      for (int i = 0; i < flags.size (); i++)
     4728        {
     4729          if (flags[i] == "-no_strip_path")
     4730            strip_path_flag = "-no_strip_path";
     4731          else if (flags[i] == "-strip_path")
     4732            strip_path_flag = "-strip_path";
     4733        }
     4734      if (strip_path_flag != "-no_strip_path" &&
     4735          !get_strip_path ())
     4736        reset = Symbol::set_strip_path (true);
     4737
     4738      if (get_strip_path () || reset)
     4739        strip_path = true;
     4740      else
     4741        strip_path = false;
     4742
     4743      Cmt::set_env_access (false);
     4744
     4745      print (ap.mode, os);
     4746
     4747      if (CmtError::get_last_error_code () == CmtError::warning &&
     4748          (get_strip_path () || reset))
     4749        {
     4750          reset = Symbol::set_strip_path (false);
     4751          if (reset)
     4752            {
     4753              strip_path = false;
     4754
     4755              CmtError::print ();
     4756              CmtError::clear ();
     4757
     4758              if (Cmt::get_debug ())
     4759                {
     4760                  cerr << "|Cmt::do_setup> Failure with:\n" << os.str ()
     4761                       << "|Cmt::do_setup> Trying again." << endl;
     4762                }
     4763
     4764              // Try again
     4765              os.str ("");
     4766              print (ap.mode, os);
     4767            }
     4768        }
     4769
     4770      if (reset) Symbol::set_strip_path (strip_saved);
     4771      Cmt::set_env_access (access_saved);
     4772
     4773      //get_cmt_flags (flags);
     4774      oh << "\n# CMTFLAGS:"
     4775        " -without_cmt"
     4776        " -without_projects"
     4777        //" -strip_path"
     4778        ;
     4779      for (int i = 0; i < flags.size (); i++)
     4780        {
     4781          if (flags[i] == "-without_cmt")
     4782            oh << " -with_cmt";
     4783          else if (flags[i] == "-with_cmt")
     4784            oh << " -without_cmt";
     4785          else if (flags[i] == "-without_projects")
     4786            oh << " -with_projects";
     4787          else if (flags[i] == "-with_projects")
     4788            oh << " -without_projects";
     4789          /*
     4790          else if (flags[i] == "-no_strip_path")
     4791            oh << " -strip_path";
     4792          else if (flags[i] == "-strip_path")
     4793            oh << " -no_strip_path";
     4794          */
     4795          else if (flags[i] == "-no_strip_path" ||
     4796                   flags[i] == "-strip_path")
     4797            continue;
     4798          else
     4799            oh << " " << flags[i];
     4800        }
     4801      //if (reset) oh << " -strip_path";
     4802      if (strip_path)
     4803        oh << " -no_strip_path";
     4804      else
     4805        oh << " -strip_path";
     4806      oh << endl;
     4807
     4808      cout << oh.str ();
     4809      cout << os.str ();
     4810
     4811      break;
     4812
     4813    default:
     4814
     4815      print (ap.mode);
     4816
     4817      break;
     4818    }
     4819
    43414820  switch (ap.mode)
    43424821    {
     
    44764955
    44774956  Use& use = Use::current();   
     4957  /*
    44784958  use.get_cmtpath_and_offset (cmtpath, offset);
    44794959
    44804960  Project* p = Project::find_by_cmtpath (cmtpath);
    4481 
    4482   cout << p->get_author () << endl;
     4961  */
     4962  if (const Project* p = use.get_project ())
     4963    cout << p->get_author () << endl;
    44834964}
    44844965
     
    45034984  ClientCollector collector (package, version);
    45044985
     4986  /*
    45054987  clear     ();
    45064988  //  configure ();
    45074989  configure (ap);
     4990  */
    45084991
    45094992  cout << "# ----------- Clients of " << package
     
    51645647
    51655648//----------------------------------------------------------
     5649/*
    51665650ActionType Cmt::get_action ()
    51675651{
    51685652  return (Me.m_action);
    51695653}
    5170 
     5654*/
    51715655/*
    51725656  const CmtSystem::cmt_string_vector& Cmt::get_cmt_path ()
     
    51855669  }
    51865670*/
    5187 
     5671 /*
    51885672const cmt_string& Cmt::get_cmt_home ()
    51895673{
     
    52055689  return (Me.m_current_dir);
    52065690}
    5207 
     5691*/
    52085692const cmt_string Cmt::get_current_dir_real ()
    52095693{
     
    52135697  return (Me.m_current_dir);
    52145698}
    5215 
     5699/*
    52165700const cmt_string& Cmt::get_current_package ()
    52175701{
    52185702  return (Me.m_current_package);
    52195703}
    5220 
     5704*/
    52215705const cmt_string& Cmt::get_current_path ()
    52225706{
     
    52335717  return (Me.m_current_offset);
    52345718}
    5235 
     5719/*
    52365720AccessMode Cmt::get_current_access ()
    52375721{
     
    52485732  return (Me.m_current_style);
    52495733}
    5250 
     5734*/
    52515735const cmt_string& Cmt::get_current_version ()
    52525736{
    52535737  return (Me.m_current_version);
    52545738}
    5255 
     5739/*
    52565740const cmt_string& Cmt::get_current_target ()
    52575741{
    52585742  return (Me.m_current_target);
    52595743}
    5260 
     5744*/
     5745/*
     5746const CmtSystem::cmt_string_vector& Cmt::get_tags_remove ()
     5747{
     5748  return (Me.m_tags_remove);
     5749}
     5750*/
     5751 /*
    52615752bool Cmt::get_debug ()
    52625753{
     
    52835774  return (Me.m_recursive);
    52845775}
    5285 
     5776 */
    52865777CmtScopeFilteringMode Cmt::get_scope_filtering_mode ()
    52875778{
     
    52975788
    52985789//----------------------------------------------------------
     5790/*
    52995791bool Cmt::get_all_sets_done ()
    53005792{
    53015793  return (Me.m_all_sets_done);
    53025794}
    5303 
     5795*/
    53045796//----------------------------------------------------------
    53055797void Cmt::get_cmt_flags (CmtSystem::cmt_string_vector& flags)
     
    54215913void Cmt::guess_current_project ()
    54225914{
     5915  if (!m_cmt_context.m_use_projects) return;
     5916
    54235917  Log;
    54245918
    54255919  log << "guess_current_project" << log_endl;
    54265920
    5427   cmt_string here = CmtSystem::pwd ();
     5921  //  cmt_string here = CmtSystem::pwd ();
    54285922
    54295923  Use& use = Use::current();
     
    54385932    //  if (Project::find_in_cmt_paths (Me.m_current_dir) == "")
    54395933    {
     5934      /*
    54405935      if (!CmtSystem::cd (current_path))
    54415936        {
     
    54445939          return;
    54455940        }
     5941      */
    54465942      cmt_string project_file = "cmt";
    54475943      project_file += CmtSystem::file_separator ();
    54485944      project_file += Project::get_project_file_name ();
    54495945
    5450       cmt_string pwd;
     5946      /*
     5947      cmt_string pwd (CmtSystem::pwd ());
     5948      cmt_string pwd_prev;
     5949      */
     5950      cmt_string dir_cur (current_path);
     5951      cmt_string dir_par;
     5952
     5953      cmt_string proj_file_cur;
    54515954
    54525955      for (;;)
    54535956        {
    5454           pwd = CmtSystem::pwd ();
     5957          /*
     5958          //      pwd = CmtSystem::pwd ();
    54555959          if (CmtSystem::test_file (project_file))
    54565960            {
     
    54625966              break;
    54635967            }
    5464 
    5465           log << "pwd=" << CmtSystem::pwd () << log_endl;
     5968          */
     5969          proj_file_cur = dir_cur;
     5970          proj_file_cur += CmtSystem::file_separator ();
     5971          proj_file_cur += project_file;
     5972          if (CmtSystem::test_file (proj_file_cur))
     5973            {
     5974              //this directory should become the first entry of the CMTPATH
     5975
     5976              IProjectFactory& factory = ProjectFactory::instance ();
     5977              factory.create_project ("", dir_cur, "CurrentProject", 0);
     5978
     5979              break;
     5980            }
     5981
     5982          /*
     5983          log << "pwd=" << pwd << log_endl;
    54665984         
    54675985          if (!CmtSystem::cd (".."))
     
    54715989            }
    54725990
    5473           if (CmtSystem::pwd () == pwd)
     5991          pwd_prev = pwd;
     5992          pwd = CmtSystem::pwd ();
     5993          if (pwd == pwd_prev)
     5994            //    if (CmtSystem::pwd () == pwd)
    54745995            {
    54755996              log << "Looks the same pwd..." << log_endl;
    54765997              break;
    54775998            }
    5478         }
    5479 
    5480       CmtSystem::cd (Me.m_current_dir);
    5481     }
     5999          */
     6000          log << "dir_cur=`" << dir_cur << "'" << log_endl;
     6001          CmtSystem::dirname (dir_cur, dir_par);
     6002          if (dir_par == dir_cur)
     6003            {
     6004              log << "Looks the same dir_cur..." << log_endl;
     6005              break;
     6006            }
     6007          dir_cur = dir_par;
     6008        }
     6009
     6010      //      CmtSystem::cd (Me.m_current_dir);
     6011    } // if (Project::find_in_cmt_paths (current_path) == "")
    54826012
    54836013  //cmt_string buffer = "path CMTPATH \n";
     
    54876017  //  Use& use = Use::current();
    54886018
     6019  bool autoconfigure_cmtpath_saved (Me.m_autoconfigure_cmtpath);
     6020  Me.m_autoconfigure_cmtpath = false;
    54896021  bool save_quiet = Me.m_quiet;
    54906022  Me.m_quiet = true;
     
    54936025
    54946026  Me.m_quiet = save_quiet;
    5495 
    5496   Me.m_autoconfigure_cmtpath = true;
    5497 
    5498   CmtSystem::cd (here);
     6027  Me.m_autoconfigure_cmtpath = autoconfigure_cmtpath_saved;
     6028  //  Me.m_autoconfigure_cmtpath = true;
     6029
     6030  //  CmtSystem::cd (Me.m_current_dir);
     6031  //CmtSystem::cd (here);
    54996032}
    55006033
     
    59666499              fprintf (f, "endif\n");
    59676500              fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
    5968               fprintf (f, "set cmt%stempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n", mangled_package.c_str ());
     6501              fprintf (f, "set cmt%stempfile=`${CMTROOT}/${CMTBIN}/cmt.exe -quiet build temporary_name`\n", mangled_package.c_str ());
    59696502              fprintf (f, "if $status != 0 then\n  set cmt%stempfile=/tmp/cmt.$$\nendif\n", mangled_package.c_str ());
    5970               //fprintf (f, "${CMTROOT}/mgr/cmt setup -%s "
    5971               fprintf (f, "${CMTROOT}/mgr/cmt %s -%s "
     6503              fprintf (f, "${CMTROOT}/${CMTBIN}/cmt.exe %s -%s "
    59726504                       "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\n",
    59736505                       action.c_str (),
     
    59806512              fprintf (f,
    59816513                       "if ( $status != 0 ) then\n"
    5982                        "  echo \"${CMTROOT}/mgr/cmt %s -%s "
     6514                       "  echo \"${CMTROOT}/${CMTBIN}/cmt.exe %s -%s "
    59836515                       "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\"\n"
    59846516                       "  set cmt%sstatus=2\n"
     
    60266558              fprintf (f, "fi\n");
    60276559              fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
    6028               fprintf (f, "cmt%stempfile=`${CMTROOT}/mgr/cmt -quiet build temporary_name`\n", mangled_package.c_str ());
     6560              fprintf (f, "cmt%stempfile=`${CMTROOT}/${CMTBIN}/cmt.exe -quiet build temporary_name`\n", mangled_package.c_str ());
    60296561              fprintf (f, "if test ! $? = 0 ; then cmt%stempfile=/tmp/cmt.$$; fi\n", mangled_package.c_str ());
    6030               //fprintf (f, "${CMTROOT}/mgr/cmt setup -%s "
    6031               fprintf (f, "${CMTROOT}/mgr/cmt %s -%s "
     6562              fprintf (f, "${CMTROOT}/${CMTBIN}/cmt.exe %s -%s "
    60326563                       "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\n",
    60336564                       action.c_str (),
     
    60406571              fprintf (f,
    60416572                       "if test $? != 0 ; then\n"
    6042                        "  echo >&2 \"${CMTROOT}/mgr/cmt %s -%s "
     6573                       "  echo >&2 \"${CMTROOT}/${CMTBIN}/cmt.exe %s -%s "
    60436574                       "-pack=%s -version=%s -path=%s %s $* >${cmt%stempfile}\"\n"
    60446575                       "  cmt%sstatus=2\n"
     
    60746605          else if (mode[i] == Bat)
    60756606            {
    6076               //fprintf (f, "rem Setting %s %s in %%~d0%%~p0\n",
    60776607              fprintf (f, "rem %s %s %s in %%~d0%%~p0\n",
    60786608                       action.c_str (),
     
    64096939
    64106940  /**
    6411    * See reach_current_package for an explanation of this call
     6941   * See apply_globals for an explanation of this call
    64126942   */
    64136943  Pattern::apply_all_globals ();
     
    64446974  Me.m_action = action_none;
    64456975
    6446   restore_all_tags (0);
     6976  //  restore_all_tags (0);
    64476977
    64486978#ifdef WIN32
     
    64817011int Cmt::parser (int argc, char* argv[])
    64827012{
     7013  // save CMTFLAGS
     7014  cmt_string cmtflags (get_cmt_flags ());
     7015
     7016  clear ();
     7017  Me.initialize ();
     7018
    64837019  ArgParser ap (Me);
    64847020 
     
    64937029    }
    64947030
    6495   // save CMTFLAGS
    6496   cmt_string cmtflags (get_cmt_flags ());
    6497 
    6498   clear ();
     7031  //  clear ();
     7032
     7033  //  Me.clear ();
     7034
     7035  parse_arguments (ap);
     7036  // Copy ap.mode into cmt_context member/instance
     7037  set_print_mode (ap.mode);
    64997038
    65007039  //  configure ();
    6501   configure (ap);
    6502 
    6503   CmtError::clear ();
     7040  switch (Me.m_action)
     7041    {
     7042    case action_none :
     7043    case action_build_temporary_name :
     7044    case action_help :
     7045      break;
     7046    default:
     7047      configure (ap);
     7048      break;
     7049    }
     7050 
     7051  //  CmtError::clear ();
    65047052
    65057053  /*
    6506     Set private if positioned inside the package
     7054    Set DeveloperMode if positioned inside the package
    65077055    (which is detected since we were able to retreive the
    65087056    Version, Package and Path)
    65097057  */
    65107058
     7059  if (!Use::current().located ())
     7060  /*
    65117061  if ((Me.m_current_path.size () == 0) ||
    65127062      (Me.m_current_package.size () == 0) ||
    65137063      (Me.m_current_version.size () == 0))
     7064  */
    65147065    {
    65157066      Me.m_current_access = UserMode;
     
    65207071    }
    65217072 
    6522   parse_arguments (ap);
     7073  //  parse_arguments (ap);
    65237074 
    65247075  if (ap.help_action == action_help)
     
    68267377  switch (Me.m_action)
    68277378    {
    6828     case action_none :
     7379      //case action_none :
    68297380    case action_awk :
    68307381    case action_broadcast :
     
    69297480        Me.m_warnings = false;
    69307481        if (strlen (ap.extra_file.c_str ()) == 0)
    6931           reach_current_package ();
     7482          use_current_package ();
     7483        //        reach_current_package ();
    69327484        else
    69337485          use_extra_file (ap.extra_file);
     
    69357487        if (strlen (ap.extra_line.c_str ()) > 0)
    69367488          SyntaxParser::parse_requirements_text (ap.extra_line, "extra statement(s)", (Use*) 0);
     7489        apply_globals ();
    69377490        Me.m_warnings = w;
    6938         //if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, &(Use::current ()));
    69397491      }
    69407492      break;
     
    69527504  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
    69537505    uses.push_back (use);
    6954   uses.push_back (&(Use::current()));
     7506  use = &(Use::current());
     7507  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
     7508    uses.push_back (use);
     7509  //  uses.push_back (&(Use::current()));
    69557510  use = Use::find (CmtSystem::get_user_context_package ());
    69567511  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
     
    74247979 * joined with semi-colons to form one shell command.
    74257980 */
    7426 void Cmt::print (PrintMode mode)
     7981void Cmt::print (PrintMode mode, ostream& out)
    74277982{
    74287983  Use::UsePtrVector& Uses = Use::get_ordered_uses ();
     
    74528007  //
    74538008
     8009  /*
    74548010  {
    74558011    CmtSystem::cmt_string_vector words;
     
    74778033      }
    74788034  }
    7479 
     8035  */
    74808036  if (mode == Requirements)
    74818037    {
     
    74878043          if (tag != 0)
    74888044            {
    7489               tag->show (true, cout, "apply_tag ");
     8045              tag->show (true, out, "apply_tag ");
    74908046            }
    74918047        }
     
    75088064          if (use.m_hidden) continue;
    75098065         
    7510           print_context (use, mode, tag);
    7511         }
    7512     }
    7513 
    7514   print_context (Use::current (), mode, tag);
     8066          print_context (use, mode, tag, out);
     8067        }
     8068    }
     8069
     8070  print_context (Use::current (), mode, tag, out);
    75158071
    75168072  if (Me.m_debug)
     
    75198075    }
    75208076
    7521   Symbol::all_print (mode);
     8077  Symbol::all_print (mode, out);
    75228078  // Script::all_print (mode);
    75238079
     
    75328088      break;
    75338089    default :
    7534   cout << endl;
     8090      out << endl;
    75358091      break;
    75368092    }
     
    76388194
    76398195//----------------------------------------------------------
    7640 void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag)
     8196void Cmt::print_context (Use& use, PrintMode mode, const cmt_string& tag, ostream& out)
    76418197{
    76428198  if (use.get_package_name () == "cmt_standalone") return;
     
    76548210  switch (mode)
    76558211    {
     8212    case Xml :
    76568213    case Requirements :
    76578214      break;
     
    76708227      if (do_root)
    76718228        {
    7672           cout << "setenv " << prefix << "ROOT \"" <<
     8229          out << "setenv " << prefix << "ROOT \"" <<
    76738230            use.get_full_path () << "\"" << endl;
    76748231        }
     
    76768233      if (use.get_package_name () == "CMT")
    76778234        {
    7678           cout << "setenv CMTCONFIG " << system << endl;
     8235          out << "setenv CMTCONFIG " << system << endl;
    76798236        }
    76808237      else
     
    76828239          if (do_config)
    76838240            {
    7684               cout << "setenv " << prefix << "CONFIG \"" << tag << "\"" << endl;
     8241              out << "setenv " << prefix << "CONFIG \"" << tag << "\"" << endl;
    76858242            }
    76868243        }
     
    76908247      if (do_root)
    76918248        {
    7692           cout << prefix << "ROOT=\"" <<
     8249          out << prefix << "ROOT=\"" <<
    76938250            use.get_full_path () << "\"; export " <<
    76948251            prefix << "ROOT" << endl;
     
    76978254      if (use.get_package_name () == "CMT")
    76988255        {
    7699           cout << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;
     8256          out << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;
    77008257        }
    77018258      else
     
    77038260          if (do_config)
    77048261            {
    7705               cout << prefix << "CONFIG=\"" <<
     8262              out << prefix << "CONFIG=\"" <<
    77068263                tag << "\"; export " <<
    77078264                prefix << "CONFIG" << endl;
     
    77138270      if (do_root)
    77148271        {
    7715           cout << "set " << prefix << "ROOT=" <<
     8272          out << "set " << prefix << "ROOT=" <<
    77168273            CmtSystem::quote (use.get_full_path (), " \t") << endl;
    77178274        }
     
    77198276      if (use.get_package_name () == "CMT")
    77208277        {
    7721           cout << "set CMTCONFIG=" << system << endl;
     8278          out << "set CMTCONFIG=" << system << endl;
    77228279        }
    77238280      else
     
    77258282          if (do_config)
    77268283            {
    7727               cout << "set " << prefix << "CONFIG=" << CmtSystem::quote (tag, " \t") << endl;
     8284              out << "set " << prefix << "CONFIG=" << CmtSystem::quote (tag, " \t") << endl;
    77288285            }
    77298286        }
     
    77338290      if (do_root)
    77348291        {
    7735           cout << "<variable><name>" << prefix << "ROOT</name>"
    7736                << "<value>" << use.get_full_path () << "</value></variable>";
     8292          out << "<variable><name>" << prefix << "ROOT</name>"
     8293              << "<value>" << use.get_full_path () << "</value></variable>";
    77378294        }
    77388295
    77398296      if (use.get_package_name () == "CMT")
    77408297        {
    7741           cout << "<variable><name>CMTCONFIG</name>"
    7742                << "<value>" << system << "</value></variable>";
     8298          out << "<variable><name>CMTCONFIG</name>"
     8299              << "<value>" << system << "</value></variable>";
    77438300        }
    77448301      else
     
    77468303          if (do_config)
    77478304            {
    7748               cout << "<variable><name>" << prefix << "CONFIG</name>"
    7749                    << "<value>" << tag << "</value></variable>";
     8305              out << "<variable><name>" << prefix << "CONFIG</name>"
     8306                  << "<value>" << tag << "</value></variable>";
    77508307            }
    77518308        }
     
    77568313          use.get_package_name () != "CMT")
    77578314        {
    7758           cout << "set " << use.prefix << "ROOT " <<
     8315          out << "set " << use.prefix << "ROOT " <<
    77598316            CmtSystem::quote (use.get_full_path (), " \t") << endl;
    77608317
     
    77758332      if (use.get_package_name () == "CMT")
    77768333        {
    7777           cout << "set CMTCONFIG " << system << endl;
     8334          out << "set CMTCONFIG " << system << endl;
    77788335        }
    77798336      else
     
    77818338          if (do_config)
    77828339            {
    7783               cout << "set " << use.prefix << "CONFIG " << CmtSystem::quote (tag, " \t") << endl;
     8340              out << "set " << use.prefix << "CONFIG " << CmtSystem::quote (tag, " \t") << endl;
     8341             
     8342              cmt_string name (use.prefix + "CONFIG");
     8343              Symbol* symbol = Symbol::find (name);
     8344              if (symbol != 0)
     8345                {
     8346                  symbol->printed = true;
     8347                }
     8348              if (symbol == 0 || symbol->type != Symbol::SymbolMacro)
     8349                {
     8350                  CmtMessage::warning
     8351                    (CmtError::get_error_name (CmtError::symbol_not_found)
     8352                     + ": macro " + name);
     8353                }
    77848354            }
    77858355        }
     
    79398509
    79408510//----------------------------------------------------------
    7941 int Cmt::reach_current_package ()
     8511int Cmt::use_current_package ()
    79428512{
    79438513  Use& use = Use::current ();
     
    79468516  if (Me.m_debug)
    79478517    {
    7948       cout << "Cmt::reach_current_package> pwd = "
     8518      cout << "Cmt::use_current_package> pwd = "
    79498519           << CmtSystem::pwd ()
    79508520           << " path=" << Me.m_current_path
     
    79598529  if (Me.m_current_package == "cmt_standalone")
    79608530    {
    7961       if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     8531      if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir))
     8532//      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
    79628533        {
    79638534          if (!CmtSystem::cd (Me.m_current_path))
    79648535            {
    79658536              CmtError::set (CmtError::package_not_found,
    7966                              "ReachCurrentPackage> Cannot reach the path directory");
     8537                             "Cannot reach the path directory: "
     8538                             + Me.m_current_path);
    79678539              return (0);
    79688540            }
     
    79758547
    79768548      Me.m_current_structuring_style = without_version_directory;
     8549      use.structuring_style = Me.m_current_structuring_style;
     8550      use.change_path (Me.m_current_path, Project::get_current ());
     8551      Me.m_current_access = DeveloperMode;
    79778552    }
    79788553  else if (Me.m_current_package != "")
    79798554    {
    7980       if (!use.move_to () && !use.move_to ("", true))
    7981         //      if (!use.move_to ())
    7982         {
    7983           CmtError::set (CmtError::package_not_found,
    7984                          "ReachCurrentPackage> Cannot reach the path directory");
    7985           return (0);
    7986         }
    7987 
    7988       Me.m_current_path = use.real_path;
     8555      if (!use.located ())
     8556        {
     8557          //      if (!use.move_to () && !use.move_to ("", true))
     8558            //      if (!use.move_to ())
     8559          if (!use.move_to ())
     8560            {
     8561              if (!CmtSystem::cd (Cmt::get_current_dir ()))
     8562                {
     8563                  CmtError::set (CmtError::file_access_error,
     8564                                 Cmt::get_current_dir ()
     8565                                 + " (use_current_package)");
     8566                  return 0;
     8567                }
     8568              if (!use.move_to ("", true))
     8569                {
     8570                  CmtError::set (CmtError::package_not_found, use.get_info ());
     8571                  return 0;
     8572                }
     8573            }
     8574         
     8575          Me.m_current_path = use.real_path;
     8576          Me.m_current_access = DeveloperMode;
     8577        }
    79898578    }
    79908579  else
     
    80248613             
    80258614              CmtError::set (CmtError::package_not_found,
    8026                              "ReachCurrentPackage> Cannot reach the mgr/cmt directory");
     8615                             "Cannot reach the mgr/cmt directory: "
     8616                             + use.get_info ());
    80278617              return (0);
    80288618            }
     
    80308620      else
    80318621        Me.m_current_style = none_style;
     8622
     8623      Me.m_current_access = DeveloperMode;
    80328624
    80338625      dir = CmtSystem::pwd ();
     
    80578649      use.style   = Me.m_current_style;
    80588650      use.structuring_style = Me.m_current_structuring_style;
    8059     }
    8060 
     8651
     8652      configure_current_dir ();
     8653      build_prefix (Me.m_current_package, Me.m_current_prefix);
     8654      build_config (Me.m_current_prefix, Me.m_current_config);
     8655    }
     8656
     8657  /*
    80618658  configure_current_dir ();
    80628659  build_prefix (Me.m_current_package, Me.m_current_prefix);
    80638660  build_config (Me.m_current_prefix, Me.m_current_config);
     8661  */
    80648662
    80658663  /*
     
    80678665  */
    80688666
    8069   if (Me.m_debug) cout << "reach_current_package0> current_tag=" << Me.m_current_tag << endl;
     8667  if (Me.m_debug) cout << "use_current_package0> current_tag=" << Me.m_current_tag << endl;
    80708668
    80718669  if (Me.m_current_tag == "")
     
    80788676          Tag* tag;
    80798677
    8080           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
     8678          tag = Tag::add (env, PriorityConfig, "current package", 0);
    80818679          tag->mark (use.get_package_name ());
    80828680          //Me.m_current_tag = env;
    80838681
    8084           //if (!Me.m_quiet) cerr << "reach_current_package1> current_tag=" << Me.m_current_tag << endl;
     8682          //if (!Me.m_quiet) cerr << "use_current_package1> current_tag=" << Me.m_current_tag << endl;
    80858683
    80868684        }
     
    81008698  SyntaxParser::parse_requirements (dir, &use);
    81018699
    8102   if (Me.m_debug) cout << "reach_current_package2> current_tag=" << Me.m_current_tag << endl;
     8700  if (CmtError::has_pending_error ()) return 0;
     8701
     8702  if (Me.m_debug) cout << "use_current_package2> current_tag=" << Me.m_current_tag << endl;
     8703
     8704  return 1;
     8705}
     8706
     8707//----------------------------------------------------------
     8708int Cmt::use_extra_file (const cmt_string& file)
     8709{
     8710  if (!CmtSystem::test_file (file))
     8711    {
     8712      CmtError::set (CmtError::path_not_found, file);
     8713      return 0;
     8714    }
     8715
     8716  // (almost) Cmt::use_current_package ()
     8717  Use& use = Use::current ();
     8718  /*
     8719    Try to access the package.
     8720  */
     8721
     8722  if (Me.m_current_package == "cmt_standalone")
     8723    {
     8724      if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir))
     8725//      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     8726        {
     8727          if (!CmtSystem::cd (Me.m_current_path))
     8728            {
     8729              CmtError::set (CmtError::package_not_found,
     8730                             "Cannot reach the path directory: "
     8731                             + Me.m_current_path);
     8732              return (0);
     8733            }
     8734        }
     8735      /*
     8736      if (!CmtSystem::test_file ("requirements"))
     8737        {
     8738          return (0);
     8739        }
     8740      */
     8741      Me.m_current_structuring_style = without_version_directory;
     8742      use.structuring_style = Me.m_current_structuring_style;
     8743      use.change_path (Me.m_current_path, Project::get_current ());
     8744      Me.m_current_access = DeveloperMode;
     8745    }
     8746  else if (Me.m_current_package != "")
     8747    {
     8748      if (!use.located ())
     8749        {
     8750          //      if (!use.move_to () && !use.move_to ("", true))
     8751            //      if (!use.move_to ())
     8752          if (!use.move_to ())
     8753            {
     8754              if (!CmtSystem::cd (Cmt::get_current_dir ()))
     8755                {
     8756                  CmtError::set (CmtError::file_access_error,
     8757                                 Cmt::get_current_dir ()
     8758                                 + " (use_extra_file)");
     8759                  return 0;
     8760                }
     8761              if (!use.move_to ("", true))
     8762                {
     8763                  CmtError::set (CmtError::package_not_found, use.get_info ());
     8764                  return 0;
     8765                }
     8766            }
     8767         
     8768          Me.m_current_path = use.real_path;
     8769          Me.m_current_access = DeveloperMode;
     8770        }
     8771    }
     8772  else
     8773    {
     8774      //
     8775      // The cmt command has been given without explicit search for
     8776      // a package. Thus it is expected that we are in the context of a
     8777      // true package.
     8778      //
     8779      //  This means that there should be a requirements file visible.
     8780      //
     8781      //  If this is not true, we'll make a try into ../cmt and then
     8782      // a last try into ../mgr
     8783      //
     8784
     8785      Me.m_current_access = DeveloperMode;
     8786      //...
     8787      configure_current_dir ();
     8788      build_prefix (Me.m_current_package, Me.m_current_prefix);
     8789      build_config (Me.m_current_prefix, Me.m_current_config);
     8790    }
     8791
     8792  /*
     8793  configure_current_dir ();
     8794  build_prefix (Me.m_current_package, Me.m_current_prefix);
     8795  build_config (Me.m_current_prefix, Me.m_current_config);
     8796  */
     8797
     8798  /*
     8799    Check Tag is always set up
     8800  */
     8801
     8802  if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
     8803
     8804  if (Me.m_current_tag == "")
     8805    {
     8806      cmt_string env;
     8807
     8808      env = CmtSystem::getenv (Me.m_current_config);
     8809      if (env != "")
     8810        {
     8811          Tag* tag;
     8812
     8813          tag = Tag::add (env, PriorityConfig, "current package", 0);
     8814          tag->mark (use.get_package_name ());
     8815          //Me.m_current_tag = env;
     8816
     8817          //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
     8818
     8819        }
     8820    }
     8821
     8822  if (Me.m_debug)
     8823    {
     8824      cout << "pwd = " << CmtSystem::pwd () << endl;
     8825    }
     8826
     8827  /*
     8828    Work on the requirements file.
     8829  */
     8830
     8831  SyntaxParser::parse_requirements (file, &use);
     8832
     8833  if (CmtError::has_pending_error ()) return 0;
     8834
     8835  if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
     8836  return 1;
     8837}
     8838
     8839//----------------------------------------------------------
     8840int Cmt::apply_globals ()
     8841{
    81038842
    81048843  /**
     
    81318870  Tag::restore_tree ();
    81328871
    8133   return (1);
    8134 }
    8135 
    8136 //----------------------------------------------------------
    8137 int Cmt::use_extra_file (const cmt_string& file)
    8138 {
    8139   if (!CmtSystem::test_file (file))
    8140     {
    8141       CmtError::set (CmtError::path_not_found, file);
    8142       return 0;
    8143     }
    8144 
    8145   // (almost) Cmt::reach_current_package ()
    8146   Use& use = Use::current ();
    8147   /*
    8148     Try to access the package.
    8149   */
    8150 
    8151   if (Me.m_current_package == "cmt_standalone")
    8152     {
    8153       if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
    8154         {
    8155           if (!CmtSystem::cd (Me.m_current_path))
    8156             {
    8157               CmtError::set (CmtError::package_not_found,
    8158                              "ReachCurrentPackage> Cannot reach the path directory");
    8159               return (0);
    8160             }
    8161         }
    8162       /*
    8163       if (!CmtSystem::test_file ("requirements"))
    8164         {
    8165           return (0);
    8166         }
    8167       */
    8168       Me.m_current_structuring_style = without_version_directory;
    8169     }
    8170   else if (Me.m_current_package != "")
    8171     {
    8172       if (!use.move_to () && !use.move_to ("", true))
    8173         //      if (!use.move_to ())
    8174         {
    8175           CmtError::set (CmtError::package_not_found,
    8176                          "ReachCurrentPackage> Cannot reach the path directory");
    8177           //          return -1;
    8178           return (0);
    8179         }
    8180 
    8181       Me.m_current_path = use.real_path;
    8182     }
    8183   else
    8184     {
    8185       //
    8186       // The cmt command has been given without explicit search for
    8187       // a package. Thus it is expected that we are in the context of a
    8188       // true package.
    8189       //
    8190       //  This means that there should be a requirements file visible.
    8191       //
    8192       //  If this is not true, we'll make a try into ../cmt and then
    8193       // a last try into ../mgr
    8194       //
    8195 
    8196       //...
    8197     }
    8198 
    8199   configure_current_dir ();
    8200   build_prefix (Me.m_current_package, Me.m_current_prefix);
    8201   build_config (Me.m_current_prefix, Me.m_current_config);
    8202 
    8203   /*
    8204     Check Tag is always set up
    8205   */
    8206 
    8207   if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
    8208 
    8209   if (Me.m_current_tag == "")
    8210     {
    8211       cmt_string env;
    8212 
    8213       env = CmtSystem::getenv (Me.m_current_config);
    8214       if (env != "")
    8215         {
    8216           Tag* tag;
    8217 
    8218           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
    8219           tag->mark (use.get_package_name ());
    8220           //Me.m_current_tag = env;
    8221 
    8222           //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
    8223 
    8224         }
    8225     }
    8226 
    8227   if (Me.m_debug)
    8228     {
    8229       cout << "pwd = " << CmtSystem::pwd () << endl;
    8230     }
    8231 
    8232   /*
    8233     Work on the requirements file.
    8234   */
    8235 
    8236   SyntaxParser::parse_requirements (file, &use);
    8237 
    8238   if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
    8239 
    8240   /**
    8241    *   It would be useful to change this mechanism. Instead of
    8242    *  applying all global patterns at once to all use contexts, it
    8243    *  would be much better to apply it at the end of each
    8244    *  requirements file parsing, and only in the context the
    8245    *  appropriate Use.
    8246    *
    8247    *   This would avoid the current flaw which is that when a global
    8248    *  pattern specifies a "private" definition, it is actually
    8249    *  applied in the scope context of the Current Use and not in
    8250    *  each individual Use. Therefore the private is lost.
    8251    *
    8252    *   However, this induces problems since some pattern definitions
    8253    *  are done AFTER the use statements, which will NOT receive the
    8254    *  pattern aplications.
    8255    *
    8256    *   Therefore it is decided to leave this "bad" mechanism until
    8257    *  everybody is aware of this constraint.
    8258    *
    8259    *
    8260    */
    8261   Pattern::apply_all_globals ();
    8262 
    8263   /*
    8264     Select all possible tags
    8265   */
    8266 
    8267   Tag::restore_tree ();
    8268 
    8269   return (1);
     8872  if (CmtError::has_pending_error ()) return 0;
     8873
     8874  return 1;
    82708875}
    82718876
     
    967610281
    967710282//----------------------------------------------------------
     10283/*
    967810284void Cmt::set_current_access (AccessMode mode)
    967910285{
     
    969210298  Me.m_scope_filtering_mode = mode;
    969310299}
    9694 
     10300*/
    969510301//----------------------------------------------------------
    969610302void Cmt::set_standard_macros ()
     
    983610442  builder.fill_for_constituent_macros ();
    983710443}
    9838 
     10444/*
    983910445void Cmt::set_all_sets_done ()
    984010446{
     
    984610452  Me.m_all_sets_done = false;
    984710453}
    9848 
     10454*/
    984910455//----------------------------------------------------------
    985010456void Cmt::use_cmt ()
     
    990510511  if (CmtSystem::test_file (f))
    990610512    {
    9907       use->m_located = true;
    9908     }
    9909   SyntaxParser::parse_requirements (f, use);
     10513      use->style = none_style;
     10514      use->structuring_style = without_version_directory;
     10515
     10516      if (name == CmtSystem::get_home_package () ||
     10517          name == CmtSystem::get_user_context_package ())
     10518        {
     10519          const Project::ProjectPtrVector& Ordered = Project::ordered_projects ();
     10520          if (0 == Ordered.size ())
     10521            {
     10522              if (m_cmt_context.m_use_projects)
     10523                {
     10524                  CmtError::set(CmtError::configuration_error,
     10525                                "No such ordered project: " + use->get_info ());
     10526                  return;
     10527                }
     10528              else
     10529                {
     10530                  use->change_path (path);
     10531                }
     10532            }
     10533          else
     10534            {
     10535              if (name == CmtSystem::get_home_package ())
     10536                use->change_path (path, Ordered[Ordered.size () - 1]);
     10537              else if (name == CmtSystem::get_user_context_package ())
     10538                use->change_path (path, Ordered[0]);
     10539            }
     10540        }
     10541      else
     10542        {
     10543          CmtMessage::verbose
     10544            (CmtError::get_error_name (CmtError::configuration_error)
     10545             + ": Unknown special use: " + use->get_info ());
     10546          use->change_path (path);
     10547        }
     10548      //      use->m_located = true;
     10549      SyntaxParser::parse_requirements (f, use);
     10550    }
     10551  else
     10552    {
     10553      use->discard ();
     10554    }
    991010555
    991110556  Me.m_recursive = recursive_copy;
     
    992210567    {
    992310568      const cmt_string& s = v[i];
    9924       if (s == "") continue;
     10569      if (s.size () == 0) continue;
    992510570
    992610571      if (result.size () != 0) result += separator;
    992710572      //if (i > 0) result += separator;
    9928       result += v[i];
     10573      result += s;
    992910574    }
    993010575}
  • CMT/v1r25-branch/source/cmt_parser.h

    r612 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_pattern.cxx

    r607 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    771772      replacement.replace_all ("<version>", context_use->version.c_str ());
    772773      replacement.replace_all ("<path>",    context_use->real_path.c_str ());
    773 
     774      /*
    774775      cmt_string cmtpath = "";
    775776      cmt_string offset = "";
     
    779780      Project* p = Project::find_by_cmtpath (cmtpath);
    780781      if (p != 0)
     782      */
     783      if (const Project* p = context_use->get_project ())
    781784        {
    782           const cmt_string& n = p->get_name ();
    783           replacement.replace_all ("<project>", n.c_str ());
     785          //          const cmt_string& n = p->get_name ();
     786          replacement.replace_all ("<project>", p->get_name ().c_str ());
    784787        }
    785788
  • CMT/v1r25-branch/source/cmt_project.cxx

    r646 r664  
    1 
    21//-----------------------------------------------------------
    32// Copyright Christian Arnault LAL-Orsay CNRS
    43// arnault@lal.in2p3.fr
    54// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    66// See the complete license in cmt_license.txt "http://www.cecill.info".
    77//-----------------------------------------------------------
     
    646646      project_use->m_hidden  = true;
    647647      project_use->selected  = true;
    648       project_use->m_located = true;
     648      project_use->change_path (project->get_cmtpath(), project);
     649      //      project_use->m_located = true;
    649650      cmt_map <Use*, bool> visited;
    650651      project_use->set_auto_imports(Unspecified, Off, visited);
     
    864865  static ProjectVector& Projects = projects ();
    865866
    866   Project* result = 0;
    867 
    868867  for (int i = (Projects.size () - 1); i >= 0; i--)
    869868    {
     
    879878        //      if (here_real.find (p.m_cmtpath_real) == 0)
    880879        {
    881           result = &p;
    882         }
    883     }
    884 
    885   return (result);
     880          return &p;
     881        }
     882    }
     883
     884  return 0;
    886885}
    887886
     
    15231522
    15241523//----------------------------------------------------------
    1525 void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections)
     1524/**
     1525 *  Fill with projects (pointers) for CMTPATH entries >=1 and <= depth
     1526 *  except for CMTUSERCONTEXT project or CMTHOME project
     1527 *  unless either is current project.
     1528 *  Special values of depth:
     1529 *   0: CMTUSERCONTEXT project only
     1530 *  -1: CMTHOME project only
     1531 *
     1532 *  @param depth in CMTPATH up to which fill
     1533 *  @param path_selections vector to fill
     1534 */
     1535void Project::fill_selection (int depth, ConstProjectPtrVector& path_selections)
     1536{
     1537  static ProjectPtrVector& Ordered = Project::ordered_projects ();
     1538  int curdepth = depth;
     1539  for (int i = 0; i < Ordered.size (); i++)
     1540    {
     1541      const Project* project = Ordered[i];
     1542      const cmt_string& src = project->get_cmtpath_source ();
     1543
     1544      if (src == "default path") continue;
     1545
     1546      if (depth > 0)
     1547        {
     1548          // project for CMTPATH entries >=1 and <= depth
     1549          // except for CMTUSERCONTEXT path or CMTHOME path
     1550          // OR
     1551          // CMTUSERCONTEXT path if it's current project
     1552          // CMTHOME        path if it's current project
     1553          if (i == 0
     1554              && !project->is_current ()
     1555              && src == "CMTUSERCONTEXT") continue;
     1556          // this is CMTUSERCONTEXT
     1557          if (i == Ordered.size () - 1
     1558              && !project->is_current ()
     1559              && src == "CMTHOME") continue;
     1560          // this is CMTHOME
     1561          path_selections.push_back (project);
     1562          //cerr << "fill: " << i << ": " << project->get_cmtpath () << ": " << curdepth << endl;
     1563          if (--curdepth == 0) break;
     1564        }
     1565      else if (depth == 0)
     1566        {
     1567          // CMTUSERCONTEXT path only
     1568          if (i == 0
     1569              && src == "CMTUSERCONTEXT")
     1570            {
     1571              path_selections.push_back (project);
     1572              break;
     1573            }
     1574        }
     1575      else if (depth == -1)
     1576        {
     1577          // CMTHOME path only
     1578          if (i == Ordered.size () - 1
     1579              && src == "CMTHOME")
     1580            {
     1581              path_selections.push_back (project);
     1582              break;
     1583            }
     1584        }
     1585    }
     1586}
     1587
     1588//----------------------------------------------------------
     1589// void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections)
     1590// {
     1591//   static ProjectPtrVector& Ordered = Project::ordered_projects ();
     1592//   int curdepth = depth;
     1593//   for (int i = 0; i < Ordered.size (); i++)
     1594//     {
     1595//       const Project* project = Ordered[i];
     1596
     1597//       const cmt_string& p = project->get_cmtpath ();
     1598//       const cmt_string& pwd = project->get_cmtpath_pwd ();
     1599//       const cmt_string& p_real = project->get_cmtpath_real ();
     1600//       const cmt_string& src = project->get_cmtpath_source ();
     1601
     1602//       if (src == "default path") continue;
     1603
     1604//       if (depth > 0)
     1605//      {
     1606//        // packages from CMTPATH entries >=1 and <= depth
     1607//        // except for CMTUSERCONTEXT path or CMTHOME path
     1608//        // OR
     1609//        // CMTUSERCONTEXT path if it's current project
     1610//        // CMTHOME        path if it's current project
     1611//        if (i == 0
     1612//            && !project->is_current ()
     1613//            && src == "CMTUSERCONTEXT") continue;
     1614//        // this is CMTUSERCONTEXT
     1615//        if (i = Ordered.size () - 1
     1616//            && !project->is_current ()
     1617//            && src == "CMTHOME") continue;
     1618//        // this is CMTHOME
     1619//        cmt_string& s1 = path_selections.add ();
     1620//        s1 = p;
     1621//        if (pwd != p)
     1622//          {
     1623//            cmt_string& s2 = path_selections.add ();
     1624//            s2 = pwd;
     1625//          }
     1626//        if (p_real != p && p_real != pwd)
     1627//          {
     1628//            cmt_string& s3 = path_selections.add ();
     1629//            s3 = p_real;
     1630//          }
     1631//        if (--curdepth == 0) break;
     1632//      }
     1633//       else if (depth == 0)
     1634//      {
     1635//        // CMTUSERCONTEXT path only
     1636//        if (i == 0
     1637//            && src == "CMTUSERCONTEXT")
     1638//          {
     1639//            cmt_string& s1 = path_selections.add ();
     1640//            s1 = p;
     1641//            if (pwd != p)
     1642//              {
     1643//                cmt_string& s2 = path_selections.add ();
     1644//                s2 = pwd;
     1645//              }
     1646//            if (p_real != p && p_real != pwd)
     1647//              {
     1648//                cmt_string& s3 = path_selections.add ();
     1649//                s3 = p_real;
     1650//              }
     1651//            break;
     1652//          }
     1653//      }
     1654//       else if (depth == -1)
     1655//      {
     1656//        // CMTHOME path only
     1657//        if (i = Ordered.size () - 1
     1658//            && src == "CMTHOME")
     1659//          {
     1660//            cmt_string& s1 = path_selections.add ();
     1661//            s1 = p;
     1662//            if (pwd != p)
     1663//              {
     1664//                cmt_string& s2 = path_selections.add ();
     1665//                s2 = pwd;
     1666//              }
     1667//            if (p_real != p && p_real != pwd)
     1668//              {
     1669//                cmt_string& s3 = path_selections.add ();
     1670//                s3 = p_real;
     1671//              }
     1672//            break;
     1673//          }
     1674//      }
     1675// //     if (depth > 0)
     1676// //       {
     1677// //         cmt_string& s1 = path_selections.add ();
     1678// //         s1 = p;
     1679// //         if (pwd != p)
     1680// //           {
     1681// //             cmt_string& s2 = path_selections.add ();
     1682// //             s2 = pwd;
     1683// //           }
     1684// //         if (p_real != p && p_real != pwd)
     1685// //           {
     1686// //             cmt_string& s3 = path_selections.add ();
     1687// //             s3 = p_real;
     1688// //           }
     1689// //         if (src != "CMTHOME" && src != "CMTUSERCONTEXT")
     1690// //           depth--;
     1691
     1692// //         if (depth == 0) break;
     1693// //       }
     1694
     1695//     }
     1696// }
     1697
     1698//----------------------------------------------------------
     1699/**
     1700 *  Fill with projects (pointers) for CMTUSERCONTEXT and CMTHOME projects
     1701 *  (if any exists)
     1702 *  unless either is current project.
     1703 * 
     1704 *  @param path_exclusions vector to fill
     1705 */
     1706void Project::fill_exclusion (ConstProjectPtrVector& path_exclusions)
    15261707{
    15271708  static ProjectPtrVector& Ordered = Project::ordered_projects ();
     
    15291710    {
    15301711      const Project* project = Ordered[i];
    1531 
    1532       const cmt_string& p = project->get_cmtpath ();
    1533       const cmt_string& pwd = project->get_cmtpath_pwd ();
    1534       const cmt_string& p_real = project->get_cmtpath_real ();
    15351712      const cmt_string& src = project->get_cmtpath_source ();
    1536       /*
    1537   static ProjectVector& Projects = projects ();
    1538 
    1539   for (int i = 0; i < Projects.size (); i++)
    1540     {
    1541       Project& project = Projects[i];
    1542 
    1543       const cmt_string& p = project.get_cmtpath ();
    1544       const cmt_string& pwd = project.get_cmtpath_pwd ();
    1545       const cmt_string& p_real = project.get_cmtpath_real ();
    1546       const cmt_string& src = project.get_cmtpath_source ();
    1547       */
    1548       if (src != "default path")
    1549         {
    1550           if (depth > 0)
    1551             {
    1552               cmt_string& s1 = path_selections.add ();
    1553               s1 = p;
    1554               if (pwd != p)
    1555                 {
    1556                   cmt_string& s2 = path_selections.add ();
    1557                   s2 = pwd;
    1558                 }
    1559               if (p_real != p && p_real != pwd)
    1560                 {
    1561                   cmt_string& s3 = path_selections.add ();
    1562                   s3 = p_real;
    1563                 }
    1564               if (src != "CMTHOME" && src != "CMTUSERCONTEXT")
    1565                 depth--;
    1566 
    1567               if (depth == 0) break;
    1568             }
    1569         }
     1713
     1714      if (!project->is_current ()
     1715          && (src == "CMTUSERCONTEXT" || src == "CMTHOME"))
     1716        path_exclusions.push_back (project);
    15701717    }
    15711718}
     
    16941841//          }
    16951842
    1696           if (path_real.find (p_real) != cmt_string::npos)
     1843          if (path_real.find (p_real) == 0) //!= cmt_string::npos)
    16971844            {
    16981845              return (p);
     
    17001847
    17011848          // To become the current area, a path must correspond to the current package
    1702           if (path.find (w) != cmt_string::npos)
     1849          if (path.find (w) == 0)// != cmt_string::npos)
    17031850            {
    17041851              return (p);
     
    17061853        }
    17071854
     1855        /* This code is never used since p is returned above
    17081856      if (p == w) continue;
    17091857
     
    17111859      //      if (CmtSystem::test_directory (w))
    17121860        {
    1713           if (path.find (w) != cmt_string::npos)
     1861          if (path.find (w) == 0)// != cmt_string::npos)
    17141862            {
    17151863              return (w);
    17161864            }
    17171865        }
     1866        */
    17181867    }
    17191868
     
    23622511  use->get_package ()->remove_use (use);
    23632512  CmtSystem::cd (m_cmtpath_pwd);
    2364   if (use->move_to ("", true) &&
    2365       !CmtSystem::absolute_path (use->real_path))
    2366     {
    2367       use->change_path (m_cmtpath_pwd);
    2368     }
     2513  if (use->move_to ("", true))
     2514    {
     2515      if (use->get_realpath ().find (this->get_cmtpath_real ()) == 0)
     2516        use->set_project (this);
     2517    }
     2518  else
     2519    if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () &&
     2520        0 == CmtSystem::getenv ("PEDANTIC").size ())
     2521      CmtMessage::warning
     2522        (CmtError::get_error_name (CmtError::configuration_error)
     2523         + ": Cannot locate container: " + use->get_info ());
     2524    else
     2525      CmtError::set(CmtError::configuration_error,
     2526                    "Cannot locate container: " + use->get_info ());
     2527 
    23692528  CmtSystem::cd (m_cmtpath_pwd + CmtSystem::file_separator () + "cmt");
     2529
     2530  if (CmtError::get_last_error_code () == CmtError::configuration_error)
     2531    return;
    23702532
    23712533  set_container_name (name);
  • CMT/v1r25-branch/source/cmt_project.h

    r608 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    9798  typedef cmt_vector<Project> ProjectVector;
    9899  typedef cmt_vector<Project*> ProjectPtrVector;
     100  typedef cmt_vector<const Project*> ConstProjectPtrVector;
    99101
    100102  static bool create (const cmt_string& name,
     
    120122  static const cmt_string& get_project_file_name ();
    121123
    122   static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
     124  static void fill_selection (int depth, ConstProjectPtrVector& path_selections);
     125  //  static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
     126  static void fill_exclusion (ConstProjectPtrVector& path_exclusions);
    123127
    124128  static void broadcast (IProjectAction& action);
  • CMT/v1r25-branch/source/cmt_regexp.cxx

    r607 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_regexp.h

    r581 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_std.h

    r637 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_string.cxx

    r610 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_string.h

    r610 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_symbol.cxx

    r637 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    1516#include "cmt_database.h"
    1617#include "cmt_log.h"
     18#include "cmt_error.h"
    1719
    1820// Global inhibitor of any display
     
    4244  const cmt_string clean (const Symbol& symbol,
    4345                          const cmt_string& tag_name = "");
     46
     47  void filter_path_value (const Symbol& symbol,
     48                          cmt_string& value,
     49                          const cmt_string& tag_name = "") const;
     50  void filter_path_value (const Symbol& symbol,
     51                          CmtSystem::cmt_string_vector& value,
     52                          const cmt_string& tag_name = "") const;
     53  inline const bool& get_strip_path () const;
     54  inline void set_strip_path (const bool& strip_path);
     55
     56  static PathBuilder* get_path_builder ();
     57
     58private:
     59  PathBuilder ();
     60  PathBuilder (bool strip_path);
     61  PathBuilder (const PathBuilder& other);
     62  PathBuilder& operator = (const PathBuilder& other);
     63
     64  bool m_strip_path;
    4465};
    4566//-------------------------------------------------------------
     
    248269}
    249270
     271//
     272// Global cache
     273//
     274namespace
     275{
     276  cmt_vmap <cmt_string, cmt_string> cmdoutputs;
     277}
    250278/**
    251279
     
    285313  int start = 0;
    286314
     315  //  static cmt_vmap <cmt_string, cmt_string> cmdoutputs;
     316
    287317  for (;;)
    288318    {
     
    337367            // to be applied. The output of the command is then substituted
    338368
     369          Symbol::all_set ();
     370
    339371          cmt_string result;
    340 
    341           Symbol::all_set ();
    342           CmtSystem::execute (command, result);
    343          
    344           /*
    345           int pos;
    346           pos = result.find ('\n');
    347           if (pos != cmt_string::npos) result.erase (pos);
    348           pos = result.find ('\r');
    349           if (pos != cmt_string::npos) result.erase (pos);
    350           */         
    351           process_cmd_output (result);
    352 
    353           if (Cmt::get_debug ())
    354             {
    355               cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>["
    356                    << result << "]" << endl;
    357             }
    358          
     372          const cmt_string * presult;
     373          if (!(presult = cmdoutputs.find (command)))
     374            {
     375              CmtSystem::execute (command, result);
     376             
     377              process_cmd_output (result);
     378              cmdoutputs.add (command, result);
     379              if (Cmt::get_debug ())
     380                {
     381                  cout << "resolve_value: Executing [" << command << "] to expand a symbol value =>["
     382                       << result << "]" << endl;
     383                }
     384            }
     385          else
     386            {
     387              result = *presult;
     388              if (Cmt::get_debug ())
     389                {
     390                  cout << "resolve_value: Found in cache [" << command << "] to expand a symbol value =>["
     391                       << result << "]" << endl;
     392                }
     393            }
     394
    359395          text.replace_all (pattern, result);
    360396
     
    378414          else
    379415            {
     416              if (Cmt::get_env_access () ||
     417                  Symbol::std_env_vars ().has (symbol_name))
     418                {
    380419                // Symbol not found. Look for env. variable
    381420              cmt_string value = CmtSystem::getenv (symbol_name);
    382              
    383421                // When the env. variable is not defined, the replacement is empty
    384422                // thus all $(xxx) ${xxx} %xxx% patterns are always filtered away.
    385423              text.replace_all (pattern, value);
    386424             
     425                  if (Cmt::get_debug ())
     426                    {
     427                      cerr << "resolve_value: getenv (" << symbol_name
     428                           << ") => " << value << endl;
     429                    }
    387430                // The substitution will restart from the same place
    388431                // allowing for recursive replacements
    389432              start = begin;
     433                }
     434              else
     435                {
     436                  if (Cmt::get_debug ())
     437                    {
     438                      cerr << "resolve_value: getenv (" << symbol_name
     439                           << ") denied" << endl;
     440                    }
     441                  CmtError::set (CmtError::warning,
     442                                 "getenv (" + symbol_name + ") denied");
     443                  return;
     444                }
    390445            }
    391446        }
     
    484539            // to be applied. The output of the command is substituted
    485540
     541          Symbol::all_set ();
     542
    486543          cmt_string result;
    487 
    488           Symbol::all_set ();
    489           CmtSystem::execute (command, result);
    490          
    491           /*
    492           int pos;
    493           pos = result.find ('\n');
    494           if (pos != cmt_string::npos) result.erase (pos);
    495           pos = result.find ('\r');
    496           if (pos != cmt_string::npos) result.erase (pos);
    497           */
    498           process_cmd_output (result);
    499          
    500           if (Cmt::get_debug ())
    501             {
    502               cout << "   Executing [" << command << "] to expand a macro value =>["
    503                    << result << "]" << endl;
    504             }
    505          
     544          const cmt_string * presult;
     545          if (!(presult = cmdoutputs.find (command)))
     546            {
     547              CmtSystem::execute (command, result);
     548             
     549              process_cmd_output (result);
     550              cmdoutputs.add (command, result);
     551              if (Cmt::get_debug ())
     552                {
     553                  cout << "resolve_value_for_macros: Executing [" << command << "] to expand a symbol value =>["
     554                       << result << "]" << endl;
     555                }
     556            }
     557          else
     558            {
     559              result = *presult;
     560              if (Cmt::get_debug ())
     561                {
     562                  cout << "resolve_value_for_macros: Found in cache [" << command << "] to expand a symbol value =>["
     563                       << result << "]" << endl;
     564                }
     565            }
     566
    506567          text.replace_all (pattern, result);
    507568
     
    621682            // to be applied. The output of the command is substituted
    622683
     684          Symbol::all_set ();
     685
    623686          cmt_string result;
    624 
    625           Symbol::all_set ();
    626           CmtSystem::execute (command, result);
    627          
    628           /*
    629           int pos;
    630           pos = result.find ('\n');
    631           if (pos != cmt_string::npos) result.erase (pos);
    632           pos = result.find ('\r');
    633           if (pos != cmt_string::npos) result.erase (pos);
    634           */         
    635           process_cmd_output (result);
    636          
    637           if (Cmt::get_debug ())
    638             {
    639               cout << "   Executing [" << command << "] to expand a macro value =>["
    640                    << result << "]" << endl;
    641             }
    642          
     687          const cmt_string * presult;
     688          if (!(presult = cmdoutputs.find (command)))
     689            {
     690              CmtSystem::execute (command, result);
     691             
     692              process_cmd_output (result);
     693              cmdoutputs.add (command, result);
     694              if (Cmt::get_debug ())
     695                {
     696                  cout << "suppress_OS_delimiters: Executing [" << command << "] to expand a symbol value =>["
     697                       << result << "]" << endl;
     698                }
     699            }
     700          else
     701            {
     702              result = *presult;
     703              if (Cmt::get_debug ())
     704                {
     705                  cout << "suppress_OS_delimiters: Found in cache [" << command << "] to expand a symbol value =>["
     706                       << result << "]" << endl;
     707                }
     708            }
     709
    643710          text.replace_all (pattern, result);
    644711
     
    692759{
    693760  static SetBuilder Set;
    694   static PathBuilder Path;
     761  static PathBuilder* PathPtr (PathBuilder::get_path_builder ());
     762  //static PathBuilder Path (Cmt::get_strip_path ());
     763  //static PathBuilder Path;
    695764  static MacroBuilder Macro;
    696765  static ScriptBuilder Script;
     
    852921      break;
    853922    case SymbolPath:
    854       symbol.builder = &Path;
     923      symbol.builder = PathPtr;
     924      //symbol.builder = &Path;
    855925      break;
    856926    case SymbolAlias:
     
    911981
    912982  return (SymbolMap);
     983}
     984
     985//-------------------------------------------------------------
     986Symbol::SymbolMap& Symbol::std_env_vars ()
     987{
     988  static SymbolMap env_vars;
     989  static Symbol std_sym;
     990  static bool initialized (false);
     991  if (!initialized)
     992    {
     993      env_vars.add ("SITEROOT", std_sym);
     994      env_vars.add ("CMTCONFIG", std_sym);
     995      env_vars.add ("CMTBIN", std_sym);
     996      env_vars.add ("CMTPATH", std_sym);
     997      env_vars.add ("CMTHEADVERSION", std_sym);
     998      env_vars.add ("CMTPROJECTPATH", std_sym);
     999      env_vars.add ("CMTSITE", std_sym);
     1000      env_vars.add ("CMTEXTRATAGS", std_sym);
     1001      env_vars.add ("CMTSTRUCTURINGSTYLE", std_sym);
     1002      env_vars.add ("CMTHOME", std_sym);
     1003      env_vars.add ("CMTUSERCONTEXT", std_sym);
     1004      initialized = true;
     1005    }
     1006  return env_vars;
    9131007}
    9141008
     
    10211115            {
    10221116              if (use->get_strategy ("SetupRoot") &&
    1023                   use->get_package_name () != "cmt_standalone")
     1117                  use->get_package_name () != "cmt_standalone" &&
     1118                  (action_setup == Cmt::get_action () ||
     1119                   action_cleanup == Cmt::get_action ()) &&
     1120                  Requirements != Cmt::get_print_mode () &&
     1121                  Xml != Cmt::get_print_mode ())
    10241122                {
    10251123#ifdef WIN32
     
    10841182           */
    10851183          if (name == "constituents") return;
    1086           if (name == "constituentscclean") return;
     1184          if (name == "constituentsclean") return;
    10871185
    10881186          if (use->get_current_scope () == ScopePrivate) return;
     
    11651263        }
    11661264    }
     1265}
     1266
     1267//-------------------------------------------------------------
     1268bool Symbol::set_strip_path (const bool& strip_path)
     1269{
     1270  PathBuilder::get_path_builder ()->set_strip_path (strip_path);
     1271  return true;
     1272  /*
     1273  // searching for a path symbol
     1274  for (int number = 0; number < Symbol::symbol_number (); number++)
     1275    {
     1276      Symbol& symbol = Symbol::symbol (number);
     1277     
     1278      if (symbol.type == Symbol::SymbolPath)
     1279        {
     1280          static_cast<PathBuilder*> (symbol.builder)->set_strip_path (strip_path);
     1281          return true;
     1282        }
     1283    }
     1284
     1285  return false;
     1286  */
    11671287}
    11681288
     
    14221542  cmt_string value;
    14231543
     1544  if (Cmt::get_env_access ())
     1545    {
    14241546  for (number = 0; number < Symbol::symbol_number (); number++)
    14251547    {
     
    14331555          Symbol::expand (value);
    14341556
     1557          if (Cmt::get_debug ())
     1558            {
     1559              cerr << "Symbol::all_set (set)> " << symbol.name << " = " << value << endl;
     1560            }
     1561
    14351562          CmtSystem::putenv (symbol.name, value);
    14361563        }
     1564    }
    14371565    }
    14381566
     
    15001628  }
    15011629
     1630  static PathBuilder* pb (0);
     1631
     1632  if (Cmt::get_env_access ())
     1633    {
    15021634  for (number = 0; number < Symbol::symbol_number (); number++)
    15031635    {
     
    15101642        {
    15111643          Symbol::expand (value);
    1512           filter_path_value (symbol.name, value);
     1644          if (!pb)
     1645            pb = static_cast<PathBuilder*> (symbol.builder);
     1646          pb->filter_path_value (symbol, value);
     1647          //filter_path_value (symbol.name, value);
    15131648
    15141649#ifdef WIN32
     
    15181653          if (Cmt::get_debug ())
    15191654            {
    1520               cerr << "Symbol::all_set-2> " << symbol.name << " = " << value << endl;
     1655              cerr << "Symbol::all_set (path)> " << symbol.name << " = " << value << endl;
    15211656            }
    15221657
     
    15241659        }
    15251660    }
     1661    }
    15261662
    15271663  running = false;
     
    15291665
    15301666//-------------------------------------------------------------
    1531 void Symbol::all_print (PrintMode mode)
     1667void Symbol::all_print (PrintMode mode, ostream& out)
     1668//void Symbol::all_print (PrintMode mode)
    15321669{
    15331670  static SymbolVector& Symbols = symbols ();
     
    15501687              (symbol.type == SymbolMacro))
    15511688            {
    1552               if (symbol.print_macro (mode))
     1689              if (symbol.print_macro (mode, out))
    15531690                {
    15541691                  //              cout << endl;
     
    15671704              (symbol.type == SymbolPath))
    15681705            {
    1569               if (symbol.print (mode))
     1706              if (symbol.print (mode, out))
    15701707                {
    15711708                  if (mode == Bat)
    15721709                    {
    1573                       cout << endl;
     1710                      out << endl;
    15741711                    }
    15751712                  else if (mode == Xml)
     
    15791716                  else
    15801717                    {
    1581                       cout << endl;
     1718                      out << endl;
    15821719                    }
    15831720                }
     
    15931730  static SymbolVector& Symbols = symbols ();
    15941731
     1732  static PathBuilder* pb (0);
     1733
    15951734  int number;
    15961735
     
    16081747          expand (temp);
    16091748
    1610           Symbol::filter_path_value (symbol.name, temp);
     1749          if (!pb)
     1750            pb = static_cast<PathBuilder*> (symbol.builder);
     1751          pb->filter_path_value (symbol, temp);
     1752          //Symbol::filter_path_value (symbol.name, temp);
    16111753        }
    16121754    }
     
    16961838            break;
    16971839          case Sh :
    1698             cout << "[ -z ${" << name << "+CMT} ] || unset " << name;
    1699           //            cout << "unset " << name;
     1840            cout << "alias " << name << " >/dev/null 2>&1 && unalias " << name;
    17001841            result = 1;
    17011842            break;
     
    17621903
    17631904//-------------------------------------------------------------
    1764 int Symbol::print (PrintMode mode)
    1765 {
     1905int Symbol::print (PrintMode mode, ostream& out)
     1906{
     1907  static PathBuilder* pb (0);
     1908
    17661909  int result = 0;
    17671910
     
    17691912  bool empty = (temp.size () == 0) ? true : false;
    17701913
     1914  cmt_string _name (name);
     1915  switch (type)
     1916    {
     1917    case SymbolSet :
     1918    case SymbolPath :
     1919      expand (temp);
     1920      if (type == SymbolPath)
     1921        {
     1922          if (!pb)
     1923            pb = static_cast<PathBuilder*> (builder);
     1924          pb->filter_path_value (*this, temp);
     1925        }
     1926      switch (mode)
     1927        {
     1928        case Xml :
     1929          break;
     1930        default:
     1931          if (0 != CmtSystem::mangle (name, _name))
     1932            CmtMessage::info ("Replace " + name + " with " + _name);
     1933          break;
     1934        }
     1935      break;
     1936    default:
     1937      break;
     1938    }
     1939
     1940  /*
    17711941  if (type == SymbolPath)
    17721942    {
    17731943      expand (temp);
    1774       Symbol::filter_path_value (name, temp);
    1775     }
    1776 
    1777   cmt_string _name;
     1944      //Symbol::filter_path_value (name, temp);
     1945      if (!pb)
     1946        pb = static_cast<PathBuilder*> (builder);
     1947      pb->filter_path_value (*this, temp);
     1948    }
     1949  */
    17781950  switch (type)
    17791951    {
    17801952      case SymbolSet :
    17811953      case SymbolPath :
    1782         if (0 != CmtSystem::mangle (name, _name))
    1783           CmtMessage::info ("Replace " + name + " with " + _name);
    17841954        switch (mode)
    17851955          {
    17861956            case Csh :
    1787               if (empty) cout << "unsetenv " << _name;
    1788               else cout << "setenv " << _name << " \"" << temp << "\"";
    1789               //else cout << "setenv " << name << " " << CmtSystem::quote (temp, " \t");
     1957              if (empty) out << "unsetenv " << _name;
     1958              else out << "setenv " << _name << " \"" << temp << "\"";
     1959              //else out << "setenv " << name << " " << CmtSystem::quote (temp, " \t");
    17901960
    17911961              result = 1;
    17921962              break;
    17931963            case Sh :
    1794               if (empty) cout << "[ -z ${" << _name << "+CMT} ] || unset " << _name;
    1795               //              if (empty) cout << "unset " << _name;
    1796               else cout << _name << "=\"" << temp << "\"; export " << _name;
    1797               //else cout << name << "=" << CmtSystem::quote (temp, " \t") << "; export " << name;
     1964              if (empty) out << "[ -z ${" << _name << "+CMT} ] || unset " << _name;
     1965              //              if (empty) out << "unset " << _name;
     1966              else out << _name << "=\"" << temp << "\"; export " << _name;
     1967              //else out << name << "=" << CmtSystem::quote (temp, " \t") << "; export " << name;
    17981968
    17991969              result = 1;
     
    18011971            case Bat :
    18021972              temp.replace_all ("/", "\\");
    1803               cout << "set " << _name << "=" << CmtSystem::quote (temp, " \t");
    1804               //cout << "set " << name << "=" << temp;
     1973              out << "set " << _name << "=" << CmtSystem::quote (temp, " \t");
     1974              //out << "set " << name << "=" << temp;
    18051975              result = 1;
    18061976              break;
    18071977            case Xml :
    1808               cout << "<variable><name>" << _name << "</name>"
     1978              out << "<variable><name>" << _name << "</name>"
    18091979                   << "<value>" << temp << "</value></variable>";
    18101980              result = 1;
     
    18161986          {
    18171987            case Csh :
    1818               cout << "alias " << name <<
     1988              out << "alias " << name <<
    18191989                " \"" << temp << "\"";
    18201990              //CmtSystem::quote (temp, " \t");
     
    18221992              break;
    18231993            case Sh :
    1824               cout << "alias " << name <<
     1994              out << "alias " << name <<
    18251995                "=\"" << temp << "\"";
    18261996              //"=" << CmtSystem::quote (temp, " \t");
     
    18281998              break;
    18291999            case Bat :
    1830               cout << "set " << name <<
     2000              out << "set " << name <<
    18312001                "=" << CmtSystem::quote (temp, " \t");
    18322002              //"=" << temp;
     
    18342004              break;
    18352005            case Xml :
    1836               cout << "<alias><name>" << name << "</name>"
     2006              out << "<alias><name>" << name << "</name>"
    18372007                   << "<value>" << temp << "</value></alias>";
    18382008              result = 1;
     
    18522022              {
    18532023                case Csh :
    1854                   cout << "if ( -f " << CmtSystem::quote (name, " \t") << ".csh ) then" << endl;
    1855                   cout << "  source " << CmtSystem::quote (name, " \t") << ".csh" << endl;
    1856                   cout <<
     2024                  out << "if ( -f " << CmtSystem::quote (name, " \t") << ".csh ) then" << endl;
     2025                  out << "  source " << CmtSystem::quote (name, " \t") << ".csh" << endl;
     2026                  out <<
    18572027                    "if ( $status != 0 ) then\n"
    18582028                    "    set cmtsetupstatus=1\n"
    18592029                    "endif\n";
    1860                   cout << "endif" << endl;
     2030                  out << "endif" << endl;
    18612031                  result = 1;
    18622032                  break;
    18632033                case Sh :
    1864                   cout << "if test -f " << CmtSystem::quote (name, " \t") << ".sh; then" << endl;
    1865                   cout << "  . " << CmtSystem::quote (name, " \t") << ".sh" << endl;
    1866                   cout <<
     2034                  out << "if test -f " << CmtSystem::quote (name, " \t") << ".sh; then" << endl;
     2035                  out << "  . " << CmtSystem::quote (name, " \t") << ".sh" << endl;
     2036                  out <<
    18672037                    "if test $? != 0; then\n"
    18682038                    "    cmtsetupstatus=1\n"
    18692039                    "fi\n";
    1870                   cout << "fi" << endl;
     2040                  out << "fi" << endl;
    18712041                  result = 1;
    18722042                  break;
    18732043                case Bat :
    1874                   cout << "call " << CmtSystem::quote (name, " \t");
     2044                  out << "call " << CmtSystem::quote (name, " \t");
    18752045                  result = 1;
    18762046                  break;
    18772047                case Xml :
    1878                   cout << "<script>" << name << "</script>";
     2048                  out << "<script>" << name << "</script>";
    18792049                  result = 1;
    18802050                  break;
     
    21242294      SymbolValue& value = value_list.values[selected];
    21252295
    2126       result += value_list.print (symbol, value, first_definition);
     2296      result += value_list.print (symbol, value, first_definition, out);
    21272297    }
    21282298
     
    22022372            else if (temp == "")
    22032373              {
    2204                 temp = CmtSystem::getenv (symbol.name);
     2374                if (Cmt::get_env_access () ||
     2375                    Symbol::std_env_vars ().has (symbol.name))
     2376                  {
     2377                    temp = CmtSystem::getenv (symbol.name);
     2378                    if (Cmt::get_debug ())
     2379                      {
     2380                        cerr << "SetBuilder::build> getenv (" << symbol.name
     2381                             << ") => " << temp << endl;
     2382                      }
     2383                  }
     2384                else
     2385                  {
     2386                    if (Cmt::get_debug ())
     2387                      {
     2388                        cerr << "SetBuilder::build> getenv (" << symbol.name
     2389                             << ") denied" << endl;
     2390                      }
     2391                    CmtError::set (CmtError::warning,
     2392                                   "getenv (" + symbol.name + ") denied");
     2393                    return "";
     2394                  }
    22052395              }
    22062396
     
    22632453}
    22642454
     2455namespace
     2456{
     2457int find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value)
     2458{
     2459  //  if (value.size () == 0) return true;
     2460 
     2461  static cmt_vmap <cmt_string, cmt_string> realpaths;
     2462
     2463  cmt_string rvalue;
     2464  const cmt_string * prvalue;
     2465
     2466  if (!(prvalue = realpaths.find (value)))
     2467    {
     2468      // if (!CmtSystem::realpath_ (value, rvalue))
     2469      //{
     2470          rvalue = value;
     2471          CmtSystem::compress_path (rvalue);
     2472      //}
     2473      prvalue = &rvalue;
     2474      realpaths.add (value, rvalue);
     2475      //      cerr << "realpaths.add: " << value << " , " << rvalue << endl;
     2476    }
     2477
     2478  for (int i = 0; i < items.size (); i++)
     2479    {
     2480      const cmt_string& item = items[i];
     2481      if (item.size () == 0) continue;
     2482      cmt_string ritem;
     2483      const cmt_string * pritem;
     2484
     2485      if (!(pritem = realpaths.find (item)))
     2486        {
     2487          //if (!CmtSystem::realpath_ (item, ritem))
     2488          //{
     2489              ritem = item;
     2490              CmtSystem::compress_path (ritem);
     2491          //}
     2492          pritem = &ritem;
     2493          realpaths.add (item, ritem);
     2494          //  cerr << "realpaths.add: " << item << " , " << ritem << endl;
     2495        }
     2496      if (*pritem == *prvalue)
     2497        {
     2498          return i;
     2499        }
     2500    }
     2501
     2502  return -1;
     2503}
     2504
     2505}
     2506/*
    22652507static bool find_path_entry (const CmtSystem::cmt_string_vector& items, const cmt_string& value)
     2508{
     2509  if (value.size () == 0) return true;
     2510
     2511  static cmt_vmap <cmt_string, cmt_string> realpaths;
     2512
     2513  cmt_string rvalue;
     2514  const cmt_string * prvalue;
     2515
     2516  if (!(prvalue = realpaths.find (value)))
     2517    {
     2518      // if (!CmtSystem::realpath_ (value, rvalue))
     2519      //{
     2520          rvalue = value;
     2521          CmtSystem::compress_path (rvalue);
     2522      //}
     2523      prvalue = &rvalue;
     2524      realpaths.add (value, rvalue);
     2525      //      cerr << "realpaths.add: " << value << " , " << rvalue << endl;
     2526    }
     2527
     2528  for (int i = 0; i < items.size (); i++)
     2529    {
     2530      const cmt_string& item = items[i];
     2531      if (item.size () == 0) continue;
     2532      cmt_string ritem;
     2533      const cmt_string * pritem;
     2534
     2535      if (!(pritem = realpaths.find (item)))
     2536        {
     2537          //if (!CmtSystem::realpath_ (item, ritem))
     2538          //{
     2539              ritem = item;
     2540              CmtSystem::compress_path (ritem);
     2541          //}
     2542          pritem = &ritem;
     2543          realpaths.add (item, ritem);
     2544          //  cerr << "realpaths.add: " << item << " , " << ritem << endl;
     2545        }
     2546      if (*pritem == *prvalue)
     2547        {
     2548          return true;
     2549        }
     2550    }
     2551
     2552  return false;
     2553}
     2554*/
     2555/*
     2556static bool find_path_entry (const cmt_string& paths, const cmt_string& value)
    22662557{
    22672558  static const cmt_string path_separator = CmtSystem::path_separator ();
    22682559  static cmt_vmap <cmt_string, cmt_string> realpaths;
    2269 
    2270   if (value.size () == 0) return true;
    22712560
    22722561  cmt_string rvalue;
     
    22852574    }
    22862575
    2287   //  CmtSystem::cmt_string_vector items;
    2288   //  CmtSystem::split (paths, path_separator, items);
     2576  CmtSystem::cmt_string_vector items;
     2577  CmtSystem::split (paths, path_separator, items);
    22892578
    22902579  bool found = false;
     
    22932582    {
    22942583      const cmt_string& item = items[i];
    2295       if (item.size () == 0) continue;
    22962584      cmt_string ritem;
    22972585      const cmt_string * pritem;
     
    23172605  return (found);
    23182606}
    2319 
    2320 static bool find_path_entry (const cmt_string& paths, const cmt_string& value)
    2321 {
    2322   static const cmt_string path_separator = CmtSystem::path_separator ();
    2323   static cmt_vmap <cmt_string, cmt_string> realpaths;
    2324 
    2325   cmt_string rvalue;
    2326   const cmt_string * prvalue;
    2327 
    2328   if (!(prvalue = realpaths.find (value)))
    2329     {
    2330       if (!CmtSystem::realpath_ (value, rvalue))
    2331         {
    2332           rvalue = value;
    2333           CmtSystem::compress_path (rvalue);
    2334         }
    2335       prvalue = &rvalue;
    2336       realpaths.add (value, rvalue);
    2337       //      cerr << "realpaths.add: " << value << " , " << rvalue << endl;
    2338     }
    2339 
    2340   CmtSystem::cmt_string_vector items;
    2341   CmtSystem::split (paths, path_separator, items);
    2342 
    2343   bool found = false;
    2344 
    2345   for (int i = 0; i < items.size (); i++)
    2346     {
    2347       const cmt_string& item = items[i];
    2348       cmt_string ritem;
    2349       const cmt_string * pritem;
    2350 
    2351       if (!(pritem = realpaths.find (item)))
    2352         {
    2353           if (!CmtSystem::realpath_ (item, ritem))
    2354             {
    2355               ritem = item;
    2356               CmtSystem::compress_path (ritem);
    2357             }
    2358           pritem = &ritem;
    2359           realpaths.add (item, ritem);
    2360           //  cerr << "realpaths.add: " << item << " , " << ritem << endl;
    2361         }
    2362       if (*pritem == *prvalue)
    2363         {
    2364           found = true;
    2365           break;
    2366         }
    2367     }
    2368 
    2369   return (found);
     2607*/
     2608//-------------------------------------------------------------
     2609PathBuilder* PathBuilder::get_path_builder ()
     2610{
     2611  static PathBuilder Path (Cmt::get_strip_path ());
     2612  return &Path;
     2613}
     2614
     2615//-------------------------------------------------------------
     2616PathBuilder::PathBuilder ()
     2617  : m_strip_path (false)
     2618{
     2619}
     2620
     2621//-------------------------------------------------------------
     2622PathBuilder::PathBuilder (bool strip_path)
     2623{
     2624  PathBuilder ();
     2625  m_strip_path = strip_path;
    23702626}
    23712627
     
    24012657  level++;
    24022658
     2659                if (Cmt::get_env_access () ||
     2660                    Symbol::std_env_vars ().has (symbol.name))
     2661                  {
     2662  //temp = CmtSystem::getenv (symbol.name);
    24032663  CmtSystem::split (CmtSystem::getenv (symbol.name), path_separator, temp_vector);
    2404   //temp = CmtSystem::getenv (symbol.name);
     2664  filter_path_value (symbol, temp_vector);
     2665                    if (Cmt::get_debug ())
     2666                      {
     2667                        cmt_string temp_txt;
     2668                        Cmt::vector_to_string (temp_vector, path_separator, temp_txt);
     2669                        cerr << "PathBuilder::build> getenv (" << symbol.name
     2670                             << ") => " << temp_txt << endl;
     2671                      }
     2672                  }
     2673                else
     2674                  {
     2675                    if (Cmt::get_debug ())
     2676                      {
     2677                        cerr << "PathBuilder::build> getenv (" << symbol.name
     2678                             << ") denied" << endl;
     2679                      }
     2680                    CmtError::set (CmtError::warning,
     2681                                   "getenv (" + symbol.name + ") denied");
     2682                    return "";
     2683                  }
    24052684
    24062685  bool first_definition = true;
     
    24422721                CmtSystem::split (new_value, path_separator, temp_vector);
    24432722                //temp = new_value;
     2723                filter_path_value (symbol, temp_vector);
    24442724              }
    24452725
     
    24512731                CmtSystem::split (new_value, path_separator, new_value_vector);
    24522732                for (int i = 0; i < new_value_vector.size (); i++)
    2453                   if (!find_path_entry (temp_vector, new_value_vector[i]))
    2454                     //if (!find_path_entry (temp, new_value))
    2455                     {
    2456                       temp_vector.push_back (new_value_vector[i]);
    2457                       /*
    2458                         if (temp != "") temp += path_separator;
    2459                        
    2460                         temp += new_value;
    2461                       */
    2462                     }
     2733                  {
     2734                    if (new_value_vector[i].size () == 0) continue;
     2735                    int j = find_path_entry (temp_vector, new_value_vector[i]);
     2736                    if (j < 0)
     2737                      {
     2738                        temp_vector.push_back (new_value_vector[i]);
     2739                      }
     2740                    else if (j < temp_vector.size () - 1)
     2741                      {
     2742                        temp_vector [j] = "";
     2743                        temp_vector.push_back (new_value_vector[i]);
     2744                      }
     2745                  }
    24632746              }
    24642747                 
     
    24732756                for (int i = temp_vector.size () - 1; i > n - 1; i--)
    24742757                  temp_vector [i] = temp_vector [i - n];
     2758                for (int i = 0; i < n; i++)
     2759                  temp_vector [i] = "";
    24752760                for (int i = 0; i < new_value_vector.size (); i++)
    2476                   if (!find_path_entry (temp_vector, new_value_vector[i]))
    2477                     //if (!find_path_entry (temp, new_value))
    2478                     {
    2479                       temp_vector [i] = new_value_vector[i];
    2480                       /*
    2481                         previous_temp = temp;
    2482                         temp = new_value;
    2483                         if (previous_temp != "") temp += path_separator;
    2484                         temp += previous_temp;
    2485                       */
    2486                     }
    2487                   else
    2488                     temp_vector [i] = "";
     2761                  {
     2762                    if (new_value_vector[i].size () == 0) continue;
     2763                    int j = find_path_entry (temp_vector, new_value_vector[i]);
     2764                    if (j < 0)
     2765                      {
     2766                        temp_vector [i] = new_value_vector[i];
     2767                      }
     2768                    else if (j >= n)
     2769                      {
     2770                        temp_vector [i] = new_value_vector[i];
     2771                        temp_vector [j] = "";
     2772                      }
     2773                  }
    24892774              }
    24902775           
     
    26142899
    26152900  level--;
    2616 
     2901  /*
    26172902  for (;;)
    26182903    {
     
    26372922  temp.replace_all ("::", ":");
    26382923  temp.replace_all (";;", ";");
    2639  
     2924  */
    26402925  return (temp);
    26412926}
     
    27673052 
    27683053  return (temp);
     3054}
     3055
     3056//-------------------------------------------------------------
     3057void PathBuilder::filter_path_value (const Symbol& symbol,
     3058                                     CmtSystem::cmt_string_vector& value,
     3059                                     const cmt_string& /* tag_name */) const
     3060{
     3061  static cmt_regexp reg ("[$%`]");
     3062
     3063  cmt_vector<int> path (value.size ());
     3064  int n (0);
     3065
     3066  for (int j = 0; j < value.size (); j++)
     3067    {
     3068      const cmt_string& v = value[j];
     3069      bool exists (false); 
     3070      for (int i = 0; i < j; i++)
     3071        {
     3072          if (value[i] == v)
     3073            {
     3074              exists = true;
     3075              break;
     3076            }
     3077        }                 
     3078      if (!exists)
     3079        {
     3080          if (m_strip_path)
     3081            {
     3082              if (!reg.match (v))
     3083                {
     3084                  if (!CmtSystem::test_directory (v))
     3085                    {
     3086                      CmtMessage::verbose ("Non-existent directory " + v + " in " + symbol.name + " skipped");
     3087                      continue;
     3088                    }
     3089                }
     3090              else
     3091                {
     3092                  if (CmtMessage::active (Verbose))
     3093                    {
     3094                      CmtMessage::warning ("Unresolved directory name " + v + " in " + symbol.name);
     3095                    }
     3096                }
     3097            }
     3098          else
     3099            {
     3100              if (CmtMessage::active (Verbose))
     3101                if (!reg.match (v) &&
     3102                    !CmtSystem::test_directory (v))
     3103                  {
     3104                    CmtMessage::warning ("Non-existent directory " + v + " in " + symbol.name);
     3105                  }
     3106            }
     3107          path[n++] = j;
     3108        }
     3109    }
     3110
     3111  for (int i = 0; i < n; i++)
     3112    if (i != path[i]) value[i] = value[path[i]];
     3113 
     3114  value.resize (n);
     3115}
     3116
     3117//-------------------------------------------------------------
     3118void PathBuilder::filter_path_value (const Symbol& symbol,
     3119                                     cmt_string& value,
     3120                                     const cmt_string& tag_name) const
     3121{
     3122  static cmt_string ps (CmtSystem::path_separator ());
     3123  CmtSystem::cmt_string_vector paths;
     3124
     3125  CmtSystem::split (value, ps, paths);
     3126  filter_path_value (symbol, paths, tag_name);
     3127  Cmt::vector_to_string (paths, ps, value);
     3128}
     3129
     3130//-------------------------------------------------------------
     3131inline const bool& PathBuilder::get_strip_path () const
     3132{
     3133  return m_strip_path;
     3134}
     3135
     3136//-------------------------------------------------------------
     3137inline void PathBuilder::set_strip_path (const bool& strip_path)
     3138{
     3139  m_strip_path = strip_path;
    27693140}
    27703141
     
    32753646int SymbolValueList::print (const Symbol& symbol,
    32763647                            const SymbolValue& value,
    3277                             bool& first_definition) const
     3648                            bool& first_definition,
     3649                            ostream& out) const
    32783650{
    32793651  int result (0);
    3280 
    3281   //if (use->get_package_name () == "CMT") return result;
    32823652
    32833653  cmt_string discarded_text;
    32843654  cmt_string define_text;
    32853655  ActionType action = Cmt::get_action ();
     3656
     3657  static PathBuilder* pb (0);
     3658  cmt_string rvalue (value.text);
    32863659
    32873660  switch (command_type)
     
    33063679      case CommandMacroRemoveAllRegexp :
    33073680        //case CommandAction :
    3308         if (value.text == "") return result;
     3681        if (value.text.size () == 0) return result;
     3682        break;
     3683    }
     3684
     3685  CmtError::code code (CmtError::ok);
     3686  cmt_string msg, n;
     3687  int exec_err (0);
     3688
     3689  switch (command_type)
     3690    {
     3691      case CommandSet :
     3692      case CommandSetAppend :
     3693      case CommandSetPrepend :
     3694      case CommandSetRemove :
     3695      case CommandSetRemoveRegexp :
     3696
     3697        if (CmtError::has_pending_error ())
     3698          {
     3699            code = CmtError::get_last_error_code ();
     3700            msg = CmtError::get_last_error ();
     3701            exec_err = CmtError::get_last_execution_error ();
     3702            n = CmtError::get_error_name (code);
     3703            CmtError::clear ();
     3704          }
     3705        resolve_value_for_macros (rvalue);
     3706        if (CmtError::get_last_error_code () != CmtError::warning)
     3707          {
     3708            if (CmtError::has_pending_error ())
     3709              {
     3710                CmtError::print ();
     3711                CmtError::clear ();
     3712              }
     3713            if (CmtError::ok != code)
     3714              {
     3715                // restore error occurred before value expansion
     3716                CmtError::set (code,
     3717                               (msg.replace (n + ": ", cmt_string ("")), msg),
     3718                               exec_err);
     3719              }
     3720            if (CommandSet != command_type &&
     3721                rvalue.size () == 0)
     3722              return result;
     3723          }
     3724        else
     3725          {
     3726            if (CmtMessage::active (Verbose))
     3727              CmtError::print ();
     3728            CmtError::clear ();
     3729            if (CmtError::ok != code)
     3730              {
     3731                // restore error occurred before value expansion
     3732                CmtError::set (code,
     3733                               (msg.replace (n + ": ", cmt_string ("")), msg),
     3734                               exec_err);
     3735              }
     3736            // Ignore the error, keep the value unresolved
     3737            rvalue = value.text;
     3738          }
     3739
     3740        break;
     3741
     3742        //case CommandAlias :
     3743      case CommandPath :
     3744      case CommandPathAppend :
     3745      case CommandPathPrepend :
     3746      case CommandPathRemove :
     3747      case CommandPathRemoveRegexp :
     3748        //case CommandMacroPrepend :
     3749        //case CommandMacro :
     3750        //case CommandMacroAppend :
     3751        //case CommandMacroRemove :
     3752        //case CommandMacroRemoveRegexp :
     3753        //case CommandMacroRemoveAll :
     3754        //case CommandMacroRemoveAllRegexp :
     3755        //case CommandAction :
     3756
     3757        if (!pb)
     3758          pb = static_cast<PathBuilder*> (symbol.builder);
     3759        if (pb->get_strip_path ())
     3760          {
     3761            /*
     3762            CmtError::code code (CmtError::ok);
     3763            cmt_string msg, n;
     3764            int exec_err (0);
     3765            */
     3766            if (CmtError::has_pending_error ())
     3767              {
     3768                code = CmtError::get_last_error_code ();
     3769                msg = CmtError::get_last_error ();
     3770                exec_err = CmtError::get_last_execution_error ();
     3771                n = CmtError::get_error_name (code);
     3772                CmtError::clear ();
     3773              }
     3774            resolve_value (rvalue);
     3775            if (CmtError::get_last_error_code () != CmtError::warning)
     3776              {
     3777                if (CmtError::has_pending_error ())
     3778                  {
     3779                    CmtError::print ();
     3780                    CmtError::clear ();
     3781                  }
     3782                if (CmtError::ok != code)
     3783                  {
     3784                    // restore error occurred before value expansion
     3785                    CmtError::set (code,
     3786                                   (msg.replace (n + ": ", cmt_string ("")), msg),
     3787                                   exec_err);
     3788                  }
     3789                if (CommandPath != command_type &&
     3790                    rvalue.size () == 0)
     3791                  return result;
     3792              }
     3793            else
     3794              {
     3795                if (CommandPathRemove == command_type ||
     3796                    CommandPathRemoveRegexp == command_type)
     3797                  {
     3798                    // This means that the value is not resolved via symbols
     3799                    // and, possibly, standard environment variables and
     3800                    //   * either has no effect on the path at all,
     3801                    //     or
     3802                    //   * there should be similar contribution from
     3803                    //     and, hence, we should get the same error with
     3804                    //     CommandPath, CommandPathAppend, or CommandPathPrepend
     3805                    //  Either way, we can ignore this error.
     3806
     3807                    if (CmtMessage::active (Verbose))
     3808                      CmtError::print ();
     3809                    CmtError::clear ();
     3810                    if (CmtError::ok != code)
     3811                      {
     3812                        // restore error occurred before value expansion
     3813                        CmtError::set (code,
     3814                                       (msg.replace (n + ": ", cmt_string ("")), msg),
     3815                                       exec_err);
     3816                      }
     3817                  }
     3818                else if (CmtError::ok != code)
     3819                  {
     3820                    // print error occurred before value expansion
     3821                    CmtMessage::error (msg);
     3822                  }
     3823                // We keep CmtError::warning to indicate that
     3824                // we could not resolve path
     3825                // (without referencing the environment)
     3826                // and strip path of non-existent directories
     3827                //
     3828                rvalue = value.text;
     3829              }
     3830          }
     3831        else // (!pb->get_strip_path ())
     3832          {
     3833            if (CmtError::has_pending_error ())
     3834              {
     3835                code = CmtError::get_last_error_code ();
     3836                msg = CmtError::get_last_error ();
     3837                exec_err = CmtError::get_last_execution_error ();
     3838                n = CmtError::get_error_name (code);
     3839                CmtError::clear ();
     3840              }
     3841            resolve_value_for_macros (rvalue);
     3842            if (CmtError::get_last_error_code () != CmtError::warning)
     3843              {
     3844                if (CmtError::has_pending_error ())
     3845                  {
     3846                    CmtError::print ();
     3847                    CmtError::clear ();
     3848                  }
     3849                if (CmtError::ok != code)
     3850                  {
     3851                    // restore error occurred before value expansion
     3852                    CmtError::set (code,
     3853                                   (msg.replace (n + ": ", cmt_string ("")), msg),
     3854                                   exec_err);
     3855                  }
     3856                if (CommandPath != command_type &&
     3857                    rvalue.size () == 0)
     3858                  return result;
     3859              }
     3860            else
     3861              {
     3862                if (CmtMessage::active (Verbose))
     3863                  CmtError::print ();
     3864                CmtError::clear ();
     3865                if (CmtError::ok != code)
     3866                  {
     3867                    // restore error occurred before value expansion
     3868                    CmtError::set (code,
     3869                                   (msg.replace (n + ": ", cmt_string ("")), msg),
     3870                                   exec_err);
     3871                  }
     3872                // Ignore the error, keep the value unresolved
     3873                rvalue = value.text;
     3874              }
     3875          }
     3876
    33093877        break;
    33103878    }
     
    33173885
    33183886  if (CmtMessage::active (Verbose))
    3319     cout << "# Package " << (use != 0 ? use->get_package_name () + " " + use->version : "");
    3320   /*
    3321   if (use != 0)
    3322     {
    3323       cout << use->get_package_name () << " " << use->version;
    3324     }
    3325   */
     3887    out << "# Package " << (use ? use->get_package_name () + " " + use->version : "");
    33263888
    33273889  switch (command_type)
     
    33293891      case CommandSet :
    33303892        if (CmtMessage::active (Verbose))
    3331           cout << " " << define_text << " set " << symbol.name << " as " << endl;
    3332         //        cout << " " << define_text << " set " << symbol.name << " as ";
    3333         cout << "set " << symbol.name;
     3893          out << " " << define_text << " set " << symbol.name << " as " << endl;
     3894        //        out << " " << define_text << " set " << symbol.name << " as ";
     3895        out << "set " << symbol.name;
    33343896        first_definition = false;
    33353897        result = 1;
     
    33373899      case CommandSetAppend :
    33383900        if (CmtMessage::active (Verbose))
    3339           cout << " appends to set " << symbol.name << " : " << endl;
    3340         //        cout << " appends to set " << symbol.name << " : ";
    3341         cout << "set_append " << symbol.name;
     3901          out << " appends to set " << symbol.name << " : " << endl;
     3902        //        out << " appends to set " << symbol.name << " : ";
     3903        out << "set_append " << symbol.name;
    33423904        result = 1;
    33433905        break;
    33443906      case CommandSetPrepend :
    33453907        if (CmtMessage::active (Verbose))
    3346           cout << " prepends to set " << symbol.name << " : " << endl;
    3347         //        cout << " prepends to set " << symbol.name << " : ";
    3348         cout << "set_prepend " << symbol.name;
     3908          out << " prepends to set " << symbol.name << " : " << endl;
     3909        //        out << " prepends to set " << symbol.name << " : ";
     3910        out << "set_prepend " << symbol.name;
    33493911        result = 1;
    33503912        break;
    33513913      case CommandSetRemove :
    33523914        if (CmtMessage::active (Verbose))
    3353           cout << " removes from set " << symbol.name << " : " << endl;
    3354         //        cout << " removes from set " << symbol.name << " : ";
    3355         cout << "set_remove " << symbol.name;
     3915          out << " removes from set " << symbol.name << " : " << endl;
     3916        //        out << " removes from set " << symbol.name << " : ";
     3917        out << "set_remove " << symbol.name;
    33563918        result = 1;
    33573919        break;
    33583920      case CommandSetRemoveRegexp :
    33593921        if (CmtMessage::active (Verbose))
    3360           cout << " removes RE from set " << symbol.name << " : " << endl;
    3361         //        cout << " removes RE from set " << symbol.name << " : ";
    3362         cout << "set_remove_regexp " << symbol.name;
     3922          out << " removes RE from set " << symbol.name << " : " << endl;
     3923        //        out << " removes RE from set " << symbol.name << " : ";
     3924        out << "set_remove_regexp " << symbol.name;
    33633925        result = 1;
    33643926        break;
    33653927      case CommandAlias :
    33663928        if (CmtMessage::active (Verbose))
    3367           cout << " " << define_text << " alias " << symbol.name << endl;
    3368         //        cout << " " << define_text << " alias " << symbol.name << " as ";
    3369         cout << "alias " << symbol.name;
     3929          out << " " << define_text << " alias " << symbol.name << endl;
     3930        //        out << " " << define_text << " alias " << symbol.name << " as ";
     3931        out << "alias " << symbol.name;
    33703932        first_definition = false;
    33713933        result = 1;
    33723934        break;
    3373       case CommandPath :
     3935    case CommandPath :
    33743936        if (CmtMessage::active (Verbose))
    3375           cout << " " << define_text << " path " << symbol.name << endl;
    3376         //        cout << " " << define_text << " path " << symbol.name << " as ";
    3377         cout << "path " << symbol.name;
     3937          out << " " << define_text << " path " << symbol.name << endl;
     3938        //        out << " " << define_text << " path " << symbol.name << " as ";
     3939        pb->filter_path_value (symbol, rvalue);
     3940
     3941        if (Cmt::get_debug ())
     3942          {
     3943            cerr << "|SymbolValueList::print> path " << symbol.name
     3944                 << " " << value.text << " => " << rvalue << endl;
     3945          }
     3946
     3947        out << "path " << symbol.name;
    33783948        first_definition = false;
    33793949        result = 1;
     
    33813951      case CommandPathAppend :
    33823952        if (CmtMessage::active (Verbose))
    3383           cout << " appends to path " << symbol.name << endl;
    3384         //        cout << " appends to path " << symbol.name << " : ";
    3385         cout << "path_append " << symbol.name;
     3953          out << " appends to path " << symbol.name << endl;
     3954        //        out << " appends to path " << symbol.name << " : ";
     3955        pb->filter_path_value (symbol, rvalue);
     3956
     3957        if (Cmt::get_debug ())
     3958          {
     3959            cerr << "|SymbolValueList::print> path_append " << symbol.name
     3960                 << " " << value.text << " => " << rvalue << endl;
     3961          }
     3962
     3963        if (rvalue.size () == 0) return result;
     3964        out << "path_append " << symbol.name;
    33863965        result = 1;
    33873966        break;
    33883967      case CommandPathPrepend :
    33893968        if (CmtMessage::active (Verbose))
    3390           cout << " prepends to path " << symbol.name << " : " << endl;
    3391         //        cout << " prepends to path " << symbol.name << " : ";
    3392         cout << "path_prepend " << symbol.name;
     3969          out << " prepends to path " << symbol.name << " : " << endl;
     3970        //        out << " prepends to path " << symbol.name << " : ";
     3971        pb->filter_path_value (symbol, rvalue);
     3972
     3973        if (Cmt::get_debug ())
     3974          {
     3975            cerr << "|SymbolValueList::print> path_prepend " << symbol.name
     3976                 << " " << value.text << " => " << rvalue << endl;
     3977          }
     3978
     3979        if (rvalue.size () == 0) return result;
     3980        out << "path_prepend " << symbol.name;
    33933981        result = 1;
    33943982        break;
    33953983      case CommandPathRemove :
    33963984        if (CmtMessage::active (Verbose))
    3397           cout << " removes from path " << symbol.name << " : " << endl;
    3398         //        cout << " removes from path " << symbol.name << " : ";
    3399         cout << "path_remove " << symbol.name;
     3985          out << " removes from path " << symbol.name << " : " << endl;
     3986        //        out << " removes from path " << symbol.name << " : ";
     3987
     3988        if (Cmt::get_debug ())
     3989          {
     3990            cerr << "|SymbolValueList::print> path_remove " << symbol.name
     3991                 << " " << value.text << " => " << rvalue << endl;
     3992          }
     3993
     3994        out << "path_remove " << symbol.name;
    34003995        result = 1;
    34013996        break;
    34023997      case CommandPathRemoveRegexp :
    34033998        if (CmtMessage::active (Verbose))
    3404           cout << " removes RE from path " << symbol.name << " : " << endl;
    3405         //        cout << " removes RE from path " << symbol.name << " : ";
    3406         cout << "path_remove_regexp " << symbol.name;
     3999          out << " removes RE from path " << symbol.name << " : " << endl;
     4000        //        out << " removes RE from path " << symbol.name << " : ";
     4001
     4002        if (Cmt::get_debug ())
     4003          {
     4004            cerr << "|SymbolValueList::print> path_remove_regexp " << symbol.name
     4005                 << " " << value.text << " => " << rvalue << endl;
     4006          }
     4007
     4008        out << "path_remove_regexp " << symbol.name;
    34074009        result = 1;
    34084010        break;
    34094011      case CommandMacro :
    34104012        if (CmtMessage::active (Verbose))
    3411           cout << " " << define_text << " macro " << symbol.name << " as " << endl;
    3412         //        cout << " " << define_text << " macro " << symbol.name << " as ";
    3413         cout << "macro " << symbol.name;
     4013          out << " " << define_text << " macro " << symbol.name << " as " << endl;
     4014        //        out << " " << define_text << " macro " << symbol.name << " as ";
     4015        out << "macro " << symbol.name;
    34144016        result = 1;
    34154017        break;
    34164018      case CommandMacroPrepend :
    34174019        if (CmtMessage::active (Verbose))
    3418           cout << " prepends to macro " << symbol.name << " : " << endl;
    3419         //        cout << " prepends to macro " << symbol.name << " : ";
    3420         cout << "macro_prepend " << symbol.name;
     4020          out << " prepends to macro " << symbol.name << " : " << endl;
     4021        //        out << " prepends to macro " << symbol.name << " : ";
     4022        out << "macro_prepend " << symbol.name;
    34214023        result = 1;
    34224024        break;
    34234025      case CommandMacroAppend :
    34244026        if (CmtMessage::active (Verbose))
    3425           cout << " appends to macro " << symbol.name << " : " << endl;
    3426         //        cout << " appends to macro " << symbol.name << " : ";
    3427         cout << "macro_append " << symbol.name;
     4027          out << " appends to macro " << symbol.name << " : " << endl;
     4028        //        out << " appends to macro " << symbol.name << " : ";
     4029        out << "macro_append " << symbol.name;
    34284030        result = 1;
    34294031        break;
    34304032      case CommandMacroRemove :
    34314033        if (CmtMessage::active (Verbose))
    3432           cout << " remove from macro " << symbol.name << " : " << endl;
    3433         //        cout << " remove from macro " << symbol.name << " : ";
    3434         cout << "macro_remove " << symbol.name;
     4034          out << " remove from macro " << symbol.name << " : " << endl;
     4035        //        out << " remove from macro " << symbol.name << " : ";
     4036        out << "macro_remove " << symbol.name;
    34354037        result = 1;
    34364038        break;
    34374039      case CommandMacroRemoveRegexp :
    34384040        if (CmtMessage::active (Verbose))
    3439           cout << " remove RE from macro " << symbol.name << " : " << endl;
    3440         //        cout << " remove RE from macro " << symbol.name << " : ";
    3441         cout << "macro_remove_regexp " << symbol.name;
     4041          out << " remove RE from macro " << symbol.name << " : " << endl;
     4042        //        out << " remove RE from macro " << symbol.name << " : ";
     4043        out << "macro_remove_regexp " << symbol.name;
    34424044        result = 1;
    34434045        break;
    34444046      case CommandMacroRemoveAll :
    34454047        if (CmtMessage::active (Verbose))
    3446           cout << " remove all from macro " << symbol.name << " : " << endl;
    3447         //        cout << " remove all from macro " << symbol.name << " : ";
    3448         cout << "macro_remove_all " << symbol.name;
     4048          out << " remove all from macro " << symbol.name << " : " << endl;
     4049        //        out << " remove all from macro " << symbol.name << " : ";
     4050        out << "macro_remove_all " << symbol.name;
    34494051        result = 1;
    34504052        break;
    34514053      case CommandMacroRemoveAllRegexp :
    34524054        if (CmtMessage::active (Verbose))
    3453           cout << " remove all RE from macro " << symbol.name << " : " << endl;
    3454         //        cout << " remove all RE from macro " << symbol.name << " : ";
    3455         cout << "macro_remove_all_regexp " << symbol.name;
     4055          out << " remove all RE from macro " << symbol.name << " : " << endl;
     4056        //        out << " remove all RE from macro " << symbol.name << " : ";
     4057        out << "macro_remove_all_regexp " << symbol.name;
    34564058        result = 1;
    34574059        break;
    34584060      case CommandSetupScript :
    34594061        if (CmtMessage::active (Verbose))
    3460           cout << " " << define_text << " setup script " << symbol.name << endl;
    3461         //       cout << " " << define_text << " action " << symbol.name << " as ";
    3462         cout << "setup_script" /* << symbol.name */;
     4062          out << " " << define_text << " setup script " << symbol.name << endl;
     4063        //       out << " " << define_text << " action " << symbol.name << " as ";
     4064        out << "setup_script" /* << symbol.name */;
    34634065        first_definition = false;
    34644066        result = 1;
     
    34664068        /*
    34674069      case CommandAction :
    3468         cout << " " << define_text << " action " << symbol.name << " as ";
     4070        out << " " << define_text << " action " << symbol.name << " as ";
    34694071        first_definition = false;
    34704072        break;
     
    34724074    }
    34734075
    3474   cout << " " << CmtSystem::quote (value.text, " \t");
    3475   //  cout << "'" << value.text << "'";
     4076  out << " " << CmtSystem::quote (rvalue, " \t");
     4077  //  out << " " << CmtSystem::quote (value.text, " \t");
     4078  //  out << "'" << value.text << "'";
    34764079         
    34774080  /*
     
    34814084      (selected_tag == Tag::get_default ()))
    34824085    {
    3483       cout << " for default tag";
     4086      out << " for default tag";
    34844087    }
    34854088  else
    34864089    {
    3487       cout << " for tag '" << selected_tag->get_name () << "'";
     4090      out << " for tag '" << selected_tag->get_name () << "'";
    34884091    }
    34894092  */
    34904093
    3491   cout << endl;
    3492   //  cout << discarded_text << endl;
     4094  out << endl;
     4095  //  out << discarded_text << endl;
    34934096  return result;
    34944097}
     
    35474150  else
    35484151    {
     4152                if (Cmt::get_env_access () ||
     4153                    Symbol::std_env_vars ().has (name))
     4154                  {
    35494155      s = CmtSystem::getenv (name);
     4156                    if (Cmt::get_debug ())
     4157                      {
     4158                        cerr << "Symbol::get_env_value> getenv (" << name
     4159                             << ") => " << s << endl;
     4160                      }
     4161                  }
     4162                else
     4163                  {
     4164                    if (Cmt::get_debug ())
     4165                      {
     4166                        cerr << "Symbol::get_env_value> getenv (" << name
     4167                             << ") denied" << endl;
     4168                      }
     4169                    CmtError::set (CmtError::warning,
     4170                                   "getenv (" + name + ") denied");
     4171                    return (s);
     4172                  }
    35504173    }
    35514174
  • CMT/v1r25-branch/source/cmt_symbol.h

    r588 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    3435  int select_last () const;
    3536  void show (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const;
    36   int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition) const;
     37  int print (const Symbol& symbol, const SymbolValue& value, bool& first_definition, ostream& out = cout) const;
    3738
    3839  CommandType command_type;
     
    8990
    9091  static void all_set ();
    91   static void all_print (PrintMode mode);
     92  static void all_print (PrintMode mode, ostream& out = cout);
     93  //static void all_print (PrintMode mode);
    9294  static void all_print_clean (PrintMode mode);
    9395  static void check_all_paths ();
     
    9698  static SymbolVector& symbols ();
    9799  static SymbolMap& symbol_map ();
     100  static SymbolMap& std_env_vars ();
    98101  static Symbol& symbol (int index);
    99102  static void clear_all ();
     
    107110
    108111  static bool get_inhibit_display ();
     112  static bool set_strip_path (const bool& strip_path);
    109113
    110114public:
     
    118122
    119123  int print_clean (PrintMode mode);
    120   int print (PrintMode mode);
     124  int print (PrintMode mode, ostream& out = cout);
     125  //int print (PrintMode mode);
    121126  cmt_string build_macro_value (bool display_it = false) const;
    122127  int print_macro (PrintMode mode, ostream& out = cout) const;
  • CMT/v1r25-branch/source/cmt_syntax.cxx

    r607 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    212213               int line_number)
    213214  {
    214        
     215    /*       
    215216    cmt_string cmtpath;
    216217    cmt_string offset;
     
    219220
    220221    Project* p = Project::find_by_cmtpath (cmtpath);
     222    */
     223    Project* p = const_cast<Project*>(use->get_project ());
     224    //    const Project* p = use->get_project ();
    221225
    222226    for (int i = 1; i < words.size (); i++)
     
    287291          {
    288292            in_error = true;
    289 
    290             CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
     293            char num[32]; sprintf (num, "%d", line_number);
     294            CmtError::set (CmtError::syntax_error,
     295                           project->get_name ()
     296                           + " project file: " + file_name
     297                           + ": line: " + num
     298                           + ": " + value + ": Bad strategy value");
     299            //CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    291300          }
    292301      }
     
    10601069               int line_number)
    10611070  {
     1071    /*
    10621072    cmt_string cmtpath;
    10631073    cmt_string offset;
     
    10661076
    10671077    Project* p = Project::find_by_cmtpath (cmtpath);
     1078    */
     1079    Project* p = const_cast<Project*>(use->get_project ());
     1080    //    const Project* p = use->get_project ();
    10681081
    10691082    for (int i = 1; i < words.size (); i++)
     
    11261139          {
    11271140            in_error = true;
    1128 
    1129             CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
     1141            char num[32]; sprintf (num, "%d", line_number);
     1142            CmtError::set (CmtError::syntax_error,
     1143                           project->get_name ()
     1144                           + " project file: " + file_name
     1145                           + ": line: " + num
     1146                           + ": " + value + ": Bad strategy value");
     1147            //CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    11301148          }
    11311149      }
     
    11641182               int line_number)
    11651183  {
     1184    /*
    11661185    cmt_string cmtpath;
    11671186    cmt_string offset;
     
    11701189
    11711190    Project* p = Project::find_by_cmtpath (cmtpath);
     1191    */
     1192    Project* p = const_cast<Project*>(use->get_project ());
     1193    //    const Project* p = use->get_project ();
    11721194
    11731195    for (int i = 1; i < words.size (); i++)
     
    12311253          {
    12321254            in_error = true;
    1233 
    1234             CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
     1255            char num[32]; sprintf (num, "%d", line_number);
     1256            CmtError::set (CmtError::syntax_error,
     1257                           project->get_name ()
     1258                           + " project file: " + file_name
     1259                           + ": line: " + num
     1260                           + ": " + value + ": Bad strategy value");
     1261            //CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword");
    12351262          }
    12361263      }
     
    14031430      //
    14041431     
    1405       Project* p = use->get_project ();
     1432      const Project* p = use->get_project ();
    14061433      if (p != 0)
    14071434        {     
     
    20542081
    20552082  keyword->action (words, project, file_name, line_number);
     2083
     2084  if (CmtError::get_last_error_code () == CmtError::syntax_error)
     2085    CmtError::print ();
    20562086}
  • CMT/v1r25-branch/source/cmt_system.cxx

    r610 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_system.h

    r610 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_tag.cxx

    r568 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    99100
    100101  Log;
     102
     103  const CmtSystem::cmt_string_vector& tags_remove = Cmt::get_tags_remove ();
     104  for (int i = tags_remove.size () - 1; i >= 0; i--)
     105    if (tags_remove[i] == m_name) return;
    101106
    102107  if (m_tag_excludes.size () > 0)
     
    231236
    232237      tag->mark (use ? use->get_package_name () : "");
     238
     239      Use::UsePtrVector * puses;
     240      if (!(puses = apply_tag ().find (tag)))
     241        {
     242          Use::UsePtrVector uses;
     243          uses.push_back (use);
     244          apply_tag ().add (tag, uses);
     245        }
     246      else
     247        {
     248          bool have (false);
     249          for (int i = 0; i < puses->size (); i++)
     250            {
     251              if ((*puses)[i] == use)
     252                {
     253                  have = true;
     254                  break;
     255                }
     256            }
     257          if (!have)
     258            puses->push_back (use);
     259        }
     260
    233261    }
    234262}
     
    603631  if (tag->m_tag_refs.size () > 0) return (true);
    604632  if (tag->m_tag_excludes.size () > 0) return (true);
     633  if (apply_tag ().has (tag)) return (true);
    605634
    606635  return (false);
     636}
     637
     638/*----------------------------------------------------------*/
     639Tag::TagUses& Tag::apply_tag ()
     640{
     641  static TagUses tag_uses;
     642  return tag_uses;
    607643}
    608644
     
    823859          out << "]";
    824860        }
     861
     862      if (Use::UsePtrVector * puses = apply_tag ().find (this))
     863        {
     864          out << " applied [";
     865          for (int i = 0; i < puses->size (); i++)
     866            {
     867              if (i > 0) out << " ";
     868              Use * use = (*puses)[i];
     869              if (use)
     870                {
     871                  out << use->get_package_name ();
     872                }
     873              else
     874                {
     875                  out << "current";
     876                }
     877            }
     878          out << "]";
     879        }
     880
    825881      if (m_act_context.size () != 0 &&
    826882          (m_def_use != 0 &&
  • CMT/v1r25-branch/source/cmt_tag.h

    r568 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
     
    1920  typedef cmt_vector<Tag> TagVector;
    2021  typedef cmt_vector<Tag*> TagPtrVector;
     22
     23  typedef cmt_vmap<const Tag*, Use::UsePtrVector> TagUses;
    2124
    2225  static void action (const CmtSystem::cmt_string_vector& words, Use* use);
     
    4043
    4144  static bool check_tag_used (const Tag* tag);
     45
     46  static TagUses& apply_tag ();
    4247
    4348public:
  • CMT/v1r25-branch/source/cmt_triggers.cxx

    r459 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_use.cxx

    r610 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    18261827  m_located = false;
    18271828  m_package = 0;
     1829  m_project = 0;
    18281830  m_index = -1;
    18291831
     
    18481850      m_package = 0;
    18491851    }
     1852  m_project = 0;
    18501853
    18511854  version   = "";
     
    19231926
    19241927//----------------------------------------------------------
    1925 void Use::change_path (const cmt_string& new_path)
     1928void Use::change_path (const cmt_string& new_path, const Project* project)
    19261929{
    19271930  //
     
    19291932  // where this package/version has been found.
    19301933  //
     1934  if (Cmt::get_debug ())
     1935    {
     1936      cout << "|Use::change_path> path: " << new_path
     1937           << " project: " << (project ? project->get_cmtpath () : "0")
     1938           << " use: " << get_info () << endl;
     1939    }
    19311940
    19321941  real_path = "";
    19331942  m_realpath = "";
    19341943
    1935   if (new_path != "")
     1944  m_project = 0;
     1945
     1946  if (new_path.size () != 0)
     1947    //  if (new_path != "")
    19361948    {
    19371949      if ((path.size () > 0) &&
     
    19511963      if (!CmtSystem::realpath_ (real_path, m_realpath))
    19521964        {
    1953           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    1954                          real_path + "'");
     1965          CmtError::set (CmtError::file_access_error,
     1966                         "Cannot compute real path `" + real_path + "': " +
     1967                         get_info ());
    19551968          CmtError::print ();
    19561969          return;
     
    19581971    }
    19591972 
     1973  if (project)
     1974    m_project = project;
     1975
    19601976  m_located = true;
     1977
     1978  if (Cmt::get_debug ())
     1979    {
     1980      cout << "<Use::change_path| real_path: " << real_path
     1981           << " m_project: " << (m_project ? m_project->get_cmtpath () : "0")
     1982           << " use: " << get_info () << endl;
     1983    }
    19611984}
    19621985
     
    23472370          }
    23482371       
    2349         m_use->change_path (path);
     2372        m_use->change_path (path, &project);
    23502373
    23512374        m_found = true;
     
    23552378    else if (m_use->alternate_versions.size () > 0)
    23562379      {
    2357         if (m_use->select_alternate ())
     2380        if (m_use->select_alternate (&project))
    23582381          {
    23592382            if (Cmt::get_debug ())
     
    24482471              cout << "move_to2> " << expanded_path << endl;
    24492472            }
    2450 
    24512473          change_path (here);
    2452 
    24532474          return (true);
    24542475        }
     
    24612482                  cout << "move_to5> " << real_path << endl;
    24622483                }
    2463              
    24642484              return (true);
    24652485            }
    24662486        }
     2487
     2488      if (!CmtSystem::cd (here))
     2489        {
     2490          CmtError::set (CmtError::file_access_error, here);
     2491        }
    24672492      return (false);
    24682493//     }
     
    24822507
    24832508//----------------------------------------------------------
    2484 bool Use::select_alternate ()
     2509bool Use::select_alternate (const Project* project)
    24852510{
    24862511  int i;
     
    25672592                }
    25682593
    2569               change_path (alternate_paths[selected_index]);
     2594              change_path (alternate_paths[selected_index], project);
    25702595              return (true);
    25712596            }
     
    35683593  offset = "";
    35693594
    3570   cmtpath = m_realpath.size ()
    3571     ? Project::find_in_cmt_paths (m_realpath, true)
    3572     : Project::find_in_cmt_paths (real_path)
    3573     ;
    3574   const Project* p = Project::find_by_cmtpath (cmtpath);
    3575 
     3595  const Project* p (0);
     3596  if (m_project)
     3597    {
     3598      p = m_project;
     3599      cmtpath = p->get_cmtpath ();
     3600    }
     3601  else
     3602    {
     3603      cmtpath = m_realpath.size ()
     3604        ? Project::find_in_cmt_paths (m_realpath, true)
     3605        : Project::find_in_cmt_paths (real_path)
     3606        ;
     3607      p = Project::find_by_cmtpath (cmtpath);
     3608  //  const Project* p = Project::find_by_cmtpath (cmtpath);
     3609    }
    35763610  //  if (cmtpath != "")
    35773611  if (p != 0)
     
    35903624      else if (!CmtSystem::realpath_ (real_path, offset))
    35913625        {
    3592           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    3593                          real_path + "'");
     3626          CmtError::set (CmtError::file_access_error,
     3627                         "Cannot compute real path `" + real_path + "': " +
     3628                         get_info ());
    35943629          CmtError::print ();
    35953630          return;
     
    36193654bool Use::get_strategy (const cmt_string& name) const
    36203655{
    3621   const Project* p =
     3656  const Project* p = get_project ();
     3657    /*
    36223658    Project::find_by_cmtpath (m_realpath.size ()
    36233659                              ? Project::find_in_cmt_paths (m_realpath, true)
    36243660                              : Project::find_in_cmt_paths (real_path)
    36253661                              );
    3626   //  const Project* p = Project::find_by_cmtpath (Project::find_in_cmt_paths (real_path));
     3662    */
    36273663
    36283664  bool strategy;
     
    37053741  buffer += "\n";
    37063742
    3707   if (located ())
     3743  if (m_located)
     3744    //  if (located ())
    37083745    {
    37093746      buffer += "macro ";
     
    37253762          buffer += package_name;
    37263763        }
    3727       //      if (style != no_version_style)
    37283764      if (structuring_style == with_version_directory)
    37293765        {
     
    37333769      buffer += "\"";
    37343770      buffer += "\n";
     3771    }
     3772
     3773  if (action_setup == Cmt::get_action () &&
     3774      Requirements == Cmt::get_print_mode ())
     3775    {
     3776      //cerr << "|Use::fill_standard_macros> Checking for " << prefix << "CONFIG" << endl;
     3777      if (!discarded &&
     3778          get_package_name () != "cmt_standalone" &&
     3779          get_strategy ("SetupConfig"))
     3780        {
     3781          buffer += "macro ";
     3782          buffer += prefix;
     3783          buffer += "CONFIG";
     3784          buffer += " \"";
     3785          buffer += CmtSystem::get_cmt_config ();
     3786          buffer += "\"";
     3787          buffer += "\n";
     3788        }
    37353789    }
    37363790
     
    37643818  buffer += "\n";
    37653819 
    3766   Project* p = Project::find_by_cmtpath (cmtpath);
     3820  const Project* p = m_project
     3821    ? m_project
     3822    : Project::find_by_cmtpath (cmtpath)
     3823    ;
     3824  /*
     3825  const Project* p (m_project);
     3826  if (!p)
     3827    p = Project::find_by_cmtpath (cmtpath);
     3828  */
    37673829
    37683830  buffer += "macro ";
     
    45204582  static const cmt_string null = "";
    45214583
     4584  return m_package ? m_package->get_name () : null ;
     4585  /*
    45224586  Package* p = m_package;
    45234587  if (p == 0) return (null);
    45244588
    45254589  return (p->get_name ());
     4590  */
    45264591}
    45274592
     
    48294894
    48304895  return (is_in_path);
    4831 }
    4832 
    4833 //----------------------------------------------------------
    4834 bool Use::located () const
    4835 {
    4836   return (m_located);
    48374896}
    48384897
     
    57365795
    57375796//----------------------------------------------------------
    5738 Project* Use::get_project ()
     5797const Project* Use::get_project () const
    57395798{   
     5799  if (m_project)
     5800    return m_project;
     5801
     5802  return Project::find_by_cmtpath (m_realpath.size ()
     5803                                   ? Project::find_in_cmt_paths (m_realpath, true)
     5804                                   : Project::find_in_cmt_paths (real_path)
     5805                                   );
     5806  /*
     5807  cmt_string cmtpath = m_realpath.size ()
     5808    ? Project::find_in_cmt_paths (m_realpath, true)
     5809    : Project::find_in_cmt_paths (real_path)
     5810    ;
     5811  return Project::find_by_cmtpath (cmtpath);
     5812  */
     5813  /*
    57405814  Project* p;
    57415815  cmt_string cmtpath = "";
     
    57445818  p = Project::find_by_cmtpath (cmtpath);
    57455819  return p;   
     5820  */
    57465821}
    57475822
  • CMT/v1r25-branch/source/cmt_use.h

    r608 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
     
    128129  bool get_paths (Use* to, UsePtrVector& list);
    129130
    130   bool located () const;
    131 
    132   void change_path (const cmt_string& path);
     131  inline bool located () const { return m_located; }
     132
     133  void change_path (const cmt_string& path, const Project* project = 0);
    133134  void set_auto_imports (State context_state, State specified_state,
    134135                         cmt_map <Use*, bool>& visited);
     
    153154  ScopeType get_current_scope () const;
    154155
    155   Project* get_project ();
     156  const Project* get_project () const;
     157  inline void set_project (const Project* project) { m_project = project; }
    156158  cmt_string get_info () const;
    157159  bool is_head_version (const cmt_string& version);
     
    182184  bool discarded;                /* discarded by version strategy   */
    183185  bool selected;                 /* used for recursive access       */
    184   bool m_located;
     186  //  bool m_located;
    185187  bool m_hidden;
    186188  ScopeType initial_scope;
     
    213215                      bool skip_discarded = false, ostream& out = cout);
    214216  //  void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
    215   bool select_alternate ();
     217  bool select_alternate (const Project* project = 0);
    216218  Use* get_selected_version ();
    217219  Use* set_selected_version (Use* selected_use);
     
    235237  //cmt_string m_package_name; /* directly read from requirements */
    236238
     239  //  Project* m_project;  /* the project the use is found in */
     240  const Project* m_project;  /* the project the use is found in */
     241
     242  bool m_located;
     243
    237244  bool m_has_native_version;
    238245
  • CMT/v1r25-branch/source/cmt_vcs.cxx

    r590 r664  
    33// arnault@lal.in2p3.fr
    44// Modified by: garonne@lal.in2p3.fr
     5// Modified by Grigory Rybkin
    56// See the complete license in cmt_license.txt "http://www.cecill.info".
    67//-----------------------------------------------------------
  • CMT/v1r25-branch/source/cmt_vcs.h

    r535 r664  
    22// Copyright Christian Arnault LAL-Orsay CNRS
    33// arnault@lal.in2p3.fr
     4// Modified by Grigory Rybkin
    45// See the complete license in cmt_license.txt "http://www.cecill.info".
    56//-----------------------------------------------------------
  • CMT/v1r25-branch/src/Makefile.core

    r616 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
     4# Modified by Grigory Rybkin
    45# See the complete license in cmt_license.txt "http://www.cecill.info".
    56#-----------------------------------------------------------
  • CMT/v1r25-branch/src/Makefile.header

    r616 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
     4# Modified by Grigory Rybkin
    45# See the complete license in cmt_license.txt "http://www.cecill.info".
    56#-----------------------------------------------------------
     
    198199        @echo
    199200ifndef BCAST_GLOBAL
    200         @uses=`$(cmtexe) -private show macros '_project$$|package$$' -tag=$(tags)| \
    201           awk -F = '{if ($$1 ~ /_project$$/) {uses[substr($$1,1,length($$1)-8)]=$$2}else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}}END{for (u in uses){if (uses[u]==uses[cur]) print u}}'`; \
     201        @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \
     202          awk -F = '{if ($$1 ~ /_project$$/) {p = $$2;gsub("'\''","",p);uses[substr($$1,1,length($$1)-8)]=p} else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}else if ($$1 ~ /_offset$$/) {u = substr($$1,1,length($$1)-7);if (!(u in uses))uses[u]=""}}END{for (u in uses){if ((uses[cur] != "" && uses[u] == uses[cur] || u == cur) && u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}}'`; \
    202203          for u in $${uses}; do \
    203204            echo "$${u} : (re)build package $${u} ($(_groups))"; \
     
    208209          done
    209210else
    210         @uses=`$(cmtexe) -private show macros '_root$$' -tag=$(tags)| \
    211           awk -F = '{u=substr($$1,1,length($$1)-5);if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}'`; \
     211        @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \
     212          awk -F = '{if ($$1 ~ /_project$$/) {p = $$2;gsub("'\''","",p);uses[substr($$1,1,length($$1)-8)]=p} else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}else if ($$1 ~ /_offset$$/) {u = substr($$1,1,length($$1)-7);if (!(u in uses))uses[u]=""}}END{for (u in uses){if (uses[u] != uses[cur] && (uses[u] == "CMTHOME" || uses[u] == "CMTUSERCONTEXT")) {continue} else if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}}'`; \
    212213          for u in $${uses}; do \
    213214            echo "$${u} : (re)build package $${u} ($(_groups))"; \
  • CMT/v1r25-branch/src/NMakefile.core

    r595 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
     4# Modified by Grigory Rybkin
    45# See the complete license in cmt_license.txt "http://www.cecill.info".
    56#-----------------------------------------------------------
  • CMT/v1r25-branch/src/NMakefile.header

    r595 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
     4# Modified by Grigory Rybkin
    45# See the complete license in cmt_license.txt "http://www.cecill.info".
    56#-----------------------------------------------------------
  • CMT/v1r25-branch/src/cleanup.csh

    r11 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
     4# Modified by Grigory Rybkin
    45# See the complete license in cmt_license.txt "http://www.cecill.info".
    56#-----------------------------------------------------------
    67
    7 set newpath=
     8unsetenv CMTBIN
     9unsetenv CMTCONFIG
    810
    9 foreach p ( `echo ${PATH} | sed 's#:# #g'` )
    10   echo ${p} | egrep '/CMT/' >& /dev/null
    11   set s=${status}
    12   if ( "${s}" != 0 ) then
    13     if ( ${newpath} == "" ) then
    14       set newpath=${p}
     11if ( $?CMTROOT == 1 ) then
     12if ( $?0 == 0 ) then
     13if ( $?tcsh == 1 ) then
     14  source ${CMTROOT}/src/cleanup.tcsh
     15else if ( "${shell:t}" == "tcsh" ) then
     16  source ${CMTROOT}/src/cleanup.tcsh
     17endif
     18endif
     19endif
     20
     21unsetenv CMTROOT
     22
     23# Remove CMT entries, if any
     24set newpath=()
     25foreach p (${path:q})
     26  if ( "${p}" !~ "*/CMT/*" ) then
     27    if ( ${#newpath} != 0 ) then
     28      set newpath=(${newpath:q} ${p:q})
    1529    else
    16       set newpath=${newpath}:${p}
     30      set newpath=(${p:q})
    1731    endif
    1832  endif
    1933end
    2034
    21 setenv PATH ${newpath}
    22 unsetenv CMTCONFIG
    23 unsetenv CMTROOT
     35set path=(${newpath:q})
     36unset newpath
    2437
     38unalias cmt
     39
     40if ( $?CLASSPATH == 1 ) then
     41if ( "${CLASSPATH}" =~ "*/CMT/*" ) then
     42# Remove CMT entries
     43  set _p="${CLASSPATH}"
     44  while ( "$_p" =~ "*:*" )
     45  set _p="${_p:s/:/ /}"
     46  end
     47
     48  set newpath=
     49  foreach p (${_p})
     50    if ( "${p}" !~ "*/CMT/*" ) then
     51      if ( "${newpath}" != "" ) then
     52        set newpath=${newpath}:${p}
     53      else
     54        set newpath=${p}
     55      endif
     56    endif
     57  end
     58
     59  if ( "${newpath}" != "" ) then
     60    setenv CLASSPATH ${newpath}
     61  else
     62    unsetenv CLASSPATH
     63  endif
     64  unset _p newpath
     65endif
     66endif
     67
     68unalias jcmt
     69
     70# Unset MAKEFLAGS, if looks set by CMT
     71if ( $?MAKEFLAGS == 1 ) then
     72if ( "$MAKEFLAGS" =~ "*QUICK=1" ) then
     73  unsetenv MAKEFLAGS
     74endif
     75endif
  • CMT/v1r25-branch/src/cleanup.sh

    r11 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
     4# Modified by Grigory Rybkin
    45# See the complete license in cmt_license.txt "http://www.cecill.info".
    56#-----------------------------------------------------------
    67
    7 newpath=""
    8 for p in `echo ${PATH} | sed 's/:/ /g'`; do
    9   if test ! "`echo ${p} | egrep CMT`" ; then
    10     if test "${newpath}" = "" ; then
    11       newpath=${p}
    12     else
    13       newpath=${newpath}:${p}
     8[ -z ${CMTBIN+CMT} ] || unset CMTBIN
     9[ -z ${CMTCONFIG+CMT} ] || unset CMTCONFIG
     10
     11if [ "${CMTROOT+CMT}" = CMT ]; then
     12if [ -n "$-" ] && [ "${-#*i}" != "$-" ]; then
     13if [ -n "${ZSH_NAME-}" ]; then
     14  . ${CMTROOT}/src/cleanup.zsh
     15elif [ -n "${BASH-}" ]; then
     16  . ${CMTROOT}/src/cleanup.bash
     17fi
     18fi
     19fi
     20
     21[ -z ${CMTROOT+CMT} ] || unset CMTROOT
     22
     23cmt_clean_path()
     24{
     25# Remove CMT entries, if any
     26  _np=
     27  _p="$1"
     28  while [ -n "$_p" ]; do
     29    __p="${_p#:}"
     30    while [ "$__p" != "$_p" ]; do
     31      _p="${__p}"
     32      __p="${_p#:}"
     33    done
     34    _e="${_p%%:*}"
     35    _p="${_p#${_e}}"
     36    if [ "${_e%/CMT/*}" = "${_e}" ] && [ -n "${_e}" ]; then
     37      if [ -n "${_np}" ]; then
     38        _np="${_np}:${_e}"
     39      else
     40        _np="${_e}"
     41      fi
    1442    fi
     43  done
     44  echo "$_np"
     45  unset _np _p __p _e
     46}
     47
     48if [ "${PATH%/CMT/*}" != "${PATH}" ]; then
     49  newpath=`cmt_clean_path "${PATH}"`
     50  PATH=${newpath}
     51  unset newpath
     52fi
     53
     54if alias cmt >/dev/null 2>&1; then
     55  unalias cmt
     56fi
     57
     58if [ -n "${CLASSPATH-}" ]; then
     59if [ "${CLASSPATH%/CMT/*}" != "${CLASSPATH}" ]; then
     60  newpath=`cmt_clean_path "${CLASSPATH}"`
     61  if [ -n "${newpath}" ]; then
     62    CLASSPATH=${newpath}
     63  else
     64    unset CLASSPATH
    1565  fi
    16 done
     66  unset newpath
     67fi
     68fi
    1769
    18 PATH=${newpath}; export PATH
     70if alias jcmt >/dev/null 2>&1; then
     71  unalias jcmt
     72fi
    1973
    20 CMTCONFIG=; export CMTCONFIG
    21 CMTROOT=; export CMTROOT
     74unset -f cmt_clean_path
     75
     76# Unset MAKEFLAGS, if looks set by CMT
     77if [ "${MAKEFLAGS+CMT}" = CMT ]; then
     78if [ "${MAKEFLAGS%QUICK=1}" != "${MAKEFLAGS}" ]; then
     79  unset MAKEFLAGS
     80fi
     81fi
  • CMT/v1r25-branch/src/setup.csh

    r612 r664  
    66#-----------------------------------------------------------
    77
    8 setenv CMTBIN `uname`-`uname -m | tr -d ' '`
     8# Remove spaces, if any
     9set _m="`uname -m`"
     10while ( "$_m" =~ "* *" )
     11set _m="${_m:s/ //}"
     12end
     13setenv CMTBIN `uname`-"$_m"
     14unset _m
    915
    1016if ( $?CMTCONFIG == 0 ) then
     
    1521if ( $?tcsh == 1 ) then
    1622  source ${CMTROOT}/src/setup.tcsh
    17 else if ( `basename "$shell"` == "tcsh" ) then
     23else if ( "${shell:t}" == "tcsh" ) then
    1824  source ${CMTROOT}/src/setup.tcsh
    1925endif
    2026endif
    2127
     28# Remove CMT entries, if any
    2229set newpath=()
    23 foreach p (${path})
     30foreach p (${path:q})
    2431  if ( "${p}" !~ "*/CMT/*" ) then
    2532    if ( ${#newpath} != 0 ) then
    26       set newpath=(${newpath} ${p})
     33      set newpath=(${newpath:q} ${p:q})
    2734    else
    28       set newpath=(${p})
     35      set newpath=(${p:q})
    2936    endif
    3037  endif
    3138end
    3239
    33 set path=(${newpath} "${CMTROOT}/${CMTBIN}")
     40set path=(${newpath:q} "${CMTROOT}/${CMTBIN}")
     41unset newpath
     42
    3443alias cmt '${CMTROOT}/${CMTBIN}/cmt.exe'
    35 unset newpath
    3644
    3745if ( $?CLASSPATH == 0 ) then
     
    4250  setenv CLASSPATH ${CLASSPATH}:${CMTROOT}/java/cmt.jar
    4351else
     52# Remove CMT entries
     53  set _p="${CLASSPATH}"
     54  while ( "$_p" =~ "*:*" )
     55  set _p="${_p:s/:/ /}"
     56  end
     57
    4458  set newpath=
    45   foreach p ( `echo ${CLASSPATH} | tr ':' ' '` )
     59  foreach p (${_p})
    4660    if ( "${p}" !~ "*/CMT/*" ) then
    4761      if ( "${newpath}" != "" ) then
     
    5872    setenv CLASSPATH ${CMTROOT}/java/cmt.jar
    5973  endif
    60   unset newpath
     74  unset _p newpath
    6175endif
    6276
  • CMT/v1r25-branch/src/setup.sh

    r611 r664  
    66#-----------------------------------------------------------
    77
    8 CMTBIN=`uname`-`uname -m | tr -d ' '`; export CMTBIN
     8# Remove spaces, if any
     9_m="`uname -m`"
     10_nm=
     11while [ -n "$_m" ]; do
     12  _t="${_m#?}"
     13  _a="${_m%${_t}}"
     14  if [ "${_a}" != " " ]; then
     15    _nm="${_nm}${_a}"
     16  fi
     17  _m="$_t"
     18done
     19CMTBIN=`uname`-"$_nm"; export CMTBIN
     20unset _m _nm _t _a
    921
    1022if test "${CMTCONFIG}" = "" ; then
     
    2032fi
    2133
     34cmt_clean_path()
     35{
     36# Remove CMT entries, if any
     37  _np=
     38  _p="$1"
     39  while [ -n "$_p" ]; do
     40    __p="${_p#:}"
     41    while [ "$__p" != "$_p" ]; do
     42      _p="${__p}"
     43      __p="${_p#:}"
     44    done
     45    _e="${_p%%:*}"
     46    _p="${_p#${_e}}"
     47    if [ "${_e%/CMT/*}" = "${_e}" ] && [ -n "${_e}" ]; then
     48      if [ -n "${_np}" ]; then
     49        _np="${_np}:${_e}"
     50      else
     51        _np="${_e}"
     52      fi
     53    fi
     54  done
     55  echo "$_np"
     56  unset _np _p __p _e
     57}
     58
    2259if [ "${PATH%/CMT/*}" = "${PATH}" ]; then
    2360  PATH=${PATH}:${CMTROOT}/${CMTBIN}; export PATH
    2461else
    25   newpath=
    26   for p in `echo ${PATH} | tr ':' ' '`; do
    27     if [ "${p%/CMT/*}" = "${p}" ]; then
    28       if [ -n "${newpath}" ]; then
    29         newpath=${newpath}:${p}
    30       else
    31         newpath=${p}
    32       fi
    33     fi
    34   done
    35 
     62  newpath=`cmt_clean_path "${PATH}"`
    3663  PATH=${newpath}:${CMTROOT}/${CMTBIN}; export PATH
    3764  unset newpath
    3865fi
    3966
    40 alias cmt='${CMTROOT}/${CMTBIN}/cmt.exe'; export cmt
     67alias cmt='${CMTROOT}/${CMTBIN}/cmt.exe'
    4168
    4269if [ -z "${CLASSPATH-}" ]; then
     
    4572  CLASSPATH=${CLASSPATH}:${CMTROOT}/java/cmt.jar; export CLASSPATH
    4673else
    47   newpath=
    48   for p in `echo ${CLASSPATH-} | tr ':' ' '`; do
    49     if [ "${p%/CMT/*}" = "${p}" ]; then
    50       if [ -n "${newpath}" ]; then
    51         newpath=${newpath}:${p}
    52       else
    53         newpath=${p}
    54       fi
    55     fi
    56   done
    57 
     74  newpath=`cmt_clean_path "${CLASSPATH}"`
    5875  if [ -n "${newpath}" ]; then
    5976    CLASSPATH=${newpath}:${CMTROOT}/java/cmt.jar; export CLASSPATH
     
    6481fi
    6582
    66 alias jcmt='(java cmt_parser)'; export jcmt
     83alias jcmt='(java cmt_parser)'
     84
     85unset -f cmt_clean_path
    6786
    6887# Set MAKEFLAGS, if unset (similar to NPROC with Plan 9 mk utility)
  • CMT/v1r25-branch/src/setup.tcsh

    r612 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
    4 # Modified by garonne@lal.in2p3.fr, Grigory Rybkin
     4# Modified by garonne@lal.in2p3.fr
     5# Modified by Grigory Rybkin
    56# See the complete license in cmt_license.txt "http://www.cecill.info".
    67#-----------------------------------------------------------
  • CMT/v1r25-branch/src/setup.zsh

    r612 r664  
    22# Copyright Christian Arnault LAL-Orsay CNRS
    33# arnault@lal.in2p3.fr
    4 # Modified by garonne@lal.in2p3.fr, Grigory Rybkin
     4# Modified by garonne@lal.in2p3.fr
     5# Modified by Grigory Rybkin
    56# See the complete license in cmt_license.txt "http://www.cecill.info".
    67#-----------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.