Utils.cxx
Go to the documentation of this file.
1 #include "Tools/EvtLib/Utils.h"
2 
4 
5 #include <wordexp.h>
6 
7 //___________________________________________________________________________
9 {
10  wordexp_t p;
11  const int status = wordexp(s.c_str(), &p, WRDE_SHOWERR | WRDE_UNDEF);
12  if(status != 0){
13  LOG("EvtLib", pFATAL) << "String '" << s
14  << "' returned error " << status << " from wordexp().";
15  exit(1);
16  }
17 
18  if(p.we_wordc == 0){
19  LOG("EvtLib", pFATAL) << "String '" << s
20  << "' didn't expand to anything.";
21  exit(1);
22  }
23 
24  if(p.we_wordc > 1){
25  LOG("EvtLib", pFATAL) << "String '" << s
26  << "' expanded to " << p.we_wordc << " locations.";
27  exit(1);
28  }
29 
30  s = p.we_wordv[0];
31 
32  wordfree(&p);
33 }
std::string string
Definition: nybbler.cc:12
void Expand(std::string &s)
Expand env vars/homedirs/wildcards in s.
Definition: Utils.cxx:8
#define pFATAL
Definition: Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
p
Definition: test.py:223
static QCString * s
Definition: config.cpp:1042