From 6f77a06664ab931cfa843d8af0df1dc67857ee95 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 17 Jul 2024 21:00:14 +0100 Subject: [PATCH] libast: cleanup: remove unused pathprobe() function This function was part of the defunct internal AT&T AST build system. Grepping the ast-open-archive repo shows it was used by nmake(1), probe(1), and libpp (pp(3)), the latter being a library supporting the AST implementation of cpp(1), the C preprocessor. According to the documentation, the pathprobe function yields the path to probe(1) information for arbitrary language processors. There's not going to be any interest in this in the future as we are going to keep our version of the build system small and self-contained, so we can get rid. --- src/lib/libast/Mamfile | 17 +- src/lib/libast/features/api | 2 +- src/lib/libast/features/map.c | 2 - src/lib/libast/include/ast.h | 2 - src/lib/libast/man/path.3 | 38 ---- src/lib/libast/path/pathprobe.c | 328 -------------------------------- 6 files changed, 4 insertions(+), 385 deletions(-) delete mode 100644 src/lib/libast/path/pathprobe.c diff --git a/src/lib/libast/Mamfile b/src/lib/libast/Mamfile index 8379a95a33d0..d325b25069ad 100644 --- a/src/lib/libast/Mamfile +++ b/src/lib/libast/Mamfile @@ -1089,19 +1089,6 @@ make install virtual exec - compile ${<} done - make pathprobe.o - make path/pathprobe.c - prev ast_api.h - make include/proc.h implicit - prev include/ast.h - done - prev include/ls.h - prev include/error.h - prev include/ast.h - done - exec - compile ${<} -DHOSTTYPE=\""${mam_cc_HOSTTYPE}"\" - done - make pathrepl.o make path/pathrepl.c prev ast_api.h @@ -1389,7 +1376,9 @@ make install virtual make systrace.o make misc/systrace.c prev include/debug.h - prev include/proc.h + make include/proc.h implicit + prev include/ast.h + done prev include/error.h prev include/ast.h done diff --git a/src/lib/libast/features/api b/src/lib/libast/features/api index e2a6840607a6..b86dceeabf86 100644 --- a/src/lib/libast/features/api +++ b/src/lib/libast/features/api @@ -8,7 +8,7 @@ api ast 20120411 cmdopen api ast 20110505 cmdopen -api ast 20100601 pathaccess pathcanon pathcat pathkey pathpath pathprobe pathrepl +api ast 20100601 pathaccess pathcanon pathcat pathkey pathpath pathrepl api ast 20000308 sfkeyprintf diff --git a/src/lib/libast/features/map.c b/src/lib/libast/features/map.c index 6d743cc9046c..3718f0ac3346 100644 --- a/src/lib/libast/features/map.c +++ b/src/lib/libast/features/map.c @@ -201,8 +201,6 @@ main(void) printf("#define pathpath _ast_pathpath\n"); printf("#undef pathposix\n"); printf("#define pathposix _ast_pathposix\n"); - printf("#undef pathprobe\n"); - printf("#define pathprobe _ast_pathprobe\n"); printf("#undef pathprog\n"); printf("#define pathprog _ast_pathprog\n"); printf("#undef pathrepl\n"); diff --git a/src/lib/libast/include/ast.h b/src/lib/libast/include/ast.h index 9b78e691fca1..748c60873ac0 100644 --- a/src/lib/libast/include/ast.h +++ b/src/lib/libast/include/ast.h @@ -365,8 +365,6 @@ extern size_t pathnative(const char*, char*, size_t); extern char* pathpath(char*, const char*, const char*, int); extern char* pathpath_20100601(const char*, const char*, int, char*, size_t); extern size_t pathposix(const char*, char*, size_t); -extern char* pathprobe(char*, char*, const char*, const char*, const char*, int); -extern char* pathprobe_20100601(const char*, const char*, const char*, int, char*, size_t, char*, size_t); extern size_t pathprog(const char*, char*, size_t); extern char* pathrepl(char*, const char*, const char*); extern char* pathrepl_20100601(char*, size_t, const char*, const char*); diff --git a/src/lib/libast/man/path.3 b/src/lib/libast/man/path.3 index 8060763488da..ac3dcc5b8e5e 100644 --- a/src/lib/libast/man/path.3 +++ b/src/lib/libast/man/path.3 @@ -54,7 +54,6 @@ int pathicase(const char* \fIpath\fP); char* pathkey(char* \fIkey\fP, char* \fIattr\fP, const char* \fIlang\fP, const char* \fIpath\fP); char* pathnext(char* \fIpath\fP, char* \fIextra\fP, long* \fIvisits\fP); char* pathpath(char* \fIpath\fP, const char* \fIp\fP, const char* \fIa\fP, int \fImode\fP); -char* pathprobe(char* \fIpath\fP, char* \fIattr\fP, const char* \fIlang\fP, const char* \fItool\fP, const char* \fIproc\fP, int \fIop\fP); char* pathrepl(char* \fIpath\fP, const char* \fImatch\fP, const char* \fIreplace\fP); int pathsetlink(const char* \fItext\fP, char* \fIname\fP); char* pathshell(void); @@ -305,43 +304,6 @@ then .I ../p is searched for. .PP -.L pathprobe -generates in -.I path -the full path name of the -.I tool -specific -.IR probe (1) -information file for the -.I lang -language processor -.IR proc . -If -.I "path == 0" -then space is allocated via -.IR malloc (3). -Probe attribute -.I name=value -pairs are copied into -.I attr -if -.IR "attr != 0" . -.I op -may be one of: -.TP -.B \-1 -return the path name with no access checks or generation -.TP -.B 0 -message emitted information must be generated via -.IR probe (1) -.TP -.B 1 -no message emitted information must be probed via -.IR probe (1) -.PP -0 is returned if the information does not exist and cannot be generated. -.PP .L pathrepl does an in-place replacement of the first occurrence of .I /match/ diff --git a/src/lib/libast/path/pathprobe.c b/src/lib/libast/path/pathprobe.c deleted file mode 100644 index 5e2fbca26ce6..000000000000 --- a/src/lib/libast/path/pathprobe.c +++ /dev/null @@ -1,328 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2024 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 2.0 * -* * -* A copy of the License is available at * -* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html * -* (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* Martijn Dekker * -* * -***********************************************************************/ -/* - * Glenn Fowler - * AT&T Research - * - * return in path the full path name of the probe(1) - * information for lang and tool using proc - * if attr != 0 then path attribute assignments placed here - * - * if path==0 then the space is malloc'd - * - * op: - * - * -3 return non-writable path name with no generation - * -2 return path name with no generation - * -1 return no $HOME path name with no generation - * 0 verbose probe - * 1 silent probe - * - * 0 returned if the info does not exist and cannot be generated - */ - -#define _AST_API_H 1 - -#include -#include -#include -#include - -char* -pathprobe(char* path, char* attr, const char* lang, const char* tool, const char* proc, int op) -{ - return pathprobe_20100601(lang, tool, proc, op, path, PATH_MAX, attr, PATH_MAX); -} - -#undef _AST_API_H - -#include - -#ifndef PROBE -#define PROBE "probe" -#endif - -#if defined(ST_RDONLY) || defined(ST_NOSUID) - -/* - * return non-0 if path is in a readonly or non-setuid fs - */ - -static int -rofs(const char* path) -{ - struct statvfs vfs; - struct stat st; - - if (!statvfs(path, &vfs)) - { -#if defined(ST_RDONLY) - if (vfs.f_flag & ST_RDONLY) - return 1; -#endif -#if defined(ST_NOSUID) - if ((vfs.f_flag & ST_NOSUID) && (stat(path, &st) || st.st_uid != getuid() && st.st_uid != geteuid())) - return 1; -#endif - } - return 0; -} - -#else - -#define rofs(p) 0 - -#endif - -char* -pathprobe_20100601(const char* lang, const char* tool, const char* aproc, int op, char* path, size_t pathsize, char* attr, size_t attrsize) -{ - char* proc = (char*)aproc; - char* p; - char* k; - char* x; - char** ap; - int n; - int v; - int force; - ssize_t r; - char* e; - char* np; - char* nx; - char* probe; - const char* dirs; - const char* dir; - Proc_t* pp; - Sfio_t* sp; - char buf[PATH_MAX]; - char cmd[PATH_MAX]; - char exe[PATH_MAX]; - char lib[PATH_MAX]; - char ver[PATH_MAX]; - char key[16]; - char* arg[8]; - long ops[2]; - unsigned long ptime; - struct stat st; - struct stat ps; - - if (*proc != '/') - { - if (p = strchr(proc, ' ')) - { - strncopy(buf, proc, p - proc + 1); - proc = buf; - } - if (!(proc = pathpath(proc, NULL, PATH_ABSOLUTE|PATH_REGULAR|PATH_EXECUTE, cmd, sizeof(cmd)))) - proc = (char*)aproc; - else if (p) - { - n = strlen(proc); - strncopy(proc + n, p, PATH_MAX - n - 1); - } - } - if (!path) - { - path = buf; - pathsize = sizeof(buf); - } - probe = PROBE; - x = lib + sizeof(lib) - 1; - k = lib + sfsprintf(lib, x - lib, "lib/%s/", probe); - p = k + sfsprintf(k, x - k, "%s/%s/", lang, tool); - pathkey(lang, tool, proc, key, sizeof(key), attr, attrsize); - if (op >= -2) - { - strncopy(p, key, x - p); - if (pathpath(lib, "", PATH_ABSOLUTE, path, pathsize) && !stat(path, &st) && (st.st_mode & S_IWUSR)) - return path == buf ? strdup(path) : path; - } - e = strncopy(p, probe, x - p); - if (!pathpath(lib, "", PATH_ABSOLUTE|PATH_EXECUTE, path, pathsize) || stat(path, &ps)) - return NULL; - for (;;) - { - ptime = ps.st_mtime; - n = strlen(path); - if (n < (PATH_MAX - 5)) - { - strcpy(path + n, ".ini"); - if (!stat(path, &st) && st.st_size && ptime < (unsigned long)st.st_mtime) - ptime = st.st_mtime; - path[n] = 0; - } - np = path + n - (e - k); - nx = path + PATH_MAX - 1; - strncopy(np, probe, nx - np); - if (!stat(path, &st)) - break; - - /* - * yes lib/probe///probe - * no lib/probe/probe - * - * do a manual pathaccess() to find a dir with both - */ - - sfsprintf(exe, sizeof(exe), "lib/%s/%s", probe, probe); - dirs = pathbin(); - for (;;) - { - if (!(dir = dirs)) - return NULL; - dirs = pathcat(dir, ':', "..", exe, path, pathsize); - pathcanon(path, pathsize, 0); - if (*path == '/' && pathexists(path, PATH_REGULAR|PATH_EXECUTE)) - { - pathcat(dir, ':', "..", lib, path, pathsize); - pathcanon(path, pathsize, 0); - if (*path == '/' && pathexists(path, PATH_REGULAR|PATH_EXECUTE) && !stat(path, &ps)) - break; - } - } - } - strncopy(p, key, x - p); - p = np; - x = nx; - strcpy(exe, path); - if (op >= -1 && (!(st.st_mode & S_ISUID) && ps.st_uid != geteuid() || rofs(path))) - { - if (!(p = getenv("HOME"))) - return NULL; - p = path + sfsprintf(path, PATH_MAX - 1, "%s/.%s/%s/", p, probe, HOSTTYPE); - } - strncopy(p, k, x - p); - force = 0; - if (op >= 0 && !stat(path, &st)) - { - if (ptime <= (unsigned long)st.st_mtime || ptime <= (unsigned long)st.st_ctime) - { - /* - * verify (