File ghostview-1.5.dif of Package ghostview
--- Dir.c
+++ Dir.c 2004-04-28 17:14:49.000000000 +0200
@@ -25,6 +25,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#ifdef SEL_FILE_IGNORE_CASE
#include <ctype.h>
@@ -129,7 +130,7 @@ SFgetDir(dir)
(void) readdir(dirp); /* throw away ".." */
#endif /* ndef S_IFLNK */
- while (dp = readdir(dirp)) {
+ while ((dp = readdir(dirp))) {
if (i >= alloc) {
alloc = 2 * (alloc + 1);
result = (SFEntry *) XtRealloc((char *) result,
--- Draw.c
+++ Draw.c 2004-04-28 17:57:44.000000000 +0200
@@ -25,6 +25,7 @@
*/
#include <stdio.h>
+#include "Ghostview.h"
#include "SFinternal.h"
#include "xstat.h"
#include <X11/StringDefs.h>
@@ -59,6 +60,7 @@ static int SFcurrentListY;
static XtIntervalId SFscrollTimerId;
+void
SFinitFont()
{
TextData *data;
@@ -86,6 +88,7 @@ SFinitFont()
SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
}
+void
SFcreateGC()
{
XGCValues gcValues;
@@ -151,11 +154,13 @@ SFcreateGC()
);
}
-SFclearList(n, doScroll)
- int n;
+void
+SFclearList(p, doScroll)
+ XtPointer p;
int doScroll;
{
SFDir *dir;
+ unsigned long n = (unsigned long) p;
SFcurrentInvert[n] = -1;
@@ -193,7 +198,7 @@ SFclearList(n, doScroll)
}
}
-static
+static void
SFdeleteEntry(dir, entry)
SFDir *dir;
SFEntry *entry;
@@ -244,7 +249,7 @@ SFdeleteEntry(dir, entry)
);
}
-static
+static void
SFwriteStatChar(name, last, statBuf)
char *name;
int last;
@@ -320,7 +325,7 @@ SFstatAndCheck(dir, entry)
return 0;
}
-static
+static void
SFdrawStrings(w, dir, from, to)
register Window w;
register SFDir *dir;
@@ -397,14 +402,16 @@ SFdrawStrings(w, dir, from, to)
}
}
-SFdrawList(n, doScroll)
- int n;
+void
+SFdrawList(p, doScroll)
+ XtPointer p;
int doScroll;
{
SFDir *dir;
Window w;
+ unsigned long n = (unsigned long)p;
- SFclearList(n, doScroll);
+ SFclearList(p, doScroll);
if (SFdirPtr + n < SFdirEnd) {
dir = &(SFdirs[SFdirPtr + n]);
@@ -422,17 +429,18 @@ SFdrawList(n, doScroll)
}
}
+void
SFdrawLists(doScroll)
int doScroll;
{
int i;
for (i = 0; i < 3; i++) {
- SFdrawList(i, doScroll);
+ SFdrawList((XtPointer)i, doScroll);
}
}
-static
+static void
SFinvertEntry(n)
register int n;
{
@@ -484,9 +492,7 @@ SFscrollTimer(p, id)
{
SFDir *dir;
int save;
- int n;
-
- n = (int) p;
+ unsigned long n = (unsigned long)p;
dir = &(SFdirs[SFdirPtr + n]);
save = dir->vOrigin;
@@ -778,7 +784,7 @@ SFhSliderMovedCallback(w, n, new)
return;
}
- SFdrawList(n, SF_DO_NOT_SCROLL);
+ SFdrawList((XtPointer)n, SF_DO_NOT_SCROLL);
}
/* ARGSUSED */
--- Ghostview.c
+++ Ghostview.c 2004-04-28 17:07:54.000000000 +0200
@@ -934,8 +934,12 @@ Dimension width, height;
XtMakeGeometryRequest(w, &request, &reply);
changed = True;
break;
+ default:
+ break;
}
break;
+ default:
+ break;
}
/* If success, setup the widet for the new size. */
@@ -1043,8 +1047,8 @@ Setup(w)
gvw->ghostview.gs_width = gvw->core.width;
gvw->ghostview.gs_height = gvw->core.height;
- sprintf(buf, "%d %d %d %d %d %d %g %g %d %d %d %d",
- bpixmap, gvw->ghostview.orientation,
+ sprintf(buf, "%lu %d %d %d %d %d %g %g %d %d %d %d",
+ (unsigned long)bpixmap, gvw->ghostview.orientation,
gvw->ghostview.llx, gvw->ghostview.lly,
gvw->ghostview.urx, gvw->ghostview.ury,
gvw->ghostview.xdpi, gvw->ghostview.ydpi,
@@ -1055,11 +1059,12 @@ Setup(w)
XA_STRING, 8, PropModeReplace,
(unsigned char *)buf, strlen(buf));
- sprintf(buf, "%s %d %d",
+ sprintf(buf, "%s %lu %lu",
gvw->ghostview.palette == XtPaletteMonochrome ? "Monochrome" :
gvw->ghostview.palette == XtPaletteGrayscale ? "Grayscale" :
gvw->ghostview.palette == XtPaletteColor ? "Color" : "?",
- gvw->ghostview.foreground, gvw->core.background_pixel);
+ (unsigned long)gvw->ghostview.foreground,
+ (unsigned long)gvw->core.background_pixel);
XChangeProperty(XtDisplay(w), XtWindow(w),
XmuInternAtom(XtDisplay(w), gvc->ghostview_class.gv_colors),
XA_STRING, 8, PropModeReplace,
@@ -1168,7 +1173,7 @@ StartInterpreter(w)
close(std_out[1]);
dup2(std_err[1], 2);
close(std_err[1]);
- sprintf(buf, "%d", XtWindow(w));
+ sprintf(buf, "%ld", (unsigned long)XtWindow(w));
setenv("GHOSTVIEW", buf, True);
setenv("DISPLAY", XDisplayString(XtDisplay(w)), True);
if (gvw->ghostview.filename == NULL) {
--- Ghostview.h
+++ Ghostview.h 2004-04-28 17:39:57.000000000 +0200
@@ -27,6 +27,17 @@
#define _Ghostview_h
/* Be sure that FILE* is defined */
#include <stdio.h>
+/* Be sure that standard libc functions are defined */
+#include <stdlib.h>
+/* Be sure that string libc functions are defined */
+#include <string.h>
+/* Be sure that wait(2) syscall is defined */
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/* Be sure that Boolean typedef is done */
+#include </usr/include/X11/Xlib.h>
+#include </usr/include/X11/Intrinsic.h>
/****************************************************************
*
@@ -207,4 +218,14 @@ typedef struct _GhostviewReturnStruct {
float xdpi, ydpi;
} GhostviewReturnStruct;
+extern int find_page(String);
+extern void SFdrawList(XtPointer, int);
+extern void SFinitFont();
+extern void SFcreateGC();
+extern int SFchdir(char*);
+extern void SFupdatePath();
+extern void SFsetText(char*);
+extern void SFtextChanged();
+extern void SFdrawLists(int);
+extern void SFclearList(XtPointer, int);
#endif /* _Ghostview_h */
--- Imakefile
+++ Imakefile 2004-04-28 16:37:35.000000000 +0200
@@ -1,7 +1,3 @@
-#ifndef XCOMM
-#define XCOMM #
-#endif
-
XCOMM Imakefile -- Imakefile for ghostview.
XCOMM Copyright (C) 1992 Timothy O. Theisen
XCOMM
--- Path.c
+++ Path.c 2004-04-28 17:49:39.000000000 +0200
@@ -25,6 +25,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#ifdef SEL_FILE_IGNORE_CASE
#include <ctype.h>
@@ -32,6 +33,7 @@
#include <X11/Xos.h>
#include <pwd.h>
+#include "Ghostview.h"
#include "SFinternal.h"
#include "xstat.h"
#include <X11/Xaw/Scrollbar.h>
@@ -48,9 +50,9 @@ typedef struct {
SFDir *SFdirs = NULL;
-int SFdirEnd;
+unsigned long SFdirEnd;
-int SFdirPtr;
+unsigned long SFdirPtr;
int SFbuttonPressed = 0;
@@ -82,7 +84,7 @@ SFchdir(path)
return result;
}
-static
+static void
SFfree(i)
int i;
{
@@ -105,7 +107,7 @@ SFfree(i)
dir->dir = NULL;
}
-static
+static void
SFstrdup(s1, s2)
char **s1;
char *s2;
@@ -113,7 +115,7 @@ SFstrdup(s1, s2)
*s1 = strcpy(XtMalloc((unsigned) (strlen(s2) + 1)), s2);
}
-static
+static void
SFunreadableDir(dir)
SFDir *dir;
{
@@ -172,7 +174,7 @@ SFstrncmp(p, q, n)
}
#endif /* def SEL_FILE_IGNORE_CASE */
-static
+static void
SFreplaceText(dir, str)
SFDir *dir;
char *str;
@@ -228,7 +230,7 @@ SFexpand(str)
while (!cmp) {
entry = &(dir->entries[dir->beginSelection]);
while (entry < max) {
- if (cmp = strncmp(growing, entry->shown, len)) {
+ if ((cmp = strncmp(growing, entry->shown, len))) {
break;
}
entry++;
@@ -356,7 +358,7 @@ SFfindFile(dir, str)
return 0;
}
-static
+static void
SFunselect()
{
SFDir *dir;
@@ -376,7 +378,7 @@ SFcompareLogins(p, q)
return strcmp(p->name, q->name);
}
-static
+static void
SFgetHomeDirs()
{
struct passwd *pw;
@@ -483,6 +485,7 @@ SFfindHomeDir(begin, end)
return 0;
}
+void
SFupdatePath()
{
static int alloc;
@@ -663,15 +666,16 @@ SFupdatePath()
if (SFdirPtr + i < SFdirEnd) {
if (SFdirs[SFdirPtr + i].changed) {
SFdirs[SFdirPtr + i].changed = 0;
- SFdrawList(i, SF_DO_SCROLL);
+ SFdrawList((XtPointer)i, SF_DO_SCROLL);
}
} else {
- SFclearList(i, SF_DO_SCROLL);
+ SFclearList((XtPointer)i, SF_DO_SCROLL);
}
}
}
}
+void
SFsetText(path)
char *path;
{
@@ -871,7 +875,7 @@ SFdirModTimer(cl, id)
SFcheckDir(n, dir) ||
((f == n) && SFcheckFiles(dir))
) {
- SFdrawList(n, SF_DO_SCROLL);
+ SFdrawList((XtPointer)n, SF_DO_SCROLL);
}
}
}
--- SFinternal.h
+++ SFinternal.h 2004-04-28 17:51:42.000000000 +0200
@@ -80,7 +80,7 @@ extern int SFcharWidth, SFcharHeight, SF
extern SFDir *SFdirs;
-extern int SFdirEnd, SFdirPtr;
+extern unsigned long SFdirEnd, SFdirPtr;
extern Pixel SFfore, SFback;
@@ -142,4 +142,8 @@ extern char SFstatChar();
extern XtIntervalId SFdirModTimerId;
+extern int SFgetDir(SFDir*);
+
+extern int SFchDir(char*);
+
extern int (*SFfunc)();
--- SelFile.c
+++ SelFile.c 2004-04-28 17:54:23.000000000 +0200
@@ -45,8 +45,9 @@
#include <errno.h>
/* BSD 4.3 errno.h does not declare errno */
extern int errno;
-extern int sys_nerr;
-extern char *sys_errlist[];
+#if !(defined __GLIBC__ && __GLIBC__ >=2)
+extern char *strerror(int);
+#endif
#include <sys/param.h>
#include <X11/cursorfont.h>
@@ -60,13 +61,14 @@ extern char *sys_errlist[];
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Cardinals.h>
+#include "Ghostview.h"
#include "SFinternal.h"
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif /* ndef MAXPATHLEN */
-#if !defined(SVR4) && !defined(SYSV) && !defined(USG)
+#if !defined(SVR4) && !defined(SYSV) && !defined(USG) && !defined(__GLIBC__)
extern char *getwd();
#endif /* !defined(SVR4) && !defined(SYSV) && !defined(USG) */
@@ -567,11 +569,12 @@ SFopenFile(name, mode, prompt, failed)
SFchdir(SFstartDir);
if ((fp = fopen(name, mode)) == NULL) {
char *buf;
- if (errno <= sys_nerr) {
- buf = XtMalloc(strlen(failed) + strlen(sys_errlist[errno]) +
+ if (errno) {
+ char * err = strerror(errno);
+ buf = XtMalloc(strlen(failed) + strlen(err) +
strlen(prompt) + 2);
strcpy(buf, failed);
- strcat(buf, sys_errlist[errno]);
+ strcat(buf, err);
strcat(buf, "\n");
strcat(buf, prompt);
} else {
@@ -588,6 +591,7 @@ SFopenFile(name, mode, prompt, failed)
return fp;
}
+void
SFtextChanged()
{
@@ -617,7 +621,7 @@ SFgetText()
SFtextBuffer);
}
-static
+static void
SFprepareToReturn()
{
SFstatus = SEL_FILE_NULL;
@@ -685,7 +689,7 @@ XsraSelFile(toplevel, prompt, ok, cancel
SFpositionWidget(selFile);
XtMapWidget(selFile);
-#if defined(SVR4) || defined(SYSV) || defined(USG)
+#if defined(SVR4) || defined(SYSV) || defined(USG) || defined(__GLIBC__)
if (!getcwd(SFstartDir, MAXPATHLEN)) {
#else /* defined(SVR4) || defined(SYSV) || defined(USG) */
if (!getwd(SFstartDir)) {
@@ -736,8 +740,8 @@ XsraSelFile(toplevel, prompt, ok, cancel
break;
case SEL_FILE_OK:
*name_return = SFgetText();
- if (fp = SFopenFile(*name_return, mode,
- prompt, failed)) {
+ if ((fp = SFopenFile(*name_return, mode,
+ prompt, failed))) {
SFprepareToReturn();
return fp;
}
--- callbacks.c
+++ callbacks.c 2006-11-09 16:46:13.000000000 +0100
@@ -160,6 +160,7 @@ reopen_file(w, client_data, call_data)
fclose(psfile);
psfile = fopen(filename, "r");
+ stat(filename, &sbuf);
mtime = sbuf.st_mtime;
if (oldfilename) XtFree(oldfilename);
oldfilename = XtNewString(filename);
@@ -636,7 +637,7 @@ okay(w, client_data, call_data)
switch (mode) {
case PRINT_WHOLE:
case PRINT_MARKED:
- if (error = print_file(name, (mode == PRINT_WHOLE))) {
+ if ((error = print_file(name, (mode == PRINT_WHOLE)))) {
char *buf = XtMalloc(strlen(error) +
strlen(app_res.print_prompt) + 2);
sprintf(buf, "%s\n%s", error, app_res.print_prompt);
@@ -648,7 +649,7 @@ okay(w, client_data, call_data)
}
break;
case OPEN:
- if (error = open_file(name)) {
+ if ((error = open_file(name))) {
char *buf = XtMalloc(strlen(error) +
strlen(app_res.open_prompt) + 2);
sprintf(buf, "%s\n%s", error, app_res.open_prompt);
@@ -660,7 +661,7 @@ okay(w, client_data, call_data)
}
break;
case SAVE:
- if (error = save_file(name)) {
+ if ((error = save_file(name))) {
char *buf = XtMalloc(strlen(error) +
strlen(app_res.save_prompt) + 2);
sprintf(buf, "%s\n%s", error, app_res.save_prompt);
--- getenv.c
+++ getenv.c 2004-04-28 17:18:20.000000000 +0200
@@ -22,7 +22,10 @@ static char sccsid[] = "@(#)getenv.c 5.7
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef __GLIBC__
/*
* getenv --
* Returns ptr to value associated with name, if any, else NULL.
@@ -64,3 +67,4 @@ _findenv(name, offset)
}
return(NULL);
}
+#endif /* !__GLIBC__ */
--- main.c
+++ main.c 2004-04-28 16:54:06.000000000 +0200
@@ -411,7 +411,7 @@ char *argv[];
XtGetApplicationResources(toplevel, (XtPointer) &app_res,
resources, XtNumber(resources), NULL, ZERO);
- if (s1 = getenv(app_res.printer_variable)) app_res.default_printer = s1;
+ if ((s1 = getenv(app_res.printer_variable))) app_res.default_printer = s1;
/* Open Windows sometimes hands me a bad bitmap */
if (app_res.openwindows) {
--- misc.c
+++ misc.c 2004-04-28 17:54:00.000000000 +0200
@@ -60,8 +60,9 @@ extern int errno;
#ifdef VMS
#include <perror.h>
#else
-extern int sys_nerr;
-extern char *sys_errlist[];
+#if !(defined __GLIBC__ && __GLIBC__ >=2)
+extern char *strerror(int);
+#endif
#endif
#include "Ghostview.h"
@@ -80,6 +81,7 @@ xorient(psorient)
int psorient;
{
switch (psorient) {
+ default:
case PORTRAIT: return XtPageOrientationPortrait;
case LANDSCAPE:
if (app_res.swap_landscape) {
@@ -88,6 +90,7 @@ xorient(psorient)
return XtPageOrientationLandscape;
}
}
+ return XtPageOrientationPortrait;
}
static void
@@ -370,16 +373,16 @@ setup_ghostview()
}
/* Build table of contents */
- if (doc && (!doc->epsf && doc->numpages > 0 ||
- doc->epsf && doc->numpages > 1)) {
+ if (doc && ((!doc->epsf && doc->numpages > 0) ||
+ ( doc->epsf && doc->numpages > 1))) {
int maxlen = 0;
int i, j;
useful_page_labels = False;
if (doc->numpages == 1) useful_page_labels = True;
for (i = 1; i < doc->numpages; i++)
- if (useful_page_labels = (useful_page_labels ||
- strcmp(doc->pages[i-1].label, doc->pages[i].label))) break;
+ if ((useful_page_labels = (useful_page_labels ||
+ strcmp(doc->pages[i-1].label, doc->pages[i].label)))) break;
if (useful_page_labels) {
for (i = 0; i < doc->numpages; i++)
maxlen = max(maxlen, strlen(doc->pages[i].label));
@@ -709,10 +712,11 @@ open_file(name)
}
if (strcmp(name, "-")) {
if ((fp = fopen(name, "r")) == NULL) {
+ char *err = strerror(errno);
String buf = XtMalloc(strlen(app_res.open_fail) +
- strlen(sys_errlist[errno]) + 1);
+ strlen(err) + 1);
strcpy(buf, app_res.open_fail);
- if (errno <= sys_nerr) strcat(buf, sys_errlist[errno]);
+ strcat(buf, err);
return buf;
} else {
if (oldfilename) XtFree(oldfilename);
@@ -749,10 +753,11 @@ save_file(name)
return(NULL);
}
if ((pswrite = fopen(name, "w")) == NULL) {
+ char *err = strerror(errno);
String buf = XtMalloc(strlen(app_res.save_fail) +
- strlen(sys_errlist[errno]) + 1);
+ strlen(err) + 1);
strcpy(buf, app_res.save_fail);
- if (errno <= sys_nerr) strcat(buf, sys_errlist[errno]);
+ strcat(buf, err);
return buf;
} else {
pscopydoc(pswrite);
@@ -791,7 +796,7 @@ print_file(name, whole_mode)
pscopydoc(printer);
} else {
FILE *psfile = fopen(filename, "r");
- while (bytes = read(fileno(psfile), buf, BUFSIZ))
+ while ((bytes = read(fileno(psfile), buf, BUFSIZ)))
bytes = write(fileno(printer), buf, bytes);
fclose(psfile);
}
@@ -848,8 +853,8 @@ pscopydoc(fp)
}
here = doc->beginheader;
- while (comment = pscopyuntil(psfile, fp, here,
- doc->endheader, "%%Pages:")) {
+ while ((comment = pscopyuntil(psfile, fp, here,
+ doc->endheader, "%%Pages:"))) {
here = ftell(psfile);
if (pages_written || pages_atend) {
free(comment);
@@ -893,8 +898,8 @@ pscopydoc(fp)
}
here = doc->begintrailer;
- while (comment = pscopyuntil(psfile, fp, here,
- doc->endtrailer, "%%Pages:")) {
+ while ((comment = pscopyuntil(psfile, fp, here,
+ doc->endtrailer, "%%Pages:"))) {
here = ftell(psfile);
if (pages_written) {
free(comment);
--- ps.c
+++ ps.c 2004-04-28 17:17:24.000000000 +0200
@@ -24,6 +24,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
@@ -425,7 +426,7 @@ psscan(file)
else
free(doc->media[0].name);
}
- while (cp = gettext(next_char, &next_char)) {
+ while ((cp = gettext(next_char, &next_char))) {
doc->media = (struct documentmedia *)
realloc(doc->media,
(doc->nummedia+1)*
@@ -469,7 +470,7 @@ psscan(file)
DSCcomment(line) && iscomment(line+2, "+")) {
section_len += line_len;
next_char = line + length("%%+");
- while (cp = gettext(next_char, &next_char)) {
+ while ((cp = gettext(next_char, &next_char))) {
doc->media = (struct documentmedia *)
realloc(doc->media,
(doc->nummedia+1)*
@@ -842,9 +843,9 @@ continuepage:
&(doc->pages[doc->numpages].boundingbox[LLX]),
&(doc->pages[doc->numpages].boundingbox[LLY]),
&(doc->pages[doc->numpages].boundingbox[URX]),
- &(doc->pages[doc->numpages].boundingbox[URY])) == 4)
- if (page_bb_set == NONE) page_bb_set = 1;
- else {
+ &(doc->pages[doc->numpages].boundingbox[URY])) == 4) {
+ if ((page_bb_set == NONE)) page_bb_set = 1;
+ } else {
float fllx, flly, furx, fury;
if (sscanf(line+length("%%PageBoundingBox:"),
"%f %f %f %f",
--- setenv.c
+++ setenv.c 2004-04-28 17:18:25.000000000 +0200
@@ -22,7 +22,11 @@ static char sccsid[] = "@(#)setenv.c 5.4
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
+
+#ifndef __GLIBC__
+
extern char *malloc();
#ifdef BSD4_2
@@ -105,3 +109,4 @@ unsetenv(name)
if (!(*P = *(P + 1)))
break;
}
+#endif /* !__GLIBC__ */