delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/27/09:07:52

From: brssp2!twuyts AT brgtw DOT att DOT com
Date: Thu, 27 Jan 94 13:27:27 +0100
Original-From: brssp2!twuyts (283510-Wuyts)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: fseek / share


Greetings,

I came across the following problem last week. Before trying to
investigate it further, I thought I'd try posting it here first. Maybe
the solution already exists.
I recently compiled groff 1.08 using djgpp 1.11maint1. Everything
worked fine till last week : grops always returned an error : 'fseek
failed on temporary file'. The only difference to the week before is
that Word 6.0 is now installed on my PC

It only gives this error when the DOS utility SHARE is installed. Word
6.0 for Windows does not work without SHARE. groff doesn't run with
SHARE. I need both ! Any hints or ideas ?

Thx,
Tim

PS 1: I have attached piece of the code. Maybe they'll help.
PS 2: Having two different DOS 6 Startups (with/without share) is NOT the solution !
 
          ______________________________________________________
_________| Tim Wuyts                                            |_________
\        | AT&T Network Systems Belgium        ____             |        /
 \       | +32 2 556 7405                    _(____)_           |       /
  \      | tim DOT wuyts AT att DOT com          ___ooO_(_o__o_)_Ooo_______|      /
   \     |---------------------------'                          |     /
   /     |"Being intelligent doesn't mean you aren't stupid."   |     \
  /      |                                                      |      \
 /       |______________________________________________________|       \
/____________)                                               (___________\


in file grops/ps.cc
   
  tmpfp = xtmpfile();
.
.
. (several lines of code ...)
.
.
  if (fseek(tempfp, 0L, 0) < 0)
    fatal("fseek on temporary file failed");

in file libgroff/tmpfile.cc

// Open a temporary file with fatal error on failure.

FILE *xtmpfile()
{
  const char *dir = getenv(GROFF_TMPDIR_ENVVAR);
  if (!dir) {
    dir = getenv(TMPDIR_ENVVAR);
    if (!dir)
      dir = DEFAULT_TMPDIR;
  }
  
  const char *p = strrchr(dir, '/');
  int needs_slash = (!p || p[1]);
  char *templ = new char[strlen(dir) + needs_slash
			    + sizeof(TMPFILE_PREFIX) - 1 + 6 + 1];
  strcpy(templ, dir);
  if (needs_slash)
    strcat(templ, "/");
  strcat(templ, TMPFILE_PREFIX);
  strcat(templ, "XXXXXX");

  errno = 0;
  int fd = mkstemp(templ);
  if (fd < 0)
    fatal("cannot create temporary file: %1", strerror(errno));
  errno = 0;
  FILE *fp = fdopen(fd, "w+");
  if (!fp)
    fatal("fdopen: %1", strerror(errno));
  if (unlink(templ) < 0)
    error("cannot unlink `%1': %2", templ, strerror(errno));
  a_delete templ;
  return fp;
}





- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019