fixes bug#34874, minor source cleanup

svn path=/trunk/kdegraphics/kdvi/; revision=122327
remotes/origin/kdvi-3.0
Stefan Kebekus 25 years ago
parent ed362f001a
commit 4e72254092
  1. 4
      dviwin.cpp
  2. 7
      font.cpp
  3. 2
      kdvi_multipage.cpp
  4. 4
      pk.cpp
  5. 25
      util.cpp
  6. 10
      vf.cpp
  7. 29
      xdvi.h

@ -457,8 +457,8 @@ void dviWindow::exportPS(QString fname, QString options, KPrinter *printer)
qSysInfo (&wordSize, &bigEndian);
// Proper error handling? We don't care.
FILE *f = fopen(QFile::encodeName(sourceFileName),"r+");
for(Q_UINT32 i=0; i<=dviFile->total_pages; i++) {
fseek(f,dviFile->page_offset[i]+1, SEEK_SET);
for(Q_UINT32 i=1; i<=dviFile->total_pages; i++) {
fseek(f,dviFile->page_offset[i-1]+1, SEEK_SET);
// Write the page number to the file, taking good care of byte
// orderings. Hopefully QT will implement random access QFiles
// soon.

@ -15,7 +15,6 @@
#include "oconfig.h"
extern FILE *xdvi_xfopen(const char *filename, const char *type);
extern void oops(QString message);
@ -39,7 +38,7 @@ void font::fontNameReceiver(QString fname)
kdDebug() << "FONT NAME RECEIVED:" << filename << endl;
#endif
file = xdvi_xfopen(QFile::encodeName(filename), "r");
file = fopen(QFile::encodeName(filename), "r");
if (file == NULL) {
kdError() << i18n("Can't find font ") << fontname << "." << endl;
return;
@ -154,13 +153,13 @@ struct glyph *font::glyphptr(unsigned int ch) {
return NULL; /* previously flagged missing char */
if (file == NULL) {
file = xdvi_xfopen(QFile::encodeName(filename), "r");
file = fopen(QFile::encodeName(filename), "r");
if (file == NULL) {
oops(QString(i18n("Font file disappeared: %1")).arg(filename) );
return NULL;
}
}
Fseek(file, g->addr, 0);
fseek(file, g->addr, 0);
read_PK_char(ch);
if (g->bitmap.bits == NULL) {

@ -112,6 +112,8 @@ KDVIMultiPage::~KDVIMultiPage()
bool KDVIMultiPage::openFile()
{
kdDebug(4300) << url().prettyURL() << endl;
emit setStatusBarText(QString(i18n("Loading file %1")).arg(m_file));
bool r = window->setFile(m_file);

@ -463,7 +463,7 @@ void font::read_PK_index(void)
kdDebug() << "Reading PK pixel file " << filename << endl;
#endif
Fseek(file, (long) one(file), SEEK_CUR); /* skip comment */
fseek(file, (long) one(file), SEEK_CUR); /* skip comment */
(void) four(file); /* skip design size */
long file_checksum = four(file);
@ -506,7 +506,7 @@ void font::read_PK_index(void)
}
glyphtable[ch].addr = ftell(file);
glyphtable[ch].x2 = PK_flag_byte;
Fseek(file, (long) bytes_left, SEEK_CUR);
fseek(file, (long) bytes_left, SEEK_CUR);
#ifdef DEBUG_PK
kdDebug() << "Scanning pk char " << ch << "at " << glyphtable[ch].addr << endl;
#endif

@ -120,31 +120,6 @@ void alloc_bitmap(bitmap *bitmap)
bitmap->bits = xmalloc(size != 0 ? size : 1, "character bitmap");
}
/*
* Close the pixel file for the least recently used font.
*/
extern fontPool font_pool;
/*
* Open a file in the given mode.
*/
FILE *xdvi_xfopen(const char *filename, const char *type)
#define TYPE type
{
/* Try not to let the file table fill up completely. */
FILE *f = fopen(filename, "r");
/* If the open failed, try closing a file unconditionally.
Interactive Unix 2.2.1, at least, doesn't set errno to EMFILE
or ENFILE even when it should. In any case, it doesn't hurt
much to always try. */
if (f == NULL)
f = fopen(filename, TYPE);
return f;
}
#undef TYPE
/*
*
* Read size bytes from the FILE fp, constructing them into a

@ -78,7 +78,7 @@ void font::read_VF_index(void)
kdDebug() << "Reading VF pixel file " << filename << endl;
#endif
// Read preamble.
Fseek(VF_file, (long) one(VF_file), 1); /* skip comment */
fseek(VF_file, (long) one(VF_file), 1); /* skip comment */
long file_checksum = four(VF_file);
if (file_checksum && checksum && file_checksum != checksum)
@ -95,7 +95,7 @@ void font::read_VF_index(void)
int design = four(VF_file);
int len = one(VF_file) + one(VF_file); /* sequence point in the middle */
char *fontname = xmalloc((unsigned) len + 1, "font name");
Fread(fontname, sizeof(char), len, VF_file);
fread(fontname, sizeof(char), len, VF_file);
fontname[len] = '\0';
#ifdef DEBUG_FONTS
@ -144,7 +144,7 @@ void font::read_VF_index(void)
if (cc >= 256) {
kdError() << i18n("Virtual character ") << cc << i18n(" in font ")
<< fontname << i18n(" ignored.") << endl;
Fseek(VF_file, (long) len, 1);
fseek(VF_file, (long) len, 1);
continue;
}
} else { /* short form packet */
@ -167,13 +167,13 @@ void font::read_VF_index(void)
} else
m->pos = (unsigned char *)xmalloc(len*sizeof(unsigned char),"unknown");
}
Fread((char *) m->pos, 1, len, VF_file);
fread((char *) m->pos, 1, len, VF_file);
m->end = m->pos + len;
}
}
if (cmnd != POST)
oops(QString(i18n("Wrong command byte found in VF macro list: %1")).arg(cmnd));
Fclose (VF_file);
fclose (VF_file);
file = NULL;
}

@ -5,21 +5,6 @@
* Written by Eric C. Cooper, CMU
*/
/********************************
* The C environment *
*******************************/
/* For wchar_t et al., that the X files might want. */
extern "C" {
#include <sys/types.h>
}
#include <X11/Xlib.h> /* include Xfuncs.h, if available */
#include <X11/Xutil.h> /* needed for XDestroyImage */
#include <X11/Xos.h>
#include <X11/Intrinsic.h>
#undef wchar_t
typedef unsigned long Pixel;
typedef char Boolean;
@ -55,20 +40,6 @@ typedef char Boolean;
#define _XFUNCPROTOEND
#endif
#define Printf (void) printf
#define Puts (void) puts
#define Fprintf (void) fprintf
#define Sprintf (void) sprintf
#define Fseek (void) fseek
#define Fread (void) fread
#define Fputs (void) fputs
#define Putc (void) putc
#define Putchar (void) putchar
#define Fclose (void) fclose
#define Fflush (void) fflush
#define Strcpy (void) strcpy
/********************************
* Types and data *
*******************************/

Loading…
Cancel
Save