~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/envvars/envvars_common.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 
3
 * http://www.gnu.org/licenses/gpl-3.0.html
 
4
 *
 
5
 * $Revision$
 
6
 * $Id$
 
7
 * $HeadURL$
 
8
 */
 
9
 
 
10
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
11
 
 
12
#include "sdk.h"
 
13
#include "prep.h"
 
14
#ifndef CB_PRECOMP
 
15
  #include <wx/checklst.h>
 
16
  #include <wx/utils.h>
 
17
 
 
18
  #include "configmanager.h"
 
19
  #include "globals.h"
 
20
  #include "manager.h"
 
21
  #include "macrosmanager.h"
 
22
  #include "logmanager.h"
 
23
#endif
 
24
 
 
25
#include "envvars_common.h"
 
26
 
 
27
// Uncomment this for tracing of method calls in C::B's DebugLog:
 
28
//#define TRACE_ENVVARS
 
29
 
 
30
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
31
 
 
32
const wxString nsEnvVars::EnvVarsSep     = _T("|");
 
33
const wxString nsEnvVars::EnvVarsDefault = _T("default");
 
34
 
 
35
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
36
 
 
37
void nsEnvVars::EnvVarsDebugLog(const wxChar* msg, ...)
 
38
{
 
39
  // load and apply configuration (to application only)
 
40
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
41
  if (!cfg)
 
42
    return;
 
43
 
 
44
  // get whether to print debug message to debug log or not
 
45
  bool debug_log = cfg->ReadBool(_T("/debug_log"));
 
46
  if (!debug_log)
 
47
    return;
 
48
 
 
49
  wxString log_msg;
 
50
  va_list  arg_list;
 
51
 
 
52
  va_start(arg_list, msg);
 
53
  log_msg = wxString::FormatV(msg, arg_list);
 
54
  va_end(arg_list);
 
55
 
 
56
  Manager::Get()->GetLogManager()->DebugLog(log_msg);
 
57
}// EnvVarsDebugLog
 
58
 
 
59
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
60
 
 
61
wxArrayString nsEnvVars::EnvvarStringTokeniser(const wxString& str)
 
62
{
 
63
#if TRACE_ENVVARS
 
64
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarStringTokeniser")));
 
65
#endif
 
66
  // tokenise string like:
 
67
  // C:\Path;"D:\Other Path"
 
68
 
 
69
  wxArrayString out;
 
70
 
 
71
  wxString search = str;
 
72
  search.Trim(true).Trim(false);
 
73
 
 
74
  // trivial case: string is empty or consists of blanks only
 
75
  if (search.IsEmpty())
 
76
    return out;
 
77
 
 
78
  wxString token;
 
79
  bool     inside_quot = false;
 
80
  size_t   pos         = 0;
 
81
  while (pos < search.Length())
 
82
  {
 
83
    wxString current_char = search.GetChar(pos);
 
84
 
 
85
    // for e.g. /libpath:"C:\My Folder"
 
86
    if (current_char.CompareTo(_T("\""))==0) // equality
 
87
      inside_quot = !inside_quot;
 
88
 
 
89
    if ((current_char.CompareTo(nsEnvVars::EnvVarsSep)==0) && (!inside_quot))
 
90
    {
 
91
      if (!token.IsEmpty())
 
92
      {
 
93
        out.Add(token);
 
94
        token.Clear();
 
95
      }
 
96
    }
 
97
    else
 
98
      token.Append(current_char);
 
99
 
 
100
    pos++;
 
101
    // Append final token
 
102
    if ((pos==search.Length()) && (!inside_quot) && (!token.IsEmpty()))
 
103
      out.Add(token);
 
104
  }// while
 
105
 
 
106
  return out;
 
107
}// EnvvarStringTokeniser
 
108
 
 
109
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
110
 
 
111
wxArrayString nsEnvVars::GetEnvvarSetNames()
 
112
{
 
113
#if TRACE_ENVVARS
 
114
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetEnvvarSetNames")));
 
115
#endif
 
116
 
 
117
  wxArrayString set_names;
 
118
 
 
119
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
120
  if (!cfg)
 
121
  {
 
122
    set_names.Add(nsEnvVars::EnvVarsDefault);
 
123
    return set_names;
 
124
  }
 
125
 
 
126
  // Read all envvar sets available
 
127
  wxArrayString sets     = cfg->EnumerateSubPaths(_T("/sets"));
 
128
  unsigned int  num_sets = sets.GetCount();
 
129
  EV_DBGLOG(_T("EnvVars: Found %d envvar sets in config."), num_sets);
 
130
 
 
131
  if (num_sets==0)
 
132
    set_names.Add(nsEnvVars::EnvVarsDefault);
 
133
  else
 
134
  {
 
135
    for (unsigned int i=0; i<num_sets; ++i)
 
136
    {
 
137
      wxString set_name = sets[i];
 
138
      if (set_name.IsEmpty())
 
139
        set_name.Printf(_T("Set%d"), i);
 
140
 
 
141
      set_names.Add(set_name);
 
142
    }// for
 
143
  }// if
 
144
 
 
145
  return set_names;
 
146
}// GetEnvvarSetNames
 
147
 
 
148
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
149
 
 
150
wxString nsEnvVars::GetActiveSetName()
 
151
{
 
152
#if TRACE_ENVVARS
 
153
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetActiveSetName")));
 
154
#endif
 
155
 
 
156
  wxString active_set = nsEnvVars::EnvVarsDefault;
 
157
 
 
158
  // load and apply configuration (to application only)
 
159
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
160
  if (!cfg)
 
161
    return active_set;
 
162
 
 
163
  // try to get the envvar set name of the currently active global envvar set
 
164
  wxString active_set_cfg = cfg->Read(_T("/active_set"));
 
165
  if (!active_set_cfg.IsEmpty())
 
166
    active_set = active_set_cfg;
 
167
 
 
168
  EV_DBGLOG(_T("EnvVars: Obtained '%s' as active envvar set from config."), active_set.c_str());
 
169
  return active_set;
 
170
}// GetActiveSetName
 
171
 
 
172
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
173
 
 
174
wxString nsEnvVars::GetSetPathByName(const wxString& set_name, bool check_exists,
 
175
                                     bool return_default)
 
176
{
 
177
#if TRACE_ENVVARS
 
178
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetSetPathByName")));
 
179
#endif
 
180
 
 
181
  wxString set_path = _T("/sets/")+nsEnvVars::EnvVarsDefault; // fall back solution
 
182
  if (!return_default)
 
183
    set_path.Empty();
 
184
 
 
185
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
186
  if (!cfg || set_path.IsEmpty())
 
187
    return set_path;
 
188
 
 
189
  if (!check_exists)
 
190
    return _T("/sets/")+set_name;
 
191
 
 
192
  // Read all envvar sets available
 
193
  wxArrayString sets     = cfg->EnumerateSubPaths(_T("/sets"));
 
194
  unsigned int  num_sets = sets.GetCount();
 
195
  for (unsigned int i=0; i<num_sets; ++i)
 
196
  {
 
197
    if (set_name.IsSameAs(sets[i]))
 
198
    {
 
199
      set_path = (_T("/sets/")+set_name);
 
200
      break; // Early exit of for-loop
 
201
    }
 
202
  }
 
203
 
 
204
  return set_path;
 
205
}// GetSetPathByName
 
206
 
 
207
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
208
 
 
209
wxArrayString nsEnvVars::GetEnvvarsBySetPath(const wxString& set_path)
 
210
{
 
211
#if TRACE_ENVVARS
 
212
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetEnvvarsBySetPath")));
 
213
#endif
 
214
 
 
215
  wxArrayString envvars;
 
216
  EV_DBGLOG(_T("EnvVars: Searching for envvars in path '%s'."), set_path.c_str());
 
217
 
 
218
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
219
  if (!cfg || set_path.IsEmpty())
 
220
    return envvars;
 
221
 
 
222
  wxArrayString envvars_keys = cfg->EnumerateKeys(set_path);
 
223
  unsigned int  num_envvars  = envvars_keys.GetCount();
 
224
  for (unsigned int i=0; i<num_envvars; ++i)
 
225
  {
 
226
    wxString envvar = cfg->Read(set_path+_T("/")+envvars_keys[i]);
 
227
    if (!envvar.IsEmpty())
 
228
      envvars.Add(envvar);
 
229
    else
 
230
      EV_DBGLOG(_T("EnvVars: Warning: empty envvar detected and skipped."));
 
231
  }
 
232
  EV_DBGLOG(_T("EnvVars: Read %d/%d envvars in path '%s'."),
 
233
    envvars.GetCount(), num_envvars, set_path.c_str());
 
234
 
 
235
  return envvars;
 
236
}// GetEnvvarsBySetPath
 
237
 
 
238
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
239
 
 
240
bool nsEnvVars::EnvvarSetExists(const wxString& set_name)
 
241
{
 
242
#if TRACE_ENVVARS
 
243
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarSetExists")));
 
244
#endif
 
245
 
 
246
  if (set_name.IsEmpty())
 
247
    return false;
 
248
 
 
249
  wxString set_path = nsEnvVars::GetSetPathByName(set_name, true, false);
 
250
  if (set_name.IsEmpty())
 
251
    return false;
 
252
 
 
253
  return true;
 
254
}// EnvvarSetExists
 
255
 
 
256
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
257
 
 
258
bool nsEnvVars::EnvvarVeto(const wxString& key, wxCheckListBox* lstEnvVars, int sel)
 
259
{
 
260
#if TRACE_ENVVARS
 
261
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarVeto")));
 
262
#endif
 
263
 
 
264
  if (wxGetEnv(key, NULL))
 
265
  {
 
266
    wxString recursion;
 
267
    if (platform::windows) recursion = _T("PATH=%PATH%;C:\\NewPath");
 
268
    else                   recursion = _T("PATH=$PATH:/new_path");
 
269
 
 
270
    wxString warn_exist;
 
271
    warn_exist.Printf(_("Warning: Environment variable '%s' is already set.\n"
 
272
                        "Continue with updating it's value?\n"
 
273
                        "(Recursions like '%s' will be considered.)"),
 
274
                        key.c_str(), recursion.c_str());
 
275
 
 
276
    if (cbMessageBox(warn_exist, _("Confirmation"),
 
277
                     wxYES_NO | wxICON_QUESTION) == wxID_NO)
 
278
    {
 
279
      if (lstEnvVars && (sel>=0))
 
280
        lstEnvVars->Check(sel, false); // Unset to visualise it's NOT set
 
281
      return true; // User has vetoed the operation
 
282
    }
 
283
  }// if
 
284
 
 
285
  return false;
 
286
}// EnvvarVeto
 
287
 
 
288
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
289
 
 
290
bool nsEnvVars::EnvvarsClear(wxCheckListBox* lstEnvVars)
 
291
{
 
292
#if TRACE_ENVVARS
 
293
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarsClear")));
 
294
#endif
 
295
 
 
296
  wxString envsNotUnSet(wxEmptyString);
 
297
 
 
298
  // Unset all (checked) variables of lstEnvVars
 
299
  for (int i=0; i<(int)lstEnvVars->GetCount(); ++i)
 
300
  {
 
301
    // Note: It's better not to just clear all because wxUnsetEnv would
 
302
    //       fail in case an envvar is not set (not checked).
 
303
    if (lstEnvVars->IsChecked(i))
 
304
    {
 
305
      wxString key = lstEnvVars->GetString(i).BeforeFirst(_T('=')).Trim(true).Trim(false);
 
306
      if (!key.IsEmpty())
 
307
      {
 
308
        if (!nsEnvVars::EnvvarDiscard(key))
 
309
        {
 
310
          // Setting env.-variable failed. Remember this key to report later.
 
311
          if (envsNotUnSet.IsEmpty())
 
312
            envsNotUnSet << key;
 
313
          else
 
314
            envsNotUnSet << _T(", ") << key;
 
315
        }
 
316
      }
 
317
    }
 
318
  }// for
 
319
 
 
320
  lstEnvVars->Clear();
 
321
 
 
322
  if (!envsNotUnSet.IsEmpty())
 
323
  {
 
324
    wxString msg;
 
325
    msg.Printf( _("There was an error unsetting the following environment variables:\n%s"),
 
326
                envsNotUnSet.c_str() );
 
327
    cbMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
 
328
    return false;
 
329
  }
 
330
 
 
331
  return true;
 
332
}// EnvvarsClear
 
333
 
 
334
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
335
 
 
336
bool nsEnvVars::EnvvarDiscard(const wxString &key)
 
337
{
 
338
#if TRACE_ENVVARS
 
339
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarDiscard")));
 
340
#endif
 
341
 
 
342
  // Replace all macros the user might have setup for the key
 
343
  wxString the_key = key;
 
344
  Manager::Get()->GetMacrosManager()->ReplaceMacros(the_key);
 
345
 
 
346
  if (!wxUnsetEnv(the_key))
 
347
  {
 
348
    Manager::Get()->GetLogManager()->Log(F(
 
349
      _("Unsetting environment variable '%s' failed."), the_key.c_str()));
 
350
    EV_DBGLOG(_T("EnvVars: Unsetting environment variable '%s' failed."),
 
351
      the_key.c_str());
 
352
    return false;
 
353
  }
 
354
 
 
355
  return true;
 
356
}// EnvvarDiscard
 
357
 
 
358
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
359
 
 
360
bool nsEnvVars::EnvvarApply(const wxString& key, const wxString& value,
 
361
                            wxCheckListBox* lstEnvVars, int sel)
 
362
{
 
363
#if TRACE_ENVVARS
 
364
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarApply")));
 
365
#endif
 
366
 
 
367
  // Key:   Replace all macros the user might have used
 
368
  wxString the_key = key;
 
369
  Manager::Get()->GetMacrosManager()->ReplaceMacros(the_key);
 
370
 
 
371
  // Value: First, expand stuff like:
 
372
  //        set PATH=%PATH%;C:\NewPath OR export PATH=$PATH:/new_path
 
373
  //        After, replace all macros the user might have used in addition
 
374
  wxString the_value = value;
 
375
  wxString value_set;
 
376
  bool     is_set    = wxGetEnv(the_key, &value_set);
 
377
  if (is_set)
 
378
  {
 
379
    wxString recursion;
 
380
    if (platform::windows) recursion = _T("%")+the_key+_("%");
 
381
    else                   recursion = _T("$")+the_key;
 
382
 
 
383
    if (the_value.Contains(recursion))
 
384
    {
 
385
      // Avoid endless recursion if the value set contains e.g. $PATH, too
 
386
      if (value_set.Contains(recursion))
 
387
      {
 
388
        EV_DBGLOG(_T("EnvVars: Setting environment variable '%s' failed "
 
389
                     "due to unsresolvable recursion."), the_key.c_str());
 
390
        if (lstEnvVars && (sel>=0))
 
391
          lstEnvVars->Check(sel, false); // Unset to visualise it's NOT set
 
392
        return false;
 
393
      }
 
394
      the_value.Replace(recursion.c_str(), value_set.c_str());
 
395
    }
 
396
  }
 
397
  Manager::Get()->GetMacrosManager()->ReplaceMacros(the_value);
 
398
 
 
399
  EV_DBGLOG(_T("EnvVars: Trying to set environment variable '%s' to value '%s'..."), the_key.c_str(), the_value.c_str());
 
400
  if (!wxSetEnv(the_key, the_value))
 
401
  {
 
402
    EV_DBGLOG(_T("EnvVars: Setting environment variable '%s' failed."), the_key.c_str());
 
403
    if (lstEnvVars && (sel>=0))
 
404
      lstEnvVars->Check(sel, false); // Unset to visualise it's NOT set
 
405
    return false;
 
406
  }
 
407
 
 
408
  return true;
 
409
}// EnvvarApply
 
410
 
 
411
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
412
 
 
413
bool nsEnvVars::EnvvarArrayApply(const wxArrayString& envvar,
 
414
                                 wxCheckListBox* lstEnvVars)
 
415
{
 
416
#if TRACE_ENVVARS
 
417
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarApply")));
 
418
#endif
 
419
 
 
420
  if (envvar.GetCount() == 3)
 
421
  {
 
422
    wxString check = envvar[0];
 
423
    wxString key   = envvar[1];
 
424
    wxString value = envvar[2];
 
425
 
 
426
    bool bCheck = check.Trim(true).Trim(false).IsSameAs(_T("1"))?true:false;
 
427
    key.Trim(true).Trim(false);
 
428
    value.Trim(true).Trim(false);
 
429
 
 
430
    int sel = 0;
 
431
    if (lstEnvVars)
 
432
    {
 
433
      sel = lstEnvVars->Append(key + _T(" = ") + value);
 
434
      lstEnvVars->Check(sel, bCheck);
 
435
    }
 
436
 
 
437
    if (bCheck)
 
438
    {
 
439
      if (EnvvarApply(key, value, lstEnvVars, sel))
 
440
        return true;
 
441
    }
 
442
    else
 
443
      return true; // No need to apply -> success, too.
 
444
  }// if
 
445
 
 
446
  return false;
 
447
}// EnvvarApply
 
448
 
 
449
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
450
 
 
451
void nsEnvVars::EnvvarSetApply(const wxString& set_name, bool even_if_active)
 
452
{
 
453
#if TRACE_ENVVARS
 
454
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarSetApply")));
 
455
#endif
 
456
 
 
457
  // Load and apply envvar set from config (to application only)
 
458
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
459
  if (!cfg)
 
460
    return;
 
461
 
 
462
  // Stores the currently active envar set that has been successfully applied at last
 
463
  static wxString last_set_applied = wxEmptyString;
 
464
 
 
465
  wxString set_to_apply = set_name;
 
466
  if (set_to_apply.IsEmpty())
 
467
    set_to_apply = nsEnvVars::GetActiveSetName();
 
468
 
 
469
  // Early exit for a special case requested by even_if_active parameter
 
470
  if (!even_if_active && set_to_apply.IsSameAs(last_set_applied))
 
471
  {
 
472
    EV_DBGLOG(_T("EnvVars: Set '%s' will not be applied (already active)."),
 
473
      set_to_apply.c_str());
 
474
    return;
 
475
  }
 
476
 
 
477
  // Show currently activated set in debug log (for reference)
 
478
  wxString set_path = nsEnvVars::GetSetPathByName(set_to_apply);
 
479
  EV_DBGLOG(_T("EnvVars: Active envvar set is '%s', config path '%s'."),
 
480
    set_to_apply.c_str(), set_path.c_str());
 
481
 
 
482
  // Read and apply all envvars from currently active set in config
 
483
  wxArrayString vars     = nsEnvVars::GetEnvvarsBySetPath(set_path);
 
484
  size_t envvars_total   = vars.GetCount();
 
485
  size_t envvars_applied = 0;
 
486
  for (unsigned int i=0; i<envvars_total; ++i)
 
487
  {
 
488
    // Format: [checked?]|[key]|[value]
 
489
    wxArrayString var_array = nsEnvVars::EnvvarStringTokeniser(vars[i]);
 
490
    if (nsEnvVars::EnvvarArrayApply(var_array))
 
491
      envvars_applied++;
 
492
    else
 
493
      EV_DBGLOG(_T("EnvVars: Invalid envvar in '%s' at position #%d."),
 
494
        set_path.c_str(), i);
 
495
  }// for
 
496
 
 
497
  if (envvars_total>0)
 
498
  {
 
499
    last_set_applied = set_to_apply;
 
500
    EV_DBGLOG(_T("EnvVars: %d/%d envvars applied within C::B focus."),
 
501
      envvars_applied, envvars_total);
 
502
  }
 
503
}// EnvvarSetApply
 
504
 
 
505
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
 
506
 
 
507
void nsEnvVars::EnvvarSetDiscard(const wxString& set_name)
 
508
{
 
509
#if TRACE_ENVVARS
 
510
  Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarSetDiscard")));
 
511
#endif
 
512
 
 
513
  // load and apply envvar set from config (to application only)
 
514
  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
 
515
  if (!cfg)
 
516
    return;
 
517
 
 
518
  wxString set_to_discard = set_name;
 
519
  if (set_to_discard.IsEmpty())
 
520
    set_to_discard = nsEnvVars::GetActiveSetName();
 
521
 
 
522
  // Show currently activated set in debug log (for reference)
 
523
  wxString set_path = nsEnvVars::GetSetPathByName(set_to_discard);
 
524
  EV_DBGLOG(_T("EnvVars: Active envvar set is '%s', config path '%s'."),
 
525
    set_to_discard.c_str(), set_path.c_str());
 
526
 
 
527
  // Read and apply all envvars from currently active set in config
 
528
  wxArrayString vars       = nsEnvVars::GetEnvvarsBySetPath(set_path);
 
529
  size_t envvars_total     = vars.GetCount();
 
530
  size_t envvars_discarded = 0;
 
531
  for (unsigned int i=0; i<envvars_total; ++i)
 
532
  {
 
533
    // Format: [checked?]|[key]|[value]
 
534
    wxArrayString var_array = nsEnvVars::EnvvarStringTokeniser(vars[i]);
 
535
    if (var_array.GetCount()==3)
 
536
    {
 
537
      wxString check = var_array[0];
 
538
      bool bCheck = check.Trim(true).Trim(false).IsSameAs(_T("1"))?true:false;
 
539
      if (!bCheck || (bCheck && nsEnvVars::EnvvarDiscard(var_array[1]))) // key
 
540
        envvars_discarded++;
 
541
    }
 
542
    else
 
543
      EV_DBGLOG(_T("EnvVars: Invalid envvar in '%s' at position #%d."),
 
544
        set_path.c_str(), i);
 
545
  }// for
 
546
 
 
547
  if (envvars_total>0)
 
548
  {
 
549
    EV_DBGLOG(_T("EnvVars: %d/%d envvars discarded within C::B focus."),
 
550
      envvars_discarded, envvars_total);
 
551
  }
 
552
}// EnvvarSetDiscard