X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fhtml.c;h=1b56ba1c2f77d2ee52af6a943e25b6846fad3124;hb=92fb12eb06716d14c05b781f5d9dcde956d77c30;hp=608de8a2d9c2f2ebc487a0cb4b39394d18f2792e;hpb=d807ad29cc0d3caa4f0e04ee4b75c70a225cfeaf;p=pspp diff --git a/src/html.c b/src/html.c index 608de8a2d9..1b56ba1c2f 100644 --- a/src/html.c +++ b/src/html.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ /* This #if encloses the rest of the file. */ #if !NO_HTML @@ -35,13 +35,18 @@ #include "alloc.h" #include "error.h" #include "filename.h" +#include "getl.h" #include "getline.h" +#include "getlogin_r.h" #include "output.h" #include "som.h" #include "tab.h" #include "version.h" #include "mkfile.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* Prototypes. */ static int postopen (struct file_ext *); static int preclose (struct file_ext *); @@ -234,9 +239,7 @@ postopen (struct file_ext *f) {"source-file", 0}, {0, 0}, }; -#if HAVE_UNISTD_H - char host[128]; -#endif + char login[128], host[128]; time_t curtime; struct tm *loctime; @@ -247,7 +250,7 @@ postopen (struct file_ext *f) FILE *prologue_file; char *buf = NULL; - int buf_size = 0; + size_t buf_size = 0; if (prologue_fn == NULL) { @@ -277,14 +280,13 @@ postopen (struct file_ext *f) *cp = 0; } - /* PORTME: Determine username, net address. */ -#if HAVE_UNISTD_H - dict[2].value = getenv ("LOGNAME"); - if (!dict[2].value) - dict[2].value = getlogin (); - if (!dict[2].value) - dict[2].value = _("nobody"); + if (getenv ("LOGNAME") != NULL) + str_copy_rpad (login, sizeof login, getenv ("LOGNAME")); + else if (getlogin_r (login, sizeof login)) + strcpy (login, _("nobody")); + dict[2].value = login; +#ifdef HAVE_UNISTD_H if (gethostname (host, 128) == -1) { if (errno == ENAMETOOLONG) @@ -292,11 +294,10 @@ postopen (struct file_ext *f) else strcpy (host, _("nowhere")); } +#else + strcpy (host, _("nowhere")); +#endif dict[3].value = host; -#else /* !HAVE_UNISTD_H */ - dict[2].value = _("nobody"); - dict[3].value = _("nowhere"); -#endif /* !HAVE_UNISTD_H */ dict[4].value = outp_title ? outp_title : ""; dict[5].value = outp_subtitle ? outp_subtitle : ""; @@ -582,13 +583,8 @@ output_tab_table (struct outp_driver *this, struct tab_table *t) fputs ("\n\n", x->file.file); } - -void html_initialise_chart(struct outp_class *c, struct chart *ch); -void html_finalise_chart(struct outp_class *c, struct chart *ch); - - -void -html_initialise_chart(struct outp_class *c UNUSED, struct chart *ch) +static void +html_initialise_chart(struct outp_driver *d UNUSED, struct chart *ch) { FILE *fp; @@ -604,8 +600,8 @@ html_initialise_chart(struct outp_class *c UNUSED, struct chart *ch) } -void -html_finalise_chart(struct outp_class *c UNUSED, struct chart *ch) +static void +html_finalise_chart(struct outp_driver *d UNUSED, struct chart *ch) { free(ch->filename); }