summaryrefslogtreecommitdiff
path: root/src/preproc/grn
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2021-08-16 12:38:56 +1000
committerG. Branden Robinson <g.branden.robinson@gmail.com>2021-08-16 13:32:49 +1000
commitd1263682db1cbccb12381ab35a1c7daf74913098 (patch)
tree9457a0c3494490ea2b6d63623bce51a1476a79a5 /src/preproc/grn
parenteead5f5cf1dedc6d180bdb34914d7157d39e270c (diff)
downloadgroff-git-d1263682db1cbccb12381ab35a1c7daf74913098.tar.gz
[grn]: Wrap long comment lines and fix typos.
Diffstat (limited to 'src/preproc/grn')
-rw-r--r--src/preproc/grn/README4
-rw-r--r--src/preproc/grn/gprint.h8
-rw-r--r--src/preproc/grn/grn.am4
-rw-r--r--src/preproc/grn/hdb.cpp23
-rw-r--r--src/preproc/grn/hgraph.cpp245
-rw-r--r--src/preproc/grn/hpoint.cpp8
-rw-r--r--src/preproc/grn/main.cpp354
7 files changed, 332 insertions, 314 deletions
diff --git a/src/preproc/grn/README b/src/preproc/grn/README
index 0e486bf66..73273f768 100644
--- a/src/preproc/grn/README
+++ b/src/preproc/grn/README
@@ -45,8 +45,8 @@ better into the groff package.
. main.cpp:
- Using groff's default values instead of DEVDIR, DEFAULTDEV, PRINTER,
- TYPESETTER, and GREMLIB.
+ Using groff's default values instead of DEVDIR, DEFAULTDEV,
+ PRINTER, TYPESETTER, and GREMLIB.
'res' is now an integer.
diff --git a/src/preproc/grn/gprint.h b/src/preproc/grn/gprint.h
index ad3be4430..63511bf19 100644
--- a/src/preproc/grn/gprint.h
+++ b/src/preproc/grn/gprint.h
@@ -48,7 +48,7 @@
#define BOTCENT 15
#define TEXT(t) ( (t <= CENTCENT) || (t >= TOPLEFT) )
-/* WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
+/* WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
* The above (TEXT) test is dependent on the relative values of the
* constants and will have to change if these values change or if new
* commands are added with value greater than BOTCENT
@@ -83,4 +83,8 @@ typedef struct elmt {
#define Nullpoint(pt) ((pt) == (POINT *) NULL)
#define PTNextPoint(pt) (pt->nextpt)
-/* EOF */
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
diff --git a/src/preproc/grn/grn.am b/src/preproc/grn/grn.am
index b9c65427a..f45fa24e0 100644
--- a/src/preproc/grn/grn.am
+++ b/src/preproc/grn/grn.am
@@ -7,8 +7,8 @@
# Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
-# groff is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
diff --git a/src/preproc/grn/hdb.cpp b/src/preproc/grn/hdb.cpp
index a4dac069a..c867feae2 100644
--- a/src/preproc/grn/hdb.cpp
+++ b/src/preproc/grn/hdb.cpp
@@ -2,8 +2,8 @@
*
* Copyright -C- 1982 Barry S. Roitblat
*
- * This file contains database routines for the hard copy programs of the
- * gremlin picture editor.
+ * This file contains database routines for the hard copy programs of
+ * the gremlin picture editor.
*/
#ifdef HAVE_CONFIG_H
@@ -41,8 +41,8 @@ int DBGetType(char *s);
long lineno = 0;
/*
- * This routine returns a pointer to an initialized database element which
- * would be the only element in an empty list.
+ * This routine returns a pointer to an initialized database element
+ * which would be the only element in an empty list.
*/
ELT *
DBInit()
@@ -140,10 +140,11 @@ DBRead(FILE *file)
/*
* Files created on the SUN have point lists terminated by a line
- * containing only an asterik ('*'). Files created on the AED have
- * point lists terminated by the coordinate pair (-1.00 -1.00).
+ * containing only an asterisk ('*'). Files created on the AED
+ * have point lists terminated by the coordinate pair (-1.00
+ * -1.00).
*/
- if (TEXT(type)) { /* read only first point for TEXT elements */
+ if (TEXT(type)) { /* read only first point for TEXT elements */
nx = xorn(x, y);
y = yorn(x, y);
(void) PTMakePoint(nx, y, &plist);
@@ -254,7 +255,7 @@ DBGetType(char *s)
if (s[5] == '\n')
return (CURVE);
switch (s[7]) {
- case 'S':
+ case 'S':
return(BSPLINE);
case 'E':
warning_with_file_and_line(gremlinfile, lineno,
@@ -313,9 +314,9 @@ DBGetType(char *s)
#ifdef UW_FASTSCAN
/*
* Optimization hack added by solomon@crys.wisc.edu, 12/2/86.
- * A huge fraction of the time was spent reading floating point numbers from
- * the input file, but the numbers always have the format 'ddd.dd'. Thus
- * the following special-purpose version of fscanf.
+ * A huge fraction of the time was spent reading floating point numbers
+ * from the input file, but the numbers always have the format 'ddd.dd'.
+ * Thus the following special-purpose version of fscanf.
*
* xscanf(f,xp,yp) does roughly what fscanf(f,"%f%f",xp,yp) does except:
* -the next piece of input must be of the form
diff --git a/src/preproc/grn/hgraph.cpp b/src/preproc/grn/hgraph.cpp
index ad051ea0e..9ed81a449 100644
--- a/src/preproc/grn/hgraph.cpp
+++ b/src/preproc/grn/hgraph.cpp
@@ -1,7 +1,7 @@
/* Last non-groff version: hgraph.c 1.14 (Berkeley) 84/11/27
*
- * This file contains the graphics routines for converting gremlin pictures
- * to troff input.
+ * This file contains the graphics routines for converting gremlin
+ * pictures to troff input.
*/
#include "lib.h"
@@ -24,7 +24,7 @@ extern int style[]; /* line and character styles */
extern double thick[];
extern char *tfont[];
extern int tsize[];
-extern int stipple_index[]; /* stipple font index for stipples 0 - 16 */
+extern int stipple_index[]; /* stipple font idx for stipples 0-16 */
extern char *stipple; /* stipple type (cf or ug) */
@@ -72,13 +72,13 @@ void NaturalEndSpline(double h[], int z[],
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: HGPrintElt (element_pointer, baseline)
|
| Results: Examines a picture element and calls the appropriate
- | routine(s) to print them according to their type. After the
- | picture is drawn, current position is (lastx, lasty).
- *----------------------------------------------------------------------------*/
+ | routine(s) to print them according to their type. After
+ | the picture is drawn, current position is (lastx,lasty).
+ *--------------------------------------------------------------------*/
void
HGPrintElt(ELT *element,
@@ -154,11 +154,11 @@ HGPrintElt(ELT *element,
/* brushf = style of outline; size = color of fill:
* on first pass (polyfill=FILL), do the interior using 'P'
* unless size=0
- * on second pass (polyfill=OUTLINE), do the outline using a series
- * of vectors. It might make more sense to use \D'p ...',
- * but there is no uniform way to specify a 'fill character'
- * that prints as 'no fill' on all output devices (and
- * stipple fonts).
+ * on second pass (polyfill=OUTLINE), do the outline using a
+ * series of vectors. It might make more sense to use \D'p
+ * ...', but there is no uniform way to specify a 'fill
+ * character' that prints as 'no fill' on all output
+ * devices (and stipple fonts).
* If polyfill=BOTH, just use the \D'p ...' command.
*/
double firstx = p1->x;
@@ -266,16 +266,16 @@ HGPrintElt(ELT *element,
} /* end PrintElt */
-/*----------------------------------------------------------------------------*
+/*---------------------------------------------------------------------*
| Routine: HGPutText (justification, position_point, string)
|
| Results: Given the justification, a point to position with, and a
| string to put, HGPutText first sends the string into a
| diversion, moves to the positioning point, then outputs
- | local vertical and horizontal motions as needed to justify
- | the text. After all motions are done, the diversion is
- | printed out.
- *----------------------------------------------------------------------------*/
+ | local vertical and horizontal motions as needed to
+ | justify the text. After all motions are done, the
+ | diversion is printed out.
+ *--------------------------------------------------------------------*/
void
HGPutText(int justify,
@@ -300,8 +300,8 @@ HGPutText(int justify,
tmove(&pnt); /* move to positioning point */
switch (justify) {
- /* local vertical motions */
- /* (the numbers here are used to be somewhat compatible with gprint) */
+ /* local vertical motions--the numbers here are used to be
+ somewhat compatible with gprint */
case CENTLEFT:
case CENTCENT:
case CENTRIGHT:
@@ -330,18 +330,18 @@ HGPutText(int justify,
printf("\\&\\*(g9\n"); /* now print the text. */
printf(".sp |\\n(g8u\n"); /* restore vertical position */
- lasty = savelasty; /* vertical position restored to where it */
- lastx = xleft; /* was before text, also horizontal is at */
- /* left */
+ lasty = savelasty; /* vertical position restored to */
+ lastx = xleft; /* where it was before text, also */
+ /* horizontal is at left */
} /* end HGPutText */
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: doarc (center_point, start_point, angle)
|
| Results: Produces either drawarc command or a drawcircle command
| depending on the angle needed to draw through.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
doarc(POINT cp,
@@ -357,14 +357,14 @@ doarc(POINT cp,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: HGSetFont (font_number, Point_size)
|
- | Results: ALWAYS outputs a .ft and .ps directive to troff. This is
- | done because someone may change stuff inside a text string.
- | Changes thickness back to default thickness. Default
- | thickness depends on font and pointsize.
- *----------------------------------------------------------------------------*/
+ | Results: ALWAYS outputs a .ft and .ps directive to troff. This
+ | is done because someone may change stuff inside a text
+ | string. Changes thickness back to default thickness.
+ | Default thickness depends on font and point size.
+ *--------------------------------------------------------------------*/
void
HGSetFont(int font,
@@ -376,15 +376,15 @@ HGSetFont(int font,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: HGSetBrush (line_mode)
|
- | Results: Generates the troff commands to set up the line width and
- | style of subsequent lines. Does nothing if no change is
- | needed.
+ | Results: Generates the troff commands to set up the line width
+ | and style of subsequent lines. Does nothing if no
+ | change is needed.
|
- | Side Efct: Sets 'linmode' and 'linethicknes'.
- *----------------------------------------------------------------------------*/
+ | Side Efct: Sets 'linmode' and 'linethickness'.
+ *--------------------------------------------------------------------*/
void
HGSetBrush(int mode)
@@ -407,14 +407,14 @@ HGSetBrush(int mode)
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: deltax (x_destination)
|
| Results: Scales and outputs a number for delta x (with a leading
| space) given 'lastx' and x_destination.
|
| Side Efct: Resets 'lastx' to x_destination.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
deltax(double x)
@@ -426,15 +426,16 @@ deltax(double x)
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: deltay (y_destination)
|
| Results: Scales and outputs a number for delta y (with a leading
| space) given 'lastyline' and y_destination.
|
- | Side Efct: Resets 'lastyline' to y_destination. Since 'line' vertical
- | motions don't affect 'page' ones, 'lasty' isn't updated.
- *----------------------------------------------------------------------------*/
+ | Side Efct: Resets 'lastyline' to y_destination. Since 'line'
+ | vertical motions don't affect 'page' ones, 'lasty' isn't
+ | updated.
+ *--------------------------------------------------------------------*/
void
deltay(double y)
@@ -446,14 +447,14 @@ deltay(double y)
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: tmove2 (px, py)
|
- | Results: Produces horizontal and vertical moves for troff given the
- | pair of points to move to and knowing the current position.
- | Also puts out a horizontal move to start the line. This is
- | a variation without the .sp command.
- *----------------------------------------------------------------------------*/
+ | Results: Produces horizontal and vertical moves for troff given
+ | the pair of points to move to and knowing the current
+ | position. Also puts out a horizontal move to start the
+ | line. This is a variation without the .sp command.
+ *--------------------------------------------------------------------*/
void
tmove2(int px,
@@ -473,14 +474,14 @@ tmove2(int px,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: tmove (point_pointer)
|
- | Results: Produces horizontal and vertical moves for troff given the
- | pointer of a point to move to and knowing the current
- | position. Also puts out a horizontal move to start the
- | line.
- *----------------------------------------------------------------------------*/
+ | Results: Produces horizontal and vertical moves for troff given
+ | the pointer of a point to move to and knowing the
+ | current position. Also puts out a horizontal move to
+ | start the line.
+ *--------------------------------------------------------------------*/
void
tmove(POINT * ptr)
@@ -501,14 +502,16 @@ tmove(POINT * ptr)
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: cr ( )
|
- | Results: Ends off an input line. '.sp -1' is also added to counteract
- | the vertical move done at the end of text lines.
+ | Results: Ends off an input line. '.sp -1' is also added to
+ | counteract the vertical move done at the end of text
+ | lines.
|
- | Side Efct: Sets 'lastx' to 'xleft' for troff's return to left margin.
- *----------------------------------------------------------------------------*/
+ | Side Efct: Sets 'lastx' to 'xleft' for troff's return to left
+ | margin.
+ *--------------------------------------------------------------------*/
void
cr()
@@ -518,11 +521,11 @@ cr()
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: line ( )
|
| Results: Draws a single solid line to (x,y).
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
line(int px,
@@ -536,14 +539,14 @@ line(int px,
}
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------*
| Routine: drawwig (ptr, type)
|
- | Results: The point sequence found in the structure pointed by ptr is
- | placed in integer arrays for further manipulation by the
- | existing routing. With the corresponding type parameter,
- | either picurve or HGCurve are called.
- *----------------------------------------------------------------------------*/
+ | Results: The point sequence found in the structure pointed by ptr
+ | is placed in integer arrays for further manipulation by
+ | the existing routing. With the corresponding type
+ | parameter, either picurve or HGCurve are called.
+ *--------------------------------------------------------------------*/
void
drawwig(POINT * ptr,
@@ -565,15 +568,16 @@ drawwig(POINT * ptr,
}
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------*
| Routine: HGArc (xcenter, ycenter, xstart, ystart, angle)
|
- | Results: This routine plots an arc centered about (cx, cy) counter
- | clockwise starting from the point (px, py) through 'angle'
- | degrees. If angle is 0, a full circle is drawn. It does so
- | by creating a draw-path around the arc whose density of
- | points depends on the size of the arc.
- *----------------------------------------------------------------------------*/
+ | Results: This routine plots an arc centered about (cx, cy)
+ | counter-clockwise starting from the point (px, py)
+ | through 'angle' degrees. If angle is 0, a full circle
+ | is drawn. It does so by creating a draw-path around the
+ | arc whose density of points depends on the size of the
+ | arc.
+ *--------------------------------------------------------------------*/
void
HGArc(int cx,
@@ -598,7 +602,7 @@ HGArc(int cx,
resolution = (1.0 + groff_hypot(xs, ys) / res) * PointsPerInterval;
/* mask = (1 << (int) log10(resolution + 1.0)) - 1; */
- (void) frexp(resolution, &m); /* A bit more elegant than log10 */
+ (void) frexp(resolution, &m); /* more elegant than log10 */
for (mask = 1; mask < m; mask = mask << 1);
mask -= 1;
@@ -626,13 +630,13 @@ HGArc(int cx,
} /* end HGArc */
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------*
| Routine: picurve (xpoints, ypoints, num_of_points)
|
- | Results: Draws a curve delimited by (not through) the line segments
- | traced by (xpoints, ypoints) point list. This is the 'Pic'
- | style curve.
- *----------------------------------------------------------------------------*/
+ | Results: Draws a curve delimited by (not through) the line
+ | segments traced by (xpoints, ypoints) point list. This
+ | is the 'Pic'-style curve.
+ *--------------------------------------------------------------------*/
void
picurve(int *x,
@@ -695,15 +699,15 @@ picurve(int *x,
}
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------*
| Routine: HGCurve(xpoints, ypoints, num_points)
|
| Results: This routine generates a smooth curve through a set of
- | points. The method used is the parametric spline curve on
- | unit knot mesh described in 'Spline Curve Techniques' by
- | Patrick Baudelaire, Robert Flegal, and Robert Sproull --
- | Xerox Parc.
- *----------------------------------------------------------------------------*/
+ | points. The method used is the parametric spline curve
+ | on unit knot mesh described in 'Spline Curve Techniques'
+ | by Patrick Baudelaire, Robert Flegal, and Robert Sproull
+ | -- Xerox Parc.
+ *--------------------------------------------------------------------*/
void
HGCurve(int *x,
@@ -725,8 +729,8 @@ HGCurve(int *x,
tmove2(lx, ly);
/*
- * Solve for derivatives of the curve at each point separately for x and y
- * (parametric).
+ * Solve for derivatives of the curve at each point separately for x
+ * and y (parametric).
*/
Parameterize(x, y, h, numpoints);
@@ -740,8 +744,8 @@ HGCurve(int *x,
}
/*
- * generate the curve using the above information and PointsPerInterval
- * vectors between each specified knot.
+ * Generate the curve using the above information and
+ * PointsPerInterval vectors between each specified knot.
*/
for (j = 1; j < numpoints; ++j) {
@@ -763,15 +767,15 @@ HGCurve(int *x,
} /* end HGCurve */
-/*----------------------------------------------------------------------------
- | Routine: Paramaterize (xpoints, ypoints, hparams, num_points)
+/*--------------------------------------------------------------------*
+ | Routine: Parameterize (xpoints, ypoints, hparams, num_points)
|
- | Results: This routine calculates parameteric values for use in
+ | Results: This routine calculates parametric values for use in
| calculating curves. The parametric values are returned
| in the array h. The values are an approximation of
| cumulative arc lengths of the curve (uses cord length).
| For additional information, see paper cited below.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
Parameterize(int x[],
@@ -797,21 +801,21 @@ Parameterize(int x[],
}
for (i = 1; i < n; ++i)
h[i] = u[i + 1] - u[i];
-} /* end Paramaterize */
+} /* end Parameterize */
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------*
| Routine: PeriodicSpline (h, z, dz, d2z, d3z, npoints)
|
- | Results: This routine solves for the cubic polynomial to fit a spline
- | curve to the points specified by the list of values.
- | The Curve generated is periodic. The algorithms for this
- | curve are from the 'Spline Curve Techniques' paper cited
- | above.
- *----------------------------------------------------------------------------*/
+ | Results: This routine solves for the cubic polynomial to fit a
+ | spline curve to the points specified by the list of
+ | values. The curve generated is periodic. The
+ | algorithms for this curve are from the 'Spline Curve
+ | Techniques' paper cited above.
+ *--------------------------------------------------------------------*/
void
-PeriodicSpline(double h[], /* paramaterization */
+PeriodicSpline(double h[], /* parameterization */
int z[], /* point list */
double dz[], /* to return the 1st derivative */
double d2z[], /* 2nd derivative */
@@ -873,14 +877,14 @@ PeriodicSpline(double h[], /* paramaterization */
} /* end PeriodicSpline */
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------
| Routine: NaturalEndSpline (h, z, dz, d2z, d3z, npoints)
|
- | Results: This routine solves for the cubic polynomial to fit a spline
- | curve the points specified by the list of values. The
- | algorithms for this curve are from the 'Spline Curve
+ | Results: This routine solves for the cubic polynomial to fit a
+ | spline curve the points specified by the list of values.
+ | The algorithms for this curve are from the 'Spline Curve
| Techniques' paper cited above.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
NaturalEndSpline(double h[], /* parameterization */
@@ -929,15 +933,15 @@ NaturalEndSpline(double h[], /* parameterization */
} /* end NaturalEndSpline */
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: change (x_position, y_position, visible_flag)
|
| Results: As HGtline passes from the invisible to visible (or vice
- | versa) portion of a line, change is called to either draw
- | the line, or initialize the beginning of the next one.
- | Change calls line to draw segments if visible_flag is set
- | (which means we're leaving a visible area).
- *----------------------------------------------------------------------------*/
+ | versa) portion of a line, change is called to either
+ | draw the line, or initialize the beginning of the next
+ | one. Change calls line to draw segments if visible_flag
+ | is set (which means we're leaving a visible area).
+ *--------------------------------------------------------------------*/
void
change(int x,
@@ -952,19 +956,20 @@ change(int x,
length = 0;
printf("\\\n");
}
- } else { /* otherwise, we're entering one, remember */
- /* beginning */
+ } else { /* otherwise entering one; remember */
+ /* beginning */
tmove2(x, y);
}
}
-/*----------------------------------------------------------------------------
+/*--------------------------------------------------------------------*
| Routine: HGtline (xstart, ystart, xend, yend)
|
- | Results: Draws a line from current position to (x1,y1) using line(x1,
- | y1) to place individual segments of dotted or dashed lines.
- *----------------------------------------------------------------------------*/
+ | Results: Draws a line from current position to (x1,y1) using
+ | line(x1, y1) to place individual segments of dotted or
+ | dashed lines.
+ *--------------------------------------------------------------------*/
void
HGtline(int x_1,
diff --git a/src/preproc/grn/hpoint.cpp b/src/preproc/grn/hpoint.cpp
index ec7fa20b6..5ef0c0a2b 100644
--- a/src/preproc/grn/hpoint.cpp
+++ b/src/preproc/grn/hpoint.cpp
@@ -1,8 +1,8 @@
/* Last non-groff version: hpoint.c 1.1 84/10/08 */
/*
- * This file contains routines for manipulating the point data structures
- * for the gremlin picture editor.
+ * This file contains routines for manipulating the point data
+ * structures for the gremlin picture editor.
*/
#ifdef HAVE_CONFIG_H
@@ -26,8 +26,8 @@ PTInit()
/*
- * This routine creates a new point with coordinates x and y and links it
- * into the pointlist.
+ * This routine creates a new point with coordinates x and y and links
+ * it into the point list.
*/
POINT *
PTMakePoint(double x,
diff --git a/src/preproc/grn/main.cpp b/src/preproc/grn/main.cpp
index 75fe7cfe2..1a940bbe5 100644
--- a/src/preproc/grn/main.cpp
+++ b/src/preproc/grn/main.cpp
@@ -6,64 +6,70 @@
*
*
* This file contains the main and file system dependent routines for
- * processing gremlin files into troff input. The program watches input go
- * by to standard output, only interpreting things between .GS and .GE
- * lines. Default values (font, size, scale, thickness) may be overridden
- * with a 'default' command and are further overridden by commands in the
- * input.
+ * processing gremlin files into troff input. The program watches input
+ * go by to standard output, only interpreting things between .GS and
+ * .GE lines. Default values (font, size, scale, thickness) may be
+ * overridden with a 'default' command and are further overridden by
+ * commands in the input.
*
- * Inside the GS and GE, commands are accepted to reconfigure the picture.
- * At most one command may reside on each line, and each command is followed
- * by a parameter separated by white space. The commands are as follows,
- * and may be abbreviated down to one character (with exception of 'scale'
- * and 'stipple' down to "sc" and "st") and may be upper or lower case.
+ * Inside the GS and GE, commands are accepted to reconfigure the
+ * picture. At most one command may reside on each line, and each
+ * command is followed by a parameter separated by white space. The
+ * commands are as follows, and may be abbreviated down to one character
+ * (with exception of 'scale' and 'stipple' down to "sc" and "st") and
+ * may be upper or lower case.
*
* default - Make all settings in the current
- * .GS/.GE the global defaults. Height,
- * width and file are NOT saved.
- * 1, 2, 3, 4 - Set size 1, 2, 3, or 4 (followed by an
- * integer point size).
- * roman, italics, bold, special - Set gremlin's fonts to any other troff
- * font (one or two characters).
- * stipple, l - Use a stipple font for polygons. Arg
- * is troff font name. No Default. Can
- * use only one stipple font per picture.
- * (See below for stipple font index.)
+ * .GS/.GE the global defaults.
+ * Height, width and file are NOT
+ * saved.
+ * 1, 2, 3, 4 - Set size 1, 2, 3, or 4 (followed
+ * by an integer point size).
+ * roman, italics, bold, special - Set gremlin's fonts to any other
+ * troff font (1 or 2 characters).
+ * stipple, l - Use a stipple font for polygons.
+ * Arg is troff font name. No
+ * default. Can use only one stipple
+ * font per picture. (See below for
+ * stipple font index.)
* scale, x - Scale is IN ADDITION to the global
* scale factor from the default.
- * pointscale - Turn on scaling point sizes to match
- * 'scale' commands. (Optional operand
- * 'off' to turn it off.)
+ * pointscale - Turn on scaling point sizes to
+ * match 'scale' commands. (Optional
+ * operand 'off' to turn it off.)
* narrow, medium, thick - Set widths of lines.
- * file - Set the file name to read the gremlin
- * picture from. If the file isn't in
- * the current directory, the gremlin
- * library is tried.
+ * file - Set the file name to read the
+ * gremlin picture from. If the file
+ * isn't in the current directory,
+ * the gremlin library is tried.
* width, height - These two commands override any
- * scaling factor that is in effect, and
- * forces the picture to fit into either
- * the height or width specified,
- * whichever makes the picture smaller.
- * The operand for these two commands is
- * a floating-point number in units of
+ * scaling factor that is in effect,
+ * and forces the picture to fit into
+ * either the height or width
+ * specified, whichever makes the
+ * picture smaller. The operand for
+ * these two commands is a
+ * floating-point number in units of
* inches.
- * l<nn> (integer <nn>) - Set association between stipple <nn>
- * and a stipple 'character'. <nn> must
- * be in the range 0 to NSTIPPLES (16)
- * inclusive. The integer operand is an
- * index in the stipple font selected.
- * Valid cf (cifplot) indices are 1-32
- * (although 24 is not defined), valid ug
- * (unigrafix) indices are 1-14, and
- * valid gs (gray scale) indices are
- * 0-16. Nonetheless, any number between
- * 0 and 255 is accepted since new
- * stipple fonts may be added. An
- * integer operand is required.
+ * l<nn> (integer <nn>) - Set association between stipple
+ * <nn> and a stipple 'character'.
+ * <nn> must be in the range 0 to
+ * NSTIPPLES (16) inclusive. The
+ * integer operand is an index in the
+ * stipple font selected. Valid cf
+ * (cifplot) indices are 1-32
+ * (although 24 is not defined),
+ * valid ug (unigrafix) indices are
+ * 1-14, and valid gs (gray scale)
+ * indices are 0-16. Nonetheless,
+ * any number between 0 and 255 is
+ * accepted since new stipple fonts
+ * may be added. An integer operand
+ * is required.
*
- * Troff number registers used: g1 through g9. g1 is the width of the
- * picture, and g2 is the height. g3, and g4, save information, g8 and g9
- * are used for text processing and g5-g7 are reserved.
+ * Troff number registers used: g1 through g9. g1 is the width of the
+ * picture, and g2 is the height. g3, and g4, save information, g8 and
+ * g9 are used for text processing and g5-g7 are reserved.
*/
@@ -93,7 +99,7 @@ extern ELT *DBRead(FILE *file);
extern POINT *PTInit();
extern POINT *PTMakePoint(double x, double y, POINT **pplist);
-#define INIT_FILE_SIZE 50 /* Initial size of array of files from cmd line. */
+#define INIT_FILE_SIZE 50 /* Initial sz of file array from cmd line. */
#define FILE_SIZE_INCR 50 /* Amount to increase array of files by. */
#define SUN_SCALEFACTOR 0.70
@@ -101,13 +107,13 @@ extern POINT *PTMakePoint(double x, double y, POINT **pplist);
/* #define DEFSTIPPLE "gs" */
#define DEFSTIPPLE "cf"
/*
- * This grn implementation emits '.st' requests to control stipple effects,
- * but groff does not (currently) support any such request.
+ * This grn implementation emits '.st' requests to control stipple
+ * effects, but groff does not (currently) support any such request.
*
- * This hack disables the emission of such requests, without destroying the
- * infrastructure necessary to support the feature in the future; to enable
- * the emission of '.st' requests, at a future date when groff can support
- * them, simply rewrite the following #define as:
+ * This hack disables the emission of such requests, without destroying
+ * the infrastructure necessary to support the feature in the future; to
+ * enable the emission of '.st' requests, at a future date when groff
+ * can support them, simply rewrite the following #define as:
*
* #define USE_ST_REQUEST stipple
*
@@ -119,7 +125,7 @@ extern POINT *PTMakePoint(double x, double y, POINT **pplist);
#define SCREENtoINCH 0.02 /* scaling factor, screen to inches */
-#define BIG 999999999999.0 /* unweildly large floating number */
+#define BIG 999999999999.0 /* unwieldy large floating number */
/* static char sccsid[] = "@(#) (Berkeley) 8/5/85, 12/28/99"; */
@@ -130,12 +136,13 @@ int dotshifter; /* for the length of dotted curves */
double linethickness; /* brush styles */
int linmod;
-int lastx; /* point registers for printing elements */
-int lasty;
-int lastyline; /* A line's vertical position is NOT the */
- /* same after that line is over, so for a */
- /* line of drawing commands, vertical */
- /* spacing is kept in lastyline */
+int lastx; /* point registers for printing */
+int lasty; /* elements */
+int lastyline; /* A line's vertical position is NOT */
+ /* the same after that line is over, */
+ /* so for a line of drawing commands, */
+ /* vertical spacing is kept in */
+ /* lastyline. */
/* These are the default fonts, sizes, line styles, */
/* and thicknesses. They can be modified from a */
@@ -156,12 +163,12 @@ double defthick[STYLES] =
1 * BASE_THICKNESS,
3 * BASE_THICKNESS};
-/* int cf_stipple_index[NSTIPPLES + 1] = */
-/* {0, 1, 3, 12, 14, 16, 19, 21, 23}; */
-/* a logarithmic scale looks better than a linear one for the gray shades */
-/* */
-/* int other_stipple_index[NSTIPPLES + 1] = */
-/* {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; */
+/* int cf_stipple_index[NSTIPPLES + 1] = */
+/* {0, 1, 3, 12, 14, 16, 19, 21, 23}; */
+/* a logarithmic scale looks better than a linear one for gray shades */
+/* */
+/* int other_stipple_index[NSTIPPLES + 1] = */
+/* {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; */
int cf_stipple_index[NSTIPPLES + 1] =
{0, 18, 32, 56, 100, 178, 316, 562, 1000}; /* only 1-8 used */
@@ -175,7 +182,7 @@ int *defstipple_index = cf_stipple_index;
int style[STYLES] =
{DOTTED, DOTDASHED, SOLID, DASHED, SOLID, SOLID};
double scale = 1.0; /* no scaling, default */
-int defpoint = 0; /* flag for pointsize scaling */
+int defpoint = 0; /* flag for point size scaling */
char *defstipple = (char *) 0;
enum E {
OUTLINE, FILL, BOTH
@@ -188,33 +195,32 @@ double adj2 = 0.0;
double adj3 = 0.0;
double adj4 = 0.0;
-double thick[STYLES]; /* thicknesses set by defaults, then by */
- /* commands */
-char *tfont[FONTS]; /* fonts originally set to deffont values, */
- /* then */
-int tsize[SIZES]; /* optionally changed by commands inside */
- /* grn */
-int stipple_index[NSTIPPLES + 1]; /* stipple font file indices */
+double thick[STYLES]; /* thicknesses set by defaults, then */
+ /* by commands */
+char *tfont[FONTS]; /* fonts originally set to deffont */
+ /* values, then optionally changed by */
+int tsize[SIZES]; /* commands inside grn */
+int stipple_index[NSTIPPLES + 1]; /* stipple font file indices */
char *stipple;
-double xscale; /* scaling factor from individual pictures */
-double troffscale; /* scaling factor at output time */
+double xscale; /* scaling factor from individual pictures */
+double troffscale; /* scaling factor at output time */
-double width; /* user-request maximum width for picture */
- /* (in inches) */
-double height; /* user-request height */
-int pointscale; /* flag for pointsize scaling */
-int setdefault; /* flag for a .GS/.GE to remember all */
- /* settings */
-int sflag; /* -s flag: sort order (do polyfill first) */
+double width; /* user-request maximum width for picture */
+ /* (in inches) */
+double height; /* user-request height */
+int pointscale; /* flag for point size scaling */
+int setdefault; /* flag for a .GS/.GE to remember all */
+ /* settings */
+int sflag; /* -s flag: sort order (do polyfill first) */
-double toppoint; /* remember the picture */
-double bottompoint; /* bounds in these variables */
+double toppoint; /* remember the picture */
+double bottompoint; /* bounds in these variables */
double leftpoint;
double rightpoint;
-int ytop; /* these are integer versions of the above */
-int ybottom; /* so not to convert each time they're used */
+int ytop; /* these are integer versions of the above */
+int ybottom; /* so not to convert each time they're used */
int xleft;
int xright;
@@ -280,14 +286,14 @@ add_file(char **file,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: main (argument_count, argument_pointer)
|
- | Results: Parses the command line, accumulating input file names, then
- | reads the inputs, passing it directly to output until a '.GS'
- | line is read. Main then passes control to 'conv' to do the
- | gremlin file conversions.
- *----------------------------------------------------------------------------*/
+ | Results: Parses the command line, accumulating input file names,
+ | then reads the inputs, passing it directly to output
+ | until a '.GS' line is read. Main then passes control to
+ | 'conv' to do the gremlin file conversions.
+ *--------------------------------------------------------------------*/
int
main(int argc,
@@ -356,7 +362,7 @@ main(int argc,
}
}
- getres(); /* set the resolution for an output device */
+ getres(); /* set the resolution for an output device */
if (gfil == 0) { /* no filename, use standard input */
file[0] = NULL;
@@ -386,16 +392,16 @@ main(int argc,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: char * operand (& argc, & argv)
|
| Results: Returns address of the operand given with a command-line
- | option. It uses either '-Xoperand' or '-X operand', whichever
- | is present. The program is terminated if no option is
- | present.
+ | option. It uses either '-Xoperand' or '-X operand',
+ | whichever is present. The program is terminated if no
+ | option is present.
|
| Side Efct: argc and argv are updated as necessary.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
char *
operand(int *argcp,
@@ -411,11 +417,11 @@ operand(int *argcp,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: getres ()
|
| Results: Sets 'res' to the resolution of the output device.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
getres()
@@ -443,7 +449,7 @@ getres()
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: int doinput (file_pointer)
|
| Results: A line of input is read into 'inputline'.
@@ -452,7 +458,7 @@ getres()
|
| Bugs: Lines longer than MAXINLINE are NOT checked, except for
| updating 'linenum'.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
int
doinput(FILE *fp)
@@ -465,14 +471,14 @@ doinput(FILE *fp)
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: initpic ( )
|
| Results: Sets all parameters to the normal defaults, possibly
- | overridden by a setdefault command. Initialize the picture
- | variables, and output the startup commands to troff to begin
- | the picture.
- *----------------------------------------------------------------------------*/
+ | overridden by a setdefault command. Initialize the
+ | picture variables, and output the startup commands to
+ | troff to begin the picture.
+ *--------------------------------------------------------------------*/
void
initpic()
@@ -488,22 +494,23 @@ initpic()
for (i = 0; i < SIZES; i++) { /* font size defaults */
tsize[i] = defsize[i];
}
- for (i = 0; i <= NSTIPPLES; i++) { /* stipple font file default indices */
+ for (i = 0; i <= NSTIPPLES; i++) { /* stipple font file default */
+ /* indices */
stipple_index[i] = defstipple_index[i];
}
stipple = defstipple;
gremlinfile[0] = 0; /* filename is 'null' */
- setdefault = 0; /* this is not the default settings (yet) */
+ setdefault = 0; /* not the default settings (yet) */
toppoint = BIG; /* set the picture bounds out */
bottompoint = -BIG; /* of range so they'll be set */
leftpoint = BIG; /* by 'savebounds' on input */
rightpoint = -BIG;
- pointscale = defpoint; /* flag for scaling point sizes default */
- xscale = scale; /* default scale of individual pictures */
- width = 0.0; /* size specifications input by user */
+ pointscale = defpoint;/* flag for scaling point sizes default */
+ xscale = scale; /* default scale of individual pictures */
+ width = 0.0; /* size specifications input by user */
height = 0.0;
linethickness = DEFTHICK; /* brush styles */
@@ -511,30 +518,30 @@ initpic()
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: conv (file_pointer, starting_line)
|
| Results: At this point, we just passed a '.GS' line in the input
- | file. conv reads the input and calls 'interpret' to process
- | commands, gathering up information until a '.GE' line is
- | found. It then calls 'HGPrint' to do the translation of the
- | gremlin file to troff commands.
- *----------------------------------------------------------------------------*/
+ | file. conv reads the input and calls 'interpret' to
+ | process commands, gathering up information until a '.GE'
+ | line is found. It then calls 'HGPrint' to do the
+ | translation of the gremlin file to troff commands.
+ *--------------------------------------------------------------------*/
void
conv(FILE *fp,
int baseline)
{
- FILE *gfp = NULL; /* input file pointer */
- int done = 0; /* flag to remember if finished */
- ELT *e; /* current element pointer */
- ELT *PICTURE; /* whole picture data base pointer */
- double temp; /* temporary calculating area */
- /* POINT ptr; */ /* coordinates of a point to pass to 'mov' */
- /* routine */
- int flyback; /* flag 'want to end up at the top of the */
- /* picture?' */
- int compat; /* test character after .GE or .GF */
+ FILE *gfp = NULL; /* input file pointer */
+ int done = 0; /* flag to remember if finished */
+ ELT *e; /* current element pointer */
+ ELT *PICTURE; /* whole picture data base pointer */
+ double temp; /* temporary calculating area */
+ /* POINT ptr; */ /* coordinates of a point to pass to 'mov' */
+ /* routine */
+ int flyback; /* flag 'want to end up at the top of the */
+ /* picture?' */
+ int compat; /* test character after .GE or .GF */
initpic(); /* set defaults, ranges, etc. */
@@ -571,7 +578,7 @@ conv(FILE *fp,
if (stipple == (char *) NULL) /* if user forgot stipple */
if (has_polygon(PICTURE)) /* and picture has a polygon */
- stipple = (char *)DEFSTIPPLE; /* then set the default */
+ stipple = (char *)DEFSTIPPLE; /* then set the default */
if ((temp = bottompoint - toppoint) < 0.1)
temp = 0.1;
@@ -585,21 +592,22 @@ conv(FILE *fp,
else {
if (temp < troffscale)
troffscale = temp;
- } /* here, troffscale is the */
+ } /* here, troffscale is the */
/* picture's scaling factor */
if (pointscale) {
- int i; /* do pointscaling here, when */
+ int i; /* do point scaling here, when */
/* scale is known, before output */
for (i = 0; i < SIZES; i++)
tsize[i] = (int) (troffscale * (double) tsize[i] + 0.5);
}
- /* change to device units */
- troffscale *= SCREENtoINCH * res; /* from screen units */
+ /* change to device units */
+ troffscale *= SCREENtoINCH * res; /* from screen units */
- ytop = (int) (toppoint * troffscale); /* calculate integer */
- ybottom = (int) (bottompoint * troffscale); /* versions of the */
- xleft = (int) (leftpoint * troffscale); /* picture limits */
+ /* Calculate integer versions of the picture limits. */
+ ytop = (int) (toppoint * troffscale);
+ ybottom = (int) (bottompoint * troffscale);
+ xleft = (int) (leftpoint * troffscale);
xright = (int) (rightpoint * troffscale);
/* save stuff in number registers, */
@@ -630,11 +638,11 @@ conv(FILE *fp,
* print only the interiors of filled polygons (as borderless
* polygons). Second time, print the outline as series of line
* segments. This way, postprocessors that overwrite rather than
- * merge picture elements (such as Postscript) can still have text and
- * graphics on a shaded background.
+ * merge picture elements (such as Postscript) can still have text
+ * and graphics on a shaded background.
*/
/* if (sflag) */
- if (!sflag) { /* changing the default for filled polygons */
+ if (!sflag) { /* changing the default for filled polygons */
e = PICTURE;
polyfill = FILL;
while (!DBNullelt(e)) {
@@ -650,7 +658,7 @@ conv(FILE *fp,
e = PICTURE;
/* polyfill = !sflag ? BOTH : OUTLINE; */
- polyfill = sflag ? BOTH : OUTLINE; /* changing the default */
+ polyfill = sflag ? BOTH : OUTLINE; /* changing default */
while (!DBNullelt(e)) {
printf(".mk\n");
HGPrintElt(e, baseline);
@@ -662,9 +670,9 @@ conv(FILE *fp,
/* decide where to end picture */
- /* I changed everything here. I always use the combination .mk and */
- /* .rt so once finished I just space down the heigth of the picture */
- /* that is \n(g2u */
+ /* I [Senderowicz?] changed everything here. I always use the */
+ /* combination .mk and .rt, so once finished I just space down */
+ /* height of the picture that is \n(g2u. */
if (flyback) { /* end picture at upper left */
/* ptr.x = leftpoint;
ptr.y = toppoint; */
@@ -676,8 +684,8 @@ conv(FILE *fp,
/* tmove(&ptr); */ /* restore default line parameters */
- /* restore everything to the way it was before the .GS, then put */
- /* out the '.GE' line from user */
+ /* Restore everything to the way it was before the .GS, then */
+ /* put out the '.GE' line from user */
/* printf("\\D't %du'\\D's %du'\n", DEFTHICK, DEFSTYLE); */
/* groff doesn't understand the \Ds command */
@@ -697,16 +705,16 @@ conv(FILE *fp,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: savestate ( )
|
- | Results: all the current scaling / font size / font name / thickness
- | / pointscale settings are saved to be the defaults. Scaled
- | point sizes are NOT saved. The scaling is done each time a
- | new picture is started.
+ | Results: All the current scaling/font size/font name/thickness/
+ | pointscale settings are made the defaults. Scaled
+ | point sizes are NOT saved. The scaling is done each
+ | time a new picture is started.
|
| Side Efct: scale, and def* are modified.
- *----------------------------------------------------------------------------*/
+ *--------------------------------------------------------------------*/
void
savestate()
@@ -719,24 +727,25 @@ savestate()
deffont[i] = tfont[i];
for (i = 0; i < SIZES; i++) /* font size defaults */
defsize[i] = tsize[i];
- for (i = 0; i <= NSTIPPLES; i++) /* stipple font file default indices */
+ /* stipple font file default indices */
+ for (i = 0; i <= NSTIPPLES; i++)
defstipple_index[i] = stipple_index[i];
- defstipple = stipple; /* if stipple has been set, it's remembered */
- scale *= xscale; /* default scale of individual pictures */
- defpoint = pointscale; /* flag for scaling pointsizes from x factors */
+ defstipple = stipple; /* if stipple has been set, it's remembered */
+ scale *= xscale; /* default scale of individual pictures */
+ defpoint = pointscale;/* flag to scale point sizes from x factors */
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: savebounds (x_coordinate, y_coordinate)
|
- | Results: Keeps track of the maximum and minimum extent of a picture
- | in the global variables: left-, right-, top- and
- | bottompoint. 'savebounds' assumes that the points have been
- | oriented to the correct direction. No scaling has taken
- | place, though.
- *----------------------------------------------------------------------------*/
+ | Results: Keeps track of the maximum and minimum extent of a
+ | picture in the global variables: left-, right-, top- and
+ | bottompoint. 'savebounds' assumes that the points have
+ | been oriented to the correct direction. No scaling has
+ | taken place, though.
+ *--------------------------------------------------------------------*/
void
savebounds(double x,
@@ -753,19 +762,18 @@ savebounds(double x,
}
-/*----------------------------------------------------------------------------*
+/*--------------------------------------------------------------------*
| Routine: interpret (character_string)
|
| Results: Commands are taken from the input string and performed.
- | Commands are separated by the endofline, and are of the
+ | Commands are separated by newlines, and are of the
| format:
| string1 string2
+ | where string1 is the command, string2 the argument.
|
- | where string1 is the command and string2 is the argument.
- |
- | Side Efct: Font and size strings, plus the gremlin file name and the
- | width and height variables are set by this routine.
- *----------------------------------------------------------------------------*/
+ | Side Efct: Font and size strings, plus the gremlin file name and
+ | the width and height variables are set by this routine.
+ *--------------------------------------------------------------------*/
void
interpret(char *line)