? |
Implements ValueBuilder.
Definition at line 1937 of file cmt_symbol.cxx.
References action_show_action, action_show_actions, action_show_macro, action_show_macros, action_show_set, action_show_sets, ActionType, SymbolValueList::command_type, CommandPath, CommandPathAppend, CommandPathPrepend, CommandPathRemove, CommandPathRemoveRegexp, SymbolValueList::discarded, Use::discarded, cmt_string::find(), find_path_entry(), Cmt::get_action(), Cmt::get_current_target(), Use::get_package_name(), Cmt::get_quiet(), CmtSystem::getenv(), SymbolValueList::is_reflexive, cmt_regexp::match(), Symbol::name, cmt_string::npos, CmtSystem::path_separator(), cmt_string::replace_all(), resolve_value(), resolve_value_for_macros(), SymbolValueList::select_first(), SymbolValueList::show(), cmt_vector< cmt_string >::size(), cmt_vector< SymbolValueList >::size(), CmtSystem::split(), SymbolValue::text, SymbolValueList::use, Symbol::value_is_reflexive(), Symbol::value_lists, SymbolValueList::values, and Cmt::vector_to_string().
01939 {
01940
01941 static int level = 0;
01942
01943 int show_it = 0;
01944
01945 cmt_string temp;
01946 cmt_string previous_temp;
01947 cmt_string new_value;
01948 static const cmt_string empty;
01949
01950 static cmt_string path_separator = CmtSystem::path_separator ();
01951
01952 ActionType action = Cmt::get_action ();
01953
01954 if (action == action_show_set)
01955 {
01956 if (symbol.name == Cmt::get_current_target ())
01957 {
01958
01959 if (level == 0) show_it = 1;
01960 }
01961 }
01962
01963 level++;
01964
01965 temp = CmtSystem::getenv (symbol.name);
01966
01967 bool first_definition = true;
01968 bool defined = false;
01969
01970 for (int i = 0; i < symbol.value_lists.size (); i++)
01971 {
01972 const SymbolValueList& value_list = symbol.value_lists[i];
01973
01974 if ((value_list.use != 0) &&
01975 (value_list.use->discarded)) continue;
01976
01977 const int selected = value_list.select_first ();
01978
01979 if (selected < 0) continue;
01980
01981 SymbolValue& value = value_list.values[selected];
01982
01983 if (show_it)
01984 {
01985 value_list.show (symbol, value, first_definition);
01986 }
01987
01988 if (value_list.discarded) continue;
01989
01990 new_value = value.text;
01991
01992
01993 resolve_value_for_macros (new_value);
01994
01995 switch (value_list.command_type)
01996 {
01997 case CommandPath :
01998
01999 if (!value_list.is_reflexive ||
02000 !symbol.value_is_reflexive (value.text))
02001 {
02002 resolve_value (new_value, symbol.name, temp);
02003 temp = new_value;
02004
02005 if (!defined)
02006 {
02007 defined = true;
02008 }
02009 else
02010 {
02011 if ((!Cmt::get_quiet ()) &&
02012 ((action == action_show_macro) ||
02013 (action == action_show_set) ||
02014 (action == action_show_action) ||
02015 (action == action_show_macros) ||
02016 (action == action_show_sets) ||
02017 (action == action_show_actions)))
02018 {
02019 cerr << "#CMT> Warning: Symbol " << symbol.name << " overridden";
02020
02021 if (value_list.use != 0)
02022 {
02023 cerr << " in package " << value_list.use->get_package_name ();
02024 }
02025
02026 cerr << endl;
02027 }
02028 }
02029 }
02030
02031 break;
02032 case CommandPathAppend :
02033
02034 if (new_value != "")
02035 {
02036 if (!find_path_entry (temp, new_value))
02037 {
02038 if (temp != "") temp += path_separator;
02039
02040 temp += new_value;
02041 }
02042 }
02043
02044 break;
02045 case CommandPathPrepend :
02046
02047 if (new_value != "")
02048 {
02049 if (!find_path_entry (temp, new_value))
02050 {
02051 previous_temp = temp;
02052 temp = new_value;
02053 if (previous_temp != "") temp += path_separator;
02054 temp += previous_temp;
02055 }
02056 }
02057
02058 break;
02059 case CommandPathRemove :
02060
02061 if (new_value != "")
02062 {
02063 CmtSystem::cmt_string_vector paths;
02064
02065 CmtSystem::split (temp, path_separator, paths);
02066
02067 for (int j = 0; j < paths.size (); ++j)
02068 {
02069 cmt_string& s = paths[j];
02070
02071 if (s.find (new_value) != cmt_string::npos)
02072 {
02073 s = "";
02074 }
02075 }
02076
02077 Cmt::vector_to_string (paths, path_separator, temp);
02078 temp.replace_all ("::", ":");
02079 temp.replace_all (";;", ";");
02080 }
02081
02082 break;
02083 case CommandPathRemoveRegexp :
02084
02085 if (new_value != "")
02086 {
02087 cmt_regexp e (new_value);
02088
02089 CmtSystem::cmt_string_vector paths;
02090
02091 CmtSystem::split (temp, path_separator, paths);
02092
02093 for (int j = 0; j < paths.size (); ++j)
02094 {
02095 cmt_string& s = paths[j];
02096
02097 if (CmtSystem::getenv ("TESTPRR") != "")
02098 {
02099 cout << "PRR> s=[" << s << "]";
02100 }
02101
02102 if (e.match (s))
02103 {
02104 s = "";
02105
02106 if (CmtSystem::getenv ("TESTPRR") != "")
02107 {
02108 cout << " match ";
02109 }
02110 }
02111 else
02112 {
02113 if (CmtSystem::getenv ("TESTPRR") != "")
02114 {
02115 cout << " no match ";
02116 }
02117 }
02118
02119 if (CmtSystem::getenv ("TESTPRR") != "")
02120 {
02121 cout << endl;
02122 }
02123 }
02124
02125 Cmt::vector_to_string (paths, path_separator, temp);
02126 temp.replace_all ("::", ":");
02127 temp.replace_all (";;", ";");
02128 }
02129
02130 break;
02131 }
02132
02133 }
02134
02135 level--;
02136
02137 return (temp);
02138 }
|