nmh-workers
[Top] [All Lists]

Portability patch for nmh 0.24's snprintf.c (for ULTRIX and...?)

1998-04-10 10:05:11

Well, to answer my previous question, yes, it does seem safe to replace the
call to mkstemp() in snprintf.c with a call to tmpfile():


33,34d32
< static char template[] = "/tmp/snprintfXXXXXX";
< 
38,41c36,38
<     char templ[sizeof(template)];
<     int s;
<     int ret, cnt = 0, nread;
<     FILE *fp;
---
    int    s;
    int    ret, cnt = 0, nread;
    FILE*  fp = tmpfile();
43,45c40
<     strcpy(templ,template);
< 
<     if ((s = mkstemp(templ)) < 0)
---
    if (fp == NULL)
47,53d41
< 
<     (void) unlink(templ);
< 
<     if ((fp = fdopen(s, "w+")) == NULL) {
<       close (s);
<       return -1;
<     }


It's ironic, because this snprintf.c is only used on OSes with no native
snprintf(), but they use a function which is likely not to be there on some
of those same OSes.  tmpfile(), on the other hand, is portable -- it comes
from <stdio.h>, so this patch should be incorporated into nmh 0.25 (whoever
ends up doing that), I think.

nmh 0.24 seems to work great on ULTRIX 4.2A with that change.  I had a
problem when trying to do a "make install", but I bet that was due to a bug
in the vendor make (GNU probably would've worked, but it wasn't installed).
To get it to go I had to touch <PREFIX>/etc/mts.conf before the make.

--
Dan Harkless
dharkless(_at_)unitech(_dot_)com
Unitech Research, Inc.


<Prev in Thread] Current Thread [Next in Thread>