[hackers] [sbase] bc: Simplify loading internal library || Roberto E. Vargas Caballero
commit 1106076d535f8c9e93694a0343e5508865df9a4b
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
AuthorDate: Fri Dec 12 12:14:21 2025 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
CommitDate: Fri Dec 12 12:14:21 2025 +0100
bc: Simplify loading internal library
Testing can be done using directly the path to the bc.library
file, and get rid of the ugly function that we had to build
dynamically the path to the library.
diff --git a/bc.y b/bc.y
index 8e50e20..9dcfd15 100644
--- a/bc.y
+++ b/bc.y
_AT_@ -845,41 +845,6 @@ bc(char *fname)
fclose(filep);
}
-static void
-loadlib(void)
-{
- int r;
- size_t len;
- char bin[FILENAME_MAX], fname[FILENAME_MAX];
- static char bclib[] = "bc.library";
-
- /*
- * try first to load the library from the same directory than
- * the executable, because that can makes easier the tests
- * because it does not require to install to test the last version
- */
- len = strlen(argv0);
- if (len >= FILENAME_MAX)
- goto share;
- memcpy(bin, argv0, len + 1);
-
- r = snprintf(fname, sizeof(fname), "%s/%s", dirname(bin), bclib);
- if (r < 0 || r >= sizeof(fname))
- goto share;
-
- if (access(fname, F_OK) < 0)
- goto share;
-
- bc(fname);
- return;
-
-share:
- r = snprintf(fname, sizeof(fname), "%s/share/misc/%s", PREFIX, bclib);
- if (r < 0 || r >= sizeof(fname))
- eprintf("invalid path name for bc.library\n");
- bc(fname);
-}
-
static void
usage(void)
{
_AT_@ -916,7 +881,7 @@ main(int argc, char *argv[])
if (!cflag)
spawn();
if (lflag)
- loadlib();
+ bc(PREFIX "/bc.library");
while (*argv)
bc(*argv++);
Received on Fri Dec 12 2025 - 12:23:50 CET
This archive was generated by hypermail 2.3.0
: Fri Dec 12 2025 - 12:24:45 CET