summaryrefslogtreecommitdiffstats
path: root/contrib/groff/src/libs/libgroff
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/groff/src/libs/libgroff')
-rw-r--r--contrib/groff/src/libs/libgroff/Makefile.sub4
-rw-r--r--contrib/groff/src/libs/libgroff/font.cc5
-rw-r--r--contrib/groff/src/libs/libgroff/getopt.c17
-rw-r--r--contrib/groff/src/libs/libgroff/maxfilename.cc67
-rw-r--r--contrib/groff/src/libs/libgroff/tmpfile.cc65
5 files changed, 108 insertions, 50 deletions
diff --git a/contrib/groff/src/libs/libgroff/Makefile.sub b/contrib/groff/src/libs/libgroff/Makefile.sub
index 5ce0691..ff5c655 100644
--- a/contrib/groff/src/libs/libgroff/Makefile.sub
+++ b/contrib/groff/src/libs/libgroff/Makefile.sub
@@ -18,6 +18,7 @@ OBJS=\
lf.o \
lineno.o \
macropath.o \
+ maxfilename.o \
nametoindex.o \
new.o \
prime.o \
@@ -49,6 +50,7 @@ CCSRCS=\
$(srcdir)/lf.cc \
$(srcdir)/lineno.cc \
$(srcdir)/macropath.cc \
+ $(srcdir)/maxfilename.cc \
$(srcdir)/nametoindex.cc \
$(srcdir)/new.cc \
$(srcdir)/prime.cc \
@@ -80,5 +82,5 @@ version.cc: $(top_srcdir)/VERSION $(top_srcdir)/REVISION
@echo Making version.cc
@echo const char \*version_string = \"$(version)\"\; >$@
@echo const char \*revision_string = \"$(revision)\"\; >>$@
- @echo const char \*Version_string = \"$(version).$(revision)\"\; | \
+ @echo extern \"C\" const char \*Version_string = \"$(version).$(revision)\"\; | \
sed -e 's/\.0\"/\"/' >>$@
diff --git a/contrib/groff/src/libs/libgroff/font.cc b/contrib/groff/src/libs/libgroff/font.cc
index 6cdd647..aa602b4 100644
--- a/contrib/groff/src/libs/libgroff/font.cc
+++ b/contrib/groff/src/libs/libgroff/font.cc
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -751,7 +752,7 @@ int font::load_desc()
while (t.next()) {
char *p = strtok(t.buf, WS);
int found = 0;
- int idx;
+ unsigned int idx;
for (idx = 0; !found && idx < sizeof(table)/sizeof(table[0]); idx++)
if (strcmp(table[idx].command, p) == 0)
found = 1;
diff --git a/contrib/groff/src/libs/libgroff/getopt.c b/contrib/groff/src/libs/libgroff/getopt.c
index 4744e43..0ecad38 100644
--- a/contrib/groff/src/libs/libgroff/getopt.c
+++ b/contrib/groff/src/libs/libgroff/getopt.c
@@ -77,11 +77,12 @@
#endif
#ifndef _
-/* This is for other GNU distributions with internationalized messages.
- When compiling libc, the _ macro is predefined. */
-# ifdef HAVE_LIBINTL_H
+/* This is for other GNU distributions with internationalized messages. */
+# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
-# define _(msgid) gettext (msgid)
+# ifndef _
+# define _(msgid) gettext (msgid)
+# endif
# else
# define _(msgid) (msgid)
# endif
@@ -521,6 +522,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (optstring[0] == ':')
print_errors = 0;
+ if (argc < 1)
+ return -1;
+
optarg = NULL;
if (optind == 0 || !__getopt_initialized)
@@ -670,7 +674,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
pfound = p;
indfound = option_index;
}
- else
+ else if (long_only
+ || pfound->has_arg != p->has_arg
+ || pfound->flag != p->flag
+ || pfound->val != p->val)
/* Second or later nonexact match found. */
ambig = 1;
}
diff --git a/contrib/groff/src/libs/libgroff/maxfilename.cc b/contrib/groff/src/libs/libgroff/maxfilename.cc
new file mode 100644
index 0000000..c5a03d7
--- /dev/null
+++ b/contrib/groff/src/libs/libgroff/maxfilename.cc
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+/* Copyright (C) 1992, 2001 Free Software Foundation, Inc.
+ Written by James Clark (jjc@jclark.com)
+
+This file is part of groff.
+
+groff is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+groff is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with groff; see the file COPYING. If not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* file_name_max(dir) does the same as pathconf(dir, _PC_NAME_MAX) */
+
+#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef _POSIX_VERSION
+
+size_t file_name_max(const char *fname)
+{
+ return pathconf(fname, _PC_NAME_MAX);
+}
+
+#else /* not _POSIX_VERSION */
+
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif /* HAVE_LIMITS_H */
+
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#else /* not HAVE_DIRENT_H */
+#ifdef HAVE_SYS_DIR_H
+#include <sys/dir.h>
+#endif /* HAVE_SYS_DIR_H */
+#endif /* not HAVE_DIRENT_H */
+
+#ifndef NAME_MAX
+#ifdef MAXNAMLEN
+#define NAME_MAX MAXNAMLEN
+#else /* !MAXNAMLEN */
+#ifdef MAXNAMELEN
+#define NAME_MAX MAXNAMELEN
+#else /* !MAXNAMELEN */
+#define NAME_MAX 14
+#endif /* !MAXNAMELEN */
+#endif /* !MAXNAMLEN */
+#endif /* !NAME_MAX */
+
+size_t file_name_max(const char *)
+{
+ return NAME_MAX;
+}
+
+#endif /* not _POSIX_VERSION */
diff --git a/contrib/groff/src/libs/libgroff/tmpfile.cc b/contrib/groff/src/libs/libgroff/tmpfile.cc
index a6c2010..8508c59 100644
--- a/contrib/groff/src/libs/libgroff/tmpfile.cc
+++ b/contrib/groff/src/libs/libgroff/tmpfile.cc
@@ -1,5 +1,6 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001
+ Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -29,12 +30,11 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "error.h"
#include "nonposix.h"
+#ifndef HAVE_MKSTEMP_PROTO
extern "C" {
- // Solaris 2.5.1 has these functions,
- // but its stdlib.h fails to declare them.
- char *mktemp(char *);
- int mkstemp(char *);
+ extern int mkstemp (char *);
}
+#endif
// If this is set, create temporary files there
#define GROFF_TMPDIR_ENVVAR "GROFF_TMPDIR"
@@ -48,7 +48,11 @@ extern "C" {
# define DEFAULT_TMPDIR "/tmp"
#endif
// Use this as the prefix for temporary filenames.
-#define TMPFILE_PREFIX "groff"
+#ifdef __MSDOS__
+#define TMPFILE_PREFIX ""
+#else
+#define TMPFILE_PREFIX "groff"
+#endif
/*
* Generate a temporary name template with a postfix
@@ -104,14 +108,13 @@ static void remove_tmp_files()
{
struct xtmpfile_list *p = xtmpfiles_to_delete;
- while (p)
- {
- if (unlink(p->fname) < 0)
- error("cannot unlink `%1': %2", p->fname, strerror(errno));
- struct xtmpfile_list *old = p;
- p = p->next;
- free(old);
- }
+ while (p) {
+ if (unlink(p->fname) < 0)
+ error("cannot unlink `%1': %2", p->fname, strerror(errno));
+ struct xtmpfile_list *old = p;
+ p = p->next;
+ free(old);
+ }
}
static void add_tmp_file(const char *name)
@@ -122,11 +125,10 @@ static void add_tmp_file(const char *name)
struct xtmpfile_list *p
= (struct xtmpfile_list *)malloc(sizeof(struct xtmpfile_list)
+ strlen (name));
- if (p == NULL)
- {
- error("cannot unlink `%1': %2", name, strerror(errno));
- return;
- }
+ if (p == NULL) {
+ error("cannot unlink `%1': %2", name, strerror(errno));
+ return;
+ }
p->next = xtmpfiles_to_delete;
strcpy(p->fname, name);
xtmpfiles_to_delete = p;
@@ -134,8 +136,6 @@ static void add_tmp_file(const char *name)
// Open a temporary file and with fatal error on failure.
-#ifndef _MSC_VER
-
FILE *xtmpfile(char **namep, char *postfix, int do_unlink)
{
char *templ = xtmptemplate(postfix);
@@ -159,28 +159,9 @@ FILE *xtmpfile(char **namep, char *postfix, int do_unlink)
#endif /* not HAVE_MKSTEMP */
if (do_unlink)
add_tmp_file(templ);
- if ((namep != 0) && ((*namep) != 0)) {
+ if ((namep != 0) && ((*namep) != 0))
*namep = templ;
- } else {
+ else
a_delete templ;
- }
return fp;
}
-
-#else
-
-// FIXME: does MSVC have mktemp or mkstemp? If so, it should now
-// use the version above, as it no longer removes an open file.
-// The version below will NOT work with grohtml, since grohtml
-// wants to know the name of the file opened by xtmpfile!!
-
-// If you're not running Unix, the following will do:
-FILE *xtmpfile(char **namep, char *postfix, int do_unlink)
-{
- FILE *fp = tmpfile();
- if (!fp)
- fatal("couldn't create temporary file");
- return fp;
-}
-
-#endif /* _MSC_VER */
OpenPOWER on IntegriCloud