summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/crossword/AcrossLite
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/crossword/AcrossLite')
-rw-r--r--Master/texmf-dist/source/latex/crossword/AcrossLite/README143
-rw-r--r--Master/texmf-dist/source/latex/crossword/AcrossLite/nytconv.c202
-rw-r--r--Master/texmf-dist/source/latex/crossword/AcrossLite/nytsconv.c209
-rw-r--r--Master/texmf-dist/source/latex/crossword/AcrossLite/usaconv.c229
4 files changed, 0 insertions, 783 deletions
diff --git a/Master/texmf-dist/source/latex/crossword/AcrossLite/README b/Master/texmf-dist/source/latex/crossword/AcrossLite/README
deleted file mode 100644
index 8555f2a213a..00000000000
--- a/Master/texmf-dist/source/latex/crossword/AcrossLite/README
+++ /dev/null
@@ -1,143 +0,0 @@
-Here are three programs and a script for use with Gerd
-Neugebauer's excellent cwpuzzle.sty package for typesetting
-crossword puzzles in LaTeX.
-
-The purpose of the programs is to convert the popular
-Across Lite(R) puzzle formats, both binary and text, to
-LaTeX input suitable for use with Gerd's package.
-
-Build the programs like this:
-
-gcc -o nytconv nytconv.c
-gcc -o nytsconv nytsconv.c
-gcc -o usaconv usaconv.c
-
-1. nytconv
-
-This program converts Across Lite(R) binary puzzle files:
-
-nytconv puzzlefile.puz >puzzlefile.tex
-
-where of course 'puzzlefile' is the name of the binary
-input file. The program is best suited to puzzles up to
-size 15x15, which is the standard daily puzzle size for
-the New York Times. NYT puzzles are distributed from their
-web site in Across Lite binary format. The web site is
-http://www.nytimes.com but registration (currently free)
-is needed to access the contents of the site.
-
-2. nytsconv
-
-This program is very similar to the previous one except
-it's for the larger Sunday puzzles, up to about 23x23.
-
-nytsconv puzzlefile.puz >puzzlefile.tex
-
-3. usaconv
-
-This program converts Across Lite(R) text files. Puzzles
-such as the USA Today daily puzzle and the Times of London
-daily puzzle are converted to LaTeX input via a two step
-process. You should go to the Across Lite web site,
-http://www.litsoft.com to pick up a USA Today conversion
-program and a Times of London conversion program. You can
-then pick up the puzzles (http://www.usatoday.com, or
-http://www.the-times.co.uk), convert to Across Lite text form,
-and then convert to LaTeX.
-
-usaconv puzzlefile.txt >puzzlefile.tex
-
-Well, you might say, what's the point? There are several.
-I don't want to solve crosswords on screen; I want printed
-copy to work with. So, why not just print from the Across
-Lite program? Because (1) I'm a LaTeX fanatic, and more
-importantly (2) I use an automated procedure to download
-the NYT and USA puzzles every morning, format them, and
-ready them for printing whenever I want a fresh puzzle!
-The only work I have to do is to actually solve the
-puzzle. (I don't have the skill needed to solve difficult
-cryptics such as the Times of London puzzles so I don't
-download them regularly.)
-
-Another important point is generating your own crosswords
-with computerized tools. Tools such as Crossword Express
-(http://www.puzzledepot.com/cwe) help you to produce
-crosswords quickly and effectively. One of the output
-format is Across Lite binary. This can then be converted
-(with the nyt- or nyts- conversion program, depending on
-puzzle size) and dropped into a LaTeX document. This is
-nice for newsletters, educational material, etc.
-
-There is still another possibility using postscript tools
-usually found on Unix systems. You might collect, say,
-100 puzzles, convert them all to LaTeX input, and process
-them. Then you can use tools such as psbook to make books
-of puzzles to take along on boring business trips or
-interesting vacation trips.
-
-For those of you with an interest, here is my automated
-Perl script for downloading and formatting puzzles. It
-requires the program 'wget' which can be found at
-ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/
-(This site is sometimes hard to reach. Keep trying. Or
-contact me for alternatives.)
-
-Now, the script, which will require local site modification:
----------------
-#!/usr/bin/perl
-
-chdir("/usr/games/crossword");
-($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
-
-# NY Times
-
- $mpart = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon];
- if ($mday lt 10){$puzzle = $mpart."0".$mday.$year;}
- else {$puzzle = $mpart.$mday.$year;}
- system("/usr/bin/wget --http-user=myname --http-passwd=secret http://www.nytimes.com/partners/xword/$puzzle.puz");
- if ($wday ne 0) {system("./nytconv $puzzle.puz >$puzzle.tex");}
- else {system("./nytsconv $puzzle.puz >$puzzle.tex");}
- system("/usr/bin/latex $puzzle");
- if ($wday ne 0) {system("/usr/bin/dvips -x 1400 $puzzle");}
- else {system("/usr/bin/dvips -x 1100 $puzzle");}
- system("/usr/bin/psnup -l -2 -pletter $puzzle.ps $puzzle.wps");
- system("echo \"quit\" >>$puzzle.wps");
- system("/usr/bin/gs -q -sDEVICE=laserjet -r300 -dQUIET -dNOPAUSE -sOutputFile=$puzzle.lj $puzzle.wps ");
- system("gzip -9 -f $puzzle.lj");
- system("/bin/rm *dvi *ps *log *aux *tex");
-
-# USA Today
-
-if ($wday ne 6 && $wday ne 0) { # no weekend puzzles
- $month = $mon + 1;
- if ($month lt 10) {$directory = $year."0".$month;}
- else {$directory = $year.$month;}
- if ($mday lt 10){$puzzle = "ut".$directory."0".$mday;}
- else {$puzzle = "ut".$directory.$mday;}
- system("/usr/bin/wget http://www.usatoday.com/life/puzzles/$directory/$puzzle.puz");
- system("./usa-acl $puzzle.puz $puzzle.txt");
- system("./usaconv $puzzle.txt >$puzzle.tex");
- system("/usr/bin/latex $puzzle");
- system("/usr/bin/dvips -x 1400 $puzzle");
- system("/usr/bin/psnup -l -2 -pletter $puzzle.ps $puzzle.wps");
- system("echo \"quit\" >>$puzzle.wps");
- system("/usr/bin/gs -q -sDEVICE=laserjet -r300 -dQUIET -dNOPAUSE -sOutputFile=$puzzle.lj $puzzle.wps ");
- system("gzip -9 -f $puzzle.lj");
- system("/bin/rm *dvi *ps *log *aux *tex *txt");
-}
-
-exit;
---------------
-
-For any questions, bug reports, or especially improvements, please
-contact me:
-
-bnewell@btigate.com
-http://www.btigate.com/~bnewell
-
-
-Bob Newell
-Bismarck, North Dakota
-28 November, 1996
-
-
diff --git a/Master/texmf-dist/source/latex/crossword/AcrossLite/nytconv.c b/Master/texmf-dist/source/latex/crossword/AcrossLite/nytconv.c
deleted file mode 100644
index 2956d29b345..00000000000
--- a/Master/texmf-dist/source/latex/crossword/AcrossLite/nytconv.c
+++ /dev/null
@@ -1,202 +0,0 @@
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#define ROWSIZE 256
-
-FILE *infile;
-int width, height, j, k, ccount, mcount, anum, dnum;
-int apos, dpos;
-
-char inbuf[ROWSIZE];
-
-/* Here is a lazy programmer's waste of space. */
-char aspace[ROWSIZE][ROWSIZE];
-char dspace[ROWSIZE][ROWSIZE];
-
-char rowtext[10*ROWSIZE];
-char tmp[ROWSIZE];
-
-char title[80];
-char author[80];
-char copyright[80];
-char matrix[ROWSIZE*ROWSIZE*10];
-char aclues[ROWSIZE*15*16];
-char dclues[ROWSIZE*15*16];
-
-void fgetaline(char *, FILE *);
-
-void main(int argc, char *argv[])
-{
-
-/* Open the puzzle file. */
- if (argc < 2) {
- printf("Usage: Acl2TeX <puzzle file>\n");
- exit(1);
- }
- infile = fopen(argv[1], "rb");
- if (infile == NULL) {
- printf("Error opening %s.\n");
- exit(1);
- }
-
-/* From here on we're assuming a non-corrupt puzzle file.
- An enhancement later could be to check for this. */
-
-/* Read in the puzzle size, skipping the stuff
- we don't understand. */
- fread(inbuf, 46, 1, infile);
- width = (int)(inbuf[44]);
- height = (int)(inbuf[45]);
-
-/* Read in the solution, assuming(!) it is not scrambled.
- This may be a bad idea but we do it anyhow. */
- fread(inbuf, 6, 1, infile); /* more basura */
- for (j=0; j<height; j++) fread(&aspace[j][0], width, 1, infile);
-
-/* Read in the diagram info separately. It's safer to use
- this to deduce the numbering scheme. */
- for (j=0; j<height; j++) fread(&dspace[j][0], width, 1, infile);
-
- /* Now start to separate some of the text headers. */
- apos=dpos=0;
- fgetaline(title, infile);
- fgetaline(author, infile);
- fgetaline(copyright, infile);
-
-/* Now we are ready to produce the LaTeX stuff for the
- puzzle diagram. Again we are assuming we have an unscrambled
- solution. How can we know this? Put on TODO list. */
-
-/* We write to standard out. Lazy but effective. */
-
- printf("\\documentclass{article}\n");
- printf("\\usepackage{cwpuzzle}\n");
- printf("\\title{%s}\n", title);
- printf("\\author{%s}\n", author);
- printf("\\date{%s}\n", copyright);
- printf("\\voffset -1in\n");
- printf("\\hoffset -1in\n");
- printf("\\begin{document}\n");
-
- ccount = 0;
- mcount = 0;
-
- for (j=0; j<height; j++) {
- strcpy(rowtext,"\0");
- for (k=0; k<width; k++) {
- /* Analyze position for across-number */
- /* Left edge non-black followed by non-black */
- anum = 0;
- if ( (k==0 && dspace[j][k]=='-' && dspace[j][k+1]=='-') ||
- /* Previous black - nonblack - nonblack */
- ( (k+1)<width && (k-1)>=0 && dspace[j][k]=='-'
- && dspace[j][k-1]=='.'
- && dspace[j][k+1]=='-' )
- ){
- ccount++;
- anum = ccount;
- }
- /* Analyze position for down-number */
- dnum = 0;
- /* Top row non-black followed by non-black */
- if ( (j==0 && dspace[j][k]=='-' && dspace[j+1][k]=='-') ||
- /* Black above - nonblack - nonblack below */
- ( (j-1)>=0 && (j+1)<height && dspace[j][k]=='-'
- && dspace[j-1][k]=='.'
- && dspace[j+1][k]=='-' )
- ){
- /* Don't double number the same space */
- if (anum == 0) ccount++;
- dnum = ccount;
- }
- /* Now, if necessary, pick up some clues and save them. */
- if (anum != 0) {
- fgetaline(tmp, infile);
- sprintf(&aclues[apos], "\\Clue{%d}{}{%s}\\\\\n",
- anum, tmp);
- apos = strlen(aclues);
- }
- if (dnum != 0) {
- fgetaline(tmp, infile);
- sprintf(&dclues[dpos], "\\Clue{%d}{}{%s}\\\\\n",
- dnum, tmp);
- dpos = strlen(dclues);
- }
- /* Concat the current info to the current row. */
- strcat(rowtext, "|");
- if (dspace[j][k] == '.') strcat(rowtext, "*");
- else {
- /* see if we need a grid number */
- if (dnum != 0) {
- sprintf(tmp, "[%d]", dnum);
- strcat(rowtext, tmp);
- }
- else if (anum != 0) {
- sprintf(tmp, "[%d]", anum);
- strcat(rowtext, tmp);
- }
- /* Put in solution letter */
- strncat(rowtext, &aspace[j][k], 1);
- }
- }
- /* End of the row. Put in marker and output it. */
- strcat(rowtext, "|.");
- sprintf(&matrix[mcount], "%s\n", rowtext);
- mcount = strlen(matrix);
- }
- /* That's it for the puzzle. */
-
- /* Now output the clue section */
- printf("\\begin{PuzzleClues}{\\textbf{Across}}\\\\\n");
- printf("%s", aclues);
- printf("\\end{PuzzleClues}\n");
- printf("\\begin{PuzzleClues}{\\textbf{Down}}\\\\\n");
- printf("%s", dclues);
- printf("\\end{PuzzleClues}\n");
-
- /* Now output the diagram */
- printf("\\newpage\n");
- printf("\\maketitle\n");
- printf("\\begin{Puzzle}{%d}{%d}\n", width, height);
- printf("%s", matrix);
- printf("\\end{Puzzle}\n");
-
-
- printf("\\end{document}\n");
-
- exit(0);
-
-}
-
- void fgetaline(char *foo, FILE *infile) {
- unsigned char i;
- int oe;
- oe = 0;
- strcpy(foo, "\0");
- while (1) {
- fread(&i, 1, 1, infile);
- if (feof(infile) || (i=='\0')) break;
- if (i == 169) {
- strcat(foo, "\\copyright ");
- }
- else {
- if (i == '_' || i == '&' || i == '#' || i== '$') strcat(foo, "\\");
- if (i == '"') {
- if ( oe == 0) {
- oe = 1;
- strcat(foo, "``");
- }
- else {
- oe = 0;
- strcat(foo, "''");
- }
- }
- else strncat(foo, &i, 1);
- }
- }
- }
-
-
-
diff --git a/Master/texmf-dist/source/latex/crossword/AcrossLite/nytsconv.c b/Master/texmf-dist/source/latex/crossword/AcrossLite/nytsconv.c
deleted file mode 100644
index 77e478f6840..00000000000
--- a/Master/texmf-dist/source/latex/crossword/AcrossLite/nytsconv.c
+++ /dev/null
@@ -1,209 +0,0 @@
-
-/* ACL to LaTeX conversion suitable for Sunday NY Times */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#define ROWSIZE 256
-
-FILE *infile;
-int width, height, j, k, ccount, mcount, anum, dnum;
-int apos, dpos;
-
-char inbuf[ROWSIZE];
-
-/* Here is a lazy programmer's waste of space. */
-char aspace[ROWSIZE][ROWSIZE];
-char dspace[ROWSIZE][ROWSIZE];
-
-char rowtext[10*ROWSIZE];
-char tmp[ROWSIZE];
-
-char title[80];
-char author[80];
-char copyright[80];
-char matrix[ROWSIZE*ROWSIZE*10];
-char aclues[ROWSIZE*15*16];
-char dclues[ROWSIZE*15*16];
-
-void fgetaline(char *, FILE *);
-
-void main(int argc, char *argv[])
-{
-
-/* Open the puzzle file. */
- if (argc < 2) {
- printf("Usage: Acl2TeX <puzzle file>\n");
- exit(1);
- }
- infile = fopen(argv[1], "rb");
- if (infile == NULL) {
- printf("Error opening %s.\n");
- exit(1);
- }
-
-/* From here on we're assuming a non-corrupt puzzle file.
- An enhancement later could be to check for this. */
-
-/* Read in the puzzle size, skipping the stuff
- we don't understand. */
- fread(inbuf, 46, 1, infile);
- width = (int)(inbuf[44]);
- height = (int)(inbuf[45]);
-
-/* Read in the solution, assuming(!) it is not scrambled.
- This may be a bad idea but we do it anyhow. */
- fread(inbuf, 6, 1, infile); /* more basura */
- for (j=0; j<height; j++) fread(&aspace[j][0], width, 1, infile);
-
-/* Read in the diagram info separately. It's safer to use
- this to deduce the numbering scheme. */
- for (j=0; j<height; j++) fread(&dspace[j][0], width, 1, infile);
-
- /* Now start to separate some of the text headers. */
- apos=dpos=0;
- fgetaline(title, infile);
- fgetaline(author, infile);
- fgetaline(copyright, infile);
-
-/* Now we are ready to produce the LaTeX stuff for the
- puzzle diagram. Again we are assuming we have an unscrambled
- solution. How can we know this? Put on TODO list. */
-
-/* We write to standard out. Lazy but effective. */
-
- printf("\\documentclass{article}\n");
- printf("\\usepackage{cwpuzzle,multicol}\n");
- printf("\\title{%s}\n", title);
- printf("\\author{%s}\n", author);
- printf("\\date{%s}\n", copyright);
- printf("\\voffset -1in\n");
- printf("\\hoffset -1in\n");
- printf("\\textwidth 6.5in\n");
- printf("\\marginparwidth 0in\n");
- printf("\\textheight 9.5in\n");
- printf("\\begin{document}\n");
- printf("{\\small\n");
- printf("\\begin{multicols}{5}\n");
- printf("\\raggedright\n");
-
- ccount = 0;
- mcount = 0;
-
- for (j=0; j<height; j++) {
- strcpy(rowtext,"\0");
- for (k=0; k<width; k++) {
- /* Analyze position for across-number */
- /* Left edge non-black followed by non-black */
- anum = 0;
- if ( (k==0 && dspace[j][k]=='-' && dspace[j][k+1]=='-') ||
- /* Previous black - nonblack - nonblack */
- ( (k+1)<width && (k-1)>=0 && dspace[j][k]=='-'
- && dspace[j][k-1]=='.'
- && dspace[j][k+1]=='-' )
- ){
- ccount++;
- anum = ccount;
- }
- /* Analyze position for down-number */
- dnum = 0;
- /* Top row non-black followed by non-black */
- if ( (j==0 && dspace[j][k]=='-' && dspace[j+1][k]=='-') ||
- /* Black above - nonblack - nonblack below */
- ( (j-1)>=0 && (j+1)<height && dspace[j][k]=='-'
- && dspace[j-1][k]=='.'
- && dspace[j+1][k]=='-' )
- ){
- /* Don't double number the same space */
- if (anum == 0) ccount++;
- dnum = ccount;
- }
- /* Now, if necessary, pick up some clues and save them. */
- if (anum != 0) {
- fgetaline(tmp, infile);
- sprintf(&aclues[apos], "{\\bf %d} %s\\\\\n",
- anum, tmp);
- apos = strlen(aclues);
- }
- if (dnum != 0) {
- fgetaline(tmp, infile);
- sprintf(&dclues[dpos], "{\\bf %d} %s\\\\\n",
- dnum, tmp);
- dpos = strlen(dclues);
- }
- /* Concat the current info to the current row. */
- strcat(rowtext, "|");
- if (dspace[j][k] == '.') strcat(rowtext, "*");
- else {
- /* see if we need a grid number */
- if (dnum != 0) {
- sprintf(tmp, "[%d]", dnum);
- strcat(rowtext, tmp);
- }
- else if (anum != 0) {
- sprintf(tmp, "[%d]", anum);
- strcat(rowtext, tmp);
- }
- /* Put in solution letter */
- strncat(rowtext, &aspace[j][k], 1);
- }
- }
- /* End of the row. Put in marker and output it. */
- strcat(rowtext, "|.");
- sprintf(&matrix[mcount], "%s\n", rowtext);
- mcount = strlen(matrix);
- }
- /* That's it for the puzzle. */
-
- /* Now output the clue section */
- printf("{\\bf ACROSS}\\\\\n");
- printf("%s", aclues);
- printf("{\\bf DOWN}\\\\\n");
- printf("%s", dclues);
- printf("\\end{multicols}\n");
- printf("}\n");
-
- /* Now output the diagram */
- printf("\\newpage\n");
- printf("\\maketitle\n");
- printf("\\begin{Puzzle}{%d}{%d}\n", width, height);
- printf("%s", matrix);
- printf("\\end{Puzzle}\n");
-
- printf("\\end{document}\n");
-
- exit(0);
-
-}
-
- void fgetaline(char *foo, FILE *infile) {
- unsigned char i;
- int oe;
- oe = 0;
- strcpy(foo, "\0");
- while (1) {
- fread(&i, 1, 1, infile);
- if (feof(infile) || (i=='\0')) break;
- if (i == 169) {
- strcat(foo, "\\copyright ");
- }
- else {
- if (i == '_' || i == '&' || i == '#' || i == '$') strcat(foo, "\\");
- if (i == '"') {
- if ( oe == 0) {
- oe = 1;
- strcat(foo, "``");
- }
- else {
- oe = 0;
- strcat(foo, "''");
- }
- }
- else strncat(foo, &i, 1);
- }
- }
- }
-
-
-
diff --git a/Master/texmf-dist/source/latex/crossword/AcrossLite/usaconv.c b/Master/texmf-dist/source/latex/crossword/AcrossLite/usaconv.c
deleted file mode 100644
index 9f8433d4fd3..00000000000
--- a/Master/texmf-dist/source/latex/crossword/AcrossLite/usaconv.c
+++ /dev/null
@@ -1,229 +0,0 @@
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#define ROWSIZE 256
-
-FILE *infile;
-int width, height, j, k, ccount, mcount, anum, dnum;
-int apos, dpos;
-int acount, dcount;
-
-char inbuf[ROWSIZE];
-
-/* Here is a lazy programmer's waste of space. */
-char aspace[ROWSIZE][ROWSIZE];
-char dspace[ROWSIZE][ROWSIZE];
-
-char rowtext[10*ROWSIZE];
-char tmp[ROWSIZE];
-
-char title[80];
-char author[80];
-char copyright[80];
-char matrix[ROWSIZE*ROWSIZE*10];
-char actext[ROWSIZE][80];
-char dctext[ROWSIZE][80];
-char aclues[ROWSIZE*15*16];
-char dclues[ROWSIZE*15*16];
-
-void fgetsa(char *, int, FILE *);
-
-void main(int argc, char *argv[])
-{
-
-/* Open the puzzle file. */
- if (argc < 2) {
- printf("Usage: usaconv <puzzle file>\n");
- exit(1);
- }
- infile = fopen(argv[1], "r");
- if (infile == NULL) {
- printf("Error opening %s.\n");
- exit(1);
- }
-
-/* From here on we're assuming a non-corrupt puzzle file.
- An enhancement later could be to check for this. */
-
-/* start reading stuff in */
- fgetsa(inbuf, 80, infile); /*<ACROSS PUZZLE>*/
- fgetsa(inbuf, 80, infile); /*<TITLE>*/
- fgetsa(title, 80, infile);
- fgetsa(inbuf, 80, infile); /*<AUTHOR>*/
- fgetsa(author, 80, infile);
- fgetsa(inbuf, 80, infile); /*<COPYRIGHT>*/
- fgetsa(copyright,80, infile);
- fgetsa(inbuf, 80, infile); /*<SIZE>*/
-
- fgetsa(inbuf, 80, infile);
- height = width = 0 ; /* we calculate instead */
-
- fgetsa(inbuf, 80, infile); /*<GRID>*/
-
-/* Read in the first line of the solution/diagram and determine width */
- fgetsa(&aspace[height][0], 80, infile);
- width = strlen(&aspace[height][0]);
- height++;
- while (1) {
- fgetsa(&aspace[height][0], 80, infile);
- if(strcmp(&aspace[height][0],"<ACROSS>")==0) goto didit;
- height++;
- }
-didit:
- /* Read and save across and down clues */
-
- apos=dpos=0;
- while(1) {
- fgetsa(&actext[apos][0], 80, infile);
- if(strcmp(&actext[apos][0],"<DOWN>")==0)goto dida;
- apos++;
- }
-dida:
- while(1) {
- fgetsa(&dctext[dpos][0], 80, infile);
- if(feof(infile)) goto didd;
- dpos++;
- }
-didd:
- apos=dpos=0;
-
-/* Now we are ready to produce the LaTeX stuff for the
- puzzle diagram. Again we are assuming we have an unscrambled
- solution. How can we know this? Put on TODO list. */
-
-/* We write to standard out. Lazy but effective. */
-
- printf("\\documentclass{article}\n");
- printf("\\usepackage{cwpuzzle}\n");
- printf("\\title{%s}\n", title);
- printf("\\author{%s}\n", author);
- printf("\\date{%s}\n", copyright);
- printf("\\voffset -1in\n");
- printf("\\hoffset -1in\n");
- printf("\\begin{document}\n");
-
- ccount = 0;
- mcount = 0;
- acount = dcount = 0;
-
- for (j=0; j<height; j++) {
- strcpy(rowtext,"\0");
- for (k=0; k<width; k++) {
- /* Analyze position for across-number */
- /* Left edge non-black followed by non-black */
- anum = 0;
- if ( (k==0 && aspace[j][k]!='.' && aspace[j][k+1]!='.') ||
- /* Previous black - nonblack - nonblack */
- ( (k+1)<width && (k-1)>=0 && aspace[j][k]!='.'
- && aspace[j][k-1]=='.'
- && aspace[j][k+1]!='.' )
- ){
- ccount++;
- anum = ccount;
- }
- /* Analyze position for down-number */
- dnum = 0;
- /* Top row non-black followed by non-black */
- if ( (j==0 && aspace[j][k]!='.' && aspace[j+1][k]!='.') ||
- /* Black above - nonblack - nonblack below */
- ( (j-1)>=0 && (j+1)<height && aspace[j][k]!='.'
- && aspace[j-1][k]=='.'
- && aspace[j+1][k]!='.' )
- ){
- /* Don't double number the same space */
- if (anum == 0) ccount++;
- dnum = ccount;
- }
- /* Now, if necessary, assign some clues and save them. */
- if (anum != 0) {
- sprintf(&aclues[apos], "\\Clue{%d}{}{%s}\\\\\n",
- anum, actext[acount]);
- acount++;
- apos = strlen(aclues);
- }
- if (dnum != 0) {
- sprintf(&dclues[dpos], "\\Clue{%d}{}{%s}\\\\\n",
- dnum, dctext[dcount]);
- dcount++;
- dpos = strlen(dclues);
- }
- /* Concat the current info to the current row. */
- strcat(rowtext, "|");
- if (aspace[j][k] == '.') strcat(rowtext, "*");
- else {
- /* see if we need a grid number */
- if (dnum != 0) {
- sprintf(tmp, "[%d]", dnum);
- strcat(rowtext, tmp);
- }
- else if (anum != 0) {
- sprintf(tmp, "[%d]", anum);
- strcat(rowtext, tmp);
- }
- /* Put in solution letter */
-/* this is for real */ if (aspace[j][k]== '&') strncat(rowtext, "\\", 1);
- strncat(rowtext, &aspace[j][k], 1);
- }
- }
- /* End of the row. Put in marker and output it. */
- strcat(rowtext, "|.");
- sprintf(&matrix[mcount], "%s\n", rowtext);
- mcount = strlen(matrix);
- }
- /* That's it for the puzzle. */
-
- /* Now output the clue section */
- printf("\\begin{PuzzleClues}{\\textbf{Across}}\\\\\n");
- for (j=0; j<strlen(aclues); j++){
- printf("%c",aclues[j]);
- }
- printf("\\end{PuzzleClues}\n");
- printf("\\begin{PuzzleClues}{\\textbf{Down}}\\\\\n");
- for (j=0; j<strlen(dclues); j++){
- printf("%c",dclues[j]);
- }
- printf("\\end{PuzzleClues}\n");
-
- /* Now output the diagram */
- printf("\\newpage\n");
- printf("\\maketitle\n");
- printf("\\begin{Puzzle}{%d}{%d}\n", width, height);
- printf("%s", matrix);
- printf("\\end{Puzzle}\n");
-
-
- printf("\\end{document}\n");
-
- exit(0);
-
-}
-
- void fgetsa(char *foo, int size, FILE *infile) {
- int i, oe;
- fgets(tmp, size, infile);
- tmp[strlen(tmp)-1] = '\0';
- strcpy(foo, "\0");
- oe = 0;
- for (i=0; i<strlen(tmp); i++) {
- if (tmp[i]=='$' || tmp[i] == '_' || tmp[i] =='&' || tmp[i] == '#') strcat(foo, "\\");
- if (tmp[i] == '"') {
- if (oe == 0) {
- oe = 1;
- strcat(foo, "``");
- }
- else {
- oe = 0;
- strcat(foo, "''");
- }
- }
- else strncat(foo, &tmp[i], 1);
- }
- }
-
-
-
-
-
-