Hi Joachim, Sorry for the wait. Attached is a patch that adds the option -k to keep final TeX documents (.ps, .pdf and .dvi). It appears to work here. If it works for you, I'll release a new upstream tarball.
Kind regards, Ryan PS: The patch may or may not apply cleanly on the Debian sources, you're probably better off running: git clone git://github.com/ryanakca/lintex.git -- |_)|_/ Ryan Kavanagh | GnuPG key | \| \ http://ryanak.ca/ | 4A11C97A (Transitioning from E95EDDC9) () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments Ol qrpelcgvat guvf zrffntr lbh ner va ivbyngvba bs gur QZPN!
diff --git a/lintex.c b/lintex.c index cb4cf6c..bc98534 100644 --- a/lintex.c +++ b/lintex.c @@ -43,6 +43,7 @@ 1.06 - 2002-09-25 , added .pdf extension. 2010-07-11 , don't delete read only files 2010-07-14 , delete .bbl BibTeX files + 2010-08-10 , add -k to keep final product ---------------------------------------------------------------------*/ @@ -106,16 +107,20 @@ typedef struct sFnode { | Global variables: | - confirm: will be 0 or 1 according to the -i command option; | - recurse: will be 0 or 1 according to the -r command option; + | - keep: will be 0 or 1 according to the -k command option; | - bExt: the extension for backup files: defaults to "~" (the emacs | convention); | - n_bExt: the length of the previous string; | - programName: the name of the executable; | - protoTree: Froot's of the file names having extensions relevant to | TeX. ".tex" extensions are assumed to be pointed to by protoTree[0]. + | - keepTree: Froot's of the file names having extensions relevant to final + | generated documents. **/ static int confirm = FALSE; static int recurse = FALSE; +static int keep = FALSE; static char bExt[MAX_B_EXT] = "~"; static size_t n_bExt; static char *programName; @@ -137,6 +142,13 @@ static Froot protoTree[] = { {0, 0, 0} /* Must be last (sentinel) */ }; +static Froot keepTree[] = { + {".pdf", 0, 0}, + {".ps", 0, 0}, + {".dvi", 0, 0}, + {0, 0, 0} +}; + /** | Procedure prototypes (in alphabetical order) **/ @@ -190,6 +202,10 @@ int main( recurse = TRUE; break; + case 'k': case 'K': + keep = TRUE; + break; + case 'b': case 'B': to_bExt = TRUE; break; @@ -340,8 +356,9 @@ static Froot *buildTree( Froot *teXTree; /* Root node of the TeX-related files */ #ifdef FULLDEBUG - printf("* Scanning directory \"%s\" - confirm = %c, recurse = %c\n", + printf("* Scanning directory \"%s\" - confirm = %c, recurse = %c, ", dirName, (confirm ? 'Y' : 'N'), (recurse ? 'Y' : 'N')); + printf("keep = %c\n", (keep ? 'Y' : 'N')); printf("* Editor trailer: \"%s\"\n", bExt); puts("------------------------------Phase 1: directory scan"); #endif /* FULLDEBUG */ @@ -423,6 +440,9 @@ static Froot *buildTree( | entries in teXTree[i].extension: stores the file name (with the | extension stripped) in the appropriate linked list, together with | its modification time. + | + | Exception: A file is not added to teXTree if the keep option is + | enabled and if the extension is in the list of extensions to keep. **/ if ((pFe = strrchr(pDe->d_name, '.')) != 0) { @@ -441,12 +461,52 @@ static Froot *buildTree( **/ for (pTT = teXTree; pTT->extension != 0; pTT++) { - if (strcmp(pFe, pTT->extension) == 0) { - insertNode(pDe->d_name, nameLen, sStat.st_mtime, access(tName, W_OK), pTT); - + if ((strcmp(pFe, pTT->extension) == 0)) { + /* Do we want to keep final product? */ + if (keep) { + /* kExt will contain the extensions we want to keep */ + Froot *kExt; + /** + | Loop on recognized TeX-related document extensions + | to make sure we aren't deleting a document we want + | to keep. + | + | Surely there's a more elegant way? + **/ + int guard = 1; + for (kExt = keepTree; kExt->extension != 0; kExt++) { + if ((strcmp(kExt->extension, pTT->extension) == 0)) { + guard = 0; + break; + } + } + if (guard) { + /** + | This is not a final TeX document. Let's add it to the list + | of files to remove. + **/ + insertNode(pDe->d_name, nameLen, sStat.st_mtime, + access(tName, W_OK), pTT); +#ifdef FULLDEBUG + printf(" - inserted in tree"); +#endif /* FULLDEBUG */ + } else { + /* This is a final TeX document. Let me know when debugging. */ #ifdef FULLDEBUG - printf(" - inserted in tree"); + printf(" - not inserted in tree (keep enabled)\n"); #endif /* FULLDEBUG */ + } + } else { + /** + | We don't want to keep final documents. Add it to the list of + | files to remove. + **/ + insertNode(pDe->d_name, nameLen, sStat.st_mtime, + access(tName, W_OK), pTT); +#ifdef FULLDEBUG + printf(" - inserted in tree"); +#endif /* FULLDEBUG */ + } break; } } /* loop on known extensions */ @@ -680,7 +740,7 @@ static char *baseName( static void syntax() { puts("Usage:"); - printf(" %s [-i] [-r] [-b ext] [dir [dir ... ]]\n", programName); + printf(" %s [-i] [-r] [-b ext] [-k] [dir [dir ... ]]\n", programName); puts("Purpose:"); puts(" removes unneeded TeX auxiliary files and editor backup files from" " the"); @@ -688,7 +748,7 @@ static void syntax() " are"); puts(" actually removed only if their modification time is more recent" " than"); - puts(" the one of the related TeX source."); + puts(" the one of the related TeX source and if they aren't readonly."); puts("Options:"); puts(" -i : asks the user before removing any file;"); puts(" -r : scans recursively the subdirectories of the given" @@ -697,6 +757,7 @@ static void syntax() " files"); puts(" (defaults to \"~\"). -b \"\" avoids any cleanup of special" " files."); + puts(" -k : keeps final document (.pdf, .ps, .dvi)"); exit(EXIT_SUCCESS); }
signature.asc
Description: Digital signature