Files
Alexey Dokuchaev 5baf43483c lang/gnu-apl: try to unbreak the port's build on recent -CURRENT
The base template for std::char_traits<> has been removed in LLVM 19;
specializations are only provided for char, wchar_t, char8_t, char16_t,
and char32_t.  This had severely impacted GNU APL which derived its
UTF8 and UCS string classes from std::basic_string<>.  The author had
made several attempts to convert these classes to use std::vector<>
instead.  Carefully cherry-pick required changes so these fixes could
be applied on top of version 1.8 as trunk had diverged significantly.

Obtained from:	upstream (SVN revisions 1823, 1831, and 1837)
Reported by:	pkg-fallout
2025-06-04 06:51:24 +00:00

59 lines
2.3 KiB
C++

--- src/LibPaths.cc.orig 2019-06-23 12:39:20 UTC
+++ src/LibPaths.cc
@@ -70,33 +70,22 @@ LibPaths::compute_bin_path(const char * argv0, bool lo
//
// we fix this by searching argv0 in $PATH
//
- const char * path = getenv("PATH"); // must NOT be modified
-
- if (path)
+ if (const char * paths = getenv("PATH"))
{
logit && CERR << "initializing paths from $PATH = "
- << path << endl;
+ << paths << endl;
- // we must not modify path, so we copy it to path1 and
- // replace the semicolons in path1 by 0. That converts
- // p1;p2; ... into a sequence of 0-terminated strings
- // p1 p2 ... The variable next points to the start of each
- // string.
- //
- const size_t plen = strlen(path);
- std::string path1;
- path1.reserve(plen + 1);
- loop(p, (plen + 1)) path1 += path[p];
- char * next = &path1[0];
- for (;;)
- {
- char * semi = strchr(next, ':');
- if (semi) *semi = 0;
- UTF8_string filename;
- for (const char * n = next; *n; ++n) filename += *n;
- filename += '/';
- for (const char * a = argv0; *a; ++a) filename += *a;
+ while (*paths)
+ {
+ size_t dir_len;
+ if (const char * colon = strchr(paths, ':'))
+ dir_len = colon - paths;
+ else
+ dir_len = strlen(paths);
+ std::string filename(paths, dir_len);
+ filename += '/';
+ filename.append(argv0);
if (access(filename.c_str(), X_OK) == 0)
{
strncpy(APL_bin_path, filename.c_str(),
@@ -110,8 +99,7 @@ LibPaths::compute_bin_path(const char * argv0, bool lo
goto done;
}
- if (semi == 0) break;
- next = semi + 1;
+ paths += dir_len + 1; // next $PATH item
}
}
else