git@sv
/
enscript.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added the $HOME variable to be used in AFMPATH
[enscript.git]
/
src
/
psgen.c
diff --git
a/src/psgen.c
b/src/psgen.c
index
b827fe1
..
3990659
100644
(file)
--- a/
src/psgen.c
+++ b/
src/psgen.c
@@
-22,6
+22,7
@@
* along with Enscript. If not, see <http://www.gnu.org/licenses/>.
*/
* along with Enscript. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <limits.h>
#include "gsint.h"
#include <libgen.h>
#include "gsint.h"
#include <libgen.h>
@@
-123,7
+124,7
@@
struct gs_token_st
double xscale;
double yscale;
int llx, lly, urx, ury; /* Bounding box. */
double xscale;
double yscale;
int llx, lly, urx, ury; /* Bounding box. */
- char filename[
512
];
+ char filename[
PATH_MAX
];
char *skipbuf;
unsigned int skipbuf_len;
unsigned int skipbuf_pos;
char *skipbuf;
unsigned int skipbuf_len;
unsigned int skipbuf_pos;
@@
-134,11
+135,11
@@
struct gs_token_st
Color bgcolor;
struct
{
Color bgcolor;
struct
{
- char name[
512
];
+ char name[
PATH_MAX
];
FontPoint size;
InputEncoding encoding;
} font;
FontPoint size;
InputEncoding encoding;
} font;
- char filename[
512
];
+ char filename[
PATH_MAX
];
} u;
};
} u;
};
@@
-247,7
+248,7
@@
static int do_print = 1;
static int user_fontp = 0;
/* The user ^@font{}-defined font. */
static int user_fontp = 0;
/* The user ^@font{}-defined font. */
-static char user_font_name[
256
];
+static char user_font_name[
PATH_MAX
];
static FontPoint user_font_pt;
static InputEncoding user_font_encoding;
static FontPoint user_font_pt;
static InputEncoding user_font_encoding;
@@
-279,12
+280,19
@@
dump_ps_header ()
{
char *cp, *cp2;
int i, j, got;
{
char *cp, *cp2;
int i, j, got;
+ char *ps_version_string; /* Version string for PS procsets. */
+
/* Dump PS header only once. */
if (ps_header_dumped)
return;
ps_header_dumped = 1;
/* Dump PS header only once. */
if (ps_header_dumped)
return;
ps_header_dumped = 1;
+ /* Create version string. */
+ ps_version_string = xstrdup (VERSION);
+ cp = strrchr (ps_version_string, '.');
+ *cp = ' ';
+
/*
* Header.
*/
/*
* Header.
*/
@@
-294,7
+302,7
@@
dump_ps_header ()
media->urx, media->ury));
OUTPUT ((cofp, "%%%%Title: %s\n", title));
OUTPUT ((cofp, "%%%%For: %s\n", passwd->pw_gecos));
media->urx, media->ury));
OUTPUT ((cofp, "%%%%Title: %s\n", title));
OUTPUT ((cofp, "%%%%For: %s\n", passwd->pw_gecos));
- OUTPUT ((cofp, "%%%%Creator: %s\n",
version_string
));
+ OUTPUT ((cofp, "%%%%Creator: %s\n",
PACKAGE_STRING
));
OUTPUT ((cofp, "%%%%CreationDate: %s\n", date_string));
OUTPUT ((cofp, "%%%%Orientation: %s\n",
((nup > 1) && nup_landscape)
OUTPUT ((cofp, "%%%%CreationDate: %s\n", date_string));
OUTPUT ((cofp, "%%%%Orientation: %s\n",
((nup > 1) && nup_landscape)
@@
-577,8
+585,8
@@
process_file (char *fname_arg, InputStream *is, int is_toc)
* Count possible line number spaces. This should be enought for 99999
* lines
*/
* Count possible line number spaces. This should be enought for 99999
* lines
*/
- linenumber_space = CHAR_WIDTH ('0') * 5 + 1.0;
- linenumber_margin =
CHAR_WIDTH (':') +
CHAR_WIDTH ('m');
+ linenumber_space =
FNT_
CHAR_WIDTH ('0') * 5 + 1.0;
+ linenumber_margin =
FNT_CHAR_WIDTH (':') + FNT_
CHAR_WIDTH ('m');
/* We got a new input file. */
input_filenum++;
/* We got a new input file. */
input_filenum++;
@@
-977,7
+985,8
@@
large for page\n"),
FATAL ((stderr,
_("user font encoding can be only the system's default or `ps'")));
FATAL ((stderr,
_("user font encoding can be only the system's default or `ps'")));
- strcpy (user_font_name, token.u.font.name);
+ memset (user_font_name, 0, sizeof(user_font_name));
+ strncpy (user_font_name, token.u.font.name, sizeof(user_font_name) - 1);
user_font_pt.w = token.u.font.size.w;
user_font_pt.h = token.u.font.size.h;
user_font_encoding = token.u.font.encoding;
user_font_pt.w = token.u.font.size.w;
user_font_pt.h = token.u.font.size.h;
user_font_encoding = token.u.font.encoding;
@@
-1128,7
+1137,7
@@
large for page\n"),
/* Help macros. */
/* Check if character <ch> fits to current line. */
/* Help macros. */
/* Check if character <ch> fits to current line. */
-#define FITS_ON_LINE(ch) ((linepos + CHAR_WIDTH (ch) < linew) || col == 0)
+#define FITS_ON_LINE(ch) ((linepos +
FNT_
CHAR_WIDTH (ch) < linew) || col == 0)
/* Is line buffer empty? */
#define BUFFER_EMPTY() (bufpos == 0)
/* Is line buffer empty? */
#define BUFFER_EMPTY() (bufpos == 0)
@@
-1151,13
+1160,13
@@
large for page\n"),
#define EMIT(ch) \
do { \
APPEND_CHAR (ch); \
#define EMIT(ch) \
do { \
APPEND_CHAR (ch); \
- linepos +=
CHAR_WIDTH (ch);
\
+ linepos +=
FNT_CHAR_WIDTH (ch);
\
col++; \
} while (0)
#define UNEMIT(ch) \
do { \
col++; \
} while (0)
#define UNEMIT(ch) \
do { \
- linepos -= CHAR_WIDTH (ch); \
+ linepos -=
FNT_
CHAR_WIDTH (ch); \
col--; \
} while (0)
col--; \
} while (0)
@@
-1443,7
+1452,7
@@
read_special_escape (InputStream *is, Token *token)
buf[i] = ch;
if (i + 1 >= sizeof (buf))
FATAL ((stderr, _("too long argument for %s escape:\n%.*s"),
buf[i] = ch;
if (i + 1 >= sizeof (buf))
FATAL ((stderr, _("too long argument for %s escape:\n%.*s"),
- escapes[
i
].name, i, buf));
+ escapes[
e
].name, i, buf));
}
buf[i] = '\0';
}
buf[i] = '\0';
@@
-1451,7
+1460,8
@@
read_special_escape (InputStream *is, Token *token)
switch (escapes[e].escape)
{
case ESC_FONT:
switch (escapes[e].escape)
{
case ESC_FONT:
- strcpy (token->u.font.name, buf);
+ memset (token->u.font.name, 0, sizeof(token->u.font.name));
+ strncpy (token->u.font.name, buf, sizeof(token->u.font.name) - 1);
/* Check for the default font. */
if (strcmp (token->u.font.name, "default") == 0)
/* Check for the default font. */
if (strcmp (token->u.font.name, "default") == 0)
@@
-1464,7
+1474,8
@@
read_special_escape (InputStream *is, Token *token)
FATAL ((stderr, _("malformed font spec for ^@font escape: %s"),
token->u.font.name));
FATAL ((stderr, _("malformed font spec for ^@font escape: %s"),
token->u.font.name));
- strcpy (token->u.font.name, cp);
+ memset (token->u.font.name, 0, sizeof(token->u.font.name));
+ strncpy (token->u.font.name, cp, sizeof(token->u.font.name) - 1);
xfree (cp);
}
token->type = tFONT;
xfree (cp);
}
token->type = tFONT;
@@
-1543,7
+1554,8
@@
read_special_escape (InputStream *is, Token *token)
break;
case ESC_SETFILENAME:
break;
case ESC_SETFILENAME:
- strcpy (token->u.filename, buf);
+ memset (token->u.filename, 0, sizeof(token->u.filename));
+ strncpy (token->u.filename, buf, sizeof(token->u.filename) - 1);
token->type = tSETFILENAME;
break;
token->type = tSETFILENAME;
break;
@@
-1678,7
+1690,7
@@
get_next_token (InputStream *is, double linestart, double linepos,
{
/* Proportional font. */
{
/* Proportional font. */
- double grid = tabsize * CHAR_WIDTH (' ');
+ double grid = tabsize *
FNT_
CHAR_WIDTH (' ');
col++;
/* Move linepos to the next multiple of <grid>. */
col++;
/* Move linepos to the next multiple of <grid>. */
@@
-1736,9
+1748,9
@@
get_next_token (InputStream *is, double linestart, double linepos,
if (ch == bs)
{
if (BUFFER_EMPTY () || !EXISTS (buffer[bufpos - 1]))
if (ch == bs)
{
if (BUFFER_EMPTY () || !EXISTS (buffer[bufpos - 1]))
- linepos -= CHAR_WIDTH ('m');
+ linepos -=
FNT_
CHAR_WIDTH ('m');
else
else
- linepos -= CHAR_WIDTH (buffer[bufpos - 1]);
+ linepos -=
FNT_
CHAR_WIDTH (buffer[bufpos - 1]);
done = DONE_DONE;
break;
done = DONE_DONE;
break;
@@
-1763,7
+1775,7
@@
get_next_token (InputStream *is, double linestart, double linepos,
APPEND_CHAR (buf[i]);
/* Update current point counters manually. */
APPEND_CHAR (buf[i]);
/* Update current point counters manually. */
- linepos += CHAR_WIDTH (ch);
+ linepos +=
FNT_
CHAR_WIDTH (ch);
col++;
}
else if (ch == '(' || ch == ')' || ch == '\\')
col++;
}
else if (ch == '(' || ch == ')' || ch == '\\')
@@
-1836,7
+1848,7
@@
get_next_token (InputStream *is, double linestart, double linepos,
/* Count length. */
for (i = 0; buf[i]; i++)
/* Count length. */
for (i = 0; buf[i]; i++)
- len += CHAR_WIDTH (buf[i]);
+ len +=
FNT_
CHAR_WIDTH (buf[i]);
if (linepos + len < linew || col == 0)
{
if (linepos + len < linew || col == 0)
{
@@
-2460,7
+2472,7
@@
recognize_eps_file (Token *token)
/* No, this BoundingBox comment is corrupted. */
MESSAGE (0, (stderr, _("EPS file \"%s\" contains malformed \
%%%%BoundingBox row:\n\"%.*s\"\n"),
/* No, this BoundingBox comment is corrupted. */
MESSAGE (0, (stderr, _("EPS file \"%s\" contains malformed \
%%%%BoundingBox row:\n\"%.*s\"\n"),
- token->u.epsf.filename,
strlen (buf) - 1
, buf));
+ token->u.epsf.filename,
(int)(strlen (buf) - 1)
, buf));
break;
}
}
break;
}
}
@@
-2587,7
+2599,7
@@
read_float (InputStream *is, int units, int horizontal)
case 'l': /* lines or characters */
if (horizontal)
case 'l': /* lines or characters */
if (horizontal)
- val *= CHAR_WIDTH ('m');
+ val *=
FNT_
CHAR_WIDTH ('m');
else
val *= LINESKIP;
break;
else
val *= LINESKIP;
break;
@@
-2716,7
+2728,7
@@
print_line_number (double x, double y, double space, double margin,
int i;
char *saved_Fname = "";
FontPoint saved_Fpt;
int i;
char *saved_Fname = "";
FontPoint saved_Fpt;
- InputEncoding saved_Fencoding;
+ InputEncoding saved_Fencoding
= 0
;
saved_Fpt.w = 0.0;
saved_Fpt.h = 0.0;
saved_Fpt.w = 0.0;
saved_Fpt.h = 0.0;
@@
-2746,7
+2758,7
@@
print_line_number (double x, double y, double space, double margin,
/* Count linenumber string length. */
sprintf (buf, "%d", linenum);
for (i = 0; buf[i]; i++)
/* Count linenumber string length. */
sprintf (buf, "%d", linenum);
for (i = 0; buf[i]; i++)
- len += CHAR_WIDTH (buf[i]);
+ len +=
FNT_
CHAR_WIDTH (buf[i]);
/* Print line numbers. */
OUTPUT ((cofp, "%g %g M (%s:) s\n", x + space - len, y, buf));
/* Print line numbers. */
OUTPUT ((cofp, "%g %g M (%s:) s\n", x + space - len, y, buf));
@@
-2769,8
+2781,6
@@
print_line_number (double x, double y, double space, double margin,
* The name of the divert file, shared between divert() and undivert()
* functions.
*/
* The name of the divert file, shared between divert() and undivert()
* functions.
*/
-static char divertfname[512];
-
static void
divert ()
{
static void
divert ()
{