Commit 604ab1da99b173d80684d341abd0c86f8c18e662
0 parents
init
Showing
33 changed files
with
12528 additions
and
0 deletions
Too many changes to show.
To preserve performance only 31 of 33 files are displayed.
.gitignore
0 → 100644
LatexMakefile
0 → 100644
| 1 | +++ a/LatexMakefile | |
| 1 | +# use this if you have latexmk installed. | |
| 2 | +OUTDIR=out | |
| 3 | +MODE=nonstopmode | |
| 4 | +MAIN=paper.tex | |
| 5 | + | |
| 6 | +all: | |
| 7 | + latexmk -shell-escape -xelatex -bibtex -pvc -interaction=$(MODE) -outdir=$(OUTDIR) -auxdir=$(OUTDIR) -f $(MAIN) | |
| 8 | + | |
| 9 | +clean: | |
| 10 | + latexmk -outdir=$(OUTDIR) -C | ... | ... |
Makefile
0 → 100644
| 1 | +++ a/Makefile | |
| 1 | +export PYTEX=$(shell pwd)/pytex/ | |
| 2 | + | |
| 3 | +START = noxxxnote nodraft noblue | |
| 4 | +END = missing | |
| 5 | +CLASS = ./sig-alternate.cls | |
| 6 | + | |
| 7 | +all: wc paper ABSTRACT | |
| 8 | + | |
| 9 | +open: paper.pdf | |
| 10 | + @nohup acroread -openInNewWindow paper.pdf 1>/dev/null 2>/dev/null & | |
| 11 | + | |
| 12 | +figures: | |
| 13 | + @cd figures ; make | |
| 14 | + | |
| 15 | +ABSTRACT: $(PYTEX)/bin/clean $(PYTEX)/bin/lib.py abstract.tex | |
| 16 | + @$(PYTEX)/bin/clean abstract.tex ABSTRACT | |
| 17 | + | |
| 18 | +# 16 Nov 2010 : GWA : Add other cleaning rules here. | |
| 19 | + | |
| 20 | +wc: abstract.tex $(PYTEX)/bin/wc $(PYTEX)/bin/lib.py | |
| 21 | + @$(PYTEX)/bin/wc abstract.tex - | |
| 22 | + | |
| 23 | +clean: rulesclean | |
| 24 | + @rm -f ABSTRACT | |
| 25 | + | |
| 26 | +include $(PYTEX)/make/Makerules | |
| 27 | + | |
| 28 | +spellcheck: .spellcheck | silent | |
| 29 | + | |
| 30 | +.spellcheck: $(PAPER_TEXFILES) .okwords | |
| 31 | + @hunspell -t -l -p $(PWD)/.okwords $(PAPER_TEXFILES) | sort -f | uniq | tee badwords && touch .spellcheck | |
| 32 | + | |
| 33 | +silent: | |
| 34 | + @: | ... | ... |
abstract.tex
0 → 100644
common.tex
0 → 100644
conclusion.tex
0 → 100644
figures/.gitignore
0 → 100644
figures/channel_per_scan.tex
0 → 100644
| 1 | +++ a/figures/channel_per_scan.tex | |
| 1 | +{ | |
| 2 | +\setlength{\tabcolsep}{1.2mm} | |
| 3 | +\setlength\extrarowheight{0.5mm} | |
| 4 | + | |
| 5 | + \begin{tabularx}{\columnwidth}{cccd{1}d{1}d{1}d{1}d{1}d{1}d{1}} | |
| 6 | +\toprule | |
| 7 | +& & & \multicolumn{7}{c}{\textbf{Number of APs In One Scan}}\\\cline{4-10} | |
| 8 | +& & & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ | |
| 9 | +\hline | |
| 10 | +\multirow{11}{*}{\rotatebox{90}{\textbf{\# of Channels Occupied}}} | |
| 11 | + | |
| 12 | + & \multirow{3}{*}{2.4GHz} &1 & 18.5 & 4.2 & 1.6 & 0.8 & 1.0 & 0.4 & 0.0\\ | |
| 13 | + & & 2 & 81.5 & 51.2 & 36.6 & 22.9 & 13.4 & 9.2 & 7.9\\ | |
| 14 | + & & 3 & - & 44.6 & 61.8 & 76.3 & 85.6 & 90.4 & 92.1\\ | |
| 15 | +\cline{2-10} | |
| 16 | + & \multirow{8}{*}{5GHz} &1 & 4.2 & 0.7 & 0.3 & 0.0 & 0.0 & 0.0 & 0.0\\ | |
| 17 | + & & 2 & 95.8 & 20.1 & 7.7 & 0.0 & 5.3 & 0.0 & 0.0\\ | |
| 18 | + & & 3 & - & 79.3 & 45.7 & 26.3 & 21.1 & 0.0 & 0.0\\ | |
| 19 | + & & 4 & - & - & 46.4 & 54.1 & 42.1 & 50.0 & 0.0\\ | |
| 20 | + & & 5 & - & - & - & 19.5 & 26.3 & 50.0 & 0.0\\ | |
| 21 | + & & 6 & - & - & - & - & 5.3 & 0.0 & 0.0\\ | |
| 22 | + & & 7 & - & - & - & - & - & 0.0 & 0.0\\ | |
| 23 | + & & 8 & - & - & - & - & - & - & 0.0\\ | |
| 24 | + | |
| 25 | +\bottomrule | |
| 26 | +\end{tabularx} | |
| 27 | +} | ... | ... |
figures/conflict_graph.odg
0 → 100644
No preview for this file type
figures/crop.py
0 → 100755
| 1 | +++ a/figures/crop.py | |
| 1 | +#!/usr/bin/python | |
| 2 | + | |
| 3 | +import os | |
| 4 | +import subprocess | |
| 5 | +import argparse | |
| 6 | + | |
| 7 | +parser = argparse.ArgumentParser() | |
| 8 | + | |
| 9 | +parser.add_argument('files', nargs='*', default=[os.getcwd(),], help="Files to crop") | |
| 10 | + | |
| 11 | +args = parser.parse_args() | |
| 12 | + | |
| 13 | +FIG_DIR = os.path.dirname(os.path.realpath(__file__)) | |
| 14 | + | |
| 15 | +devnull = open('/dev/null', 'w') | |
| 16 | + | |
| 17 | +def crop_dir(dir): | |
| 18 | + for file in os.listdir(FIG_DIR): | |
| 19 | + crop_file(file) | |
| 20 | + | |
| 21 | +def crop_file(file): | |
| 22 | + name, extension = os.path.splitext(file) | |
| 23 | + if 'logo' in name: | |
| 24 | + print "Ignoring " + file | |
| 25 | + return | |
| 26 | + if extension == '.pdf': | |
| 27 | + print "Croping " + file | |
| 28 | + subprocess.check_call('pdfcrop %s %s' % (file, file), stdout=devnull, shell=True) | |
| 29 | + elif extension in ['.jpg', '.png']: | |
| 30 | + print "Croping " + file | |
| 31 | + subprocess.check_call('convert -trim %s %s' % (file, file), stdout=devnull, shell=True) | |
| 32 | + | |
| 33 | +for file in args.files: | |
| 34 | + file_path = os.path.abspath(file) | |
| 35 | + if os.path.isdir(file_path): | |
| 36 | + crop_dir(file_path) | |
| 37 | + else: | |
| 38 | + crop_file(file_path) | ... | ... |
figures/datatable.tex
0 → 100644
| 1 | +++ a/figures/datatable.tex | |
| 1 | +\begin{table}[t] | |
| 2 | + \centering | |
| 3 | + \begin{tabularx}{0.48\textwidth}{lX} | |
| 4 | + \toprule | |
| 5 | + \textbf{Data Type} & \textbf{Information} \\ | |
| 6 | + \toprule | |
| 7 | + Scan results & AP's SSID, BSSID, signal strength, channel and | |
| 8 | + beacon frame timestamp. \\ | |
| 9 | + Connectivity & Connection (\wifi{}/3G/None). \\ | |
| 10 | + Link quality & RSSI from associated AP when \wifi{} is connected.\\ | |
| 11 | + Screen & Whether screen is on or off. \\ | |
| 12 | + Activity & User's activity recognized by Google Play service~\cite{androidactivity}.\\ | |
| 13 | + Uptime & Device elapsed time from last boot. \\ | |
| 14 | + \bottomrule | |
| 15 | + \end{tabularx} | |
| 16 | + \caption{\textbf{Data type summary.}} | |
| 17 | + \label{tab:data} | |
| 18 | +\end{table} | ... | ... |
figures/davis_floor_plan.odg
0 → 100644
No preview for this file type
figures/logos/blue.jpg
0 → 100644
7 KB
figures/participanttable.tex
0 → 100644
| 1 | +++ a/figures/participanttable.tex | |
| 1 | +\begin{table}[t] | |
| 2 | +{\small | |
| 3 | + \begin{tabularx}{\columnwidth}{Xr} | |
| 4 | + | |
| 5 | + \textbf{By Department} &\\\toprule | |
| 6 | + Computer Science \& Engineering & 18 \\ | |
| 7 | + Civil Structure \& Environmental Engineering & 7 \\ | |
| 8 | + Human Resources & 5 \\ | |
| 9 | + School of Medicine And Biomedical Sciences & 4 \\ | |
| 10 | + School of Dental Medicine & 4\\\midrule | |
| 11 | + Other 70 Departments & 125\\\\ | |
| 12 | + | |
| 13 | + \end{tabularx} | |
| 14 | + } | |
| 15 | + | |
| 16 | + \caption{\textbf{Department Distribution of Participants}. Participants | |
| 17 | + were evenly-distributed between 75 university departments.} | |
| 18 | + | |
| 19 | + \label{tab:demographic} | |
| 20 | + \vspace*{-0.2in} | |
| 21 | +\end{table} | ... | ... |
figures/phonelab_penetration.tex
0 → 100644
| 1 | +++ a/figures/phonelab_penetration.tex | |
| 1 | +AP ID & All Users & \PhoneLab{} Users\\\midrule | |
| 2 | + 8 & 232 & 17 (7.3\%)\\ | |
| 3 | + 2 & 219 & 13 (5.9\%)\\ | |
| 4 | +13 & 289 & 14 (4.8\%)\\ | |
| 5 | + 3 & 277 & 13 (4.7\%)\\ | |
| 6 | + 9 & 150 & 7 (4.7\%)\\ | |
| 7 | + 7 & 279 & 11 (3.9\%)\\ | |
| 8 | + 0 & 207 & 8 (3.9\%)\\ | |
| 9 | +10 & 251 & 8 (3.2\%)\\ | |
| 10 | + 4 & 864 & 26 (3.0\%)\\ | |
| 11 | + 5 & 803 & 24 (3.0\%)\\ | |
| 12 | + 1 & 289 & 8 (2.8\%)\\ | |
| 13 | +12 & 421 & 7 (1.7\%)\\ | |
| 14 | +11 & 254 & 4 (1.6\%)\\ | |
| 15 | + 6 & 308 & 4 (1.3\%)\\ | |
| 16 | + | ... | ... |
figures/privacy.tex
0 → 100644
| 1 | +++ a/figures/privacy.tex | |
| 1 | +\textbf{Case Studies} & \textbf{Device ID} & \textbf{Timestamp} & \textbf{SSID} & \textbf{BSSID} & \textbf{RSSI} & \textbf{Channel} & \textbf{\wifi{} Connection} \\ | |
| 2 | +\toprule | |
| 3 | +Conflict Graph (\S\ref{subsec:channel}) & $\times$ & $\times$ & $\Diamond$ & $\surd$ & $\Diamond$ & $\times$ & $\Diamond$\\ | |
| 4 | +Spatial Planning (\S\ref{subsec:spatial}) & $\times$ & $\times$ & $\Diamond$ & $\surd$ & $\surd$ & $\times$ & $\surd$ \\ | |
| 5 | +Rogue AP (\S\ref{subsec:rogue}) & $\times$ & $\times$ & $\Diamond$ & $\surd$ & $\Diamond$ & $\times$ & $\Diamond$\\ | |
| 6 | +\bottomrule | |
| 7 | + | ... | ... |
include/start.tex
0 → 100644
| 1 | +++ a/include/start.tex | |
| 1 | +\documentclass{sig-alternate} | |
| 2 | +\usepackage{times,datetime,url,hyperref,graphicx,multirow,color,calc,ulem,threeparttable,tabularx,booktabs,enumitem,comment,balance,subcaption,morefloats,mathrsfs} | |
| 3 | +\usepackage[group-separator={,}]{siunitx} | |
| 4 | +\usepackage[font=small]{caption} | |
| 5 | + | |
| 6 | +\hypersetup{% | |
| 7 | + bookmarks=true, | |
| 8 | + unicode=true, | |
| 9 | + pdftoolbar=true, | |
| 10 | + pdfmenubar=true, | |
| 11 | + pdffitwindow=true, | |
| 12 | + pdfstartview={FitV}, | |
| 13 | + pdfnewwindow=true, | |
| 14 | + colorlinks=false, | |
| 15 | + pdfdisplaydoctitle=true, | |
| 16 | + pdfborder={0 0 0} | |
| 17 | +} | |
| 18 | +\usepackage[all]{hypcap} | |
| 19 | + | |
| 20 | +\usepackage[absolute]{textpos} | |
| 21 | +\setlength{\TPHorizModule}{1in} | |
| 22 | +\setlength{\TPVertModule}{1in} | |
| 23 | +\textblockorigin{0.75in}{0.875in} | |
| 24 | + | |
| 25 | +\setlist[itemize]{leftmargin=*,partopsep=5pt} | |
| 26 | +\setlist[enumerate]{leftmargin=*,partopsep=5pt} | |
| 27 | + | |
| 28 | +\newcommand*{\refname}{References} | |
| 29 | +\paperheight 11in | |
| 30 | +\paperwidth 8.5in | |
| 31 | + | |
| 32 | +\usepackage{dcolumn} | |
| 33 | +\newcolumntype{d}[1]{D{.}{.}{#1}} | |
| 34 | + | |
| 35 | +\input{.xxxnote} | |
| 36 | +\input{.draft} | |
| 37 | +\input{.blue} | |
| 38 | +\input{common.tex} | ... | ... |
introduction.tex
0 → 100644
paper.tex
0 → 100644
| 1 | +++ a/paper.tex | |
| 1 | +\input{./include/start.tex} | |
| 2 | + | |
| 3 | +\def\theconference{HotWireless'15} | |
| 4 | +\def\thetitle{Investigating Reciprocal \wifi{} Sharing Opportunities Using Smartphones} | |
| 5 | +\def\theauthors{Jinghao Shi, Liwen Gui, Chunming Qiao, Dimitrios Koutsonikolas, and Geoffrey Challen} | |
| 6 | +\def\thepapernumber{5} | |
| 7 | +\def\aftercaptiongap{-4mm} | |
| 8 | +%\def\isdraft{} | |
| 9 | +%\def\isblue{} | |
| 10 | + | |
| 11 | +\ifdefined\isdraft | |
| 12 | + \usepackage{draftwatermark} | |
| 13 | + \SetWatermarkText{Under Submission} | |
| 14 | + \SetWatermarkScale{0.6} | |
| 15 | + \usepackage{fancyhdr} | |
| 16 | + \pagestyle{fancy} | |
| 17 | + \renewcommand{\headrulewidth}{0pt} | |
| 18 | + \lhead{} | |
| 19 | + \chead{Under Submission to \theconference{}. Do not distribute.} | |
| 20 | + \rhead{} | |
| 21 | +\else | |
| 22 | +\fi | |
| 23 | + | |
| 24 | +\begin{document} | |
| 25 | + | |
| 26 | +\ifdefined\isblue | |
| 27 | +\begin{textblock}{1}(6.4,-0.4) | |
| 28 | +\noindent\href{http://blue.cse.buffalo.edu}{\includegraphics[width=0.6in]{./figures/logos/blue.jpg}} | |
| 29 | +\end{textblock} | |
| 30 | +\else | |
| 31 | +\fi | |
| 32 | + | |
| 33 | +\title{\thetitle\vspace*{-0.3in}} | |
| 34 | + | |
| 35 | +\numberofauthors{1} | |
| 36 | + | |
| 37 | +\author{% | |
| 38 | + \alignauthor Jinghao Shi, Liwen Gui, Chunming Qiao\\Dimitrios Koutsonikolas and Geoffrey Challen\\% | |
| 39 | + \affaddr{University at Buffalo}\\[0.05in]% | |
| 40 | + \email{\texttt{\{jinghaos,liwengui,dimitrio,challen\}@buffalo.edu}}\\ | |
| 41 | + \href{http://blue.cse.buffalo.edu/projects/pocketsniffer}{\texttt{http://blue.cse.buffalo.edu/projects/pocketsniffer}}\\[0.05in]% | |
| 42 | +Paper \#\thepapernumber{}% | |
| 43 | +\vspace*{-0.1in} | |
| 44 | +} | |
| 45 | + | |
| 46 | +\hypersetup{% | |
| 47 | + pdfinfo={% | |
| 48 | + Title={\thetitle}, | |
| 49 | + Author={\theauthors}, | |
| 50 | + } | |
| 51 | +} | |
| 52 | + | |
| 53 | + | |
| 54 | +\maketitle | |
| 55 | + | |
| 56 | +\input{abstract.tex} | |
| 57 | +\input{introduction.tex} | |
| 58 | +\input{conclusion.tex} | |
| 59 | + | |
| 60 | +{\footnotesize | |
| 61 | + \balance | |
| 62 | + \bibliographystyle{abbrv} | |
| 63 | + \bibliography{references} | |
| 64 | +} | |
| 65 | + | |
| 66 | +\end{document} | ... | ... |
pytex/.gitignore
0 → 100644
pytex/README
0 → 100644
| 1 | +++ a/pytex/README | |
| 1 | +To use, create a PYTEX environment variable and point it at the directory | |
| 2 | +where you install these files. | |
| 3 | + | |
| 4 | +This contains a combined Python-Latex build system useful for generating | |
| 5 | +scientific documents. | |
| 6 | + | |
| 7 | +bin/ contains useful Python tools for generating and building Latex | |
| 8 | +documents. | |
| 9 | + | |
| 10 | +cls/ contains useful class files for NSF proposals, letters, etc. Most of | |
| 11 | +these are based on the Memoir Latex package. | |
| 12 | + | |
| 13 | +make/ contains a Make system designed to be used with these Python tools. | |
| 14 | + | |
| 15 | +skel/ contains a set of example directories using each of the class files in | |
| 16 | +cls/. | |
| 17 | + | |
| 18 | +docs/ contains the Memoir Latex package and a reminder about how to write NSF | |
| 19 | +broader impact sections. | ... | ... |
pytex/bin/.gitignore
0 → 100644
pytex/bin/blank
0 → 100755
| 1 | +++ a/pytex/bin/blank | |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +import sys,subprocess | |
| 4 | +subprocess.check_output("convert -size %dx%d -density 300 -format pdf xc:white -bordercolor black -border 1x1 %s" % \ | |
| 5 | + ((int(float(sys.argv[2]) * 300.) - 1), | |
| 6 | + (int(float(sys.argv[3]) * 300.) - 1), | |
| 7 | + sys.argv[1]), shell=True) | ... | ... |
pytex/bin/clean
0 → 100755
| 1 | +++ a/pytex/bin/clean | |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +import lib, sys | |
| 4 | +from optparse import OptionParser | |
| 5 | +import re | |
| 6 | + | |
| 7 | +parser = OptionParser() | |
| 8 | +(options, args) = parser.parse_args() | |
| 9 | + | |
| 10 | +if len(args) < 2: | |
| 11 | + sys.exit(1) | |
| 12 | + | |
| 13 | +if args[0] == "-": | |
| 14 | + dirty_string = sys.stdin.read() | |
| 15 | +else: | |
| 16 | + dirty_string = open(args[0], "r").read() | |
| 17 | + | |
| 18 | +match = re.search(r"""(?ms)<clean:start>\s*(?P<excerpt>.*?)\s*<clean:end>""", dirty_string) | |
| 19 | +if match != None: | |
| 20 | + dirty_string = match.group('excerpt') | |
| 21 | + | |
| 22 | +if args[1] == "-": | |
| 23 | + outfile = sys.stdout | |
| 24 | +else: | |
| 25 | + outfile = open(args[1], "w") | |
| 26 | + | |
| 27 | +outfile.write(lib.clean(dirty_string).encode('utf8')) | ... | ... |
pytex/bin/flatex.c
0 → 100644
| 1 | +++ a/pytex/bin/flatex.c | |
| 1 | +/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* | |
| 2 | + * flatex.c - | |
| 3 | + * Flatten a latex file into a single file, by explicitly including | |
| 4 | + * the files inclued by \include and \input commands. Also, if bibtex is | |
| 5 | + * beeing used, then includes the .bbl file into the resulting file. Thus, | |
| 6 | + * creating a stand alone latex file that can be emailed to someone else. | |
| 7 | + * | |
| 8 | + * Compile : gcc -o flatex flatex.c | |
| 9 | + * Tested on : Linux + gcc | |
| 10 | + * By : Sariel Har-Peled | |
| 11 | + * Email : sariel@math.tau.ac.il | |
| 12 | + * WEB Page : http://www.math.tau.ac.il/~sariel/flatex.html | |
| 13 | + * Status : You can do whatever you like with this program. please | |
| 14 | + * email me bugs & suggestions. | |
| 15 | + * | |
| 16 | + * To do : Add support to the includeonly command. | |
| 17 | + *----------------------------------------------------------------------- | |
| 18 | + * FLATEX 1.21, 1994, 1996, by Sariel Har-Peled. | |
| 19 | + * | |
| 20 | + * flatex - create a single latex file with no include/inputs | |
| 21 | + * | |
| 22 | + * flatex [-v] [-x FileName] [files] | |
| 23 | + * -v Verbose, display file structure. | |
| 24 | + * -x Unflatex: extract files from archive | |
| 25 | + * -q Quiet mode. Cleaner output but -x can not be used. | |
| 26 | + * -b Do not insert bibiliography file(.bbl) | |
| 27 | + * | |
| 28 | + * Flatex page: http://www.math.tau.ac.il/~sariel/flatex.html | |
| 29 | + *----------------------------------------------------------------------- | |
| 30 | + * History: | |
| 31 | + * 26/8/96, 1.21 | |
| 32 | + * Fixed bug with includegraphics command. | |
| 33 | +\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ | |
| 34 | + | |
| 35 | +#include <stdlib.h> | |
| 36 | +#include <stdio.h> | |
| 37 | +#include <string.h> | |
| 38 | +#include <math.h> | |
| 39 | +#include <ctype.h> | |
| 40 | + | |
| 41 | + | |
| 42 | +/*====================================================================== | |
| 43 | + * Static constants. | |
| 44 | +\*======================================================================*/ | |
| 45 | +#define LINE_SIZE 1000 | |
| 46 | +#define FALSE 0 | |
| 47 | +#define TRUE 1 | |
| 48 | +#define USE_ARGUMENT( X ) ((void)X) | |
| 49 | + | |
| 50 | + | |
| 51 | +/*====================================================================== | |
| 52 | + * Types | |
| 53 | +\*======================================================================*/ | |
| 54 | +typedef struct { | |
| 55 | + char verbose; | |
| 56 | + char fBibInsert, fQuiet; | |
| 57 | + int cSpecialInputLevel; | |
| 58 | + char szFullName[ LINE_SIZE ]; | |
| 59 | +} structFlags; | |
| 60 | + | |
| 61 | + | |
| 62 | +/*====================================================================== | |
| 63 | + * Static prototypes. | |
| 64 | +\*======================================================================*/ | |
| 65 | +static void flatIt( FILE * flOut, | |
| 66 | + char * szInName, | |
| 67 | + int level, | |
| 68 | + structFlags * pFlags ); | |
| 69 | +static void replaceExt( char * str, char * ext ); | |
| 70 | + | |
| 71 | + | |
| 72 | +/*====================================================================== | |
| 73 | + * Start of Code | |
| 74 | +\*======================================================================*/ | |
| 75 | + | |
| 76 | + | |
| 77 | +static void spacesByLevel( int level ) | |
| 78 | +{ | |
| 79 | + while ( level > 0 ) { | |
| 80 | + printf( " " ); | |
| 81 | + level--; | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 85 | + | |
| 86 | +static void printHelp( void ) | |
| 87 | +{ | |
| 88 | + printf( "flatex - create a single latex file with no include/inputs\n" ); | |
| 89 | + printf( "\n\tflatex [-v] [-x FileName] [files]\n" ); | |
| 90 | + printf( "\t\t-v\tVerbose, display file structure.\n" ); | |
| 91 | + printf( "\t\t-x\tUnflatex: extract files from archive\n" ); | |
| 92 | + printf( "\t\t-q\tQuiet mode. Cleaner output but -x can not be used.\n" ); | |
| 93 | + printf( "\t\t-b\tDo not insert bibiliography file(.bbl)\n" ); | |
| 94 | + printf( "\nFlatex page: http://www.math.tau.ac.il/~sariel/flatex.html\n" ); | |
| 95 | + printf( "\n" ); | |
| 96 | +} | |
| 97 | + | |
| 98 | + | |
| 99 | +static void * myMalloc( unsigned int size ) | |
| 100 | +{ | |
| 101 | + void * ptr; | |
| 102 | + | |
| 103 | + ptr = malloc( size ); | |
| 104 | + if ( ptr == NULL ) { | |
| 105 | + fprintf( stderr, "Not enough memory" ); | |
| 106 | + exit( -1 ); | |
| 107 | + } | |
| 108 | + | |
| 109 | + return ptr; | |
| 110 | +} | |
| 111 | + | |
| 112 | + | |
| 113 | +static void handleIncludeCommand( char * line, | |
| 114 | + char * lpszInclude, | |
| 115 | + FILE * flOut, | |
| 116 | + int level, | |
| 117 | + structFlags * pFlags ) | |
| 118 | +{ | |
| 119 | + char * lpszBrace, * lpszName, * lpszEndBrace; | |
| 120 | + char ch, fInput = 0; | |
| 121 | + | |
| 122 | + lpszBrace = NULL; | |
| 123 | + | |
| 124 | + if ( strncmp( lpszInclude, "\\input", 6 ) == 0 ) { | |
| 125 | + lpszBrace = lpszInclude + 6; | |
| 126 | + fInput = 1; | |
| 127 | + } else | |
| 128 | + if ( strncmp( lpszInclude, "\\include", 8 ) == 0 ) { | |
| 129 | + lpszBrace = lpszInclude + 8; | |
| 130 | + } | |
| 131 | + | |
| 132 | + ch = *lpszInclude; | |
| 133 | + *lpszInclude = 0; | |
| 134 | + fputs( line, flOut ); | |
| 135 | + *lpszInclude = ch; | |
| 136 | + | |
| 137 | + lpszEndBrace = strchr( lpszBrace, '}' ); | |
| 138 | + if ( *lpszBrace != '{' || lpszEndBrace == NULL ) { | |
| 139 | + fprintf( stderr, "ERROR: Expected brace not found.\n\n\tline:%s\n", | |
| 140 | + line ); | |
| 141 | + exit( -1 ); | |
| 142 | + } | |
| 143 | + | |
| 144 | + *lpszEndBrace = 0; | |
| 145 | + lpszName = (char *)myMalloc( LINE_SIZE ); | |
| 146 | + strcpy( lpszName, lpszBrace + 1 ); | |
| 147 | + if ( ! fInput ) | |
| 148 | + replaceExt( lpszName, ".tex" ); | |
| 149 | + | |
| 150 | + flatIt( flOut, lpszName, level + 1, pFlags ); | |
| 151 | + | |
| 152 | + lpszEndBrace++; | |
| 153 | + while ( *lpszEndBrace ) { | |
| 154 | + *line++ = *lpszEndBrace++; | |
| 155 | + } | |
| 156 | + *line = 0; | |
| 157 | + | |
| 158 | + free( lpszName ); | |
| 159 | +} | |
| 160 | + | |
| 161 | + | |
| 162 | +static char isBefore( char * lpszA, char * lpszB ) | |
| 163 | +{ | |
| 164 | + if ( lpszB == NULL ) | |
| 165 | + return TRUE; | |
| 166 | + if ( lpszA == NULL ) | |
| 167 | + return FALSE; | |
| 168 | + | |
| 169 | + if ( (int)( lpszA -lpszB ) < 0 ) { | |
| 170 | + return TRUE; | |
| 171 | + } | |
| 172 | + return FALSE; | |
| 173 | +} | |
| 174 | + | |
| 175 | + | |
| 176 | +static FILE * fopenTex( char * file, | |
| 177 | + char * mode ) | |
| 178 | +{ | |
| 179 | + FILE * fl; | |
| 180 | + | |
| 181 | + fl = fopen( file, mode ); | |
| 182 | + if ( fl != NULL ) | |
| 183 | + return fl; | |
| 184 | + | |
| 185 | + replaceExt( file, ".tex" ); | |
| 186 | + fl = fopen( file, mode ); | |
| 187 | + | |
| 188 | + return fl; | |
| 189 | +} | |
| 190 | + | |
| 191 | + | |
| 192 | +static char isTexFileExists( char * file ) | |
| 193 | +{ | |
| 194 | + FILE * fl; | |
| 195 | + | |
| 196 | + fl = fopenTex( file, "rt" ); | |
| 197 | + if ( fl != NULL ) { | |
| 198 | + fclose( fl ); | |
| 199 | + return 1; | |
| 200 | + } | |
| 201 | + | |
| 202 | + return 0; | |
| 203 | +} | |
| 204 | + | |
| 205 | + | |
| 206 | +static void addTexExt( char * file ) | |
| 207 | +{ | |
| 208 | + FILE * fl; | |
| 209 | + | |
| 210 | + fl = fopenTex( file, "rt"); | |
| 211 | + if ( fl != NULL ) | |
| 212 | + fclose( fl ); | |
| 213 | +} | |
| 214 | + | |
| 215 | + | |
| 216 | +static char is_str_prefix( char * str, char * prefix ) | |
| 217 | +{ | |
| 218 | + int len; | |
| 219 | + | |
| 220 | + if ( str == NULL || prefix == NULL ) | |
| 221 | + return 0; | |
| 222 | + | |
| 223 | + len = strlen( prefix ); | |
| 224 | + | |
| 225 | + return (strncmp( str, prefix, len ) == 0); | |
| 226 | +} | |
| 227 | + | |
| 228 | + | |
| 229 | +static void flatIt( FILE * flOut, | |
| 230 | + char * pSzInName, | |
| 231 | + int level, | |
| 232 | + structFlags * pFlags ) | |
| 233 | +{ | |
| 234 | + FILE * flIn; | |
| 235 | + char * str, * lpszInput, * lpszInclude, * line, * lpszRem, *inc; | |
| 236 | + char * lpszLine, * lpszRemark, * lpszBib, * lpszBibStyle; | |
| 237 | + char * lpszNewCommand, * lpszName; | |
| 238 | + char cont; | |
| 239 | + char repFlag; | |
| 240 | + char szInName[ 100 ]; | |
| 241 | + char fInclude; | |
| 242 | + | |
| 243 | + strcpy( szInName, pSzInName ); | |
| 244 | + | |
| 245 | + addTexExt( szInName ); | |
| 246 | + if ( ! pFlags->fQuiet ) | |
| 247 | + fprintf( flOut, "%%%cflatex input: [%s]\n", | |
| 248 | + pFlags->cSpecialInputLevel > 0? '*' : ' ', | |
| 249 | + szInName ); | |
| 250 | + if ( pFlags->verbose ) { | |
| 251 | + printf( "\t" ); | |
| 252 | + spacesByLevel( level ); | |
| 253 | + printf( "%s\n", szInName ); | |
| 254 | + } | |
| 255 | + | |
| 256 | + line = (char *)myMalloc( LINE_SIZE ); | |
| 257 | + lpszLine = (char *)myMalloc( LINE_SIZE ); | |
| 258 | + lpszRemark = (char *)myMalloc( LINE_SIZE ); | |
| 259 | + | |
| 260 | + flIn = fopenTex( szInName, "rt" ); | |
| 261 | + if ( flIn == NULL ) { | |
| 262 | + fprintf( stderr, "Unable to open file: %s\n", szInName ); | |
| 263 | + exit( -1 ); | |
| 264 | + } | |
| 265 | + | |
| 266 | + *lpszRemark = 0; | |
| 267 | + while ( ! feof( flIn ) ) { | |
| 268 | + str = fgets( line, LINE_SIZE, flIn ); | |
| 269 | + if ( str == NULL ) | |
| 270 | + break; | |
| 271 | + | |
| 272 | + fInclude = FALSE; | |
| 273 | + | |
| 274 | + strcpy( lpszLine, line ); | |
| 275 | + | |
| 276 | + lpszRem = strchr( line, '%' ); | |
| 277 | + if ( lpszRem != NULL ) { | |
| 278 | + strcpy( lpszRemark, lpszRem ); | |
| 279 | + *lpszRem = 0; | |
| 280 | + } | |
| 281 | + | |
| 282 | + do { | |
| 283 | + cont = 0; | |
| 284 | + lpszInput = strstr( line, "\\input" ); | |
| 285 | + | |
| 286 | + lpszBib = strstr( line, "\\bibliography" ); | |
| 287 | + lpszBibStyle = strstr( line, "\\bibliographystyle" ); | |
| 288 | + | |
| 289 | + if ( pFlags->fBibInsert && | |
| 290 | + ( lpszBib != NULL || lpszBibStyle != NULL ) ) { | |
| 291 | + lpszName = (char *)myMalloc( LINE_SIZE ); | |
| 292 | + | |
| 293 | + strcpy( lpszName, lpszLine ); | |
| 294 | + strcpy( lpszLine, pFlags->fQuiet? "%" : "%FLATEX-REM:" ); | |
| 295 | + strcat( lpszLine, lpszName ); | |
| 296 | + | |
| 297 | + if ( lpszBibStyle != NULL ) { | |
| 298 | + strcpy( lpszName, pFlags->szFullName ); | |
| 299 | + replaceExt( lpszName, ".bbl" ); | |
| 300 | + | |
| 301 | + pFlags->cSpecialInputLevel++; | |
| 302 | + flatIt( flOut, lpszName, level + 1, pFlags ); | |
| 303 | + pFlags->cSpecialInputLevel--; | |
| 304 | + | |
| 305 | + if ( pFlags->verbose ) { | |
| 306 | + printf( "\t" ); | |
| 307 | + spacesByLevel( level + 1 ); | |
| 308 | + printf( "(Bibiliography)\n" ); | |
| 309 | + } | |
| 310 | + } | |
| 311 | + break; | |
| 312 | + } | |
| 313 | + | |
| 314 | + inc = line; | |
| 315 | + do { | |
| 316 | + repFlag = 0; | |
| 317 | + lpszInclude = strstr( inc, "\\include" ); | |
| 318 | + | |
| 319 | + if ( is_str_prefix( lpszInclude, "\\includeversion" ) | |
| 320 | + || is_str_prefix( lpszInclude, | |
| 321 | + "\\includegraphics" ) ) { | |
| 322 | + repFlag = 1; | |
| 323 | + inc = lpszInclude + 1; | |
| 324 | + continue; | |
| 325 | + } | |
| 326 | + | |
| 327 | + if ( is_str_prefix( lpszInclude, "\\includeonly" ) ) { | |
| 328 | + fprintf( stderr, "WARNING: \"\\includeonly\" command " | |
| 329 | + "ignored\n" ); | |
| 330 | + inc = lpszInclude + 1; | |
| 331 | + repFlag = 1; | |
| 332 | + continue; | |
| 333 | + } | |
| 334 | + if ( lpszInclude != NULL && isalpha( lpszInclude[ 8 ] ) ) { | |
| 335 | + fprintf( stderr, | |
| 336 | + "\nWarning: include-like(?) command ignored" | |
| 337 | + " at line:\n\t%s", lpszLine ); | |
| 338 | + inc = lpszInclude + 1; | |
| 339 | + repFlag = 1; | |
| 340 | + continue; | |
| 341 | + } | |
| 342 | + } while ( repFlag ); | |
| 343 | + | |
| 344 | + if ( isBefore( lpszInput, lpszInclude ) ) | |
| 345 | + lpszInclude = lpszInput; | |
| 346 | + | |
| 347 | + if ( lpszInclude != NULL ) { | |
| 348 | + lpszNewCommand = strstr( line, "\\newcommand" ); | |
| 349 | + if ( lpszNewCommand == NULL ) { | |
| 350 | + handleIncludeCommand( line, lpszInclude, flOut, level, | |
| 351 | + pFlags ); | |
| 352 | + cont = 1; | |
| 353 | + fInclude = TRUE; | |
| 354 | + } | |
| 355 | + } | |
| 356 | + } while ( cont ); | |
| 357 | + if ( fInclude ) { | |
| 358 | + strcat( line, lpszRemark ); | |
| 359 | + fputs( line, flOut ); | |
| 360 | + } else | |
| 361 | + fputs( lpszLine, flOut ); | |
| 362 | + } | |
| 363 | + | |
| 364 | + fclose( flIn ); | |
| 365 | + fputs( "\n", flOut ); | |
| 366 | + | |
| 367 | + if ( ! pFlags->fQuiet ) | |
| 368 | + fprintf( flOut, "%% flatex input end: [%s]\n", szInName ); | |
| 369 | + | |
| 370 | + free( line ); | |
| 371 | + free( lpszLine ); | |
| 372 | + free( lpszRemark ); | |
| 373 | +} | |
| 374 | + | |
| 375 | + | |
| 376 | +static void replaceExt( char * str, char * ext ) | |
| 377 | +{ | |
| 378 | + int len, ind; | |
| 379 | + | |
| 380 | + len = strlen( str ); | |
| 381 | + ind = len - 1; | |
| 382 | + while ( ind >= 0 && str[ ind ] != '.' && str[ ind ] != '\\' && | |
| 383 | + str[ ind ] != '/' ) | |
| 384 | + ind--; | |
| 385 | + | |
| 386 | + if ( ind >= 0 && str[ ind ] == '.' ) { | |
| 387 | + str[ ind ] = 0; | |
| 388 | + } | |
| 389 | + | |
| 390 | + strcat( str, ext ); | |
| 391 | +} | |
| 392 | + | |
| 393 | +static char strCmpPrefixAndCopy( char * line, | |
| 394 | + char * str, | |
| 395 | + char * outName ) | |
| 396 | +{ | |
| 397 | + char * pos, * pPreLine; | |
| 398 | + | |
| 399 | + pPreLine = line; | |
| 400 | + | |
| 401 | + pos = strstr( line, str ); | |
| 402 | + if ( pos == NULL ) | |
| 403 | + return 0; | |
| 404 | + | |
| 405 | + line = pos + strlen( str ); | |
| 406 | + strcpy( outName, line ); | |
| 407 | + pos = strchr( outName, ']' ); | |
| 408 | + | |
| 409 | + if ( pos == NULL ) { | |
| 410 | + fprintf( stderr, "Error encountered in line: [%s]", pPreLine ); | |
| 411 | + exit( -1 ); | |
| 412 | + } | |
| 413 | + *pos = 0; | |
| 414 | + | |
| 415 | + return 1; | |
| 416 | +} | |
| 417 | + | |
| 418 | + | |
| 419 | +static void writeFile( FILE * flIn, | |
| 420 | + char * pOutName, | |
| 421 | + int level ) | |
| 422 | +{ | |
| 423 | + FILE * flOut; | |
| 424 | + char * lpszLine; | |
| 425 | + char line[ LINE_SIZE ], outName[ LINE_SIZE ]; | |
| 426 | + char flag; | |
| 427 | + | |
| 428 | + outName[ 0 ] = 0; | |
| 429 | + | |
| 430 | + if ( pOutName == NULL ) { | |
| 431 | + flOut = NULL; | |
| 432 | + printf( "Scanning for flatex archive start...\n" ); | |
| 433 | + } else { | |
| 434 | + flOut = fopen( pOutName, "wt" ); | |
| 435 | + if ( flOut == NULL ) { | |
| 436 | + fprintf( stderr, "Unable to open file: %s", pOutName ); | |
| 437 | + exit( -1 ); | |
| 438 | + } | |
| 439 | + spacesByLevel( level ); | |
| 440 | + printf( "[%s]\n", pOutName ); | |
| 441 | + } | |
| 442 | + | |
| 443 | + do { | |
| 444 | + lpszLine = fgets( line, LINE_SIZE, flIn ); | |
| 445 | + if ( lpszLine == NULL ) | |
| 446 | + break; | |
| 447 | + | |
| 448 | + flag = strCmpPrefixAndCopy( line, "% flatex input end: [", outName ); | |
| 449 | + if ( flag ) { | |
| 450 | + if ( flOut == NULL ) { | |
| 451 | + fprintf( stderr, "Something is wrong!!!!\n" ); | |
| 452 | + exit( -1 ); | |
| 453 | + } | |
| 454 | + //spacesByLevel( level ); | |
| 455 | + // printf( "/\n" ); | |
| 456 | + //printf( "Writing [%s] done\n", outName ); | |
| 457 | + break; | |
| 458 | + } | |
| 459 | + | |
| 460 | + flag = strCmpPrefixAndCopy( line, "% flatex input: [", outName ); | |
| 461 | + if ( flag ) { | |
| 462 | + writeFile( flIn, outName, level + 1 ); | |
| 463 | + if ( flOut != NULL ) | |
| 464 | + fprintf( flOut, "\\input{%s}\n", outName ); | |
| 465 | + } else { | |
| 466 | + flag = strCmpPrefixAndCopy( line, "%*flatex input: [", outName ); | |
| 467 | + if ( flag ) { | |
| 468 | + writeFile( flIn, outName, level + 1 ); | |
| 469 | + } else { | |
| 470 | + if ( flOut != NULL ) { | |
| 471 | + if ( strncmp( line, "%FLATEX-REM:", 12 ) == 0 ) | |
| 472 | + fputs( line + 12, flOut ); | |
| 473 | + else | |
| 474 | + fputs( line, flOut ); | |
| 475 | + } | |
| 476 | + } | |
| 477 | + } | |
| 478 | + } while ( ! feof( flIn ) ); | |
| 479 | + | |
| 480 | + if ( flOut != NULL ) | |
| 481 | + fclose( flOut ); | |
| 482 | +} | |
| 483 | + | |
| 484 | + | |
| 485 | +static void flatOutFile( char * fileName, | |
| 486 | + structFlags * pFlags ) | |
| 487 | +{ | |
| 488 | + FILE * flIn; | |
| 489 | + | |
| 490 | + USE_ARGUMENT( pFlags ); | |
| 491 | + | |
| 492 | + flIn = fopen( fileName, "rt" ); | |
| 493 | + if ( flIn == NULL ) { | |
| 494 | + fprintf( stderr, "Unable to open file: %s", fileName ); | |
| 495 | + exit( -1 ); | |
| 496 | + } | |
| 497 | + | |
| 498 | + writeFile( flIn, NULL, 0 ); | |
| 499 | + | |
| 500 | + fclose( flIn ); | |
| 501 | +} | |
| 502 | + | |
| 503 | + | |
| 504 | +static void flatFile( char * fileName, | |
| 505 | + structFlags * pFlags ) | |
| 506 | +{ | |
| 507 | + char * szInName, * szOutName; | |
| 508 | + int inLen; | |
| 509 | + FILE * flOut; | |
| 510 | + | |
| 511 | + szInName = (char *)myMalloc( LINE_SIZE ); | |
| 512 | + szOutName = (char *)myMalloc( LINE_SIZE ); | |
| 513 | + | |
| 514 | + strcpy( szInName, fileName ); | |
| 515 | + if ( ! isTexFileExists( szInName ) ) { | |
| 516 | + fprintf( stderr, "--Unable to open file: [%s]\n", fileName ); | |
| 517 | + exit( -1 ); | |
| 518 | + } | |
| 519 | + | |
| 520 | + inLen = strlen( szInName ); | |
| 521 | + if ( inLen < 4 || ( szInName[ inLen ] != '.' && | |
| 522 | + strcmp( szInName + inLen - 4, ".tex" ) != 0 ) ) { | |
| 523 | + strcat( szInName, ".tex" ); | |
| 524 | + } | |
| 525 | + | |
| 526 | + printf( "input file: [%s]\n", szInName ); | |
| 527 | + | |
| 528 | + strcpy( pFlags->szFullName, szInName ); | |
| 529 | + | |
| 530 | + strcpy( szOutName, szInName ); | |
| 531 | + replaceExt( szOutName, ".flt" ); | |
| 532 | + | |
| 533 | + flOut = fopen( szOutName, "wt" ); | |
| 534 | + if ( flOut == NULL ) { | |
| 535 | + fprintf( stderr, "Unable to open file: %s", szOutName ); | |
| 536 | + exit( -1 ); | |
| 537 | + } | |
| 538 | + | |
| 539 | + flatIt( flOut, szInName, 0, pFlags ); | |
| 540 | + | |
| 541 | + fclose( flOut ); | |
| 542 | + | |
| 543 | + printf( "\n\tFile: \"%s\" generated\n", szOutName ); | |
| 544 | +} | |
| 545 | + | |
| 546 | + | |
| 547 | +static char isFlag( char * str, char ch ) | |
| 548 | +{ | |
| 549 | + if ( str[ 0 ] == '-' && | |
| 550 | + ( str[ 1 ] == ch || str[ 1 ] == toupper( ch ) ) | |
| 551 | + && ( str[ 2 ] == 0 ) ) | |
| 552 | + return TRUE; | |
| 553 | + | |
| 554 | + return FALSE; | |
| 555 | +} | |
| 556 | + | |
| 557 | + | |
| 558 | +int main( int argc, char * argv[] ) | |
| 559 | +{ | |
| 560 | + int ind; | |
| 561 | + structFlags sFlags; | |
| 562 | + | |
| 563 | + printf( "FLATEX 1.21, 1994, 1996, by Sariel Har-Peled.\n\n" ); | |
| 564 | + if ( argc == 1 ) | |
| 565 | + printHelp(); | |
| 566 | + | |
| 567 | + sFlags.verbose = FALSE; | |
| 568 | + sFlags.fBibInsert = TRUE; | |
| 569 | + sFlags.cSpecialInputLevel = 0; | |
| 570 | + *sFlags.szFullName = 0; | |
| 571 | + sFlags.fQuiet = FALSE; | |
| 572 | + | |
| 573 | + for ( ind = 1; ind < argc; ind++ ) { | |
| 574 | + if ( isFlag( argv[ ind ], 'v' ) ) { | |
| 575 | + sFlags.verbose = TRUE; | |
| 576 | + continue; | |
| 577 | + } | |
| 578 | + if ( isFlag( argv[ ind ], 'b' ) ) { | |
| 579 | + sFlags.fBibInsert = FALSE; | |
| 580 | + continue; | |
| 581 | + } | |
| 582 | + if ( isFlag( argv[ ind ], 'q' ) ) { | |
| 583 | + sFlags.fQuiet = TRUE; | |
| 584 | + continue; | |
| 585 | + } | |
| 586 | + if ( isFlag( argv[ ind ], 'x' ) ) { | |
| 587 | + flatOutFile( argv[ ind + 1 ], &sFlags ); | |
| 588 | + ind++; | |
| 589 | + continue; | |
| 590 | + } | |
| 591 | + | |
| 592 | + flatFile( argv[ ind ], &sFlags ); | |
| 593 | + } | |
| 594 | + return 0; | |
| 595 | +} | |
| 596 | + | |
| 597 | +/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* | |
| 598 | + * | |
| 599 | + * flatex.c - End of File | |
| 600 | +\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ | |
| 601 | + | ... | ... |
pytex/bin/lib.py
0 → 100644
| 1 | +++ a/pytex/bin/lib.py | |
| 1 | +import re | |
| 2 | + | |
| 3 | +def clean(inlines): | |
| 4 | + | |
| 5 | + removecomments = re.compile(r"^(%.*)$", re.M) | |
| 6 | + inlines = removecomments.sub("", inlines) | |
| 7 | + fixpercents = re.compile(r"\\%", re.M) | |
| 8 | + inlines = fixpercents.sub("%", inlines) | |
| 9 | + removetex = re.compile(r"~?\\(((sub)*)section(\*?)|cite|chapter|thispagestyle)\*+\{([^\}]+)\}", re.M) | |
| 10 | + inlines = removetex.sub("", inlines) | |
| 11 | + removetex2 = re.compile(r"\\(clearpage)", re.M) | |
| 12 | + inlines = removetex2.sub("", inlines) | |
| 13 | + keeptex = re.compile(r"\\(textit|textbf|texttt|textsc|sloppypar|sloppy)\{([^\}]+)\}", re.M) | |
| 14 | + while True: | |
| 15 | + beforelines = inlines | |
| 16 | + inlines = keeptex.sub(r"\2", inlines) | |
| 17 | + if inlines == beforelines: | |
| 18 | + break | |
| 19 | + keeptex2 = re.compile(r"\{\\scshape\s+([^\}]+)\}", re.S | re.M) | |
| 20 | + inlines = keeptex2.sub(r"\1", inlines) | |
| 21 | + quotes = re.compile(r"(``|'')", re.M) | |
| 22 | + inlines = quotes.sub(r'"', inlines) | |
| 23 | + phonelab_macro = re.compile(r"\\PhoneLab{}", re.M) | |
| 24 | + inlines = phonelab_macro.sub("PhoneLab", inlines) | |
| 25 | + netsense_macro = re.compile(r"\\NetSense{}", re.M) | |
| 26 | + inlines = netsense_macro.sub("NetSense", inlines) | |
| 27 | + sciwinet_macro = re.compile(r"\\SciWiNet{}", re.M) | |
| 28 | + inlines = sciwinet_macro.sub("SciWiNet", inlines) | |
| 29 | + composite_macro = re.compile(r"\\ComPoSiTe{}", re.M) | |
| 30 | + inlines = composite_macro.sub("ComPoSiTe", inlines) | |
| 31 | + agiledroid_macro = re.compile(r"\\AG{}", re.M) | |
| 32 | + inlines = agiledroid_macro.sub("AgileDroid", inlines) | |
| 33 | + wifi_macro = re.compile(r"\\wifi{}", re.M) | |
| 34 | + inlines = wifi_macro.sub("Wifi", inlines) | |
| 35 | + keep_together = re.compile(r"~", re.M) | |
| 36 | + inlines = keep_together.sub(" ", inlines) | |
| 37 | + en_dashes = re.compile(r"([^-])--([^-])", re.M) | |
| 38 | + inlines = en_dashes.sub(u"\\1\u2013\\2", inlines) | |
| 39 | + em_dashes = re.compile(r"([^-])---([^-])", re.M) | |
| 40 | + inlines = em_dashes.sub(u"\\1\u2014\\2", inlines) | |
| 41 | + enum = re.compile(r"\\begin\{enumerate\}(.*?)\\end\{enumerate\}", re.S | re.M) | |
| 42 | + | |
| 43 | + class Counter: | |
| 44 | + def __init__(self): | |
| 45 | + self.count = 0 | |
| 46 | + def reset(self): | |
| 47 | + self.count = 0 | |
| 48 | + def increment(self, matchObject): | |
| 49 | + self.count += 1 | |
| 50 | + return str(self.count) + "." | |
| 51 | + | |
| 52 | + def match(m): | |
| 53 | + c = Counter() | |
| 54 | + item = re.compile(r"\\item") | |
| 55 | + text = item.sub(c.increment, m.group(1)) | |
| 56 | + c.reset() | |
| 57 | + return text | |
| 58 | + inlines = enum.sub(match, inlines) | |
| 59 | + | |
| 60 | + removeitem = re.compile(r"~?\\item", re.M) | |
| 61 | + inlines = removeitem.sub("", inlines) | |
| 62 | + removeflushenumbf = re.compile(r"\\begin\{flushenumbf\}\s+(.*?)\s+\\end\{flushenumbf\}", re.S | re.M) | |
| 63 | + inlines = removeflushenumbf.sub(r"\1", inlines) | |
| 64 | + removebeginabstract = re.compile(r"\\begin\{abstract\}\s+(.*?)\s+\\end\{abstract\}", re.S | re.M) | |
| 65 | + inlines = removebeginabstract.sub(r"\1", inlines) | |
| 66 | + | |
| 67 | + lines = re.split(r'\s{2,}', inlines) | |
| 68 | + | |
| 69 | + while re.match(lines[0], r"^\s*$"): | |
| 70 | + lines = lines[1:] | |
| 71 | + if len(lines) == 0: | |
| 72 | + return "" | |
| 73 | + while re.match(lines[-1], r"^\s*$"): | |
| 74 | + lines = lines[:-1] | |
| 75 | + if len(lines) == 0: | |
| 76 | + return "" | |
| 77 | + | |
| 78 | + output = '\n\n'.join([re.sub(r'\n', ' ', line) for line in lines]) | |
| 79 | + return output | ... | ... |
pytex/bin/number
0 → 100755
| 1 | +++ a/pytex/bin/number | |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +from optparse import OptionParser | |
| 4 | +import sys, subprocess, time, re, shlex, tempfile, os | |
| 5 | + | |
| 6 | +parser = OptionParser() | |
| 7 | +parser.add_option("-s", "--skip", dest="skip", type=int, default=0, help="number of initial pages to skip (default 0)") | |
| 8 | +parser.add_option("-a", "--avoid", dest="avoid", type=str, default="", help="pages to avoid, comma separated (default \"\")") | |
| 9 | +(options, args) = parser.parse_args() | |
| 10 | + | |
| 11 | +avoid = options.avoid.split(",") | |
| 12 | +avoid = [int(a) for a in avoid] | |
| 13 | + | |
| 14 | +infile = args[0] | |
| 15 | +outfile = args[1] | |
| 16 | +ininfo = subprocess.Popen("pdfinfo \"%s\"" % (infile), shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 17 | +origpages = int(re.search(r'Pages:\s+(\d+)', ininfo).group(1)) | |
| 18 | +numpages = origpages - options.skip | |
| 19 | + | |
| 20 | +latexstart = r'''\documentclass[11pt]{memoir} | |
| 21 | +\usepackage{times} | |
| 22 | +\maxdeadcycles=1000 | |
| 23 | +\setstocksize{11in}{8.5in} | |
| 24 | +\settrimmedsize{11in}{8.5in}{*} | |
| 25 | +\settrims{0pt}{0pt} | |
| 26 | +\setlrmarginsandblock{1in}{1in}{*} | |
| 27 | +\setulmarginsandblock{1in}{1in}{*} | |
| 28 | +\setheadfoot{0.1pt}{36pt} | |
| 29 | +\setmarginnotes{0.5cm}{1.5cm}{0.1cm} | |
| 30 | +\checkandfixthelayout | |
| 31 | +\copypagestyle{number}{headings} | |
| 32 | +\makeoddhead{number}{}{}{} | |
| 33 | +\makeevenhead{number}{}{}{} | |
| 34 | +\makeoddfoot{number}{}{\thepage}{} | |
| 35 | +\makeevenfoot{number}{}{\thepage}{} | |
| 36 | +\begin{document} | |
| 37 | +\pagestyle{number}''' | |
| 38 | + | |
| 39 | +latexend = r'''\end{document}''' | |
| 40 | + | |
| 41 | +startdir = os.getcwd() | |
| 42 | +tempdir = tempfile.mkdtemp() | |
| 43 | +subprocess.call("cp \"%s\" \"%s\"/A.pdf" % (infile, tempdir), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| 44 | +os.chdir(tempdir) | |
| 45 | +latexfile = open('B.tex', 'w') | |
| 46 | +print >>latexfile, latexstart | |
| 47 | +for a in range(numpages): | |
| 48 | + print >>latexfile, r'''\mbox{} | |
| 49 | +\newpage''' | |
| 50 | +print >>latexfile, latexend | |
| 51 | +latexfile.close() | |
| 52 | +subprocess.Popen("pdflatex --interaction=nonstopmode B.tex", shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 53 | +subprocess.Popen(r"pdftk A.pdf burst output A%03d.pdf", shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 54 | +subprocess.Popen(r"pdftk B.pdf burst output B%03d.pdf", shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 55 | +Boffset = options.skip | |
| 56 | +for Aindex in range(origpages): | |
| 57 | + Aindex += 1 | |
| 58 | + if (Aindex <= Boffset) or ((Aindex - Boffset) in avoid): | |
| 59 | + subprocess.Popen(r"cp A%03d.pdf C%03d.pdf" % (Aindex, Aindex), shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 60 | + else: | |
| 61 | + subprocess.Popen(r"pdftk A%03d.pdf background B%03d.pdf output C%03d.pdf" % (Aindex, Aindex - Boffset, Aindex), shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 62 | +subprocess.Popen(r"pdftk %s output D.pdf" % (' '.join(["C%03d.pdf" % (i + 1) for i in range(origpages)])), shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 63 | +subprocess.call("cp D.pdf \"%s\"/\"%s\"" % (startdir, outfile), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| 64 | + | |
| 65 | +os.chdir(startdir) | ... | ... |
pytex/bin/rotateandstitch
0 → 100755
| 1 | +++ a/pytex/bin/rotateandstitch | |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +from optparse import OptionParser | |
| 4 | +import sys, subprocess, time, re, shlex | |
| 5 | + | |
| 6 | +parser = OptionParser() | |
| 7 | +(options, args) = parser.parse_args() | |
| 8 | + | |
| 9 | +pagesize = re.compile(r'Page size:\s+(\d+)\s+x\s+(\d+)') | |
| 10 | +files = [] | |
| 11 | +outpdf = args.pop(0) | |
| 12 | +for arg in args: | |
| 13 | + output = subprocess.Popen("pdfinfo \"%s\"" % (arg), shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 14 | + pagematch = pagesize.search(output) | |
| 15 | + if pagematch == None: | |
| 16 | + continue | |
| 17 | + if pagematch.group(1) < pagematch.group(2): | |
| 18 | + files.append(arg) | |
| 19 | + continue | |
| 20 | + infile = arg | |
| 21 | + outfile = re.sub(r'.pdf', '.rotate.pdf', infile) | |
| 22 | + output = subprocess.Popen("pdftk \"%s\" cat 1-endW output \"%s\"" % (infile, outfile), shell=True, stdout=subprocess.PIPE).communicate()[0] | |
| 23 | + files.append(outfile) | |
| 24 | + | |
| 25 | +def order(pdf): | |
| 26 | + nummatch = re.search(r'(\d+)', pdf) | |
| 27 | + if nummatch == None: | |
| 28 | + return 0 | |
| 29 | + else: | |
| 30 | + return int(nummatch.group(1)) | |
| 31 | + | |
| 32 | +files = sorted(files, key=order) | |
| 33 | +output = subprocess.Popen("pdftk %s cat output \"%s\"" % (' '.join(['"%s"' % (file) for file in files]), outpdf), shell=True, stdout=subprocess.PIPE).communicate()[0] | ... | ... |
pytex/bin/texincludes
0 → 100755
| 1 | +++ a/pytex/bin/texincludes | |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +import sys,re,glob,StringIO,os,tempfile,filecmp,shutil | |
| 4 | +from optparse import OptionParser | |
| 5 | + | |
| 6 | +parser = OptionParser() | |
| 7 | +(options, args) = parser.parse_args() | |
| 8 | + | |
| 9 | +if len(args) < 1: | |
| 10 | + sys.exit(1) | |
| 11 | + | |
| 12 | +files = glob.glob("*.tex") | |
| 13 | + | |
| 14 | +if len(files) == 0: | |
| 15 | + sys.exit(0) | |
| 16 | + | |
| 17 | +outfile = tempfile.NamedTemporaryFile(delete=False) | |
| 18 | + | |
| 19 | +docfile = re.compile(r"""(?m)^(?!\s*%).*\\begin\{document\}""") | |
| 20 | +inputs = re.compile(r"""(?m)^(?!\s*%).*\\input{(.*)}""") | |
| 21 | +bibs = re.compile(r"""(?m)^(?!\s*%).*\\bibliography\{(.*)\}""") | |
| 22 | +citations = re.compile(r"""^(?m)^(?!\s*%).*\\(?:no)?cite""") | |
| 23 | +graphics = re.compile(r"""(?m)^(?!\s*%).*\\includegraphics(\[.*?\])?\{(.*?)\}""") | |
| 24 | +withpdf = re.compile(r"^.*\.pdf$") | |
| 25 | +nobibtex = re.compile(r"""(?m)^% !NOBIBTEX!""") | |
| 26 | + | |
| 27 | +nobibtexs = {} | |
| 28 | + | |
| 29 | +output = StringIO.StringIO() | |
| 30 | +allnames = [] | |
| 31 | + | |
| 32 | +for f in files: | |
| 33 | + lines = open(f, "r").read() | |
| 34 | + if not docfile.search(lines): | |
| 35 | + continue | |
| 36 | + input_files = [] | |
| 37 | + bib_files = [] | |
| 38 | + graphic_files = [] | |
| 39 | + toprocess = [f] | |
| 40 | + | |
| 41 | + docitations = False | |
| 42 | + dontbibtex = False | |
| 43 | + fbasename = os.path.splitext(f)[0] | |
| 44 | + | |
| 45 | + while len(toprocess) > 0: | |
| 46 | + try: | |
| 47 | + lines = open(toprocess[0], "r").read() | |
| 48 | + if nobibtex.search(lines): | |
| 49 | + nobibtexs[toprocess[0]] = True | |
| 50 | + else: | |
| 51 | + nobibtexs[toprocess[0]] = False | |
| 52 | + if len(citations.findall(lines)) > 0: | |
| 53 | + docitations = True | |
| 54 | + toprocess += inputs.findall(lines) | |
| 55 | + b = bibs.finditer(lines) | |
| 56 | + for m in b: | |
| 57 | + allbibs = m.group(1).split(",") | |
| 58 | + for bib in allbibs: | |
| 59 | + bib_files.append(bib + ".bib") | |
| 60 | + g = graphics.finditer(lines) | |
| 61 | + for m in g: | |
| 62 | + if withpdf.match(m.group(2)): | |
| 63 | + graphic_files.append(m.group(2)) | |
| 64 | + else: | |
| 65 | + path, ext = os.splitext(m.group(2)) | |
| 66 | + if ext == '': | |
| 67 | + graphic_files.append(path + ".pdf") | |
| 68 | + else: | |
| 69 | + graphic_files.append(m.group(2)) | |
| 70 | + except: | |
| 71 | + True | |
| 72 | + input_files.append(toprocess.pop(0)) | |
| 73 | + | |
| 74 | + all_files = input_files | |
| 75 | + all_files.extend(graphic_files) | |
| 76 | + all_files.extend(bib_files) | |
| 77 | + for file in args[1:]: | |
| 78 | + all_files.append(file) | |
| 79 | + allnames.append(fbasename) | |
| 80 | + | |
| 81 | + tex_files = [all_file for all_file in all_files if all_file.endswith(".tex")] | |
| 82 | + print >>output, "%s_TEXFILES=%s" % (fbasename.upper(), " ".join(tex_files),) | |
| 83 | + print >>output, "%s : LOG := %s.log" % (fbasename, fbasename) | |
| 84 | + print >>output, "%s : PDF := %s.pdf" % (fbasename, fbasename) | |
| 85 | + print >>output, "%s : $(START) %s.pdf $(END)" % (fbasename, fbasename) | |
| 86 | + print >>output, "%s.ps : %s.pdf" % (fbasename, fbasename) | |
| 87 | + print >>output, "%s.pdf %s.blg : .deps %s" % (fbasename, fbasename, " ".join(all_files)) | |
| 88 | + if docitations and not nobibtexs[f]: | |
| 89 | + print >>output, "\tpdflatex -shell-escape %s" % (f) | |
| 90 | + print >>output, "\tbibtex %s" % (fbasename) | |
| 91 | + print >>output, "\tpdflatex -shell-escape %s" % (f) | |
| 92 | + print >>output, "\tpdflatex -shell-escape %s" % (f) | |
| 93 | + else: | |
| 94 | + print >>output, "\tpdflatex -shell-escape %s" % (f) | |
| 95 | + print >>output, "\tpdflatex -shell-escape %s" % (f) | |
| 96 | + print >>output, "spell-%s : %s" % (fbasename, " ".join(tex_files),) | |
| 97 | + print >>output, "\tispell %s" % (" ".join(tex_files),) | |
| 98 | + | |
| 99 | +print >>outfile, output.getvalue(), | |
| 100 | +print >>outfile, "PDFS = %s" % (" ".join([n + ".pdf" for n in allnames])) | |
| 101 | +outfile.close() | |
| 102 | + | |
| 103 | +if not os.path.exists(args[0]) or not filecmp.cmp(outfile.name, args[0], shallow=False): | |
| 104 | + shutil.move(outfile.name, args[0]) | |
| 105 | +else: | |
| 106 | + os.unlink(outfile.name) | ... | ... |
pytex/bin/wc
0 → 100755
| 1 | +++ a/pytex/bin/wc | |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +import lib | |
| 4 | +import sys, re, os | |
| 5 | +from optparse import OptionParser | |
| 6 | + | |
| 7 | +parser = OptionParser() | |
| 8 | +parser.add_option("-o", "--overonly", dest="overonly", action="store_true", default=False, help="only display sections over the word count (default False)") | |
| 9 | +(options, args) = parser.parse_args() | |
| 10 | + | |
| 11 | +if len(args) < 2: | |
| 12 | + sys.exit(1) | |
| 13 | + | |
| 14 | +if args[0] == "-": | |
| 15 | + inlines = sys.stdin.read() | |
| 16 | +else: | |
| 17 | + try: | |
| 18 | + inlines = open(args[0], "r").read() | |
| 19 | + except: | |
| 20 | + sys.exit(1) | |
| 21 | + | |
| 22 | +if args[1] == "-": | |
| 23 | + outfile = sys.stdout | |
| 24 | +else: | |
| 25 | + try: | |
| 26 | + outfile = open(args[1], "w") | |
| 27 | + except: | |
| 28 | + sys.exit(1) | |
| 29 | + | |
| 30 | +clean = re.compile(r'<wc:start description="([^"]*)" max=(\d+)>(.*?)<wc:end>', re.S) | |
| 31 | +index = 1 | |
| 32 | +for f in clean.finditer(inlines): | |
| 33 | + description = f.group(1) | |
| 34 | + max = int(f.group(2)) | |
| 35 | + count = len(lib.clean(f.group(3)).split()) | |
| 36 | + if not options.overonly or count > max: | |
| 37 | + if count > max: | |
| 38 | + char = "*" | |
| 39 | + else: | |
| 40 | + char = " " | |
| 41 | + print "%c %2d. M:%3d C:%3d %s" % (char, index, max, count, description) | |
| 42 | + index += 1 | |
| 43 | +clean = re.compile(r'<cc:start description="([^"]*)" max=(\d+)>(.*?)<cc:end>', re.S) | |
| 44 | +index = 1 | |
| 45 | +for f in clean.finditer(inlines): | |
| 46 | + description = f.group(1) | |
| 47 | + max = int(f.group(2)) | |
| 48 | + count = len(lib.clean(f.group(3)).strip()) | |
| 49 | + if not options.overonly or count > max: | |
| 50 | + if count > max: | |
| 51 | + char = "*" | |
| 52 | + else: | |
| 53 | + char = " " | |
| 54 | + print "%c %2d. M:%3d C:%3d %s" % (char, index, max, count, description) | |
| 55 | + index += 1 | ... | ... |
pytex/make/Makerules
0 → 100644
| 1 | +++ a/pytex/make/Makerules | |
| 1 | +SHELL := /bin/bash | |
| 2 | +export TEXINPUTS :=.:$(PYTEX)/cls: | |
| 3 | + | |
| 4 | +# 16 Nov 2010 : GWA : Watch all .tex files below this directory to determine | |
| 5 | +# when to rebuild the dependencies. | |
| 6 | + | |
| 7 | +TEXFILES = $(shell find . -name "*.tex") | |
| 8 | + | |
| 9 | +# 16 Nov 2010 : GWA : Kind of a nasty hack, but we use a special Python | |
| 10 | +# script to regenerate make rules which are then loaded by the | |
| 11 | +# include below. This was the least nasty way of getting | |
| 12 | +# complex Latex dependencies to rebuild properly, while also | |
| 13 | +# enabling/disabling Bibtex as needed. | |
| 14 | + | |
| 15 | +.deps: $(TEXFILES) | |
| 16 | + @$(PYTEX)/bin/texincludes .deps $(CLASS) | |
| 17 | +include .deps | |
| 18 | + | |
| 19 | +%.ps : %.pdf | |
| 20 | + acroread -toPostScript $< | |
| 21 | + | |
| 22 | +allclean: rulesclean | |
| 23 | + @/bin/rm -f .deps | |
| 24 | + | |
| 25 | +rulesclean: | |
| 26 | + @/bin/rm -f *.dvi *.aux *.ps *~ *.log *.lot *.lof *.toc *.blg *.bbl url.sty *.out *.bak $(PDFS) | |
| 27 | + | |
| 28 | +# 16 Nov 2010 : GWA : Special dummy targets below. | |
| 29 | + | |
| 30 | +xxxnote: | |
| 31 | + @echo "\\newcommand{\\XXXnote}[1]{\\textcolor{red}{\\bfseries XXX: #1}}" > .xxxnote-new | |
| 32 | + @if [ -n "`diff -N 2>/dev/null .xxxnote .xxxnote-new`" ]; then\ | |
| 33 | + mv .xxxnote-new .xxxnote; \ | |
| 34 | + else\ | |
| 35 | + rm -f .xxxnote-new; \ | |
| 36 | + fi | |
| 37 | + | |
| 38 | +noxxxnote: | |
| 39 | + @echo "\\newcommand{\\XXXnote}[1]{}" > .xxxnote-new | |
| 40 | + @if [ -n "`diff -N 2>/dev/null .xxxnote .xxxnote-new`" ]; then\ | |
| 41 | + mv .xxxnote-new .xxxnote; \ | |
| 42 | + else\ | |
| 43 | + rm -f .xxxnote-new; \ | |
| 44 | + fi | |
| 45 | + | |
| 46 | +draft: | |
| 47 | + @echo "\\def\\isdraft{1}" > .draft-new | |
| 48 | + @if [ -n "`diff -N 2>/dev/null .draft .draft-new`" ]; then\ | |
| 49 | + mv .draft-new .draft; \ | |
| 50 | + else\ | |
| 51 | + rm -f .draft-new; \ | |
| 52 | + fi | |
| 53 | + | |
| 54 | +nodraft: | |
| 55 | + @echo "" > .draft-new | |
| 56 | + @if [ -n "`diff -N 2>/dev/null .draft .draft-new`" ]; then\ | |
| 57 | + mv .draft-new .draft; \ | |
| 58 | + else\ | |
| 59 | + rm -f .draft-new; \ | |
| 60 | + fi | |
| 61 | + | |
| 62 | +blue: | |
| 63 | + @echo "\\def\\isblue{1}" > .blue-new | |
| 64 | + @if [ -n "`diff -N 2>/dev/null .blue .blue-new`" ]; then\ | |
| 65 | + mv .blue-new .blue; \ | |
| 66 | + else\ | |
| 67 | + rm -f .blue-new; \ | |
| 68 | + fi | |
| 69 | + | |
| 70 | +noblue: | |
| 71 | + @echo "" > .blue-new | |
| 72 | + @if [ -n "`diff -N 2>/dev/null .blue .blue-new`" ]; then\ | |
| 73 | + mv .blue-new .blue; \ | |
| 74 | + else\ | |
| 75 | + rm -f .blue-new; \ | |
| 76 | + fi | |
| 77 | + | |
| 78 | +.embed.pdf: $(PDF) | |
| 79 | + gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=.embed.pdf -f $(PDF) | |
| 80 | + @cp .embed.pdf $(PDF) | |
| 81 | + | |
| 82 | +embed: .embed.pdf | |
| 83 | + | |
| 84 | +MISSINGREFERENCES = $(strip $(shell grep Ref $(LOG) | awk '{print substr($$4, 2, length($$4) - 2)}')) | |
| 85 | +MISSINGCITATIONS = $(strip $(shell grep Cit $(LOG) | awk '{print substr($$4, 2, length($$4) - 2)}')) | |
| 86 | +missing: | |
| 87 | + @if [ "$(MISSINGREFERENCES)" != "" ]; then\ | |
| 88 | + echo "-------------------------------------------------------------";\ | |
| 89 | + echo "Missing references:";\ | |
| 90 | + echo "-------------------------------------------------------------";\ | |
| 91 | + echo $(MISSINGREFERENCES);\ | |
| 92 | + fi | |
| 93 | + @if [ "$(MISSINGCITATIONS)" != "" ]; then\ | |
| 94 | + echo "-------------------------------------------------------------";\ | |
| 95 | + echo "Missing citations:";\ | |
| 96 | + echo "-------------------------------------------------------------";\ | |
| 97 | + echo $(MISSINGCITATIONS);\ | |
| 98 | + fi | |
| 99 | + | |
| 100 | +missing-fail: missing | |
| 101 | + @if [ "$(MISSINGREFERENCES)" != "" ]; then false; fi | |
| 102 | + @if [ "$(MISSINGCITATIONS)" != "" ]; then false; fi | |
| 103 | + | |
| 104 | +pages: $(PDF) | |
| 105 | + @pdfinfo $(PDF) 2>/dev/null | grep "Pages" | awk '{print "$(PDF)", $$2;}' | |
| 106 | + | |
| 107 | +# 16 Nov 2010 : GWA : Phony targets. | |
| 108 | + | |
| 109 | +.PHONY : pages rulesclean missing-fail missing xxxnote noxxxnote draft nodraft blue noblue clean allclean all figures wc | ... | ... |