mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-20 04:34:41 +08:00
Extract a function for splitting a colon-separated string
We're going to need this logic in another place, so make a function of this.
This commit is contained in:
@@ -57,6 +57,22 @@ unsigned char * contents = 0;
|
|||||||
#define ElfFileParamNames Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym, Elf_Verneed
|
#define ElfFileParamNames Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym, Elf_Verneed
|
||||||
|
|
||||||
|
|
||||||
|
static vector<string> splitColonDelimitedString(const char * s){
|
||||||
|
vector<string> parts;
|
||||||
|
const char * pos = s;
|
||||||
|
while (*pos) {
|
||||||
|
const char * end = strchr(pos, ':');
|
||||||
|
if (!end) end = strchr(pos, 0);
|
||||||
|
|
||||||
|
parts.push_back(string(pos, end - pos));
|
||||||
|
if (*end == ':') ++end;
|
||||||
|
pos = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static unsigned int getPageSize(){
|
static unsigned int getPageSize(){
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
@@ -1095,15 +1111,9 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op, string newRPath)
|
|||||||
|
|
||||||
newRPath = "";
|
newRPath = "";
|
||||||
|
|
||||||
char * pos = rpath;
|
vector<string> rpathDirs = splitColonDelimitedString(rpath);
|
||||||
while (*pos) {
|
for (vector<string>::iterator it = rpathDirs.begin(); it != rpathDirs.end(); ++it) {
|
||||||
char * end = strchr(pos, ':');
|
const string & dirName = *it;
|
||||||
if (!end) end = strchr(pos, 0);
|
|
||||||
|
|
||||||
/* Get the name of the directory. */
|
|
||||||
string dirName(pos, end - pos);
|
|
||||||
if (*end == ':') ++end;
|
|
||||||
pos = end;
|
|
||||||
|
|
||||||
/* Non-absolute entries are allowed (e.g., the special
|
/* Non-absolute entries are allowed (e.g., the special
|
||||||
"$ORIGIN" hack). */
|
"$ORIGIN" hack). */
|
||||||
|
Reference in New Issue
Block a user