wdvi

network DVI viewer
Log | Files | Refs

commit e074efe03ca2520950889990927aafe02934c05c
parent 479333262ab24b7d49375155a6bf22fd3bf84c53
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Sat, 28 Aug 2021 15:25:01 +0000

Remove SELFAUTO support

Diffstat:
Mfilefind.c | 170-------------------------------------------------------------------------------
Mxdvi.c | 4----
Mxdvi.h | 9---------
3 files changed, 0 insertions(+), 183 deletions(-)

diff --git a/filefind.c b/filefind.c @@ -372,158 +372,6 @@ ffputenv(key, keylen, value, flag) } -#ifdef SELFAUTO - - /* contains values of SELFAUTOLOC, SELFAUTODIR, and SELFAUTOPARENT */ -static const char *selfautostr = NULL; -static int selfautoloclen; -static int selfautodirlen; -static int selfautoparentlen; - -/* - * Resolve a symlink. Returns the length of the new string. - */ - -static int -getrealname(pos, len) - int pos; /* position in ffline[] of beginning of filename */ - int len; /* length of string in ffline[] */ -{ - struct stat statbuf; - char *buffer; - int bufsize; - char *buf1; - int pos1; - int len1; - - for (;;) { /* loop over symlinks in chain */ - if (lstat(ffline + pos, &statbuf) != 0) { - perror(ffline + pos); - return len; - } - if (!S_ISLNK(statbuf.st_mode)) - break; - buffer = xmalloc(statbuf.st_size + 1); - bufsize = readlink(ffline + pos, buffer, statbuf.st_size + 1); - if (bufsize < 0 || bufsize > statbuf.st_size) { - perror(ffline + pos); - return len; - } - buffer[bufsize] = '\0'; - buf1 = buffer; - if (buffer[0] == '/') /* if absolute path, just replace */ - pos1 = pos; /* copy it to the beginning */ - else { - pos1 = pos + len; - /* find preceding slash */ - while (pos1 > pos && ffline[--pos1] != '/') ; - /* get rid of multiple slashes */ - while (pos1 > pos && ffline[pos1 - 1] == '/') --pos1; - for (;;) { - if (buf1[0] == '.' && buf1[1] == '/') - buf1 += 2; - else if (buf1[0] == '.' && buf1[1] == '.' && buf1[2] == '/') - { - buf1 += 3; - ffline[pos1] = '\0'; - pos1 = getrealname(pos, pos1 - pos) + pos; - /* back up to preceding slash */ - while (pos1 > pos && ffline[--pos1] != '/') ; - /* get rid of multiple slashes */ - while (pos1 > pos && ffline[pos1 - 1] == '/') --pos1; - } - else break; - while (*buf1 == '/') ++buf1; - } - ++pos1; /* put the slash back */ - } - len1 = buffer + bufsize + 1 - buf1; - if (pos1 + len1 >= ffline_len) - expandline(pos1 + len1); - bcopy(buf1, ffline + pos1, len1); - free(buffer); - len = pos1 + len1 - pos - 1; - } - return len; -} - - -/* - * Initialize SELFAUTOLOC, SELFAUTODIR, and SELFAUTOPARENT. - */ - -static void -selfautoinit(pos) - int pos; -{ - const char *p; - int len; - const char *path; - int argv0len; - int pos1; - struct stat statbuf; - - if (index(argv0, '/') != NULL) { /* if program was called directly */ - len = strlen(argv0) + 1; - if (pos + len >= ffline_len) - expandline(pos + len); - bcopy(argv0, ffline + pos, len); - --len; - } - else { /* try to find it in $PATH */ - path = getenv("PATH"); - argv0len = strlen(argv0) + 1; - len = 0; - if (path != NULL) - for (;;) { - p = sep_index(path); - len = p - path; - pos1 = pos + len; - if (pos + len + argv0len >= ffline_len) - expandline(pos + len + argv0len); - bcopy(path, ffline + pos, len); - ffline[pos1] = '/'; - bcopy(argv0, ffline + pos1 + 1, argv0len); - len += argv0len; - if (stat(ffline + pos, &statbuf) == 0 - && S_ISREG(statbuf.st_mode) - && (statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) - break; - if (*p == '\0') { - len = 0; - break; - } - path = p + 1; - } - } - - /* Now we have: file name starting in ffline[pos], and len = length. */ - - len = getrealname(pos, len); - p = ffline + pos + len; - while (p > ffline + pos && *--p != '/') ; - selfautoloclen = p - (ffline + pos); - selfautostr = xmemdup(ffline + pos, selfautoloclen); - p = selfautostr + selfautoloclen; - while (p > selfautostr && *--p != '/') ; - selfautodirlen = p - selfautostr; - while (p > selfautostr && *--p != '/') ; - selfautoparentlen = p - selfautostr; - - if (FFDEBUG) { - fputs("SELFAUTOLOC = ", stdout); - fwrite(selfautostr, 1, selfautoloclen, stdout); - fputs("\nSELFAUTODIR = ", stdout); - fwrite(selfautostr, 1, selfautodirlen, stdout); - fputs("\nSELFAUTOPARENT = ", stdout); - fwrite(selfautostr, 1, selfautoparentlen, stdout); - putchar('\n'); - } -} - -#endif /* SELFAUTO */ - - /* * Do a dollar substitution of this variable. Return position in ffline. */ @@ -540,24 +388,6 @@ dollarsub(key, keylen, pos, percent) const char *env_value; struct envrec *env_rec; -#ifdef SELFAUTO - if (keylen >= 11 && memcmp(key, "SELFAUTO", 8) == 0 - && ((keylen == 11 - && (memcmp(key + 8, "LOC", 3) == 0 || memcmp(key + 8, "DIR", 3) == 0)) - || (keylen == 14 && memcmp(key + 8, "PARENT", 6) == 0))) { - int len; - - if (selfautostr == NULL) - selfautoinit(pos); - len = (keylen != 11 ? selfautoparentlen - : key[8] == 'L' ? selfautoloclen : selfautodirlen); - if (pos + len >= ffline_len) - expandline(pos + len); - bcopy(selfautostr, ffline + pos, len); - return pos + len; - } -#endif - if (pos + keylen >= ffline_len) expandline(pos + keylen); bcopy(key, ffline + pos, keylen); diff --git a/xdvi.c b/xdvi.c @@ -1357,10 +1357,6 @@ main(argc, argv) prog = rindex(*argv, '/'); if (prog != NULL) ++prog; else prog = *argv; -#if SELFAUTO - argv0 = argv[0]; -#endif - top_level = XtInitialize(prog, "XDvi", options, XtNumber(options), &argc, argv); XtAddActions(Actions, num_actions); diff --git a/xdvi.h b/xdvi.h @@ -56,11 +56,6 @@ NOTE: #define WORDS_BIGENDIAN 1 #endif -#if SELFAUTO && !defined(DEFAULT_CONFIG_PATH) -#define DEFAULT_CONFIG_PATH \ - ".:$SELFAUTOLOC:$SELFAUTODIR:$SELFAUTOPARENT:$SELFAUTODIR/share/texmf/web2c:$SELFAUTOPARENT/share/texmf/web2c:$SELFAUTODIR/texmf/web2c:$SELFAUTOPARENT/texmf/web2c:$TETEXDIR:$TEXMF/web2c" -#endif - #undef CFGFILE /* no cheating */ #if defined(DEFAULT_CONFIG_PATH) @@ -763,10 +758,6 @@ Atom atoms[5]; #define XA_WM_DELETE_WINDOW (atoms[3]) #define XA_WM_PROTOCOLS (atoms[4]) -#ifdef SELFAUTO -const char *argv0; /* argv[0] */ -#endif - /******************************** * Procedures * *******************************/