#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "cmt_use.h"
#include "cmt_symbol.h"
#include "cmt_system.h"
#include "cmt_database.h"
Include dependency graph for cmt_symbol.cxx:
Go to the source code of this file.
Compounds | |
class | MacroBuilder |
class | PathBuilder |
class | ScriptBuilder |
class | SetBuilder |
class | symbol_marker |
Functions | |
void | resolve_value (cmt_string& text, const cmt_string& macro_name, const cmt_string& value) |
void | resolve_value (cmt_string& text) |
void | resolve_value_for_macros (cmt_string& text) |
void | suppress_OS_delimiters (cmt_string& text) |
This function suppress all OS delimiters ie ${ } or % % and replaces them by pure macro delimiters. More... | |
bool | find_path_entry (const cmt_string& paths, const cmt_string& value) |
Variables | |
SetBuilder | Set |
PathBuilder | Path |
MacroBuilder | Macro |
ScriptBuilder | Script |
|
Definition at line 1529 of file cmt_symbol.cxx. Referenced by PathBuilder::build(). 01530 { 01531 static const cmt_string path_separator = CmtSystem::path_separator (); 01532 static const cmt_string double_path_separator = path_separator + path_separator; 01533 01534 cmt_string complete_paths; 01535 01536 complete_paths = path_separator; 01537 complete_paths += paths; 01538 complete_paths += path_separator; 01539 01540 complete_paths.replace_all (double_path_separator, path_separator); 01541 01542 cmt_string complete_value; 01543 complete_value = path_separator; 01544 complete_value += value; 01545 complete_value += path_separator; 01546 01547 if (complete_paths.find (complete_value) == cmt_string::npos) return (false); 01548 else return (true); 01549 } |
|
Definition at line 202 of file cmt_symbol.cxx. Referenced by PathBuilder::build(), SetBuilder::build(), PathBuilder::clean(), and Symbol::expand(). 00203 { 00204 cmt_string pattern; 00205 cmt_string macro_name; 00206 char end_pattern; 00207 00208 int start = 0; 00209 00210 for (;;) 00211 { 00212 // 00213 // Try and substitute all ${xxx} $(xxx) or %xxx% patterns 00214 // using symbol values. 00215 // 00216 00217 int begin; 00218 int end; 00219 00220 symbol_marker markers[3]; 00221 00222 markers[0].set (text.find (start, "$("), ')', 2); 00223 markers[1].set (text.find (start, "${"), '}', 2); 00224 markers[2].set (text.find (start, "%"), '%', 1); 00225 00226 // Find the first of three patterns 00227 00228 symbol_marker& marker = symbol_marker::get_lowest (markers, 2); 00229 00230 begin = marker.ptr; 00231 00232 if (begin == cmt_string::npos) break; 00233 00234 end_pattern = marker.pattern; 00235 start = begin + marker.intro; 00236 00237 end = text.find (start, end_pattern); 00238 if (end == cmt_string::npos) 00239 { 00240 // The pattern is a fake one (no ending!) 00241 start++; 00242 continue; 00243 } 00244 00245 // This should never happen... 00246 if (end < begin) break; 00247 00248 // Extract the complete pattern 00249 text.substr (begin, end - begin + 1, pattern); 00250 00251 // Then only the macro name 00252 text.substr (begin + marker.intro, end - begin - marker.intro, macro_name); 00253 00254 Symbol* macro = Symbol::find (macro_name); 00255 if (macro != 0) 00256 { 00257 // Macro found 00258 cmt_string value = macro->resolve_macro_value (); 00259 text.replace_all (pattern, value); 00260 00261 // The substitution will restart from the same place 00262 // allowing for recursive replacements 00263 start = begin; 00264 } 00265 else 00266 { 00267 // Macro not found. Look for env. variable 00268 cmt_string value = CmtSystem::getenv (macro_name); 00269 00270 // When the env. variable is not defined, the replacement is empty 00271 // thus all $(xxx) ${xxx} %xxx% patterns are always filtered away. 00272 text.replace_all (pattern, value); 00273 00274 // The substitution will restart from the same place 00275 // allowing for recursive replacements 00276 start = begin; 00277 } 00278 } 00279 } |
|
Definition at line 174 of file cmt_symbol.cxx. 00177 { 00178 static cmt_string pattern; 00179 00180 pattern = "${"; 00181 pattern += macro_name; 00182 pattern += "}"; 00183 00184 text.replace_all (pattern, value); 00185 00186 pattern = "$("; 00187 pattern += macro_name; 00188 pattern += ")"; 00189 00190 text.replace_all (pattern, value); 00191 00192 #ifdef WIN32 00193 pattern = "%"; 00194 pattern += macro_name; 00195 pattern += "%"; 00196 00197 text.replace_all (pattern, value); 00198 #endif 00199 } |
|
Definition at line 282 of file cmt_symbol.cxx. Referenced by PathBuilder::build(), SetBuilder::build(), and PathBuilder::clean(). 00283 { 00284 cmt_string pattern; 00285 cmt_string macro_name; 00286 char end_pattern; 00287 00288 int start = 0; 00289 00290 for (;;) 00291 { 00292 // 00293 // Try and substitute all ${xxx} $(xxx) or %xxx% patterns 00294 // using symbol values, only when the symbol is a macro. 00295 // 00296 00297 int begin; 00298 int end; 00299 00300 symbol_marker markers[3]; 00301 00302 markers[0].set (text.find (start, "$("), ')', 2); 00303 markers[1].set (text.find (start, "${"), '}', 2); 00304 markers[2].set (text.find (start, "%"), '%', 1); 00305 00306 // Find the first of three patterns 00307 00308 symbol_marker& marker = symbol_marker::get_lowest (markers, 2); 00309 00310 begin = marker.ptr; 00311 00312 if (begin == cmt_string::npos) break; 00313 00314 end_pattern = marker.pattern; 00315 start = begin + marker.intro; 00316 00317 end = text.find (start, end_pattern); 00318 if (end == cmt_string::npos) 00319 { 00320 // The pattern is a fake one (no ending!) 00321 start++; 00322 continue; 00323 } 00324 00325 // This should never happen... 00326 if (end < begin) break; 00327 00328 // Extract the complete pattern 00329 text.substr (begin, end - begin + 1, pattern); 00330 00331 // Then only the macro name 00332 text.substr (begin + marker.intro, end - begin - marker.intro, macro_name); 00333 00334 Symbol* macro = Symbol::find (macro_name); 00335 if ((macro != 0) && 00336 (macro->command == CommandMacro)) 00337 { 00338 // Macro found 00339 cmt_string value = macro->resolve_macro_value (); 00340 text.replace_all (pattern, value); 00341 00342 // The substitution will restart from the same place 00343 // allowing for recursive replacements 00344 start = begin; 00345 } 00346 else if ((macro == 0) || 00347 ((macro->command == CommandSet) || (macro->command == CommandPath))) 00348 { 00349 // Set found 00350 // ensure that the delimiters will match the OS dependent 00351 // delimiters. 00352 00353 cmt_string pattern_close = marker.pattern; 00354 00355 if (pattern_close != CmtSystem::ev_close ()) 00356 { 00357 cmt_string new_pattern; 00358 00359 new_pattern = CmtSystem::ev_open (); 00360 new_pattern += macro_name; 00361 new_pattern += CmtSystem::ev_close (); 00362 00363 text.replace (pattern, new_pattern); 00364 } 00365 00366 start = end + 1; 00367 } 00368 else 00369 { 00370 start = end + 1; 00371 } 00372 } 00373 } |
|
This function suppress all OS delimiters ie ${ } or % % and replaces them by pure macro delimiters.
Definition at line 379 of file cmt_symbol.cxx. Referenced by Symbol::show_macro(). 00380 { 00381 cmt_string pattern; 00382 cmt_string macro_name; 00383 char end_pattern; 00384 00385 int start = 0; 00386 00387 for (;;) 00388 { 00389 int begin; 00390 int end; 00391 00392 symbol_marker markers[3]; 00393 00394 markers[0].set (text.find (start, "${"), '}', 2); 00395 00396 #ifdef WIN32 00397 markers[1].set (text.find (start, "%"), '%', 1); 00398 #endif 00399 00400 // Find the first of three patterns 00401 00402 symbol_marker& marker = symbol_marker::get_lowest (markers, 2); 00403 00404 begin = marker.ptr; 00405 00406 if (begin == cmt_string::npos) break; 00407 00408 end_pattern = marker.pattern; 00409 start = begin + marker.intro; 00410 00411 end = text.find (start, end_pattern); 00412 if (end == cmt_string::npos) 00413 { 00414 // The pattern is a fake one (no ending!) 00415 start++; 00416 continue; 00417 } 00418 00419 // This should never happen... 00420 if (end < begin) break; 00421 00422 // Extract the complete pattern 00423 text.substr (begin, end - begin + 1, pattern); 00424 00425 // Then only the macro name 00426 text.substr (begin + marker.intro, end - begin - marker.intro, macro_name); 00427 00428 cmt_string new_pattern; 00429 00430 new_pattern = "$("; 00431 new_pattern += macro_name; 00432 new_pattern += ")"; 00433 00434 text.replace (pattern, new_pattern); 00435 00436 start = begin; 00437 } 00438 } |
|
Definition at line 169 of file cmt_symbol.cxx. |
|
Definition at line 168 of file cmt_symbol.cxx. |
|
Definition at line 170 of file cmt_symbol.cxx. |
|
Definition at line 167 of file cmt_symbol.cxx. |